]> granicus.if.org Git - postgresql/commit
Call set_rel_pathlist_hook before generate_gather_paths, not after.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 9 Feb 2019 16:41:09 +0000 (11:41 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 9 Feb 2019 16:41:09 +0000 (11:41 -0500)
commit6257f525aff4e711d7eb5405626e7eeac37e2ff5
treebf4f399d6dd2e70d8c5def06caa52ac51361bccc
parentef922faea703aff4996eab17520cb5201a793701
Call set_rel_pathlist_hook before generate_gather_paths, not after.

The previous ordering of these steps satisfied the nominal requirement
that set_rel_pathlist_hook could editorialize on the whole set of Paths
constructed for a base relation.  In practice, though, trying to change
the set of partial paths was impossible.  Adding one didn't work because
(a) it was too late to be included in Gather paths made by the core code,
and (b) calling add_partial_path after generate_gather_paths is unsafe,
because it might try to delete a path it thinks is dominated, but that
is already embedded in some Gather path(s).  Nor could the hook safely
remove partial paths, for the same reason that they might already be
embedded in Gathers.

Better to call extensions first, let them add partial paths as desired,
and then gather.  In v11 and up, we already doubled down on that ordering
by postponing gathering even further for single-relation queries; so even
if the hook wished to editorialize on Gather path construction, it could
not.

Report and patch by KaiGai Kohei.  Back-patch to 9.6 where Gather paths
were added.

Discussion: https://postgr.es/m/CAOP8fzahwpKJRTVVTqo2AE=mDTz_efVzV6Get_0=U3SO+-ha1A@mail.gmail.com
doc/src/sgml/custom-scan.sgml
src/backend/optimizer/path/allpaths.c