mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Fix transition tables for wCTEs.
The original coding didn't handle this case properly; each separate DML substatement needs its own set of transitions. Patch by Thomas Munro Discussion: https://postgr.es/m/CAL9smLCDQ%3D2o024rBgtD4WihzX8B3C6u_oSQ2K3%2BR5grJrV0bg%40mail.gmail.com
This commit is contained in:
@ -419,6 +419,12 @@ ExecSimpleRelationInsert(EState *estate, TupleTableSlot *slot)
|
||||
ExecARInsertTriggers(estate, resultRelInfo, tuple,
|
||||
recheckIndexes, NULL);
|
||||
|
||||
/*
|
||||
* XXX we should in theory pass a TransitionCaptureState object to the
|
||||
* above to capture transition tuples, but after statement triggers
|
||||
* don't actually get fired by replication yet anyway
|
||||
*/
|
||||
|
||||
list_free(recheckIndexes);
|
||||
}
|
||||
}
|
||||
|
@ -1442,14 +1442,18 @@ fireASTriggers(ModifyTableState *node)
|
||||
case CMD_INSERT:
|
||||
if (node->mt_onconflict == ONCONFLICT_UPDATE)
|
||||
ExecASUpdateTriggers(node->ps.state,
|
||||
resultRelInfo);
|
||||
ExecASInsertTriggers(node->ps.state, resultRelInfo);
|
||||
resultRelInfo,
|
||||
node->mt_transition_capture);
|
||||
ExecASInsertTriggers(node->ps.state, resultRelInfo,
|
||||
node->mt_transition_capture);
|
||||
break;
|
||||
case CMD_UPDATE:
|
||||
ExecASUpdateTriggers(node->ps.state, resultRelInfo);
|
||||
ExecASUpdateTriggers(node->ps.state, resultRelInfo,
|
||||
node->mt_transition_capture);
|
||||
break;
|
||||
case CMD_DELETE:
|
||||
ExecASDeleteTriggers(node->ps.state, resultRelInfo);
|
||||
ExecASDeleteTriggers(node->ps.state, resultRelInfo,
|
||||
node->mt_transition_capture);
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "unknown operation");
|
||||
@ -2304,6 +2308,10 @@ ExecEndModifyTable(ModifyTableState *node)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Free transition tables */
|
||||
if (node->mt_transition_capture != NULL)
|
||||
DestroyTransitionCaptureState(node->mt_transition_capture);
|
||||
|
||||
/*
|
||||
* Allow any FDWs to shut down
|
||||
*/
|
||||
|
Reference in New Issue
Block a user