1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

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.
This commit is contained in:
Tom Lane
2000-06-05 07:29:25 +00:00
parent c61db5ba2d
commit 48165ec226
47 changed files with 2201 additions and 2034 deletions

View File

@ -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);
}