Long time ago, I propose regclass like function which does not throw
an error if the table is not found. Instead I want to let it return
InvalidOid or NULL.
Tatsuo Ishii <firstname.lastname@example.org> writes:
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
I don't think the cast should act that way, but I could see providing a
separate conversion function that returns 0 ... or perhaps better NULL
... if no match.
Such a function should be very helpfull. Great!
I made pretty simple function for this. Essential part is something
char *pro_name_or_oid = PG_GETARG_CSTRING(0);
result = DirectFunctionCall1(regclassin,
result = InvalidOid;
IMO this implementation is the least invasive but not so
Before proposing more complete patches, I would like to hear comments:
which way I should go? The least invasive one like above? Or Should I
refactor regclassin, for example implementing "regclassin_gut" which
do the essential job, and making wrapper functions, one is active
existing regclass, and the other act as new one?