aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index ae15b815332..f211448f413 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.49 2002/10/21 20:31:51 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.50 2002/10/21 22:06:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -376,6 +376,16 @@ TruncateRelation(const RangeVar *relation)
aclcheck_error(ACLCHECK_NOT_OWNER, RelationGetRelationName(rel));
/*
+ * Truncate within a transaction block is dangerous, because if
+ * the transaction is later rolled back we have no way to undo
+ * truncation of the relation's physical file. Disallow it except for
+ * a rel created in the current xact (which would be deleted on abort,
+ * anyway).
+ */
+ if (!rel->rd_isnew)
+ PreventTransactionChain((void *) relation, "TRUNCATE TABLE");
+
+ /*
* Don't allow truncate on temp tables of other backends ... their
* local buffer manager is not going to cope.
*/