Re: Schema variables - new implementation for Postgres 15

Поиск
Список
Период
Сортировка
От Joel Jacobson
Тема Re: Schema variables - new implementation for Postgres 15
Дата
Msg-id b569df2b-084c-47c1-8bba-dbdcc45874ec@www.fastmail.com
обсуждение исходный текст
Ответ на Schema variables - new implementation for Postgres 15  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: Schema variables - new implementation for Postgres 15
Список pgsql-hackers
On Thu, Apr 15, 2021, at 10:42, Pavel Stehule wrote:
Attachments:
  • schema-variables-v-execnode-2021-01.patch
  • schema-variables-v-utility-2021-01.patch

Applications are currently know to be misusing set_config()+current_setting() to pass information in a session or transaction.

Such users might be interested in using Schema variables as a better replacement.

However, since set_config() is transactional, it can't be used as a drop-in replacement:

+   <para>
+    The value of a schema variable is local to the current session. Retrieving
+    a variable's value returns either a NULL or a default value, unless its value
+    is set to something else in the current session with a LET command. The content
+    of a variable is not transactional. This is the same as in regular variables
+    in PL languages.
+   </para>

I think the "The content of a variable is not transactional." part is therefore a bad idea.

Another pattern is to use TEMP TABLEs to pass around information in a session or transaction.
If the LET command would be transactional, it could be used as a drop-in replacement for such use-cases as well.

Furthermore, I think a non-transactional LET command would be insidious,
since it looks like any other SQL command, all of which are transactional.
(The ones that aren't such as REINDEX CONCURRENTLY will properly throw an error if run inside a transaction block.)

A non-transactional LET command IMO would be non-SQL-idiomatic and non-intuitive.

/Joel



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: Replication slot stats misgivings
Следующее
От: Bharath Rupireddy
Дата:
Сообщение: Re: TRUNCATE on foreign table