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

Commitbba6a6f

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 parente376422 commitbba6a6f

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
@@ -2748,6 +2748,10 @@ NOTICE: trigger = child3_delete_trig, old table = (42,CCC)
27482748
-- copy into parent sees parent-format tuples
27492749
copy parent (a, b) from stdin;
27502750
NOTICE: trigger = parent_insert_trig, new table = (AAA,42), (BBB,42), (CCC,42)
2751+
-- check detach/reattach behavior; statement triggers with transition tables
2752+
-- should not prevent a table from becoming a partition again
2753+
alter table parent detach partition child1;
2754+
alter table parent attach partition child1 for values in ('AAA');
27512755
-- DML affecting parent sees tuples collected from children even if
27522756
-- there is no transition table trigger on the children
27532757
drop trigger child1_insert_trig on child1;
@@ -2945,6 +2949,10 @@ NOTICE: trigger = parent_insert_trig, new table = (AAA,42), (BBB,42), (CCC,42)
29452949
create index on parent(b);
29462950
copy parent (a, b) from stdin;
29472951
NOTICE: trigger = parent_insert_trig, new table = (DDD,42)
2952+
-- check disinherit/reinherit behavior; statement triggers with transition
2953+
-- tables should not prevent a table from becoming an inheritance child again
2954+
alter table child1 no inherit parent;
2955+
alter table child1 inherit parent;
29482956
-- DML affecting parent sees tuples collected from children even if
29492957
-- there is no transition table trigger on the children
29502958
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
@@ -1922,6 +1922,11 @@ BBB42
19221922
CCC42
19231923
\.
19241924

1925+
-- check detach/reattach behavior; statement triggers with transition tables
1926+
-- should not prevent a table from becoming a partition again
1927+
altertable parent detach partition child1;
1928+
altertable parent attach partition child1 forvaluesin ('AAA');
1929+
19251930
-- DML affecting parent sees tuples collected from children even if
19261931
-- there is no transition table trigger on the children
19271932
droptrigger child1_insert_trigon child1;
@@ -2141,6 +2146,11 @@ copy parent (a, b) from stdin;
21412146
DDD42
21422147
\.
21432148

2149+
-- check disinherit/reinherit behavior; statement triggers with transition
2150+
-- tables should not prevent a table from becoming an inheritance child again
2151+
altertable child1 no inherit parent;
2152+
altertable child1 inherit parent;
2153+
21442154
-- DML affecting parent sees tuples collected from children even if
21452155
-- there is no transition table trigger on the children
21462156
droptrigger child1_insert_trigon child1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp