Skip to content

Commit e3941d2

Browse files
committed
Change hook order in aqo_copy_generic_path_info().
+ Add checking the convention: any extension that sets had_path is also responsible for setting path_clauses, path_jointype, path_relids, path_parallel_workers, and was_parameterized.
1 parent 425ac40 commit e3941d2

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

postprocessing.c

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,26 @@ aqo_copy_generic_path_info(PlannerInfo *root, Plan *dest, Path *src)
352352
{
353353
bool is_join_path;
354354

355+
if (prev_copy_generic_path_info_hook)
356+
prev_copy_generic_path_info_hook(root, dest, src);
357+
355358
is_join_path = (src->type == T_NestPath || src->type == T_MergePath ||
356359
src->type == T_HashPath);
357360

358-
dest->had_path = true;
361+
if (dest->had_path)
362+
{
363+
/*
364+
* The convention is that any extension that sets had_path is also
365+
* responsible for setting path_clauses, path_jointype, path_relids,
366+
* path_parallel_workers, and was_parameterized.
367+
*/
368+
Assert(dest->path_clauses && dest->path_jointype &&
369+
dest->path_relids && dest->path_parallel_workers);
370+
return;
371+
}
372+
else
373+
dest->had_path = true;
374+
359375
if (is_join_path)
360376
{
361377
dest->path_clauses = ((JoinPath *) src)->joinrestrictinfo;
@@ -372,9 +388,6 @@ aqo_copy_generic_path_info(PlannerInfo *root, Plan *dest, Path *src)
372388
dest->path_relids = get_list_of_relids(root, src->parent->relids);
373389
dest->path_parallel_workers = src->parallel_workers;
374390
dest->was_parametrized = (src->param_info != NULL);
375-
376-
if (prev_copy_generic_path_info_hook)
377-
prev_copy_generic_path_info_hook(root, dest, src);
378391
}
379392

380393
/*
@@ -460,17 +473,8 @@ learn_query_stat(QueryDesc *queryDesc)
460473
}
461474
selectivity_cache_clear();
462475

463-
if (prev_ExecutorEnd_hook)
464-
prev_ExecutorEnd_hook(queryDesc);
465-
else
466-
standard_ExecutorEnd(queryDesc);
467-
468-
ExtractFromQueryContext(queryDesc);
469-
470476
/*
471477
* Store all learn data into the AQO service relations.
472-
* We postpone this operation to avoid an invalidation recurse induced by
473-
* CommandCounterIncrement.
474478
*/
475479
if ((query_context.collect_stat) && (stat != NULL))
476480
{
@@ -481,6 +485,17 @@ learn_query_stat(QueryDesc *queryDesc)
481485
pfree_query_stat(stat);
482486
}
483487
RemoveFromQueryContext(queryDesc);
488+
489+
if (prev_ExecutorEnd_hook)
490+
prev_ExecutorEnd_hook(queryDesc);
491+
else
492+
standard_ExecutorEnd(queryDesc);
493+
494+
/*
495+
* standard_ExecutorEnd clears the queryDesc->planstate. After this point no
496+
* one operation with the plan can be made.
497+
*/
498+
// ExtractFromQueryContext(queryDesc);
484499
}
485500

486501
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy