Re: Patch for SQL-Standard Interval output and decoupling DateStyle from IntervalStyle

From: Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>, Brendan Jurd <direvus(at)gmail(dot)com>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Patch for SQL-Standard Interval output and decoupling DateStyle from IntervalStyle
Date: 2008-11-08 20:30:30
Message-ID: 4915F6E6.3090600@cheapcomplexdevices.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Another thought here ... I'm looking at the sign hack
> + if (IntervalStyle == INTSTYLE_SQL_STANDARD &&
>....
> and not liking it very much. Yes, it does the intended thing for strict
> SQL-spec input, but it seems to produce a bunch of weird corner cases
> for non-spec input. Consider [... many examples ...]
>
> I'm inclined to think we need a more semantically-based instead of
> syntactically-based rule. For instance, if first field is negative and
> no other field has an explicit sign, then force all fields to be <= 0.
> This would probably have to be applied at the end of DecodeInterval
> instead of on-the-fly within the loop.
>
> Thoughts?

I'll take a step back and think about that....

Yes, at first glance I think that approach is better; but we'd need
to make sure not to apply the rule too enthusiastically on traditional
postgres intervals; or worse, ones that mix sql standardish and postgres
values For example
dish=# select interval '-1 1:1 1 years';
interval
--------------------------
1 year -1 days +01:01:00
(1 row)
that 8.3 accepts. (or do we not care about those)?

In some ways I wonder if we should have 2 totally separate parsing
one for the SQL standard ones, and one for the postgres.
That would avoid some other confusing inputs like:
select interval '-00-01 1 years';
select interval '1-1 hours';
select interval '1:1 years';
select interval '1 hours 1-1 1 years'
that are currently accepted.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-11-08 20:30:53 Re: Patch for SQL-Standard Interval output and decoupling DateStyle from IntervalStyle
Previous Message Jonah H. Harris 2008-11-08 20:25:14 [PATCH] Recreate Missing WAL Directories (from TODO)