*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.190 2002/08/28 20:46:47 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.196 2002/09/04 20:31:14 momjian Exp $
*
*
* INTERFACE ROUTINES
/*
* Allocate and zero a tuple descriptor for a one-column tuple.
*/
- funcTupDesc = CreateTemplateTupleDesc(1, UNDEFOID);
+ funcTupDesc = CreateTemplateTupleDesc(1, false);
funcTupDesc->attrs[0] = (Form_pg_attribute) palloc(ATTRIBUTE_TUPLE_SIZE);
MemSet(funcTupDesc->attrs[0], 0, ATTRIBUTE_TUPLE_SIZE);
* allocate the new tuple descriptor
*/
- indexTupDesc = CreateTemplateTupleDesc(numatts, WITHOUTOID);
+ indexTupDesc = CreateTemplateTupleDesc(numatts, false);
/* ----------------
* for each attribute we are indexing, obtain its attribute
to->attcacheoff = -1;
to->attnotnull = false;
to->atthasdef = false;
+ to->attisinherited = false;
/*
* We do not yet have the correct relation OID for the index, so
/* XXX Natts_pg_class_fixed is a hack - see pg_class.h */
tuple = heap_addheader(Natts_pg_class_fixed,
- true,
+ true,
CLASS_TUPLE_SIZE,
(void *) indexRelation->rd_rel);
/*
- * the new tuple must have the oid already chosen for the index.
- * sure would be embarrassing to do this sort of thing in polite company.
+ * the new tuple must have the oid already chosen for the index. sure
+ * would be embarrassing to do this sort of thing in polite company.
*/
- AssertTupleDescHasOid(pg_class->rd_att);
HeapTupleSetOid(tuple, RelationGetRelid(indexRelation));
simple_heap_insert(pg_class, tuple);
Assert(indexTupDesc->attrs[i]->attcacheoff == -1);
new_tuple = heap_addheader(Natts_pg_attribute,
- false,
+ false,
ATTRIBUTE_TUPLE_SIZE,
(void *) indexTupDesc->attrs[i]);
indexForm->indexrelid = indexoid;
indexForm->indrelid = heapoid;
indexForm->indproc = indexInfo->ii_FuncOid;
- indexForm->indisclustered = false; /* not used */
+ indexForm->indisclustered = false; /* not clustered, yet */
indexForm->indisunique = indexInfo->ii_Unique;
indexForm->indisprimary = primary;
memcpy((char *) &indexForm->indpred, (char *) predText, predLen);
* form a tuple to insert into pg_index
*/
tuple = heap_addheader(Natts_pg_index,
- false,
+ false,
itupLen,
(void *) indexForm);
heapRelation = heap_open(heapRelationId, ShareLock);
/*
- * The index will be in the same namespace as its parent table,
- * and is shared across databases if and only if the parent is.
+ * The index will be in the same namespace as its parent table, and is
+ * shared across databases if and only if the parent is.
*/
namespaceId = RelationGetNamespace(heapRelation);
shared_relation = heapRelation->rd_rel->relisshared;
* We cannot allow indexing a shared relation after initdb (because
* there's no way to make the entry in other databases' pg_class).
* Unfortunately we can't distinguish initdb from a manually started
- * standalone backend. However, we can at least prevent this mistake
+ * standalone backend. However, we can at least prevent this mistake
* under normal multi-user operation.
*/
if (shared_relation && IsUnderPostmaster)
indexInfo->ii_KeyAttrNumbers,
classObjectId);
- indexTupDesc->tdhasoid = WITHOUTOID;
+ indexTupDesc->tdhasoid = false;
+
/*
* create the index relation's relcache entry and physical disk file.
* (If we fail further down, it's the smgr's responsibility to remove
indexRelation->rd_rel->relowner = GetUserId();
indexRelation->rd_rel->relam = accessMethodObjectId;
indexRelation->rd_rel->relkind = RELKIND_INDEX;
- indexRelation->rd_rel->relhasoids = false; /* WITHOUTOID! */
+ indexRelation->rd_rel->relhasoids = false;
/*
* store index's pg_class entry
* Register constraint and dependencies for the index.
*
* If the index is from a CONSTRAINT clause, construct a pg_constraint
- * entry. The index is then linked to the constraint, which in turn is
- * linked to the table. If it's not a CONSTRAINT, make the dependency
- * directly on the table.
+ * entry. The index is then linked to the constraint, which in turn
+ * is linked to the table. If it's not a CONSTRAINT, make the
+ * dependency directly on the table.
*
- * We don't need a dependency on the namespace, because there'll be
- * an indirect dependency via our parent table.
+ * We don't need a dependency on the namespace, because there'll be an
+ * indirect dependency via our parent table.
*
- * During bootstrap we can't register any dependencies, and we don't
- * try to make a constraint either.
+ * During bootstrap we can't register any dependencies, and we don't try
+ * to make a constraint either.
*/
if (!IsBootstrapProcessingMode())
{
- ObjectAddress myself,
- referenced;
+ ObjectAddress myself,
+ referenced;
myself.classId = RelOid_pg_class;
myself.objectId = indexoid;
else
{
elog(ERROR, "index_create: constraint must be PRIMARY or UNIQUE");
- constraintType = 0; /* keep compiler quiet */
+ constraintType = 0; /* keep compiler quiet */
}
conOid = CreateConstraintEntry(indexRelationName,
namespaceId,
constraintType,
- false, /* isDeferrable */
- false, /* isDeferred */
+ false, /* isDeferrable */
+ false, /* isDeferred */
heapRelationId,
indexInfo->ii_KeyAttrNumbers,
indexInfo->ii_NumKeyAttrs,
- InvalidOid, /* no domain */
- InvalidOid, /* no foreign key */
+ InvalidOid, /* no domain */
+ InvalidOid, /* no foreign key */
NULL,
0,
' ',
' ',
' ',
- NULL, /* no check constraint */
+ NULL, /* no check constraint */
NULL,
NULL);
* fix RELATION relation
*/
DeleteRelationTuple(indexId);
+
/*
* fix ATTRIBUTE relation
*/
smgrunlink(DEFAULT_SMGR, userIndexRelation);
/*
- * We are presently too lazy to attempt to compute the new correct value
- * of relhasindex (the next VACUUM will fix it if necessary). So there is
- * no need to update the pg_class tuple for the owning relation.
- * But we must send out a shared-cache-inval notice on the owning relation
- * to ensure other backends update their relcache lists of indexes.
+ * We are presently too lazy to attempt to compute the new correct
+ * value of relhasindex (the next VACUUM will fix it if necessary).
+ * So there is no need to update the pg_class tuple for the owning
+ * relation. But we must send out a shared-cache-inval notice on the
+ * owning relation to ensure other backends update their relcache
+ * lists of indexes.
*/
CacheInvalidateRelcache(heapId);
Buffer buffer;
RelationData workrel;
- Assert(!IsSystemRelation(relation) || relation->rd_rel->relkind == RELKIND_INDEX);
+ Assert(!IsSystemRelation(relation) || IsToastRelation(relation) ||
+ relation->rd_rel->relkind == RELKIND_INDEX);
pg_class = heap_openr(RelationRelationName, RowExclusiveLock);
/* Fetch and lock the classTuple associated with this relation */
* transaction.)
*/
if (!TransactionIdIsCurrentTransactionId(
- HeapTupleHeaderGetXmin(heapTuple->t_data)))
+ HeapTupleHeaderGetXmin(heapTuple->t_data)))
elog(ERROR, "IndexBuildHeapScan: concurrent insert in progress");
indexIt = true;
tupleIsAlive = true;
* transaction.)
*/
if (!TransactionIdIsCurrentTransactionId(
- HeapTupleHeaderGetXmax(heapTuple->t_data)))
+ HeapTupleHeaderGetXmax(heapTuple->t_data)))
elog(ERROR, "IndexBuildHeapScan: concurrent delete in progress");
indexIt = true;
tupleIsAlive = false;
/*
* Open our index relation and get an exclusive lock on it.
*
- * Note: doing this before opening the parent heap relation means
- * there's a possibility for deadlock failure against another xact
- * that is doing normal accesses to the heap and index. However,
- * it's not real clear why you'd be needing to do REINDEX on a table
- * that's in active use, so I'd rather have the protection of making
- * sure the index is locked down.
+ * Note: doing this before opening the parent heap relation means there's
+ * a possibility for deadlock failure against another xact that is
+ * doing normal accesses to the heap and index. However, it's not
+ * real clear why you'd be needing to do REINDEX on a table that's in
+ * active use, so I'd rather have the protection of making sure the
+ * index is locked down.
*/
iRel = index_open(indexId);
if (iRel == NULL)
indexInfo = BuildIndexInfo(iRel->rd_index);
/* Open the parent heap relation */
- heapRelation = heap_open(heapId, ExclusiveLock);
+ heapRelation = heap_open(heapId, AccessExclusiveLock);
if (heapRelation == NULL)
elog(ERROR, "reindex_index: can't open heap relation");
/*
* Ensure to hold an exclusive lock throughout the transaction. The
- * lock could be less intensive but now it's AccessExclusiveLock for
- * simplicity.
+ * lock could be less intensive (in the non-overwrite path) but now
+ * it's AccessExclusiveLock for simplicity.
*/
rel = heap_open(relid, AccessExclusiveLock);
* ignore the indexes of the target system relation while processing
* reindex.
*/
- if (!IsIgnoringSystemIndexes() && IsSystemRelation(rel))
+ if (!IsIgnoringSystemIndexes() &&
+ IsSystemRelation(rel) && !IsToastRelation(rel))
deactivate_needed = true;
#ifndef ENABLE_REINDEX_NAILED_RELATIONS