Re: BUG #5358: Throwing unexpected ERROR

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5358: Throwing unexpected ERROR
Date: 2010-03-03 00:51:00
Message-ID: 27537.1267577460@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Craig Ringer 2010-03-03 01:05:11 Re: BUG #5351: compiling with --disable-shared is broken (patch included)
Previous Message Bruce Momjian 2010-03-03 00:50:43 Re: BUG #5354: Type timestamptz doesn't allow to store time zone