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

Function afterTriggerCheckState

src/backend/commands/trigger.c:3708–3744  ·  view source on GitHub ↗

---------- * afterTriggerCheckState() * * Returns true if the trigger event is actually in state DEFERRED. * ---------- */

Source from the content-addressed store, hash-verified

3706 * ----------
3707 */
3708static bool
3709afterTriggerCheckState(AfterTriggerShared evtshared)
3710{
3711 Oid tgoid = evtshared->ats_tgoid;
3712 SetConstraintState state = afterTriggers.state;
3713 int i;
3714
3715 /*
3716 * For not-deferrable triggers (i.e. normal AFTER ROW triggers and
3717 * constraints declared NOT DEFERRABLE), the state is always false.
3718 */
3719 if ((evtshared->ats_event & AFTER_TRIGGER_DEFERRABLE) == 0)
3720 return false;
3721
3722 /*
3723 * If constraint state exists, SET CONSTRAINTS might have been executed
3724 * either for this trigger or for all triggers.
3725 */
3726 if (state != NULL)
3727 {
3728 /* Check for SET CONSTRAINTS for this specific trigger. */
3729 for (i = 0; i < state->numstates; i++)
3730 {
3731 if (state->trigstates[i].sct_tgoid == tgoid)
3732 return state->trigstates[i].sct_tgisdeferred;
3733 }
3734
3735 /* Check for SET CONSTRAINTS ALL. */
3736 if (state->all_isset)
3737 return state->all_isdeferred;
3738 }
3739
3740 /*
3741 * Otherwise return the default state for the trigger.
3742 */
3743 return ((evtshared->ats_event & AFTER_TRIGGER_INITDEFERRED) != 0);
3744}
3745
3746
3747/* ----------

Callers 1

afterTriggerMarkEventsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected