summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2004-04-23 20:32:20 +0000
committerNeil Conway <neilc@samurai.com>2004-04-23 20:32:20 +0000
commitfc7fd50182f5fcec0d9c900ca8e6a48649ceb196 (patch)
treef3d8b8a55aaef91582fd8d1a8ccada55fcbb9957 /src/test
parent7a66015e98e890c27e3483a413d5a88927c5b818 (diff)
Add ceiling() as an alias for ceil(), and power() as an alias for pow().
Regression tests and documentation have both been updated. SQL2003 requires that both ceiling() and ceil() be present, so I have documented both spellings. SQL2003 doesn't mention pow() as far as I can see, so I decided to replace pow() with power() in the documentation: there is little reason to encourage the continued usage of a function that isn't compliant with the standard, given a standard-compliant alternative. RELEASE NOTES: should state that pow() is considered deprecated (although I don't see the need to ever remove it.)
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/float8-exp-three-digits-win32.out19
-rw-r--r--src/test/regress/expected/float8-exp-three-digits.out19
-rw-r--r--src/test/regress/expected/float8-small-is-zero.out19
-rw-r--r--src/test/regress/expected/float8.out19
-rw-r--r--src/test/regress/expected/numeric.out26
-rw-r--r--src/test/regress/sql/float8.sql6
-rw-r--r--src/test/regress/sql/numeric.sql16
7 files changed, 115 insertions, 9 deletions
diff --git a/src/test/regress/expected/float8-exp-three-digits-win32.out b/src/test/regress/expected/float8-exp-three-digits-win32.out
index e64a46399ae..c6f3064b675 100644
--- a/src/test/regress/expected/float8-exp-three-digits-win32.out
+++ b/src/test/regress/expected/float8-exp-three-digits-win32.out
@@ -225,7 +225,7 @@ SELECT '' AS five, f.f1, f.f1 % AS round_f1
| 1.2345678901234e-200 | 0
(5 rows)
--- ceil
+-- ceil / ceiling
select ceil(f1) as ceil_f1 from float8_tbl f;
ceil_f1
----------------------
@@ -236,6 +236,16 @@ select ceil(f1) as ceil_f1 from float8_tbl f;
1
(5 rows)
+select ceiling(f1) as ceiling_f1 from float8_tbl f;
+ ceiling_f1
+----------------------
+ 0
+ 1005
+ -34
+ 1.2345678901234e+200
+ 1
+(5 rows)
+
-- floor
select floor(f1) as floor_f1 from float8_tbl f;
floor_f1
@@ -281,6 +291,13 @@ SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1
| 1.2345678901234e-200 | 1.11111110611109e-100
(3 rows)
+-- power
+SELECT power(float8 '144', float8 '0.5');
+ power
+-------
+ 12
+(1 row)
+
-- take exp of ln(f.f1)
SELECT '' AS three, f.f1, exp(ln(f.f1)) AS exp_ln_f1
FROM FLOAT8_TBL f
diff --git a/src/test/regress/expected/float8-exp-three-digits.out b/src/test/regress/expected/float8-exp-three-digits.out
index 7cfa2bec168..479503959bd 100644
--- a/src/test/regress/expected/float8-exp-three-digits.out
+++ b/src/test/regress/expected/float8-exp-three-digits.out
@@ -224,7 +224,7 @@ SELECT '' AS five, f.f1, f.f1 % AS round_f1
| 1.2345678901234e-200 | 0
(5 rows)
--- ceil
+-- ceil / ceiling
select ceil(f1) as ceil_f1 from float8_tbl f;
ceil_f1
----------------------
@@ -235,6 +235,16 @@ select ceil(f1) as ceil_f1 from float8_tbl f;
1
(5 rows)
+select ceiling(f1) as ceiling_f1 from float8_tbl f;
+ ceiling_f1
+----------------------
+ 0
+ 1005
+ -34
+ 1.2345678901234e+200
+ 1
+(5 rows)
+
-- floor
select floor(f1) as floor_f1 from float8_tbl f;
floor_f1
@@ -280,6 +290,13 @@ SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1
| 1.2345678901234e-200 | 1.11111110611109e-100
(3 rows)
+-- power
+SELECT power(float8 '144', float8 '0.5');
+ power
+-------
+ 12
+(1 row)
+
-- take exp of ln(f.f1)
SELECT '' AS three, f.f1, exp(ln(f.f1)) AS exp_ln_f1
FROM FLOAT8_TBL f
diff --git a/src/test/regress/expected/float8-small-is-zero.out b/src/test/regress/expected/float8-small-is-zero.out
index 11eefa230b7..b599c1ca5d8 100644
--- a/src/test/regress/expected/float8-small-is-zero.out
+++ b/src/test/regress/expected/float8-small-is-zero.out
@@ -233,7 +233,7 @@ SELECT '' AS five, f.f1, f.f1 % AS round_f1
| 1.2345678901234e-200 | 0
(5 rows)
--- ceil
+-- ceil / ceiling
select ceil(f1) as ceil_f1 from float8_tbl f;
ceil_f1
----------------------
@@ -244,6 +244,16 @@ select ceil(f1) as ceil_f1 from float8_tbl f;
1
(5 rows)
+select ceiling(f1) as ceiling_f1 from float8_tbl f;
+ ceiling_f1
+----------------------
+ 0
+ 1005
+ -34
+ 1.2345678901234e+200
+ 1
+(5 rows)
+
-- floor
select floor(f1) as floor_f1 from float8_tbl f;
floor_f1
@@ -289,6 +299,13 @@ SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1
| 1.2345678901234e-200 | 1.11111110611109e-100
(3 rows)
+-- power
+SELECT power(float8 '144', float8 '0.5');
+ power
+-------
+ 12
+(1 row)
+
-- take exp of ln(f.f1)
SELECT '' AS three, f.f1, exp(ln(f.f1)) AS exp_ln_f1
FROM FLOAT8_TBL f
diff --git a/src/test/regress/expected/float8.out b/src/test/regress/expected/float8.out
index 03a493aaa4e..8ba64db0202 100644
--- a/src/test/regress/expected/float8.out
+++ b/src/test/regress/expected/float8.out
@@ -225,7 +225,7 @@ SELECT '' AS five, f.f1, f.f1 % AS round_f1
| 1.2345678901234e-200 | 0
(5 rows)
--- ceil
+-- ceil / ceiling
select ceil(f1) as ceil_f1 from float8_tbl f;
ceil_f1
----------------------
@@ -236,6 +236,16 @@ select ceil(f1) as ceil_f1 from float8_tbl f;
1
(5 rows)
+select ceiling(f1) as ceiling_f1 from float8_tbl f;
+ ceiling_f1
+----------------------
+ 0
+ 1005
+ -34
+ 1.2345678901234e+200
+ 1
+(5 rows)
+
-- floor
select floor(f1) as floor_f1 from float8_tbl f;
floor_f1
@@ -281,6 +291,13 @@ SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1
| 1.2345678901234e-200 | 1.11111110611109e-100
(3 rows)
+-- power
+SELECT power(float8 '144', float8 '0.5');
+ power
+-------
+ 12
+(1 row)
+
-- take exp of ln(f.f1)
SELECT '' AS three, f.f1, exp(ln(f.f1)) AS exp_ln_f1
FROM FLOAT8_TBL f
diff --git a/src/test/regress/expected/numeric.out b/src/test/regress/expected/numeric.out
index bf3bb441afc..6a536c704ba 100644
--- a/src/test/regress/expected/numeric.out
+++ b/src/test/regress/expected/numeric.out
@@ -646,10 +646,10 @@ SELECT t1.id1, t1.result, t2.expected
(0 rows)
-- ******************************
--- * POW(10, LN(value)) check
+-- * POWER(10, LN(value)) check
-- ******************************
DELETE FROM num_result;
-INSERT INTO num_result SELECT id, 0, POW(numeric '10', LN(ABS(round(val,200))))
+INSERT INTO num_result SELECT id, 0, POWER(numeric '10', LN(ABS(round(val,200))))
FROM num_data
WHERE val != '0.0';
SELECT t1.id1, t1.result, t2.expected
@@ -708,6 +708,28 @@ SELECT * FROM fract_only;
(6 rows)
DROP TABLE fract_only;
+-- Simple check that ceil(), floor(), and round() work correctly
+CREATE TABLE ceil_floor_round (a numeric);
+INSERT INTO ceil_floor_round VALUES ('-5.5');
+INSERT INTO ceil_floor_round VALUES ('-5.499999');
+INSERT INTO ceil_floor_round VALUES ('9.5');
+INSERT INTO ceil_floor_round VALUES ('9.4999999');
+INSERT INTO ceil_floor_round VALUES ('0.0');
+INSERT INTO ceil_floor_round VALUES ('0.0000001');
+INSERT INTO ceil_floor_round VALUES ('-0.000001');
+SELECT a, ceil(a), ceiling(a), floor(a), round(a) FROM ceil_floor_round;
+ a | ceil | ceiling | floor | round
+-----------+------+---------+-------+-------
+ -5.5 | -5 | -5 | -6 | -6
+ -5.499999 | -5 | -5 | -6 | -5
+ 9.5 | 10 | 10 | 9 | 10
+ 9.4999999 | 10 | 10 | 9 | 9
+ 0.0 | 0 | 0 | 0 | 0
+ 0.0000001 | 1 | 1 | 0 | 0
+ -0.000001 | 0 | 0 | -1 | 0
+(7 rows)
+
+DROP TABLE ceil_floor_round;
-- TO_CHAR()
--
SELECT '' AS to_char_1, to_char(val, '9G999G999G999G999G999')
diff --git a/src/test/regress/sql/float8.sql b/src/test/regress/sql/float8.sql
index 4c706099cdd..83f0763c6f2 100644
--- a/src/test/regress/sql/float8.sql
+++ b/src/test/regress/sql/float8.sql
@@ -85,8 +85,9 @@ SELECT '' AS five, f.f1, %f.f1 AS trunc_f1
SELECT '' AS five, f.f1, f.f1 % AS round_f1
FROM FLOAT8_TBL f;
--- ceil
+-- ceil / ceiling
select ceil(f1) as ceil_f1 from float8_tbl f;
+select ceiling(f1) as ceiling_f1 from float8_tbl f;
-- floor
select floor(f1) as floor_f1 from float8_tbl f;
@@ -103,6 +104,9 @@ SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1
FROM FLOAT8_TBL f
WHERE f.f1 > '0.0';
+-- power
+SELECT power(float8 '144', float8 '0.5');
+
-- take exp of ln(f.f1)
SELECT '' AS three, f.f1, exp(ln(f.f1)) AS exp_ln_f1
FROM FLOAT8_TBL f
diff --git a/src/test/regress/sql/numeric.sql b/src/test/regress/sql/numeric.sql
index b3900344027..59693ab83dc 100644
--- a/src/test/regress/sql/numeric.sql
+++ b/src/test/regress/sql/numeric.sql
@@ -623,10 +623,10 @@ SELECT t1.id1, t1.result, t2.expected
AND t1.result != t2.expected;
-- ******************************
--- * POW(10, LN(value)) check
+-- * POWER(10, LN(value)) check
-- ******************************
DELETE FROM num_result;
-INSERT INTO num_result SELECT id, 0, POW(numeric '10', LN(ABS(round(val,200))))
+INSERT INTO num_result SELECT id, 0, POWER(numeric '10', LN(ABS(round(val,200))))
FROM num_data
WHERE val != '0.0';
SELECT t1.id1, t1.result, t2.expected
@@ -655,6 +655,18 @@ INSERT INTO fract_only VALUES (8, '0.00017');
SELECT * FROM fract_only;
DROP TABLE fract_only;
+-- Simple check that ceil(), floor(), and round() work correctly
+CREATE TABLE ceil_floor_round (a numeric);
+INSERT INTO ceil_floor_round VALUES ('-5.5');
+INSERT INTO ceil_floor_round VALUES ('-5.499999');
+INSERT INTO ceil_floor_round VALUES ('9.5');
+INSERT INTO ceil_floor_round VALUES ('9.4999999');
+INSERT INTO ceil_floor_round VALUES ('0.0');
+INSERT INTO ceil_floor_round VALUES ('0.0000001');
+INSERT INTO ceil_floor_round VALUES ('-0.000001');
+SELECT a, ceil(a), ceiling(a), floor(a), round(a) FROM ceil_floor_round;
+DROP TABLE ceil_floor_round;
+
-- TO_CHAR()
--
SELECT '' AS to_char_1, to_char(val, '9G999G999G999G999G999')