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

Function standard_ExecutorEnd

src/backend/executor/execMain.c:1240–1396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1238}
1239
1240void
1241standard_ExecutorEnd(QueryDesc *queryDesc)
1242{
1243 EState *estate;
1244 MemoryContext oldcontext;
1245
1246 /* GPDB: whether this is a inner query for extension usage */
1247 bool isInnerQuery;
1248
1249 /* sanity checks */
1250 Assert(queryDesc != NULL);
1251
1252 estate = queryDesc->estate;
1253
1254 Assert(estate != NULL);
1255
1256 /* GPDB: Save SPI flag first in case the memory context of plannedstmt is cleaned up*/
1257 isInnerQuery = estate->es_plannedstmt->metricsQueryType > TOP_LEVEL_QUERY;
1258
1259 if (DEBUG1 >= log_min_messages)
1260 {
1261 char msec_str[32];
1262 switch (check_log_duration(msec_str, false))
1263 {
1264 case 1:
1265 case 2:
1266 ereport(LOG, (errmsg("duration to ExecutorEnd starting: %s ms", msec_str)));
1267 break;
1268 }
1269 }
1270
1271 /*
1272 * Check that ExecutorFinish was called, unless in EXPLAIN-only mode. This
1273 * Assert is needed because ExecutorFinish is new as of 9.1, and callers
1274 * might forget to call it.
1275 */
1276 Assert(estate->es_finished ||
1277 (estate->es_top_eflags & EXEC_FLAG_EXPLAIN_ONLY));
1278
1279 /*
1280 * Switch into per-query memory context to run ExecEndPlan
1281 */
1282 oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
1283
1284 /*
1285 * If EXPLAIN ANALYZE, qExec returns stats to qDisp now.
1286 */
1287 if (estate->es_sliceTable &&
1288 estate->es_sliceTable->instrument_options &&
1289 (estate->es_sliceTable->instrument_options & INSTRUMENT_CDB) &&
1290 Gp_role == GP_ROLE_EXECUTE)
1291 cdbexplain_sendExecStats(queryDesc);
1292
1293 /*
1294 * if needed, collect mpp dispatch results and tear down
1295 * all mpp specific resources (e.g. interconnect).
1296 */
1297 PG_TRY();

Callers 4

pgss_ExecutorEndFunction · 0.85
explain_ExecutorEndFunction · 0.85
ExecutorEndFunction · 0.85
pg_hint_ExecutorEndFunction · 0.85

Calls 12

check_log_durationFunction · 0.85
MemoryContextSwitchToFunction · 0.85
cdbexplain_sendExecStatsFunction · 0.85
mppExecutorFinishupFunction · 0.85
mppExecutorCleanupFunction · 0.85
RemoveMotionLayerFunction · 0.85
list_lengthFunction · 0.85
postprocess_initplansFunction · 0.85
FreeExecutorStateFunction · 0.85
ExecEndPlanFunction · 0.85
UnregisterSnapshotFunction · 0.85
errmsgFunction · 0.50

Tested by

no test coverage detected