From 4a9adb9ca30abc3f06ca5e0f69521feb3438919f Mon Sep 17 00:00:00 2001 From: Julien Rouhaud Date: Sat, 21 Jul 2018 00:08:44 +0200 Subject: [PATCH] Fix pg12 compatibility wrt. 7d872c91a3f This commit introduced a new root->append_rel_array that's setup just before we get a change to fill in the necessary data in root->append_rel_list. For now, we call setup_append_rel_array() (and free previously palloc'd memory if needed) for each hypo_injectHypotheticalPartitioning() call, but this is a waste of cycles, we'll need to call it ideally only once per query execution. --- hypopg_table.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hypopg_table.c b/hypopg_table.c index 33667b7..e61e13c 100644 --- a/hypopg_table.c +++ b/hypopg_table.c @@ -2019,6 +2019,21 @@ hypo_injectHypotheticalPartitioning(PlannerInfo *root, rel->pages = (BlockNumber) pages; rel->tuples = clamp_row_est(rel->tuples * selectivity); } + + /* + * This is done in query_planner just before add_base_rels_to_query() is + * called, so before get_relation_info_hook is called and setup + * root->append_rel_list + * + * FIXME find a way to call it once per planning and not one per + * get_relation_info_hook call. + */ + if (root->append_rel_array) + { + pfree(root->append_rel_array); + root->append_rel_array = NULL; + } + setup_append_rel_array(root); }