]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Clean up match_orclause_to_indexcol().
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 17 Nov 2025 18:54:52 +0000 (13:54 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 17 Nov 2025 18:55:26 +0000 (13:55 -0500)
commitbf5b13a8a005b3606ca120b6f3d76120e70eee92
treeb671b63db030ed671d4f16a12a7d63388cca9b0c
parent74561f8f713285ea8a7d1f6a3eba71838ea82675
Clean up match_orclause_to_indexcol().

Remove bogus stripping of RelabelTypes: that can result in building
an output SAOP tree with incorrect exposed exprType for the operands,
which might confuse polymorphic operators.  Moreover it demonstrably
prevents folding some OR-trees to SAOPs when the RHS expressions
have different base types that were coerced to the same type by
RelabelTypes.

Reduce prohibition on type_is_rowtype to just disallow type RECORD.
We need that because otherwise we would happily fold multiple RECORD
Consts into a RECORDARRAY Const even if they aren't the same record
type.  (We could allow that perhaps, if we checked that they all have
the same typmod, but the case doesn't seem worth that much effort.)
However, there is no reason at all to disallow the transformation
for named composite types, nor domains over them: as long as we can
find a suitable array type we're good.

Remove some assertions that seem rather out of place (it's not
this code's duty to verify that the RestrictInfo structure is
sane).  Rewrite some comments.

The issues with RelabelType stripping seem severe enough to
back-patch this into v18 where the code was introduced.

Author: Tender Wang <tndrwang@gmail.com>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAHewXN=aH7GQBk4fXU-WaEeVmQWUmBAeNyBfJ3VKzPphyPKUkQ@mail.gmail.com
Backpatch-through: 18
src/backend/optimizer/path/indxpath.c