mirror of
https://github.com/postgres/postgres.git
synced 2025-11-13 16:22:44 +03:00
Ye-old pgindent run. Same 4-space tabs.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.37 2000/01/26 05:56:09 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.38 2000/04/12 17:14:55 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* See acl.h.
|
||||
@@ -364,7 +364,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
|
||||
*/
|
||||
if (((mode & ACL_WR) || (mode & ACL_AP)) &&
|
||||
!allowSystemTableMods && IsSystemRelationName(relname) &&
|
||||
strncmp(relname,"pg_temp.", strlen("pg_temp.")) != 0 &&
|
||||
strncmp(relname, "pg_temp.", strlen("pg_temp.")) != 0 &&
|
||||
!((Form_pg_shadow) GETSTRUCT(tuple))->usecatupd)
|
||||
{
|
||||
elog(DEBUG, "pg_aclcheck: catalog update to \"%s\": permission denied",
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.31 2000/04/09 04:43:15 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.32 2000/04/12 17:14:55 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -44,6 +44,7 @@ relpath(const char *relname)
|
||||
snprintf(path, bufsize, "%s%c%s", DataDir, SEP_CHAR, relname);
|
||||
return path;
|
||||
}
|
||||
|
||||
/*
|
||||
* If it is in the current database, assume it is in current working
|
||||
* directory. NB: this does not work during bootstrap!
|
||||
@@ -55,7 +56,7 @@ relpath(const char *relname)
|
||||
* relpath_blind - construct path to a relation's file
|
||||
*
|
||||
* Construct the path using only the info available to smgrblindwrt,
|
||||
* namely the names and OIDs of the database and relation. (Shared system
|
||||
* namely the names and OIDs of the database and relation. (Shared system
|
||||
* relations are identified with dbid = 0.) Note that we may have to
|
||||
* access a relation belonging to a different database!
|
||||
*
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.124 2000/03/17 02:36:05 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.125 2000/04/12 17:14:55 momjian Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@@ -69,9 +69,9 @@
|
||||
|
||||
|
||||
static void AddNewRelationTuple(Relation pg_class_desc,
|
||||
Relation new_rel_desc, Oid new_rel_oid,
|
||||
int natts,
|
||||
char relkind, char *temp_relname);
|
||||
Relation new_rel_desc, Oid new_rel_oid,
|
||||
int natts,
|
||||
char relkind, char *temp_relname);
|
||||
static void AddToNoNameRelList(Relation r);
|
||||
|
||||
static void DeleteAttributeTuples(Relation rel);
|
||||
@@ -82,7 +82,7 @@ static void RelationRemoveInheritance(Relation relation);
|
||||
static void RemoveFromNoNameRelList(Relation r);
|
||||
static void AddNewRelationType(char *typeName, Oid new_rel_oid);
|
||||
static void StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin,
|
||||
bool updatePgAttribute);
|
||||
bool updatePgAttribute);
|
||||
static void StoreRelCheck(Relation rel, char *ccname, char *ccbin);
|
||||
static void StoreConstraints(Relation rel);
|
||||
static void RemoveConstraints(Relation rel);
|
||||
@@ -271,8 +271,9 @@ heap_create(char *relname,
|
||||
|
||||
rel = (Relation) palloc(len);
|
||||
MemSet((char *) rel, 0, len);
|
||||
rel->rd_fd = -1; /* table is not open */
|
||||
rel->rd_fd = -1; /* table is not open */
|
||||
rel->rd_unlinked = TRUE; /* table is not created yet */
|
||||
|
||||
/*
|
||||
* create a new tuple descriptor from the one passed in
|
||||
*/
|
||||
@@ -345,7 +346,7 @@ heap_create(char *relname,
|
||||
bool
|
||||
heap_storage_create(Relation rel)
|
||||
{
|
||||
bool smgrcall = false;
|
||||
bool smgrcall = false;
|
||||
|
||||
if (rel->rd_unlinked)
|
||||
{
|
||||
@@ -715,6 +716,7 @@ AddNewRelationTuple(Relation pg_class_desc,
|
||||
|
||||
if (!IsIgnoringSystemIndexes())
|
||||
{
|
||||
|
||||
/*
|
||||
* First, open the catalog indices and insert index tuples for the
|
||||
* new relation.
|
||||
@@ -878,7 +880,7 @@ heap_create_with_catalog(char *relname,
|
||||
* SOMEDAY: fill the STATISTIC relation properly.
|
||||
* ----------------
|
||||
*/
|
||||
heap_close(new_rel_desc, NoLock); /* do not unlock till end of xact */
|
||||
heap_close(new_rel_desc, NoLock); /* do not unlock till end of xact */
|
||||
heap_close(pg_class_desc, RowExclusiveLock);
|
||||
|
||||
return new_rel_oid;
|
||||
@@ -893,7 +895,7 @@ heap_create_with_catalog(char *relname,
|
||||
* 3) remove indexes
|
||||
* 4) remove pg_class tuple
|
||||
* 5) remove pg_attribute tuples and related descriptions
|
||||
* 6) remove pg_description tuples
|
||||
* 6) remove pg_description tuples
|
||||
* 7) remove pg_type tuples
|
||||
* 8) RemoveConstraints ()
|
||||
* 9) unlink relation
|
||||
@@ -963,7 +965,7 @@ RelationRemoveInheritance(Relation relation)
|
||||
tuple = heap_getnext(scan, 0);
|
||||
if (HeapTupleIsValid(tuple))
|
||||
{
|
||||
Oid subclass = ((Form_pg_inherits) GETSTRUCT(tuple))->inhrelid;
|
||||
Oid subclass = ((Form_pg_inherits) GETSTRUCT(tuple))->inhrelid;
|
||||
|
||||
heap_endscan(scan);
|
||||
heap_close(catalogRelation, RowExclusiveLock);
|
||||
@@ -1073,7 +1075,7 @@ DeleteRelationTuple(Relation rel)
|
||||
{
|
||||
heap_close(pg_class_desc, RowExclusiveLock);
|
||||
elog(ERROR, "Relation '%s' does not exist",
|
||||
RelationGetRelationName(rel));
|
||||
RelationGetRelationName(rel));
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
@@ -1096,19 +1098,27 @@ DeleteRelationTuple(Relation rel)
|
||||
static void
|
||||
RelationTruncateIndexes(Relation heapRelation)
|
||||
{
|
||||
Relation indexRelation, currentIndex;
|
||||
Relation indexRelation,
|
||||
currentIndex;
|
||||
ScanKeyData entry;
|
||||
HeapScanDesc scan;
|
||||
HeapTuple indexTuple, procTuple, classTuple;
|
||||
HeapTuple indexTuple,
|
||||
procTuple,
|
||||
classTuple;
|
||||
Form_pg_index index;
|
||||
Oid heapId, indexId, procId, accessMethodId;
|
||||
Node *oldPred = NULL;
|
||||
PredInfo *predInfo;
|
||||
List *cnfPred = NULL;
|
||||
Oid heapId,
|
||||
indexId,
|
||||
procId,
|
||||
accessMethodId;
|
||||
Node *oldPred = NULL;
|
||||
PredInfo *predInfo;
|
||||
List *cnfPred = NULL;
|
||||
AttrNumber *attributeNumberA;
|
||||
FuncIndexInfo fInfo, *funcInfo = NULL;
|
||||
int i, numberOfAttributes;
|
||||
char *predString;
|
||||
FuncIndexInfo fInfo,
|
||||
*funcInfo = NULL;
|
||||
int i,
|
||||
numberOfAttributes;
|
||||
char *predString;
|
||||
|
||||
heapId = RelationGetRelid(heapRelation);
|
||||
|
||||
@@ -1120,8 +1130,10 @@ RelationTruncateIndexes(Relation heapRelation)
|
||||
scan = heap_beginscan(indexRelation, false, SnapshotNow, 1, &entry);
|
||||
while (HeapTupleIsValid(indexTuple = heap_getnext(scan, 0)))
|
||||
{
|
||||
|
||||
/*
|
||||
* For each index, fetch index attributes so we can apply index_build
|
||||
* For each index, fetch index attributes so we can apply
|
||||
* index_build
|
||||
*/
|
||||
index = (Form_pg_index) GETSTRUCT(indexTuple);
|
||||
indexId = index->indexrelid;
|
||||
@@ -1181,8 +1193,8 @@ RelationTruncateIndexes(Relation heapRelation)
|
||||
LockRelation(currentIndex, AccessExclusiveLock);
|
||||
|
||||
/*
|
||||
* Release any buffers associated with this index. If they're dirty,
|
||||
* they're just dropped without bothering to flush to disk.
|
||||
* Release any buffers associated with this index. If they're
|
||||
* dirty, they're just dropped without bothering to flush to disk.
|
||||
*/
|
||||
ReleaseRelationBuffers(currentIndex);
|
||||
if (FlushRelationBuffers(currentIndex, (BlockNumber) 0, false) < 0)
|
||||
@@ -1198,35 +1210,35 @@ RelationTruncateIndexes(Relation heapRelation)
|
||||
attributeNumberA, 0, NULL, funcInfo, predInfo);
|
||||
|
||||
/*
|
||||
* index_build will close both the heap and index relations
|
||||
* (but not give up the locks we hold on them). That's fine
|
||||
* for the index, but we need to open the heap again. We need
|
||||
* no new lock, since this backend still has the exclusive lock
|
||||
* grabbed by heap_truncate.
|
||||
* index_build will close both the heap and index relations (but
|
||||
* not give up the locks we hold on them). That's fine for the
|
||||
* index, but we need to open the heap again. We need no new
|
||||
* lock, since this backend still has the exclusive lock grabbed
|
||||
* by heap_truncate.
|
||||
*/
|
||||
heapRelation = heap_open(heapId, NoLock);
|
||||
Assert(heapRelation != NULL);
|
||||
}
|
||||
|
||||
/* Complete the scan and close pg_index */
|
||||
heap_endscan(scan);
|
||||
heap_endscan(scan);
|
||||
heap_close(indexRelation, AccessShareLock);
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
* heap_truncate
|
||||
* heap_truncate
|
||||
*
|
||||
* This routine is used to truncate the data from the
|
||||
* storage manager of any data within the relation handed
|
||||
* to this routine.
|
||||
* This routine is used to truncate the data from the
|
||||
* storage manager of any data within the relation handed
|
||||
* to this routine.
|
||||
* ----------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
heap_truncate(char *relname)
|
||||
{
|
||||
Relation rel;
|
||||
Oid rid;
|
||||
Relation rel;
|
||||
Oid rid;
|
||||
|
||||
/* Open relation for processing, and grab exclusive access on it. */
|
||||
|
||||
@@ -1245,12 +1257,12 @@ heap_truncate(char *relname)
|
||||
* they don't exist anyway. So, no warning in that case.
|
||||
* ----------------
|
||||
*/
|
||||
if (IsTransactionBlock() && ! rel->rd_myxactonly)
|
||||
if (IsTransactionBlock() && !rel->rd_myxactonly)
|
||||
elog(NOTICE, "Caution: TRUNCATE TABLE cannot be rolled back, so don't abort now");
|
||||
|
||||
/*
|
||||
* Release any buffers associated with this relation. If they're dirty,
|
||||
* they're just dropped without bothering to flush to disk.
|
||||
* Release any buffers associated with this relation. If they're
|
||||
* dirty, they're just dropped without bothering to flush to disk.
|
||||
*/
|
||||
|
||||
ReleaseRelationBuffers(rel);
|
||||
@@ -1300,17 +1312,17 @@ DeleteAttributeTuples(Relation rel)
|
||||
attnum++)
|
||||
{
|
||||
if (HeapTupleIsValid(tup = SearchSysCacheTupleCopy(ATTNUM,
|
||||
ObjectIdGetDatum(RelationGetRelid(rel)),
|
||||
Int16GetDatum(attnum),
|
||||
ObjectIdGetDatum(RelationGetRelid(rel)),
|
||||
Int16GetDatum(attnum),
|
||||
0, 0)))
|
||||
{
|
||||
|
||||
/*** Delete any comments associated with this attribute ***/
|
||||
|
||||
DeleteComments(tup->t_data->t_oid);
|
||||
/*** Delete any comments associated with this attribute ***/
|
||||
|
||||
heap_delete(pg_attribute_desc, &tup->t_self, NULL);
|
||||
heap_freetuple(tup);
|
||||
DeleteComments(tup->t_data->t_oid);
|
||||
|
||||
heap_delete(pg_attribute_desc, &tup->t_self, NULL);
|
||||
heap_freetuple(tup);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1429,7 +1441,7 @@ DeleteTypeTuple(Relation rel)
|
||||
* we release the read lock on pg_type. -mer 13 Aug 1991
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
|
||||
heap_delete(pg_type_desc, &tup->t_self, NULL);
|
||||
|
||||
heap_endscan(pg_type_scan);
|
||||
@@ -1477,7 +1489,7 @@ heap_drop_with_catalog(const char *relname)
|
||||
* they don't exist anyway. So, no warning in that case.
|
||||
* ----------------
|
||||
*/
|
||||
if (IsTransactionBlock() && ! rel->rd_myxactonly)
|
||||
if (IsTransactionBlock() && !rel->rd_myxactonly)
|
||||
elog(NOTICE, "Caution: DROP TABLE cannot be rolled back, so don't abort now");
|
||||
|
||||
/* ----------------
|
||||
@@ -1547,8 +1559,8 @@ heap_drop_with_catalog(const char *relname)
|
||||
|
||||
/*
|
||||
* Close relcache entry, but *keep* AccessExclusiveLock on the
|
||||
* relation until transaction commit. This ensures no one else
|
||||
* will try to do something with the doomed relation.
|
||||
* relation until transaction commit. This ensures no one else will
|
||||
* try to do something with the doomed relation.
|
||||
*/
|
||||
heap_close(rel, NoLock);
|
||||
|
||||
@@ -1704,7 +1716,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin,
|
||||
Relation idescs[Num_pg_attrdef_indices];
|
||||
HeapTuple tuple;
|
||||
Datum values[4];
|
||||
static char nulls[4] = {' ', ' ', ' ', ' '};
|
||||
static char nulls[4] = {' ', ' ', ' ', ' '};
|
||||
Relation attrrel;
|
||||
Relation attridescs[Num_pg_attr_indices];
|
||||
HeapTuple atttup;
|
||||
@@ -1714,6 +1726,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin,
|
||||
* Need to construct source equivalent of given node-string.
|
||||
*/
|
||||
expr = stringToNode(adbin);
|
||||
|
||||
/*
|
||||
* deparse_expression needs a RangeTblEntry list, so make one
|
||||
*/
|
||||
@@ -1747,18 +1760,18 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin,
|
||||
heap_freetuple(tuple);
|
||||
pfree(adsrc);
|
||||
|
||||
if (! updatePgAttribute)
|
||||
if (!updatePgAttribute)
|
||||
return; /* done if pg_attribute is OK */
|
||||
|
||||
attrrel = heap_openr(AttributeRelationName, RowExclusiveLock);
|
||||
atttup = SearchSysCacheTupleCopy(ATTNUM,
|
||||
ObjectIdGetDatum(RelationGetRelid(rel)),
|
||||
ObjectIdGetDatum(RelationGetRelid(rel)),
|
||||
(Datum) attnum, 0, 0);
|
||||
if (!HeapTupleIsValid(atttup))
|
||||
elog(ERROR, "cache lookup of attribute %d in relation %u failed",
|
||||
attnum, RelationGetRelid(rel));
|
||||
attStruct = (Form_pg_attribute) GETSTRUCT(atttup);
|
||||
if (! attStruct->atthasdef)
|
||||
if (!attStruct->atthasdef)
|
||||
{
|
||||
attStruct->atthasdef = true;
|
||||
heap_update(attrrel, &atttup->t_self, atttup, NULL);
|
||||
@@ -1789,13 +1802,14 @@ StoreRelCheck(Relation rel, char *ccname, char *ccbin)
|
||||
Relation idescs[Num_pg_relcheck_indices];
|
||||
HeapTuple tuple;
|
||||
Datum values[4];
|
||||
static char nulls[4] = {' ', ' ', ' ', ' '};
|
||||
static char nulls[4] = {' ', ' ', ' ', ' '};
|
||||
|
||||
/*
|
||||
* Convert condition to a normal boolean expression tree.
|
||||
*/
|
||||
expr = stringToNode(ccbin);
|
||||
expr = (Node *) make_ands_explicit((List *) expr);
|
||||
|
||||
/*
|
||||
* deparse_expression needs a RangeTblEntry list, so make one
|
||||
*/
|
||||
@@ -1850,9 +1864,10 @@ StoreConstraints(Relation rel)
|
||||
if (!constr)
|
||||
return;
|
||||
|
||||
/* deparsing of constraint expressions will fail unless the just-created
|
||||
* pg_attribute tuples for this relation are made visible. So, bump
|
||||
* the command counter.
|
||||
/*
|
||||
* deparsing of constraint expressions will fail unless the
|
||||
* just-created pg_attribute tuples for this relation are made
|
||||
* visible. So, bump the command counter.
|
||||
*/
|
||||
CommandCounterIncrement();
|
||||
|
||||
@@ -1882,7 +1897,7 @@ StoreConstraints(Relation rel)
|
||||
* expression.
|
||||
*
|
||||
* NB: caller should have opened rel with AccessExclusiveLock, and should
|
||||
* hold that lock till end of transaction. Also, we assume the caller has
|
||||
* hold that lock till end of transaction. Also, we assume the caller has
|
||||
* done a CommandCounterIncrement if necessary to make the relation's catalog
|
||||
* tuples visible.
|
||||
*/
|
||||
@@ -1921,8 +1936,8 @@ AddRelationRawConstraints(Relation rel,
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a dummy ParseState and insert the target relation as
|
||||
* its sole rangetable entry. We need a ParseState for transformExpr.
|
||||
* Create a dummy ParseState and insert the target relation as its
|
||||
* sole rangetable entry. We need a ParseState for transformExpr.
|
||||
*/
|
||||
pstate = make_parsestate(NULL);
|
||||
makeRangeTable(pstate, NULL);
|
||||
@@ -1938,25 +1953,28 @@ AddRelationRawConstraints(Relation rel,
|
||||
Oid type_id;
|
||||
|
||||
Assert(colDef->raw_default != NULL);
|
||||
|
||||
/*
|
||||
* Transform raw parsetree to executable expression.
|
||||
*/
|
||||
expr = transformExpr(pstate, colDef->raw_default, EXPR_COLUMN_FIRST);
|
||||
|
||||
/*
|
||||
* Make sure default expr does not refer to any vars.
|
||||
*/
|
||||
if (contain_var_clause(expr))
|
||||
elog(ERROR, "Cannot use attribute(s) in DEFAULT clause");
|
||||
|
||||
/*
|
||||
* Check that it will be possible to coerce the expression
|
||||
* to the column's type. We store the expression without
|
||||
* coercion, however, to avoid premature coercion in cases like
|
||||
* Check that it will be possible to coerce the expression to the
|
||||
* column's type. We store the expression without coercion,
|
||||
* however, to avoid premature coercion in cases like
|
||||
*
|
||||
* CREATE TABLE tbl (fld datetime DEFAULT 'now');
|
||||
*
|
||||
* NB: this should match the code in updateTargetListEntry()
|
||||
* that will actually do the coercion, to ensure we don't accept
|
||||
* an unusable default expression.
|
||||
* NB: this should match the code in updateTargetListEntry() that
|
||||
* will actually do the coercion, to ensure we don't accept an
|
||||
* unusable default expression.
|
||||
*/
|
||||
type_id = exprType(expr);
|
||||
if (type_id != InvalidOid)
|
||||
@@ -1966,23 +1984,26 @@ AddRelationRawConstraints(Relation rel,
|
||||
if (type_id != atp->atttypid)
|
||||
{
|
||||
if (CoerceTargetExpr(NULL, expr, type_id,
|
||||
atp->atttypid, atp->atttypmod) == NULL)
|
||||
atp->atttypid, atp->atttypmod) == NULL)
|
||||
elog(ERROR, "Attribute '%s' is of type '%s'"
|
||||
" but default expression is of type '%s'"
|
||||
"\n\tYou will need to rewrite or cast the expression",
|
||||
"\n\tYou will need to rewrite or cast the expression",
|
||||
NameStr(atp->attname),
|
||||
typeidTypeName(atp->atttypid),
|
||||
typeidTypeName(type_id));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Might as well try to reduce any constant expressions.
|
||||
*/
|
||||
expr = eval_const_expressions(expr);
|
||||
|
||||
/*
|
||||
* Must fix opids, in case any operators remain...
|
||||
*/
|
||||
fix_opids(expr);
|
||||
|
||||
/*
|
||||
* OK, store it.
|
||||
*/
|
||||
@@ -2037,26 +2058,31 @@ AddRelationRawConstraints(Relation rel,
|
||||
ccname = (char *) palloc(NAMEDATALEN);
|
||||
snprintf(ccname, NAMEDATALEN, "$%d", numchecks + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Transform raw parsetree to executable expression.
|
||||
*/
|
||||
expr = transformExpr(pstate, cdef->raw_expr, EXPR_COLUMN_FIRST);
|
||||
|
||||
/*
|
||||
* Make sure it yields a boolean result.
|
||||
*/
|
||||
if (exprType(expr) != BOOLOID)
|
||||
elog(ERROR, "CHECK '%s' does not yield boolean result",
|
||||
ccname);
|
||||
|
||||
/*
|
||||
* Make sure no outside relations are referred to.
|
||||
*/
|
||||
if (length(pstate->p_rtable) != 1)
|
||||
elog(ERROR, "Only relation '%s' can be referenced in CHECK",
|
||||
relname);
|
||||
|
||||
/*
|
||||
* Might as well try to reduce any constant expressions.
|
||||
*/
|
||||
expr = eval_const_expressions(expr);
|
||||
|
||||
/*
|
||||
* Constraints are evaluated with execQual, which expects an
|
||||
* implicit-AND list, so convert expression to implicit-AND form.
|
||||
@@ -2064,10 +2090,12 @@ AddRelationRawConstraints(Relation rel,
|
||||
* overkill...)
|
||||
*/
|
||||
expr = (Node *) make_ands_implicit((Expr *) expr);
|
||||
|
||||
/*
|
||||
* Must fix opids in operator clauses.
|
||||
*/
|
||||
fix_opids(expr);
|
||||
|
||||
/*
|
||||
* OK, store it.
|
||||
*/
|
||||
@@ -2081,12 +2109,12 @@ AddRelationRawConstraints(Relation rel,
|
||||
* We do this even if there was no change, in order to ensure that an
|
||||
* SI update message is sent out for the pg_class tuple, which will
|
||||
* force other backends to rebuild their relcache entries for the rel.
|
||||
* (Of course, for a newly created rel there is no need for an SI message,
|
||||
* but for ALTER TABLE ADD ATTRIBUTE this'd be important.)
|
||||
* (Of course, for a newly created rel there is no need for an SI
|
||||
* message, but for ALTER TABLE ADD ATTRIBUTE this'd be important.)
|
||||
*/
|
||||
relrel = heap_openr(RelationRelationName, RowExclusiveLock);
|
||||
reltup = SearchSysCacheTupleCopy(RELOID,
|
||||
ObjectIdGetDatum(RelationGetRelid(rel)),
|
||||
ObjectIdGetDatum(RelationGetRelid(rel)),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(reltup))
|
||||
elog(ERROR, "cache lookup of relation %u failed", RelationGetRelid(rel));
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.107 2000/03/01 05:39:24 inoue Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.108 2000/04/12 17:14:55 momjian Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@@ -56,37 +56,41 @@
|
||||
|
||||
/* non-export function prototypes */
|
||||
static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName,
|
||||
bool istemp);
|
||||
bool istemp);
|
||||
static TupleDesc BuildFuncTupleDesc(FuncIndexInfo *funcInfo);
|
||||
static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation,
|
||||
List *attributeList, int numatts, AttrNumber *attNums);
|
||||
List *attributeList, int numatts, AttrNumber *attNums);
|
||||
|
||||
static void ConstructIndexReldesc(Relation indexRelation, Oid amoid);
|
||||
static Oid UpdateRelationRelation(Relation indexRelation, char *temp_relname);
|
||||
static void InitializeAttributeOids(Relation indexRelation,
|
||||
int numatts, Oid indexoid);
|
||||
int numatts, Oid indexoid);
|
||||
static void AppendAttributeTuples(Relation indexRelation, int numatts);
|
||||
static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
|
||||
FuncIndexInfo *funcInfo, int natts,
|
||||
AttrNumber *attNums, Oid *classOids, Node *predicate,
|
||||
List *attributeList, bool islossy, bool unique, bool primary);
|
||||
FuncIndexInfo *funcInfo, int natts,
|
||||
AttrNumber *attNums, Oid *classOids, Node *predicate,
|
||||
List *attributeList, bool islossy, bool unique, bool primary);
|
||||
static void DefaultBuild(Relation heapRelation, Relation indexRelation,
|
||||
int numberOfAttributes, AttrNumber *attributeNumber,
|
||||
IndexStrategy indexStrategy, uint16 parameterCount,
|
||||
int numberOfAttributes, AttrNumber *attributeNumber,
|
||||
IndexStrategy indexStrategy, uint16 parameterCount,
|
||||
Datum *parameter, FuncIndexInfoPtr funcInfo, PredInfo *predInfo);
|
||||
static Oid IndexGetRelation(Oid indexId);
|
||||
static Oid IndexGetRelation(Oid indexId);
|
||||
|
||||
static bool reindexing = false;
|
||||
extern bool SetReindexProcessing(bool reindexmode)
|
||||
static bool reindexing = false;
|
||||
extern bool
|
||||
SetReindexProcessing(bool reindexmode)
|
||||
{
|
||||
bool old = reindexing;
|
||||
bool old = reindexing;
|
||||
|
||||
reindexing = reindexmode;
|
||||
return old;
|
||||
}
|
||||
extern bool IsReindexProcessing(void)
|
||||
extern bool
|
||||
IsReindexProcessing(void)
|
||||
{
|
||||
return reindexing;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* sysatts is a structure containing attribute tuple forms
|
||||
* for system attributes (numbered -1, -2, ...). This really
|
||||
@@ -1011,7 +1015,7 @@ index_create(char *heapRelationName,
|
||||
* ----------------
|
||||
*/
|
||||
indexRelation = heap_create(indexRelationName,
|
||||
indexTupDesc, false, istemp, false);
|
||||
indexTupDesc, false, istemp, false);
|
||||
|
||||
/* ----------------
|
||||
* construct the index relation descriptor
|
||||
@@ -1075,9 +1079,9 @@ index_create(char *heapRelationName,
|
||||
* bootstrapping. Otherwise, we call the routine that constructs the
|
||||
* index.
|
||||
*
|
||||
* In normal processing mode, the heap and index relations are closed
|
||||
* by index_build() --- but we continue to hold the ShareLock on the
|
||||
* heap that we acquired above, until end of transaction.
|
||||
* In normal processing mode, the heap and index relations are closed by
|
||||
* index_build() --- but we continue to hold the ShareLock on the heap
|
||||
* that we acquired above, until end of transaction.
|
||||
*/
|
||||
if (IsBootstrapProcessingMode())
|
||||
{
|
||||
@@ -1139,7 +1143,7 @@ index_drop(Oid indexId)
|
||||
* they don't exist anyway. So, no warning in that case.
|
||||
* ----------------
|
||||
*/
|
||||
if (IsTransactionBlock() && ! userIndexRelation->rd_myxactonly)
|
||||
if (IsTransactionBlock() && !userIndexRelation->rd_myxactonly)
|
||||
elog(NOTICE, "Caution: DROP INDEX cannot be rolled back, so don't abort now");
|
||||
|
||||
/* ----------------
|
||||
@@ -1147,7 +1151,7 @@ index_drop(Oid indexId)
|
||||
* ----------------
|
||||
*/
|
||||
DeleteComments(indexId);
|
||||
|
||||
|
||||
/* ----------------
|
||||
* fix RELATION relation
|
||||
* ----------------
|
||||
@@ -1267,15 +1271,16 @@ FormIndexDatum(int numberOfAttributes,
|
||||
* --------------------------------------------
|
||||
*/
|
||||
static
|
||||
bool LockClassinfoForUpdate(Oid relid, HeapTuple rtup, Buffer *buffer, bool confirmCommitted)
|
||||
bool
|
||||
LockClassinfoForUpdate(Oid relid, HeapTuple rtup, Buffer *buffer, bool confirmCommitted)
|
||||
{
|
||||
HeapTuple classTuple;
|
||||
Form_pg_class pgcform;
|
||||
Form_pg_class pgcform;
|
||||
bool test;
|
||||
Relation relationRelation;
|
||||
|
||||
classTuple = SearchSysCacheTuple(RELOID, PointerGetDatum(relid),
|
||||
0, 0, 0);
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(classTuple))
|
||||
return false;
|
||||
rtup->t_self = classTuple->t_self;
|
||||
@@ -1294,7 +1299,8 @@ bool LockClassinfoForUpdate(Oid relid, HeapTuple rtup, Buffer *buffer, bool conf
|
||||
RelationInvalidateHeapTuple(relationRelation, rtup);
|
||||
if (confirmCommitted)
|
||||
{
|
||||
HeapTupleHeader th = rtup->t_data;
|
||||
HeapTupleHeader th = rtup->t_data;
|
||||
|
||||
if (!(th->t_infomask & HEAP_XMIN_COMMITTED))
|
||||
elog(ERROR, "The tuple isn't committed");
|
||||
if (th->t_infomask & HEAP_XMAX_COMMITTED)
|
||||
@@ -1309,28 +1315,29 @@ bool LockClassinfoForUpdate(Oid relid, HeapTuple rtup, Buffer *buffer, bool conf
|
||||
* Indexes of the relation active ?
|
||||
* ---------------------------------------------
|
||||
*/
|
||||
bool IndexesAreActive(Oid relid, bool confirmCommitted)
|
||||
bool
|
||||
IndexesAreActive(Oid relid, bool confirmCommitted)
|
||||
{
|
||||
HeapTupleData tuple;
|
||||
HeapTupleData tuple;
|
||||
Relation indexRelation;
|
||||
Buffer buffer;
|
||||
HeapScanDesc scan;
|
||||
ScanKeyData entry;
|
||||
HeapScanDesc scan;
|
||||
ScanKeyData entry;
|
||||
bool isactive;
|
||||
|
||||
if (!LockClassinfoForUpdate(relid, &tuple, &buffer, confirmCommitted))
|
||||
elog(ERROR, "IndexesAreActive couldn't lock %u", relid);
|
||||
if (((Form_pg_class) GETSTRUCT(&tuple))->relkind != RELKIND_RELATION)
|
||||
elog(ERROR, "relation %u isn't an relation", relid);
|
||||
elog(ERROR, "relation %u isn't an relation", relid);
|
||||
isactive = ((Form_pg_class) GETSTRUCT(&tuple))->relhasindex;
|
||||
ReleaseBuffer(buffer);
|
||||
if (isactive)
|
||||
return isactive;
|
||||
indexRelation = heap_openr(IndexRelationName, AccessShareLock);
|
||||
ScanKeyEntryInitialize(&entry, 0, Anum_pg_index_indrelid,
|
||||
F_OIDEQ, ObjectIdGetDatum(relid));
|
||||
F_OIDEQ, ObjectIdGetDatum(relid));
|
||||
scan = heap_beginscan(indexRelation, false, SnapshotNow,
|
||||
1, &entry);
|
||||
1, &entry);
|
||||
if (!heap_getnext(scan, 0))
|
||||
isactive = true;
|
||||
heap_endscan(scan);
|
||||
@@ -1348,8 +1355,8 @@ setRelhasindexInplace(Oid relid, bool hasindex, bool immediate)
|
||||
Relation whichRel;
|
||||
Relation pg_class;
|
||||
HeapTuple tuple;
|
||||
Form_pg_class rd_rel;
|
||||
HeapScanDesc pg_class_scan = NULL;
|
||||
Form_pg_class rd_rel;
|
||||
HeapScanDesc pg_class_scan = NULL;
|
||||
|
||||
/* ----------------
|
||||
* This routine handles updates for only the heap relation
|
||||
@@ -1384,7 +1391,7 @@ setRelhasindexInplace(Oid relid, bool hasindex, bool immediate)
|
||||
if (!IsIgnoringSystemIndexes())
|
||||
{
|
||||
tuple = SearchSysCacheTupleCopy(RELOID,
|
||||
ObjectIdGetDatum(relid), 0, 0, 0);
|
||||
ObjectIdGetDatum(relid), 0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1406,13 +1413,15 @@ setRelhasindexInplace(Oid relid, bool hasindex, bool immediate)
|
||||
heap_close(pg_class, RowExclusiveLock);
|
||||
elog(ERROR, "setRelhasindexInplace: cannot scan RELATION relation");
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirm that target tuple is locked by this transaction
|
||||
* in case of immedaite updation.
|
||||
* Confirm that target tuple is locked by this transaction in case of
|
||||
* immedaite updation.
|
||||
*/
|
||||
if (immediate)
|
||||
{
|
||||
HeapTupleHeader th = tuple->t_data;
|
||||
HeapTupleHeader th = tuple->t_data;
|
||||
|
||||
if (!(th->t_infomask & HEAP_XMIN_COMMITTED))
|
||||
elog(ERROR, "Immediate hasindex updation can be done only for committed tuples %x", th->t_infomask);
|
||||
if (th->t_infomask & HEAP_XMAX_INVALID)
|
||||
@@ -1447,7 +1456,7 @@ setRelhasindexInplace(Oid relid, bool hasindex, bool immediate)
|
||||
}
|
||||
else
|
||||
{
|
||||
HeapTupleData htup;
|
||||
HeapTupleData htup;
|
||||
Buffer buffer;
|
||||
|
||||
htup.t_self = tuple->t_self;
|
||||
@@ -1485,7 +1494,7 @@ UpdateStats(Oid relid, long reltuples, bool inplace)
|
||||
Datum values[Natts_pg_class];
|
||||
char nulls[Natts_pg_class];
|
||||
char replace[Natts_pg_class];
|
||||
HeapScanDesc pg_class_scan = NULL;
|
||||
HeapScanDesc pg_class_scan = NULL;
|
||||
bool in_place_upd;
|
||||
|
||||
/* ----------------
|
||||
@@ -1560,7 +1569,7 @@ UpdateStats(Oid relid, long reltuples, bool inplace)
|
||||
* pattern "CREATE TABLE; CREATE INDEX; insert data" leaves the table
|
||||
* with zero size statistics until a VACUUM is done. The optimizer will
|
||||
* generate very bad plans if the stats claim the table is empty when
|
||||
* it is actually sizable. See also CREATE TABLE in heap.c.
|
||||
* it is actually sizable. See also CREATE TABLE in heap.c.
|
||||
* ----------------
|
||||
*/
|
||||
relpages = RelationGetNumberOfBlocks(whichRel);
|
||||
@@ -1697,10 +1706,12 @@ DefaultBuild(Relation heapRelation,
|
||||
char *nullv;
|
||||
long reltuples,
|
||||
indtuples;
|
||||
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
ExprContext *econtext;
|
||||
TupleTable tupleTable;
|
||||
TupleTableSlot *slot;
|
||||
|
||||
#endif
|
||||
Node *predicate;
|
||||
Node *oldPred;
|
||||
@@ -1781,6 +1792,7 @@ DefaultBuild(Relation heapRelation,
|
||||
reltuples++;
|
||||
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
|
||||
/*
|
||||
* If oldPred != NULL, this is an EXTEND INDEX command, so skip
|
||||
* this tuple if it was already in the existing partial index
|
||||
@@ -1804,7 +1816,7 @@ DefaultBuild(Relation heapRelation,
|
||||
{
|
||||
/* SetSlotContents(slot, heapTuple); */
|
||||
slot->val = heapTuple;
|
||||
if (! ExecQual((List *) predicate, econtext, false))
|
||||
if (!ExecQual((List *) predicate, econtext, false))
|
||||
continue;
|
||||
}
|
||||
#endif /* OMIT_PARTIAL_INDEX */
|
||||
@@ -1854,18 +1866,18 @@ DefaultBuild(Relation heapRelation,
|
||||
/*
|
||||
* Since we just counted the tuples in the heap, we update its stats
|
||||
* in pg_class to guarantee that the planner takes advantage of the
|
||||
* index we just created. But, only update statistics during
|
||||
* normal index definitions, not for indices on system catalogs
|
||||
* created during bootstrap processing. We must close the relations
|
||||
* before updating statistics to guarantee that the relcache entries
|
||||
* are flushed when we increment the command counter in UpdateStats().
|
||||
* But we do not release any locks on the relations; those will be
|
||||
* held until end of transaction.
|
||||
* index we just created. But, only update statistics during normal
|
||||
* index definitions, not for indices on system catalogs created
|
||||
* during bootstrap processing. We must close the relations before
|
||||
* updating statistics to guarantee that the relcache entries are
|
||||
* flushed when we increment the command counter in UpdateStats(). But
|
||||
* we do not release any locks on the relations; those will be held
|
||||
* until end of transaction.
|
||||
*/
|
||||
if (IsNormalProcessingMode())
|
||||
{
|
||||
Oid hrelid = RelationGetRelid(heapRelation);
|
||||
Oid irelid = RelationGetRelid(indexRelation);
|
||||
Oid hrelid = RelationGetRelid(heapRelation);
|
||||
Oid irelid = RelationGetRelid(indexRelation);
|
||||
bool inplace = IsReindexProcessing();
|
||||
|
||||
heap_close(heapRelation, NoLock);
|
||||
@@ -1936,7 +1948,7 @@ index_build(Relation heapRelation,
|
||||
|
||||
/*
|
||||
* IndexGetRelation: given an index's relation OID, get the OID of the
|
||||
* relation it is an index on. Uses the system cache.
|
||||
* relation it is an index on. Uses the system cache.
|
||||
*/
|
||||
static Oid
|
||||
IndexGetRelation(Oid indexId)
|
||||
@@ -2037,11 +2049,11 @@ IndexIsUniqueNoCache(Oid indexId)
|
||||
bool
|
||||
activate_index(Oid indexId, bool activate)
|
||||
{
|
||||
if (!activate) /* Currently does nothing */
|
||||
if (!activate) /* Currently does nothing */
|
||||
return true;
|
||||
return reindex_index(indexId, false);
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------
|
||||
* reindex_index - This routine is used to recreate an index
|
||||
* --------------------------------
|
||||
@@ -2049,18 +2061,26 @@ activate_index(Oid indexId, bool activate)
|
||||
bool
|
||||
reindex_index(Oid indexId, bool force)
|
||||
{
|
||||
Relation iRel, indexRelation, heapRelation;
|
||||
ScanKeyData entry;
|
||||
HeapScanDesc scan;
|
||||
HeapTuple indexTuple, procTuple, classTuple;
|
||||
Form_pg_index index;
|
||||
Oid heapId, procId, accessMethodId;
|
||||
Node *oldPred = NULL;
|
||||
PredInfo *predInfo;
|
||||
AttrNumber *attributeNumberA;
|
||||
FuncIndexInfo fInfo, *funcInfo = NULL;
|
||||
int i, numberOfAttributes;
|
||||
char *predString;
|
||||
Relation iRel,
|
||||
indexRelation,
|
||||
heapRelation;
|
||||
ScanKeyData entry;
|
||||
HeapScanDesc scan;
|
||||
HeapTuple indexTuple,
|
||||
procTuple,
|
||||
classTuple;
|
||||
Form_pg_index index;
|
||||
Oid heapId,
|
||||
procId,
|
||||
accessMethodId;
|
||||
Node *oldPred = NULL;
|
||||
PredInfo *predInfo;
|
||||
AttrNumber *attributeNumberA;
|
||||
FuncIndexInfo fInfo,
|
||||
*funcInfo = NULL;
|
||||
int i,
|
||||
numberOfAttributes;
|
||||
char *predString;
|
||||
bool old;
|
||||
|
||||
old = SetReindexProcessing(true);
|
||||
@@ -2135,7 +2155,7 @@ reindex_index(Oid indexId, bool force)
|
||||
LockRelation(iRel, AccessExclusiveLock);
|
||||
|
||||
/*
|
||||
* Release any buffers associated with this index. If they're dirty,
|
||||
* Release any buffers associated with this index. If they're dirty,
|
||||
* they're just dropped without bothering to flush to disk.
|
||||
*/
|
||||
ReleaseRelationBuffers(iRel);
|
||||
@@ -2149,14 +2169,13 @@ reindex_index(Oid indexId, bool force)
|
||||
/* Initialize the index and rebuild */
|
||||
InitIndexStrategy(numberOfAttributes, iRel, accessMethodId);
|
||||
index_build(heapRelation, iRel, numberOfAttributes,
|
||||
attributeNumberA, 0, NULL, funcInfo, predInfo);
|
||||
attributeNumberA, 0, NULL, funcInfo, predInfo);
|
||||
|
||||
/*
|
||||
* index_build will close both the heap and index relations
|
||||
* (but not give up the locks we hold on them). That's fine
|
||||
* for the index, but we need to open the heap again. We need
|
||||
* no new lock, since this backend still has the exclusive lock
|
||||
* grabbed by heap_truncate.
|
||||
* index_build will close both the heap and index relations (but not
|
||||
* give up the locks we hold on them). That's fine for the index, but
|
||||
* we need to open the heap again. We need no new lock, since this
|
||||
* backend still has the exclusive lock grabbed by heap_truncate.
|
||||
*/
|
||||
iRel = index_open(indexId);
|
||||
Assert(iRel != NULL);
|
||||
@@ -2170,7 +2189,7 @@ reindex_index(Oid indexId, bool force)
|
||||
|
||||
/*
|
||||
* ----------------------------
|
||||
* activate_indexes_of_a_table
|
||||
* activate_indexes_of_a_table
|
||||
* activate/deactivate indexes of the specified table.
|
||||
* ----------------------------
|
||||
*/
|
||||
@@ -2182,21 +2201,18 @@ activate_indexes_of_a_table(Oid relid, bool activate)
|
||||
if (!activate)
|
||||
setRelhasindexInplace(relid, false, true);
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (activate)
|
||||
reindex_relation(relid, false);
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
* reindex_relation - This routine is used to recreate indexes
|
||||
* of a relation.
|
||||
@@ -2206,10 +2222,11 @@ bool
|
||||
reindex_relation(Oid relid, bool force)
|
||||
{
|
||||
Relation indexRelation;
|
||||
ScanKeyData entry;
|
||||
HeapScanDesc scan;
|
||||
ScanKeyData entry;
|
||||
HeapScanDesc scan;
|
||||
HeapTuple indexTuple;
|
||||
bool old, reindexed;
|
||||
bool old,
|
||||
reindexed;
|
||||
|
||||
old = SetReindexProcessing(true);
|
||||
if (IndexesAreActive(relid, true))
|
||||
@@ -2224,13 +2241,14 @@ reindex_relation(Oid relid, bool force)
|
||||
|
||||
indexRelation = heap_openr(IndexRelationName, AccessShareLock);
|
||||
ScanKeyEntryInitialize(&entry, 0, Anum_pg_index_indrelid,
|
||||
F_OIDEQ, ObjectIdGetDatum(relid));
|
||||
F_OIDEQ, ObjectIdGetDatum(relid));
|
||||
scan = heap_beginscan(indexRelation, false, SnapshotNow,
|
||||
1, &entry);
|
||||
1, &entry);
|
||||
reindexed = false;
|
||||
while (HeapTupleIsValid(indexTuple = heap_getnext(scan, 0)))
|
||||
{
|
||||
Form_pg_index index = (Form_pg_index) GETSTRUCT(indexTuple);
|
||||
Form_pg_index index = (Form_pg_index) GETSTRUCT(indexTuple);
|
||||
|
||||
if (activate_index(index->indexrelid, true))
|
||||
reindexed = true;
|
||||
else
|
||||
@@ -2242,9 +2260,7 @@ reindex_relation(Oid relid, bool force)
|
||||
heap_endscan(scan);
|
||||
heap_close(indexRelation, AccessShareLock);
|
||||
if (reindexed)
|
||||
{
|
||||
setRelhasindexInplace(relid, true, false);
|
||||
}
|
||||
SetReindexProcessing(old);
|
||||
return reindexed;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.59 2000/02/18 09:28:41 inoue Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.60 2000/04/12 17:14:56 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -31,54 +31,54 @@
|
||||
*/
|
||||
|
||||
char *Name_pg_aggregate_indices[Num_pg_aggregate_indices] =
|
||||
{AggregateNameTypeIndex};
|
||||
{AggregateNameTypeIndex};
|
||||
char *Name_pg_am_indices[Num_pg_am_indices] =
|
||||
{AmNameIndex};
|
||||
{AmNameIndex};
|
||||
char *Name_pg_amop_indices[Num_pg_amop_indices] =
|
||||
{AccessMethodOpidIndex, AccessMethodStrategyIndex};
|
||||
{AccessMethodOpidIndex, AccessMethodStrategyIndex};
|
||||
char *Name_pg_attr_indices[Num_pg_attr_indices] =
|
||||
{AttributeRelidNameIndex, AttributeRelidNumIndex};
|
||||
{AttributeRelidNameIndex, AttributeRelidNumIndex};
|
||||
char *Name_pg_attrdef_indices[Num_pg_attrdef_indices] =
|
||||
{AttrDefaultIndex};
|
||||
{AttrDefaultIndex};
|
||||
char *Name_pg_class_indices[Num_pg_class_indices] =
|
||||
{ClassNameIndex, ClassOidIndex};
|
||||
{ClassNameIndex, ClassOidIndex};
|
||||
char *Name_pg_group_indices[Num_pg_group_indices] =
|
||||
{GroupNameIndex, GroupSysidIndex};
|
||||
{GroupNameIndex, GroupSysidIndex};
|
||||
char *Name_pg_index_indices[Num_pg_index_indices] =
|
||||
{IndexRelidIndex};
|
||||
{IndexRelidIndex};
|
||||
char *Name_pg_inherits_indices[Num_pg_inherits_indices] =
|
||||
{InheritsRelidSeqnoIndex};
|
||||
{InheritsRelidSeqnoIndex};
|
||||
char *Name_pg_language_indices[Num_pg_language_indices] =
|
||||
{LanguageOidIndex, LanguageNameIndex};
|
||||
{LanguageOidIndex, LanguageNameIndex};
|
||||
char *Name_pg_listener_indices[Num_pg_listener_indices] =
|
||||
{ListenerRelnamePidIndex};
|
||||
{ListenerRelnamePidIndex};
|
||||
char *Name_pg_opclass_indices[Num_pg_opclass_indices] =
|
||||
{OpclassNameIndex, OpclassDeftypeIndex};
|
||||
{OpclassNameIndex, OpclassDeftypeIndex};
|
||||
char *Name_pg_operator_indices[Num_pg_operator_indices] =
|
||||
{OperatorOidIndex, OperatorNameIndex};
|
||||
{OperatorOidIndex, OperatorNameIndex};
|
||||
char *Name_pg_proc_indices[Num_pg_proc_indices] =
|
||||
{ProcedureOidIndex, ProcedureNameIndex};
|
||||
{ProcedureOidIndex, ProcedureNameIndex};
|
||||
char *Name_pg_relcheck_indices[Num_pg_relcheck_indices] =
|
||||
{RelCheckIndex};
|
||||
{RelCheckIndex};
|
||||
char *Name_pg_rewrite_indices[Num_pg_rewrite_indices] =
|
||||
{RewriteOidIndex, RewriteRulenameIndex};
|
||||
{RewriteOidIndex, RewriteRulenameIndex};
|
||||
char *Name_pg_shadow_indices[Num_pg_shadow_indices] =
|
||||
{ShadowNameIndex, ShadowSysidIndex};
|
||||
{ShadowNameIndex, ShadowSysidIndex};
|
||||
char *Name_pg_statistic_indices[Num_pg_statistic_indices] =
|
||||
{StatisticRelidAttnumIndex};
|
||||
{StatisticRelidAttnumIndex};
|
||||
char *Name_pg_trigger_indices[Num_pg_trigger_indices] =
|
||||
{TriggerRelidIndex, TriggerConstrNameIndex, TriggerConstrRelidIndex};
|
||||
{TriggerRelidIndex, TriggerConstrNameIndex, TriggerConstrRelidIndex};
|
||||
char *Name_pg_type_indices[Num_pg_type_indices] =
|
||||
{TypeNameIndex, TypeOidIndex};
|
||||
char *Name_pg_description_indices[Num_pg_description_indices] =
|
||||
{DescriptionObjIndex};
|
||||
{TypeNameIndex, TypeOidIndex};
|
||||
char *Name_pg_description_indices[Num_pg_description_indices] =
|
||||
{DescriptionObjIndex};
|
||||
|
||||
|
||||
|
||||
static HeapTuple CatalogIndexFetchTuple(Relation heapRelation,
|
||||
Relation idesc,
|
||||
ScanKey skey,
|
||||
int16 num_keys);
|
||||
Relation idesc,
|
||||
ScanKey skey,
|
||||
int16 num_keys);
|
||||
|
||||
|
||||
/*
|
||||
@@ -279,7 +279,7 @@ CatalogIndexFetchTuple(Relation heapRelation,
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* Class-specific index lookups
|
||||
* Class-specific index lookups
|
||||
*---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -297,7 +297,7 @@ AggregateNameTypeIndexScan(Relation heapRelation, char *aggName, Oid aggType)
|
||||
Relation idesc;
|
||||
ScanKeyData skey[2];
|
||||
HeapTuple tuple;
|
||||
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
@@ -324,7 +324,7 @@ AmNameIndexScan(Relation heapRelation, char *amName)
|
||||
Relation idesc;
|
||||
ScanKeyData skey[1];
|
||||
HeapTuple tuple;
|
||||
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
@@ -414,8 +414,8 @@ AccessMethodStrategyIndexScan(Relation heapRelation,
|
||||
|
||||
HeapTuple
|
||||
AttributeRelidNameIndexScan(Relation heapRelation,
|
||||
Oid relid,
|
||||
char *attname)
|
||||
Oid relid,
|
||||
char *attname)
|
||||
{
|
||||
Relation idesc;
|
||||
ScanKeyData skey[2];
|
||||
@@ -444,8 +444,8 @@ AttributeRelidNameIndexScan(Relation heapRelation,
|
||||
|
||||
HeapTuple
|
||||
AttributeRelidNumIndexScan(Relation heapRelation,
|
||||
Oid relid,
|
||||
AttrNumber attnum)
|
||||
Oid relid,
|
||||
AttrNumber attnum)
|
||||
{
|
||||
Relation idesc;
|
||||
ScanKeyData skey[2];
|
||||
@@ -500,7 +500,7 @@ OpclassNameIndexScan(Relation heapRelation, char *opcName)
|
||||
Relation idesc;
|
||||
ScanKeyData skey[1];
|
||||
HeapTuple tuple;
|
||||
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
@@ -521,7 +521,7 @@ GroupNameIndexScan(Relation heapRelation, char *groName)
|
||||
Relation idesc;
|
||||
ScanKeyData skey[1];
|
||||
HeapTuple tuple;
|
||||
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
@@ -542,7 +542,7 @@ GroupSysidIndexScan(Relation heapRelation, int4 sysId)
|
||||
Relation idesc;
|
||||
ScanKeyData skey[1];
|
||||
HeapTuple tuple;
|
||||
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
@@ -581,8 +581,8 @@ IndexRelidIndexScan(Relation heapRelation, Oid relid)
|
||||
|
||||
HeapTuple
|
||||
InheritsRelidSeqnoIndexScan(Relation heapRelation,
|
||||
Oid relid,
|
||||
int4 seqno)
|
||||
Oid relid,
|
||||
int4 seqno)
|
||||
{
|
||||
Relation idesc;
|
||||
ScanKeyData skey[2];
|
||||
@@ -615,7 +615,7 @@ LanguageNameIndexScan(Relation heapRelation, char *lanName)
|
||||
Relation idesc;
|
||||
ScanKeyData skey[1];
|
||||
HeapTuple tuple;
|
||||
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
@@ -658,7 +658,7 @@ ListenerRelnamePidIndexScan(Relation heapRelation, char *relName, int4 pid)
|
||||
Relation idesc;
|
||||
ScanKeyData skey[2];
|
||||
HeapTuple tuple;
|
||||
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
@@ -681,10 +681,10 @@ ListenerRelnamePidIndexScan(Relation heapRelation, char *relName, int4 pid)
|
||||
|
||||
HeapTuple
|
||||
OperatorNameIndexScan(Relation heapRelation,
|
||||
char *oprName,
|
||||
Oid oprLeft,
|
||||
Oid oprRight,
|
||||
char oprKind)
|
||||
char *oprName,
|
||||
Oid oprLeft,
|
||||
Oid oprRight,
|
||||
char oprKind)
|
||||
{
|
||||
Relation idesc;
|
||||
ScanKeyData skey[4];
|
||||
@@ -810,7 +810,7 @@ ClassNameIndexScan(Relation heapRelation, char *relName)
|
||||
Relation idesc;
|
||||
ScanKeyData skey[1];
|
||||
HeapTuple tuple;
|
||||
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
@@ -853,7 +853,7 @@ RewriteRulenameIndexScan(Relation heapRelation, char *ruleName)
|
||||
Relation idesc;
|
||||
ScanKeyData skey[1];
|
||||
HeapTuple tuple;
|
||||
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
@@ -896,7 +896,7 @@ ShadowNameIndexScan(Relation heapRelation, char *useName)
|
||||
Relation idesc;
|
||||
ScanKeyData skey[1];
|
||||
HeapTuple tuple;
|
||||
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
@@ -917,7 +917,7 @@ ShadowSysidIndexScan(Relation heapRelation, int4 sysId)
|
||||
Relation idesc;
|
||||
ScanKeyData skey[1];
|
||||
HeapTuple tuple;
|
||||
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
@@ -934,8 +934,8 @@ ShadowSysidIndexScan(Relation heapRelation, int4 sysId)
|
||||
|
||||
HeapTuple
|
||||
StatisticRelidAttnumIndexScan(Relation heapRelation,
|
||||
Oid relId,
|
||||
AttrNumber attNum)
|
||||
Oid relId,
|
||||
AttrNumber attNum)
|
||||
{
|
||||
Relation idesc;
|
||||
ScanKeyData skey[2];
|
||||
@@ -1004,4 +1004,3 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId)
|
||||
|
||||
return tuple;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.30 2000/03/26 19:43:58 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.31 2000/04/12 17:14:56 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -168,7 +168,7 @@ AggregateCreate(char *aggName,
|
||||
/* handle finalfn */
|
||||
if (aggfinalfnName)
|
||||
{
|
||||
int nargs = 0;
|
||||
int nargs = 0;
|
||||
|
||||
if (OidIsValid(xret1))
|
||||
fnArgs[nargs++] = xret1;
|
||||
@@ -184,7 +184,7 @@ AggregateCreate(char *aggName,
|
||||
{
|
||||
if (nargs == 2)
|
||||
elog(ERROR, "AggregateCreate: '%s'('%s','%s') does not exist",
|
||||
aggfinalfnName, aggtransfn1typeName, aggtransfn2typeName);
|
||||
aggfinalfnName, aggtransfn1typeName, aggtransfn2typeName);
|
||||
else if (OidIsValid(xret1))
|
||||
elog(ERROR, "AggregateCreate: '%s'('%s') does not exist",
|
||||
aggfinalfnName, aggtransfn1typeName);
|
||||
@@ -200,8 +200,10 @@ AggregateCreate(char *aggName,
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If no finalfn, aggregate result type is type of the sole
|
||||
* state value (we already checked there is only one)
|
||||
|
||||
/*
|
||||
* If no finalfn, aggregate result type is type of the sole state
|
||||
* value (we already checked there is only one)
|
||||
*/
|
||||
if (OidIsValid(xret1))
|
||||
fret = xret1;
|
||||
@@ -284,9 +286,9 @@ AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool *isNull)
|
||||
Assert(xfuncno == 1 || xfuncno == 2);
|
||||
|
||||
/*
|
||||
* since we will have to use fastgetattr (in case one or both init vals
|
||||
* are NULL), we will need to open the relation. Do that first to
|
||||
* ensure we don't get a stale tuple from the cache.
|
||||
* since we will have to use fastgetattr (in case one or both init
|
||||
* vals are NULL), we will need to open the relation. Do that first
|
||||
* to ensure we don't get a stale tuple from the cache.
|
||||
*/
|
||||
|
||||
aggRel = heap_openr(AggregateRelationName, AccessShareLock);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.41 2000/04/04 21:44:37 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.42 2000/04/12 17:14:56 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -154,7 +154,7 @@ ProcedureCreate(char *procedureName,
|
||||
return tup->t_data->t_oid;
|
||||
#else
|
||||
elog(ERROR, "lookup for procedure by source needs fix (Jan)");
|
||||
#endif /* SETS_FIXED */
|
||||
#endif /* SETS_FIXED */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ ProcedureCreate(char *procedureName,
|
||||
prosrc = procedureName;
|
||||
if (fmgr_lookupByName(prosrc) == (func_ptr) NULL)
|
||||
elog(ERROR,
|
||||
"ProcedureCreate: there is no builtin function named \"%s\"",
|
||||
"ProcedureCreate: there is no builtin function named \"%s\"",
|
||||
prosrc);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.49 2000/01/26 05:56:11 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.50 2000/04/12 17:14:56 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -374,7 +374,7 @@ TypeCreate(char *typeName,
|
||||
values[i++] = (Datum) GetUserId(); /* 2 */
|
||||
values[i++] = (Datum) internalSize; /* 3 */
|
||||
values[i++] = (Datum) externalSize; /* 4 */
|
||||
values[i++] = (Datum) passedByValue;/* 5 */
|
||||
values[i++] = (Datum) passedByValue; /* 5 */
|
||||
values[i++] = (Datum) typeType; /* 6 */
|
||||
values[i++] = (Datum) (bool) 1; /* 7 */
|
||||
values[i++] = (Datum) typDelim; /* 8 */
|
||||
|
||||
Reference in New Issue
Block a user