Re: interval( 'seconds 27960' ) is broken

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: elein(at)nextbus(dot)com
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: interval( 'seconds 27960' ) is broken
Date: 2001-05-08 07:15:48
Message-ID: 3AF79D24.11A22AB7@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> > In 7.0.3, I'm converting seconds from midnight to a time of
> > day using interval ( 'seconds <val>'). This worked fine in
> > 7.0.3 and gives a Bad interval external representation message
> > in 7.1.
> This has never been the intended or documented format; it should
> be '<val> seconds'. Allowing both is ambiguous, so I'd say that
> the behavior change is a correct one.

In fact, the leading "seconds" label in the above example was never
actually used. What was happening was that the bare "<val>" was
interpreted as having units of seconds, and the leading label had no
effect.

It may help to notice that interval parsing proceeds from right to left,
mostly to allow the units specifier (e.g. "seconds") to be read before
the actual value. A leading units specifier is simply ignored, since
there is no value to the left for it to apply to.

In 7.1, a unitless number is not allowed for an interval, at least
partly because SQL9x requires time zones to be considered intervals
under some conditions. So the default handling of intervals had to be
consistant with that usage.

I would recommend specifying things as "interval ( '<val> seconds' )".

- Thomas

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Chris Storah 2001-05-08 09:37:56 Re: 7.1 euro-style dates insert error
Previous Message Bruce Momjian 2001-05-08 02:37:02 Re: backend dies on 7.1.1 loading large datamodel.