Re: regclass without error?

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: regclass without error?
Дата
Msg-id AANLkTin_BDS5GLbaOdY5GJ0ng272odwj+rd=Fs-YFtLi@mail.gmail.com
обсуждение исходный текст
Ответ на regclass without error?  (Tatsuo Ishii <ishii@postgresql.org>)
Ответы Re: regclass without error?  (Tatsuo Ishii <ishii@postgresql.org>)
Список 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 по дате отправления:

Предыдущее
От: Dave Page
Дата:
Сообщение: Re: Streaming a base backup from master
Следующее
От: Hans-Jürgen Schönig
Дата:
Сообщение: Re: Path question