Fix index matching for operators with mixed collatable/noncollatable inputs.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 29 Sep 2011 04:43:42 +0000 (00:43 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 29 Sep 2011 04:43:42 +0000 (00:43 -0400)
commitcb37c291060dd13b1a8ff61fceee09efcfbc34e1
tree06fc08fb35cb56d38dc3d520de1a54b57eb44485
parent5e5958428b7c6e91ffddf46bf9aafd920af57a60
Fix index matching for operators with mixed collatable/noncollatable inputs.

If an indexable operator for a non-collatable indexed datatype has a
collatable right-hand input type, any OpExpr for it will be marked with a
nonzero inputcollid (since having one collatable input is sufficient to
make that happen).  However, an index on a non-collatable column certainly
doesn't have any collation.  This caused us to fail to match such operators
to their indexes, because indxpath.c required an exact match of index
collation and clause collation.  It seems correct to allow a match when the
index is collation-less regardless of the clause's inputcollid: an operator
with both noncollatable and collatable inputs could perhaps depend on the
collation of the collatable input, but it could hardly expect the index for
the noncollatable input to have that same collation.

Per bug #6232 from Pierre Ducroquet.  His example is specifically about
"hstore ? text" but the problem seems quite generic.
src/backend/optimizer/path/indxpath.c