Thread: Overwriting Operator for numeric and float8 fails

Overwriting Operator for numeric and float8 fails

From
"Johann Zuschlag"
Date:
Hi,

My application does queries like this:

SELECT t6.* FROM RECHNUNG  t6 WHERE t6.bruttosumm = 00000034.70 ORDER BY t6.nummer DESC

I get the following error: Unable to identify an operator '=' for types 'numeric' and 'float8'...
and of course the same for the operator '<>'.
Ok, ok quotes missing.

Before I just let the ODBC-driver patch the quotes. Not so smart.
Now I tried the smarter way by overwriting the operator:

create function numeric_eq(numeric,float8)
returns bool
as ''
language 'internal';

create operator = (
leftarg=numeric,
rightarg=float8,
procedure=numeric_eq,
commutator='=',
negator='<>',
restrict=eqsel,
join=eqjoinsel
);

The Problem is: It doesn't work and the backend process crashes and get's restarted.
I tried it with 7.03 and I guess 7.1.3 behaves the same.
What am I doing wrong? Can somebody give me a hint?

Thanks in advance



Johann Zuschlag
zuschlag@online.de



Re: Overwriting Operator for numeric and float8 fails

From
Andrew Gould
Date:
I think you have a syntax error in the SELECT
statement.  What is RECHNUNG? The only table reference
that I see is t6.

If RECHNUNG is the database, connect to the database
and try:

Select * from t6 where bruttosum = 00000034.70
order by nummer desc;

Best of luck,

Andrew Gould

--- Johann Zuschlag <zuschlag@online.de> wrote:
> Hi,
>
> My application does queries like this:
>
> SELECT t6.* FROM RECHNUNG  t6 WHERE t6.bruttosumm =
> 00000034.70 ORDER BY t6.nummer DESC
>
> I get the following error: Unable to identify an
> operator '=' for types 'numeric' and 'float8'...
> and of course the same for the operator '<>'.
> Ok, ok quotes missing.
>
> Before I just let the ODBC-driver patch the quotes.
> Not so smart.
> Now I tried the smarter way by overwriting the
> operator:
>
> create function numeric_eq(numeric,float8)
> returns bool
> as ''
> language 'internal';
>
> create operator = (
> leftarg=numeric,
> rightarg=float8,
> procedure=numeric_eq,
> commutator='=',
> negator='<>',
> restrict=eqsel,
> join=eqjoinsel
> );
>
> The Problem is: It doesn't work and the backend
> process crashes and get's restarted.
> I tried it with 7.03 and I guess 7.1.3 behaves the
> same.
> What am I doing wrong? Can somebody give me a hint?
>
> Thanks in advance
>
>
>
> Johann Zuschlag
> zuschlag@online.de
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the
> unregister command
>     (send "unregister YourEmailAddressHere" to
majordomo@postgresql.org)


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Re: Overwriting Operator for numeric and float8 fails

From
"Johann Zuschlag"
Date:
On Sun, 19 Aug 2001 10:23:39 +0200, Johann Zuschlag wrote:
>I get the following error: Unable to identify an operator '=' for types 'numeric' and 'float8'...
<snip>
>create function numeric_eq(numeric,float8)
>returns bool
>as ''
>language 'internal';
>
>create operator = (
>leftarg=numeric,
>rightarg=float8,
>procedure=numeric_eq,
>commutator='=',
>negator='<>',
>restrict=eqsel,
>join=eqjoinsel
>);
>
>The Problem is: It doesn't work and the backend process crashes and get's restarted.
>I tried it with 7.03 and I guess 7.1.3 behaves the same.
>What am I doing wrong? Can somebody give me a hint?
>
I appreciate your help, but I can't change the queries
of my (commercial) application. So first thing I did, was
doing the changes in the ODBC driver. But still, the
above stated overwriting should work one way or
other. Any ideas how to do it correctly?

Johann


Johann Zuschlag
zuschlag@online.de