BUG #14607: session variables are non-deterministic

From: jankaraffa(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #14607: session variables are non-deterministic
Date: 2017-03-31 12:35:12
Message-ID: 20170331123512.2688.34145@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 14607
Logged by: Jan Karaffa
Email address: jankaraffa(at)gmail(dot)com
PostgreSQL version: 9.4.11
Operating system: Red Hat 4.4.7-17, 64bit
Description:

let's have myPartTable as partitioned table with check constraint on
part_key::text column

SET myvar.partition_key='ABC';
select count(*) from myPartTable
where part_key = current_setting('myvar.partition_key')::text;

Execution plan shows that all inherited (partitioned) tables are scanned. 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.

If current_setting function would behave deterministic it would enable us to
pass session parameters into the view and perform limitation inside of view
where it makes sense. Current "workaround" is to move logic from view to
function, which is not as easy to use in hibernate as the standard views.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Pavel Stehule 2017-03-31 13:03:30 Re: BUG #14607: session variables are non-deterministic
Previous Message Michael Paquier 2017-03-31 09:12:32 Re: BUG #14606: Memory usage continue to increase