Re: Comparing fixed precision to floating (no anwer)

From: Mike Finn <mike(dot)finn(at)tacticalExecutive(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Comparing fixed precision to floating (no anwer)
Date: 2001-08-23 15:08:39
Message-ID: 9m36cn$2lel$1@news.tht.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

Johann Zuschlag wrote:

> I have the same problem but nobody seems to understand
> that you can't always change the query like in my case,

I understand :-).

My problem occurs for pretty much the same reason, and the suggestion I put
forth on the interfaces.java list is that either the JDBC driver should
understand that an explicit cast is required when substituting the constant
values (much like the way it understands strings and quotes), or that the
back-end should have a commutable =(numeric, float8).

Your routine is not working becase you have no body in your function.

The HACK below does work. I say HACK because
a) this routine should really should be in C
as it will executed billions of times when
used in where clauses (but I am not a "C" programmer)
b) I don't really understand the effects/implications
of the commutator, negator, restrict, and join parameters
(I simply copied them from your example, and the docs
were a bit beyond me)

Maybe someone listening with a bit more pg savvy can help us out further.

P.S. IMHO there should also be "standard" commutable operators for
=(numeric, int8)
=(numeric, int4)
etc...

========================================
Tried on pg7.1, Linux

create function numeric_eq(numeric,float8) returns bool as '
select $1 = $2::numeric;
' language 'sql';

drop operator = (numeric, float8);

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

=============================
Mike Finn
Tactical Executive Systems
mike(dot)finn(at)tacticalExecutive(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mike Castle 2001-08-23 15:11:29 Re: SELECT FOR UPDATE
Previous Message Jeff Eckermann 2001-08-23 14:59:01 Re: problems transfering databases

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2001-08-23 15:25:33 RE: Re: Couple of patches for jdbc driver
Previous Message Bruce Momjian 2001-08-23 14:46:18 Re: Re: Couple of patches for jdbc driver