* ProcessUtilityForAlterTable * Recursive entry from ALTER TABLE * * ALTER TABLE sometimes generates subcommands such as CREATE INDEX. * It calls this, not the main entry point ProcessUtility, to execute * such subcommands. * * stmt: the utility command to execute * context: opaque passthrough struct with the info we need * * It's caller's responsibility to do CommandCounterIncrement af
| 2572 | * calling this, if needed. |
| 2573 | */ |
| 2574 | void |
| 2575 | ProcessUtilityForAlterTable(Node *stmt, AlterTableUtilityContext *context) |
| 2576 | { |
| 2577 | PlannedStmt *wrapper; |
| 2578 | |
| 2579 | /* |
| 2580 | * For event triggers, we must "close" the current complex-command set, |
| 2581 | * and start a new one afterwards; this is needed to ensure the ordering |
| 2582 | * of command events is consistent with the way they were executed. |
| 2583 | */ |
| 2584 | EventTriggerAlterTableEnd(); |
| 2585 | |
| 2586 | /* Create a suitable wrapper */ |
| 2587 | wrapper = makeNode(PlannedStmt); |
| 2588 | wrapper->commandType = CMD_UTILITY; |
| 2589 | wrapper->canSetTag = false; |
| 2590 | wrapper->utilityStmt = stmt; |
| 2591 | wrapper->stmt_location = context->pstmt->stmt_location; |
| 2592 | wrapper->stmt_len = context->pstmt->stmt_len; |
| 2593 | |
| 2594 | /* |
| 2595 | * We don't allow to dispatch some subcmds in ALTER TABLE before the QD has |
| 2596 | * finished local execution. It causes the execution order different on QD |
| 2597 | * and QEs, what's more some commands are not executed on QEs, this dispatched |
| 2598 | * sub-commands will probably fail. |
| 2599 | * In the end, the QD will dispatch the parse tree all in one after |
| 2600 | * the QD has finished local execution, but before commit. |
| 2601 | */ |
| 2602 | HOLD_DISPATCH(); |
| 2603 | ProcessUtility(wrapper, |
| 2604 | context->queryString, |
| 2605 | false, |
| 2606 | PROCESS_UTILITY_SUBCOMMAND, |
| 2607 | context->params, |
| 2608 | context->queryEnv, |
| 2609 | None_Receiver, |
| 2610 | NULL); |
| 2611 | RESUME_DISPATCH(); |
| 2612 | |
| 2613 | EventTriggerAlterTableStart(context->pstmt->utilityStmt); |
| 2614 | EventTriggerAlterTableRelid(context->relid); |
| 2615 | } |
| 2616 | |
| 2617 | /* |
| 2618 | * Dispatch function for DropStmt |
no test coverage detected