aboutsummaryrefslogtreecommitdiff
path: root/src/include/commands/tablecmds.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-01-30 19:46:48 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-01-30 19:46:48 +0000
commit0688d84041f7963a2a00468c53aec7bb6051ef5c (patch)
tree51e38fe31f476f4003c44f3b23f5253c33f0b56a /src/include/commands/tablecmds.h
parent47df4f668826c0646ae30d37971e4ff15e77b3e3 (diff)
downloadpostgresql-0688d84041f7963a2a00468c53aec7bb6051ef5c.tar.gz
postgresql-0688d84041f7963a2a00468c53aec7bb6051ef5c.zip
Add checks to TRUNCATE, CLUSTER, and REINDEX to prevent performing these
operations when the current transaction has any open references to the target relation or index (implying it has an active query using the relation). The need for this was previously recognized in connection with ALTER TABLE, but anything that summarily eliminates tuples or moves them around would confuse an active scan. While this patch does not in itself fix bug #3883 (the deadlock would happen before the new check fires), it will discourage people from attempting the sequence of operations that creates a deadlock risk, so it's at least a partial response to that problem. In passing, add a previously-missing check to REINDEX to prevent trying to reindex another backend's temp table. This isn't a security problem since only a superuser would get past the schema permission checks, but if we are testing for this in other utility commands then surely REINDEX should too.
Diffstat (limited to 'src/include/commands/tablecmds.h')
-rw-r--r--src/include/commands/tablecmds.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h
index e915fb894c3..e9c965439ce 100644
--- a/src/include/commands/tablecmds.h
+++ b/src/include/commands/tablecmds.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/tablecmds.h,v 1.36 2008/01/01 19:45:57 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/commands/tablecmds.h,v 1.37 2008/01/30 19:46:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -34,6 +34,8 @@ extern void AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
Oid oldNspOid, Oid newNspOid,
bool hasDependEntry);
+extern void CheckTableNotInUse(Relation rel, const char *stmt);
+
extern void ExecuteTruncate(TruncateStmt *stmt);
extern void renameatt(Oid myrelid,