summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane2003-07-29 00:03:19 +0000
committerTom Lane2003-07-29 00:03:19 +0000
commit9c2a7c2269d1ecebd7f83e769bb2640cb82fa0e0 (patch)
treef868b45501a84e01215cefb03754bab63e23730b /src/test
parent2baf4efe09f65d8e8cac32fb882ab9f0fd601574 (diff)
Apply (a somewhat revised version of) Greg Mullane's patch to eliminate
heuristic determination of day vs month in date/time input. Add the ability to specify that input is interpreted as yy-mm-dd order (which formerly worked, but only for yy greater than 31). DateStyle's input component now has the preferred spellings DMY, MDY, or YMD; the older keywords European and US are now aliases for the first two of these. Per recent discussions on pgsql-general.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/horology-no-DST-before-1970.out41
-rw-r--r--src/test/regress/expected/horology-solaris-1947.out41
-rw-r--r--src/test/regress/expected/horology.out41
-rw-r--r--src/test/regress/expected/timestamp.out4
-rw-r--r--src/test/regress/expected/timestamptz.out4
-rw-r--r--src/test/regress/pg_regress.sh6
-rw-r--r--src/test/regress/sql/horology.sql12
-rw-r--r--src/test/regress/sql/timestamp.sql4
-rw-r--r--src/test/regress/sql/timestamptz.sql4
9 files changed, 92 insertions, 65 deletions
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 f824122b876..0aa1da407f4 100644
--- a/src/test/regress/expected/horology-no-DST-before-1970.out
+++ b/src/test/regress/expected/horology-no-DST-before-1970.out
@@ -3,7 +3,7 @@
--
-- needed so tests pass even in Australia
SET australian_timezones = 'off';
-SET DateStyle = 'Postgres,US';
+SET DateStyle = 'Postgres, MDY';
--
-- Test various input formats
--
@@ -79,12 +79,17 @@ SELECT timestamp with time zone '12/27/2001 04:05:06.789-08';
Thu Dec 27 04:05:06.789 2001 PST
(1 row)
+-- 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"
+set datestyle to dmy;
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
timestamptz
----------------------------------
- Thu Dec 27 04:05:06.789 2001 PST
+ Thu 27 Dec 04:05:06.789 2001 PST
(1 row)
+reset datestyle;
SELECT timestamp with time zone 'Y2001M12D27H04M05S06.789+08';
timestamptz
----------------------------------
@@ -170,13 +175,13 @@ SELECT timestamp with time zone 'J2452271T040506.789-08';
(1 row)
-- German/European-style dates with periods as delimiters
-SELECT timestamp with time zone '27.12.2001 04:05:06.789+08';
+SELECT timestamp with time zone '12.27.2001 04:05:06.789+08';
timestamptz
----------------------------------
Wed Dec 26 12:05:06.789 2001 PST
(1 row)
-SELECT timestamp with time zone '27.12.2001 04:05:06.789-08';
+SELECT timestamp with time zone '12.27.2001 04:05:06.789-08';
timestamptz
----------------------------------
Thu Dec 27 04:05:06.789 2001 PST
@@ -257,7 +262,7 @@ SELECT time with time zone 'T040506.789 -08';
04:05:06.7890-08
(1 row)
-SET DateStyle = 'Postgres,US';
+SET DateStyle = 'Postgres, MDY';
--
-- date, time arithmetic
--
@@ -2385,9 +2390,9 @@ DROP TABLE TEMP_TIMESTAMP;
--
SET DateStyle TO 'US,Postgres';
SHOW DateStyle;
- DateStyle
---------------
- Postgres, US
+ DateStyle
+---------------
+ Postgres, MDY
(1 row)
SELECT '' AS "64", d1 AS us_postgres FROM TIMESTAMP_TBL;
@@ -2557,7 +2562,7 @@ SET DateStyle TO 'US,SQL';
SHOW DateStyle;
DateStyle
-----------
- SQL, US
+ SQL, MDY
(1 row)
SELECT '' AS "64", d1 AS us_sql FROM TIMESTAMP_TBL;
@@ -2643,9 +2648,9 @@ SELECT '' AS seven, f1 AS us_sql FROM ABSTIME_TBL;
SET DateStyle TO 'European,Postgres';
SHOW DateStyle;
- DateStyle
---------------------
- Postgres, European
+ DateStyle
+---------------
+ Postgres, DMY
(1 row)
INSERT INTO TIMESTAMP_TBL VALUES('13/06/1957');
@@ -2739,9 +2744,9 @@ SELECT '' AS seven, f1 AS european_postgres FROM ABSTIME_TBL;
SET DateStyle TO 'European,ISO';
SHOW DateStyle;
- DateStyle
----------------
- ISO, European
+ DateStyle
+-----------
+ ISO, DMY
(1 row)
SELECT '' AS "65", d1 AS european_iso FROM TIMESTAMP_TBL;
@@ -2828,9 +2833,9 @@ SELECT '' AS seven, f1 AS european_iso FROM ABSTIME_TBL;
SET DateStyle TO 'European,SQL';
SHOW DateStyle;
- DateStyle
----------------
- SQL, European
+ DateStyle
+-----------
+ SQL, DMY
(1 row)
SELECT '' AS "65", d1 AS european_sql FROM TIMESTAMP_TBL;
diff --git a/src/test/regress/expected/horology-solaris-1947.out b/src/test/regress/expected/horology-solaris-1947.out
index 736208001b5..cdb9c7f1d86 100644
--- a/src/test/regress/expected/horology-solaris-1947.out
+++ b/src/test/regress/expected/horology-solaris-1947.out
@@ -3,7 +3,7 @@
--
-- needed so tests pass even in Australia
SET australian_timezones = 'off';
-SET DateStyle = 'Postgres,US';
+SET DateStyle = 'Postgres, MDY';
--
-- Test various input formats
--
@@ -79,12 +79,17 @@ SELECT timestamp with time zone '12/27/2001 04:05:06.789-08';
Thu Dec 27 04:05:06.789 2001 PST
(1 row)
+-- 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"
+set datestyle to dmy;
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
timestamptz
----------------------------------
- Thu Dec 27 04:05:06.789 2001 PST
+ Thu 27 Dec 04:05:06.789 2001 PST
(1 row)
+reset datestyle;
SELECT timestamp with time zone 'Y2001M12D27H04M05S06.789+08';
timestamptz
----------------------------------
@@ -170,13 +175,13 @@ SELECT timestamp with time zone 'J2452271T040506.789-08';
(1 row)
-- German/European-style dates with periods as delimiters
-SELECT timestamp with time zone '27.12.2001 04:05:06.789+08';
+SELECT timestamp with time zone '12.27.2001 04:05:06.789+08';
timestamptz
----------------------------------
Wed Dec 26 12:05:06.789 2001 PST
(1 row)
-SELECT timestamp with time zone '27.12.2001 04:05:06.789-08';
+SELECT timestamp with time zone '12.27.2001 04:05:06.789-08';
timestamptz
----------------------------------
Thu Dec 27 04:05:06.789 2001 PST
@@ -257,7 +262,7 @@ SELECT time with time zone 'T040506.789 -08';
04:05:06.7890-08
(1 row)
-SET DateStyle = 'Postgres,US';
+SET DateStyle = 'Postgres, MDY';
--
-- date, time arithmetic
--
@@ -2385,9 +2390,9 @@ DROP TABLE TEMP_TIMESTAMP;
--
SET DateStyle TO 'US,Postgres';
SHOW DateStyle;
- DateStyle
---------------
- Postgres, US
+ DateStyle
+---------------
+ Postgres, MDY
(1 row)
SELECT '' AS "64", d1 AS us_postgres FROM TIMESTAMP_TBL;
@@ -2557,7 +2562,7 @@ SET DateStyle TO 'US,SQL';
SHOW DateStyle;
DateStyle
-----------
- SQL, US
+ SQL, MDY
(1 row)
SELECT '' AS "64", d1 AS us_sql FROM TIMESTAMP_TBL;
@@ -2643,9 +2648,9 @@ SELECT '' AS seven, f1 AS us_sql FROM ABSTIME_TBL;
SET DateStyle TO 'European,Postgres';
SHOW DateStyle;
- DateStyle
---------------------
- Postgres, European
+ DateStyle
+---------------
+ Postgres, DMY
(1 row)
INSERT INTO TIMESTAMP_TBL VALUES('13/06/1957');
@@ -2739,9 +2744,9 @@ SELECT '' AS seven, f1 AS european_postgres FROM ABSTIME_TBL;
SET DateStyle TO 'European,ISO';
SHOW DateStyle;
- DateStyle
----------------
- ISO, European
+ DateStyle
+-----------
+ ISO, DMY
(1 row)
SELECT '' AS "65", d1 AS european_iso FROM TIMESTAMP_TBL;
@@ -2828,9 +2833,9 @@ SELECT '' AS seven, f1 AS european_iso FROM ABSTIME_TBL;
SET DateStyle TO 'European,SQL';
SHOW DateStyle;
- DateStyle
----------------
- SQL, European
+ DateStyle
+-----------
+ SQL, DMY
(1 row)
SELECT '' AS "65", d1 AS european_sql FROM TIMESTAMP_TBL;
diff --git a/src/test/regress/expected/horology.out b/src/test/regress/expected/horology.out
index 735e703e4c4..984e75e8b4c 100644
--- a/src/test/regress/expected/horology.out
+++ b/src/test/regress/expected/horology.out
@@ -3,7 +3,7 @@
--
-- needed so tests pass even in Australia
SET australian_timezones = 'off';
-SET DateStyle = 'Postgres,US';
+SET DateStyle = 'Postgres, MDY';
--
-- Test various input formats
--
@@ -79,12 +79,17 @@ SELECT timestamp with time zone '12/27/2001 04:05:06.789-08';
Thu Dec 27 04:05:06.789 2001 PST
(1 row)
+-- 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"
+set datestyle to dmy;
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
timestamptz
----------------------------------
- Thu Dec 27 04:05:06.789 2001 PST
+ Thu 27 Dec 04:05:06.789 2001 PST
(1 row)
+reset datestyle;
SELECT timestamp with time zone 'Y2001M12D27H04M05S06.789+08';
timestamptz
----------------------------------
@@ -170,13 +175,13 @@ SELECT timestamp with time zone 'J2452271T040506.789-08';
(1 row)
-- German/European-style dates with periods as delimiters
-SELECT timestamp with time zone '27.12.2001 04:05:06.789+08';
+SELECT timestamp with time zone '12.27.2001 04:05:06.789+08';
timestamptz
----------------------------------
Wed Dec 26 12:05:06.789 2001 PST
(1 row)
-SELECT timestamp with time zone '27.12.2001 04:05:06.789-08';
+SELECT timestamp with time zone '12.27.2001 04:05:06.789-08';
timestamptz
----------------------------------
Thu Dec 27 04:05:06.789 2001 PST
@@ -257,7 +262,7 @@ SELECT time with time zone 'T040506.789 -08';
04:05:06.7890-08
(1 row)
-SET DateStyle = 'Postgres,US';
+SET DateStyle = 'Postgres, MDY';
--
-- date, time arithmetic
--
@@ -2385,9 +2390,9 @@ DROP TABLE TEMP_TIMESTAMP;
--
SET DateStyle TO 'US,Postgres';
SHOW DateStyle;
- DateStyle
---------------
- Postgres, US
+ DateStyle
+---------------
+ Postgres, MDY
(1 row)
SELECT '' AS "64", d1 AS us_postgres FROM TIMESTAMP_TBL;
@@ -2557,7 +2562,7 @@ SET DateStyle TO 'US,SQL';
SHOW DateStyle;
DateStyle
-----------
- SQL, US
+ SQL, MDY
(1 row)
SELECT '' AS "64", d1 AS us_sql FROM TIMESTAMP_TBL;
@@ -2643,9 +2648,9 @@ SELECT '' AS seven, f1 AS us_sql FROM ABSTIME_TBL;
SET DateStyle TO 'European,Postgres';
SHOW DateStyle;
- DateStyle
---------------------
- Postgres, European
+ DateStyle
+---------------
+ Postgres, DMY
(1 row)
INSERT INTO TIMESTAMP_TBL VALUES('13/06/1957');
@@ -2739,9 +2744,9 @@ SELECT '' AS seven, f1 AS european_postgres FROM ABSTIME_TBL;
SET DateStyle TO 'European,ISO';
SHOW DateStyle;
- DateStyle
----------------
- ISO, European
+ DateStyle
+-----------
+ ISO, DMY
(1 row)
SELECT '' AS "65", d1 AS european_iso FROM TIMESTAMP_TBL;
@@ -2828,9 +2833,9 @@ SELECT '' AS seven, f1 AS european_iso FROM ABSTIME_TBL;
SET DateStyle TO 'European,SQL';
SHOW DateStyle;
- DateStyle
----------------
- SQL, European
+ DateStyle
+-----------
+ SQL, DMY
(1 row)
SELECT '' AS "65", d1 AS european_sql FROM TIMESTAMP_TBL;
diff --git a/src/test/regress/expected/timestamp.out b/src/test/regress/expected/timestamp.out
index 71420dd2baf..0b45bb9c1a7 100644
--- a/src/test/regress/expected/timestamp.out
+++ b/src/test/regress/expected/timestamp.out
@@ -97,9 +97,11 @@ INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01 PST');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb-10-1997 17:32:01 PST');
INSERT INTO TIMESTAMP_TBL VALUES ('02-10-1997 17:32:01 PST');
INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 PST');
+set datestyle to ymd;
INSERT INTO TIMESTAMP_TBL VALUES ('97FEB10 5:32:01PM UTC');
INSERT INTO TIMESTAMP_TBL VALUES ('97/02/10 17:32:01 UTC');
-INSERT INTO TIMESTAMP_TBL VALUES ('97.041 17:32:01 UTC');
+reset datestyle;
+INSERT INTO TIMESTAMP_TBL VALUES ('1997.041 17:32:01 UTC');
-- Check date conversion and date arithmetic
INSERT INTO TIMESTAMP_TBL VALUES ('1997-06-10 18:32:01 PDT');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 17:32:01 1997');
diff --git a/src/test/regress/expected/timestamptz.out b/src/test/regress/expected/timestamptz.out
index a383ac2f616..49525518c7b 100644
--- a/src/test/regress/expected/timestamptz.out
+++ b/src/test/regress/expected/timestamptz.out
@@ -92,9 +92,11 @@ INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01 PST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb-10-1997 17:32:01 PST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('02-10-1997 17:32:01 PST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 PST');
+set datestyle to ymd;
INSERT INTO TIMESTAMPTZ_TBL VALUES ('97FEB10 5:32:01PM UTC');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('97/02/10 17:32:01 UTC');
-INSERT INTO TIMESTAMPTZ_TBL VALUES ('97.041 17:32:01 UTC');
+reset datestyle;
+INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997.041 17:32:01 UTC');
-- Check date conversion and date arithmetic
INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-06-10 18:32:01 PDT');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997');
diff --git a/src/test/regress/pg_regress.sh b/src/test/regress/pg_regress.sh
index 037d6f83ec4..230d2befe1f 100644
--- a/src/test/regress/pg_regress.sh
+++ b/src/test/regress/pg_regress.sh
@@ -1,5 +1,5 @@
#! /bin/sh
-# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.31 2003/05/14 03:26:03 tgl Exp $
+# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.32 2003/07/29 00:03:19 tgl Exp $
me=`basename $0`
: ${TMPDIR=/tmp}
@@ -191,7 +191,7 @@ esac
# ----------
PGTZ='PST8PDT'; export PGTZ
-PGDATESTYLE='ISO,US'; export PGDATESTYLE
+PGDATESTYLE='ISO, MDY'; export PGDATESTYLE
# ----------
@@ -432,7 +432,7 @@ PSQL="$bindir/psql -q -X $psql_options"
# ----------
PGTZ='PST8PDT'; export PGTZ
-PGDATESTYLE='Postgres,US'; export PGDATESTYLE
+PGDATESTYLE='Postgres, MDY'; export PGDATESTYLE
# ----------
diff --git a/src/test/regress/sql/horology.sql b/src/test/regress/sql/horology.sql
index 88ac83b5add..c9171b28bdd 100644
--- a/src/test/regress/sql/horology.sql
+++ b/src/test/regress/sql/horology.sql
@@ -3,7 +3,7 @@
--
-- needed so tests pass even in Australia
SET australian_timezones = 'off';
-SET DateStyle = 'Postgres,US';
+SET DateStyle = 'Postgres, MDY';
--
-- Test various input formats
@@ -20,7 +20,11 @@ SELECT timestamp with time zone '2001-12-27 04:05:06.789-08';
SELECT timestamp with time zone '2001.12.27 04:05:06.789-08';
SELECT timestamp with time zone '2001/12/27 04:05:06.789-08';
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';
+set datestyle to dmy;
+SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
+reset datestyle;
SELECT timestamp with time zone 'Y2001M12D27H04M05S06.789+08';
SELECT timestamp with time zone 'Y2001M12D27H04M05S06.789-08';
SELECT timestamp with time zone 'Y2001M12D27H04MM05S06.789+08';
@@ -36,8 +40,8 @@ SELECT timestamp with time zone 'J2452271T040506-08';
SELECT timestamp with time zone 'J2452271T040506.789+08';
SELECT timestamp with time zone 'J2452271T040506.789-08';
-- German/European-style dates with periods as delimiters
-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';
+SELECT timestamp with time zone '12.27.2001 04:05:06.789+08';
+SELECT timestamp with time zone '12.27.2001 04:05:06.789-08';
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';
@@ -53,7 +57,7 @@ SELECT time with time zone 'T040506.789+08';
SELECT time with time zone 'T040506.789-08';
SELECT time with time zone 'T040506.789 +08';
SELECT time with time zone 'T040506.789 -08';
-SET DateStyle = 'Postgres,US';
+SET DateStyle = 'Postgres, MDY';
--
-- date, time arithmetic
diff --git a/src/test/regress/sql/timestamp.sql b/src/test/regress/sql/timestamp.sql
index b08e81e80e4..48a9151a703 100644
--- a/src/test/regress/sql/timestamp.sql
+++ b/src/test/regress/sql/timestamp.sql
@@ -80,9 +80,11 @@ INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01 PST');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb-10-1997 17:32:01 PST');
INSERT INTO TIMESTAMP_TBL VALUES ('02-10-1997 17:32:01 PST');
INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 PST');
+set datestyle to ymd;
INSERT INTO TIMESTAMP_TBL VALUES ('97FEB10 5:32:01PM UTC');
INSERT INTO TIMESTAMP_TBL VALUES ('97/02/10 17:32:01 UTC');
-INSERT INTO TIMESTAMP_TBL VALUES ('97.041 17:32:01 UTC');
+reset datestyle;
+INSERT INTO TIMESTAMP_TBL VALUES ('1997.041 17:32:01 UTC');
-- Check date conversion and date arithmetic
INSERT INTO TIMESTAMP_TBL VALUES ('1997-06-10 18:32:01 PDT');
diff --git a/src/test/regress/sql/timestamptz.sql b/src/test/regress/sql/timestamptz.sql
index e60bacb9624..71414f198e1 100644
--- a/src/test/regress/sql/timestamptz.sql
+++ b/src/test/regress/sql/timestamptz.sql
@@ -74,9 +74,11 @@ INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01 PST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb-10-1997 17:32:01 PST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('02-10-1997 17:32:01 PST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 PST');
+set datestyle to ymd;
INSERT INTO TIMESTAMPTZ_TBL VALUES ('97FEB10 5:32:01PM UTC');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('97/02/10 17:32:01 UTC');
-INSERT INTO TIMESTAMPTZ_TBL VALUES ('97.041 17:32:01 UTC');
+reset datestyle;
+INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997.041 17:32:01 UTC');
-- Check date conversion and date arithmetic
INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-06-10 18:32:01 PDT');