pgsql: Fix convert_IN_to_join to properly handle the case where the

Поиск
Список
Период
Сортировка
От tgl@postgresql.org (Tom Lane)
Тема pgsql: Fix convert_IN_to_join to properly handle the case where the
Дата
Msg-id 20080421205415.6EA8F7559CC@cvs.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Log Message:
-----------
Fix convert_IN_to_join to properly handle the case where the subselect's
output is not of the same type that's needed for the IN comparison (ie,
where the parser inserted an implicit coercion above the subselect result).
We should record the coerced expression, not just a raw Var referencing
the subselect output, as the quantity that needs to be unique-ified if
we choose to implement the IN as Unique followed by a plain join.

As of 8.3 this error was causing crashes, as seen in bug #4113 from Javier
Hernandez, because the executor was being told to hash or sort the raw
subselect output column using operators appropriate to the coerced type.

In prior versions there was no crash because the executor chose the
hash or sort operators for itself based on the column type it saw.
However, that's still not really right, because what's unique for one data
type might not be unique for another.  In corner cases we could get multiple
outputs of a row that should appear only once, as demonstrated by the
regression test case included in this commit.

However, this patch doesn't apply cleanly to 8.2 or before, and the code
involved has shifted enough over time that I'm hesitant to try to back-patch.
Given the lack of complaints from the field about such corner cases, I think
the bug may not be important enough to risk breaking other things with a
back-patch.

Modified Files:
--------------
    pgsql/src/backend/optimizer/plan:
        subselect.c (r1.129 -> r1.130)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/subselect.c?r1=1.129&r2=1.130)
    pgsql/src/backend/optimizer/util:
        pathnode.c (r1.142 -> r1.143)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/util/pathnode.c?r1=1.142&r2=1.143)
    pgsql/src/include/nodes:
        relation.h (r1.155 -> r1.156)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/nodes/relation.h?r1=1.155&r2=1.156)
    pgsql/src/test/regress/expected:
        subselect.out (r1.16 -> r1.17)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/subselect.out?r1=1.16&r2=1.17)
    pgsql/src/test/regress/sql:
        subselect.sql (r1.11 -> r1.12)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/subselect.sql?r1=1.11&r2=1.12)

В списке pgsql-committers по дате отправления:

Предыдущее
От: mha@postgresql.org (Magnus Hagander)
Дата:
Сообщение: pgsql: Clean up float4byval and float8byval handling by dealing with
Следующее
От: tgl@postgresql.org (Tom Lane)
Дата:
Сообщение: pgsql: Fix convert_IN_to_join to properly handle the case where the