diff options
Diffstat (limited to 'src/backend/utils/adt')
| -rw-r--r-- | src/backend/utils/adt/Makefile | 4 | ||||
| -rw-r--r-- | src/backend/utils/adt/acl.c | 24 | ||||
| -rw-r--r-- | src/backend/utils/adt/arrayfuncs.c | 5 | ||||
| -rw-r--r-- | src/backend/utils/adt/datetime.c | 4 | ||||
| -rw-r--r-- | src/backend/utils/adt/not_in.c | 7 | ||||
| -rw-r--r-- | src/backend/utils/adt/oid.c | 42 | ||||
| -rw-r--r-- | src/backend/utils/adt/oidint2.c | 116 | ||||
| -rw-r--r-- | src/backend/utils/adt/oidint4.c | 116 | ||||
| -rw-r--r-- | src/backend/utils/adt/oidname.c | 125 | ||||
| -rw-r--r-- | src/backend/utils/adt/regproc.c | 253 | ||||
| -rw-r--r-- | src/backend/utils/adt/selfuncs.c | 29 | ||||
| -rw-r--r-- | src/backend/utils/adt/sets.c | 30 |
12 files changed, 220 insertions, 535 deletions
diff --git a/src/backend/utils/adt/Makefile b/src/backend/utils/adt/Makefile index f8bfa0ff0d..9d2f4df3e3 100644 --- a/src/backend/utils/adt/Makefile +++ b/src/backend/utils/adt/Makefile @@ -4,7 +4,7 @@ # Makefile for utils/adt # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.15 1998/07/26 04:30:52 scrappy Exp $ +# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.16 1998/08/19 02:02:52 momjian Exp $ # #------------------------------------------------------------------------- @@ -21,7 +21,7 @@ OBJS = acl.o arrayfuncs.o arrayutils.o bool.o cash.o char.o chunk.o \ date.o datetime.o datum.o dt.o filename.o float.o \ geo_ops.o geo_selfuncs.o int.o int8.o like.o \ misc.o nabstime.o name.o not_in.o numutils.o \ - oid.o oidname.o oidint2.o oidint4.o oracle_compat.o \ + oid.o oracle_compat.o \ regexp.o regproc.o selfuncs.o sets.o tid.o timestamp.o \ varchar.o varlena.o version.o diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index f212dfcdd7..aa0f101469 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.28 1998/06/15 19:29:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.29 1998/08/19 02:02:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -86,7 +86,7 @@ getid(char *s, char *n) static char * aclparse(char *s, AclItem *aip, unsigned *modechg) { - HeapTuple htp; + HeapTuple htup; char name[NAMEDATALEN]; Assert(s && aip && modechg); @@ -150,11 +150,12 @@ aclparse(char *s, AclItem *aip, unsigned *modechg) switch (aip->ai_idtype) { case ACL_IDTYPE_UID: - htp = SearchSysCacheTuple(USENAME, PointerGetDatum(name), - 0, 0, 0); - if (!HeapTupleIsValid(htp)) + htup = SearchSysCacheTuple(USENAME, + PointerGetDatum(name), + 0, 0, 0); + if (!HeapTupleIsValid(htup)) elog(ERROR, "aclparse: non-existent user \"%s\"", name); - aip->ai_id = ((Form_pg_shadow) GETSTRUCT(htp))->usesysid; + aip->ai_id = ((Form_pg_shadow) GETSTRUCT(htup))->usesysid; break; case ACL_IDTYPE_GID: aip->ai_id = get_grosysid(name); @@ -241,7 +242,7 @@ aclitemout(AclItem *aip) { char *p; char *out; - HeapTuple htp; + HeapTuple htup; unsigned i; static AclItem default_aclitem = {ACL_ID_WORLD, ACL_IDTYPE_WORLD, @@ -260,9 +261,10 @@ aclitemout(AclItem *aip) switch (aip->ai_idtype) { case ACL_IDTYPE_UID: - htp = SearchSysCacheTuple(USESYSID, ObjectIdGetDatum(aip->ai_id), - 0, 0, 0); - if (!HeapTupleIsValid(htp)) + htup = SearchSysCacheTuple(USESYSID, + ObjectIdGetDatum(aip->ai_id), + 0, 0, 0); + if (!HeapTupleIsValid(htup)) { char *tmp = int2out(aip->ai_id); @@ -283,7 +285,7 @@ aclitemout(AclItem *aip) } else strncat(p, (char *) &((Form_pg_shadow) - GETSTRUCT(htp))->usename, + GETSTRUCT(htup))->usename, sizeof(NameData)); break; case ACL_IDTYPE_GID: diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index b3c898cbcf..cf76efabf3 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.31 1998/07/12 21:29:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.32 1998/08/19 02:02:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1302,7 +1302,8 @@ system_cache_lookup(Oid element_type, HeapTuple typeTuple; TypeTupleForm typeStruct; - typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(element_type), + typeTuple = SearchSysCacheTuple(TYPOID, + ObjectIdGetDatum(element_type), 0, 0, 0); if (!HeapTupleIsValid(typeTuple)) diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index b0f38347f8..beb0e719dd 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.23 1998/06/15 19:29:33 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.24 1998/08/19 02:02:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -614,7 +614,7 @@ datetime_datetime(DateADT date, TimeADT *time) int32 /* RelativeTime */ -int42reltime(int32 timevalue) +int4reltime(int32 timevalue) { return (timevalue); } diff --git a/src/backend/utils/adt/not_in.c b/src/backend/utils/adt/not_in.c index 986f0e4d24..4658d29b49 100644 --- a/src/backend/utils/adt/not_in.c +++ b/src/backend/utils/adt/not_in.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.10 1998/07/27 19:38:18 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.11 1998/08/19 02:02:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -78,9 +78,8 @@ int4notin(int16 not_in_arg, char *relation_and_attr) retval = true; /* do a scan of the relation, and do the check */ - for (current_tuple = heap_getnext(scan_descriptor, 0, NULL); - current_tuple != NULL && retval; - current_tuple = heap_getnext(scan_descriptor, 0, NULL)) + while (HeapTupleIsValid(current_tuple = heap_getnext(scan_descriptor, 0)) && + retval) { value = heap_getattr(current_tuple, (AttrNumber) attrid, diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c index e6d66d126e..3e1097f0e0 100644 --- a/src/backend/utils/adt/oid.c +++ b/src/backend/utils/adt/oid.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.15 1998/02/26 04:37:16 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.16 1998/08/19 02:02:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -126,6 +126,46 @@ oid8eq(Oid arg1[], Oid arg2[]) } bool +oid8lt(Oid arg1[], Oid arg2[]) +{ + int i; + for (i=0; i < 8; i++) + if (!int4eq(arg1[i], arg2[i])) + return int4lt(arg1[i], arg2[i]); + return false; +} + +bool +oid8le(Oid arg1[], Oid arg2[]) +{ + int i; + for (i=0; i < 8; i++) + if (!int4eq(arg1[i], arg2[i])) + return int4le(arg1[i], arg2[i]); + return true; +} + +bool +oid8ge(Oid arg1[], Oid arg2[]) +{ + int i; + for (i=0; i < 8; i++) + if (!int4eq(arg1[i], arg2[i])) + return int4ge(arg1[i], arg2[i]); + return true; +} + +bool +oid8gt(Oid arg1[], Oid arg2[]) +{ + int i; + for (i=0; i < 8; i++) + if (!int4eq(arg1[i], arg2[i])) + return int4gt(arg1[i], arg2[i]); + return false; +} + +bool oideqint4(Oid arg1, int32 arg2) { /* oid is unsigned, but int4 is signed */ diff --git a/src/backend/utils/adt/oidint2.c b/src/backend/utils/adt/oidint2.c deleted file mode 100644 index 1bcb37ef74..0000000000 --- a/src/backend/utils/adt/oidint2.c +++ /dev/null @@ -1,116 +0,0 @@ -/*------------------------------------------------------------------------- - * - * oidint2.c-- - * Functions for the built-in type "oidint2". - * - * Copyright (c) 1994, Regents of the University of California - * - * - * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidint2.c,v 1.6 1998/06/15 19:29:36 momjian Exp $ - * - *------------------------------------------------------------------------- - */ -#include <stdio.h> -#include "postgres.h" -#include "utils/palloc.h" -#include "utils/builtins.h" /* for pg_atoi() */ -#include "utils/oidcompos.h" /* where function declarations go */ - - -OidInt2 -oidint2in(char *o) -{ - OidInt2 oi; - char *p; - - oi = (OidInt2) palloc(sizeof(OidInt2Data)); - - for (p = o; *p != '\0' && *p != '/'; p++) - continue; - - oi->oi_oid = (Oid) pg_atoi(o, sizeof(Oid), '/'); - if (*p == '\0') - oi->oi_int2 = 0; - else - oi->oi_int2 = (int16) pg_atoi(++p, sizeof(int2), '\0'); - - return (oi); -} - -char * -oidint2out(OidInt2 o) -{ - char *r; - - /* - * -2147483647/-32767 0 1 1234567890123456789 - */ - r = (char *) palloc(19); - sprintf(r, "%d/%d", o->oi_oid, o->oi_int2); - - return (r); -} - -bool -oidint2lt(OidInt2 o1, OidInt2 o2) -{ - return - ((bool) (o1->oi_oid < o2->oi_oid || - (o1->oi_oid == o2->oi_oid && o1->oi_int2 < o2->oi_int2))); -} - -bool -oidint2le(OidInt2 o1, OidInt2 o2) -{ - return ((bool) (o1->oi_oid < o2->oi_oid || - (o1->oi_oid == o2->oi_oid && o1->oi_int2 <= o2->oi_int2))); -} - -bool -oidint2eq(OidInt2 o1, OidInt2 o2) -{ - return ((bool) (o1->oi_oid == o2->oi_oid && o1->oi_int2 == o2->oi_int2)); -} - -bool -oidint2ge(OidInt2 o1, OidInt2 o2) -{ - return ((bool) (o1->oi_oid > o2->oi_oid || - (o1->oi_oid == o2->oi_oid && o1->oi_int2 >= o2->oi_int2))); -} - -bool -oidint2gt(OidInt2 o1, OidInt2 o2) -{ - return ((bool) (o1->oi_oid > o2->oi_oid || - (o1->oi_oid == o2->oi_oid && o1->oi_int2 > o2->oi_int2))); -} - -bool -oidint2ne(OidInt2 o1, OidInt2 o2) -{ - return ((bool) (o1->oi_oid != o2->oi_oid || o1->oi_int2 != o2->oi_int2)); -} - -int -oidint2cmp(OidInt2 o1, OidInt2 o2) -{ - if (oidint2lt(o1, o2)) - return (-1); - else if (oidint2eq(o1, o2)) - return (0); - else - return (1); -} - -OidInt2 -mkoidint2(Oid v_oid, uint16 v_int2) -{ - OidInt2 o; - - o = (OidInt2) palloc(sizeof(OidInt2Data)); - o->oi_oid = v_oid; - o->oi_int2 = v_int2; - return (o); -} diff --git a/src/backend/utils/adt/oidint4.c b/src/backend/utils/adt/oidint4.c deleted file mode 100644 index 90f482708b..0000000000 --- a/src/backend/utils/adt/oidint4.c +++ /dev/null @@ -1,116 +0,0 @@ -/*------------------------------------------------------------------------- - * - * oidint4.c-- - * Functions for the built-in type "oidint4". - * - * Copyright (c) 1994, Regents of the University of California - * - * - * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidint4.c,v 1.6 1998/06/15 19:29:36 momjian Exp $ - * - *------------------------------------------------------------------------- - */ -#include <stdio.h> /* for sprintf() */ -#include "postgres.h" -#include "utils/palloc.h" -#include "utils/builtins.h" -#include "utils/oidcompos.h" /* where function declarations go */ - -OidInt4 -oidint4in(char *o) -{ - OidInt4 oi; - char *p; - - oi = (OidInt4) palloc(sizeof(OidInt4Data)); - - for (p = o; *p != '\0' && *p != '/'; p++) - continue; - - oi->oi_oid = (Oid) pg_atoi(o, sizeof(Oid), '/'); - if (*p == '\0') - oi->oi_int4 = 0; - else - oi->oi_int4 = pg_atoi(++p, sizeof(int4), '\0'); - - return (oi); -} - -char * -oidint4out(OidInt4 o) -{ - char *r; - - /* - * -2147483647/-2147483647 0 1 2 - * 123456789012345678901234 - */ - r = (char *) palloc(24); - sprintf(r, "%d/%d", o->oi_oid, o->oi_int4); - - return (r); -} - -bool -oidint4lt(OidInt4 o1, OidInt4 o2) -{ - return - ((bool) (o1->oi_oid < o2->oi_oid || - (o1->oi_oid == o2->oi_oid && o1->oi_int4 < o2->oi_int4))); -} - -bool -oidint4le(OidInt4 o1, OidInt4 o2) -{ - return ((bool) (o1->oi_oid < o2->oi_oid || - (o1->oi_oid == o2->oi_oid && o1->oi_int4 <= o2->oi_int4))); -} - -bool -oidint4eq(OidInt4 o1, OidInt4 o2) -{ - return ((bool) (o1->oi_oid == o2->oi_oid && o1->oi_int4 == o2->oi_int4)); -} - -bool -oidint4ge(OidInt4 o1, OidInt4 o2) -{ - return ((bool) (o1->oi_oid > o2->oi_oid || - (o1->oi_oid == o2->oi_oid && o1->oi_int4 >= o2->oi_int4))); -} - -bool -oidint4gt(OidInt4 o1, OidInt4 o2) -{ - return ((bool) (o1->oi_oid > o2->oi_oid || - (o1->oi_oid == o2->oi_oid && o1->oi_int4 > o2->oi_int4))); -} - -bool -oidint4ne(OidInt4 o1, OidInt4 o2) -{ - return ((bool) (o1->oi_oid != o2->oi_oid || o1->oi_int4 != o2->oi_int4)); -} - -int -oidint4cmp(OidInt4 o1, OidInt4 o2) -{ - if (oidint4lt(o1, o2)) - return (-1); - else if (oidint4eq(o1, o2)) - return (0); - else - return (1); -} - -OidInt4 -mkoidint4(Oid v_oid, uint32 v_int4) -{ - OidInt4 o; - - o = (OidInt4) palloc(sizeof(OidInt4Data)); - o->oi_oid = v_oid; - o->oi_int4 = v_int4; - return (o); -} diff --git a/src/backend/utils/adt/oidname.c b/src/backend/utils/adt/oidname.c deleted file mode 100644 index ff61681984..0000000000 --- a/src/backend/utils/adt/oidname.c +++ /dev/null @@ -1,125 +0,0 @@ -/*------------------------------------------------------------------------- - * - * oidname.c-- - * adt for multiple key indices involving oid and name. Used for cache - * index scans (could also be used in the general case with name). - * - * Copyright (c) 1994, Regents of the University of California - * - * - * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidname.c,v 1.12 1998/02/26 04:37:18 momjian Exp $ - * - *------------------------------------------------------------------------- - */ -#include <stdio.h> -#include <string.h> - -#include "postgres.h" -#include "utils/oidcompos.h" /* where function declarations go */ -#include "utils/builtins.h" /* for pg_atoi() */ -#include "utils/palloc.h" - -OidName -oidnamein(char *inStr) -{ - OidName oc; - char *inptr; - - oc = (OidName) palloc(sizeof(OidNameData)); - - MemSet(oc, 0, sizeof(OidNameData)); - for (inptr = inStr; *inptr && *inptr != ','; inptr++) - ; - - if (*inptr) - { - oc->id = (Oid) pg_atoi(inStr, sizeof(Oid), ','); - /* copy one less to ensure null-padding */ - ++inptr; - StrNCpy(oc->name.data, inptr, NAMEDATALEN); - } - else - elog(ERROR, "Bad input data for type oidname"); - - return oc; -} - -char * -oidnameout(OidName oidname) -{ - char buf[30 + NAMEDATALEN]; /* oidname length + oid length + - * some safety */ - char *res; - - sprintf(buf, "%d,%s", oidname->id, oidname->name.data); - res = pstrdup(buf); - return (res); -} - -bool -oidnamelt(OidName o1, OidName o2) -{ - return (bool) - (o1->id < o2->id || - (o1->id == o2->id && namecmp(&o1->name, &o2->name) < 0)); -} - -bool -oidnamele(OidName o1, OidName o2) -{ - return (bool) - (o1->id < o2->id || - (o1->id == o2->id && namecmp(&o1->name, &o2->name) <= 0)); -} - -bool -oidnameeq(OidName o1, OidName o2) -{ - return (bool) - (o1->id == o2->id && - (namecmp(&o1->name, &o2->name) == 0)); -} - -bool -oidnamene(OidName o1, OidName o2) -{ - return (bool) - (o1->id != o2->id || - (namecmp(&o1->name, &o2->name) != 0)); -} - -bool -oidnamege(OidName o1, OidName o2) -{ - return (bool) (o1->id > o2->id || (o1->id == o2->id && - namecmp(&o1->name, &o2->name) >= 0)); -} - -bool -oidnamegt(OidName o1, OidName o2) -{ - return (bool) (o1->id > o2->id || (o1->id == o2->id && - namecmp(&o1->name, &o2->name) > 0)); -} - -int -oidnamecmp(OidName o1, OidName o2) -{ - if (o1->id == o2->id) - return (namecmp(&o1->name, &o2->name)); - - return (o1->id < o2->id) ? -1 : 1; -} - -OidName -mkoidname(Oid id, char *name) -{ - OidName oidname; - - oidname = (OidName) palloc(sizeof(Oid) + NAMEDATALEN); - - oidname->id = id; - namestrcpy(&oidname->name, name); - return oidname; -} diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c index b3beb0b7cc..227158748b 100644 --- a/src/backend/utils/adt/regproc.c +++ b/src/backend/utils/adt/regproc.c @@ -1,4 +1,4 @@ -/*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * * regproc.c-- * Functions for the built-in type "RegProcedure". @@ -7,143 +7,190 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.21 1998/07/27 19:38:19 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.22 1998/08/19 02:03:04 momjian Exp $ * *------------------------------------------------------------------------- */ #include <string.h> #include "postgres.h" +#include "miscadmin.h" #include "access/heapam.h" #include "access/relscan.h" #include "fmgr.h" #include "utils/palloc.h" +#include "utils/syscache.h" #include "catalog/catname.h" +#include "catalog/pg_proc.h" +#include "catalog/pg_type.h" #include "utils/builtins.h" /* where function declarations go */ /***************************************************************************** * USER I/O ROUTINES * *****************************************************************************/ - + /* * regprocin - converts "proname" to proid * * proid of NULL signifies unknown */ int32 -regprocin(char *proname) +regprocin(char *pro_oid_name) { - Relation proc; - HeapScanDesc procscan; HeapTuple proctup; - ScanKeyData key; RegProcedure result = (Oid) 0; - bool isnull; - if (proname == NULL) + if (pro_oid_name == NULL) return (0); - proc = heap_openr(ProcedureRelationName); - if (!RelationIsValid(proc)) + + + if (!IsBootstrapProcessingMode()) { - elog(ERROR, "regprocin: could not open %s", - ProcedureRelationName); - return (0); + /* + * we need to use the oid because there can be multiple entries + * with the same name, i.e. 1323(int4eq) + */ + proctup = SearchSysCacheTuple(PROOID, + ObjectIdGetDatum(atoi(pro_oid_name)), + 0, 0, 0); + if (HeapTupleIsValid(proctup)) + result = (RegProcedure) proctup->t_oid; + else result = (RegProcedure) 0; } - ScanKeyEntryInitialize(&key, - (bits16) 0, - (AttrNumber) 1, - (RegProcedure) F_NAMEEQ, - (Datum) proname); - - procscan = heap_beginscan(proc, 0, SnapshotNow, 1, &key); - if (!HeapScanIsValid(procscan)) + else { + Relation proc; + HeapScanDesc procscan; + ScanKeyData key; + bool isnull; + + proc = heap_openr(ProcedureRelationName); + if (!RelationIsValid(proc)) + { + elog(ERROR, "regprocin: could not open %s", + ProcedureRelationName); + return (0); + } + ScanKeyEntryInitialize(&key, + (bits16) 0, + (AttrNumber) 1, + (RegProcedure) F_NAMEEQ, + (Datum) pro_oid_name); + + procscan = heap_beginscan(proc, 0, SnapshotNow, 1, &key); + if (!HeapScanIsValid(procscan)) + { + heap_close(proc); + elog(ERROR, "regprocin: could not being scan of %s", + ProcedureRelationName); + return (0); + } + proctup = heap_getnext(procscan, 0); + if (HeapTupleIsValid(proctup)) + { + result = (RegProcedure) heap_getattr(proctup, + ObjectIdAttributeNumber, + RelationGetTupleDescriptor(proc), + &isnull); + if (isnull) + elog(FATAL, "regprocin: null procedure %s", pro_oid_name); + } + else + result = (RegProcedure) 0; + + heap_endscan(procscan); heap_close(proc); - elog(ERROR, "regprocin: could not being scan of %s", - ProcedureRelationName); - return (0); - } - proctup = heap_getnext(procscan, 0, (Buffer *) NULL); - switch (HeapTupleIsValid(proctup)) - { - case 1: - result = (RegProcedure) heap_getattr(proctup, - ObjectIdAttributeNumber, - RelationGetTupleDescriptor(proc), - &isnull); - if (isnull) - elog(FATAL, "regprocin: null procedure %s", proname); - break; - case 0: - result = (RegProcedure) 0; + } + #ifdef EBUG - elog(DEBUG, "regprocin: no such procedure %s", proname); + elog(DEBUG, "regprocin: no such procedure %s", pro_oid_name); #endif /* defined(EBUG) */ - } - heap_endscan(procscan); - heap_close(proc); - return ((int32) result); + return (int32) result; } /* - * regprocout - converts proid to "proname" + * regprocout - converts proid to "pro_oid_name" */ char * regprocout(RegProcedure proid) { - Relation proc; - HeapScanDesc procscan; HeapTuple proctup; char *result; - ScanKeyData key; result = (char *) palloc(NAMEDATALEN); - proc = heap_openr(ProcedureRelationName); - if (!RelationIsValid(proc)) - { - elog(ERROR, "regprocout: could not open %s", - ProcedureRelationName); - return (0); - } - ScanKeyEntryInitialize(&key, - (bits16) 0, - (AttrNumber) ObjectIdAttributeNumber, - (RegProcedure) F_INT4EQ, - (Datum) proid); - - procscan = heap_beginscan(proc, 0, SnapshotNow, 1, &key); - if (!HeapScanIsValid(procscan)) + + if (!IsBootstrapProcessingMode()) { - heap_close(proc); - elog(ERROR, "regprocout: could not being scan of %s", - ProcedureRelationName); - return (0); + proctup = SearchSysCacheTuple(PROOID, + ObjectIdGetDatum(proid), + 0, 0, 0); + + if (HeapTupleIsValid(proctup)) + { + char *s; + + s = ((Form_pg_proc) GETSTRUCT(proctup))->proname.data; + snprintf(result, NAMEDATALEN, "%d(%s)", proid, s); + } + else + { + result[0] = '-'; + result[1] = '\0'; + } } - proctup = heap_getnext(procscan, 0, (Buffer *) NULL); - switch (HeapTupleIsValid(proctup)) + else { + Relation proc; + HeapScanDesc procscan; + ScanKeyData key; + + proc = heap_openr(ProcedureRelationName); + if (!RelationIsValid(proc)) + { + elog(ERROR, "regprocout: could not open %s", + ProcedureRelationName); + return (0); + } + ScanKeyEntryInitialize(&key, + (bits16) 0, + (AttrNumber) ObjectIdAttributeNumber, + (RegProcedure) F_INT4EQ, + (Datum) proid); + + procscan = heap_beginscan(proc, 0, SnapshotNow, 1, &key); + if (!HeapScanIsValid(procscan)) + { + heap_close(proc); + elog(ERROR, "regprocout: could not being scan of %s", + ProcedureRelationName); + return (0); + } + proctup = heap_getnext(procscan, 0); + if (HeapTupleIsValid(proctup)) + { char *s; bool isnull; - case 1: s = (char *) heap_getattr(proctup, 1, RelationGetTupleDescriptor(proc), &isnull); if (!isnull) - { StrNCpy(result, s, NAMEDATALEN); - break; - } - elog(FATAL, "regprocout: null procedure %d", proid); - /* FALLTHROUGH */ - case 0: - result[0] = '-'; - result[1] = '\0'; + else + elog(FATAL, "regprocout: null procedure %d", proid); + } + else + { + result[0] = '-'; + result[1] = '\0'; + } + heap_endscan(procscan); + heap_close(proc); + return (result); + } + #ifdef EBUG elog(DEBUG, "regprocout: no such procedure %d", proid); #endif /* defined(EBUG) */ - } - heap_endscan(procscan); - heap_close(proc); return (result); } @@ -153,11 +200,8 @@ regprocout(RegProcedure proid) text * oid8types(Oid (*oidArray)[]) { - Relation type; - HeapScanDesc typescan; HeapTuple typetup; text *result; - ScanKeyData key; int num; Oid *sp; @@ -170,55 +214,26 @@ oid8types(Oid (*oidArray)[]) result = (text *) palloc(NAMEDATALEN * 8 + 8 + VARHDRSZ); *VARDATA(result) = '\0'; - type = heap_openr(TypeRelationName); - if (!RelationIsValid(type)) - { - elog(ERROR, "int8typeout: could not open %s", - TypeRelationName); - return (0); - } sp = *oidArray; for (num = 8; num != 0; num--, sp++) { if (*sp != InvalidOid) { - ScanKeyEntryInitialize(&key, - (bits16) 0, - (AttrNumber) ObjectIdAttributeNumber, - (RegProcedure) F_INT4EQ, - (Datum) *sp); - - typescan = heap_beginscan(type, 0, SnapshotNow, 1, &key); - if (!HeapScanIsValid(typescan)) - { - heap_close(type); - elog(ERROR, "int8typeout: could not being scan of %s", - TypeRelationName); - return (0); - } - typetup = heap_getnext(typescan, 0, (Buffer *) NULL); + typetup = SearchSysCacheTuple(TYPOID, + ObjectIdGetDatum(*sp), + 0, 0, 0); if (HeapTupleIsValid(typetup)) { char *s; - bool isnull; - s = (char *) heap_getattr(typetup, 1, - RelationGetTupleDescriptor(type), &isnull); - if (!isnull) - { - StrNCpy(VARDATA(result) + strlen(VARDATA(result)), s, + s = ((TypeTupleForm) GETSTRUCT(typetup))->typname.data; + StrNCpy(VARDATA(result) + strlen(VARDATA(result)), s, NAMEDATALEN); - strcat(VARDATA(result), " "); - } - else - elog(FATAL, "int8typeout: null procedure %d", *sp); - /* FALLTHROUGH */ + strcat(VARDATA(result), " "); } - heap_endscan(typescan); } } - heap_close(type); VARSIZE(result) = strlen(VARDATA(result)) + VARHDRSZ; return (result); } diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index d444ced107..a5a0b86e4a 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.20 1998/07/27 19:38:20 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.21 1998/08/19 02:03:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -295,7 +295,8 @@ getattdisbursion(Oid relid, AttrNumber attnum) if (nvals > 0) return (nvals); - atp = SearchSysCacheTuple(RELOID, ObjectIdGetDatum(relid), + atp = SearchSysCacheTuple(RELOID, + ObjectIdGetDatum(relid), 0, 0, 0); /* @@ -334,8 +335,8 @@ gethilokey(Oid relid, char **high, char **low) { - Relation rdesc; - HeapScanDesc sdesc; + Relation rel; + HeapScanDesc scan; static ScanKeyData key[3] = { {0, Anum_pg_statistic_starelid, F_OIDEQ, {0, 0, F_OIDEQ}}, {0, Anum_pg_statistic_staattnum, F_INT2EQ, {0, 0, F_INT2EQ}}, @@ -344,13 +345,13 @@ gethilokey(Oid relid, bool isnull; HeapTuple tuple; - rdesc = heap_openr(StatisticRelationName); + rel = heap_openr(StatisticRelationName); key[0].sk_argument = ObjectIdGetDatum(relid); key[1].sk_argument = Int16GetDatum((int16) attnum); key[2].sk_argument = ObjectIdGetDatum(opid); - sdesc = heap_beginscan(rdesc, 0, SnapshotNow, 3, key); - tuple = heap_getnext(sdesc, 0, (Buffer *) NULL); + scan = heap_beginscan(rel, 0, SnapshotNow, 3, key); + tuple = heap_getnext(scan, 0); if (!HeapTupleIsValid(tuple)) { *high = "n"; @@ -365,19 +366,19 @@ gethilokey(Oid relid, *high = textout((struct varlena *) heap_getattr(tuple, Anum_pg_statistic_stahikey, - RelationGetTupleDescriptor(rdesc), + RelationGetTupleDescriptor(rel), &isnull)); if (isnull) elog(DEBUG, "gethilokey: high key is null"); *low = textout((struct varlena *) heap_getattr(tuple, Anum_pg_statistic_stalokey, - RelationGetTupleDescriptor(rdesc), + RelationGetTupleDescriptor(rel), &isnull)); if (isnull) elog(DEBUG, "gethilokey: low key is null"); - heap_endscan(sdesc); - heap_close(rdesc); + heap_endscan(scan); + heap_close(rel); } float64 @@ -497,7 +498,8 @@ hashsel(Oid operatorObjectId, * have selectivity functions */ - atp = SearchSysCacheTuple(RELOID, ObjectIdGetDatum(indexrelid), + atp = SearchSysCacheTuple(RELOID, + ObjectIdGetDatum(indexrelid), 0, 0, 0); if (!HeapTupleIsValid(atp)) { @@ -549,7 +551,8 @@ hashnpage(Oid operatorObjectId, int npage; int ntuples; - atp = SearchSysCacheTuple(RELOID, ObjectIdGetDatum(indexrelid), + atp = SearchSysCacheTuple(RELOID, + ObjectIdGetDatum(indexrelid), 0, 0, 0); if (!HeapTupleIsValid(atp)) { diff --git a/src/backend/utils/adt/sets.c b/src/backend/utils/adt/sets.c index 2822756786..1d150805ce 100644 --- a/src/backend/utils/adt/sets.c +++ b/src/backend/utils/adt/sets.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.15 1998/07/27 19:38:21 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.16 1998/08/19 02:03:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,13 +56,6 @@ SetDefine(char *querystr, char *typename) Datum replValue[Natts_pg_proc]; char replNull[Natts_pg_proc]; char repl[Natts_pg_proc]; - HeapScanDesc pg_proc_scan; - Buffer buffer; - ItemPointerData ipdata; - - static ScanKeyData oidKey[1] = { - {0, ObjectIdAttributeNumber, F_OIDEQ}}; - setoid = ProcedureCreate(procname, /* changed below, after oid known */ true, /* returnsSet */ @@ -117,37 +110,26 @@ SetDefine(char *querystr, char *typename) /* change the pg_proc tuple */ procrel = heap_openr(ProcedureRelationName); RelationSetLockForWrite(procrel); - fmgr_info(F_OIDEQ, - &oidKey[0].sk_func); - oidKey[0].sk_nargs = oidKey[0].sk_func.fn_nargs; - oidKey[0].sk_argument = ObjectIdGetDatum(setoid); - pg_proc_scan = heap_beginscan(procrel, - 0, - SnapshotSelf, - 1, - oidKey); - tup = heap_getnext(pg_proc_scan, 0, &buffer); + + tup = SearchSysCacheTuple(PROOID, + ObjectIdGetDatum(setoid), + 0, 0, 0); if (HeapTupleIsValid(tup)) { newtup = heap_modifytuple(tup, - buffer, procrel, replValue, replNull, repl); - /* XXX may not be necessary */ - ItemPointerCopy(&tup->t_ctid, &ipdata); - setheapoverride(true); - heap_replace(procrel, &ipdata, newtup); + heap_replace(procrel, &tup->t_ctid, newtup); setheapoverride(false); setoid = newtup->t_oid; } else elog(ERROR, "setin: could not find new set oid tuple"); - heap_endscan(pg_proc_scan); if (RelationGetRelationTupleForm(procrel)->relhasindex) { |
