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