Re: Schema variables - new implementation for Postgres 15 - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: Schema variables - new implementation for Postgres 15
Date
Msg-id CAFj8pRCBVSQS5tFeMQjeGZ=5G3TyKvbMKOEpmEMSNQfeOwbWOQ@mail.gmail.com
Whole thread Raw
In response to Re: Schema variables - new implementation for Postgres 15  (Wolfgang Walther <walther@technowledgy.de>)
Responses Re: Schema variables - new implementation for Postgres 15
List pgsql-hackers


pá 31. 5. 2024 v 15:29 odesílatel Wolfgang Walther <walther@technowledgy.de> napsal:
Pavel Stehule:
> 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

I already proposed earlier to only require listing them in FROM when
there is actually a related FROM.

but there is technical problem - plpgsql expression are internally SQL queries. Isn't possible to cleanly to parse queries and expressions differently.

 

In this case you could still write:

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

(assuming only x is a variable here)

Best,

Wolfgang

pgsql-hackers by date:

Previous
From: Wolfgang Walther
Date:
Subject: Re: Schema variables - new implementation for Postgres 15
Next
From: Pavel Stehule
Date:
Subject: Re: Schema variables - new implementation for Postgres 15