|
04:05:06.789-8
ISO 8601
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
fsec_t fsec;
struct tm tt,
*tm = &tt;
+ int tz;
int nf;
char lowstr[MAXDATELEN + 1];
char *field[MAXDATEFIELDS];
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);
(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
------------------
(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
------------------
(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
------------------
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');
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';
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');