Implementing an operator in C?

From: Mario Weilguni <mweilguni(at)sime(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Implementing an operator in C?
Date: 2001-02-04 10:12:35
Message-ID: 95j9ul$2e6q$1@news.tht.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Mount 2001-02-04 11:49:27 Re: TODO list: Allow Java server-side programming
Previous Message Hannu Krosing 2001-02-04 09:26:48 Re: Like vs '=' bug with indexing