Index: src/backend/utils/adt/float.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/utils/adt/float.c,v
retrieving revision 1.81
diff -c -r1.81 float.c
*** src/backend/utils/adt/float.c	4 Sep 2002 20:31:27 -0000	1.81
--- src/backend/utils/adt/float.c	4 Oct 2002 15:52:31 -0000
***************
*** 129,138 ****
  
  
  /*
!    check to see if a float4 val is outside of
!    the FLOAT4_MIN, FLOAT4_MAX bounds.
! 
!    raise an elog warning if it is
  */
  static void
  CheckFloat4Val(double val)
--- 129,138 ----
  
  
  /*
!  * check to see if a float4 val is outside of
!  * the FLOAT4_MIN, FLOAT4_MAX bounds.
!  *
!  * raise an elog warning if it is
  */
  static void
  CheckFloat4Val(double val)
***************
*** 153,163 ****
  }
  
  /*
!    check to see if a float8 val is outside of
!    the FLOAT8_MIN, FLOAT8_MAX bounds.
! 
!    raise an elog warning if it is
! */
  static void
  CheckFloat8Val(double val)
  {
--- 153,163 ----
  }
  
  /*
!  * check to see if a float8 val is outside of
!  * the FLOAT8_MIN, FLOAT8_MAX bounds.
!  *
!  * raise an elog error if it is
!  */
  static void
  CheckFloat8Val(double val)
  {
***************
*** 172,178 ****
  		elog(ERROR, "Bad float8 input format -- overflow");
  	if (val != 0.0 && fabs(val) < FLOAT8_MIN)
  		elog(ERROR, "Bad float8 input format -- underflow");
- 	return;
  #endif   /* UNSAFE_FLOATS */
  }
  
--- 172,177 ----
***************
*** 1039,1044 ****
--- 1038,1087 ----
  	PG_RETURN_FLOAT8(result);
  }
  
+ /*
+  *		dceil			- returns the smallest integer greater than or
+  *						  equal to the specified float
+  */
+ Datum
+ dceil(PG_FUNCTION_ARGS)
+ {
+ 	float8		arg1 = PG_GETARG_FLOAT8(0);
+ 
+ 	PG_RETURN_FLOAT8(ceil(arg1));
+ }
+ 
+ /*
+  *		dfloor			- returns the largest integer lesser than or
+  *						  equal to the specified float
+  */
+ Datum
+ dfloor(PG_FUNCTION_ARGS)
+ {
+ 	float8		arg1 = PG_GETARG_FLOAT8(0);
+ 
+ 	PG_RETURN_FLOAT8(floor(arg1));
+ }
+ 
+ /*
+  *		dsign			- returns -1 if the argument is less than 0, 0
+  *						  if the argument is equal to 0, and 1 if the
+  *						  argument is greater than zero.
+  */
+ Datum
+ dsign(PG_FUNCTION_ARGS)
+ {
+ 	float8		arg1 = PG_GETARG_FLOAT8(0);
+ 	float8		result;
+ 
+ 	if (arg1 > 0)
+ 		result = 1.0;
+ 	else if (arg1 < 0)
+ 		result = -1.0;
+ 	else
+ 		result = 0.0;
+ 
+ 	PG_RETURN_FLOAT8(result);
+ }
  
  /*
   *		dtrunc			- returns truncation-towards-zero of arg1,
Index: src/backend/utils/adt/numeric.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/utils/adt/numeric.c,v
retrieving revision 1.55
diff -c -r1.55 numeric.c
*** src/backend/utils/adt/numeric.c	2 Oct 2002 19:21:26 -0000	1.55
--- src/backend/utils/adt/numeric.c	4 Oct 2002 05:44:25 -0000
***************
*** 425,431 ****
  	PG_RETURN_NUMERIC(res);
  }
  
! 
  Datum
  numeric_sign(PG_FUNCTION_ARGS)
  {
--- 425,437 ----
  	PG_RETURN_NUMERIC(res);
  }
  
! /* ----------
!  * numeric_sign() -
!  *
!  * returns -1 if the argument is less than 0, 0 if the argument is equal
!  * to 0, and 1 if the argument is greater than zero.
!  * ----------
!  */
  Datum
  numeric_sign(PG_FUNCTION_ARGS)
  {
Index: src/include/catalog/catversion.h
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/include/catalog/catversion.h,v
retrieving revision 1.160
diff -c -r1.160 catversion.h
*** src/include/catalog/catversion.h	22 Sep 2002 19:42:51 -0000	1.160
--- src/include/catalog/catversion.h	4 Oct 2002 06:36:51 -0000
***************
*** 53,58 ****
   */
  
  /*							yyyymmddN */
! #define CATALOG_VERSION_NO	200209221
  
  #endif
--- 53,58 ----
   */
  
  /*							yyyymmddN */
! #define CATALOG_VERSION_NO	200210041
  
  #endif
Index: src/include/catalog/pg_proc.h
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/include/catalog/pg_proc.h,v
retrieving revision 1.273
diff -c -r1.273 pg_proc.h
*** src/include/catalog/pg_proc.h	22 Sep 2002 17:27:23 -0000	1.273
--- src/include/catalog/pg_proc.h	4 Oct 2002 06:35:58 -0000
***************
*** 473,478 ****
--- 473,484 ----
  DESCR("round to nearest integer");
  DATA(insert OID = 229 (  dtrunc			   PGNSP PGUID 12 f f t f i 1 701 "701"  dtrunc - _null_ ));
  DESCR("truncate to integer");
+ DATA(insert OID = 2308 ( ceil			   PGNSP PGUID 12 f f t f i 1 701 "701"  dceil - _null_ ));
+ DESCR("smallest integer >= value");
+ DATA(insert OID = 2309 ( floor			   PGNSP PGUID 12 f f t f i 1 701 "701"  dfloor - _null_ ));
+ DESCR("largest integer <= value");
+ DATA(insert OID = 2310 ( sign			   PGNSP PGUID 12 f f t f i 1 701 "701"  dsign - _null_ ));
+ DESCR("sign of value");
  DATA(insert OID = 230 (  dsqrt			   PGNSP PGUID 12 f f t f i 1 701 "701"  dsqrt - _null_ ));
  DESCR("square root");
  DATA(insert OID = 231 (  dcbrt			   PGNSP PGUID 12 f f t f i 1 701 "701"  dcbrt - _null_ ));
Index: src/include/utils/builtins.h
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/include/utils/builtins.h,v
retrieving revision 1.202
diff -c -r1.202 builtins.h
*** src/include/utils/builtins.h	22 Sep 2002 17:27:25 -0000	1.202
--- src/include/utils/builtins.h	4 Oct 2002 15:54:33 -0000
***************
*** 261,266 ****
--- 261,269 ----
  extern Datum float8_text(PG_FUNCTION_ARGS);
  extern Datum float4_text(PG_FUNCTION_ARGS);
  extern Datum dround(PG_FUNCTION_ARGS);
+ extern Datum dceil(PG_FUNCTION_ARGS);
+ extern Datum dfloor(PG_FUNCTION_ARGS);
+ extern Datum dsign(PG_FUNCTION_ARGS);
  extern Datum dtrunc(PG_FUNCTION_ARGS);
  extern Datum dsqrt(PG_FUNCTION_ARGS);
  extern Datum dcbrt(PG_FUNCTION_ARGS);
Index: src/test/regress/expected/float8.out
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/test/regress/expected/float8.out,v
retrieving revision 1.13
diff -c -r1.13 float8.out
*** src/test/regress/expected/float8.out	20 Mar 2000 05:19:10 -0000	1.13
--- src/test/regress/expected/float8.out	4 Oct 2002 16:02:54 -0000
***************
*** 149,161 ****
        | 1.2345678901234e-200 |                    0
  (5 rows)
  
  SELECT sqrt(float8 '64') AS eight;
   eight 
  -------
       8
  (1 row)
  
- -- square root 
  SELECT |/ float8 '64' AS eight;
   eight 
  -------
--- 149,194 ----
        | 1.2345678901234e-200 |                    0
  (5 rows)
  
+ -- ceil
+ select ceil(f1) as ceil_f1 from float8_tbl f;
+        ceil_f1        
+ ----------------------
+                     0
+                  1005
+                   -34
+  1.2345678901234e+200
+                     1
+ (5 rows)
+ 
+ -- floor
+ select floor(f1) as floor_f1 from float8_tbl f;
+        floor_f1       
+ ----------------------
+                     0
+                  1004
+                   -35
+  1.2345678901234e+200
+                     0
+ (5 rows)
+ 
+ -- sign
+ select sign(f1) as sign_f1 from float8_tbl f;
+  sign_f1 
+ ---------
+        0
+        1
+       -1
+        1
+        1
+ (5 rows)
+ 
+ -- square root 
  SELECT sqrt(float8 '64') AS eight;
   eight 
  -------
       8
  (1 row)
  
  SELECT |/ float8 '64' AS eight;
   eight 
  -------
Index: src/test/regress/sql/float8.sql
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/test/regress/sql/float8.sql,v
retrieving revision 1.7
diff -c -r1.7 float8.sql
*** src/test/regress/sql/float8.sql	20 Mar 2000 05:19:11 -0000	1.7
--- src/test/regress/sql/float8.sql	4 Oct 2002 15:59:44 -0000
***************
*** 60,68 ****
  SELECT '' AS five, f.f1, f.f1 % AS round_f1
     FROM FLOAT8_TBL f;
  
! SELECT sqrt(float8 '64') AS eight;
  
  -- square root 
  SELECT |/ float8 '64' AS eight;
  
  SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1
--- 60,77 ----
  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;
! 
! -- sign
! select sign(f1) as sign_f1 from float8_tbl f;
  
  -- square root 
+ SELECT sqrt(float8 '64') AS eight;
+ 
  SELECT |/ float8 '64' AS eight;
  
  SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1
