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

Function pg_plan_query

src/backend/tcop/postgres.c:976–1052  ·  view source on GitHub ↗

* Generate a plan for a single already-rewritten query. * This is a thin wrapper around planner() and takes the same parameters. */

Source from the content-addressed store, hash-verified

974 * This is a thin wrapper around planner() and takes the same parameters.
975 */
976PlannedStmt *
977pg_plan_query(Query *querytree, const char *query_string, int cursorOptions,
978 ParamListInfo boundParams)
979{
980 PlannedStmt *plan;
981
982 /* Utility commands have no plans. */
983 if (querytree->commandType == CMD_UTILITY)
984 return NULL;
985
986 /* Planner must have a snapshot in case it calls user-defined functions. */
987 Assert(ActiveSnapshotSet());
988
989 TRACE_POSTGRESQL_QUERY_PLAN_START();
990
991 if (log_planner_stats)
992 ResetUsage();
993
994 /* call the optimizer */
995 plan = planner(querytree, query_string, cursorOptions, boundParams);
996
997 if (log_planner_stats)
998 ShowUsage("PLANNER STATISTICS");
999
1000#ifdef COPY_PARSE_PLAN_TREES
1001 /* Optional debugging check: pass plan tree through copyObject() */
1002 {
1003 PlannedStmt *new_plan = copyObject(plan);
1004
1005 /*
1006 * equal() currently does not have routines to compare Plan nodes, so
1007 * don't try to test equality here. Perhaps fix someday?
1008 */
1009#ifdef NOT_USED
1010 /* This checks both copyObject() and the equal() routines... */
1011 if (!equal(new_plan, plan))
1012 elog(WARNING, "copyObject() failed to produce an equal plan tree");
1013 else
1014#endif
1015 plan = new_plan;
1016 }
1017#endif
1018
1019#ifdef WRITE_READ_PARSE_PLAN_TREES
1020 /* Optional debugging check: pass plan tree through outfuncs/readfuncs */
1021 {
1022 char *str;
1023 PlannedStmt *new_plan;
1024
1025 str = nodeToString(plan);
1026 new_plan = stringToNodeWithLocations(str);
1027 pfree(str);
1028
1029 /*
1030 * equal() currently does not have routines to compare Plan nodes, so
1031 * don't try to test equality here. Perhaps fix someday?
1032 */
1033#ifdef NOT_USED

Callers 8

pg_plan_queriesFunction · 0.85
BeginCopyFunction · 0.85
PerformCursorOpenFunction · 0.85
refresh_matview_datafillFunction · 0.85
ExecCreateTableAsFunction · 0.85
ExplainOneQueryFunction · 0.85
init_execution_stateFunction · 0.85

Calls 9

ActiveSnapshotSetFunction · 0.85
ResetUsageFunction · 0.85
plannerFunction · 0.85
ShowUsageFunction · 0.85
equalFunction · 0.85
nodeToStringFunction · 0.85
elog_node_displayFunction · 0.85
pfreeFunction · 0.50

Tested by

no test coverage detected