]> granicus.if.org Git - postgresql/commitdiff
Convert all remaining float4 and float8 functions to new fmgr style.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 1 Aug 2000 18:29:35 +0000 (18:29 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 1 Aug 2000 18:29:35 +0000 (18:29 +0000)
At this point I think it'd be possible to make float4 be pass-by-value
without too much work --- and float8 too on machines where Datum is
8 bytes.  Something to try when the mood strikes, anyway.

src/backend/commands/variable.c
src/backend/utils/adt/cash.c
src/backend/utils/adt/float.c
src/backend/utils/adt/int.c
src/backend/utils/adt/numeric.c
src/backend/utils/adt/numutils.c
src/backend/utils/adt/oid.c
src/include/catalog/pg_proc.h
src/include/utils/builtins.h
src/include/utils/cash.h

index d7e730544b03902e1e1583a835f906cd008a17c3..a70dfcad9bb48e5027b911ad4221cd3e81476bc5 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.39 2000/07/14 15:35:44 thomas Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.40 2000/08/01 18:29:29 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -566,7 +566,7 @@ parse_random_seed(char *value)
        else
        {
                sscanf(value, "%lf", &seed);
-               setseed(&seed);
+               DirectFunctionCall1(setseed, Float8GetDatum(seed));
        }
        return (TRUE);
 }
@@ -583,7 +583,7 @@ reset_random_seed(void)
 {
        double          seed = 0.5;
 
-       setseed(&seed);
+       DirectFunctionCall1(setseed, Float8GetDatum(seed));
        return (TRUE);
 }
 
index b85f37942c1dd5b79d40582a9e610cc21916f84d..e1a68940a84446d0eb22d171d0b988749b9cab90 100644 (file)
@@ -9,7 +9,7 @@
  * workings can be found in the book "Software Solutions in C" by
  * Dale Schumacher, Academic Press, ISBN: 0-12-632360-7.
  *
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.43 2000/07/07 18:49:52 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.44 2000/08/01 18:29:35 tgl Exp $
  */
 
 #include <limits.h>
@@ -425,31 +425,31 @@ cash_mi(Cash *c1, Cash *c2)
 /* cash_mul_flt8()
  * Multiply cash by float8.
  */
-Cash *
-cash_mul_flt8(Cash *c, float8 *f)
+Datum
+cash_mul_flt8(PG_FUNCTION_ARGS)
 {
-       Cash       *result;
-
-       if (!PointerIsValid(f) || !PointerIsValid(c))
-               return NULL;
-
-       if (!PointerIsValid(result = palloc(sizeof(Cash))))
-               elog(ERROR, "Memory allocation failed, can't multiply cash");
-
-       *result = ((*f) * (*c));
+       Cash            c = PG_GETARG_CASH(0);
+       float8          f = PG_GETARG_FLOAT8(1);
+       Cash            result;
 
-       return result;
-}      /* cash_mul_flt8() */
+       result = c * f;
+       PG_RETURN_CASH(result);
+}
 
 
 /* flt8_mul_cash()
  * Multiply float8 by cash.
  */
-Cash *
-flt8_mul_cash(float8 *f, Cash *c)
+Datum
+flt8_mul_cash(PG_FUNCTION_ARGS)
 {
-       return cash_mul_flt8(c, f);
-}      /* flt8_mul_cash() */
+       float8          f = PG_GETARG_FLOAT8(0);
+       Cash            c = PG_GETARG_CASH(1);
+       Cash            result;
+
+       result = f * c;
+       PG_RETURN_CASH(result);
+}
 
 
 /* cash_div_flt8()
@@ -458,53 +458,48 @@ flt8_mul_cash(float8 *f, Cash *c)
  * XXX Don't know if rounding or truncating is correct behavior.
  * Round for now. - tgl 97/04/15
  */
-Cash *
-cash_div_flt8(Cash *c, float8 *f)
+Datum
+cash_div_flt8(PG_FUNCTION_ARGS)
 {
-       Cash       *result;
-
-       if (!PointerIsValid(f) || !PointerIsValid(c))
-               return NULL;
-
-       if (!PointerIsValid(result = palloc(sizeof(Cash))))
-               elog(ERROR, "Memory allocation failed, can't divide cash");
+       Cash            c = PG_GETARG_CASH(0);
+       float8          f = PG_GETARG_FLOAT8(1);
+       Cash            result;
 
-       if (*f == 0.0)
+       if (f == 0.0)
                elog(ERROR, "cash_div:  divide by 0.0 error");
 
-       *result = rint(*c / *f);
-
-       return result;
-}      /* cash_div_flt8() */
+       result = rint(c / f);
+       PG_RETURN_CASH(result);
+}
 
 /* cash_mul_flt4()
  * Multiply cash by float4.
  */
-Cash *
-cash_mul_flt4(Cash *c, float4 *f)
+Datum
+cash_mul_flt4(PG_FUNCTION_ARGS)
 {
-       Cash       *result;
-
-       if (!PointerIsValid(f) || !PointerIsValid(c))
-               return NULL;
-
-       if (!PointerIsValid(result = palloc(sizeof(Cash))))
-               elog(ERROR, "Memory allocation failed, can't multiply cash");
-
-       *result = ((*f) * (*c));
+       Cash            c = PG_GETARG_CASH(0);
+       float4          f = PG_GETARG_FLOAT4(1);
+       Cash            result;
 
-       return result;
-}      /* cash_mul_flt4() */
+       result = c * f;
+       PG_RETURN_CASH(result);
+}
 
 
 /* flt4_mul_cash()
- * Multiply float4 by float4.
+ * Multiply float4 by cash.
  */
-Cash *
-flt4_mul_cash(float4 *f, Cash *c)
+Datum
+flt4_mul_cash(PG_FUNCTION_ARGS)
 {
-       return cash_mul_flt4(c, f);
-}      /* flt4_mul_cash() */
+       float4          f = PG_GETARG_FLOAT4(0);
+       Cash            c = PG_GETARG_CASH(1);
+       Cash            result;
+
+       result = f * c;
+       PG_RETURN_CASH(result);
+}
 
 
 /* cash_div_flt4()
@@ -513,24 +508,19 @@ flt4_mul_cash(float4 *f, Cash *c)
  * XXX Don't know if rounding or truncating is correct behavior.
  * Round for now. - tgl 97/04/15
  */
-Cash *
-cash_div_flt4(Cash *c, float4 *f)
+Datum
+cash_div_flt4(PG_FUNCTION_ARGS)
 {
-       Cash       *result;
-
-       if (!PointerIsValid(f) || !PointerIsValid(c))
-               return NULL;
-
-       if (!PointerIsValid(result = palloc(sizeof(Cash))))
-               elog(ERROR, "Memory allocation failed, can't divide cash");
+       Cash            c = PG_GETARG_CASH(0);
+       float4          f = PG_GETARG_FLOAT4(1);
+       Cash            result;
 
-       if (*f == 0.0)
+       if (f == 0.0)
                elog(ERROR, "cash_div:  divide by 0.0 error");
 
-       *result = rint(*c / *f);
-
-       return result;
-}      /* cash_div_flt4() */
+       result = rint(c / f);
+       PG_RETURN_CASH(result);
+}
 
 
 /* cash_mul_int4()
index 940724ab05f23ffde190e51bc9846a088ba408be..54735191a9f2fdffbe09773f658839fd236147cb 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.66 2000/07/28 02:13:31 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.67 2000/08/01 18:29:35 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -54,7 +54,6 @@
 #include "postgres.h"
 
 #include <limits.h>
-
 /* for finite() on Solaris */
 #ifdef HAVE_IEEEFP_H
 # include <ieeefp.h>
 #include "utils/array.h"
 #include "utils/builtins.h"
 
-static void CheckFloat8Val(double val);
-
-#ifndef NAN
-#define NAN            (0.0/0.0)
-#endif
-
-#ifndef SHRT_MAX
-#define SHRT_MAX 32767
-#endif
-#ifndef SHRT_MIN
-#define SHRT_MIN (-32768)
-#endif
-
-#define FORMAT                 'g'             /* use "g" output format as standard
-                                                                * format */
-/* not sure what the following should be, but better to make it over-sufficient */
-#define MAXFLOATWIDTH  64
-#define MAXDOUBLEWIDTH 128
 
 #if !(NeXT && NX_CURRENT_COMPILER_RELEASE > NX_COMPILER_RELEASE_3_2)
  /* NS3.3 has conflicting declarations of these in <math.h> */
@@ -110,6 +91,32 @@ extern double rint(double x);
 
 #endif /* NeXT check */
 
+
+static void CheckFloat4Val(double val);
+static void CheckFloat8Val(double val);
+
+#ifndef M_PI
+/* from my RH5.2 gcc math.h file - thomas 2000-04-03 */
+#define M_PI 3.14159265358979323846
+#endif
+
+#ifndef NAN
+#define NAN            (0.0/0.0)
+#endif
+
+#ifndef SHRT_MAX
+#define SHRT_MAX 32767
+#endif
+#ifndef SHRT_MIN
+#define SHRT_MIN (-32768)
+#endif
+
+#define FORMAT                 'g'             /* use "g" output format as standard
+                                                                * format */
+/* not sure what the following should be, but better to make it over-sufficient */
+#define MAXFLOATWIDTH  64
+#define MAXDOUBLEWIDTH 128
+
 /* ========== USER I/O ROUTINES ========== */
 
 
@@ -176,10 +183,10 @@ CheckFloat8Val(double val)
  *                                               where <sp> is a space, digit is 0-9,
  *                                               <exp> is "e" or "E" followed by an integer.
  */
-float32
-float4in(char *num)
+Datum
+float4in(PG_FUNCTION_ARGS)
 {
-       float32         result = (float32) palloc(sizeof(float32data));
+       char       *num = PG_GETARG_CSTRING(0);
        double          val;
        char       *endptr;
 
@@ -200,30 +207,25 @@ float4in(char *num)
         * if we get here, we have a legal double, still need to check to see
         * if it's a legal float
         */
-
        CheckFloat4Val(val);
 
-       *result = val;
-       return result;
+       PG_RETURN_FLOAT4((float4) val);
 }
 
 /*
  *             float4out               - converts a float4 number to a string
  *                                               using a standard output format
  */
-char *
-float4out(float32 num)
+Datum
+float4out(PG_FUNCTION_ARGS)
 {
+       float4          num = PG_GETARG_FLOAT4(0);
        char       *ascii = (char *) palloc(MAXFLOATWIDTH + 1);
 
-       if (!num)
-               return strcpy(ascii, "(null)");
-
-       sprintf(ascii, "%.*g", FLT_DIG, *num);
-       return ascii;
+       sprintf(ascii, "%.*g", FLT_DIG, num);
+       PG_RETURN_CSTRING(ascii);
 }
 
-
 /*
  *             float8in                - converts "num" to float8
  *                                               restricted syntax:
@@ -231,10 +233,10 @@ float4out(float32 num)
  *                                               where <sp> is a space, digit is 0-9,
  *                                               <exp> is "e" or "E" followed by an integer.
  */
-float64
-float8in(char *num)
+Datum
+float8in(PG_FUNCTION_ARGS)
 {
-       float64         result = (float64) palloc(sizeof(float64data));
+       char       *num = PG_GETARG_CSTRING(0);
        double          val;
        char       *endptr;
 
@@ -257,8 +259,7 @@ float8in(char *num)
 
        CheckFloat8Val(val);
 
-       *result = val;
-       return result;
+       PG_RETURN_FLOAT8(val);
 }
 
 
@@ -266,21 +267,19 @@ float8in(char *num)
  *             float8out               - converts float8 number to a string
  *                                               using a standard output format
  */
-char *
-float8out(float64 num)
+Datum
+float8out(PG_FUNCTION_ARGS)
 {
+       float8          num = PG_GETARG_FLOAT8(0);
        char       *ascii = (char *) palloc(MAXDOUBLEWIDTH + 1);
 
-       if (!num)
-               return strcpy(ascii, "(null)");
+       if (isnan(num))
+               PG_RETURN_CSTRING(strcpy(ascii, "NaN"));
+       if (isinf(num))
+               PG_RETURN_CSTRING(strcpy(ascii, "Infinity"));
 
-       if (isnan(*num))
-               return strcpy(ascii, "NaN");
-       if (isinf(*num))
-               return strcpy(ascii, "Infinity");
-
-       sprintf(ascii, "%.*g", DBL_DIG, *num);
-       return ascii;
+       sprintf(ascii, "%.*g", DBL_DIG, num);
+       PG_RETURN_CSTRING(ascii);
 }
 
 /* ========== PUBLIC ROUTINES ========== */
@@ -293,72 +292,47 @@ float8out(float64 num)
  */
 
 /*
- *             float4abs               - returns a pointer to |arg1| (absolute value)
+ *             float4abs               - returns |arg1| (absolute value)
  */
-float32
-float4abs(float32 arg1)
+Datum
+float4abs(PG_FUNCTION_ARGS)
 {
-       float32         result;
-       double          val;
-
-       if (!arg1)
-               return (float32) NULL;
-
-       val = fabs(*arg1);
+       float4          arg1 = PG_GETARG_FLOAT4(0);
 
-       CheckFloat4Val(val);
-
-       result = (float32) palloc(sizeof(float32data));
-       *result = val;
-       return result;
+       PG_RETURN_FLOAT4((float4) fabs(arg1));
 }
 
 /*
- *             float4um                - returns a pointer to -arg1 (unary minus)
+ *             float4um                - returns -arg1 (unary minus)
  */
-float32
-float4um(float32 arg1)
+Datum
+float4um(PG_FUNCTION_ARGS)
 {
-       float32         result;
-       double          val;
-
-       if (!arg1)
-               return (float32) NULL;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
 
-       val = ((*arg1 != 0) ? -(*arg1) : *arg1);
-       CheckFloat4Val(val);
-
-       result = (float32) palloc(sizeof(float32data));
-       *result = val;
-       return result;
+       PG_RETURN_FLOAT4((float4) -arg1);
 }
 
-float32
-float4larger(float32 arg1, float32 arg2)
+Datum
+float4larger(PG_FUNCTION_ARGS)
 {
-       float32         result;
-
-       if (!arg1 || !arg2)
-               return (float32) NULL;
-
-       result = (float32) palloc(sizeof(float32data));
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
+       float4          result;
 
-       *result = ((*arg1 > *arg2) ? *arg1 : *arg2);
-       return result;
+       result = ((arg1 > arg2) ? arg1 : arg2);
+       PG_RETURN_FLOAT4(result);
 }
 
-float32
-float4smaller(float32 arg1, float32 arg2)
+Datum
+float4smaller(PG_FUNCTION_ARGS)
 {
-       float32         result;
-
-       if (!arg1 || !arg2)
-               return (float32) NULL;
-
-       result = (float32) palloc(sizeof(float32data));
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
+       float4          result;
 
-       *result = ((*arg1 > *arg2) ? *arg2 : *arg1);
-       return result;
+       result = ((arg1 < arg2) ? arg1 : arg2);
+       PG_RETURN_FLOAT4(result);
 }
 
 /*
@@ -368,72 +342,58 @@ float4smaller(float32 arg1, float32 arg2)
  */
 
 /*
- *             float8abs               - returns a pointer to |arg1| (absolute value)
+ *             float8abs               - returns |arg1| (absolute value)
  */
-float64
-float8abs(float64 arg1)
+Datum
+float8abs(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          val;
-
-       if (!arg1)
-               return (float64) NULL;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       result = (float64) palloc(sizeof(float64data));
+       result = fabs(arg1);
 
-       val = fabs(*arg1);
-       CheckFloat8Val(val);
-       *result = val;
-       return result;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
 
 /*
- *             float8um                - returns a pointer to -arg1 (unary minus)
+ *             float8um                - returns -arg1 (unary minus)
  */
-float64
-float8um(float64 arg1)
+Datum
+float8um(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          val;
-
-       if (!arg1)
-               return (float64) NULL;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       val = ((*arg1 != 0) ? -(*arg1) : *arg1);
+       result = ((arg1 != 0) ? -(arg1) : arg1);
 
-       CheckFloat8Val(val);
-       result = (float64) palloc(sizeof(float64data));
-       *result = val;
-       return result;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
-float64
-float8larger(float64 arg1, float64 arg2)
+Datum
+float8larger(PG_FUNCTION_ARGS)
 {
-       float64         result;
-
-       if (!arg1 || !arg2)
-               return (float64) NULL;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
+       float8          result;
 
-       result = (float64) palloc(sizeof(float64data));
+       result = ((arg1 > arg2) ? arg1 : arg2);
 
-       *result = ((*arg1 > *arg2) ? *arg1 : *arg2);
-       return result;
+       PG_RETURN_FLOAT8(result);
 }
 
-float64
-float8smaller(float64 arg1, float64 arg2)
+Datum
+float8smaller(PG_FUNCTION_ARGS)
 {
-       float64         result;
-
-       if (!arg1 || !arg2)
-               return (float64) NULL;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
+       float8          result;
 
-       result = (float64) palloc(sizeof(float64data));
+       result = ((arg1 < arg2) ? arg1 : arg2);
 
-       *result = ((*arg1 > *arg2) ? *arg2 : *arg1);
-       return result;
+       PG_RETURN_FLOAT8(result);
 }
 
 
@@ -444,158 +404,123 @@ float8smaller(float64 arg1, float64 arg2)
  */
 
 /*
- *             float4pl                - returns a pointer to arg1 + arg2
- *             float4mi                - returns a pointer to arg1 - arg2
- *             float4mul               - returns a pointer to arg1 * arg2
- *             float4div               - returns a pointer to arg1 / arg2
+ *             float4pl                - returns arg1 + arg2
+ *             float4mi                - returns arg1 - arg2
+ *             float4mul               - returns arg1 * arg2
+ *             float4div               - returns arg1 / arg2
  */
-float32
-float4pl(float32 arg1, float32 arg2)
+Datum
+float4pl(PG_FUNCTION_ARGS)
 {
-       float32         result;
-       double          val;
-
-       if (!arg1 || !arg2)
-               return (float32) NULL;
-
-       val = *arg1 + *arg2;
-       CheckFloat4Val(val);
-
-       result = (float32) palloc(sizeof(float32data));
-       *result = val;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
+       double          result;
 
-       return result;
+       result = arg1 + arg2;
+       CheckFloat4Val(result);
+       PG_RETURN_FLOAT4((float4) result);
 }
 
-float32
-float4mi(float32 arg1, float32 arg2)
+Datum
+float4mi(PG_FUNCTION_ARGS)
 {
-       float32         result;
-       double          val;
-
-       if (!arg1 || !arg2)
-               return (float32) NULL;
-
-       val = *arg1 - *arg2;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
+       double          result;
 
-       CheckFloat4Val(val);
-       result = (float32) palloc(sizeof(float32data));
-       *result = val;
-       return result;
+       result = arg1 - arg2;
+       CheckFloat4Val(result);
+       PG_RETURN_FLOAT4((float4) result);
 }
 
-float32
-float4mul(float32 arg1, float32 arg2)
+Datum
+float4mul(PG_FUNCTION_ARGS)
 {
-       float32         result;
-       double          val;
-
-       if (!arg1 || !arg2)
-               return (float32) NULL;
-
-       val = *arg1 * *arg2;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
+       double          result;
 
-       CheckFloat4Val(val);
-       result = (float32) palloc(sizeof(float32data));
-       *result = val;
-       return result;
+       result = arg1 * arg2;
+       CheckFloat4Val(result);
+       PG_RETURN_FLOAT4((float4) result);
 }
 
-float32
-float4div(float32 arg1, float32 arg2)
+Datum
+float4div(PG_FUNCTION_ARGS)
 {
-       float32         result;
-       double          val;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
+       double          result;
 
-       if (!arg1 || !arg2)
-               return (float32) NULL;
-
-       if (*arg2 == 0.0)
+       if (arg2 == 0.0)
                elog(ERROR, "float4div: divide by zero error");
 
-       val = *arg1 / *arg2;
+       /* Do division in float8, then check for overflow */
+       result = (float8) arg1 / (float8) arg2;
 
-       CheckFloat4Val(val);
-       result = (float32) palloc(sizeof(float32data));
-       *result = val;
-       return result;
+       CheckFloat4Val(result);
+       PG_RETURN_FLOAT4((float4) result);
 }
 
 /*
- *             float8pl                - returns a pointer to arg1 + arg2
- *             float8mi                - returns a pointer to arg1 - arg2
- *             float8mul               - returns a pointer to arg1 * arg2
- *             float8div               - returns a pointer to arg1 / arg2
+ *             float8pl                - returns arg1 + arg2
+ *             float8mi                - returns arg1 - arg2
+ *             float8mul               - returns arg1 * arg2
+ *             float8div               - returns arg1 / arg2
  */
-float64
-float8pl(float64 arg1, float64 arg2)
+Datum
+float8pl(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          val;
-
-       if (!arg1 || !arg2)
-               return (float64) NULL;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
+       float8          result;
 
-       result = (float64) palloc(sizeof(float64data));
+       result = arg1 + arg2;
 
-       val = *arg1 + *arg2;
-       CheckFloat8Val(val);
-       *result = val;
-       return result;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
-float64
-float8mi(float64 arg1, float64 arg2)
+Datum
+float8mi(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          val;
-
-       if (!arg1 || !arg2)
-               return (float64) NULL;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
+       float8          result;
 
-       result = (float64) palloc(sizeof(float64data));
+       result = arg1 - arg2;
 
-       val = *arg1 - *arg2;
-       CheckFloat8Val(val);
-       *result = val;
-       return result;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
-float64
-float8mul(float64 arg1, float64 arg2)
+Datum
+float8mul(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          val;
-
-       if (!arg1 || !arg2)
-               return (float64) NULL;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
+       float8          result;
 
-       result = (float64) palloc(sizeof(float64data));
+       result = arg1 * arg2;
 
-       val = *arg1 * *arg2;
-       CheckFloat8Val(val);
-       *result = val;
-       return result;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
-float64
-float8div(float64 arg1, float64 arg2)
+Datum
+float8div(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          val;
-
-       if (!arg1 || !arg2)
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
+       float8          result;
 
-       if (*arg2 == 0.0)
+       if (arg2 == 0.0)
                elog(ERROR, "float8div: divide by zero error");
 
-       val = *arg1 / *arg2;
-       CheckFloat8Val(val);
-       *result = val;
-       return result;
+       result = arg1 / arg2;
+
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
 
@@ -608,115 +533,115 @@ float8div(float64 arg1, float64 arg2)
 /*
  *             float4{eq,ne,lt,le,gt,ge}               - float4/float4 comparison operations
  */
-bool
-float4eq(float32 arg1, float32 arg2)
+Datum
+float4eq(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
 
-       return *arg1 == *arg2;
+       PG_RETURN_BOOL(arg1 == arg2);
 }
 
-bool
-float4ne(float32 arg1, float32 arg2)
+Datum
+float4ne(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
 
-       return *arg1 != *arg2;
+       PG_RETURN_BOOL(arg1 != arg2);
 }
 
-bool
-float4lt(float32 arg1, float32 arg2)
+Datum
+float4lt(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
 
-       return *arg1 < *arg2;
+       PG_RETURN_BOOL(arg1 < arg2);
 }
 
-bool
-float4le(float32 arg1, float32 arg2)
+Datum
+float4le(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
 
-       return *arg1 <= *arg2;
+       PG_RETURN_BOOL(arg1 <= arg2);
 }
 
-bool
-float4gt(float32 arg1, float32 arg2)
+Datum
+float4gt(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
 
-       return *arg1 > *arg2;
+       PG_RETURN_BOOL(arg1 > arg2);
 }
 
-bool
-float4ge(float32 arg1, float32 arg2)
+Datum
+float4ge(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
 
-       return *arg1 >= *arg2;
+       PG_RETURN_BOOL(arg1 >= arg2);
 }
 
 /*
  *             float8{eq,ne,lt,le,gt,ge}               - float8/float8 comparison operations
  */
-bool
-float8eq(float64 arg1, float64 arg2)
+Datum
+float8eq(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
 
-       return *arg1 == *arg2;
+       PG_RETURN_BOOL(arg1 == arg2);
 }
 
-bool
-float8ne(float64 arg1, float64 arg2)
+Datum
+float8ne(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
 
-       return *arg1 != *arg2;
+       PG_RETURN_BOOL(arg1 != arg2);
 }
 
-bool
-float8lt(float64 arg1, float64 arg2)
+Datum
+float8lt(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
 
-       return *arg1 < *arg2;
+       PG_RETURN_BOOL(arg1 < arg2);
 }
 
-bool
-float8le(float64 arg1, float64 arg2)
+Datum
+float8le(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
 
-       return *arg1 <= *arg2;
+       PG_RETURN_BOOL(arg1 <= arg2);
 }
 
-bool
-float8gt(float64 arg1, float64 arg2)
+Datum
+float8gt(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
 
-       return *arg1 > *arg2;
+       PG_RETURN_BOOL(arg1 > arg2);
 }
 
-bool
-float8ge(float64 arg1, float64 arg2)
+Datum
+float8ge(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
 
-       return *arg1 >= *arg2;
+       PG_RETURN_BOOL(arg1 >= arg2);
 }
 
 
@@ -729,57 +654,43 @@ float8ge(float64 arg1, float64 arg2)
 /*
  *             ftod                    - converts a float4 number to a float8 number
  */
-float64
-ftod(float32 num)
+Datum
+ftod(PG_FUNCTION_ARGS)
 {
-       float64         result;
-
-       if (!num)
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float4          num = PG_GETARG_FLOAT4(0);
 
-       *result = *num;
-       return result;
+       PG_RETURN_FLOAT8((float8) num);
 }
 
 
 /*
  *             dtof                    - converts a float8 number to a float4 number
  */
-float32
-dtof(float64 num)
+Datum
+dtof(PG_FUNCTION_ARGS)
 {
-       float32         result;
-
-       if (!num)
-               return (float32) NULL;
-
-       CheckFloat4Val(*num);
+       float8          num = PG_GETARG_FLOAT8(0);
 
-       result = (float32) palloc(sizeof(float32data));
+       CheckFloat4Val(num);
 
-       *result = *num;
-       return result;
+       PG_RETURN_FLOAT4((float4) num);
 }
 
 
 /*
  *             dtoi4                   - converts a float8 number to an int4 number
  */
-int32
-dtoi4(float64 num)
+Datum
+dtoi4(PG_FUNCTION_ARGS)
 {
+       float8          num = PG_GETARG_FLOAT8(0);
        int32           result;
 
-       if (!num)
-               return 0;                               /* fmgr will return NULL anyway */
-
-       if ((*num < INT_MIN) || (*num > INT_MAX))
+       if ((num < INT_MIN) || (num > INT_MAX))
                elog(ERROR, "dtoi4: integer out of range");
 
-       result = rint(*num);
-       return result;
+       result = (int32) rint(num);
+       PG_RETURN_INT32(result);
 }
 
 
@@ -829,21 +740,19 @@ i2tod(PG_FUNCTION_ARGS)
 
 
 /*
- *             ftoi4                   - converts a float8 number to an int4 number
+ *             ftoi4                   - converts a float4 number to an int4 number
  */
-int32
-ftoi4(float32 num)
+Datum
+ftoi4(PG_FUNCTION_ARGS)
 {
+       float4          num = PG_GETARG_FLOAT4(0);
        int32           result;
 
-       if (!num)
-               return 0;                               /* fmgr will return NULL anyway */
-
-       if ((*num < INT_MIN) || (*num > INT_MAX))
+       if ((num < INT_MIN) || (num > INT_MAX))
                elog(ERROR, "ftoi4: integer out of range");
 
-       result = rint(*num);
-       return result;
+       result = (int32) rint(num);
+       PG_RETURN_INT32(result);
 }
 
 
@@ -903,7 +812,9 @@ float8_text(PG_FUNCTION_ARGS)
        int                     len;
        char       *str;
 
-       str = float8out(&num);          /* XXX temporary hack */
+       str = DatumGetCString(DirectFunctionCall1(float8out,
+                                                                                         Float8GetDatum(num)));
+
        len = strlen(str) + VARHDRSZ;
 
        result = (text *) palloc(len);
@@ -924,7 +835,7 @@ Datum
 text_float8(PG_FUNCTION_ARGS)
 {
        text       *string = PG_GETARG_TEXT_P(0);
-       float64         result;
+       Datum           result;
        int                     len;
        char       *str;
 
@@ -933,11 +844,11 @@ text_float8(PG_FUNCTION_ARGS)
        memcpy(str, VARDATA(string), len);
        *(str + len) = '\0';
 
-       result = float8in(str);
+       result = DirectFunctionCall1(float8in, CStringGetDatum(str));
 
        pfree(str);
 
-       return PointerGetDatum(result);
+       PG_RETURN_DATUM(result);
 }
 
 
@@ -952,7 +863,9 @@ float4_text(PG_FUNCTION_ARGS)
        int                     len;
        char       *str;
 
-       str = float4out(&num);          /* XXX temporary hack */
+       str = DatumGetCString(DirectFunctionCall1(float4out,
+                                                                                         Float4GetDatum(num)));
+
        len = strlen(str) + VARHDRSZ;
 
        result = (text *) palloc(len);
@@ -973,7 +886,7 @@ Datum
 text_float4(PG_FUNCTION_ARGS)
 {
        text       *string = PG_GETARG_TEXT_P(0);
-       float32         result;
+       Datum           result;
        int                     len;
        char       *str;
 
@@ -982,11 +895,11 @@ text_float4(PG_FUNCTION_ARGS)
        memcpy(str, VARDATA(string), len);
        *(str + len) = '\0';
 
-       result = float4in(str);
+       result = DirectFunctionCall1(float4in, CStringGetDatum(str));
 
        pfree(str);
 
-       return PointerGetDatum(result);
+       PG_RETURN_DATUM(result);
 }
 
 
@@ -997,143 +910,111 @@ text_float4(PG_FUNCTION_ARGS)
  */
 
 /*
- *             dround                  - returns a pointer to  ROUND(arg1)
+ *             dround                  - returns       ROUND(arg1)
  */
-float64
-dround(float64 arg1)
+Datum
+dround(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          tmp;
-
-       if (!arg1)
-               return (float64) NULL;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       result = (float64) palloc(sizeof(float64data));
+       result = rint(arg1);
 
-       tmp = *arg1;
-       *result = (float64data) rint(tmp);
-       return result;
+       PG_RETURN_FLOAT8(result);
 }
 
 
 /*
- *             dtrunc                  - returns a pointer to  truncation of arg1,
- *                                               arg1 >= 0 ... the greatest integer as float8 less
+ *             dtrunc                  - returns truncation-towards-zero of arg1,
+ *                                               arg1 >= 0 ... the greatest integer less
  *                                                                             than or equal to arg1
- *                                               arg1 < 0      ... the greatest integer as float8 greater
+ *                                               arg1 < 0      ... the least integer greater
  *                                                                             than or equal to arg1
  */
-float64
-dtrunc(float64 arg1)
+Datum
+dtrunc(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          tmp;
-
-       if (!arg1)
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       tmp = *arg1;
-       if (*arg1 >= 0)
-               *result = (float64data) floor(tmp);
+       if (arg1 >= 0)
+               result = floor(arg1);
        else
-               *result = (float64data) -(floor(-tmp));
-       return result;
+               result = -floor(-arg1);
+
+       PG_RETURN_FLOAT8(result);
 }
 
 
 /*
- *             dsqrt                   - returns a pointer to square root of arg1
+ *             dsqrt                   - returns square root of arg1
  */
-float64
-dsqrt(float64 arg1)
+Datum
+dsqrt(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          tmp;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       if (!arg1)
-               return (float64) NULL;
+       if (arg1 < 0)
+               elog(ERROR, "can't take sqrt of a negative number");
 
-       result = (float64) palloc(sizeof(float64data));
+       result = sqrt(arg1);
 
-       tmp = *arg1;
-       *result = (float64data) sqrt(tmp);
-       return result;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
 
 /*
- *             dcbrt                   - returns a pointer to cube root of arg1
+ *             dcbrt                   - returns cube root of arg1
  */
-float64
-dcbrt(float64 arg1)
+Datum
+dcbrt(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          tmp;
-
-       if (!arg1)
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       tmp = *arg1;
-       *result = (float64data) cbrt(tmp);
-       return result;
+       result = cbrt(arg1);
+       PG_RETURN_FLOAT8(result);
 }
 
 
 /*
- *             dpow                    - returns a pointer to pow(arg1,arg2)
+ *             dpow                    - returns pow(arg1,arg2)
  */
-float64
-dpow(float64 arg1, float64 arg2)
+Datum
+dpow(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          tmp1,
-                               tmp2;
-
-       if (!arg1 || !arg2)
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
-
-       tmp1 = *arg1;
-       tmp2 = *arg2;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
+       float8          result;
 
        /*
         * We must check both for errno getting set and for a NaN result, in
         * order to deal with the vagaries of different platforms...
         */
        errno = 0;
-       *result = (float64data) pow(tmp1, tmp2);
+       result = pow(arg1, arg2);
        if (errno != 0
 #ifdef HAVE_FINITE
-               || !finite(*result)
+               || !finite(result)
 #endif
                )
                elog(ERROR, "pow() result is out of range");
 
-       CheckFloat8Val(*result);
-       return result;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
 
 /*
- *             dexp                    - returns a pointer to the exponential function of arg1
+ *             dexp                    - returns the exponential function of arg1
  */
-float64
-dexp(float64 arg1)
+Datum
+dexp(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          tmp;
-
-       if (!arg1)
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
-
-       tmp = *arg1;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
        /*
         * We must check both for errno getting set and for a NaN result, in
@@ -1141,395 +1022,318 @@ dexp(float64 arg1)
         * zero result implies unreported underflow.
         */
        errno = 0;
-       *result = (float64data) exp(tmp);
-       if (errno != 0 || *result == 0.0
+       result = exp(arg1);
+       if (errno != 0 || result == 0.0
 #ifdef HAVE_FINITE
-               || !finite(*result)
+               || !finite(result)
 #endif
                )
                elog(ERROR, "exp() result is out of range");
 
-       CheckFloat8Val(*result);
-       return result;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
 
 /*
- *             dlog1                   - returns a pointer to the natural logarithm of arg1
+ *             dlog1                   - returns the natural logarithm of arg1
  *                                               ("dlog" is already a logging routine...)
  */
-float64
-dlog1(float64 arg1)
+Datum
+dlog1(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          tmp;
-
-       if (!PointerIsValid(arg1))
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       tmp = *arg1;
-       if (tmp == 0.0)
+       if (arg1 == 0.0)
                elog(ERROR, "can't take log of zero");
-       if (tmp < 0)
+       if (arg1 < 0)
                elog(ERROR, "can't take log of a negative number");
-       *result = (float64data) log(tmp);
 
-       CheckFloat8Val(*result);
-       return result;
-}      /* dlog1() */
+       result = log(arg1);
+
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
+}
 
 
 /*
- *             dlog10                  - returns a pointer to the base 10 logarithm of arg1
+ *             dlog10                  - returns the base 10 logarithm of arg1
  */
-float64
-dlog10(float64 arg1)
+Datum
+dlog10(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          tmp;
-
-       if (!PointerIsValid(arg1))
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       tmp = *arg1;
-       if (tmp == 0.0)
+       if (arg1 == 0.0)
                elog(ERROR, "can't take log of zero");
-       if (tmp < 0)
+       if (arg1 < 0)
                elog(ERROR, "can't take log of a negative number");
-       *result = (float64data) log10(tmp);
 
-       CheckFloat8Val(*result);
-       return result;
-}      /* dlog10() */
+       result = log10(arg1);
+
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
+}
 
 
 /*
- *             dacos                   - returns a pointer to the arccos of arg1 (radians)
+ *             dacos                   - returns the arccos of arg1 (radians)
  */
-float64
-dacos(float64 arg1)
+Datum
+dacos(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          tmp;
-
-       if (!PointerIsValid(arg1))
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       tmp = *arg1;
        errno = 0;
-       *result = (float64data) acos(tmp);
+       result = acos(arg1);
        if (errno != 0
 #ifdef HAVE_FINITE
-               || !finite(*result)
+               || !finite(result)
 #endif
                )
-               elog(ERROR, "dacos(%f) input is out of range", *arg1);
+               elog(ERROR, "acos(%f) input is out of range", arg1);
 
-       CheckFloat8Val(*result);
-       return result;
-}      /* dacos() */
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
+}
 
 
 /*
- *             dasin                   - returns a pointer to the arcsin of arg1 (radians)
+ *             dasin                   - returns the arcsin of arg1 (radians)
  */
-float64
-dasin(float64 arg1)
+Datum
+dasin(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          tmp;
-
-       if (!PointerIsValid(arg1))
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       tmp = *arg1;
        errno = 0;
-       *result = (float64data) asin(tmp);
+       result = asin(arg1);
        if (errno != 0
 #ifdef HAVE_FINITE
-               || !finite(*result)
+               || !finite(result)
 #endif
                )
-               elog(ERROR, "dasin(%f) input is out of range", *arg1);
+               elog(ERROR, "asin(%f) input is out of range", arg1);
 
-       CheckFloat8Val(*result);
-       return result;
-}      /* dasin() */
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
+}
 
 
 /*
- *             datan                   - returns a pointer to the arctan of arg1 (radians)
+ *             datan                   - returns the arctan of arg1 (radians)
  */
-float64
-datan(float64 arg1)
+Datum
+datan(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          tmp;
-
-       if (!PointerIsValid(arg1))
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       tmp = *arg1;
        errno = 0;
-       *result = (float64data) atan(tmp);
+       result = atan(arg1);
        if (errno != 0
 #ifdef HAVE_FINITE
-               || !finite(*result)
+               || !finite(result)
 #endif
                )
-               elog(ERROR, "atan(%f) input is out of range", *arg1);
+               elog(ERROR, "atan(%f) input is out of range", arg1);
 
-       CheckFloat8Val(*result);
-       return result;
-}      /* datan() */
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
+}
 
 
 /*
- *             atan2                   - returns a pointer to the arctan2 of arg1 (radians)
+ *             atan2                   - returns the arctan2 of arg1 (radians)
  */
-float64
-datan2(float64 arg1, float64 arg2)
+Datum
+datan2(PG_FUNCTION_ARGS)
 {
-       float64         result;
-
-       if (!PointerIsValid(arg1) || !PointerIsValid(arg1))
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
+       float8          result;
 
        errno = 0;
-       *result = (float64data) atan2(*arg1, *arg2);
+       result = atan2(arg1, arg2);
        if (errno != 0
 #ifdef HAVE_FINITE
-               || !finite(*result)
+               || !finite(result)
 #endif
                )
-               elog(ERROR, "atan2(%f,%f) input is out of range", *arg1, *arg2);
+               elog(ERROR, "atan2(%f,%f) input is out of range", arg1, arg2);
 
-       CheckFloat8Val(*result);
-       return result;
-}      /* datan2() */
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
+}
 
 
 /*
- *             dcos                    - returns a pointer to the cosine of arg1 (radians)
+ *             dcos                    - returns the cosine of arg1 (radians)
  */
-float64
-dcos(float64 arg1)
+Datum
+dcos(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          tmp;
-
-       if (!PointerIsValid(arg1))
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       tmp = *arg1;
        errno = 0;
-       *result = (float64data) cos(tmp);
+       result = cos(arg1);
        if (errno != 0
 #ifdef HAVE_FINITE
-               || !finite(*result)
+               || !finite(result)
 #endif
                )
-               elog(ERROR, "dcos(%f) input is out of range", *arg1);
+               elog(ERROR, "cos(%f) input is out of range", arg1);
 
-       CheckFloat8Val(*result);
-       return result;
-}      /* dcos() */
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
+}
 
 
 /*
- *             dcot                    - returns a pointer to the cotangent of arg1 (radians)
+ *             dcot                    - returns the cotangent of arg1 (radians)
  */
-float64
-dcot(float64 arg1)
+Datum
+dcot(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          tmp;
-
-       if (!PointerIsValid(arg1))
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       tmp = *arg1;
        errno = 0;
-       *result = (float64data) tan(tmp);
-       if ((errno != 0) || (*result == 0.0)
+       result = tan(arg1);
+       if (errno != 0 || result == 0.0
 #ifdef HAVE_FINITE
-               || !finite(*result)
+               || !finite(result)
 #endif
                )
-               elog(ERROR, "dcot(%f) input is out of range", *arg1);
+               elog(ERROR, "cot(%f) input is out of range", arg1);
 
-       *result = 1.0 / (*result);
-       CheckFloat8Val(*result);
-       return result;
-}      /* dcot() */
+       result = 1.0 / result;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
+}
 
 
 /*
- *             dsin                    - returns a pointer to the sine of arg1 (radians)
+ *             dsin                    - returns the sine of arg1 (radians)
  */
-float64
-dsin(float64 arg1)
+Datum
+dsin(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          tmp;
-
-       if (!PointerIsValid(arg1))
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       tmp = *arg1;
        errno = 0;
-       *result = (float64data) sin(tmp);
+       result = sin(arg1);
        if (errno != 0
 #ifdef HAVE_FINITE
-               || !finite(*result)
+               || !finite(result)
 #endif
                )
-               elog(ERROR, "dsin(%f) input is out of range", *arg1);
+               elog(ERROR, "sin(%f) input is out of range", arg1);
 
-       CheckFloat8Val(*result);
-       return result;
-}      /* dsin() */
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
+}
 
 
 /*
- *             dtan                    - returns a pointer to the tangent of arg1 (radians)
+ *             dtan                    - returns the tangent of arg1 (radians)
  */
-float64
-dtan(float64 arg1)
+Datum
+dtan(PG_FUNCTION_ARGS)
 {
-       float64         result;
-       double          tmp;
-
-       if (!PointerIsValid(arg1))
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       tmp = *arg1;
        errno = 0;
-       *result = (float64data) tan(tmp);
+       result = tan(arg1);
        if (errno != 0
 #ifdef HAVE_FINITE
-               || !finite(*result)
+               || !finite(result)
 #endif
                )
-               elog(ERROR, "dtan(%f) input is out of range", *arg1);
-
-       CheckFloat8Val(*result);
-       return result;
-}      /* dtan() */
+               elog(ERROR, "tan(%f) input is out of range", arg1);
 
-
-#ifndef M_PI
-/* from my RH5.2 gcc math.h file - thomas 2000-04-03 */
-#define M_PI 3.14159265358979323846
-#endif
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
+}
 
 
 /*
- *             degrees         - returns a pointer to degrees converted from radians
+ *             degrees         - returns degrees converted from radians
  */
-float64
-degrees(float64 arg1)
+Datum
+degrees(PG_FUNCTION_ARGS)
 {
-       float64         result;
-
-       if (!arg1)
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       *result = ((*arg1) * (180.0 / M_PI));
+       result = arg1 * (180.0 / M_PI);
 
-       CheckFloat8Val(*result);
-       return result;
-}      /* degrees() */
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
+}
 
 
 /*
- *             dpi                             - returns a pointer to degrees converted to radians
+ *             dpi                             - returns the constant PI
  */
-float64
-dpi(void)
+Datum
+dpi(PG_FUNCTION_ARGS)
 {
-       float64         result;
-
-       result = (float64) palloc(sizeof(float64data));
-
-       *result = (M_PI);
-
-       return result;
-}      /* dpi() */
+       PG_RETURN_FLOAT8(M_PI);
+}
 
 
 /*
- *             radians         - returns a pointer to radians converted from degrees
+ *             radians         - returns radians converted from degrees
  */
-float64
-radians(float64 arg1)
+Datum
+radians(PG_FUNCTION_ARGS)
 {
-       float64         result;
-
-       if (!arg1)
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float8          result;
 
-       *result = ((*arg1) * (M_PI / 180.0));
+       result = arg1 * (M_PI / 180.0);
 
-       CheckFloat8Val(*result);
-       return result;
-}      /* radians() */
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
+}
 
 
 /*
  *             drandom         - returns a random number
  */
-float64
-drandom(void)
+Datum
+drandom(PG_FUNCTION_ARGS)
 {
-       float64         result;
-
-       result = (float64) palloc(sizeof(float64data));
+       float8          result;
 
        /* result 0.0-1.0 */
-       *result = (((double) random()) / RAND_MAX);
+       result = ((double) random()) / RAND_MAX;
 
-       CheckFloat8Val(*result);
-       return result;
-}      /* drandom() */
+       PG_RETURN_FLOAT8(result);
+}
 
 
 /*
  *             setseed         - set seed for the random number generator
  */
-int32
-setseed(float64 seed)
+Datum
+setseed(PG_FUNCTION_ARGS)
 {
-       int                     iseed = ((*seed) * RAND_MAX);
+       float8          seed = PG_GETARG_FLOAT8(0);
+       int                     iseed = (seed * RAND_MAX);
 
-       srandom((unsigned int) ((*seed) * RAND_MAX));
+       srandom((unsigned int) iseed);
 
-       return iseed;
-}      /* setseed() */
+       PG_RETURN_INT32(iseed);
+}
 
 
 
@@ -1710,142 +1514,121 @@ float8_stddev(PG_FUNCTION_ARGS)
  */
 
 /*
- *             float48pl               - returns a pointer to arg1 + arg2
- *             float48mi               - returns a pointer to arg1 - arg2
- *             float48mul              - returns a pointer to arg1 * arg2
- *             float48div              - returns a pointer to arg1 / arg2
+ *             float48pl               - returns arg1 + arg2
+ *             float48mi               - returns arg1 - arg2
+ *             float48mul              - returns arg1 * arg2
+ *             float48div              - returns arg1 / arg2
  */
-float64
-float48pl(float32 arg1, float64 arg2)
+Datum
+float48pl(PG_FUNCTION_ARGS)
 {
-       float64         result;
-
-       if (!arg1 || !arg2)
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
+       float8          result;
 
-       *result = *arg1 + *arg2;
-       CheckFloat8Val(*result);
-       return result;
+       result = arg1 + arg2;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
-float64
-float48mi(float32 arg1, float64 arg2)
+Datum
+float48mi(PG_FUNCTION_ARGS)
 {
-       float64         result;
-
-       if (!arg1 || !arg2)
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
+       float8          result;
 
-       *result = *arg1 - *arg2;
-       CheckFloat8Val(*result);
-       return result;
+       result = arg1 - arg2;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
-float64
-float48mul(float32 arg1, float64 arg2)
+Datum
+float48mul(PG_FUNCTION_ARGS)
 {
-       float64         result;
-
-       if (!arg1 || !arg2)
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
+       float8          result;
 
-       *result = *arg1 * *arg2;
-       CheckFloat8Val(*result);
-       return result;
+       result = arg1 * arg2;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
-float64
-float48div(float32 arg1, float64 arg2)
+Datum
+float48div(PG_FUNCTION_ARGS)
 {
-       float64         result;
-
-       if (!arg1 || !arg2)
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
+       float8          result;
 
-       if (*arg2 == 0.0)
+       if (arg2 == 0.0)
                elog(ERROR, "float48div: divide by zero");
 
-       *result = *arg1 / *arg2;
-       CheckFloat8Val(*result);
-       return result;
+       result = arg1 / arg2;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
 /*
- *             float84pl               - returns a pointer to arg1 + arg2
- *             float84mi               - returns a pointer to arg1 - arg2
- *             float84mul              - returns a pointer to arg1 * arg2
- *             float84div              - returns a pointer to arg1 / arg2
+ *             float84pl               - returns arg1 + arg2
+ *             float84mi               - returns arg1 - arg2
+ *             float84mul              - returns arg1 * arg2
+ *             float84div              - returns arg1 / arg2
  */
-float64
-float84pl(float64 arg1, float32 arg2)
+Datum
+float84pl(PG_FUNCTION_ARGS)
 {
-       float64         result;
-
-       if (!arg1 || !arg2)
-               return (float64) NULL;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
+       float8          result;
 
-       result = (float64) palloc(sizeof(float64data));
+       result = arg1 + arg2;
 
-       *result = *arg1 + *arg2;
-       CheckFloat8Val(*result);
-       return result;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
-float64
-float84mi(float64 arg1, float32 arg2)
+Datum
+float84mi(PG_FUNCTION_ARGS)
 {
-       float64         result;
-
-       if (!arg1 || !arg2)
-               return (float64) NULL;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
+       float8          result;
 
-       result = (float64) palloc(sizeof(float64data));
+       result = arg1 - arg2;
 
-       *result = *arg1 - *arg2;
-       CheckFloat8Val(*result);
-       return result;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
-float64
-float84mul(float64 arg1, float32 arg2)
+Datum
+float84mul(PG_FUNCTION_ARGS)
 {
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
+       float8          result;
 
-       float64         result;
-
-       if (!arg1 || !arg2)
-               return (float64) NULL;
-
-       result = (float64) palloc(sizeof(float64data));
+       result = arg1 * arg2;
 
-       *result = *arg1 * *arg2;
-       CheckFloat8Val(*result);
-       return result;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
-float64
-float84div(float64 arg1, float32 arg2)
+Datum
+float84div(PG_FUNCTION_ARGS)
 {
-       float64         result;
-
-       if (!arg1 || !arg2)
-               return (float64) NULL;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
+       float8          result;
 
-       result = (float64) palloc(sizeof(float64data));
+       if (arg2 == 0.0)
+               elog(ERROR, "float84div: divide by zero");
 
-       if (*arg2 == 0.0)
-               elog(ERROR, "float48div: divide by zero");
+       result = arg1 / arg2;
 
-       *result = *arg1 / *arg2;
-       CheckFloat8Val(*result);
-       return result;
+       CheckFloat8Val(result);
+       PG_RETURN_FLOAT8(result);
 }
 
 /*
@@ -1857,115 +1640,115 @@ float84div(float64 arg1, float32 arg2)
 /*
  *             float48{eq,ne,lt,le,gt,ge}              - float4/float8 comparison operations
  */
-bool
-float48eq(float32 arg1, float64 arg2)
+Datum
+float48eq(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
 
-       return *arg1 == *arg2;
+       PG_RETURN_BOOL(arg1 == arg2);
 }
 
-bool
-float48ne(float32 arg1, float64 arg2)
+Datum
+float48ne(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
 
-       return *arg1 != *arg2;
+       PG_RETURN_BOOL(arg1 != arg2);
 }
 
-bool
-float48lt(float32 arg1, float64 arg2)
+Datum
+float48lt(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
 
-       return *arg1 < *arg2;
+       PG_RETURN_BOOL(arg1 < arg2);
 }
 
-bool
-float48le(float32 arg1, float64 arg2)
+Datum
+float48le(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
 
-       return *arg1 <= *arg2;
+       PG_RETURN_BOOL(arg1 <= arg2);
 }
 
-bool
-float48gt(float32 arg1, float64 arg2)
+Datum
+float48gt(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
 
-       return *arg1 > *arg2;
+       PG_RETURN_BOOL(arg1 > arg2);
 }
 
-bool
-float48ge(float32 arg1, float64 arg2)
+Datum
+float48ge(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float4          arg1 = PG_GETARG_FLOAT4(0);
+       float8          arg2 = PG_GETARG_FLOAT8(1);
 
-       return *arg1 >= *arg2;
+       PG_RETURN_BOOL(arg1 >= arg2);
 }
 
 /*
- *             float84{eq,ne,lt,le,gt,ge}              - float4/float8 comparison operations
+ *             float84{eq,ne,lt,le,gt,ge}              - float8/float4 comparison operations
  */
-bool
-float84eq(float64 arg1, float32 arg2)
+Datum
+float84eq(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
 
-       return *arg1 == *arg2;
+       PG_RETURN_BOOL(arg1 == arg2);
 }
 
-bool
-float84ne(float64 arg1, float32 arg2)
+Datum
+float84ne(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
 
-       return *arg1 != *arg2;
+       PG_RETURN_BOOL(arg1 != arg2);
 }
 
-bool
-float84lt(float64 arg1, float32 arg2)
+Datum
+float84lt(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
 
-       return *arg1 < *arg2;
+       PG_RETURN_BOOL(arg1 < arg2);
 }
 
-bool
-float84le(float64 arg1, float32 arg2)
+Datum
+float84le(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
 
-       return *arg1 <= *arg2;
+       PG_RETURN_BOOL(arg1 <= arg2);
 }
 
-bool
-float84gt(float64 arg1, float32 arg2)
+Datum
+float84gt(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
 
-       return *arg1 > *arg2;
+       PG_RETURN_BOOL(arg1 > arg2);
 }
 
-bool
-float84ge(float64 arg1, float32 arg2)
+Datum
+float84ge(PG_FUNCTION_ARGS)
 {
-       if (!arg1 || !arg2)
-               return 0;
+       float8          arg1 = PG_GETARG_FLOAT8(0);
+       float4          arg2 = PG_GETARG_FLOAT4(1);
 
-       return *arg1 >= *arg2;
+       PG_RETURN_BOOL(arg1 >= arg2);
 }
 
 /* ========== PRIVATE ROUTINES ========== */
@@ -1996,26 +1779,14 @@ float84ge(float64 arg1, float32 arg2)
  *             Inexact flag raised if x not equal to rint(x).
  */
 
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-                       one = 1.0,
+static const double one = 1.0,
                        TWO52[2] = {
        4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
        -4.50359962737049600000e+15,/* 0xC3300000, 0x00000000 */
 };
 
-#ifdef __STDC__
 static double
 rint(double x)
-#else
-static double
-rint(x)
-double         x;
-
-#endif
 {
        int                     i0,
                                n0,
@@ -2088,10 +1859,8 @@ double           x;
 
 #ifndef HAVE_CBRT
 
-static
-double
-cbrt(x)
-double         x;
+static double
+cbrt(double x)
 {
        int                     isneg = (x < 0.0);
        double          tmpres = pow(fabs(x), (double) 1.0 / (double) 3.0);
index 7133142c0b6cbe6bbc0316c68c1c2328915f6bd1..b1153c30d1763f40225d4578abe41a9b1cb4297c 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.41 2000/07/17 03:05:17 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.42 2000/08/01 18:29:35 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -65,7 +65,7 @@ int2out(PG_FUNCTION_ARGS)
        int16           arg1 = PG_GETARG_INT16(0);
        char       *result = (char *) palloc(7); /* sign, 5 digits, '\0' */
 
-       itoa((int) arg1, result);
+       pg_itoa(arg1, result);
        PG_RETURN_CSTRING(result);
 }
 
@@ -123,7 +123,7 @@ int2vectorout(PG_FUNCTION_ARGS)
        {
                if (num != 0)
                        *rp++ = ' ';
-               ltoa(int2Array[num], rp);
+               pg_itoa(int2Array[num], rp);
                while (*++rp != '\0')
                        ;
        }
@@ -187,7 +187,7 @@ int44out(PG_FUNCTION_ARGS)
        walk = result;
        for (i = 0; i < 4; i++)
        {
-               itoa(an_array[i], walk);
+               pg_ltoa(an_array[i], walk);
                while (*++walk != '\0')
                        ;
                *walk++ = ' ';
@@ -221,7 +221,7 @@ int4out(PG_FUNCTION_ARGS)
        int32           arg1 = PG_GETARG_INT32(0);
        char       *result = (char *) palloc(12); /* sign, 10 digits, '\0' */
 
-       ltoa(arg1, result);
+       pg_ltoa(arg1, result);
        PG_RETURN_CSTRING(result);
 }
 
@@ -259,7 +259,7 @@ int2_text(PG_FUNCTION_ARGS)
        int16           arg1 = PG_GETARG_INT16(0);
        text       *result = (text *) palloc(7+VARHDRSZ); /* sign,5 digits, '\0' */
 
-       itoa((int) arg1, VARDATA(result));
+       pg_itoa(arg1, VARDATA(result));
        VARATT_SIZEP(result) = strlen(VARDATA(result)) + VARHDRSZ;
        PG_RETURN_TEXT_P(result);
 }
@@ -290,7 +290,7 @@ int4_text(PG_FUNCTION_ARGS)
        int32           arg1 = PG_GETARG_INT32(0);
        text       *result = (text *) palloc(12+VARHDRSZ); /* sign,10 digits,'\0' */
 
-       ltoa(arg1, VARDATA(result));
+       pg_ltoa(arg1, VARDATA(result));
        VARATT_SIZEP(result) = strlen(VARDATA(result)) + VARHDRSZ;
        PG_RETURN_TEXT_P(result);
 }
index bc9a6fe6b31ec1e0ac159923ef89bcfd3b65f0f8..a867e7f34824c128e79a733490e0fc53200bd0a6 100644 (file)
@@ -5,7 +5,7 @@
  *
  *     1998 Jan Wieck
  *
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.33 2000/07/29 03:26:41 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.34 2000/08/01 18:29:35 tgl Exp $
  *
  * ----------
  */
@@ -1766,17 +1766,19 @@ numeric_float8(PG_FUNCTION_ARGS)
 {
        Numeric         num = PG_GETARG_NUMERIC(0);
        char       *tmp;
-       float64         result;
+       Datum           result;
 
        if (NUMERIC_IS_NAN(num))
                PG_RETURN_FLOAT8(NAN);
 
        tmp = DatumGetCString(DirectFunctionCall1(numeric_out,
                                                                                          NumericGetDatum(num)));
-       result = float8in(tmp);
+
+       result = DirectFunctionCall1(float8in, CStringGetDatum(tmp));
+
        pfree(tmp);
 
-       PG_RETURN_POINTER(result);
+       PG_RETURN_DATUM(result);
 }
 
 
@@ -1809,17 +1811,19 @@ numeric_float4(PG_FUNCTION_ARGS)
 {
        Numeric         num = PG_GETARG_NUMERIC(0);
        char       *tmp;
-       float32         result;
+       Datum           result;
 
        if (NUMERIC_IS_NAN(num))
-               PG_RETURN_FLOAT4(NAN);
+               PG_RETURN_FLOAT4((float4) NAN);
 
        tmp = DatumGetCString(DirectFunctionCall1(numeric_out,
                                                                                          NumericGetDatum(num)));
-       result = float4in(tmp);
+
+       result = DirectFunctionCall1(float4in, CStringGetDatum(tmp));
+
        pfree(tmp);
 
-       PG_RETURN_POINTER(result);
+       PG_RETURN_DATUM(result);
 }
 
 
index 3d4956afe2eca8ed7a63d728dc4ed206690db027..ea188e70f3196c8e925c8b70ef1d1f657f7b255c 100644 (file)
@@ -3,7 +3,7 @@
  * numutils.c
  *       utility functions for I/O of built-in numeric types.
  *
- *             integer:                                itoa, ltoa
+ *             integer:                                pg_itoa, pg_ltoa
  *             floating point:                 ftoa, atof1
  *
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.41 2000/07/12 22:59:09 petere Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.42 2000/08/01 18:29:35 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -116,27 +116,27 @@ pg_atoi(char *s, int size, int c)
 }
 
 /*
- *             itoa                    - converts a short int to its string represention
+ *             pg_itoa                 - converts a short int to its string represention
  *
  *             Note:
  *                             previously based on ~ingres/source/gutil/atoi.c
  *                             now uses vendor's sprintf conversion
  */
 void
-itoa(int i, char *a)
+pg_itoa(int16 i, char *a)
 {
        sprintf(a, "%hd", (short) i);
 }
 
 /*
- *             ltoa                    - converts a long int to its string represention
+ *             pg_ltoa                 - converts a long int to its string represention
  *
  *             Note:
  *                             previously based on ~ingres/source/gutil/atoi.c
  *                             now uses vendor's sprintf conversion
  */
 void
-ltoa(int32 l, char *a)
+pg_ltoa(int32 l, char *a)
 {
        sprintf(a, "%d", l);
 }
index a51eadfc5ef5969ee70cf0224b34731f6c338e27..6ae7d48d2c73b6fd4b82e1acbfd29dc754155b89 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.37 2000/07/03 23:09:52 wieck Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.38 2000/08/01 18:29:35 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -79,7 +79,7 @@ oidvectorout(PG_FUNCTION_ARGS)
        {
                if (num != 0)
                        *rp++ = ' ';
-               ltoa(oidArray[num], rp);
+               pg_ltoa((int32) oidArray[num], rp);
                while (*++rp != '\0')
                        ;
        }
index 7d06975b70286987360a81629a2dc058fc8689e0..42e99039c715cbd49532323302ebd2cc98e73ad2 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_proc.h,v 1.154 2000/07/31 22:39:05 tgl Exp $
+ * $Id: pg_proc.h,v 1.155 2000/08/01 18:29:30 tgl Exp $
  *
  * NOTES
  *       The script catalog/genbki.sh reads this file and generates .bki
@@ -365,13 +365,13 @@ DESCR("modulus");
 DATA(insert OID = 175 (  int42mod                 PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100  int42mod - ));
 DESCR("modulus");
 DATA(insert OID = 176 (  int2pl                           PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100  int2pl - ));
-DESCR("addition");
+DESCR("add");
 DATA(insert OID = 177 (  int4pl                           PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100  int4pl - ));
-DESCR("addition");
+DESCR("add");
 DATA(insert OID = 178 (  int24pl                  PGUID 12 f t t t 2 f 23 "21 23" 100 0 0 100  int24pl - ));
-DESCR("addition");
+DESCR("add");
 DATA(insert OID = 179 (  int42pl                  PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100  int42pl - ));
-DESCR("addition");
+DESCR("add");
 DATA(insert OID = 180 (  int2mi                           PGUID 12 f t t t 2 f 21 "21 21" 100 0 0 100  int2mi - ));
 DESCR("subtract");
 DATA(insert OID = 181 (  int4mi                           PGUID 12 f t t t 2 f 23 "23 23" 100 0 0 100  int4mi - ));
@@ -415,27 +415,27 @@ DESCR("r-tree");
 
 /* OIDS 200 - 299 */
 
-DATA(insert OID = 200 (  float4in                 PGUID 11 f t t t 1 f 700 "0" 100 0 0 100  float4in - ));
+DATA(insert OID = 200 (  float4in                 PGUID 12 f t t t 1 f 700 "0" 100 0 0 100  float4in - ));
 DESCR("(internal)");
-DATA(insert OID = 201 (  float4out                PGUID 11 f t t t 1 f 23  "0" 100 0 0 100  float4out - ));
+DATA(insert OID = 201 (  float4out                PGUID 12 f t t t 1 f 23  "700" 100 0 0 100  float4out - ));
 DESCR("(internal)");
-DATA(insert OID = 202 (  float4mul                PGUID 11 f t t t 2 f 700 "700 700" 100 0 0 100  float4mul - ));
+DATA(insert OID = 202 (  float4mul                PGUID 12 f t t t 2 f 700 "700 700" 100 0 0 100  float4mul - ));
 DESCR("multiply");
-DATA(insert OID = 203 (  float4div                PGUID 11 f t t t 2 f 700 "700 700" 100 0 0 100  float4div - ));
+DATA(insert OID = 203 (  float4div                PGUID 12 f t t t 2 f 700 "700 700" 100 0 0 100  float4div - ));
 DESCR("divide");
-DATA(insert OID = 204 (  float4pl                 PGUID 11 f t t t 2 f 700 "700 700" 100 0 0 100  float4pl - ));
-DESCR("addition");
-DATA(insert OID = 205 (  float4mi                 PGUID 11 f t t t 2 f 700 "700 700" 100 0 0 100  float4mi - ));
+DATA(insert OID = 204 (  float4pl                 PGUID 12 f t t t 2 f 700 "700 700" 100 0 0 100  float4pl - ));
+DESCR("add");
+DATA(insert OID = 205 (  float4mi                 PGUID 12 f t t t 2 f 700 "700 700" 100 0 0 100  float4mi - ));
 DESCR("subtract");
-DATA(insert OID = 206 (  float4um                 PGUID 11 f t t t 1 f 700 "700" 100 0 0 100  float4um - ));
+DATA(insert OID = 206 (  float4um                 PGUID 12 f t t t 1 f 700 "700" 100 0 0 100  float4um - ));
 DESCR("negate");
-DATA(insert OID = 207 (  float4abs                PGUID 11 f t t t 1 f 700 "700" 100 0 0 100  float4abs - ));
+DATA(insert OID = 207 (  float4abs                PGUID 12 f t t t 1 f 700 "700" 100 0 0 100  float4abs - ));
 DESCR("absolute value");
 DATA(insert OID = 208 (  float4_accum     PGUID 12 f t t t 2 f 1022 "1022 700" 100 0 0 100  float4_accum - ));
 DESCR("aggregate transition function");
-DATA(insert OID = 209 (  float4larger     PGUID 11 f t t t 2 f 700 "700 700" 100 0 0 100  float4larger - ));
+DATA(insert OID = 209 (  float4larger     PGUID 12 f t t t 2 f 700 "700 700" 100 0 0 100  float4larger - ));
 DESCR("larger of two");
-DATA(insert OID = 211 (  float4smaller    PGUID 11 f t t t 2 f 700 "700 700" 100 0 0 100  float4smaller - ));
+DATA(insert OID = 211 (  float4smaller    PGUID 12 f t t t 2 f 700 "700 700" 100 0 0 100  float4smaller - ));
 DESCR("smaller of two");
 
 DATA(insert OID = 212 (  int4um                           PGUID 12 f t t t 1 f 23 "23" 100 0 0 100  int4um - ));
@@ -443,27 +443,27 @@ DESCR("negate");
 DATA(insert OID = 213 (  int2um                           PGUID 12 f t t t 1 f 21 "21" 100 0 0 100  int2um - ));
 DESCR("negate");
 
-DATA(insert OID = 214 (  float8in                 PGUID 11 f t t t 1 f 701 "0" 100 0 0 100  float8in - ));
+DATA(insert OID = 214 (  float8in                 PGUID 12 f t t t 1 f 701 "0" 100 0 0 100  float8in - ));
 DESCR("(internal)");
-DATA(insert OID = 215 (  float8out                PGUID 11 f t t t 1 f 23  "0" 100 0 0 100  float8out - ));
+DATA(insert OID = 215 (  float8out                PGUID 12 f t t t 1 f 23  "701" 100 0 0 100  float8out - ));
 DESCR("(internal)");
-DATA(insert OID = 216 (  float8mul                PGUID 11 f t t t 2 f 701 "701 701" 100 0 0 100  float8mul - ));
+DATA(insert OID = 216 (  float8mul                PGUID 12 f t t t 2 f 701 "701 701" 100 0 0 100  float8mul - ));
 DESCR("multiply");
-DATA(insert OID = 217 (  float8div                PGUID 11 f t t t 2 f 701 "701 701" 100 0 0 100  float8div - ));
+DATA(insert OID = 217 (  float8div                PGUID 12 f t t t 2 f 701 "701 701" 100 0 0 100  float8div - ));
 DESCR("divide");
-DATA(insert OID = 218 (  float8pl                 PGUID 11 f t t t 2 f 701 "701 701" 100 0 0 100  float8pl - ));
-DESCR("addition");
-DATA(insert OID = 219 (  float8mi                 PGUID 11 f t t t 2 f 701 "701 701" 100 0 0 100  float8mi - ));
+DATA(insert OID = 218 (  float8pl                 PGUID 12 f t t t 2 f 701 "701 701" 100 0 0 100  float8pl - ));
+DESCR("add");
+DATA(insert OID = 219 (  float8mi                 PGUID 12 f t t t 2 f 701 "701 701" 100 0 0 100  float8mi - ));
 DESCR("subtract");
-DATA(insert OID = 220 (  float8um                 PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  float8um - ));
+DATA(insert OID = 220 (  float8um                 PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  float8um - ));
 DESCR("negate");
-DATA(insert OID = 221 (  float8abs                PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  float8abs - ));
+DATA(insert OID = 221 (  float8abs                PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  float8abs - ));
 DESCR("absolute value");
 DATA(insert OID = 222 (  float8_accum     PGUID 12 f t t t 2 f 1022 "1022 701" 100 0 0 100  float8_accum - ));
 DESCR("aggregate transition function");
-DATA(insert OID = 223 (  float8larger     PGUID 11 f t t t 2 f 701 "701 701" 100 0 0 100  float8larger - ));
+DATA(insert OID = 223 (  float8larger     PGUID 12 f t t t 2 f 701 "701 701" 100 0 0 100  float8larger - ));
 DESCR("larger of two");
-DATA(insert OID = 224 (  float8smaller    PGUID 11 f t t t 2 f 701 "701 701" 100 0 0 100  float8smaller - ));
+DATA(insert OID = 224 (  float8smaller    PGUID 12 f t t t 2 f 701 "701 701" 100 0 0 100  float8smaller - ));
 DESCR("smaller of two");
 
 DATA(insert OID = 225 (  lseg_center      PGUID 12 f t t t 1 f 600 "601" 100 0 0 100  lseg_center - ));
@@ -473,19 +473,19 @@ DESCR("center of");
 DATA(insert OID = 227 (  poly_center      PGUID 12 f t t t 1 f 600 "604" 100 0 0 100  poly_center - ));
 DESCR("center of");
 
-DATA(insert OID = 228 (  dround                           PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dround - ));
-DESCR("round to integer");
-DATA(insert OID = 229 (  dtrunc                           PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dtrunc - ));
+DATA(insert OID = 228 (  dround                           PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dround - ));
+DESCR("round to nearest integer");
+DATA(insert OID = 229 (  dtrunc                           PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dtrunc - ));
 DESCR("truncate to integer");
-DATA(insert OID = 230 (  dsqrt                    PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dsqrt - ));
+DATA(insert OID = 230 (  dsqrt                    PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dsqrt - ));
 DESCR("square root");
-DATA(insert OID = 231 (  dcbrt                    PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dcbrt - ));
+DATA(insert OID = 231 (  dcbrt                    PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dcbrt - ));
 DESCR("cube root");
-DATA(insert OID = 232 (  dpow                     PGUID 11 f t t t 2 f 701 "701 701" 100 0 0 100  dpow - ));
+DATA(insert OID = 232 (  dpow                     PGUID 12 f t t t 2 f 701 "701 701" 100 0 0 100  dpow - ));
 DESCR("exponentiation (x^y)");
-DATA(insert OID = 233 (  dexp                     PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dexp - ));
+DATA(insert OID = 233 (  dexp                     PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dexp - ));
 DESCR("natural exponential (e^x)");
-DATA(insert OID = 234 (  dlog1                    PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dlog1 - ));
+DATA(insert OID = 234 (  dlog1                    PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dlog1 - ));
 DESCR("natural logarithm");
 DATA(insert OID = 235 (  float8                           PGUID 12 f t t t 1 f 701  "21" 100 0 0 100  i2tod - ));
 DESCR("convert int2 to float8");
@@ -507,7 +507,7 @@ DESCR("(internal)");
 DATA(insert OID = 243 (  reltimeout               PGUID 12 f t f t 1 f 23  "0" 100 0 0 100  reltimeout - ));
 DESCR("(internal)");
 DATA(insert OID = 244 (  timepl                           PGUID 12 f t f t 2 f 702 "702 703" 100 0 0 100  timepl - ));
-DESCR("addition");
+DESCR("add");
 DATA(insert OID = 245 (  timemi                           PGUID 12 f t f t 2 f 702 "702 703" 100 0 0 100  timemi - ));
 DESCR("subtract");
 DATA(insert OID = 246 (  tintervalin      PGUID 12 f t f t 1 f 704 "0" 100 0 0 100  tintervalin - ));
@@ -579,80 +579,80 @@ DESCR("");
 DATA(insert OID = 278 (  inter_lb                 PGUID 12 f t t t 2 f 16 "628 603" 100 0 0 100        inter_lb - ));
 DESCR("");
 
-DATA(insert OID = 279 (  float48mul               PGUID 11 f t t t 2 f 701 "700 701" 100 0 0 100  float48mul - ));
+DATA(insert OID = 279 (  float48mul               PGUID 12 f t t t 2 f 701 "700 701" 100 0 0 100  float48mul - ));
 DESCR("multiply");
-DATA(insert OID = 280 (  float48div               PGUID 11 f t t t 2 f 701 "700 701" 100 0 0 100  float48div - ));
+DATA(insert OID = 280 (  float48div               PGUID 12 f t t t 2 f 701 "700 701" 100 0 0 100  float48div - ));
 DESCR("divide");
-DATA(insert OID = 281 (  float48pl                PGUID 11 f t t t 2 f 701 "700 701" 100 0 0 100  float48pl - ));
-DESCR("addition");
-DATA(insert OID = 282 (  float48mi                PGUID 11 f t t t 2 f 701 "700 701" 100 0 0 100  float48mi - ));
+DATA(insert OID = 281 (  float48pl                PGUID 12 f t t t 2 f 701 "700 701" 100 0 0 100  float48pl - ));
+DESCR("add");
+DATA(insert OID = 282 (  float48mi                PGUID 12 f t t t 2 f 701 "700 701" 100 0 0 100  float48mi - ));
 DESCR("subtract");
-DATA(insert OID = 283 (  float84mul               PGUID 11 f t t t 2 f 701 "701 700" 100 0 0 100  float84mul - ));
+DATA(insert OID = 283 (  float84mul               PGUID 12 f t t t 2 f 701 "701 700" 100 0 0 100  float84mul - ));
 DESCR("multiply");
-DATA(insert OID = 284 (  float84div               PGUID 11 f t t t 2 f 701 "701 700" 100 0 0 100  float84div - ));
+DATA(insert OID = 284 (  float84div               PGUID 12 f t t t 2 f 701 "701 700" 100 0 0 100  float84div - ));
 DESCR("divide");
-DATA(insert OID = 285 (  float84pl                PGUID 11 f t t t 2 f 701 "701 700" 100 0 0 100  float84pl - ));
-DESCR("addition");
-DATA(insert OID = 286 (  float84mi                PGUID 11 f t t t 2 f 701 "701 700" 100 0 0 100  float84mi - ));
+DATA(insert OID = 285 (  float84pl                PGUID 12 f t t t 2 f 701 "701 700" 100 0 0 100  float84pl - ));
+DESCR("add");
+DATA(insert OID = 286 (  float84mi                PGUID 12 f t t t 2 f 701 "701 700" 100 0 0 100  float84mi - ));
 DESCR("subtract");
 
-DATA(insert OID = 287 (  float4eq                 PGUID 11 f t t t 2 f 16 "700 700" 100 0 0 100        float4eq - ));
+DATA(insert OID = 287 (  float4eq                 PGUID 12 f t t t 2 f 16 "700 700" 100 0 0 100        float4eq - ));
 DESCR("equal");
-DATA(insert OID = 288 (  float4ne                 PGUID 11 f t t t 2 f 16 "700 700" 100 0 0 100        float4ne - ));
+DATA(insert OID = 288 (  float4ne                 PGUID 12 f t t t 2 f 16 "700 700" 100 0 0 100        float4ne - ));
 DESCR("not equal");
-DATA(insert OID = 289 (  float4lt                 PGUID 11 f t t t 2 f 16 "700 700" 100 0 0 100        float4lt - ));
+DATA(insert OID = 289 (  float4lt                 PGUID 12 f t t t 2 f 16 "700 700" 100 0 0 100        float4lt - ));
 DESCR("less-than");
-DATA(insert OID = 290 (  float4le                 PGUID 11 f t t t 2 f 16 "700 700" 100 0 0 100        float4le - ));
+DATA(insert OID = 290 (  float4le                 PGUID 12 f t t t 2 f 16 "700 700" 100 0 0 100        float4le - ));
 DESCR("less-than-or-equal");
-DATA(insert OID = 291 (  float4gt                 PGUID 11 f t t t 2 f 16 "700 700" 100 0 0 100        float4gt - ));
+DATA(insert OID = 291 (  float4gt                 PGUID 12 f t t t 2 f 16 "700 700" 100 0 0 100        float4gt - ));
 DESCR("greater-than");
-DATA(insert OID = 292 (  float4ge                 PGUID 11 f t t t 2 f 16 "700 700" 100 0 0 100        float4ge - ));
+DATA(insert OID = 292 (  float4ge                 PGUID 12 f t t t 2 f 16 "700 700" 100 0 0 100        float4ge - ));
 DESCR("greater-than-or-equal");
 
-DATA(insert OID = 293 (  float8eq                 PGUID 11 f t t t 2 f 16 "701 701" 100 0 0 100        float8eq - ));
+DATA(insert OID = 293 (  float8eq                 PGUID 12 f t t t 2 f 16 "701 701" 100 0 0 100        float8eq - ));
 DESCR("equal");
-DATA(insert OID = 294 (  float8ne                 PGUID 11 f t t t 2 f 16 "701 701" 100 0 0 100        float8ne - ));
+DATA(insert OID = 294 (  float8ne                 PGUID 12 f t t t 2 f 16 "701 701" 100 0 0 100        float8ne - ));
 DESCR("not equal");
-DATA(insert OID = 295 (  float8lt                 PGUID 11 f t t t 2 f 16 "701 701" 100 0 0 100        float8lt - ));
+DATA(insert OID = 295 (  float8lt                 PGUID 12 f t t t 2 f 16 "701 701" 100 0 0 100        float8lt - ));
 DESCR("less-than");
-DATA(insert OID = 296 (  float8le                 PGUID 11 f t t t 2 f 16 "701 701" 100 0 0 100        float8le - ));
+DATA(insert OID = 296 (  float8le                 PGUID 12 f t t t 2 f 16 "701 701" 100 0 0 100        float8le - ));
 DESCR("less-than-or-equal");
-DATA(insert OID = 297 (  float8gt                 PGUID 11 f t t t 2 f 16 "701 701" 100 0 0 100        float8gt - ));
+DATA(insert OID = 297 (  float8gt                 PGUID 12 f t t t 2 f 16 "701 701" 100 0 0 100        float8gt - ));
 DESCR("greater-than");
-DATA(insert OID = 298 (  float8ge                 PGUID 11 f t t t 2 f 16 "701 701" 100 0 0 100        float8ge - ));
+DATA(insert OID = 298 (  float8ge                 PGUID 12 f t t t 2 f 16 "701 701" 100 0 0 100        float8ge - ));
 DESCR("greater-than-or-equal");
 
-DATA(insert OID = 299 (  float48eq                PGUID 11 f t t t 2 f 16 "700 701" 100 0 0 100        float48eq - ));
+DATA(insert OID = 299 (  float48eq                PGUID 12 f t t t 2 f 16 "700 701" 100 0 0 100        float48eq - ));
 DESCR("equal");
 
 /* OIDS 300 - 399 */
 
-DATA(insert OID = 300 (  float48ne                PGUID 11 f t t t 2 f 16 "700 701" 100 0 0 100        float48ne - ));
+DATA(insert OID = 300 (  float48ne                PGUID 12 f t t t 2 f 16 "700 701" 100 0 0 100        float48ne - ));
 DESCR("not equal");
-DATA(insert OID = 301 (  float48lt                PGUID 11 f t t t 2 f 16 "700 701" 100 0 0 100        float48lt - ));
+DATA(insert OID = 301 (  float48lt                PGUID 12 f t t t 2 f 16 "700 701" 100 0 0 100        float48lt - ));
 DESCR("less-than");
-DATA(insert OID = 302 (  float48le                PGUID 11 f t t t 2 f 16 "700 701" 100 0 0 100        float48le - ));
+DATA(insert OID = 302 (  float48le                PGUID 12 f t t t 2 f 16 "700 701" 100 0 0 100        float48le - ));
 DESCR("less-than-or-equal");
-DATA(insert OID = 303 (  float48gt                PGUID 11 f t t t 2 f 16 "700 701" 100 0 0 100        float48gt - ));
+DATA(insert OID = 303 (  float48gt                PGUID 12 f t t t 2 f 16 "700 701" 100 0 0 100        float48gt - ));
 DESCR("greater-than");
-DATA(insert OID = 304 (  float48ge                PGUID 11 f t t t 2 f 16 "700 701" 100 0 0 100        float48ge - ));
+DATA(insert OID = 304 (  float48ge                PGUID 12 f t t t 2 f 16 "700 701" 100 0 0 100        float48ge - ));
 DESCR("greater-than-or-equal");
-DATA(insert OID = 305 (  float84eq                PGUID 11 f t t t 2 f 16 "701 700" 100 0 0 100        float84eq - ));
+DATA(insert OID = 305 (  float84eq                PGUID 12 f t t t 2 f 16 "701 700" 100 0 0 100        float84eq - ));
 DESCR("equal");
-DATA(insert OID = 306 (  float84ne                PGUID 11 f t t t 2 f 16 "701 700" 100 0 0 100        float84ne - ));
+DATA(insert OID = 306 (  float84ne                PGUID 12 f t t t 2 f 16 "701 700" 100 0 0 100        float84ne - ));
 DESCR("not equal");
-DATA(insert OID = 307 (  float84lt                PGUID 11 f t t t 2 f 16 "701 700" 100 0 0 100        float84lt - ));
+DATA(insert OID = 307 (  float84lt                PGUID 12 f t t t 2 f 16 "701 700" 100 0 0 100        float84lt - ));
 DESCR("less-than");
-DATA(insert OID = 308 (  float84le                PGUID 11 f t t t 2 f 16 "701 700" 100 0 0 100        float84le - ));
+DATA(insert OID = 308 (  float84le                PGUID 12 f t t t 2 f 16 "701 700" 100 0 0 100        float84le - ));
 DESCR("less-than-or-equal");
-DATA(insert OID = 309 (  float84gt                PGUID 11 f t t t 2 f 16 "701 700" 100 0 0 100        float84gt - ));
+DATA(insert OID = 309 (  float84gt                PGUID 12 f t t t 2 f 16 "701 700" 100 0 0 100        float84gt - ));
 DESCR("greater-than");
-DATA(insert OID = 310 (  float84ge                PGUID 11 f t t t 2 f 16 "701 700" 100 0 0 100        float84ge - ));
+DATA(insert OID = 310 (  float84ge                PGUID 12 f t t t 2 f 16 "701 700" 100 0 0 100        float84ge - ));
 DESCR("greater-than-or-equal");
 
-DATA(insert OID = 311 (  float8                           PGUID 11 f t t t 1 f 701 "700" 100 0 0 100  ftod - ));
+DATA(insert OID = 311 (  float8                           PGUID 12 f t t t 1 f 701 "700" 100 0 0 100  ftod - ));
 DESCR("convert float4 to float8");
-DATA(insert OID = 312 (  float4                           PGUID 11 f t t t 1 f 700 "701" 100 0 0 100  dtof - ));
+DATA(insert OID = 312 (  float4                           PGUID 12 f t t t 1 f 700 "701" 100 0 0 100  dtof - ));
 DESCR("convert float8 to float4");
 DATA(insert OID = 313 (  int4                     PGUID 12 f t t t 1 f  23  "21" 100 0 0 100  i2toi4 - ));
 DESCR("convert int2 to int4");
@@ -662,11 +662,11 @@ DATA(insert OID = 315 (  int2vectoreq        PGUID 12 f t t t 2 f  16  "22 22" 100 0
 DESCR("equal");
 DATA(insert OID = 316 (  float8                           PGUID 12 f t t t 1 f 701  "23" 100 0 0 100  i4tod - ));
 DESCR("convert int4 to float8");
-DATA(insert OID = 317 (  int4                     PGUID 11 f t t t 1 f  23 "701" 100 0 0 100  dtoi4 - ));
+DATA(insert OID = 317 (  int4                     PGUID 12 f t t t 1 f  23 "701" 100 0 0 100  dtoi4 - ));
 DESCR("convert float8 to int4");
 DATA(insert OID = 318 (  float4                           PGUID 12 f t t t 1 f 700  "23" 100 0 0 100  i4tof - ));
 DESCR("convert int4 to float4");
-DATA(insert OID = 319 (  int4                     PGUID 11 f t t t 1 f  23 "700" 100 0 0 100  ftoi4 - ));
+DATA(insert OID = 319 (  int4                     PGUID 12 f t t t 1 f  23 "700" 100 0 0 100  ftoi4 - ));
 DESCR("convert float4 to int4");
 
 DATA(insert OID = 320 (  rtinsert                 PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100  rtinsert - ));
@@ -842,9 +842,9 @@ DESCR("(internal)");
 DATA(insert OID = 462 (  int8um                           PGUID 12 f t t t 1 f 20 "20" 100 0 0 100  int8um - ));
 DESCR("negate");
 DATA(insert OID = 463 (  int8pl                           PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100  int8pl - ));
-DESCR("addition");
+DESCR("add");
 DATA(insert OID = 464 (  int8mi                           PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100  int8mi - ));
-DESCR("subtraction");
+DESCR("subtract");
 DATA(insert OID = 465 (  int8mul                  PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100  int8mul - ));
 DESCR("multiply");
 DATA(insert OID = 466 (  int8div                  PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100  int8div - ));
@@ -1058,11 +1058,11 @@ DESCR("convert float8 to text");
 DATA(insert OID = 841 (  text                     PGUID 12 f t t t 1 f  25 "700" 100 0 0 100  float4_text -));
 DESCR("convert float4 to text");
 
-DATA(insert OID =  846 (  cash_mul_flt4    PGUID 11 f t t t 2 f 790 "790 700" 100 0 0 100  cash_mul_flt4 - ));
+DATA(insert OID =  846 (  cash_mul_flt4    PGUID 12 f t t t 2 f 790 "790 700" 100 0 0 100  cash_mul_flt4 - ));
 DESCR("multiply");
-DATA(insert OID =  847 (  cash_div_flt4    PGUID 11 f t t t 2 f 790 "790 700" 100 0 0 100  cash_div_flt4 - ));
+DATA(insert OID =  847 (  cash_div_flt4    PGUID 12 f t t t 2 f 790 "790 700" 100 0 0 100  cash_div_flt4 - ));
 DESCR("divide");
-DATA(insert OID =  848 (  flt4_mul_cash    PGUID 11 f t t t 2 f 790 "700 790" 100 0 0 100  flt4_mul_cash - ));
+DATA(insert OID =  848 (  flt4_mul_cash    PGUID 12 f t t t 2 f 790 "700 790" 100 0 0 100  flt4_mul_cash - ));
 DESCR("multiply");
 
 DATA(insert OID =  849 (  position                PGUID 12 f t t t 2 f 23 "25 25" 100 0 1 0 textpos - ));
@@ -1127,19 +1127,19 @@ DESCR("greater-than");
 DATA(insert OID =  893 (  cash_ge                 PGUID 11 f t t t 2 f  16 "790 790" 100 0 0 100  cash_ge - ));
 DESCR("greater-than-or-equal");
 DATA(insert OID =  894 (  cash_pl                 PGUID 11 f t t t 2 f 790 "790 790" 100 0 0 100  cash_pl - ));
-DESCR("addition");
+DESCR("add");
 DATA(insert OID =  895 (  cash_mi                 PGUID 11 f t t t 2 f 790 "790 790" 100 0 0 100  cash_mi - ));
 DESCR("subtract");
-DATA(insert OID =  896 (  cash_mul_flt8                   PGUID 11 f t t t 2 f 790 "790 701" 100 0 0 100  cash_mul_flt8 - ));
+DATA(insert OID =  896 (  cash_mul_flt8                   PGUID 12 f t t t 2 f 790 "790 701" 100 0 0 100  cash_mul_flt8 - ));
 DESCR("multiply");
-DATA(insert OID =  897 (  cash_div_flt8                   PGUID 11 f t t t 2 f 790 "790 701" 100 0 0 100  cash_div_flt8 - ));
+DATA(insert OID =  897 (  cash_div_flt8                   PGUID 12 f t t t 2 f 790 "790 701" 100 0 0 100  cash_div_flt8 - ));
 DESCR("divide");
 DATA(insert OID =  898 (  cashlarger      PGUID 11 f t t t 2 f 790 "790 790" 100 0 0 100  cashlarger - ));
 DESCR("larger of two");
 DATA(insert OID =  899 (  cashsmaller     PGUID 11 f t t t 2 f 790 "790 790" 100 0 0 100  cashsmaller - ));
 DESCR("smaller of two");
 
-DATA(insert OID =  919 (  flt8_mul_cash                   PGUID 11 f t t t 2 f 790 "701 790" 100 0 0 100  flt8_mul_cash - ));
+DATA(insert OID =  919 (  flt8_mul_cash           PGUID 12 f t t t 2 f 790 "701 790" 100 0 0 100  flt8_mul_cash - ));
 DESCR("multiply");
 
 /* OIDS 900 - 999 */
@@ -1348,7 +1348,7 @@ DESCR("smaller of two");
 DATA(insert OID = 1140 (  date_mi                 PGUID 12 f t t t 2 f 23 "1082 1082" 100 0 0 100  date_mi - ));
 DESCR("subtract");
 DATA(insert OID = 1141 (  date_pli                PGUID 12 f t t t 2 f 1082 "1082 23" 100 0 0 100  date_pli - ));
-DESCR("addition");
+DESCR("add");
 DATA(insert OID = 1142 (  date_mii                PGUID 12 f t t t 2 f 1082 "1082 23" 100 0 0 100  date_mii - ));
 DESCR("subtract");
 DATA(insert OID = 1143 (  time_in                 PGUID 12 f t f t 1 f 1083 "0" 100 0 0 100    time_in - ));
@@ -1359,7 +1359,7 @@ DATA(insert OID = 1145 (  time_eq            PGUID 12 f t t t 2 f 16 "1083 1083" 100 0
 DESCR("equal");
 
 DATA(insert OID = 1146 (  circle_add_pt    PGUID 12 f t t t 2 f 718 "718 600" 100 0 0 100  circle_add_pt - ));
-DESCR("addition");
+DESCR("add");
 DATA(insert OID = 1147 (  circle_sub_pt    PGUID 12 f t t t 2 f 718 "718 600" 100 0 0 100  circle_sub_pt - ));
 DESCR("subtract");
 DATA(insert OID = 1148 (  circle_mul_pt    PGUID 12 f t t t 2 f 718 "718 600" 100 0 0 100  circle_mul_pt - ));
@@ -1405,7 +1405,7 @@ DESCR("greater-than");
 DATA(insert OID = 1168 (  interval_um     PGUID 12 f t f t 1 f 1186 "1186" 100 0 0 100  interval_um - ));
 DESCR("subtract");
 DATA(insert OID = 1169 (  interval_pl     PGUID 12 f t f t 2 f 1186 "1186 1186" 100 0 0 100    interval_pl - ));
-DESCR("addition");
+DESCR("add");
 DATA(insert OID = 1170 (  interval_mi     PGUID 12 f t f t 2 f 1186 "1186 1186" 100 0 0 100    interval_mi - ));
 DESCR("subtract");
 DATA(insert OID = 1171 (  date_part               PGUID 12 f t f t 2 f  701 "25 1184" 100 0 0 100  timestamp_part - ));
@@ -1494,17 +1494,17 @@ DATA(insert OID = 1272 (  datetime_pl      PGUID 12 f t f t 2 f 1184 "1082 1083" 1
 DESCR("convert date and time to timestamp");
 
 DATA(insert OID = 1274 (  int84pl                 PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100  int84pl - ));
-DESCR("addition");
+DESCR("add");
 DATA(insert OID = 1275 (  int84mi                 PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100  int84mi - ));
-DESCR("subtraction");
+DESCR("subtract");
 DATA(insert OID = 1276 (  int84mul                PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100  int84mul - ));
 DESCR("multiply");
 DATA(insert OID = 1277 (  int84div                PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100  int84div - ));
 DESCR("divide");
 DATA(insert OID = 1278 (  int48pl                 PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100  int48pl - ));
-DESCR("addition");
+DESCR("add");
 DATA(insert OID = 1279 (  int48mi                 PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100  int48mi - ));
-DESCR("subtraction");
+DESCR("subtract");
 DATA(insert OID = 1280 (  int48mul                PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100  int48mul - ));
 DESCR("multiply");
 DATA(insert OID = 1281 (  int48div                PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100  int48div - ));
@@ -1582,23 +1582,23 @@ DESCR("character length");
 DATA(insert OID = 1326 (  interval_div          PGUID 12 f t f t 2 f 1186 "1186 701" 100 0 0 100  interval_div - ));
 DESCR("divide");
 
-DATA(insert OID = 1339 (  dlog10                        PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dlog10 - ));
+DATA(insert OID = 1339 (  dlog10                        PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dlog10 - ));
 DESCR("base 10 logarithm");
-DATA(insert OID = 1340 (  log                           PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dlog10 - ));
+DATA(insert OID = 1340 (  log                           PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dlog10 - ));
 DESCR("base 10 logarithm");
-DATA(insert OID = 1341 (  ln                            PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dlog1 - ));
+DATA(insert OID = 1341 (  ln                            PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dlog1 - ));
 DESCR("natural logarithm");
-DATA(insert OID = 1342 (  round                                 PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dround - ));
-DESCR("round to integral part");
-DATA(insert OID = 1343 (  trunc                                 PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dtrunc - ));
-DESCR("truncate to integral part");
-DATA(insert OID = 1344 (  sqrt                          PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dsqrt - ));
+DATA(insert OID = 1342 (  round                                 PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dround - ));
+DESCR("round to nearest integer");
+DATA(insert OID = 1343 (  trunc                                 PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dtrunc - ));
+DESCR("truncate to integer");
+DATA(insert OID = 1344 (  sqrt                          PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dsqrt - ));
 DESCR("square root");
-DATA(insert OID = 1345 (  cbrt                          PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dcbrt - ));
+DATA(insert OID = 1345 (  cbrt                          PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dcbrt - ));
 DESCR("cube root");
-DATA(insert OID = 1346 (  pow                           PGUID 11 f t t t 2 f 701 "701 701" 100 0 0 100  dpow - ));
+DATA(insert OID = 1346 (  pow                           PGUID 12 f t t t 2 f 701 "701 701" 100 0 0 100  dpow - ));
 DESCR("exponentiation");
-DATA(insert OID = 1347 (  exp                           PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dexp - ));
+DATA(insert OID = 1347 (  exp                           PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dexp - ));
 DESCR("exponential");
 
 DATA(insert OID = 1348 (  obj_description       PGUID 14 f t f t 1 f   25 "26" 100 0 0 100  "select description from pg_description where objoid = $1" - ));
@@ -1696,9 +1696,9 @@ DATA(insert OID = 1392 (  factorial                  PGUID 12 f t t t 1 f 23 "23" 100 0 0 100
 DESCR("factorial");
 DATA(insert OID = 1393 (  factorial               PGUID 12 f t t t 1 f 20 "20" 100 0 0 100  int8fac - ));
 DESCR("factorial");
-DATA(insert OID = 1394 (  abs                     PGUID 11 f t t t 1 f 700 "700" 100 0 0 100  float4abs - ));
+DATA(insert OID = 1394 (  abs                     PGUID 12 f t t t 1 f 700 "700" 100 0 0 100  float4abs - ));
 DESCR("absolute value");
-DATA(insert OID = 1395 (  abs                     PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  float8abs - ));
+DATA(insert OID = 1395 (  abs                     PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  float8abs - ));
 DESCR("absolute value");
 DATA(insert OID = 1396 (  abs                     PGUID 12 f t t t 1 f 20 "20" 100 0 0 100  int8abs - ));
 DESCR("absolute value");
@@ -1993,34 +1993,34 @@ DESCR("less than");
 DATA(insert OID = 1596 (  bitcmp                       PGUID 11 f t t t 2 f 23 "1560 1560" 100 0 1 0  bitcmp - ));
 DESCR("compare");
 
-DATA(insert OID = 1598 (  random                       PGUID 11 f t f t 0 f 701 "0" 100 0 0 100        drandom - ));
-DESCR("radians to degrees");
-DATA(insert OID = 1599 (  setseed                      PGUID 11 f t t t 1 f    23 "701" 100 0 0 100  setseed - ));
-DESCR("radians to degrees");
+DATA(insert OID = 1598 (  random                       PGUID 12 f t f t 0 f 701 "0" 100 0 0 100        drandom - ));
+DESCR("random value");
+DATA(insert OID = 1599 (  setseed                      PGUID 12 f t f t 1 f  23 "701" 100 0 0 100  setseed - ));
+DESCR("set random seed");
 
 /* OIDS 1600 - 1699 */
 
-DATA(insert OID = 1600 (  asin                         PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dasin - ));
+DATA(insert OID = 1600 (  asin                         PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dasin - ));
 DESCR("arcsine");
-DATA(insert OID = 1601 (  acos                         PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dacos - ));
-DESCR("arcsine");
-DATA(insert OID = 1602 (  atan                         PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  datan - ));
+DATA(insert OID = 1601 (  acos                         PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dacos - ));
+DESCR("arccosine");
+DATA(insert OID = 1602 (  atan                         PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  datan - ));
 DESCR("arctangent");
-DATA(insert OID = 1603 (  atan2                                PGUID 11 f t t t 2 f 701 "701 701" 100 0 0 100  datan2 - ));
+DATA(insert OID = 1603 (  atan2                                PGUID 12 f t t t 2 f 701 "701 701" 100 0 0 100  datan2 - ));
 DESCR("arctangent, two arguments");
-DATA(insert OID = 1604 (  sin                          PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dsin - ));
+DATA(insert OID = 1604 (  sin                          PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dsin - ));
 DESCR("sine");
-DATA(insert OID = 1605 (  cos                          PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dcos - ));
+DATA(insert OID = 1605 (  cos                          PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dcos - ));
 DESCR("cosine");
-DATA(insert OID = 1606 (  tan                          PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dtan - ));
+DATA(insert OID = 1606 (  tan                          PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dtan - ));
 DESCR("tangent");
-DATA(insert OID = 1607 (  cot                          PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  dcot - ));
+DATA(insert OID = 1607 (  cot                          PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  dcot - ));
 DESCR("cotangent");
-DATA(insert OID = 1608 (  degrees                      PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  degrees - ));
-DESCR("radians to degrees");
-DATA(insert OID = 1609 (  radians                      PGUID 11 f t t t 1 f 701 "701" 100 0 0 100  radians - ));
+DATA(insert OID = 1608 (  degrees                      PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  degrees - ));
 DESCR("radians to degrees");
-DATA(insert OID = 1610 (  pi                           PGUID 11 f t t t 0 f 701 "0" 100 0 0 100        dpi - ));
+DATA(insert OID = 1609 (  radians                      PGUID 12 f t t t 1 f 701 "701" 100 0 0 100  radians - ));
+DESCR("degrees to radians");
+DATA(insert OID = 1610 (  pi                           PGUID 12 f t t t 0 f 701 "0" 100 0 0 100        dpi - ));
 DESCR("PI");
 
 DATA(insert OID = 1618 (  interval_mul         PGUID 12 f t t t 2 f 1186 "1186 701" 100 0 0 100        interval_mul - ));
@@ -2295,7 +2295,7 @@ DESCR("lower-than");
 DATA(insert OID = 1723 ( numeric_le                            PGUID 12 f t t t 2 f 16 "1700 1700" 100 0 0 100  numeric_le - ));
 DESCR("lower-than-or-equal");
 DATA(insert OID = 1724 ( numeric_add                   PGUID 12 f t t t 2 f 1700 "1700 1700" 100 0 0 100  numeric_add - ));
-DESCR("addition");
+DESCR("add");
 DATA(insert OID = 1725 ( numeric_sub                   PGUID 12 f t t t 2 f 1700 "1700 1700" 100 0 0 100  numeric_sub - ));
 DESCR("subtract");
 DATA(insert OID = 1726 ( numeric_mul                   PGUID 12 f t t t 2 f 1700 "1700 1700" 100 0 0 100  numeric_mul - ));
index dfbc422993935f5d9c0ebe66641d840d8eb9b663..862cea230c51c9a72d7592a2b18f134f31f77243 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: builtins.h,v 1.127 2000/07/30 22:14:04 tgl Exp $
+ * $Id: builtins.h,v 1.128 2000/08/01 18:29:31 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -141,19 +141,9 @@ extern int namestrcpy(Name name, const char *str);
 extern int     namestrcmp(Name name, const char *str);
 
 /* numutils.c */
-/* XXX hack.  HP-UX has a ltoa (with different arguments) already. */
-#ifdef __hpux
-#define ltoa pg_ltoa
-#endif  /* hpux */
 extern int32 pg_atoi(char *s, int size, int c);
-
-/* XXX hack.  QNX has itoa and ltoa (with different arguments) already. */
-#ifdef __QNX__
-#define itoa pg_itoa
-#define ltoa pg_ltoa
-#endif  /* QNX */
-extern void itoa(int i, char *a);
-extern void ltoa(int32 l, char *a);
+extern void pg_itoa(int16 i, char *a);
+extern void pg_ltoa(int32 l, char *a);
 
 /*
  *             Per-opclass comparison functions for new btrees.  These are
@@ -172,105 +162,99 @@ extern Datum btcharcmp(PG_FUNCTION_ARGS);
 extern Datum btnamecmp(PG_FUNCTION_ARGS);
 extern Datum bttextcmp(PG_FUNCTION_ARGS);
 
-/* filename.c */
-extern char *filename_in(char *file);
-extern char *filename_out(char *s);
-
 /* float.c */
-extern float32 float4in(char *num);
-extern char *float4out(float32 num);
-extern float64 float8in(char *num);
-extern char *float8out(float64 num);
-extern float32 float4abs(float32 arg1);
-extern float32 float4um(float32 arg1);
-extern float32 float4larger(float32 arg1, float32 arg2);
-extern float32 float4smaller(float32 arg1, float32 arg2);
-extern float64 float8abs(float64 arg1);
-extern float64 float8um(float64 arg1);
-extern float64 float8larger(float64 arg1, float64 arg2);
-extern float64 float8smaller(float64 arg1, float64 arg2);
-extern float32 float4pl(float32 arg1, float32 arg2);
-extern float32 float4mi(float32 arg1, float32 arg2);
-extern float32 float4mul(float32 arg1, float32 arg2);
-extern float32 float4div(float32 arg1, float32 arg2);
-extern float64 float8pl(float64 arg1, float64 arg2);
-extern float64 float8mi(float64 arg1, float64 arg2);
-extern float64 float8mul(float64 arg1, float64 arg2);
-extern float64 float8div(float64 arg1, float64 arg2);
-extern bool float4eq(float32 arg1, float32 arg2);
-extern bool float4ne(float32 arg1, float32 arg2);
-extern bool float4lt(float32 arg1, float32 arg2);
-extern bool float4le(float32 arg1, float32 arg2);
-extern bool float4gt(float32 arg1, float32 arg2);
-extern bool float4ge(float32 arg1, float32 arg2);
-extern bool float8eq(float64 arg1, float64 arg2);
-extern bool float8ne(float64 arg1, float64 arg2);
-extern bool float8lt(float64 arg1, float64 arg2);
-extern bool float8le(float64 arg1, float64 arg2);
-extern bool float8gt(float64 arg1, float64 arg2);
-extern bool float8ge(float64 arg1, float64 arg2);
-extern float64 ftod(float32 num);
+extern Datum float4in(PG_FUNCTION_ARGS);
+extern Datum float4out(PG_FUNCTION_ARGS);
+extern Datum float8in(PG_FUNCTION_ARGS);
+extern Datum float8out(PG_FUNCTION_ARGS);
+extern Datum float4abs(PG_FUNCTION_ARGS);
+extern Datum float4um(PG_FUNCTION_ARGS);
+extern Datum float4larger(PG_FUNCTION_ARGS);
+extern Datum float4smaller(PG_FUNCTION_ARGS);
+extern Datum float8abs(PG_FUNCTION_ARGS);
+extern Datum float8um(PG_FUNCTION_ARGS);
+extern Datum float8larger(PG_FUNCTION_ARGS);
+extern Datum float8smaller(PG_FUNCTION_ARGS);
+extern Datum float4pl(PG_FUNCTION_ARGS);
+extern Datum float4mi(PG_FUNCTION_ARGS);
+extern Datum float4mul(PG_FUNCTION_ARGS);
+extern Datum float4div(PG_FUNCTION_ARGS);
+extern Datum float8pl(PG_FUNCTION_ARGS);
+extern Datum float8mi(PG_FUNCTION_ARGS);
+extern Datum float8mul(PG_FUNCTION_ARGS);
+extern Datum float8div(PG_FUNCTION_ARGS);
+extern Datum float4eq(PG_FUNCTION_ARGS);
+extern Datum float4ne(PG_FUNCTION_ARGS);
+extern Datum float4lt(PG_FUNCTION_ARGS);
+extern Datum float4le(PG_FUNCTION_ARGS);
+extern Datum float4gt(PG_FUNCTION_ARGS);
+extern Datum float4ge(PG_FUNCTION_ARGS);
+extern Datum float8eq(PG_FUNCTION_ARGS);
+extern Datum float8ne(PG_FUNCTION_ARGS);
+extern Datum float8lt(PG_FUNCTION_ARGS);
+extern Datum float8le(PG_FUNCTION_ARGS);
+extern Datum float8gt(PG_FUNCTION_ARGS);
+extern Datum float8ge(PG_FUNCTION_ARGS);
+extern Datum ftod(PG_FUNCTION_ARGS);
 extern Datum i4tod(PG_FUNCTION_ARGS);
 extern Datum i2tod(PG_FUNCTION_ARGS);
-extern float32 dtof(float64 num);
-extern int32 dtoi4(float64 num);
+extern Datum dtof(PG_FUNCTION_ARGS);
+extern Datum dtoi4(PG_FUNCTION_ARGS);
 extern Datum dtoi2(PG_FUNCTION_ARGS);
 extern Datum i4tof(PG_FUNCTION_ARGS);
 extern Datum i2tof(PG_FUNCTION_ARGS);
-extern int32 ftoi4(float32 num);
+extern Datum ftoi4(PG_FUNCTION_ARGS);
 extern Datum ftoi2(PG_FUNCTION_ARGS);
 extern Datum text_float8(PG_FUNCTION_ARGS);
 extern Datum text_float4(PG_FUNCTION_ARGS);
 extern Datum float8_text(PG_FUNCTION_ARGS);
 extern Datum float4_text(PG_FUNCTION_ARGS);
-extern float64 dround(float64 arg1);
-extern float64 dtrunc(float64 arg1);
-extern float64 dsqrt(float64 arg1);
-extern float64 dcbrt(float64 arg1);
-extern float64 dpow(float64 arg1, float64 arg2);
-extern float64 dexp(float64 arg1);
-extern float64 dlog1(float64 arg1);
-extern float64 dlog10(float64 arg1);
-extern float64 dacos(float64 arg1);
-extern float64 dasin(float64 arg1);
-extern float64 datan(float64 arg1);
-extern float64 datan2(float64 arg1, float64 arg2);
-extern float64 dcos(float64 arg1);
-extern float64 dcot(float64 arg1);
-extern float64 dsin(float64 arg1);
-extern float64 dtan(float64 arg1);
-extern float64 degrees(float64 arg1);
-extern float64 dpi(void);
-extern float64 radians(float64 arg1);
-extern float64 dtan(float64 arg1);
-extern float64 drandom(void);
-extern int32 setseed(float64 seed);
+extern Datum dround(PG_FUNCTION_ARGS);
+extern Datum dtrunc(PG_FUNCTION_ARGS);
+extern Datum dsqrt(PG_FUNCTION_ARGS);
+extern Datum dcbrt(PG_FUNCTION_ARGS);
+extern Datum dpow(PG_FUNCTION_ARGS);
+extern Datum dexp(PG_FUNCTION_ARGS);
+extern Datum dlog1(PG_FUNCTION_ARGS);
+extern Datum dlog10(PG_FUNCTION_ARGS);
+extern Datum dacos(PG_FUNCTION_ARGS);
+extern Datum dasin(PG_FUNCTION_ARGS);
+extern Datum datan(PG_FUNCTION_ARGS);
+extern Datum datan2(PG_FUNCTION_ARGS);
+extern Datum dcos(PG_FUNCTION_ARGS);
+extern Datum dcot(PG_FUNCTION_ARGS);
+extern Datum dsin(PG_FUNCTION_ARGS);
+extern Datum dtan(PG_FUNCTION_ARGS);
+extern Datum degrees(PG_FUNCTION_ARGS);
+extern Datum dpi(PG_FUNCTION_ARGS);
+extern Datum radians(PG_FUNCTION_ARGS);
+extern Datum drandom(PG_FUNCTION_ARGS);
+extern Datum setseed(PG_FUNCTION_ARGS);
 extern Datum float8_accum(PG_FUNCTION_ARGS);
 extern Datum float4_accum(PG_FUNCTION_ARGS);
 extern Datum float8_avg(PG_FUNCTION_ARGS);
 extern Datum float8_variance(PG_FUNCTION_ARGS);
 extern Datum float8_stddev(PG_FUNCTION_ARGS);
-
-extern float64 float48pl(float32 arg1, float64 arg2);
-extern float64 float48mi(float32 arg1, float64 arg2);
-extern float64 float48mul(float32 arg1, float64 arg2);
-extern float64 float48div(float32 arg1, float64 arg2);
-extern float64 float84pl(float64 arg1, float32 arg2);
-extern float64 float84mi(float64 arg1, float32 arg2);
-extern float64 float84mul(float64 arg1, float32 arg2);
-extern float64 float84div(float64 arg1, float32 arg2);
-extern bool float48eq(float32 arg1, float64 arg2);
-extern bool float48ne(float32 arg1, float64 arg2);
-extern bool float48lt(float32 arg1, float64 arg2);
-extern bool float48le(float32 arg1, float64 arg2);
-extern bool float48gt(float32 arg1, float64 arg2);
-extern bool float48ge(float32 arg1, float64 arg2);
-extern bool float84eq(float64 arg1, float32 arg2);
-extern bool float84ne(float64 arg1, float32 arg2);
-extern bool float84lt(float64 arg1, float32 arg2);
-extern bool float84le(float64 arg1, float32 arg2);
-extern bool float84gt(float64 arg1, float32 arg2);
-extern bool float84ge(float64 arg1, float32 arg2);
+extern Datum float48pl(PG_FUNCTION_ARGS);
+extern Datum float48mi(PG_FUNCTION_ARGS);
+extern Datum float48mul(PG_FUNCTION_ARGS);
+extern Datum float48div(PG_FUNCTION_ARGS);
+extern Datum float84pl(PG_FUNCTION_ARGS);
+extern Datum float84mi(PG_FUNCTION_ARGS);
+extern Datum float84mul(PG_FUNCTION_ARGS);
+extern Datum float84div(PG_FUNCTION_ARGS);
+extern Datum float48eq(PG_FUNCTION_ARGS);
+extern Datum float48ne(PG_FUNCTION_ARGS);
+extern Datum float48lt(PG_FUNCTION_ARGS);
+extern Datum float48le(PG_FUNCTION_ARGS);
+extern Datum float48gt(PG_FUNCTION_ARGS);
+extern Datum float48ge(PG_FUNCTION_ARGS);
+extern Datum float84eq(PG_FUNCTION_ARGS);
+extern Datum float84ne(PG_FUNCTION_ARGS);
+extern Datum float84lt(PG_FUNCTION_ARGS);
+extern Datum float84le(PG_FUNCTION_ARGS);
+extern Datum float84gt(PG_FUNCTION_ARGS);
+extern Datum float84ge(PG_FUNCTION_ARGS);
 
 /* misc.c */
 extern Datum nullvalue(PG_FUNCTION_ARGS);
index cc612961d2954f132123aab06fc315c15bb72c0d..4a5829b090c65d06bd33b4919b150541f13286e6 100644 (file)
@@ -25,13 +25,13 @@ extern bool cash_ge(Cash *c1, Cash *c2);
 extern Cash *cash_pl(Cash *c1, Cash *c2);
 extern Cash *cash_mi(Cash *c1, Cash *c2);
 
-extern Cash *cash_mul_flt8(Cash *c, float8 *f);
-extern Cash *cash_div_flt8(Cash *c, float8 *f);
-extern Cash *flt8_mul_cash(float8 *f, Cash *c);
+extern Datum cash_mul_flt8(PG_FUNCTION_ARGS);
+extern Datum cash_div_flt8(PG_FUNCTION_ARGS);
+extern Datum flt8_mul_cash(PG_FUNCTION_ARGS);
 
-extern Cash *cash_mul_flt4(Cash *c, float4 *f);
-extern Cash *cash_div_flt4(Cash *c, float4 *f);
-extern Cash *flt4_mul_cash(float4 *f, Cash *c);
+extern Datum cash_mul_flt4(PG_FUNCTION_ARGS);
+extern Datum cash_div_flt4(PG_FUNCTION_ARGS);
+extern Datum flt4_mul_cash(PG_FUNCTION_ARGS);
 
 extern Datum cash_mul_int4(PG_FUNCTION_ARGS);
 extern Datum cash_div_int4(PG_FUNCTION_ARGS);