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

From Mario Weilguni
Subject Implementing an operator in C?
Date
Msg-id 95j9ul$2e6q$1@news.tht.net
Whole thread Raw
Responses Re: Implementing an operator in C?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Sorry if I'm posting to the wrong list, if so, please could you point me to 
the correct list? Thanks!

I'm trying to work with Access and Postgres as backend, but I often get 
errors like "unable to find an operator '=' for numeric and float" and 
such. Now I've implemented an operator in PLPGSQL, but I'm not very 
satisfied with the results (performance-wise). I've tried it in C, but 
failed:

I've written a function like this one (I tried to copy the behaviour a 
compersion function in utils/adt/numeric.c):

Datum
numeric_float8_eq(PG_FUNCTION_ARGS)
{       Numeric         num1 = PG_GETARG_NUMERIC(0);       float8          num2 = PG_GETARG_FLOAT8(1);       bool
    result;
 
       if (NUMERIC_IS_NAN(num1) || isnan(num2))               result = false;       else       {         float8 num3 =
numeric_float8(num1);        if(num2 == num3)           result = true;         else           result = false;       }
 
       PG_FREE_IF_COPY(num1, 0);
       PG_RETURN_BOOL(result);
}

Unfortunatly, this fails. The backend dies with a SIGNAL11 when calling 
this functions. Are there any examples how to implement such operators (any 
example might help)?

Thanks!

Best regards,       Mario Weilguni



pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: Like vs '=' bug with indexing
Next
From: Peter Mount
Date:
Subject: Re: TODO list: Allow Java server-side programming