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

Verified output from new psql.

Include a few new tests for datetime/timespan arithmetic.
parent 24e8ca6e
This diff is collapsed.
QUERY: CREATE TABLE BOX_TBL (f1 box); --
QUERY: INSERT INTO BOX_TBL (f1) VALUES ('(2.0,2.0,0.0,0.0)'); -- BOX
QUERY: INSERT INTO BOX_TBL (f1) VALUES ('(1.0,1.0,3.0,3.0)'); --
QUERY: INSERT INTO BOX_TBL (f1) VALUES ('(2.5, 2.5, 2.5,3.5)'); --
QUERY: INSERT INTO BOX_TBL (f1) VALUES ('(3.0, 3.0,3.0,3.0)'); -- box logic
QUERY: INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)'); -- o
-- 3 o--|X
-- | o|
-- 2 +-+-+ |
-- | | | |
-- 1 | o-+-o
-- | |
-- 0 +---+
--
-- 0 1 2 3
--
-- boxes are specified by two points, given by four floats x1,y1,x2,y2
CREATE TABLE BOX_TBL (f1 box);
INSERT INTO BOX_TBL (f1) VALUES ('(2.0,2.0,0.0,0.0)');
INSERT INTO BOX_TBL (f1) VALUES ('(1.0,1.0,3.0,3.0)');
-- degenerate cases where the box is a line or a point
-- note that lines and points boxes all have zero area
INSERT INTO BOX_TBL (f1) VALUES ('(2.5, 2.5, 2.5,3.5)');
INSERT INTO BOX_TBL (f1) VALUES ('(3.0, 3.0,3.0,3.0)');
-- badly formatted box inputs
INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)');
ERROR: Bad box external representation '(2.3, 4.5)' ERROR: Bad box external representation '(2.3, 4.5)'
QUERY: INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad'); INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad');
ERROR: Bad box external representation 'asdfasdf(ad' ERROR: Bad box external representation 'asdfasdf(ad'
QUERY: SELECT '' AS four, BOX_TBL.*; SELECT '' AS four, BOX_TBL.*;
four|f1 four | f1
----+------------------- ------+---------------------
|(2,2),(0,0) | (2,2),(0,0)
|(3,3),(1,1) | (3,3),(1,1)
|(2.5,3.5),(2.5,2.5) | (2.5,3.5),(2.5,2.5)
|(3,3),(3,3) | (3,3),(3,3)
(4 rows) (4 rows)
QUERY: SELECT '' AS four, b.*, box_area(b.f1) as barea SELECT '' AS four, b.*, box_area(b.f1) as barea
FROM BOX_TBL b; FROM BOX_TBL b;
four|f1 |barea four | f1 | barea
----+-------------------+----- ------+---------------------+-------
|(2,2),(0,0) | 4 | (2,2),(0,0) | 4
|(3,3),(1,1) | 4 | (3,3),(1,1) | 4
|(2.5,3.5),(2.5,2.5)| 0 | (2.5,3.5),(2.5,2.5) | 0
|(3,3),(3,3) | 0 | (3,3),(3,3) | 0
(4 rows) (4 rows)
QUERY: SELECT '' AS three, b.f1 -- overlap
FROM BOX_TBL b SELECT '' AS three, b.f1
WHERE b.f1 && '(2.5,2.5,1.0,1.0)'::box; FROM BOX_TBL b
three|f1 WHERE b.f1 && box '(2.5,2.5,1.0,1.0)';
-----+------------------- three | f1
|(2,2),(0,0) -------+---------------------
|(3,3),(1,1) | (2,2),(0,0)
|(2.5,3.5),(2.5,2.5) | (3,3),(1,1)
| (2.5,3.5),(2.5,2.5)
(3 rows) (3 rows)
QUERY: SELECT '' AS two, b1.* -- left-or-overlap (x only)
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)';
two|f1 two | f1
---+------------------- -----+---------------------
|(2,2),(0,0) | (2,2),(0,0)
|(2.5,3.5),(2.5,2.5) | (2.5,3.5),(2.5,2.5)
(2 rows) (2 rows)
QUERY: SELECT '' AS two, b1.* -- right-or-overlap (x only)
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)';
two|f1 two | f1
---+------------------- -----+---------------------
|(2.5,3.5),(2.5,2.5) | (2.5,3.5),(2.5,2.5)
|(3,3),(3,3) | (3,3),(3,3)
(2 rows) (2 rows)
QUERY: SELECT '' AS two, b.f1 -- left of
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)';
two|f1 two | f1
---+------------------- -----+---------------------
|(2,2),(0,0) | (2,2),(0,0)
|(2.5,3.5),(2.5,2.5) | (2.5,3.5),(2.5,2.5)
(2 rows) (2 rows)
QUERY: SELECT '' AS four, b.f1 -- area <=
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)';
four|f1 four | f1
----+------------------- ------+---------------------
|(2,2),(0,0) | (2,2),(0,0)
|(3,3),(1,1) | (3,3),(1,1)
|(2.5,3.5),(2.5,2.5) | (2.5,3.5),(2.5,2.5)
|(3,3),(3,3) | (3,3),(3,3)
(4 rows) (4 rows)
QUERY: SELECT '' AS two, b.f1 -- area <
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)';
two|f1 two | f1
---+------------------- -----+---------------------
|(2.5,3.5),(2.5,2.5) | (2.5,3.5),(2.5,2.5)
|(3,3),(3,3) | (3,3),(3,3)
(2 rows) (2 rows)
QUERY: SELECT '' AS two, b.f1 -- area =
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)';
two|f1 two | f1
---+----------- -----+-------------
|(2,2),(0,0) | (2,2),(0,0)
|(3,3),(1,1) | (3,3),(1,1)
(2 rows) (2 rows)
QUERY: SELECT '' AS two, b.f1 -- area >
FROM BOX_TBL b SELECT '' AS two, b.f1
WHERE b.f1 > '(3.5,3.0,4.5,3.0)'::box; FROM BOX_TBL b -- zero area
two|f1 WHERE b.f1 > box '(3.5,3.0,4.5,3.0)';
---+----------- two | f1
|(2,2),(0,0) -----+-------------
|(3,3),(1,1) | (2,2),(0,0)
| (3,3),(1,1)
(2 rows) (2 rows)
QUERY: SELECT '' AS four, b.f1 -- area >=
FROM BOX_TBL b SELECT '' AS four, b.f1
WHERE b.f1 >= '(3.5,3.0,4.5,3.0)'::box; FROM BOX_TBL b -- zero area
four|f1 WHERE b.f1 >= box '(3.5,3.0,4.5,3.0)';
----+------------------- four | f1
|(2,2),(0,0) ------+---------------------
|(3,3),(1,1) | (2,2),(0,0)
|(2.5,3.5),(2.5,2.5) | (3,3),(1,1)
|(3,3),(3,3) | (2.5,3.5),(2.5,2.5)
| (3,3),(3,3)
(4 rows) (4 rows)
QUERY: SELECT '' AS two, b.f1 -- right of
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;
two|f1 two | f1
---+------------------- -----+---------------------
|(2,2),(0,0) | (2,2),(0,0)
|(2.5,3.5),(2.5,2.5) | (2.5,3.5),(2.5,2.5)
(2 rows) (2 rows)
QUERY: SELECT '' AS three, b.f1 -- contained in
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)';
three|f1 three | f1
-----+----------- -------+-------------
|(2,2),(0,0) | (2,2),(0,0)
|(3,3),(1,1) | (3,3),(1,1)
|(3,3),(3,3) | (3,3),(3,3)
(3 rows) (3 rows)
QUERY: SELECT '' AS three, b.f1 -- contains
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;
three|f1 three | f1
-----+----------- -------+-------------
|(2,2),(0,0) | (2,2),(0,0)
|(3,3),(1,1) | (3,3),(1,1)
|(3,3),(3,3) | (3,3),(3,3)
(3 rows) (3 rows)
QUERY: SELECT '' AS one, b.f1 -- box equality
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;
one|f1 one | f1
---+----------- -----+-------------
|(3,3),(1,1) | (3,3),(1,1)
(1 row) (1 row)
QUERY: SELECT '' AS four, @@(b1.f1) AS p -- center of box, left unary operator
SELECT '' AS four, @@(b1.f1) AS p
FROM BOX_TBL b1; FROM BOX_TBL b1;
four|p four | p
----+------- ------+---------
|(1,1) | (1,1)
|(2,2) | (2,2)
|(2.5,3) | (2.5,3)
|(3,3) | (3,3)
(4 rows) (4 rows)
QUERY: SELECT '' AS one, b1.*, b2.* -- wholly-contained
FROM BOX_TBL b1, BOX_TBL b2 SELECT '' AS one, b1.*, b2.*
FROM BOX_TBL b1, BOX_TBL b2
WHERE b1.f1 ~ b2.f1 and not b1.f1 ~= b2.f1; WHERE b1.f1 ~ b2.f1 and not b1.f1 ~= b2.f1;
one|f1 |f1 one | f1 | f1
---+-----------+----------- -----+-------------+-------------
|(3,3),(1,1)|(3,3),(3,3) | (3,3),(1,1) | (3,3),(3,3)
(1 row) (1 row)
QUERY: SELECT '' AS four, height(f1), width(f1) FROM BOX_TBL; SELECT '' AS four, height(f1), width(f1) FROM BOX_TBL;
four|height|width four | height | width
----+------+----- ------+--------+-------
| 2| 2 | 2 | 2
| 2| 2 | 2 | 2
| 1| 0 | 1 | 0
| 0| 0 | 0 | 0
(4 rows) (4 rows)
QUERY: CREATE TABLE CIRCLE_TBL (f1 circle); --
QUERY: INSERT INTO CIRCLE_TBL VALUES ('<(0,0),3>'); -- CIRCLE
QUERY: INSERT INTO CIRCLE_TBL VALUES ('<(1,2),100>'); --
QUERY: INSERT INTO CIRCLE_TBL VALUES ('1,3,5'); CREATE TABLE CIRCLE_TBL (f1 circle);
QUERY: INSERT INTO CIRCLE_TBL VALUES ('((1,2),3)'); INSERT INTO CIRCLE_TBL VALUES ('<(0,0),3>');
QUERY: INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10>'); INSERT INTO CIRCLE_TBL VALUES ('<(1,2),100>');
QUERY: INSERT INTO CIRCLE_TBL VALUES ('<(100,0),100>'); INSERT INTO CIRCLE_TBL VALUES ('1,3,5');
QUERY: INSERT INTO CIRCLE_TBL VALUES ('<(-100,0),-100>'); INSERT INTO CIRCLE_TBL VALUES ('((1,2),3)');
INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10>');
INSERT INTO CIRCLE_TBL VALUES ('<(100,0),100>');
-- bad values
INSERT INTO CIRCLE_TBL VALUES ('<(-100,0),-100>');
ERROR: Bad circle external representation '<(-100,0),-100>' ERROR: Bad circle external representation '<(-100,0),-100>'
QUERY: INSERT INTO CIRCLE_TBL VALUES ('1abc,3,5'); INSERT INTO CIRCLE_TBL VALUES ('1abc,3,5');
ERROR: Bad circle external representation '1abc,3,5' ERROR: Bad circle external representation '1abc,3,5'
QUERY: INSERT INTO CIRCLE_TBL VALUES ('(3,(1,2),3)'); INSERT INTO CIRCLE_TBL VALUES ('(3,(1,2),3)');
ERROR: Bad circle external representation '(3,(1,2),3)' ERROR: Bad circle external representation '(3,(1,2),3)'
QUERY: SELECT * FROM CIRCLE_TBL; SELECT * FROM CIRCLE_TBL;
f1 f1
-------------- ----------------
<(0,0),3> <(0,0),3>
<(1,2),100> <(1,2),100>
<(1,3),5> <(1,3),5>
<(1,2),3> <(1,2),3>
<(100,200),10> <(100,200),10>
<(100,0),100> <(100,0),100>
(6 rows) (6 rows)
QUERY: SELECT '' AS six, center(f1) AS center SELECT '' AS six, center(f1) AS center
FROM CIRCLE_TBL; FROM CIRCLE_TBL;
six|center six | center
---+--------- -----+-----------
|(0,0) | (0,0)
|(1,2) | (1,2)
|(1,3) | (1,3)
|(1,2) | (1,2)
|(100,200) | (100,200)
|(100,0) | (100,0)
(6 rows) (6 rows)
QUERY: SELECT '' AS six, radius(f1) AS radius SELECT '' AS six, radius(f1) AS radius
FROM CIRCLE_TBL; FROM CIRCLE_TBL;
six|radius six | radius
---+------ -----+--------
| 3 | 3
| 100 | 100
| 5 | 5
| 3 | 3
| 10 | 10
| 100 | 100
(6 rows) (6 rows)
QUERY: SELECT '' AS six, diameter(f1) AS diameter SELECT '' AS six, diameter(f1) AS diameter
FROM CIRCLE_TBL; FROM CIRCLE_TBL;
six|diameter six | diameter
---+-------- -----+----------
| 6 | 6
| 200 | 200
| 10 | 10
| 6 | 6
| 20 | 20
| 200 | 200
(6 rows) (6 rows)
QUERY: SELECT '' AS two, f1 FROM CIRCLE_TBL WHERE radius(f1) < 5; SELECT '' AS two, f1 FROM CIRCLE_TBL WHERE radius(f1) < 5;
two|f1 two | f1
---+--------- -----+-----------
|<(0,0),3> | <(0,0),3>
|<(1,2),3> | <(1,2),3>
(2 rows) (2 rows)
QUERY: SELECT '' AS four, f1 FROM CIRCLE_TBL WHERE diameter(f1) >= 10; SELECT '' AS four, f1 FROM CIRCLE_TBL WHERE diameter(f1) >= 10;
four|f1 four | f1
----+-------------- ------+----------------
|<(1,2),100> | <(1,2),100>
|<(1,3),5> | <(1,3),5>
|<(100,200),10> | <(100,200),10>
|<(100,0),100> | <(100,0),100>
(4 rows) (4 rows)
QUERY: SELECT '' as five, c1.f1 AS one, c2.f1 AS two, (c1.f1 <-> c2.f1) AS distance SELECT '' as five, c1.f1 AS one, c2.f1 AS two, (c1.f1 <-> c2.f1) AS distance
FROM CIRCLE_TBL c1, CIRCLE_TBL c2 FROM CIRCLE_TBL c1, CIRCLE_TBL c2
WHERE (c1.f1 < c2.f1) AND ((c1.f1 <-> c2.f1) > 0) WHERE (c1.f1 < c2.f1) AND ((c1.f1 <-> c2.f1) > 0)
ORDER BY distance, one, two; ORDER BY distance, one, two;
five|one |two | distance five | one | two | distance
----+--------------+--------------+---------------- ------+----------------+----------------+------------------
|<(100,200),10>|<(100,0),100> | 90 | <(100,200),10> | <(100,0),100> | 90
|<(100,200),10>|<(1,2),100> |111.370729772479 | <(100,200),10> | <(1,2),100> | 111.370729772479
|<(1,3),5> |<(100,200),10>|205.476756144497 | <(1,3),5> | <(100,200),10> | 205.476756144497
|<(1,2),3> |<(100,200),10>|208.370729772479 | <(1,2),3> | <(100,200),10> | 208.370729772479
|<(0,0),3> |<(100,200),10>|210.606797749979 | <(0,0),3> | <(100,200),10> | 210.606797749979
(5 rows) (5 rows)
QUERY: SELECT 'trailing' AS first; --
first -- COMMENTS
-------- --
trailing SELECT 'trailing' AS first; -- trailing single line
first
----------
trailing
(1 row) (1 row)
QUERY:
SELECT /* embedded single line */ 'embedded' AS second; SELECT /* embedded single line */ 'embedded' AS second;
second second
-------- ----------
embedded embedded
(1 row) (1 row)
QUERY: SELECT /* both embedded and trailing single line */ 'both' AS third; SELECT /* both embedded and trailing single line */ 'both' AS third; -- trailing single line
third third
----- -------
both both
(1 row) (1 row)
QUERY:
SELECT 'before multi-line' AS fourth; SELECT 'before multi-line' AS fourth;
fourth fourth
----------------- -------------------
before multi-line before multi-line
(1 row) (1 row)
QUERY: /* This is an example of SQL which should not execute: /* This is an example of SQL which should not execute:
* select 'multi-line'; * select 'multi-line';
*/ */
SELECT 'after multi-line' AS fifth; SELECT 'after multi-line' AS fifth;
fifth fifth
---------------- ------------------
after multi-line after multi-line
(1 row) (1 row)
/* and this is the end of the file */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
QUERY: CREATE TABLE LSEG_TBL (s lseg); --
QUERY: INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)]'); -- LSEG
QUERY: INSERT INTO LSEG_TBL VALUES ('(0,0),(6,6)'); -- Line segments
QUERY: INSERT INTO LSEG_TBL VALUES ('10,-10 ,-3,-4'); --
QUERY: INSERT INTO LSEG_TBL VALUES ('[-1e6,2e2,3e5, -4e1]'); --DROP TABLE LSEG_TBL;
QUERY: INSERT INTO LSEG_TBL VALUES ('(11,22,33,44)'); CREATE TABLE LSEG_TBL (s lseg);
QUERY: INSERT INTO LSEG_TBL VALUES ('(3asdf,2 ,3,4r2)'); INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)]');
INSERT INTO LSEG_TBL VALUES ('(0,0),(6,6)');
INSERT INTO LSEG_TBL VALUES ('10,-10 ,-3,-4');
INSERT INTO LSEG_TBL VALUES ('[-1e6,2e2,3e5, -4e1]');
INSERT INTO LSEG_TBL VALUES ('(11,22,33,44)');
-- bad values for parser testing
INSERT INTO LSEG_TBL VALUES ('(3asdf,2 ,3,4r2)');
ERROR: Bad lseg external representation '(3asdf,2 ,3,4r2)' ERROR: Bad lseg external representation '(3asdf,2 ,3,4r2)'
QUERY: INSERT INTO LSEG_TBL VALUES ('[1,2,3, 4'); INSERT INTO LSEG_TBL VALUES ('[1,2,3, 4');
ERROR: Bad lseg external representation '[1,2,3, 4' ERROR: Bad lseg external representation '[1,2,3, 4'
QUERY: INSERT INTO LSEG_TBL VALUES ('[(,2),(3,4)]'); INSERT INTO LSEG_TBL VALUES ('[(,2),(3,4)]');
ERROR: Bad lseg external representation '[(,2),(3,4)]' ERROR: Bad lseg external representation '[(,2),(3,4)]'
QUERY: INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)'); INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)');
ERROR: Bad lseg external representation '[(1,2),(3,4)' ERROR: Bad lseg external representation '[(1,2),(3,4)'
QUERY: select * from LSEG_TBL; select * from LSEG_TBL;
s s
----------------------------- -------------------------------
[(1,2),(3,4)] [(1,2),(3,4)]
[(0,0),(6,6)] [(0,0),(6,6)]
[(10,-10),(-3,-4)] [(10,-10),(-3,-4)]
[(-1000000,200),(300000,-40)] [(-1000000,200),(300000,-40)]
[(11,22),(33,44)] [(11,22),(33,44)]
(5 rows) (5 rows)
QUERY: SELECT * FROM LSEG_TBL WHERE s <= '[(1,2),(3,4)]'::lseg; SELECT * FROM LSEG_TBL WHERE s <= lseg '[(1,2),(3,4)]';
s s
------------- ---------------
[(1,2),(3,4)] [(1,2),(3,4)]
(1 row) (1 row)
QUERY: SELECT * FROM LSEG_TBL WHERE (s <-> '[(1,2),(3,4)]'::lseg) < 10; SELECT * FROM LSEG_TBL WHERE (s <-> lseg '[(1,2),(3,4)]') < 10;
s s
------------------ --------------------
[(1,2),(3,4)] [(1,2),(3,4)]
[(0,0),(6,6)] [(0,0),(6,6)]
[(10,-10),(-3,-4)] [(10,-10),(-3,-4)]
(3 rows) (3 rows)
This diff is collapsed.
QUERY: CREATE TABLE TEMP_FLOAT (f1 FLOAT8); --
QUERY: INSERT INTO TEMP_FLOAT (f1) -- NUMEROLOGY
-- Test various combinations of numeric types and functions.
--
--
-- Test implicit type conversions
-- This fails for Postgres v6.1 (and earlier?)
-- so let's try explicit conversions for now - tgl 97/05/07
--
CREATE TABLE TEMP_FLOAT (f1 FLOAT8);
INSERT INTO TEMP_FLOAT (f1)
SELECT float8(f1) FROM INT4_TBL; SELECT float8(f1) FROM INT4_TBL;
QUERY: INSERT INTO TEMP_FLOAT (f1) INSERT INTO TEMP_FLOAT (f1)
SELECT float8(f1) FROM INT2_TBL; SELECT float8(f1) FROM INT2_TBL;
QUERY: SELECT '' AS ten, f1 FROM TEMP_FLOAT SELECT '' AS ten, f1 FROM TEMP_FLOAT
ORDER BY f1; ORDER BY f1;
ten| f1 ten | f1
---+----------- -----+-------------
|-2147483647 | -2147483647
| -123456 | -123456
| -32767 | -32767
| -1234 | -1234
| 0 | 0
| 0 | 0
| 1234 | 1234
| 32767 | 32767
| 123456 | 123456
| 2147483647 | 2147483647
(10 rows) (10 rows)
QUERY: CREATE TABLE TEMP_INT4 (f1 INT4); -- int4
QUERY: INSERT INTO TEMP_INT4 (f1) CREATE TABLE TEMP_INT4 (f1 INT4);
INSERT INTO TEMP_INT4 (f1)
SELECT int4(f1) FROM FLOAT8_TBL SELECT int4(f1) FROM FLOAT8_TBL
WHERE (f1 > -2147483647) AND (f1 < 2147483647); WHERE (f1 > -2147483647) AND (f1 < 2147483647);
QUERY: INSERT INTO TEMP_INT4 (f1) INSERT INTO TEMP_INT4 (f1)
SELECT int4(f1) FROM INT2_TBL; SELECT int4(f1) FROM INT2_TBL;
QUERY: SELECT '' AS nine, f1 FROM TEMP_INT4 SELECT '' AS nine, f1 FROM TEMP_INT4
ORDER BY f1; ORDER BY f1;
nine| f1 nine | f1
----+------ ------+--------
|-32767 | -32767
| -1234 | -1234
| -1004 | -1004
| -35 | -35
| 0 | 0
| 0 | 0
| 0 | 0
| 1234 | 1234
| 32767 | 32767
(9 rows) (9 rows)
QUERY: CREATE TABLE TEMP_INT2 (f1 INT2); -- int2
QUERY: INSERT INTO TEMP_INT2 (f1) CREATE TABLE TEMP_INT2 (f1 INT2);
INSERT INTO TEMP_INT2 (f1)
SELECT int2(f1) FROM FLOAT8_TBL SELECT int2(f1) FROM FLOAT8_TBL
WHERE (f1 >= -32767) AND (f1 <= 32767); WHERE (f1 >= -32767) AND (f1 <= 32767);
QUERY: INSERT INTO TEMP_INT2 (f1) INSERT INTO TEMP_INT2 (f1)
SELECT int2(f1) FROM INT4_TBL SELECT int2(f1) FROM INT4_TBL
WHERE (f1 >= -32767) AND (f1 <= 32767); WHERE (f1 >= -32767) AND (f1 <= 32767);
QUERY: SELECT '' AS five, f1 FROM TEMP_INT2 SELECT '' AS five, f1 FROM TEMP_INT2
ORDER BY f1; ORDER BY f1;
five| f1 five | f1
----+----- ------+-------
|-1004 | -1004
| -35 | -35
| 0 | 0
| 0 | 0
| 0 | 0
(5 rows) (5 rows)
QUERY: CREATE TABLE TEMP_GROUP (f1 INT4, f2 INT4, f3 FLOAT8); --
QUERY: INSERT INTO TEMP_GROUP -- Group-by combinations
--
CREATE TABLE TEMP_GROUP (f1 INT4, f2 INT4, f3 FLOAT8);
INSERT INTO TEMP_GROUP
SELECT 1, (- i.f1), (- f.f1) SELECT 1, (- i.f1), (- f.f1)
FROM INT4_TBL i, FLOAT8_TBL f; FROM INT4_TBL i, FLOAT8_TBL f;
QUERY: INSERT INTO TEMP_GROUP INSERT INTO TEMP_GROUP
SELECT 2, i.f1, f.f1 SELECT 2, i.f1, f.f1
FROM INT4_TBL i, FLOAT8_TBL f; FROM INT4_TBL i, FLOAT8_TBL f;
QUERY: SELECT DISTINCT f1 AS two FROM TEMP_GROUP; SELECT DISTINCT f1 AS two FROM TEMP_GROUP;
two two
--- -----
1 1
2 2
(2 rows) (2 rows)
QUERY: SELECT f1 AS two, max(f3) AS max_float, min(f3) as min_float SELECT f1 AS two, max(f3) AS max_float, min(f3) as min_float
FROM TEMP_GROUP FROM TEMP_GROUP
GROUP BY two GROUP BY two
ORDER BY two, max_float, min_float; ORDER BY two, max_float, min_float;
two|max_float |min_float two | max_float | min_float
---+--------------------+--------------------- -----+----------------------+-----------------------
1|1.2345678901234e+200|0 1 | 1.2345678901234e+200 | 0
2|0 |-1.2345678901234e+200 2 | 0 | -1.2345678901234e+200
(2 rows) (2 rows)
QUERY: SELECT f1 AS two, max(f3) AS max_float, min(f3) AS min_float SELECT f1 AS two, max(f3) AS max_float, min(f3) AS min_float
FROM TEMP_GROUP FROM TEMP_GROUP
GROUP BY two GROUP BY two
ORDER BY two, max_float, min_float; ORDER BY two, max_float, min_float;
two|max_float |min_float two | max_float | min_float
---+--------------------+--------------------- -----+----------------------+-----------------------
1|1.2345678901234e+200|0 1 | 1.2345678901234e+200 | 0
2|0 |-1.2345678901234e+200 2 | 0 | -1.2345678901234e+200
(2 rows) (2 rows)
QUERY: SELECT f1 AS two, (max(f3) + 1) AS max_plus_1, (min(f3) - 1) AS min_minus_1 SELECT f1 AS two, (max(f3) + 1) AS max_plus_1, (min(f3) - 1) AS min_minus_1
FROM TEMP_GROUP FROM TEMP_GROUP
GROUP BY two GROUP BY two
ORDER BY two, min_minus_1; ORDER BY two, min_minus_1;
two|max_plus_1 |min_minus_1 two | max_plus_1 | min_minus_1
---+--------------------+--------------------- -----+----------------------+-----------------------
1|1.2345678901234e+200|-1 1 | 1.2345678901234e+200 | -1
2|1 |-1.2345678901234e+200 2 | 1 | -1.2345678901234e+200
(2 rows) (2 rows)
QUERY: SELECT f1 AS two, (max(f3) + 1) AS max_plus_1, (min(f3) - 1) AS min_minus_1 SELECT f1 AS two, (max(f3) + 1) AS max_plus_1, (min(f3) - 1) AS min_minus_1
FROM TEMP_GROUP FROM TEMP_GROUP
GROUP BY two GROUP BY two
ORDER BY two, min_minus_1; ORDER BY two, min_minus_1;
two|max_plus_1 |min_minus_1 two | max_plus_1 | min_minus_1
---+--------------------+--------------------- -----+----------------------+-----------------------
1|1.2345678901234e+200|-1 1 | 1.2345678901234e+200 | -1
2|1 |-1.2345678901234e+200 2 | 1 | -1.2345678901234e+200
(2 rows) (2 rows)
QUERY: DROP TABLE TEMP_INT2; DROP TABLE TEMP_INT2;
QUERY: DROP TABLE TEMP_INT4; DROP TABLE TEMP_INT4;
QUERY: DROP TABLE TEMP_FLOAT; DROP TABLE TEMP_FLOAT;
QUERY: DROP TABLE TEMP_GROUP; DROP TABLE TEMP_GROUP;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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