git.postgresql.org Git - postgresql.git/commit

git projects / postgresql.git / commit
? search:
summary | shortlog | log | commit | commitdiff | tree
(parent: a31b03b) | patch
Fix convert_IN_to_join to properly handle the case where the subselect's
2008年4月21日 20:54:15 +0000 (20:54 +0000)
2008年4月21日 20:54:15 +0000 (20:54 +0000)
commit ff673f558af1d09d006966f4bd779b1f464a4fc8
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.
src/backend/optimizer/plan/subselect.c diff | blob | blame | history
src/backend/optimizer/util/pathnode.c diff | blob | blame | history
src/include/nodes/relation.h diff | blob | blame | history
src/test/regress/expected/subselect.out diff | blob | blame | history
src/test/regress/sql/subselect.sql diff | blob | blame | history
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /