postgresql/src
Tom Lane a11b3bd37f Fix misprocessing of equivalence classes involving record_eq().
canonicalize_ec_expression() is supposed to agree with coerce_type() as to
whether a RelabelType should be inserted to make a subexpression be valid
input for the operators of a given opclass.  However, it did the wrong
thing with named-composite-type inputs to record_eq(): it put in a
RelabelType to RECORDOID, which the parser doesn't.  In some cases this was
harmless because all code paths involving a particular equivalence class
did the same thing, but in other cases this would result in failing to
recognize a composite-type expression as being a member of an equivalence
class that it actually is a member of.  The most obvious bad effect was to
fail to recognize that an index on a composite column could provide the
sort order needed for a mergejoin on that column, as reported by Teodor
Sigaev.  I think there might be other, subtler, cases that result in
misoptimization.  It also seems possible that an unwanted RelabelType
would sometimes get into an emitted plan --- but because record_eq and
friends don't examine the declared type of their input expressions, that
would not create any visible problems.

To fix, just treat RECORDOID as if it were a polymorphic type, which in
some sense it is.  We might want to consider formalizing that a bit more
someday, but for the moment this seems to be the only place where an
IsPolymorphicType() test ought to include RECORDOID as well.

This has been broken for a long time, so back-patch to all supported
branches.

Discussion: https://postgr.es/m/a6b22369-e3bf-4d49-f59d-0c41d3551e81@sigaev.ru
2018-05-16 13:46:23 -04:00
..
backend Fix misprocessing of equivalence classes involving record_eq(). 2018-05-16 13:46:23 -04:00
bin psql: have \d show FKs on partitioned tables 2018-05-14 12:14:17 -04:00
common
fe_utils Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
include Make gen_partprune_steps static 2018-05-09 10:40:25 -03:00
interfaces Further -Wimplicit-fallthrough cleanup. 2018-05-01 19:53:48 -07:00
makefiles Remove Windows module-list-dumping code. 2018-04-30 13:20:13 -04:00
pl Clean up some perlcritic warnings 2018-05-07 15:35:32 -04:00
port Fix file paths in comments 2018-05-14 18:59:43 +02:00
template
test Fix misprocessing of equivalence classes involving record_eq(). 2018-05-16 13:46:23 -04:00
timezone Update time zone data files to tzdata release 2018e. 2018-05-09 13:56:22 -04:00
tools Restrict vertical tightness to parentheses in Perl code 2018-05-09 10:14:46 -04:00
tutorial
.gitignore
DEVELOPERS
Makefile
Makefile.global.in Un-break contrib install with llvm. 2018-04-28 14:45:39 -04:00
Makefile.shlib
nls-global.mk