Skip to content

Commit 2e0976e

Browse files
author
Thomas G. Lockhart
committed
Fix testing problem when 'current' equal to 'now' for separate inserts
on fast machines with fast disks. Adjust a few other tests to be more complete.
1 parent 644b37c commit 2e0976e

File tree

2 files changed

+41
-12
lines changed

2 files changed

+41
-12
lines changed

src/test/regress/expected/datetime.out

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
1+
QUERY: SELECT ('today'::datetime = ('yesterday'::datetime + '1 day'::timespan)) as "True";
2+
True
3+
----
4+
t
5+
(1 row)
6+
7+
QUERY: SELECT ('today'::datetime = ('tomorrow'::datetime - '1 day'::timespan)) as "True";
8+
True
9+
----
10+
t
11+
(1 row)
12+
13+
QUERY: SELECT ('tomorrow'::datetime = ('yesterday'::datetime + '2 days'::timespan)) as "True";
14+
True
15+
----
16+
t
17+
(1 row)
18+
19+
QUERY: SELECT ('current'::datetime = 'now'::datetime) as "True";
20+
True
21+
----
22+
t
23+
(1 row)
24+
25+
QUERY: SELECT ('now'::datetime - 'current'::datetime) AS "ZeroSecs";
26+
ZeroSecs
27+
--------
28+
@ 0
29+
(1 row)
30+
131
QUERY: CREATE TABLE DATETIME_TBL( d1 datetime);
232
QUERY: INSERT INTO DATETIME_TBL VALUES ('current');
3-
QUERY: INSERT INTO DATETIME_TBL VALUES ('now');
433
QUERY: INSERT INTO DATETIME_TBL VALUES ('today');
534
QUERY: INSERT INTO DATETIME_TBL VALUES ('yesterday');
635
QUERY: INSERT INTO DATETIME_TBL VALUES ('tomorrow');
@@ -36,12 +65,6 @@ one
3665
1
3766
(1 row)
3867

39-
QUERY: SELECT 'now'::datetime - 'current'::datetime AS ZeroSecs;
40-
zerosecs
41-
--------
42-
@ 0
43-
(1 row)
44-
4568
QUERY: SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'now'::datetime;
4669
one
4770
---

src/test/regress/sql/datetime.sql

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
-- *** testing new built-in time types: datetime, timespan ***
22

3-
CREATE TABLE DATETIME_TBL( d1 datetime);
4-
53
-- Shorthand values
6-
-- Not directly testable since these are not constant for regression testing.
4+
-- Not directly usable for regression testing since these are not constants.
75
-- So, just try to test parser and hope for the best - tgl 97/04/26
6+
7+
SELECT ('today'::datetime = ('yesterday'::datetime + '1 day'::timespan)) as "True";
8+
SELECT ('today'::datetime = ('tomorrow'::datetime - '1 day'::timespan)) as "True";
9+
SELECT ('tomorrow'::datetime = ('yesterday'::datetime + '2 days'::timespan)) as "True";
10+
SELECT ('current'::datetime = 'now'::datetime) as "True";
11+
SELECT ('now'::datetime - 'current'::datetime) AS "ZeroSecs";
12+
13+
CREATE TABLE DATETIME_TBL( d1 datetime);
14+
815
INSERT INTO DATETIME_TBL VALUES ('current');
9-
INSERT INTO DATETIME_TBL VALUES ('now');
1016
INSERT INTO DATETIME_TBL VALUES ('today');
1117
INSERT INTO DATETIME_TBL VALUES ('yesterday');
1218
INSERT INTO DATETIME_TBL VALUES ('tomorrow');
@@ -19,8 +25,8 @@ SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'yesterday'::datetime;
1925
SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'today'::datetime + '1 day'::timespan;
2026
SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'today'::datetime - '1 day'::timespan;
2127

22-
SELECT 'now'::datetime - 'current'::datetime AS ZeroSecs;
2328
SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'now'::datetime;
29+
2430
DELETE FROM DATETIME_TBL;
2531

2632
-- verify uniform transaction time within transaction block

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy