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:06:20
Message-ID: 4915F13C.7060800@cheapcomplexdevices.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> BTW, I just noticed that CVS HEAD has a bug in reading negative SQL-spec
> literals:
> regression=# select interval '-2008-10';
> regression=# select interval '-0000-10';
> Surely the latter must mean -10 months. This is orthogonal to the
> current patch ...

Perhaps the below patch fixes that?
(though line numbers probably won't match since this was based off
of the patched version)

*** a/src/backend/utils/adt/datetime.c
--- b/src/backend/utils/adt/datetime.c
***************
*** 2879,2885 **** DecodeInterval(char **field, int *ftype, int nf, int range,
if (*cp != '\0')
return DTERR_BAD_FORMAT;
type = DTK_MONTH;
! if (val < 0)
val2 = -val2;
val = val * MONTHS_PER_YEAR + val2;
fval = 0;
--- 2879,2885 ----
if (*cp != '\0')
return DTERR_BAD_FORMAT;
type = DTK_MONTH;
! if (field[0][0] == '-')
val2 = -val2;
val = val * MONTHS_PER_YEAR + val2;
fval = 0;
[5]lt:/home/ramayer/proj/pg/postgresql/src/backend/utils/adt%

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-11-08 20:07:30 Re: Patch for SQL-Standard Interval output and decoupling DateStyle from IntervalStyle
Previous Message Paul Schlie 2008-11-08 20:02:50 Re: Block-level CRC checks