Skip site navigation (1) Skip section navigation (2)

Re: regclass without error?

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: regclass without error?
Date: 2010-09-03 13:33:02
Message-ID: AANLkTin_BDS5GLbaOdY5GJ0ng272odwj+rd=Fs-YFtLi@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Fri, Sep 3, 2010 at 4:28 AM, Tatsuo Ishii <ishii(at)postgresql(dot)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

In response to

Responses

pgsql-hackers by date

Next:From: Robert HaasDate: 2010-09-03 13:43:13
Subject: Re: Streaming a base backup from master
Previous:From: Dave PageDate: 2010-09-03 13:32:42
Subject: Re: Streaming a base backup from master

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group