> On Thu, Apr 02, 2020 at 11:01:50AM +0900, Michael Paquier wrote:
>
> > + /*
> > + * No need to check if exprCollOid is invalid, since if it would be,
> > + * then transformCollateClause will throw an error earlier
> > + */
> > + if (!type_is_collatable(colType))
> > + ereport(ERROR,
> > + (errcode(ERRCODE_DATATYPE_MISMATCH),
> > + errmsg("collations are not supported by type %s",
> > + format_type_be(colType))));
> > +
> >
> > if (OidIsValid(exprCollOid) &&
> > exprCollOid != DEFAULT_COLLATION_OID &&
> > exprCollOid != partCollation)
>
> Another point that could be made is that as we know that we are in the
> presence of a CollateExpr() here, and exprCollOid will never be
> InvalidOid. So there could be a point in using an assertion instead
> of the check done below making sure that exprCollOid is always valid?
Thanks for the suggestion. It's not strictly related to the fix I guess,
but of course you're right, and we can indeed improve this part and
replace the check with an assert.