Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8bf4c44

Browse files
Daniil Anisimovdanolivo
Daniil Anisimov
authored andcommitted
Fix. Conventionally use of hooks.
Also, some arrangement for stable14 added by a.lepikhov
1 parent 8e346c5 commit 8bf4c44

File tree

6 files changed

+17
-61
lines changed

6 files changed

+17
-61
lines changed

aqo.c

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -315,50 +315,11 @@ _PG_init(void)
315315
NULL,
316316
NULL);
317317

318-
<<<<<<< HEAD
319-
prev_shmem_startup_hook = shmem_startup_hook;
320-
shmem_startup_hook = aqo_init_shmem;
321-
prev_planner_hook = planner_hook;
322-
planner_hook = aqo_planner;
323-
prev_ExecutorStart_hook = ExecutorStart_hook;
324-
ExecutorStart_hook = aqo_ExecutorStart;
325-
prev_ExecutorRun = ExecutorRun_hook;
326-
ExecutorRun_hook = aqo_ExecutorRun;
327-
prev_ExecutorEnd_hook = ExecutorEnd_hook;
328-
ExecutorEnd_hook = aqo_ExecutorEnd;
329-
330-
/* Cardinality prediction hooks. */
331-
prev_set_baserel_rows_estimate_hook = set_baserel_rows_estimate_hook;
332-
set_foreign_rows_estimate_hook = aqo_set_baserel_rows_estimate;
333-
set_baserel_rows_estimate_hook = aqo_set_baserel_rows_estimate;
334-
prev_get_parameterized_baserel_size_hook = get_parameterized_baserel_size_hook;
335-
get_parameterized_baserel_size_hook = aqo_get_parameterized_baserel_size;
336-
prev_set_joinrel_size_estimates_hook = set_joinrel_size_estimates_hook;
337-
set_joinrel_size_estimates_hook = aqo_set_joinrel_size_estimates;
338-
prev_get_parameterized_joinrel_size_hook = get_parameterized_joinrel_size_hook;
339-
get_parameterized_joinrel_size_hook = aqo_get_parameterized_joinrel_size;
340-
prev_estimate_num_groups_hook = estimate_num_groups_hook;
341-
estimate_num_groups_hook = aqo_estimate_num_groups_hook;
342-
parampathinfo_postinit_hook = ppi_hook;
343-
344-
prev_create_plan_hook = create_plan_hook;
345-
create_plan_hook = aqo_create_plan_hook;
346-
347-
/* Service hooks. */
348-
prev_ExplainOnePlan_hook = ExplainOnePlan_hook;
349-
ExplainOnePlan_hook = print_into_explain;
350-
prev_ExplainOneNode_hook = ExplainOneNode_hook;
351-
ExplainOneNode_hook = print_node_explain;
352-
353-
prev_create_upper_paths_hook = create_upper_paths_hook;
354-
create_upper_paths_hook = aqo_store_upper_signature_hook;
355-
=======
356318
aqo_shmem_init();
357319
aqo_preprocessing_init();
358320
aqo_postprocessing_init();
359321
aqo_cardinality_hooks_init();
360322
aqo_path_utils_init();
361-
>>>>>>> daf05a0 (Bugfix. Do away with possible conflict of hooks, declared as 'extern' in)
362323

363324
init_deactivated_queries_storage();
364325

@@ -393,7 +354,6 @@ _PG_init(void)
393354
RegisterAQOPlanNodeMethods();
394355

395356
EmitWarningsOnPlaceholders("aqo");
396-
RequestAddinShmemSpace(aqo_memsize());
397357
}
398358

399359
/*

aqo_shared.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ int fs_max_items = 10000; /* Max number of different feature spaces in ML model
1818
int fss_max_items = 100000; /* Max number of different feature subspaces in ML model */
1919

2020
static shmem_startup_hook_type aqo_shmem_startup_next = NULL;
21-
static shmem_request_hook_type aqo_shmem_request_next = NULL;
2221

2322
static void on_shmem_shutdown(int code, Datum arg);
2423

@@ -29,7 +28,7 @@ aqo_init_shmem(void)
2928
HASHCTL info;
3029

3130
if (aqo_shmem_startup_next)
32-
aqo_shmem_startup_next();
31+
(*aqo_shmem_startup_next)();
3332

3433
aqo_state = NULL;
3534
stat_htab = NULL;
@@ -128,9 +127,6 @@ aqo_shmem_request(void)
128127
{
129128
Size size;
130129

131-
if (aqo_shmem_request_next)
132-
aqo_shmem_request_next();
133-
134130
size = MAXALIGN(sizeof(AQOSharedState));
135131
size = add_size(size, hash_estimate_size(fs_max_items, sizeof(AQOSharedState)));
136132
size = add_size(size, hash_estimate_size(fs_max_items, sizeof(StatEntry)));
@@ -146,6 +142,6 @@ aqo_shmem_init(void)
146142
{
147143
aqo_shmem_startup_next = shmem_startup_hook;
148144
shmem_startup_hook = aqo_init_shmem;
149-
aqo_shmem_request_next = shmem_request_hook;
150-
shmem_request_hook = aqo_shmem_request;
145+
146+
aqo_shmem_request();
151147
}

cardinality_hooks.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ aqo_set_baserel_rows_estimate(PlannerInfo *root, RelOptInfo *rel)
115115

116116
default_estimator:
117117
rel->predicted_cardinality = -1.;
118-
aqo_set_baserel_rows_estimate_next(root, rel);
118+
(*aqo_set_baserel_rows_estimate_next)(root, rel);
119119
}
120120

121121
static void
@@ -226,7 +226,7 @@ aqo_get_parameterized_baserel_size(PlannerInfo *root,
226226
return predicted;
227227

228228
default_estimator:
229-
return aqo_get_parameterized_baserel_size_next(root, rel, param_clauses);
229+
return (*aqo_get_parameterized_baserel_size_next)(root, rel, param_clauses);
230230
}
231231

232232
/*
@@ -301,7 +301,7 @@ aqo_set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
301301

302302
default_estimator:
303303
rel->predicted_cardinality = -1;
304-
aqo_set_joinrel_size_estimates_next(root, rel, outer_rel, inner_rel,
304+
(*aqo_set_joinrel_size_estimates_next)(root, rel, outer_rel, inner_rel,
305305
sjinfo, restrictlist);
306306
}
307307

@@ -374,7 +374,7 @@ aqo_get_parameterized_joinrel_size(PlannerInfo *root,
374374
return predicted;
375375

376376
default_estimator:
377-
return aqo_get_parameterized_joinrel_size_next(root, rel,
377+
return (*aqo_get_parameterized_joinrel_size_next)(root, rel,
378378
outer_path, inner_path,
379379
sjinfo, clauses);
380380
}
@@ -463,7 +463,7 @@ aqo_estimate_num_groups(PlannerInfo *root, List *groupExprs,
463463

464464
default_estimator:
465465
if (aqo_estimate_num_groups_next)
466-
return aqo_estimate_num_groups_next(root, groupExprs, subpath,
466+
return (*aqo_estimate_num_groups_next)(root, groupExprs, subpath,
467467
grouped_rel, pgset, estinfo);
468468
else
469469
return estimate_num_groups(root, groupExprs, subpath->rows,

path_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ aqo_create_plan(PlannerInfo *root, Path *src, Plan **dest)
525525
AQOPlanNode *node;
526526

527527
if (aqo_create_plan_next)
528-
aqo_create_plan_next(root, src, dest);
528+
(*aqo_create_plan_next)(root, src, dest);
529529

530530
if (!query_context.use_aqo && !query_context.learn_aqo &&
531531
!query_context.collect_stat)

postprocessing.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ aqo_ExecutorStart(QueryDesc *queryDesc, int eflags)
600600
StoreToQueryEnv(queryDesc);
601601
}
602602

603-
aqo_ExecutorStart_next(queryDesc, eflags);
603+
(*aqo_ExecutorStart_next)(queryDesc, eflags);
604604

605605
if (use_aqo)
606606
StorePlanInternals(queryDesc);
@@ -725,7 +725,7 @@ aqo_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count,
725725

726726
PG_TRY();
727727
{
728-
aqo_ExecutorRun_next(queryDesc, direction, count, execute_once);
728+
(*aqo_ExecutorRun_next)(queryDesc, direction, count, execute_once);
729729
}
730730
PG_FINALLY();
731731
{
@@ -841,7 +841,7 @@ aqo_ExecutorEnd(QueryDesc *queryDesc)
841841
MemoryContextSwitchTo(oldctx);
842842
MemoryContextReset(AQOLearnMemCtx);
843843

844-
aqo_ExecutorEnd_next(queryDesc);
844+
(*aqo_ExecutorEnd_next)(queryDesc);
845845

846846
/*
847847
* standard_ExecutorEnd clears the queryDesc->planstate. After this point no
@@ -982,7 +982,7 @@ print_into_explain(PlannedStmt *plannedstmt, IntoClause *into,
982982
QueryEnvironment *queryEnv)
983983
{
984984
if (aqo_ExplainOnePlan_next)
985-
aqo_ExplainOnePlan_next(plannedstmt, into, es, queryString,
985+
(*aqo_ExplainOnePlan_next)(plannedstmt, into, es, queryString,
986986
params, planduration, queryEnv);
987987

988988
if (IsQueryDisabled() || !aqo_show_details)
@@ -1038,7 +1038,7 @@ print_node_explain(ExplainState *es, PlanState *ps, Plan *plan)
10381038

10391039
/* Extension, which took a hook early can be executed early too. */
10401040
if (aqo_ExplainOneNode_next)
1041-
aqo_ExplainOneNode_next(es, ps, plan);
1041+
(*aqo_ExplainOneNode_next)(es, ps, plan);
10421042

10431043
if (IsQueryDisabled() || !plan || es->format != EXPLAIN_FORMAT_TEXT)
10441044
return;

preprocessing.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ aqo_planner(Query *parse, const char *query_string, int cursorOptions,
125125
*/
126126
disable_aqo_for_query();
127127

128-
return aqo_planner_next(parse, query_string, cursorOptions, boundParams);
128+
return (*aqo_planner_next)(parse, query_string, cursorOptions, boundParams);
129129
}
130130

131131
selectivity_cache_clear();
@@ -151,7 +151,7 @@ aqo_planner(Query *parse, const char *query_string, int cursorOptions,
151151
*/
152152
disable_aqo_for_query();
153153

154-
return aqo_planner_next(parse, query_string, cursorOptions, boundParams);
154+
return (*aqo_planner_next)(parse, query_string, cursorOptions, boundParams);
155155
}
156156

157157
elog(DEBUG1, "AQO will be used for query '%s', class "UINT64_FORMAT,
@@ -319,7 +319,7 @@ aqo_planner(Query *parse, const char *query_string, int cursorOptions,
319319
{
320320
PlannedStmt *stmt;
321321

322-
stmt = aqo_planner_next(parse, query_string, cursorOptions, boundParams);
322+
stmt = (*aqo_planner_next)(parse, query_string, cursorOptions, boundParams);
323323

324324
/* Release the memory, allocated for AQO predictions */
325325
MemoryContextReset(AQOPredictMemCtx);

0 commit comments

Comments
 (0)