* exec_mpp_query * * Called in a qExec process to read and execute a query plan sent by CdbDispatchPlan(). * * query_string -- optional query text (C string). * serializedPlantree[len] -- PlannedStmt node, or (NULL,0) if query provided. * serializedQueryDispatchDesc[len] -- QueryDispatchDesc node, or (NULL,0) if query provided. * * Caller may supply either a Query (representing utility com
| 1107 | * a PlannedStmt (representing a planned DML command), but not both. |
| 1108 | */ |
| 1109 | static void |
| 1110 | exec_mpp_query(const char *query_string, |
| 1111 | const char * serializedPlantree, int serializedPlantreelen, |
| 1112 | const char * serializedQueryDispatchDesc, int serializedQueryDispatchDesclen) |
| 1113 | { |
| 1114 | CommandDest dest = whereToSendOutput; |
| 1115 | MemoryContext oldcontext; |
| 1116 | bool save_log_statement_stats = log_statement_stats; |
| 1117 | bool was_logged = false; |
| 1118 | char msec_str[32]; |
| 1119 | PlannedStmt *plan = NULL; |
| 1120 | QueryDispatchDesc *ddesc = NULL; |
| 1121 | CmdType commandType = CMD_UNKNOWN; |
| 1122 | SliceTable *sliceTable = NULL; |
| 1123 | ExecSlice *slice = NULL; |
| 1124 | ParamListInfo paramLI = NULL; |
| 1125 | |
| 1126 | SIMPLE_FAULT_INJECTOR("exec_mpp_query_start"); |
| 1127 | |
| 1128 | Assert(Gp_role == GP_ROLE_EXECUTE); |
| 1129 | /* |
| 1130 | * If we didn't get passed a query string, dummy something up for ps display and pg_stat_activity |
| 1131 | */ |
| 1132 | if (query_string == NULL || strlen(query_string)==0) |
| 1133 | query_string = "mppexec"; |
| 1134 | |
| 1135 | /* |
| 1136 | * Report query to various monitoring facilities. |
| 1137 | */ |
| 1138 | |
| 1139 | debug_query_string = query_string; |
| 1140 | |
| 1141 | pgstat_report_activity(STATE_RUNNING, query_string); |
| 1142 | |
| 1143 | /* |
| 1144 | * We use save_log_statement_stats so ShowUsage doesn't report incorrect |
| 1145 | * results because ResetUsage wasn't called. |
| 1146 | */ |
| 1147 | if (save_log_statement_stats) |
| 1148 | ResetUsage(); |
| 1149 | |
| 1150 | /* |
| 1151 | * Start up a transaction command. All queries generated by the |
| 1152 | * query_string will be in this same command block, *unless* we find a |
| 1153 | * BEGIN/COMMIT/ABORT statement; we have to force a new xact command after |
| 1154 | * one of those, else bad things will happen in xact.c. (Note that this |
| 1155 | * will normally change current memory context.) |
| 1156 | */ |
| 1157 | start_xact_command(); |
| 1158 | |
| 1159 | /* |
| 1160 | * Zap any pre-existing unnamed statement. (While not strictly necessary, |
| 1161 | * it seems best to define simple-Query mode as if it used the unnamed |
| 1162 | * statement and portal; this ensures we recover any storage used by prior |
| 1163 | * unnamed operations.) |
| 1164 | */ |
| 1165 | drop_unnamed_stmt(); |
| 1166 |
no test coverage detected