pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Eugen Konkov <kes-kes@yandex.ru>
To: PostgreSQL-development <pgsql-hackers@postgreSQL.org>
Subject: Re: BUG #15646: Inconsistent behavior for current_setting/set_config
Date: Tue, 26 Feb 2019 14:48:46 +0200
Message-ID: <251485831.20190226144846@yandex.ru> (raw)
In-Reply-To: <356428520.20190226143539@yandex.ru>
References: <15646-0d3caee9f6266f60@postgresql.org>
	<d2ac387b-e796-e3ef-10e5-e06fede7c973@joeconway.com>
	<16698.1550682675@sss.pgh.pa.us>
	<2247b773-fe5a-c08a-5655-5dff35be2954@joeconway.com>
	<356428520.20190226143539@yandex.ru>

Hello

Documentation has no description how 'false' value for 'is_local' parameter interact with transaction



Do I understand correct?

https://www.postgresql.org/docs/11/functions-admin.html#FUNCTIONS-ADMIN-SET
>set_config sets the parameter setting_name to new_value. If is_local is true, the new value will only apply to the current transaction. If you want the new value to apply for the current session, use false instead. 

If I use 'false' then transaction will not have effect, because I set the value to session?

tucha=> select current_setting( 'my.app_period', true );
 current_setting 
-----------------
 
(1 row)

tucha=> begin;
BEGIN
tucha=> select set_config( 'my.app_period', tstzrange( '-infinity', 'infinity' )::text, false );
      set_config      
----------------------
 [-infinity,infinity)
(1 row)

tucha=> rollback;
ROLLBACK

NOTICE: session is rolled back and session value is rolled back despite on that I did not use 'true' as parameter for local:

tucha=> select current_setting( 'my.app_period', true );
 current_setting 
-----------------
 
(1 row)

tucha=> begin;
BEGIN
tucha=> select set_config( 'my.app_period', tstzrange( '-infinity', 'infinity' )::text, false );
      set_config      
----------------------
 [-infinity,infinity)
(1 row)

tucha=> commit;
COMMIT

When I commit then the value is applied to session:
tucha=> select current_setting( 'my.app_period', true );
   current_setting    
----------------------
 [-infinity,infinity)
(1 row)



-- 
Best regards,
Eugen Konkov





view thread (9+ messages)  latest in thread

Message-ID: <251485831.20190226144846@yandex.ru>
Permalink:  ../251485831.20190226144846@yandex.ru/
Also on:    postgresql.org/message-id/251485831.20190226144846@yandex.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: kes-kes@yandex.ru, pgsql-hackers@postgreSQL.org
  Subject: Re: BUG #15646: Inconsistent behavior for current_setting/set_config
  In-Reply-To: <251485831.20190226144846@yandex.ru>
  References: <15646-0d3caee9f6266f60@postgresql.org> <d2ac387b-e796-e3ef-10e5-e06fede7c973@joeconway.com> <16698.1550682675@sss.pgh.pa.us> <2247b773-fe5a-c08a-5655-5dff35be2954@joeconway.com> <356428520.20190226143539@yandex.ru> <251485831.20190226144846@yandex.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox