diff options
author | Tom Lane | 2003-01-31 01:08:08 +0000 |
---|---|---|
committer | Tom Lane | 2003-01-31 01:08:08 +0000 |
commit | bd96dd118403c6e05486c1060745956ca2ee4466 (patch) | |
tree | 04227c7e2ad040a7cd8b361b37cfe49a4c5f342e /src | |
parent | 37b247a5e93321b309d71c84d8f9d5dc1c098e3f (diff) |
Allow a time zone to be specified (and silently ignored) in the input
for type 'time without time zone', as we already did for type
'timestamp without time zone'. This patch was proposed by Tom Lockhart
on 7-Nov-02, but he never got around to applying it. Adjust regression
tests and documentation to match.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/adt/date.c | 5 | ||||
-rw-r--r-- | src/test/regress/expected/horology-no-DST-before-1970.out | 26 | ||||
-rw-r--r-- | src/test/regress/expected/horology-solaris-1947.out | 26 | ||||
-rw-r--r-- | src/test/regress/expected/horology.out | 26 | ||||
-rw-r--r-- | src/test/regress/expected/time.out | 9 | ||||
-rw-r--r-- | src/test/regress/sql/horology.sql | 2 | ||||
-rw-r--r-- | src/test/regress/sql/time.sql | 7 |
7 files changed, 73 insertions, 28 deletions
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index 90f41ad817d..09d0e9aa256 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.77 2003/01/29 01:08:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.78 2003/01/31 01:08:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -511,6 +511,7 @@ time_in(PG_FUNCTION_ARGS) fsec_t fsec; struct tm tt, *tm = &tt; + int tz; int nf; char lowstr[MAXDATELEN + 1]; char *field[MAXDATEFIELDS]; @@ -521,7 +522,7 @@ time_in(PG_FUNCTION_ARGS) elog(ERROR, "Bad time external representation (too long) '%s'", str); if ((ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0) - || (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, NULL) != 0)) + || (DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0)) elog(ERROR, "Bad time external representation '%s'", str); tm2time(tm, fsec, &result); diff --git a/src/test/regress/expected/horology-no-DST-before-1970.out b/src/test/regress/expected/horology-no-DST-before-1970.out index b8b7423ec52..ab40a6404ca 100644 --- a/src/test/regress/expected/horology-no-DST-before-1970.out +++ b/src/test/regress/expected/horology-no-DST-before-1970.out @@ -196,15 +196,31 @@ SELECT timestamp with time zone '27.12.2001 04:05:06.789-08'; (1 row) SET DateStyle = 'ISO'; --- Reject time without time zone having a time zone specified +-- As of 7.4, allow time without time zone having a time zone specified SELECT time without time zone '040506.789+08'; -ERROR: Bad time external representation '040506.789+08' + time +--------------- + 04:05:06.7890 +(1 row) + SELECT time without time zone '040506.789-08'; -ERROR: Bad time external representation '040506.789-08' + time +--------------- + 04:05:06.7890 +(1 row) + SELECT time without time zone 'T040506.789+08'; -ERROR: Bad time external representation 'T040506.789+08' + time +--------------- + 04:05:06.7890 +(1 row) + SELECT time without time zone 'T040506.789-08'; -ERROR: Bad time external representation 'T040506.789-08' + time +--------------- + 04:05:06.7890 +(1 row) + SELECT time with time zone '040506.789+08'; timetz ------------------ diff --git a/src/test/regress/expected/horology-solaris-1947.out b/src/test/regress/expected/horology-solaris-1947.out index 1601a346f01..222ee303679 100644 --- a/src/test/regress/expected/horology-solaris-1947.out +++ b/src/test/regress/expected/horology-solaris-1947.out @@ -196,15 +196,31 @@ SELECT timestamp with time zone '27.12.2001 04:05:06.789-08'; (1 row) SET DateStyle = 'ISO'; --- Reject time without time zone having a time zone specified +-- As of 7.4, allow time without time zone having a time zone specified SELECT time without time zone '040506.789+08'; -ERROR: Bad time external representation '040506.789+08' + time +--------------- + 04:05:06.7890 +(1 row) + SELECT time without time zone '040506.789-08'; -ERROR: Bad time external representation '040506.789-08' + time +--------------- + 04:05:06.7890 +(1 row) + SELECT time without time zone 'T040506.789+08'; -ERROR: Bad time external representation 'T040506.789+08' + time +--------------- + 04:05:06.7890 +(1 row) + SELECT time without time zone 'T040506.789-08'; -ERROR: Bad time external representation 'T040506.789-08' + time +--------------- + 04:05:06.7890 +(1 row) + SELECT time with time zone '040506.789+08'; timetz ------------------ diff --git a/src/test/regress/expected/horology.out b/src/test/regress/expected/horology.out index 294b7854106..2735641e396 100644 --- a/src/test/regress/expected/horology.out +++ b/src/test/regress/expected/horology.out @@ -196,15 +196,31 @@ SELECT timestamp with time zone '27.12.2001 04:05:06.789-08'; (1 row) SET DateStyle = 'ISO'; --- Reject time without time zone having a time zone specified +-- As of 7.4, allow time without time zone having a time zone specified SELECT time without time zone '040506.789+08'; -ERROR: Bad time external representation '040506.789+08' + time +--------------- + 04:05:06.7890 +(1 row) + SELECT time without time zone '040506.789-08'; -ERROR: Bad time external representation '040506.789-08' + time +--------------- + 04:05:06.7890 +(1 row) + SELECT time without time zone 'T040506.789+08'; -ERROR: Bad time external representation 'T040506.789+08' + time +--------------- + 04:05:06.7890 +(1 row) + SELECT time without time zone 'T040506.789-08'; -ERROR: Bad time external representation 'T040506.789-08' + time +--------------- + 04:05:06.7890 +(1 row) + SELECT time with time zone '040506.789+08'; timetz ------------------ diff --git a/src/test/regress/expected/time.out b/src/test/regress/expected/time.out index ddefeadc34d..e8b2b6de337 100644 --- a/src/test/regress/expected/time.out +++ b/src/test/regress/expected/time.out @@ -4,12 +4,9 @@ CREATE TABLE TIME_TBL (f1 time(2)); INSERT INTO TIME_TBL VALUES ('00:00'); INSERT INTO TIME_TBL VALUES ('01:00'); -INSERT INTO TIME_TBL VALUES ('02:03'); -INSERT INTO TIME_TBL VALUES ('07:07 PST'); -ERROR: Bad time external representation '07:07 PST' -INSERT INTO TIME_TBL VALUES ('08:08 EDT'); -ERROR: Bad time external representation '08:08 EDT' -INSERT INTO TIME_TBL VALUES ('11:59'); +-- as of 7.4, timezone spec should be accepted and ignored +INSERT INTO TIME_TBL VALUES ('02:03 PST'); +INSERT INTO TIME_TBL VALUES ('11:59 EDT'); INSERT INTO TIME_TBL VALUES ('12:00'); INSERT INTO TIME_TBL VALUES ('12:01'); INSERT INTO TIME_TBL VALUES ('23:59'); diff --git a/src/test/regress/sql/horology.sql b/src/test/regress/sql/horology.sql index 6d767d23760..0af769a8b2c 100644 --- a/src/test/regress/sql/horology.sql +++ b/src/test/regress/sql/horology.sql @@ -42,7 +42,7 @@ SET DateStyle = 'German'; SELECT timestamp with time zone '27.12.2001 04:05:06.789+08'; SELECT timestamp with time zone '27.12.2001 04:05:06.789-08'; SET DateStyle = 'ISO'; --- Reject time without time zone having a time zone specified +-- As of 7.4, allow time without time zone having a time zone specified SELECT time without time zone '040506.789+08'; SELECT time without time zone '040506.789-08'; SELECT time without time zone 'T040506.789+08'; diff --git a/src/test/regress/sql/time.sql b/src/test/regress/sql/time.sql index 8ab8caa6077..510cc148549 100644 --- a/src/test/regress/sql/time.sql +++ b/src/test/regress/sql/time.sql @@ -6,10 +6,9 @@ CREATE TABLE TIME_TBL (f1 time(2)); INSERT INTO TIME_TBL VALUES ('00:00'); INSERT INTO TIME_TBL VALUES ('01:00'); -INSERT INTO TIME_TBL VALUES ('02:03'); -INSERT INTO TIME_TBL VALUES ('07:07 PST'); -INSERT INTO TIME_TBL VALUES ('08:08 EDT'); -INSERT INTO TIME_TBL VALUES ('11:59'); +-- as of 7.4, timezone spec should be accepted and ignored +INSERT INTO TIME_TBL VALUES ('02:03 PST'); +INSERT INTO TIME_TBL VALUES ('11:59 EDT'); INSERT INTO TIME_TBL VALUES ('12:00'); INSERT INTO TIME_TBL VALUES ('12:01'); INSERT INTO TIME_TBL VALUES ('23:59'); |