Re: Patch for SQL-standard negative valued year-month literals

From: Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Stephen R(dot) van den Berg" <srb(at)cuci(dot)nl>, Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Patch for SQL-standard negative valued year-month literals
Date: 2008-09-17 14:19:18
Message-ID: 48D111E6.4090208@cheapcomplexdevices.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> "Stephen R. van den Berg" <srb(at)cuci(dot)nl> writes:
>> Intervals are a scalar, not an addition of assorted values, alternating signs
>> between fields would be wrong.
>
> Sorry, you're the one who's wrong on that. We've treated intervals as
> three independent fields for years now (and before that it was two
> independent fields). We're not going to throw away that capability.

+1 It's very useful.

Currently our terse input format that's similar to the SQL standard
rejects more mixed-sign intervals than I'd like. I'd be quite
happy if:
'1 2:03:-04'
gave me
'1 day 2 hours 3 minutes -4 seconds'
but currently we reject that mixed-sign-literal.

I'd just like to find a way to have SQL-standard input produce SQL-standard
output in the cases where the input happened to match the standard.

If we had a blank slate, my vote would be that
'-1 2:03:04' should mean what the SQL standard says it should.
'-1 +2:03:04' should mean negative 1 days, plus 2 hours 3 minutes 4 sec
'1 2:03:-04' should mean 1 day 2 hours 3 minutes minus 4 seconds
'-1 2:03:+04' should mean negative 1 day 2 hours 3 minutes plus 4 seconds
but I'm aware that there are backward compatibility issues.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2008-09-17 14:22:28 Re: Autovacuum and Autoanalyze
Previous Message Kevin Grittner 2008-09-17 14:13:33 Re: Common Table Expressions (WITH RECURSIVE) patch