I came up with this idea to loop over all tables and column names to count the number of null values in postgres. However, I failed to do that by Error 42702: column reference "table_name" is ambiguous.
create or replace function count_nulls()
    returns table ("table_name" text, "column_name" text, "nulls" int)
    language plpgsql as
$func$
    declare _record information_schema.columns %ROWTYPE;
    begin
        for _record in
            SELECT "table_name", "column_name"
            FROM information_schema.columns
            where "table_schema" = 'public'
        loop
            select quote_literal(_record.table_name) as "table",
                 quote_literal(_record.column_name) as "column", 
                 count(*) as "nulls"
            from quote_literal(_record.table_name)
            where quote_literal(_record.column_name) is null
            group by "table", "column";
        end loop;
        return;
    end;
$func$;
select * from count_nulls();
Any pointers to documentation or keywords for further search is appreciated.
 
    