Given an array literal as a parameter, and a table expression as (pseudo-code-like):
SELECT y.id
FROM (VALUES (4)
, (1)
, (2)
, (6)) y (id)
WHERE y.id = < if ANY('{4}') then 4 else y.id >
;
Is there a WHERE clause that can give y.id 4 if there's a match in the array, or every y.id if not, resulting in e.g.,
id
--
4
or
id
--
4
1
2
6
If the array literal did not contain 4.
Need to be compatible with Postgres version 12.