summaryrefslogtreecommitdiff
path: root/src/backend/commands/analyze.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-08-18 16:09:13 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-08-18 16:09:13 +0000
commit7aa772f03e03c361683cf05c8cd66a9bfc8956c7 (patch)
tree4fb82294b3cdbdb9ddb9b8bd3c81407d6189bb57 /src/backend/commands/analyze.c
parente91600d1c2e79914e6c8ac445c340e704c710b66 (diff)
Now that we've rearranged relation open to get a lock before touching
the rel, it's easy to get rid of the narrow race-condition window that used to exist in VACUUM and CLUSTER. Did some minor code-beautification work in the same area, too.
Diffstat (limited to 'src/backend/commands/analyze.c')
-rw-r--r--src/backend/commands/analyze.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index 34a38b20e29..2930eacb503 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.96 2006/07/14 14:52:18 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.97 2006/08/18 16:09:08 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -129,20 +129,16 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
CHECK_FOR_INTERRUPTS();
/*
- * Race condition -- if the pg_class tuple has gone away since the last
- * time we saw it, we don't need to process it.
+ * Open the relation, getting only a read lock on it. If the rel has
+ * been dropped since we last saw it, we don't need to process it.
*/
- if (!SearchSysCacheExists(RELOID,
- ObjectIdGetDatum(relid),
- 0, 0, 0))
+ onerel = try_relation_open(relid, AccessShareLock);
+ if (!onerel)
return;
/*
- * Open the class, getting only a read lock on it, and check permissions.
- * Permissions check should match vacuum's check!
+ * Check permissions --- this should match vacuum's check!
*/
- onerel = relation_open(relid, AccessShareLock);
-
if (!(pg_class_ownercheck(RelationGetRelid(onerel), GetUserId()) ||
(pg_database_ownercheck(MyDatabaseId, GetUserId()) && !onerel->rd_rel->relisshared)))
{