diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-02-07 12:59:47 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-02-07 13:11:12 -0500 |
commit | 34ea1ab7fd305afe1124a6e73ada0ebae04b6ebb (patch) | |
tree | 28134be91fb909a218fa661b2bcd3fa6c3e04475 /doc/src | |
parent | 51b025933d442823b076e36f4dbe756d25b1a159 (diff) | |
download | postgresql-34ea1ab7fd305afe1124a6e73ada0ebae04b6ebb.tar.gz postgresql-34ea1ab7fd305afe1124a6e73ada0ebae04b6ebb.zip |
Split create_foreignscan_path() into three functions.
Up to now postgres_fdw has been using create_foreignscan_path() to
generate not only base-relation paths, but also paths for foreign joins
and foreign upperrels. This is wrong, because create_foreignscan_path()
calls get_baserel_parampathinfo() which will only do the right thing for
baserels. It accidentally fails to fail for unparameterized paths, which
are the only ones postgres_fdw (thought it) was handling, but we really
need different APIs for the baserel and join cases.
In HEAD, the best thing to do seems to be to split up the baserel,
joinrel, and upperrel cases into three functions so that they can
have different APIs. I haven't actually given create_foreign_join_path
a different API in this commit: we should spend a bit of time thinking
about just what we want to do there, since perhaps FDWs would want to
do something different from the build-up-a-join-pairwise approach that
get_joinrel_parampathinfo expects. In the meantime, since postgres_fdw
isn't prepared to generate parameterized joins anyway, just give it a
defense against trying to plan joins with lateral refs.
In addition (and this is what triggered this whole mess) fix bug #15613
from Srinivasan S A, by teaching file_fdw and postgres_fdw that plain
baserel foreign paths still have outer refs if the relation has
lateral_relids. Add some assertions in relnode.c to catch future
occurrences of the same error --- in particular, to catch other FDWs
doing that, but also as backstop against core-code mistakes like the
one fixed by commit bdd9a99aa.
Bug #15613 also needs to be fixed in the back branches, but the
appropriate fix will look quite a bit different there, since we don't
want to assume that existing FDWs get the word right away.
Discussion: https://postgr.es/m/15613-092be1be9576c728@postgresql.org
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/fdwhandler.sgml | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/doc/src/sgml/fdwhandler.sgml b/doc/src/sgml/fdwhandler.sgml index 452b776b9e1..77038f53f9a 100644 --- a/doc/src/sgml/fdwhandler.sgml +++ b/doc/src/sgml/fdwhandler.sgml @@ -309,7 +309,9 @@ GetForeignJoinPaths(PlannerInfo *root, function is called during query planning. As with <function>GetForeignPaths</function>, this function should generate <structname>ForeignPath</structname> path(s) for the - supplied <literal>joinrel</literal>, and call <function>add_path</function> to add these + supplied <literal>joinrel</literal> + (use <function>create_foreign_join_path</function> to build them), + and call <function>add_path</function> to add these paths to the set of paths considered for the join. But unlike <function>GetForeignPaths</function>, it is not necessary that this function succeed in creating at least one path, since paths involving local @@ -369,7 +371,9 @@ GetForeignUpperPaths(PlannerInfo *root, called only if all base relation(s) involved in the query belong to the same FDW. This function should generate <structname>ForeignPath</structname> path(s) for any post-scan/join processing that the FDW knows how to - perform remotely, and call <function>add_path</function> to add these paths to + perform remotely + (use <function>create_foreign_upper_path</function> to build them), + and call <function>add_path</function> to add these paths to the indicated upper relation. As with <function>GetForeignJoinPaths</function>, it is not necessary that this function succeed in creating any paths, since paths involving local processing are always possible. |