* ExplainOneQuery - * print out the execution plan for one Query * * "into" is NULL unless we are explaining the contents of a CreateTableAsStmt. */
| 504 | * "into" is NULL unless we are explaining the contents of a CreateTableAsStmt. |
| 505 | */ |
| 506 | static void |
| 507 | ExplainOneQuery(Query *query, int cursorOptions, |
| 508 | IntoClause *into, ExplainState *es, |
| 509 | const char *queryString, ParamListInfo params, |
| 510 | QueryEnvironment *queryEnv) |
| 511 | { |
| 512 | #ifdef USE_ORCA |
| 513 | if (es->dxl) |
| 514 | { |
| 515 | ExplainDXL(query, es, queryString, params); |
| 516 | return; |
| 517 | } |
| 518 | #endif |
| 519 | |
| 520 | /* planner will not cope with utility statements */ |
| 521 | if (query->commandType == CMD_UTILITY) |
| 522 | { |
| 523 | ExplainOneUtility(query->utilityStmt, into, es, queryString, params, |
| 524 | queryEnv); |
| 525 | return; |
| 526 | } |
| 527 | |
| 528 | /* if an advisor plugin is present, let it manage things */ |
| 529 | if (ExplainOneQuery_hook) |
| 530 | (*ExplainOneQuery_hook) (query, cursorOptions, into, es, |
| 531 | queryString, params, queryEnv); |
| 532 | else |
| 533 | { |
| 534 | PlannedStmt *plan; |
| 535 | instr_time planstart, |
| 536 | planduration; |
| 537 | BufferUsage bufusage_start, |
| 538 | bufusage; |
| 539 | |
| 540 | if (es->buffers) |
| 541 | bufusage_start = pgBufferUsage; |
| 542 | INSTR_TIME_SET_CURRENT(planstart); |
| 543 | |
| 544 | /* plan the query */ |
| 545 | plan = pg_plan_query(query, queryString, cursorOptions, params); |
| 546 | |
| 547 | INSTR_TIME_SET_CURRENT(planduration); |
| 548 | INSTR_TIME_SUBTRACT(planduration, planstart); |
| 549 | |
| 550 | /* |
| 551 | * GPDB_92_MERGE_FIXME: it really should be an optimizer's responsibility |
| 552 | * to correctly set the into-clause and into-policy of the PlannedStmt. |
| 553 | */ |
| 554 | if (into != NULL) |
| 555 | plan->intoClause = copyObject(into); |
| 556 | |
| 557 | /* calc differences of buffer counters. */ |
| 558 | if (es->buffers) |
| 559 | { |
| 560 | memset(&bufusage, 0, sizeof(BufferUsage)); |
| 561 | BufferUsageAccumDiff(&bufusage, &pgBufferUsage, &bufusage_start); |
| 562 | } |
| 563 |
no test coverage detected