mirror of
https://github.com/postgres/postgres.git
synced 2025-04-20 00:42:27 +03:00
Completion of project to use fixed OIDs for all system catalogs and
indexes. Replace all heap_openr and index_openr calls by heap_open and index_open. Remove runtime lookups of catalog OID numbers in various places. Remove relcache's support for looking up system catalogs by name. Bulky but mostly very boring patch ...
This commit is contained in:
parent
9dc2e6deaf
commit
162bd08b3f
@ -36,7 +36,6 @@
|
|||||||
#include "funcapi.h"
|
#include "funcapi.h"
|
||||||
#include "access/tupdesc.h"
|
#include "access/tupdesc.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
#include "catalog/pg_index.h"
|
#include "catalog/pg_index.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
@ -1538,7 +1537,7 @@ get_pkey_attnames(Oid relid, int16 *numatts)
|
|||||||
*numatts = 0;
|
*numatts = 0;
|
||||||
|
|
||||||
/* use relid to get all related indexes */
|
/* use relid to get all related indexes */
|
||||||
indexRelation = heap_openr(IndexRelationName, AccessShareLock);
|
indexRelation = heap_open(IndexRelationId, AccessShareLock);
|
||||||
ScanKeyInit(&entry,
|
ScanKeyInit(&entry,
|
||||||
Anum_pg_index_indrelid,
|
Anum_pg_index_indrelid,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/pg_proc.h"
|
#include "catalog/pg_proc.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include "access/relscan.h"
|
#include "access/relscan.h"
|
||||||
#include "access/skey.h"
|
#include "access/skey.h"
|
||||||
#include "access/tupdesc.h"
|
#include "access/tupdesc.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/pg_listener.h"
|
#include "catalog/pg_listener.h"
|
||||||
#include "commands/async.h"
|
#include "commands/async.h"
|
||||||
#include "fmgr.h"
|
#include "fmgr.h"
|
||||||
@ -75,7 +74,7 @@ active_listeners(text *relname)
|
|||||||
int ourpid = getpid();
|
int ourpid = getpid();
|
||||||
char listen_name[NAMEDATALEN];
|
char listen_name[NAMEDATALEN];
|
||||||
|
|
||||||
lRel = heap_openr(ListenerRelationName, AccessShareLock);
|
lRel = heap_open(ListenerRelationId, AccessShareLock);
|
||||||
tdesc = RelationGetDescr(lRel);
|
tdesc = RelationGetDescr(lRel);
|
||||||
|
|
||||||
if (relname && (VARSIZE(relname) > VARHDRSZ))
|
if (relname && (VARSIZE(relname) > VARHDRSZ))
|
||||||
|
@ -8,17 +8,15 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.186 2005/03/28 01:50:32 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.187 2005/04/14 20:03:22 tgl Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
* relation_open - open any relation by relation OID
|
* relation_open - open any relation by relation OID
|
||||||
* relation_openrv - open any relation specified by a RangeVar
|
* relation_openrv - open any relation specified by a RangeVar
|
||||||
* relation_openr - open a system relation by name
|
|
||||||
* relation_close - close any relation
|
* relation_close - close any relation
|
||||||
* heap_open - open a heap relation by relation OID
|
* heap_open - open a heap relation by relation OID
|
||||||
* heap_openrv - open a heap relation specified by a RangeVar
|
* heap_openrv - open a heap relation specified by a RangeVar
|
||||||
* heap_openr - open a system heap relation by name
|
|
||||||
* heap_close - (now just a macro for relation_close)
|
* heap_close - (now just a macro for relation_close)
|
||||||
* heap_beginscan - begin relation scan
|
* heap_beginscan - begin relation scan
|
||||||
* heap_rescan - restart a relation scan
|
* heap_rescan - restart a relation scan
|
||||||
@ -502,15 +500,6 @@ relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
|
|||||||
{
|
{
|
||||||
Oid relOid;
|
Oid relOid;
|
||||||
|
|
||||||
/*
|
|
||||||
* In bootstrap mode, don't do any namespace processing.
|
|
||||||
*/
|
|
||||||
if (IsBootstrapProcessingMode())
|
|
||||||
{
|
|
||||||
Assert(relation->schemaname == NULL);
|
|
||||||
return relation_openr(relation->relname, lockmode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for shared-cache-inval messages before trying to open the
|
* Check for shared-cache-inval messages before trying to open the
|
||||||
* relation. This is needed to cover the case where the name
|
* relation. This is needed to cover the case where the name
|
||||||
@ -533,37 +522,6 @@ relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
|
|||||||
return relation_open(relOid, lockmode);
|
return relation_open(relOid, lockmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------
|
|
||||||
* relation_openr - open a system relation specified by name.
|
|
||||||
*
|
|
||||||
* As above, but the relation is specified by an unqualified name;
|
|
||||||
* it is assumed to live in the system catalog namespace.
|
|
||||||
* ----------------
|
|
||||||
*/
|
|
||||||
Relation
|
|
||||||
relation_openr(const char *sysRelationName, LOCKMODE lockmode)
|
|
||||||
{
|
|
||||||
Relation r;
|
|
||||||
|
|
||||||
Assert(lockmode >= NoLock && lockmode < MAX_LOCKMODES);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We assume we should not need to worry about the rel's OID changing,
|
|
||||||
* hence no need for AcceptInvalidationMessages here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* The relcache does all the real work... */
|
|
||||||
r = RelationSysNameGetRelation(sysRelationName);
|
|
||||||
|
|
||||||
if (!RelationIsValid(r))
|
|
||||||
elog(ERROR, "could not open relation \"%s\"", sysRelationName);
|
|
||||||
|
|
||||||
if (lockmode != NoLock)
|
|
||||||
LockRelation(r, lockmode);
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* relation_close - close any relation
|
* relation_close - close any relation
|
||||||
*
|
*
|
||||||
@ -657,41 +615,6 @@ heap_openrv(const RangeVar *relation, LOCKMODE lockmode)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------
|
|
||||||
* heap_openr - open a system heap relation specified by name.
|
|
||||||
*
|
|
||||||
* As above, but the relation is specified by an unqualified name;
|
|
||||||
* it is assumed to live in the system catalog namespace.
|
|
||||||
* ----------------
|
|
||||||
*/
|
|
||||||
Relation
|
|
||||||
heap_openr(const char *sysRelationName, LOCKMODE lockmode)
|
|
||||||
{
|
|
||||||
Relation r;
|
|
||||||
|
|
||||||
r = relation_openr(sysRelationName, lockmode);
|
|
||||||
|
|
||||||
if (r->rd_rel->relkind == RELKIND_INDEX)
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
|
||||||
errmsg("\"%s\" is an index",
|
|
||||||
RelationGetRelationName(r))));
|
|
||||||
else if (r->rd_rel->relkind == RELKIND_SPECIAL)
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
|
||||||
errmsg("\"%s\" is a special relation",
|
|
||||||
RelationGetRelationName(r))));
|
|
||||||
else if (r->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
|
||||||
errmsg("\"%s\" is a composite type",
|
|
||||||
RelationGetRelationName(r))));
|
|
||||||
|
|
||||||
pgstat_initstats(&r->pgstat_info, r);
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* heap_beginscan - begin relation scan
|
* heap_beginscan - begin relation scan
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.46 2005/03/29 00:16:51 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.47 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* many of the old access method routines have been turned into
|
* many of the old access method routines have been turned into
|
||||||
@ -162,7 +162,7 @@ IndexScanEnd(IndexScanDesc scan)
|
|||||||
* systable_beginscan --- set up for heap-or-index scan
|
* systable_beginscan --- set up for heap-or-index scan
|
||||||
*
|
*
|
||||||
* rel: catalog to scan, already opened and suitably locked
|
* rel: catalog to scan, already opened and suitably locked
|
||||||
* indexRelname: name of index to conditionally use
|
* indexId: OID of index to conditionally use
|
||||||
* indexOK: if false, forces a heap scan (see notes below)
|
* indexOK: if false, forces a heap scan (see notes below)
|
||||||
* snapshot: time qual to use (usually should be SnapshotNow)
|
* snapshot: time qual to use (usually should be SnapshotNow)
|
||||||
* nkeys, key: scan keys
|
* nkeys, key: scan keys
|
||||||
@ -179,7 +179,7 @@ IndexScanEnd(IndexScanDesc scan)
|
|||||||
*/
|
*/
|
||||||
SysScanDesc
|
SysScanDesc
|
||||||
systable_beginscan(Relation heapRelation,
|
systable_beginscan(Relation heapRelation,
|
||||||
const char *indexRelname,
|
Oid indexId,
|
||||||
bool indexOK,
|
bool indexOK,
|
||||||
Snapshot snapshot,
|
Snapshot snapshot,
|
||||||
int nkeys, ScanKey key)
|
int nkeys, ScanKey key)
|
||||||
@ -187,18 +187,10 @@ systable_beginscan(Relation heapRelation,
|
|||||||
SysScanDesc sysscan;
|
SysScanDesc sysscan;
|
||||||
Relation irel;
|
Relation irel;
|
||||||
|
|
||||||
if (indexOK && !IsIgnoringSystemIndexes())
|
if (indexOK &&
|
||||||
{
|
!IsIgnoringSystemIndexes() &&
|
||||||
/* We assume it's a system index, so index_openr is OK */
|
!ReindexIsProcessingIndex(indexId))
|
||||||
irel = index_openr(indexRelname);
|
irel = index_open(indexId);
|
||||||
|
|
||||||
if (ReindexIsProcessingIndex(RelationGetRelid(irel)))
|
|
||||||
{
|
|
||||||
/* oops, can't use index that's being rebuilt */
|
|
||||||
index_close(irel);
|
|
||||||
irel = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
irel = NULL;
|
irel = NULL;
|
||||||
|
|
||||||
|
@ -8,12 +8,11 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.79 2005/03/27 23:52:59 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.80 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
* index_open - open an index relation by relation OID
|
* index_open - open an index relation by relation OID
|
||||||
* index_openrv - open an index relation specified by a RangeVar
|
* index_openrv - open an index relation specified by a RangeVar
|
||||||
* index_openr - open a system index relation by name
|
|
||||||
* index_close - close an index relation
|
* index_close - close an index relation
|
||||||
* index_beginscan - start a scan of an index with amgettuple
|
* index_beginscan - start a scan of an index with amgettuple
|
||||||
* index_beginscan_multi - start a scan of an index with amgetmulti
|
* index_beginscan_multi - start a scan of an index with amgetmulti
|
||||||
@ -172,31 +171,6 @@ index_openrv(const RangeVar *relation)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------
|
|
||||||
* index_openr - open a system index relation specified by name.
|
|
||||||
*
|
|
||||||
* As above, but the relation is specified by an unqualified name;
|
|
||||||
* it is assumed to live in the system catalog namespace.
|
|
||||||
* ----------------
|
|
||||||
*/
|
|
||||||
Relation
|
|
||||||
index_openr(const char *sysRelationName)
|
|
||||||
{
|
|
||||||
Relation r;
|
|
||||||
|
|
||||||
r = relation_openr(sysRelationName, NoLock);
|
|
||||||
|
|
||||||
if (r->rd_rel->relkind != RELKIND_INDEX)
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
|
||||||
errmsg("\"%s\" is not an index",
|
|
||||||
RelationGetRelationName(r))));
|
|
||||||
|
|
||||||
pgstat_initstats(&r->pgstat_info, r);
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* index_close - close a index relation
|
* index_close - close a index relation
|
||||||
*
|
*
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.201 2005/03/29 19:44:22 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.202 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -26,12 +26,12 @@
|
|||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "access/xlog.h"
|
#include "access/xlog.h"
|
||||||
#include "bootstrap/bootstrap.h"
|
#include "bootstrap/bootstrap.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/index.h"
|
#include "catalog/index.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
#include "executor/executor.h"
|
#include "executor/executor.h"
|
||||||
#include "libpq/pqsignal.h"
|
#include "libpq/pqsignal.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
|
#include "nodes/makefuncs.h"
|
||||||
#include "postmaster/bgwriter.h"
|
#include "postmaster/bgwriter.h"
|
||||||
#include "storage/freespace.h"
|
#include "storage/freespace.h"
|
||||||
#include "storage/ipc.h"
|
#include "storage/ipc.h"
|
||||||
@ -46,10 +46,14 @@
|
|||||||
#include "utils/ps_status.h"
|
#include "utils/ps_status.h"
|
||||||
#include "utils/relcache.h"
|
#include "utils/relcache.h"
|
||||||
|
|
||||||
|
extern int optind;
|
||||||
|
extern char *optarg;
|
||||||
|
|
||||||
|
|
||||||
#define ALLOC(t, c) ((t *) calloc((unsigned)(c), sizeof(t)))
|
#define ALLOC(t, c) ((t *) calloc((unsigned)(c), sizeof(t)))
|
||||||
|
|
||||||
extern int Int_yyparse(void);
|
extern int Int_yyparse(void);
|
||||||
|
|
||||||
static void usage(void);
|
static void usage(void);
|
||||||
static void bootstrap_signals(void);
|
static void bootstrap_signals(void);
|
||||||
static hashnode *AddStr(char *str, int strlength, int mderef);
|
static hashnode *AddStr(char *str, int strlength, int mderef);
|
||||||
@ -169,17 +173,12 @@ static struct typmap *Ap = NULL;
|
|||||||
static int Warnings = 0;
|
static int Warnings = 0;
|
||||||
static char Blanks[MAXATTR];
|
static char Blanks[MAXATTR];
|
||||||
|
|
||||||
static char *relname; /* current relation name */
|
|
||||||
|
|
||||||
Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */
|
Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */
|
||||||
static Datum values[MAXATTR]; /* corresponding attribute values */
|
static Datum values[MAXATTR]; /* corresponding attribute values */
|
||||||
int numattr; /* number of attributes for cur. rel */
|
int numattr; /* number of attributes for cur. rel */
|
||||||
|
|
||||||
static MemoryContext nogc = NULL; /* special no-gc mem context */
|
static MemoryContext nogc = NULL; /* special no-gc mem context */
|
||||||
|
|
||||||
extern int optind;
|
|
||||||
extern char *optarg;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* At bootstrap time, we first declare all the indices to be built, and
|
* At bootstrap time, we first declare all the indices to be built, and
|
||||||
* then build them. The IndexList structure stores enough information
|
* then build them. The IndexList structure stores enough information
|
||||||
@ -572,12 +571,12 @@ boot_openrel(char *relname)
|
|||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
if (strlen(relname) >= NAMEDATALEN - 1)
|
if (strlen(relname) >= NAMEDATALEN)
|
||||||
relname[NAMEDATALEN - 1] = '\0';
|
relname[NAMEDATALEN - 1] = '\0';
|
||||||
|
|
||||||
if (Typ == NULL)
|
if (Typ == NULL)
|
||||||
{
|
{
|
||||||
rel = heap_openr(TypeRelationName, NoLock);
|
rel = heap_open(TypeRelationId, NoLock);
|
||||||
scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
|
scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
|
||||||
i = 0;
|
i = 0;
|
||||||
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
||||||
@ -605,10 +604,9 @@ boot_openrel(char *relname)
|
|||||||
closerel(NULL);
|
closerel(NULL);
|
||||||
|
|
||||||
elog(DEBUG4, "open relation %s, attrsize %d",
|
elog(DEBUG4, "open relation %s, attrsize %d",
|
||||||
relname ? relname : "(null)",
|
relname, (int) ATTRIBUTE_TUPLE_SIZE);
|
||||||
(int) ATTRIBUTE_TUPLE_SIZE);
|
|
||||||
|
|
||||||
boot_reldesc = heap_openr(relname, NoLock);
|
boot_reldesc = heap_openrv(makeRangeVar(NULL, relname), NoLock);
|
||||||
numattr = boot_reldesc->rd_rel->relnatts;
|
numattr = boot_reldesc->rd_rel->relnatts;
|
||||||
for (i = 0; i < numattr; i++)
|
for (i = 0; i < numattr; i++)
|
||||||
{
|
{
|
||||||
@ -641,7 +639,7 @@ closerel(char *name)
|
|||||||
{
|
{
|
||||||
if (strcmp(RelationGetRelationName(boot_reldesc), name) != 0)
|
if (strcmp(RelationGetRelationName(boot_reldesc), name) != 0)
|
||||||
elog(ERROR, "close of %s when %s was expected",
|
elog(ERROR, "close of %s when %s was expected",
|
||||||
name, relname ? relname : "(null)");
|
name, RelationGetRelationName(boot_reldesc));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
elog(ERROR, "close of %s before any relation was opened",
|
elog(ERROR, "close of %s before any relation was opened",
|
||||||
@ -652,7 +650,8 @@ closerel(char *name)
|
|||||||
elog(ERROR, "no open relation to close");
|
elog(ERROR, "no open relation to close");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
elog(DEBUG4, "close relation %s", relname ? relname : "(null)");
|
elog(DEBUG4, "close relation %s",
|
||||||
|
RelationGetRelationName(boot_reldesc));
|
||||||
heap_close(boot_reldesc, NoLock);
|
heap_close(boot_reldesc, NoLock);
|
||||||
boot_reldesc = NULL;
|
boot_reldesc = NULL;
|
||||||
}
|
}
|
||||||
@ -676,7 +675,7 @@ DefineAttr(char *name, char *type, int attnum)
|
|||||||
if (boot_reldesc != NULL)
|
if (boot_reldesc != NULL)
|
||||||
{
|
{
|
||||||
elog(WARNING, "no open relations allowed with CREATE command");
|
elog(WARNING, "no open relations allowed with CREATE command");
|
||||||
closerel(relname);
|
closerel(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attrtypes[attnum] == NULL)
|
if (attrtypes[attnum] == NULL)
|
||||||
@ -933,7 +932,7 @@ gettype(char *type)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
elog(DEBUG4, "external type: %s", type);
|
elog(DEBUG4, "external type: %s", type);
|
||||||
rel = heap_openr(TypeRelationName, NoLock);
|
rel = heap_open(TypeRelationId, NoLock);
|
||||||
scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
|
scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
|
||||||
i = 0;
|
i = 0;
|
||||||
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.110 2005/01/27 23:36:06 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.111 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* See acl.h.
|
* See acl.h.
|
||||||
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
#include "catalog/pg_conversion.h"
|
#include "catalog/pg_conversion.h"
|
||||||
@ -270,7 +269,7 @@ ExecuteGrantStmt_Relation(GrantStmt *stmt)
|
|||||||
char replaces[Natts_pg_class];
|
char replaces[Natts_pg_class];
|
||||||
|
|
||||||
/* open pg_class */
|
/* open pg_class */
|
||||||
relation = heap_openr(RelationRelationName, RowExclusiveLock);
|
relation = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
relOid = RangeVarGetRelid(relvar, false);
|
relOid = RangeVarGetRelid(relvar, false);
|
||||||
tuple = SearchSysCache(RELOID,
|
tuple = SearchSysCache(RELOID,
|
||||||
ObjectIdGetDatum(relOid),
|
ObjectIdGetDatum(relOid),
|
||||||
@ -438,7 +437,7 @@ ExecuteGrantStmt_Database(GrantStmt *stmt)
|
|||||||
char nulls[Natts_pg_database];
|
char nulls[Natts_pg_database];
|
||||||
char replaces[Natts_pg_database];
|
char replaces[Natts_pg_database];
|
||||||
|
|
||||||
relation = heap_openr(DatabaseRelationName, RowExclusiveLock);
|
relation = heap_open(DatabaseRelationId, RowExclusiveLock);
|
||||||
ScanKeyInit(&entry[0],
|
ScanKeyInit(&entry[0],
|
||||||
Anum_pg_database_datname,
|
Anum_pg_database_datname,
|
||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
@ -597,7 +596,7 @@ ExecuteGrantStmt_Function(GrantStmt *stmt)
|
|||||||
|
|
||||||
oid = LookupFuncNameTypeNames(func->funcname, func->funcargs, false);
|
oid = LookupFuncNameTypeNames(func->funcname, func->funcargs, false);
|
||||||
|
|
||||||
relation = heap_openr(ProcedureRelationName, RowExclusiveLock);
|
relation = heap_open(ProcedureRelationId, RowExclusiveLock);
|
||||||
tuple = SearchSysCache(PROCOID,
|
tuple = SearchSysCache(PROCOID,
|
||||||
ObjectIdGetDatum(oid),
|
ObjectIdGetDatum(oid),
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
@ -748,7 +747,7 @@ ExecuteGrantStmt_Language(GrantStmt *stmt)
|
|||||||
char nulls[Natts_pg_language];
|
char nulls[Natts_pg_language];
|
||||||
char replaces[Natts_pg_language];
|
char replaces[Natts_pg_language];
|
||||||
|
|
||||||
relation = heap_openr(LanguageRelationName, RowExclusiveLock);
|
relation = heap_open(LanguageRelationId, RowExclusiveLock);
|
||||||
tuple = SearchSysCache(LANGNAME,
|
tuple = SearchSysCache(LANGNAME,
|
||||||
PointerGetDatum(langname),
|
PointerGetDatum(langname),
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
@ -911,7 +910,7 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt)
|
|||||||
char nulls[Natts_pg_namespace];
|
char nulls[Natts_pg_namespace];
|
||||||
char replaces[Natts_pg_namespace];
|
char replaces[Natts_pg_namespace];
|
||||||
|
|
||||||
relation = heap_openr(NamespaceRelationName, RowExclusiveLock);
|
relation = heap_open(NamespaceRelationId, RowExclusiveLock);
|
||||||
tuple = SearchSysCache(NAMESPACENAME,
|
tuple = SearchSysCache(NAMESPACENAME,
|
||||||
CStringGetDatum(nspname),
|
CStringGetDatum(nspname),
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
@ -1067,7 +1066,7 @@ ExecuteGrantStmt_Tablespace(GrantStmt *stmt)
|
|||||||
char nulls[Natts_pg_tablespace];
|
char nulls[Natts_pg_tablespace];
|
||||||
char replaces[Natts_pg_tablespace];
|
char replaces[Natts_pg_tablespace];
|
||||||
|
|
||||||
relation = heap_openr(TableSpaceRelationName, RowExclusiveLock);
|
relation = heap_open(TableSpaceRelationId, RowExclusiveLock);
|
||||||
ScanKeyInit(&entry[0],
|
ScanKeyInit(&entry[0],
|
||||||
Anum_pg_tablespace_spcname,
|
Anum_pg_tablespace_spcname,
|
||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
@ -1455,7 +1454,7 @@ pg_database_aclmask(Oid db_oid, AclId userid,
|
|||||||
*
|
*
|
||||||
* There's no syscache for pg_database, so must look the hard way
|
* There's no syscache for pg_database, so must look the hard way
|
||||||
*/
|
*/
|
||||||
pg_database = heap_openr(DatabaseRelationName, AccessShareLock);
|
pg_database = heap_open(DatabaseRelationId, AccessShareLock);
|
||||||
ScanKeyInit(&entry[0],
|
ScanKeyInit(&entry[0],
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
@ -1726,7 +1725,7 @@ pg_tablespace_aclmask(Oid spc_oid, AclId userid,
|
|||||||
*
|
*
|
||||||
* There's no syscache for pg_tablespace, so must look the hard way
|
* There's no syscache for pg_tablespace, so must look the hard way
|
||||||
*/
|
*/
|
||||||
pg_tablespace = heap_openr(TableSpaceRelationName, AccessShareLock);
|
pg_tablespace = heap_open(TableSpaceRelationId, AccessShareLock);
|
||||||
ScanKeyInit(&entry[0],
|
ScanKeyInit(&entry[0],
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
@ -2002,7 +2001,7 @@ pg_tablespace_ownercheck(Oid spc_oid, AclId userid)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* There's no syscache for pg_tablespace, so must look the hard way */
|
/* There's no syscache for pg_tablespace, so must look the hard way */
|
||||||
pg_tablespace = heap_openr(TableSpaceRelationName, AccessShareLock);
|
pg_tablespace = heap_open(TableSpaceRelationId, AccessShareLock);
|
||||||
ScanKeyInit(&entry[0],
|
ScanKeyInit(&entry[0],
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
@ -2070,7 +2069,7 @@ pg_database_ownercheck(Oid db_oid, AclId userid)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* There's no syscache for pg_database, so must look the hard way */
|
/* There's no syscache for pg_database, so must look the hard way */
|
||||||
pg_database = heap_openr(DatabaseRelationName, AccessShareLock);
|
pg_database = heap_open(DatabaseRelationId, AccessShareLock);
|
||||||
ScanKeyInit(&entry[0],
|
ScanKeyInit(&entry[0],
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.58 2005/03/07 04:15:34 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.59 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
#include "access/transam.h"
|
#include "access/transam.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/pg_namespace.h"
|
#include "catalog/pg_namespace.h"
|
||||||
#include "catalog/pg_tablespace.h"
|
#include "catalog/pg_tablespace.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.43 2005/04/14 01:38:15 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.44 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/heap.h"
|
#include "catalog/heap.h"
|
||||||
#include "catalog/index.h"
|
#include "catalog/index.h"
|
||||||
@ -28,7 +27,9 @@
|
|||||||
#include "catalog/pg_conversion.h"
|
#include "catalog/pg_conversion.h"
|
||||||
#include "catalog/pg_depend.h"
|
#include "catalog/pg_depend.h"
|
||||||
#include "catalog/pg_language.h"
|
#include "catalog/pg_language.h"
|
||||||
|
#include "catalog/pg_namespace.h"
|
||||||
#include "catalog/pg_opclass.h"
|
#include "catalog/pg_opclass.h"
|
||||||
|
#include "catalog/pg_operator.h"
|
||||||
#include "catalog/pg_proc.h"
|
#include "catalog/pg_proc.h"
|
||||||
#include "catalog/pg_rewrite.h"
|
#include "catalog/pg_rewrite.h"
|
||||||
#include "catalog/pg_trigger.h"
|
#include "catalog/pg_trigger.h"
|
||||||
@ -65,14 +66,25 @@ typedef struct
|
|||||||
List *rtables; /* list of rangetables to resolve Vars */
|
List *rtables; /* list of rangetables to resolve Vars */
|
||||||
} find_expr_references_context;
|
} find_expr_references_context;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Because not all system catalogs have predetermined OIDs, we build a table
|
* This constant table maps ObjectClasses to the corresponding catalog OIDs.
|
||||||
* mapping between ObjectClasses and OIDs. This is done at most once per
|
* See also getObjectClass().
|
||||||
* backend run, to minimize lookup overhead.
|
|
||||||
*/
|
*/
|
||||||
static bool object_classes_initialized = false;
|
static const Oid object_classes[MAX_OCLASS] = {
|
||||||
static Oid object_classes[MAX_OCLASS];
|
RelationRelationId, /* OCLASS_CLASS */
|
||||||
|
ProcedureRelationId, /* OCLASS_PROC */
|
||||||
|
TypeRelationId, /* OCLASS_TYPE */
|
||||||
|
CastRelationId, /* OCLASS_CAST */
|
||||||
|
ConstraintRelationId, /* OCLASS_CONSTRAINT */
|
||||||
|
ConversionRelationId, /* OCLASS_CONVERSION */
|
||||||
|
AttrDefaultRelationId, /* OCLASS_DEFAULT */
|
||||||
|
LanguageRelationId, /* OCLASS_LANGUAGE */
|
||||||
|
OperatorRelationId, /* OCLASS_OPERATOR */
|
||||||
|
OperatorClassRelationId, /* OCLASS_OPCLASS */
|
||||||
|
RewriteRelationId, /* OCLASS_REWRITE */
|
||||||
|
TriggerRelationId, /* OCLASS_TRIGGER */
|
||||||
|
NamespaceRelationId /* OCLASS_SCHEMA */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static void findAutoDeletableObjects(const ObjectAddress *object,
|
static void findAutoDeletableObjects(const ObjectAddress *object,
|
||||||
@ -103,7 +115,6 @@ static void add_exact_object_address(const ObjectAddress *object,
|
|||||||
static bool object_address_present(const ObjectAddress *object,
|
static bool object_address_present(const ObjectAddress *object,
|
||||||
ObjectAddresses *addrs);
|
ObjectAddresses *addrs);
|
||||||
static void term_object_addresses(ObjectAddresses *addrs);
|
static void term_object_addresses(ObjectAddresses *addrs);
|
||||||
static void init_object_classes(void);
|
|
||||||
static void getRelationDescription(StringInfo buffer, Oid relid);
|
static void getRelationDescription(StringInfo buffer, Oid relid);
|
||||||
|
|
||||||
|
|
||||||
@ -135,7 +146,7 @@ performDeletion(const ObjectAddress *object,
|
|||||||
* We save some cycles by opening pg_depend just once and passing the
|
* We save some cycles by opening pg_depend just once and passing the
|
||||||
* Relation pointer down to all the recursive deletion steps.
|
* Relation pointer down to all the recursive deletion steps.
|
||||||
*/
|
*/
|
||||||
depRel = heap_openr(DependRelationName, RowExclusiveLock);
|
depRel = heap_open(DependRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Construct a list of objects that are reachable by AUTO or INTERNAL
|
* Construct a list of objects that are reachable by AUTO or INTERNAL
|
||||||
@ -189,7 +200,7 @@ deleteWhatDependsOn(const ObjectAddress *object,
|
|||||||
* We save some cycles by opening pg_depend just once and passing the
|
* We save some cycles by opening pg_depend just once and passing the
|
||||||
* Relation pointer down to all the recursive deletion steps.
|
* Relation pointer down to all the recursive deletion steps.
|
||||||
*/
|
*/
|
||||||
depRel = heap_openr(DependRelationName, RowExclusiveLock);
|
depRel = heap_open(DependRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Construct a list of objects that are reachable by AUTO or INTERNAL
|
* Construct a list of objects that are reachable by AUTO or INTERNAL
|
||||||
@ -282,7 +293,7 @@ findAutoDeletableObjects(const ObjectAddress *object,
|
|||||||
else
|
else
|
||||||
nkeys = 2;
|
nkeys = 2;
|
||||||
|
|
||||||
scan = systable_beginscan(depRel, DependReferenceIndex, true,
|
scan = systable_beginscan(depRel, DependReferenceIndexId, true,
|
||||||
SnapshotNow, nkeys, key);
|
SnapshotNow, nkeys, key);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
||||||
@ -417,7 +428,7 @@ recursiveDeletion(const ObjectAddress *object,
|
|||||||
else
|
else
|
||||||
nkeys = 2;
|
nkeys = 2;
|
||||||
|
|
||||||
scan = systable_beginscan(depRel, DependDependerIndex, true,
|
scan = systable_beginscan(depRel, DependDependerIndexId, true,
|
||||||
SnapshotNow, nkeys, key);
|
SnapshotNow, nkeys, key);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
||||||
@ -650,7 +661,7 @@ deleteDependentObjects(const ObjectAddress *object,
|
|||||||
else
|
else
|
||||||
nkeys = 2;
|
nkeys = 2;
|
||||||
|
|
||||||
scan = systable_beginscan(depRel, DependReferenceIndex, true,
|
scan = systable_beginscan(depRel, DependReferenceIndexId, true,
|
||||||
SnapshotNow, nkeys, key);
|
SnapshotNow, nkeys, key);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
||||||
@ -1203,11 +1214,6 @@ init_object_addresses(ObjectAddresses *addrs)
|
|||||||
addrs->maxrefs = 32; /* arbitrary initial array size */
|
addrs->maxrefs = 32; /* arbitrary initial array size */
|
||||||
addrs->refs = (ObjectAddress *)
|
addrs->refs = (ObjectAddress *)
|
||||||
palloc(addrs->maxrefs * sizeof(ObjectAddress));
|
palloc(addrs->maxrefs * sizeof(ObjectAddress));
|
||||||
|
|
||||||
/* Initialize object_classes[] if not done yet */
|
|
||||||
/* This will be needed by add_object_address() */
|
|
||||||
if (!object_classes_initialized)
|
|
||||||
init_object_classes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1297,42 +1303,15 @@ term_object_addresses(ObjectAddresses *addrs)
|
|||||||
pfree(addrs->refs);
|
pfree(addrs->refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the object_classes[] table.
|
|
||||||
*
|
|
||||||
* Although some of these OIDs aren't compile-time constants, they surely
|
|
||||||
* shouldn't change during a backend's run. So, we look them up the
|
|
||||||
* first time through and then cache them.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
init_object_classes(void)
|
|
||||||
{
|
|
||||||
object_classes[OCLASS_CLASS] = RelationRelationId;
|
|
||||||
object_classes[OCLASS_PROC] = ProcedureRelationId;
|
|
||||||
object_classes[OCLASS_TYPE] = TypeRelationId;
|
|
||||||
object_classes[OCLASS_CAST] = get_system_catalog_relid(CastRelationName);
|
|
||||||
object_classes[OCLASS_CONSTRAINT] = get_system_catalog_relid(ConstraintRelationName);
|
|
||||||
object_classes[OCLASS_CONVERSION] = get_system_catalog_relid(ConversionRelationName);
|
|
||||||
object_classes[OCLASS_DEFAULT] = get_system_catalog_relid(AttrDefaultRelationName);
|
|
||||||
object_classes[OCLASS_LANGUAGE] = get_system_catalog_relid(LanguageRelationName);
|
|
||||||
object_classes[OCLASS_OPERATOR] = get_system_catalog_relid(OperatorRelationName);
|
|
||||||
object_classes[OCLASS_OPCLASS] = get_system_catalog_relid(OperatorClassRelationName);
|
|
||||||
object_classes[OCLASS_REWRITE] = get_system_catalog_relid(RewriteRelationName);
|
|
||||||
object_classes[OCLASS_TRIGGER] = get_system_catalog_relid(TriggerRelationName);
|
|
||||||
object_classes[OCLASS_SCHEMA] = get_system_catalog_relid(NamespaceRelationName);
|
|
||||||
object_classes_initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Determine the class of a given object identified by objectAddress.
|
* Determine the class of a given object identified by objectAddress.
|
||||||
*
|
*
|
||||||
* This function is needed just because some of the system catalogs do
|
* This function is essentially the reverse mapping for the object_classes[]
|
||||||
* not have hardwired-at-compile-time OIDs.
|
* table. We implement it as a function because the OIDs aren't consecutive.
|
||||||
*/
|
*/
|
||||||
ObjectClass
|
ObjectClass
|
||||||
getObjectClass(const ObjectAddress *object)
|
getObjectClass(const ObjectAddress *object)
|
||||||
{
|
{
|
||||||
/* Easy for the bootstrapped catalogs... */
|
|
||||||
switch (object->classId)
|
switch (object->classId)
|
||||||
{
|
{
|
||||||
case RelationRelationId:
|
case RelationRelationId:
|
||||||
@ -1346,65 +1325,49 @@ getObjectClass(const ObjectAddress *object)
|
|||||||
case TypeRelationId:
|
case TypeRelationId:
|
||||||
Assert(object->objectSubId == 0);
|
Assert(object->objectSubId == 0);
|
||||||
return OCLASS_TYPE;
|
return OCLASS_TYPE;
|
||||||
|
|
||||||
|
case CastRelationId:
|
||||||
|
Assert(object->objectSubId == 0);
|
||||||
|
return OCLASS_CAST;
|
||||||
|
|
||||||
|
case ConstraintRelationId:
|
||||||
|
Assert(object->objectSubId == 0);
|
||||||
|
return OCLASS_CONSTRAINT;
|
||||||
|
|
||||||
|
case ConversionRelationId:
|
||||||
|
Assert(object->objectSubId == 0);
|
||||||
|
return OCLASS_CONVERSION;
|
||||||
|
|
||||||
|
case AttrDefaultRelationId:
|
||||||
|
Assert(object->objectSubId == 0);
|
||||||
|
return OCLASS_DEFAULT;
|
||||||
|
|
||||||
|
case LanguageRelationId:
|
||||||
|
Assert(object->objectSubId == 0);
|
||||||
|
return OCLASS_LANGUAGE;
|
||||||
|
|
||||||
|
case OperatorRelationId:
|
||||||
|
Assert(object->objectSubId == 0);
|
||||||
|
return OCLASS_OPERATOR;
|
||||||
|
|
||||||
|
case OperatorClassRelationId:
|
||||||
|
Assert(object->objectSubId == 0);
|
||||||
|
return OCLASS_OPCLASS;
|
||||||
|
|
||||||
|
case RewriteRelationId:
|
||||||
|
Assert(object->objectSubId == 0);
|
||||||
|
return OCLASS_REWRITE;
|
||||||
|
|
||||||
|
case TriggerRelationId:
|
||||||
|
Assert(object->objectSubId == 0);
|
||||||
|
return OCLASS_TRIGGER;
|
||||||
|
|
||||||
|
case NamespaceRelationId:
|
||||||
|
Assert(object->objectSubId == 0);
|
||||||
|
return OCLASS_SCHEMA;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* shouldn't get here */
|
||||||
* Handle cases where catalog's OID is not hardwired.
|
|
||||||
*/
|
|
||||||
if (!object_classes_initialized)
|
|
||||||
init_object_classes();
|
|
||||||
|
|
||||||
if (object->classId == object_classes[OCLASS_CAST])
|
|
||||||
{
|
|
||||||
Assert(object->objectSubId == 0);
|
|
||||||
return OCLASS_CAST;
|
|
||||||
}
|
|
||||||
if (object->classId == object_classes[OCLASS_CONSTRAINT])
|
|
||||||
{
|
|
||||||
Assert(object->objectSubId == 0);
|
|
||||||
return OCLASS_CONSTRAINT;
|
|
||||||
}
|
|
||||||
if (object->classId == object_classes[OCLASS_CONVERSION])
|
|
||||||
{
|
|
||||||
Assert(object->objectSubId == 0);
|
|
||||||
return OCLASS_CONVERSION;
|
|
||||||
}
|
|
||||||
if (object->classId == object_classes[OCLASS_DEFAULT])
|
|
||||||
{
|
|
||||||
Assert(object->objectSubId == 0);
|
|
||||||
return OCLASS_DEFAULT;
|
|
||||||
}
|
|
||||||
if (object->classId == object_classes[OCLASS_LANGUAGE])
|
|
||||||
{
|
|
||||||
Assert(object->objectSubId == 0);
|
|
||||||
return OCLASS_LANGUAGE;
|
|
||||||
}
|
|
||||||
if (object->classId == object_classes[OCLASS_OPERATOR])
|
|
||||||
{
|
|
||||||
Assert(object->objectSubId == 0);
|
|
||||||
return OCLASS_OPERATOR;
|
|
||||||
}
|
|
||||||
if (object->classId == object_classes[OCLASS_OPCLASS])
|
|
||||||
{
|
|
||||||
Assert(object->objectSubId == 0);
|
|
||||||
return OCLASS_OPCLASS;
|
|
||||||
}
|
|
||||||
if (object->classId == object_classes[OCLASS_REWRITE])
|
|
||||||
{
|
|
||||||
Assert(object->objectSubId == 0);
|
|
||||||
return OCLASS_REWRITE;
|
|
||||||
}
|
|
||||||
if (object->classId == object_classes[OCLASS_TRIGGER])
|
|
||||||
{
|
|
||||||
Assert(object->objectSubId == 0);
|
|
||||||
return OCLASS_TRIGGER;
|
|
||||||
}
|
|
||||||
if (object->classId == object_classes[OCLASS_SCHEMA])
|
|
||||||
{
|
|
||||||
Assert(object->objectSubId == 0);
|
|
||||||
return OCLASS_SCHEMA;
|
|
||||||
}
|
|
||||||
|
|
||||||
elog(ERROR, "unrecognized object class: %u", object->classId);
|
elog(ERROR, "unrecognized object class: %u", object->classId);
|
||||||
return OCLASS_CLASS; /* keep compiler quiet */
|
return OCLASS_CLASS; /* keep compiler quiet */
|
||||||
}
|
}
|
||||||
@ -1449,14 +1412,14 @@ getObjectDescription(const ObjectAddress *object)
|
|||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Form_pg_cast castForm;
|
Form_pg_cast castForm;
|
||||||
|
|
||||||
castDesc = heap_openr(CastRelationName, AccessShareLock);
|
castDesc = heap_open(CastRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&skey[0],
|
ScanKeyInit(&skey[0],
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(object->objectId));
|
ObjectIdGetDatum(object->objectId));
|
||||||
|
|
||||||
rcscan = systable_beginscan(castDesc, CastOidIndex, true,
|
rcscan = systable_beginscan(castDesc, CastOidIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
tup = systable_getnext(rcscan);
|
tup = systable_getnext(rcscan);
|
||||||
@ -1484,14 +1447,14 @@ getObjectDescription(const ObjectAddress *object)
|
|||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Form_pg_constraint con;
|
Form_pg_constraint con;
|
||||||
|
|
||||||
conDesc = heap_openr(ConstraintRelationName, AccessShareLock);
|
conDesc = heap_open(ConstraintRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&skey[0],
|
ScanKeyInit(&skey[0],
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(object->objectId));
|
ObjectIdGetDatum(object->objectId));
|
||||||
|
|
||||||
rcscan = systable_beginscan(conDesc, ConstraintOidIndex, true,
|
rcscan = systable_beginscan(conDesc, ConstraintOidIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
tup = systable_getnext(rcscan);
|
tup = systable_getnext(rcscan);
|
||||||
@ -1544,14 +1507,14 @@ getObjectDescription(const ObjectAddress *object)
|
|||||||
Form_pg_attrdef attrdef;
|
Form_pg_attrdef attrdef;
|
||||||
ObjectAddress colobject;
|
ObjectAddress colobject;
|
||||||
|
|
||||||
attrdefDesc = heap_openr(AttrDefaultRelationName, AccessShareLock);
|
attrdefDesc = heap_open(AttrDefaultRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&skey[0],
|
ScanKeyInit(&skey[0],
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(object->objectId));
|
ObjectIdGetDatum(object->objectId));
|
||||||
|
|
||||||
adscan = systable_beginscan(attrdefDesc, AttrDefaultOidIndex,
|
adscan = systable_beginscan(attrdefDesc, AttrDefaultOidIndexId,
|
||||||
true, SnapshotNow, 1, skey);
|
true, SnapshotNow, 1, skey);
|
||||||
|
|
||||||
tup = systable_getnext(adscan);
|
tup = systable_getnext(adscan);
|
||||||
@ -1643,14 +1606,14 @@ getObjectDescription(const ObjectAddress *object)
|
|||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Form_pg_rewrite rule;
|
Form_pg_rewrite rule;
|
||||||
|
|
||||||
ruleDesc = heap_openr(RewriteRelationName, AccessShareLock);
|
ruleDesc = heap_open(RewriteRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&skey[0],
|
ScanKeyInit(&skey[0],
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(object->objectId));
|
ObjectIdGetDatum(object->objectId));
|
||||||
|
|
||||||
rcscan = systable_beginscan(ruleDesc, RewriteOidIndex, true,
|
rcscan = systable_beginscan(ruleDesc, RewriteOidIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
tup = systable_getnext(rcscan);
|
tup = systable_getnext(rcscan);
|
||||||
@ -1678,14 +1641,14 @@ getObjectDescription(const ObjectAddress *object)
|
|||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Form_pg_trigger trig;
|
Form_pg_trigger trig;
|
||||||
|
|
||||||
trigDesc = heap_openr(TriggerRelationName, AccessShareLock);
|
trigDesc = heap_open(TriggerRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&skey[0],
|
ScanKeyInit(&skey[0],
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(object->objectId));
|
ObjectIdGetDatum(object->objectId));
|
||||||
|
|
||||||
tgscan = systable_beginscan(trigDesc, TriggerOidIndex, true,
|
tgscan = systable_beginscan(trigDesc, TriggerOidIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
tup = systable_getnext(tgscan);
|
tup = systable_getnext(tgscan);
|
||||||
|
@ -6,11 +6,12 @@
|
|||||||
# files. These .bki files are used to initialize the postgres template
|
# files. These .bki files are used to initialize the postgres template
|
||||||
# database.
|
# database.
|
||||||
#
|
#
|
||||||
# Copyright (c) 1994, Regents of the University of California
|
# Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
|
# Portions Copyright (c) 1994, Regents of the University of California
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# IDENTIFICATION
|
# IDENTIFICATION
|
||||||
# $PostgreSQL: pgsql/src/backend/catalog/genbki.sh,v 1.35 2005/04/14 01:38:16 tgl Exp $
|
# $PostgreSQL: pgsql/src/backend/catalog/genbki.sh,v 1.36 2005/04/14 20:03:23 tgl Exp $
|
||||||
#
|
#
|
||||||
# NOTES
|
# NOTES
|
||||||
# non-essential whitespace is removed from the generated file.
|
# non-essential whitespace is removed from the generated file.
|
||||||
@ -230,10 +231,10 @@ comment_level > 0 { next; }
|
|||||||
iname = substr(data, 1, pos-1);
|
iname = substr(data, 1, pos-1);
|
||||||
data = substr(data, pos+1, length(data)-pos);
|
data = substr(data, pos+1, length(data)-pos);
|
||||||
pos = index(data, ",");
|
pos = index(data, ",");
|
||||||
ioid = substr(data, 1, pos-1);
|
oid = substr(data, 1, pos-1);
|
||||||
data = substr(data, pos+1, length(data)-pos);
|
data = substr(data, pos+1, length(data)-pos);
|
||||||
|
|
||||||
print "declare index " iname " " ioid " " data
|
print "declare index " iname " " oid " " data
|
||||||
}
|
}
|
||||||
|
|
||||||
/^DECLARE_UNIQUE_INDEX\(/ {
|
/^DECLARE_UNIQUE_INDEX\(/ {
|
||||||
@ -250,10 +251,10 @@ comment_level > 0 { next; }
|
|||||||
iname = substr(data, 1, pos-1);
|
iname = substr(data, 1, pos-1);
|
||||||
data = substr(data, pos+1, length(data)-pos);
|
data = substr(data, pos+1, length(data)-pos);
|
||||||
pos = index(data, ",");
|
pos = index(data, ",");
|
||||||
ioid = substr(data, 1, pos-1);
|
oid = substr(data, 1, pos-1);
|
||||||
data = substr(data, pos+1, length(data)-pos);
|
data = substr(data, pos+1, length(data)-pos);
|
||||||
|
|
||||||
print "declare unique index " iname " " ioid " " data
|
print "declare unique index " iname " " oid " " data
|
||||||
}
|
}
|
||||||
|
|
||||||
/^BUILD_INDICES/ { print "build indices"; }
|
/^BUILD_INDICES/ { print "build indices"; }
|
||||||
@ -277,7 +278,7 @@ comment_level > 0 { next; }
|
|||||||
catalogandoid = substr($1,9,pos-9);
|
catalogandoid = substr($1,9,pos-9);
|
||||||
pos = index(catalogandoid, ",");
|
pos = index(catalogandoid, ",");
|
||||||
catalog = substr(catalogandoid, 1, pos-1);
|
catalog = substr(catalogandoid, 1, pos-1);
|
||||||
catalogoid = substr(catalogandoid, pos+1, length(catalogandoid)-pos);
|
oid = substr(catalogandoid, pos+1, length(catalogandoid)-pos);
|
||||||
|
|
||||||
if ($0 ~ /BKI_BOOTSTRAP/) {
|
if ($0 ~ /BKI_BOOTSTRAP/) {
|
||||||
bootstrap = "bootstrap ";
|
bootstrap = "bootstrap ";
|
||||||
@ -296,7 +297,7 @@ comment_level > 0 { next; }
|
|||||||
}
|
}
|
||||||
|
|
||||||
# ----------------
|
# ----------------
|
||||||
# process the contents of the catalog definition
|
# process the columns of the catalog definition
|
||||||
#
|
#
|
||||||
# attname[ x ] contains the attribute name for attribute x
|
# attname[ x ] contains the attribute name for attribute x
|
||||||
# atttype[ x ] contains the attribute type fot attribute x
|
# atttype[ x ] contains the attribute type fot attribute x
|
||||||
@ -312,7 +313,7 @@ inside == 1 {
|
|||||||
# if this is the last line, then output the bki catalog stuff.
|
# if this is the last line, then output the bki catalog stuff.
|
||||||
# ----
|
# ----
|
||||||
if ($1 ~ /}/) {
|
if ($1 ~ /}/) {
|
||||||
print "create " bootstrap shared_relation without_oids catalog " " catalogoid;
|
print "create " bootstrap shared_relation without_oids catalog " " oid;
|
||||||
print "\t(";
|
print "\t(";
|
||||||
|
|
||||||
for (j=1; j<i-1; j++) {
|
for (j=1; j<i-1; j++) {
|
||||||
@ -335,7 +336,7 @@ inside == 1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# ----
|
# ----
|
||||||
# if we are inside the catalog definition, then keep sucking up
|
# we are inside the catalog definition, so keep sucking up
|
||||||
# attribute names and types
|
# attribute names and types
|
||||||
# ----
|
# ----
|
||||||
if ($2 ~ /\[.*\]/) { # array attribute
|
if ($2 ~ /\[.*\]/) { # array attribute
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.283 2005/04/14 01:38:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.284 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
@ -32,7 +32,6 @@
|
|||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/heap.h"
|
#include "catalog/heap.h"
|
||||||
#include "catalog/index.h"
|
#include "catalog/index.h"
|
||||||
@ -40,6 +39,7 @@
|
|||||||
#include "catalog/pg_attrdef.h"
|
#include "catalog/pg_attrdef.h"
|
||||||
#include "catalog/pg_constraint.h"
|
#include "catalog/pg_constraint.h"
|
||||||
#include "catalog/pg_inherits.h"
|
#include "catalog/pg_inherits.h"
|
||||||
|
#include "catalog/pg_namespace.h"
|
||||||
#include "catalog/pg_statistic.h"
|
#include "catalog/pg_statistic.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
#include "commands/tablecmds.h"
|
#include "commands/tablecmds.h"
|
||||||
@ -452,7 +452,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
|
|||||||
/*
|
/*
|
||||||
* open pg_attribute and its indexes.
|
* open pg_attribute and its indexes.
|
||||||
*/
|
*/
|
||||||
rel = heap_openr(AttributeRelationName, RowExclusiveLock);
|
rel = heap_open(AttributeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
indstate = CatalogOpenIndexes(rel);
|
indstate = CatalogOpenIndexes(rel);
|
||||||
|
|
||||||
@ -723,7 +723,7 @@ heap_create_with_catalog(const char *relname,
|
|||||||
* is creating the same relation name in parallel but hadn't committed
|
* is creating the same relation name in parallel but hadn't committed
|
||||||
* yet when we checked for a duplicate name above.
|
* yet when we checked for a duplicate name above.
|
||||||
*/
|
*/
|
||||||
pg_class_desc = heap_openr(RelationRelationName, RowExclusiveLock);
|
pg_class_desc = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
AddNewRelationTuple(pg_class_desc,
|
AddNewRelationTuple(pg_class_desc,
|
||||||
new_rel_desc,
|
new_rel_desc,
|
||||||
@ -764,7 +764,7 @@ heap_create_with_catalog(const char *relname,
|
|||||||
myself.classId = RelationRelationId;
|
myself.classId = RelationRelationId;
|
||||||
myself.objectId = new_rel_oid;
|
myself.objectId = new_rel_oid;
|
||||||
myself.objectSubId = 0;
|
myself.objectSubId = 0;
|
||||||
referenced.classId = get_system_catalog_relid(NamespaceRelationName);
|
referenced.classId = NamespaceRelationId;
|
||||||
referenced.objectId = relnamespace;
|
referenced.objectId = relnamespace;
|
||||||
referenced.objectSubId = 0;
|
referenced.objectSubId = 0;
|
||||||
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
||||||
@ -814,14 +814,14 @@ RelationRemoveInheritance(Oid relid)
|
|||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
catalogRelation = heap_openr(InheritsRelationName, RowExclusiveLock);
|
catalogRelation = heap_open(InheritsRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
ScanKeyInit(&key,
|
ScanKeyInit(&key,
|
||||||
Anum_pg_inherits_inhrelid,
|
Anum_pg_inherits_inhrelid,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(relid));
|
ObjectIdGetDatum(relid));
|
||||||
|
|
||||||
scan = systable_beginscan(catalogRelation, InheritsRelidSeqnoIndex, true,
|
scan = systable_beginscan(catalogRelation, InheritsRelidSeqnoIndexId, true,
|
||||||
SnapshotNow, 1, &key);
|
SnapshotNow, 1, &key);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
|
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
|
||||||
@ -846,7 +846,7 @@ DeleteRelationTuple(Oid relid)
|
|||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
/* Grab an appropriate lock on the pg_class relation */
|
/* Grab an appropriate lock on the pg_class relation */
|
||||||
pg_class_desc = heap_openr(RelationRelationName, RowExclusiveLock);
|
pg_class_desc = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tup = SearchSysCache(RELOID,
|
tup = SearchSysCache(RELOID,
|
||||||
ObjectIdGetDatum(relid),
|
ObjectIdGetDatum(relid),
|
||||||
@ -879,7 +879,7 @@ DeleteAttributeTuples(Oid relid)
|
|||||||
HeapTuple atttup;
|
HeapTuple atttup;
|
||||||
|
|
||||||
/* Grab an appropriate lock on the pg_attribute relation */
|
/* Grab an appropriate lock on the pg_attribute relation */
|
||||||
attrel = heap_openr(AttributeRelationName, RowExclusiveLock);
|
attrel = heap_open(AttributeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/* Use the index to scan only attributes of the target relation */
|
/* Use the index to scan only attributes of the target relation */
|
||||||
ScanKeyInit(&key[0],
|
ScanKeyInit(&key[0],
|
||||||
@ -887,7 +887,7 @@ DeleteAttributeTuples(Oid relid)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(relid));
|
ObjectIdGetDatum(relid));
|
||||||
|
|
||||||
scan = systable_beginscan(attrel, AttributeRelidNumIndex, true,
|
scan = systable_beginscan(attrel, AttributeRelidNumIndexId, true,
|
||||||
SnapshotNow, 1, key);
|
SnapshotNow, 1, key);
|
||||||
|
|
||||||
/* Delete all the matching tuples */
|
/* Delete all the matching tuples */
|
||||||
@ -925,7 +925,7 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
|
|||||||
*/
|
*/
|
||||||
rel = relation_open(relid, AccessExclusiveLock);
|
rel = relation_open(relid, AccessExclusiveLock);
|
||||||
|
|
||||||
attr_rel = heap_openr(AttributeRelationName, RowExclusiveLock);
|
attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tuple = SearchSysCacheCopy(ATTNUM,
|
tuple = SearchSysCacheCopy(ATTNUM,
|
||||||
ObjectIdGetDatum(relid),
|
ObjectIdGetDatum(relid),
|
||||||
@ -1010,7 +1010,7 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
|
|||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
attrdef_rel = heap_openr(AttrDefaultRelationName, RowExclusiveLock);
|
attrdef_rel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
ScanKeyInit(&scankeys[0],
|
ScanKeyInit(&scankeys[0],
|
||||||
Anum_pg_attrdef_adrelid,
|
Anum_pg_attrdef_adrelid,
|
||||||
@ -1021,7 +1021,7 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
|
|||||||
BTEqualStrategyNumber, F_INT2EQ,
|
BTEqualStrategyNumber, F_INT2EQ,
|
||||||
Int16GetDatum(attnum));
|
Int16GetDatum(attnum));
|
||||||
|
|
||||||
scan = systable_beginscan(attrdef_rel, AttrDefaultIndex, true,
|
scan = systable_beginscan(attrdef_rel, AttrDefaultIndexId, true,
|
||||||
SnapshotNow, 2, scankeys);
|
SnapshotNow, 2, scankeys);
|
||||||
|
|
||||||
/* There should be at most one matching tuple, but we loop anyway */
|
/* There should be at most one matching tuple, but we loop anyway */
|
||||||
@ -1029,7 +1029,7 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
|
|||||||
{
|
{
|
||||||
ObjectAddress object;
|
ObjectAddress object;
|
||||||
|
|
||||||
object.classId = RelationGetRelid(attrdef_rel);
|
object.classId = AttrDefaultRelationId;
|
||||||
object.objectId = HeapTupleGetOid(tuple);
|
object.objectId = HeapTupleGetOid(tuple);
|
||||||
object.objectSubId = 0;
|
object.objectSubId = 0;
|
||||||
|
|
||||||
@ -1066,7 +1066,7 @@ RemoveAttrDefaultById(Oid attrdefId)
|
|||||||
AttrNumber myattnum;
|
AttrNumber myattnum;
|
||||||
|
|
||||||
/* Grab an appropriate lock on the pg_attrdef relation */
|
/* Grab an appropriate lock on the pg_attrdef relation */
|
||||||
attrdef_rel = heap_openr(AttrDefaultRelationName, RowExclusiveLock);
|
attrdef_rel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/* Find the pg_attrdef tuple */
|
/* Find the pg_attrdef tuple */
|
||||||
ScanKeyInit(&scankeys[0],
|
ScanKeyInit(&scankeys[0],
|
||||||
@ -1074,7 +1074,7 @@ RemoveAttrDefaultById(Oid attrdefId)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(attrdefId));
|
ObjectIdGetDatum(attrdefId));
|
||||||
|
|
||||||
scan = systable_beginscan(attrdef_rel, AttrDefaultOidIndex, true,
|
scan = systable_beginscan(attrdef_rel, AttrDefaultOidIndexId, true,
|
||||||
SnapshotNow, 1, scankeys);
|
SnapshotNow, 1, scankeys);
|
||||||
|
|
||||||
tuple = systable_getnext(scan);
|
tuple = systable_getnext(scan);
|
||||||
@ -1094,7 +1094,7 @@ RemoveAttrDefaultById(Oid attrdefId)
|
|||||||
heap_close(attrdef_rel, RowExclusiveLock);
|
heap_close(attrdef_rel, RowExclusiveLock);
|
||||||
|
|
||||||
/* Fix the pg_attribute row */
|
/* Fix the pg_attribute row */
|
||||||
attr_rel = heap_openr(AttributeRelationName, RowExclusiveLock);
|
attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tuple = SearchSysCacheCopy(ATTNUM,
|
tuple = SearchSysCacheCopy(ATTNUM,
|
||||||
ObjectIdGetDatum(myrelid),
|
ObjectIdGetDatum(myrelid),
|
||||||
@ -1236,14 +1236,14 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin)
|
|||||||
values[Anum_pg_attrdef_adsrc - 1] = DirectFunctionCall1(textin,
|
values[Anum_pg_attrdef_adsrc - 1] = DirectFunctionCall1(textin,
|
||||||
CStringGetDatum(adsrc));
|
CStringGetDatum(adsrc));
|
||||||
|
|
||||||
adrel = heap_openr(AttrDefaultRelationName, RowExclusiveLock);
|
adrel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tuple = heap_formtuple(adrel->rd_att, values, nulls);
|
tuple = heap_formtuple(adrel->rd_att, values, nulls);
|
||||||
attrdefOid = simple_heap_insert(adrel, tuple);
|
attrdefOid = simple_heap_insert(adrel, tuple);
|
||||||
|
|
||||||
CatalogUpdateIndexes(adrel, tuple);
|
CatalogUpdateIndexes(adrel, tuple);
|
||||||
|
|
||||||
defobject.classId = RelationGetRelid(adrel);
|
defobject.classId = AttrDefaultRelationId;
|
||||||
defobject.objectId = attrdefOid;
|
defobject.objectId = attrdefOid;
|
||||||
defobject.objectSubId = 0;
|
defobject.objectSubId = 0;
|
||||||
|
|
||||||
@ -1259,7 +1259,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin)
|
|||||||
* Update the pg_attribute entry for the column to show that a default
|
* Update the pg_attribute entry for the column to show that a default
|
||||||
* exists.
|
* exists.
|
||||||
*/
|
*/
|
||||||
attrrel = heap_openr(AttributeRelationName, RowExclusiveLock);
|
attrrel = heap_open(AttributeRelationId, RowExclusiveLock);
|
||||||
atttup = SearchSysCacheCopy(ATTNUM,
|
atttup = SearchSysCacheCopy(ATTNUM,
|
||||||
ObjectIdGetDatum(RelationGetRelid(rel)),
|
ObjectIdGetDatum(RelationGetRelid(rel)),
|
||||||
Int16GetDatum(attnum),
|
Int16GetDatum(attnum),
|
||||||
@ -1666,7 +1666,7 @@ SetRelationNumChecks(Relation rel, int numchecks)
|
|||||||
HeapTuple reltup;
|
HeapTuple reltup;
|
||||||
Form_pg_class relStruct;
|
Form_pg_class relStruct;
|
||||||
|
|
||||||
relrel = heap_openr(RelationRelationName, RowExclusiveLock);
|
relrel = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
reltup = SearchSysCacheCopy(RELOID,
|
reltup = SearchSysCacheCopy(RELOID,
|
||||||
ObjectIdGetDatum(RelationGetRelid(rel)),
|
ObjectIdGetDatum(RelationGetRelid(rel)),
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
@ -1797,7 +1797,7 @@ RemoveRelConstraints(Relation rel, const char *constrName,
|
|||||||
HeapTuple contup;
|
HeapTuple contup;
|
||||||
|
|
||||||
/* Grab an appropriate lock on the pg_constraint relation */
|
/* Grab an appropriate lock on the pg_constraint relation */
|
||||||
conrel = heap_openr(ConstraintRelationName, RowExclusiveLock);
|
conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/* Use the index to scan only constraints of the target relation */
|
/* Use the index to scan only constraints of the target relation */
|
||||||
ScanKeyInit(&key[0],
|
ScanKeyInit(&key[0],
|
||||||
@ -1805,7 +1805,7 @@ RemoveRelConstraints(Relation rel, const char *constrName,
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(RelationGetRelid(rel)));
|
ObjectIdGetDatum(RelationGetRelid(rel)));
|
||||||
|
|
||||||
conscan = systable_beginscan(conrel, ConstraintRelidIndex, true,
|
conscan = systable_beginscan(conrel, ConstraintRelidIndexId, true,
|
||||||
SnapshotNow, 1, key);
|
SnapshotNow, 1, key);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1819,7 +1819,7 @@ RemoveRelConstraints(Relation rel, const char *constrName,
|
|||||||
{
|
{
|
||||||
ObjectAddress conobj;
|
ObjectAddress conobj;
|
||||||
|
|
||||||
conobj.classId = RelationGetRelid(conrel);
|
conobj.classId = ConstraintRelationId;
|
||||||
conobj.objectId = HeapTupleGetOid(contup);
|
conobj.objectId = HeapTupleGetOid(contup);
|
||||||
conobj.objectSubId = 0;
|
conobj.objectSubId = 0;
|
||||||
|
|
||||||
@ -1852,7 +1852,7 @@ RemoveStatistics(Oid relid, AttrNumber attnum)
|
|||||||
int nkeys;
|
int nkeys;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
pgstatistic = heap_openr(StatisticRelationName, RowExclusiveLock);
|
pgstatistic = heap_open(StatisticRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
ScanKeyInit(&key[0],
|
ScanKeyInit(&key[0],
|
||||||
Anum_pg_statistic_starelid,
|
Anum_pg_statistic_starelid,
|
||||||
@ -1870,7 +1870,7 @@ RemoveStatistics(Oid relid, AttrNumber attnum)
|
|||||||
nkeys = 2;
|
nkeys = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
scan = systable_beginscan(pgstatistic, StatisticRelidAttnumIndex, true,
|
scan = systable_beginscan(pgstatistic, StatisticRelidAttnumIndexId, true,
|
||||||
SnapshotNow, nkeys, key);
|
SnapshotNow, nkeys, key);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
|
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
|
||||||
@ -2036,9 +2036,9 @@ heap_truncate_check_FKs(List *relations, bool tempTables)
|
|||||||
* Otherwise, must scan pg_constraint. Right now, it is a seqscan
|
* Otherwise, must scan pg_constraint. Right now, it is a seqscan
|
||||||
* because there is no available index on confrelid.
|
* because there is no available index on confrelid.
|
||||||
*/
|
*/
|
||||||
fkeyRel = heap_openr(ConstraintRelationName, AccessShareLock);
|
fkeyRel = heap_open(ConstraintRelationId, AccessShareLock);
|
||||||
|
|
||||||
fkeyScan = systable_beginscan(fkeyRel, NULL, false,
|
fkeyScan = systable_beginscan(fkeyRel, InvalidOid, false,
|
||||||
SnapshotNow, 0, NULL);
|
SnapshotNow, 0, NULL);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tuple = systable_getnext(fkeyScan)))
|
while (HeapTupleIsValid(tuple = systable_getnext(fkeyScan)))
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.251 2005/04/14 01:38:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.252 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
@ -27,7 +27,6 @@
|
|||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "bootstrap/bootstrap.h"
|
#include "bootstrap/bootstrap.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/heap.h"
|
#include "catalog/heap.h"
|
||||||
#include "catalog/index.h"
|
#include "catalog/index.h"
|
||||||
@ -245,7 +244,7 @@ UpdateRelationRelation(Relation indexRelation)
|
|||||||
Relation pg_class;
|
Relation pg_class;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
pg_class = heap_openr(RelationRelationName, RowExclusiveLock);
|
pg_class = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/* XXX Natts_pg_class_fixed is a hack - see pg_class.h */
|
/* XXX Natts_pg_class_fixed is a hack - see pg_class.h */
|
||||||
tuple = heap_addheader(Natts_pg_class_fixed,
|
tuple = heap_addheader(Natts_pg_class_fixed,
|
||||||
@ -301,7 +300,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
|
|||||||
/*
|
/*
|
||||||
* open the attribute relation and its indexes
|
* open the attribute relation and its indexes
|
||||||
*/
|
*/
|
||||||
pg_attribute = heap_openr(AttributeRelationName, RowExclusiveLock);
|
pg_attribute = heap_open(AttributeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
indstate = CatalogOpenIndexes(pg_attribute);
|
indstate = CatalogOpenIndexes(pg_attribute);
|
||||||
|
|
||||||
@ -400,7 +399,7 @@ UpdateIndexRelation(Oid indexoid,
|
|||||||
/*
|
/*
|
||||||
* open the system catalog index relation
|
* open the system catalog index relation
|
||||||
*/
|
*/
|
||||||
pg_index = heap_openr(IndexRelationName, RowExclusiveLock);
|
pg_index = heap_open(IndexRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Build a pg_index tuple
|
* Build a pg_index tuple
|
||||||
@ -649,7 +648,7 @@ index_create(Oid heapRelationId,
|
|||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
referenced.classId = get_system_catalog_relid(ConstraintRelationName);
|
referenced.classId = ConstraintRelationId;
|
||||||
referenced.objectId = conOid;
|
referenced.objectId = conOid;
|
||||||
referenced.objectSubId = 0;
|
referenced.objectSubId = 0;
|
||||||
|
|
||||||
@ -672,9 +671,9 @@ index_create(Oid heapRelationId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Store dependency on operator classes */
|
/* Store dependency on operator classes */
|
||||||
referenced.classId = get_system_catalog_relid(OperatorClassRelationName);
|
|
||||||
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
|
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
|
||||||
{
|
{
|
||||||
|
referenced.classId = OperatorClassRelationId;
|
||||||
referenced.objectId = classObjectId[i];
|
referenced.objectId = classObjectId[i];
|
||||||
referenced.objectSubId = 0;
|
referenced.objectSubId = 0;
|
||||||
|
|
||||||
@ -797,7 +796,7 @@ index_drop(Oid indexId)
|
|||||||
/*
|
/*
|
||||||
* fix INDEX relation, and check for expressional index
|
* fix INDEX relation, and check for expressional index
|
||||||
*/
|
*/
|
||||||
indexRelation = heap_openr(IndexRelationName, RowExclusiveLock);
|
indexRelation = heap_open(IndexRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tuple = SearchSysCache(INDEXRELID,
|
tuple = SearchSysCache(INDEXRELID,
|
||||||
ObjectIdGetDatum(indexId),
|
ObjectIdGetDatum(indexId),
|
||||||
@ -997,7 +996,7 @@ setRelhasindex(Oid relid, bool hasindex, bool isprimary, Oid reltoastidxid)
|
|||||||
* use heap_update, so cheat and overwrite the tuple in-place. In
|
* use heap_update, so cheat and overwrite the tuple in-place. In
|
||||||
* normal processing, make a copy to scribble on.
|
* normal processing, make a copy to scribble on.
|
||||||
*/
|
*/
|
||||||
pg_class = heap_openr(RelationRelationName, RowExclusiveLock);
|
pg_class = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
if (!IsBootstrapProcessingMode())
|
if (!IsBootstrapProcessingMode())
|
||||||
{
|
{
|
||||||
@ -1110,7 +1109,7 @@ setNewRelfilenode(Relation relation)
|
|||||||
* Find the pg_class tuple for the given relation. This is not used
|
* Find the pg_class tuple for the given relation. This is not used
|
||||||
* during bootstrap, so okay to use heap_update always.
|
* during bootstrap, so okay to use heap_update always.
|
||||||
*/
|
*/
|
||||||
pg_class = heap_openr(RelationRelationName, RowExclusiveLock);
|
pg_class = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tuple = SearchSysCacheCopy(RELOID,
|
tuple = SearchSysCacheCopy(RELOID,
|
||||||
ObjectIdGetDatum(RelationGetRelid(relation)),
|
ObjectIdGetDatum(RelationGetRelid(relation)),
|
||||||
@ -1202,10 +1201,10 @@ UpdateStats(Oid relid, double reltuples)
|
|||||||
* case the stats updates will not be WAL-logged and so could be lost
|
* case the stats updates will not be WAL-logged and so could be lost
|
||||||
* in a crash. This seems OK considering VACUUM does the same thing.
|
* in a crash. This seems OK considering VACUUM does the same thing.
|
||||||
*/
|
*/
|
||||||
pg_class = heap_openr(RelationRelationName, RowExclusiveLock);
|
pg_class = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
in_place_upd = IsBootstrapProcessingMode() ||
|
in_place_upd = IsBootstrapProcessingMode() ||
|
||||||
ReindexIsProcessingHeap(RelationGetRelid(pg_class));
|
ReindexIsProcessingHeap(RelationRelationId);
|
||||||
|
|
||||||
if (!in_place_upd)
|
if (!in_place_upd)
|
||||||
{
|
{
|
||||||
|
@ -13,14 +13,13 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.74 2005/03/29 00:16:56 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.75 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "access/xact.h"
|
#include "access/xact.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
#include "catalog/pg_conversion.h"
|
#include "catalog/pg_conversion.h"
|
||||||
@ -1783,7 +1782,7 @@ RemoveTempRelations(Oid tempNamespaceId)
|
|||||||
* be a waste of cycles). We do this by finding everything that has a
|
* be a waste of cycles). We do this by finding everything that has a
|
||||||
* dependency on the namespace.
|
* dependency on the namespace.
|
||||||
*/
|
*/
|
||||||
object.classId = get_system_catalog_relid(NamespaceRelationName);
|
object.classId = NamespaceRelationId;
|
||||||
object.objectId = tempNamespaceId;
|
object.objectId = tempNamespaceId;
|
||||||
object.objectSubId = 0;
|
object.objectSubId = 0;
|
||||||
|
|
||||||
|
@ -8,19 +8,19 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_aggregate.c,v 1.74 2005/04/14 01:38:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/pg_aggregate.c,v 1.75 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
#include "catalog/pg_aggregate.h"
|
#include "catalog/pg_aggregate.h"
|
||||||
#include "catalog/pg_language.h"
|
#include "catalog/pg_language.h"
|
||||||
|
#include "catalog/pg_operator.h"
|
||||||
#include "catalog/pg_proc.h"
|
#include "catalog/pg_proc.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
#include "optimizer/cost.h"
|
#include "optimizer/cost.h"
|
||||||
@ -224,7 +224,7 @@ AggregateCreate(const char *aggName,
|
|||||||
else
|
else
|
||||||
nulls[Anum_pg_aggregate_agginitval - 1] = 'n';
|
nulls[Anum_pg_aggregate_agginitval - 1] = 'n';
|
||||||
|
|
||||||
aggdesc = heap_openr(AggregateRelationName, RowExclusiveLock);
|
aggdesc = heap_open(AggregateRelationId, RowExclusiveLock);
|
||||||
tupDesc = aggdesc->rd_att;
|
tupDesc = aggdesc->rd_att;
|
||||||
|
|
||||||
tup = heap_formtuple(tupDesc, values, nulls);
|
tup = heap_formtuple(tupDesc, values, nulls);
|
||||||
@ -262,7 +262,7 @@ AggregateCreate(const char *aggName,
|
|||||||
/* Depends on sort operator, if any */
|
/* Depends on sort operator, if any */
|
||||||
if (OidIsValid(sortop))
|
if (OidIsValid(sortop))
|
||||||
{
|
{
|
||||||
referenced.classId = get_system_catalog_relid(OperatorRelationName);
|
referenced.classId = OperatorRelationId;
|
||||||
referenced.objectId = sortop;
|
referenced.objectId = sortop;
|
||||||
referenced.objectSubId = 0;
|
referenced.objectSubId = 0;
|
||||||
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_constraint.c,v 1.24 2005/04/14 01:38:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/pg_constraint.c,v 1.25 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -17,11 +17,11 @@
|
|||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/pg_constraint.h"
|
#include "catalog/pg_constraint.h"
|
||||||
#include "catalog/pg_depend.h"
|
#include "catalog/pg_depend.h"
|
||||||
|
#include "catalog/pg_trigger.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
#include "commands/defrem.h"
|
#include "commands/defrem.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
@ -72,7 +72,7 @@ CreateConstraintEntry(const char *constraintName,
|
|||||||
int i;
|
int i;
|
||||||
ObjectAddress conobject;
|
ObjectAddress conobject;
|
||||||
|
|
||||||
conDesc = heap_openr(ConstraintRelationName, RowExclusiveLock);
|
conDesc = heap_open(ConstraintRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
Assert(constraintName);
|
Assert(constraintName);
|
||||||
namestrcpy(&cname, constraintName);
|
namestrcpy(&cname, constraintName);
|
||||||
@ -160,7 +160,7 @@ CreateConstraintEntry(const char *constraintName,
|
|||||||
/* update catalog indexes */
|
/* update catalog indexes */
|
||||||
CatalogUpdateIndexes(conDesc, tup);
|
CatalogUpdateIndexes(conDesc, tup);
|
||||||
|
|
||||||
conobject.classId = RelationGetRelid(conDesc);
|
conobject.classId = ConstraintRelationId;
|
||||||
conobject.objectId = conOid;
|
conobject.objectId = conOid;
|
||||||
conobject.objectSubId = 0;
|
conobject.objectSubId = 0;
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId,
|
|||||||
ScanKeyData skey[2];
|
ScanKeyData skey[2];
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
conDesc = heap_openr(ConstraintRelationName, AccessShareLock);
|
conDesc = heap_open(ConstraintRelationId, AccessShareLock);
|
||||||
|
|
||||||
found = false;
|
found = false;
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId,
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(objNamespace));
|
ObjectIdGetDatum(objNamespace));
|
||||||
|
|
||||||
conscan = systable_beginscan(conDesc, ConstraintNameNspIndex, true,
|
conscan = systable_beginscan(conDesc, ConstraintNameNspIndexId, true,
|
||||||
SnapshotNow, 2, skey);
|
SnapshotNow, 2, skey);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tup = systable_getnext(conscan)))
|
while (HeapTupleIsValid(tup = systable_getnext(conscan)))
|
||||||
@ -362,7 +362,7 @@ ChooseConstraintName(const char *name1, const char *name2,
|
|||||||
bool found;
|
bool found;
|
||||||
ListCell *l;
|
ListCell *l;
|
||||||
|
|
||||||
conDesc = heap_openr(ConstraintRelationName, AccessShareLock);
|
conDesc = heap_open(ConstraintRelationId, AccessShareLock);
|
||||||
|
|
||||||
/* try the unmodified label first */
|
/* try the unmodified label first */
|
||||||
StrNCpy(modlabel, label, sizeof(modlabel));
|
StrNCpy(modlabel, label, sizeof(modlabel));
|
||||||
@ -394,7 +394,7 @@ ChooseConstraintName(const char *name1, const char *name2,
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(namespace));
|
ObjectIdGetDatum(namespace));
|
||||||
|
|
||||||
conscan = systable_beginscan(conDesc, ConstraintNameNspIndex, true,
|
conscan = systable_beginscan(conDesc, ConstraintNameNspIndexId, true,
|
||||||
SnapshotNow, 2, skey);
|
SnapshotNow, 2, skey);
|
||||||
|
|
||||||
found = (HeapTupleIsValid(systable_getnext(conscan)));
|
found = (HeapTupleIsValid(systable_getnext(conscan)));
|
||||||
@ -427,14 +427,14 @@ RemoveConstraintById(Oid conId)
|
|||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Form_pg_constraint con;
|
Form_pg_constraint con;
|
||||||
|
|
||||||
conDesc = heap_openr(ConstraintRelationName, RowExclusiveLock);
|
conDesc = heap_open(ConstraintRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
ScanKeyInit(&skey[0],
|
ScanKeyInit(&skey[0],
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(conId));
|
ObjectIdGetDatum(conId));
|
||||||
|
|
||||||
conscan = systable_beginscan(conDesc, ConstraintOidIndex, true,
|
conscan = systable_beginscan(conDesc, ConstraintOidIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
tup = systable_getnext(conscan);
|
tup = systable_getnext(conscan);
|
||||||
@ -466,7 +466,7 @@ RemoveConstraintById(Oid conId)
|
|||||||
HeapTuple relTup;
|
HeapTuple relTup;
|
||||||
Form_pg_class classForm;
|
Form_pg_class classForm;
|
||||||
|
|
||||||
pgrel = heap_openr(RelationRelationName, RowExclusiveLock);
|
pgrel = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
relTup = SearchSysCacheCopy(RELOID,
|
relTup = SearchSysCacheCopy(RELOID,
|
||||||
ObjectIdGetDatum(con->conrelid),
|
ObjectIdGetDatum(con->conrelid),
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
@ -524,42 +524,37 @@ GetConstraintNameForTrigger(Oid triggerId)
|
|||||||
{
|
{
|
||||||
char *result;
|
char *result;
|
||||||
Oid constraintId = InvalidOid;
|
Oid constraintId = InvalidOid;
|
||||||
Oid pg_trigger_id;
|
|
||||||
Oid pg_constraint_id;
|
|
||||||
Relation depRel;
|
Relation depRel;
|
||||||
Relation conRel;
|
Relation conRel;
|
||||||
ScanKeyData key[2];
|
ScanKeyData key[2];
|
||||||
SysScanDesc scan;
|
SysScanDesc scan;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
pg_trigger_id = get_system_catalog_relid(TriggerRelationName);
|
|
||||||
pg_constraint_id = get_system_catalog_relid(ConstraintRelationName);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We must grovel through pg_depend to find the owning constraint.
|
* We must grovel through pg_depend to find the owning constraint.
|
||||||
* Perhaps pg_trigger should have a column for the owning constraint ...
|
* Perhaps pg_trigger should have a column for the owning constraint ...
|
||||||
* but right now this is not performance-critical code.
|
* but right now this is not performance-critical code.
|
||||||
*/
|
*/
|
||||||
depRel = heap_openr(DependRelationName, AccessShareLock);
|
depRel = heap_open(DependRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&key[0],
|
ScanKeyInit(&key[0],
|
||||||
Anum_pg_depend_classid,
|
Anum_pg_depend_classid,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(pg_trigger_id));
|
ObjectIdGetDatum(TriggerRelationId));
|
||||||
ScanKeyInit(&key[1],
|
ScanKeyInit(&key[1],
|
||||||
Anum_pg_depend_objid,
|
Anum_pg_depend_objid,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(triggerId));
|
ObjectIdGetDatum(triggerId));
|
||||||
/* assume we can ignore objsubid for a trigger */
|
/* assume we can ignore objsubid for a trigger */
|
||||||
|
|
||||||
scan = systable_beginscan(depRel, DependDependerIndex, true,
|
scan = systable_beginscan(depRel, DependDependerIndexId, true,
|
||||||
SnapshotNow, 2, key);
|
SnapshotNow, 2, key);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
||||||
{
|
{
|
||||||
Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup);
|
Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup);
|
||||||
|
|
||||||
if (foundDep->refclassid == pg_constraint_id &&
|
if (foundDep->refclassid == ConstraintRelationId &&
|
||||||
foundDep->deptype == DEPENDENCY_INTERNAL)
|
foundDep->deptype == DEPENDENCY_INTERNAL)
|
||||||
{
|
{
|
||||||
constraintId = foundDep->refobjid;
|
constraintId = foundDep->refobjid;
|
||||||
@ -574,14 +569,14 @@ GetConstraintNameForTrigger(Oid triggerId)
|
|||||||
if (!OidIsValid(constraintId))
|
if (!OidIsValid(constraintId))
|
||||||
return NULL; /* no owning constraint found */
|
return NULL; /* no owning constraint found */
|
||||||
|
|
||||||
conRel = heap_openr(ConstraintRelationName, AccessShareLock);
|
conRel = heap_open(ConstraintRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&key[0],
|
ScanKeyInit(&key[0],
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(constraintId));
|
ObjectIdGetDatum(constraintId));
|
||||||
|
|
||||||
scan = systable_beginscan(conRel, ConstraintOidIndex, true,
|
scan = systable_beginscan(conRel, ConstraintOidIndexId, true,
|
||||||
SnapshotNow, 1, key);
|
SnapshotNow, 1, key);
|
||||||
|
|
||||||
tup = systable_getnext(scan);
|
tup = systable_getnext(scan);
|
||||||
|
@ -8,14 +8,13 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_conversion.c,v 1.21 2005/04/14 01:38:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/pg_conversion.c,v 1.22 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/pg_conversion.h"
|
#include "catalog/pg_conversion.h"
|
||||||
@ -82,7 +81,7 @@ ConversionCreate(const char *conname, Oid connamespace,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* open pg_conversion */
|
/* open pg_conversion */
|
||||||
rel = heap_openr(ConversionRelationName, RowExclusiveLock);
|
rel = heap_open(ConversionRelationId, RowExclusiveLock);
|
||||||
tupDesc = rel->rd_att;
|
tupDesc = rel->rd_att;
|
||||||
|
|
||||||
/* initialize nulls and values */
|
/* initialize nulls and values */
|
||||||
@ -111,7 +110,7 @@ ConversionCreate(const char *conname, Oid connamespace,
|
|||||||
/* update the index if any */
|
/* update the index if any */
|
||||||
CatalogUpdateIndexes(rel, tup);
|
CatalogUpdateIndexes(rel, tup);
|
||||||
|
|
||||||
myself.classId = RelationGetRelid(rel);
|
myself.classId = ConversionRelationId;
|
||||||
myself.objectId = HeapTupleGetOid(tup);
|
myself.objectId = HeapTupleGetOid(tup);
|
||||||
myself.objectSubId = 0;
|
myself.objectSubId = 0;
|
||||||
|
|
||||||
@ -154,7 +153,7 @@ ConversionDrop(Oid conversionOid, DropBehavior behavior)
|
|||||||
/*
|
/*
|
||||||
* Do the deletion
|
* Do the deletion
|
||||||
*/
|
*/
|
||||||
object.classId = get_system_catalog_relid(ConversionRelationName);
|
object.classId = ConversionRelationId;
|
||||||
object.objectId = conversionOid;
|
object.objectId = conversionOid;
|
||||||
object.objectSubId = 0;
|
object.objectSubId = 0;
|
||||||
|
|
||||||
@ -182,7 +181,7 @@ RemoveConversionById(Oid conversionOid)
|
|||||||
ObjectIdGetDatum(conversionOid));
|
ObjectIdGetDatum(conversionOid));
|
||||||
|
|
||||||
/* open pg_conversion */
|
/* open pg_conversion */
|
||||||
rel = heap_openr(ConversionRelationName, RowExclusiveLock);
|
rel = heap_open(ConversionRelationId, RowExclusiveLock);
|
||||||
tupDesc = rel->rd_att;
|
tupDesc = rel->rd_att;
|
||||||
|
|
||||||
scan = heap_beginscan(rel, SnapshotNow,
|
scan = heap_beginscan(rel, SnapshotNow,
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_depend.c,v 1.12 2004/12/31 21:59:38 pgsql Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/pg_depend.c,v 1.13 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/pg_depend.h"
|
#include "catalog/pg_depend.h"
|
||||||
@ -69,7 +68,7 @@ recordMultipleDependencies(const ObjectAddress *depender,
|
|||||||
if (IsBootstrapProcessingMode())
|
if (IsBootstrapProcessingMode())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dependDesc = heap_openr(DependRelationName, RowExclusiveLock);
|
dependDesc = heap_open(DependRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/* Don't open indexes unless we need to make an update */
|
/* Don't open indexes unless we need to make an update */
|
||||||
indstate = NULL;
|
indstate = NULL;
|
||||||
@ -136,7 +135,7 @@ deleteDependencyRecordsFor(Oid classId, Oid objectId)
|
|||||||
SysScanDesc scan;
|
SysScanDesc scan;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
depRel = heap_openr(DependRelationName, RowExclusiveLock);
|
depRel = heap_open(DependRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
ScanKeyInit(&key[0],
|
ScanKeyInit(&key[0],
|
||||||
Anum_pg_depend_classid,
|
Anum_pg_depend_classid,
|
||||||
@ -147,7 +146,7 @@ deleteDependencyRecordsFor(Oid classId, Oid objectId)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(objectId));
|
ObjectIdGetDatum(objectId));
|
||||||
|
|
||||||
scan = systable_beginscan(depRel, DependDependerIndex, true,
|
scan = systable_beginscan(depRel, DependDependerIndexId, true,
|
||||||
SnapshotNow, 2, key);
|
SnapshotNow, 2, key);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
||||||
@ -190,7 +189,7 @@ isObjectPinned(const ObjectAddress *object, Relation rel)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(object->objectId));
|
ObjectIdGetDatum(object->objectId));
|
||||||
|
|
||||||
scan = systable_beginscan(rel, DependReferenceIndex, true,
|
scan = systable_beginscan(rel, DependReferenceIndexId, true,
|
||||||
SnapshotNow, 2, key);
|
SnapshotNow, 2, key);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_largeobject.c,v 1.23 2005/02/23 23:27:54 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/pg_largeobject.c,v 1.24 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/pg_largeobject.h"
|
#include "catalog/pg_largeobject.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
@ -40,7 +39,7 @@ LargeObjectCreate(Oid loid)
|
|||||||
char nulls[Natts_pg_largeobject];
|
char nulls[Natts_pg_largeobject];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
pg_largeobject = heap_openr(LargeObjectRelationName, RowExclusiveLock);
|
pg_largeobject = heap_open(LargeObjectRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Form new tuple
|
* Form new tuple
|
||||||
@ -86,9 +85,9 @@ LargeObjectDrop(Oid loid)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(loid));
|
ObjectIdGetDatum(loid));
|
||||||
|
|
||||||
pg_largeobject = heap_openr(LargeObjectRelationName, RowExclusiveLock);
|
pg_largeobject = heap_open(LargeObjectRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
sd = systable_beginscan(pg_largeobject, LargeObjectLOidPNIndex, true,
|
sd = systable_beginscan(pg_largeobject, LargeObjectLOidPNIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
while ((tuple = systable_getnext(sd)) != NULL)
|
while ((tuple = systable_getnext(sd)) != NULL)
|
||||||
@ -123,9 +122,9 @@ LargeObjectExists(Oid loid)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(loid));
|
ObjectIdGetDatum(loid));
|
||||||
|
|
||||||
pg_largeobject = heap_openr(LargeObjectRelationName, AccessShareLock);
|
pg_largeobject = heap_open(LargeObjectRelationId, AccessShareLock);
|
||||||
|
|
||||||
sd = systable_beginscan(pg_largeobject, LargeObjectLOidPNIndex, true,
|
sd = systable_beginscan(pg_largeobject, LargeObjectLOidPNIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
if (systable_getnext(sd) != NULL)
|
if (systable_getnext(sd) != NULL)
|
||||||
|
@ -8,14 +8,13 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_namespace.c,v 1.12 2004/12/31 21:59:38 pgsql Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/pg_namespace.c,v 1.13 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/pg_namespace.h"
|
#include "catalog/pg_namespace.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
@ -61,7 +60,7 @@ NamespaceCreate(const char *nspName, int32 ownerSysId)
|
|||||||
values[Anum_pg_namespace_nspowner - 1] = Int32GetDatum(ownerSysId);
|
values[Anum_pg_namespace_nspowner - 1] = Int32GetDatum(ownerSysId);
|
||||||
nulls[Anum_pg_namespace_nspacl - 1] = 'n';
|
nulls[Anum_pg_namespace_nspacl - 1] = 'n';
|
||||||
|
|
||||||
nspdesc = heap_openr(NamespaceRelationName, RowExclusiveLock);
|
nspdesc = heap_open(NamespaceRelationId, RowExclusiveLock);
|
||||||
tupDesc = nspdesc->rd_att;
|
tupDesc = nspdesc->rd_att;
|
||||||
|
|
||||||
tup = heap_formtuple(tupDesc, values, nulls);
|
tup = heap_formtuple(tupDesc, values, nulls);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_operator.c,v 1.90 2005/04/14 01:38:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/pg_operator.c,v 1.91 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* these routines moved here from commands/define.c and somewhat cleaned up.
|
* these routines moved here from commands/define.c and somewhat cleaned up.
|
||||||
@ -18,10 +18,10 @@
|
|||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
|
#include "catalog/pg_namespace.h"
|
||||||
#include "catalog/pg_operator.h"
|
#include "catalog/pg_operator.h"
|
||||||
#include "catalog/pg_proc.h"
|
#include "catalog/pg_proc.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
@ -58,7 +58,7 @@ static Oid get_other_operator(List *otherOp,
|
|||||||
Oid leftTypeId, Oid rightTypeId,
|
Oid leftTypeId, Oid rightTypeId,
|
||||||
bool isCommutator);
|
bool isCommutator);
|
||||||
|
|
||||||
static void makeOperatorDependencies(HeapTuple tuple, Oid pg_operator_relid);
|
static void makeOperatorDependencies(HeapTuple tuple);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -254,7 +254,7 @@ OperatorShellMake(const char *operatorName,
|
|||||||
/*
|
/*
|
||||||
* open pg_operator
|
* open pg_operator
|
||||||
*/
|
*/
|
||||||
pg_operator_desc = heap_openr(OperatorRelationName, RowExclusiveLock);
|
pg_operator_desc = heap_open(OperatorRelationId, RowExclusiveLock);
|
||||||
tupDesc = pg_operator_desc->rd_att;
|
tupDesc = pg_operator_desc->rd_att;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -270,7 +270,7 @@ OperatorShellMake(const char *operatorName,
|
|||||||
CatalogUpdateIndexes(pg_operator_desc, tup);
|
CatalogUpdateIndexes(pg_operator_desc, tup);
|
||||||
|
|
||||||
/* Add dependencies for the entry */
|
/* Add dependencies for the entry */
|
||||||
makeOperatorDependencies(tup, RelationGetRelid(pg_operator_desc));
|
makeOperatorDependencies(tup);
|
||||||
|
|
||||||
heap_freetuple(tup);
|
heap_freetuple(tup);
|
||||||
|
|
||||||
@ -620,7 +620,7 @@ OperatorCreate(const char *operatorName,
|
|||||||
values[i++] = ObjectIdGetDatum(restOid); /* oprrest */
|
values[i++] = ObjectIdGetDatum(restOid); /* oprrest */
|
||||||
values[i++] = ObjectIdGetDatum(joinOid); /* oprjoin */
|
values[i++] = ObjectIdGetDatum(joinOid); /* oprjoin */
|
||||||
|
|
||||||
pg_operator_desc = heap_openr(OperatorRelationName, RowExclusiveLock);
|
pg_operator_desc = heap_open(OperatorRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we are adding to an operator shell, update; else insert
|
* If we are adding to an operator shell, update; else insert
|
||||||
@ -654,7 +654,7 @@ OperatorCreate(const char *operatorName,
|
|||||||
CatalogUpdateIndexes(pg_operator_desc, tup);
|
CatalogUpdateIndexes(pg_operator_desc, tup);
|
||||||
|
|
||||||
/* Add dependencies for the entry */
|
/* Add dependencies for the entry */
|
||||||
makeOperatorDependencies(tup, RelationGetRelid(pg_operator_desc));
|
makeOperatorDependencies(tup);
|
||||||
|
|
||||||
heap_close(pg_operator_desc, RowExclusiveLock);
|
heap_close(pg_operator_desc, RowExclusiveLock);
|
||||||
|
|
||||||
@ -773,7 +773,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
|
|||||||
*/
|
*/
|
||||||
CommandCounterIncrement();
|
CommandCounterIncrement();
|
||||||
|
|
||||||
pg_operator_desc = heap_openr(OperatorRelationName, RowExclusiveLock);
|
pg_operator_desc = heap_open(OperatorRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tup = SearchSysCacheCopy(OPEROID,
|
tup = SearchSysCacheCopy(OPEROID,
|
||||||
ObjectIdGetDatum(commId),
|
ObjectIdGetDatum(commId),
|
||||||
@ -877,13 +877,13 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
|
|||||||
* the given operator is a shell.
|
* the given operator is a shell.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
makeOperatorDependencies(HeapTuple tuple, Oid pg_operator_relid)
|
makeOperatorDependencies(HeapTuple tuple)
|
||||||
{
|
{
|
||||||
Form_pg_operator oper = (Form_pg_operator) GETSTRUCT(tuple);
|
Form_pg_operator oper = (Form_pg_operator) GETSTRUCT(tuple);
|
||||||
ObjectAddress myself,
|
ObjectAddress myself,
|
||||||
referenced;
|
referenced;
|
||||||
|
|
||||||
myself.classId = pg_operator_relid;
|
myself.classId = OperatorRelationId;
|
||||||
myself.objectId = HeapTupleGetOid(tuple);
|
myself.objectId = HeapTupleGetOid(tuple);
|
||||||
myself.objectSubId = 0;
|
myself.objectSubId = 0;
|
||||||
|
|
||||||
@ -893,7 +893,7 @@ makeOperatorDependencies(HeapTuple tuple, Oid pg_operator_relid)
|
|||||||
/* Dependency on namespace */
|
/* Dependency on namespace */
|
||||||
if (OidIsValid(oper->oprnamespace))
|
if (OidIsValid(oper->oprnamespace))
|
||||||
{
|
{
|
||||||
referenced.classId = get_system_catalog_relid(NamespaceRelationName);
|
referenced.classId = NamespaceRelationId;
|
||||||
referenced.objectId = oper->oprnamespace;
|
referenced.objectId = oper->oprnamespace;
|
||||||
referenced.objectSubId = 0;
|
referenced.objectSubId = 0;
|
||||||
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
||||||
|
@ -8,16 +8,17 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.127 2005/04/14 01:38:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.128 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
|
#include "catalog/pg_language.h"
|
||||||
|
#include "catalog/pg_namespace.h"
|
||||||
#include "catalog/pg_proc.h"
|
#include "catalog/pg_proc.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
#include "executor/functions.h"
|
#include "executor/functions.h"
|
||||||
@ -226,7 +227,7 @@ ProcedureCreate(const char *procedureName,
|
|||||||
/* start out with empty permissions */
|
/* start out with empty permissions */
|
||||||
nulls[Anum_pg_proc_proacl - 1] = 'n';
|
nulls[Anum_pg_proc_proacl - 1] = 'n';
|
||||||
|
|
||||||
rel = heap_openr(ProcedureRelationName, RowExclusiveLock);
|
rel = heap_open(ProcedureRelationId, RowExclusiveLock);
|
||||||
tupDesc = RelationGetDescr(rel);
|
tupDesc = RelationGetDescr(rel);
|
||||||
|
|
||||||
/* Check for pre-existing definition */
|
/* Check for pre-existing definition */
|
||||||
@ -336,13 +337,13 @@ ProcedureCreate(const char *procedureName,
|
|||||||
myself.objectSubId = 0;
|
myself.objectSubId = 0;
|
||||||
|
|
||||||
/* dependency on namespace */
|
/* dependency on namespace */
|
||||||
referenced.classId = get_system_catalog_relid(NamespaceRelationName);
|
referenced.classId = NamespaceRelationId;
|
||||||
referenced.objectId = procNamespace;
|
referenced.objectId = procNamespace;
|
||||||
referenced.objectSubId = 0;
|
referenced.objectSubId = 0;
|
||||||
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
||||||
|
|
||||||
/* dependency on implementation language */
|
/* dependency on implementation language */
|
||||||
referenced.classId = get_system_catalog_relid(LanguageRelationName);
|
referenced.classId = LanguageRelationId;
|
||||||
referenced.objectId = languageObjectId;
|
referenced.objectId = languageObjectId;
|
||||||
referenced.objectSubId = 0;
|
referenced.objectSubId = 0;
|
||||||
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
||||||
|
@ -8,16 +8,16 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.99 2005/04/14 01:38:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.100 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
|
#include "catalog/pg_namespace.h"
|
||||||
#include "catalog/pg_proc.h"
|
#include "catalog/pg_proc.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
@ -56,7 +56,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace)
|
|||||||
/*
|
/*
|
||||||
* open pg_type
|
* open pg_type
|
||||||
*/
|
*/
|
||||||
pg_type_desc = heap_openr(TypeRelationName, RowExclusiveLock);
|
pg_type_desc = heap_open(TypeRelationId, RowExclusiveLock);
|
||||||
tupDesc = pg_type_desc->rd_att;
|
tupDesc = pg_type_desc->rd_att;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -274,7 +274,7 @@ TypeCreate(const char *typeName,
|
|||||||
* NOTE: updating will not work correctly in bootstrap mode; but we don't
|
* NOTE: updating will not work correctly in bootstrap mode; but we don't
|
||||||
* expect to be overwriting any shell types in bootstrap mode.
|
* expect to be overwriting any shell types in bootstrap mode.
|
||||||
*/
|
*/
|
||||||
pg_type_desc = heap_openr(TypeRelationName, RowExclusiveLock);
|
pg_type_desc = heap_open(TypeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tup = SearchSysCacheCopy(TYPENAMENSP,
|
tup = SearchSysCacheCopy(TYPENAMENSP,
|
||||||
CStringGetDatum(typeName),
|
CStringGetDatum(typeName),
|
||||||
@ -389,7 +389,7 @@ GenerateTypeDependencies(Oid typeNamespace,
|
|||||||
/* skip for relation rowtype, since we have indirect dependency */
|
/* skip for relation rowtype, since we have indirect dependency */
|
||||||
if (!OidIsValid(relationOid))
|
if (!OidIsValid(relationOid))
|
||||||
{
|
{
|
||||||
referenced.classId = get_system_catalog_relid(NamespaceRelationName);
|
referenced.classId = NamespaceRelationId;
|
||||||
referenced.objectId = typeNamespace;
|
referenced.objectId = typeNamespace;
|
||||||
referenced.objectSubId = 0;
|
referenced.objectSubId = 0;
|
||||||
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
||||||
@ -502,7 +502,7 @@ TypeRename(const char *oldTypeName, Oid typeNamespace,
|
|||||||
Relation pg_type_desc;
|
Relation pg_type_desc;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
pg_type_desc = heap_openr(TypeRelationName, RowExclusiveLock);
|
pg_type_desc = heap_open(TypeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tuple = SearchSysCacheCopy(TYPENAMENSP,
|
tuple = SearchSysCacheCopy(TYPENAMENSP,
|
||||||
CStringGetDatum(oldTypeName),
|
CStringGetDatum(oldTypeName),
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.25 2005/04/14 01:38:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.26 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
* DESCRIPTION
|
* DESCRIPTION
|
||||||
* The "DefineFoo" routines take the parse tree and pick out the
|
* The "DefineFoo" routines take the parse tree and pick out the
|
||||||
@ -23,7 +23,6 @@
|
|||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
@ -236,7 +235,7 @@ RenameAggregate(List *name, TypeName *basetype, const char *newname)
|
|||||||
else
|
else
|
||||||
basetypeOid = ANYOID;
|
basetypeOid = ANYOID;
|
||||||
|
|
||||||
rel = heap_openr(ProcedureRelationName, RowExclusiveLock);
|
rel = heap_open(ProcedureRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
procOid = find_aggregate_func(name, basetypeOid, false);
|
procOid = find_aggregate_func(name, basetypeOid, false);
|
||||||
|
|
||||||
@ -315,7 +314,7 @@ AlterAggregateOwner(List *name, TypeName *basetype, AclId newOwnerSysId)
|
|||||||
else
|
else
|
||||||
basetypeOid = ANYOID;
|
basetypeOid = ANYOID;
|
||||||
|
|
||||||
rel = heap_openr(ProcedureRelationName, RowExclusiveLock);
|
rel = heap_open(ProcedureRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
procOid = find_aggregate_func(name, basetypeOid, false);
|
procOid = find_aggregate_func(name, basetypeOid, false);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.84 2005/03/21 01:24:02 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.85 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -19,7 +19,6 @@
|
|||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "access/tuptoaster.h"
|
#include "access/tuptoaster.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/index.h"
|
#include "catalog/index.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
@ -187,8 +186,7 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
|
|||||||
/*
|
/*
|
||||||
* We can ANALYZE any table except pg_statistic. See update_attstats
|
* We can ANALYZE any table except pg_statistic. See update_attstats
|
||||||
*/
|
*/
|
||||||
if (IsSystemNamespace(RelationGetNamespace(onerel)) &&
|
if (RelationGetRelid(onerel) == StatisticRelationId)
|
||||||
strcmp(RelationGetRelationName(onerel), StatisticRelationName) == 0)
|
|
||||||
{
|
{
|
||||||
relation_close(onerel, AccessShareLock);
|
relation_close(onerel, AccessShareLock);
|
||||||
return;
|
return;
|
||||||
@ -1091,7 +1089,7 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats)
|
|||||||
if (natts <= 0)
|
if (natts <= 0)
|
||||||
return; /* nothing to do */
|
return; /* nothing to do */
|
||||||
|
|
||||||
sd = heap_openr(StatisticRelationName, RowExclusiveLock);
|
sd = heap_open(StatisticRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
for (attno = 0; attno < natts; attno++)
|
for (attno = 0; attno < natts; attno++)
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.120 2005/03/20 23:40:24 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.121 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -79,7 +79,6 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/pg_listener.h"
|
#include "catalog/pg_listener.h"
|
||||||
#include "commands/async.h"
|
#include "commands/async.h"
|
||||||
#include "libpq/libpq.h"
|
#include "libpq/libpq.h"
|
||||||
@ -205,7 +204,7 @@ Async_Listen(char *relname, int pid)
|
|||||||
if (Trace_notify)
|
if (Trace_notify)
|
||||||
elog(DEBUG1, "Async_Listen(%s,%d)", relname, pid);
|
elog(DEBUG1, "Async_Listen(%s,%d)", relname, pid);
|
||||||
|
|
||||||
lRel = heap_openr(ListenerRelationName, ExclusiveLock);
|
lRel = heap_open(ListenerRelationId, ExclusiveLock);
|
||||||
|
|
||||||
/* Detect whether we are already listening on this relname */
|
/* Detect whether we are already listening on this relname */
|
||||||
scan = heap_beginscan(lRel, SnapshotNow, 0, NULL);
|
scan = heap_beginscan(lRel, SnapshotNow, 0, NULL);
|
||||||
@ -299,7 +298,7 @@ Async_Unlisten(char *relname, int pid)
|
|||||||
if (Trace_notify)
|
if (Trace_notify)
|
||||||
elog(DEBUG1, "Async_Unlisten(%s,%d)", relname, pid);
|
elog(DEBUG1, "Async_Unlisten(%s,%d)", relname, pid);
|
||||||
|
|
||||||
lRel = heap_openr(ListenerRelationName, ExclusiveLock);
|
lRel = heap_open(ListenerRelationId, ExclusiveLock);
|
||||||
|
|
||||||
scan = heap_beginscan(lRel, SnapshotNow, 0, NULL);
|
scan = heap_beginscan(lRel, SnapshotNow, 0, NULL);
|
||||||
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
||||||
@ -357,7 +356,7 @@ Async_UnlistenAll(void)
|
|||||||
if (Trace_notify)
|
if (Trace_notify)
|
||||||
elog(DEBUG1, "Async_UnlistenAll");
|
elog(DEBUG1, "Async_UnlistenAll");
|
||||||
|
|
||||||
lRel = heap_openr(ListenerRelationName, ExclusiveLock);
|
lRel = heap_open(ListenerRelationId, ExclusiveLock);
|
||||||
tdesc = RelationGetDescr(lRel);
|
tdesc = RelationGetDescr(lRel);
|
||||||
|
|
||||||
/* Find and delete all entries with my listenerPID */
|
/* Find and delete all entries with my listenerPID */
|
||||||
@ -466,7 +465,7 @@ AtCommit_Notify(void)
|
|||||||
value[0] = value[1] = value[2] = (Datum) 0;
|
value[0] = value[1] = value[2] = (Datum) 0;
|
||||||
value[Anum_pg_listener_notify - 1] = Int32GetDatum(MyProcPid);
|
value[Anum_pg_listener_notify - 1] = Int32GetDatum(MyProcPid);
|
||||||
|
|
||||||
lRel = heap_openr(ListenerRelationName, ExclusiveLock);
|
lRel = heap_open(ListenerRelationId, ExclusiveLock);
|
||||||
tdesc = RelationGetDescr(lRel);
|
tdesc = RelationGetDescr(lRel);
|
||||||
scan = heap_beginscan(lRel, SnapshotNow, 0, NULL);
|
scan = heap_beginscan(lRel, SnapshotNow, 0, NULL);
|
||||||
|
|
||||||
@ -902,7 +901,7 @@ ProcessIncomingNotify(void)
|
|||||||
|
|
||||||
StartTransactionCommand();
|
StartTransactionCommand();
|
||||||
|
|
||||||
lRel = heap_openr(ListenerRelationName, ExclusiveLock);
|
lRel = heap_open(ListenerRelationId, ExclusiveLock);
|
||||||
tdesc = RelationGetDescr(lRel);
|
tdesc = RelationGetDescr(lRel);
|
||||||
|
|
||||||
/* Scan only entries with my listenerPID */
|
/* Scan only entries with my listenerPID */
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.135 2005/04/14 01:38:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.136 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -20,7 +20,6 @@
|
|||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/heap.h"
|
#include "catalog/heap.h"
|
||||||
#include "catalog/index.h"
|
#include "catalog/index.h"
|
||||||
@ -434,7 +433,7 @@ mark_index_clustered(Relation rel, Oid indexOid)
|
|||||||
/*
|
/*
|
||||||
* Check each index of the relation and set/clear the bit as needed.
|
* Check each index of the relation and set/clear the bit as needed.
|
||||||
*/
|
*/
|
||||||
pg_index = heap_openr(IndexRelationName, RowExclusiveLock);
|
pg_index = heap_open(IndexRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
foreach(index, RelationGetIndexList(rel))
|
foreach(index, RelationGetIndexList(rel))
|
||||||
{
|
{
|
||||||
@ -719,7 +718,7 @@ swap_relation_files(Oid r1, Oid r2)
|
|||||||
CatalogIndexState indstate;
|
CatalogIndexState indstate;
|
||||||
|
|
||||||
/* We need writable copies of both pg_class tuples. */
|
/* We need writable copies of both pg_class tuples. */
|
||||||
relRelation = heap_openr(RelationRelationName, RowExclusiveLock);
|
relRelation = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
reltup1 = SearchSysCacheCopy(RELOID,
|
reltup1 = SearchSysCacheCopy(RELOID,
|
||||||
ObjectIdGetDatum(r1),
|
ObjectIdGetDatum(r1),
|
||||||
@ -883,7 +882,7 @@ get_tables_to_cluster(MemoryContext cluster_context)
|
|||||||
* ever have indisclustered set, because CLUSTER will refuse to set it
|
* ever have indisclustered set, because CLUSTER will refuse to set it
|
||||||
* when called with one of them as argument.
|
* when called with one of them as argument.
|
||||||
*/
|
*/
|
||||||
indRelation = relation_openr(IndexRelationName, AccessShareLock);
|
indRelation = heap_open(IndexRelationId, AccessShareLock);
|
||||||
ScanKeyInit(&entry,
|
ScanKeyInit(&entry,
|
||||||
Anum_pg_index_indisclustered,
|
Anum_pg_index_indisclustered,
|
||||||
BTEqualStrategyNumber, F_BOOLEQ,
|
BTEqualStrategyNumber, F_BOOLEQ,
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.82 2005/04/14 01:38:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.83 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -16,13 +16,17 @@
|
|||||||
|
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
|
#include "catalog/pg_cast.h"
|
||||||
#include "catalog/pg_constraint.h"
|
#include "catalog/pg_constraint.h"
|
||||||
|
#include "catalog/pg_conversion.h"
|
||||||
#include "catalog/pg_database.h"
|
#include "catalog/pg_database.h"
|
||||||
#include "catalog/pg_description.h"
|
#include "catalog/pg_description.h"
|
||||||
|
#include "catalog/pg_language.h"
|
||||||
#include "catalog/pg_largeobject.h"
|
#include "catalog/pg_largeobject.h"
|
||||||
|
#include "catalog/pg_namespace.h"
|
||||||
|
#include "catalog/pg_opclass.h"
|
||||||
#include "catalog/pg_operator.h"
|
#include "catalog/pg_operator.h"
|
||||||
#include "catalog/pg_proc.h"
|
#include "catalog/pg_proc.h"
|
||||||
#include "catalog/pg_rewrite.h"
|
#include "catalog/pg_rewrite.h"
|
||||||
@ -192,9 +196,9 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
|
|||||||
BTEqualStrategyNumber, F_INT4EQ,
|
BTEqualStrategyNumber, F_INT4EQ,
|
||||||
Int32GetDatum(subid));
|
Int32GetDatum(subid));
|
||||||
|
|
||||||
description = heap_openr(DescriptionRelationName, RowExclusiveLock);
|
description = heap_open(DescriptionRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
sd = systable_beginscan(description, DescriptionObjIndex, true,
|
sd = systable_beginscan(description, DescriptionObjIndexId, true,
|
||||||
SnapshotNow, 3, skey);
|
SnapshotNow, 3, skey);
|
||||||
|
|
||||||
while ((oldtuple = systable_getnext(sd)) != NULL)
|
while ((oldtuple = systable_getnext(sd)) != NULL)
|
||||||
@ -274,9 +278,9 @@ DeleteComments(Oid oid, Oid classoid, int32 subid)
|
|||||||
else
|
else
|
||||||
nkeys = 2;
|
nkeys = 2;
|
||||||
|
|
||||||
description = heap_openr(DescriptionRelationName, RowExclusiveLock);
|
description = heap_open(DescriptionRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
sd = systable_beginscan(description, DescriptionObjIndex, true,
|
sd = systable_beginscan(description, DescriptionObjIndexId, true,
|
||||||
SnapshotNow, nkeys, skey);
|
SnapshotNow, nkeys, skey);
|
||||||
|
|
||||||
while ((oldtuple = systable_getnext(sd)) != NULL)
|
while ((oldtuple = systable_getnext(sd)) != NULL)
|
||||||
@ -353,8 +357,8 @@ CommentRelation(int objtype, List *relname, char *comment)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Create the comment using the relation's oid */
|
/* Create the comment using the relation's oid */
|
||||||
|
CreateComments(RelationGetRelid(relation), RelationRelationId,
|
||||||
CreateComments(RelationGetRelid(relation), RelationRelationId, 0, comment);
|
0, comment);
|
||||||
|
|
||||||
/* Done, but hold lock until commit */
|
/* Done, but hold lock until commit */
|
||||||
relation_close(relation, NoLock);
|
relation_close(relation, NoLock);
|
||||||
@ -407,7 +411,6 @@ CommentAttribute(List *qualname, char *comment)
|
|||||||
attrname, RelationGetRelationName(relation))));
|
attrname, RelationGetRelationName(relation))));
|
||||||
|
|
||||||
/* Create the comment using the relation's oid */
|
/* Create the comment using the relation's oid */
|
||||||
|
|
||||||
CreateComments(RelationGetRelid(relation), RelationRelationId,
|
CreateComments(RelationGetRelid(relation), RelationRelationId,
|
||||||
(int32) attnum, comment);
|
(int32) attnum, comment);
|
||||||
|
|
||||||
@ -476,7 +479,7 @@ CommentDatabase(List *qualname, char *comment)
|
|||||||
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE,
|
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE,
|
||||||
database);
|
database);
|
||||||
|
|
||||||
/* Create the comment with the pg_database oid */
|
/* Call CreateComments() to create/drop the comments */
|
||||||
CreateComments(oid, DatabaseRelationId, 0, comment);
|
CreateComments(oid, DatabaseRelationId, 0, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,7 +496,6 @@ static void
|
|||||||
CommentNamespace(List *qualname, char *comment)
|
CommentNamespace(List *qualname, char *comment)
|
||||||
{
|
{
|
||||||
Oid oid;
|
Oid oid;
|
||||||
Oid classoid;
|
|
||||||
char *namespace;
|
char *namespace;
|
||||||
|
|
||||||
if (list_length(qualname) != 1)
|
if (list_length(qualname) != 1)
|
||||||
@ -515,11 +517,8 @@ CommentNamespace(List *qualname, char *comment)
|
|||||||
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_NAMESPACE,
|
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_NAMESPACE,
|
||||||
namespace);
|
namespace);
|
||||||
|
|
||||||
/* pg_namespace doesn't have a hard-coded OID, so must look it up */
|
|
||||||
classoid = get_system_catalog_relid(NamespaceRelationName);
|
|
||||||
|
|
||||||
/* Call CreateComments() to create/drop the comments */
|
/* Call CreateComments() to create/drop the comments */
|
||||||
CreateComments(oid, classoid, 0, comment);
|
CreateComments(oid, NamespaceRelationId, 0, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -547,7 +546,6 @@ CommentRule(List *qualname, char *comment)
|
|||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
Oid reloid;
|
Oid reloid;
|
||||||
Oid ruleoid;
|
Oid ruleoid;
|
||||||
Oid classoid;
|
|
||||||
AclResult aclcheck;
|
AclResult aclcheck;
|
||||||
|
|
||||||
/* Separate relname and trig name */
|
/* Separate relname and trig name */
|
||||||
@ -567,7 +565,7 @@ CommentRule(List *qualname, char *comment)
|
|||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
PointerGetDatum(rulename));
|
PointerGetDatum(rulename));
|
||||||
|
|
||||||
RewriteRelation = heap_openr(RewriteRelationName, AccessShareLock);
|
RewriteRelation = heap_open(RewriteRelationId, AccessShareLock);
|
||||||
scanDesc = heap_beginscan(RewriteRelation, SnapshotNow,
|
scanDesc = heap_beginscan(RewriteRelation, SnapshotNow,
|
||||||
1, &scanKeyData);
|
1, &scanKeyData);
|
||||||
|
|
||||||
@ -631,11 +629,8 @@ CommentRule(List *qualname, char *comment)
|
|||||||
aclcheck_error(aclcheck, ACL_KIND_CLASS,
|
aclcheck_error(aclcheck, ACL_KIND_CLASS,
|
||||||
get_rel_name(reloid));
|
get_rel_name(reloid));
|
||||||
|
|
||||||
/* pg_rewrite doesn't have a hard-coded OID, so must look it up */
|
|
||||||
classoid = get_system_catalog_relid(RewriteRelationName);
|
|
||||||
|
|
||||||
/* Call CreateComments() to create/drop the comments */
|
/* Call CreateComments() to create/drop the comments */
|
||||||
CreateComments(ruleoid, classoid, 0, comment);
|
CreateComments(ruleoid, RewriteRelationId, 0, comment);
|
||||||
|
|
||||||
heap_close(relation, NoLock);
|
heap_close(relation, NoLock);
|
||||||
}
|
}
|
||||||
@ -671,7 +666,6 @@ CommentType(List *typename, char *comment)
|
|||||||
TypeNameToString(tname));
|
TypeNameToString(tname));
|
||||||
|
|
||||||
/* Call CreateComments() to create/drop the comments */
|
/* Call CreateComments() to create/drop the comments */
|
||||||
|
|
||||||
CreateComments(oid, TypeRelationId, 0, comment);
|
CreateComments(oid, TypeRelationId, 0, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -707,7 +701,6 @@ CommentAggregate(List *aggregate, List *arguments, char *comment)
|
|||||||
NameListToString(aggregate));
|
NameListToString(aggregate));
|
||||||
|
|
||||||
/* Call CreateComments() to create/drop the comments */
|
/* Call CreateComments() to create/drop the comments */
|
||||||
|
|
||||||
CreateComments(oid, ProcedureRelationId, 0, comment);
|
CreateComments(oid, ProcedureRelationId, 0, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -736,7 +729,6 @@ CommentProc(List *function, List *arguments, char *comment)
|
|||||||
NameListToString(function));
|
NameListToString(function));
|
||||||
|
|
||||||
/* Call CreateComments() to create/drop the comments */
|
/* Call CreateComments() to create/drop the comments */
|
||||||
|
|
||||||
CreateComments(oid, ProcedureRelationId, 0, comment);
|
CreateComments(oid, ProcedureRelationId, 0, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -756,7 +748,6 @@ CommentOperator(List *opername, List *arguments, char *comment)
|
|||||||
TypeName *typenode1 = (TypeName *) linitial(arguments);
|
TypeName *typenode1 = (TypeName *) linitial(arguments);
|
||||||
TypeName *typenode2 = (TypeName *) lsecond(arguments);
|
TypeName *typenode2 = (TypeName *) lsecond(arguments);
|
||||||
Oid oid;
|
Oid oid;
|
||||||
Oid classoid;
|
|
||||||
|
|
||||||
/* Look up the operator */
|
/* Look up the operator */
|
||||||
oid = LookupOperNameTypeNames(opername, typenode1, typenode2, false);
|
oid = LookupOperNameTypeNames(opername, typenode1, typenode2, false);
|
||||||
@ -766,11 +757,8 @@ CommentOperator(List *opername, List *arguments, char *comment)
|
|||||||
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPER,
|
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPER,
|
||||||
NameListToString(opername));
|
NameListToString(opername));
|
||||||
|
|
||||||
/* pg_operator doesn't have a hard-coded OID, so must look it up */
|
|
||||||
classoid = get_system_catalog_relid(OperatorRelationName);
|
|
||||||
|
|
||||||
/* Call CreateComments() to create/drop the comments */
|
/* Call CreateComments() to create/drop the comments */
|
||||||
CreateComments(oid, classoid, 0, comment);
|
CreateComments(oid, OperatorRelationId, 0, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -817,7 +805,7 @@ CommentTrigger(List *qualname, char *comment)
|
|||||||
* Fetch the trigger tuple from pg_trigger. There can be only one
|
* Fetch the trigger tuple from pg_trigger. There can be only one
|
||||||
* because of the unique index.
|
* because of the unique index.
|
||||||
*/
|
*/
|
||||||
pg_trigger = heap_openr(TriggerRelationName, AccessShareLock);
|
pg_trigger = heap_open(TriggerRelationId, AccessShareLock);
|
||||||
ScanKeyInit(&entry[0],
|
ScanKeyInit(&entry[0],
|
||||||
Anum_pg_trigger_tgrelid,
|
Anum_pg_trigger_tgrelid,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
@ -826,7 +814,7 @@ CommentTrigger(List *qualname, char *comment)
|
|||||||
Anum_pg_trigger_tgname,
|
Anum_pg_trigger_tgname,
|
||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
CStringGetDatum(trigname));
|
CStringGetDatum(trigname));
|
||||||
scan = systable_beginscan(pg_trigger, TriggerRelidNameIndex, true,
|
scan = systable_beginscan(pg_trigger, TriggerRelidNameIndexId, true,
|
||||||
SnapshotNow, 2, entry);
|
SnapshotNow, 2, entry);
|
||||||
triggertuple = systable_getnext(scan);
|
triggertuple = systable_getnext(scan);
|
||||||
|
|
||||||
@ -842,9 +830,8 @@ CommentTrigger(List *qualname, char *comment)
|
|||||||
|
|
||||||
systable_endscan(scan);
|
systable_endscan(scan);
|
||||||
|
|
||||||
/* Create the comment with the pg_trigger oid */
|
/* Call CreateComments() to create/drop the comments */
|
||||||
|
CreateComments(oid, TriggerRelationId, 0, comment);
|
||||||
CreateComments(oid, RelationGetRelid(pg_trigger), 0, comment);
|
|
||||||
|
|
||||||
/* Done, but hold lock on relation */
|
/* Done, but hold lock on relation */
|
||||||
|
|
||||||
@ -896,14 +883,14 @@ CommentConstraint(List *qualname, char *comment)
|
|||||||
* than one match, because constraints are not required to have unique
|
* than one match, because constraints are not required to have unique
|
||||||
* names; if so, error out.
|
* names; if so, error out.
|
||||||
*/
|
*/
|
||||||
pg_constraint = heap_openr(ConstraintRelationName, AccessShareLock);
|
pg_constraint = heap_open(ConstraintRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&skey[0],
|
ScanKeyInit(&skey[0],
|
||||||
Anum_pg_constraint_conrelid,
|
Anum_pg_constraint_conrelid,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||||
|
|
||||||
scan = systable_beginscan(pg_constraint, ConstraintRelidIndex, true,
|
scan = systable_beginscan(pg_constraint, ConstraintRelidIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
|
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
|
||||||
@ -930,8 +917,8 @@ CommentConstraint(List *qualname, char *comment)
|
|||||||
errmsg("constraint \"%s\" for table \"%s\" does not exist",
|
errmsg("constraint \"%s\" for table \"%s\" does not exist",
|
||||||
conName, RelationGetRelationName(relation))));
|
conName, RelationGetRelationName(relation))));
|
||||||
|
|
||||||
/* Create the comment with the pg_constraint oid */
|
/* Call CreateComments() to create/drop the comments */
|
||||||
CreateComments(conOid, RelationGetRelid(pg_constraint), 0, comment);
|
CreateComments(conOid, ConstraintRelationId, 0, comment);
|
||||||
|
|
||||||
/* Done, but hold lock on relation */
|
/* Done, but hold lock on relation */
|
||||||
heap_close(pg_constraint, AccessShareLock);
|
heap_close(pg_constraint, AccessShareLock);
|
||||||
@ -951,7 +938,6 @@ static void
|
|||||||
CommentConversion(List *qualname, char *comment)
|
CommentConversion(List *qualname, char *comment)
|
||||||
{
|
{
|
||||||
Oid conversionOid;
|
Oid conversionOid;
|
||||||
Oid classoid;
|
|
||||||
|
|
||||||
conversionOid = FindConversionByName(qualname);
|
conversionOid = FindConversionByName(qualname);
|
||||||
if (!OidIsValid(conversionOid))
|
if (!OidIsValid(conversionOid))
|
||||||
@ -965,11 +951,8 @@ CommentConversion(List *qualname, char *comment)
|
|||||||
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CONVERSION,
|
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CONVERSION,
|
||||||
NameListToString(qualname));
|
NameListToString(qualname));
|
||||||
|
|
||||||
/* pg_conversion doesn't have a hard-coded OID, so must look it up */
|
|
||||||
classoid = get_system_catalog_relid(ConversionRelationName);
|
|
||||||
|
|
||||||
/* Call CreateComments() to create/drop the comments */
|
/* Call CreateComments() to create/drop the comments */
|
||||||
CreateComments(conversionOid, classoid, 0, comment);
|
CreateComments(conversionOid, ConversionRelationId, 0, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -985,7 +968,6 @@ static void
|
|||||||
CommentLanguage(List *qualname, char *comment)
|
CommentLanguage(List *qualname, char *comment)
|
||||||
{
|
{
|
||||||
Oid oid;
|
Oid oid;
|
||||||
Oid classoid;
|
|
||||||
char *language;
|
char *language;
|
||||||
|
|
||||||
if (list_length(qualname) != 1)
|
if (list_length(qualname) != 1)
|
||||||
@ -1008,11 +990,8 @@ CommentLanguage(List *qualname, char *comment)
|
|||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
errmsg("must be superuser to comment on procedural language")));
|
errmsg("must be superuser to comment on procedural language")));
|
||||||
|
|
||||||
/* pg_language doesn't have a hard-coded OID, so must look it up */
|
|
||||||
classoid = get_system_catalog_relid(LanguageRelationName);
|
|
||||||
|
|
||||||
/* Call CreateComments() to create/drop the comments */
|
/* Call CreateComments() to create/drop the comments */
|
||||||
CreateComments(oid, classoid, 0, comment);
|
CreateComments(oid, LanguageRelationId, 0, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1032,7 +1011,6 @@ CommentOpClass(List *qualname, List *arguments, char *comment)
|
|||||||
char *opcname;
|
char *opcname;
|
||||||
Oid amID;
|
Oid amID;
|
||||||
Oid opcID;
|
Oid opcID;
|
||||||
Oid classoid;
|
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
Assert(list_length(arguments) == 1);
|
Assert(list_length(arguments) == 1);
|
||||||
@ -1098,11 +1076,8 @@ CommentOpClass(List *qualname, List *arguments, char *comment)
|
|||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
|
|
||||||
/* pg_opclass doesn't have a hard-coded OID, so must look it up */
|
|
||||||
classoid = get_system_catalog_relid(OperatorClassRelationName);
|
|
||||||
|
|
||||||
/* Call CreateComments() to create/drop the comments */
|
/* Call CreateComments() to create/drop the comments */
|
||||||
CreateComments(opcID, classoid, 0, comment);
|
CreateComments(opcID, OperatorClassRelationId, 0, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1118,7 +1093,6 @@ static void
|
|||||||
CommentLargeObject(List *qualname, char *comment)
|
CommentLargeObject(List *qualname, char *comment)
|
||||||
{
|
{
|
||||||
Oid loid;
|
Oid loid;
|
||||||
Oid classoid;
|
|
||||||
Node *node;
|
Node *node;
|
||||||
|
|
||||||
Assert(list_length(qualname) == 1);
|
Assert(list_length(qualname) == 1);
|
||||||
@ -1152,11 +1126,8 @@ CommentLargeObject(List *qualname, char *comment)
|
|||||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||||
errmsg("large object %u does not exist", loid)));
|
errmsg("large object %u does not exist", loid)));
|
||||||
|
|
||||||
/* pg_largeobject doesn't have a hard-coded OID, so must look it up */
|
|
||||||
classoid = get_system_catalog_relid(LargeObjectRelationName);
|
|
||||||
|
|
||||||
/* Call CreateComments() to create/drop the comments */
|
/* Call CreateComments() to create/drop the comments */
|
||||||
CreateComments(loid, classoid, 0, comment);
|
CreateComments(loid, LargeObjectRelationId, 0, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1178,7 +1149,6 @@ CommentCast(List *qualname, List *arguments, char *comment)
|
|||||||
Oid targettypeid;
|
Oid targettypeid;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
Oid castOid;
|
Oid castOid;
|
||||||
Oid classoid;
|
|
||||||
|
|
||||||
Assert(list_length(qualname) == 1);
|
Assert(list_length(qualname) == 1);
|
||||||
sourcetype = (TypeName *) linitial(qualname);
|
sourcetype = (TypeName *) linitial(qualname);
|
||||||
@ -1226,9 +1196,6 @@ CommentCast(List *qualname, List *arguments, char *comment)
|
|||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
|
|
||||||
/* pg_cast doesn't have a hard-coded OID, so must look it up */
|
|
||||||
classoid = get_system_catalog_relid(CastRelationName);
|
|
||||||
|
|
||||||
/* Call CreateComments() to create/drop the comments */
|
/* Call CreateComments() to create/drop the comments */
|
||||||
CreateComments(castOid, classoid, 0, comment);
|
CreateComments(castOid, CastRelationId, 0, comment);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.16 2004/12/31 21:59:41 pgsql Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.17 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -17,7 +17,6 @@
|
|||||||
#include "catalog/pg_conversion.h"
|
#include "catalog/pg_conversion.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
@ -124,7 +123,7 @@ RenameConversion(List *name, const char *newname)
|
|||||||
Relation rel;
|
Relation rel;
|
||||||
AclResult aclresult;
|
AclResult aclresult;
|
||||||
|
|
||||||
rel = heap_openr(ConversionRelationName, RowExclusiveLock);
|
rel = heap_open(ConversionRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
conversionOid = FindConversionByName(name);
|
conversionOid = FindConversionByName(name);
|
||||||
if (!OidIsValid(conversionOid))
|
if (!OidIsValid(conversionOid))
|
||||||
@ -183,7 +182,7 @@ AlterConversionOwner(List *name, AclId newOwnerSysId)
|
|||||||
Relation rel;
|
Relation rel;
|
||||||
Form_pg_conversion convForm;
|
Form_pg_conversion convForm;
|
||||||
|
|
||||||
rel = heap_openr(ConversionRelationName, RowExclusiveLock);
|
rel = heap_open(ConversionRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
conversionOid = FindConversionByName(name);
|
conversionOid = FindConversionByName(name);
|
||||||
if (!OidIsValid(conversionOid))
|
if (!OidIsValid(conversionOid))
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.239 2005/03/25 21:57:57 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.240 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -22,7 +22,6 @@
|
|||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "access/printtup.h"
|
#include "access/printtup.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/index.h"
|
#include "catalog/index.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
#include "catalog/pg_index.h"
|
#include "catalog/pg_index.h"
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.155 2005/03/23 00:03:28 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.156 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/pg_database.h"
|
#include "catalog/pg_database.h"
|
||||||
#include "catalog/pg_shadow.h"
|
#include "catalog/pg_shadow.h"
|
||||||
@ -364,7 +363,7 @@ createdb(const CreatedbStmt *stmt)
|
|||||||
* Iterate through all tablespaces of the template database, and copy
|
* Iterate through all tablespaces of the template database, and copy
|
||||||
* each one to the new database.
|
* each one to the new database.
|
||||||
*/
|
*/
|
||||||
rel = heap_openr(TableSpaceRelationName, AccessShareLock);
|
rel = heap_open(TableSpaceRelationId, AccessShareLock);
|
||||||
scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
|
scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
|
||||||
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
||||||
{
|
{
|
||||||
@ -459,7 +458,7 @@ createdb(const CreatedbStmt *stmt)
|
|||||||
/*
|
/*
|
||||||
* Now OK to grab exclusive lock on pg_database.
|
* Now OK to grab exclusive lock on pg_database.
|
||||||
*/
|
*/
|
||||||
pg_database_rel = heap_openr(DatabaseRelationName, ExclusiveLock);
|
pg_database_rel = heap_open(DatabaseRelationId, ExclusiveLock);
|
||||||
|
|
||||||
/* Check to see if someone else created same DB name meanwhile. */
|
/* Check to see if someone else created same DB name meanwhile. */
|
||||||
if (get_db_info(dbname, NULL, NULL, NULL,
|
if (get_db_info(dbname, NULL, NULL, NULL,
|
||||||
@ -557,7 +556,7 @@ dropdb(const char *dbname)
|
|||||||
* since ReverifyMyDatabase takes RowShareLock. This allows ordinary
|
* since ReverifyMyDatabase takes RowShareLock. This allows ordinary
|
||||||
* readers of pg_database to proceed in parallel.
|
* readers of pg_database to proceed in parallel.
|
||||||
*/
|
*/
|
||||||
pgdbrel = heap_openr(DatabaseRelationName, ExclusiveLock);
|
pgdbrel = heap_open(DatabaseRelationId, ExclusiveLock);
|
||||||
|
|
||||||
if (!get_db_info(dbname, &db_id, &db_owner, NULL,
|
if (!get_db_info(dbname, &db_id, &db_owner, NULL,
|
||||||
&db_istemplate, NULL, NULL, NULL, NULL, NULL))
|
&db_istemplate, NULL, NULL, NULL, NULL, NULL))
|
||||||
@ -596,7 +595,7 @@ dropdb(const char *dbname)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(db_id));
|
ObjectIdGetDatum(db_id));
|
||||||
|
|
||||||
pgdbscan = systable_beginscan(pgdbrel, DatabaseOidIndex, true,
|
pgdbscan = systable_beginscan(pgdbrel, DatabaseOidIndexId, true,
|
||||||
SnapshotNow, 1, &key);
|
SnapshotNow, 1, &key);
|
||||||
|
|
||||||
tup = systable_getnext(pgdbscan);
|
tup = systable_getnext(pgdbscan);
|
||||||
@ -621,7 +620,7 @@ dropdb(const char *dbname)
|
|||||||
* NOTE: this is probably dead code since any such comments should have
|
* NOTE: this is probably dead code since any such comments should have
|
||||||
* been in that database, not mine.
|
* been in that database, not mine.
|
||||||
*/
|
*/
|
||||||
DeleteComments(db_id, RelationGetRelid(pgdbrel), 0);
|
DeleteComments(db_id, DatabaseRelationId, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Drop pages for this database that are in the shared buffer cache.
|
* Drop pages for this database that are in the shared buffer cache.
|
||||||
@ -676,13 +675,13 @@ RenameDatabase(const char *oldname, const char *newname)
|
|||||||
* Obtain ExclusiveLock so that no new session gets started
|
* Obtain ExclusiveLock so that no new session gets started
|
||||||
* while the rename is in progress.
|
* while the rename is in progress.
|
||||||
*/
|
*/
|
||||||
rel = heap_openr(DatabaseRelationName, ExclusiveLock);
|
rel = heap_open(DatabaseRelationId, ExclusiveLock);
|
||||||
|
|
||||||
ScanKeyInit(&key,
|
ScanKeyInit(&key,
|
||||||
Anum_pg_database_datname,
|
Anum_pg_database_datname,
|
||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
NameGetDatum(oldname));
|
NameGetDatum(oldname));
|
||||||
scan = systable_beginscan(rel, DatabaseNameIndex, true,
|
scan = systable_beginscan(rel, DatabaseNameIndexId, true,
|
||||||
SnapshotNow, 1, &key);
|
SnapshotNow, 1, &key);
|
||||||
|
|
||||||
tup = systable_getnext(scan);
|
tup = systable_getnext(scan);
|
||||||
@ -717,7 +716,7 @@ RenameDatabase(const char *oldname, const char *newname)
|
|||||||
Anum_pg_database_datname,
|
Anum_pg_database_datname,
|
||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
NameGetDatum(newname));
|
NameGetDatum(newname));
|
||||||
scan2 = systable_beginscan(rel, DatabaseNameIndex, true,
|
scan2 = systable_beginscan(rel, DatabaseNameIndexId, true,
|
||||||
SnapshotNow, 1, &key2);
|
SnapshotNow, 1, &key2);
|
||||||
if (HeapTupleIsValid(systable_getnext(scan2)))
|
if (HeapTupleIsValid(systable_getnext(scan2)))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -776,12 +775,12 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
|
|||||||
* We don't need ExclusiveLock since we aren't updating the
|
* We don't need ExclusiveLock since we aren't updating the
|
||||||
* flat file.
|
* flat file.
|
||||||
*/
|
*/
|
||||||
rel = heap_openr(DatabaseRelationName, RowExclusiveLock);
|
rel = heap_open(DatabaseRelationId, RowExclusiveLock);
|
||||||
ScanKeyInit(&scankey,
|
ScanKeyInit(&scankey,
|
||||||
Anum_pg_database_datname,
|
Anum_pg_database_datname,
|
||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
NameGetDatum(stmt->dbname));
|
NameGetDatum(stmt->dbname));
|
||||||
scan = systable_beginscan(rel, DatabaseNameIndex, true,
|
scan = systable_beginscan(rel, DatabaseNameIndexId, true,
|
||||||
SnapshotNow, 1, &scankey);
|
SnapshotNow, 1, &scankey);
|
||||||
tuple = systable_getnext(scan);
|
tuple = systable_getnext(scan);
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
@ -861,12 +860,12 @@ AlterDatabaseOwner(const char *dbname, AclId newOwnerSysId)
|
|||||||
* We don't need ExclusiveLock since we aren't updating the
|
* We don't need ExclusiveLock since we aren't updating the
|
||||||
* flat file.
|
* flat file.
|
||||||
*/
|
*/
|
||||||
rel = heap_openr(DatabaseRelationName, RowExclusiveLock);
|
rel = heap_open(DatabaseRelationId, RowExclusiveLock);
|
||||||
ScanKeyInit(&scankey,
|
ScanKeyInit(&scankey,
|
||||||
Anum_pg_database_datname,
|
Anum_pg_database_datname,
|
||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
NameGetDatum(dbname));
|
NameGetDatum(dbname));
|
||||||
scan = systable_beginscan(rel, DatabaseNameIndex, true,
|
scan = systable_beginscan(rel, DatabaseNameIndexId, true,
|
||||||
SnapshotNow, 1, &scankey);
|
SnapshotNow, 1, &scankey);
|
||||||
tuple = systable_getnext(scan);
|
tuple = systable_getnext(scan);
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
@ -958,14 +957,14 @@ get_db_info(const char *name, Oid *dbIdP, int4 *ownerIdP,
|
|||||||
AssertArg(name);
|
AssertArg(name);
|
||||||
|
|
||||||
/* Caller may wish to grab a better lock on pg_database beforehand... */
|
/* Caller may wish to grab a better lock on pg_database beforehand... */
|
||||||
relation = heap_openr(DatabaseRelationName, AccessShareLock);
|
relation = heap_open(DatabaseRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&scanKey,
|
ScanKeyInit(&scanKey,
|
||||||
Anum_pg_database_datname,
|
Anum_pg_database_datname,
|
||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
NameGetDatum(name));
|
NameGetDatum(name));
|
||||||
|
|
||||||
scan = systable_beginscan(relation, DatabaseNameIndex, true,
|
scan = systable_beginscan(relation, DatabaseNameIndexId, true,
|
||||||
SnapshotNow, 1, &scanKey);
|
SnapshotNow, 1, &scanKey);
|
||||||
|
|
||||||
tuple = systable_getnext(scan);
|
tuple = systable_getnext(scan);
|
||||||
@ -1041,7 +1040,7 @@ remove_dbtablespaces(Oid db_id)
|
|||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
rel = heap_openr(TableSpaceRelationName, AccessShareLock);
|
rel = heap_open(TableSpaceRelationId, AccessShareLock);
|
||||||
scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
|
scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
|
||||||
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
||||||
{
|
{
|
||||||
@ -1108,12 +1107,12 @@ get_database_oid(const char *dbname)
|
|||||||
Oid oid;
|
Oid oid;
|
||||||
|
|
||||||
/* There's no syscache for pg_database, so must look the hard way */
|
/* There's no syscache for pg_database, so must look the hard way */
|
||||||
pg_database = heap_openr(DatabaseRelationName, AccessShareLock);
|
pg_database = heap_open(DatabaseRelationId, AccessShareLock);
|
||||||
ScanKeyInit(&entry[0],
|
ScanKeyInit(&entry[0],
|
||||||
Anum_pg_database_datname,
|
Anum_pg_database_datname,
|
||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
CStringGetDatum(dbname));
|
CStringGetDatum(dbname));
|
||||||
scan = systable_beginscan(pg_database, DatabaseNameIndex, true,
|
scan = systable_beginscan(pg_database, DatabaseNameIndexId, true,
|
||||||
SnapshotNow, 1, entry);
|
SnapshotNow, 1, entry);
|
||||||
|
|
||||||
dbtuple = systable_getnext(scan);
|
dbtuple = systable_getnext(scan);
|
||||||
@ -1148,12 +1147,12 @@ get_database_name(Oid dbid)
|
|||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
/* There's no syscache for pg_database, so must look the hard way */
|
/* There's no syscache for pg_database, so must look the hard way */
|
||||||
pg_database = heap_openr(DatabaseRelationName, AccessShareLock);
|
pg_database = heap_open(DatabaseRelationId, AccessShareLock);
|
||||||
ScanKeyInit(&entry[0],
|
ScanKeyInit(&entry[0],
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(dbid));
|
ObjectIdGetDatum(dbid));
|
||||||
scan = systable_beginscan(pg_database, DatabaseOidIndex, true,
|
scan = systable_beginscan(pg_database, DatabaseOidIndexId, true,
|
||||||
SnapshotNow, 1, entry);
|
SnapshotNow, 1, entry);
|
||||||
|
|
||||||
dbtuple = systable_getnext(scan);
|
dbtuple = systable_getnext(scan);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.60 2005/04/14 01:38:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.61 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
* DESCRIPTION
|
* DESCRIPTION
|
||||||
* These routines take the parse tree and pick out the
|
* These routines take the parse tree and pick out the
|
||||||
@ -34,10 +34,10 @@
|
|||||||
|
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
|
#include "catalog/pg_aggregate.h"
|
||||||
#include "catalog/pg_cast.h"
|
#include "catalog/pg_cast.h"
|
||||||
#include "catalog/pg_language.h"
|
#include "catalog/pg_language.h"
|
||||||
#include "catalog/pg_proc.h"
|
#include "catalog/pg_proc.h"
|
||||||
@ -742,7 +742,7 @@ RemoveFunctionById(Oid funcOid)
|
|||||||
/*
|
/*
|
||||||
* Delete the pg_proc tuple.
|
* Delete the pg_proc tuple.
|
||||||
*/
|
*/
|
||||||
relation = heap_openr(ProcedureRelationName, RowExclusiveLock);
|
relation = heap_open(ProcedureRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tup = SearchSysCache(PROCOID,
|
tup = SearchSysCache(PROCOID,
|
||||||
ObjectIdGetDatum(funcOid),
|
ObjectIdGetDatum(funcOid),
|
||||||
@ -763,7 +763,7 @@ RemoveFunctionById(Oid funcOid)
|
|||||||
*/
|
*/
|
||||||
if (isagg)
|
if (isagg)
|
||||||
{
|
{
|
||||||
relation = heap_openr(AggregateRelationName, RowExclusiveLock);
|
relation = heap_open(AggregateRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tup = SearchSysCache(AGGFNOID,
|
tup = SearchSysCache(AGGFNOID,
|
||||||
ObjectIdGetDatum(funcOid),
|
ObjectIdGetDatum(funcOid),
|
||||||
@ -793,7 +793,7 @@ RenameFunction(List *name, List *argtypes, const char *newname)
|
|||||||
Relation rel;
|
Relation rel;
|
||||||
AclResult aclresult;
|
AclResult aclresult;
|
||||||
|
|
||||||
rel = heap_openr(ProcedureRelationName, RowExclusiveLock);
|
rel = heap_open(ProcedureRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
procOid = LookupFuncNameTypeNames(name, argtypes, false);
|
procOid = LookupFuncNameTypeNames(name, argtypes, false);
|
||||||
|
|
||||||
@ -860,7 +860,7 @@ AlterFunctionOwner(List *name, List *argtypes, AclId newOwnerSysId)
|
|||||||
Form_pg_proc procForm;
|
Form_pg_proc procForm;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
|
|
||||||
rel = heap_openr(ProcedureRelationName, RowExclusiveLock);
|
rel = heap_open(ProcedureRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
procOid = LookupFuncNameTypeNames(name, argtypes, false);
|
procOid = LookupFuncNameTypeNames(name, argtypes, false);
|
||||||
|
|
||||||
@ -948,7 +948,7 @@ AlterFunction(AlterFunctionStmt *stmt)
|
|||||||
DefElem *strict_item = NULL;
|
DefElem *strict_item = NULL;
|
||||||
DefElem *security_def_item = NULL;
|
DefElem *security_def_item = NULL;
|
||||||
|
|
||||||
rel = heap_openr(ProcedureRelationName, RowExclusiveLock);
|
rel = heap_open(ProcedureRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
funcOid = LookupFuncNameTypeNames(stmt->func->funcname,
|
funcOid = LookupFuncNameTypeNames(stmt->func->funcname,
|
||||||
stmt->func->funcargs,
|
stmt->func->funcargs,
|
||||||
@ -1014,7 +1014,7 @@ SetFunctionReturnType(Oid funcOid, Oid newRetType)
|
|||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Form_pg_proc procForm;
|
Form_pg_proc procForm;
|
||||||
|
|
||||||
pg_proc_rel = heap_openr(ProcedureRelationName, RowExclusiveLock);
|
pg_proc_rel = heap_open(ProcedureRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tup = SearchSysCacheCopy(PROCOID,
|
tup = SearchSysCacheCopy(PROCOID,
|
||||||
ObjectIdGetDatum(funcOid),
|
ObjectIdGetDatum(funcOid),
|
||||||
@ -1050,7 +1050,7 @@ SetFunctionArgType(Oid funcOid, int argIndex, Oid newArgType)
|
|||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Form_pg_proc procForm;
|
Form_pg_proc procForm;
|
||||||
|
|
||||||
pg_proc_rel = heap_openr(ProcedureRelationName, RowExclusiveLock);
|
pg_proc_rel = heap_open(ProcedureRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tup = SearchSysCacheCopy(PROCOID,
|
tup = SearchSysCacheCopy(PROCOID,
|
||||||
ObjectIdGetDatum(funcOid),
|
ObjectIdGetDatum(funcOid),
|
||||||
@ -1266,7 +1266,7 @@ CreateCast(CreateCastStmt *stmt)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
relation = heap_openr(CastRelationName, RowExclusiveLock);
|
relation = heap_open(CastRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for duplicate. This is just to give a friendly error
|
* Check for duplicate. This is just to give a friendly error
|
||||||
@ -1299,7 +1299,7 @@ CreateCast(CreateCastStmt *stmt)
|
|||||||
CatalogUpdateIndexes(relation, tuple);
|
CatalogUpdateIndexes(relation, tuple);
|
||||||
|
|
||||||
/* make dependency entries */
|
/* make dependency entries */
|
||||||
myself.classId = RelationGetRelid(relation);
|
myself.classId = CastRelationId;
|
||||||
myself.objectId = HeapTupleGetOid(tuple);
|
myself.objectId = HeapTupleGetOid(tuple);
|
||||||
myself.objectSubId = 0;
|
myself.objectSubId = 0;
|
||||||
|
|
||||||
@ -1379,7 +1379,7 @@ DropCast(DropCastStmt *stmt)
|
|||||||
/*
|
/*
|
||||||
* Do the deletion
|
* Do the deletion
|
||||||
*/
|
*/
|
||||||
object.classId = get_system_catalog_relid(CastRelationName);
|
object.classId = CastRelationId;
|
||||||
object.objectId = HeapTupleGetOid(tuple);
|
object.objectId = HeapTupleGetOid(tuple);
|
||||||
object.objectSubId = 0;
|
object.objectSubId = 0;
|
||||||
|
|
||||||
@ -1397,13 +1397,13 @@ DropCastById(Oid castOid)
|
|||||||
SysScanDesc scan;
|
SysScanDesc scan;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
relation = heap_openr(CastRelationName, RowExclusiveLock);
|
relation = heap_open(CastRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
ScanKeyInit(&scankey,
|
ScanKeyInit(&scankey,
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(castOid));
|
ObjectIdGetDatum(castOid));
|
||||||
scan = systable_beginscan(relation, CastOidIndex, true,
|
scan = systable_beginscan(relation, CastOidIndexId, true,
|
||||||
SnapshotNow, 1, &scankey);
|
SnapshotNow, 1, &scankey);
|
||||||
|
|
||||||
tuple = systable_getnext(scan);
|
tuple = systable_getnext(scan);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.129 2005/04/14 01:38:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.130 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/heap.h"
|
#include "catalog/heap.h"
|
||||||
#include "catalog/index.h"
|
#include "catalog/index.h"
|
||||||
@ -1039,7 +1038,7 @@ ReindexDatabase(const char *dbname, bool force /* currently unused */ ,
|
|||||||
* We only consider plain relations here (toast rels will be processed
|
* We only consider plain relations here (toast rels will be processed
|
||||||
* indirectly by reindex_relation).
|
* indirectly by reindex_relation).
|
||||||
*/
|
*/
|
||||||
relationRelation = heap_openr(RelationRelationName, AccessShareLock);
|
relationRelation = heap_open(RelationRelationId, AccessShareLock);
|
||||||
scan = heap_beginscan(relationRelation, SnapshotNow, 0, NULL);
|
scan = heap_beginscan(relationRelation, SnapshotNow, 0, NULL);
|
||||||
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.31 2005/04/14 01:38:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.32 2005/04/14 20:03:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -17,13 +17,13 @@
|
|||||||
|
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
#include "catalog/pg_am.h"
|
#include "catalog/pg_am.h"
|
||||||
#include "catalog/pg_amop.h"
|
#include "catalog/pg_amop.h"
|
||||||
#include "catalog/pg_amproc.h"
|
#include "catalog/pg_amproc.h"
|
||||||
|
#include "catalog/pg_namespace.h"
|
||||||
#include "catalog/pg_opclass.h"
|
#include "catalog/pg_opclass.h"
|
||||||
#include "catalog/pg_operator.h"
|
#include "catalog/pg_operator.h"
|
||||||
#include "catalog/pg_proc.h"
|
#include "catalog/pg_proc.h"
|
||||||
@ -255,7 +255,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rel = heap_openr(OperatorClassRelationName, RowExclusiveLock);
|
rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure there is no existing opclass of this name (this is just
|
* Make sure there is no existing opclass of this name (this is just
|
||||||
@ -287,7 +287,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(amoid));
|
ObjectIdGetDatum(amoid));
|
||||||
|
|
||||||
scan = systable_beginscan(rel, OpclassAmNameNspIndex, true,
|
scan = systable_beginscan(rel, OpclassAmNameNspIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
||||||
@ -345,12 +345,12 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
|||||||
* Create dependencies. Note: we do not create a dependency link to
|
* Create dependencies. Note: we do not create a dependency link to
|
||||||
* the AM, because we don't currently support DROP ACCESS METHOD.
|
* the AM, because we don't currently support DROP ACCESS METHOD.
|
||||||
*/
|
*/
|
||||||
myself.classId = RelationGetRelid(rel);
|
myself.classId = OperatorClassRelationId;
|
||||||
myself.objectId = opclassoid;
|
myself.objectId = opclassoid;
|
||||||
myself.objectSubId = 0;
|
myself.objectSubId = 0;
|
||||||
|
|
||||||
/* dependency on namespace */
|
/* dependency on namespace */
|
||||||
referenced.classId = get_system_catalog_relid(NamespaceRelationName);
|
referenced.classId = NamespaceRelationId;
|
||||||
referenced.objectId = namespaceoid;
|
referenced.objectId = namespaceoid;
|
||||||
referenced.objectSubId = 0;
|
referenced.objectSubId = 0;
|
||||||
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
||||||
@ -371,11 +371,11 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dependencies on operators */
|
/* dependencies on operators */
|
||||||
referenced.classId = get_system_catalog_relid(OperatorRelationName);
|
|
||||||
foreach(l, operators)
|
foreach(l, operators)
|
||||||
{
|
{
|
||||||
OpClassMember *op = (OpClassMember *) lfirst(l);
|
OpClassMember *op = (OpClassMember *) lfirst(l);
|
||||||
|
|
||||||
|
referenced.classId = OperatorRelationId;
|
||||||
referenced.objectId = op->object;
|
referenced.objectId = op->object;
|
||||||
referenced.objectSubId = 0;
|
referenced.objectSubId = 0;
|
||||||
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
||||||
@ -547,7 +547,7 @@ storeOperators(Oid opclassoid, List *operators)
|
|||||||
ListCell *l;
|
ListCell *l;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
rel = heap_openr(AccessMethodOperatorRelationName, RowExclusiveLock);
|
rel = heap_open(AccessMethodOperatorRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
foreach(l, operators)
|
foreach(l, operators)
|
||||||
{
|
{
|
||||||
@ -591,7 +591,7 @@ storeProcedures(Oid opclassoid, List *procedures)
|
|||||||
ListCell *l;
|
ListCell *l;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
rel = heap_openr(AccessMethodProcedureRelationName, RowExclusiveLock);
|
rel = heap_open(AccessMethodProcedureRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
foreach(l, procedures)
|
foreach(l, procedures)
|
||||||
{
|
{
|
||||||
@ -701,7 +701,7 @@ RemoveOpClass(RemoveOpClassStmt *stmt)
|
|||||||
/*
|
/*
|
||||||
* Do the deletion
|
* Do the deletion
|
||||||
*/
|
*/
|
||||||
object.classId = get_system_catalog_relid(OperatorClassRelationName);
|
object.classId = OperatorClassRelationId;
|
||||||
object.objectId = opcID;
|
object.objectId = opcID;
|
||||||
object.objectSubId = 0;
|
object.objectSubId = 0;
|
||||||
|
|
||||||
@ -722,7 +722,7 @@ RemoveOpClassById(Oid opclassOid)
|
|||||||
/*
|
/*
|
||||||
* First remove the pg_opclass entry itself.
|
* First remove the pg_opclass entry itself.
|
||||||
*/
|
*/
|
||||||
rel = heap_openr(OperatorClassRelationName, RowExclusiveLock);
|
rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tup = SearchSysCache(CLAOID,
|
tup = SearchSysCache(CLAOID,
|
||||||
ObjectIdGetDatum(opclassOid),
|
ObjectIdGetDatum(opclassOid),
|
||||||
@ -744,9 +744,9 @@ RemoveOpClassById(Oid opclassOid)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(opclassOid));
|
ObjectIdGetDatum(opclassOid));
|
||||||
|
|
||||||
rel = heap_openr(AccessMethodOperatorRelationName, RowExclusiveLock);
|
rel = heap_open(AccessMethodOperatorRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
scan = systable_beginscan(rel, AccessMethodStrategyIndex, true,
|
scan = systable_beginscan(rel, AccessMethodStrategyIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
||||||
@ -763,9 +763,9 @@ RemoveOpClassById(Oid opclassOid)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(opclassOid));
|
ObjectIdGetDatum(opclassOid));
|
||||||
|
|
||||||
rel = heap_openr(AccessMethodProcedureRelationName, RowExclusiveLock);
|
rel = heap_open(AccessMethodProcedureRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
scan = systable_beginscan(rel, AccessMethodProcedureIndex, true,
|
scan = systable_beginscan(rel, AccessMethodProcedureIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
||||||
@ -800,7 +800,7 @@ RenameOpClass(List *name, const char *access_method, const char *newname)
|
|||||||
errmsg("access method \"%s\" does not exist",
|
errmsg("access method \"%s\" does not exist",
|
||||||
access_method)));
|
access_method)));
|
||||||
|
|
||||||
rel = heap_openr(OperatorClassRelationName, RowExclusiveLock);
|
rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Look up the opclass
|
* Look up the opclass
|
||||||
@ -900,7 +900,7 @@ AlterOpClassOwner(List *name, const char *access_method, AclId newOwnerSysId)
|
|||||||
errmsg("access method \"%s\" does not exist",
|
errmsg("access method \"%s\" does not exist",
|
||||||
access_method)));
|
access_method)));
|
||||||
|
|
||||||
rel = heap_openr(OperatorClassRelationName, RowExclusiveLock);
|
rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Look up the opclass
|
* Look up the opclass
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/operatorcmds.c,v 1.20 2004/12/31 21:59:41 pgsql Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/operatorcmds.c,v 1.21 2005/04/14 20:03:24 tgl Exp $
|
||||||
*
|
*
|
||||||
* DESCRIPTION
|
* DESCRIPTION
|
||||||
* The "DefineFoo" routines take the parse tree and pick out the
|
* The "DefineFoo" routines take the parse tree and pick out the
|
||||||
@ -35,7 +35,6 @@
|
|||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
@ -234,7 +233,7 @@ RemoveOperator(RemoveOperStmt *stmt)
|
|||||||
/*
|
/*
|
||||||
* Do the deletion
|
* Do the deletion
|
||||||
*/
|
*/
|
||||||
object.classId = get_system_catalog_relid(OperatorRelationName);
|
object.classId = OperatorRelationId;
|
||||||
object.objectId = operOid;
|
object.objectId = operOid;
|
||||||
object.objectSubId = 0;
|
object.objectSubId = 0;
|
||||||
|
|
||||||
@ -250,7 +249,7 @@ RemoveOperatorById(Oid operOid)
|
|||||||
Relation relation;
|
Relation relation;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
relation = heap_openr(OperatorRelationName, RowExclusiveLock);
|
relation = heap_open(OperatorRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tup = SearchSysCache(OPEROID,
|
tup = SearchSysCache(OPEROID,
|
||||||
ObjectIdGetDatum(operOid),
|
ObjectIdGetDatum(operOid),
|
||||||
@ -277,7 +276,7 @@ AlterOperatorOwner(List *name, TypeName *typeName1, TypeName *typeName2,
|
|||||||
Relation rel;
|
Relation rel;
|
||||||
Form_pg_operator oprForm;
|
Form_pg_operator oprForm;
|
||||||
|
|
||||||
rel = heap_openr(OperatorRelationName, RowExclusiveLock);
|
rel = heap_open(OperatorRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
operOid = LookupOperNameTypeNames(name, typeName1, typeName2,
|
operOid = LookupOperNameTypeNames(name, typeName1, typeName2,
|
||||||
false);
|
false);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.59 2005/04/14 01:38:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.60 2005/04/14 20:03:24 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -16,7 +16,6 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
@ -132,7 +131,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
|
|||||||
values[i++] = ObjectIdGetDatum(valProcOid); /* lanvalidator */
|
values[i++] = ObjectIdGetDatum(valProcOid); /* lanvalidator */
|
||||||
nulls[i] = 'n'; /* lanacl */
|
nulls[i] = 'n'; /* lanacl */
|
||||||
|
|
||||||
rel = heap_openr(LanguageRelationName, RowExclusiveLock);
|
rel = heap_open(LanguageRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tupDesc = rel->rd_att;
|
tupDesc = rel->rd_att;
|
||||||
tup = heap_formtuple(tupDesc, values, nulls);
|
tup = heap_formtuple(tupDesc, values, nulls);
|
||||||
@ -144,7 +143,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
|
|||||||
/*
|
/*
|
||||||
* Create dependencies for language
|
* Create dependencies for language
|
||||||
*/
|
*/
|
||||||
myself.classId = RelationGetRelid(rel);
|
myself.classId = LanguageRelationId;
|
||||||
myself.objectId = HeapTupleGetOid(tup);
|
myself.objectId = HeapTupleGetOid(tup);
|
||||||
myself.objectSubId = 0;
|
myself.objectSubId = 0;
|
||||||
|
|
||||||
@ -200,7 +199,7 @@ DropProceduralLanguage(DropPLangStmt *stmt)
|
|||||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||||
errmsg("language \"%s\" does not exist", languageName)));
|
errmsg("language \"%s\" does not exist", languageName)));
|
||||||
|
|
||||||
object.classId = get_system_catalog_relid(LanguageRelationName);
|
object.classId = LanguageRelationId;
|
||||||
object.objectId = HeapTupleGetOid(langTup);
|
object.objectId = HeapTupleGetOid(langTup);
|
||||||
object.objectSubId = 0;
|
object.objectSubId = 0;
|
||||||
|
|
||||||
@ -221,7 +220,7 @@ DropProceduralLanguageById(Oid langOid)
|
|||||||
Relation rel;
|
Relation rel;
|
||||||
HeapTuple langTup;
|
HeapTuple langTup;
|
||||||
|
|
||||||
rel = heap_openr(LanguageRelationName, RowExclusiveLock);
|
rel = heap_open(LanguageRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
langTup = SearchSysCache(LANGOID,
|
langTup = SearchSysCache(LANGOID,
|
||||||
ObjectIdGetDatum(langOid),
|
ObjectIdGetDatum(langOid),
|
||||||
@ -245,7 +244,7 @@ RenameLanguage(const char *oldname, const char *newname)
|
|||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
|
|
||||||
rel = heap_openr(LanguageRelationName, RowExclusiveLock);
|
rel = heap_open(LanguageRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tup = SearchSysCacheCopy(LANGNAME,
|
tup = SearchSysCacheCopy(LANGNAME,
|
||||||
CStringGetDatum(oldname),
|
CStringGetDatum(oldname),
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.28 2005/01/27 23:23:55 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.29 2005/04/14 20:03:24 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
@ -189,7 +188,7 @@ RemoveSchema(List *names, DropBehavior behavior)
|
|||||||
* Do the deletion. Objects contained in the schema are removed by
|
* Do the deletion. Objects contained in the schema are removed by
|
||||||
* means of their dependency links to the schema.
|
* means of their dependency links to the schema.
|
||||||
*/
|
*/
|
||||||
object.classId = get_system_catalog_relid(NamespaceRelationName);
|
object.classId = NamespaceRelationId;
|
||||||
object.objectId = namespaceId;
|
object.objectId = namespaceId;
|
||||||
object.objectSubId = 0;
|
object.objectSubId = 0;
|
||||||
|
|
||||||
@ -206,7 +205,7 @@ RemoveSchemaById(Oid schemaOid)
|
|||||||
Relation relation;
|
Relation relation;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
relation = heap_openr(NamespaceRelationName, RowExclusiveLock);
|
relation = heap_open(NamespaceRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tup = SearchSysCache(NAMESPACEOID,
|
tup = SearchSysCache(NAMESPACEOID,
|
||||||
ObjectIdGetDatum(schemaOid),
|
ObjectIdGetDatum(schemaOid),
|
||||||
@ -232,7 +231,7 @@ RenameSchema(const char *oldname, const char *newname)
|
|||||||
Relation rel;
|
Relation rel;
|
||||||
AclResult aclresult;
|
AclResult aclresult;
|
||||||
|
|
||||||
rel = heap_openr(NamespaceRelationName, RowExclusiveLock);
|
rel = heap_open(NamespaceRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tup = SearchSysCacheCopy(NAMESPACENAME,
|
tup = SearchSysCacheCopy(NAMESPACENAME,
|
||||||
CStringGetDatum(oldname),
|
CStringGetDatum(oldname),
|
||||||
@ -287,7 +286,7 @@ AlterSchemaOwner(const char *name, AclId newOwnerSysId)
|
|||||||
Relation rel;
|
Relation rel;
|
||||||
Form_pg_namespace nspForm;
|
Form_pg_namespace nspForm;
|
||||||
|
|
||||||
rel = heap_openr(NamespaceRelationName, RowExclusiveLock);
|
rel = heap_open(NamespaceRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tup = SearchSysCache(NAMESPACENAME,
|
tup = SearchSysCache(NAMESPACENAME,
|
||||||
CStringGetDatum(name),
|
CStringGetDatum(name),
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.154 2005/04/14 01:38:17 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.155 2005/04/14 20:03:24 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -17,7 +17,6 @@
|
|||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/tuptoaster.h"
|
#include "access/tuptoaster.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/heap.h"
|
#include "catalog/heap.h"
|
||||||
#include "catalog/index.h"
|
#include "catalog/index.h"
|
||||||
@ -1133,7 +1132,7 @@ StoreCatalogInheritance(Oid relationId, List *supers)
|
|||||||
* and then entered into pg_ipl. Since that catalog doesn't exist
|
* and then entered into pg_ipl. Since that catalog doesn't exist
|
||||||
* anymore, there's no need to look for indirect ancestors.)
|
* anymore, there's no need to look for indirect ancestors.)
|
||||||
*/
|
*/
|
||||||
relation = heap_openr(InheritsRelationName, RowExclusiveLock);
|
relation = heap_open(InheritsRelationId, RowExclusiveLock);
|
||||||
desc = RelationGetDescr(relation);
|
desc = RelationGetDescr(relation);
|
||||||
|
|
||||||
seqNumber = 1;
|
seqNumber = 1;
|
||||||
@ -1224,7 +1223,7 @@ setRelhassubclassInRelation(Oid relationId, bool relhassubclass)
|
|||||||
* If the tuple already has the right relhassubclass setting, we don't
|
* If the tuple already has the right relhassubclass setting, we don't
|
||||||
* need to update it, but we still need to issue an SI inval message.
|
* need to update it, but we still need to issue an SI inval message.
|
||||||
*/
|
*/
|
||||||
relationRelation = heap_openr(RelationRelationName, RowExclusiveLock);
|
relationRelation = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
tuple = SearchSysCacheCopy(RELOID,
|
tuple = SearchSysCacheCopy(RELOID,
|
||||||
ObjectIdGetDatum(relationId),
|
ObjectIdGetDatum(relationId),
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
@ -1347,7 +1346,7 @@ renameatt(Oid myrelid,
|
|||||||
oldattname)));
|
oldattname)));
|
||||||
}
|
}
|
||||||
|
|
||||||
attrelation = heap_openr(AttributeRelationName, RowExclusiveLock);
|
attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
atttup = SearchSysCacheCopyAttName(myrelid, oldattname);
|
atttup = SearchSysCacheCopyAttName(myrelid, oldattname);
|
||||||
if (!HeapTupleIsValid(atttup))
|
if (!HeapTupleIsValid(atttup))
|
||||||
@ -1514,7 +1513,7 @@ renamerel(Oid myrelid, const char *newrelname)
|
|||||||
* Find relation's pg_class tuple, and make sure newrelname isn't in
|
* Find relation's pg_class tuple, and make sure newrelname isn't in
|
||||||
* use.
|
* use.
|
||||||
*/
|
*/
|
||||||
relrelation = heap_openr(RelationRelationName, RowExclusiveLock);
|
relrelation = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
reltup = SearchSysCacheCopy(RELOID,
|
reltup = SearchSysCacheCopy(RELOID,
|
||||||
PointerGetDatum(myrelid),
|
PointerGetDatum(myrelid),
|
||||||
@ -1626,14 +1625,14 @@ update_ri_trigger_args(Oid relid,
|
|||||||
char nulls[Natts_pg_trigger];
|
char nulls[Natts_pg_trigger];
|
||||||
char replaces[Natts_pg_trigger];
|
char replaces[Natts_pg_trigger];
|
||||||
|
|
||||||
tgrel = heap_openr(TriggerRelationName, RowExclusiveLock);
|
tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
|
||||||
if (fk_scan)
|
if (fk_scan)
|
||||||
{
|
{
|
||||||
ScanKeyInit(&skey[0],
|
ScanKeyInit(&skey[0],
|
||||||
Anum_pg_trigger_tgconstrrelid,
|
Anum_pg_trigger_tgconstrrelid,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(relid));
|
ObjectIdGetDatum(relid));
|
||||||
trigscan = systable_beginscan(tgrel, TriggerConstrRelidIndex,
|
trigscan = systable_beginscan(tgrel, TriggerConstrRelidIndexId,
|
||||||
true, SnapshotNow,
|
true, SnapshotNow,
|
||||||
1, skey);
|
1, skey);
|
||||||
}
|
}
|
||||||
@ -1643,7 +1642,7 @@ update_ri_trigger_args(Oid relid,
|
|||||||
Anum_pg_trigger_tgrelid,
|
Anum_pg_trigger_tgrelid,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(relid));
|
ObjectIdGetDatum(relid));
|
||||||
trigscan = systable_beginscan(tgrel, TriggerRelidNameIndex,
|
trigscan = systable_beginscan(tgrel, TriggerRelidNameIndexId,
|
||||||
true, SnapshotNow,
|
true, SnapshotNow,
|
||||||
1, skey);
|
1, skey);
|
||||||
}
|
}
|
||||||
@ -2772,7 +2771,7 @@ find_composite_type_dependencies(Oid typeOid, const char *origTblName)
|
|||||||
* We scan pg_depend to find those things that depend on the rowtype.
|
* We scan pg_depend to find those things that depend on the rowtype.
|
||||||
* (We assume we can ignore refobjsubid for a rowtype.)
|
* (We assume we can ignore refobjsubid for a rowtype.)
|
||||||
*/
|
*/
|
||||||
depRel = relation_openr(DependRelationName, AccessShareLock);
|
depRel = heap_open(DependRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&key[0],
|
ScanKeyInit(&key[0],
|
||||||
Anum_pg_depend_refclassid,
|
Anum_pg_depend_refclassid,
|
||||||
@ -2783,7 +2782,7 @@ find_composite_type_dependencies(Oid typeOid, const char *origTblName)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(typeOid));
|
ObjectIdGetDatum(typeOid));
|
||||||
|
|
||||||
depScan = systable_beginscan(depRel, DependReferenceIndex, true,
|
depScan = systable_beginscan(depRel, DependReferenceIndexId, true,
|
||||||
SnapshotNow, 2, key);
|
SnapshotNow, 2, key);
|
||||||
|
|
||||||
while (HeapTupleIsValid(depTup = systable_getnext(depScan)))
|
while (HeapTupleIsValid(depTup = systable_getnext(depScan)))
|
||||||
@ -2894,7 +2893,7 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
|
|||||||
Form_pg_type tform;
|
Form_pg_type tform;
|
||||||
Expr *defval;
|
Expr *defval;
|
||||||
|
|
||||||
attrdesc = heap_openr(AttributeRelationName, RowExclusiveLock);
|
attrdesc = heap_open(AttributeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Are we adding the column to a recursion child? If so, check
|
* Are we adding the column to a recursion child? If so, check
|
||||||
@ -2935,7 +2934,7 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pgclass = heap_openr(RelationRelationName, RowExclusiveLock);
|
pgclass = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
reltup = SearchSysCacheCopy(RELOID,
|
reltup = SearchSysCacheCopy(RELOID,
|
||||||
ObjectIdGetDatum(myrelid),
|
ObjectIdGetDatum(myrelid),
|
||||||
@ -3155,7 +3154,7 @@ ATExecDropNotNull(Relation rel, const char *colName)
|
|||||||
/*
|
/*
|
||||||
* lookup the attribute
|
* lookup the attribute
|
||||||
*/
|
*/
|
||||||
attr_rel = heap_openr(AttributeRelationName, RowExclusiveLock);
|
attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
|
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
|
||||||
|
|
||||||
@ -3248,7 +3247,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
|
|||||||
/*
|
/*
|
||||||
* lookup the attribute
|
* lookup the attribute
|
||||||
*/
|
*/
|
||||||
attr_rel = heap_openr(AttributeRelationName, RowExclusiveLock);
|
attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
|
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
|
||||||
|
|
||||||
@ -3396,7 +3395,7 @@ ATExecSetStatistics(Relation rel, const char *colName, Node *newValue)
|
|||||||
newtarget)));
|
newtarget)));
|
||||||
}
|
}
|
||||||
|
|
||||||
attrelation = heap_openr(AttributeRelationName, RowExclusiveLock);
|
attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
|
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
|
||||||
|
|
||||||
@ -3457,7 +3456,7 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue)
|
|||||||
newstorage = 0; /* keep compiler quiet */
|
newstorage = 0; /* keep compiler quiet */
|
||||||
}
|
}
|
||||||
|
|
||||||
attrelation = heap_openr(AttributeRelationName, RowExclusiveLock);
|
attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
|
tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
|
||||||
|
|
||||||
@ -3564,7 +3563,7 @@ ATExecDropColumn(Relation rel, const char *colName,
|
|||||||
Relation attr_rel;
|
Relation attr_rel;
|
||||||
ListCell *child;
|
ListCell *child;
|
||||||
|
|
||||||
attr_rel = heap_openr(AttributeRelationName, RowExclusiveLock);
|
attr_rel = heap_open(AttributeRelationId, RowExclusiveLock);
|
||||||
foreach(child, children)
|
foreach(child, children)
|
||||||
{
|
{
|
||||||
Oid childrelid = lfirst_oid(child);
|
Oid childrelid = lfirst_oid(child);
|
||||||
@ -3652,7 +3651,7 @@ ATExecDropColumn(Relation rel, const char *colName,
|
|||||||
Relation class_rel;
|
Relation class_rel;
|
||||||
Form_pg_class tuple_class;
|
Form_pg_class tuple_class;
|
||||||
|
|
||||||
class_rel = heap_openr(RelationRelationName, RowExclusiveLock);
|
class_rel = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tuple = SearchSysCacheCopy(RELOID,
|
tuple = SearchSysCacheCopy(RELOID,
|
||||||
ObjectIdGetDatum(RelationGetRelid(rel)),
|
ObjectIdGetDatum(RelationGetRelid(rel)),
|
||||||
@ -4404,10 +4403,10 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint,
|
|||||||
/*
|
/*
|
||||||
* Preset objectAddress fields
|
* Preset objectAddress fields
|
||||||
*/
|
*/
|
||||||
constrobj.classId = get_system_catalog_relid(ConstraintRelationName);
|
constrobj.classId = ConstraintRelationId;
|
||||||
constrobj.objectId = constrOid;
|
constrobj.objectId = constrOid;
|
||||||
constrobj.objectSubId = 0;
|
constrobj.objectSubId = 0;
|
||||||
trigobj.classId = get_system_catalog_relid(TriggerRelationName);
|
trigobj.classId = TriggerRelationId;
|
||||||
trigobj.objectSubId = 0;
|
trigobj.objectSubId = 0;
|
||||||
|
|
||||||
/* Make changes-so-far visible */
|
/* Make changes-so-far visible */
|
||||||
@ -4820,7 +4819,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
|
|||||||
SysScanDesc scan;
|
SysScanDesc scan;
|
||||||
HeapTuple depTup;
|
HeapTuple depTup;
|
||||||
|
|
||||||
attrelation = heap_openr(AttributeRelationName, RowExclusiveLock);
|
attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/* Look up the target column */
|
/* Look up the target column */
|
||||||
heapTup = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
|
heapTup = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
|
||||||
@ -4891,7 +4890,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
|
|||||||
* index that implements a constraint will not show a direct
|
* index that implements a constraint will not show a direct
|
||||||
* dependency on the column.
|
* dependency on the column.
|
||||||
*/
|
*/
|
||||||
depRel = heap_openr(DependRelationName, RowExclusiveLock);
|
depRel = heap_open(DependRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
ScanKeyInit(&key[0],
|
ScanKeyInit(&key[0],
|
||||||
Anum_pg_depend_refclassid,
|
Anum_pg_depend_refclassid,
|
||||||
@ -4906,7 +4905,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
|
|||||||
BTEqualStrategyNumber, F_INT4EQ,
|
BTEqualStrategyNumber, F_INT4EQ,
|
||||||
Int32GetDatum((int32) attnum));
|
Int32GetDatum((int32) attnum));
|
||||||
|
|
||||||
scan = systable_beginscan(depRel, DependReferenceIndex, true,
|
scan = systable_beginscan(depRel, DependReferenceIndexId, true,
|
||||||
SnapshotNow, 3, key);
|
SnapshotNow, 3, key);
|
||||||
|
|
||||||
while (HeapTupleIsValid(depTup = systable_getnext(scan)))
|
while (HeapTupleIsValid(depTup = systable_getnext(scan)))
|
||||||
@ -5030,7 +5029,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
|
|||||||
BTEqualStrategyNumber, F_INT4EQ,
|
BTEqualStrategyNumber, F_INT4EQ,
|
||||||
Int32GetDatum((int32) attnum));
|
Int32GetDatum((int32) attnum));
|
||||||
|
|
||||||
scan = systable_beginscan(depRel, DependDependerIndex, true,
|
scan = systable_beginscan(depRel, DependDependerIndexId, true,
|
||||||
SnapshotNow, 3, key);
|
SnapshotNow, 3, key);
|
||||||
|
|
||||||
while (HeapTupleIsValid(depTup = systable_getnext(scan)))
|
while (HeapTupleIsValid(depTup = systable_getnext(scan)))
|
||||||
@ -5136,18 +5135,17 @@ ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab)
|
|||||||
* It should be okay to use DROP_RESTRICT here, since nothing else
|
* It should be okay to use DROP_RESTRICT here, since nothing else
|
||||||
* should be depending on these objects.
|
* should be depending on these objects.
|
||||||
*/
|
*/
|
||||||
if (tab->changedConstraintOids)
|
|
||||||
obj.classId = get_system_catalog_relid(ConstraintRelationName);
|
|
||||||
foreach(l, tab->changedConstraintOids)
|
foreach(l, tab->changedConstraintOids)
|
||||||
{
|
{
|
||||||
|
obj.classId = ConstraintRelationId;
|
||||||
obj.objectId = lfirst_oid(l);
|
obj.objectId = lfirst_oid(l);
|
||||||
obj.objectSubId = 0;
|
obj.objectSubId = 0;
|
||||||
performDeletion(&obj, DROP_RESTRICT);
|
performDeletion(&obj, DROP_RESTRICT);
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.classId = RelationRelationId;
|
|
||||||
foreach(l, tab->changedIndexOids)
|
foreach(l, tab->changedIndexOids)
|
||||||
{
|
{
|
||||||
|
obj.classId = RelationRelationId;
|
||||||
obj.objectId = lfirst_oid(l);
|
obj.objectId = lfirst_oid(l);
|
||||||
obj.objectSubId = 0;
|
obj.objectSubId = 0;
|
||||||
performDeletion(&obj, DROP_RESTRICT);
|
performDeletion(&obj, DROP_RESTRICT);
|
||||||
@ -5266,7 +5264,7 @@ ATExecChangeOwner(Oid relationOid, int32 newOwnerSysId)
|
|||||||
target_rel = relation_open(relationOid, AccessExclusiveLock);
|
target_rel = relation_open(relationOid, AccessExclusiveLock);
|
||||||
|
|
||||||
/* Get its pg_class tuple, too */
|
/* Get its pg_class tuple, too */
|
||||||
class_rel = heap_openr(RelationRelationName, RowExclusiveLock);
|
class_rel = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tuple = SearchSysCache(RELOID,
|
tuple = SearchSysCache(RELOID,
|
||||||
ObjectIdGetDatum(relationOid),
|
ObjectIdGetDatum(relationOid),
|
||||||
@ -5396,7 +5394,7 @@ change_owner_recurse_to_sequences(Oid relationOid, int32 newOwnerSysId)
|
|||||||
* SERIAL sequences are those having an internal dependency on one
|
* SERIAL sequences are those having an internal dependency on one
|
||||||
* of the table's columns (we don't care *which* column, exactly).
|
* of the table's columns (we don't care *which* column, exactly).
|
||||||
*/
|
*/
|
||||||
depRel = heap_openr(DependRelationName, AccessShareLock);
|
depRel = heap_open(DependRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&key[0],
|
ScanKeyInit(&key[0],
|
||||||
Anum_pg_depend_refclassid,
|
Anum_pg_depend_refclassid,
|
||||||
@ -5408,7 +5406,7 @@ change_owner_recurse_to_sequences(Oid relationOid, int32 newOwnerSysId)
|
|||||||
ObjectIdGetDatum(relationOid));
|
ObjectIdGetDatum(relationOid));
|
||||||
/* we leave refobjsubid unspecified */
|
/* we leave refobjsubid unspecified */
|
||||||
|
|
||||||
scan = systable_beginscan(depRel, DependReferenceIndex, true,
|
scan = systable_beginscan(depRel, DependReferenceIndexId, true,
|
||||||
SnapshotNow, 2, key);
|
SnapshotNow, 2, key);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
||||||
@ -5587,7 +5585,7 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace)
|
|||||||
reltoastidxid = rel->rd_rel->reltoastidxid;
|
reltoastidxid = rel->rd_rel->reltoastidxid;
|
||||||
|
|
||||||
/* Get a modifiable copy of the relation's pg_class row */
|
/* Get a modifiable copy of the relation's pg_class row */
|
||||||
pg_class = heap_openr(RelationRelationName, RowExclusiveLock);
|
pg_class = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tuple = SearchSysCacheCopy(RELOID,
|
tuple = SearchSysCacheCopy(RELOID,
|
||||||
ObjectIdGetDatum(tableOid),
|
ObjectIdGetDatum(tableOid),
|
||||||
@ -5909,7 +5907,7 @@ AlterTableCreateToastTable(Oid relOid, bool silent)
|
|||||||
/*
|
/*
|
||||||
* Store the toast table's OID in the parent relation's pg_class row
|
* Store the toast table's OID in the parent relation's pg_class row
|
||||||
*/
|
*/
|
||||||
class_rel = heap_openr(RelationRelationName, RowExclusiveLock);
|
class_rel = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
reltup = SearchSysCacheCopy(RELOID,
|
reltup = SearchSysCacheCopy(RELOID,
|
||||||
ObjectIdGetDatum(relOid),
|
ObjectIdGetDatum(relOid),
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.16 2005/01/27 23:23:55 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.17 2005/04/14 20:03:24 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -50,7 +50,6 @@
|
|||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/pg_namespace.h"
|
#include "catalog/pg_namespace.h"
|
||||||
#include "catalog/pg_tablespace.h"
|
#include "catalog/pg_tablespace.h"
|
||||||
@ -125,7 +124,7 @@ TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo)
|
|||||||
Relation rel;
|
Relation rel;
|
||||||
|
|
||||||
if (!isRedo)
|
if (!isRedo)
|
||||||
rel = heap_openr(TableSpaceRelationName, ExclusiveLock);
|
rel = heap_open(TableSpaceRelationId, ExclusiveLock);
|
||||||
else
|
else
|
||||||
rel = NULL;
|
rel = NULL;
|
||||||
|
|
||||||
@ -291,7 +290,7 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
|
|||||||
* is to lock the proposed tablename against other would-be creators.
|
* is to lock the proposed tablename against other would-be creators.
|
||||||
* The insertion will roll back if we find problems below.
|
* The insertion will roll back if we find problems below.
|
||||||
*/
|
*/
|
||||||
rel = heap_openr(TableSpaceRelationName, RowExclusiveLock);
|
rel = heap_open(TableSpaceRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
MemSet(nulls, ' ', Natts_pg_tablespace);
|
MemSet(nulls, ' ', Natts_pg_tablespace);
|
||||||
|
|
||||||
@ -407,7 +406,7 @@ DropTableSpace(DropTableSpaceStmt *stmt)
|
|||||||
* is trying to do DROP TABLESPACE or TablespaceCreateDbspace
|
* is trying to do DROP TABLESPACE or TablespaceCreateDbspace
|
||||||
* concurrently.
|
* concurrently.
|
||||||
*/
|
*/
|
||||||
rel = heap_openr(TableSpaceRelationName, ExclusiveLock);
|
rel = heap_open(TableSpaceRelationId, ExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the target tuple
|
* Find the target tuple
|
||||||
@ -736,7 +735,7 @@ RenameTableSpace(const char *oldname, const char *newname)
|
|||||||
Form_pg_tablespace newform;
|
Form_pg_tablespace newform;
|
||||||
|
|
||||||
/* Search pg_tablespace */
|
/* Search pg_tablespace */
|
||||||
rel = heap_openr(TableSpaceRelationName, RowExclusiveLock);
|
rel = heap_open(TableSpaceRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
ScanKeyInit(&entry[0],
|
ScanKeyInit(&entry[0],
|
||||||
Anum_pg_tablespace_spcname,
|
Anum_pg_tablespace_spcname,
|
||||||
@ -803,7 +802,7 @@ AlterTableSpaceOwner(const char *name, AclId newOwnerSysId)
|
|||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
/* Search pg_tablespace */
|
/* Search pg_tablespace */
|
||||||
rel = heap_openr(TableSpaceRelationName, RowExclusiveLock);
|
rel = heap_open(TableSpaceRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
ScanKeyInit(&entry[0],
|
ScanKeyInit(&entry[0],
|
||||||
Anum_pg_tablespace_spcname,
|
Anum_pg_tablespace_spcname,
|
||||||
@ -952,7 +951,7 @@ get_tablespace_oid(const char *tablespacename)
|
|||||||
ScanKeyData entry[1];
|
ScanKeyData entry[1];
|
||||||
|
|
||||||
/* Search pg_tablespace */
|
/* Search pg_tablespace */
|
||||||
rel = heap_openr(TableSpaceRelationName, AccessShareLock);
|
rel = heap_open(TableSpaceRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&entry[0],
|
ScanKeyInit(&entry[0],
|
||||||
Anum_pg_tablespace_spcname,
|
Anum_pg_tablespace_spcname,
|
||||||
@ -987,7 +986,7 @@ get_tablespace_name(Oid spc_oid)
|
|||||||
ScanKeyData entry[1];
|
ScanKeyData entry[1];
|
||||||
|
|
||||||
/* Search pg_tablespace */
|
/* Search pg_tablespace */
|
||||||
rel = heap_openr(TableSpaceRelationName, AccessShareLock);
|
rel = heap_open(TableSpaceRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&entry[0],
|
ScanKeyInit(&entry[0],
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.185 2005/04/14 01:38:17 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.186 2005/04/14 20:03:24 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -17,7 +17,6 @@
|
|||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "access/xact.h"
|
#include "access/xact.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
@ -252,12 +251,12 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
|
|||||||
* NOTE that this is cool only because we have AccessExclusiveLock on the
|
* NOTE that this is cool only because we have AccessExclusiveLock on the
|
||||||
* relation, so the trigger set won't be changing underneath us.
|
* relation, so the trigger set won't be changing underneath us.
|
||||||
*/
|
*/
|
||||||
tgrel = heap_openr(TriggerRelationName, RowExclusiveLock);
|
tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
|
||||||
ScanKeyInit(&key,
|
ScanKeyInit(&key,
|
||||||
Anum_pg_trigger_tgrelid,
|
Anum_pg_trigger_tgrelid,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(RelationGetRelid(rel)));
|
ObjectIdGetDatum(RelationGetRelid(rel)));
|
||||||
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndex, true,
|
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true,
|
||||||
SnapshotNow, 1, &key);
|
SnapshotNow, 1, &key);
|
||||||
while (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
|
while (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
|
||||||
{
|
{
|
||||||
@ -374,7 +373,7 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
|
|||||||
|
|
||||||
CatalogUpdateIndexes(tgrel, tuple);
|
CatalogUpdateIndexes(tgrel, tuple);
|
||||||
|
|
||||||
myself.classId = RelationGetRelid(tgrel);
|
myself.classId = TriggerRelationId;
|
||||||
myself.objectId = trigoid;
|
myself.objectId = trigoid;
|
||||||
myself.objectSubId = 0;
|
myself.objectSubId = 0;
|
||||||
|
|
||||||
@ -389,7 +388,7 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
|
|||||||
* backends (and this one too!) are sent SI message to make them
|
* backends (and this one too!) are sent SI message to make them
|
||||||
* rebuild relcache entries.
|
* rebuild relcache entries.
|
||||||
*/
|
*/
|
||||||
pgrel = heap_openr(RelationRelationName, RowExclusiveLock);
|
pgrel = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
tuple = SearchSysCacheCopy(RELOID,
|
tuple = SearchSysCacheCopy(RELOID,
|
||||||
ObjectIdGetDatum(RelationGetRelid(rel)),
|
ObjectIdGetDatum(RelationGetRelid(rel)),
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
@ -463,7 +462,7 @@ DropTrigger(Oid relid, const char *trigname, DropBehavior behavior)
|
|||||||
/*
|
/*
|
||||||
* Find the trigger, verify permissions, set up object address
|
* Find the trigger, verify permissions, set up object address
|
||||||
*/
|
*/
|
||||||
tgrel = heap_openr(TriggerRelationName, AccessShareLock);
|
tgrel = heap_open(TriggerRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&skey[0],
|
ScanKeyInit(&skey[0],
|
||||||
Anum_pg_trigger_tgrelid,
|
Anum_pg_trigger_tgrelid,
|
||||||
@ -475,7 +474,7 @@ DropTrigger(Oid relid, const char *trigname, DropBehavior behavior)
|
|||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
CStringGetDatum(trigname));
|
CStringGetDatum(trigname));
|
||||||
|
|
||||||
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndex, true,
|
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true,
|
||||||
SnapshotNow, 2, skey);
|
SnapshotNow, 2, skey);
|
||||||
|
|
||||||
tup = systable_getnext(tgscan);
|
tup = systable_getnext(tgscan);
|
||||||
@ -490,7 +489,7 @@ DropTrigger(Oid relid, const char *trigname, DropBehavior behavior)
|
|||||||
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS,
|
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS,
|
||||||
get_rel_name(relid));
|
get_rel_name(relid));
|
||||||
|
|
||||||
object.classId = RelationGetRelid(tgrel);
|
object.classId = TriggerRelationId;
|
||||||
object.objectId = HeapTupleGetOid(tup);
|
object.objectId = HeapTupleGetOid(tup);
|
||||||
object.objectSubId = 0;
|
object.objectSubId = 0;
|
||||||
|
|
||||||
@ -519,7 +518,7 @@ RemoveTriggerById(Oid trigOid)
|
|||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
Form_pg_class classForm;
|
Form_pg_class classForm;
|
||||||
|
|
||||||
tgrel = heap_openr(TriggerRelationName, RowExclusiveLock);
|
tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the trigger to delete.
|
* Find the trigger to delete.
|
||||||
@ -529,7 +528,7 @@ RemoveTriggerById(Oid trigOid)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(trigOid));
|
ObjectIdGetDatum(trigOid));
|
||||||
|
|
||||||
tgscan = systable_beginscan(tgrel, TriggerOidIndex, true,
|
tgscan = systable_beginscan(tgrel, TriggerOidIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
tup = systable_getnext(tgscan);
|
tup = systable_getnext(tgscan);
|
||||||
@ -572,7 +571,7 @@ RemoveTriggerById(Oid trigOid)
|
|||||||
* so no one else is creating/deleting triggers on this rel at the
|
* so no one else is creating/deleting triggers on this rel at the
|
||||||
* same time.
|
* same time.
|
||||||
*/
|
*/
|
||||||
pgrel = heap_openr(RelationRelationName, RowExclusiveLock);
|
pgrel = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
tuple = SearchSysCacheCopy(RELOID,
|
tuple = SearchSysCacheCopy(RELOID,
|
||||||
ObjectIdGetDatum(relid),
|
ObjectIdGetDatum(relid),
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
@ -636,7 +635,7 @@ renametrig(Oid relid,
|
|||||||
* NOTE that this is cool only because we have AccessExclusiveLock on the
|
* NOTE that this is cool only because we have AccessExclusiveLock on the
|
||||||
* relation, so the trigger set won't be changing underneath us.
|
* relation, so the trigger set won't be changing underneath us.
|
||||||
*/
|
*/
|
||||||
tgrel = heap_openr(TriggerRelationName, RowExclusiveLock);
|
tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First pass -- look for name conflict
|
* First pass -- look for name conflict
|
||||||
@ -649,7 +648,7 @@ renametrig(Oid relid,
|
|||||||
Anum_pg_trigger_tgname,
|
Anum_pg_trigger_tgname,
|
||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
PointerGetDatum(newname));
|
PointerGetDatum(newname));
|
||||||
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndex, true,
|
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true,
|
||||||
SnapshotNow, 2, key);
|
SnapshotNow, 2, key);
|
||||||
if (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
|
if (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -669,7 +668,7 @@ renametrig(Oid relid,
|
|||||||
Anum_pg_trigger_tgname,
|
Anum_pg_trigger_tgname,
|
||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
PointerGetDatum(oldname));
|
PointerGetDatum(oldname));
|
||||||
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndex, true,
|
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true,
|
||||||
SnapshotNow, 2, key);
|
SnapshotNow, 2, key);
|
||||||
if (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
|
if (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
|
||||||
{
|
{
|
||||||
@ -739,7 +738,7 @@ RelationBuildTriggers(Relation relation)
|
|||||||
triggers = (Trigger *) palloc(ntrigs * sizeof(Trigger));
|
triggers = (Trigger *) palloc(ntrigs * sizeof(Trigger));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: since we scan the triggers using TriggerRelidNameIndex, we
|
* Note: since we scan the triggers using TriggerRelidNameIndexId, we
|
||||||
* will be reading the triggers in name order, except possibly during
|
* will be reading the triggers in name order, except possibly during
|
||||||
* emergency-recovery operations (ie, IsIgnoringSystemIndexes). This
|
* emergency-recovery operations (ie, IsIgnoringSystemIndexes). This
|
||||||
* in turn ensures that triggers will be fired in name order.
|
* in turn ensures that triggers will be fired in name order.
|
||||||
@ -749,8 +748,8 @@ RelationBuildTriggers(Relation relation)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||||
|
|
||||||
tgrel = heap_openr(TriggerRelationName, AccessShareLock);
|
tgrel = heap_open(TriggerRelationId, AccessShareLock);
|
||||||
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndex, true,
|
tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true,
|
||||||
SnapshotNow, 1, &skey);
|
SnapshotNow, 1, &skey);
|
||||||
|
|
||||||
while (HeapTupleIsValid(htup = systable_getnext(tgscan)))
|
while (HeapTupleIsValid(htup = systable_getnext(tgscan)))
|
||||||
@ -2802,7 +2801,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
|
|||||||
* First lookup all trigger Oid's for the constraint names.
|
* First lookup all trigger Oid's for the constraint names.
|
||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
tgrel = heap_openr(TriggerRelationName, AccessShareLock);
|
tgrel = heap_open(TriggerRelationId, AccessShareLock);
|
||||||
|
|
||||||
foreach(l, stmt->constraints)
|
foreach(l, stmt->constraints)
|
||||||
{
|
{
|
||||||
@ -2828,7 +2827,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
|
|||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
PointerGetDatum(cname));
|
PointerGetDatum(cname));
|
||||||
|
|
||||||
tgscan = systable_beginscan(tgrel, TriggerConstrNameIndex, true,
|
tgscan = systable_beginscan(tgrel, TriggerConstrNameIndexId, true,
|
||||||
SnapshotNow, 1, &skey);
|
SnapshotNow, 1, &skey);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.69 2005/04/14 01:38:17 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.70 2005/04/14 20:03:24 tgl Exp $
|
||||||
*
|
*
|
||||||
* DESCRIPTION
|
* DESCRIPTION
|
||||||
* The "DefineFoo" routines take the parse tree and pick out the
|
* The "DefineFoo" routines take the parse tree and pick out the
|
||||||
@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/heap.h"
|
#include "catalog/heap.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
@ -458,7 +457,7 @@ RemoveTypeById(Oid typeOid)
|
|||||||
Relation relation;
|
Relation relation;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
|
|
||||||
relation = heap_openr(TypeRelationName, RowExclusiveLock);
|
relation = heap_open(TypeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tup = SearchSysCache(TYPEOID,
|
tup = SearchSysCache(TYPEOID,
|
||||||
ObjectIdGetDatum(typeOid),
|
ObjectIdGetDatum(typeOid),
|
||||||
@ -1143,7 +1142,7 @@ AlterDomainDefault(List *names, Node *defaultRaw)
|
|||||||
typename->arrayBounds = NIL;
|
typename->arrayBounds = NIL;
|
||||||
|
|
||||||
/* Lock the domain in the type table */
|
/* Lock the domain in the type table */
|
||||||
rel = heap_openr(TypeRelationName, RowExclusiveLock);
|
rel = heap_open(TypeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/* Use LookupTypeName here so that shell types can be removed. */
|
/* Use LookupTypeName here so that shell types can be removed. */
|
||||||
domainoid = LookupTypeName(typename);
|
domainoid = LookupTypeName(typename);
|
||||||
@ -1265,7 +1264,7 @@ AlterDomainNotNull(List *names, bool notNull)
|
|||||||
typename->arrayBounds = NIL;
|
typename->arrayBounds = NIL;
|
||||||
|
|
||||||
/* Lock the type table */
|
/* Lock the type table */
|
||||||
typrel = heap_openr(TypeRelationName, RowExclusiveLock);
|
typrel = heap_open(TypeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/* Use LookupTypeName here so that shell types can be found (why?). */
|
/* Use LookupTypeName here so that shell types can be found (why?). */
|
||||||
domainoid = LookupTypeName(typename);
|
domainoid = LookupTypeName(typename);
|
||||||
@ -1377,7 +1376,7 @@ AlterDomainDropConstraint(List *names, const char *constrName, DropBehavior beha
|
|||||||
typename->arrayBounds = NIL;
|
typename->arrayBounds = NIL;
|
||||||
|
|
||||||
/* Lock the type table */
|
/* Lock the type table */
|
||||||
rel = heap_openr(TypeRelationName, RowExclusiveLock);
|
rel = heap_open(TypeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/* Use LookupTypeName here so that shell types can be removed. */
|
/* Use LookupTypeName here so that shell types can be removed. */
|
||||||
domainoid = LookupTypeName(typename);
|
domainoid = LookupTypeName(typename);
|
||||||
@ -1397,7 +1396,7 @@ AlterDomainDropConstraint(List *names, const char *constrName, DropBehavior beha
|
|||||||
domainOwnerCheck(tup, typename);
|
domainOwnerCheck(tup, typename);
|
||||||
|
|
||||||
/* Grab an appropriate lock on the pg_constraint relation */
|
/* Grab an appropriate lock on the pg_constraint relation */
|
||||||
conrel = heap_openr(ConstraintRelationName, RowExclusiveLock);
|
conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/* Use the index to scan only constraints of the target relation */
|
/* Use the index to scan only constraints of the target relation */
|
||||||
ScanKeyInit(&key[0],
|
ScanKeyInit(&key[0],
|
||||||
@ -1405,7 +1404,7 @@ AlterDomainDropConstraint(List *names, const char *constrName, DropBehavior beha
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(HeapTupleGetOid(tup)));
|
ObjectIdGetDatum(HeapTupleGetOid(tup)));
|
||||||
|
|
||||||
conscan = systable_beginscan(conrel, ConstraintTypidIndex, true,
|
conscan = systable_beginscan(conrel, ConstraintTypidIndexId, true,
|
||||||
SnapshotNow, 1, key);
|
SnapshotNow, 1, key);
|
||||||
|
|
||||||
typTup = (Form_pg_type) GETSTRUCT(tup);
|
typTup = (Form_pg_type) GETSTRUCT(tup);
|
||||||
@ -1421,7 +1420,7 @@ AlterDomainDropConstraint(List *names, const char *constrName, DropBehavior beha
|
|||||||
{
|
{
|
||||||
ObjectAddress conobj;
|
ObjectAddress conobj;
|
||||||
|
|
||||||
conobj.classId = RelationGetRelid(conrel);
|
conobj.classId = ConstraintRelationId;
|
||||||
conobj.objectId = HeapTupleGetOid(contup);
|
conobj.objectId = HeapTupleGetOid(contup);
|
||||||
conobj.objectSubId = 0;
|
conobj.objectSubId = 0;
|
||||||
|
|
||||||
@ -1464,7 +1463,7 @@ AlterDomainAddConstraint(List *names, Node *newConstraint)
|
|||||||
typename->arrayBounds = NIL;
|
typename->arrayBounds = NIL;
|
||||||
|
|
||||||
/* Lock the type table */
|
/* Lock the type table */
|
||||||
typrel = heap_openr(TypeRelationName, RowExclusiveLock);
|
typrel = heap_open(TypeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/* Use LookupTypeName here so that shell types can be found (why?). */
|
/* Use LookupTypeName here so that shell types can be found (why?). */
|
||||||
domainoid = LookupTypeName(typename);
|
domainoid = LookupTypeName(typename);
|
||||||
@ -1650,7 +1649,7 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode)
|
|||||||
* We scan pg_depend to find those things that depend on the domain.
|
* We scan pg_depend to find those things that depend on the domain.
|
||||||
* (We assume we can ignore refobjsubid for a domain.)
|
* (We assume we can ignore refobjsubid for a domain.)
|
||||||
*/
|
*/
|
||||||
depRel = relation_openr(DependRelationName, AccessShareLock);
|
depRel = heap_open(DependRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&key[0],
|
ScanKeyInit(&key[0],
|
||||||
Anum_pg_depend_refclassid,
|
Anum_pg_depend_refclassid,
|
||||||
@ -1661,7 +1660,7 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(domainOid));
|
ObjectIdGetDatum(domainOid));
|
||||||
|
|
||||||
depScan = systable_beginscan(depRel, DependReferenceIndex, true,
|
depScan = systable_beginscan(depRel, DependReferenceIndexId, true,
|
||||||
SnapshotNow, 2, key);
|
SnapshotNow, 2, key);
|
||||||
|
|
||||||
while (HeapTupleIsValid(depTup = systable_getnext(depScan)))
|
while (HeapTupleIsValid(depTup = systable_getnext(depScan)))
|
||||||
@ -1927,7 +1926,7 @@ GetDomainConstraints(Oid typeOid)
|
|||||||
bool notNull = false;
|
bool notNull = false;
|
||||||
Relation conRel;
|
Relation conRel;
|
||||||
|
|
||||||
conRel = heap_openr(ConstraintRelationName, AccessShareLock);
|
conRel = heap_open(ConstraintRelationId, AccessShareLock);
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@ -1961,7 +1960,7 @@ GetDomainConstraints(Oid typeOid)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(typeOid));
|
ObjectIdGetDatum(typeOid));
|
||||||
|
|
||||||
scan = systable_beginscan(conRel, ConstraintTypidIndex, true,
|
scan = systable_beginscan(conRel, ConstraintTypidIndexId, true,
|
||||||
SnapshotNow, 1, key);
|
SnapshotNow, 1, key);
|
||||||
|
|
||||||
while (HeapTupleIsValid(conTup = systable_getnext(scan)))
|
while (HeapTupleIsValid(conTup = systable_getnext(scan)))
|
||||||
@ -2052,7 +2051,7 @@ AlterTypeOwner(List *names, AclId newOwnerSysId)
|
|||||||
typename->arrayBounds = NIL;
|
typename->arrayBounds = NIL;
|
||||||
|
|
||||||
/* Lock the type table */
|
/* Lock the type table */
|
||||||
rel = heap_openr(TypeRelationName, RowExclusiveLock);
|
rel = heap_open(TypeRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/* Use LookupTypeName here so that shell types can be processed (why?) */
|
/* Use LookupTypeName here so that shell types can be processed (why?) */
|
||||||
typeOid = LookupTypeName(typename);
|
typeOid = LookupTypeName(typename);
|
||||||
|
@ -6,14 +6,13 @@
|
|||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.150 2005/04/14 01:38:17 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.151 2005/04/14 20:03:24 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/pg_database.h"
|
#include "catalog/pg_database.h"
|
||||||
#include "catalog/pg_group.h"
|
#include "catalog/pg_group.h"
|
||||||
@ -180,7 +179,7 @@ CreateUser(CreateUserStmt *stmt)
|
|||||||
* to be sure of what the next usesysid should be, and we need to
|
* to be sure of what the next usesysid should be, and we need to
|
||||||
* protect our eventual update of the flat password file.
|
* protect our eventual update of the flat password file.
|
||||||
*/
|
*/
|
||||||
pg_shadow_rel = heap_openr(ShadowRelationName, ExclusiveLock);
|
pg_shadow_rel = heap_open(ShadowRelationId, ExclusiveLock);
|
||||||
pg_shadow_dsc = RelationGetDescr(pg_shadow_rel);
|
pg_shadow_dsc = RelationGetDescr(pg_shadow_rel);
|
||||||
|
|
||||||
scan = heap_beginscan(pg_shadow_rel, SnapshotNow, 0, NULL);
|
scan = heap_beginscan(pg_shadow_rel, SnapshotNow, 0, NULL);
|
||||||
@ -401,7 +400,7 @@ AlterUser(AlterUserStmt *stmt)
|
|||||||
* secure exclusive lock to protect our update of the flat password
|
* secure exclusive lock to protect our update of the flat password
|
||||||
* file.
|
* file.
|
||||||
*/
|
*/
|
||||||
pg_shadow_rel = heap_openr(ShadowRelationName, ExclusiveLock);
|
pg_shadow_rel = heap_open(ShadowRelationId, ExclusiveLock);
|
||||||
pg_shadow_dsc = RelationGetDescr(pg_shadow_rel);
|
pg_shadow_dsc = RelationGetDescr(pg_shadow_rel);
|
||||||
|
|
||||||
tuple = SearchSysCache(SHADOWNAME,
|
tuple = SearchSysCache(SHADOWNAME,
|
||||||
@ -516,7 +515,7 @@ AlterUserSet(AlterUserSetStmt *stmt)
|
|||||||
* RowExclusiveLock is sufficient, because we don't need to update the
|
* RowExclusiveLock is sufficient, because we don't need to update the
|
||||||
* flat password file.
|
* flat password file.
|
||||||
*/
|
*/
|
||||||
rel = heap_openr(ShadowRelationName, RowExclusiveLock);
|
rel = heap_open(ShadowRelationId, RowExclusiveLock);
|
||||||
oldtuple = SearchSysCache(SHADOWNAME,
|
oldtuple = SearchSysCache(SHADOWNAME,
|
||||||
PointerGetDatum(stmt->user),
|
PointerGetDatum(stmt->user),
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
@ -594,7 +593,7 @@ DropUser(DropUserStmt *stmt)
|
|||||||
* deleted. Note we secure exclusive lock, because we need to protect
|
* deleted. Note we secure exclusive lock, because we need to protect
|
||||||
* our update of the flat password file.
|
* our update of the flat password file.
|
||||||
*/
|
*/
|
||||||
pg_shadow_rel = heap_openr(ShadowRelationName, ExclusiveLock);
|
pg_shadow_rel = heap_open(ShadowRelationId, ExclusiveLock);
|
||||||
pg_shadow_dsc = RelationGetDescr(pg_shadow_rel);
|
pg_shadow_dsc = RelationGetDescr(pg_shadow_rel);
|
||||||
|
|
||||||
foreach(item, stmt->users)
|
foreach(item, stmt->users)
|
||||||
@ -635,7 +634,7 @@ DropUser(DropUserStmt *stmt)
|
|||||||
* don't read the manual, it doesn't seem to be the behaviour one
|
* don't read the manual, it doesn't seem to be the behaviour one
|
||||||
* would expect either.) -- petere 2000/01/14)
|
* would expect either.) -- petere 2000/01/14)
|
||||||
*/
|
*/
|
||||||
pg_rel = heap_openr(DatabaseRelationName, AccessShareLock);
|
pg_rel = heap_open(DatabaseRelationId, AccessShareLock);
|
||||||
pg_dsc = RelationGetDescr(pg_rel);
|
pg_dsc = RelationGetDescr(pg_rel);
|
||||||
|
|
||||||
ScanKeyInit(&scankey,
|
ScanKeyInit(&scankey,
|
||||||
@ -677,7 +676,7 @@ DropUser(DropUserStmt *stmt)
|
|||||||
*
|
*
|
||||||
* try calling alter group drop user for every group
|
* try calling alter group drop user for every group
|
||||||
*/
|
*/
|
||||||
pg_rel = heap_openr(GroupRelationName, ExclusiveLock);
|
pg_rel = heap_open(GroupRelationId, ExclusiveLock);
|
||||||
pg_dsc = RelationGetDescr(pg_rel);
|
pg_dsc = RelationGetDescr(pg_rel);
|
||||||
scan = heap_beginscan(pg_rel, SnapshotNow, 0, NULL);
|
scan = heap_beginscan(pg_rel, SnapshotNow, 0, NULL);
|
||||||
while ((tmp_tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
while ((tmp_tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
||||||
@ -734,7 +733,7 @@ RenameUser(const char *oldname, const char *newname)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* ExclusiveLock because we need to update the password file */
|
/* ExclusiveLock because we need to update the password file */
|
||||||
rel = heap_openr(ShadowRelationName, ExclusiveLock);
|
rel = heap_open(ShadowRelationId, ExclusiveLock);
|
||||||
dsc = RelationGetDescr(rel);
|
dsc = RelationGetDescr(rel);
|
||||||
|
|
||||||
oldtuple = SearchSysCache(SHADOWNAME,
|
oldtuple = SearchSysCache(SHADOWNAME,
|
||||||
@ -819,13 +818,17 @@ CheckPgUserAclNotNull(void)
|
|||||||
elog(ERROR, "cache lookup failed for relation %u", ShadowRelationId);
|
elog(ERROR, "cache lookup failed for relation %u", ShadowRelationId);
|
||||||
|
|
||||||
if (heap_attisnull(htup, Anum_pg_class_relacl))
|
if (heap_attisnull(htup, Anum_pg_class_relacl))
|
||||||
|
{
|
||||||
|
Form_pg_class classForm = (Form_pg_class) GETSTRUCT(htup);
|
||||||
|
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
errmsg("before using passwords you must revoke privileges on %s",
|
errmsg("before using passwords you must revoke privileges on %s",
|
||||||
ShadowRelationName),
|
NameStr(classForm->relname)),
|
||||||
errdetail("This restriction is to prevent unprivileged users from reading the passwords."),
|
errdetail("This restriction is to prevent unprivileged users from reading the passwords."),
|
||||||
errhint("Try REVOKE ALL ON \"%s\" FROM PUBLIC.",
|
errhint("Try REVOKE ALL ON \"%s\" FROM PUBLIC.",
|
||||||
ShadowRelationName)));
|
NameStr(classForm->relname))));
|
||||||
|
}
|
||||||
|
|
||||||
ReleaseSysCache(htup);
|
ReleaseSysCache(htup);
|
||||||
}
|
}
|
||||||
@ -914,7 +917,7 @@ CreateGroup(CreateGroupStmt *stmt)
|
|||||||
* to be sure of what the next grosysid should be, and we need to
|
* to be sure of what the next grosysid should be, and we need to
|
||||||
* protect our eventual update of the flat group file.
|
* protect our eventual update of the flat group file.
|
||||||
*/
|
*/
|
||||||
pg_group_rel = heap_openr(GroupRelationName, ExclusiveLock);
|
pg_group_rel = heap_open(GroupRelationId, ExclusiveLock);
|
||||||
pg_group_dsc = RelationGetDescr(pg_group_rel);
|
pg_group_dsc = RelationGetDescr(pg_group_rel);
|
||||||
|
|
||||||
scan = heap_beginscan(pg_group_rel, SnapshotNow, 0, NULL);
|
scan = heap_beginscan(pg_group_rel, SnapshotNow, 0, NULL);
|
||||||
@ -1032,7 +1035,7 @@ AlterGroup(AlterGroupStmt *stmt, const char *tag)
|
|||||||
/*
|
/*
|
||||||
* Secure exclusive lock to protect our update of the flat group file.
|
* Secure exclusive lock to protect our update of the flat group file.
|
||||||
*/
|
*/
|
||||||
pg_group_rel = heap_openr(GroupRelationName, ExclusiveLock);
|
pg_group_rel = heap_open(GroupRelationId, ExclusiveLock);
|
||||||
pg_group_dsc = RelationGetDescr(pg_group_rel);
|
pg_group_dsc = RelationGetDescr(pg_group_rel);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1271,7 +1274,7 @@ DropGroup(DropGroupStmt *stmt)
|
|||||||
/*
|
/*
|
||||||
* Secure exclusive lock to protect our update of the flat group file.
|
* Secure exclusive lock to protect our update of the flat group file.
|
||||||
*/
|
*/
|
||||||
pg_group_rel = heap_openr(GroupRelationName, ExclusiveLock);
|
pg_group_rel = heap_open(GroupRelationId, ExclusiveLock);
|
||||||
|
|
||||||
/* Find and delete the group. */
|
/* Find and delete the group. */
|
||||||
|
|
||||||
@ -1308,7 +1311,7 @@ RenameGroup(const char *oldname, const char *newname)
|
|||||||
Relation rel;
|
Relation rel;
|
||||||
|
|
||||||
/* ExclusiveLock because we need to update the flat group file */
|
/* ExclusiveLock because we need to update the flat group file */
|
||||||
rel = heap_openr(GroupRelationName, ExclusiveLock);
|
rel = heap_open(GroupRelationId, ExclusiveLock);
|
||||||
|
|
||||||
tup = SearchSysCacheCopy(GRONAME,
|
tup = SearchSysCacheCopy(GRONAME,
|
||||||
CStringGetDatum(oldname),
|
CStringGetDatum(oldname),
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.305 2005/03/20 22:00:52 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.306 2005/04/14 20:03:24 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -28,7 +28,6 @@
|
|||||||
#include "access/subtrans.h"
|
#include "access/subtrans.h"
|
||||||
#include "access/xlog.h"
|
#include "access/xlog.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
#include "catalog/pg_database.h"
|
#include "catalog/pg_database.h"
|
||||||
#include "catalog/pg_index.h"
|
#include "catalog/pg_index.h"
|
||||||
@ -542,7 +541,7 @@ get_rel_oids(const RangeVar *vacrel, const char *stmttype)
|
|||||||
BTEqualStrategyNumber, F_CHAREQ,
|
BTEqualStrategyNumber, F_CHAREQ,
|
||||||
CharGetDatum(RELKIND_RELATION));
|
CharGetDatum(RELKIND_RELATION));
|
||||||
|
|
||||||
pgclass = heap_openr(RelationRelationName, AccessShareLock);
|
pgclass = heap_open(RelationRelationId, AccessShareLock);
|
||||||
|
|
||||||
scan = heap_beginscan(pgclass, SnapshotNow, 1, &key);
|
scan = heap_beginscan(pgclass, SnapshotNow, 1, &key);
|
||||||
|
|
||||||
@ -642,7 +641,7 @@ vac_update_relstats(Oid relid, BlockNumber num_pages, double num_tuples,
|
|||||||
/*
|
/*
|
||||||
* update number of tuples and number of pages in pg_class
|
* update number of tuples and number of pages in pg_class
|
||||||
*/
|
*/
|
||||||
rd = heap_openr(RelationRelationName, RowExclusiveLock);
|
rd = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
ctup = SearchSysCache(RELOID,
|
ctup = SearchSysCache(RELOID,
|
||||||
ObjectIdGetDatum(relid),
|
ObjectIdGetDatum(relid),
|
||||||
@ -718,7 +717,7 @@ vac_update_dbstats(Oid dbid,
|
|||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
Form_pg_database dbform;
|
Form_pg_database dbform;
|
||||||
|
|
||||||
relation = heap_openr(DatabaseRelationName, RowExclusiveLock);
|
relation = heap_open(DatabaseRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/* Must use a heap scan, since there's no syscache for pg_database */
|
/* Must use a heap scan, since there's no syscache for pg_database */
|
||||||
ScanKeyInit(&entry[0],
|
ScanKeyInit(&entry[0],
|
||||||
@ -792,7 +791,7 @@ vac_truncate_clog(TransactionId vacuumXID, TransactionId frozenXID)
|
|||||||
* Note: the "already wrapped" cases should now be impossible due to the
|
* Note: the "already wrapped" cases should now be impossible due to the
|
||||||
* defenses in GetNewTransactionId, but we keep them anyway.
|
* defenses in GetNewTransactionId, but we keep them anyway.
|
||||||
*/
|
*/
|
||||||
relation = heap_openr(DatabaseRelationName, AccessShareLock);
|
relation = heap_open(DatabaseRelationId, AccessShareLock);
|
||||||
|
|
||||||
scan = heap_beginscan(relation, SnapshotNow, 0, NULL);
|
scan = heap_beginscan(relation, SnapshotNow, 0, NULL);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.120 2005/04/06 16:34:04 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.121 2005/04/14 20:03:24 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -40,7 +40,6 @@
|
|||||||
|
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/index.h"
|
#include "catalog/index.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/pg_index.h"
|
#include "catalog/pg_index.h"
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.104 2005/04/06 16:34:06 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.105 2005/04/14 20:03:24 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/pg_amop.h"
|
#include "catalog/pg_amop.h"
|
||||||
#include "catalog/pg_inherits.h"
|
#include "catalog/pg_inherits.h"
|
||||||
#include "catalog/pg_index.h"
|
#include "catalog/pg_index.h"
|
||||||
@ -509,7 +508,7 @@ find_inheritance_children(Oid inhparent)
|
|||||||
Anum_pg_inherits_inhparent,
|
Anum_pg_inherits_inhparent,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(inhparent));
|
ObjectIdGetDatum(inhparent));
|
||||||
relation = heap_openr(InheritsRelationName, AccessShareLock);
|
relation = heap_open(InheritsRelationId, AccessShareLock);
|
||||||
scan = heap_beginscan(relation, SnapshotNow, 1, key);
|
scan = heap_beginscan(relation, SnapshotNow, 1, key);
|
||||||
while ((inheritsTuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
while ((inheritsTuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.319 2005/04/13 16:50:54 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.320 2005/04/14 20:03:24 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -14,7 +14,6 @@
|
|||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/heap.h"
|
#include "catalog/heap.h"
|
||||||
#include "catalog/index.h"
|
#include "catalog/index.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
|
@ -8,14 +8,13 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.177 2005/03/31 22:46:13 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.178 2005/04/14 20:03:25 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/pg_inherits.h"
|
#include "catalog/pg_inherits.h"
|
||||||
#include "catalog/pg_proc.h"
|
#include "catalog/pg_proc.h"
|
||||||
#include "funcapi.h"
|
#include "funcapi.h"
|
||||||
@ -922,7 +921,7 @@ find_inheritors(Oid relid, Oid **supervec)
|
|||||||
queue = list_make1_oid(relid);
|
queue = list_make1_oid(relid);
|
||||||
visited = NIL;
|
visited = NIL;
|
||||||
|
|
||||||
inhrel = heap_openr(InheritsRelationName, AccessShareLock);
|
inhrel = heap_open(InheritsRelationId, AccessShareLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use queue to do a breadth-first traversal of the inheritance graph
|
* Use queue to do a breadth-first traversal of the inheritance graph
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2001-2005, PostgreSQL Global Development Group
|
* Copyright (c) 2001-2005, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.90 2005/04/08 00:55:07 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.91 2005/04/14 20:03:25 tgl Exp $
|
||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "access/xact.h"
|
#include "access/xact.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/pg_database.h"
|
#include "catalog/pg_database.h"
|
||||||
#include "catalog/pg_shadow.h"
|
#include "catalog/pg_shadow.h"
|
||||||
#include "libpq/libpq.h"
|
#include "libpq/libpq.h"
|
||||||
@ -865,7 +864,7 @@ pgstat_vacuum_tabstat(void)
|
|||||||
dbidused = 0;
|
dbidused = 0;
|
||||||
dbidlist = (Oid *) palloc(sizeof(Oid) * dbidalloc);
|
dbidlist = (Oid *) palloc(sizeof(Oid) * dbidalloc);
|
||||||
|
|
||||||
dbrel = heap_openr(DatabaseRelationName, AccessShareLock);
|
dbrel = heap_open(DatabaseRelationId, AccessShareLock);
|
||||||
dbscan = heap_beginscan(dbrel, SnapshotNow, 0, NULL);
|
dbscan = heap_beginscan(dbrel, SnapshotNow, 0, NULL);
|
||||||
while ((dbtup = heap_getnext(dbscan, ForwardScanDirection)) != NULL)
|
while ((dbtup = heap_getnext(dbscan, ForwardScanDirection)) != NULL)
|
||||||
{
|
{
|
||||||
|
@ -8,14 +8,13 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteDefine.c,v 1.103 2005/04/14 01:38:17 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteDefine.c,v 1.104 2005/04/14 20:03:25 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/pg_rewrite.h"
|
#include "catalog/pg_rewrite.h"
|
||||||
@ -87,7 +86,7 @@ InsertRule(char *rulname,
|
|||||||
/*
|
/*
|
||||||
* Ready to store new pg_rewrite tuple
|
* Ready to store new pg_rewrite tuple
|
||||||
*/
|
*/
|
||||||
pg_rewrite_desc = heap_openr(RewriteRelationName, RowExclusiveLock);
|
pg_rewrite_desc = heap_open(RewriteRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check to see if we are replacing an existing tuple
|
* Check to see if we are replacing an existing tuple
|
||||||
@ -139,8 +138,7 @@ InsertRule(char *rulname,
|
|||||||
|
|
||||||
/* If replacing, get rid of old dependencies and make new ones */
|
/* If replacing, get rid of old dependencies and make new ones */
|
||||||
if (is_update)
|
if (is_update)
|
||||||
deleteDependencyRecordsFor(RelationGetRelid(pg_rewrite_desc),
|
deleteDependencyRecordsFor(RewriteRelationId, rewriteObjectId);
|
||||||
rewriteObjectId);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Install dependency on rule's relation to ensure it will go away on
|
* Install dependency on rule's relation to ensure it will go away on
|
||||||
@ -570,7 +568,7 @@ RenameRewriteRule(Oid owningRel, const char *oldName,
|
|||||||
Relation pg_rewrite_desc;
|
Relation pg_rewrite_desc;
|
||||||
HeapTuple ruletup;
|
HeapTuple ruletup;
|
||||||
|
|
||||||
pg_rewrite_desc = heap_openr(RewriteRelationName, RowExclusiveLock);
|
pg_rewrite_desc = heap_open(RewriteRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
ruletup = SearchSysCacheCopy(RULERELNAME,
|
ruletup = SearchSysCacheCopy(RULERELNAME,
|
||||||
ObjectIdGetDatum(owningRel),
|
ObjectIdGetDatum(owningRel),
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteRemove.c,v 1.61 2004/12/31 22:00:46 pgsql Exp $
|
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteRemove.c,v 1.62 2005/04/14 20:03:25 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/pg_rewrite.h"
|
#include "catalog/pg_rewrite.h"
|
||||||
@ -72,7 +71,7 @@ RemoveRewriteRule(Oid owningRel, const char *ruleName, DropBehavior behavior)
|
|||||||
/*
|
/*
|
||||||
* Do the deletion
|
* Do the deletion
|
||||||
*/
|
*/
|
||||||
object.classId = get_system_catalog_relid(RewriteRelationName);
|
object.classId = RewriteRelationId;
|
||||||
object.objectId = HeapTupleGetOid(tuple);
|
object.objectId = HeapTupleGetOid(tuple);
|
||||||
object.objectSubId = 0;
|
object.objectSubId = 0;
|
||||||
|
|
||||||
@ -99,7 +98,7 @@ RemoveRewriteRuleById(Oid ruleOid)
|
|||||||
/*
|
/*
|
||||||
* Open the pg_rewrite relation.
|
* Open the pg_rewrite relation.
|
||||||
*/
|
*/
|
||||||
RewriteRelation = heap_openr(RewriteRelationName, RowExclusiveLock);
|
RewriteRelation = heap_open(RewriteRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the tuple for the target rule.
|
* Find the tuple for the target rule.
|
||||||
@ -109,7 +108,7 @@ RemoveRewriteRuleById(Oid ruleOid)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(ruleOid));
|
ObjectIdGetDatum(ruleOid));
|
||||||
|
|
||||||
rcscan = systable_beginscan(RewriteRelation, RewriteOidIndex, true,
|
rcscan = systable_beginscan(RewriteRelation, RewriteOidIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
tuple = systable_getnext(rcscan);
|
tuple = systable_getnext(rcscan);
|
||||||
|
@ -8,14 +8,13 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteSupport.c,v 1.60 2004/12/31 22:00:46 pgsql Exp $
|
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteSupport.c,v 1.61 2005/04/14 20:03:25 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "rewrite/rewriteSupport.h"
|
#include "rewrite/rewriteSupport.h"
|
||||||
#include "utils/inval.h"
|
#include "utils/inval.h"
|
||||||
@ -60,7 +59,7 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules,
|
|||||||
* Find the tuple to update in pg_class, using syscache for the
|
* Find the tuple to update in pg_class, using syscache for the
|
||||||
* lookup.
|
* lookup.
|
||||||
*/
|
*/
|
||||||
relationRelation = heap_openr(RelationRelationName, RowExclusiveLock);
|
relationRelation = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
tuple = SearchSysCacheCopy(RELOID,
|
tuple = SearchSysCacheCopy(RELOID,
|
||||||
ObjectIdGetDatum(relationId),
|
ObjectIdGetDatum(relationId),
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/storage/large_object/inv_api.c,v 1.109 2005/01/27 23:24:09 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/storage/large_object/inv_api.c,v 1.110 2005/04/14 20:03:25 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -19,7 +19,6 @@
|
|||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "access/tuptoaster.h"
|
#include "access/tuptoaster.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/pg_largeobject.h"
|
#include "catalog/pg_largeobject.h"
|
||||||
#include "commands/comment.h"
|
#include "commands/comment.h"
|
||||||
@ -60,9 +59,9 @@ open_lo_relation(void)
|
|||||||
|
|
||||||
/* Use RowExclusiveLock since we might either read or write */
|
/* Use RowExclusiveLock since we might either read or write */
|
||||||
if (lo_heap_r == NULL)
|
if (lo_heap_r == NULL)
|
||||||
lo_heap_r = heap_openr(LargeObjectRelationName, RowExclusiveLock);
|
lo_heap_r = heap_open(LargeObjectRelationId, RowExclusiveLock);
|
||||||
if (lo_index_r == NULL)
|
if (lo_index_r == NULL)
|
||||||
lo_index_r = index_openr(LargeObjectLOidPNIndex);
|
lo_index_r = index_open(LargeObjectLOidPNIndexId);
|
||||||
}
|
}
|
||||||
PG_CATCH();
|
PG_CATCH();
|
||||||
{
|
{
|
||||||
@ -230,15 +229,10 @@ inv_close(LargeObjectDesc *obj_desc)
|
|||||||
int
|
int
|
||||||
inv_drop(Oid lobjId)
|
inv_drop(Oid lobjId)
|
||||||
{
|
{
|
||||||
Oid classoid;
|
|
||||||
|
|
||||||
LargeObjectDrop(lobjId);
|
LargeObjectDrop(lobjId);
|
||||||
|
|
||||||
/* pg_largeobject doesn't have a hard-coded OID, so must look it up */
|
|
||||||
classoid = get_system_catalog_relid(LargeObjectRelationName);
|
|
||||||
|
|
||||||
/* Delete any comments on the large object */
|
/* Delete any comments on the large object */
|
||||||
DeleteComments(lobjId, classoid, 0);
|
DeleteComments(lobjId, LargeObjectRelationId, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Advance command counter so that tuple removal will be seen by later
|
* Advance command counter so that tuple removal will be seen by later
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.93 2005/03/29 00:17:08 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.94 2005/04/14 20:03:26 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
#include "catalog/pg_operator.h"
|
#include "catalog/pg_operator.h"
|
||||||
@ -97,8 +96,8 @@ regprocin(PG_FUNCTION_ARGS)
|
|||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
CStringGetDatum(pro_name_or_oid));
|
CStringGetDatum(pro_name_or_oid));
|
||||||
|
|
||||||
hdesc = heap_openr(ProcedureRelationName, AccessShareLock);
|
hdesc = heap_open(ProcedureRelationId, AccessShareLock);
|
||||||
sysscan = systable_beginscan(hdesc, ProcedureNameArgsNspIndex, true,
|
sysscan = systable_beginscan(hdesc, ProcedureNameArgsNspIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
|
while (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
|
||||||
@ -447,8 +446,8 @@ regoperin(PG_FUNCTION_ARGS)
|
|||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
CStringGetDatum(opr_name_or_oid));
|
CStringGetDatum(opr_name_or_oid));
|
||||||
|
|
||||||
hdesc = heap_openr(OperatorRelationName, AccessShareLock);
|
hdesc = heap_open(OperatorRelationId, AccessShareLock);
|
||||||
sysscan = systable_beginscan(hdesc, OperatorNameNspIndex, true,
|
sysscan = systable_beginscan(hdesc, OperatorNameNspIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
|
while (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
|
||||||
@ -825,8 +824,8 @@ regclassin(PG_FUNCTION_ARGS)
|
|||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
CStringGetDatum(class_name_or_oid));
|
CStringGetDatum(class_name_or_oid));
|
||||||
|
|
||||||
hdesc = heap_openr(RelationRelationName, AccessShareLock);
|
hdesc = heap_open(RelationRelationId, AccessShareLock);
|
||||||
sysscan = systable_beginscan(hdesc, ClassNameNspIndex, true,
|
sysscan = systable_beginscan(hdesc, ClassNameNspIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
if (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
|
if (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
|
||||||
@ -991,8 +990,8 @@ regtypein(PG_FUNCTION_ARGS)
|
|||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
BTEqualStrategyNumber, F_NAMEEQ,
|
||||||
CStringGetDatum(typ_name_or_oid));
|
CStringGetDatum(typ_name_or_oid));
|
||||||
|
|
||||||
hdesc = heap_openr(TypeRelationName, AccessShareLock);
|
hdesc = heap_open(TypeRelationId, AccessShareLock);
|
||||||
sysscan = systable_beginscan(hdesc, TypeNameNspIndex, true,
|
sysscan = systable_beginscan(hdesc, TypeNameNspIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
if (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
|
if (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* back to source text
|
* back to source text
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.192 2005/04/14 01:38:19 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.193 2005/04/14 20:03:26 tgl Exp $
|
||||||
*
|
*
|
||||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||||
*
|
*
|
||||||
@ -41,7 +41,6 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/dependency.h"
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/heap.h"
|
#include "catalog/heap.h"
|
||||||
#include "catalog/index.h"
|
#include "catalog/index.h"
|
||||||
@ -469,14 +468,14 @@ pg_get_triggerdef(PG_FUNCTION_ARGS)
|
|||||||
/*
|
/*
|
||||||
* Fetch the pg_trigger tuple by the Oid of the trigger
|
* Fetch the pg_trigger tuple by the Oid of the trigger
|
||||||
*/
|
*/
|
||||||
tgrel = heap_openr(TriggerRelationName, AccessShareLock);
|
tgrel = heap_open(TriggerRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&skey[0],
|
ScanKeyInit(&skey[0],
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(trigid));
|
ObjectIdGetDatum(trigid));
|
||||||
|
|
||||||
tgscan = systable_beginscan(tgrel, TriggerOidIndex, true,
|
tgscan = systable_beginscan(tgrel, TriggerOidIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
ht_trig = systable_getnext(tgscan);
|
ht_trig = systable_getnext(tgscan);
|
||||||
@ -867,14 +866,14 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
|
|||||||
* Fetch the pg_constraint row. There's no syscache for pg_constraint
|
* Fetch the pg_constraint row. There's no syscache for pg_constraint
|
||||||
* so we must do it the hard way.
|
* so we must do it the hard way.
|
||||||
*/
|
*/
|
||||||
conDesc = heap_openr(ConstraintRelationName, AccessShareLock);
|
conDesc = heap_open(ConstraintRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&skey[0],
|
ScanKeyInit(&skey[0],
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(constraintId));
|
ObjectIdGetDatum(constraintId));
|
||||||
|
|
||||||
conscan = systable_beginscan(conDesc, ConstraintOidIndex, true,
|
conscan = systable_beginscan(conDesc, ConstraintOidIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
tup = systable_getnext(conscan);
|
tup = systable_getnext(conscan);
|
||||||
@ -1269,7 +1268,7 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS)
|
|||||||
column, tablerv->relname)));
|
column, tablerv->relname)));
|
||||||
|
|
||||||
/* Search the dependency table for the dependent sequence */
|
/* Search the dependency table for the dependent sequence */
|
||||||
depRel = heap_openr(DependRelationName, AccessShareLock);
|
depRel = heap_open(DependRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&key[0],
|
ScanKeyInit(&key[0],
|
||||||
Anum_pg_depend_refclassid,
|
Anum_pg_depend_refclassid,
|
||||||
@ -1284,7 +1283,7 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS)
|
|||||||
BTEqualStrategyNumber, F_INT4EQ,
|
BTEqualStrategyNumber, F_INT4EQ,
|
||||||
Int32GetDatum(attnum));
|
Int32GetDatum(attnum));
|
||||||
|
|
||||||
scan = systable_beginscan(depRel, DependReferenceIndex, true,
|
scan = systable_beginscan(depRel, DependReferenceIndexId, true,
|
||||||
SnapshotNow, 3, key);
|
SnapshotNow, 3, key);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.176 2005/04/01 20:31:50 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.177 2005/04/14 20:03:26 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -79,7 +79,6 @@
|
|||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "access/nbtree.h"
|
#include "access/nbtree.h"
|
||||||
#include "access/tuptoaster.h"
|
#include "access/tuptoaster.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/pg_namespace.h"
|
#include "catalog/pg_namespace.h"
|
||||||
#include "catalog/pg_opclass.h"
|
#include "catalog/pg_opclass.h"
|
||||||
#include "catalog/pg_operator.h"
|
#include "catalog/pg_operator.h"
|
||||||
|
55
src/backend/utils/cache/catcache.c
vendored
55
src/backend/utils/cache/catcache.c
vendored
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.119 2005/03/25 18:30:27 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.120 2005/04/14 20:03:26 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -21,7 +21,6 @@
|
|||||||
#include "catalog/pg_opclass.h"
|
#include "catalog/pg_opclass.h"
|
||||||
#include "catalog/pg_operator.h"
|
#include "catalog/pg_operator.h"
|
||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
#ifdef CATCACHE_STATS
|
#ifdef CATCACHE_STATS
|
||||||
@ -35,7 +34,7 @@
|
|||||||
#include "utils/syscache.h"
|
#include "utils/syscache.h"
|
||||||
|
|
||||||
|
|
||||||
/* #define CACHEDEBUG */ /* turns DEBUG elogs on */
|
/* #define CACHEDEBUG */ /* turns DEBUG elogs on */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constants related to size of the catcache.
|
* Constants related to size of the catcache.
|
||||||
@ -297,9 +296,9 @@ CatCachePrintStats(void)
|
|||||||
{
|
{
|
||||||
if (cache->cc_ntup == 0 && cache->cc_searches == 0)
|
if (cache->cc_ntup == 0 && cache->cc_searches == 0)
|
||||||
continue; /* don't print unused caches */
|
continue; /* don't print unused caches */
|
||||||
elog(DEBUG2, "catcache %s/%s: %d tup, %ld srch, %ld+%ld=%ld hits, %ld+%ld=%ld loads, %ld invals, %ld discards, %ld lsrch, %ld lhits",
|
elog(DEBUG2, "catcache %s/%u: %d tup, %ld srch, %ld+%ld=%ld hits, %ld+%ld=%ld loads, %ld invals, %ld discards, %ld lsrch, %ld lhits",
|
||||||
cache->cc_relname,
|
cache->cc_relname,
|
||||||
cache->cc_indname,
|
cache->cc_indexoid,
|
||||||
cache->cc_ntup,
|
cache->cc_ntup,
|
||||||
cache->cc_searches,
|
cache->cc_searches,
|
||||||
cache->cc_hits,
|
cache->cc_hits,
|
||||||
@ -763,8 +762,9 @@ CatalogCacheFlushRelation(Oid relId)
|
|||||||
#ifdef CACHEDEBUG
|
#ifdef CACHEDEBUG
|
||||||
#define InitCatCache_DEBUG2 \
|
#define InitCatCache_DEBUG2 \
|
||||||
do { \
|
do { \
|
||||||
elog(DEBUG2, "InitCatCache: rel=%s id=%d nkeys=%d size=%d", \
|
elog(DEBUG2, "InitCatCache: rel=%u ind=%u id=%d nkeys=%d size=%d", \
|
||||||
cp->cc_relname, cp->id, cp->cc_nkeys, cp->cc_nbuckets); \
|
cp->cc_reloid, cp->cc_indexoid, cp->id, \
|
||||||
|
cp->cc_nkeys, cp->cc_nbuckets); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -773,8 +773,8 @@ do { \
|
|||||||
|
|
||||||
CatCache *
|
CatCache *
|
||||||
InitCatCache(int id,
|
InitCatCache(int id,
|
||||||
const char *relname,
|
Oid reloid,
|
||||||
const char *indname,
|
Oid indexoid,
|
||||||
int reloidattr,
|
int reloidattr,
|
||||||
int nkeys,
|
int nkeys,
|
||||||
const int *key)
|
const int *key)
|
||||||
@ -821,9 +821,9 @@ InitCatCache(int id,
|
|||||||
* other internal fields. But don't open the relation yet.
|
* other internal fields. But don't open the relation yet.
|
||||||
*/
|
*/
|
||||||
cp->id = id;
|
cp->id = id;
|
||||||
cp->cc_relname = relname;
|
cp->cc_relname = "(not known yet)";
|
||||||
cp->cc_indname = indname;
|
cp->cc_reloid = reloid;
|
||||||
cp->cc_reloid = InvalidOid; /* temporary */
|
cp->cc_indexoid = indexoid;
|
||||||
cp->cc_relisshared = false; /* temporary */
|
cp->cc_relisshared = false; /* temporary */
|
||||||
cp->cc_tupdesc = (TupleDesc) NULL;
|
cp->cc_tupdesc = (TupleDesc) NULL;
|
||||||
cp->cc_reloidattr = reloidattr;
|
cp->cc_reloidattr = reloidattr;
|
||||||
@ -861,9 +861,9 @@ InitCatCache(int id,
|
|||||||
* that the relcache entry can be opened at this point!
|
* that the relcache entry can be opened at this point!
|
||||||
*/
|
*/
|
||||||
#ifdef CACHEDEBUG
|
#ifdef CACHEDEBUG
|
||||||
#define CatalogCacheInitializeCache_DEBUG2 \
|
#define CatalogCacheInitializeCache_DEBUG1 \
|
||||||
elog(DEBUG2, "CatalogCacheInitializeCache: cache @%p %s", cache, \
|
elog(DEBUG2, "CatalogCacheInitializeCache: cache @%p rel=%u", cache, \
|
||||||
cache->cc_relname)
|
cache->cc_reloid)
|
||||||
|
|
||||||
#define CatalogCacheInitializeCache_DEBUG2 \
|
#define CatalogCacheInitializeCache_DEBUG2 \
|
||||||
do { \
|
do { \
|
||||||
@ -878,7 +878,7 @@ do { \
|
|||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define CatalogCacheInitializeCache_DEBUG2
|
#define CatalogCacheInitializeCache_DEBUG1
|
||||||
#define CatalogCacheInitializeCache_DEBUG2
|
#define CatalogCacheInitializeCache_DEBUG2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -890,13 +890,13 @@ CatalogCacheInitializeCache(CatCache *cache)
|
|||||||
TupleDesc tupdesc;
|
TupleDesc tupdesc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
CatalogCacheInitializeCache_DEBUG2;
|
CatalogCacheInitializeCache_DEBUG1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open the relation without locking --- we only need the tupdesc,
|
* Open the relation without locking --- we only need the tupdesc,
|
||||||
* which we assume will never change ...
|
* which we assume will never change ...
|
||||||
*/
|
*/
|
||||||
relation = heap_openr(cache->cc_relname, NoLock);
|
relation = heap_open(cache->cc_reloid, NoLock);
|
||||||
Assert(RelationIsValid(relation));
|
Assert(RelationIsValid(relation));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -913,9 +913,10 @@ CatalogCacheInitializeCache(CatCache *cache)
|
|||||||
tupdesc = CreateTupleDescCopyConstr(RelationGetDescr(relation));
|
tupdesc = CreateTupleDescCopyConstr(RelationGetDescr(relation));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get the relation's OID and relisshared flag, too
|
* save the relation's name and relisshared flag, too (cc_relname
|
||||||
|
* is used only for debugging purposes)
|
||||||
*/
|
*/
|
||||||
cache->cc_reloid = RelationGetRelid(relation);
|
cache->cc_relname = pstrdup(RelationGetRelationName(relation));
|
||||||
cache->cc_relisshared = RelationGetForm(relation)->relisshared;
|
cache->cc_relisshared = RelationGetForm(relation)->relisshared;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -999,7 +1000,7 @@ InitCatCachePhase2(CatCache *cache)
|
|||||||
{
|
{
|
||||||
Relation idesc;
|
Relation idesc;
|
||||||
|
|
||||||
idesc = index_openr(cache->cc_indname);
|
idesc = index_open(cache->cc_indexoid);
|
||||||
index_close(idesc);
|
index_close(idesc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1202,7 +1203,7 @@ SearchCatCache(CatCache *cache,
|
|||||||
relation = heap_open(cache->cc_reloid, AccessShareLock);
|
relation = heap_open(cache->cc_reloid, AccessShareLock);
|
||||||
|
|
||||||
scandesc = systable_beginscan(relation,
|
scandesc = systable_beginscan(relation,
|
||||||
cache->cc_indname,
|
cache->cc_indexoid,
|
||||||
IndexScanOK(cache, cur_skey),
|
IndexScanOK(cache, cur_skey),
|
||||||
SnapshotNow,
|
SnapshotNow,
|
||||||
cache->cc_nkeys,
|
cache->cc_nkeys,
|
||||||
@ -1230,9 +1231,17 @@ SearchCatCache(CatCache *cache,
|
|||||||
* If tuple was not found, we need to build a negative cache entry
|
* If tuple was not found, we need to build a negative cache entry
|
||||||
* containing a fake tuple. The fake tuple has the correct key
|
* containing a fake tuple. The fake tuple has the correct key
|
||||||
* columns, but nulls everywhere else.
|
* columns, but nulls everywhere else.
|
||||||
|
*
|
||||||
|
* In bootstrap mode, we don't build negative entries, because the
|
||||||
|
* cache invalidation mechanism isn't alive and can't clear them
|
||||||
|
* if the tuple gets created later. (Bootstrap doesn't do UPDATEs,
|
||||||
|
* so it doesn't need cache inval for that.)
|
||||||
*/
|
*/
|
||||||
if (ct == NULL)
|
if (ct == NULL)
|
||||||
{
|
{
|
||||||
|
if (IsBootstrapProcessingMode())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
ntp = build_dummy_tuple(cache, cache->cc_nkeys, cur_skey);
|
ntp = build_dummy_tuple(cache, cache->cc_nkeys, cur_skey);
|
||||||
ct = CatalogCacheCreateEntry(cache, ntp,
|
ct = CatalogCacheCreateEntry(cache, ntp,
|
||||||
hashValue, hashIndex,
|
hashValue, hashIndex,
|
||||||
@ -1427,7 +1436,7 @@ SearchCatCacheList(CatCache *cache,
|
|||||||
relation = heap_open(cache->cc_reloid, AccessShareLock);
|
relation = heap_open(cache->cc_reloid, AccessShareLock);
|
||||||
|
|
||||||
scandesc = systable_beginscan(relation,
|
scandesc = systable_beginscan(relation,
|
||||||
cache->cc_indname,
|
cache->cc_indexoid,
|
||||||
true,
|
true,
|
||||||
SnapshotNow,
|
SnapshotNow,
|
||||||
nkeys,
|
nkeys,
|
||||||
|
21
src/backend/utils/cache/lsyscache.c
vendored
21
src/backend/utils/cache/lsyscache.c
vendored
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.123 2005/04/11 23:06:56 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.124 2005/04/14 20:03:26 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Eventually, the index information should go through here, too.
|
* Eventually, the index information should go through here, too.
|
||||||
@ -931,25 +931,6 @@ get_relname_relid(const char *relname, Oid relnamespace)
|
|||||||
0, 0);
|
0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* get_system_catalog_relid
|
|
||||||
* Get the OID of a system catalog identified by name.
|
|
||||||
*/
|
|
||||||
Oid
|
|
||||||
get_system_catalog_relid(const char *catname)
|
|
||||||
{
|
|
||||||
Oid relid;
|
|
||||||
|
|
||||||
relid = GetSysCacheOid(RELNAMENSP,
|
|
||||||
PointerGetDatum(catname),
|
|
||||||
ObjectIdGetDatum(PG_CATALOG_NAMESPACE),
|
|
||||||
0, 0);
|
|
||||||
if (!OidIsValid(relid))
|
|
||||||
elog(ERROR, "cache lookup failed for system relation %s", catname);
|
|
||||||
|
|
||||||
return relid;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef NOT_USED
|
#ifdef NOT_USED
|
||||||
/*
|
/*
|
||||||
* get_relnatts
|
* get_relnatts
|
||||||
|
315
src/backend/utils/cache/relcache.c
vendored
315
src/backend/utils/cache/relcache.c
vendored
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.219 2005/04/14 01:38:19 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.220 2005/04/14 20:03:26 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -17,7 +17,6 @@
|
|||||||
* RelationCacheInitialize - initialize relcache
|
* RelationCacheInitialize - initialize relcache
|
||||||
* RelationCacheInitializePhase2 - finish initializing relcache
|
* RelationCacheInitializePhase2 - finish initializing relcache
|
||||||
* RelationIdGetRelation - get a reldesc by relation id
|
* RelationIdGetRelation - get a reldesc by relation id
|
||||||
* RelationSysNameGetRelation - get a reldesc by system rel name
|
|
||||||
* RelationIdCacheGetRelation - get a cached reldesc by relid
|
* RelationIdCacheGetRelation - get a cached reldesc by relid
|
||||||
* RelationClose - close an open relation
|
* RelationClose - close an open relation
|
||||||
*
|
*
|
||||||
@ -34,7 +33,6 @@
|
|||||||
#include "access/genam.h"
|
#include "access/genam.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
#include "catalog/pg_amop.h"
|
#include "catalog/pg_amop.h"
|
||||||
@ -85,14 +83,16 @@ static FormData_pg_attribute Desc_pg_index[Natts_pg_index] = {Schema_pg_index};
|
|||||||
/*
|
/*
|
||||||
* Hash tables that index the relation cache
|
* Hash tables that index the relation cache
|
||||||
*
|
*
|
||||||
* Relations are looked up two ways, by OID and by name,
|
* We used to index the cache by both name and OID, but now there
|
||||||
* thus there are two hash tables for referencing them.
|
* is only an index by OID.
|
||||||
*
|
|
||||||
* The OID index covers all relcache entries. The name index
|
|
||||||
* covers *only* system relations (only those in PG_CATALOG_NAMESPACE).
|
|
||||||
*/
|
*/
|
||||||
|
typedef struct relidcacheent
|
||||||
|
{
|
||||||
|
Oid reloid;
|
||||||
|
Relation reldesc;
|
||||||
|
} RelIdCacheEnt;
|
||||||
|
|
||||||
static HTAB *RelationIdCache;
|
static HTAB *RelationIdCache;
|
||||||
static HTAB *RelationSysNameCache;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This flag is false until we have prepared the critical relcache entries
|
* This flag is false until we have prepared the critical relcache entries
|
||||||
@ -125,33 +125,6 @@ static List *initFileRelationIds = NIL;
|
|||||||
*/
|
*/
|
||||||
static bool need_eosubxact_work = false;
|
static bool need_eosubxact_work = false;
|
||||||
|
|
||||||
/*
|
|
||||||
* RelationBuildDescInfo exists so code can be shared
|
|
||||||
* between RelationIdGetRelation() and RelationSysNameGetRelation()
|
|
||||||
*/
|
|
||||||
typedef struct RelationBuildDescInfo
|
|
||||||
{
|
|
||||||
int infotype; /* lookup by id or by name */
|
|
||||||
#define INFO_RELID 1
|
|
||||||
#define INFO_RELNAME 2
|
|
||||||
union
|
|
||||||
{
|
|
||||||
Oid info_id; /* relation object id */
|
|
||||||
char *info_name; /* system relation name */
|
|
||||||
} i;
|
|
||||||
} RelationBuildDescInfo;
|
|
||||||
|
|
||||||
typedef struct relidcacheent
|
|
||||||
{
|
|
||||||
Oid reloid;
|
|
||||||
Relation reldesc;
|
|
||||||
} RelIdCacheEnt;
|
|
||||||
|
|
||||||
typedef struct relnamecacheent
|
|
||||||
{
|
|
||||||
NameData relname;
|
|
||||||
Relation reldesc;
|
|
||||||
} RelNameCacheEnt;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* macros to manipulate the lookup hashtables
|
* macros to manipulate the lookup hashtables
|
||||||
@ -169,39 +142,13 @@ do { \
|
|||||||
errmsg("out of memory"))); \
|
errmsg("out of memory"))); \
|
||||||
/* used to give notice if found -- now just keep quiet */ \
|
/* used to give notice if found -- now just keep quiet */ \
|
||||||
idhentry->reldesc = RELATION; \
|
idhentry->reldesc = RELATION; \
|
||||||
if (IsSystemNamespace(RelationGetNamespace(RELATION))) \
|
|
||||||
{ \
|
|
||||||
char *relname = RelationGetRelationName(RELATION); \
|
|
||||||
RelNameCacheEnt *namehentry; \
|
|
||||||
namehentry = (RelNameCacheEnt*)hash_search(RelationSysNameCache, \
|
|
||||||
relname, \
|
|
||||||
HASH_ENTER, \
|
|
||||||
&found); \
|
|
||||||
if (namehentry == NULL) \
|
|
||||||
ereport(ERROR, \
|
|
||||||
(errcode(ERRCODE_OUT_OF_MEMORY), \
|
|
||||||
errmsg("out of memory"))); \
|
|
||||||
/* used to give notice if found -- now just keep quiet */ \
|
|
||||||
namehentry->reldesc = RELATION; \
|
|
||||||
} \
|
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define RelationIdCacheLookup(ID, RELATION) \
|
#define RelationIdCacheLookup(ID, RELATION) \
|
||||||
do { \
|
do { \
|
||||||
RelIdCacheEnt *hentry; \
|
RelIdCacheEnt *hentry; \
|
||||||
hentry = (RelIdCacheEnt*)hash_search(RelationIdCache, \
|
hentry = (RelIdCacheEnt*)hash_search(RelationIdCache, \
|
||||||
(void *)&(ID), HASH_FIND,NULL); \
|
(void *) &(ID), HASH_FIND,NULL); \
|
||||||
if (hentry) \
|
|
||||||
RELATION = hentry->reldesc; \
|
|
||||||
else \
|
|
||||||
RELATION = NULL; \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
#define RelationSysNameCacheLookup(NAME, RELATION) \
|
|
||||||
do { \
|
|
||||||
RelNameCacheEnt *hentry; \
|
|
||||||
hentry = (RelNameCacheEnt*)hash_search(RelationSysNameCache, \
|
|
||||||
(void *) (NAME), HASH_FIND,NULL); \
|
|
||||||
if (hentry) \
|
if (hentry) \
|
||||||
RELATION = hentry->reldesc; \
|
RELATION = hentry->reldesc; \
|
||||||
else \
|
else \
|
||||||
@ -212,20 +159,10 @@ do { \
|
|||||||
do { \
|
do { \
|
||||||
RelIdCacheEnt *idhentry; \
|
RelIdCacheEnt *idhentry; \
|
||||||
idhentry = (RelIdCacheEnt*)hash_search(RelationIdCache, \
|
idhentry = (RelIdCacheEnt*)hash_search(RelationIdCache, \
|
||||||
(void *)&(RELATION->rd_id), \
|
(void *) &(RELATION->rd_id), \
|
||||||
HASH_REMOVE, NULL); \
|
HASH_REMOVE, NULL); \
|
||||||
if (idhentry == NULL) \
|
if (idhentry == NULL) \
|
||||||
elog(WARNING, "trying to delete a rd_id reldesc that does not exist"); \
|
elog(WARNING, "trying to delete a rd_id reldesc that does not exist"); \
|
||||||
if (IsSystemNamespace(RelationGetNamespace(RELATION))) \
|
|
||||||
{ \
|
|
||||||
char *relname = RelationGetRelationName(RELATION); \
|
|
||||||
RelNameCacheEnt *namehentry; \
|
|
||||||
namehentry = (RelNameCacheEnt*)hash_search(RelationSysNameCache, \
|
|
||||||
relname, \
|
|
||||||
HASH_REMOVE, NULL); \
|
|
||||||
if (namehentry == NULL) \
|
|
||||||
elog(WARNING, "trying to delete a relname reldesc that does not exist"); \
|
|
||||||
} \
|
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
|
||||||
@ -253,19 +190,16 @@ static void RelationClearRelation(Relation relation, bool rebuild);
|
|||||||
|
|
||||||
static void RelationReloadClassinfo(Relation relation);
|
static void RelationReloadClassinfo(Relation relation);
|
||||||
static void RelationFlushRelation(Relation relation);
|
static void RelationFlushRelation(Relation relation);
|
||||||
static Relation RelationSysNameCacheGetRelation(const char *relationName);
|
|
||||||
static bool load_relcache_init_file(void);
|
static bool load_relcache_init_file(void);
|
||||||
static void write_relcache_init_file(void);
|
static void write_relcache_init_file(void);
|
||||||
|
|
||||||
static void formrdesc(const char *relationName, Oid relationReltype,
|
static void formrdesc(const char *relationName, Oid relationReltype,
|
||||||
bool hasoids, int natts, FormData_pg_attribute *att);
|
bool hasoids, int natts, FormData_pg_attribute *att);
|
||||||
|
|
||||||
static HeapTuple ScanPgRelation(RelationBuildDescInfo buildinfo, bool indexOK);
|
static HeapTuple ScanPgRelation(Oid targetRelId, bool indexOK);
|
||||||
static Relation AllocateRelationDesc(Relation relation, Form_pg_class relp);
|
static Relation AllocateRelationDesc(Relation relation, Form_pg_class relp);
|
||||||
static void RelationBuildTupleDesc(RelationBuildDescInfo buildinfo,
|
static void RelationBuildTupleDesc(Relation relation);
|
||||||
Relation relation);
|
static Relation RelationBuildDesc(Oid targetRelId, Relation oldrelation);
|
||||||
static Relation RelationBuildDesc(RelationBuildDescInfo buildinfo,
|
|
||||||
Relation oldrelation);
|
|
||||||
static void RelationInitPhysicalAddr(Relation relation);
|
static void RelationInitPhysicalAddr(Relation relation);
|
||||||
static TupleDesc GetPgIndexDescriptor(void);
|
static TupleDesc GetPgIndexDescriptor(void);
|
||||||
static void AttrDefaultFetch(Relation relation);
|
static void AttrDefaultFetch(Relation relation);
|
||||||
@ -286,54 +220,26 @@ static OpClassCacheEnt *LookupOpclassInfo(Oid operatorClassOid,
|
|||||||
* ScanPgRelation
|
* ScanPgRelation
|
||||||
*
|
*
|
||||||
* this is used by RelationBuildDesc to find a pg_class
|
* this is used by RelationBuildDesc to find a pg_class
|
||||||
* tuple matching either a relation name or a relation id
|
* tuple matching targetRelId.
|
||||||
* as specified in buildinfo.
|
|
||||||
*
|
*
|
||||||
* NB: the returned tuple has been copied into palloc'd storage
|
* NB: the returned tuple has been copied into palloc'd storage
|
||||||
* and must eventually be freed with heap_freetuple.
|
* and must eventually be freed with heap_freetuple.
|
||||||
*/
|
*/
|
||||||
static HeapTuple
|
static HeapTuple
|
||||||
ScanPgRelation(RelationBuildDescInfo buildinfo, bool indexOK)
|
ScanPgRelation(Oid targetRelId, bool indexOK)
|
||||||
{
|
{
|
||||||
HeapTuple pg_class_tuple;
|
HeapTuple pg_class_tuple;
|
||||||
Relation pg_class_desc;
|
Relation pg_class_desc;
|
||||||
const char *indexRelname;
|
|
||||||
SysScanDesc pg_class_scan;
|
SysScanDesc pg_class_scan;
|
||||||
ScanKeyData key[2];
|
ScanKeyData key[1];
|
||||||
int nkeys;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* form a scan key
|
* form a scan key
|
||||||
*/
|
*/
|
||||||
switch (buildinfo.infotype)
|
ScanKeyInit(&key[0],
|
||||||
{
|
ObjectIdAttributeNumber,
|
||||||
case INFO_RELID:
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ScanKeyInit(&key[0],
|
ObjectIdGetDatum(targetRelId));
|
||||||
ObjectIdAttributeNumber,
|
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
|
||||||
ObjectIdGetDatum(buildinfo.i.info_id));
|
|
||||||
nkeys = 1;
|
|
||||||
indexRelname = ClassOidIndex;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INFO_RELNAME:
|
|
||||||
ScanKeyInit(&key[0],
|
|
||||||
Anum_pg_class_relname,
|
|
||||||
BTEqualStrategyNumber, F_NAMEEQ,
|
|
||||||
NameGetDatum(buildinfo.i.info_name));
|
|
||||||
ScanKeyInit(&key[1],
|
|
||||||
Anum_pg_class_relnamespace,
|
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
|
||||||
ObjectIdGetDatum(PG_CATALOG_NAMESPACE));
|
|
||||||
nkeys = 2;
|
|
||||||
indexRelname = ClassNameNspIndex;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
elog(ERROR, "unrecognized buildinfo type: %d",
|
|
||||||
buildinfo.infotype);
|
|
||||||
return NULL; /* keep compiler quiet */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open pg_class and fetch a tuple. Force heap scan if we haven't yet
|
* Open pg_class and fetch a tuple. Force heap scan if we haven't yet
|
||||||
@ -341,11 +247,11 @@ ScanPgRelation(RelationBuildDescInfo buildinfo, bool indexOK)
|
|||||||
* startup without a pg_internal.init file). The caller can also
|
* startup without a pg_internal.init file). The caller can also
|
||||||
* force a heap scan by setting indexOK == false.
|
* force a heap scan by setting indexOK == false.
|
||||||
*/
|
*/
|
||||||
pg_class_desc = heap_openr(RelationRelationName, AccessShareLock);
|
pg_class_desc = heap_open(RelationRelationId, AccessShareLock);
|
||||||
pg_class_scan = systable_beginscan(pg_class_desc, indexRelname,
|
pg_class_scan = systable_beginscan(pg_class_desc, ClassOidIndexId,
|
||||||
indexOK && criticalRelcachesBuilt,
|
indexOK && criticalRelcachesBuilt,
|
||||||
SnapshotNow,
|
SnapshotNow,
|
||||||
nkeys, key);
|
1, key);
|
||||||
|
|
||||||
pg_class_tuple = systable_getnext(pg_class_scan);
|
pg_class_tuple = systable_getnext(pg_class_scan);
|
||||||
|
|
||||||
@ -429,8 +335,7 @@ AllocateRelationDesc(Relation relation, Form_pg_class relp)
|
|||||||
* the pg_attribute, pg_attrdef & pg_constraint system catalogs.
|
* the pg_attribute, pg_attrdef & pg_constraint system catalogs.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
RelationBuildTupleDesc(RelationBuildDescInfo buildinfo,
|
RelationBuildTupleDesc(Relation relation)
|
||||||
Relation relation)
|
|
||||||
{
|
{
|
||||||
HeapTuple pg_attribute_tuple;
|
HeapTuple pg_attribute_tuple;
|
||||||
Relation pg_attribute_desc;
|
Relation pg_attribute_desc;
|
||||||
@ -469,9 +374,9 @@ RelationBuildTupleDesc(RelationBuildDescInfo buildinfo,
|
|||||||
* yet built the critical relcache entries (this includes initdb and
|
* yet built the critical relcache entries (this includes initdb and
|
||||||
* startup without a pg_internal.init file).
|
* startup without a pg_internal.init file).
|
||||||
*/
|
*/
|
||||||
pg_attribute_desc = heap_openr(AttributeRelationName, AccessShareLock);
|
pg_attribute_desc = heap_open(AttributeRelationId, AccessShareLock);
|
||||||
pg_attribute_scan = systable_beginscan(pg_attribute_desc,
|
pg_attribute_scan = systable_beginscan(pg_attribute_desc,
|
||||||
AttributeRelidNumIndex,
|
AttributeRelidNumIndexId,
|
||||||
criticalRelcachesBuilt,
|
criticalRelcachesBuilt,
|
||||||
SnapshotNow,
|
SnapshotNow,
|
||||||
2, skey);
|
2, skey);
|
||||||
@ -648,15 +553,15 @@ RelationBuildRuleLock(Relation relation)
|
|||||||
/*
|
/*
|
||||||
* open pg_rewrite and begin a scan
|
* open pg_rewrite and begin a scan
|
||||||
*
|
*
|
||||||
* Note: since we scan the rules using RewriteRelRulenameIndex, we will
|
* Note: since we scan the rules using RewriteRelRulenameIndexId,
|
||||||
* be reading the rules in name order, except possibly during
|
* we will be reading the rules in name order, except possibly during
|
||||||
* emergency-recovery operations (ie, IsIgnoringSystemIndexes). This
|
* emergency-recovery operations (ie, IsIgnoringSystemIndexes). This
|
||||||
* in turn ensures that rules will be fired in name order.
|
* in turn ensures that rules will be fired in name order.
|
||||||
*/
|
*/
|
||||||
rewrite_desc = heap_openr(RewriteRelationName, AccessShareLock);
|
rewrite_desc = heap_open(RewriteRelationId, AccessShareLock);
|
||||||
rewrite_tupdesc = RelationGetDescr(rewrite_desc);
|
rewrite_tupdesc = RelationGetDescr(rewrite_desc);
|
||||||
rewrite_scan = systable_beginscan(rewrite_desc,
|
rewrite_scan = systable_beginscan(rewrite_desc,
|
||||||
RewriteRelRulenameIndex,
|
RewriteRelRulenameIndexId,
|
||||||
true, SnapshotNow,
|
true, SnapshotNow,
|
||||||
1, &key);
|
1, &key);
|
||||||
|
|
||||||
@ -788,8 +693,7 @@ equalRuleLocks(RuleLock *rlock1, RuleLock *rlock2)
|
|||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static Relation
|
static Relation
|
||||||
RelationBuildDesc(RelationBuildDescInfo buildinfo,
|
RelationBuildDesc(Oid targetRelId, Relation oldrelation)
|
||||||
Relation oldrelation)
|
|
||||||
{
|
{
|
||||||
Relation relation;
|
Relation relation;
|
||||||
Oid relid;
|
Oid relid;
|
||||||
@ -800,7 +704,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo,
|
|||||||
/*
|
/*
|
||||||
* find the tuple in pg_class corresponding to the given relation id
|
* find the tuple in pg_class corresponding to the given relation id
|
||||||
*/
|
*/
|
||||||
pg_class_tuple = ScanPgRelation(buildinfo, true);
|
pg_class_tuple = ScanPgRelation(targetRelId, true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if no such tuple exists, return NULL
|
* if no such tuple exists, return NULL
|
||||||
@ -844,7 +748,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo,
|
|||||||
/*
|
/*
|
||||||
* initialize the tuple descriptor (relation->rd_att).
|
* initialize the tuple descriptor (relation->rd_att).
|
||||||
*/
|
*/
|
||||||
RelationBuildTupleDesc(buildinfo, relation);
|
RelationBuildTupleDesc(relation);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fetch rules and triggers that affect this relation
|
* Fetch rules and triggers that affect this relation
|
||||||
@ -1191,9 +1095,8 @@ LookupOpclassInfo(Oid operatorClassOid,
|
|||||||
Anum_pg_amop_amopsubtype,
|
Anum_pg_amop_amopsubtype,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(InvalidOid));
|
ObjectIdGetDatum(InvalidOid));
|
||||||
rel = heap_openr(AccessMethodOperatorRelationName,
|
rel = heap_open(AccessMethodOperatorRelationId, AccessShareLock);
|
||||||
AccessShareLock);
|
scan = systable_beginscan(rel, AccessMethodStrategyIndexId, indexOK,
|
||||||
scan = systable_beginscan(rel, AccessMethodStrategyIndex, indexOK,
|
|
||||||
SnapshotNow, 2, skey);
|
SnapshotNow, 2, skey);
|
||||||
|
|
||||||
while (HeapTupleIsValid(htup = systable_getnext(scan)))
|
while (HeapTupleIsValid(htup = systable_getnext(scan)))
|
||||||
@ -1226,9 +1129,8 @@ LookupOpclassInfo(Oid operatorClassOid,
|
|||||||
Anum_pg_amproc_amprocsubtype,
|
Anum_pg_amproc_amprocsubtype,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(InvalidOid));
|
ObjectIdGetDatum(InvalidOid));
|
||||||
rel = heap_openr(AccessMethodProcedureRelationName,
|
rel = heap_open(AccessMethodProcedureRelationId, AccessShareLock);
|
||||||
AccessShareLock);
|
scan = systable_beginscan(rel, AccessMethodProcedureIndexId, indexOK,
|
||||||
scan = systable_beginscan(rel, AccessMethodProcedureIndex, indexOK,
|
|
||||||
SnapshotNow, 2, skey);
|
SnapshotNow, 2, skey);
|
||||||
|
|
||||||
while (HeapTupleIsValid(htup = systable_getnext(scan)))
|
while (HeapTupleIsValid(htup = systable_getnext(scan)))
|
||||||
@ -1440,35 +1342,6 @@ RelationIdCacheGetRelation(Oid relationId)
|
|||||||
return rd;
|
return rd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* RelationSysNameCacheGetRelation
|
|
||||||
*
|
|
||||||
* As above, but lookup by name; only works for system catalogs.
|
|
||||||
*/
|
|
||||||
static Relation
|
|
||||||
RelationSysNameCacheGetRelation(const char *relationName)
|
|
||||||
{
|
|
||||||
Relation rd;
|
|
||||||
NameData name;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* make sure that the name key used for hash lookup is properly
|
|
||||||
* null-padded
|
|
||||||
*/
|
|
||||||
namestrcpy(&name, relationName);
|
|
||||||
RelationSysNameCacheLookup(NameStr(name), rd);
|
|
||||||
|
|
||||||
if (RelationIsValid(rd))
|
|
||||||
{
|
|
||||||
RelationIncrementReferenceCount(rd);
|
|
||||||
/* revalidate nailed index if necessary */
|
|
||||||
if (!rd->rd_isvalid)
|
|
||||||
RelationReloadClassinfo(rd);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rd;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RelationIdGetRelation
|
* RelationIdGetRelation
|
||||||
*
|
*
|
||||||
@ -1482,7 +1355,6 @@ Relation
|
|||||||
RelationIdGetRelation(Oid relationId)
|
RelationIdGetRelation(Oid relationId)
|
||||||
{
|
{
|
||||||
Relation rd;
|
Relation rd;
|
||||||
RelationBuildDescInfo buildinfo;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* first try and get a reldesc from the cache
|
* first try and get a reldesc from the cache
|
||||||
@ -1495,41 +1367,7 @@ RelationIdGetRelation(Oid relationId)
|
|||||||
* no reldesc in the cache, so have RelationBuildDesc() build one and
|
* no reldesc in the cache, so have RelationBuildDesc() build one and
|
||||||
* add it.
|
* add it.
|
||||||
*/
|
*/
|
||||||
buildinfo.infotype = INFO_RELID;
|
rd = RelationBuildDesc(relationId, NULL);
|
||||||
buildinfo.i.info_id = relationId;
|
|
||||||
|
|
||||||
rd = RelationBuildDesc(buildinfo, NULL);
|
|
||||||
if (RelationIsValid(rd))
|
|
||||||
RelationIncrementReferenceCount(rd);
|
|
||||||
return rd;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* RelationSysNameGetRelation
|
|
||||||
*
|
|
||||||
* As above, but lookup by name; only works for system catalogs.
|
|
||||||
*/
|
|
||||||
Relation
|
|
||||||
RelationSysNameGetRelation(const char *relationName)
|
|
||||||
{
|
|
||||||
Relation rd;
|
|
||||||
RelationBuildDescInfo buildinfo;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* first try and get a reldesc from the cache
|
|
||||||
*/
|
|
||||||
rd = RelationSysNameCacheGetRelation(relationName);
|
|
||||||
if (RelationIsValid(rd))
|
|
||||||
return rd;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* no reldesc in the cache, so have RelationBuildDesc() build one and
|
|
||||||
* add it.
|
|
||||||
*/
|
|
||||||
buildinfo.infotype = INFO_RELNAME;
|
|
||||||
buildinfo.i.info_name = (char *) relationName;
|
|
||||||
|
|
||||||
rd = RelationBuildDesc(buildinfo, NULL);
|
|
||||||
if (RelationIsValid(rd))
|
if (RelationIsValid(rd))
|
||||||
RelationIncrementReferenceCount(rd);
|
RelationIncrementReferenceCount(rd);
|
||||||
return rd;
|
return rd;
|
||||||
@ -1612,7 +1450,6 @@ RelationClose(Relation relation)
|
|||||||
static void
|
static void
|
||||||
RelationReloadClassinfo(Relation relation)
|
RelationReloadClassinfo(Relation relation)
|
||||||
{
|
{
|
||||||
RelationBuildDescInfo buildinfo;
|
|
||||||
bool indexOK;
|
bool indexOK;
|
||||||
HeapTuple pg_class_tuple;
|
HeapTuple pg_class_tuple;
|
||||||
Form_pg_class relp;
|
Form_pg_class relp;
|
||||||
@ -1620,19 +1457,17 @@ RelationReloadClassinfo(Relation relation)
|
|||||||
/* Should be called only for invalidated nailed indexes */
|
/* Should be called only for invalidated nailed indexes */
|
||||||
Assert(relation->rd_isnailed && !relation->rd_isvalid &&
|
Assert(relation->rd_isnailed && !relation->rd_isvalid &&
|
||||||
relation->rd_rel->relkind == RELKIND_INDEX);
|
relation->rd_rel->relkind == RELKIND_INDEX);
|
||||||
/* Read the pg_class row */
|
|
||||||
buildinfo.infotype = INFO_RELID;
|
|
||||||
buildinfo.i.info_id = relation->rd_id;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
* Read the pg_class row
|
||||||
|
*
|
||||||
* Don't try to use an indexscan of pg_class_oid_index to reload the
|
* Don't try to use an indexscan of pg_class_oid_index to reload the
|
||||||
* info for pg_class_oid_index ...
|
* info for pg_class_oid_index ...
|
||||||
*/
|
*/
|
||||||
indexOK = strcmp(RelationGetRelationName(relation), ClassOidIndex) != 0;
|
indexOK = (RelationGetRelid(relation) != ClassOidIndexId);
|
||||||
pg_class_tuple = ScanPgRelation(buildinfo, indexOK);
|
pg_class_tuple = ScanPgRelation(RelationGetRelid(relation), indexOK);
|
||||||
if (!HeapTupleIsValid(pg_class_tuple))
|
if (!HeapTupleIsValid(pg_class_tuple))
|
||||||
elog(ERROR, "could not find tuple for system relation %u",
|
elog(ERROR, "could not find tuple for system relation %u",
|
||||||
relation->rd_id);
|
RelationGetRelid(relation));
|
||||||
relp = (Form_pg_class) GETSTRUCT(pg_class_tuple);
|
relp = (Form_pg_class) GETSTRUCT(pg_class_tuple);
|
||||||
memcpy((char *) relation->rd_rel, (char *) relp, CLASS_TUPLE_SIZE);
|
memcpy((char *) relation->rd_rel, (char *) relp, CLASS_TUPLE_SIZE);
|
||||||
/* Now we can recalculate physical address */
|
/* Now we can recalculate physical address */
|
||||||
@ -1750,17 +1585,14 @@ RelationClearRelation(Relation relation, bool rebuild)
|
|||||||
* is good because whatever ref counts the entry may have do not
|
* is good because whatever ref counts the entry may have do not
|
||||||
* necessarily belong to that resource owner.
|
* necessarily belong to that resource owner.
|
||||||
*/
|
*/
|
||||||
|
Oid save_relid = RelationGetRelid(relation);
|
||||||
int old_refcnt = relation->rd_refcnt;
|
int old_refcnt = relation->rd_refcnt;
|
||||||
SubTransactionId old_createSubid = relation->rd_createSubid;
|
SubTransactionId old_createSubid = relation->rd_createSubid;
|
||||||
TupleDesc old_att = relation->rd_att;
|
TupleDesc old_att = relation->rd_att;
|
||||||
RuleLock *old_rules = relation->rd_rules;
|
RuleLock *old_rules = relation->rd_rules;
|
||||||
MemoryContext old_rulescxt = relation->rd_rulescxt;
|
MemoryContext old_rulescxt = relation->rd_rulescxt;
|
||||||
RelationBuildDescInfo buildinfo;
|
|
||||||
|
|
||||||
buildinfo.infotype = INFO_RELID;
|
if (RelationBuildDesc(save_relid, relation) != relation)
|
||||||
buildinfo.i.info_id = RelationGetRelid(relation);
|
|
||||||
|
|
||||||
if (RelationBuildDesc(buildinfo, relation) != relation)
|
|
||||||
{
|
{
|
||||||
/* Should only get here if relation was deleted */
|
/* Should only get here if relation was deleted */
|
||||||
flush_rowtype_cache(old_reltype);
|
flush_rowtype_cache(old_reltype);
|
||||||
@ -1768,8 +1600,7 @@ RelationClearRelation(Relation relation, bool rebuild)
|
|||||||
if (old_rulescxt)
|
if (old_rulescxt)
|
||||||
MemoryContextDelete(old_rulescxt);
|
MemoryContextDelete(old_rulescxt);
|
||||||
pfree(relation);
|
pfree(relation);
|
||||||
elog(ERROR, "relation %u deleted while still in use",
|
elog(ERROR, "relation %u deleted while still in use", save_relid);
|
||||||
buildinfo.i.info_id);
|
|
||||||
}
|
}
|
||||||
relation->rd_refcnt = old_refcnt;
|
relation->rd_refcnt = old_refcnt;
|
||||||
relation->rd_createSubid = old_createSubid;
|
relation->rd_createSubid = old_createSubid;
|
||||||
@ -1952,8 +1783,7 @@ RelationCacheInvalidate(void)
|
|||||||
if (relation->rd_isnailed &&
|
if (relation->rd_isnailed &&
|
||||||
relation->rd_rel->relkind == RELKIND_INDEX)
|
relation->rd_rel->relkind == RELKIND_INDEX)
|
||||||
{
|
{
|
||||||
if (strcmp(RelationGetRelationName(relation),
|
if (RelationGetRelid(relation) == ClassOidIndexId)
|
||||||
ClassOidIndex) == 0)
|
|
||||||
rebuildFirstList = lcons(relation, rebuildFirstList);
|
rebuildFirstList = lcons(relation, rebuildFirstList);
|
||||||
else
|
else
|
||||||
rebuildFirstList = lappend(rebuildFirstList, relation);
|
rebuildFirstList = lappend(rebuildFirstList, relation);
|
||||||
@ -2319,11 +2149,6 @@ RelationCacheInitialize(void)
|
|||||||
* create hashtables that index the relcache
|
* create hashtables that index the relcache
|
||||||
*/
|
*/
|
||||||
MemSet(&ctl, 0, sizeof(ctl));
|
MemSet(&ctl, 0, sizeof(ctl));
|
||||||
ctl.keysize = sizeof(NameData);
|
|
||||||
ctl.entrysize = sizeof(RelNameCacheEnt);
|
|
||||||
RelationSysNameCache = hash_create("Relcache by name", INITRELCACHESIZE,
|
|
||||||
&ctl, HASH_ELEM);
|
|
||||||
|
|
||||||
ctl.keysize = sizeof(Oid);
|
ctl.keysize = sizeof(Oid);
|
||||||
ctl.entrysize = sizeof(RelIdCacheEnt);
|
ctl.entrysize = sizeof(RelIdCacheEnt);
|
||||||
ctl.hash = tag_hash;
|
ctl.hash = tag_hash;
|
||||||
@ -2338,13 +2163,13 @@ RelationCacheInitialize(void)
|
|||||||
if (IsBootstrapProcessingMode() ||
|
if (IsBootstrapProcessingMode() ||
|
||||||
!load_relcache_init_file())
|
!load_relcache_init_file())
|
||||||
{
|
{
|
||||||
formrdesc(RelationRelationName, PG_CLASS_RELTYPE_OID,
|
formrdesc("pg_class", PG_CLASS_RELTYPE_OID,
|
||||||
true, Natts_pg_class, Desc_pg_class);
|
true, Natts_pg_class, Desc_pg_class);
|
||||||
formrdesc(AttributeRelationName, PG_ATTRIBUTE_RELTYPE_OID,
|
formrdesc("pg_attribute", PG_ATTRIBUTE_RELTYPE_OID,
|
||||||
false, Natts_pg_attribute, Desc_pg_attribute);
|
false, Natts_pg_attribute, Desc_pg_attribute);
|
||||||
formrdesc(ProcedureRelationName, PG_PROC_RELTYPE_OID,
|
formrdesc("pg_proc", PG_PROC_RELTYPE_OID,
|
||||||
true, Natts_pg_proc, Desc_pg_proc);
|
true, Natts_pg_proc, Desc_pg_proc);
|
||||||
formrdesc(TypeRelationName, PG_TYPE_RELTYPE_OID,
|
formrdesc("pg_type", PG_TYPE_RELTYPE_OID,
|
||||||
true, Natts_pg_type, Desc_pg_type);
|
true, Natts_pg_type, Desc_pg_type);
|
||||||
|
|
||||||
#define NUM_CRITICAL_RELS 4 /* fix if you change list above */
|
#define NUM_CRITICAL_RELS 4 /* fix if you change list above */
|
||||||
@ -2393,27 +2218,23 @@ RelationCacheInitializePhase2(void)
|
|||||||
*/
|
*/
|
||||||
if (!criticalRelcachesBuilt)
|
if (!criticalRelcachesBuilt)
|
||||||
{
|
{
|
||||||
RelationBuildDescInfo buildinfo;
|
|
||||||
Relation ird;
|
Relation ird;
|
||||||
|
|
||||||
#define LOAD_CRIT_INDEX(indname) \
|
#define LOAD_CRIT_INDEX(indexoid) \
|
||||||
do { \
|
do { \
|
||||||
buildinfo.infotype = INFO_RELNAME; \
|
ird = RelationBuildDesc((indexoid), NULL); \
|
||||||
buildinfo.i.info_name = (indname); \
|
|
||||||
ird = RelationBuildDesc(buildinfo, NULL); \
|
|
||||||
ird->rd_isnailed = true; \
|
ird->rd_isnailed = true; \
|
||||||
ird->rd_refcnt = 1; \
|
ird->rd_refcnt = 1; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
LOAD_CRIT_INDEX(ClassNameNspIndex);
|
LOAD_CRIT_INDEX(ClassOidIndexId);
|
||||||
LOAD_CRIT_INDEX(ClassOidIndex);
|
LOAD_CRIT_INDEX(AttributeRelidNumIndexId);
|
||||||
LOAD_CRIT_INDEX(AttributeRelidNumIndex);
|
LOAD_CRIT_INDEX(IndexRelidIndexId);
|
||||||
LOAD_CRIT_INDEX(IndexRelidIndex);
|
LOAD_CRIT_INDEX(AccessMethodStrategyIndexId);
|
||||||
LOAD_CRIT_INDEX(AccessMethodStrategyIndex);
|
LOAD_CRIT_INDEX(AccessMethodProcedureIndexId);
|
||||||
LOAD_CRIT_INDEX(AccessMethodProcedureIndex);
|
LOAD_CRIT_INDEX(OperatorOidIndexId);
|
||||||
LOAD_CRIT_INDEX(OperatorOidIndex);
|
|
||||||
|
|
||||||
#define NUM_CRITICAL_INDEXES 7 /* fix if you change list above */
|
#define NUM_CRITICAL_INDEXES 6 /* fix if you change list above */
|
||||||
|
|
||||||
criticalRelcachesBuilt = true;
|
criticalRelcachesBuilt = true;
|
||||||
}
|
}
|
||||||
@ -2510,7 +2331,7 @@ RelationCacheInitializePhase3(void)
|
|||||||
* fields of pg_index before we have the standard catalog caches available.
|
* fields of pg_index before we have the standard catalog caches available.
|
||||||
* We use predefined data that's set up in just the same way as the
|
* We use predefined data that's set up in just the same way as the
|
||||||
* bootstrapped reldescs used by formrdesc(). The resulting tupdesc is
|
* bootstrapped reldescs used by formrdesc(). The resulting tupdesc is
|
||||||
* not 100% kosher: it does not have the correct relation OID in attrelid,
|
* not 100% kosher: it does not have the correct rowtype OID in tdtypeid,
|
||||||
* nor does it have a TupleConstr field. But it's good enough for the
|
* nor does it have a TupleConstr field. But it's good enough for the
|
||||||
* purpose of extracting fields.
|
* purpose of extracting fields.
|
||||||
*/
|
*/
|
||||||
@ -2569,8 +2390,8 @@ AttrDefaultFetch(Relation relation)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||||
|
|
||||||
adrel = heap_openr(AttrDefaultRelationName, AccessShareLock);
|
adrel = heap_open(AttrDefaultRelationId, AccessShareLock);
|
||||||
adscan = systable_beginscan(adrel, AttrDefaultIndex, true,
|
adscan = systable_beginscan(adrel, AttrDefaultIndexId, true,
|
||||||
SnapshotNow, 1, &skey);
|
SnapshotNow, 1, &skey);
|
||||||
found = 0;
|
found = 0;
|
||||||
|
|
||||||
@ -2634,8 +2455,8 @@ CheckConstraintFetch(Relation relation)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||||
|
|
||||||
conrel = heap_openr(ConstraintRelationName, AccessShareLock);
|
conrel = heap_open(ConstraintRelationId, AccessShareLock);
|
||||||
conscan = systable_beginscan(conrel, ConstraintRelidIndex, true,
|
conscan = systable_beginscan(conrel, ConstraintRelidIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
while (HeapTupleIsValid(htup = systable_getnext(conscan)))
|
while (HeapTupleIsValid(htup = systable_getnext(conscan)))
|
||||||
@ -2725,8 +2546,8 @@ RelationGetIndexList(Relation relation)
|
|||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(RelationGetRelid(relation)));
|
ObjectIdGetDatum(RelationGetRelid(relation)));
|
||||||
|
|
||||||
indrel = heap_openr(IndexRelationName, AccessShareLock);
|
indrel = heap_open(IndexRelationId, AccessShareLock);
|
||||||
indscan = systable_beginscan(indrel, IndexIndrelidIndex, true,
|
indscan = systable_beginscan(indrel, IndexIndrelidIndexId, true,
|
||||||
SnapshotNow, 1, &skey);
|
SnapshotNow, 1, &skey);
|
||||||
|
|
||||||
while (HeapTupleIsValid(htup = systable_getnext(indscan)))
|
while (HeapTupleIsValid(htup = systable_getnext(indscan)))
|
||||||
|
168
src/backend/utils/cache/syscache.c
vendored
168
src/backend/utils/cache/syscache.c
vendored
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.97 2005/03/29 00:17:12 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.98 2005/04/14 20:03:26 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* These routines allow the parser/planner/executor to perform
|
* These routines allow the parser/planner/executor to perform
|
||||||
@ -23,7 +23,6 @@
|
|||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "access/transam.h"
|
#include "access/transam.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/pg_aggregate.h"
|
#include "catalog/pg_aggregate.h"
|
||||||
#include "catalog/pg_amop.h"
|
#include "catalog/pg_amop.h"
|
||||||
@ -57,7 +56,7 @@
|
|||||||
|
|
||||||
Add your entry to the cacheinfo[] array below. All cache lists are
|
Add your entry to the cacheinfo[] array below. All cache lists are
|
||||||
alphabetical, so add it in the proper place. Specify the relation
|
alphabetical, so add it in the proper place. Specify the relation
|
||||||
name, index name, number of keys, and key attribute numbers. If the
|
OID, index OID, number of keys, and key attribute numbers. If the
|
||||||
relation contains tuples that are associated with a particular relation
|
relation contains tuples that are associated with a particular relation
|
||||||
(for example, its attributes, rules, triggers, etc) then specify the
|
(for example, its attributes, rules, triggers, etc) then specify the
|
||||||
attribute number that contains the OID of the associated relation.
|
attribute number that contains the OID of the associated relation.
|
||||||
@ -66,18 +65,18 @@
|
|||||||
|
|
||||||
There must be a unique index underlying each syscache (ie, an index
|
There must be a unique index underlying each syscache (ie, an index
|
||||||
whose key is the same as that of the cache). If there is not one
|
whose key is the same as that of the cache). If there is not one
|
||||||
already, add definitions for it to include/catalog/indexing.h: you
|
already, add definitions for it to include/catalog/indexing.h: you need
|
||||||
need a #define for the index name and a DECLARE_UNIQUE_INDEX macro
|
to add a DECLARE_UNIQUE_INDEX macro and a #define for the index OID.
|
||||||
with the actual declaration. (This will require a catversion.h update,
|
(Adding an index requires a catversion.h update, while simply
|
||||||
while simply adding/deleting caches only requires a recompile.)
|
adding/deleting caches only requires a recompile.)
|
||||||
|
|
||||||
Finally, any place your relation gets heap_insert() or
|
Finally, any place your relation gets heap_insert() or
|
||||||
heap_update calls, make sure there is a CatalogUpdateIndexes() or
|
heap_update() calls, make sure there is a CatalogUpdateIndexes() or
|
||||||
similar call. The heap_* calls do not update indexes.
|
similar call. The heap_* calls do not update indexes.
|
||||||
|
|
||||||
bjm 1999/11/22
|
bjm 1999/11/22
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
*---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -85,16 +84,16 @@
|
|||||||
*/
|
*/
|
||||||
struct cachedesc
|
struct cachedesc
|
||||||
{
|
{
|
||||||
const char *name; /* name of the relation being cached */
|
Oid reloid; /* OID of the relation being cached */
|
||||||
const char *indname; /* name of index relation for this cache */
|
Oid indoid; /* OID of index relation for this cache */
|
||||||
int reloidattr; /* attr number of rel OID reference, or 0 */
|
int reloidattr; /* attr number of rel OID reference, or 0 */
|
||||||
int nkeys; /* # of keys needed for cache lookup */
|
int nkeys; /* # of keys needed for cache lookup */
|
||||||
int key[4]; /* attribute numbers of key attrs */
|
int key[4]; /* attribute numbers of key attrs */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct cachedesc cacheinfo[] = {
|
static const struct cachedesc cacheinfo[] = {
|
||||||
{AggregateRelationName, /* AGGFNOID */
|
{AggregateRelationId, /* AGGFNOID */
|
||||||
AggregateFnoidIndex,
|
AggregateFnoidIndexId,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -103,8 +102,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{AccessMethodRelationName, /* AMNAME */
|
{AccessMethodRelationId, /* AMNAME */
|
||||||
AmNameIndex,
|
AmNameIndexId,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -113,8 +112,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{AccessMethodRelationName, /* AMOID */
|
{AccessMethodRelationId, /* AMOID */
|
||||||
AmOidIndex,
|
AmOidIndexId,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -123,8 +122,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{AccessMethodOperatorRelationName, /* AMOPOPID */
|
{AccessMethodOperatorRelationId, /* AMOPOPID */
|
||||||
AccessMethodOperatorIndex,
|
AccessMethodOperatorIndexId,
|
||||||
0,
|
0,
|
||||||
2,
|
2,
|
||||||
{
|
{
|
||||||
@ -133,8 +132,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{AccessMethodOperatorRelationName, /* AMOPSTRATEGY */
|
{AccessMethodOperatorRelationId, /* AMOPSTRATEGY */
|
||||||
AccessMethodStrategyIndex,
|
AccessMethodStrategyIndexId,
|
||||||
0,
|
0,
|
||||||
3,
|
3,
|
||||||
{
|
{
|
||||||
@ -143,8 +142,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
Anum_pg_amop_amopstrategy,
|
Anum_pg_amop_amopstrategy,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{AccessMethodProcedureRelationName, /* AMPROCNUM */
|
{AccessMethodProcedureRelationId, /* AMPROCNUM */
|
||||||
AccessMethodProcedureIndex,
|
AccessMethodProcedureIndexId,
|
||||||
0,
|
0,
|
||||||
3,
|
3,
|
||||||
{
|
{
|
||||||
@ -153,8 +152,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
Anum_pg_amproc_amprocnum,
|
Anum_pg_amproc_amprocnum,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{AttributeRelationName, /* ATTNAME */
|
{AttributeRelationId, /* ATTNAME */
|
||||||
AttributeRelidNameIndex,
|
AttributeRelidNameIndexId,
|
||||||
Anum_pg_attribute_attrelid,
|
Anum_pg_attribute_attrelid,
|
||||||
2,
|
2,
|
||||||
{
|
{
|
||||||
@ -163,8 +162,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{AttributeRelationName, /* ATTNUM */
|
{AttributeRelationId, /* ATTNUM */
|
||||||
AttributeRelidNumIndex,
|
AttributeRelidNumIndexId,
|
||||||
Anum_pg_attribute_attrelid,
|
Anum_pg_attribute_attrelid,
|
||||||
2,
|
2,
|
||||||
{
|
{
|
||||||
@ -174,8 +173,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{
|
{
|
||||||
CastRelationName, /* CASTSOURCETARGET */
|
CastRelationId, /* CASTSOURCETARGET */
|
||||||
CastSourceTargetIndex,
|
CastSourceTargetIndexId,
|
||||||
0,
|
0,
|
||||||
2,
|
2,
|
||||||
{
|
{
|
||||||
@ -184,8 +183,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{OperatorClassRelationName, /* CLAAMNAMENSP */
|
{OperatorClassRelationId, /* CLAAMNAMENSP */
|
||||||
OpclassAmNameNspIndex,
|
OpclassAmNameNspIndexId,
|
||||||
0,
|
0,
|
||||||
3,
|
3,
|
||||||
{
|
{
|
||||||
@ -194,8 +193,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
Anum_pg_opclass_opcnamespace,
|
Anum_pg_opclass_opcnamespace,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{OperatorClassRelationName, /* CLAOID */
|
{OperatorClassRelationId, /* CLAOID */
|
||||||
OpclassOidIndex,
|
OpclassOidIndexId,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -204,8 +203,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{ConversionRelationName, /* CONDEFAULT */
|
{ConversionRelationId, /* CONDEFAULT */
|
||||||
ConversionDefaultIndex,
|
ConversionDefaultIndexId,
|
||||||
0,
|
0,
|
||||||
4,
|
4,
|
||||||
{
|
{
|
||||||
@ -214,8 +213,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
Anum_pg_conversion_contoencoding,
|
Anum_pg_conversion_contoencoding,
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
}},
|
}},
|
||||||
{ConversionRelationName, /* CONNAMENSP */
|
{ConversionRelationId, /* CONNAMENSP */
|
||||||
ConversionNameNspIndex,
|
ConversionNameNspIndexId,
|
||||||
0,
|
0,
|
||||||
2,
|
2,
|
||||||
{
|
{
|
||||||
@ -224,8 +223,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{ConversionRelationName, /* CONOID */
|
{ConversionRelationId, /* CONOID */
|
||||||
ConversionOidIndex,
|
ConversionOidIndexId,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -234,8 +233,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{GroupRelationName, /* GRONAME */
|
{GroupRelationId, /* GRONAME */
|
||||||
GroupNameIndex,
|
GroupNameIndexId,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -244,8 +243,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{GroupRelationName, /* GROSYSID */
|
{GroupRelationId, /* GROSYSID */
|
||||||
GroupSysidIndex,
|
GroupSysidIndexId,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -254,8 +253,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{IndexRelationName, /* INDEXRELID */
|
{IndexRelationId, /* INDEXRELID */
|
||||||
IndexRelidIndex,
|
IndexRelidIndexId,
|
||||||
Anum_pg_index_indrelid,
|
Anum_pg_index_indrelid,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -264,8 +263,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{InheritsRelationName, /* INHRELID */
|
{InheritsRelationId, /* INHRELID */
|
||||||
InheritsRelidSeqnoIndex,
|
InheritsRelidSeqnoIndexId,
|
||||||
Anum_pg_inherits_inhrelid,
|
Anum_pg_inherits_inhrelid,
|
||||||
2,
|
2,
|
||||||
{
|
{
|
||||||
@ -274,8 +273,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{LanguageRelationName, /* LANGNAME */
|
{LanguageRelationId, /* LANGNAME */
|
||||||
LanguageNameIndex,
|
LanguageNameIndexId,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -284,8 +283,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{LanguageRelationName, /* LANGOID */
|
{LanguageRelationId, /* LANGOID */
|
||||||
LanguageOidIndex,
|
LanguageOidIndexId,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -294,8 +293,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{NamespaceRelationName, /* NAMESPACENAME */
|
{NamespaceRelationId, /* NAMESPACENAME */
|
||||||
NamespaceNameIndex,
|
NamespaceNameIndexId,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -304,8 +303,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{NamespaceRelationName, /* NAMESPACEOID */
|
{NamespaceRelationId, /* NAMESPACEOID */
|
||||||
NamespaceOidIndex,
|
NamespaceOidIndexId,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -314,8 +313,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{OperatorRelationName, /* OPERNAMENSP */
|
{OperatorRelationId, /* OPERNAMENSP */
|
||||||
OperatorNameNspIndex,
|
OperatorNameNspIndexId,
|
||||||
0,
|
0,
|
||||||
4,
|
4,
|
||||||
{
|
{
|
||||||
@ -324,8 +323,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
Anum_pg_operator_oprright,
|
Anum_pg_operator_oprright,
|
||||||
Anum_pg_operator_oprnamespace
|
Anum_pg_operator_oprnamespace
|
||||||
}},
|
}},
|
||||||
{OperatorRelationName, /* OPEROID */
|
{OperatorRelationId, /* OPEROID */
|
||||||
OperatorOidIndex,
|
OperatorOidIndexId,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -334,8 +333,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{ProcedureRelationName, /* PROCNAMEARGSNSP */
|
{ProcedureRelationId, /* PROCNAMEARGSNSP */
|
||||||
ProcedureNameArgsNspIndex,
|
ProcedureNameArgsNspIndexId,
|
||||||
0,
|
0,
|
||||||
3,
|
3,
|
||||||
{
|
{
|
||||||
@ -344,8 +343,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
Anum_pg_proc_pronamespace,
|
Anum_pg_proc_pronamespace,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{ProcedureRelationName, /* PROCOID */
|
{ProcedureRelationId, /* PROCOID */
|
||||||
ProcedureOidIndex,
|
ProcedureOidIndexId,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -354,8 +353,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{RelationRelationName, /* RELNAMENSP */
|
{RelationRelationId, /* RELNAMENSP */
|
||||||
ClassNameNspIndex,
|
ClassNameNspIndexId,
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
2,
|
2,
|
||||||
{
|
{
|
||||||
@ -364,8 +363,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{RelationRelationName, /* RELOID */
|
{RelationRelationId, /* RELOID */
|
||||||
ClassOidIndex,
|
ClassOidIndexId,
|
||||||
ObjectIdAttributeNumber,
|
ObjectIdAttributeNumber,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -374,8 +373,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{RewriteRelationName, /* RULERELNAME */
|
{RewriteRelationId, /* RULERELNAME */
|
||||||
RewriteRelRulenameIndex,
|
RewriteRelRulenameIndexId,
|
||||||
Anum_pg_rewrite_ev_class,
|
Anum_pg_rewrite_ev_class,
|
||||||
2,
|
2,
|
||||||
{
|
{
|
||||||
@ -384,8 +383,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{ShadowRelationName, /* SHADOWNAME */
|
{ShadowRelationId, /* SHADOWNAME */
|
||||||
ShadowNameIndex,
|
ShadowNameIndexId,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -394,8 +393,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{ShadowRelationName, /* SHADOWSYSID */
|
{ShadowRelationId, /* SHADOWSYSID */
|
||||||
ShadowSysidIndex,
|
ShadowSysidIndexId,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -404,8 +403,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{StatisticRelationName, /* STATRELATT */
|
{StatisticRelationId, /* STATRELATT */
|
||||||
StatisticRelidAttnumIndex,
|
StatisticRelidAttnumIndexId,
|
||||||
Anum_pg_statistic_starelid,
|
Anum_pg_statistic_starelid,
|
||||||
2,
|
2,
|
||||||
{
|
{
|
||||||
@ -414,8 +413,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{TypeRelationName, /* TYPENAMENSP */
|
{TypeRelationId, /* TYPENAMENSP */
|
||||||
TypeNameNspIndex,
|
TypeNameNspIndexId,
|
||||||
Anum_pg_type_typrelid,
|
Anum_pg_type_typrelid,
|
||||||
2,
|
2,
|
||||||
{
|
{
|
||||||
@ -424,8 +423,8 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}},
|
}},
|
||||||
{TypeRelationName, /* TYPEOID */
|
{TypeRelationId, /* TYPEOID */
|
||||||
TypeOidIndex,
|
TypeOidIndexId,
|
||||||
Anum_pg_type_typrelid,
|
Anum_pg_type_typrelid,
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
@ -436,8 +435,7 @@ static const struct cachedesc cacheinfo[] = {
|
|||||||
}}
|
}}
|
||||||
};
|
};
|
||||||
|
|
||||||
static CatCache *SysCache[
|
static CatCache *SysCache[lengthof(cacheinfo)];
|
||||||
lengthof(cacheinfo)];
|
|
||||||
static int SysCacheSize = lengthof(cacheinfo);
|
static int SysCacheSize = lengthof(cacheinfo);
|
||||||
static bool CacheInitialized = false;
|
static bool CacheInitialized = false;
|
||||||
|
|
||||||
@ -462,14 +460,14 @@ InitCatalogCache(void)
|
|||||||
for (cacheId = 0; cacheId < SysCacheSize; cacheId++)
|
for (cacheId = 0; cacheId < SysCacheSize; cacheId++)
|
||||||
{
|
{
|
||||||
SysCache[cacheId] = InitCatCache(cacheId,
|
SysCache[cacheId] = InitCatCache(cacheId,
|
||||||
cacheinfo[cacheId].name,
|
cacheinfo[cacheId].reloid,
|
||||||
cacheinfo[cacheId].indname,
|
cacheinfo[cacheId].indoid,
|
||||||
cacheinfo[cacheId].reloidattr,
|
cacheinfo[cacheId].reloidattr,
|
||||||
cacheinfo[cacheId].nkeys,
|
cacheinfo[cacheId].nkeys,
|
||||||
cacheinfo[cacheId].key);
|
cacheinfo[cacheId].key);
|
||||||
if (!PointerIsValid(SysCache[cacheId]))
|
if (!PointerIsValid(SysCache[cacheId]))
|
||||||
elog(ERROR, "could not initialize cache %s (%d)",
|
elog(ERROR, "could not initialize cache %u (%d)",
|
||||||
cacheinfo[cacheId].name, cacheId);
|
cacheinfo[cacheId].reloid, cacheId);
|
||||||
}
|
}
|
||||||
CacheInitialized = true;
|
CacheInitialized = true;
|
||||||
}
|
}
|
||||||
|
7
src/backend/utils/cache/typcache.c
vendored
7
src/backend/utils/cache/typcache.c
vendored
@ -36,7 +36,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.11 2004/12/31 22:01:25 pgsql Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.12 2005/04/14 20:03:26 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -46,7 +46,6 @@
|
|||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "access/hash.h"
|
#include "access/hash.h"
|
||||||
#include "access/nbtree.h"
|
#include "access/nbtree.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/indexing.h"
|
#include "catalog/indexing.h"
|
||||||
#include "catalog/pg_am.h"
|
#include "catalog/pg_am.h"
|
||||||
#include "catalog/pg_opclass.h"
|
#include "catalog/pg_opclass.h"
|
||||||
@ -328,14 +327,14 @@ lookup_default_opclass(Oid type_id, Oid am_id)
|
|||||||
* that we consider all opclasses, regardless of the current search
|
* that we consider all opclasses, regardless of the current search
|
||||||
* path.
|
* path.
|
||||||
*/
|
*/
|
||||||
rel = heap_openr(OperatorClassRelationName, AccessShareLock);
|
rel = heap_open(OperatorClassRelationId, AccessShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&skey[0],
|
ScanKeyInit(&skey[0],
|
||||||
Anum_pg_opclass_opcamid,
|
Anum_pg_opclass_opcamid,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(am_id));
|
ObjectIdGetDatum(am_id));
|
||||||
|
|
||||||
scan = systable_beginscan(rel, OpclassAmNameNspIndex, true,
|
scan = systable_beginscan(rel, OpclassAmNameNspIndexId, true,
|
||||||
SnapshotNow, 1, skey);
|
SnapshotNow, 1, skey);
|
||||||
|
|
||||||
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.5 2005/04/14 01:38:20 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.6 2005/04/14 20:03:26 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -32,7 +32,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/pg_database.h"
|
#include "catalog/pg_database.h"
|
||||||
#include "catalog/pg_group.h"
|
#include "catalog/pg_group.h"
|
||||||
#include "catalog/pg_namespace.h"
|
#include "catalog/pg_namespace.h"
|
||||||
@ -724,11 +723,11 @@ AtEOXact_UpdateFlatFiles(bool isCommit)
|
|||||||
* so get the locks we need before writing anything.
|
* so get the locks we need before writing anything.
|
||||||
*/
|
*/
|
||||||
if (database_file_update_subid != InvalidSubTransactionId)
|
if (database_file_update_subid != InvalidSubTransactionId)
|
||||||
drel = heap_openr(DatabaseRelationName, ExclusiveLock);
|
drel = heap_open(DatabaseRelationId, ExclusiveLock);
|
||||||
if (group_file_update_subid != InvalidSubTransactionId)
|
if (group_file_update_subid != InvalidSubTransactionId)
|
||||||
grel = heap_openr(GroupRelationName, ExclusiveLock);
|
grel = heap_open(GroupRelationId, ExclusiveLock);
|
||||||
if (user_file_update_subid != InvalidSubTransactionId)
|
if (user_file_update_subid != InvalidSubTransactionId)
|
||||||
urel = heap_openr(ShadowRelationName, ExclusiveLock);
|
urel = heap_open(ShadowRelationId, ExclusiveLock);
|
||||||
|
|
||||||
/* Okay to write the files */
|
/* Okay to write the files */
|
||||||
if (database_file_update_subid != InvalidSubTransactionId)
|
if (database_file_update_subid != InvalidSubTransactionId)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.138 2005/03/18 03:48:49 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.139 2005/04/14 20:03:26 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -29,7 +29,6 @@
|
|||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/pg_shadow.h"
|
#include "catalog/pg_shadow.h"
|
||||||
#include "libpq/libpq-be.h"
|
#include "libpq/libpq-be.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.144 2005/03/19 23:27:06 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.145 2005/04/14 20:03:26 tgl Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
#include "catalog/catalog.h"
|
#include "catalog/catalog.h"
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
#include "catalog/pg_database.h"
|
#include "catalog/pg_database.h"
|
||||||
#include "catalog/pg_shadow.h"
|
#include "catalog/pg_shadow.h"
|
||||||
@ -134,7 +133,7 @@ ReverifyMyDatabase(const char *name)
|
|||||||
* Because we grab RowShareLock here, we can be sure that dropdb()
|
* Because we grab RowShareLock here, we can be sure that dropdb()
|
||||||
* is not running in parallel with us (any more).
|
* is not running in parallel with us (any more).
|
||||||
*/
|
*/
|
||||||
pgdbrel = heap_openr(DatabaseRelationName, RowShareLock);
|
pgdbrel = heap_open(DatabaseRelationId, RowShareLock);
|
||||||
|
|
||||||
ScanKeyInit(&key,
|
ScanKeyInit(&key,
|
||||||
Anum_pg_database_datname,
|
Anum_pg_database_datname,
|
||||||
@ -537,7 +536,7 @@ ThereIsAtLeastOneUser(void)
|
|||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
pg_shadow_rel = heap_openr(ShadowRelationName, AccessExclusiveLock);
|
pg_shadow_rel = heap_open(ShadowRelationId, AccessExclusiveLock);
|
||||||
pg_shadow_dsc = RelationGetDescr(pg_shadow_rel);
|
pg_shadow_dsc = RelationGetDescr(pg_shadow_rel);
|
||||||
|
|
||||||
scan = heap_beginscan(pg_shadow_rel, SnapshotNow, 0, NULL);
|
scan = heap_beginscan(pg_shadow_rel, SnapshotNow, 0, NULL);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/access/genam.h,v 1.49 2005/03/27 23:53:04 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/access/genam.h,v 1.50 2005/04/14 20:03:27 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -70,7 +70,6 @@ typedef SysScanDescData *SysScanDesc;
|
|||||||
*/
|
*/
|
||||||
extern Relation index_open(Oid relationId);
|
extern Relation index_open(Oid relationId);
|
||||||
extern Relation index_openrv(const RangeVar *relation);
|
extern Relation index_openrv(const RangeVar *relation);
|
||||||
extern Relation index_openr(const char *sysRelationName);
|
|
||||||
extern void index_close(Relation relation);
|
extern void index_close(Relation relation);
|
||||||
extern bool index_insert(Relation indexRelation,
|
extern bool index_insert(Relation indexRelation,
|
||||||
Datum *values, bool *isnull,
|
Datum *values, bool *isnull,
|
||||||
@ -119,7 +118,7 @@ extern void IndexScanEnd(IndexScanDesc scan);
|
|||||||
* heap-or-index access to system catalogs (in genam.c)
|
* heap-or-index access to system catalogs (in genam.c)
|
||||||
*/
|
*/
|
||||||
extern SysScanDesc systable_beginscan(Relation heapRelation,
|
extern SysScanDesc systable_beginscan(Relation heapRelation,
|
||||||
const char *indexRelname,
|
Oid indexId,
|
||||||
bool indexOK,
|
bool indexOK,
|
||||||
Snapshot snapshot,
|
Snapshot snapshot,
|
||||||
int nkeys, ScanKey key);
|
int nkeys, ScanKey key);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.98 2005/03/21 01:24:04 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.99 2005/04/14 20:03:27 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -126,12 +126,10 @@ extern Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
|
|||||||
extern Relation relation_open(Oid relationId, LOCKMODE lockmode);
|
extern Relation relation_open(Oid relationId, LOCKMODE lockmode);
|
||||||
extern Relation conditional_relation_open(Oid relationId, LOCKMODE lockmode, bool nowait);
|
extern Relation conditional_relation_open(Oid relationId, LOCKMODE lockmode, bool nowait);
|
||||||
extern Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode);
|
extern Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode);
|
||||||
extern Relation relation_openr(const char *sysRelationName, LOCKMODE lockmode);
|
|
||||||
extern void relation_close(Relation relation, LOCKMODE lockmode);
|
extern void relation_close(Relation relation, LOCKMODE lockmode);
|
||||||
|
|
||||||
extern Relation heap_open(Oid relationId, LOCKMODE lockmode);
|
extern Relation heap_open(Oid relationId, LOCKMODE lockmode);
|
||||||
extern Relation heap_openrv(const RangeVar *relation, LOCKMODE lockmode);
|
extern Relation heap_openrv(const RangeVar *relation, LOCKMODE lockmode);
|
||||||
extern Relation heap_openr(const char *sysRelationName, LOCKMODE lockmode);
|
|
||||||
|
|
||||||
#define heap_close(r,l) relation_close(r,l)
|
#define heap_close(r,l) relation_close(r,l)
|
||||||
|
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* catname.h
|
|
||||||
* POSTGRES system catalog relation name definitions.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
|
||||||
*
|
|
||||||
* $PostgreSQL: pgsql/src/include/catalog/catname.h,v 1.35 2005/04/14 01:38:20 tgl Exp $
|
|
||||||
*
|
|
||||||
*-------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
#ifndef CATNAME_H
|
|
||||||
#define CATNAME_H
|
|
||||||
|
|
||||||
|
|
||||||
#define AggregateRelationName "pg_aggregate"
|
|
||||||
#define AccessMethodRelationName "pg_am"
|
|
||||||
#define AccessMethodOperatorRelationName "pg_amop"
|
|
||||||
#define AccessMethodProcedureRelationName "pg_amproc"
|
|
||||||
#define AttributeRelationName "pg_attribute"
|
|
||||||
#define CastRelationName "pg_cast"
|
|
||||||
#define ConstraintRelationName "pg_constraint"
|
|
||||||
#define ConversionRelationName "pg_conversion"
|
|
||||||
#define DatabaseRelationName "pg_database"
|
|
||||||
#define DependRelationName "pg_depend"
|
|
||||||
#define DescriptionRelationName "pg_description"
|
|
||||||
#define GroupRelationName "pg_group"
|
|
||||||
#define IndexRelationName "pg_index"
|
|
||||||
#define InheritsRelationName "pg_inherits"
|
|
||||||
#define LanguageRelationName "pg_language"
|
|
||||||
#define LargeObjectRelationName "pg_largeobject"
|
|
||||||
#define ListenerRelationName "pg_listener"
|
|
||||||
#define NamespaceRelationName "pg_namespace"
|
|
||||||
#define OperatorClassRelationName "pg_opclass"
|
|
||||||
#define OperatorRelationName "pg_operator"
|
|
||||||
#define ProcedureRelationName "pg_proc"
|
|
||||||
#define RelationRelationName "pg_class"
|
|
||||||
#define RewriteRelationName "pg_rewrite"
|
|
||||||
#define ShadowRelationName "pg_shadow"
|
|
||||||
#define StatisticRelationName "pg_statistic"
|
|
||||||
#define TableSpaceRelationName "pg_tablespace"
|
|
||||||
#define TypeRelationName "pg_type"
|
|
||||||
#define AttrDefaultRelationName "pg_attrdef"
|
|
||||||
#define TriggerRelationName "pg_trigger"
|
|
||||||
|
|
||||||
#endif /* CATNAME_H */
|
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/catalog/indexing.h,v 1.86 2005/04/14 01:38:20 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/catalog/indexing.h,v 1.87 2005/04/14 20:03:27 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -17,68 +17,6 @@
|
|||||||
|
|
||||||
#include "access/htup.h"
|
#include "access/htup.h"
|
||||||
|
|
||||||
/*
|
|
||||||
* Names of indexes on system catalogs
|
|
||||||
*
|
|
||||||
* References to specific system indexes in the C code should use these
|
|
||||||
* macros rather than hardwiring the actual index name.
|
|
||||||
*/
|
|
||||||
#define AccessMethodOperatorIndex "pg_amop_opr_opc_index"
|
|
||||||
#define AccessMethodStrategyIndex "pg_amop_opc_strat_index"
|
|
||||||
#define AccessMethodProcedureIndex "pg_amproc_opc_proc_index"
|
|
||||||
#define AggregateFnoidIndex "pg_aggregate_fnoid_index"
|
|
||||||
#define AmNameIndex "pg_am_name_index"
|
|
||||||
#define AmOidIndex "pg_am_oid_index"
|
|
||||||
#define AttrDefaultIndex "pg_attrdef_adrelid_adnum_index"
|
|
||||||
#define AttrDefaultOidIndex "pg_attrdef_oid_index"
|
|
||||||
#define AttributeRelidNameIndex "pg_attribute_relid_attnam_index"
|
|
||||||
#define AttributeRelidNumIndex "pg_attribute_relid_attnum_index"
|
|
||||||
#define CastOidIndex "pg_cast_oid_index"
|
|
||||||
#define CastSourceTargetIndex "pg_cast_source_target_index"
|
|
||||||
#define ClassNameNspIndex "pg_class_relname_nsp_index"
|
|
||||||
#define ClassOidIndex "pg_class_oid_index"
|
|
||||||
#define ConstraintNameNspIndex "pg_constraint_conname_nsp_index"
|
|
||||||
#define ConstraintOidIndex "pg_constraint_oid_index"
|
|
||||||
#define ConstraintRelidIndex "pg_constraint_conrelid_index"
|
|
||||||
#define ConstraintTypidIndex "pg_constraint_contypid_index"
|
|
||||||
#define ConversionDefaultIndex "pg_conversion_default_index"
|
|
||||||
#define ConversionNameNspIndex "pg_conversion_name_nsp_index"
|
|
||||||
#define ConversionOidIndex "pg_conversion_oid_index"
|
|
||||||
#define DatabaseNameIndex "pg_database_datname_index"
|
|
||||||
#define DatabaseOidIndex "pg_database_oid_index"
|
|
||||||
#define DependDependerIndex "pg_depend_depender_index"
|
|
||||||
#define DependReferenceIndex "pg_depend_reference_index"
|
|
||||||
#define DescriptionObjIndex "pg_description_o_c_o_index"
|
|
||||||
#define GroupNameIndex "pg_group_name_index"
|
|
||||||
#define GroupSysidIndex "pg_group_sysid_index"
|
|
||||||
#define IndexIndrelidIndex "pg_index_indrelid_index"
|
|
||||||
#define IndexRelidIndex "pg_index_indexrelid_index"
|
|
||||||
#define InheritsRelidSeqnoIndex "pg_inherits_relid_seqno_index"
|
|
||||||
#define LanguageNameIndex "pg_language_name_index"
|
|
||||||
#define LanguageOidIndex "pg_language_oid_index"
|
|
||||||
#define LargeObjectLOidPNIndex "pg_largeobject_loid_pn_index"
|
|
||||||
#define NamespaceNameIndex "pg_namespace_nspname_index"
|
|
||||||
#define NamespaceOidIndex "pg_namespace_oid_index"
|
|
||||||
#define OpclassAmNameNspIndex "pg_opclass_am_name_nsp_index"
|
|
||||||
#define OpclassOidIndex "pg_opclass_oid_index"
|
|
||||||
#define OperatorNameNspIndex "pg_operator_oprname_l_r_n_index"
|
|
||||||
#define OperatorOidIndex "pg_operator_oid_index"
|
|
||||||
#define ProcedureNameArgsNspIndex "pg_proc_proname_args_nsp_index"
|
|
||||||
#define ProcedureOidIndex "pg_proc_oid_index"
|
|
||||||
#define RewriteOidIndex "pg_rewrite_oid_index"
|
|
||||||
#define RewriteRelRulenameIndex "pg_rewrite_rel_rulename_index"
|
|
||||||
#define ShadowNameIndex "pg_shadow_usename_index"
|
|
||||||
#define ShadowSysidIndex "pg_shadow_usesysid_index"
|
|
||||||
#define StatisticRelidAttnumIndex "pg_statistic_relid_att_index"
|
|
||||||
#define TablespaceNameIndex "pg_tablespace_spcname_index"
|
|
||||||
#define TablespaceOidIndex "pg_tablespace_oid_index"
|
|
||||||
#define TriggerConstrNameIndex "pg_trigger_tgconstrname_index"
|
|
||||||
#define TriggerConstrRelidIndex "pg_trigger_tgconstrrelid_index"
|
|
||||||
#define TriggerRelidNameIndex "pg_trigger_tgrelid_tgname_index"
|
|
||||||
#define TriggerOidIndex "pg_trigger_oid_index"
|
|
||||||
#define TypeNameNspIndex "pg_type_typname_nsp_index"
|
|
||||||
#define TypeOidIndex "pg_type_oid_index"
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The state object used by CatalogOpenIndexes and friends is actually the
|
* The state object used by CatalogOpenIndexes and friends is actually the
|
||||||
@ -113,6 +51,10 @@ extern void CatalogUpdateIndexes(Relation heapRel, HeapTuple heapTuple);
|
|||||||
* The keyword is DECLARE_INDEX or DECLARE_UNIQUE_INDEX. The first two
|
* The keyword is DECLARE_INDEX or DECLARE_UNIQUE_INDEX. The first two
|
||||||
* arguments are the index name and OID, the rest is much like a standard
|
* arguments are the index name and OID, the rest is much like a standard
|
||||||
* 'create index' SQL command.
|
* 'create index' SQL command.
|
||||||
|
*
|
||||||
|
* For each index, we also provide a #define for its OID. References to
|
||||||
|
* the index in the C code should always use these #defines, not the actual
|
||||||
|
* index name (much less the numeric OID).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DECLARE_UNIQUE_INDEX(pg_aggregate_fnoid_index,2650, on pg_aggregate using btree(aggfnoid oid_ops));
|
DECLARE_UNIQUE_INDEX(pg_aggregate_fnoid_index,2650, on pg_aggregate using btree(aggfnoid oid_ops));
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/utils/catcache.h,v 1.53 2005/03/25 18:30:28 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/utils/catcache.h,v 1.54 2005/04/14 20:03:27 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -36,8 +36,8 @@ typedef struct catcache
|
|||||||
int id; /* cache identifier --- see syscache.h */
|
int id; /* cache identifier --- see syscache.h */
|
||||||
struct catcache *cc_next; /* link to next catcache */
|
struct catcache *cc_next; /* link to next catcache */
|
||||||
const char *cc_relname; /* name of relation the tuples come from */
|
const char *cc_relname; /* name of relation the tuples come from */
|
||||||
const char *cc_indname; /* name of index matching cache keys */
|
|
||||||
Oid cc_reloid; /* OID of relation the tuples come from */
|
Oid cc_reloid; /* OID of relation the tuples come from */
|
||||||
|
Oid cc_indexoid; /* OID of index matching cache keys */
|
||||||
bool cc_relisshared; /* is relation shared across databases? */
|
bool cc_relisshared; /* is relation shared across databases? */
|
||||||
TupleDesc cc_tupdesc; /* tuple descriptor (copied from reldesc) */
|
TupleDesc cc_tupdesc; /* tuple descriptor (copied from reldesc) */
|
||||||
int cc_reloidattr; /* AttrNumber of relation OID attr, or 0 */
|
int cc_reloidattr; /* AttrNumber of relation OID attr, or 0 */
|
||||||
@ -164,7 +164,7 @@ extern DLLIMPORT MemoryContext CacheMemoryContext;
|
|||||||
extern void CreateCacheMemoryContext(void);
|
extern void CreateCacheMemoryContext(void);
|
||||||
extern void AtEOXact_CatCache(bool isCommit);
|
extern void AtEOXact_CatCache(bool isCommit);
|
||||||
|
|
||||||
extern CatCache *InitCatCache(int id, const char *relname, const char *indname,
|
extern CatCache *InitCatCache(int id, Oid reloid, Oid indexoid,
|
||||||
int reloidattr,
|
int reloidattr,
|
||||||
int nkeys, const int *key);
|
int nkeys, const int *key);
|
||||||
extern void InitCatCachePhase2(CatCache *cache);
|
extern void InitCatCachePhase2(CatCache *cache);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.97 2005/04/11 23:06:56 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.98 2005/04/14 20:03:27 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -62,7 +62,6 @@ extern bool get_func_retset(Oid funcid);
|
|||||||
extern bool func_strict(Oid funcid);
|
extern bool func_strict(Oid funcid);
|
||||||
extern char func_volatile(Oid funcid);
|
extern char func_volatile(Oid funcid);
|
||||||
extern Oid get_relname_relid(const char *relname, Oid relnamespace);
|
extern Oid get_relname_relid(const char *relname, Oid relnamespace);
|
||||||
extern Oid get_system_catalog_relid(const char *catname);
|
|
||||||
extern char *get_rel_name(Oid relid);
|
extern char *get_rel_name(Oid relid);
|
||||||
extern Oid get_rel_namespace(Oid relid);
|
extern Oid get_rel_namespace(Oid relid);
|
||||||
extern Oid get_rel_type_id(Oid relid);
|
extern Oid get_rel_type_id(Oid relid);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.49 2005/04/14 01:38:22 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.50 2005/04/14 20:03:27 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -20,7 +20,6 @@
|
|||||||
* relation lookup routines
|
* relation lookup routines
|
||||||
*/
|
*/
|
||||||
extern Relation RelationIdGetRelation(Oid relationId);
|
extern Relation RelationIdGetRelation(Oid relationId);
|
||||||
extern Relation RelationSysNameGetRelation(const char *relationName);
|
|
||||||
|
|
||||||
/* finds an existing cache entry, but won't make a new one */
|
/* finds an existing cache entry, but won't make a new one */
|
||||||
extern Relation RelationIdCacheGetRelation(Oid relationId);
|
extern Relation RelationIdCacheGetRelation(Oid relationId);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* procedural language
|
* procedural language
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.87 2005/04/07 14:53:04 tgl Exp $
|
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.88 2005/04/14 20:03:27 tgl Exp $
|
||||||
*
|
*
|
||||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||||
*
|
*
|
||||||
@ -42,7 +42,6 @@
|
|||||||
#include "pl.tab.h"
|
#include "pl.tab.h"
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
#include "catalog/catname.h"
|
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
#include "catalog/pg_attribute.h"
|
#include "catalog/pg_attribute.h"
|
||||||
#include "catalog/pg_attrdef.h"
|
#include "catalog/pg_attrdef.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user