diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-06-12 15:58:32 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-06-12 15:58:32 +0000 |
commit | d0599994da684374cf7b30eab4c69c019f38f5ab (patch) | |
tree | 9427a7aa3cba8578df7898fcebad5bb5306e3ff9 /src/backend/utils/adt/datetime.c | |
parent | e41c7bb7cd75b36f9d51d2f335bb66fb5a213987 (diff) | |
download | postgresql-d0599994da684374cf7b30eab4c69c019f38f5ab.tar.gz postgresql-d0599994da684374cf7b30eab4c69c019f38f5ab.zip |
Fix DecodeDateTime to allow timezone to appear before year. This had
historically worked in some but not all cases, but as of 8.2 it failed for all
timezone formats. Fix, and add regression test cases to catch future
regressions in this area. Per gripe from Adam Witney.
Diffstat (limited to 'src/backend/utils/adt/datetime.c')
-rw-r--r-- | src/backend/utils/adt/datetime.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index b5cc2461589..ddd4fa6167d 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.180 2007/05/29 04:58:43 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.181 2007/06/12 15:58:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -721,11 +721,17 @@ DecodeDateTime(char **field, int *ftype, int nf, } /*** * Already have a date? Then this might be a time zone name - * with embedded punctuation (e.g. "America/New_York") or - * a run-together time with trailing time zone (e.g. hhmmss-zz). + * with embedded punctuation (e.g. "America/New_York") or a + * run-together time with trailing time zone (e.g. hhmmss-zz). * - thomas 2001-12-25 + * + * We consider it a time zone if we already have month & day. + * This is to allow the form "mmm dd hhmmss tz year", which + * we've historically accepted. ***/ - else if ((fmask & DTK_DATE_M) == DTK_DATE_M || ptype != 0) + else if (ptype != 0 || + ((fmask & (DTK_M(MONTH) | DTK_M(DAY))) == + (DTK_M(MONTH) | DTK_M(DAY)))) { /* No time zone accepted? Then quit... */ if (tzp == NULL) |