Use a fixed error message for ERANGE to avoid duplicate test result files.
Add some resultmap entries for SCO OpenServer.
This commit is contained in:
parent
80185f4b5b
commit
bf51b8608b
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.87 2001/06/20 18:07:56 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.88 2001/08/06 21:55:13 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -720,7 +720,11 @@ static const char *useful_strerror(int errnum)
|
||||
static char errorstr_buf[48];
|
||||
char *str;
|
||||
|
||||
str = strerror(errnum);
|
||||
if (errnum == ERANGE)
|
||||
/* small trick to save creating many regression test result files */
|
||||
str = gettext("Numerical result out of range");
|
||||
else
|
||||
str = strerror(errnum);
|
||||
|
||||
/*
|
||||
* Some strerror()s return an empty string for out-of-range errno.
|
||||
|
@ -1,215 +0,0 @@
|
||||
--
|
||||
-- INT2
|
||||
-- NOTE: int2 operators never check for over/underflow!
|
||||
-- Some of these answers are consequently numerically incorrect.
|
||||
--
|
||||
CREATE TABLE INT2_TBL(f1 int2);
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('0');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('1234');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('-1234');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
|
||||
ERROR: pg_atoi: error in "34.5": can't parse ".5"
|
||||
-- largest and smallest values
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('32767');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('-32767');
|
||||
-- bad input values -- should give warnings
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('100000');
|
||||
ERROR: pg_atoi: error reading "100000": Math result out of range
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
|
||||
ERROR: pg_atoi: error in "asdf": can't parse "asdf"
|
||||
SELECT '' AS five, INT2_TBL.*;
|
||||
five | 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
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int4 '0';
|
||||
four | f1
|
||||
------+--------
|
||||
| 1234
|
||||
| -1234
|
||||
| 32767
|
||||
| -32767
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int2 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int4 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int2 '0';
|
||||
two | f1
|
||||
-----+--------
|
||||
| -1234
|
||||
| -32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int4 '0';
|
||||
two | f1
|
||||
-----+--------
|
||||
| -1234
|
||||
| -32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int2 '0';
|
||||
three | f1
|
||||
-------+--------
|
||||
| 0
|
||||
| -1234
|
||||
| -32767
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int4 '0';
|
||||
three | f1
|
||||
-------+--------
|
||||
| 0
|
||||
| -1234
|
||||
| -32767
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int2 '0';
|
||||
two | f1
|
||||
-----+-------
|
||||
| 1234
|
||||
| 32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int4 '0';
|
||||
two | f1
|
||||
-----+-------
|
||||
| 1234
|
||||
| 32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int2 '0';
|
||||
three | f1
|
||||
-------+-------
|
||||
| 0
|
||||
| 1234
|
||||
| 32767
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int4 '0';
|
||||
three | 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
|
||||
(1 row)
|
||||
|
||||
-- any evens
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
|
||||
three | f1
|
||||
-------+-------
|
||||
| 0
|
||||
| 1234
|
||||
| -1234
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+-------
|
||||
| 0 | 0
|
||||
| 1234 | 2468
|
||||
| -1234 | -2468
|
||||
| 32767 | -2
|
||||
| -32767 | 2
|
||||
(5 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
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+--------
|
||||
| 0 | 2
|
||||
| 1234 | 1236
|
||||
| -1234 | -1232
|
||||
| 32767 | -32767
|
||||
| -32767 | -32765
|
||||
(5 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
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+-------
|
||||
| 0 | -2
|
||||
| 1234 | 1232
|
||||
| -1234 | -1236
|
||||
| 32767 | 32765
|
||||
| -32767 | 32767
|
||||
(5 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
|
||||
(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
|
||||
(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
|
||||
(5 rows)
|
||||
|
@ -1,215 +0,0 @@
|
||||
--
|
||||
-- INT2
|
||||
-- NOTE: int2 operators never check for over/underflow!
|
||||
-- Some of these answers are consequently numerically incorrect.
|
||||
--
|
||||
CREATE TABLE INT2_TBL(f1 int2);
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('0');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('1234');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('-1234');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
|
||||
ERROR: pg_atoi: error in "34.5": can't parse ".5"
|
||||
-- largest and smallest values
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('32767');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('-32767');
|
||||
-- bad input values -- should give warnings
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('100000');
|
||||
ERROR: pg_atoi: error reading "100000": Math result not representable
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
|
||||
ERROR: pg_atoi: error in "asdf": can't parse "asdf"
|
||||
SELECT '' AS five, INT2_TBL.*;
|
||||
five | 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
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int4 '0';
|
||||
four | f1
|
||||
------+--------
|
||||
| 1234
|
||||
| -1234
|
||||
| 32767
|
||||
| -32767
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int2 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int4 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int2 '0';
|
||||
two | f1
|
||||
-----+--------
|
||||
| -1234
|
||||
| -32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int4 '0';
|
||||
two | f1
|
||||
-----+--------
|
||||
| -1234
|
||||
| -32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int2 '0';
|
||||
three | f1
|
||||
-------+--------
|
||||
| 0
|
||||
| -1234
|
||||
| -32767
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int4 '0';
|
||||
three | f1
|
||||
-------+--------
|
||||
| 0
|
||||
| -1234
|
||||
| -32767
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int2 '0';
|
||||
two | f1
|
||||
-----+-------
|
||||
| 1234
|
||||
| 32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int4 '0';
|
||||
two | f1
|
||||
-----+-------
|
||||
| 1234
|
||||
| 32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int2 '0';
|
||||
three | f1
|
||||
-------+-------
|
||||
| 0
|
||||
| 1234
|
||||
| 32767
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int4 '0';
|
||||
three | 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
|
||||
(1 row)
|
||||
|
||||
-- any evens
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
|
||||
three | f1
|
||||
-------+-------
|
||||
| 0
|
||||
| 1234
|
||||
| -1234
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+-------
|
||||
| 0 | 0
|
||||
| 1234 | 2468
|
||||
| -1234 | -2468
|
||||
| 32767 | -2
|
||||
| -32767 | 2
|
||||
(5 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
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+--------
|
||||
| 0 | 2
|
||||
| 1234 | 1236
|
||||
| -1234 | -1232
|
||||
| 32767 | -32767
|
||||
| -32767 | -32765
|
||||
(5 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
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+-------
|
||||
| 0 | -2
|
||||
| 1234 | 1232
|
||||
| -1234 | -1236
|
||||
| 32767 | 32765
|
||||
| -32767 | 32767
|
||||
(5 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
|
||||
(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
|
||||
(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
|
||||
(5 rows)
|
||||
|
@ -1,215 +0,0 @@
|
||||
--
|
||||
-- INT2
|
||||
-- NOTE: int2 operators never check for over/underflow!
|
||||
-- Some of these answers are consequently numerically incorrect.
|
||||
--
|
||||
CREATE TABLE INT2_TBL(f1 int2);
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('0');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('1234');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('-1234');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
|
||||
ERROR: pg_atoi: error in "34.5": can't parse ".5"
|
||||
-- largest and smallest values
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('32767');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('-32767');
|
||||
-- bad input values -- should give warnings
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('100000');
|
||||
ERROR: pg_atoi: error reading "100000": Range Error
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
|
||||
ERROR: pg_atoi: error in "asdf": can't parse "asdf"
|
||||
SELECT '' AS five, INT2_TBL.*;
|
||||
five | 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
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int4 '0';
|
||||
four | f1
|
||||
------+--------
|
||||
| 1234
|
||||
| -1234
|
||||
| 32767
|
||||
| -32767
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int2 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int4 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int2 '0';
|
||||
two | f1
|
||||
-----+--------
|
||||
| -1234
|
||||
| -32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int4 '0';
|
||||
two | f1
|
||||
-----+--------
|
||||
| -1234
|
||||
| -32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int2 '0';
|
||||
three | f1
|
||||
-------+--------
|
||||
| 0
|
||||
| -1234
|
||||
| -32767
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int4 '0';
|
||||
three | f1
|
||||
-------+--------
|
||||
| 0
|
||||
| -1234
|
||||
| -32767
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int2 '0';
|
||||
two | f1
|
||||
-----+-------
|
||||
| 1234
|
||||
| 32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int4 '0';
|
||||
two | f1
|
||||
-----+-------
|
||||
| 1234
|
||||
| 32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int2 '0';
|
||||
three | f1
|
||||
-------+-------
|
||||
| 0
|
||||
| 1234
|
||||
| 32767
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int4 '0';
|
||||
three | 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
|
||||
(1 row)
|
||||
|
||||
-- any evens
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
|
||||
three | f1
|
||||
-------+-------
|
||||
| 0
|
||||
| 1234
|
||||
| -1234
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+-------
|
||||
| 0 | 0
|
||||
| 1234 | 2468
|
||||
| -1234 | -2468
|
||||
| 32767 | -2
|
||||
| -32767 | 2
|
||||
(5 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
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+--------
|
||||
| 0 | 2
|
||||
| 1234 | 1236
|
||||
| -1234 | -1232
|
||||
| 32767 | -32767
|
||||
| -32767 | -32765
|
||||
(5 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
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+-------
|
||||
| 0 | -2
|
||||
| 1234 | 1232
|
||||
| -1234 | -1236
|
||||
| 32767 | 32765
|
||||
| -32767 | 32767
|
||||
(5 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
|
||||
(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
|
||||
(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
|
||||
(5 rows)
|
||||
|
@ -1,215 +0,0 @@
|
||||
--
|
||||
-- INT2
|
||||
-- NOTE: int2 operators never check for over/underflow!
|
||||
-- Some of these answers are consequently numerically incorrect.
|
||||
--
|
||||
CREATE TABLE INT2_TBL(f1 int2);
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('0');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('1234');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('-1234');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
|
||||
ERROR: pg_atoi: error in "34.5": can't parse ".5"
|
||||
-- largest and smallest values
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('32767');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('-32767');
|
||||
-- bad input values -- should give warnings
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('100000');
|
||||
ERROR: pg_atoi: error reading "100000": Result too large
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
|
||||
ERROR: pg_atoi: error in "asdf": can't parse "asdf"
|
||||
SELECT '' AS five, INT2_TBL.*;
|
||||
five | 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
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS four, i.* FROM INT2_TBL i WHERE i.f1 <> int4 '0';
|
||||
four | f1
|
||||
------+--------
|
||||
| 1234
|
||||
| -1234
|
||||
| 32767
|
||||
| -32767
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int2 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT2_TBL i WHERE i.f1 = int4 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int2 '0';
|
||||
two | f1
|
||||
-----+--------
|
||||
| -1234
|
||||
| -32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 < int4 '0';
|
||||
two | f1
|
||||
-----+--------
|
||||
| -1234
|
||||
| -32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int2 '0';
|
||||
three | f1
|
||||
-------+--------
|
||||
| 0
|
||||
| -1234
|
||||
| -32767
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 <= int4 '0';
|
||||
three | f1
|
||||
-------+--------
|
||||
| 0
|
||||
| -1234
|
||||
| -32767
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int2 '0';
|
||||
two | f1
|
||||
-----+-------
|
||||
| 1234
|
||||
| 32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT2_TBL i WHERE i.f1 > int4 '0';
|
||||
two | f1
|
||||
-----+-------
|
||||
| 1234
|
||||
| 32767
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int2 '0';
|
||||
three | f1
|
||||
-------+-------
|
||||
| 0
|
||||
| 1234
|
||||
| 32767
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE i.f1 >= int4 '0';
|
||||
three | 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
|
||||
(1 row)
|
||||
|
||||
-- any evens
|
||||
SELECT '' AS three, i.* FROM INT2_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
|
||||
three | f1
|
||||
-------+-------
|
||||
| 0
|
||||
| 1234
|
||||
| -1234
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+-------
|
||||
| 0 | 0
|
||||
| 1234 | 2468
|
||||
| -1234 | -2468
|
||||
| 32767 | -2
|
||||
| -32767 | 2
|
||||
(5 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
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+--------
|
||||
| 0 | 2
|
||||
| 1234 | 1236
|
||||
| -1234 | -1232
|
||||
| 32767 | -32767
|
||||
| -32767 | -32765
|
||||
(5 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
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i;
|
||||
five | f1 | x
|
||||
------+--------+-------
|
||||
| 0 | -2
|
||||
| 1234 | 1232
|
||||
| -1234 | -1236
|
||||
| 32767 | 32765
|
||||
| -32767 | 32767
|
||||
(5 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
|
||||
(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
|
||||
(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
|
||||
(5 rows)
|
||||
|
@ -1,297 +0,0 @@
|
||||
--
|
||||
-- INT4
|
||||
-- WARNING: int4 operators never check for over/underflow!
|
||||
-- Some of these answers are consequently numerically incorrect.
|
||||
--
|
||||
CREATE TABLE INT4_TBL(f1 int4);
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('0');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('123456');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('-123456');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('34.5');
|
||||
ERROR: pg_atoi: error in "34.5": can't parse ".5"
|
||||
-- largest and smallest values
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('2147483647');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('-2147483647');
|
||||
-- bad input values -- should give warnings
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('1000000000000');
|
||||
ERROR: pg_atoi: error reading "1000000000000": Math result out of range
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('asdf');
|
||||
ERROR: pg_atoi: error in "asdf": can't parse "asdf"
|
||||
SELECT '' AS five, INT4_TBL.*;
|
||||
five | 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
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS four, i.* FROM INT4_TBL i WHERE i.f1 <> int4 '0';
|
||||
four | f1
|
||||
------+-------------
|
||||
| 123456
|
||||
| -123456
|
||||
| 2147483647
|
||||
| -2147483647
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int2 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int4 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int2 '0';
|
||||
two | f1
|
||||
-----+-------------
|
||||
| -123456
|
||||
| -2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int4 '0';
|
||||
two | f1
|
||||
-----+-------------
|
||||
| -123456
|
||||
| -2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int2 '0';
|
||||
three | f1
|
||||
-------+-------------
|
||||
| 0
|
||||
| -123456
|
||||
| -2147483647
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int4 '0';
|
||||
three | f1
|
||||
-------+-------------
|
||||
| 0
|
||||
| -123456
|
||||
| -2147483647
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int2 '0';
|
||||
two | f1
|
||||
-----+------------
|
||||
| 123456
|
||||
| 2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int4 '0';
|
||||
two | f1
|
||||
-----+------------
|
||||
| 123456
|
||||
| 2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int2 '0';
|
||||
three | f1
|
||||
-------+------------
|
||||
| 0
|
||||
| 123456
|
||||
| 2147483647
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int4 '0';
|
||||
three | 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
|
||||
(1 row)
|
||||
|
||||
-- any evens
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
|
||||
three | f1
|
||||
-------+---------
|
||||
| 0
|
||||
| 123456
|
||||
| -123456
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+---------
|
||||
| 0 | 0
|
||||
| 123456 | 246912
|
||||
| -123456 | -246912
|
||||
| 2147483647 | -2
|
||||
| -2147483647 | 2
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+---------
|
||||
| 0 | 0
|
||||
| 123456 | 246912
|
||||
| -123456 | -246912
|
||||
| 2147483647 | -2
|
||||
| -2147483647 | 2
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+-------------
|
||||
| 0 | 2
|
||||
| 123456 | 123458
|
||||
| -123456 | -123454
|
||||
| 2147483647 | -2147483647
|
||||
| -2147483647 | -2147483645
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+-------------
|
||||
| 0 | 2
|
||||
| 123456 | 123458
|
||||
| -123456 | -123454
|
||||
| 2147483647 | -2147483647
|
||||
| -2147483647 | -2147483645
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+------------
|
||||
| 0 | -2
|
||||
| 123456 | 123454
|
||||
| -123456 | -123458
|
||||
| 2147483647 | 2147483645
|
||||
| -2147483647 | 2147483647
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+------------
|
||||
| 0 | -2
|
||||
| 123456 | 123454
|
||||
| -123456 | -123458
|
||||
| 2147483647 | 2147483645
|
||||
| -2147483647 | 2147483647
|
||||
(5 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
|
||||
(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
|
||||
(5 rows)
|
||||
|
||||
--
|
||||
-- more complex expressions
|
||||
--
|
||||
-- variations on unary minus parsing
|
||||
SELECT -2+3 AS one;
|
||||
one
|
||||
-----
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT 4-2 AS two;
|
||||
two
|
||||
-----
|
||||
2
|
||||
(1 row)
|
||||
|
||||
SELECT 2- -1 AS three;
|
||||
three
|
||||
-------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
SELECT 2 - -2 AS four;
|
||||
four
|
||||
------
|
||||
4
|
||||
(1 row)
|
||||
|
||||
SELECT int2 '2' * int2 '2' = int2 '16' / int2 '4' AS true;
|
||||
true
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT int4 '2' * int2 '2' = int2 '16' / int4 '4' AS true;
|
||||
true
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT int2 '2' * int4 '2' = int4 '16' / int2 '4' AS true;
|
||||
true
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT int4 '1000' < int4 '999' AS false;
|
||||
false
|
||||
-------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
SELECT 4! AS twenty_four;
|
||||
twenty_four
|
||||
-------------
|
||||
24
|
||||
(1 row)
|
||||
|
||||
SELECT !!3 AS six;
|
||||
six
|
||||
-----
|
||||
6
|
||||
(1 row)
|
||||
|
||||
SELECT 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 AS ten;
|
||||
ten
|
||||
-----
|
||||
10
|
||||
(1 row)
|
||||
|
||||
SELECT 2 + 2 / 2 AS three;
|
||||
three
|
||||
-------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
SELECT (2 + 2) / 2 AS two;
|
||||
two
|
||||
-----
|
||||
2
|
||||
(1 row)
|
||||
|
@ -1,297 +0,0 @@
|
||||
--
|
||||
-- INT4
|
||||
-- WARNING: int4 operators never check for over/underflow!
|
||||
-- Some of these answers are consequently numerically incorrect.
|
||||
--
|
||||
CREATE TABLE INT4_TBL(f1 int4);
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('0');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('123456');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('-123456');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('34.5');
|
||||
ERROR: pg_atoi: error in "34.5": can't parse ".5"
|
||||
-- largest and smallest values
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('2147483647');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('-2147483647');
|
||||
-- bad input values -- should give warnings
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('1000000000000');
|
||||
ERROR: pg_atoi: error reading "1000000000000": Math result not representable
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('asdf');
|
||||
ERROR: pg_atoi: error in "asdf": can't parse "asdf"
|
||||
SELECT '' AS five, INT4_TBL.*;
|
||||
five | 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
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS four, i.* FROM INT4_TBL i WHERE i.f1 <> int4 '0';
|
||||
four | f1
|
||||
------+-------------
|
||||
| 123456
|
||||
| -123456
|
||||
| 2147483647
|
||||
| -2147483647
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int2 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int4 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int2 '0';
|
||||
two | f1
|
||||
-----+-------------
|
||||
| -123456
|
||||
| -2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int4 '0';
|
||||
two | f1
|
||||
-----+-------------
|
||||
| -123456
|
||||
| -2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int2 '0';
|
||||
three | f1
|
||||
-------+-------------
|
||||
| 0
|
||||
| -123456
|
||||
| -2147483647
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int4 '0';
|
||||
three | f1
|
||||
-------+-------------
|
||||
| 0
|
||||
| -123456
|
||||
| -2147483647
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int2 '0';
|
||||
two | f1
|
||||
-----+------------
|
||||
| 123456
|
||||
| 2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int4 '0';
|
||||
two | f1
|
||||
-----+------------
|
||||
| 123456
|
||||
| 2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int2 '0';
|
||||
three | f1
|
||||
-------+------------
|
||||
| 0
|
||||
| 123456
|
||||
| 2147483647
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int4 '0';
|
||||
three | 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
|
||||
(1 row)
|
||||
|
||||
-- any evens
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
|
||||
three | f1
|
||||
-------+---------
|
||||
| 0
|
||||
| 123456
|
||||
| -123456
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+---------
|
||||
| 0 | 0
|
||||
| 123456 | 246912
|
||||
| -123456 | -246912
|
||||
| 2147483647 | -2
|
||||
| -2147483647 | 2
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+---------
|
||||
| 0 | 0
|
||||
| 123456 | 246912
|
||||
| -123456 | -246912
|
||||
| 2147483647 | -2
|
||||
| -2147483647 | 2
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+-------------
|
||||
| 0 | 2
|
||||
| 123456 | 123458
|
||||
| -123456 | -123454
|
||||
| 2147483647 | -2147483647
|
||||
| -2147483647 | -2147483645
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+-------------
|
||||
| 0 | 2
|
||||
| 123456 | 123458
|
||||
| -123456 | -123454
|
||||
| 2147483647 | -2147483647
|
||||
| -2147483647 | -2147483645
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+------------
|
||||
| 0 | -2
|
||||
| 123456 | 123454
|
||||
| -123456 | -123458
|
||||
| 2147483647 | 2147483645
|
||||
| -2147483647 | 2147483647
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+------------
|
||||
| 0 | -2
|
||||
| 123456 | 123454
|
||||
| -123456 | -123458
|
||||
| 2147483647 | 2147483645
|
||||
| -2147483647 | 2147483647
|
||||
(5 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
|
||||
(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
|
||||
(5 rows)
|
||||
|
||||
--
|
||||
-- more complex expressions
|
||||
--
|
||||
-- variations on unary minus parsing
|
||||
SELECT -2+3 AS one;
|
||||
one
|
||||
-----
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT 4-2 AS two;
|
||||
two
|
||||
-----
|
||||
2
|
||||
(1 row)
|
||||
|
||||
SELECT 2- -1 AS three;
|
||||
three
|
||||
-------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
SELECT 2 - -2 AS four;
|
||||
four
|
||||
------
|
||||
4
|
||||
(1 row)
|
||||
|
||||
SELECT int2 '2' * int2 '2' = int2 '16' / int2 '4' AS true;
|
||||
true
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT int4 '2' * int2 '2' = int2 '16' / int4 '4' AS true;
|
||||
true
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT int2 '2' * int4 '2' = int4 '16' / int2 '4' AS true;
|
||||
true
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT int4 '1000' < int4 '999' AS false;
|
||||
false
|
||||
-------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
SELECT 4! AS twenty_four;
|
||||
twenty_four
|
||||
-------------
|
||||
24
|
||||
(1 row)
|
||||
|
||||
SELECT !!3 AS six;
|
||||
six
|
||||
-----
|
||||
6
|
||||
(1 row)
|
||||
|
||||
SELECT 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 AS ten;
|
||||
ten
|
||||
-----
|
||||
10
|
||||
(1 row)
|
||||
|
||||
SELECT 2 + 2 / 2 AS three;
|
||||
three
|
||||
-------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
SELECT (2 + 2) / 2 AS two;
|
||||
two
|
||||
-----
|
||||
2
|
||||
(1 row)
|
||||
|
@ -1,297 +0,0 @@
|
||||
--
|
||||
-- INT4
|
||||
-- WARNING: int4 operators never check for over/underflow!
|
||||
-- Some of these answers are consequently numerically incorrect.
|
||||
--
|
||||
CREATE TABLE INT4_TBL(f1 int4);
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('0');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('123456');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('-123456');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('34.5');
|
||||
ERROR: pg_atoi: error in "34.5": can't parse ".5"
|
||||
-- largest and smallest values
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('2147483647');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('-2147483647');
|
||||
-- bad input values -- should give warnings
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('1000000000000');
|
||||
ERROR: pg_atoi: error reading "1000000000000": Range Error
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('asdf');
|
||||
ERROR: pg_atoi: error in "asdf": can't parse "asdf"
|
||||
SELECT '' AS five, INT4_TBL.*;
|
||||
five | 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
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS four, i.* FROM INT4_TBL i WHERE i.f1 <> int4 '0';
|
||||
four | f1
|
||||
------+-------------
|
||||
| 123456
|
||||
| -123456
|
||||
| 2147483647
|
||||
| -2147483647
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int2 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int4 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int2 '0';
|
||||
two | f1
|
||||
-----+-------------
|
||||
| -123456
|
||||
| -2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int4 '0';
|
||||
two | f1
|
||||
-----+-------------
|
||||
| -123456
|
||||
| -2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int2 '0';
|
||||
three | f1
|
||||
-------+-------------
|
||||
| 0
|
||||
| -123456
|
||||
| -2147483647
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int4 '0';
|
||||
three | f1
|
||||
-------+-------------
|
||||
| 0
|
||||
| -123456
|
||||
| -2147483647
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int2 '0';
|
||||
two | f1
|
||||
-----+------------
|
||||
| 123456
|
||||
| 2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int4 '0';
|
||||
two | f1
|
||||
-----+------------
|
||||
| 123456
|
||||
| 2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int2 '0';
|
||||
three | f1
|
||||
-------+------------
|
||||
| 0
|
||||
| 123456
|
||||
| 2147483647
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int4 '0';
|
||||
three | 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
|
||||
(1 row)
|
||||
|
||||
-- any evens
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
|
||||
three | f1
|
||||
-------+---------
|
||||
| 0
|
||||
| 123456
|
||||
| -123456
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+---------
|
||||
| 0 | 0
|
||||
| 123456 | 246912
|
||||
| -123456 | -246912
|
||||
| 2147483647 | -2
|
||||
| -2147483647 | 2
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+---------
|
||||
| 0 | 0
|
||||
| 123456 | 246912
|
||||
| -123456 | -246912
|
||||
| 2147483647 | -2
|
||||
| -2147483647 | 2
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+-------------
|
||||
| 0 | 2
|
||||
| 123456 | 123458
|
||||
| -123456 | -123454
|
||||
| 2147483647 | -2147483647
|
||||
| -2147483647 | -2147483645
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+-------------
|
||||
| 0 | 2
|
||||
| 123456 | 123458
|
||||
| -123456 | -123454
|
||||
| 2147483647 | -2147483647
|
||||
| -2147483647 | -2147483645
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+------------
|
||||
| 0 | -2
|
||||
| 123456 | 123454
|
||||
| -123456 | -123458
|
||||
| 2147483647 | 2147483645
|
||||
| -2147483647 | 2147483647
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+------------
|
||||
| 0 | -2
|
||||
| 123456 | 123454
|
||||
| -123456 | -123458
|
||||
| 2147483647 | 2147483645
|
||||
| -2147483647 | 2147483647
|
||||
(5 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
|
||||
(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
|
||||
(5 rows)
|
||||
|
||||
--
|
||||
-- more complex expressions
|
||||
--
|
||||
-- variations on unary minus parsing
|
||||
SELECT -2+3 AS one;
|
||||
one
|
||||
-----
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT 4-2 AS two;
|
||||
two
|
||||
-----
|
||||
2
|
||||
(1 row)
|
||||
|
||||
SELECT 2- -1 AS three;
|
||||
three
|
||||
-------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
SELECT 2 - -2 AS four;
|
||||
four
|
||||
------
|
||||
4
|
||||
(1 row)
|
||||
|
||||
SELECT int2 '2' * int2 '2' = int2 '16' / int2 '4' AS true;
|
||||
true
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT int4 '2' * int2 '2' = int2 '16' / int4 '4' AS true;
|
||||
true
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT int2 '2' * int4 '2' = int4 '16' / int2 '4' AS true;
|
||||
true
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT int4 '1000' < int4 '999' AS false;
|
||||
false
|
||||
-------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
SELECT 4! AS twenty_four;
|
||||
twenty_four
|
||||
-------------
|
||||
24
|
||||
(1 row)
|
||||
|
||||
SELECT !!3 AS six;
|
||||
six
|
||||
-----
|
||||
6
|
||||
(1 row)
|
||||
|
||||
SELECT 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 AS ten;
|
||||
ten
|
||||
-----
|
||||
10
|
||||
(1 row)
|
||||
|
||||
SELECT 2 + 2 / 2 AS three;
|
||||
three
|
||||
-------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
SELECT (2 + 2) / 2 AS two;
|
||||
two
|
||||
-----
|
||||
2
|
||||
(1 row)
|
||||
|
@ -1,297 +0,0 @@
|
||||
--
|
||||
-- INT4
|
||||
-- WARNING: int4 operators never check for over/underflow!
|
||||
-- Some of these answers are consequently numerically incorrect.
|
||||
--
|
||||
CREATE TABLE INT4_TBL(f1 int4);
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('0');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('123456');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('-123456');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('34.5');
|
||||
ERROR: pg_atoi: error in "34.5": can't parse ".5"
|
||||
-- largest and smallest values
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('2147483647');
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('-2147483647');
|
||||
-- bad input values -- should give warnings
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('1000000000000');
|
||||
ERROR: pg_atoi: error reading "1000000000000": Result too large
|
||||
INSERT INTO INT4_TBL(f1) VALUES ('asdf');
|
||||
ERROR: pg_atoi: error in "asdf": can't parse "asdf"
|
||||
SELECT '' AS five, INT4_TBL.*;
|
||||
five | 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
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS four, i.* FROM INT4_TBL i WHERE i.f1 <> int4 '0';
|
||||
four | f1
|
||||
------+-------------
|
||||
| 123456
|
||||
| -123456
|
||||
| 2147483647
|
||||
| -2147483647
|
||||
(4 rows)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int2 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int4 '0';
|
||||
one | f1
|
||||
-----+----
|
||||
| 0
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int2 '0';
|
||||
two | f1
|
||||
-----+-------------
|
||||
| -123456
|
||||
| -2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int4 '0';
|
||||
two | f1
|
||||
-----+-------------
|
||||
| -123456
|
||||
| -2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int2 '0';
|
||||
three | f1
|
||||
-------+-------------
|
||||
| 0
|
||||
| -123456
|
||||
| -2147483647
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int4 '0';
|
||||
three | f1
|
||||
-------+-------------
|
||||
| 0
|
||||
| -123456
|
||||
| -2147483647
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int2 '0';
|
||||
two | f1
|
||||
-----+------------
|
||||
| 123456
|
||||
| 2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int4 '0';
|
||||
two | f1
|
||||
-----+------------
|
||||
| 123456
|
||||
| 2147483647
|
||||
(2 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int2 '0';
|
||||
three | f1
|
||||
-------+------------
|
||||
| 0
|
||||
| 123456
|
||||
| 2147483647
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int4 '0';
|
||||
three | 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
|
||||
(1 row)
|
||||
|
||||
-- any evens
|
||||
SELECT '' AS three, i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0';
|
||||
three | f1
|
||||
-------+---------
|
||||
| 0
|
||||
| 123456
|
||||
| -123456
|
||||
(3 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+---------
|
||||
| 0 | 0
|
||||
| 123456 | 246912
|
||||
| -123456 | -246912
|
||||
| 2147483647 | -2
|
||||
| -2147483647 | 2
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+---------
|
||||
| 0 | 0
|
||||
| 123456 | 246912
|
||||
| -123456 | -246912
|
||||
| 2147483647 | -2
|
||||
| -2147483647 | 2
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+-------------
|
||||
| 0 | 2
|
||||
| 123456 | 123458
|
||||
| -123456 | -123454
|
||||
| 2147483647 | -2147483647
|
||||
| -2147483647 | -2147483645
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+-------------
|
||||
| 0 | 2
|
||||
| 123456 | 123458
|
||||
| -123456 | -123454
|
||||
| 2147483647 | -2147483647
|
||||
| -2147483647 | -2147483645
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+------------
|
||||
| 0 | -2
|
||||
| 123456 | 123454
|
||||
| -123456 | -123458
|
||||
| 2147483647 | 2147483645
|
||||
| -2147483647 | 2147483647
|
||||
(5 rows)
|
||||
|
||||
SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i;
|
||||
five | f1 | x
|
||||
------+-------------+------------
|
||||
| 0 | -2
|
||||
| 123456 | 123454
|
||||
| -123456 | -123458
|
||||
| 2147483647 | 2147483645
|
||||
| -2147483647 | 2147483647
|
||||
(5 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
|
||||
(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
|
||||
(5 rows)
|
||||
|
||||
--
|
||||
-- more complex expressions
|
||||
--
|
||||
-- variations on unary minus parsing
|
||||
SELECT -2+3 AS one;
|
||||
one
|
||||
-----
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT 4-2 AS two;
|
||||
two
|
||||
-----
|
||||
2
|
||||
(1 row)
|
||||
|
||||
SELECT 2- -1 AS three;
|
||||
three
|
||||
-------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
SELECT 2 - -2 AS four;
|
||||
four
|
||||
------
|
||||
4
|
||||
(1 row)
|
||||
|
||||
SELECT int2 '2' * int2 '2' = int2 '16' / int2 '4' AS true;
|
||||
true
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT int4 '2' * int2 '2' = int2 '16' / int4 '4' AS true;
|
||||
true
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT int2 '2' * int4 '2' = int4 '16' / int2 '4' AS true;
|
||||
true
|
||||
------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT int4 '1000' < int4 '999' AS false;
|
||||
false
|
||||
-------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
SELECT 4! AS twenty_four;
|
||||
twenty_four
|
||||
-------------
|
||||
24
|
||||
(1 row)
|
||||
|
||||
SELECT !!3 AS six;
|
||||
six
|
||||
-----
|
||||
6
|
||||
(1 row)
|
||||
|
||||
SELECT 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 AS ten;
|
||||
ten
|
||||
-----
|
||||
10
|
||||
(1 row)
|
||||
|
||||
SELECT 2 + 2 / 2 AS three;
|
||||
three
|
||||
-------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
SELECT (2 + 2) / 2 AS two;
|
||||
two
|
||||
-----
|
||||
2
|
||||
(1 row)
|
||||
|
@ -1,6 +1,7 @@
|
||||
abstime/alpha.*-dec-osf=abstime-solaris-1947
|
||||
abstime/i.86-pc-solaris=abstime-solaris-1947
|
||||
abstime/sparc-sun-solaris=abstime-solaris-1947
|
||||
abstime/.*-sco=abstime-solaris-1947
|
||||
abstime/.*-sysv5uw=abstime-solaris-1947
|
||||
float4/.*-qnx=float4-exp-three-digits
|
||||
float8/.*-freebsd=float8-small-is-zero
|
||||
@ -38,42 +39,10 @@ horology/hppa=horology-no-DST-before-1970
|
||||
horology/i.86-pc-solaris=horology-solaris-1947
|
||||
horology/sparc-sun-solaris=horology-solaris-1947
|
||||
horology/.*-sysv5uw=horology-solaris-1947
|
||||
int2/.*-aix4=int2-too-large
|
||||
int2/.*-bsdi=int2-too-large
|
||||
int2/.*-darwin=int2-too-large
|
||||
int2/.*-freebsd=int2-too-large
|
||||
int2/.*-irix6=int2-too-large
|
||||
int2/.*-netbsd=int2-too-large
|
||||
int2/.*-qnx=int2-too-large
|
||||
int2/.*-openbsd=int2-too-large
|
||||
int2/alpha.*-dec-osf=int2-too-large
|
||||
int2/hppa=int2-too-large
|
||||
int2/i.86-pc-cygwin=int2-math-result-out-of-range
|
||||
int2/i.86-pc-linux-gnulibc=int2-not-representable
|
||||
int2/i.86-pc-solaris=int2-too-large
|
||||
int2/powerpc-unknown-linux-gnulibc1=int2-not-representable
|
||||
int2/sparc-sun-solaris=int2-too-large
|
||||
int2/.*-sysv5uw=int2-too-large
|
||||
int2/.*-beos=int2-range-error
|
||||
int4/.*-aix4=int4-too-large
|
||||
int4/.*-bsdi=int4-too-large
|
||||
int4/.*-darwin=int4-too-large
|
||||
int4/.*-freebsd=int4-too-large
|
||||
int4/.*-irix6=int4-too-large
|
||||
int4/.*-netbsd=int4-too-large
|
||||
int4/.*-qnx=int4-too-large
|
||||
int4/.*-openbsd=int4-too-large
|
||||
int4/alpha.*-dec-osf=int4-too-large
|
||||
int4/hppa=int4-too-large
|
||||
int4/i.86-pc-cygwin=int4-math-result-out-of-range
|
||||
int4/i.86-pc-linux-gnulibc=int4-not-representable
|
||||
int4/i.86-pc-solaris=int4-too-large
|
||||
int4/powerpc-unknown-linux-gnulibc1=int4-not-representable
|
||||
int4/sparc-sun-solaris=int4-too-large
|
||||
int4/.*-sysv5uw=int4-too-large
|
||||
int4/.*-beos=int4-range-error
|
||||
horology/.*-sco=horology-solaris-1947
|
||||
int8/.*-qnx=int8-exp-three-digits
|
||||
tinterval/alpha.*-dec-osf=tinterval-solaris-1947
|
||||
tinterval/i.86-pc-solaris=tinterval-solaris-1947
|
||||
tinterval/sparc-sun-solaris=tinterval-solaris-1947
|
||||
tinterval/.*-sysv5uw=tinterval-solaris-1947
|
||||
tinterval/.*-sco=tinterval-solaris-1947
|
||||
|
Loading…
Reference in New Issue
Block a user