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

Function AfterTriggerFreeQuery

src/backend/commands/trigger.c:4859–4900  ·  view source on GitHub ↗

* AfterTriggerFreeQuery * Release subsidiary storage for a trigger query level. * This includes closing down tuplestores. * Note: it's important for this to be safe if interrupted by an error * and then called again for the same query level. */

Source from the content-addressed store, hash-verified

4857 * and then called again for the same query level.
4858 */
4859static void
4860AfterTriggerFreeQuery(AfterTriggersQueryData *qs)
4861{
4862 Tuplestorestate *ts;
4863 List *tables;
4864 ListCell *lc;
4865
4866 /* Drop the trigger events */
4867 afterTriggerFreeEventList(&qs->events);
4868
4869 /* Drop FDW tuplestore if any */
4870 ts = qs->fdw_tuplestore;
4871 qs->fdw_tuplestore = NULL;
4872 if (ts)
4873 tuplestore_end(ts);
4874
4875 /* Release per-table subsidiary storage */
4876 tables = qs->tables;
4877 foreach(lc, tables)
4878 {
4879 AfterTriggersTableData *table = (AfterTriggersTableData *) lfirst(lc);
4880
4881 ts = table->old_tuplestore;
4882 table->old_tuplestore = NULL;
4883 if (ts)
4884 release_or_prolong_tuplestore(ts, table->prolonged);
4885 ts = table->new_tuplestore;
4886 table->new_tuplestore = NULL;
4887 if (ts)
4888 release_or_prolong_tuplestore(ts, table->prolonged);
4889 if (table->storeslot)
4890 ExecDropSingleTupleTableSlot(table->storeslot);
4891 }
4892
4893 /*
4894 * Now free the AfterTriggersTableData structs and list cells. Reset list
4895 * pointer first; if list_free_deep somehow gets an error, better to leak
4896 * that storage than have an infinite loop.
4897 */
4898 qs->tables = NIL;
4899 list_free_deep(tables);
4900}
4901
4902/*
4903 * Release the tuplestore, or append it to the prolonged tuplestores list.

Callers 2

AfterTriggerEndQueryFunction · 0.85
AfterTriggerEndSubXactFunction · 0.85

Calls 6

tuplestore_endFunction · 0.85
list_free_deepFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected