1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-15 03:41:20 +03:00

heap_fetch requires buffer pointer, must be released; heap_getnext

no longer returns buffer pointer, can be gotten from scan;
	descriptor; bootstrap can create multi-key indexes;
pg_procname index now is multi-key index; oidint2, oidint4, oidname
are gone (must be removed from regression tests); use System Cache
rather than sequential scan in many places; heap_modifytuple no
longer takes buffer parameter; remove unused buffer parameter in
a few other functions; oid8 is not index-able; remove some use of
single-character variable names; cleanup Buffer variables usage
and scan descriptor looping; cleaned up allocation and freeing of
tuples; 18k lines of diff;
This commit is contained in:
Bruce Momjian
1998-08-19 02:04:17 +00:00
parent 31de2c9461
commit 7971539020
123 changed files with 2139 additions and 3134 deletions

View File

@@ -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

View File

@@ -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:

View File

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

View File

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

View File

@@ -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,

View File

@@ -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 $
*
*-------------------------------------------------------------------------
*/
@@ -125,6 +125,46 @@ oid8eq(Oid arg1[], Oid arg2[])
return (bool) (memcmp(arg1, arg2, 8 * sizeof(Oid)) == 0);
}
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)
{

View File

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

View File

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

View File

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

View File

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

View File

@@ -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))
{

View File

@@ -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)
{

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.31 1998/07/27 19:38:22 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.32 1998/08/19 02:03:08 momjian Exp $
*
* Notes:
* XXX This needs to use exception.h to handle recovery when
@@ -36,11 +36,9 @@
static void CatCacheRemoveCTup(CatCache *cache, Dlelem *e);
static Index CatalogCacheComputeHashIndex(struct catcache * cacheInP);
static Index
CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
static Index CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
Relation relation, HeapTuple tuple);
static void
CatalogCacheInitializeCache(struct catcache * cache,
static void CatalogCacheInitializeCache(struct catcache * cache,
Relation relation);
static long comphash(long l, char *v);
@@ -182,7 +180,7 @@ CatalogCacheInitializeCache(struct catcache * cache,
* ----------------
*/
Assert(RelationIsValid(relation));
cache->relationId = RelationGetRelationId(relation);
cache->relationId = RelationGetRelid(relation);
tupdesc = cache->cc_tupdesc = RelationGetTupleDescriptor(relation);
CACHE3_elog(DEBUG, "CatalogCacheInitializeCache: relid %d, %d keys",
@@ -250,7 +248,7 @@ CatalogCacheInitializeCache(struct catcache * cache,
*/
relation = index_openr(cache->cc_indname);
Assert(relation);
cache->indexId = RelationGetRelationId(relation);
cache->indexId = RelationGetRelid(relation);
index_close(relation);
}
else
@@ -827,7 +825,6 @@ SearchSysCache(struct catcache * cache,
CatCTup *nct2;
Dlelem *elt;
HeapTuple ntp = 0;
Buffer buffer;
Relation relation;
MemoryContext oldcxt;
@@ -997,8 +994,7 @@ SearchSysCache(struct catcache * cache,
sd = heap_beginscan(relation, 0, SnapshotNow,
cache->cc_nkeys, cache->cc_skey);
/* should this buffer be ReleaseBuffer'd? --djm 8/20/96 */
ntp = heap_getnext(sd, 0, &buffer);
ntp = heap_getnext(sd, 0);
MemoryContextSwitchTo((MemoryContext) CacheCxt);
@@ -1129,7 +1125,7 @@ RelationInvalidateCatalogCacheTuple(Relation relation,
* in the proper hash bucket
* ----------------
*/
relationId = RelationGetRelationId(relation);
relationId = RelationGetRelid(relation);
for (ccp = Caches; ccp; ccp = ccp->cc_next)
{

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.14 1998/07/26 04:30:55 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.15 1998/08/19 02:03:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -72,7 +72,8 @@ GetDynamicFuncArgType(Var *arg, ExprContext *econtext)
relname = (char *) getrelname(rtid, econtext->ecxt_range_table);
tup = SearchSysCacheTuple(TYPNAME, PointerGetDatum(relname),
tup = SearchSysCacheTuple(TYPNAME,
PointerGetDatum(relname),
0, 0, 0);
if (!tup)
elog(ERROR, "Lookup failed on type tuple for class %s",
@@ -129,7 +130,7 @@ init_fcache(Oid foid,
* ----------------
*/
typeTuple = SearchSysCacheTuple(TYPOID,
ObjectIdGetDatum(procedureStruct->prorettype),
ObjectIdGetDatum(procedureStruct->prorettype),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.11 1998/06/15 19:29:39 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.12 1998/08/19 02:03:11 momjian Exp $
*
* Note - this code is real crufty...
*
@@ -267,7 +267,7 @@ getmyrelids()
MyAMRelationId = tuple->t_oid;
tuple = SearchSysCacheTuple(RELNAME,
PointerGetDatum(AccessMethodOperatorRelationName),
PointerGetDatum(AccessMethodOperatorRelationName),
0, 0, 0);
Assert(HeapTupleIsValid(tuple));
MyAMOPRelationId = tuple->t_oid;
@@ -476,7 +476,7 @@ RelationInvalidateRelationCache(Relation relation,
* ----------------
*/
ValidateHacks(); /* XXX */
relationId = RelationGetRelationId(relation);
relationId = RelationGetRelid(relation);
/* ----------------
*

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.19 1998/08/16 05:38:41 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.20 1998/08/19 02:03:12 momjian Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
@@ -47,8 +47,7 @@ op_class(Oid oprno, int32 opclass, Oid amopid)
{
FormData_pg_amop amoptup;
if (SearchSysCacheStruct(AMOPOPID,
(char *) &amoptup,
if (SearchSysCacheStruct(AMOPOPID, (char *) &amoptup,
ObjectIdGetDatum(opclass),
ObjectIdGetDatum(oprno),
ObjectIdGetDatum(amopid),
@@ -72,8 +71,7 @@ get_attname(Oid relid, AttrNumber attnum)
{
FormData_pg_attribute att_tup;
if (SearchSysCacheStruct(ATTNUM,
(char *) &att_tup,
if (SearchSysCacheStruct(ATTNUM, (char *) &att_tup,
ObjectIdGetDatum(relid),
UInt16GetDatum(attnum),
0, 0))
@@ -115,8 +113,7 @@ get_atttype(Oid relid, AttrNumber attnum)
{
AttributeTupleForm att_tup = (AttributeTupleForm) palloc(sizeof(*att_tup));
if (SearchSysCacheStruct(ATTNUM,
(char *) att_tup,
if (SearchSysCacheStruct(ATTNUM, (char *) att_tup,
ObjectIdGetDatum(relid),
UInt16GetDatum(attnum),
0, 0))
@@ -132,24 +129,24 @@ get_atttype(Oid relid, AttrNumber attnum)
bool
get_attisset(Oid relid, char *attname)
{
HeapTuple htup;
HeapTuple tuple;
AttrNumber attno;
AttributeTupleForm att_tup;
attno = get_attnum(relid, attname);
htup = SearchSysCacheTuple(ATTNAME,
tuple = SearchSysCacheTuple(ATTNAME,
ObjectIdGetDatum(relid),
PointerGetDatum(attname),
0, 0);
if (!HeapTupleIsValid(htup))
if (!HeapTupleIsValid(tuple))
elog(ERROR, "get_attisset: no attribute %s in relation %d",
attname, relid);
if (heap_attisnull(htup, attno))
if (heap_attisnull(tuple, attno))
return false;
else
{
att_tup = (AttributeTupleForm) GETSTRUCT(htup);
att_tup = (AttributeTupleForm) GETSTRUCT(tuple);
return att_tup->attisset;
}
}
@@ -166,10 +163,9 @@ get_atttypmod(Oid relid, AttrNumber attnum)
{
FormData_pg_attribute att_tup;
if (SearchSysCacheStruct(ATTNUM,
(char *) &att_tup,
if (SearchSysCacheStruct(ATTNUM, (char *) &att_tup,
ObjectIdGetDatum(relid),
Int32GetDatum(attnum),
Int16GetDatum(attnum),
0, 0))
return att_tup.atttypmod;
else
@@ -400,8 +396,7 @@ get_rel_name(Oid relid)
{
FormData_pg_class reltup;
if ((SearchSysCacheStruct(RELOID,
(char *) &reltup,
if ((SearchSysCacheStruct(RELOID, (char *) &reltup,
ObjectIdGetDatum(relid),
0, 0, 0)))
return pstrdup(reltup.relname.data);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.46 1998/08/11 18:28:22 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.47 1998/08/19 02:03:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -337,7 +337,6 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo)
Relation pg_class_desc;
HeapScanDesc pg_class_scan;
ScanKeyData key;
Buffer buf;
/* ----------------
* form a scan key
@@ -371,9 +370,8 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo)
pg_class_desc = heap_openr(RelationRelationName);
if (!IsInitProcessingMode())
RelationSetLockForRead(pg_class_desc);
pg_class_scan =
heap_beginscan(pg_class_desc, 0, SnapshotNow, 1, &key);
pg_class_tuple = heap_getnext(pg_class_scan, 0, &buf);
pg_class_scan = heap_beginscan(pg_class_desc, 0, SnapshotNow, 1, &key);
pg_class_tuple = heap_getnext(pg_class_scan, 0);
/* ----------------
* get set to return tuple
@@ -394,7 +392,6 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo)
memmove((char *) return_tuple,
(char *) pg_class_tuple,
(int) pg_class_tuple->t_len);
ReleaseBuffer(buf);
}
/* all done */
@@ -534,15 +531,14 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
ScanKeyEntryInitialize(&key, 0,
Anum_pg_attribute_attrelid,
F_OIDEQ,
ObjectIdGetDatum(relation->rd_id));
ObjectIdGetDatum(RelationGetRelid(relation)));
/* ----------------
* open pg_attribute and begin a scan
* ----------------
*/
pg_attribute_desc = heap_openr(AttributeRelationName);
pg_attribute_scan =
heap_beginscan(pg_attribute_desc, 0, SnapshotNow, 1, &key);
pg_attribute_scan = heap_beginscan(pg_attribute_desc, 0, SnapshotNow, 1, &key);
/* ----------------
* add attribute data to relation->rd_att
@@ -550,7 +546,7 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
*/
need = natts;
pg_attribute_tuple = heap_getnext(pg_attribute_scan, 0, (Buffer *) NULL);
pg_attribute_tuple = heap_getnext(pg_attribute_scan, 0);
while (HeapTupleIsValid(pg_attribute_tuple) && need > 0)
{
attp = (AttributeTupleForm) GETSTRUCT(pg_attribute_tuple);
@@ -565,13 +561,12 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
ATTRIBUTE_TUPLE_SIZE);
need--;
}
pg_attribute_tuple = heap_getnext(pg_attribute_scan,
0, (Buffer *) NULL);
pg_attribute_tuple = heap_getnext(pg_attribute_scan, 0);
}
if (need > 0)
elog(ERROR, "catalog is missing %d attribute%s for relid %d",
need, (need == 1 ? "" : "s"), relation->rd_id);
need, (need == 1 ? "" : "s"), RelationGetRelid(relation));
/* ----------------
* end the scan and close the attribute relation
@@ -600,8 +595,8 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
for (i = 1; i <= relation->rd_rel->relnatts; i++)
{
atttup = (HeapTuple) AttributeNumIndexScan(attrel, relation->rd_id, i);
atttup = (HeapTuple) AttributeNumIndexScan(attrel,
RelationGetRelid(relation), i);
if (!HeapTupleIsValid(atttup))
elog(ERROR, "cannot find attribute %d of relation %s", i,
@@ -705,24 +700,21 @@ RelationBuildRuleLock(Relation relation)
ScanKeyEntryInitialize(&key, 0,
Anum_pg_rewrite_ev_class,
F_OIDEQ,
ObjectIdGetDatum(relation->rd_id));
ObjectIdGetDatum(RelationGetRelid(relation)));
/* ----------------
* open pg_attribute and begin a scan
* ----------------
*/
pg_rewrite_desc = heap_openr(RewriteRelationName);
pg_rewrite_scan =
heap_beginscan(pg_rewrite_desc, 0, SnapshotNow, 1, &key);
pg_rewrite_tupdesc =
RelationGetTupleDescriptor(pg_rewrite_desc);
pg_rewrite_scan = heap_beginscan(pg_rewrite_desc, 0, SnapshotNow, 1, &key);
pg_rewrite_tupdesc = RelationGetTupleDescriptor(pg_rewrite_desc);
/* ----------------
* add attribute data to relation->rd_att
* ----------------
*/
while ((pg_rewrite_tuple = heap_getnext(pg_rewrite_scan, 0,
(Buffer *) NULL)) != NULL)
while (HeapTupleIsValid(pg_rewrite_tuple=heap_getnext(pg_rewrite_scan, 0)))
{
bool isnull;
Datum ruleaction;
@@ -867,7 +859,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo)
* initialize the relation's relation id (relation->rd_id)
* ----------------
*/
relation->rd_id = relid;
RelationGetRelid(relation) = relid;
/* ----------------
* initialize relation->rd_refcnt
@@ -1093,7 +1085,7 @@ formrdesc(char *relationName,
* initialize relation id
* ----------------
*/
relation->rd_id = relation->rd_att->attrs[0]->attrelid;
RelationGetRelid(relation) = relation->rd_att->attrs[0]->attrelid;
/* ----------------
* add new reldesc to relcache
@@ -1109,7 +1101,7 @@ formrdesc(char *relationName,
* the check (and possible set) after cache insertion.
*/
relation->rd_rel->relhasindex =
CatalogHasIndex(relationName, relation->rd_id);
CatalogHasIndex(relationName, RelationGetRelid(relation));
}
@@ -1328,7 +1320,7 @@ RelationFlushRelation(Relation *relationPtr,
RelationCacheDelete(relation);
FreeTupleDesc(relation->rd_att);
SystemCacheRelationFlushed(relation->rd_id);
SystemCacheRelationFlushed(RelationGetRelid(relation));
FreeTriggerDesc(relation);
@@ -1379,7 +1371,7 @@ RelationForgetRelation(Oid rid)
Relation reln = lfirst(curr);
Assert(reln != NULL && reln->rd_islocal);
if (reln->rd_id == rid)
if (RelationGetRelid(reln) == rid)
break;
prev = curr;
}
@@ -1678,7 +1670,6 @@ AttrDefaultFetch(Relation relation)
Form_pg_attrdef adform;
IndexScanDesc sd;
RetrieveIndexResult indexRes;
Buffer buffer;
ItemPointer iptr;
struct varlena *val;
bool isnull;
@@ -1689,7 +1680,7 @@ AttrDefaultFetch(Relation relation)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(relation->rd_id));
ObjectIdGetDatum(RelationGetRelid(relation)));
adrel = heap_openr(AttrDefaultRelationName);
irel = index_openr(AttrDefaultIndex);
@@ -1698,6 +1689,8 @@ AttrDefaultFetch(Relation relation)
for (found = 0;;)
{
Buffer buffer;
indexRes = index_getnext(sd, ForwardScanDirection);
if (!indexRes)
break;
@@ -1736,12 +1729,12 @@ AttrDefaultFetch(Relation relation)
attrdef[i].adsrc = textout(val);
break;
}
ReleaseBuffer(buffer);
if (i >= ndef)
elog(ERROR, "AttrDefaultFetch: unexpected record found for attr %d in rel %s",
adform->adnum,
relation->rd_rel->relname.data);
ReleaseBuffer(buffer);
}
if (found < ndef)
@@ -1752,7 +1745,6 @@ AttrDefaultFetch(Relation relation)
pfree(sd);
index_close(irel);
heap_close(adrel);
}
static void
@@ -1766,7 +1758,6 @@ RelCheckFetch(Relation relation)
HeapTuple tuple;
IndexScanDesc sd;
RetrieveIndexResult indexRes;
Buffer buffer;
ItemPointer iptr;
Name rcname;
struct varlena *val;
@@ -1777,7 +1768,7 @@ RelCheckFetch(Relation relation)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(relation->rd_id));
ObjectIdGetDatum(RelationGetRelid(relation)));
rcrel = heap_openr(RelCheckRelationName);
irel = index_openr(RelCheckIndex);
@@ -1786,6 +1777,8 @@ RelCheckFetch(Relation relation)
for (found = 0;;)
{
Buffer buffer;
indexRes = index_getnext(sd, ForwardScanDirection);
if (!indexRes)
break;
@@ -1821,7 +1814,6 @@ RelCheckFetch(Relation relation)
relation->rd_rel->relname.data);
check[found].ccsrc = textout(val);
found++;
ReleaseBuffer(buffer);
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.19 1998/07/20 16:57:05 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.20 1998/08/19 02:03:15 momjian Exp $
*
* NOTES
* These routines allow the parser/planner/executor to perform
@@ -67,262 +67,320 @@ typedef HeapTuple (*ScanFunc) ();
static struct cachedesc cacheinfo[] = {
{AccessMethodOperatorRelationName, /* AMOPOPID */
3,
{Anum_pg_amop_amopclaid,
{
Anum_pg_amop_amopclaid,
Anum_pg_amop_amopopr,
Anum_pg_amop_amopid,
0},
0
},
sizeof(FormData_pg_amop),
NULL,
(ScanFunc) NULL},
{AccessMethodOperatorRelationName, /* AMOPSTRATEGY */
3,
{Anum_pg_amop_amopid,
{
Anum_pg_amop_amopid,
Anum_pg_amop_amopclaid,
Anum_pg_amop_amopstrategy,
0},
0
},
sizeof(FormData_pg_amop),
NULL,
(ScanFunc) NULL},
{AttributeRelationName, /* ATTNAME */
2,
{Anum_pg_attribute_attrelid,
{
Anum_pg_attribute_attrelid,
Anum_pg_attribute_attname,
0,
0},
0
},
ATTRIBUTE_TUPLE_SIZE,
AttributeNameIndex,
(ScanFunc) AttributeNameIndexScan},
{AttributeRelationName, /* ATTNUM */
2,
{Anum_pg_attribute_attrelid,
{
Anum_pg_attribute_attrelid,
Anum_pg_attribute_attnum,
0,
0},
0
},
ATTRIBUTE_TUPLE_SIZE,
AttributeNumIndex,
(ScanFunc) AttributeNumIndexScan},
{IndexRelationName, /* INDEXRELID */
1,
{Anum_pg_index_indexrelid,
{
Anum_pg_index_indexrelid,
0,
0,
0},
0
},
offsetof(FormData_pg_index, indpred),
NULL,
NULL},
{LanguageRelationName, /* LANNAME */
1,
{Anum_pg_language_lanname,
{
Anum_pg_language_lanname,
0,
0,
0},
0
},
offsetof(FormData_pg_language, lancompiler),
NULL,
NULL},
{OperatorRelationName, /* OPRNAME */
4,
{Anum_pg_operator_oprname,
{
Anum_pg_operator_oprname,
Anum_pg_operator_oprleft,
Anum_pg_operator_oprright,
Anum_pg_operator_oprkind},
Anum_pg_operator_oprkind
},
sizeof(FormData_pg_operator),
NULL,
NULL},
{OperatorRelationName, /* OPROID */
1,
{ObjectIdAttributeNumber,
{
ObjectIdAttributeNumber,
0,
0,
0},
0
},
sizeof(FormData_pg_operator),
NULL,
(ScanFunc) NULL},
{ProcedureRelationName, /* PRONAME */
3,
{Anum_pg_proc_proname,
{
Anum_pg_proc_proname,
Anum_pg_proc_pronargs,
Anum_pg_proc_proargtypes,
0},
0
},
offsetof(FormData_pg_proc, prosrc),
ProcedureNameIndex,
(ScanFunc) ProcedureNameIndexScan},
{ProcedureRelationName, /* PROOID */
1,
{ObjectIdAttributeNumber,
{
ObjectIdAttributeNumber,
0,
0,
0},
0
},
offsetof(FormData_pg_proc, prosrc),
ProcedureOidIndex,
(ScanFunc) ProcedureOidIndexScan},
{RelationRelationName, /* RELNAME */
1,
{Anum_pg_class_relname,
{
Anum_pg_class_relname,
0,
0,
0},
0
},
CLASS_TUPLE_SIZE,
ClassNameIndex,
(ScanFunc) ClassNameIndexScan},
{RelationRelationName, /* RELOID */
1,
{ObjectIdAttributeNumber,
{
ObjectIdAttributeNumber,
0,
0,
0},
0
},
CLASS_TUPLE_SIZE,
ClassOidIndex,
(ScanFunc) ClassOidIndexScan},
{TypeRelationName, /* TYPNAME */
1,
{Anum_pg_type_typname,
{
Anum_pg_type_typname,
0,
0,
0},
0
},
offsetof(TypeTupleFormData, typalign) +sizeof(char),
TypeNameIndex,
TypeNameIndexScan},
{TypeRelationName, /* TYPOID */
1,
{ObjectIdAttributeNumber,
{
ObjectIdAttributeNumber,
0,
0,
0},
0
},
offsetof(TypeTupleFormData, typalign) +sizeof(char),
TypeOidIndex,
TypeOidIndexScan},
{AccessMethodRelationName, /* AMNAME */
1,
{Anum_pg_am_amname,
{
Anum_pg_am_amname,
0,
0,
0},
0
},
sizeof(FormData_pg_am),
NULL,
NULL},
{OperatorClassRelationName, /* CLANAME */
1,
{Anum_pg_opclass_opcname,
{
Anum_pg_opclass_opcname,
0,
0,
0},
0
},
sizeof(FormData_pg_opclass),
NULL,
NULL},
{IndexRelationName, /* INDRELIDKEY */
{IndexRelationName, /* INDRELIDKEY */ /* never used */
2,
{Anum_pg_index_indrelid,
{
Anum_pg_index_indrelid,
Anum_pg_index_indkey,
0,
0},
0
},
offsetof(FormData_pg_index, indpred),
NULL,
(ScanFunc) NULL},
{InheritsRelationName, /* INHRELID */
2,
{Anum_pg_inherits_inhrel,
{
Anum_pg_inherits_inhrel,
Anum_pg_inherits_inhseqno,
0,
0},
0
},
sizeof(FormData_pg_inherits),
NULL,
(ScanFunc) NULL},
{RewriteRelationName, /* RULOID */
1,
{ObjectIdAttributeNumber,
{
ObjectIdAttributeNumber,
0,
0,
0},
0
},
offsetof(FormData_pg_rewrite, ev_qual),
NULL,
(ScanFunc) NULL},
{AggregateRelationName, /* AGGNAME */
2,
{Anum_pg_aggregate_aggname,
{
Anum_pg_aggregate_aggname,
Anum_pg_aggregate_aggbasetype,
0,
0},
0
},
offsetof(FormData_pg_aggregate, agginitval1),
NULL,
(ScanFunc) NULL},
{ListenerRelationName, /* LISTENREL */
2,
{Anum_pg_listener_relname,
{
Anum_pg_listener_relname,
Anum_pg_listener_pid,
0,
0},
0
},
sizeof(FormData_pg_listener),
NULL,
(ScanFunc) NULL},
{ShadowRelationName, /* USENAME */
1,
{Anum_pg_shadow_usename,
{
Anum_pg_shadow_usename,
0,
0,
0},
0
},
sizeof(FormData_pg_shadow),
NULL,
(ScanFunc) NULL},
{ShadowRelationName, /* USESYSID */
1,
{Anum_pg_shadow_usesysid,
{
Anum_pg_shadow_usesysid,
0,
0,
0},
0
},
sizeof(FormData_pg_shadow),
NULL,
(ScanFunc) NULL},
{GroupRelationName, /* GRONAME */
1,
{Anum_pg_group_groname,
{
Anum_pg_group_groname,
0,
0,
0},
0
},
offsetof(FormData_pg_group, grolist[0]),
NULL,
(ScanFunc) NULL},
{GroupRelationName, /* GROSYSID */
1,
{Anum_pg_group_grosysid,
{
Anum_pg_group_grosysid,
0,
0,
0},
0
},
offsetof(FormData_pg_group, grolist[0]),
NULL,
(ScanFunc) NULL},
{RewriteRelationName, /* REWRITENAME */
1,
{Anum_pg_rewrite_rulename,
{
Anum_pg_rewrite_rulename,
0,
0,
0},
0
},
offsetof(FormData_pg_rewrite, ev_qual),
NULL,
(ScanFunc) NULL},
{ProcedureRelationName, /* PROSRC */
1,
{Anum_pg_proc_prosrc,
{
Anum_pg_proc_prosrc,
0,
0,
0},
0
},
offsetof(FormData_pg_proc, prosrc),
ProcedureSrcIndex,
(ScanFunc) ProcedureSrcIndexScan},
{OperatorClassRelationName, /* CLADEFTYPE */
1,
{Anum_pg_opclass_opcdeftype,
{
Anum_pg_opclass_opcdeftype,
0,
0,
0},
0
},
sizeof(FormData_pg_opclass),
NULL,
(ScanFunc) NULL},
{LanguageRelationName, /* LANOID */
1,
{ObjectIdAttributeNumber,
{
ObjectIdAttributeNumber,
0,
0,
0},
0
},
offsetof(FormData_pg_language, lancompiler),
NULL,
NULL}
@@ -380,16 +438,39 @@ InitCatalogCache()
}
}
}
/*
* SearchSysCacheTupleCopy--
*
* THis is like SearchSysCacheTuple, except it returns a copy of the tuple
* that the user is required to pfree().
*/
HeapTuple
SearchSysCacheTupleCopy(int cacheId,/* cache selection code */
Datum key1,
Datum key2,
Datum key3,
Datum key4)
{
HeapTuple cachetup;
cachetup = SearchSysCacheTuple(cacheId, key1, key2, key3, key4);
if (PointerIsValid(cachetup))
return heap_copytuple(cachetup);
else
return cachetup; /* NULL */
}
/*
* SearchSysCacheTuple--
*
* A layer on top of SearchSysCache that does the initialization and
* key-setting for you.
* A layer on top of SearchSysCache that does the initialization and
* key-setting for you.
*
* Returns the tuple if one is found, NULL if not.
* Returns the cache copy of the tuple if one is found, NULL if not.
* The tuple is the 'cache' copy.
*
* XXX The tuple that is returned is NOT supposed to be pfree'd!
* XXX The tuple that is returned is NOT supposed to be pfree'd!
*/
HeapTuple
SearchSysCacheTuple(int cacheId,/* cache selection code */
@@ -542,7 +623,6 @@ SearchSysCacheGetAttribute(int cacheId,
if (isNull)
{
/*
* Used to be an elog(DEBUG, ...) here and a claim that it should
* be a FATAL error, I don't think either is warranted -mer 6/9/92
@@ -622,7 +702,6 @@ TypeDefaultRetrieve(Oid typId)
cacheinfo[TYPOID].name, TYPOID);
#endif /* defined(CACHEDEBUG) */
return (NULL);
}
dataSize = VARSIZE(typDefault) - VARHDRSZ;

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.18 1998/06/15 19:29:42 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.19 1998/08/19 02:03:16 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -58,7 +58,7 @@ fmgr_dynamic(Oid procedureId, int *pronargs)
*probinstring;
Datum probinattr;
func_ptr user_fn;
Relation rdesc;
Relation rel;
bool isnull;
if (procedureId == procedureId_save)
@@ -71,7 +71,8 @@ fmgr_dynamic(Oid procedureId, int *pronargs)
* The procedure isn't a builtin, so we'll have to do a catalog lookup
* to find its pg_proc entry.
*/
procedureTuple = SearchSysCacheTuple(PROOID, ObjectIdGetDatum(procedureId),
procedureTuple = SearchSysCacheTuple(PROOID,
ObjectIdGetDatum(procedureId),
0, 0, 0);
if (!HeapTupleIsValid(procedureTuple))
{
@@ -87,13 +88,13 @@ fmgr_dynamic(Oid procedureId, int *pronargs)
/*
* Extract the procedure info from the pg_proc tuple. Since probin is
* varlena, do a amgetattr() on the procedure tuple. To do that, we
* need the rdesc for the procedure relation, so...
* need the rel for the procedure relation, so...
*/
/* open pg_procedure */
rdesc = heap_openr(ProcedureRelationName);
if (!RelationIsValid(rdesc))
rel = heap_openr(ProcedureRelationName);
if (!RelationIsValid(rel))
{
elog(ERROR, "fmgr: Could not open relation %s",
ProcedureRelationName);
@@ -101,10 +102,10 @@ fmgr_dynamic(Oid procedureId, int *pronargs)
}
probinattr = heap_getattr(procedureTuple,
Anum_pg_proc_probin,
RelationGetTupleDescriptor(rdesc), &isnull);
RelationGetTupleDescriptor(rel), &isnull);
if (!PointerIsValid(probinattr) /* || isnull */ )
{
heap_close(rdesc);
heap_close(rel);
elog(ERROR, "fmgr: Could not extract probin for %d from %s",
procedureId, ProcedureRelationName);
return ((func_ptr) NULL);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.17 1998/06/15 19:29:44 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.18 1998/08/19 02:03:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -172,7 +172,7 @@ fmgr_info(Oid procedureId, FmgrInfo *finfo)
if (!(fcp = fmgr_isbuiltin(procedureId)))
{
procedureTuple = SearchSysCacheTuple(PROOID,
ObjectIdGetDatum(procedureId),
ObjectIdGetDatum(procedureId),
0, 0, 0);
if (!HeapTupleIsValid(procedureTuple))
{

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.19 1998/08/11 18:28:25 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.20 1998/08/19 02:03:19 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -468,8 +468,9 @@ SetUserId()
}
userName = GetPgUserName();
userTup = SearchSysCacheTuple(USENAME, PointerGetDatum(userName),
0, 0, 0);
userTup = SearchSysCacheTuple(USENAME,
PointerGetDatum(userName),
0, 0, 0);
if (!HeapTupleIsValid(userTup))
elog(FATAL, "SetUserId: user \"%s\" is not in \"%s\"",
userName,

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.15 1998/08/11 18:28:30 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.16 1998/08/19 02:03:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,7 +45,6 @@ GetDatabaseInfo(char *name, int4 *owner, char *path)
Relation dbrel;
HeapTuple dbtup;
HeapTuple tup;
Buffer buf;
HeapScanDesc scan;
ScanKeyData scanKey;
@@ -64,13 +63,10 @@ GetDatabaseInfo(char *name, int4 *owner, char *path)
/*
* Since we're going to close the relation, copy the tuple.
*/
tup = heap_getnext(scan, 0, &buf);
tup = heap_getnext(scan, 0);
if (HeapTupleIsValid(tup))
{
dbtup = heap_copytuple(tup);
ReleaseBuffer(buf);
}
else
dbtup = tup;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.5 1998/02/25 13:08:23 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.6 1998/08/19 02:03:25 momjian Exp $
*
* DESCRIPTION
* See superuser().
@@ -30,8 +30,9 @@ superuser(void)
HeapTuple utup;
utup = SearchSysCacheTuple(USENAME, PointerGetDatum(UserName),
0, 0, 0);
utup = SearchSysCacheTuple(USENAME,
PointerGetDatum(UserName),
0, 0, 0);
Assert(utup != NULL);
return ((Form_pg_shadow) GETSTRUCT(utup))->usesuper;
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.16 1998/06/15 19:29:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.17 1998/08/19 02:03:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -40,7 +40,7 @@ setheapoverride(bool on)
if (on)
{
TransactionIdStore(GetCurrentTransactionId(),
&HeapSpecialTransactionId);
&HeapSpecialTransactionId);
HeapSpecialCommandId = GetCurrentCommandId();
}
else