Re: Schema variables - new implementation for Postgres 15

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Wolfgang Walther <walther(at)technowledgy(dot)de>
Cc: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, 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-05-31 13:11:21
Message-ID: CAFj8pRD5C2f4qmUi3UuT-9rLZYZAdNUZn55ivymO1UhO6JL_9A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

pá 31. 5. 2024 v 15:02 odesílatel Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
napsal:

>
>
> pá 31. 5. 2024 v 13:37 odesílatel Wolfgang Walther <
> walther(at)technowledgy(dot)de> napsal:
>
>> Pavel Stehule:
>> > But in this case you could make variables and tables share the same
>> > namespace, i.e. forbid creating a variable with the same name as an
>> > already existing table.
>> >
>> >
>> > It helps, but not on 100% - there is a search path
>>
>
>> I think we can ignore the search_path for this discussion. That's not a
>> problem of variables vs tables, but just a search path related problem.
>> It is exactly the same thing right now, when you create a new table x(x)
>> in a schema which happens to be earlier in your search path.
>>
>
> I don't think it is a valid argument - search_path is there, and we cannot
> ignore it, because it allows just one case.
>
> And the need to use a variable in FROM clause introduces implicit
> unpacking or inconsistency with current work with composite's types, so I
> am more sure this way is not good.
>

The session variables can be used in queries, but should be used in
PL/pgSQL expressions, and then the mandatory usage in FROM clause will do
lot of problems and unreadable code like

DO $$
BEGIN
RAISE NOTICE '% %', (SELECT x FROM x), (SELECT a,b FROM y);

END
$$

This requirement does variables unusable in PL

>
>
>
>>
>> The objection to the proposed approach for variables was that it would
>> introduce *new* ambiguities, which Alvaro's suggestion avoids.
>>
>> Best,
>>
>> Wolfgang
>>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Wolfgang Walther 2024-05-31 13:29:29 Re: Schema variables - new implementation for Postgres 15
Previous Message Pavel Stehule 2024-05-31 13:02:49 Re: Schema variables - new implementation for Postgres 15