pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: jankaraffa@gmail.com, "pgsql-bugs@postgresql.org" <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14607: session variables are non-deterministic
Date: Fri, 31 Mar 2017 20:37:27 -0400
Message-ID: <27436.1491007047@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFj8pRBuXmD645FMU0LiELvBj9YCkttoPPzkif5HzVP0C7-Ctw@mail.gmail.com>
References: <20170331123512.2688.34145@wrigleys.postgresql.org>
	<CAFj8pRBuXmD645FMU0LiELvBj9YCkttoPPzkif5HzVP0C7-Ctw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Pavel Stehule <pavel.stehule@gmail.com> writes:
> 2017-03-31 14:35 GMT+02:00 <jankaraffa@gmail.com>:
>> It behaves like current_setting function is non-deterministic and therefore
>> sql optimalizator is not considered output as constant. For me it looks like
>> bug as session variable can not change during parsing/execution.

> session variable is volatile - so it is not bug.

> There is a workaround - you can wrap a access to this variable to STABLE
> function

current_setting() already is stable according to the pg_proc catalog.
This is not a bug because the OP is wrong: GUC values *can* change between
planning and execution.  It's very easy for that to happen when dealing
with cached plans.

(Really, they could change even during execution of a query, but we choose
to avert our eyes from that fact rather than mark the function volatile
and thereby make it even less optimizable.)

You could force it by using a wrapper function marked IMMUTABLE, but that
really seems like carrying around a loaded gun aimed at your foot.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (3+ messages)

Message-ID: <27436.1491007047@sss.pgh.pa.us>
Permalink:  ../27436.1491007047@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/27436.1491007047@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, pavel.stehule@gmail.com
  Subject: Re: BUG #14607: session variables are non-deterministic
  In-Reply-To: <27436.1491007047@sss.pgh.pa.us>
  References: <20170331123512.2688.34145@wrigleys.postgresql.org> <CAFj8pRBuXmD645FMU0LiELvBj9YCkttoPPzkif5HzVP0C7-Ctw@mail.gmail.com> <27436.1491007047@sss.pgh.pa.us>

* 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