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 CAFj8pRCPPm6o12hawtFLAOq7E830R6xuKB2+CU0maXUMua9mKw@mail.gmail.com
Whole thread Raw
In response to Re: Schema variables - new implementation for Postgres 15  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Schema variables - new implementation for Postgres 15
List pgsql-hackers


so 25. 5. 2024 v 3:29 odesílatel Tom Lane <tgl@sss.pgh.pa.us> napsal:
Pavel Stehule <pavel.stehule@gmail.com> writes:
> we can introduce special safe mode started by
> set enable_direct_variable_read to off;
> and allowing access to variables only by usage dedicated function
> (supported by parser) named like variable or pg_variable

Didn't we learn twenty years ago that GUCs that change query
semantics are an awful idea?  Pick a single access method
for these things and stick to it.

I don't think the proposed GUC exactly changes query semantics - it is equivalent of plpgsql options: plpgsql_extra_xxxx or #variable_conflict. It allows us to identify broken queries. And for tools that generates queries is not problem to wrap reading variable by special pseudo function. The code where pseudo function will be used should to work with active or inactive strict mode (related to possibility to use variables).

Sure there is more possibilities, but I don't want to lost the possibility to write code like

CREATE TEMP VARIABLE _x;

LET _x = 'hello';

DO $$
BEGIN
  RAISE NOTICE '%', _x;
END;
$$;

So I am searching for a way to do it safely, but still intuitive and user friendly.

Regards

Pavel

 

                        regards, tom lane

pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: Volatile write caches on macOS and Windows, redux
Next
From: Bertrand Drouvot
Date:
Subject: relfilenode statistics