Re: BUG #18676: Execute function while selecting from table with partial index using this function.
От | Tom Lane |
---|---|
Тема | Re: BUG #18676: Execute function while selecting from table with partial index using this function. |
Дата | |
Msg-id | 3972734.1730130166@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | BUG #18676: Execute function while selecting from table with partial index using this function. (PG Bug reporting form <noreply@postgresql.org>) |
Список | 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 по дате отправления: