aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/numeric.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-06-05 07:29:25 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-06-05 07:29:25 +0000
commit48165ec2262b73c5b81a6caabab66d883d013a83 (patch)
tree08e878a2a1e7f76981406ac2b34729a510aecac6 /src/backend/utils/adt/numeric.c
parentc61db5ba2decf2e620f6ce3699d4b702957ed72a (diff)
downloadpostgresql-48165ec2262b73c5b81a6caabab66d883d013a83.tar.gz
postgresql-48165ec2262b73c5b81a6caabab66d883d013a83.zip
Latest round of fmgr updates. All functions with bool,char, or int2
inputs have been converted to newstyle. This should go a long way towards fixing our portability problems with platforms where char and short parameters are passed differently from int-width parameters. Still more to do for the Alpha port however.
Diffstat (limited to 'src/backend/utils/adt/numeric.c')
-rw-r--r--src/backend/utils/adt/numeric.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c
index 36e333e1217..500cb151ac7 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -5,7 +5,7 @@
*
* 1998 Jan Wieck
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.27 2000/04/12 17:15:50 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.28 2000/06/05 07:28:52 tgl Exp $
*
* ----------
*/
@@ -33,6 +33,9 @@
* Local definitions
* ----------
*/
+#define PG_GETARG_NUMERIC(n) ((Numeric) DatumGetPointer(fcinfo->arg[n]))
+#define PG_RETURN_NUMERIC(x) return PointerGetDatum(x)
+
#ifndef MIN
#define MIN(a,b) (((a)<(b)) ? (a) : (b))
#endif
@@ -1714,7 +1717,8 @@ int4_numeric(int32 val)
init_var(&result);
- tmp = int4out(val);
+ tmp = DatumGetCString(DirectFunctionCall1(int4out,
+ Int32GetDatum(val)));
set_var_from_str(tmp, &result);
res = make_result(&result);
@@ -1730,7 +1734,7 @@ numeric_int4(Numeric num)
{
NumericVar x;
char *str;
- int32 result;
+ Datum result;
if (num == NULL)
return 0;
@@ -1749,7 +1753,7 @@ numeric_int4(Numeric num)
free_var(&x);
- result = int4in(str);
+ result = DirectFunctionCall1(int4in, CStringGetDatum(str));
pfree(str);
return result;
@@ -1807,35 +1811,35 @@ numeric_int8(Numeric num)
}
-Numeric
-int2_numeric(int16 val)
+Datum
+int2_numeric(PG_FUNCTION_ARGS)
{
+ int16 val = PG_GETARG_INT16(0);
Numeric res;
NumericVar result;
char *tmp;
init_var(&result);
- tmp = int2out(val);
+ tmp = DatumGetCString(DirectFunctionCall1(int2out,
+ Int16GetDatum(val)));
set_var_from_str(tmp, &result);
res = make_result(&result);
free_var(&result);
pfree(tmp);
- return res;
+ PG_RETURN_NUMERIC(res);
}
-int16
-numeric_int2(Numeric num)
+Datum
+numeric_int2(PG_FUNCTION_ARGS)
{
+ Numeric num = PG_GETARG_NUMERIC(0);
NumericVar x;
char *str;
- int16 result;
-
- if (num == NULL)
- return 0;
+ Datum result;
if (NUMERIC_IS_NAN(num))
elog(ERROR, "Cannot convert NaN to int2");
@@ -1851,7 +1855,7 @@ numeric_int2(Numeric num)
free_var(&x);
- result = int2in(str);
+ result = DirectFunctionCall1(int2in, CStringGetDatum(str));
pfree(str);
return result;