Commit f2a9e203 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Test for "current" time by comparing against "now".

parent 98462b73
...@@ -36,15 +36,28 @@ one ...@@ -36,15 +36,28 @@ one
1 1
(1 row) (1 row)
QUERY: INSERT INTO DATETIME_TBL VALUES ('current'); QUERY: SELECT 'now'::datetime - 'current'::datetime AS ZeroSecs;
QUERY: BEGIN; zerosecs
QUERY: INSERT INTO DATETIME_TBL VALUES ('now'); --------
@ 0
(1 row)
QUERY: SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'now'::datetime; QUERY: SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'now'::datetime;
one one
--- ---
1 1
(1 row) (1 row)
QUERY: DELETE FROM DATETIME_TBL;
QUERY: INSERT INTO DATETIME_TBL VALUES ('current');
QUERY: BEGIN;
QUERY: INSERT INTO DATETIME_TBL VALUES ('now');
QUERY: SELECT count(*) AS two FROM DATETIME_TBL WHERE d1 = 'now'::datetime;
two
---
2
(1 row)
QUERY: END; QUERY: END;
QUERY: DELETE FROM DATETIME_TBL; QUERY: DELETE FROM DATETIME_TBL;
QUERY: INSERT INTO DATETIME_TBL VALUES ('invalid'); QUERY: INSERT INTO DATETIME_TBL VALUES ('invalid');
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
CREATE TABLE DATETIME_TBL( d1 datetime); CREATE TABLE DATETIME_TBL( d1 datetime);
-- Shorthand values -- Shorthand values
-- Not testable since these are not constant for regression testing. -- Not directly testable since these are not constant for regression testing.
-- So, just try to test parser and hope for the best - tgl 97/04/26 -- So, just try to test parser and hope for the best - tgl 97/04/26
INSERT INTO DATETIME_TBL VALUES ('current'); INSERT INTO DATETIME_TBL VALUES ('current');
INSERT INTO DATETIME_TBL VALUES ('now'); INSERT INTO DATETIME_TBL VALUES ('now');
...@@ -19,10 +19,15 @@ SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'yesterday'::datetime; ...@@ -19,10 +19,15 @@ SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'yesterday'::datetime;
SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'today'::datetime + '1 day'::timespan; SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'today'::datetime + '1 day'::timespan;
SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'today'::datetime - '1 day'::timespan; SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'today'::datetime - '1 day'::timespan;
SELECT 'now'::datetime - 'current'::datetime AS ZeroSecs;
SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'now'::datetime;
DELETE FROM DATETIME_TBL;
-- verify uniform transaction time within transaction block
INSERT INTO DATETIME_TBL VALUES ('current'); INSERT INTO DATETIME_TBL VALUES ('current');
BEGIN; BEGIN;
INSERT INTO DATETIME_TBL VALUES ('now'); INSERT INTO DATETIME_TBL VALUES ('now');
SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'now'::datetime; SELECT count(*) AS two FROM DATETIME_TBL WHERE d1 = 'now'::datetime;
END; END;
DELETE FROM DATETIME_TBL; DELETE FROM DATETIME_TBL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment