CREATE TABLE public.t (id integer);

CREATE OR REPLACE FUNCTION public.f()
 RETURNS SETOF t
 LANGUAGE plpgsql
 SECURITY DEFINER
AS $$
DECLARE
 rec RECORD;
BEGIN
    FOR rec IN SELECT * FROM t
    LOOP
        RETURN NEXT rec;
    END LOOP;
    RETURN;
END;
$$;

CREATE SCHEMA s;
CREATE VIEW s.t AS SELECT * FROM public.f();
SET search_path TO s;
SELECT * from t;
