Commit 4c4e68dc authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

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.
parent d8310553
-- **** testing built-in time types: abstime, reltime, and tinterval **** --
-- ABSTIME
-- testing built-in time type abstime
-- uses reltime and tinterval
--
-- --
-- timezones may vary based not only on location but the operating -- timezones may vary based not only on location but the operating
...@@ -10,18 +14,18 @@ CREATE TABLE ABSTIME_TBL (f1 abstime); ...@@ -10,18 +14,18 @@ CREATE TABLE ABSTIME_TBL (f1 abstime);
INSERT INTO ABSTIME_TBL (f1) VALUES ('Jan 14, 1973 03:14:21'); INSERT INTO ABSTIME_TBL (f1) VALUES ('Jan 14, 1973 03:14:21');
-- was INSERT INTO ABSTIME_TBL (f1) VALUES ('now'::abstime): -- was INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'now'):
INSERT INTO ABSTIME_TBL (f1) VALUES ('Mon May 1 00:30:30 1995'::abstime); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'Mon May 1 00:30:30 1995');
INSERT INTO ABSTIME_TBL (f1) VALUES ('epoch'::abstime); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'epoch');
INSERT INTO ABSTIME_TBL (f1) VALUES ('current'::abstime); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'current');
INSERT INTO ABSTIME_TBL (f1) VALUES ('infinity'::abstime); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'infinity');
INSERT INTO ABSTIME_TBL (f1) VALUES ('-infinity'::abstime); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity');
INSERT INTO ABSTIME_TBL (f1) VALUES ('May 10, 1947 23:59:12'); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
-- what happens if we specify slightly misformatted abstime? -- what happens if we specify slightly misformatted abstime?
...@@ -40,48 +44,48 @@ INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843'); ...@@ -40,48 +44,48 @@ INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843');
SELECT '' AS eight, ABSTIME_TBL.*; SELECT '' AS eight, ABSTIME_TBL.*;
SELECT '' AS six, ABSTIME_TBL.* SELECT '' AS six, ABSTIME_TBL.*
WHERE ABSTIME_TBL.f1 < 'Jun 30, 2001'::abstime; WHERE ABSTIME_TBL.f1 < abstime 'Jun 30, 2001';
SELECT '' AS six, ABSTIME_TBL.* SELECT '' AS six, ABSTIME_TBL.*
WHERE ABSTIME_TBL.f1 > '-infinity'::abstime; WHERE ABSTIME_TBL.f1 > abstime '-infinity';
SELECT '' AS six, ABSTIME_TBL.* SELECT '' AS six, ABSTIME_TBL.*
WHERE 'May 10, 1947 23:59:12'::abstime <> ABSTIME_TBL.f1; WHERE abstime 'May 10, 1947 23:59:12' <> ABSTIME_TBL.f1;
SELECT '' AS one, ABSTIME_TBL.* SELECT '' AS one, ABSTIME_TBL.*
WHERE 'current'::abstime = ABSTIME_TBL.f1; WHERE abstime 'current' = ABSTIME_TBL.f1;
SELECT '' AS three, ABSTIME_TBL.* SELECT '' AS three, ABSTIME_TBL.*
WHERE 'epoch'::abstime >= ABSTIME_TBL.f1; WHERE abstime 'epoch' >= ABSTIME_TBL.f1;
SELECT '' AS four, ABSTIME_TBL.* SELECT '' AS four, ABSTIME_TBL.*
WHERE ABSTIME_TBL.f1 <= 'Jan 14, 1973 03:14:21'::abstime; WHERE ABSTIME_TBL.f1 <= abstime 'Jan 14, 1973 03:14:21';
SELECT '' AS four, ABSTIME_TBL.* SELECT '' AS four, ABSTIME_TBL.*
WHERE ABSTIME_TBL.f1 <?> WHERE ABSTIME_TBL.f1 <?>
'["Apr 1 1950 00:00:00" "Dec 30 1999 23:00:00"]'::tinterval; tinterval '["Apr 1 1950 00:00:00" "Dec 30 1999 23:00:00"]';
-- these four queries should return the same answer -- these four queries should return the same answer
-- the "infinity" and "-infinity" tuples in ABSTIME_TBL cannot be added and -- the "infinity" and "-infinity" tuples in ABSTIME_TBL cannot be added and
-- therefore, should not show up in the results. -- therefore, should not show up in the results.
SELECT '' AS three, ABSTIME_TBL.* SELECT '' AS three, ABSTIME_TBL.*
WHERE (ABSTIME_TBL.f1 + '@ 3 year'::reltime) -- +3 years WHERE (ABSTIME_TBL.f1 + reltime '@ 3 year') -- +3 years
< 'Jan 14 14:00:00 1977'::abstime; < abstime 'Jan 14 14:00:00 1977';
SELECT '' AS three, ABSTIME_TBL.* SELECT '' AS three, ABSTIME_TBL.*
WHERE (ABSTIME_TBL.f1 + '@ 3 year ago'::reltime) -- -3 years WHERE (ABSTIME_TBL.f1 + reltime '@ 3 year ago') -- -3 years
< 'Jan 14 14:00:00 1971'::abstime; < abstime 'Jan 14 14:00:00 1971';
SELECT '' AS three, ABSTIME_TBL.* SELECT '' AS three, ABSTIME_TBL.*
WHERE (ABSTIME_TBL.f1 - '@ 3 year'::reltime) -- -(+3) years WHERE (ABSTIME_TBL.f1 - reltime '@ 3 year') -- -(+3) years
< 'Jan 14 14:00:00 1971'::abstime; < abstime 'Jan 14 14:00:00 1971';
SELECT '' AS three, ABSTIME_TBL.* SELECT '' AS three, ABSTIME_TBL.*
WHERE (ABSTIME_TBL.f1 - '@ 3 year ago'::reltime) -- -(-3) years WHERE (ABSTIME_TBL.f1 - reltime '@ 3 year ago') -- -(-3) years
< 'Jan 14 14:00:00 1977'::abstime; < abstime 'Jan 14 14:00:00 1977';
SELECT '' AS ten, ABSTIME_TBL.f1 AS abstime, RELTIME_TBL.f1 AS reltime SELECT '' AS ten, ABSTIME_TBL.f1 AS abstime, RELTIME_TBL.f1 AS reltime
WHERE (ABSTIME_TBL.f1 + RELTIME_TBL.f1) WHERE (ABSTIME_TBL.f1 + RELTIME_TBL.f1)
< 'Jan 14 14:00:00 1971'::abstime < abstime 'Jan 14 14:00:00 1971'
ORDER BY abstime, reltime; ORDER BY abstime, reltime;
-- ****************** test built-in type box ******************** --
-- BOX
--
-- --
-- box logic -- box logic
...@@ -43,67 +45,67 @@ SELECT '' AS four, b.*, box_area(b.f1) as barea ...@@ -43,67 +45,67 @@ SELECT '' AS four, b.*, box_area(b.f1) as barea
-- overlap -- overlap
SELECT '' AS three, b.f1 SELECT '' AS three, b.f1
FROM BOX_TBL b FROM BOX_TBL b
WHERE b.f1 && '(2.5,2.5,1.0,1.0)'::box; WHERE b.f1 && box '(2.5,2.5,1.0,1.0)';
-- left-or-overlap (x only) -- left-or-overlap (x only)
SELECT '' AS two, b1.* SELECT '' AS two, b1.*
FROM BOX_TBL b1 FROM BOX_TBL b1
WHERE b1.f1 &< '(2.0,2.0,2.5,2.5)'::box; WHERE b1.f1 &< box '(2.0,2.0,2.5,2.5)';
-- right-or-overlap (x only) -- right-or-overlap (x only)
SELECT '' AS two, b1.* SELECT '' AS two, b1.*
FROM BOX_TBL b1 FROM BOX_TBL b1
WHERE b1.f1 &> '(2.0,2.0,2.5,2.5)'::box; WHERE b1.f1 &> box '(2.0,2.0,2.5,2.5)';
-- left of -- left of
SELECT '' AS two, b.f1 SELECT '' AS two, b.f1
FROM BOX_TBL b FROM BOX_TBL b
WHERE b.f1 << '(3.0,3.0,5.0,5.0)'::box; WHERE b.f1 << box '(3.0,3.0,5.0,5.0)';
-- area <= -- area <=
SELECT '' AS four, b.f1 SELECT '' AS four, b.f1
FROM BOX_TBL b FROM BOX_TBL b
WHERE b.f1 <= '(3.0,3.0,5.0,5.0)'::box; WHERE b.f1 <= box '(3.0,3.0,5.0,5.0)';
-- area < -- area <
SELECT '' AS two, b.f1 SELECT '' AS two, b.f1
FROM BOX_TBL b FROM BOX_TBL b
WHERE b.f1 < '(3.0,3.0,5.0,5.0)'::box; WHERE b.f1 < box '(3.0,3.0,5.0,5.0)';
-- area = -- area =
SELECT '' AS two, b.f1 SELECT '' AS two, b.f1
FROM BOX_TBL b FROM BOX_TBL b
WHERE b.f1 = '(3.0,3.0,5.0,5.0)'::box; WHERE b.f1 = box '(3.0,3.0,5.0,5.0)';
-- area > -- area >
SELECT '' AS two, b.f1 SELECT '' AS two, b.f1
FROM BOX_TBL b -- zero area FROM BOX_TBL b -- zero area
WHERE b.f1 > '(3.5,3.0,4.5,3.0)'::box; WHERE b.f1 > box '(3.5,3.0,4.5,3.0)';
-- area >= -- area >=
SELECT '' AS four, b.f1 SELECT '' AS four, b.f1
FROM BOX_TBL b -- zero area FROM BOX_TBL b -- zero area
WHERE b.f1 >= '(3.5,3.0,4.5,3.0)'::box; WHERE b.f1 >= box '(3.5,3.0,4.5,3.0)';
-- right of -- right of
SELECT '' AS two, b.f1 SELECT '' AS two, b.f1
FROM BOX_TBL b FROM BOX_TBL b
WHERE '(3.0,3.0,5.0,5.0)'::box >> b.f1; WHERE box '(3.0,3.0,5.0,5.0)' >> b.f1;
-- contained in -- contained in
SELECT '' AS three, b.f1 SELECT '' AS three, b.f1
FROM BOX_TBL b FROM BOX_TBL b
WHERE b.f1 @ '(0,0,3,3)'::box; WHERE b.f1 @ box '(0,0,3,3)';
-- contains -- contains
SELECT '' AS three, b.f1 SELECT '' AS three, b.f1
FROM BOX_TBL b FROM BOX_TBL b
WHERE '(0,0,3,3)'::box ~ b.f1; WHERE box '(0,0,3,3)' ~ b.f1;
-- box equality -- box equality
SELECT '' AS one, b.f1 SELECT '' AS one, b.f1
FROM BOX_TBL b FROM BOX_TBL b
WHERE '(1,1,3,3)'::box ~= b.f1; WHERE box '(1,1,3,3)' ~= b.f1;
-- center of box, left unary operator -- center of box, left unary operator
SELECT '' AS four, @@(b1.f1) AS p SELECT '' AS four, @@(b1.f1) AS p
......
-- --
-- circles -- CIRCLE
-- --
CREATE TABLE CIRCLE_TBL (f1 circle); CREATE TABLE CIRCLE_TBL (f1 circle);
......
-- --
-- Comments -- COMMENTS
-- --
SELECT 'trailing' AS first; -- trailing single line SELECT 'trailing' AS first; -- trailing single line
......
-- *** testing new built-in time types: datetime, timespan *** --
-- DATETIME
--
-- Shorthand values -- Shorthand values
-- Not directly usable for regression testing since these are not constants. -- Not directly usable for regression testing since these are not constants.
-- 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
SELECT ('today'::datetime = ('yesterday'::datetime + '1 day'::timespan)) as "True"; SELECT (datetime 'today' = (datetime 'yesterday' + timespan '1 day')) as "True";
SELECT ('today'::datetime = ('tomorrow'::datetime - '1 day'::timespan)) as "True"; SELECT (datetime 'today' = (datetime 'tomorrow' - timespan '1 day')) as "True";
SELECT ('tomorrow'::datetime = ('yesterday'::datetime + '2 days'::timespan)) as "True"; SELECT (datetime 'tomorrow' = (datetime 'yesterday' + timespan '2 days')) as "True";
SELECT ('current'::datetime = 'now'::datetime) as "True"; SELECT (datetime 'current' = 'now') as "True";
SELECT ('now'::datetime - 'current'::datetime) AS "ZeroSecs"; SELECT (datetime 'now' - 'current') AS "ZeroSecs";
SET DateStyle = 'Postgres,noneuropean'; SET DateStyle = 'Postgres,noneuropean';
SELECT datetime('1994-01-01', '11:00') AS "Jan_01_1994_11am"; SELECT datetime('1994-01-01', '11:00') AS "Jan_01_1994_11am";
...@@ -22,13 +24,13 @@ INSERT INTO DATETIME_TBL VALUES ('tomorrow'); ...@@ -22,13 +24,13 @@ INSERT INTO DATETIME_TBL VALUES ('tomorrow');
INSERT INTO DATETIME_TBL VALUES ('tomorrow EST'); INSERT INTO DATETIME_TBL VALUES ('tomorrow EST');
INSERT INTO DATETIME_TBL VALUES ('tomorrow zulu'); INSERT INTO DATETIME_TBL VALUES ('tomorrow zulu');
SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'today'::datetime; SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = datetime 'today';
SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'tomorrow'::datetime; SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = datetime 'tomorrow';
SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'yesterday'::datetime; SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = datetime 'yesterday';
SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'today'::datetime + '1 day'::timespan; SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = datetime 'today' + timespan '1 day';
SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'today'::datetime - '1 day'::timespan; SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = datetime 'today' - timespan '1 day';
SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = 'now'::datetime; SELECT count(*) AS one FROM DATETIME_TBL WHERE d1 = datetime 'now';
DELETE FROM DATETIME_TBL; DELETE FROM DATETIME_TBL;
...@@ -36,7 +38,7 @@ DELETE FROM DATETIME_TBL; ...@@ -36,7 +38,7 @@ DELETE FROM DATETIME_TBL;
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 two FROM DATETIME_TBL WHERE d1 = 'now'::datetime; SELECT count(*) AS two FROM DATETIME_TBL WHERE d1 = datetime 'now';
END; END;
DELETE FROM DATETIME_TBL; DELETE FROM DATETIME_TBL;
...@@ -125,31 +127,31 @@ SELECT '' AS sixtythree, d1 FROM DATETIME_TBL; ...@@ -125,31 +127,31 @@ SELECT '' AS sixtythree, d1 FROM DATETIME_TBL;
-- Demonstrate functions and operators -- Demonstrate functions and operators
SELECT '' AS fortythree, d1 FROM DATETIME_TBL SELECT '' AS fortythree, d1 FROM DATETIME_TBL
WHERE d1 > '1997-01-02'::datetime and d1 != 'current'::datetime; WHERE d1 > datetime '1997-01-02' and d1 != datetime 'current';
SELECT '' AS fifteen, d1 FROM DATETIME_TBL SELECT '' AS fifteen, d1 FROM DATETIME_TBL
WHERE d1 < '1997-01-02'::datetime and d1 != 'current'::datetime; WHERE d1 < datetime '1997-01-02' and d1 != datetime 'current';
SELECT '' AS one, d1 FROM DATETIME_TBL SELECT '' AS one, d1 FROM DATETIME_TBL
WHERE d1 = '1997-01-02'::datetime and d1 != 'current'::datetime; WHERE d1 = datetime '1997-01-02' and d1 != datetime 'current';
SELECT '' AS fiftyeight, d1 FROM DATETIME_TBL SELECT '' AS fiftyeight, d1 FROM DATETIME_TBL
WHERE d1 != '1997-01-02'::datetime and d1 != 'current'::datetime; WHERE d1 != datetime '1997-01-02' and d1 != datetime 'current';
SELECT '' AS sixteen, d1 FROM DATETIME_TBL SELECT '' AS sixteen, d1 FROM DATETIME_TBL
WHERE d1 <= '1997-01-02'::datetime and d1 != 'current'::datetime; WHERE d1 <= datetime '1997-01-02' and d1 != datetime 'current';
SELECT '' AS fortyfour, d1 FROM DATETIME_TBL SELECT '' AS fortyfour, d1 FROM DATETIME_TBL
WHERE d1 >= '1997-01-02'::datetime and d1 != 'current'::datetime; WHERE d1 >= datetime '1997-01-02' and d1 != datetime 'current';
SELECT '' AS sixtythree, d1 + '1 year'::timespan AS one_year FROM DATETIME_TBL; SELECT '' AS sixtythree, d1 + timespan '1 year' AS one_year FROM DATETIME_TBL;
SELECT '' AS sixtythree, d1 - '1 year'::timespan AS one_year FROM DATETIME_TBL; SELECT '' AS sixtythree, d1 - timespan '1 year' AS one_year FROM DATETIME_TBL;
-- Casting within a BETWEEN qualifier should probably be allowed by the parser. - tgl 97/04/26 -- Casting within a BETWEEN qualifier should probably be allowed by the parser. - tgl 97/04/26
--SELECT '' AS fifty, d1 - '1997-01-02'::datetime AS diff --SELECT '' AS fifty, d1 - datetime '1997-01-02' AS diff
-- FROM DATETIME_TBL WHERE d1 BETWEEN '1902-01-01'::datetime AND '2038-01-01'::datetime; -- FROM DATETIME_TBL WHERE d1 BETWEEN datetime '1902-01-01' AND datetime '2038-01-01';
SELECT '' AS fifty, d1 - '1997-01-02'::datetime AS diff SELECT '' AS fifty, d1 - datetime '1997-01-02' AS diff
FROM DATETIME_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01'; FROM DATETIME_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
SELECT '' AS fortynine, date_part( 'year', d1) AS year, date_part( 'month', d1) AS month, SELECT '' AS fortynine, date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
......
--
-- GEOMETRY
--
-- --
-- Points -- Points
-- --
...@@ -21,22 +25,22 @@ SELECT '' AS two, (@@ f1) AS center ...@@ -21,22 +25,22 @@ SELECT '' AS two, (@@ f1) AS center
-- "is horizontal" function -- "is horizontal" function
SELECT '' AS two, p1.f1 SELECT '' AS two, p1.f1
FROM POINT_TBL p1 FROM POINT_TBL p1
WHERE ishorizontal(p1.f1, '(0,0)'::point); WHERE ishorizontal(p1.f1, point '(0,0)');
-- "is horizontal" operator -- "is horizontal" operator
SELECT '' AS two, p1.f1 SELECT '' AS two, p1.f1
FROM POINT_TBL p1 FROM POINT_TBL p1
WHERE p1.f1 ?- '(0,0)'::point; WHERE p1.f1 ?- point '(0,0)';
-- "is vertical" function -- "is vertical" function
SELECT '' AS one, p1.f1 SELECT '' AS one, p1.f1
FROM POINT_TBL p1 FROM POINT_TBL p1
WHERE isvertical(p1.f1, '(5.1,34.5)'::point); WHERE isvertical(p1.f1, point '(5.1,34.5)');
-- "is vertical" operator -- "is vertical" operator
SELECT '' AS one, p1.f1 SELECT '' AS one, p1.f1
FROM POINT_TBL p1 FROM POINT_TBL p1
WHERE p1.f1 ?| '(5.1,34.5)'::point; WHERE p1.f1 ?| point '(5.1,34.5)';
-- --
-- Line segments -- Line segments
...@@ -73,7 +77,7 @@ SELECT '' AS twentyfour, b.f1 * p.f1 AS rotation ...@@ -73,7 +77,7 @@ SELECT '' AS twentyfour, b.f1 * p.f1 AS rotation
SELECT '' AS twenty, b.f1 / p.f1 AS rotation SELECT '' AS twenty, b.f1 / p.f1 AS rotation
FROM BOX_TBL b, POINT_TBL p FROM BOX_TBL b, POINT_TBL p
WHERE (p.f1 <-> '(0,0)'::point) >= 1; WHERE (p.f1 <-> point '(0,0)') >= 1;
-- --
-- Paths -- Paths
...@@ -86,11 +90,11 @@ SELECT '' AS eight, points(f1) AS npoints, f1 AS path FROM PATH_TBL; ...@@ -86,11 +90,11 @@ SELECT '' AS eight, points(f1) AS npoints, f1 AS path FROM PATH_TBL;
SELECT '' AS four, path(f1) FROM POLYGON_TBL; SELECT '' AS four, path(f1) FROM POLYGON_TBL;
-- translation -- translation
SELECT '' AS eight, p1.f1 + '(10,10)'::point AS dist_add SELECT '' AS eight, p1.f1 + point '(10,10)' AS dist_add
FROM PATH_TBL p1; FROM PATH_TBL p1;
-- scaling and rotation -- scaling and rotation
SELECT '' AS eight, p1.f1 * '(2,-1)'::point AS dist_mul SELECT '' AS eight, p1.f1 * point '(2,-1)' AS dist_mul
FROM PATH_TBL p1; FROM PATH_TBL p1;
RESET geqo; RESET geqo;
......
-- --
-- horology.sql -- HOROLOGY
-- --
-- --
-- datetime, timespan arithmetic -- datetime, timespan arithmetic
-- --
SELECT datetime '1996-03-01' - timespan '1 second' AS "Feb 29";
SELECT datetime '1999-03-01' - timespan '1 second' AS "Feb 28";
SELECT datetime '2000-03-01' - timespan '1 second' AS "Feb 29";
SELECT datetime '1999-12-01' + timespan '1 month - 1 second' AS "Dec 31";
CREATE TABLE TEMP_DATETIME (f1 datetime); CREATE TABLE TEMP_DATETIME (f1 datetime);
-- get some candidate input values -- get some candidate input values
...@@ -28,8 +33,8 @@ SELECT '' AS hundred, d.f1 AS datetime, t.f1 AS timespan, d.f1 - t.f1 AS minus ...@@ -28,8 +33,8 @@ SELECT '' AS hundred, d.f1 AS datetime, t.f1 AS timespan, d.f1 - t.f1 AS minus
WHERE isfinite(d.f1) WHERE isfinite(d.f1)
ORDER BY minus, datetime, timespan; ORDER BY minus, datetime, timespan;
SELECT '' AS ten, d.f1 AS datetime, '1980-01-06 00:00 GMT'::datetime AS gpstime_zero, SELECT '' AS ten, d.f1 AS datetime, datetime '1980-01-06 00:00 GMT' AS gpstime_zero,
d.f1 - '1980-01-06 00:00 GMT'::datetime AS difference d.f1 - datetime '1980-01-06 00:00 GMT' AS difference
FROM TEMP_DATETIME d FROM TEMP_DATETIME d
ORDER BY difference; ORDER BY difference;
...@@ -54,7 +59,7 @@ SELECT '' AS four, f1 AS abstime, ...@@ -54,7 +59,7 @@ SELECT '' AS four, f1 AS abstime,
date_part('day',f1) AS day, date_part('hour', f1) AS hour, date_part('day',f1) AS day, date_part('hour', f1) AS hour,
date_part('minute', f1) AS minute, date_part('second', f1) AS second date_part('minute', f1) AS minute, date_part('second', f1) AS second
FROM ABSTIME_TBL FROM ABSTIME_TBL
WHERE isfinite(f1) and f1 <> 'current'::abstime WHERE isfinite(f1) and f1 <> abstime 'current'
ORDER BY abstime; ORDER BY abstime;
-- --
...@@ -63,7 +68,7 @@ SELECT '' AS four, f1 AS abstime, ...@@ -63,7 +68,7 @@ SELECT '' AS four, f1 AS abstime,
SELECT '' AS ten, f1 AS datetime, date( f1) AS date SELECT '' AS ten, f1 AS datetime, date( f1) AS date
FROM TEMP_DATETIME FROM TEMP_DATETIME
WHERE f1 <> 'current'::datetime WHERE f1 <> datetime 'current'
ORDER BY date; ORDER BY date;
SELECT '' AS ten, f1 AS datetime, abstime( f1) AS abstime SELECT '' AS ten, f1 AS datetime, abstime( f1) AS abstime
...@@ -72,7 +77,7 @@ SELECT '' AS ten, f1 AS datetime, abstime( f1) AS abstime ...@@ -72,7 +77,7 @@ SELECT '' AS ten, f1 AS datetime, abstime( f1) AS abstime
SELECT '' AS five, f1 AS abstime, date( f1) AS date SELECT '' AS five, f1 AS abstime, date( f1) AS date
FROM ABSTIME_TBL FROM ABSTIME_TBL
WHERE isfinite(f1) AND f1 <> 'current'::abstime WHERE isfinite(f1) AND f1 <> abstime 'current'
ORDER BY date; ORDER BY date;
SELECT '' AS five, d1 AS datetime, abstime(d1) AS abstime SELECT '' AS five, d1 AS datetime, abstime(d1) AS abstime
......
-- INET regression tests --
-- INET
-- --
-- prepare the table... -- prepare the table...
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
-- Test join clauses -- Test join clauses
-- --
CREATE TABLE JOIN_TBL ( CREATE TABLE JOIN1_TBL (
i integer, i integer,
j integer, j integer,
x text t text
); );
CREATE TABLE JOIN2_TBL ( CREATE TABLE JOIN2_TBL (
...@@ -15,10 +15,21 @@ CREATE TABLE JOIN2_TBL ( ...@@ -15,10 +15,21 @@ CREATE TABLE JOIN2_TBL (
k integer k integer
); );
INSERT INTO JOIN_TBL VALUES (1, 3, 'one'); CREATE TABLE JOIN3_TBL (
INSERT INTO JOIN_TBL VALUES (2, 2, 'two'); i integer,
INSERT INTO JOIN_TBL VALUES (3, 1, 'three'); j integer,
INSERT INTO JOIN_TBL VALUES (4, 0, 'four'); y integer
);
CREATE TABLE JOIN4_TBL (
k integer,
z integer
);
INSERT INTO JOIN1_TBL VALUES (1, 3, 'one');
INSERT INTO JOIN1_TBL VALUES (2, 2, 'two');
INSERT INTO JOIN1_TBL VALUES (3, 1, 'three');
INSERT INTO JOIN1_TBL VALUES (4, 0, 'four');
INSERT INTO JOIN2_TBL VALUES (1, -1); INSERT INTO JOIN2_TBL VALUES (1, -1);
INSERT INTO JOIN2_TBL VALUES (2, 2); INSERT INTO JOIN2_TBL VALUES (2, 2);
...@@ -26,27 +37,62 @@ INSERT INTO JOIN2_TBL VALUES (3, -3); ...@@ -26,27 +37,62 @@ INSERT INTO JOIN2_TBL VALUES (3, -3);
INSERT INTO JOIN2_TBL VALUES (2, 4); INSERT INTO JOIN2_TBL VALUES (2, 4);
--
-- CROSS JOIN
-- Qualifications are not allowed on cross joins,
-- which degenerate into a standard unqualified inner join.
--
SELECT '' AS "xxx", *
FROM JOIN1_TBL CROSS JOIN JOIN2_TBL;
SELECT '' AS "xxx", i, k, t
FROM JOIN1_TBL CROSS JOIN JOIN2_TBL;
SELECT '' AS "xxx", ii, tt, kk
FROM JOIN1_TBL CROSS JOIN JOIN2_TBL AS JT (ii, jj, tt, ii2, kk);
SELECT '' AS "xxx", jt.ii, jt.jj, jt.kk
FROM JOIN1_TBL CROSS JOIN JOIN2_TBL AS JT (ii, jj, tt, ii2, kk);
--
-- --
-- Inner joins (equi-joins) -- Inner joins (equi-joins)
-- --
--
--
-- Inner joins (equi-joins) with USING clause
-- The USING syntax changes the shape of the resulting table
-- by including a column in the USING clause only once in the result.
--
-- Inner equi-join on all columns with the same name
SELECT '' AS "xxx", * SELECT '' AS "xxx", *
FROM JOIN_TBL CROSS JOIN JOIN2_TBL; FROM JOIN1_TBL NATURAL JOIN JOIN2_TBL;
-- Inner equi-join on specified column
SELECT '' AS "xxx", * SELECT '' AS "xxx", *
FROM JOIN_TBL NATURAL JOIN JOIN2_TBL; FROM JOIN1_TBL INNER JOIN JOIN2_TBL USING (i);
-- Same as above, slightly different syntax
SELECT '' AS "xxx", * SELECT '' AS "xxx", *
FROM JOIN_TBL INNER JOIN JOIN2_TBL USING (i); FROM JOIN1_TBL JOIN JOIN2_TBL USING (i);
--
-- Inner joins (equi-joins)
--
SELECT '' AS "xxx", * SELECT '' AS "xxx", *
FROM JOIN_TBL JOIN JOIN2_TBL ON (JOIN_TBL.i = JOIN2_TBL.i); FROM JOIN1_TBL JOIN JOIN2_TBL ON (JOIN1_TBL.i = JOIN2_TBL.i);
SELECT '' AS "xxx", * SELECT '' AS "xxx", *
FROM JOIN_TBL JOIN JOIN2_TBL ON (JOIN_TBL.i = JOIN2_TBL.k); FROM JOIN1_TBL JOIN JOIN2_TBL ON (JOIN1_TBL.i = JOIN2_TBL.k);
SELECT '' AS "xxx", * SELECT '' AS "xxx", *
FROM JOIN_TBL CROSS JOIN JOIN2_TBL; FROM JOIN1_TBL CROSS JOIN JOIN2_TBL;
-- --
...@@ -54,7 +100,7 @@ SELECT '' AS "xxx", * ...@@ -54,7 +100,7 @@ SELECT '' AS "xxx", *
-- --
SELECT '' AS "xxx", * SELECT '' AS "xxx", *
FROM JOIN_TBL JOIN JOIN2_TBL ON (JOIN_TBL.i <= JOIN2_TBL.k); FROM JOIN1_TBL JOIN JOIN2_TBL ON (JOIN1_TBL.i <= JOIN2_TBL.k);
-- --
...@@ -62,16 +108,16 @@ SELECT '' AS "xxx", * ...@@ -62,16 +108,16 @@ SELECT '' AS "xxx", *
-- --
SELECT '' AS "xxx", * SELECT '' AS "xxx", *
FROM JOIN_TBL OUTER JOIN JOIN2_TBL USING (i); FROM JOIN1_TBL OUTER JOIN JOIN2_TBL USING (i);
SELECT '' AS "xxx", * SELECT '' AS "xxx", *
FROM JOIN_TBL LEFT OUTER JOIN JOIN2_TBL USING (i); FROM JOIN1_TBL LEFT OUTER JOIN JOIN2_TBL USING (i);
SELECT '' AS "xxx", * SELECT '' AS "xxx", *
FROM JOIN_TBL RIGHT OUTER JOIN JOIN2_TBL USING (i); FROM JOIN1_TBL RIGHT OUTER JOIN JOIN2_TBL USING (i);
SELECT '' AS "xxx", * SELECT '' AS "xxx", *
FROM JOIN_TBL FULL OUTER JOIN JOIN2_TBL USING (i); FROM JOIN1_TBL FULL OUTER JOIN JOIN2_TBL USING (i);
-- --
...@@ -82,6 +128,6 @@ SELECT '' AS "xxx", * ...@@ -82,6 +128,6 @@ SELECT '' AS "xxx", *
-- Clean up -- Clean up
-- --
DROP TABLE JOIN_TBL; DROP TABLE JOIN1_TBL;
DROP TABLE JOIN2_TBL; DROP TABLE JOIN2_TBL;
-- --
-- LSEG
-- Line segments -- Line segments
-- --
...@@ -19,7 +20,7 @@ INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)'); ...@@ -19,7 +20,7 @@ INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)');
select * from LSEG_TBL; select * from LSEG_TBL;
SELECT * FROM LSEG_TBL WHERE s <= '[(1,2),(3,4)]'::lseg; SELECT * FROM LSEG_TBL WHERE s <= lseg '[(1,2),(3,4)]';
SELECT * FROM LSEG_TBL WHERE (s <-> '[(1,2),(3,4)]'::lseg) < 10; SELECT * FROM LSEG_TBL WHERE (s <-> lseg '[(1,2),(3,4)]') < 10;
-- ****************************** --
-- * Test suite for the Postgres NUMERIC data type -- NUMERIC
-- ****************************** --
CREATE TABLE num_data (id int4, val numeric(210,10)); CREATE TABLE num_data (id int4, val numeric(210,10));
CREATE TABLE num_exp_add (id1 int4, id2 int4, expected numeric(210,10)); CREATE TABLE num_exp_add (id1 int4, id2 int4, expected numeric(210,10));
...@@ -614,7 +614,7 @@ SELECT t1.id1, t1.result, t2.expected ...@@ -614,7 +614,7 @@ SELECT t1.id1, t1.result, t2.expected
-- * Logarithm base 10 check -- * Logarithm base 10 check
-- ****************************** -- ******************************
DELETE FROM num_result; DELETE FROM num_result;
INSERT INTO num_result SELECT id, 0, LOG('10'::numeric, ABS(val)) INSERT INTO num_result SELECT id, 0, LOG(numeric '10', ABS(val))
FROM num_data FROM num_data
WHERE val != '0.0'; WHERE val != '0.0';
SELECT t1.id1, t1.result, t2.expected SELECT t1.id1, t1.result, t2.expected
...@@ -626,7 +626,7 @@ SELECT t1.id1, t1.result, t2.expected ...@@ -626,7 +626,7 @@ SELECT t1.id1, t1.result, t2.expected
-- * POWER(10, LN(value)) check -- * POWER(10, LN(value)) check
-- ****************************** -- ******************************
DELETE FROM num_result; DELETE FROM num_result;
INSERT INTO num_result SELECT id, 0, POWER('10'::numeric, LN(ABS(round(val,200)))) INSERT INTO num_result SELECT id, 0, POWER(numeric '10', LN(ABS(round(val,200))))
FROM num_data FROM num_data
WHERE val != '0.0'; WHERE val != '0.0';
SELECT t1.id1, t1.result, t2.expected SELECT t1.id1, t1.result, t2.expected
......
-- --
-- numerology.sql -- NUMEROLOGY
-- Test various combinations of numeric types and functions.
-- --
-- --
......
-- --
-- OIDJOIN
-- This is created by pgsql/contrib/findoidjoins/make_oidjoin_check -- This is created by pgsql/contrib/findoidjoins/make_oidjoin_check
-- --
SELECT oid, pg_aggregate.aggtransfn1 SELECT oid, pg_aggregate.aggtransfn1
FROM pg_aggregate FROM pg_aggregate
WHERE pg_aggregate.aggtransfn1 != 0 AND WHERE pg_aggregate.aggtransfn1 != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_aggregate.aggtransfn1); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_aggregate.aggtransfn1);
SELECT oid, pg_aggregate.aggtransfn2 SELECT oid, pg_aggregate.aggtransfn2
FROM pg_aggregate FROM pg_aggregate
WHERE pg_aggregate.aggtransfn2 != 0 AND WHERE pg_aggregate.aggtransfn2 != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_aggregate.aggtransfn2); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_aggregate.aggtransfn2);
SELECT oid, pg_aggregate.aggfinalfn SELECT oid, pg_aggregate.aggfinalfn
FROM pg_aggregate FROM pg_aggregate
WHERE pg_aggregate.aggfinalfn != 0 AND WHERE pg_aggregate.aggfinalfn != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_aggregate.aggfinalfn); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_aggregate.aggfinalfn);
SELECT oid, pg_aggregate.aggbasetype SELECT oid, pg_aggregate.aggbasetype
FROM pg_aggregate FROM pg_aggregate
WHERE pg_aggregate.aggbasetype != 0 AND WHERE pg_aggregate.aggbasetype != 0 AND
NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_aggregate.aggbasetype); NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_aggregate.aggbasetype);
SELECT oid, pg_aggregate.aggtranstype1 SELECT oid, pg_aggregate.aggtranstype1
FROM pg_aggregate FROM pg_aggregate
WHERE pg_aggregate.aggtranstype1 != 0 AND WHERE pg_aggregate.aggtranstype1 != 0 AND
NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_aggregate.aggtranstype1); NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_aggregate.aggtranstype1);
SELECT oid, pg_aggregate.aggtranstype2 SELECT oid, pg_aggregate.aggtranstype2
FROM pg_aggregate FROM pg_aggregate
WHERE pg_aggregate.aggtranstype2 != 0 AND WHERE pg_aggregate.aggtranstype2 != 0 AND
NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_aggregate.aggtranstype2); NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_aggregate.aggtranstype2);
SELECT oid, pg_aggregate.aggfinaltype SELECT oid, pg_aggregate.aggfinaltype
FROM pg_aggregate FROM pg_aggregate
WHERE pg_aggregate.aggfinaltype != 0 AND WHERE pg_aggregate.aggfinaltype != 0 AND
NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_aggregate.aggfinaltype); NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_aggregate.aggfinaltype);
SELECT oid, pg_am.amgettuple SELECT oid, pg_am.amgettuple
FROM pg_am FROM pg_am
WHERE pg_am.amgettuple != 0 AND WHERE pg_am.amgettuple != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.amgettuple); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.amgettuple);
SELECT oid, pg_am.aminsert SELECT oid, pg_am.aminsert
FROM pg_am FROM pg_am
WHERE pg_am.aminsert != 0 AND WHERE pg_am.aminsert != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.aminsert); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.aminsert);
SELECT oid, pg_am.amdelete SELECT oid, pg_am.amdelete
FROM pg_am FROM pg_am
WHERE pg_am.amdelete != 0 AND WHERE pg_am.amdelete != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.amdelete); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.amdelete);
SELECT oid, pg_am.ambeginscan SELECT oid, pg_am.ambeginscan
FROM pg_am FROM pg_am
WHERE pg_am.ambeginscan != 0 AND WHERE pg_am.ambeginscan != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.ambeginscan); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.ambeginscan);
SELECT oid, pg_am.amrescan SELECT oid, pg_am.amrescan
FROM pg_am FROM pg_am
WHERE pg_am.amrescan != 0 AND WHERE pg_am.amrescan != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.amrescan); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.amrescan);
SELECT oid, pg_am.amendscan SELECT oid, pg_am.amendscan
FROM pg_am FROM pg_am
WHERE pg_am.amendscan != 0 AND WHERE pg_am.amendscan != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.amendscan); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.amendscan);
SELECT oid, pg_am.ammarkpos SELECT oid, pg_am.ammarkpos
FROM pg_am FROM pg_am
WHERE pg_am.ammarkpos != 0 AND WHERE pg_am.ammarkpos != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.ammarkpos); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.ammarkpos);
SELECT oid, pg_am.amrestrpos SELECT oid, pg_am.amrestrpos
FROM pg_am FROM pg_am
WHERE pg_am.amrestrpos != 0 AND WHERE pg_am.amrestrpos != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.amrestrpos); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.amrestrpos);
SELECT oid, pg_am.ambuild SELECT oid, pg_am.ambuild
FROM pg_am FROM pg_am
WHERE pg_am.ambuild != 0 AND WHERE pg_am.ambuild != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.ambuild); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_am.ambuild);
SELECT oid, pg_amop.amopid SELECT oid, pg_amop.amopid
FROM pg_amop FROM pg_amop
WHERE pg_amop.amopid != 0 AND WHERE pg_amop.amopid != 0 AND
NOT EXISTS(SELECT * FROM pg_am AS t1 WHERE t1.oid = pg_amop.amopid); NOT EXISTS(SELECT * FROM pg_am AS t1 WHERE t1.oid = pg_amop.amopid);
SELECT oid, pg_amop.amopclaid SELECT oid, pg_amop.amopclaid
FROM pg_amop FROM pg_amop
WHERE pg_amop.amopclaid != 0 AND WHERE pg_amop.amopclaid != 0 AND
NOT EXISTS(SELECT * FROM pg_opclass AS t1 WHERE t1.oid = pg_amop.amopclaid); NOT EXISTS(SELECT * FROM pg_opclass AS t1 WHERE t1.oid = pg_amop.amopclaid);
SELECT oid, pg_amop.amopopr SELECT oid, pg_amop.amopopr
FROM pg_amop FROM pg_amop
WHERE pg_amop.amopopr != 0 AND WHERE pg_amop.amopopr != 0 AND
NOT EXISTS(SELECT * FROM pg_operator AS t1 WHERE t1.oid = pg_amop.amopopr); NOT EXISTS(SELECT * FROM pg_operator AS t1 WHERE t1.oid = pg_amop.amopopr);
SELECT oid, pg_amop.amopselect SELECT oid, pg_amop.amopselect
FROM pg_amop FROM pg_amop
WHERE pg_amop.amopselect != 0 AND WHERE pg_amop.amopselect != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_amop.amopselect); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_amop.amopselect);
SELECT oid, pg_amop.amopnpages SELECT oid, pg_amop.amopnpages
FROM pg_amop FROM pg_amop
WHERE pg_amop.amopnpages != 0 AND WHERE pg_amop.amopnpages != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_amop.amopnpages); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_amop.amopnpages);
SELECT oid, pg_amproc.amid SELECT oid, pg_amproc.amid
FROM pg_amproc FROM pg_amproc
WHERE pg_amproc.amid != 0 AND WHERE pg_amproc.amid != 0 AND
NOT EXISTS(SELECT * FROM pg_am AS t1 WHERE t1.oid = pg_amproc.amid); NOT EXISTS(SELECT * FROM pg_am AS t1 WHERE t1.oid = pg_amproc.amid);
SELECT oid, pg_amproc.amopclaid SELECT oid, pg_amproc.amopclaid
FROM pg_amproc FROM pg_amproc
WHERE pg_amproc.amopclaid != 0 AND WHERE pg_amproc.amopclaid != 0 AND
NOT EXISTS(SELECT * FROM pg_opclass AS t1 WHERE t1.oid = pg_amproc.amopclaid); NOT EXISTS(SELECT * FROM pg_opclass AS t1 WHERE t1.oid = pg_amproc.amopclaid);
SELECT oid, pg_amproc.amproc SELECT oid, pg_amproc.amproc
FROM pg_amproc FROM pg_amproc
WHERE pg_amproc.amproc != 0 AND WHERE pg_amproc.amproc != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_amproc.amproc); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_amproc.amproc);
SELECT oid, pg_attribute.attrelid SELECT oid, pg_attribute.attrelid
FROM pg_attribute FROM pg_attribute
WHERE pg_attribute.attrelid != 0 AND WHERE pg_attribute.attrelid != 0 AND
NOT EXISTS(SELECT * FROM pg_class AS t1 WHERE t1.oid = pg_attribute.attrelid); NOT EXISTS(SELECT * FROM pg_class AS t1 WHERE t1.oid = pg_attribute.attrelid);
SELECT oid, pg_attribute.atttypid SELECT oid, pg_attribute.atttypid
FROM pg_attribute FROM pg_attribute
WHERE pg_attribute.atttypid != 0 AND WHERE pg_attribute.atttypid != 0 AND
NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_attribute.atttypid); NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_attribute.atttypid);
SELECT oid, pg_class.reltype SELECT oid, pg_class.reltype
FROM pg_class FROM pg_class
WHERE pg_class.reltype != 0 AND WHERE pg_class.reltype != 0 AND
NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_class.reltype); NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_class.reltype);
SELECT oid, pg_class.relam SELECT oid, pg_class.relam
FROM pg_class FROM pg_class
WHERE pg_class.relam != 0 AND WHERE pg_class.relam != 0 AND
NOT EXISTS(SELECT * FROM pg_am AS t1 WHERE t1.oid = pg_class.relam); NOT EXISTS(SELECT * FROM pg_am AS t1 WHERE t1.oid = pg_class.relam);
SELECT oid, pg_index.indexrelid SELECT oid, pg_index.indexrelid
FROM pg_index FROM pg_index
WHERE pg_index.indexrelid != 0 AND WHERE pg_index.indexrelid != 0 AND
NOT EXISTS(SELECT * FROM pg_class AS t1 WHERE t1.oid = pg_index.indexrelid); NOT EXISTS(SELECT * FROM pg_class AS t1 WHERE t1.oid = pg_index.indexrelid);
SELECT oid, pg_index.indrelid SELECT oid, pg_index.indrelid
FROM pg_index FROM pg_index
WHERE pg_index.indrelid != 0 AND WHERE pg_index.indrelid != 0 AND
NOT EXISTS(SELECT * FROM pg_class AS t1 WHERE t1.oid = pg_index.indrelid); NOT EXISTS(SELECT * FROM pg_class AS t1 WHERE t1.oid = pg_index.indrelid);
SELECT oid, pg_opclass.opcdeftype SELECT oid, pg_opclass.opcdeftype
FROM pg_opclass FROM pg_opclass
WHERE pg_opclass.opcdeftype != 0 AND WHERE pg_opclass.opcdeftype != 0 AND
NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_opclass.opcdeftype); NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_opclass.opcdeftype);
SELECT oid, pg_operator.oprleft SELECT oid, pg_operator.oprleft
FROM pg_operator FROM pg_operator
WHERE pg_operator.oprleft != 0 AND WHERE pg_operator.oprleft != 0 AND
NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_operator.oprleft); NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_operator.oprleft);
SELECT oid, pg_operator.oprright SELECT oid, pg_operator.oprright
FROM pg_operator FROM pg_operator
WHERE pg_operator.oprright != 0 AND WHERE pg_operator.oprright != 0 AND
NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_operator.oprright); NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_operator.oprright);
SELECT oid, pg_operator.oprresult SELECT oid, pg_operator.oprresult
FROM pg_operator FROM pg_operator
WHERE pg_operator.oprresult != 0 AND WHERE pg_operator.oprresult != 0 AND
NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_operator.oprresult); NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_operator.oprresult);
SELECT oid, pg_operator.oprcom SELECT oid, pg_operator.oprcom
FROM pg_operator FROM pg_operator
WHERE pg_operator.oprcom != 0 AND WHERE pg_operator.oprcom != 0 AND
NOT EXISTS(SELECT * FROM pg_operator AS t1 WHERE t1.oid = pg_operator.oprcom); NOT EXISTS(SELECT * FROM pg_operator AS t1 WHERE t1.oid = pg_operator.oprcom);
SELECT oid, pg_operator.oprnegate SELECT oid, pg_operator.oprnegate
FROM pg_operator FROM pg_operator
WHERE pg_operator.oprnegate != 0 AND WHERE pg_operator.oprnegate != 0 AND
NOT EXISTS(SELECT * FROM pg_operator AS t1 WHERE t1.oid = pg_operator.oprnegate); NOT EXISTS(SELECT * FROM pg_operator AS t1 WHERE t1.oid = pg_operator.oprnegate);
SELECT oid, pg_operator.oprlsortop SELECT oid, pg_operator.oprlsortop
FROM pg_operator FROM pg_operator
WHERE pg_operator.oprlsortop != 0 AND WHERE pg_operator.oprlsortop != 0 AND
NOT EXISTS(SELECT * FROM pg_operator AS t1 WHERE t1.oid = pg_operator.oprlsortop); NOT EXISTS(SELECT * FROM pg_operator AS t1 WHERE t1.oid = pg_operator.oprlsortop);
SELECT oid, pg_operator.oprrsortop SELECT oid, pg_operator.oprrsortop
FROM pg_operator FROM pg_operator
WHERE pg_operator.oprrsortop != 0 AND WHERE pg_operator.oprrsortop != 0 AND
NOT EXISTS(SELECT * FROM pg_operator AS t1 WHERE t1.oid = pg_operator.oprrsortop); NOT EXISTS(SELECT * FROM pg_operator AS t1 WHERE t1.oid = pg_operator.oprrsortop);
SELECT oid, pg_operator.oprcode SELECT oid, pg_operator.oprcode
FROM pg_operator FROM pg_operator
WHERE pg_operator.oprcode != 0 AND WHERE pg_operator.oprcode != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_operator.oprcode); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_operator.oprcode);
SELECT oid, pg_operator.oprrest SELECT oid, pg_operator.oprrest
FROM pg_operator FROM pg_operator
WHERE pg_operator.oprrest != 0 AND WHERE pg_operator.oprrest != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_operator.oprrest); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_operator.oprrest);
SELECT oid, pg_operator.oprjoin SELECT oid, pg_operator.oprjoin
FROM pg_operator FROM pg_operator
WHERE pg_operator.oprjoin != 0 AND WHERE pg_operator.oprjoin != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_operator.oprjoin); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_operator.oprjoin);
SELECT oid, pg_proc.prolang SELECT oid, pg_proc.prolang
FROM pg_proc FROM pg_proc
WHERE pg_proc.prolang != 0 AND WHERE pg_proc.prolang != 0 AND
NOT EXISTS(SELECT * FROM pg_language AS t1 WHERE t1.oid = pg_proc.prolang); NOT EXISTS(SELECT * FROM pg_language AS t1 WHERE t1.oid = pg_proc.prolang);
SELECT oid, pg_proc.prorettype SELECT oid, pg_proc.prorettype
FROM pg_proc FROM pg_proc
WHERE pg_proc.prorettype != 0 AND WHERE pg_proc.prorettype != 0 AND
NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_proc.prorettype); NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_proc.prorettype);
SELECT oid, pg_rewrite.ev_class SELECT oid, pg_rewrite.ev_class
FROM pg_rewrite FROM pg_rewrite
WHERE pg_rewrite.ev_class != 0 AND WHERE pg_rewrite.ev_class != 0 AND
NOT EXISTS(SELECT * FROM pg_class AS t1 WHERE t1.oid = pg_rewrite.ev_class); NOT EXISTS(SELECT * FROM pg_class AS t1 WHERE t1.oid = pg_rewrite.ev_class);
SELECT oid, pg_type.typrelid SELECT oid, pg_type.typrelid
FROM pg_type FROM pg_type
WHERE pg_type.typrelid != 0 AND WHERE pg_type.typrelid != 0 AND
NOT EXISTS(SELECT * FROM pg_class AS t1 WHERE t1.oid = pg_type.typrelid); NOT EXISTS(SELECT * FROM pg_class AS t1 WHERE t1.oid = pg_type.typrelid);
SELECT oid, pg_type.typelem SELECT oid, pg_type.typelem
FROM pg_type FROM pg_type
WHERE pg_type.typelem != 0 AND WHERE pg_type.typelem != 0 AND
NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_type.typelem); NOT EXISTS(SELECT * FROM pg_type AS t1 WHERE t1.oid = pg_type.typelem);
SELECT oid, pg_type.typinput SELECT oid, pg_type.typinput
FROM pg_type FROM pg_type
WHERE pg_type.typinput != 0 AND WHERE pg_type.typinput != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_type.typinput); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_type.typinput);
SELECT oid, pg_type.typoutput SELECT oid, pg_type.typoutput
FROM pg_type FROM pg_type
WHERE pg_type.typoutput != 0 AND WHERE pg_type.typoutput != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_type.typoutput); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_type.typoutput);
SELECT oid, pg_type.typreceive SELECT oid, pg_type.typreceive
FROM pg_type FROM pg_type
WHERE pg_type.typreceive != 0 AND WHERE pg_type.typreceive != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_type.typreceive); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_type.typreceive);
SELECT oid, pg_type.typsend SELECT oid, pg_type.typsend
FROM pg_type FROM pg_type
WHERE pg_type.typsend != 0 AND WHERE pg_type.typsend != 0 AND
NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_type.typsend); NOT EXISTS(SELECT * FROM pg_proc AS t1 WHERE t1.oid = pg_type.typsend);
-- --
-- OPR_SANITY
-- Sanity checks for common errors in making operator/procedure system tables: -- Sanity checks for common errors in making operator/procedure system tables:
-- pg_operator, pg_proc, pg_aggregate, pg_am, pg_amop, pg_amproc, pg_opclass. -- pg_operator, pg_proc, pg_aggregate, pg_am, pg_amop, pg_amproc, pg_opclass.
-- --
......
-- --
-- path.sql -- PATH
-- --
--DROP TABLE PATH_TBL; --DROP TABLE PATH_TBL;
......
-- ************testing built-in type point **************** --
-- POINT
--
CREATE TABLE POINT_TBL(f1 point); CREATE TABLE POINT_TBL(f1 point);
...@@ -41,15 +43,15 @@ SELECT '' AS one, p.* FROM POINT_TBL p WHERE p.f1 ~= '(5.1, 34.5)'; ...@@ -41,15 +43,15 @@ SELECT '' AS one, p.* FROM POINT_TBL p WHERE p.f1 ~= '(5.1, 34.5)';
-- point in box -- point in box
SELECT '' AS three, p.* FROM POINT_TBL p SELECT '' AS three, p.* FROM POINT_TBL p
WHERE p.f1 @ '(0,0,100,100)'::box; WHERE p.f1 @ box '(0,0,100,100)';
SELECT '' AS three, p.* FROM POINT_TBL p SELECT '' AS three, p.* FROM POINT_TBL p
WHERE not p.f1 @ '(0,0,100,100)'::box; WHERE not p.f1 @ box '(0,0,100,100)';
SELECT '' AS two, p.* FROM POINT_TBL p SELECT '' AS two, p.* FROM POINT_TBL p
WHERE p.f1 @ '[(0,0),(-10,0),(-10,10)]'::path; WHERE p.f1 @ path '[(0,0),(-10,0),(-10,10)]';
SELECT '' AS six, p.f1, p.f1 <-> '(0,0)'::point AS dist SELECT '' AS six, p.f1, p.f1 <-> point '(0,0)' AS dist
FROM POINT_TBL p FROM POINT_TBL p
ORDER BY dist; ORDER BY dist;
......
-- *************testing built-in type polygon **************** --
-- POLYGON
-- --
-- polygon logic -- polygon logic
-- --
...@@ -67,17 +68,17 @@ SELECT '' AS zero, p.* ...@@ -67,17 +68,17 @@ SELECT '' AS zero, p.*
-- contained -- contained
SELECT '' AS one, p.* SELECT '' AS one, p.*
FROM POLYGON_TBL p FROM POLYGON_TBL p
WHERE p.f1 @ '(3.0,1.0),(3.0,3.0),(1.0,0.0)'::polygon; WHERE p.f1 @ polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)';
-- same -- same
SELECT '' AS one, p.* SELECT '' AS one, p.*
FROM POLYGON_TBL p FROM POLYGON_TBL p
WHERE p.f1 ~= '(3.0,1.0),(3.0,3.0),(1.0,0.0)'::polygon; WHERE p.f1 ~= polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)';
-- contains -- contains
SELECT '' AS one, p.* SELECT '' AS one, p.*
FROM POLYGON_TBL p FROM POLYGON_TBL p
WHERE p.f1 ~ '(3.0,1.0),(3.0,3.0),(1.0,0.0)'::polygon; WHERE p.f1 ~ polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)';
-- --
-- polygon logic -- polygon logic
...@@ -93,26 +94,26 @@ SELECT '' AS one, p.* ...@@ -93,26 +94,26 @@ SELECT '' AS one, p.*
-- 0 1 2 3 4 -- 0 1 2 3 4
-- --
-- left of -- left of
SELECT '(2.0,0.0),(2.0,4.0),(0.0,0.0)'::polygon << '(3.0,1.0),(3.0,3.0),(1.0,0.0)'::polygon AS false; SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' << polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS false;
-- left overlap -- left overlap
SELECT '(2.0,0.0),(2.0,4.0),(0.0,0.0)'::polygon << '(3.0,1.0),(3.0,3.0),(1.0,0.0)'::polygon AS true; SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' << polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS true;
-- right overlap -- right overlap
SELECT '(2.0,0.0),(2.0,4.0),(0.0,0.0)'::polygon &> '(3.0,1.0),(3.0,3.0),(1.0,0.0)'::polygon AS true; SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' &> polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS true;
-- right of -- right of
SELECT '(2.0,0.0),(2.0,4.0),(0.0,0.0)'::polygon >> '(3.0,1.0),(3.0,3.0),(1.0,0.0)'::polygon AS false; SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' >> polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS false;
-- contained in -- contained in
SELECT '(2.0,0.0),(2.0,4.0),(0.0,0.0)'::polygon @ '(3.0,1.0),(3.0,3.0),(1.0,0.0)'::polygon AS false; SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' @ polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS false;
-- contains -- contains
SELECT '(2.0,0.0),(2.0,4.0),(0.0,0.0)'::polygon ~ '(3.0,1.0),(3.0,3.0),(1.0,0.0)'::polygon AS false; SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' ~ polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS false;
-- same -- same
SELECT '(2.0,0.0),(2.0,4.0),(0.0,0.0)'::polygon ~= '(3.0,1.0),(3.0,3.0),(1.0,0.0)'::polygon AS false; SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' ~= polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS false;
-- overlap -- overlap
SELECT '(2.0,0.0),(2.0,4.0),(0.0,0.0)'::polygon && '(3.0,1.0),(3.0,3.0),(1.0,0.0)'::polygon AS true; SELECT polygon '(2.0,0.0),(2.0,4.0),(0.0,0.0)' && polygon '(3.0,1.0),(3.0,3.0),(1.0,0.0)' AS true;
--
-- RELTIME
--
CREATE TABLE RELTIME_TBL (f1 reltime); CREATE TABLE RELTIME_TBL (f1 reltime);
INSERT INTO RELTIME_TBL (f1) VALUES ('@ 1 minute'); INSERT INTO RELTIME_TBL (f1) VALUES ('@ 1 minute');
...@@ -13,7 +17,7 @@ INSERT INTO RELTIME_TBL (f1) VALUES ('@ 3 months'); ...@@ -13,7 +17,7 @@ INSERT INTO RELTIME_TBL (f1) VALUES ('@ 3 months');
INSERT INTO RELTIME_TBL (f1) VALUES ('@ 14 seconds ago'); INSERT INTO RELTIME_TBL (f1) VALUES ('@ 14 seconds ago');
-- badly formatted reltimes: -- badly formatted reltimes
INSERT INTO RELTIME_TBL (f1) VALUES ('badly formatted reltime'); INSERT INTO RELTIME_TBL (f1) VALUES ('badly formatted reltime');
INSERT INTO RELTIME_TBL (f1) VALUES ('@ 30 eons ago'); INSERT INTO RELTIME_TBL (f1) VALUES ('@ 30 eons ago');
...@@ -23,22 +27,22 @@ INSERT INTO RELTIME_TBL (f1) VALUES ('@ 30 eons ago'); ...@@ -23,22 +27,22 @@ INSERT INTO RELTIME_TBL (f1) VALUES ('@ 30 eons ago');
SELECT '' AS six, RELTIME_TBL.*; SELECT '' AS six, RELTIME_TBL.*;
SELECT '' AS five, RELTIME_TBL.* SELECT '' AS five, RELTIME_TBL.*
WHERE RELTIME_TBL.f1 <> '@ 10 days'::reltime; WHERE RELTIME_TBL.f1 <> reltime '@ 10 days';
SELECT '' AS three, RELTIME_TBL.* SELECT '' AS three, RELTIME_TBL.*
WHERE RELTIME_TBL.f1 <= '@ 5 hours'::reltime; WHERE RELTIME_TBL.f1 <= reltime '@ 5 hours';
SELECT '' AS three, RELTIME_TBL.* SELECT '' AS three, RELTIME_TBL.*
WHERE RELTIME_TBL.f1 < '@ 1 day'::reltime; WHERE RELTIME_TBL.f1 < reltime '@ 1 day';
SELECT '' AS one, RELTIME_TBL.* SELECT '' AS one, RELTIME_TBL.*
WHERE RELTIME_TBL.f1 = '@ 34 years'::reltime; WHERE RELTIME_TBL.f1 = reltime '@ 34 years';
SELECT '' AS two, RELTIME_TBL.* SELECT '' AS two, RELTIME_TBL.*
WHERE RELTIME_TBL.f1 >= '@ 1 month'::reltime; WHERE RELTIME_TBL.f1 >= reltime '@ 1 month';
SELECT '' AS five, RELTIME_TBL.* SELECT '' AS five, RELTIME_TBL.*
WHERE RELTIME_TBL.f1 > '@ 3 seconds ago'::reltime; WHERE RELTIME_TBL.f1 > reltime '@ 3 seconds ago';
SELECT '' AS fifteen, r1.*, r2.* SELECT '' AS fifteen, r1.*, r2.*
FROM RELTIME_TBL r1, RELTIME_TBL r2 FROM RELTIME_TBL r1, RELTIME_TBL r2
......
-- --
-- STRINGS
-- Test various data entry syntaxes. -- Test various data entry syntaxes.
-- --
......
--
-- TIMESPAN
--
CREATE TABLE TIMESPAN_TBL (f1 timespan); CREATE TABLE TIMESPAN_TBL (f1 timespan);
INSERT INTO TIMESPAN_TBL (f1) VALUES ('@ 1 minute'); INSERT INTO TIMESPAN_TBL (f1) VALUES ('@ 1 minute');
...@@ -11,7 +15,7 @@ INSERT INTO TIMESPAN_TBL (f1) VALUES ('6 years'); ...@@ -11,7 +15,7 @@ INSERT INTO TIMESPAN_TBL (f1) VALUES ('6 years');
INSERT INTO TIMESPAN_TBL (f1) VALUES ('5 months'); INSERT INTO TIMESPAN_TBL (f1) VALUES ('5 months');
INSERT INTO TIMESPAN_TBL (f1) VALUES ('5 months 12 hours'); INSERT INTO TIMESPAN_TBL (f1) VALUES ('5 months 12 hours');
-- badly formatted timespan: -- badly formatted timespan
INSERT INTO TIMESPAN_TBL (f1) VALUES ('badly formatted timespan'); INSERT INTO TIMESPAN_TBL (f1) VALUES ('badly formatted timespan');
INSERT INTO TIMESPAN_TBL (f1) VALUES ('@ 30 eons ago'); INSERT INTO TIMESPAN_TBL (f1) VALUES ('@ 30 eons ago');
...@@ -20,22 +24,22 @@ INSERT INTO TIMESPAN_TBL (f1) VALUES ('@ 30 eons ago'); ...@@ -20,22 +24,22 @@ INSERT INTO TIMESPAN_TBL (f1) VALUES ('@ 30 eons ago');
SELECT '' AS ten, TIMESPAN_TBL.*; SELECT '' AS ten, TIMESPAN_TBL.*;
SELECT '' AS nine, TIMESPAN_TBL.* SELECT '' AS nine, TIMESPAN_TBL.*
WHERE TIMESPAN_TBL.f1 <> '@ 10 days'::timespan; WHERE TIMESPAN_TBL.f1 <> timespan '@ 10 days';
SELECT '' AS three, TIMESPAN_TBL.* SELECT '' AS three, TIMESPAN_TBL.*
WHERE TIMESPAN_TBL.f1 <= '@ 5 hours'::timespan; WHERE TIMESPAN_TBL.f1 <= timespan '@ 5 hours';
SELECT '' AS three, TIMESPAN_TBL.* SELECT '' AS three, TIMESPAN_TBL.*
WHERE TIMESPAN_TBL.f1 < '@ 1 day'::timespan; WHERE TIMESPAN_TBL.f1 < timespan '@ 1 day';
SELECT '' AS one, TIMESPAN_TBL.* SELECT '' AS one, TIMESPAN_TBL.*
WHERE TIMESPAN_TBL.f1 = '@ 34 years'::timespan; WHERE TIMESPAN_TBL.f1 = timespan '@ 34 years';
SELECT '' AS five, TIMESPAN_TBL.* SELECT '' AS five, TIMESPAN_TBL.*
WHERE TIMESPAN_TBL.f1 >= '@ 1 month'::timespan; WHERE TIMESPAN_TBL.f1 >= timespan '@ 1 month';
SELECT '' AS nine, TIMESPAN_TBL.* SELECT '' AS nine, TIMESPAN_TBL.*
WHERE TIMESPAN_TBL.f1 > '@ 3 seconds ago'::timespan; WHERE TIMESPAN_TBL.f1 > timespan '@ 3 seconds ago';
SELECT '' AS fortyfive, r1.*, r2.* SELECT '' AS fortyfive, r1.*, r2.*
FROM TIMESPAN_TBL r1, TIMESPAN_TBL r2 FROM TIMESPAN_TBL r1, TIMESPAN_TBL r2
......
--
-- TINTERVAL
--
CREATE TABLE TINTERVAL_TBL (f1 tinterval); CREATE TABLE TINTERVAL_TBL (f1 tinterval);
INSERT INTO TINTERVAL_TBL (f1) INSERT INTO TINTERVAL_TBL (f1)
...@@ -61,7 +65,7 @@ SELECT '' AS three, t.* ...@@ -61,7 +65,7 @@ SELECT '' AS three, t.*
SELECT '' AS three, t1.* SELECT '' AS three, t1.*
FROM TINTERVAL_TBL t1 FROM TINTERVAL_TBL t1
WHERE t1.f1 && WHERE t1.f1 &&
'["Aug 15 14:23:19 1983" "Sep 16 14:23:19 1983"]'::tinterval; tinterval '["Aug 15 14:23:19 1983" "Sep 16 14:23:19 1983"]';
SET geqo TO 'off'; SET geqo TO 'off';
...@@ -80,15 +84,15 @@ SELECT '' AS fourteen, t1.f1 AS interval1, t2.f1 AS interval2 ...@@ -80,15 +84,15 @@ SELECT '' AS fourteen, t1.f1 AS interval1, t2.f1 AS interval2
SELECT '' AS five, t1.f1 SELECT '' AS five, t1.f1
FROM TINTERVAL_TBL t1 FROM TINTERVAL_TBL t1
WHERE not t1.f1 << WHERE not t1.f1 <<
'["Aug 15 14:23:19 1980" "Sep 16 14:23:19 1990"]'::tinterval tinterval '["Aug 15 14:23:19 1980" "Sep 16 14:23:19 1990"]'
ORDER BY t1.f1; ORDER BY t1.f1;
-- make time interval -- make time interval
SELECT '' AS three, t1.f1 SELECT '' AS three, t1.f1
FROM TINTERVAL_TBL t1 FROM TINTERVAL_TBL t1
WHERE t1.f1 && WHERE t1.f1 &&
('Aug 15 14:23:19 1983'::abstime <#> (abstime 'Aug 15 14:23:19 1983' <#>
'Sep 16 14:23:19 1983'::abstime) abstime 'Sep 16 14:23:19 1983')
ORDER BY t1.f1; ORDER BY t1.f1;
RESET geqo; RESET geqo;
......
-- --
-- TYPE_SANITY
-- Sanity checks for common errors in making type-related system tables: -- Sanity checks for common errors in making type-related system tables:
-- pg_type, pg_class, pg_attribute. -- pg_type, pg_class, pg_attribute.
-- --
......
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