> On Tue, Aug 18, 2026 at 8:54 AM Tender Wang <[email protected]> wrote:
> The attached patch fixes this by checking the CASE argument against
> the equality operator and input collation of each WHEN comparison
> using the existing grouping_check_operand() logic.

I confirmed that this is a real wrong-result issue, and this approach
looks correct to me.

One small issue with the patch:
+               Assert(IsA(cw->expr, OpExpr));
+               opexpr = (OpExpr *) cw->expr;

cw->expr is not guaranteed to be an OpExpr.  transformCaseExpr() calls
coerce_to_boolean() after constructing the "=" expression.  With a
user-defined "=" operator returning a non-boolean type and an assignment
cast from that type to boolean, cw->expr becomes a FuncExpr wrapping the
OpExpr.

Therefore, the assertion can fail in an assert build, while the cast is
unsafe in a non-assert build.  I think the non-OpExpr case should be
handled conservatively as a grouping conflict.

Best Regards,
Yuhang Qiu



Reply via email to