The multirow subselect will be used in the right hand side of the in
operator in the where
clause:
create table t (a integer);
insert into t (a) values (1), (9);
drop function if exists f();
create function f()
returns void as $$
begin
execute '
select a
from t
where a in $1
' using (select 1 union select 2);
end;$$
language plpgsql;
select f();
ERROR: more than one row returned by a subquery used as an expression
CONTEXT: SQL statement "SELECT (select 1 union select 2)"
PL/pgSQL function "f" line 3 at EXECUTE statement
How to achieve what the above function would if it worked?
=any
vsin
). The necessity is that the table is partitioned and if thewhere
parameters are not constants the planner will not optimize the query. – Logrolling