Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf2a9e20

Browse files
author
Thomas G. Lockhart
committed
Test for "current" time by comparing against "now".
1 parent98462b7 commitf2a9e20

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

‎src/test/regress/expected/datetime.out

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,28 @@ one
3636
1
3737
(1 row)
3838

39-
QUERY: INSERT INTO DATETIME_TBL VALUES ('current');
40-
QUERY: BEGIN;
41-
QUERY: INSERT INTO DATETIME_TBL VALUES ('now');
39+
QUERY: SELECT 'now'::datetime - 'current'::datetime AS ZeroSecs;
40+
zerosecs
41+
--------
42+
@ 0
43+
(1 row)
44+
4245
QUERY: SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'now'::datetime;
4346
one
4447
---
4548
1
4649
(1 row)
4750

51+
QUERY: DELETE FROM DATETIME_TBL;
52+
QUERY: INSERT INTO DATETIME_TBL VALUES ('current');
53+
QUERY: BEGIN;
54+
QUERY: INSERT INTO DATETIME_TBL VALUES ('now');
55+
QUERY: SELECT count(*) AS two FROM DATETIME_TBL WHERE d1 = 'now'::datetime;
56+
two
57+
---
58+
2
59+
(1 row)
60+
4861
QUERY: END;
4962
QUERY: DELETE FROM DATETIME_TBL;
5063
QUERY: INSERT INTO DATETIME_TBL VALUES ('invalid');

‎src/test/regress/sql/datetime.sql

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
CREATETABLEDATETIME_TBL( d1 datetime);
44

55
-- Shorthand values
6-
-- Not testable since these are not constant for regression testing.
6+
-- Notdirectlytestable since these are not constant for regression testing.
77
-- So, just try to test parser and hope for the best - tgl 97/04/26
88
INSERT INTO DATETIME_TBLVALUES ('current');
99
INSERT INTO DATETIME_TBLVALUES ('now');
@@ -19,10 +19,15 @@ SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'yesterday'::datetime;
1919
SELECTcount(*)AS oneFROM DATETIME_TBLWHERE d1='today'::datetime+'1 day'::timespan;
2020
SELECTcount(*)AS oneFROM DATETIME_TBLWHERE d1='today'::datetime-'1 day'::timespan;
2121

22+
SELECT'now'::datetime-'current'::datetimeAS ZeroSecs;
23+
SELECTcount(*)AS oneFROM DATETIME_TBLWHERE d1='now'::datetime;
24+
DELETEFROM DATETIME_TBL;
25+
26+
-- verify uniform transaction time within transaction block
2227
INSERT INTO DATETIME_TBLVALUES ('current');
2328
BEGIN;
2429
INSERT INTO DATETIME_TBLVALUES ('now');
25-
SELECTcount(*)ASoneFROM DATETIME_TBLWHERE d1='now'::datetime;
30+
SELECTcount(*)AStwoFROM DATETIME_TBLWHERE d1='now'::datetime;
2631
END;
2732
DELETEFROM DATETIME_TBL;
2833

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp