Re: idea: multiple arguments to_regclass function - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: idea: multiple arguments to_regclass function
Date
Msg-id CAFj8pRDWiM0coB4scmEn_qjt+xfTb9P5uRVY8hU6MSQQA-xRHg@mail.gmail.com
Whole thread Raw
In response to Re: idea: multiple arguments to_regclass function  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers


ne 16. 4. 2023 v 16:23 odesílatel Tom Lane <tgl@sss.pgh.pa.us> napsal:
Pavel Stehule <pavel.stehule@gmail.com> writes:
> I missing some variants of to_regclass

> to_regclass(schemaname, objectname)
> to_regclass(catalogname, schemaname, objectname)

Can do that already:

to_regclass(quote_ident(schemaname) || '.' || quote_ident(objectname))

I'm not eager to build nine more to_reg* functions to do the equivalent
of that, and even less eager to build eighteen.

Yes, I can. But there is overhead with escaping and string concatenation.  And it is a little bit sad, so immediately the parser has to do an inverse process.

Maybe we can introduce only three functions

anyelement get_object(catalogname name, schemaname name, objectname name, returntype anyelement)
anyelement get_object(schemaname name, objectname name, returntype anyelement)
anyelement get_object(objectname name, returntype anyelement)

so usage can be like

DECLATE _tab regclass;
BEGIN
  _tab := get_object('public', 'mytab', _tab);
  ..

?

Regards

Pavel







                        regards, tom lane

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Direct I/O
Next
From: Tom Lane
Date:
Subject: Re: Direct I/O