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

Function AfterTriggerSetState

src/backend/commands/trigger.c:5332–5642  ·  view source on GitHub ↗

---------- * AfterTriggerSetState() * * Execute the SET CONSTRAINTS ... utility command. * ---------- */

Source from the content-addressed store, hash-verified

5330 * ----------
5331 */
5332void
5333AfterTriggerSetState(ConstraintsSetStmt *stmt)
5334{
5335 int my_level = GetCurrentTransactionNestLevel();
5336
5337 /* If we haven't already done so, initialize our state. */
5338 if (afterTriggers.state == NULL)
5339 afterTriggers.state = SetConstraintStateCreate(8);
5340
5341 /*
5342 * If in a subtransaction, and we didn't save the current state already,
5343 * save it so it can be restored if the subtransaction aborts.
5344 */
5345 if (my_level > 1 &&
5346 afterTriggers.trans_stack[my_level].state == NULL)
5347 {
5348 afterTriggers.trans_stack[my_level].state =
5349 SetConstraintStateCopy(afterTriggers.state);
5350 }
5351
5352 /*
5353 * Handle SET CONSTRAINTS ALL ...
5354 */
5355 if (stmt->constraints == NIL)
5356 {
5357 /*
5358 * Forget any previous SET CONSTRAINTS commands in this transaction.
5359 */
5360 afterTriggers.state->numstates = 0;
5361
5362 /*
5363 * Set the per-transaction ALL state to known.
5364 */
5365 afterTriggers.state->all_isset = true;
5366 afterTriggers.state->all_isdeferred = stmt->deferred;
5367 }
5368 else
5369 {
5370 Relation conrel;
5371 Relation tgrel;
5372 List *conoidlist = NIL;
5373 List *tgoidlist = NIL;
5374 ListCell *lc;
5375
5376 /*
5377 * Handle SET CONSTRAINTS constraint-name [, ...]
5378 *
5379 * First, identify all the named constraints and make a list of their
5380 * OIDs. Since, unlike the SQL spec, we allow multiple constraints of
5381 * the same name within a schema, the specifications are not
5382 * necessarily unique. Our strategy is to target all matching
5383 * constraints within the first search-path schema that has any
5384 * matches, but disregard matches in schemas beyond the first match.
5385 * (This is a bit odd but it's the historical behavior.)
5386 *
5387 * A constraint in a partitioned table may have corresponding
5388 * constraints in the partitions. Grab those too.
5389 */

Callers 1

standard_ProcessUtilityFunction · 0.85

Calls 15

SetConstraintStateCreateFunction · 0.85
SetConstraintStateCopyFunction · 0.85
table_openFunction · 0.85
get_database_nameFunction · 0.85
LookupExplicitNamespaceFunction · 0.85
fetch_search_pathFunction · 0.85
ScanKeyInitFunction · 0.85
CStringGetDatumFunction · 0.85
ObjectIdGetDatumFunction · 0.85
systable_beginscanFunction · 0.85
systable_getnextFunction · 0.85

Tested by

no test coverage detected