1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

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.
This commit is contained in:
Tom Lane
2002-10-21 22:06:20 +00:00
parent f724c164d3
commit 200b151615
9 changed files with 107 additions and 87 deletions

View File

@ -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 $
*
*-------------------------------------------------------------------------
*/
@ -375,6 +375,16 @@ TruncateRelation(const RangeVar *relation)
if (!pg_class_ownercheck(relid, GetUserId()))
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.