add plannerHook

This commit is contained in:
ganyang
2023-01-03 11:54:40 +08:00
parent ea4f17cc42
commit 255c419497
3 changed files with 9 additions and 2 deletions

View File

@ -1289,8 +1289,12 @@ PlannedStmt* pg_plan_query(Query* querytree, int cursorOptions, ParamListInfo bo
if (!OidIsValid(lc_replan_nodegroup))
check_query_acl(querytree);
/* call the optimizer */
plan = planner(querytree, cursorOptions, boundParams);
if (u_sess->hook_cxt.plannerHook != NULL) {
plan = ((plannerFunc)(u_sess->hook_cxt.plannerHook))(querytree, cursorOptions, boundParams);
} else {
/* call the optimizer */
plan = planner(querytree, cursorOptions, boundParams);
}
PGSTAT_END_TIME_RECORD(PLAN_TIME);

View File

@ -2711,6 +2711,7 @@ typedef struct knl_u_hook_context {
void *standardProcessUtilityHook;
void *aggIsSupportedHook;
void *searchFuncHook;
void *plannerHook;
} knl_u_hook_context;
/* PBE message flag */
typedef enum {

View File

@ -209,4 +209,6 @@ extern bool check_stream_for_loop_fetch(Portal portal);
extern bool IsPlanForPartitionScan(Plan* plan);
extern bool queryIsReadOnly(Query* query);
typedef PlannedStmt* (*plannerFunc)(Query* parse, int cursorOptions, ParamListInfo boundParams);
#endif /* PLANNER_H */