Re: INTERVAL SECOND limited to 59 seconds?

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>, Sebastien FLAESCH <sf(at)4js(dot)com>, pgsql-general(at)postgresql(dot)org, mmoncure(at)gmail(dot)com
Subject: Re: INTERVAL SECOND limited to 59 seconds?
Date: 2009-06-10 02:49:31
Message-ID: 4A2F1F3B.1080308@cheapcomplexdevices.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Tom Lane wrote:
> I wrote:
>> I'm inclined to say that these two cases are out of line with what
>> the rest of the code does and we should change them.
> ...
> Now, all three of these cases throw "invalid input syntax" in 8.3,
> so this is not a regression from released behavior. The question
> is does anyone think that these syntaxes should be valid? They're
> not legal per spec, for sure, and they seem pretty ambiguous to me.

Seems to do a sane thing for all sane inputs I threw at it.

It still accepts one odd input that 8.3 rejected:
regression=# select interval '1 1' hour;
Perhaps the additional patch below fixes that?

***************
*** 3022,3028 **** DecodeInterval(char **field, int *ftype, int nf, int range,
tm->tm_hour += val;
AdjustFractSeconds(fval, tm, fsec, SECS_PER_HOUR);
tmask = DTK_M(HOUR);
! type = DTK_DAY; /* set for next field */
break;

case DTK_DAY:
--- 3022,3029 ----
tm->tm_hour += val;
AdjustFractSeconds(fval, tm, fsec, SECS_PER_HOUR);
tmask = DTK_M(HOUR);
! if (range == (INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR)))
! type = DTK_DAY; /* set for next field */
break;

case DTK_DAY:

It also gives different answers than 8.3 for "select interval '1 1:' hour"
but I guess that's intended, right?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-06-10 02:59:19 Re: INTERVAL SECOND limited to 59 seconds?
Previous Message Tom Lane 2009-06-09 22:59:27 Re: INTERVAL SECOND limited to 59 seconds?

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-06-10 02:59:19 Re: INTERVAL SECOND limited to 59 seconds?
Previous Message Tom Lane 2009-06-10 01:30:05 Re: Not quite a security hole in internal_in