| From: | Edoardo Panfili <edoardo(at)aspix(dot)it> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: immutable functions and enumerate type casts in indexes |
| Date: | 2008-09-02 08:53:03 |
| Message-ID: | 48BCFEEF.4010406@aspix.it |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Tom Lane ha scritto:
> Edoardo Panfili <edoardo(at)aspix(dot)it> writes:
>> my enumerated type is (this is a subset)
>> CREATE TYPE hibridation AS ENUM('none','genus','specie');
>
>> function declaration
>> CREATE FUNCTION ename(text,boolean,text,text RETURNS text AS
>> 'funzioniGDB.so' LANGUAGE C IMMUTABLE;
>
>> index creation (the type of ibrido is hibridation)
>> CREATE INDEX i_specie_nome_specie ON specie
>> (esterna_nome(ibrido::text,proParte,genere,specie));
>
>> the result is
>> ERROR: functions in index expression must be marked IMMUTABLE
>
> Now, maybe for your purposes here it's okay to consider it immutable.
> In that case what I'd suggest doing is redefining ename() to take the
> enum directly. You could invoke enum_out within the function if you
> really need a text equivalent.
thank you! this is the right way for me.
Now it works.
But i have a little question about parameters of enum_out.
Datum enum_out(PG_FUNCTION_ARGS);
this is a part of my function
-----------------------------------------------------------
Datum esterna_nome2(PG_FUNCTION_ARGS){
int label;
label = enum_out(fcinfo);
sprintf(debug,"false enum_out: \"%s\" ",unrolled);
elog(LOG, debug);
-----------------------------------------------------------
but it works only because my enum parameter is the first (and using
fcinfo is a little obscure).
I must build a FunctionCallInfo structure (I think) but how?
Edoardo
| From | Date | Subject | |
|---|---|---|---|
| Next Message | tfinneid | 2008-09-02 10:12:02 | plpgsql returning resultset |
| Previous Message | Oleg Bartunov | 2008-09-02 06:15:59 | Re: Text search configuration |