Skip to content

Commit f39a7f3

Browse files
author
Etsuro Fujita
committed
Fix oversight in FindTriggerIncompatibleWithInheritance.
This function is called from ATExecAttachPartition/ATExecAddInherit, which prevent tables with row-level triggers with transition tables from becoming partitions or inheritance children, to check if there is such a trigger on the given table, but failed to check if a found trigger is row-level, causing the caller functions to needlessly prevent a table with only a statement-level trigger with transition tables from becoming a partition or inheritance child. Repair. Oversight in commit 501ed02. Author: Etsuro Fujita <etsuro.fujita@gmail.com> Discussion: https://postgr.es/m/CAPmGK167mXzwzzmJ_0YZ3EZrbwiCxtM1vogH_8drqsE6PtxRYw%40mail.gmail.com Backpatch-through: 13
1 parent 18d2d8a commit f39a7f3

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/backend/commands/trigger.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,6 +2348,8 @@ FindTriggerIncompatibleWithInheritance(TriggerDesc *trigdesc)
23482348
{
23492349
Trigger *trigger = &trigdesc->triggers[i];
23502350

2351+
if (!TRIGGER_FOR_ROW(trigger->tgtype))
2352+
continue;
23512353
if (trigger->tgoldtable != NULL || trigger->tgnewtable != NULL)
23522354
return trigger->tgname;
23532355
}

src/test/regress/expected/triggers.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3016,6 +3016,10 @@ NOTICE: trigger = child3_delete_trig, old table = (42,CCC)
30163016
-- copy into parent sees parent-format tuples
30173017
copy parent (a, b) from stdin;
30183018
NOTICE: trigger = parent_insert_trig, new table = (AAA,42), (BBB,42), (CCC,42)
3019+
-- check detach/reattach behavior; statement triggers with transition tables
3020+
-- should not prevent a table from becoming a partition again
3021+
alter table parent detach partition child1;
3022+
alter table parent attach partition child1 for values in ('AAA');
30193023
-- DML affecting parent sees tuples collected from children even if
30203024
-- there is no transition table trigger on the children
30213025
drop trigger child1_insert_trig on child1;
@@ -3213,6 +3217,10 @@ NOTICE: trigger = parent_insert_trig, new table = (AAA,42), (BBB,42), (CCC,42)
32133217
create index on parent(b);
32143218
copy parent (a, b) from stdin;
32153219
NOTICE: trigger = parent_insert_trig, new table = (DDD,42)
3220+
-- check disinherit/reinherit behavior; statement triggers with transition
3221+
-- tables should not prevent a table from becoming an inheritance child again
3222+
alter table child1 no inherit parent;
3223+
alter table child1 inherit parent;
32163224
-- DML affecting parent sees tuples collected from children even if
32173225
-- there is no transition table trigger on the children
32183226
drop trigger child1_insert_trig on child1;

src/test/regress/sql/triggers.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,6 +2110,11 @@ BBB 42
21102110
CCC 42
21112111
\.
21122112

2113+
-- check detach/reattach behavior; statement triggers with transition tables
2114+
-- should not prevent a table from becoming a partition again
2115+
alter table parent detach partition child1;
2116+
alter table parent attach partition child1 for values in ('AAA');
2117+
21132118
-- DML affecting parent sees tuples collected from children even if
21142119
-- there is no transition table trigger on the children
21152120
drop trigger child1_insert_trig on child1;
@@ -2329,6 +2334,11 @@ copy parent (a, b) from stdin;
23292334
DDD 42
23302335
\.
23312336

2337+
-- check disinherit/reinherit behavior; statement triggers with transition
2338+
-- tables should not prevent a table from becoming an inheritance child again
2339+
alter table child1 no inherit parent;
2340+
alter table child1 inherit parent;
2341+
23322342
-- DML affecting parent sees tuples collected from children even if
23332343
-- there is no transition table trigger on the children
23342344
drop trigger child1_insert_trig on child1;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy