From: Tom Lane <tgl@sss.pgh.pa.us> Date: Sat, 8 Nov 2008 20:51:49 +0000 (+0000) Subject: Fix recently added code for SQL years-months interval syntax so that X-Git-Tag: REL8_4_BETA1~743 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eec501c4f773add9f30789efc28f8ce3bf2e5de9;p=postgresql Fix recently added code for SQL years-months interval syntax so that it behaves correctly for a leading minus sign, zero year value, and nonzero month value. Per discussion with Ron Mayer. --- diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 0ec29c7cb8..8efe2b22f2 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.195 2008/10/02 13:47:38 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.196 2008/11/08 20:51:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -2863,7 +2863,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range, if (*cp != '\0') return DTERR_BAD_FORMAT; type = DTK_MONTH; - if (val < 0) + if (*field[i] == '-') val2 = -val2; val = val * MONTHS_PER_YEAR + val2; fval = 0;