Thread: pgsql: Fix bug introduced into mergejoin logic by performance

pgsql: Fix bug introduced into mergejoin logic by performance

From
tgl@postgresql.org (Tom Lane)
Date:
Log Message:
-----------
Fix bug introduced into mergejoin logic by performance improvement patch of
2005-05-13.  When we find that a new inner tuple can't possibly match any
outer tuple (because it contains a NULL), we can't immediately skip the
tuple when we are in NEXTINNER state.  Doing so can lead to emitting
multiple copies of the tuple in FillInner mode, because we may rescan the
tuple after returning to a previous marked tuple.  Instead, proceed to
NEXTOUTER state the same as we used to do.  After we've found that there's
no need to return to the marked position, we can go to SKIPINNER_ADVANCE
state instead of SKIP_TEST when the inner tuple is unmatchable; this
preserves the performance improvement.  Per bug report from Bruce.
I also made a couple of cosmetic code rearrangements and added a regression
test for the problem.

Tags:
----
REL8_1_STABLE

Modified Files:
--------------
    pgsql/src/backend/executor:
        nodeMergejoin.c (r1.75.2.1 -> r1.75.2.2)

(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeMergejoin.c.diff?r1=1.75.2.1&r2=1.75.2.2)
    pgsql/src/test/regress/expected:
        join.out (r1.25 -> r1.25.2.1)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/join.out.diff?r1=1.25&r2=1.25.2.1)
        join_1.out (r1.6 -> r1.6.2.1)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/join_1.out.diff?r1=1.6&r2=1.6.2.1)
    pgsql/src/test/regress/sql:
        join.sql (r1.17 -> r1.17.2.1)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/join.sql.diff?r1=1.17&r2=1.17.2.1)