summaryrefslogtreecommitdiff
path: root/src/backend/catalog/index.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-08-01 17:32:22 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-08-01 17:32:22 +0000
commitefcaf1e868d8399d932e68b8b248bcbd089b2d6b (patch)
treec6235945f73faab427498dd8662efab5cf2fe5fd /src/backend/catalog/index.c
parent9d9cdf82a404f3e2a2d82cefc2c35ded55bb3b2e (diff)
downloadpostgresql-efcaf1e868d8399d932e68b8b248bcbd089b2d6b.tar.gz
Some mop-up work for savepoints (nested transactions). Store a small
number of active subtransaction XIDs in each backend's PGPROC entry, and use this to avoid expensive probes into pg_subtrans during TransactionIdIsInProgress. Extend EOXactCallback API to allow add-on modules to get control at subxact start/end. (This is deliberately not compatible with the former API, since any uses of that API probably need manual review anyway.) Add basic reference documentation for SAVEPOINT and related commands. Minor other cleanups to check off some of the open issues for subtransactions. Alvaro Herrera and Tom Lane.
Diffstat (limited to 'src/backend/catalog/index.c')
-rw-r--r--src/backend/catalog/index.c68
1 files changed, 40 insertions, 28 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 581799fc5f..9cb3c56110 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.234 2004/06/18 06:13:19 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.235 2004/08/01 17:32:14 tgl Exp $
*
*
* INTERFACE ROUTINES
@@ -1646,7 +1646,6 @@ reindex_index(Oid indexId)
{
Relation iRel,
heapRelation;
- IndexInfo *indexInfo;
Oid heapId;
bool inplace;
@@ -1671,8 +1670,6 @@ reindex_index(Oid indexId)
/* Open and lock the parent heap relation */
heapRelation = heap_open(heapId, AccessExclusiveLock);
- SetReindexProcessing(heapId, indexId);
-
/*
* If it's a shared index, we must do inplace processing (because we
* have no way to update relfilenode in other databases). Otherwise
@@ -1690,36 +1687,51 @@ reindex_index(Oid indexId)
errmsg("shared index \"%s\" can only be reindexed in stand-alone mode",
RelationGetRelationName(iRel))));
- /* Fetch info needed for index_build */
- indexInfo = BuildIndexInfo(iRel);
-
- if (inplace)
+ PG_TRY();
{
+ IndexInfo *indexInfo;
+
+ /* Suppress use of the target index while rebuilding it */
+ SetReindexProcessing(heapId, indexId);
+
+ /* Fetch info needed for index_build */
+ indexInfo = BuildIndexInfo(iRel);
+
+ if (inplace)
+ {
+ /*
+ * Release any buffers associated with this index. If they're
+ * dirty, they're just dropped without bothering to flush to disk.
+ */
+ DropRelationBuffers(iRel);
+
+ /* Now truncate the actual data */
+ RelationTruncate(iRel, 0);
+ }
+ else
+ {
+ /*
+ * We'll build a new physical relation for the index.
+ */
+ setNewRelfilenode(iRel);
+ }
+
+ /* Initialize the index and rebuild */
+ index_build(heapRelation, iRel, indexInfo);
+
/*
- * Release any buffers associated with this index. If they're
- * dirty, they're just dropped without bothering to flush to disk.
+ * index_build will close both the heap and index relations (but not
+ * give up the locks we hold on them). So we're done.
*/
- DropRelationBuffers(iRel);
-
- /* Now truncate the actual data */
- RelationTruncate(iRel, 0);
}
- else
+ PG_CATCH();
{
- /*
- * We'll build a new physical relation for the index.
- */
- setNewRelfilenode(iRel);
+ /* Make sure flag gets cleared on error exit */
+ ResetReindexProcessing();
+ PG_RE_THROW();
}
-
- /* Initialize the index and rebuild */
- index_build(heapRelation, iRel, indexInfo);
-
- /*
- * index_build will close both the heap and index relations (but not
- * give up the locks we hold on them). So we're done.
- */
- SetReindexProcessing(InvalidOid, InvalidOid);
+ PG_END_TRY();
+ ResetReindexProcessing();
}
/*