Re: describe objects, as in pg_depend

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: describe objects, as in pg_depend
Date: 2010-11-17 15:39:49
Message-ID: 1290008127-sup-8494@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Excerpts from Tom Lane's message of mié nov 17 12:20:06 -0300 2010:
> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> > A customer of ours (Enova Financial) requested the ability to describe
> > objects in pg_depend. The wiki contains a simplistic SQL snippet that
> > does the task, but only for some of the object types, and it's rather
> > ugly. It struck me that we could fulfill this very easily by exposing
> > the getObjectDescription() function at the SQL level, as in the attached
> > module.
>
> What's the point of the InvalidOid check? It seems like you're mostly
> just introducing a corner case: sometimes, but not always, the function
> will return NULL instead of failing for bad input. I think it should
> just fail always.

If the check is not there, the calling query will have to prevent the
function from being called on rows having OID=0 in pg_depend. (These
rows show up in the catalog for pinned objects). The query becomes
either incomplete (because you don't report pinned objects) or awkward
(because you have to insert a CASE expression to avoid calling the
function in that case).

I don't think it's all that necessary anyway. If the function goes in
without that check, it will still be a huge improvement over the statu
quo.

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2010-11-17 15:43:00 Re: Indent authentication overloading
Previous Message Tom Lane 2010-11-17 15:39:04 Re: Indent authentication overloading