postgresql/src/test/regress/expected/int8-exp-three-digits.out
2000-03-01 19:11:12 +00:00

120 lines
4.7 KiB
Plaintext

--
-- INT8
-- Test int8 64-bit integers.
--
CREATE TABLE INT8_TBL(q1 int8, q2 int8);
INSERT INTO INT8_TBL VALUES('123','456');
INSERT INTO INT8_TBL VALUES('123','4567890123456789');
INSERT INTO INT8_TBL VALUES('4567890123456789','123');
INSERT INTO INT8_TBL VALUES('4567890123456789','4567890123456789');
INSERT INTO INT8_TBL VALUES('4567890123456789','-4567890123456789');
SELECT * FROM INT8_TBL;
q1 | q2
------------------+-------------------
123 | 456
123 | 4567890123456789
4567890123456789 | 123
4567890123456789 | 4567890123456789
4567890123456789 | -4567890123456789
(5 rows)
SELECT '' AS five, q1 AS plus, -q1 AS minus FROM INT8_TBL;
five | plus | minus
------+------------------+-------------------
| 123 | -123
| 123 | -123
| 4567890123456789 | -4567890123456789
| 4567890123456789 | -4567890123456789
| 4567890123456789 | -4567890123456789
(5 rows)
SELECT '' AS five, q1, q2, q1 + q2 AS plus FROM INT8_TBL;
five | q1 | q2 | plus
------+------------------+-------------------+------------------
| 123 | 456 | 579
| 123 | 4567890123456789 | 4567890123456912
| 4567890123456789 | 123 | 4567890123456912
| 4567890123456789 | 4567890123456789 | 9135780246913578
| 4567890123456789 | -4567890123456789 | 0
(5 rows)
SELECT '' AS five, q1, q2, q1 - q2 AS minus FROM INT8_TBL;
five | q1 | q2 | minus
------+------------------+-------------------+-------------------
| 123 | 456 | -333
| 123 | 4567890123456789 | -4567890123456666
| 4567890123456789 | 123 | 4567890123456666
| 4567890123456789 | 4567890123456789 | 0
| 4567890123456789 | -4567890123456789 | 9135780246913578
(5 rows)
SELECT '' AS three, q1, q2, q1 * q2 AS multiply FROM INT8_TBL
WHERE q1 < 1000 or (q2 > 0 and q2 < 1000);
three | q1 | q2 | multiply
-------+------------------+------------------+--------------------
| 123 | 456 | 56088
| 123 | 4567890123456789 | 561850485185185047
| 4567890123456789 | 123 | 561850485185185047
(3 rows)
SELECT '' AS five, q1, q2, q1 / q2 AS divide FROM INT8_TBL;
five | q1 | q2 | divide
------+------------------+-------------------+----------------
| 123 | 456 | 0
| 123 | 4567890123456789 | 0
| 4567890123456789 | 123 | 37137318076884
| 4567890123456789 | 4567890123456789 | 1
| 4567890123456789 | -4567890123456789 | -1
(5 rows)
SELECT '' AS five, q1, float8(q1) FROM INT8_TBL;
five | q1 | float8
------+------------------+-----------------------
| 123 | 123
| 123 | 123
| 4567890123456789 | 4.56789012345679e+015
| 4567890123456789 | 4.56789012345679e+015
| 4567890123456789 | 4.56789012345679e+015
(5 rows)
SELECT '' AS five, q2, float8(q2) FROM INT8_TBL;
five | q2 | float8
------+-------------------+------------------------
| 456 | 456
| 4567890123456789 | 4.56789012345679e+015
| 123 | 123
| 4567890123456789 | 4.56789012345679e+015
| -4567890123456789 | -4.56789012345679e+015
(5 rows)
SELECT '' AS five, q1, int8(float8(q1)) AS "two coercions" FROM INT8_TBL;
five | q1 | two coercions
------+------------------+------------------
| 123 | 123
| 123 | 123
| 4567890123456789 | 4567890123456789
| 4567890123456789 | 4567890123456789
| 4567890123456789 | 4567890123456789
(5 rows)
SELECT '' AS five, 2 * q1 AS "twice int4" FROM INT8_TBL;
five | twice int4
------+------------------
| 246
| 246
| 9135780246913578
| 9135780246913578
| 9135780246913578
(5 rows)
SELECT '' AS five, q1 * 2 AS "twice int4" FROM INT8_TBL;
five | twice int4
------+------------------
| 246
| 246
| 9135780246913578
| 9135780246913578
| 9135780246913578
(5 rows)