Re: interval typmodout is broken

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: interval typmodout is broken
Дата
Msg-id 20140924213259.GU5311@eldon.alvh.no-ip.org
обсуждение исходный текст
Ответ на Re: interval typmodout is broken  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: interval typmodout is broken  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Tom Lane wrote:
> Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> > I just noticed when working on DDL deparsing that the typmodout routine
> > for intervals is broken.  The code uses
> 
> >     if (precision != INTERVAL_FULL_PRECISION)
> >         snprintf(res, 64, "%s(%d)", fieldstr, precision);
> >     else
> >         snprintf(res, 64, "%s", fieldstr);
> 
> > which puts the parenthised number after the textual name; but the
> > grammar only takes it the other way around.
> 
> You sure about that?  The grammar for INTERVAL is weird.  I believe
> the output we're trying to produce here is something like
> 
>     INTERVAL HOUR TO SECOND(2)
> 
> where "fieldstr" would be " HOUR TO SECOND" and "precision" would
> give the fractional-second precision.

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));                                                    ^



-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services



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

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: Review of GetUserId() Usage
Следующее
От: Tom Lane
Дата:
Сообщение: Sloppy thinking about leakproof properties of opclass co-members