Received: from trends.net (root@clio.trends.ca [209.47.148.2]) by hub.org (8.9.1/8.8.8) with ESMTP id KAA01569 for ; Wed, 21 Oct 1998 10:15:09 -0400 (EDT) (envelope-from daveh@insightdist.com) Received: from u1.abs.net (root@u1.abs.net [207.114.0.131]) by trends.net (8.8.8/8.8.8) with ESMTP id KAA23206 for ; Wed, 21 Oct 1998 10:01:40 -0400 (EDT) Received: from insightdist.com (nobody@localhost) by u1.abs.net (8.9.0/8.9.0) with UUCP id JAA03047 for pgsql-interfaces@postgreSQL.org; Wed, 21 Oct 1998 09:59:24 -0400 (EDT) X-Authentication-Warning: u1.abs.net: nobody set sender to insightdist.com!daveh using -f Received: from ceodev by insightdist.com (AIX 3.2/UCB 5.64/4.03) id AA26061; Wed, 21 Oct 1998 08:36:06 -0400 Received: from daveh by ceodev (AIX 4.1/UCB 5.64/4.03) id AA73548; Wed, 21 Oct 1998 08:36:06 -0400 Message-Id: <362DD619.A3AE849A@insightdist.com> Date: Wed, 21 Oct 1998 08:39:53 -0400 From: David Hartwig Organization: Insight Distribution Systems X-Mailer: Mozilla 4.05 [en] (Win95; I) Mime-Version: 1.0 To: "Jose' Soares" Cc: sferac@bo.nettuno.it, pgsql-interfaces Subject: Re: [HACKERS] Re: [INTERFACES] using indexes with the OR clause References: <11661.981020@bo.nettuno.it> <362CAD8D.EAC7CEE8@insightdist.com> <362DBB65.32F0E0E3@sferacarta.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Jose' Soares wrote: > David Hartwig wrote: > > > > In the "Connect Settings" (either global or per data source) add the > > following line: > > SET ksqo TO 'on' > > > > Stands for "Key Set Query Oprimizer". It actually breaked those nasty > > OR's into UNIONS. There will eventually be a radio button for this. > > We have be in a crunch lately at work. > > > Yes, this works well now. > > > Are you using row versioning? If so, you may have to overload an > > operator for > on xid. > > Do you mean < I think, because my log says ERROR: Unable to find an > ordering operator '<' for type xid > Any way. I tried to create the operators =, < and > but I have some > troubles to do this. > > I modified xidint4.c and xidint4.sql, the sources that you sent me some > time ago, as follow: > > ---------------xidint4.c------------- > /* Insight Distribution Systems - System V - Apr 1998i > static char accntnum_c[] = "@(#)accntnum.c 1.1 > /sccs/sql/extend/s.accntnum. > */ > #include /* for sprintf() */ > #include > #include "postgres.h" > #include "utils/palloc.h" > > bool xidint4_eq(int32 arg1, int32 arg2); > bool xidint4_gt(int32 arg1, int32 arg2); > bool xidint4_lt(int32 arg1, int32 arg2); > > bool xidint4_eq(int32 arg1, int32 arg2) > { > return (arg1 == arg2); > } > > bool xidint4_gt(int32 arg1, int32 arg2) > { > return (arg1 > arg2); > } > > bool xidint4_lt(int32 arg1, int32 arg2) > { > return (arg1 < arg2); > } > > --------------------xidint4.sql--------------------------- > create function xidint4_eq(xid,int4) > returns bool > as '/usr/local/pgsql/lib/contrib/xidint4.so' > language 'c'; > > create function xidint4_gt(xid,int4) > returns bool > as '/usr/local/pgsql/lib/contrib/xidint4.so' > language 'c'; > > create function xidint4_lt(xid,int4) > returns bool > as '/usr/local/pgsql/lib/contrib/xidint4.so' > language 'c'; > > create operator = ( > leftarg=xid, > rightarg=int4, > procedure=xidint4_eq, > commutator='=', > negator='<>', > restrict=eqsel, > join=eqjoinsel > ); > > create operator < ( > leftarg=xid, > rightarg=int4, > procedure=xidint4_lt, > commutator='<', > negator='>', > restrict=intltsel, > join=intltjoinsel > ); > > create operator > ( > leftarg=xid, > rightarg=int4, > procedure=xidint4_gt, > commutator='>', > negator='<', > restrict=intgtsel, > join=intgtjoinsel > ); > > This script gives me this message for every operator it creates, > NOTICE: buffer leak [392] detected in BufferPoolCheckLeak() > CREATE > > but at end seems that it works, I can query a table as: > > select xmin from attivita where xmin = 92017; > select xmin from attivita where xmin > 92016; > select xmin from attivita where xmin < 92018; > > But psqlodbc.log has still the message: > > ERROR: Unable to find an ordering operator '<' for type xid > > Thanks David for your help. > > Jose' Hmmm... Sound a bit strange. Lets keep an eye on it. Anyway, I have a minimalist patch which is confined to SQL which accomplishes the same thing. I just overload the int4 functions. Works well. If you use this patch, be sure to DROP the other XID operators and functions that you just created to remove any ambiguity. ++++++++++++++++++++++++++++++++++++++ create function int4eq(xid,int4) returns bool as '' language 'internal'; create operator = ( leftarg=xid, rightarg=int4, procedure=int4eq, commutator='=', negator='<>', restrict=eqsel, join=eqjoinsel ); create function int4lt(xid,xid) returns bool as '' language 'internal'; create function int4lt(xid,xid) returns bool as '' language 'internal'; create operator < ( leftarg=xid, rightarg=xid, procedure=int4lt, commutator='=', negator='<>', restrict=eqsel, join=eqjoinsel );