Tom Lane wrote: > Alvaro Herrera <alvhe...@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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers