aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHiroshi Inoue <inoue@tpf.co.jp>2001-08-17 23:50:00 +0000
committerHiroshi Inoue <inoue@tpf.co.jp>2001-08-17 23:50:00 +0000
commit58d4f951ea193db219e9da66e07c73b8aa3f06db (patch)
treec7ed006952cba87456a6e4f29cf869fbd37c3d24 /src
parent9df188bc0d40c7c52d58d9678eb374dc68ee49a2 (diff)
downloadpostgresql-58d4f951ea193db219e9da66e07c73b8aa3f06db.tar.gz
postgresql-58d4f951ea193db219e9da66e07c73b8aa3f06db.zip
Ensure to hold an exclusive lock while reindexing a relation.
This is mainly to help developers to understand the code.
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/index.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index d3f866236f7..4dbc1648c19 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.159 2001/08/10 18:57:33 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.160 2001/08/17 23:50:00 inoue Exp $
*
*
* INTERFACE ROUTINES
@@ -2017,10 +2017,15 @@ reindex_relation(Oid relid, bool force)
upd_pg_class_inplace = true;
/*
+ * Ensure to hold an exclusive lock throughout the
+ * transaction. The lock could be less intensive
+ * but now it's AccessExclusiveLock for simplicity.
+ */
+ rel = heap_open(relid, AccessExclusiveLock);
+ /*
* ignore the indexes of the target system relation while processing
* reindex.
*/
- rel = RelationIdGetRelation(relid);
if (!IsIgnoringSystemIndexes() && IsSystemRelationName(NameStr(rel->rd_rel->relname)))
deactivate_needed = true;
#ifndef ENABLE_REINDEX_NAILED_RELATIONS
@@ -2055,7 +2060,10 @@ reindex_relation(Oid relid, bool force)
else
elog(ERROR, "the target relation %u is shared", relid);
}
- RelationClose(rel);
+ /*
+ * Continue to hold the lock.
+ */
+ heap_close(rel, NoLock);
old = SetReindexProcessing(true);
if (deactivate_needed)