This lets it do the right thing for, eg, varchar columns.
Back-patch to 9.5 where this logic appeared.
David Rowley, per report from Kim Rose Carlsen
Discussion: https://postgr.es/m/VI1PR05MB17091F9A9876528055D6A827C76D0@VI1PR05MB1709.eurprd05.prod.outlook.com
else
var = (Var *) get_leftop(rinfo->clause);
+ /*
+ * We may ignore any RelabelType node above the operand. (There
+ * won't be more than one, since eval_const_expressions() has been
+ * applied already.)
+ */
+ if (var && IsA(var, RelabelType))
+ var = (Var *) ((RelabelType *) var)->arg;
+
/*
* If inner side isn't a Var referencing a subquery output column,
* this clause doesn't help us.