Re: Schema variables - new implementation for Postgres 15

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: walther(at)technowledgy(dot)de, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Sergey Shinderuk <s(dot)shinderuk(at)postgrespro(dot)ru>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Julien Rouhaud <rjuju123(at)gmail(dot)com>, dean(dot)a(dot)rasheed(at)gmail(dot)com, er(at)xs4all(dot)nl, joel(at)compiler(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Schema variables - new implementation for Postgres 15
Date: 2024-06-03 21:41:02
Message-ID: CAFj8pRCbmmDQ2itZ_0CnAPheaxhiP+iepMcv+6Z44UPCKStn8w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

> You can see, the RDBMS allows different types of session variables,
> different implementations. Usually one system allows more implementation of
> session variables. There is a possibility of emulation implementation
> between RDBMS, but security setting is possible only in Oracle or DB2.
>

MySQL concept is very handy for ad hoc work, but it is too primitive for
secure or safe use in stored procedures.

Oracle concept is safe, but needs packages, needs writing wrappers, needs
PL/SQL.

I designed a concept that is very similar to DB2 (independently on IBM),
and I think it is strong and can be well mapped to PostgreSQL (no packages,
more different PL, strongly typed, ...)

I think it would be nice to support the MySQL concept as syntactic sugar
for GUC. This can be easy and for some use cases really very handy (and
less confusing for beginners - using set_confing and current_setting is
intuitive for work (emulation) of session variables (although the MSSQL
solution is less intuitive).

SET @myvar TO 10; --> SELECT set_config('session.myvar', 10)
SET @@work_mem TO '10MB'; --> SELECT set_config('work_mem', '10MB');
SELECT @myvar; --> SELECT current_setting('session.myvar');
SELECT @@work_mem; --> SELECT current_setting('work_mem');

The syntax @ and @@ is widely used, and the mapping can be simple. This my
proposal is not a replacement of the proposal of "schema" session
variables. It is another concept, and I think so both can live together
very well, because they are used for different purposes. Oracle, DB2
supports +/- both concepts

Regards

Pavel

>
> Regards
>
> Pavel
>
>
>
>
>
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Erik Wienhold 2024-06-03 21:48:47 Re: pltcl crashes due to a syntax error
Previous Message Masahiko Sawada 2024-06-03 21:26:37 Revive num_dead_tuples column of pg_stat_progress_vacuum