postgresql/src/include
Tom Lane afdc7515fd Fix planning of non-strict equivalence clauses above outer joins.
If a potential equivalence clause references a variable from the nullable
side of an outer join, the planner needs to take care that derived clauses
are not pushed to below the outer join; else they may use the wrong value
for the variable.  (The problem arises only with non-strict clauses, since
if an upper clause can be proven strict then the outer join will get
simplified to a plain join.)  The planner attempted to prevent this type
of error by checking that potential equivalence clauses aren't
outerjoin-delayed as a whole, but actually we have to check each side
separately, since the two sides of the clause will get moved around
separately if it's treated as an equivalence.  Bugs of this type can be
demonstrated as far back as 7.4, even though releases before 8.3 had only
a very ad-hoc notion of equivalence clauses.

In addition, we neglected to account for the possibility that such clauses
might have nonempty nullable_relids even when not outerjoin-delayed; so the
equivalence-class machinery lacked logic to compute correct nullable_relids
values for clauses it constructs.  This oversight was harmless before 9.2
because we were only using RestrictInfo.nullable_relids for OR clauses;
but as of 9.2 it could result in pushing constructed equivalence clauses
to incorrect places.  (This accounts for bug #7604 from Bill MacArthur.)

Fix the first problem by adding a new test check_equivalence_delay() in
distribute_qual_to_rels, and fix the second one by adding code in
equivclass.c and called functions to set correct nullable_relids for
generated clauses.  Although I believe the second part of this is not
currently necessary before 9.2, I chose to back-patch it anyway, partly to
keep the logic similar across branches and partly because it seems possible
we might find other reasons why we need valid values of nullable_relids in
the older branches.

Add regression tests illustrating these problems.  In 9.0 and up, also
add test cases checking that we can push constants through outer joins,
since we've broken that optimization before and I nearly broke it again
with an overly simplistic patch for this problem.
2012-10-18 12:29:06 -04:00
..
access Revert back-branch changes in behavior of age(xid). 2012-05-31 11:12:33 -04:00
bootstrap Introduce Streaming Replication. 2010-01-15 09:19:10 +00:00
catalog Fix permissions on pg_largeobject_metadata.h in 9.0 branch. 2011-09-11 13:17:12 -04:00
commands Prevent CREATE TABLE LIKE/INHERITS from (mis) copying whole-row Vars. 2012-06-30 16:44:09 -04:00
executor Fix PlanRowMark/ExecRowMark structures to handle inheritance correctly. 2011-01-12 20:47:09 -05:00
foreign Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
lib Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
libpq Remove arbitrary limitation on length of common name in SSL certificates. 2012-02-23 15:48:14 -05:00
mb Back-patch addition of pg_wchar-to-multibyte conversion functionality. 2012-07-10 16:52:47 -04:00
nodes Fix planning of non-strict equivalence clauses above outer joins. 2012-10-18 12:29:06 -04:00
optimizer Fix planning of non-strict equivalence clauses above outer joins. 2012-10-18 12:29:06 -04:00
parser Make OFF keyword unreserved. It's not hard to imagine wanting to use 'off' 2010-10-22 17:44:36 +03:00
port Backport changes to allow building with MinGW 64 bit compiler. 2011-04-09 17:59:27 -04:00
portability Support inlining various small performance-critical functions on non-GCC 2010-02-13 02:34:16 +00:00
postmaster pgindent run for 9.0 2010-02-26 02:01:40 +00:00
regex Back-patch fix for extraction of fixed prefixes from regular expressions. 2012-07-10 18:00:47 -04:00
replication Remove prototype for non-existent function from walreceiver.h. Tidy up by 2010-09-13 10:14:30 +00:00
rewrite Prevent CREATE TABLE LIKE/INHERITS from (mis) copying whole-row Vars. 2012-06-30 16:44:09 -04:00
snowball Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
storage Improve coding around the fsync request queue. 2012-07-17 16:55:56 -04:00
tcop pgindent run for 9.0 2010-02-26 02:01:40 +00:00
tsearch Update a number of broken links in comments. 2010-04-02 15:21:20 +00:00
utils Back-patch fix for extraction of fixed prefixes from regular expressions. 2012-07-10 18:00:47 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:06 +02:00
c.h Backport changes to allow building with MinGW 64 bit compiler. 2011-04-09 17:59:27 -04:00
fmgr.h Mark PG_MODULE_MAGIC and PG_FUNCTION_INFO_V1 with PGDLLEXPORT 2010-05-27 07:59:48 +00:00
funcapi.h pgindent run for 9.0 2010-02-26 02:01:40 +00:00
getaddrinfo.h Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
getopt_long.h Remove optreset from src/port/ implementations of getopt and getopt_long. 2010-12-16 16:22:12 -05:00
Makefile Fix server header file installation with vpath builds 2011-11-10 20:55:39 +02:00
miscadmin.h Do stack-depth checking in all postmaster children. 2012-04-08 19:09:12 +03:00
pg_config.h.in Use __sync_lock_test_and_set() for spinlocks on ARM, if available. 2012-01-07 15:39:05 -05:00
pg_config.h.win32 Stamp 9.0.10. 2012-09-19 17:53:08 -04:00
pg_config_manual.h Remove all the special-case code for INT64_IS_BUSTED, per decision that 2010-01-07 04:53:35 +00:00
pg_trace.h Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
pgstat.h Fix VACUUM so that it always updates pg_class.reltuples/relpages. 2011-05-30 17:07:07 -04:00
pgtime.h Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
port.h Move the line to undefine setlocale() macro on Win32 outside USE_REPL_SNPRINTF 2011-09-01 09:18:27 +03:00
postgres.h Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
postgres_ext.h Move NAMEDATALEN definition from postgres_ext.h to pg_config_manual.h. It 2007-02-06 09:16:08 +00:00
postgres_fe.h Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
rusagestub.h Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
windowapi.h Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00