summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAndrew Gierth2017-06-28 18:00:55 +0000
committerAndrew Gierth2017-06-28 18:00:55 +0000
commit8c55244ae379822d8bf62f6db0b5b1f7637eea3a (patch)
tree3f2afebbcbab046dace68bf6d5f8d1e65fab1437 /src/include
parentc46c0e5202e8cfe750c6629db7852fdb15d528f3 (diff)
Fix transition tables for ON CONFLICT.
We now disallow having triggers with both transition tables and ON INSERT OR UPDATE (which was a PG extension to the spec anyway), because in this case it's not at all clear how the transition tables should work for an INSERT ... ON CONFLICT query. Separate ON INSERT and ON UPDATE triggers with transition tables are allowed, and the transition tables for these reflect only the inserted and only the updated tuples respectively. Patch by Thomas Munro Discussion: https://postgr.es/m/CAEepm%3D11KHQ0JmETJQihSvhZB5mUZL2xrqHeXbCeLhDiqQ39%3Dw%40mail.gmail.com
Diffstat (limited to 'src/include')
-rw-r--r--src/include/commands/trigger.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h
index 06199953fe9..36c1134b649 100644
--- a/src/include/commands/trigger.h
+++ b/src/include/commands/trigger.h
@@ -73,9 +73,17 @@ typedef struct TransitionCaptureState
*/
HeapTuple tcs_original_insert_tuple;
- /* The tuplestores backing the transition tables. */
- Tuplestorestate *tcs_old_tuplestore;
- Tuplestorestate *tcs_new_tuplestore;
+ /*
+ * The tuplestores backing the transition tables. We use separate
+ * tuplestores for INSERT and UPDATE, because INSERT ... ON CONFLICT
+ * ... DO UPDATE causes INSERT and UPDATE triggers to fire and needs a way
+ * to keep track of the new tuple images resulting from the two cases
+ * separately. We only need a single old image tuplestore, because there
+ * is no statement that can both update and delete at the same time.
+ */
+ Tuplestorestate *tcs_old_tuplestore; /* for DELETE and UPDATE old images */
+ Tuplestorestate *tcs_insert_tuplestore; /* for INSERT new images */
+ Tuplestorestate *tcs_update_tuplestore; /* for UPDATE new images */
} TransitionCaptureState;
/*