ERROR: DefineIndex: index function must be marked iscachable
Hi all!
What can I do in this case?
I could not found anything about iscachable.
postgres$ cat in.sql
create index bt_proposta_f01 on proposta
using btree (func_cod_secretaria(nr_proponente));
postgres$ psql -d escola -f in.sql
psql:in.sql:2: ERROR: DefineIndex: index function must be marked iscachable
postgres$
\\\!/< 55 11 5080 9283
!_"""_! Elielson Fontanezi
(O) (o) PRODAM - Technical Support
Analyst
-------------------------------oOOO--(_)--OOOo------------------------------
-----
Success usually comes to those who are too busy to be looking for it.
oooo0 0oooo
---------------------------( )----------(
)--------------------------------
\ ( ) /
\_/ \_/
On Fri, 25 Jul 2003, Elielson Fontanezi wrote:
What can I do in this case?
I could not found anything about iscachable.
postgres$ cat in.sql
create index bt_proposta_f01 on proposta
using btree (func_cod_secretaria(nr_proponente));postgres$ psql -d escola -f in.sql
psql:in.sql:2: ERROR: DefineIndex: index function must be marked iscachable
Check the create function reference page, I believe you'd need to add WITH
(iscachable) to the end of the function creation.
iscachable means that the function always returnes the same result when
given the same arguments. It's a prereq to using the function in an
index. If your function doesn't meet those requirements (for example if it
does a query on a table) making an index on that function is a bad idea.
Dnia 2003-07-25 21:09, U�ytkownik Elielson Fontanezi napisa�:
Hi all!
What can I do in this case?
I could not found anything about iscachable.postgres$ cat in.sql
create index bt_proposta_f01 on proposta
using btree (func_cod_secretaria(nr_proponente));postgres$ psql -d escola -f in.sql
psql:in.sql:2: ERROR: DefineIndex: index function must be marked iscachable
postgres$
You should follow the error. Your function func_cod_secretaria has to be
declared as cacheable. (Look into documentation - sql commands / create
function). IMMUTABLE function should help.
This function has also for some nr_proponente returns always the same
value (look at IMMUTABLE description)
Regards,
Tomasz Myrta
On Fri, 25 Jul 2003, Stephan Szabo wrote:
On Fri, 25 Jul 2003, Elielson Fontanezi wrote:
What can I do in this case?
I could not found anything about iscachable.postgres$ cat in.sql
create index bt_proposta_f01 on proposta
using btree (func_cod_secretaria(nr_proponente));postgres$ psql -d escola -f in.sql
psql:in.sql:2: ERROR: DefineIndex: index function must be marked iscachableCheck the create function reference page, I believe you'd need to add WITH
(iscachable) to the end of the function creation.iscachable means that the function always returnes the same result when
given the same arguments. It's a prereq to using the function in an
index. If your function doesn't meet those requirements (for example if it
does a query on a table) making an index on that function is a bad idea.
Almost forgot. In recent versions you'd specify that the function was
IMMUTABLE and I believe the error message would use such as well. What
version are you using (it might be worth considering an upgrade to 7.4
when it comes out)