IN clause by mergejoin, and a type coercion is needed just above the subplan.
A more extensive patch will follow in HEAD.
/*
* Do we need to insert a Result node?
*
- * Currently, the only non-projection-capable plan type we can
- * see here is Append.
+ * Currently, the only non-projection-capable plan types we can
+ * see here are Append and Unique.
*/
- if (IsA(lefttree, Append))
+ if (IsA(lefttree, Append) || IsA(lefttree, Unique))
{
tlist = copyObject(tlist);
lefttree = (Plan *) make_result(tlist, NULL, lefttree);