Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9e63f83

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 frombecoming partitions or inheritance children, to check if there is such atrigger on the given table, but failed to check if a found trigger isrow-level, causing the caller functions to needlessly prevent a tablewith only a statement-level trigger with transition tables from becominga partition or inheritance child. Repair.Oversight in commit501ed02.Author: Etsuro Fujita <etsuro.fujita@gmail.com>Discussion:https://postgr.es/m/CAPmGK167mXzwzzmJ_0YZ3EZrbwiCxtM1vogH_8drqsE6PtxRYw%40mail.gmail.comBackpatch-through: 13
1 parent85ccd7e commit9e63f83

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
@@ -2285,6 +2285,8 @@ FindTriggerIncompatibleWithInheritance(TriggerDesc *trigdesc)
22852285
{
22862286
Trigger*trigger=&trigdesc->triggers[i];
22872287

2288+
if (!TRIGGER_FOR_ROW(trigger->tgtype))
2289+
continue;
22882290
if (trigger->tgoldtable!=NULL||trigger->tgnewtable!=NULL)
22892291
returntrigger->tgname;
22902292
}

‎src/test/regress/expected/triggers.out‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,6 +2769,10 @@ NOTICE: trigger = child3_delete_trig, old table = (42,CCC)
27692769
-- copy into parent sees parent-format tuples
27702770
copy parent (a, b) from stdin;
27712771
NOTICE: trigger = parent_insert_trig, new table = (AAA,42), (BBB,42), (CCC,42)
2772+
-- check detach/reattach behavior; statement triggers with transition tables
2773+
-- should not prevent a table from becoming a partition again
2774+
alter table parent detach partition child1;
2775+
alter table parent attach partition child1 for values in ('AAA');
27722776
-- DML affecting parent sees tuples collected from children even if
27732777
-- there is no transition table trigger on the children
27742778
drop trigger child1_insert_trig on child1;
@@ -2966,6 +2970,10 @@ NOTICE: trigger = parent_insert_trig, new table = (AAA,42), (BBB,42), (CCC,42)
29662970
create index on parent(b);
29672971
copy parent (a, b) from stdin;
29682972
NOTICE: trigger = parent_insert_trig, new table = (DDD,42)
2973+
-- check disinherit/reinherit behavior; statement triggers with transition
2974+
-- tables should not prevent a table from becoming an inheritance child again
2975+
alter table child1 no inherit parent;
2976+
alter table child1 inherit parent;
29692977
-- DML affecting parent sees tuples collected from children even if
29702978
-- there is no transition table trigger on the children
29712979
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
@@ -1935,6 +1935,11 @@ BBB42
19351935
CCC42
19361936
\.
19371937

1938+
-- check detach/reattach behavior; statement triggers with transition tables
1939+
-- should not prevent a table from becoming a partition again
1940+
altertable parent detach partition child1;
1941+
altertable parent attach partition child1 forvaluesin ('AAA');
1942+
19381943
-- DML affecting parent sees tuples collected from children even if
19391944
-- there is no transition table trigger on the children
19401945
droptrigger child1_insert_trigon child1;
@@ -2154,6 +2159,11 @@ copy parent (a, b) from stdin;
21542159
DDD42
21552160
\.
21562161

2162+
-- check disinherit/reinherit behavior; statement triggers with transition
2163+
-- tables should not prevent a table from becoming an inheritance child again
2164+
altertable child1 no inherit parent;
2165+
altertable child1 inherit parent;
2166+
21572167
-- DML affecting parent sees tuples collected from children even if
21582168
-- there is no transition table trigger on the children
21592169
droptrigger child1_insert_trigon child1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp