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

Function EventTriggerSQLDrop

src/backend/commands/event_trigger.c:736–801  ·  view source on GitHub ↗

* Fire sql_drop triggers. */

Source from the content-addressed store, hash-verified

734 * Fire sql_drop triggers.
735 */
736void
737EventTriggerSQLDrop(Node *parsetree)
738{
739 List *runlist;
740 EventTriggerData trigdata;
741
742 /*
743 * See EventTriggerDDLCommandStart for a discussion about why event
744 * triggers are disabled in single user mode.
745 */
746 if (!IsUnderPostmaster)
747 return;
748
749 /*
750 * Use current state to determine whether this event fires at all. If
751 * there are no triggers for the sql_drop event, then we don't have
752 * anything to do here. Note that dropped object collection is disabled
753 * if this is the case, so even if we were to try to run, the list would
754 * be empty.
755 */
756 if (!currentEventTriggerState ||
757 slist_is_empty(&currentEventTriggerState->SQLDropList))
758 return;
759
760 runlist = EventTriggerCommonSetup(parsetree,
761 EVT_SQLDrop, "sql_drop",
762 &trigdata);
763
764 /*
765 * Nothing to do if run list is empty. Note this typically can't happen,
766 * because if there are no sql_drop events, then objects-to-drop wouldn't
767 * have been collected in the first place and we would have quit above.
768 * But it could occur if event triggers were dropped partway through.
769 */
770 if (runlist == NIL)
771 return;
772
773 /*
774 * Make sure anything the main command did will be visible to the event
775 * triggers.
776 */
777 CommandCounterIncrement();
778
779 /*
780 * Make sure pg_event_trigger_dropped_objects only works when running
781 * these triggers. Use PG_TRY to ensure in_sql_drop is reset even when
782 * one trigger fails. (This is perhaps not necessary, as the currentState
783 * variable will be removed shortly by our caller, but it seems better to
784 * play safe.)
785 */
786 currentEventTriggerState->in_sql_drop = true;
787
788 /* Run the triggers. */
789 PG_TRY();
790 {
791 EventTriggerInvoke(runlist, &trigdata);
792 }
793 PG_FINALLY();

Callers 1

ProcessUtilitySlowFunction · 0.85

Calls 5

slist_is_emptyFunction · 0.85
EventTriggerCommonSetupFunction · 0.85
CommandCounterIncrementFunction · 0.85
EventTriggerInvokeFunction · 0.85
list_freeFunction · 0.50

Tested by

no test coverage detected