diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-10-21 22:06:20 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-10-21 22:06:20 +0000 |
commit | 200b15161556a2bc6e6b0cccd08be1ca3a438643 (patch) | |
tree | c520e1a6420f079c6b87594bd9687031f8e8ecc4 /src/backend/commands/tablecmds.c | |
parent | f724c164d3b9194555a7a7ee10bbb4bfb63caa7a (diff) | |
download | postgresql-200b15161556a2bc6e6b0cccd08be1ca3a438643.tar.gz postgresql-200b15161556a2bc6e6b0cccd08be1ca3a438643.zip |
Fix places that were using IsTransactionBlock() as an (inadequate) check
that they'd get to commit immediately on finishing. There's now a
centralized routine PreventTransactionChain() that implements the
necessary tests.
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 12 |
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. */ |