mirror of
https://github.com/postgres/postgres.git
synced 2025-12-12 02:37:31 +03:00
Adjust date/time input parsing code to correctly distinguish the four
SQLSTATE error codes required by SQL99 (invalid format, datetime field overflow, interval field overflow, invalid time zone displacement value). Also emit a HINT about DateStyle in cases where it seems appropriate. Per recent gripes.
This commit is contained in:
@@ -28,9 +28,10 @@ INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity');
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
|
||||
-- what happens if we specify slightly misformatted abstime?
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00');
|
||||
ERROR: invalid input syntax for abstime: "Feb 35, 1946 10:00:00"
|
||||
ERROR: date/time field value out of range: "Feb 35, 1946 10:00:00"
|
||||
HINT: Perhaps you need a different DateStyle setting.
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10');
|
||||
ERROR: invalid input syntax for abstime: "Feb 28, 1984 25:08:10"
|
||||
ERROR: date/time field value out of range: "Feb 28, 1984 25:08:10"
|
||||
-- badly formatted abstimes: these should result in invalid abstimes
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
|
||||
ERROR: invalid input syntax for abstime: "bad date format"
|
||||
|
||||
@@ -28,9 +28,10 @@ INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity');
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
|
||||
-- what happens if we specify slightly misformatted abstime?
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00');
|
||||
ERROR: invalid input syntax for abstime: "Feb 35, 1946 10:00:00"
|
||||
ERROR: date/time field value out of range: "Feb 35, 1946 10:00:00"
|
||||
HINT: Perhaps you need a different DateStyle setting.
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10');
|
||||
ERROR: invalid input syntax for abstime: "Feb 28, 1984 25:08:10"
|
||||
ERROR: date/time field value out of range: "Feb 28, 1984 25:08:10"
|
||||
-- badly formatted abstimes: these should result in invalid abstimes
|
||||
INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
|
||||
ERROR: invalid input syntax for abstime: "bad date format"
|
||||
|
||||
@@ -10,7 +10,7 @@ INSERT INTO DATE_TBL VALUES ('1996-03-01');
|
||||
INSERT INTO DATE_TBL VALUES ('1996-03-02');
|
||||
INSERT INTO DATE_TBL VALUES ('1997-02-28');
|
||||
INSERT INTO DATE_TBL VALUES ('1997-02-29');
|
||||
ERROR: invalid input syntax for date: "1997-02-29"
|
||||
ERROR: date/time field value out of range: "1997-02-29"
|
||||
INSERT INTO DATE_TBL VALUES ('1997-03-01');
|
||||
INSERT INTO DATE_TBL VALUES ('1997-03-02');
|
||||
INSERT INTO DATE_TBL VALUES ('2000-04-01');
|
||||
|
||||
@@ -81,7 +81,8 @@ SELECT timestamp with time zone '12/27/2001 04:05:06.789-08';
|
||||
|
||||
-- should fail in mdy mode:
|
||||
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
||||
ERROR: invalid input syntax for timestamp with time zone: "27/12/2001 04:05:06.789-08"
|
||||
ERROR: date/time field value out of range: "27/12/2001 04:05:06.789-08"
|
||||
HINT: Perhaps you need a different DateStyle setting.
|
||||
set datestyle to dmy;
|
||||
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
||||
timestamptz
|
||||
|
||||
@@ -81,7 +81,8 @@ SELECT timestamp with time zone '12/27/2001 04:05:06.789-08';
|
||||
|
||||
-- should fail in mdy mode:
|
||||
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
||||
ERROR: invalid input syntax for timestamp with time zone: "27/12/2001 04:05:06.789-08"
|
||||
ERROR: date/time field value out of range: "27/12/2001 04:05:06.789-08"
|
||||
HINT: Perhaps you need a different DateStyle setting.
|
||||
set datestyle to dmy;
|
||||
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
||||
timestamptz
|
||||
|
||||
@@ -81,7 +81,8 @@ SELECT timestamp with time zone '12/27/2001 04:05:06.789-08';
|
||||
|
||||
-- should fail in mdy mode:
|
||||
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
||||
ERROR: invalid input syntax for timestamp with time zone: "27/12/2001 04:05:06.789-08"
|
||||
ERROR: date/time field value out of range: "27/12/2001 04:05:06.789-08"
|
||||
HINT: Perhaps you need a different DateStyle setting.
|
||||
set datestyle to dmy;
|
||||
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
||||
timestamptz
|
||||
|
||||
@@ -128,7 +128,7 @@ INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1996');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 28 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 29 17:32:01 1997');
|
||||
ERROR: invalid input syntax for timestamp: "Feb 29 17:32:01 1997"
|
||||
ERROR: date/time field value out of range: "Feb 29 17:32:01 1997"
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Mar 01 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 30 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1997');
|
||||
@@ -138,7 +138,7 @@ INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 2000');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 2001');
|
||||
-- Currently unsupported syntax and ranges
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 -0097');
|
||||
ERROR: invalid input syntax for timestamp: "Feb 16 17:32:01 -0097"
|
||||
ERROR: time zone displacement out of range: "Feb 16 17:32:01 -0097"
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 5097 BC');
|
||||
ERROR: timestamp out of range: "Feb 16 17:32:01 5097 BC"
|
||||
SELECT '' AS "64", d1 FROM TIMESTAMP_TBL;
|
||||
|
||||
@@ -123,7 +123,7 @@ INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1996');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 28 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 29 17:32:01 1997');
|
||||
ERROR: invalid input syntax for timestamp with time zone: "Feb 29 17:32:01 1997"
|
||||
ERROR: date/time field value out of range: "Feb 29 17:32:01 1997"
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mar 01 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 30 17:32:01 1997');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1997');
|
||||
@@ -133,7 +133,7 @@ INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 2000');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 2001');
|
||||
-- Currently unsupported syntax and ranges
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 -0097');
|
||||
ERROR: invalid input syntax for timestamp with time zone: "Feb 16 17:32:01 -0097"
|
||||
ERROR: time zone displacement out of range: "Feb 16 17:32:01 -0097"
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 5097 BC');
|
||||
ERROR: timestamp out of range: "Feb 16 17:32:01 5097 BC"
|
||||
SELECT '' AS "64", d1 FROM TIMESTAMPTZ_TBL;
|
||||
|
||||
Reference in New Issue
Block a user