Index: doc/src/sgml/func.sgml
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/doc/src/sgml/func.sgml,v
retrieving revision 1.197
diff -c -r1.197 func.sgml
*** doc/src/sgml/func.sgml 10 Apr 2004 18:02:59 -0000 1.197
--- doc/src/sgml/func.sgml 22 Apr 2004 22:10:52 -0000
***************
*** 588,593 ****
--- 588,601 ----
+ ceiling(dp or numeric)
+ (same as input)
+ smallest integer not less than argument (alias for ceil
+ ceiling(-95.3)
+ -95
+
+
+
degrees(dp)
dp
radians to degrees
***************
*** 654,673 ****
! pow(a dp,
b dp)
dp
a> raised to the power of b
! pow(9.0, 3.0)
729
! pow(a numeric,
b numeric)
numeric
a> raised to the power of b
! pow(9.0, 3.0)
729
--- 662,681 ----
! power(a dp,
b dp)
dp
a> raised to the power of b
! power(9.0, 3.0)
729
! power(a numeric,
b numeric)
numeric
a> raised to the power of b
! power(9.0, 3.0)
729
Index: src/include/catalog/catversion.h
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/src/include/catalog/catversion.h,v
retrieving revision 1.223
diff -c -r1.223 catversion.h
*** src/include/catalog/catversion.h 1 Apr 2004 21:28:45 -0000 1.223
--- src/include/catalog/catversion.h 22 Apr 2004 20:16:56 -0000
***************
*** 53,58 ****
*/
/* yyyymmddN */
! #define CATALOG_VERSION_NO 200403291
#endif
--- 53,58 ----
*/
/* yyyymmddN */
! #define CATALOG_VERSION_NO 200404220
#endif
Index: src/include/catalog/pg_proc.h
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/src/include/catalog/pg_proc.h,v
retrieving revision 1.324
diff -c -r1.324 pg_proc.h
*** src/include/catalog/pg_proc.h 2 Apr 2004 23:14:08 -0000 1.324
--- src/include/catalog/pg_proc.h 22 Apr 2004 21:55:29 -0000
***************
*** 471,476 ****
--- 471,478 ----
DESCR("truncate to integer");
DATA(insert OID = 2308 ( ceil PGNSP PGUID 12 f f t f i 1 701 "701" _null_ dceil - _null_ ));
DESCR("smallest integer >= value");
+ DATA(insert OID = 2320 ( ceiling PGNSP PGUID 12 f f t f i 1 701 "701" _null_ dceil - _null_ ));
+ DESCR("smallest integer >= value");
DATA(insert OID = 2309 ( floor PGNSP PGUID 12 f f t f i 1 701 "701" _null_ dfloor - _null_ ));
DESCR("largest integer <= value");
DATA(insert OID = 2310 ( sign PGNSP PGUID 12 f f t f i 1 701 "701" _null_ dsign - _null_ ));
***************
*** 1667,1672 ****
--- 1669,1676 ----
DESCR("cube root");
DATA(insert OID = 1346 ( pow PGNSP PGUID 12 f f t f i 2 701 "701 701" _null_ dpow - _null_ ));
DESCR("exponentiation");
+ DATA(insert OID = 1368 ( power PGNSP PGUID 12 f f t f i 2 701 "701 701" _null_ dpow - _null_ ));
+ DESCR("exponentiation");
DATA(insert OID = 1347 ( exp PGNSP PGUID 12 f f t f i 1 701 "701" _null_ dexp - _null_ ));
DESCR("exponential");
***************
*** 2440,2445 ****
--- 2444,2451 ----
DESCR("value truncated to 'scale' of zero");
DATA(insert OID = 1711 ( ceil PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ numeric_ceil - _null_ ));
DESCR("smallest integer >= value");
+ DATA(insert OID = 2167 ( ceiling PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ numeric_ceil - _null_ ));
+ DESCR("smallest integer >= value");
DATA(insert OID = 1712 ( floor PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ numeric_floor - _null_ ));
DESCR("largest integer <= value");
DATA(insert OID = 1718 ( numeric_eq PGNSP PGUID 12 f f t f i 2 16 "1700 1700" _null_ numeric_eq - _null_ ));
***************
*** 2483,2488 ****
--- 2489,2496 ----
DATA(insert OID = 1737 ( numeric_log PGNSP PGUID 12 f f t f i 2 1700 "1700 1700" _null_ numeric_log - _null_ ));
DESCR("logarithm base m of n");
DATA(insert OID = 1738 ( pow PGNSP PGUID 12 f f t f i 2 1700 "1700 1700" _null_ numeric_power - _null_ ));
+ DESCR("m raised to the power of n");
+ DATA(insert OID = 2169 ( power PGNSP PGUID 12 f f t f i 2 1700 "1700 1700" _null_ numeric_power - _null_ ));
DESCR("m raised to the power of n");
DATA(insert OID = 1739 ( numeric_power PGNSP PGUID 12 f f t f i 2 1700 "1700 1700" _null_ numeric_power - _null_ ));
DESCR("m raised to the power of n");
Index: src/test/regress/expected/float8-exp-three-digits-win32.out
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/src/test/regress/expected/float8-exp-three-digits-win32.out,v
retrieving revision 1.3
diff -c -r1.3 float8-exp-three-digits-win32.out
*** src/test/regress/expected/float8-exp-three-digits-win32.out 24 Mar 2004 02:02:26 -0000 1.3
--- src/test/regress/expected/float8-exp-three-digits-win32.out 23 Apr 2004 00:27:01 -0000
***************
*** 225,231 ****
| 1.2345678901234e-200 | 0
(5 rows)
! -- ceil
select ceil(f1) as ceil_f1 from float8_tbl f;
ceil_f1
----------------------
--- 225,231 ----
| 1.2345678901234e-200 | 0
(5 rows)
! -- ceil / ceiling
select ceil(f1) as ceil_f1 from float8_tbl f;
ceil_f1
----------------------
***************
*** 236,241 ****
--- 236,251 ----
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,285 ****
--- 290,302 ----
| 1.2345678901234e+200 | 1.11111110611109e+100
| 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
Index: src/test/regress/expected/float8-exp-three-digits.out
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/src/test/regress/expected/float8-exp-three-digits.out,v
retrieving revision 1.8
diff -c -r1.8 float8-exp-three-digits.out
*** src/test/regress/expected/float8-exp-three-digits.out 24 Mar 2004 02:02:26 -0000 1.8
--- src/test/regress/expected/float8-exp-three-digits.out 23 Apr 2004 00:26:53 -0000
***************
*** 224,230 ****
| 1.2345678901234e-200 | 0
(5 rows)
! -- ceil
select ceil(f1) as ceil_f1 from float8_tbl f;
ceil_f1
----------------------
--- 224,230 ----
| 1.2345678901234e-200 | 0
(5 rows)
! -- ceil / ceiling
select ceil(f1) as ceil_f1 from float8_tbl f;
ceil_f1
----------------------
***************
*** 235,240 ****
--- 235,250 ----
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
***************
*** 279,284 ****
--- 289,301 ----
| 1.2345678901234e+200 | 1.11111110611109e+100
| 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
Index: src/test/regress/expected/float8-small-is-zero.out
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/src/test/regress/expected/float8-small-is-zero.out,v
retrieving revision 1.6
diff -c -r1.6 float8-small-is-zero.out
*** src/test/regress/expected/float8-small-is-zero.out 24 Mar 2004 02:02:26 -0000 1.6
--- src/test/regress/expected/float8-small-is-zero.out 23 Apr 2004 00:27:11 -0000
***************
*** 233,239 ****
| 1.2345678901234e-200 | 0
(5 rows)
! -- ceil
select ceil(f1) as ceil_f1 from float8_tbl f;
ceil_f1
----------------------
--- 233,239 ----
| 1.2345678901234e-200 | 0
(5 rows)
! -- ceil / ceiling
select ceil(f1) as ceil_f1 from float8_tbl f;
ceil_f1
----------------------
***************
*** 244,249 ****
--- 244,259 ----
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
***************
*** 288,293 ****
--- 298,310 ----
| 1.2345678901234e+200 | 1.11111110611109e+100
| 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
Index: src/test/regress/expected/float8.out
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/src/test/regress/expected/float8.out,v
retrieving revision 1.20
diff -c -r1.20 float8.out
*** src/test/regress/expected/float8.out 24 Mar 2004 02:02:26 -0000 1.20
--- src/test/regress/expected/float8.out 23 Apr 2004 00:26:36 -0000
***************
*** 225,231 ****
| 1.2345678901234e-200 | 0
(5 rows)
! -- ceil
select ceil(f1) as ceil_f1 from float8_tbl f;
ceil_f1
----------------------
--- 225,231 ----
| 1.2345678901234e-200 | 0
(5 rows)
! -- ceil / ceiling
select ceil(f1) as ceil_f1 from float8_tbl f;
ceil_f1
----------------------
***************
*** 236,241 ****
--- 236,251 ----
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,285 ****
--- 290,302 ----
| 1.2345678901234e+200 | 1.11111110611109e+100
| 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
Index: src/test/regress/expected/numeric.out
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/src/test/regress/expected/numeric.out,v
retrieving revision 1.13
diff -c -r1.13 numeric.out
*** src/test/regress/expected/numeric.out 11 Mar 2004 02:11:13 -0000 1.13
--- src/test/regress/expected/numeric.out 22 Apr 2004 22:37:12 -0000
***************
*** 646,655 ****
(0 rows)
-- ******************************
! -- * POW(10, LN(value)) check
-- ******************************
DELETE FROM num_result;
! INSERT INTO num_result SELECT id, 0, POW(numeric '10', LN(ABS(round(val,200))))
FROM num_data
WHERE val != '0.0';
SELECT t1.id1, t1.result, t2.expected
--- 646,655 ----
(0 rows)
-- ******************************
! -- * POWER(10, LN(value)) check
-- ******************************
DELETE FROM num_result;
! 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,713 ****
--- 708,735 ----
(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')
Index: src/test/regress/sql/float8.sql
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/src/test/regress/sql/float8.sql,v
retrieving revision 1.11
diff -c -r1.11 float8.sql
*** src/test/regress/sql/float8.sql 24 Mar 2004 02:02:27 -0000 1.11
--- src/test/regress/sql/float8.sql 23 Apr 2004 00:15:42 -0000
***************
*** 85,92 ****
SELECT '' AS five, f.f1, f.f1 % AS round_f1
FROM FLOAT8_TBL f;
! -- ceil
select ceil(f1) as ceil_f1 from float8_tbl f;
-- floor
select floor(f1) as floor_f1 from float8_tbl f;
--- 85,93 ----
SELECT '' AS five, f.f1, f.f1 % AS round_f1
FROM FLOAT8_TBL f;
! -- 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;
***************
*** 102,107 ****
--- 103,111 ----
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
Index: src/test/regress/sql/numeric.sql
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/src/test/regress/sql/numeric.sql,v
retrieving revision 1.8
diff -c -r1.8 numeric.sql
*** src/test/regress/sql/numeric.sql 11 Mar 2004 02:11:14 -0000 1.8
--- src/test/regress/sql/numeric.sql 22 Apr 2004 22:04:27 -0000
***************
*** 623,632 ****
AND t1.result != t2.expected;
-- ******************************
! -- * POW(10, LN(value)) check
-- ******************************
DELETE FROM num_result;
! INSERT INTO num_result SELECT id, 0, POW(numeric '10', LN(ABS(round(val,200))))
FROM num_data
WHERE val != '0.0';
SELECT t1.id1, t1.result, t2.expected
--- 623,632 ----
AND t1.result != t2.expected;
-- ******************************
! -- * POWER(10, LN(value)) check
-- ******************************
DELETE FROM num_result;
! 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
***************
*** 654,659 ****
--- 654,671 ----
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()
--