Thread: proposal - reglanguage type

proposal - reglanguage type

From
Pavel Stehule
Date:
Hi

I miss a reglanguage type from our set of reg* types.

It reduce a mental overhead for queries over pg_proc table

With this type I can easy filter only plpgsql functions

select *
  from pg_proc
where prolang = 'plpgsql'::reglanguage
   and pronamespace <> 'pg_catalog'::regnamespace;

Regards

Pavel
Attachment

Re: proposal - reglanguage type

From
Tom Lane
Date:
Pavel Stehule <pavel.stehule@gmail.com> writes:
> I miss a reglanguage type from our set of reg* types.

I'm skeptical about this.  I don't think we want to wind up with a reg*
type for every system catalog, so there needs to be some rule about which
ones it's worth the trouble for.  The original idea was to provide a reg*
type if the lookup rule would be anything more complicated than "select
oid from <catalog> where name = 'foo'".  We went beyond that with
regnamespace and regrole, but I think there was a sufficient argument of
usefulness for those two.  I don't see that reglanguage has enough of
a use-case.

            regards, tom lane



Re: proposal - reglanguage type

From
Pavel Stehule
Date:


ne 1. 3. 2020 v 19:31 odesílatel Tom Lane <tgl@sss.pgh.pa.us> napsal:
Pavel Stehule <pavel.stehule@gmail.com> writes:
> I miss a reglanguage type from our set of reg* types.

I'm skeptical about this.  I don't think we want to wind up with a reg*
type for every system catalog, so there needs to be some rule about which
ones it's worth the trouble for.  The original idea was to provide a reg*
type if the lookup rule would be anything more complicated than "select
oid from <catalog> where name = 'foo'".  We went beyond that with
regnamespace and regrole, but I think there was a sufficient argument of
usefulness for those two.  I don't see that reglanguage has enough of
a use-case.

the use-case is probably only one - filtering pg_proc. Probably the most common filter is

prolang = (SELECT oid                    FROM pg_language                   WHERE lanname = 'plpgsql')
It's little bit not comfortable so for namespace we can do pronamespace <> 'pg_catalog'::regnamespace and there is nothing for language.

This feature is interesting for people who write code in plpgsql, or who migrate from PL/SQL (and for people who use plpgsql_check).

All mass check (mass usage of plpgsql_check) have to use filter on prolang.

Regards

Pavel


 

                        regards, tom lane