From: | Edoardo Panfili <edoardo(at)aspix(dot)it> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Cc: | Martijn van Oosterhout <kleptog(at)svana(dot)org>, tgl(at)sss(dot)pgh(dot)pa(dot)us |
Subject: | Re: immutable functions and enumerate type casts in indexes |
Date: | 2008-09-03 13:42:38 |
Message-ID: | 48BE944E.7030408@aspix.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Martijn van Oosterhout ha scritto:
> On Tue, Sep 02, 2008 at 10:53:03AM +0200, Edoardo Panfili wrote:
>> 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).
>
>
> Look in the fmgr.h header for functions like DirectFunctionCall1 and
> various other ways of calling functions.
>
Now it works! thank you to Martin and Tom.
this is a code fragment:
--------------------------------------------------------------
#include "utils/builtins.h"
PG_FUNCTION_INFO_V1(esterna_nome);
Datum esterna_nome(PG_FUNCTION_ARGS){
Datum datumIbrido = PG_GETARG_DATUM(0);
Datum labelDatum;
char *label;
labelDatum = DirectFunctionCall1(enum_out,datumIbrido);
label = (char *) DatumGetPointer(labelDatum);
if(strcmp(label,("label_constant"))==0){
...
}
...
}
--------------------------------------------------------------
I don't know why but I need <<#include "utils/builtins.h">>
The line "label = (char *) DatumGetPointer(labelDatum);" is essential to
use the information in strcmp() if I use directly labelDatum it does not
works (but it works inside a sprintf(buffer,"%s",labelDatum)).
thank you again
Edoardo
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2008-09-03 14:53:28 | Re: immutable functions and enumerate type casts in indexes |
Previous Message | Asko Oja | 2008-09-03 13:17:54 | Re: Oracle and Postgresql |