aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-04-16 19:29:10 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-04-16 19:29:10 -0400
commitd2f60a3ab055fb61c8e1056a7c5652f1dec85e00 (patch)
tree6c88533d46c1e014e414164c3c27795ace297e15 /src
parent2d3320d3d256eed7ea3deb8383348f2021e6a247 (diff)
downloadpostgresql-d2f60a3ab055fb61c8e1056a7c5652f1dec85e00.tar.gz
postgresql-d2f60a3ab055fb61c8e1056a7c5652f1dec85e00.zip
Add an Assert that indexam.c isn't used on an index awaiting reindexing.
This might have caught the recent embarrassment over trying to modify pg_index while its indexes were being rebuilt. Noah Misch
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/index/indexam.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c
index 6e0db795176..08de8b4f88a 100644
--- a/src/backend/access/index/indexam.c
+++ b/src/backend/access/index/indexam.c
@@ -65,6 +65,7 @@
#include "access/relscan.h"
#include "access/transam.h"
#include "access/xact.h"
+#include "catalog/index.h"
#include "pgstat.h"
#include "storage/bufmgr.h"
#include "storage/lmgr.h"
@@ -76,12 +77,21 @@
/* ----------------------------------------------------------------
* macros used in index_ routines
+ *
+ * Note: the ReindexIsProcessingIndex() check in RELATION_CHECKS is there
+ * to check that we don't try to scan or do retail insertions into an index
+ * that is currently being rebuilt or pending rebuild. This helps to catch
+ * things that don't work when reindexing system catalogs. The assertion
+ * doesn't prevent the actual rebuild because we don't use RELATION_CHECKS
+ * when calling the index AM's ambuild routine, and there is no reason for
+ * ambuild to call its subsidiary routines through this file.
* ----------------------------------------------------------------
*/
#define RELATION_CHECKS \
( \
AssertMacro(RelationIsValid(indexRelation)), \
- AssertMacro(PointerIsValid(indexRelation->rd_am)) \
+ AssertMacro(PointerIsValid(indexRelation->rd_am)), \
+ AssertMacro(!ReindexIsProcessingIndex(RelationGetRelid(indexRelation))) \
)
#define SCAN_CHECKS \