| From: | Tender Wang <tndrwang(at)gmail(dot)com> |
|---|---|
| To: | Richard Guo <guofenglinux(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Unsafe qual pushdown through DISTINCT with simple CASE expressions |
| Date: | 2026-08-28 05:55:25 |
| Message-ID: | CAHewXNm-VsGpyKOhXH9PEdT9_Sry2krj1-WX2F1MuuXMjrTtGg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Richard Guo <guofenglinux(at)gmail(dot)com> 于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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2026-08-28 06:04:15 | Re: REPACK (CONCURRENTLY) fails when replica identity index is dropped |
| Previous Message | Masahiko Sawada | 2026-08-28 05:52:17 | Re: First draft of PG 19 release notes |