Thread: idea: multiple arguments to_regclass function
Hi
I missing some variants of to_regclass
to_regclass(schemaname, objectname)
to_regclass(catalogname, schemaname, objectname)
It can helps with object identification, when I have separated schema and name
What do you think about this?
Regards
Pavel
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. regards, tom lane
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