Skip site navigation (1) Skip section navigation (2)

pgsql: Consider a clause to be outerjoin_delayed if it references the

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Consider a clause to be outerjoin_delayed if it references the
Date: 2008-06-27 20:54:37
Message-ID: 20080627205437.4A40B754857@cvs.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Log Message:
-----------
Consider a clause to be outerjoin_delayed if it references the nullable side
of any lower outer join, even if it also references the non-nullable side and
so could not get pushed below the outer join anyway.  We need this in case
the clause is an OR clause: if it doesn't get marked outerjoin_delayed,
create_or_index_quals() could pull an indexable restriction for the nullable
side out of it, leading to wrong results as demonstrated by today's bug
report from toruvinn.  (See added regression test case for an example.)

In principle this has been wrong for quite a while.  In practice I don't
think any branch before 8.3 can really show the failure, because
create_or_index_quals() will only pull out indexable conditions, and before
8.3 those were always strict.  So though we might have improperly generated
null-extended rows in the outer join, they'd get discarded from the result
anyway.  The gating factor that makes the failure visible is that 8.3
considers "col IS NULL" to be indexable.  Hence I'm not going to risk
back-patching further than 8.3.

Modified Files:
--------------
    pgsql/src/backend/optimizer/plan:
        initsplan.c (r1.139 -> r1.140)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/initsplan.c?r1=1.139&r2=1.140)
    pgsql/src/test/regress/expected:
        join.out (r1.33 -> r1.34)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/join.out?r1=1.33&r2=1.34)
        join_1.out (r1.15 -> r1.16)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/join_1.out?r1=1.15&r2=1.16)
    pgsql/src/test/regress/sql:
        join.sql (r1.24 -> r1.25)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/join.sql?r1=1.24&r2=1.25)

pgsql-committers by date

Next:From: Tom LaneDate: 2008-06-27 20:54:45
Subject: pgsql: Consider a clause to be outerjoin_delayed if it references the
Previous:From: Magnus HaganderDate: 2008-06-27 18:58:16
Subject: pgsql: Fix standalone libpq build on win32.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group