summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNeil Conway2007-05-29 04:58:43 +0000
committerNeil Conway2007-05-29 04:58:43 +0000
commit6af04882de5c519d7e49af8e69a031d2b3b46adc (patch)
treeb134e2f4f34897c2b0fe1a663c3d97d17f9f35f9 /src/test
parente78720ff2f93dcb82484a310d86ce9875385bc20 (diff)
Fix a bug in input processing for the "interval" type. Previously,
"microsecond" and "millisecond" units were not considered valid input by themselves, which caused inputs like "1 millisecond" to be rejected erroneously. Update the docs, add regression tests, and backport to 8.2 and 8.1
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/interval.out23
-rw-r--r--src/test/regress/sql/interval.sql11
2 files changed, 34 insertions, 0 deletions
diff --git a/src/test/regress/expected/interval.out b/src/test/regress/expected/interval.out
index f7c35deca1..72a031df5f 100644
--- a/src/test/regress/expected/interval.out
+++ b/src/test/regress/expected/interval.out
@@ -326,3 +326,26 @@ SELECT justify_interval(interval '1 month -1 hour') as "1 month -1 hour";
@ 29 days 23 hours
(1 row)
+-- test fractional second input, and detection of duplicate units
+SET DATESTYLE = 'ISO';
+SELECT '1 millisecond'::interval, '1 microsecond'::interval,
+ '500 seconds 99 milliseconds 51 microseconds'::interval;
+ interval | interval | interval
+--------------+-----------------+-----------------
+ 00:00:00.001 | 00:00:00.000001 | 00:08:20.099051
+(1 row)
+
+SELECT '3 days 5 milliseconds'::interval;
+ interval
+---------------------
+ 3 days 00:00:00.005
+(1 row)
+
+SELECT '1 second 2 seconds'::interval; -- error
+ERROR: invalid input syntax for type interval: "1 second 2 seconds"
+SELECT '10 milliseconds 20 milliseconds'::interval; -- error
+ERROR: invalid input syntax for type interval: "10 milliseconds 20 milliseconds"
+SELECT '5.5 seconds 3 milliseconds'::interval; -- error
+ERROR: invalid input syntax for type interval: "5.5 seconds 3 milliseconds"
+SELECT '1:20:05 5 microseconds'::interval; -- error
+ERROR: invalid input syntax for type interval: "1:20:05 5 microseconds"
diff --git a/src/test/regress/sql/interval.sql b/src/test/regress/sql/interval.sql
index 9b2e62514d..d081bf1ffe 100644
--- a/src/test/regress/sql/interval.sql
+++ b/src/test/regress/sql/interval.sql
@@ -116,3 +116,14 @@ SELECT justify_days(interval '6 months 36 days 5 hours 4 minutes 3 seconds') as
-- test justify_interval()
SELECT justify_interval(interval '1 month -1 hour') as "1 month -1 hour";
+
+-- test fractional second input, and detection of duplicate units
+SET DATESTYLE = 'ISO';
+SELECT '1 millisecond'::interval, '1 microsecond'::interval,
+ '500 seconds 99 milliseconds 51 microseconds'::interval;
+SELECT '3 days 5 milliseconds'::interval;
+
+SELECT '1 second 2 seconds'::interval; -- error
+SELECT '10 milliseconds 20 milliseconds'::interval; -- error
+SELECT '5.5 seconds 3 milliseconds'::interval; -- error
+SELECT '1:20:05 5 microseconds'::interval; -- error \ No newline at end of file