Re: Implementing an operator in C? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Implementing an operator in C?
Date
Msg-id 6744.981313926@sss.pgh.pa.us
Whole thread Raw
In response to Implementing an operator in C?  (Mario Weilguni <mweilguni@sime.com>)
Responses Re: Implementing an operator in C?
List pgsql-hackers
Mario Weilguni <mweilguni@sime.com> writes:
>           float8 num3 = numeric_float8(num1);

That won't work in the brave new world of 7.1 :-(.  You need to do
something like
float8 num3 = DatumGetFloat8(DirectFunctionCall1(numeric_float8,                NumericGetDatum(num1)));

Ugly, I know ... but we have to be rigidly careful about converting
values to Datum and back in order to avoid portability problems.

A decent C compiler should've warned about type mismatches in your call,
BTW.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Like vs '=' bug with indexing
Next
From: Bruce Momjian
Date:
Subject: Re: Re: [PATCHES] A Sparc/Linux patch (for 7.1), and a Linux rc.d/init.d script....