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

From Heikki Linnakangas
Subject Re: regclass without error?
Date
Msg-id 4D230824.2040309@enterprisedb.com
Whole thread Raw
In response to Re: regclass without error?  (Tatsuo Ishii <ishii@postgresql.org>)
Responses Re: regclass without error?  (Tatsuo Ishii <ishii@postgresql.org>)
List pgsql-hackers
On 04.01.2011 11:07, Tatsuo Ishii wrote:
> Datum
> pgpool_regclass(PG_FUNCTION_ARGS)
> {
>     char        *pro_name_or_oid = PG_GETARG_CSTRING(0);
>     Oid    result;
>
>     PG_TRY();
>     {
>         result = DirectFunctionCall1(regclassin,
>                                      CStringGetDatum(pro_name_or_oid));
>     }
>     PG_CATCH();
>     {
>         result = InvalidOid;
>     }
>     PG_END_TRY();
>
>     PG_RETURN_OID(result);
> }
>
> IMO this implementation is the least invasive but not so
> elegant.

It's not generally safe to suppress errors like that. You could leak 
locks or tuple descriptors etc. And if the error is not "no scuh table", 
but e.g. out of memory, you don't want to suppress it anyway.

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Dimitri Fontaine
Date:
Subject: ALTER EXTENSION UPGRADE patch v1
Next
From: "Kevin Grittner"
Date:
Subject: Re: Re: new patch of MERGE (merge_204) & a question about duplicated ctid