postgresql/src
Tom Lane da88191945 Fix incorrect matching of subexpressions in outer-join plan nodes.
Previously we would re-use input subexpressions in all expression trees
attached to a Join plan node.  However, if it's an outer join and the
subexpression appears in the nullable-side input, this is potentially
incorrect for apparently-matching subexpressions that came from above
the outer join (ie, targetlist and qpqual expressions), because the
executor will treat the subexpression value as NULL when maybe it should
not be.

The case is fairly hard to hit because (a) you need a non-strict
subexpression (else NULL is correct), and (b) we don't usually compute
expressions in the outputs of non-toplevel plan nodes.  But we might do
so if the expressions are sort keys for a mergejoin, for example.

Probably in the long run we should make a more explicit distinction between
Vars appearing above and below an outer join, but that will be a major
planner redesign and not at all back-patchable.  For the moment, just hack
set_join_references so that it will not match any non-Var expressions
coming from nullable inputs to expressions that came from above the join.
(This is somewhat overkill, in that a strict expression could still be
matched, but it doesn't seem worth the effort to check that.)

Per report from Qingqing Zhou.  The added regression test case is based
on his example.

This has been broken for a very long time, so back-patch to all active
branches.
2015-04-04 19:55:15 -04:00
..
backend Fix incorrect matching of subexpressions in outer-join plan nodes. 2015-04-04 19:55:15 -04:00
bin psql: fix \connect with URIs and conninfo strings 2015-04-01 20:00:07 -03:00
include Remove code to match IPv4 pg_hba.conf entries to IPv4-in-IPv6 addresses. 2015-02-17 12:49:18 -05:00
interfaces Fix documentation for libpq's PQfn(). 2015-03-08 13:35:53 -04:00
makefiles Don't use deprecated dllwrap on Cygwin. 2014-02-01 16:14:15 -05:00
pl Free SQLSTATE and SQLERRM no earlier than other PL/pgSQL variables. 2015-02-25 23:49:45 -05:00
port Unlink static libraries before rebuilding them. 2015-03-01 13:08:48 -05:00
template Don't try to force use of -no-cpp-precomp on OS X. It's been five years 2010-08-02 04:51:25 +00:00
test Fix incorrect matching of subexpressions in outer-join plan nodes. 2015-04-04 19:55:15 -04:00
timezone Update time zone data files to tzdata release 2015a. 2015-01-30 22:46:22 -05:00
tools Have config_sspi_auth() permit IPv6 localhost connections. 2014-12-25 14:10:21 -05:00
tutorial Remove tabs after spaces in C comments 2014-05-06 11:26:25 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:06 +02:00
bcc32.mak Remove old-style win32 client-only visual c++ build infrastructure for everything except 2007-03-05 14:18:38 +00:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Rethink the way walreceiver is linked into the backend. Instead than shoving 2010-01-20 09:16:24 +00:00
Makefile.global.in Add mode where contrib installcheck runs each module in a separately named database. 2012-12-11 11:48:00 -05:00
Makefile.shlib Unlink static libraries before rebuilding them. 2015-03-01 13:08:48 -05:00
nls-global.mk Avoid error from mkdir if no languages are to be installed 2010-05-13 14:35:28 +00:00
win32.mak Update supported standalone VC++ version to 7.1+ only, and fix 2007-08-03 10:47:11 +00:00