postgresql/contrib/postgres_fdw
Tom Lane 9e7e29c75a Fix planner problems with LATERAL references in PlaceHolderVars.
The planner largely failed to consider the possibility that a
PlaceHolderVar's expression might contain a lateral reference to a Var
coming from somewhere outside the PHV's syntactic scope.  We had a previous
report of a problem in this area, which I tried to fix in a quick-hack way
in commit 4da6439bd8, but Antonin Houska
pointed out that there were still some problems, and investigation turned
up other issues.  This patch largely reverts that commit in favor of a more
thoroughly thought-through solution.  The new theory is that a PHV's
ph_eval_at level cannot be higher than its original syntactic level.  If it
contains lateral references, those don't change the ph_eval_at level, but
rather they create a lateral-reference requirement for the ph_eval_at join
relation.  The code in joinpath.c needs to handle that.

Another issue is that createplan.c wasn't handling nested PlaceHolderVars
properly.

In passing, push knowledge of lateral-reference checks for join clauses
into join_clause_is_movable_to.  This is mainly so that FDWs don't need
to deal with it.

This patch doesn't fix the original join-qual-placement problem reported by
Jeremy Evans (and indeed, one of the new regression test cases shows the
wrong answer because of that).  But the PlaceHolderVar problems need to be
fixed before that issue can be addressed, so committing this separately
seems reasonable.
2013-08-17 20:22:37 -04:00
..
expected Improve updatability checking for views and foreign tables. 2013-06-12 17:53:33 -04:00
sql Improve updatability checking for views and foreign tables. 2013-06-12 17:53:33 -04:00
.gitignore Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
connection.c pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
deparse.c Avoid retrieving dummy NULL columns in postgres_fdw. 2013-03-22 00:31:11 -04:00
Makefile Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
option.c Improve updatability checking for views and foreign tables. 2013-06-12 17:53:33 -04:00
postgres_fdw--1.0.sql Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
postgres_fdw.c Fix planner problems with LATERAL references in PlaceHolderVars. 2013-08-17 20:22:37 -04:00
postgres_fdw.control Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
postgres_fdw.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00