Commit c06d6aa4 authored by Peter Eisentraut's avatar Peter Eisentraut

Clean up ancient test style

Many older tests where written in a style like

    SELECT '' AS two, i.* FROM INT2_TBL

where the first column indicated the number of expected result rows.
This has gotten increasingly out of date, as the test data fixtures
have expanded, so a lot of these were wrong and misleading.  Moreover,
this style isn't really necessary, since the psql output already shows
the number of result rows.

To clean this up, remove all those extra columns.

Discussion: https://www.postgresql.org/message-id/flat/1a25312b-2686-380d-3c67-7a69094a999f%40enterprisedb.com
parent b3817f5f
......@@ -226,48 +226,48 @@ INSERT INTO BOOLTBL1 (f1) VALUES (bool 't');
INSERT INTO BOOLTBL1 (f1) VALUES (bool 'True');
INSERT INTO BOOLTBL1 (f1) VALUES (bool 'true');
-- BOOLTBL1 should be full of true's at this point
SELECT '' AS t_3, BOOLTBL1.* FROM BOOLTBL1;
t_3 | f1
-----+----
| t
| t
| t
SELECT BOOLTBL1.* FROM BOOLTBL1;
f1
----
t
t
t
(3 rows)
SELECT '' AS t_3, BOOLTBL1.*
SELECT BOOLTBL1.*
FROM BOOLTBL1
WHERE f1 = bool 'true';
t_3 | f1
-----+----
| t
| t
| t
f1
----
t
t
t
(3 rows)
SELECT '' AS t_3, BOOLTBL1.*
SELECT BOOLTBL1.*
FROM BOOLTBL1
WHERE f1 <> bool 'false';
t_3 | f1
-----+----
| t
| t
| t
f1
----
t
t
t
(3 rows)
SELECT '' AS zero, BOOLTBL1.*
SELECT BOOLTBL1.*
FROM BOOLTBL1
WHERE booleq(bool 'false', f1);
zero | f1
------+----
f1
----
(0 rows)
INSERT INTO BOOLTBL1 (f1) VALUES (bool 'f');
SELECT '' AS f_1, BOOLTBL1.*
SELECT BOOLTBL1.*
FROM BOOLTBL1
WHERE f1 = bool 'false';
f_1 | f1
-----+----
| f
f1
----
f
(1 row)
CREATE TABLE BOOLTBL2 (f1 bool);
......@@ -283,86 +283,86 @@ ERROR: invalid input syntax for type boolean: "XXX"
LINE 2: VALUES (bool 'XXX');
^
-- BOOLTBL2 should be full of false's at this point
SELECT '' AS f_4, BOOLTBL2.* FROM BOOLTBL2;
f_4 | f1
-----+----
| f
| f
| f
| f
SELECT BOOLTBL2.* FROM BOOLTBL2;
f1
----
f
f
f
f
(4 rows)
SELECT '' AS tf_12, BOOLTBL1.*, BOOLTBL2.*
SELECT BOOLTBL1.*, BOOLTBL2.*
FROM BOOLTBL1, BOOLTBL2
WHERE BOOLTBL2.f1 <> BOOLTBL1.f1;
tf_12 | f1 | f1
-------+----+----
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
f1 | f1
----+----
t | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
(12 rows)
SELECT '' AS tf_12, BOOLTBL1.*, BOOLTBL2.*
SELECT BOOLTBL1.*, BOOLTBL2.*
FROM BOOLTBL1, BOOLTBL2
WHERE boolne(BOOLTBL2.f1,BOOLTBL1.f1);
tf_12 | f1 | f1
-------+----+----
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
f1 | f1
----+----
t | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
(12 rows)
SELECT '' AS ff_4, BOOLTBL1.*, BOOLTBL2.*
SELECT BOOLTBL1.*, BOOLTBL2.*
FROM BOOLTBL1, BOOLTBL2
WHERE BOOLTBL2.f1 = BOOLTBL1.f1 and BOOLTBL1.f1 = bool 'false';
ff_4 | f1 | f1
------+----+----
| f | f
| f | f
| f | f
| f | f
f1 | f1
----+----
f | f
f | f
f | f
f | f
(4 rows)
SELECT '' AS tf_12_ff_4, BOOLTBL1.*, BOOLTBL2.*
SELECT BOOLTBL1.*, BOOLTBL2.*
FROM BOOLTBL1, BOOLTBL2
WHERE BOOLTBL2.f1 = BOOLTBL1.f1 or BOOLTBL1.f1 = bool 'true'
ORDER BY BOOLTBL1.f1, BOOLTBL2.f1;
tf_12_ff_4 | f1 | f1
------------+----+----
| f | f
| f | f
| f | f
| f | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
| t | f
f1 | f1
----+----
f | f
f | f
f | f
f | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
t | f
(16 rows)
--
......@@ -370,76 +370,76 @@ SELECT '' AS tf_12_ff_4, BOOLTBL1.*, BOOLTBL2.*
-- Try all combinations to ensure that we get nothing when we expect nothing
-- - thomas 2000-01-04
--
SELECT '' AS "True", f1
SELECT f1
FROM BOOLTBL1
WHERE f1 IS TRUE;
True | f1
------+----
| t
| t
| t
f1
----
t
t
t
(3 rows)
SELECT '' AS "Not False", f1
SELECT f1
FROM BOOLTBL1
WHERE f1 IS NOT FALSE;
Not False | f1
-----------+----
| t
| t
| t
f1
----
t
t
t
(3 rows)
SELECT '' AS "False", f1
SELECT f1
FROM BOOLTBL1
WHERE f1 IS FALSE;
False | f1
-------+----
| f
f1
----
f
(1 row)
SELECT '' AS "Not True", f1
SELECT f1
FROM BOOLTBL1
WHERE f1 IS NOT TRUE;
Not True | f1
----------+----
| f
f1
----
f
(1 row)
SELECT '' AS "True", f1
SELECT f1
FROM BOOLTBL2
WHERE f1 IS TRUE;
True | f1
------+----
f1
----
(0 rows)
SELECT '' AS "Not False", f1
SELECT f1
FROM BOOLTBL2
WHERE f1 IS NOT FALSE;
Not False | f1
-----------+----
f1
----
(0 rows)
SELECT '' AS "False", f1
SELECT f1
FROM BOOLTBL2
WHERE f1 IS FALSE;
False | f1
-------+----
| f
| f
| f
| f
f1
----
f
f
f
f
(4 rows)
SELECT '' AS "Not True", f1
SELECT f1
FROM BOOLTBL2
WHERE f1 IS NOT TRUE;
Not True | f1
----------+----
| f
| f
| f
| f
f1
----
f
f
f
f
(4 rows)
--
......
......@@ -44,197 +44,197 @@ INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad');
ERROR: invalid input syntax for type box: "asdfasdf(ad"
LINE 1: INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad');
^
SELECT '' AS four, * FROM BOX_TBL;
four | f1
------+---------------------
| (2,2),(0,0)
| (3,3),(1,1)
| (-2,2),(-8,-10)
| (2.5,3.5),(2.5,2.5)
| (3,3),(3,3)
SELECT * FROM BOX_TBL;
f1
---------------------
(2,2),(0,0)
(3,3),(1,1)
(-2,2),(-8,-10)
(2.5,3.5),(2.5,2.5)
(3,3),(3,3)
(5 rows)
SELECT '' AS four, b.*, area(b.f1) as barea
SELECT b.*, area(b.f1) as barea
FROM BOX_TBL b;
four | f1 | barea
------+---------------------+-------
| (2,2),(0,0) | 4
| (3,3),(1,1) | 4
| (-2,2),(-8,-10) | 72
| (2.5,3.5),(2.5,2.5) | 0
| (3,3),(3,3) | 0
f1 | barea
---------------------+-------
(2,2),(0,0) | 4
(3,3),(1,1) | 4
(-2,2),(-8,-10) | 72
(2.5,3.5),(2.5,2.5) | 0
(3,3),(3,3) | 0
(5 rows)
-- overlap
SELECT '' AS three, b.f1
SELECT b.f1
FROM BOX_TBL b
WHERE b.f1 && box '(2.5,2.5,1.0,1.0)';
three | f1
-------+---------------------
| (2,2),(0,0)
| (3,3),(1,1)
| (2.5,3.5),(2.5,2.5)
f1
---------------------
(2,2),(0,0)
(3,3),(1,1)
(2.5,3.5),(2.5,2.5)
(3 rows)
-- left-or-overlap (x only)
SELECT '' AS two, b1.*
SELECT b1.*
FROM BOX_TBL b1
WHERE b1.f1 &< box '(2.0,2.0,2.5,2.5)';
two | f1
-----+---------------------
| (2,2),(0,0)
| (-2,2),(-8,-10)
| (2.5,3.5),(2.5,2.5)
f1
---------------------
(2,2),(0,0)
(-2,2),(-8,-10)
(2.5,3.5),(2.5,2.5)
(3 rows)
-- right-or-overlap (x only)
SELECT '' AS two, b1.*
SELECT b1.*
FROM BOX_TBL b1
WHERE b1.f1 &> box '(2.0,2.0,2.5,2.5)';
two | f1
-----+---------------------
| (2.5,3.5),(2.5,2.5)
| (3,3),(3,3)
f1
---------------------
(2.5,3.5),(2.5,2.5)
(3,3),(3,3)
(2 rows)
-- left of
SELECT '' AS two, b.f1
SELECT b.f1
FROM BOX_TBL b
WHERE b.f1 << box '(3.0,3.0,5.0,5.0)';
two | f1
-----+---------------------
| (2,2),(0,0)
| (-2,2),(-8,-10)
| (2.5,3.5),(2.5,2.5)
f1
---------------------
(2,2),(0,0)
(-2,2),(-8,-10)
(2.5,3.5),(2.5,2.5)
(3 rows)
-- area <=
SELECT '' AS four, b.f1
SELECT b.f1
FROM BOX_TBL b
WHERE b.f1 <= box '(3.0,3.0,5.0,5.0)';
four | f1
------+---------------------
| (2,2),(0,0)
| (3,3),(1,1)
| (2.5,3.5),(2.5,2.5)
| (3,3),(3,3)
f1
---------------------
(2,2),(0,0)
(3,3),(1,1)
(2.5,3.5),(2.5,2.5)
(3,3),(3,3)
(4 rows)
-- area <
SELECT '' AS two, b.f1
SELECT b.f1
FROM BOX_TBL b
WHERE b.f1 < box '(3.0,3.0,5.0,5.0)';
two | f1
-----+---------------------
| (2.5,3.5),(2.5,2.5)
| (3,3),(3,3)
f1
---------------------
(2.5,3.5),(2.5,2.5)
(3,3),(3,3)
(2 rows)
-- area =
SELECT '' AS two, b.f1
SELECT b.f1
FROM BOX_TBL b
WHERE b.f1 = box '(3.0,3.0,5.0,5.0)';
two | f1
-----+-------------
| (2,2),(0,0)
| (3,3),(1,1)
f1
-------------
(2,2),(0,0)
(3,3),(1,1)
(2 rows)
-- area >
SELECT '' AS two, b.f1
SELECT b.f1
FROM BOX_TBL b -- zero area
WHERE b.f1 > box '(3.5,3.0,4.5,3.0)';
two | f1
-----+-----------------
| (2,2),(0,0)
| (3,3),(1,1)
| (-2,2),(-8,-10)
f1
-----------------
(2,2),(0,0)
(3,3),(1,1)
(-2,2),(-8,-10)
(3 rows)
-- area >=
SELECT '' AS four, b.f1
SELECT b.f1
FROM BOX_TBL b -- zero area
WHERE b.f1 >= box '(3.5,3.0,4.5,3.0)';
four | f1
------+---------------------
| (2,2),(0,0)
| (3,3),(1,1)
| (-2,2),(-8,-10)
| (2.5,3.5),(2.5,2.5)
| (3,3),(3,3)
f1
---------------------
(2,2),(0,0)
(3,3),(1,1)
(-2,2),(-8,-10)
(2.5,3.5),(2.5,2.5)
(3,3),(3,3)
(5 rows)
-- right of
SELECT '' AS two, b.f1
SELECT b.f1
FROM BOX_TBL b
WHERE box '(3.0,3.0,5.0,5.0)' >> b.f1;
two | f1
-----+---------------------
| (2,2),(0,0)
| (-2,2),(-8,-10)
| (2.5,3.5),(2.5,2.5)
f1
---------------------
(2,2),(0,0)
(-2,2),(-8,-10)
(2.5,3.5),(2.5,2.5)
(3 rows)
-- contained in
SELECT '' AS three, b.f1
SELECT b.f1
FROM BOX_TBL b
WHERE b.f1 <@ box '(0,0,3,3)';
three | f1
-------+-------------
| (2,2),(0,0)
| (3,3),(1,1)
| (3,3),(3,3)
f1
-------------
(2,2),(0,0)
(3,3),(1,1)
(3,3),(3,3)
(3 rows)
-- contains
SELECT '' AS three, b.f1
SELECT b.f1
FROM BOX_TBL b
WHERE box '(0,0,3,3)' @> b.f1;
three | f1
-------+-------------
| (2,2),(0,0)
| (3,3),(1,1)
| (3,3),(3,3)
f1
-------------
(2,2),(0,0)
(3,3),(1,1)
(3,3),(3,3)
(3 rows)
-- box equality
SELECT '' AS one, b.f1
SELECT b.f1
FROM BOX_TBL b
WHERE box '(1,1,3,3)' ~= b.f1;
one | f1
-----+-------------
| (3,3),(1,1)
f1
-------------
(3,3),(1,1)
(1 row)
-- center of box, left unary operator
SELECT '' AS four, @@(b1.f1) AS p
SELECT @@(b1.f1) AS p
FROM BOX_TBL b1;
four | p
------+---------
| (1,1)
| (2,2)
| (-5,-4)
| (2.5,3)
| (3,3)
p
---------
(1,1)
(2,2)
(-5,-4)
(2.5,3)
(3,3)
(5 rows)
-- wholly-contained
SELECT '' AS one, b1.*, b2.*
SELECT b1.*, b2.*
FROM BOX_TBL b1, BOX_TBL b2
WHERE b1.f1 @> b2.f1 and not b1.f1 ~= b2.f1;
one | f1 | f1
-----+-------------+-------------
| (3,3),(1,1) | (3,3),(3,3)
f1 | f1
-------------+-------------
(3,3),(1,1) | (3,3),(3,3)
(1 row)
SELECT '' AS four, height(f1), width(f1) FROM BOX_TBL;
four | height | width
------+--------+-------
| 2 | 2
| 2 | 2
| 12 | 6
| 1 | 0
| 0 | 0
SELECT height(f1), width(f1) FROM BOX_TBL;
height | width
--------+-------
2 | 2
2 | 2
12 | 6
1 | 0
0 | 0
(5 rows)
--
......
......@@ -107,33 +107,33 @@ SELECT CASE 'a' WHEN 'a' THEN 1 ELSE 2 END;
--
-- Examples of targets involving tables
--
SELECT '' AS "Five",
SELECT
CASE
WHEN i >= 3 THEN i
END AS ">= 3 or Null"
FROM CASE_TBL;
Five | >= 3 or Null
------+--------------
|
|
| 3
| 4
>= 3 or Null
--------------
3
4
(4 rows)
SELECT '' AS "Five",
SELECT
CASE WHEN i >= 3 THEN (i + i)
ELSE i
END AS "Simplest Math"
FROM CASE_TBL;
Five | Simplest Math
------+---------------
| 1
| 2
| 6
| 8
Simplest Math
---------------
1
2
6
8
(4 rows)
SELECT '' AS "Five", i AS "Value",
SELECT i AS "Value",
CASE WHEN (i < 0) THEN 'small'
WHEN (i = 0) THEN 'zero'
WHEN (i = 1) THEN 'one'
......@@ -141,15 +141,15 @@ SELECT '' AS "Five", i AS "Value",
ELSE 'big'
END AS "Category"
FROM CASE_TBL;
Five | Value | Category
------+-------+----------
| 1 | one
| 2 | two
| 3 | big
| 4 | big
Value | Category
-------+----------
1 | one
2 | two
3 | big
4 | big
(4 rows)
SELECT '' AS "Five",
SELECT
CASE WHEN ((i < 0) or (i < 0)) THEN 'small'
WHEN ((i = 0) or (i = 0)) THEN 'zero'
WHEN ((i = 1) or (i = 1)) THEN 'one'
......@@ -157,12 +157,12 @@ SELECT '' AS "Five",
ELSE 'big'
END AS "Category"
FROM CASE_TBL;
Five | Category
------+----------
| one
| two
| big
| big
Category
----------
one
two
big
big
(4 rows)
--
......@@ -223,44 +223,44 @@ SELECT *
4 | | 2 | -4
(2 rows)
SELECT '' AS Five, NULLIF(a.i,b.i) AS "NULLIF(a.i,b.i)",
SELECT NULLIF(a.i,b.i) AS "NULLIF(a.i,b.i)",
NULLIF(b.i, 4) AS "NULLIF(b.i,4)"
FROM CASE_TBL a, CASE2_TBL b;
five | NULLIF(a.i,b.i) | NULLIF(b.i,4)
------+-----------------+---------------
| | 1
| 2 | 1
| 3 | 1
| 4 | 1
| 1 | 2
| | 2
| 3 | 2
| 4 | 2
| 1 | 3
| 2 | 3
| | 3
| 4 | 3
| 1 | 2
| | 2
| 3 | 2
| 4 | 2
| | 1
| 2 | 1
| 3 | 1
| 4 | 1
| 1 |
| 2 |
| 3 |
| 4 |
NULLIF(a.i,b.i) | NULLIF(b.i,4)
-----------------+---------------
| 1
2 | 1
3 | 1
4 | 1
1 | 2
| 2
3 | 2
4 | 2
1 | 3
2 | 3
| 3
4 | 3
1 | 2
| 2
3 | 2
4 | 2
| 1
2 | 1
3 | 1
4 | 1
1 |
2 |
3 |
4 |
(24 rows)
SELECT '' AS "Two", *
SELECT *
FROM CASE_TBL a, CASE2_TBL b
WHERE COALESCE(f,b.i) = 2;
Two | i | f | i | j
-----+---+---+---+----
| 4 | | 2 | -2
| 4 | | 2 | -4
i | f | i | j
---+---+---+----
4 | | 2 | -2
4 | | 2 | -4
(2 rows)
--
......
......@@ -25,79 +25,79 @@ INSERT INTO CHAR_TBL (f1) VALUES ('');
INSERT INTO CHAR_TBL (f1) VALUES ('cd');
ERROR: value too long for type character(1)
INSERT INTO CHAR_TBL (f1) VALUES ('c ');
SELECT '' AS seven, * FROM CHAR_TBL;
seven | f1
-------+----
| a
| A
| 1
| 2
| 3
|
| c
SELECT * FROM CHAR_TBL;
f1
----
a
A
1
2
3
c
(7 rows)
SELECT '' AS six, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 <> 'a';
six | f1
-----+----
| A
| 1
| 2
| 3
|
| c
f1
----
A
1
2
3
c
(6 rows)
SELECT '' AS one, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 = 'a';
one | f1
-----+----
| a
f1
----
a
(1 row)
SELECT '' AS five, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 < 'a';
five | f1
------+----
| A
| 1
| 2
| 3
|
f1
----
A
1
2
3
(5 rows)
SELECT '' AS six, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 <= 'a';
six | f1
-----+----
| a
| A
| 1
| 2
| 3
|
f1
----
a
A
1
2
3
(6 rows)
SELECT '' AS one, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 > 'a';
one | f1
-----+----
| c
f1
----
c
(1 row)
SELECT '' AS two, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 >= 'a';
two | f1
-----+----
| a
| c
f1
----
a
c
(2 rows)
DROP TABLE CHAR_TBL;
......@@ -111,12 +111,12 @@ INSERT INTO CHAR_TBL (f1) VALUES ('abcd');
INSERT INTO CHAR_TBL (f1) VALUES ('abcde');
ERROR: value too long for type character(4)
INSERT INTO CHAR_TBL (f1) VALUES ('abcd ');
SELECT '' AS four, * FROM CHAR_TBL;
four | f1
------+------
| a
| ab
| abcd
| abcd
SELECT * FROM CHAR_TBL;
f1
------
a
ab
abcd
abcd
(4 rows)
......@@ -25,79 +25,79 @@ INSERT INTO CHAR_TBL (f1) VALUES ('');
INSERT INTO CHAR_TBL (f1) VALUES ('cd');
ERROR: value too long for type character(1)
INSERT INTO CHAR_TBL (f1) VALUES ('c ');
SELECT '' AS seven, * FROM CHAR_TBL;
seven | f1
-------+----
| a
| A
| 1
| 2
| 3
|
| c
SELECT * FROM CHAR_TBL;
f1
----
a
A
1
2
3
c
(7 rows)
SELECT '' AS six, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 <> 'a';
six | f1
-----+----
| A
| 1
| 2
| 3
|
| c
f1
----
A
1
2
3
c
(6 rows)
SELECT '' AS one, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 = 'a';
one | f1
-----+----
| a
f1
----
a
(1 row)
SELECT '' AS five, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 < 'a';
five | f1
------+----
| 1
| 2
| 3
|
f1
----
1
2
3
(4 rows)
SELECT '' AS six, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 <= 'a';
six | f1
-----+----
| a
| 1
| 2
| 3
|
f1
----
a
1
2
3
(5 rows)
SELECT '' AS one, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 > 'a';
one | f1
-----+----
| A
| c
f1
----
A
c
(2 rows)
SELECT '' AS two, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 >= 'a';
two | f1
-----+----
| a
| A
| c
f1
----
a
A
c
(3 rows)
DROP TABLE CHAR_TBL;
......@@ -111,12 +111,12 @@ INSERT INTO CHAR_TBL (f1) VALUES ('abcd');
INSERT INTO CHAR_TBL (f1) VALUES ('abcde');
ERROR: value too long for type character(4)
INSERT INTO CHAR_TBL (f1) VALUES ('abcd ');
SELECT '' AS four, * FROM CHAR_TBL;
four | f1
------+------
| a
| ab
| abcd
| abcd
SELECT * FROM CHAR_TBL;
f1
------
a
ab
abcd
abcd
(4 rows)
......@@ -25,79 +25,79 @@ INSERT INTO CHAR_TBL (f1) VALUES ('');
INSERT INTO CHAR_TBL (f1) VALUES ('cd');
ERROR: value too long for type character(1)
INSERT INTO CHAR_TBL (f1) VALUES ('c ');
SELECT '' AS seven, * FROM CHAR_TBL;
seven | f1
-------+----
| a
| A
| 1
| 2
| 3
|
| c
SELECT * FROM CHAR_TBL;
f1
----
a
A
1
2
3
c
(7 rows)
SELECT '' AS six, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 <> 'a';
six | f1
-----+----
| A
| 1
| 2
| 3
|
| c
f1
----
A
1
2
3
c
(6 rows)
SELECT '' AS one, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 = 'a';
one | f1
-----+----
| a
f1
----
a
(1 row)
SELECT '' AS five, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 < 'a';
five | f1
------+----
|
f1
----
(1 row)
SELECT '' AS six, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 <= 'a';
six | f1
-----+----
| a
|
f1
----
a
(2 rows)
SELECT '' AS one, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 > 'a';
one | f1
-----+----
| A
| 1
| 2
| 3
| c
f1
----
A
1
2
3
c
(5 rows)
SELECT '' AS two, c.*
SELECT c.*
FROM CHAR_TBL c
WHERE c.f1 >= 'a';
two | f1
-----+----
| a
| A
| 1
| 2
| 3
| c
f1
----
a
A
1
2
3
c
(6 rows)
DROP TABLE CHAR_TBL;
......@@ -111,12 +111,12 @@ INSERT INTO CHAR_TBL (f1) VALUES ('abcd');
INSERT INTO CHAR_TBL (f1) VALUES ('abcde');
ERROR: value too long for type character(4)
INSERT INTO CHAR_TBL (f1) VALUES ('abcd ');
SELECT '' AS four, * FROM CHAR_TBL;
four | f1
------+------
| a
| ab
| abcd
| abcd
SELECT * FROM CHAR_TBL;
f1
------
a
ab
abcd
abcd
(4 rows)
......@@ -47,79 +47,79 @@ SELECT * FROM CIRCLE_TBL;
<(3,5),NaN>
(8 rows)
SELECT '' AS six, center(f1) AS center
SELECT center(f1) AS center
FROM CIRCLE_TBL;
six | center
-----+-----------
| (5,1)
| (1,2)
| (1,3)
| (1,2)
| (100,200)
| (100,1)
| (3,5)
| (3,5)
center
-----------
(5,1)
(1,2)
(1,3)
(1,2)
(100,200)
(100,1)
(3,5)
(3,5)
(8 rows)
SELECT '' AS six, radius(f1) AS radius
SELECT radius(f1) AS radius
FROM CIRCLE_TBL;
six | radius
-----+--------
| 3
| 100
| 5
| 3
| 10
| 115
| 0
| NaN
radius
--------
3
100
5
3
10
115
0
NaN
(8 rows)
SELECT '' AS six, diameter(f1) AS diameter
SELECT diameter(f1) AS diameter
FROM CIRCLE_TBL;
six | diameter
-----+----------
| 6
| 200
| 10
| 6
| 20
| 230
| 0
| NaN
diameter
----------
6
200
10
6
20
230
0
NaN
(8 rows)
SELECT '' AS two, f1 FROM CIRCLE_TBL WHERE radius(f1) < 5;
two | f1
-----+-----------
| <(5,1),3>
| <(1,2),3>
| <(3,5),0>
SELECT f1 FROM CIRCLE_TBL WHERE radius(f1) < 5;
f1
-----------
<(5,1),3>
<(1,2),3>
<(3,5),0>
(3 rows)
SELECT '' AS four, f1 FROM CIRCLE_TBL WHERE diameter(f1) >= 10;
four | f1
------+----------------
| <(1,2),100>
| <(1,3),5>
| <(100,200),10>
| <(100,1),115>
| <(3,5),NaN>
SELECT f1 FROM CIRCLE_TBL WHERE diameter(f1) >= 10;
f1
----------------
<(1,2),100>
<(1,3),5>
<(100,200),10>
<(100,1),115>
<(3,5),NaN>
(5 rows)
SELECT '' as five, c1.f1 AS one, c2.f1 AS two, (c1.f1 <-> c2.f1) AS distance
SELECT c1.f1 AS one, c2.f1 AS two, (c1.f1 <-> c2.f1) AS distance
FROM CIRCLE_TBL c1, CIRCLE_TBL c2
WHERE (c1.f1 < c2.f1) AND ((c1.f1 <-> c2.f1) > 0)
ORDER BY distance, area(c1.f1), area(c2.f1);
five | one | two | distance
------+----------------+----------------+------------------
| <(3,5),0> | <(1,2),3> | 0.60555127546399
| <(3,5),0> | <(5,1),3> | 1.4721359549996
| <(100,200),10> | <(100,1),115> | 74
| <(100,200),10> | <(1,2),100> | 111.37072977248
| <(1,3),5> | <(100,200),10> | 205.4767561445
| <(5,1),3> | <(100,200),10> | 207.51303816328
| <(3,5),0> | <(100,200),10> | 207.79348015953
| <(1,2),3> | <(100,200),10> | 208.37072977248
one | two | distance
----------------+----------------+------------------
<(3,5),0> | <(1,2),3> | 0.60555127546399
<(3,5),0> | <(5,1),3> | 1.4721359549996
<(100,200),10> | <(100,1),115> | 74
<(100,200),10> | <(1,2),100> | 111.37072977248
<(1,3),5> | <(100,200),10> | 205.4767561445
<(5,1),3> | <(100,200),10> | 207.51303816328
<(3,5),0> | <(100,200),10> | 207.79348015953
<(1,2),3> | <(100,200),10> | 208.37072977248
(8 rows)
......@@ -161,136 +161,136 @@ SELECT 'nan'::numeric::float4;
NaN
(1 row)
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e+20
| 1.2345679e-20
SELECT * FROM FLOAT4_TBL;
f1
---------------
0
1004.3
-34.84
1.2345679e+20
1.2345679e-20
(5 rows)
SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <> '1004.3';
four | f1
------+---------------
| 0
| -34.84
| 1.2345679e+20
| 1.2345679e-20
SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 <> '1004.3';
f1
---------------
0
-34.84
1.2345679e+20
1.2345679e-20
(4 rows)
SELECT '' AS one, f.* FROM FLOAT4_TBL f WHERE f.f1 = '1004.3';
one | f1
-----+--------
| 1004.3
SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 = '1004.3';
f1
--------
1004.3
(1 row)
SELECT '' AS three, f.* FROM FLOAT4_TBL f WHERE '1004.3' > f.f1;
three | f1
-------+---------------
| 0
| -34.84
| 1.2345679e-20
SELECT f.* FROM FLOAT4_TBL f WHERE '1004.3' > f.f1;
f1
---------------
0
-34.84
1.2345679e-20
(3 rows)
SELECT '' AS three, f.* FROM FLOAT4_TBL f WHERE f.f1 < '1004.3';
three | f1
-------+---------------
| 0
| -34.84
| 1.2345679e-20
SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 < '1004.3';
f1
---------------
0
-34.84
1.2345679e-20
(3 rows)
SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE '1004.3' >= f.f1;
four | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e-20
SELECT f.* FROM FLOAT4_TBL f WHERE '1004.3' >= f.f1;
f1
---------------
0
1004.3
-34.84
1.2345679e-20
(4 rows)
SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <= '1004.3';
four | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e-20
SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 <= '1004.3';
f1
---------------
0
1004.3
-34.84
1.2345679e-20
(4 rows)
SELECT '' AS three, f.f1, f.f1 * '-10' AS x FROM FLOAT4_TBL f
SELECT f.f1, f.f1 * '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+---------------+----------------
| 1004.3 | -10043
| 1.2345679e+20 | -1.2345678e+21
| 1.2345679e-20 | -1.2345678e-19
f1 | x
---------------+----------------
1004.3 | -10043
1.2345679e+20 | -1.2345678e+21
1.2345679e-20 | -1.2345678e-19
(3 rows)
SELECT '' AS three, f.f1, f.f1 + '-10' AS x FROM FLOAT4_TBL f
SELECT f.f1, f.f1 + '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+---------------+---------------
| 1004.3 | 994.3
| 1.2345679e+20 | 1.2345679e+20
| 1.2345679e-20 | -10
f1 | x
---------------+---------------
1004.3 | 994.3
1.2345679e+20 | 1.2345679e+20
1.2345679e-20 | -10
(3 rows)
SELECT '' AS three, f.f1, f.f1 / '-10' AS x FROM FLOAT4_TBL f
SELECT f.f1, f.f1 / '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+---------------+----------------
| 1004.3 | -100.43
| 1.2345679e+20 | -1.2345679e+19
| 1.2345679e-20 | -1.2345679e-21
f1 | x
---------------+----------------
1004.3 | -100.43
1.2345679e+20 | -1.2345679e+19
1.2345679e-20 | -1.2345679e-21
(3 rows)
SELECT '' AS three, f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f
SELECT f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+---------------+---------------
| 1004.3 | 1014.3
| 1.2345679e+20 | 1.2345679e+20
| 1.2345679e-20 | 10
f1 | x
---------------+---------------
1004.3 | 1014.3
1.2345679e+20 | 1.2345679e+20
1.2345679e-20 | 10
(3 rows)
-- test divide by zero
SELECT '' AS bad, f.f1 / '0.0' from FLOAT4_TBL f;
SELECT f.f1 / '0.0' from FLOAT4_TBL f;
ERROR: division by zero
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e+20
| 1.2345679e-20
SELECT * FROM FLOAT4_TBL;
f1
---------------
0
1004.3
-34.84
1.2345679e+20
1.2345679e-20
(5 rows)
-- test the unary float4abs operator
SELECT '' AS five, f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f;
five | f1 | abs_f1
------+---------------+---------------
| 0 | 0
| 1004.3 | 1004.3
| -34.84 | 34.84
| 1.2345679e+20 | 1.2345679e+20
| 1.2345679e-20 | 1.2345679e-20
SELECT f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f;
f1 | abs_f1
---------------+---------------
0 | 0
1004.3 | 1004.3
-34.84 | 34.84
1.2345679e+20 | 1.2345679e+20
1.2345679e-20 | 1.2345679e-20
(5 rows)
UPDATE FLOAT4_TBL
SET f1 = FLOAT4_TBL.f1 * '-1'
WHERE FLOAT4_TBL.f1 > '0.0';
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+----------------
| 0
| -34.84
| -1004.3
| -1.2345679e+20
| -1.2345679e-20
SELECT * FROM FLOAT4_TBL;
f1
----------------
0
-34.84
-1004.3
-1.2345679e+20
-1.2345679e-20
(5 rows)
-- test edge-case coercions to integer
......
......@@ -161,136 +161,136 @@ SELECT 'nan'::numeric::float4;
NaN
(1 row)
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e+20
| 1.2345679e-20
SELECT * FROM FLOAT4_TBL;
f1
---------------
0
1004.3
-34.84
1.2345679e+20
1.2345679e-20
(5 rows)
SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <> '1004.3';
four | f1
------+---------------
| 0
| -34.84
| 1.2345679e+20
| 1.2345679e-20
SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 <> '1004.3';
f1
---------------
0
-34.84
1.2345679e+20
1.2345679e-20
(4 rows)
SELECT '' AS one, f.* FROM FLOAT4_TBL f WHERE f.f1 = '1004.3';
one | f1
-----+--------
| 1004.3
SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 = '1004.3';
f1
--------
1004.3
(1 row)
SELECT '' AS three, f.* FROM FLOAT4_TBL f WHERE '1004.3' > f.f1;
three | f1
-------+---------------
| 0
| -34.84
| 1.2345679e-20
SELECT f.* FROM FLOAT4_TBL f WHERE '1004.3' > f.f1;
f1
---------------
0
-34.84
1.2345679e-20
(3 rows)
SELECT '' AS three, f.* FROM FLOAT4_TBL f WHERE f.f1 < '1004.3';
three | f1
-------+---------------
| 0
| -34.84
| 1.2345679e-20
SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 < '1004.3';
f1
---------------
0
-34.84
1.2345679e-20
(3 rows)
SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE '1004.3' >= f.f1;
four | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e-20
SELECT f.* FROM FLOAT4_TBL f WHERE '1004.3' >= f.f1;
f1
---------------
0
1004.3
-34.84
1.2345679e-20
(4 rows)
SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <= '1004.3';
four | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e-20
SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 <= '1004.3';
f1
---------------
0
1004.3
-34.84
1.2345679e-20
(4 rows)
SELECT '' AS three, f.f1, f.f1 * '-10' AS x FROM FLOAT4_TBL f
SELECT f.f1, f.f1 * '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+---------------+----------------
| 1004.3 | -10043
| 1.2345679e+20 | -1.2345678e+21
| 1.2345679e-20 | -1.2345678e-19
f1 | x
---------------+----------------
1004.3 | -10043
1.2345679e+20 | -1.2345678e+21
1.2345679e-20 | -1.2345678e-19
(3 rows)
SELECT '' AS three, f.f1, f.f1 + '-10' AS x FROM FLOAT4_TBL f
SELECT f.f1, f.f1 + '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+---------------+---------------
| 1004.3 | 994.3
| 1.2345679e+20 | 1.2345679e+20
| 1.2345679e-20 | -10
f1 | x
---------------+---------------
1004.3 | 994.3
1.2345679e+20 | 1.2345679e+20
1.2345679e-20 | -10
(3 rows)
SELECT '' AS three, f.f1, f.f1 / '-10' AS x FROM FLOAT4_TBL f
SELECT f.f1, f.f1 / '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+---------------+----------------
| 1004.3 | -100.43
| 1.2345679e+20 | -1.2345679e+19
| 1.2345679e-20 | -1.2345679e-21
f1 | x
---------------+----------------
1004.3 | -100.43
1.2345679e+20 | -1.2345679e+19
1.2345679e-20 | -1.2345679e-21
(3 rows)
SELECT '' AS three, f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f
SELECT f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
three | f1 | x
-------+---------------+---------------
| 1004.3 | 1014.3
| 1.2345679e+20 | 1.2345679e+20
| 1.2345679e-20 | 10
f1 | x
---------------+---------------
1004.3 | 1014.3
1.2345679e+20 | 1.2345679e+20
1.2345679e-20 | 10
(3 rows)
-- test divide by zero
SELECT '' AS bad, f.f1 / '0.0' from FLOAT4_TBL f;
SELECT f.f1 / '0.0' from FLOAT4_TBL f;
ERROR: division by zero
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e+20
| 1.2345679e-20
SELECT * FROM FLOAT4_TBL;
f1
---------------
0
1004.3
-34.84
1.2345679e+20
1.2345679e-20
(5 rows)
-- test the unary float4abs operator
SELECT '' AS five, f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f;
five | f1 | abs_f1
------+---------------+---------------
| 0 | 0
| 1004.3 | 1004.3
| -34.84 | 34.84
| 1.2345679e+20 | 1.2345679e+20
| 1.2345679e-20 | 1.2345679e-20
SELECT f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f;
f1 | abs_f1
---------------+---------------
0 | 0
1004.3 | 1004.3
-34.84 | 34.84
1.2345679e+20 | 1.2345679e+20
1.2345679e-20 | 1.2345679e-20
(5 rows)
UPDATE FLOAT4_TBL
SET f1 = FLOAT4_TBL.f1 * '-1'
WHERE FLOAT4_TBL.f1 > '0.0';
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+----------------
| 0
| -34.84
| -1004.3
| -1.2345679e+20
| -1.2345679e-20
SELECT * FROM FLOAT4_TBL;
f1
----------------
0
-34.84
-1004.3
-1.2345679e+20
-1.2345679e-20
(5 rows)
-- test edge-case coercions to integer
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -41,205 +41,205 @@ INSERT INTO INT2_TBL(f1) VALUES ('');
ERROR: invalid input syntax for type smallint: ""
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('');
^
SELECT '' AS five, * FROM INT2_TBL;
five | f1
------+--------
| 0
| 1234
| -1234
| 32767
| -32767
SELECT * FROM INT2_TBL;
f1
--------
0
1234
-1234
32767
-32767
(5 rows)
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int2 '0';
four | f1
------+--------
| 1234
| -1234
| 32767
| -32767
SELECT i.* FROM INT2_TBL i WHERE i.f1 <> int2 '0';
f1
--------
1234
-1234
32767
-32767
(4 rows)
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int4 '0';
four | f1
------+--------
| 1234
| -1234
| 32767
| -32767
SELECT i.* FROM INT2_TBL i WHERE i.f1 <> int4 '0';
f1
--------
1234
-1234
32767
-32767
(4 rows)
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int2 '0';
one | f1
-----+----
| 0
SELECT i.* FROM INT2_TBL i WHERE i.f1 = int2 '0';
f1
----
0
(1 row)
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int4 '0';
one | f1
-----+----
| 0
SELECT i.* FROM INT2_TBL i WHERE i.f1 = int4 '0';
f1
----
0
(1 row)
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int2 '0';
two | f1
-----+--------
| -1234
| -32767
SELECT i.* FROM INT2_TBL i WHERE i.f1 < int2 '0';
f1
--------
-1234
-32767
(2 rows)
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int4 '0';
two | f1
-----+--------
| -1234
| -32767
SELECT i.* FROM INT2_TBL i WHERE i.f1 < int4 '0';
f1
--------
-1234
-32767
(2 rows)
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int2 '0';
three | f1
-------+--------
| 0
| -1234
| -32767
SELECT i.* FROM INT2_TBL i WHERE i.f1 <= int2 '0';
f1
--------
0
-1234
-32767
(3 rows)
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int4 '0';
three | f1
-------+--------
| 0
| -1234
| -32767
SELECT i.* FROM INT2_TBL i WHERE i.f1 <= int4 '0';
f1
--------
0
-1234
-32767
(3 rows)
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int2 '0';
two | f1
-----+-------
| 1234
| 32767
SELECT i.* FROM INT2_TBL i WHERE i.f1 > int2 '0';
f1
-------
1234
32767
(2 rows)
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int4 '0';
two | f1
-----+-------
| 1234
| 32767
SELECT i.* FROM INT2_TBL i WHERE i.f1 > int4 '0';
f1
-------
1234
32767
(2 rows)
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int2 '0';
three | f1
-------+-------
| 0
| 1234
| 32767
SELECT i.* FROM INT2_TBL i WHERE i.f1 >= int2 '0';
f1
-------
0
1234
32767
(3 rows)
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int4 '0';
three | f1
-------+-------
| 0
| 1234
| 32767
SELECT i.* FROM INT2_TBL i WHERE i.f1 >= int4 '0';
f1
-------
0
1234
32767
(3 rows)
-- positive odds
SELECT '' AS one, i.* FROM INT2_TBL i WHERE (i.f1 % int2 '2') = int2 '1';
one | f1
-----+-------
| 32767
SELECT i.* FROM INT2_TBL i WHERE (i.f1 % int2 '2') = int2 '1';
f1
-------
32767
(1 row)
-- any evens
SELECT '' AS three, i.* FROM INT2_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
three | f1
-------+-------
| 0
| 1234
| -1234
SELECT i.* FROM INT2_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
f1
-------
0
1234
-1234
(3 rows)
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i;
SELECT i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i;
ERROR: smallint out of range
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i
SELECT i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i
WHERE abs(f1) < 16384;
five | f1 | x
------+-------+-------
| 0 | 0
| 1234 | 2468
| -1234 | -2468
f1 | x
-------+-------
0 | 0
1234 | 2468
-1234 | -2468
(3 rows)
SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT2_TBL i;
five | f1 | x
------+--------+--------
| 0 | 0
| 1234 | 2468
| -1234 | -2468
| 32767 | 65534
| -32767 | -65534
SELECT i.f1, i.f1 * int4 '2' AS x FROM INT2_TBL i;
f1 | x
--------+--------
0 | 0
1234 | 2468
-1234 | -2468
32767 | 65534
-32767 | -65534
(5 rows)
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i;
SELECT i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i;
ERROR: smallint out of range
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i
SELECT i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i
WHERE f1 < 32766;
five | f1 | x
------+--------+--------
| 0 | 2
| 1234 | 1236
| -1234 | -1232
| -32767 | -32765
f1 | x
--------+--------
0 | 2
1234 | 1236
-1234 | -1232
-32767 | -32765
(4 rows)
SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT2_TBL i;
five | f1 | x
------+--------+--------
| 0 | 2
| 1234 | 1236
| -1234 | -1232
| 32767 | 32769
| -32767 | -32765
SELECT i.f1, i.f1 + int4 '2' AS x FROM INT2_TBL i;
f1 | x
--------+--------
0 | 2
1234 | 1236
-1234 | -1232
32767 | 32769
-32767 | -32765
(5 rows)
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i;
SELECT i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i;
ERROR: smallint out of range
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i
SELECT i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i
WHERE f1 > -32767;
five | f1 | x
------+-------+-------
| 0 | -2
| 1234 | 1232
| -1234 | -1236
| 32767 | 32765
f1 | x
-------+-------
0 | -2
1234 | 1232
-1234 | -1236
32767 | 32765
(4 rows)
SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT2_TBL i;
five | f1 | x
------+--------+--------
| 0 | -2
| 1234 | 1232
| -1234 | -1236
| 32767 | 32765
| -32767 | -32769
SELECT i.f1, i.f1 - int4 '2' AS x FROM INT2_TBL i;
f1 | x
--------+--------
0 | -2
1234 | 1232
-1234 | -1236
32767 | 32765
-32767 | -32769
(5 rows)
SELECT '' AS five, i.f1, i.f1 / int2 '2' AS x FROM INT2_TBL i;
five | f1 | x
------+--------+--------
| 0 | 0
| 1234 | 617
| -1234 | -617
| 32767 | 16383
| -32767 | -16383
SELECT i.f1, i.f1 / int2 '2' AS x FROM INT2_TBL i;
f1 | x
--------+--------
0 | 0
1234 | 617
-1234 | -617
32767 | 16383
-32767 | -16383
(5 rows)
SELECT '' AS five, i.f1, i.f1 / int4 '2' AS x FROM INT2_TBL i;
five | f1 | x
------+--------+--------
| 0 | 0
| 1234 | 617
| -1234 | -617
| 32767 | 16383
| -32767 | -16383
SELECT i.f1, i.f1 / int4 '2' AS x FROM INT2_TBL i;
f1 | x
--------+--------
0 | 0
1234 | 617
-1234 | -617
32767 | 16383
-32767 | -16383
(5 rows)
-- corner cases
......
......@@ -41,210 +41,210 @@ INSERT INTO INT4_TBL(f1) VALUES ('');
ERROR: invalid input syntax for type integer: ""
LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('');
^
SELECT '' AS five, * FROM INT4_TBL;
five | f1
------+-------------
| 0
| 123456
| -123456
| 2147483647
| -2147483647
SELECT * FROM INT4_TBL;
f1
-------------
0
123456
-123456
2147483647
-2147483647
(5 rows)
SELECT '' AS four, i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0';
four | f1
------+-------------
| 123456
| -123456
| 2147483647
| -2147483647
SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0';
f1
-------------
123456
-123456
2147483647
-2147483647
(4 rows)
SELECT '' AS four, i.* FROM INT4_TBL i WHERE i.f1 <> int4 '0';
four | f1
------+-------------
| 123456
| -123456
| 2147483647
| -2147483647
SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int4 '0';
f1
-------------
123456
-123456
2147483647
-2147483647
(4 rows)
SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int2 '0';
one | f1
-----+----
| 0
SELECT i.* FROM INT4_TBL i WHERE i.f1 = int2 '0';
f1
----
0
(1 row)
SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int4 '0';
one | f1
-----+----
| 0
SELECT i.* FROM INT4_TBL i WHERE i.f1 = int4 '0';
f1
----
0
(1 row)
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int2 '0';
two | f1
-----+-------------
| -123456
| -2147483647
SELECT i.* FROM INT4_TBL i WHERE i.f1 < int2 '0';
f1
-------------
-123456
-2147483647
(2 rows)
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int4 '0';
two | f1
-----+-------------
| -123456
| -2147483647
SELECT i.* FROM INT4_TBL i WHERE i.f1 < int4 '0';
f1
-------------
-123456
-2147483647
(2 rows)
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int2 '0';
three | f1
-------+-------------
| 0
| -123456
| -2147483647
SELECT i.* FROM INT4_TBL i WHERE i.f1 <= int2 '0';
f1
-------------
0
-123456
-2147483647
(3 rows)
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int4 '0';
three | f1
-------+-------------
| 0
| -123456
| -2147483647
SELECT i.* FROM INT4_TBL i WHERE i.f1 <= int4 '0';
f1
-------------
0
-123456
-2147483647
(3 rows)
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int2 '0';
two | f1
-----+------------
| 123456
| 2147483647
SELECT i.* FROM INT4_TBL i WHERE i.f1 > int2 '0';
f1
------------
123456
2147483647
(2 rows)
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int4 '0';
two | f1
-----+------------
| 123456
| 2147483647
SELECT i.* FROM INT4_TBL i WHERE i.f1 > int4 '0';
f1
------------
123456
2147483647
(2 rows)
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int2 '0';
three | f1
-------+------------
| 0
| 123456
| 2147483647
SELECT i.* FROM INT4_TBL i WHERE i.f1 >= int2 '0';
f1
------------
0
123456
2147483647
(3 rows)
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int4 '0';
three | f1
-------+------------
| 0
| 123456
| 2147483647
SELECT i.* FROM INT4_TBL i WHERE i.f1 >= int4 '0';
f1
------------
0
123456
2147483647
(3 rows)
-- positive odds
SELECT '' AS one, i.* FROM INT4_TBL i WHERE (i.f1 % int2 '2') = int2 '1';
one | f1
-----+------------
| 2147483647
SELECT i.* FROM INT4_TBL i WHERE (i.f1 % int2 '2') = int2 '1';
f1
------------
2147483647
(1 row)
-- any evens
SELECT '' AS three, i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
three | f1
-------+---------
| 0
| 123456
| -123456
SELECT i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
f1
---------
0
123456
-123456
(3 rows)
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i;
SELECT i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i;
ERROR: integer out of range
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i
SELECT i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i
WHERE abs(f1) < 1073741824;
five | f1 | x
------+---------+---------
| 0 | 0
| 123456 | 246912
| -123456 | -246912
f1 | x
---------+---------
0 | 0
123456 | 246912
-123456 | -246912
(3 rows)
SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i;
SELECT i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i;
ERROR: integer out of range
SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i
SELECT i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i
WHERE abs(f1) < 1073741824;
five | f1 | x
------+---------+---------
| 0 | 0
| 123456 | 246912
| -123456 | -246912
f1 | x
---------+---------
0 | 0
123456 | 246912
-123456 | -246912
(3 rows)
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i;
SELECT i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i;
ERROR: integer out of range
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i
SELECT i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i
WHERE f1 < 2147483646;
five | f1 | x
------+-------------+-------------
| 0 | 2
| 123456 | 123458
| -123456 | -123454
| -2147483647 | -2147483645
f1 | x
-------------+-------------
0 | 2
123456 | 123458
-123456 | -123454
-2147483647 | -2147483645
(4 rows)
SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i;
SELECT i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i;
ERROR: integer out of range
SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i
SELECT i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i
WHERE f1 < 2147483646;
five | f1 | x
------+-------------+-------------
| 0 | 2
| 123456 | 123458
| -123456 | -123454
| -2147483647 | -2147483645
f1 | x
-------------+-------------
0 | 2
123456 | 123458
-123456 | -123454
-2147483647 | -2147483645
(4 rows)
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i;
SELECT i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i;
ERROR: integer out of range
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i
SELECT i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i
WHERE f1 > -2147483647;
five | f1 | x
------+------------+------------
| 0 | -2
| 123456 | 123454
| -123456 | -123458
| 2147483647 | 2147483645
f1 | x
------------+------------
0 | -2
123456 | 123454
-123456 | -123458
2147483647 | 2147483645
(4 rows)
SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i;
SELECT i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i;
ERROR: integer out of range
SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i
SELECT i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i
WHERE f1 > -2147483647;
five | f1 | x
------+------------+------------
| 0 | -2
| 123456 | 123454
| -123456 | -123458
| 2147483647 | 2147483645
f1 | x
------------+------------
0 | -2
123456 | 123454
-123456 | -123458
2147483647 | 2147483645
(4 rows)
SELECT '' AS five, i.f1, i.f1 / int2 '2' AS x FROM INT4_TBL i;
five | f1 | x
------+-------------+-------------
| 0 | 0
| 123456 | 61728
| -123456 | -61728
| 2147483647 | 1073741823
| -2147483647 | -1073741823
SELECT i.f1, i.f1 / int2 '2' AS x FROM INT4_TBL i;
f1 | x
-------------+-------------
0 | 0
123456 | 61728
-123456 | -61728
2147483647 | 1073741823
-2147483647 | -1073741823
(5 rows)
SELECT '' AS five, i.f1, i.f1 / int4 '2' AS x FROM INT4_TBL i;
five | f1 | x
------+-------------+-------------
| 0 | 0
| 123456 | 61728
| -123456 | -61728
| 2147483647 | 1073741823
| -2147483647 | -1073741823
SELECT i.f1, i.f1 / int4 '2' AS x FROM INT4_TBL i;
f1 | x
-------------+-------------
0 | 0
123456 | 61728
-123456 | -61728
2147483647 | 1073741823
-2147483647 | -1073741823
(5 rows)
--
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -26,101 +26,101 @@ INSERT INTO NAME_TBL(f1) VALUES ('343f%2a');
INSERT INTO NAME_TBL(f1) VALUES ('d34aaasdf');
INSERT INTO NAME_TBL(f1) VALUES ('');
INSERT INTO NAME_TBL(f1) VALUES ('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ');
SELECT '' AS seven, * FROM NAME_TBL;
seven | f1
-------+-----------------------------------------------------------------
| 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
| 1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
| asdfghjkl;
| 343f%2a
| d34aaasdf
|
| 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
SELECT * FROM NAME_TBL;
f1
-----------------------------------------------------------------
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
asdfghjkl;
343f%2a
d34aaasdf
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
(7 rows)
SELECT '' AS six, c.f1 FROM NAME_TBL c WHERE c.f1 <> '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
six | f1
-----+-----------------------------------------------------------------
| 1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
| asdfghjkl;
| 343f%2a
| d34aaasdf
|
SELECT c.f1 FROM NAME_TBL c WHERE c.f1 <> '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
f1
-----------------------------------------------------------------
1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
asdfghjkl;
343f%2a
d34aaasdf
(5 rows)
SELECT '' AS one, c.f1 FROM NAME_TBL c WHERE c.f1 = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
one | f1
-----+-----------------------------------------------------------------
| 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
| 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
SELECT c.f1 FROM NAME_TBL c WHERE c.f1 = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
f1
-----------------------------------------------------------------
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
(2 rows)
SELECT '' AS three, c.f1 FROM NAME_TBL c WHERE c.f1 < '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
three | f1
-------+----
|
SELECT c.f1 FROM NAME_TBL c WHERE c.f1 < '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
f1
----
(1 row)
SELECT '' AS four, c.f1 FROM NAME_TBL c WHERE c.f1 <= '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
four | f1
------+-----------------------------------------------------------------
| 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
|
| 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
SELECT c.f1 FROM NAME_TBL c WHERE c.f1 <= '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
f1
-----------------------------------------------------------------
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
(3 rows)
SELECT '' AS three, c.f1 FROM NAME_TBL c WHERE c.f1 > '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
three | f1
-------+-----------------------------------------------------------------
| 1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
| asdfghjkl;
| 343f%2a
| d34aaasdf
SELECT c.f1 FROM NAME_TBL c WHERE c.f1 > '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
f1
-----------------------------------------------------------------
1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
asdfghjkl;
343f%2a
d34aaasdf
(4 rows)
SELECT '' AS four, c.f1 FROM NAME_TBL c WHERE c.f1 >= '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
four | f1
------+-----------------------------------------------------------------
| 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
| 1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
| asdfghjkl;
| 343f%2a
| d34aaasdf
| 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
SELECT c.f1 FROM NAME_TBL c WHERE c.f1 >= '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
f1
-----------------------------------------------------------------
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
asdfghjkl;
343f%2a
d34aaasdf
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
(6 rows)
SELECT '' AS seven, c.f1 FROM NAME_TBL c WHERE c.f1 ~ '.*';
seven | f1
-------+-----------------------------------------------------------------
| 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
| 1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
| asdfghjkl;
| 343f%2a
| d34aaasdf
|
| 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
SELECT c.f1 FROM NAME_TBL c WHERE c.f1 ~ '.*';
f1
-----------------------------------------------------------------
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
asdfghjkl;
343f%2a
d34aaasdf
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
(7 rows)
SELECT '' AS zero, c.f1 FROM NAME_TBL c WHERE c.f1 !~ '.*';
zero | f1
------+----
SELECT c.f1 FROM NAME_TBL c WHERE c.f1 !~ '.*';
f1
----
(0 rows)
SELECT '' AS three, c.f1 FROM NAME_TBL c WHERE c.f1 ~ '[0-9]';
three | f1
-------+-----------------------------------------------------------------
| 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
| 1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
| 343f%2a
| d34aaasdf
| 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
SELECT c.f1 FROM NAME_TBL c WHERE c.f1 ~ '[0-9]';
f1
-----------------------------------------------------------------
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
343f%2a
d34aaasdf
1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
(5 rows)
SELECT '' AS two, c.f1 FROM NAME_TBL c WHERE c.f1 ~ '.*asdf.*';
two | f1
-----+------------
| asdfghjkl;
| d34aaasdf
SELECT c.f1 FROM NAME_TBL c WHERE c.f1 ~ '.*asdf.*';
f1
------------
asdfghjkl;
d34aaasdf
(2 rows)
DROP TABLE NAME_TBL;
......
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.
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.
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.
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.
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