MCPcopy Create free account
hub / github.com/apache/cloudberry / AfterTriggerEndSubXact

Function AfterTriggerEndSubXact

src/backend/commands/trigger.c:5097–5199  ·  view source on GitHub ↗

* AfterTriggerEndSubXact() * * The current subtransaction is ending. */

Source from the content-addressed store, hash-verified

5095 * The current subtransaction is ending.
5096 */
5097void
5098AfterTriggerEndSubXact(bool isCommit)
5099{
5100 int my_level = GetCurrentTransactionNestLevel();
5101 SetConstraintState state;
5102 AfterTriggerEvent event;
5103 AfterTriggerEventChunk *chunk;
5104 CommandId subxact_firing_id;
5105 ListCell *lc;
5106
5107 /*
5108 * Pop the prior state if needed.
5109 */
5110 if (isCommit)
5111 {
5112 Assert(my_level < afterTriggers.maxtransdepth);
5113 /* If we saved a prior state, we don't need it anymore */
5114 state = afterTriggers.trans_stack[my_level].state;
5115 if (state != NULL)
5116 pfree(state);
5117 /* this avoids double pfree if error later: */
5118 afterTriggers.trans_stack[my_level].state = NULL;
5119 Assert(afterTriggers.query_depth ==
5120 afterTriggers.trans_stack[my_level].query_depth);
5121 }
5122 else
5123 {
5124 /*
5125 * Aborting. It is possible subxact start failed before calling
5126 * AfterTriggerBeginSubXact, in which case we mustn't risk touching
5127 * trans_stack levels that aren't there.
5128 */
5129 if (my_level >= afterTriggers.maxtransdepth)
5130 return;
5131
5132 /*
5133 * Release query-level storage for queries being aborted, and restore
5134 * query_depth to its pre-subxact value. This assumes that a
5135 * subtransaction will not add events to query levels started in a
5136 * earlier transaction state.
5137 */
5138 while (afterTriggers.query_depth > afterTriggers.trans_stack[my_level].query_depth)
5139 {
5140 if (afterTriggers.query_depth < afterTriggers.maxquerydepth)
5141 AfterTriggerFreeQuery(&afterTriggers.query_stack[afterTriggers.query_depth]);
5142 afterTriggers.query_depth--;
5143 }
5144 Assert(afterTriggers.query_depth ==
5145 afterTriggers.trans_stack[my_level].query_depth);
5146
5147 /*
5148 * Restore the global deferred-event list to its former length,
5149 * discarding any events queued by the subxact.
5150 */
5151 afterTriggerRestoreEventList(&afterTriggers.events,
5152 &afterTriggers.trans_stack[my_level].events);
5153
5154 /*

Callers 2

CommitSubTransactionFunction · 0.85
AbortSubTransactionFunction · 0.85

Calls 7

AfterTriggerFreeQueryFunction · 0.85
tuplestore_get_resownerFunction · 0.85
tuplestore_endFunction · 0.85
pfreeFunction · 0.50
foreachFunction · 0.50

Tested by

no test coverage detected