aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/misc.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/misc.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/misc.c')
-rw-r--r--src/backend/utils/adt/misc.c73
1 files changed, 38 insertions, 35 deletions
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index 00af6350de5..7e3b8b167b9 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -8,44 +8,39 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.18 2000/01/26 05:57:14 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.19 2000/06/05 07:28:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include <sys/types.h>
#include <sys/file.h>
#include <time.h>
+
#include "postgres.h"
+
#include "utils/builtins.h"
-/*-------------------------------------------------------------------------
+
+/*
* Check if data is Null
*/
-bool
-nullvalue(Datum value, bool *isNull)
+Datum
+nullvalue(PG_FUNCTION_ARGS)
{
- if (*isNull)
- {
- *isNull = false;
- return true;
- }
- return false;
-
+ if (PG_ARGISNULL(0))
+ PG_RETURN_BOOL(true);
+ PG_RETURN_BOOL(false);
}
-/*----------------------------------------------------------------------*
- * check if data is not Null *
- *--------------------------------------------------------------------- */
-bool
-nonnullvalue(Datum value, bool *isNull)
+/*
+ * Check if data is not Null
+ */
+Datum
+nonnullvalue(PG_FUNCTION_ARGS)
{
- if (*isNull)
- {
- *isNull = false;
- return false;
- }
- return true;
-
+ if (PG_ARGISNULL(0))
+ PG_RETURN_BOOL(false);
+ PG_RETURN_BOOL(true);
}
/*
@@ -63,13 +58,18 @@ nonnullvalue(Datum value, bool *isNull)
static bool random_initialized = false;
-bool
-oidrand(Oid o, int32 X)
+Datum
+oidrand(PG_FUNCTION_ARGS)
{
+ /* XXX seems like we ought to be using the oid for something? */
+#ifdef NOT_USED
+ Oid o = PG_GETARG_OID(0);
+#endif
+ int32 X = PG_GETARG_INT32(1);
bool result;
if (X == 0)
- return true;
+ PG_RETURN_BOOL(true);
/*
* We do this because the cancel key is actually a random, so we don't
@@ -83,26 +83,29 @@ oidrand(Oid o, int32 X)
}
result = (random() % X == 0);
- return result;
+ PG_RETURN_BOOL(result);
}
/*
oidsrand(int32 X) -
seeds the random number generator
- always return true
+ always returns true
*/
-bool
-oidsrand(int32 X)
+Datum
+oidsrand(PG_FUNCTION_ARGS)
{
+ int32 X = PG_GETARG_INT32(0);
+
srand(X);
random_initialized = true;
- return true;
+ PG_RETURN_BOOL(true);
}
-
-int32
-userfntest(int i)
+Datum
+userfntest(PG_FUNCTION_ARGS)
{
- return i;
+ int32 i = PG_GETARG_INT32(0);
+
+ PG_RETURN_INT32(i);
}