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

Commit4c4e68d

Browse files
author
Thomas G. Lockhart
committed
Clean up format of tests.
Remove older "::" type coersion syntax in favor of extended SQL92 style.Include a few new tests for datetime/timespan arithmetic.
1 parentd831055 commit4c4e68d

22 files changed

+427
-340
lines changed

‎src/test/regress/sql/abstime.sql

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
-- **** testing built-in time types: abstime, reltime, and tinterval ****
1+
--
2+
-- ABSTIME
3+
-- testing built-in time type abstime
4+
-- uses reltime and tinterval
5+
--
26

37
--
48
-- timezones may vary based not only on location but the operating
@@ -10,18 +14,18 @@ CREATE TABLE ABSTIME_TBL (f1 abstime);
1014

1115
INSERT INTO ABSTIME_TBL (f1)VALUES ('Jan 14, 1973 03:14:21');
1216

13-
-- was INSERT INTO ABSTIME_TBL (f1) VALUES ('now'::abstime):
14-
INSERT INTO ABSTIME_TBL (f1)VALUES ('Mon May 1 00:30:30 1995'::abstime);
17+
-- was INSERT INTO ABSTIME_TBL (f1) VALUES (abstime'now'):
18+
INSERT INTO ABSTIME_TBL (f1)VALUES (abstime'Mon May 1 00:30:30 1995');
1519

16-
INSERT INTO ABSTIME_TBL (f1)VALUES ('epoch'::abstime);
20+
INSERT INTO ABSTIME_TBL (f1)VALUES (abstime'epoch');
1721

18-
INSERT INTO ABSTIME_TBL (f1)VALUES ('current'::abstime);
22+
INSERT INTO ABSTIME_TBL (f1)VALUES (abstime'current');
1923

20-
INSERT INTO ABSTIME_TBL (f1)VALUES ('infinity'::abstime);
24+
INSERT INTO ABSTIME_TBL (f1)VALUES (abstime'infinity');
2125

22-
INSERT INTO ABSTIME_TBL (f1)VALUES ('-infinity'::abstime);
26+
INSERT INTO ABSTIME_TBL (f1)VALUES (abstime'-infinity');
2327

24-
INSERT INTO ABSTIME_TBL (f1)VALUES ('May 10, 1947 23:59:12');
28+
INSERT INTO ABSTIME_TBL (f1)VALUES (abstime'May 10, 1947 23:59:12');
2529

2630

2731
-- what happens if we specify slightly misformatted abstime?
@@ -40,48 +44,48 @@ INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843');
4044
SELECT''AS eight, ABSTIME_TBL.*;
4145

4246
SELECT''AS six, ABSTIME_TBL.*
43-
WHEREABSTIME_TBL.f1<'Jun 30, 2001'::abstime;
47+
WHEREABSTIME_TBL.f1<abstime'Jun 30, 2001';
4448

4549
SELECT''AS six, ABSTIME_TBL.*
46-
WHEREABSTIME_TBL.f1>'-infinity'::abstime;
50+
WHEREABSTIME_TBL.f1>abstime'-infinity';
4751

4852
SELECT''AS six, ABSTIME_TBL.*
49-
WHERE'May 10, 1947 23:59:12'::abstime<>ABSTIME_TBL.f1;
53+
WHEREabstime'May 10, 1947 23:59:12'<>ABSTIME_TBL.f1;
5054

5155
SELECT''AS one, ABSTIME_TBL.*
52-
WHERE'current'::abstime=ABSTIME_TBL.f1;
56+
WHEREabstime'current'=ABSTIME_TBL.f1;
5357

5458
SELECT''AS three, ABSTIME_TBL.*
55-
WHERE'epoch'::abstime>=ABSTIME_TBL.f1;
59+
WHEREabstime'epoch'>=ABSTIME_TBL.f1;
5660

5761
SELECT''AS four, ABSTIME_TBL.*
58-
WHEREABSTIME_TBL.f1<='Jan 14, 1973 03:14:21'::abstime;
62+
WHEREABSTIME_TBL.f1<=abstime'Jan 14, 1973 03:14:21';
5963

6064
SELECT''AS four, ABSTIME_TBL.*
6165
WHEREABSTIME_TBL.f1<?>
62-
'["Apr 1 1950 00:00:00" "Dec 30 1999 23:00:00"]'::tinterval;
66+
tinterval'["Apr 1 1950 00:00:00" "Dec 30 1999 23:00:00"]';
6367

6468
-- these four queries should return the same answer
6569
-- the "infinity" and "-infinity" tuples in ABSTIME_TBL cannot be added and
6670
-- therefore, should not show up in the results.
6771
SELECT''AS three, ABSTIME_TBL.*
68-
WHERE (ABSTIME_TBL.f1+'@ 3 year'::reltime)-- +3 years
69-
<'Jan 14 14:00:00 1977'::abstime;
72+
WHERE (ABSTIME_TBL.f1+reltime'@ 3 year')-- +3 years
73+
<abstime'Jan 14 14:00:00 1977';
7074

7175
SELECT''AS three, ABSTIME_TBL.*
72-
WHERE (ABSTIME_TBL.f1+'@ 3 year ago'::reltime)-- -3 years
73-
<'Jan 14 14:00:00 1971'::abstime;
76+
WHERE (ABSTIME_TBL.f1+reltime'@ 3 year ago')-- -3 years
77+
<abstime'Jan 14 14:00:00 1971';
7478

7579
SELECT''AS three, ABSTIME_TBL.*
76-
WHERE (ABSTIME_TBL.f1-'@ 3 year'::reltime)-- -(+3) years
77-
<'Jan 14 14:00:00 1971'::abstime;
80+
WHERE (ABSTIME_TBL.f1-reltime'@ 3 year')-- -(+3) years
81+
<abstime'Jan 14 14:00:00 1971';
7882

7983
SELECT''AS three, ABSTIME_TBL.*
80-
WHERE (ABSTIME_TBL.f1-'@ 3 year ago'::reltime)-- -(-3) years
81-
<'Jan 14 14:00:00 1977'::abstime;
84+
WHERE (ABSTIME_TBL.f1-reltime'@ 3 year ago')-- -(-3) years
85+
<abstime'Jan 14 14:00:00 1977';
8286

8387
SELECT''AS ten,ABSTIME_TBL.f1AS abstime,RELTIME_TBL.f1AS reltime
8488
WHERE (ABSTIME_TBL.f1+RELTIME_TBL.f1)
85-
<'Jan 14 14:00:00 1971'::abstime
89+
<abstime'Jan 14 14:00:00 1971'
8690
ORDER BY abstime, reltime;
8791

‎src/test/regress/sql/box.sql

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
-- ****************** test built-in type box ********************
1+
--
2+
-- BOX
3+
--
24

35
--
46
-- box logic
@@ -43,67 +45,67 @@ SELECT '' AS four, b.*, box_area(b.f1) as barea
4345
-- overlap
4446
SELECT''AS three,b.f1
4547
FROM BOX_TBL b
46-
WHEREb.f1 &&'(2.5,2.5,1.0,1.0)'::box;
48+
WHEREb.f1 &&box'(2.5,2.5,1.0,1.0)';
4749

4850
-- left-or-overlap (x only)
4951
SELECT''AS two, b1.*
5052
FROM BOX_TBL b1
51-
WHEREb1.f1 &<'(2.0,2.0,2.5,2.5)'::box;
53+
WHEREb1.f1 &<box'(2.0,2.0,2.5,2.5)';
5254

5355
-- right-or-overlap (x only)
5456
SELECT''AS two, b1.*
5557
FROM BOX_TBL b1
56-
WHEREb1.f1 &>'(2.0,2.0,2.5,2.5)'::box;
58+
WHEREb1.f1 &>box'(2.0,2.0,2.5,2.5)';
5759

5860
-- left of
5961
SELECT''AS two,b.f1
6062
FROM BOX_TBL b
61-
WHEREb.f1<<'(3.0,3.0,5.0,5.0)'::box;
63+
WHEREb.f1<<box'(3.0,3.0,5.0,5.0)';
6264

6365
-- area <=
6466
SELECT''AS four,b.f1
6567
FROM BOX_TBL b
66-
WHEREb.f1<='(3.0,3.0,5.0,5.0)'::box;
68+
WHEREb.f1<=box'(3.0,3.0,5.0,5.0)';
6769

6870
-- area <
6971
SELECT''AS two,b.f1
7072
FROM BOX_TBL b
71-
WHEREb.f1<'(3.0,3.0,5.0,5.0)'::box;
73+
WHEREb.f1<box'(3.0,3.0,5.0,5.0)';
7274

7375
-- area =
7476
SELECT''AS two,b.f1
7577
FROM BOX_TBL b
76-
WHEREb.f1='(3.0,3.0,5.0,5.0)'::box;
78+
WHEREb.f1=box'(3.0,3.0,5.0,5.0)';
7779

7880
-- area >
7981
SELECT''AS two,b.f1
8082
FROM BOX_TBL b-- zero area
81-
WHEREb.f1>'(3.5,3.0,4.5,3.0)'::box;
83+
WHEREb.f1>box'(3.5,3.0,4.5,3.0)';
8284

8385
-- area >=
8486
SELECT''AS four,b.f1
8587
FROM BOX_TBL b-- zero area
86-
WHEREb.f1>='(3.5,3.0,4.5,3.0)'::box;
88+
WHEREb.f1>=box'(3.5,3.0,4.5,3.0)';
8789

8890
-- right of
8991
SELECT''AS two,b.f1
9092
FROM BOX_TBL b
91-
WHERE'(3.0,3.0,5.0,5.0)'::box>>b.f1;
93+
WHEREbox'(3.0,3.0,5.0,5.0)'>>b.f1;
9294

9395
-- contained in
9496
SELECT''AS three,b.f1
9597
FROM BOX_TBL b
96-
WHEREb.f1 @'(0,0,3,3)'::box;
98+
WHEREb.f1 @box'(0,0,3,3)';
9799

98100
-- contains
99101
SELECT''AS three,b.f1
100102
FROM BOX_TBL b
101-
WHERE'(0,0,3,3)'::box ~b.f1;
103+
WHEREbox'(0,0,3,3)' ~b.f1;
102104

103105
-- box equality
104106
SELECT''AS one,b.f1
105107
FROM BOX_TBL b
106-
WHERE'(1,1,3,3)'::box ~=b.f1;
108+
WHEREbox'(1,1,3,3)' ~=b.f1;
107109

108110
-- center of box, left unary operator
109111
SELECT''AS four, @@(b1.f1)AS p

‎src/test/regress/sql/circle.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--
2-
--circles
2+
--CIRCLE
33
--
44

55
CREATETABLECIRCLE_TBL (f1circle);

‎src/test/regress/sql/comments.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--
2-
--Comments
2+
--COMMENTS
33
--
44

55
SELECT'trailing'AS first;-- trailing single line

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

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
-- *** testing new built-in time types: datetime, timespan ***
1+
--
2+
-- DATETIME
3+
--
24

35
-- Shorthand values
46
-- Not directly usable for regression testing since these are not constants.
57
-- So, just try to test parser and hope for the best - tgl 97/04/26
68

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";
9+
SELECT (datetime'today'= (datetime'yesterday'+timespan'1 day'))as"True";
10+
SELECT (datetime'today'= (datetime'tomorrow'-timespan'1 day'))as"True";
11+
SELECT (datetime'tomorrow'= (datetime'yesterday'+timespan'2 days'))as"True";
12+
SELECT (datetime'current'='now')as"True";
13+
SELECT (datetime'now'-'current')AS"ZeroSecs";
1214

1315
SET DateStyle='Postgres,noneuropean';
1416
SELECT datetime('1994-01-01','11:00')AS"Jan_01_1994_11am";
@@ -22,21 +24,21 @@ INSERT INTO DATETIME_TBL VALUES ('tomorrow');
2224
INSERT INTO DATETIME_TBLVALUES ('tomorrow EST');
2325
INSERT INTO DATETIME_TBLVALUES ('tomorrow zulu');
2426

25-
SELECTcount(*)AS oneFROM DATETIME_TBLWHERE d1='today'::datetime;
26-
SELECTcount(*)AS oneFROM DATETIME_TBLWHERE d1='tomorrow'::datetime;
27-
SELECTcount(*)AS oneFROM DATETIME_TBLWHERE d1='yesterday'::datetime;
28-
SELECTcount(*)AS oneFROM DATETIME_TBLWHERE d1='today'::datetime+'1 day'::timespan;
29-
SELECTcount(*)AS oneFROM DATETIME_TBLWHERE d1='today'::datetime-'1 day'::timespan;
27+
SELECTcount(*)AS oneFROM DATETIME_TBLWHERE d1=datetime'today';
28+
SELECTcount(*)AS oneFROM DATETIME_TBLWHERE d1=datetime'tomorrow';
29+
SELECTcount(*)AS oneFROM DATETIME_TBLWHERE d1=datetime'yesterday';
30+
SELECTcount(*)AS oneFROM DATETIME_TBLWHERE d1=datetime'today'+timespan'1 day';
31+
SELECTcount(*)AS oneFROM DATETIME_TBLWHERE d1=datetime'today'-timespan'1 day';
3032

31-
SELECTcount(*)AS oneFROM DATETIME_TBLWHERE d1='now'::datetime;
33+
SELECTcount(*)AS oneFROM DATETIME_TBLWHERE d1=datetime'now';
3234

3335
DELETEFROM DATETIME_TBL;
3436

3537
-- verify uniform transaction time within transaction block
3638
INSERT INTO DATETIME_TBLVALUES ('current');
3739
BEGIN;
3840
INSERT INTO DATETIME_TBLVALUES ('now');
39-
SELECTcount(*)AS twoFROM DATETIME_TBLWHERE d1='now'::datetime;
41+
SELECTcount(*)AS twoFROM DATETIME_TBLWHERE d1=datetime'now';
4042
END;
4143
DELETEFROM DATETIME_TBL;
4244

@@ -125,31 +127,31 @@ SELECT '' AS sixtythree, d1 FROM DATETIME_TBL;
125127

126128
-- Demonstrate functions and operators
127129
SELECT''AS fortythree, d1FROM DATETIME_TBL
128-
WHERE d1>'1997-01-02'::datetimeand d1!='current'::datetime;
130+
WHERE d1>datetime'1997-01-02'and d1!=datetime'current';
129131

130132
SELECT''AS fifteen, d1FROM DATETIME_TBL
131-
WHERE d1<'1997-01-02'::datetimeand d1!='current'::datetime;
133+
WHERE d1<datetime'1997-01-02'and d1!=datetime'current';
132134

133135
SELECT''AS one, d1FROM DATETIME_TBL
134-
WHERE d1='1997-01-02'::datetimeand d1!='current'::datetime;
136+
WHERE d1=datetime'1997-01-02'and d1!=datetime'current';
135137

136138
SELECT''AS fiftyeight, d1FROM DATETIME_TBL
137-
WHERE d1!='1997-01-02'::datetimeand d1!='current'::datetime;
139+
WHERE d1!=datetime'1997-01-02'and d1!=datetime'current';
138140

139141
SELECT''AS sixteen, d1FROM DATETIME_TBL
140-
WHERE d1<='1997-01-02'::datetimeand d1!='current'::datetime;
142+
WHERE d1<=datetime'1997-01-02'and d1!=datetime'current';
141143

142144
SELECT''AS fortyfour, d1FROM DATETIME_TBL
143-
WHERE d1>='1997-01-02'::datetimeand d1!='current'::datetime;
145+
WHERE d1>=datetime'1997-01-02'and d1!=datetime'current';
144146

145-
SELECT''AS sixtythree, d1+'1 year'::timespanAS one_yearFROM DATETIME_TBL;
147+
SELECT''AS sixtythree, d1+timespan'1 year'AS one_yearFROM DATETIME_TBL;
146148

147-
SELECT''AS sixtythree, d1-'1 year'::timespanAS one_yearFROM DATETIME_TBL;
149+
SELECT''AS sixtythree, d1-timespan'1 year'AS one_yearFROM DATETIME_TBL;
148150

149151
-- Casting within a BETWEEN qualifier should probably be allowed by the parser. - tgl 97/04/26
150-
--SELECT '' AS fifty, d1 - '1997-01-02'::datetime AS diff
151-
-- FROM DATETIME_TBL WHERE d1 BETWEEN '1902-01-01'::datetime AND '2038-01-01'::datetime;
152-
SELECT''AS fifty, d1-'1997-01-02'::datetimeAS diff
152+
--SELECT '' AS fifty, d1 -datetime'1997-01-02' AS diff
153+
-- FROM DATETIME_TBL WHERE d1 BETWEENdatetime'1902-01-01' ANDdatetime'2038-01-01';
154+
SELECT''AS fifty, d1-datetime'1997-01-02'AS diff
153155
FROM DATETIME_TBLWHERE d1 BETWEEN'1902-01-01'AND'2038-01-01';
154156

155157
SELECT''AS fortynine, date_part('year', d1)AS year, date_part('month', d1)AS month,

‎src/test/regress/sql/geometry.sql

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
--
2+
-- GEOMETRY
3+
--
4+
15
--
26
-- Points
37
--
@@ -21,22 +25,22 @@ SELECT '' AS two, (@@ f1) AS center
2125
-- "is horizontal" function
2226
SELECT''AS two,p1.f1
2327
FROM POINT_TBL p1
24-
WHERE ishorizontal(p1.f1,'(0,0)'::point);
28+
WHERE ishorizontal(p1.f1,point'(0,0)');
2529

2630
-- "is horizontal" operator
2731
SELECT''AS two,p1.f1
2832
FROM POINT_TBL p1
29-
WHEREp1.f1 ?-'(0,0)'::point;
33+
WHEREp1.f1 ?-point'(0,0)';
3034

3135
-- "is vertical" function
3236
SELECT''AS one,p1.f1
3337
FROM POINT_TBL p1
34-
WHERE isvertical(p1.f1,'(5.1,34.5)'::point);
38+
WHERE isvertical(p1.f1,point'(5.1,34.5)');
3539

3640
-- "is vertical" operator
3741
SELECT''AS one,p1.f1
3842
FROM POINT_TBL p1
39-
WHEREp1.f1 ?|'(5.1,34.5)'::point;
43+
WHEREp1.f1 ?|point'(5.1,34.5)';
4044

4145
--
4246
-- Line segments
@@ -73,7 +77,7 @@ SELECT '' AS twentyfour, b.f1 * p.f1 AS rotation
7377

7478
SELECT''AS twenty,b.f1/p.f1AS rotation
7579
FROM BOX_TBL b, POINT_TBL p
76-
WHERE (p.f1<->'(0,0)'::point)>=1;
80+
WHERE (p.f1<->point'(0,0)')>=1;
7781

7882
--
7983
-- Paths
@@ -86,11 +90,11 @@ SELECT '' AS eight, points(f1) AS npoints, f1 AS path FROM PATH_TBL;
8690
SELECT''AS four,path(f1)FROM POLYGON_TBL;
8791

8892
-- translation
89-
SELECT''AS eight,p1.f1+'(10,10)'::pointAS dist_add
93+
SELECT''AS eight,p1.f1+point'(10,10)'AS dist_add
9094
FROM PATH_TBL p1;
9195

9296
-- scaling and rotation
93-
SELECT''AS eight,p1.f1*'(2,-1)'::pointAS dist_mul
97+
SELECT''AS eight,p1.f1*point'(2,-1)'AS dist_mul
9498
FROM PATH_TBL p1;
9599

96100
RESET geqo;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp