From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Bill Studenmund <wrstuden(at)netbsd(dot)org> |
Cc: | Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>, Teodor Sigaev <teodor(at)stack(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Proposed new create command, CREATE OPERATOR CLASS |
Date: | 2002-03-06 21:58:43 |
Message-ID: | 200203062158.g26Lwho26042@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Bill, is there a patch that is ready for application?
---------------------------------------------------------------------------
Bill Studenmund wrote:
> On Mon, 29 Oct 2001, Oleg Bartunov wrote:
>
> > On Thu, 25 Oct 2001, Teodor Sigaev wrote:
> >
> > > >>Wait a second, how can you do that? Doesn't that violate
> > > >>pg_amop_opc_strategy_index ?
> > > >
> > > > This is evidently a bug in the script. Oleg?
> > >
> > > Make me right if I mistake.
>
> Don't add @@ to pg_amop.
>
> > > When we was developing operator @@, I saw that postgres don't use index in
> > > select if operation has not commutator. But operator with different types in
> > > argument can't be commutator with itself. So I maked operator ~~ only for
> > > postgres can use index access for operator @@. There is no any difficulties to
> > > adding index support for operator ~~. The same things is with contrib/tsearch
> > > module.
> > >
> > > But I think that there is not any other necessity in presence ~~.
>
> ?? An operator with different times in the arguements most certainly can
> be a commutator with itself.
>
> Try:
>
> select oid, oprname as "n", oprkind as "k", oprleft, oprright, oprresult,
> oprcom, oprcode from pg_operator where oprleft <> oprright and oprname =
> '+';
>
> and look at the results. There are a number of pairs of same-name
> commutators: 552 & 553 add int2 to int4, 688 & 692 add int4 to int8, and
> so on.
>
> Also, I was able to do this:
>
> testing=# CREATE OPERATOR @@ (
> testing(# LEFTARG = _int4, RIGHTARG = query_int, PROCEDURE = boolop,
> testing(# COMMUTATOR = '@@', RESTRICT = contsel, join = contjoinsel );
> CREATE
> testing=# CREATE OPERATOR @@ (
> testing(# LEFTARG = query_int, RIGHTARG = _int4, PROCEDURE = rboolop,
> testing(# COMMUTATOR = '@@', RESTRICT = contsel, join = contjoinsel );
> CREATE
> testing=#
>
> > Tom,
> >
> > this is interesting question - do we really need commutator to get
> > postgres to use index. This is the only reason we created ~~ operator.
>
> Please note: my concern is not with the ~~ operator, it's with trying to
> insert that operator into pg_amop. Well, with trying to insert both the @@
> and ~~ operators in as strategy (amopstrategy) 20. amopclaid and
> amopstrategy are part of a unique index for pg_amop. So you *can't* add
> two operators in the same opclass as the same sequence number.
>
> Although, given the above example, I think the ~~ operator should be
> renamed the @@ operator. :-)
>
> I think you do need to have both variants of the operator around. A
> binary, type asymmetric operator without a commutator is less useful. And
> makes lese sense.
>
> Take care,
>
> Bill
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
From | Date | Subject | |
---|---|---|---|
Next Message | Roque Bonilla | 2002-03-06 22:09:51 | Re: LRU and full table scans |
Previous Message | Trond Eivind =?iso-8859-1?q?Glomsr=F8d?= | 2002-03-06 21:45:34 | Re: Mandrake RPMs rebuilt |