"Gurjeet Singh" <singh.gurj...@gmail.com> writes:
> select relname, pg_relation_size( 'public."' || relname || '"' )/1024
> from (select distinct relname
>       from (select r.relname, c.attname, c.attnotnull, t.typname
>               from pg_namespace as s, pg_class as r, pg_attribute as c, 
> pg_type as t
>               where s.oid = r.relnamespace
>               and r.oid = c.attrelid
>               and c.atttypid = t.oid
>               and s.nspname = 'public'
>               and t.typname in ('bytea', 'text') ) as s1
>       ) as s2
> where pg_relation_size( 'public."' || relname || '"' ) <> 0;

> ERROR:  relation "public.pg_type" does not exist

That approach to generating a textual name for a relation is really
pretty unworkable: it's on the hairy edge of being vulnerable to
SQL injection attacks, not to mention being inefficient and unwieldy.
Just pass r.oid to pg_relation_size, instead.

                        regards, tom lane

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to