@@ -477,6 +477,17 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
477477 memset ((void * ) & root -> simple_rte_array [current_len ], 0 ,
478478 irange_len * sizeof (RangeTblEntry * ));
479479
480+ #if PG_VERSION_NUM >= 110000
481+ /* Make sure append_rel_array is wide enough */
482+ if (root -> append_rel_array == NULL )
483+ root -> append_rel_array = (AppendRelInfo * * ) palloc0 (0 );
484+ root -> append_rel_array = (AppendRelInfo * * )
485+ repalloc (root -> append_rel_array ,
486+ new_len * sizeof (AppendRelInfo * ));
487+ memset ((void * ) & root -> append_rel_array [current_len ], 0 ,
488+ irange_len * sizeof (AppendRelInfo * ));
489+ #endif
490+
480491 /* Don't forget to update array size! */
481492 root -> simple_rel_array_size = new_len ;
482493 }
@@ -485,7 +496,7 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
485496 parent_rel = heap_open (rte -> relid , NoLock );
486497
487498 parent_rowmark = get_plan_rowmark (root -> rowMarks , rti );
488-
499+
489500 /* Add parent if asked to */
490501 if (prel -> enable_parent )
491502 append_child_relation (root , parent_rel , parent_rowmark ,
@@ -514,21 +525,12 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
514525 rel -> partial_pathlist = NIL ;
515526#endif
516527
517- /* Convert list to array for faster lookups */
518- #if PG_VERSION_NUM >= 110000
519- setup_append_rel_array (root );
520- #endif
521-
522528 /* Generate new paths using the rels we've just added */
523529 set_append_rel_pathlist (root , rel , rti , pathkeyAsc , pathkeyDesc );
524530 set_append_rel_size_compat (root , rel , rti );
525531
526- /* consider gathering partial paths for the parent appendrel */
527- #if PG_VERSION_NUM >= 110000
528- generate_gather_paths (root , rel , false);
529- #elif PG_VERSION_NUM >= 90600
530- generate_gather_paths (root , rel );
531- #endif
532+ /* consider gathering partial paths for the parent appendrel */
533+ generate_gather_paths_compat (root , rel );
532534
533535 /* Skip if both custom nodes are disabled */
534536 if (!(pg_pathman_enable_runtimeappend ||
0 commit comments