From 70530c808bf8eaba2a41a28c9dc7b96dcc3b6c51 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 11 Sep 2008 15:27:30 +0000 Subject: Adjust the parser to accept the typename syntax INTERVAL ... SECOND(n) and the literal syntax INTERVAL 'string' ... SECOND(n), as required by the SQL standard. Our old syntax put (n) directly after INTERVAL, which was a mistake, but will still be accepted for backward compatibility as well as symmetry with the TIMESTAMP cases. Change intervaltypmodout to show it in the spec's way, too. (This could potentially affect clients, if there are any that analyze the typmod of an INTERVAL in any detail.) Also fix interval input to handle 'min:sec.frac' properly; I had overlooked this case in my previous patch. Document the use of the interval fields qualifier, which up to now we had never mentioned in the docs. (I think the omission was intentional because it didn't work per spec; but it does now, or at least close enough to be credible.) --- src/backend/utils/adt/timestamp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/backend/utils/adt/timestamp.c') diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 9060b989f9c..acfc89ba047 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.191 2008/09/10 18:29:41 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.192 2008/09/11 15:27:30 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -744,7 +744,7 @@ intervaltypmodin(PG_FUNCTION_ARGS) tl = ArrayGetIntegerTypmods(ta, &n); /* - * tl[0] - opt_interval tl[1] - Iconst (optional) + * tl[0] - interval range (fields bitmask) tl[1] - precision (optional) * * Note we must validate tl[0] even though it's normally guaranteed * correct by the grammar --- consider SELECT 'foo'::"interval"(1000). @@ -881,7 +881,7 @@ intervaltypmodout(PG_FUNCTION_ARGS) } if (precision != INTERVAL_FULL_PRECISION) - snprintf(res, 64, "(%d)%s", precision, fieldstr); + snprintf(res, 64, "%s(%d)", fieldstr, precision); else snprintf(res, 64, "%s", fieldstr); -- cgit v1.2.3