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

Commit1add0b1

Browse files
committed
Fix COPY's handling of transition tables with indexes.
Commitc46c0e5 failed to pass theTransitionCaptureState object to ExecARInsertTriggers() in the casewhere it's using heap_multi_insert and there are indexes. Repair.Thomas Munro, from a report by David FetterDiscussion:https://postgr.es/m/20170708084213.GA14720%40fetter.org
1 parent7b02ba6 commit1add0b1

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

‎src/backend/commands/copy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2915,7 +2915,7 @@ CopyFromInsertBatch(CopyState cstate, EState *estate, CommandId mycid,
29152915
estate, false,NULL,NIL);
29162916
ExecARInsertTriggers(estate,resultRelInfo,
29172917
bufferedTuples[i],
2918-
recheckIndexes,NULL);
2918+
recheckIndexes,cstate->transition_capture);
29192919
list_free(recheckIndexes);
29202920
}
29212921
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2156,6 +2156,11 @@ NOTICE: trigger = child3_delete_trig, old table = (CCC,42,foo)
21562156
-- are really inserted into the parent)
21572157
copy parent (a, b) from stdin;
21582158
NOTICE: trigger = parent_insert_trig, new table = (AAA,42), (BBB,42), (CCC,42)
2159+
-- same behavior for copy if there is an index (interesting because rows are
2160+
-- captured by a different code path in copy.c if there are indexes)
2161+
create index on parent(b);
2162+
copy parent (a, b) from stdin;
2163+
NOTICE: trigger = parent_insert_trig, new table = (DDD,42)
21592164
-- DML affecting parent sees tuples collected from children even if
21602165
-- there is no transition table trigger on the children
21612166
drop trigger child1_insert_trig on child1;
@@ -2168,7 +2173,7 @@ drop trigger child3_insert_trig on child3;
21682173
drop trigger child3_update_trig on child3;
21692174
drop trigger child3_delete_trig on child3;
21702175
delete from parent;
2171-
NOTICE: trigger = parent_delete_trig, old table = (AAA,42), (BBB,42), (CCC,42)
2176+
NOTICE: trigger = parent_delete_trig, old table = (AAA,42), (BBB,42), (CCC,42), (DDD,42)
21722177
drop table child1, child2, child3, parent;
21732178
--
21742179
-- Verify prohibition of row triggers with transition triggers on

‎src/test/regress/sql/triggers.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,13 @@ BBB42
16611661
CCC42
16621662
\.
16631663

1664+
-- same behavior for copy if there is an index (interesting because rows are
1665+
-- captured by a different code path in copy.c if there are indexes)
1666+
createindexon parent(b);
1667+
copy parent (a, b)from stdin;
1668+
DDD42
1669+
\.
1670+
16641671
-- DML affecting parent sees tuples collected from children even if
16651672
-- there is no transition table trigger on the children
16661673
droptrigger child1_insert_trigon child1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp