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

pgsql: Repair planner bug introduced in 8.2 by ability to rearrange

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Repair planner bug introduced in 8.2 by ability to rearrange
Date: 2007-05-22 23:23:59
Message-ID: 20070522232359.8A40B9FB22C@postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Log Message:
-----------
Repair planner bug introduced in 8.2 by ability to rearrange outer joins:
in cases where a sub-SELECT inserts a WHERE clause between two outer joins,
that clause may prevent us from re-ordering the two outer joins.  The code
was considering only the joins' own ON-conditions in determining reordering
safety, which is not good enough.  Add a "delay_upper_joins" flag to
OuterJoinInfo to flag that we have detected such a clause and higher-level
outer joins shouldn't be permitted to commute with this one.  (This might
seem overly coarse, but given the current rules for OJ reordering, it's
sufficient AFAICT.)

The failure case is actually pretty narrow: it needs a WHERE clause within
the RHS of a left join that checks the RHS of a lower left join, but is not
strict for that RHS (else we'd have simplified the lower join to a plain
join).  Even then no failure will be manifest unless the planner chooses to
rearrange the join order.

Per bug report from Adam Terrey.

Modified Files:
--------------
    pgsql/src/backend/nodes:
        copyfuncs.c (r1.375 -> r1.376)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/copyfuncs.c.diff?r1=1.375&r2=1.376)
        equalfuncs.c (r1.306 -> r1.307)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/equalfuncs.c.diff?r1=1.306&r2=1.307)
        outfuncs.c (r1.307 -> r1.308)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/outfuncs.c.diff?r1=1.307&r2=1.308)
    pgsql/src/backend/optimizer/plan:
        initsplan.c (r1.131 -> r1.132)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/initsplan.c.diff?r1=1.131&r2=1.132)
    pgsql/src/include/nodes:
        relation.h (r1.142 -> r1.143)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/nodes/relation.h.diff?r1=1.142&r2=1.143)
    pgsql/src/test/regress/expected:
        join.out (r1.29 -> r1.30)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/join.out.diff?r1=1.29&r2=1.30)
        join_1.out (r1.11 -> r1.12)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/join_1.out.diff?r1=1.11&r2=1.12)
    pgsql/src/test/regress/sql:
        join.sql (r1.20 -> r1.21)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/join.sql.diff?r1=1.20&r2=1.21)

pgsql-committers by date

Next:From: Tom LaneDate: 2007-05-22 23:24:09
Subject: pgsql: Repair planner bug introduced in 8.2 by ability to rearrange
Previous:From: Gregory StarkDate: 2007-05-22 20:37:38
Subject: Re: pgsql: Teach tuplestore.c to throw away data before the "mark" point

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