From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | poliv78(at)gmail(dot)com |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #18676: Execute function while selecting from table with partial index using this function. |
Date: | 2024-10-28 15:42:46 |
Message-ID: | 3972734.1730130166@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
PG Bug reporting form <noreply(at)postgresql(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Maciej Jaros | 2024-10-28 18:07:45 | Re: BUG #18675: Postgres is not realasing memory causing OOM |
Previous Message | PG Bug reporting form | 2024-10-28 14:58:34 | BUG #18676: Execute function while selecting from table with partial index using this function. |