From f8bbfad075e855d4603e44847cd6ec51c91b3f92 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 4 Sep 2006 21:15:56 +0000 Subject: Disallow TRUNCATE when there are any pending after-trigger events for the target relation(s). There might be some cases where we could discard the pending event instead, but for the moment a conservative approach seems sufficient. Per report from Markus Schiltknecht and subsequent discussion. --- src/backend/commands/tablecmds.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/backend/commands/tablecmds.c') diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 7e8884496d0..45167b816af 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.201 2006/08/25 04:06:48 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.202 2006/09/04 21:15:55 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -611,6 +611,13 @@ ExecuteTruncate(TruncateStmt *stmt) heap_truncate_check_FKs(rels, false); #endif + /* + * Also check for pending AFTER trigger events on the target relations. + * We can't just leave those be, since they will try to fetch tuples + * that the TRUNCATE removes. + */ + AfterTriggerCheckTruncate(relids); + /* * OK, truncate each table. */ -- cgit v1.2.3