Add read-only param to set_config(...) / SET that effects (at least)customized runtime options

Поиск
Список
Период
Сортировка
От Matthias Kurz
Тема Add read-only param to set_config(...) / SET that effects (at least)customized runtime options
Дата
Msg-id CAO=2mx5OHkF_UY5fC4x22vbYyicLaY3po3OxYt1YKccEf9EjUw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Add read-only param to set_config(...) / SET that effects (atleast) customized runtime options  (Chapman Flack <chap@anastigmatix.net>)
Список pgsql-hackers
Hi,

in MS SQL Server you are able to make an entry of SESSION_CONTEXT read-only by passing the @read_only param to the sp_set_session_context function:
"[ @read_only= ] { 0 | 1 } A flag of type bit. If 1, then the value for the specified key cannot be changed again on this logical connection. If 0 (default), then the value can be changed."

I propose the same functionally for PostgreSQL - at least when setting "customized options" (the ones with a dot in the name: https://www.postgresql.org/docs/10/static/runtime-config-custom.html)

The set_config(...) method therefore would end up like:
set_config(setting_name, new_value, is_local, read_only)

The equalient SET command could look something like:
SET READONLY my_app.some_var = 'foo';
SET READONLY SESSION my_app.some_var = 'foo';
SET READONLY LOCAL my_app.some_var = 'foo';

Of course read-only would default to false for backwards compatibility.
When setting READONLY for on SESSION config then that config is not allowed to be changed anymore until the connection gets closed - even when running RESET ALL or DISCARD ALL.
When setting read-only for a transaction config "the effects of the SET LOCAL command disappear at function exit" will still be true, like written in https://www.postgresql.org/docs/10/static/sql-set.html.

What do you think?

Regards,
Matthias

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Postgresql9.6 type cache invalidation issue - different behave of psql and pg regress
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: SHOW ALL does not honor pg_read_all_settings membership