1 /*-------------------------------------------------------------------------
4 * Functions for the built-in type Oid.
6 * Copyright (c) 1994, Regents of the University of California
10 * $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.6 1997/03/14 23:20:52 scrappy Exp $
12 *-------------------------------------------------------------------------
19 #include "utils/builtins.h" /* where function declarations go */
21 /*****************************************************************************
23 *****************************************************************************/
26 * oid8in - converts "num num ..." to internal form
29 * Fills any nonexistent digits with NULL oids.
31 Oid *oid8in(char *oidString)
33 register Oid (*result)[];
36 if (oidString == NULL)
38 result = (Oid (*)[]) palloc(sizeof(Oid [8]));
39 if ((nums = sscanf(oidString, "%d%d%d%d%d%d%d%d",
47 &(*result)[7])) != 8) {
49 (*result)[nums++] = 0;
52 return((Oid *) result);
56 * oid8out - converts internal form to "num num ..."
58 char *oid8out(Oid (*oidArray)[])
65 if (oidArray == NULL) {
66 result = (char *) palloc(2);
72 /* assumes sign, 10 digits, ' ' */
73 rp = result = (char *) palloc(8 * 12);
75 for (num = 8; num != 0; num--) {
87 extern int32 int4in();
94 extern char *int4out();
99 /*****************************************************************************
101 *****************************************************************************/
103 bool oideq(Oid arg1, Oid arg2)
105 return(arg1 == arg2);
108 bool oidne(Oid arg1, Oid arg2)
110 return(arg1 != arg2);
113 bool oid8eq(Oid arg1[], Oid arg2[])
115 return (bool)(memcmp(arg1, arg2, 8 * sizeof(Oid)) == 0);
118 bool oideqint4(Oid arg1, int32 arg2)
120 /* oid is unsigned, but int4 is signed */
121 return (arg2 >= 0 && arg1 == arg2);
124 bool int4eqoid(int32 arg1, Oid arg2)
126 /* oid is unsigned, but int4 is signed */
127 return (arg1 >= 0 && arg1 == arg2);