aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/init/miscinit.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-09-24 18:54:02 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-09-24 18:54:02 +0000
commita56a016ceb612cdee1ddc5990682f36d541e5b07 (patch)
treec496319424e0445562dd42ee7229e6d87567996f /src/backend/utils/init/miscinit.c
parent5f78c6a886a22209dee62de0c13edd6a68453011 (diff)
downloadpostgresql-a56a016ceb612cdee1ddc5990682f36d541e5b07.tar.gz
postgresql-a56a016ceb612cdee1ddc5990682f36d541e5b07.zip
Repair some REINDEX problems per recent discussions. The relcache is
now able to cope with assigning new relfilenode values to nailed-in-cache indexes, so they can be reindexed using the fully crash-safe method. This leaves only shared system indexes as special cases. Remove the 'index deactivation' code, since it provides no useful protection in the shared- index case. Require reindexing of shared indexes to be done in standalone mode, but remove other restrictions on REINDEX. -P (IgnoreSystemIndexes) now prevents using indexes for lookups, but does not disable index updates. It is therefore safe to allow from PGOPTIONS. Upshot: reindexing system catalogs can be done without a standalone backend for all cases except shared catalogs.
Diffstat (limited to 'src/backend/utils/init/miscinit.c')
-rw-r--r--src/backend/utils/init/miscinit.c59
1 files changed, 55 insertions, 4 deletions
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index 9f19d1187ba..22baac3706f 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.113 2003/08/04 04:03:10 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.114 2003/09/24 18:54:01 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -51,6 +51,11 @@ static char socketLockFile[MAXPGPATH];
/* ----------------------------------------------------------------
* ignoring system indexes support stuff
+ *
+ * NOTE: "ignoring system indexes" means we do not use the system indexes
+ * for lookups (either in hardwired catalog accesses or in planner-generated
+ * plans). We do, however, still update the indexes when a catalog
+ * modification is made.
* ----------------------------------------------------------------
*/
@@ -61,15 +66,14 @@ static bool isIgnoringSystemIndexes = false;
* True if ignoring system indexes.
*/
bool
-IsIgnoringSystemIndexes()
+IsIgnoringSystemIndexes(void)
{
return isIgnoringSystemIndexes;
}
/*
* IgnoreSystemIndexes
- * Set true or false whether PostgreSQL ignores system indexes.
- *
+ * Set true or false whether PostgreSQL ignores system indexes.
*/
void
IgnoreSystemIndexes(bool mode)
@@ -78,6 +82,53 @@ IgnoreSystemIndexes(bool mode)
}
/* ----------------------------------------------------------------
+ * system index reindexing support
+ *
+ * When we are busy reindexing a system index, this code provides support
+ * for preventing catalog lookups from using that index.
+ * ----------------------------------------------------------------
+ */
+
+static Oid currentlyReindexedHeap = InvalidOid;
+static Oid currentlyReindexedIndex = InvalidOid;
+
+/*
+ * ReindexIsProcessingHeap
+ * True if heap specified by OID is currently being reindexed.
+ */
+bool
+ReindexIsProcessingHeap(Oid heapOid)
+{
+ return heapOid == currentlyReindexedHeap;
+}
+
+/*
+ * ReindexIsProcessingIndex
+ * True if index specified by OID is currently being reindexed.
+ */
+bool
+ReindexIsProcessingIndex(Oid indexOid)
+{
+ return indexOid == currentlyReindexedIndex;
+}
+
+/*
+ * SetReindexProcessing
+ * Set flag that specified heap/index are being reindexed.
+ * Pass InvalidOid to indicate that reindexing is not active.
+ */
+void
+SetReindexProcessing(Oid heapOid, Oid indexOid)
+{
+ /* Args should be both, or neither, InvalidOid */
+ Assert((heapOid == InvalidOid) == (indexOid == InvalidOid));
+ /* Reindexing is not re-entrant. */
+ Assert(indexOid == InvalidOid || currentlyReindexedIndex == InvalidOid);
+ currentlyReindexedHeap = heapOid;
+ currentlyReindexedIndex = indexOid;
+}
+
+/* ----------------------------------------------------------------
* database path / name support stuff
* ----------------------------------------------------------------
*/