Re: regclass without error? - Mailing list pgsql-hackers

From Robert Haas
Subject Re: regclass without error?
Date
Msg-id AANLkTin_BDS5GLbaOdY5GJ0ng272odwj+rd=Fs-YFtLi@mail.gmail.com
Whole thread Raw
In response to regclass without error?  (Tatsuo Ishii <ishii@postgresql.org>)
Responses Re: regclass without error?
List pgsql-hackers
On Fri, Sep 3, 2010 at 4:28 AM, Tatsuo Ishii <ishii@postgresql.org> wrote:
> Is there any way to use regclass without having ERROR?
>
> pgpool-II needs to find the oid from table name and for the purpose it
> issues something like "SELECT 'table_name'::regproc::oid". Problem is,
> if the table does not exist, an error occured and the transaction
> aborts. Ideally if the table does not exist, the SELECT returns 0
> (InvalidOid).
>
> Any idea?

You can write a query against the system catalog tables.  Or you could
install a function that wraps the regclass cast in an exception
handler.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company


pgsql-hackers by date:

Previous
From: Dave Page
Date:
Subject: Re: Streaming a base backup from master
Next
From: Hans-Jürgen Schönig
Date:
Subject: Re: Path question