* exec_simple_query * * Execute a "simple Query" protocol message. */
| 1649 | * Execute a "simple Query" protocol message. |
| 1650 | */ |
| 1651 | void |
| 1652 | exec_simple_query(const char *query_string) |
| 1653 | { |
| 1654 | CommandDest dest = whereToSendOutput; |
| 1655 | MemoryContext oldcontext; |
| 1656 | List *parsetree_list; |
| 1657 | ListCell *parsetree_item; |
| 1658 | bool save_log_statement_stats = log_statement_stats; |
| 1659 | bool was_logged = false; |
| 1660 | bool use_implicit_block; |
| 1661 | char msec_str[32]; |
| 1662 | |
| 1663 | SIMPLE_FAULT_INJECTOR("exec_simple_query_start"); |
| 1664 | |
| 1665 | if (Gp_role != GP_ROLE_EXECUTE) |
| 1666 | increment_command_count(); |
| 1667 | |
| 1668 | /* |
| 1669 | * Report query to various monitoring facilities. |
| 1670 | */ |
| 1671 | debug_query_string = query_string; |
| 1672 | |
| 1673 | pgstat_report_activity(STATE_RUNNING, query_string); |
| 1674 | |
| 1675 | TRACE_POSTGRESQL_QUERY_START(query_string); |
| 1676 | |
| 1677 | /* |
| 1678 | * We use save_log_statement_stats so ShowUsage doesn't report incorrect |
| 1679 | * results because ResetUsage wasn't called. |
| 1680 | */ |
| 1681 | if (save_log_statement_stats) |
| 1682 | ResetUsage(); |
| 1683 | |
| 1684 | /* |
| 1685 | * Start up a transaction command. All queries generated by the |
| 1686 | * query_string will be in this same command block, *unless* we find a |
| 1687 | * BEGIN/COMMIT/ABORT statement; we have to force a new xact command after |
| 1688 | * one of those, else bad things will happen in xact.c. (Note that this |
| 1689 | * will normally change current memory context.) |
| 1690 | */ |
| 1691 | start_xact_command(); |
| 1692 | |
| 1693 | /* |
| 1694 | * Zap any pre-existing unnamed statement. (While not strictly necessary, |
| 1695 | * it seems best to define simple-Query mode as if it used the unnamed |
| 1696 | * statement and portal; this ensures we recover any storage used by prior |
| 1697 | * unnamed operations.) |
| 1698 | */ |
| 1699 | drop_unnamed_stmt(); |
| 1700 | |
| 1701 | /* |
| 1702 | * Switch to appropriate context for constructing parsetrees. |
| 1703 | */ |
| 1704 | oldcontext = MemoryContextSwitchTo(MessageContext); |
| 1705 | |
| 1706 | /* |
| 1707 | * Do basic parsing of the query or queries (this should be safe even if |
| 1708 | * we are in aborted transaction state!) |
no test coverage detected