1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* oid.c
|
2000-12-22 22:36:09 +01:00
|
|
|
* Functions for the built-in type Oid ... also oidvector.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2014-01-07 22:05:30 +01:00
|
|
|
* Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/backend/utils/adt/oid.c
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2000-11-21 05:27:39 +01:00
|
|
|
#include "postgres.h"
|
1996-11-06 11:32:10 +01:00
|
|
|
|
2000-01-10 16:41:34 +01:00
|
|
|
#include <ctype.h>
|
2000-12-22 22:36:09 +01:00
|
|
|
#include <limits.h>
|
2000-11-21 05:27:39 +01:00
|
|
|
|
2005-03-29 02:17:27 +02:00
|
|
|
#include "catalog/pg_type.h"
|
2003-05-09 17:44:42 +02:00
|
|
|
#include "libpq/pqformat.h"
|
2005-03-29 02:17:27 +02:00
|
|
|
#include "utils/array.h"
|
1999-07-16 05:14:30 +02:00
|
|
|
#include "utils/builtins.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2003-05-09 17:44:42 +02:00
|
|
|
|
2005-03-29 02:17:27 +02:00
|
|
|
#define OidVectorSize(n) (offsetof(oidvector, values) + (n) * sizeof(Oid))
|
|
|
|
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* USER I/O ROUTINES *
|
1996-07-09 08:22:35 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2000-12-22 22:36:09 +01:00
|
|
|
static Oid
|
2007-06-05 23:31:09 +02:00
|
|
|
oidin_subr(const char *s, char **endloc)
|
2000-12-22 22:36:09 +01:00
|
|
|
{
|
|
|
|
unsigned long cvt;
|
|
|
|
char *endptr;
|
|
|
|
Oid result;
|
|
|
|
|
2004-03-11 03:11:14 +01:00
|
|
|
if (*s == '\0')
|
2005-02-11 05:09:05 +01:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
|
|
|
errmsg("invalid input syntax for type oid: \"%s\"",
|
|
|
|
s)));
|
2004-03-11 03:11:14 +01:00
|
|
|
|
2000-12-22 22:36:09 +01:00
|
|
|
errno = 0;
|
|
|
|
cvt = strtoul(s, &endptr, 10);
|
|
|
|
|
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* strtoul() normally only sets ERANGE. On some systems it also may set
|
|
|
|
* EINVAL, which simply means it couldn't parse the input string. This is
|
|
|
|
* handled by the second "if" consistent across platforms.
|
2000-12-22 22:36:09 +01:00
|
|
|
*/
|
2003-07-27 06:53:12 +02:00
|
|
|
if (errno && errno != ERANGE && errno != EINVAL)
|
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
2004-02-18 01:01:34 +01:00
|
|
|
errmsg("invalid input syntax for type oid: \"%s\"",
|
2003-07-27 06:53:12 +02:00
|
|
|
s)));
|
2004-03-04 22:47:18 +01:00
|
|
|
|
2004-03-11 03:11:14 +01:00
|
|
|
if (endptr == s && *s != '\0')
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
2004-02-18 01:01:34 +01:00
|
|
|
errmsg("invalid input syntax for type oid: \"%s\"",
|
2003-07-27 06:53:12 +02:00
|
|
|
s)));
|
|
|
|
|
|
|
|
if (errno == ERANGE)
|
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
2004-02-18 01:01:34 +01:00
|
|
|
errmsg("value \"%s\" is out of range for type oid", s)));
|
2000-12-22 22:36:09 +01:00
|
|
|
|
|
|
|
if (endloc)
|
|
|
|
{
|
|
|
|
/* caller wants to deal with rest of string */
|
|
|
|
*endloc = endptr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* allow only whitespace after number */
|
|
|
|
while (*endptr && isspace((unsigned char) *endptr))
|
|
|
|
endptr++;
|
|
|
|
if (*endptr)
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
2004-02-18 01:01:34 +01:00
|
|
|
errmsg("invalid input syntax for type oid: \"%s\"",
|
2003-07-27 06:53:12 +02:00
|
|
|
s)));
|
2000-12-22 22:36:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
result = (Oid) cvt;
|
|
|
|
|
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* Cope with possibility that unsigned long is wider than Oid, in which
|
|
|
|
* case strtoul will not raise an error for some values that are out of
|
|
|
|
* the range of Oid.
|
2000-12-28 02:51:15 +01:00
|
|
|
*
|
2005-11-22 19:17:34 +01:00
|
|
|
* For backwards compatibility, we want to accept inputs that are given
|
|
|
|
* with a minus sign, so allow the input value if it matches after either
|
2005-10-15 04:49:52 +02:00
|
|
|
* signed or unsigned extension to long.
|
2000-12-22 22:36:09 +01:00
|
|
|
*
|
2005-11-22 19:17:34 +01:00
|
|
|
* To ensure consistent results on 32-bit and 64-bit platforms, make sure
|
|
|
|
* the error message is the same as if strtoul() had returned ERANGE.
|
2000-12-22 22:36:09 +01:00
|
|
|
*/
|
2000-12-28 02:51:15 +01:00
|
|
|
#if OID_MAX != ULONG_MAX
|
|
|
|
if (cvt != (unsigned long) result &&
|
2001-03-22 05:01:46 +01:00
|
|
|
cvt != (unsigned long) ((int) result))
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
2004-02-18 01:01:34 +01:00
|
|
|
errmsg("value \"%s\" is out of range for type oid", s)));
|
2000-12-22 22:36:09 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
oidin(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
char *s = PG_GETARG_CSTRING(0);
|
|
|
|
Oid result;
|
|
|
|
|
2007-06-05 23:31:09 +02:00
|
|
|
result = oidin_subr(s, NULL);
|
2000-12-22 22:36:09 +01:00
|
|
|
PG_RETURN_OID(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
oidout(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid o = PG_GETARG_OID(0);
|
|
|
|
char *result = (char *) palloc(12);
|
|
|
|
|
|
|
|
snprintf(result, 12, "%u", o);
|
|
|
|
PG_RETURN_CSTRING(result);
|
|
|
|
}
|
|
|
|
|
2003-05-09 17:44:42 +02:00
|
|
|
/*
|
|
|
|
* oidrecv - converts external binary format to oid
|
|
|
|
*/
|
|
|
|
Datum
|
|
|
|
oidrecv(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
|
|
|
|
|
|
|
|
PG_RETURN_OID((Oid) pq_getmsgint(buf, sizeof(Oid)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* oidsend - converts oid to binary format
|
|
|
|
*/
|
|
|
|
Datum
|
|
|
|
oidsend(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid arg1 = PG_GETARG_OID(0);
|
|
|
|
StringInfoData buf;
|
|
|
|
|
|
|
|
pq_begintypsend(&buf);
|
|
|
|
pq_sendint(&buf, arg1, sizeof(Oid));
|
|
|
|
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
|
|
|
|
}
|
|
|
|
|
2005-03-29 02:17:27 +02:00
|
|
|
/*
|
|
|
|
* construct oidvector given a raw array of Oids
|
|
|
|
*
|
|
|
|
* If oids is NULL then caller must fill values[] afterward
|
|
|
|
*/
|
|
|
|
oidvector *
|
|
|
|
buildoidvector(const Oid *oids, int n)
|
|
|
|
{
|
|
|
|
oidvector *result;
|
|
|
|
|
|
|
|
result = (oidvector *) palloc0(OidVectorSize(n));
|
|
|
|
|
|
|
|
if (n > 0 && oids)
|
|
|
|
memcpy(result->values, oids, n * sizeof(Oid));
|
|
|
|
|
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* Attach standard array header. For historical reasons, we set the index
|
|
|
|
* lower bound to 0 not 1.
|
2005-03-29 02:17:27 +02:00
|
|
|
*/
|
2007-02-28 00:48:10 +01:00
|
|
|
SET_VARSIZE(result, OidVectorSize(n));
|
2005-03-29 02:17:27 +02:00
|
|
|
result->ndim = 1;
|
2005-11-17 23:14:56 +01:00
|
|
|
result->dataoffset = 0; /* never any nulls */
|
2005-03-29 02:17:27 +02:00
|
|
|
result->elemtype = OIDOID;
|
|
|
|
result->dim1 = n;
|
|
|
|
result->lbound1 = 0;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2000-12-22 22:36:09 +01:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
2000-01-10 17:13:23 +01:00
|
|
|
* oidvectorin - converts "num num ..." to internal form
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
oidvectorin(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-06-05 09:29:25 +02:00
|
|
|
char *oidString = PG_GETARG_CSTRING(0);
|
2005-03-29 02:17:27 +02:00
|
|
|
oidvector *result;
|
|
|
|
int n;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2005-03-29 02:17:27 +02:00
|
|
|
result = (oidvector *) palloc0(OidVectorSize(FUNC_MAX_ARGS));
|
|
|
|
|
|
|
|
for (n = 0; n < FUNC_MAX_ARGS; n++)
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
2000-12-03 21:45:40 +01:00
|
|
|
while (*oidString && isspace((unsigned char) *oidString))
|
2000-01-10 16:41:34 +01:00
|
|
|
oidString++;
|
2000-12-22 22:36:09 +01:00
|
|
|
if (*oidString == '\0')
|
|
|
|
break;
|
2007-06-05 23:31:09 +02:00
|
|
|
result->values[n] = oidin_subr(oidString, &oidString);
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
2000-12-03 21:45:40 +01:00
|
|
|
while (*oidString && isspace((unsigned char) *oidString))
|
2000-01-10 16:41:34 +01:00
|
|
|
oidString++;
|
|
|
|
if (*oidString)
|
2003-07-27 06:53:12 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
|
|
|
errmsg("oidvector has too many elements")));
|
2005-03-29 02:17:27 +02:00
|
|
|
|
2007-02-28 00:48:10 +01:00
|
|
|
SET_VARSIZE(result, OidVectorSize(n));
|
2005-03-29 02:17:27 +02:00
|
|
|
result->ndim = 1;
|
2005-11-17 23:14:56 +01:00
|
|
|
result->dataoffset = 0; /* never any nulls */
|
2005-03-29 02:17:27 +02:00
|
|
|
result->elemtype = OIDOID;
|
|
|
|
result->dim1 = n;
|
|
|
|
result->lbound1 = 0;
|
2000-01-10 05:36:37 +01:00
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
PG_RETURN_POINTER(result);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-01-10 17:13:23 +01:00
|
|
|
* oidvectorout - converts internal form to "num num ..."
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
oidvectorout(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2005-03-29 02:17:27 +02:00
|
|
|
oidvector *oidArray = (oidvector *) PG_GETARG_POINTER(0);
|
2000-04-12 19:17:23 +02:00
|
|
|
int num,
|
2005-03-29 02:17:27 +02:00
|
|
|
nnums = oidArray->dim1;
|
1998-02-26 05:46:47 +01:00
|
|
|
char *rp;
|
1997-09-08 04:41:22 +02:00
|
|
|
char *result;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
/* assumes sign, 10 digits, ' ' */
|
2005-03-29 02:17:27 +02:00
|
|
|
rp = result = (char *) palloc(nnums * 12 + 1);
|
|
|
|
for (num = 0; num < nnums; num++)
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
2000-01-10 16:41:34 +01:00
|
|
|
if (num != 0)
|
|
|
|
*rp++ = ' ';
|
2005-03-29 02:17:27 +02:00
|
|
|
sprintf(rp, "%u", oidArray->values[num]);
|
1997-09-07 07:04:48 +02:00
|
|
|
while (*++rp != '\0')
|
|
|
|
;
|
|
|
|
}
|
2000-01-10 16:41:34 +01:00
|
|
|
*rp = '\0';
|
2000-06-05 09:29:25 +02:00
|
|
|
PG_RETURN_CSTRING(result);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2003-05-09 17:44:42 +02:00
|
|
|
/*
|
|
|
|
* oidvectorrecv - converts external binary format to oidvector
|
|
|
|
*/
|
|
|
|
Datum
|
|
|
|
oidvectorrecv(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
|
2006-03-02 22:13:04 +01:00
|
|
|
FunctionCallInfoData locfcinfo;
|
2005-03-29 02:17:27 +02:00
|
|
|
oidvector *result;
|
|
|
|
|
2006-03-02 22:13:04 +01:00
|
|
|
/*
|
2006-10-04 02:30:14 +02:00
|
|
|
* Normally one would call array_recv() using DirectFunctionCall3, but
|
|
|
|
* that does not work since array_recv wants to cache some data using
|
|
|
|
* fcinfo->flinfo->fn_extra. So we need to pass it our own flinfo
|
|
|
|
* parameter.
|
2006-03-02 22:13:04 +01:00
|
|
|
*/
|
2011-04-13 01:19:24 +02:00
|
|
|
InitFunctionCallInfoData(locfcinfo, fcinfo->flinfo, 3,
|
|
|
|
InvalidOid, NULL, NULL);
|
2006-03-02 22:13:04 +01:00
|
|
|
|
|
|
|
locfcinfo.arg[0] = PointerGetDatum(buf);
|
|
|
|
locfcinfo.arg[1] = ObjectIdGetDatum(OIDOID);
|
|
|
|
locfcinfo.arg[2] = Int32GetDatum(-1);
|
|
|
|
locfcinfo.argnull[0] = false;
|
|
|
|
locfcinfo.argnull[1] = false;
|
|
|
|
locfcinfo.argnull[2] = false;
|
|
|
|
|
|
|
|
result = (oidvector *) DatumGetPointer(array_recv(&locfcinfo));
|
|
|
|
|
|
|
|
Assert(!locfcinfo.isnull);
|
|
|
|
|
2009-09-04 13:20:23 +02:00
|
|
|
/* sanity checks: oidvector must be 1-D, 0-based, no nulls */
|
2005-11-17 23:14:56 +01:00
|
|
|
if (ARR_NDIM(result) != 1 ||
|
|
|
|
ARR_HASNULL(result) ||
|
2009-09-04 13:20:23 +02:00
|
|
|
ARR_ELEMTYPE(result) != OIDOID ||
|
|
|
|
ARR_LBOUND(result)[0] != 0)
|
2005-03-29 02:17:27 +02:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
|
|
|
errmsg("invalid oidvector data")));
|
2009-09-04 13:20:23 +02:00
|
|
|
|
|
|
|
/* check length for consistency with oidvectorin() */
|
|
|
|
if (ARR_DIMS(result)[0] > FUNC_MAX_ARGS)
|
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
|
|
|
errmsg("oidvector has too many elements")));
|
|
|
|
|
2003-05-09 17:44:42 +02:00
|
|
|
PG_RETURN_POINTER(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* oidvectorsend - converts oidvector to binary format
|
|
|
|
*/
|
|
|
|
Datum
|
|
|
|
oidvectorsend(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2005-03-29 02:17:27 +02:00
|
|
|
return array_send(fcinfo);
|
2003-05-09 17:44:42 +02:00
|
|
|
}
|
|
|
|
|
2010-06-13 19:43:13 +02:00
|
|
|
/*
|
|
|
|
* oidparse - get OID from IConst/FConst node
|
|
|
|
*/
|
|
|
|
Oid
|
|
|
|
oidparse(Node *node)
|
|
|
|
{
|
|
|
|
switch (nodeTag(node))
|
|
|
|
{
|
|
|
|
case T_Integer:
|
|
|
|
return intVal(node);
|
|
|
|
case T_Float:
|
2010-07-06 21:19:02 +02:00
|
|
|
|
2010-06-13 19:43:13 +02:00
|
|
|
/*
|
2010-07-06 21:19:02 +02:00
|
|
|
* Values too large for int4 will be represented as Float
|
|
|
|
* constants by the lexer. Accept these if they are valid OID
|
|
|
|
* strings.
|
2010-06-13 19:43:13 +02:00
|
|
|
*/
|
|
|
|
return oidin_subr(strVal(node), NULL);
|
|
|
|
default:
|
|
|
|
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
|
|
|
|
}
|
2010-07-06 21:19:02 +02:00
|
|
|
return InvalidOid; /* keep compiler quiet */
|
2010-06-13 19:43:13 +02:00
|
|
|
}
|
|
|
|
|
2003-05-09 17:44:42 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* PUBLIC ROUTINES *
|
1996-07-09 08:22:35 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
oideq(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-06-05 09:29:25 +02:00
|
|
|
Oid arg1 = PG_GETARG_OID(0);
|
|
|
|
Oid arg2 = PG_GETARG_OID(1);
|
|
|
|
|
|
|
|
PG_RETURN_BOOL(arg1 == arg2);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
oidne(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-06-05 09:29:25 +02:00
|
|
|
Oid arg1 = PG_GETARG_OID(0);
|
|
|
|
Oid arg2 = PG_GETARG_OID(1);
|
|
|
|
|
|
|
|
PG_RETURN_BOOL(arg1 != arg2);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2000-11-21 04:23:21 +01:00
|
|
|
Datum
|
|
|
|
oidlt(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid arg1 = PG_GETARG_OID(0);
|
|
|
|
Oid arg2 = PG_GETARG_OID(1);
|
|
|
|
|
|
|
|
PG_RETURN_BOOL(arg1 < arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
oidle(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid arg1 = PG_GETARG_OID(0);
|
|
|
|
Oid arg2 = PG_GETARG_OID(1);
|
|
|
|
|
|
|
|
PG_RETURN_BOOL(arg1 <= arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
oidge(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid arg1 = PG_GETARG_OID(0);
|
|
|
|
Oid arg2 = PG_GETARG_OID(1);
|
|
|
|
|
|
|
|
PG_RETURN_BOOL(arg1 >= arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
oidgt(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid arg1 = PG_GETARG_OID(0);
|
|
|
|
Oid arg2 = PG_GETARG_OID(1);
|
|
|
|
|
|
|
|
PG_RETURN_BOOL(arg1 > arg2);
|
|
|
|
}
|
|
|
|
|
2001-08-15 00:21:59 +02:00
|
|
|
Datum
|
|
|
|
oidlarger(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid arg1 = PG_GETARG_OID(0);
|
|
|
|
Oid arg2 = PG_GETARG_OID(1);
|
|
|
|
|
|
|
|
PG_RETURN_OID((arg1 > arg2) ? arg1 : arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Datum
|
|
|
|
oidsmaller(PG_FUNCTION_ARGS)
|
|
|
|
{
|
|
|
|
Oid arg1 = PG_GETARG_OID(0);
|
|
|
|
Oid arg2 = PG_GETARG_OID(1);
|
|
|
|
|
|
|
|
PG_RETURN_OID((arg1 < arg2) ? arg1 : arg2);
|
|
|
|
}
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
oidvectoreq(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2005-03-29 02:17:27 +02:00
|
|
|
int32 cmp = DatumGetInt32(btoidvectorcmp(fcinfo));
|
2000-06-05 09:29:25 +02:00
|
|
|
|
2005-03-29 02:17:27 +02:00
|
|
|
PG_RETURN_BOOL(cmp == 0);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
oidvectorne(PG_FUNCTION_ARGS)
|
1998-10-29 19:07:09 +01:00
|
|
|
{
|
2005-03-29 02:17:27 +02:00
|
|
|
int32 cmp = DatumGetInt32(btoidvectorcmp(fcinfo));
|
2000-06-05 09:29:25 +02:00
|
|
|
|
2005-03-29 02:17:27 +02:00
|
|
|
PG_RETURN_BOOL(cmp != 0);
|
1998-10-29 19:07:09 +01:00
|
|
|
}
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
oidvectorlt(PG_FUNCTION_ARGS)
|
1998-08-19 04:04:17 +02:00
|
|
|
{
|
2005-03-29 02:17:27 +02:00
|
|
|
int32 cmp = DatumGetInt32(btoidvectorcmp(fcinfo));
|
|
|
|
|
|
|
|
PG_RETURN_BOOL(cmp < 0);
|
1998-08-19 04:04:17 +02:00
|
|
|
}
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
oidvectorle(PG_FUNCTION_ARGS)
|
1998-08-19 04:04:17 +02:00
|
|
|
{
|
2005-03-29 02:17:27 +02:00
|
|
|
int32 cmp = DatumGetInt32(btoidvectorcmp(fcinfo));
|
|
|
|
|
|
|
|
PG_RETURN_BOOL(cmp <= 0);
|
1998-08-19 04:04:17 +02:00
|
|
|
}
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
oidvectorge(PG_FUNCTION_ARGS)
|
1998-08-19 04:04:17 +02:00
|
|
|
{
|
2005-03-29 02:17:27 +02:00
|
|
|
int32 cmp = DatumGetInt32(btoidvectorcmp(fcinfo));
|
|
|
|
|
|
|
|
PG_RETURN_BOOL(cmp >= 0);
|
1998-08-19 04:04:17 +02:00
|
|
|
}
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
oidvectorgt(PG_FUNCTION_ARGS)
|
1998-08-19 04:04:17 +02:00
|
|
|
{
|
2005-03-29 02:17:27 +02:00
|
|
|
int32 cmp = DatumGetInt32(btoidvectorcmp(fcinfo));
|
|
|
|
|
|
|
|
PG_RETURN_BOOL(cmp > 0);
|
1998-08-19 04:04:17 +02:00
|
|
|
}
|