CREATE OR REPLACE FUNCTION my_function(user_id integer)
RETURNS TABLE(id integer, firstname character varying, lastname character varying)
AS $$
DECLARE
ids INTEGER[];
BEGIN
ids := ARRAY[1,2];
RETURN QUERY
SELECT users.id, users.firstname, users.lastname
FROM public.users
WHERE users.id = ANY(ids);
END;
$$ LANGUAGE plpgsql;
select * from my_function(1);