Richard Guo <[email protected]> 于2026年8月28日周五 10:20写道: > I think it'd be better to avoid this duplication. So I'd like to take > the approach used elsewhere in planner for the same placeholder: while > walking the WHEN conditions, the walker binds a Var arg in the context > and resolves each CaseTestExpr to it. The Var is then checked as each > WHEN uses it. This is how eval_const_expressions() handles the > CaseTestExpr nodes. > > Attached is the patch doing that.
I took a look at the existing handling of CaseTestExpr in the planner, and it works as you described. I noticed that you added special handling for ArrayCoerceExpr in grouping_conflict_walker(), but the current regression tests don't exercise this new branch. I think it would be better to add a test case to cover it. For example: CREATE TEMP TABLE case_array_test (a int[]); EXPLAIN (COSTS OFF) SELECT * FROM (SELECT DISTINCT a FROM case_array_test) s WHERE CASE a::bigint[] WHEN ARRAY[1::bigint] THEN true ELSE false END; The rest looks good to me. -- Thanks, Tender Wang
