* Setup for running triggers for the given event. Return value is an OID list * of functions to run; if there are any, trigdata is filled with an * appropriate EventTriggerData for them to receive. */
| 553 | * appropriate EventTriggerData for them to receive. |
| 554 | */ |
| 555 | static List * |
| 556 | EventTriggerCommonSetup(Node *parsetree, |
| 557 | EventTriggerEvent event, const char *eventstr, |
| 558 | EventTriggerData *trigdata) |
| 559 | { |
| 560 | CommandTag tag; |
| 561 | List *cachelist; |
| 562 | ListCell *lc; |
| 563 | List *runlist = NIL; |
| 564 | |
| 565 | /* |
| 566 | * We want the list of command tags for which this procedure is actually |
| 567 | * invoked to match up exactly with the list that CREATE EVENT TRIGGER |
| 568 | * accepts. This debugging cross-check will throw an error if this |
| 569 | * function is invoked for a command tag that CREATE EVENT TRIGGER won't |
| 570 | * accept. (Unfortunately, there doesn't seem to be any simple, automated |
| 571 | * way to verify that CREATE EVENT TRIGGER doesn't accept extra stuff that |
| 572 | * never reaches this control point.) |
| 573 | * |
| 574 | * If this cross-check fails for you, you probably need to either adjust |
| 575 | * standard_ProcessUtility() not to invoke event triggers for the command |
| 576 | * type in question, or you need to adjust event_trigger_ok to accept the |
| 577 | * relevant command tag. |
| 578 | */ |
| 579 | #ifdef USE_ASSERT_CHECKING |
| 580 | { |
| 581 | CommandTag dbgtag; |
| 582 | |
| 583 | dbgtag = CreateCommandTag(parsetree); |
| 584 | if (event == EVT_DDLCommandStart || |
| 585 | event == EVT_DDLCommandEnd || |
| 586 | event == EVT_SQLDrop) |
| 587 | { |
| 588 | if (!command_tag_event_trigger_ok(dbgtag)) |
| 589 | elog(ERROR, "unexpected command tag \"%s\"", GetCommandTagName(dbgtag)); |
| 590 | } |
| 591 | else if (event == EVT_TableRewrite) |
| 592 | { |
| 593 | if (!command_tag_table_rewrite_ok(dbgtag)) |
| 594 | elog(ERROR, "unexpected command tag \"%s\"", GetCommandTagName(dbgtag)); |
| 595 | } |
| 596 | } |
| 597 | #endif |
| 598 | |
| 599 | /* Use cache to find triggers for this event; fast exit if none. */ |
| 600 | cachelist = EventCacheLookup(event); |
| 601 | if (cachelist == NIL) |
| 602 | return NIL; |
| 603 | |
| 604 | /* Get the command tag. */ |
| 605 | tag = CreateCommandTag(parsetree); |
| 606 | |
| 607 | /* |
| 608 | * Filter list of event triggers by command tag, and copy them into our |
| 609 | * memory context. Once we start running the command triggers, or indeed |
| 610 | * once we do anything at all that touches the catalogs, an invalidation |
| 611 | * might leave cachelist pointing at garbage, so we must do this before we |
| 612 | * can do much else. |
no test coverage detected