From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: interval typmodout is broken |
Date: | 2014-09-24 21:32:59 |
Message-ID: | 20140924213259.GU5311@eldon.alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Tom Lane wrote:
> Alvaro Herrera <alvherre(at)2ndquadrant(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2014-09-24 21:34:11 | Sloppy thinking about leakproof properties of opclass co-members |
Previous Message | Stephen Frost | 2014-09-24 20:58:24 | Re: Review of GetUserId() Usage |