aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Gierth <rhodiumtoad@postgresql.org>2017-07-10 11:40:08 +0100
committerAndrew Gierth <rhodiumtoad@postgresql.org>2017-07-10 11:40:08 +0100
commit1add0b15f117769f619af12720bea2f73d4f7359 (patch)
tree10a07b55e36dec83a5a8070958dede905e27ab2c /src
parent7b02ba62e9ffad5b14c24756a0c2aeae839c9d05 (diff)
downloadpostgresql-1add0b15f117769f619af12720bea2f73d4f7359.tar.gz
postgresql-1add0b15f117769f619af12720bea2f73d4f7359.zip
Fix COPY's handling of transition tables with indexes.
Commit c46c0e5202e8cfe750c6629db7852fdb15d528f3 failed to pass the TransitionCaptureState object to ExecARInsertTriggers() in the case where it's using heap_multi_insert and there are indexes. Repair. Thomas Munro, from a report by David Fetter Discussion: https://postgr.es/m/20170708084213.GA14720%40fetter.org
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/copy.c2
-rw-r--r--src/test/regress/expected/triggers.out7
-rw-r--r--src/test/regress/sql/triggers.sql7
3 files changed, 14 insertions, 2 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index f391828e74f..fc5f4f66ead 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -2915,7 +2915,7 @@ CopyFromInsertBatch(CopyState cstate, EState *estate, CommandId mycid,
estate, false, NULL, NIL);
ExecARInsertTriggers(estate, resultRelInfo,
bufferedTuples[i],
- recheckIndexes, NULL);
+ recheckIndexes, cstate->transition_capture);
list_free(recheckIndexes);
}
}
diff --git a/src/test/regress/expected/triggers.out b/src/test/regress/expected/triggers.out
index aaee30219ad..ac132b042d5 100644
--- a/src/test/regress/expected/triggers.out
+++ b/src/test/regress/expected/triggers.out
@@ -2156,6 +2156,11 @@ NOTICE: trigger = child3_delete_trig, old table = (CCC,42,foo)
-- are really inserted into the parent)
copy parent (a, b) from stdin;
NOTICE: trigger = parent_insert_trig, new table = (AAA,42), (BBB,42), (CCC,42)
+-- same behavior for copy if there is an index (interesting because rows are
+-- captured by a different code path in copy.c if there are indexes)
+create index on parent(b);
+copy parent (a, b) from stdin;
+NOTICE: trigger = parent_insert_trig, new table = (DDD,42)
-- DML affecting parent sees tuples collected from children even if
-- there is no transition table trigger on the children
drop trigger child1_insert_trig on child1;
@@ -2168,7 +2173,7 @@ drop trigger child3_insert_trig on child3;
drop trigger child3_update_trig on child3;
drop trigger child3_delete_trig on child3;
delete from parent;
-NOTICE: trigger = parent_delete_trig, old table = (AAA,42), (BBB,42), (CCC,42)
+NOTICE: trigger = parent_delete_trig, old table = (AAA,42), (BBB,42), (CCC,42), (DDD,42)
drop table child1, child2, child3, parent;
--
-- Verify prohibition of row triggers with transition triggers on
diff --git a/src/test/regress/sql/triggers.sql b/src/test/regress/sql/triggers.sql
index 659a5a1422b..b10159a1cf2 100644
--- a/src/test/regress/sql/triggers.sql
+++ b/src/test/regress/sql/triggers.sql
@@ -1661,6 +1661,13 @@ BBB 42
CCC 42
\.
+-- same behavior for copy if there is an index (interesting because rows are
+-- captured by a different code path in copy.c if there are indexes)
+create index on parent(b);
+copy parent (a, b) from stdin;
+DDD 42
+\.
+
-- DML affecting parent sees tuples collected from children even if
-- there is no transition table trigger on the children
drop trigger child1_insert_trig on child1;