pgsql: Clean up match_orclause_to_indexcol(). - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Clean up match_orclause_to_indexcol().
Date
Msg-id E1vL4WC-0002G1-2b@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ed931377abc0403ce137d9a7f7ded67cb9355c8d

Modified Files
--------------
src/backend/optimizer/path/indxpath.c | 115 +++++++++++++---------------------
1 file changed, 45 insertions(+), 70 deletions(-)


pgsql-committers by date:

Previous
From: Fujii Masao
Date:
Subject: pgsql: doc: Document default values for some pg_recvlogical options.
Next
From: Nathan Bossart
Date:
Subject: pgsql: Update .abi-compliance-history for change to CreateStatistics().