CREATE OR REPLACE FUNCTION
    aus_all_user_flags (integer)
RETURNS
    SETOF aus_all_user_flag_set
AS '
    DECLARE
        rec aus_all_user_flag_set%ROWTYPE; --
    BEGIN
        CREATE TEMPORARY TABLE tmp_all_user_flags (
            user_id     INT NOT NULL,
            flag_name   VARCHAR(128) NOT NULL,
            enabled     BOOL NULL
        ) ON COMMIT DROP; --
    
        PERFORM aus_find_all_user_flags ($1, $1); --    
        
        FOR rec IN EXECUTE ''SELECT * FROM tmp_all_user_flags'' LOOP
            RETURN NEXT rec; --
        END LOOP; --
        
        DROP TABLE tmp_all_user_flags; --
        
        RETURN null; --
    END; --
' LANGUAGE plpgsql;
