diff options
Diffstat (limited to 'src/test/regress/expected/numeric.out')
| -rw-r--r-- | src/test/regress/expected/numeric.out | 104 |
1 files changed, 63 insertions, 41 deletions
diff --git a/src/test/regress/expected/numeric.out b/src/test/regress/expected/numeric.out index 96c70a8a09..3780c17e5a 100644 --- a/src/test/regress/expected/numeric.out +++ b/src/test/regress/expected/numeric.out @@ -730,55 +730,77 @@ SELECT a, ceil(a), ceiling(a), floor(a), round(a) FROM ceil_floor_round; (7 rows) DROP TABLE ceil_floor_round; --- Testing for width_bucket() --- NULL result -SELECT width_bucket(NULL, NULL, NULL, NULL); - width_bucket --------------- - -(1 row) - +-- Testing for width_bucket(). For convenience, we test both the +-- numeric and float8 versions of the function in this file. -- errors SELECT width_bucket(5.0, 3.0, 4.0, 0); ERROR: count must be greater than zero SELECT width_bucket(5.0, 3.0, 4.0, -5); ERROR: count must be greater than zero -SELECT width_bucket(3.0, 3.0, 3.0, 888); +SELECT width_bucket(3.5, 3.0, 3.0, 888); +ERROR: lower bound cannot equal upper bound +SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, 0); +ERROR: count must be greater than zero +SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, -5); +ERROR: count must be greater than zero +SELECT width_bucket(3.5::float8, 3.0::float8, 3.0::float8, 888); ERROR: lower bound cannot equal upper bound +SELECT width_bucket('NaN', 3.0, 4.0, 888); +ERROR: operand, lower bound and upper bound cannot be NaN +SELECT width_bucket(0::float8, 'NaN', 4.0::float8, 888); +ERROR: operand, lower bound and upper bound cannot be NaN -- normal operation -CREATE TABLE width_bucket_test (operand numeric); -COPY width_bucket_test FROM stdin; +CREATE TABLE width_bucket_test (operand_num numeric, operand_f8 float8); +COPY width_bucket_test (operand_num) FROM stdin; +UPDATE width_bucket_test SET operand_f8 = operand_num::float8; SELECT - operand, - width_bucket(operand, 0, 10, 5) AS wb_1, - width_bucket(operand, 10, 0, 5) AS wb_2, - width_bucket(operand, 2, 8, 4) AS wb_3, - width_bucket(operand, 5.0, 5.5, 20) AS wb_4, - width_bucket(operand, -25, 25, 10) AS wb_5 + operand_num, operand_f8, + width_bucket(operand_num, 0, 10, 5) AS wb_1, + width_bucket(operand_f8, 0, 10, 5) AS wb_1f, + width_bucket(operand_num, 10, 0, 5) AS wb_2, + width_bucket(operand_f8, 10, 0, 5) AS wb_2f, + width_bucket(operand_num, 2, 8, 4) AS wb_3, + width_bucket(operand_f8, 2, 8, 4) AS wb_3f, + width_bucket(operand_num, 5.0, 5.5, 20) AS wb_4, + width_bucket(operand_f8, 5.0, 5.5, 20) AS wb_4f, + width_bucket(operand_num, -25, 25, 10) AS wb_5, + width_bucket(operand_f8, -25, 25, 10) AS wb_5f FROM width_bucket_test; - operand | wb_1 | wb_2 | wb_3 | wb_4 | wb_5 -------------------+------+------+------+------+------ - -5.2 | 0 | 6 | 0 | 0 | 4 - -0.0000000000001 | 0 | 6 | 0 | 0 | 5 - 0.0000000000001 | 1 | 5 | 0 | 0 | 6 - 1 | 1 | 5 | 0 | 0 | 6 - 1.99999999999999 | 1 | 5 | 0 | 0 | 6 - 2 | 2 | 5 | 1 | 0 | 6 - 2.00000000000001 | 2 | 4 | 1 | 0 | 6 - 3 | 2 | 4 | 1 | 0 | 6 - 4 | 3 | 4 | 2 | 0 | 6 - 4.5 | 3 | 3 | 2 | 0 | 6 - 5 | 3 | 3 | 3 | 1 | 7 - 5.5 | 3 | 3 | 3 | 21 | 7 - 6 | 4 | 3 | 3 | 21 | 7 - 7 | 4 | 2 | 4 | 21 | 7 - 8 | 5 | 2 | 5 | 21 | 7 - 9 | 5 | 1 | 5 | 21 | 7 - 9.99999999999999 | 5 | 1 | 5 | 21 | 7 - 10 | 6 | 1 | 5 | 21 | 8 - 10.0000000000001 | 6 | 0 | 5 | 21 | 8 - NaN | 6 | 0 | 5 | 21 | 11 -(20 rows) + operand_num | operand_f8 | wb_1 | wb_1f | wb_2 | wb_2f | wb_3 | wb_3f | wb_4 | wb_4f | wb_5 | wb_5f +------------------+------------------+------+-------+------+-------+------+-------+------+-------+------+------- + -5.2 | -5.2 | 0 | 0 | 6 | 6 | 0 | 0 | 0 | 0 | 4 | 4 + -0.0000000001 | -1e-10 | 0 | 0 | 6 | 6 | 0 | 0 | 0 | 0 | 5 | 5 + 0.000000000001 | 1e-12 | 1 | 1 | 5 | 5 | 0 | 0 | 0 | 0 | 6 | 6 + 1 | 1 | 1 | 1 | 5 | 5 | 0 | 0 | 0 | 0 | 6 | 6 + 1.99999999999999 | 1.99999999999999 | 1 | 1 | 5 | 5 | 0 | 0 | 0 | 0 | 6 | 6 + 2 | 2 | 2 | 2 | 5 | 5 | 1 | 1 | 0 | 0 | 6 | 6 + 2.00000000000001 | 2.00000000000001 | 2 | 2 | 4 | 4 | 1 | 1 | 0 | 0 | 6 | 6 + 3 | 3 | 2 | 2 | 4 | 4 | 1 | 1 | 0 | 0 | 6 | 6 + 4 | 4 | 3 | 3 | 4 | 4 | 2 | 2 | 0 | 0 | 6 | 6 + 4.5 | 4.5 | 3 | 3 | 3 | 3 | 2 | 2 | 0 | 0 | 6 | 6 + 5 | 5 | 3 | 3 | 3 | 3 | 3 | 3 | 1 | 1 | 7 | 7 + 5.5 | 5.5 | 3 | 3 | 3 | 3 | 3 | 3 | 21 | 21 | 7 | 7 + 6 | 6 | 4 | 4 | 3 | 3 | 3 | 3 | 21 | 21 | 7 | 7 + 7 | 7 | 4 | 4 | 2 | 2 | 4 | 4 | 21 | 21 | 7 | 7 + 8 | 8 | 5 | 5 | 2 | 2 | 5 | 5 | 21 | 21 | 7 | 7 + 9 | 9 | 5 | 5 | 1 | 1 | 5 | 5 | 21 | 21 | 7 | 7 + 9.99999999999999 | 9.99999999999999 | 5 | 5 | 1 | 1 | 5 | 5 | 21 | 21 | 7 | 7 + 10 | 10 | 6 | 6 | 1 | 1 | 5 | 5 | 21 | 21 | 8 | 8 + 10.0000000000001 | 10.0000000000001 | 6 | 6 | 0 | 0 | 5 | 5 | 21 | 21 | 8 | 8 +(19 rows) + +-- for float8 only, check positive and negative infinity: we require +-- finite bucket bounds, but allow an infinite operand +SELECT width_bucket(0.0::float8, 'Infinity'::float8, 5, 10); -- error +ERROR: lower and upper bounds must be finite +SELECT width_bucket(0.0::float8, 5, '-Infinity'::float8, 20); -- error +ERROR: lower and upper bounds must be finite +SELECT width_bucket('Infinity'::float8, 1, 10, 10), + width_bucket('-Infinity'::float8, 1, 10, 10); + width_bucket | width_bucket +--------------+-------------- + 11 | 0 +(1 row) DROP TABLE width_bucket_test; -- TO_CHAR() @@ -800,7 +822,7 @@ SELECT '' AS to_char_1, to_char(val, '9G999G999G999G999G999') (10 rows) SELECT '' AS to_char_2, to_char(val, '9G999G999G999G999G999D999G999G999G999G999') - FROM num_data; + FROM num_data; to_char_2 | to_char -----------+-------------------------------------------- | .000,000,000,000,000 |
