Re: BUG #18676: Execute function while selecting from table with partial index using this function. - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #18676: Execute function while selecting from table with partial index using this function.
Date
Msg-id 3972734.1730130166@sss.pgh.pa.us
Whole thread Raw
In response to BUG #18676: Execute function while selecting from table with partial index using this function.  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> Please run the script below. It creates sample table with partial index
> using IMMUTABLE function. 
> I think when table is changing - index in changing and thus function used in
> WHERE cluse can be run.
> But it is not supposed to be run on just simple SELECT from table without
> even condition to use this index. 

[ shrug... ]  There is no bug here.  The planner is entitled to
investigate the properties of indexes attached to a table it's
trying to plan for.  Sure, this index is not relevant to this
query --- but how's the planner going to know that without
examining the index?  And part of that examination involves
reducing any partial-index predicate to standard form, which
includes constant-folding.  Since your function is marked
IMMUTABLE, that means it should be evaluated and reduced to
a constant.

Part of the contract for marking a function IMMUTABLE is that
it has no interesting side-effects.  This example breaks that
in two ways: the RAISE NOTICE is a side-effect, and the
possibility of a permissions failure is another one.

            regards, tom lane



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #18676: Execute function while selecting from table with partial index using this function.
Next
From: Maciej Jaros
Date:
Subject: Re: BUG #18675: Postgres is not realasing memory causing OOM