From: | Edoardo Panfili <edoardo(at)aspix(dot)it> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: immutable functions and enumerate type casts in indexes |
Date: | 2008-09-03 15:23:39 |
Message-ID: | 48BEABFB.9030807@aspix.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Tom Lane ha scritto:
> Edoardo Panfili <edoardo(at)aspix(dot)it> writes:
>> labelDatum = DirectFunctionCall1(enum_out,datumIbrido);
>> label = (char *) DatumGetPointer(labelDatum);
>
> Just FYI, preferred style for the second line would be
>
> label = DatumGetCString(labelDatum);
>
> Nearly all standard data types have DatumGetFoo and FooGetDatum
> macros to hide the conversion details (even if it's only a cast).
the clean version:
--------------------------------------------------------------
#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 = DatumGetCString(labelDatum);
if(strcmp(label,("label_constant"))==0){
...
}
...
}
--------------------------------------------------------------
thank you again!
Edoardo
From | Date | Subject | |
---|---|---|---|
Next Message | SCassidy | 2008-09-03 15:36:51 | Re: Oracle and Postgresql |
Previous Message | Tom Lane | 2008-09-03 15:17:51 | Re: vacuum analyze hurts performance |