Re: interval typmodout is broken

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: interval typmodout is broken
Дата
Msg-id 6273.1411618016@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: interval typmodout is broken  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Ответы Re: interval typmodout is broken  (Bruce Momjian <bruce@momjian.us>)
Список pgsql-hackers
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> Tom Lane wrote:
>> You sure about that?  The grammar for INTERVAL is weird.

> Well, I tested what is taken on input, and yes I agree the grammar is
> weird (but not more weird than timestamp/timestamptz, mind).  The input
> function only accepts the precision just after the INTERVAL keyword, not
> after the fieldstr:

> alvherre=# create table str (a interval(2) hour to minute);
> CREATE TABLE

> alvherre=# create table str2 (a interval hour to minute(2));
> ERROR:  syntax error at or near "("
> L�NEA 1: create table str2 (a interval hour to minute(2));
>                                                      ^

No, that's not about where it is, it's about what the field is: only
"second" can have a precision.  Our grammar is actually allowing stuff
here that it shouldn't.  According to the SQL spec, you could writeinterval hour(2) to minute
but this involves a "leading field precision", which we do not support
and should definitely not be conflating with trailing-field precision.
Or you could writeinterval hour to second(2)
which is valid and we support it.  You can *not* writeinterval hour to minute(2)
either per spec or per our implementation; andinterval(2) hour to minute
is 100% invalid per spec, even though our grammar goes out of its
way to accept it.

In short, the typmodout function is doing what it ought to.  It's the
grammar that's broken.  It looks to me like Tom Lockhart coded the
grammar to accept a bunch of cases that he never got round to actually
implementing reasonably.  In particular, per SQL spec these are
completely different animals:interval hour(2) to secondinterval hour to second(2)
but our grammar transforms them into the same thing.

We ought to fix that...
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: identify_locking_dependencies is broken for schema-only dumps
Следующее
От: Gregory Smith
Дата:
Сообщение: Re: proposal: rounding up time value less than its unit.