Thread

  1. create operator problem

    Vazsonyi Peter[ke] <neko@kornel.szif.hu> — 1998-04-24T13:42:08Z

    Hello!
    
    I use an external function in postgres and here i try create operator for
    like with regional character support ::
    
    -----< Cut begin
    create function mylike(text,text) returns bool
    as '/home/vip/neko/tudakozo/comp.so' language 'c';
    CREATE
    select mylike('Jeno','Jen'),mylike('aJenO','Jen'),mylike('fJeNof','Jen'),
           mylike('JEnke','Jen');
    mylike|mylike|mylike|mylike
    ------+------+------+------
    t     |t     |t     |t
    (1 row)
    
    select 'f:', mylike('asd','fds');
    ?column?|mylike
    --------+------
    f:      |f
    (1 row)
    
    -- It works
    
    drop operator ~~ (text,text);
    DROP
    create operator ~~ (leftarg=text,rightarg=text,procedure=mylike);
    CREATE
    select 'this will be true'::text ~~ 'true';
    ?column?
    --------
    f
    (1 row)
    -- it seems not ;(
    -----< Cut end
    
    I'm not a realy postgres guru, but whith postgres 6.2 can i use this
    function as operator too. If that was a bug, this letter is a bug report,
    but if it isn't please help me!  The used postgres's vn: 6.3-2, it runs on a
    linux (RH4.2;i386 + updates)
    
    sprintf         ("`-''-/").___..--''"`-._            Error In
    ("%|s",          `6_ 6  )   `-.  (     ).`-.__.`)    Loading Object
    "Petike"         (_Y_.)'  ._   )  `._ `. ``-..-'     line:3
    /* Neko */     _..`--'_..-_/  /--'_.' ,'             Before /*Neko*/
     );           (il),-''  (li),'  ((!.-'	 see: http://lsc.kva.hu
    
    
    
  2. Re: [HACKERS] create operator problem

    Tom Ivar Helbekkmo <tih+mail@hamartun.priv.no> — 1998-04-24T15:43:47Z

    "Vazsonyi Peter[ke]" <neko@kornel.szif.hu> writes:
    
    > drop operator ~~ (text,text);
    > DROP
    > create operator ~~ (leftarg=text,rightarg=text,procedure=mylike);
    > CREATE
    > select 'this will be true'::text ~~ 'true';
    > ?column?
    > --------
    > f
    > (1 row)
    > -- it seems not ;(
    
    I got bitten by this, too.  There's special handling of ~~ hardcoded
    into the parser, which expects that it implements the vanilla flavor
    of likeness testing.  It has to do with enabling the use of indices to
    speed up the matching.  Bottom line: you can't redefine it.
    
    -tih
    -- 
    Popularity is the hallmark of mediocrity.  --Niles Crane, "Frasier"
    
    
  3. Re: [HACKERS] create operator problem

    Bruce Momjian <maillist@candle.pha.pa.us> — 1998-04-25T22:07:31Z

    > 
    > Hello!
    > 
    > I use an external function in postgres and here i try create operator for
    > like with regional character support ::
    > 
    > -----< Cut begin
    > create function mylike(text,text) returns bool
    > as '/home/vip/neko/tudakozo/comp.so' language 'c';
    > CREATE
    > select mylike('Jeno','Jen'),mylike('aJenO','Jen'),mylike('fJeNof','Jen'),
    >        mylike('JEnke','Jen');
    > mylike|mylike|mylike|mylike
    > ------+------+------+------
    > t     |t     |t     |t
    > (1 row)
    > 
    > select 'f:', mylike('asd','fds');
    > ?column?|mylike
    > --------+------
    > f:      |f
    > (1 row)
    > 
    > -- It works
    > 
    > drop operator ~~ (text,text);
    > DROP
    > create operator ~~ (leftarg=text,rightarg=text,procedure=mylike);
    > CREATE
    > select 'this will be true'::text ~~ 'true';
    > ?column?
    > --------
    > f
    > (1 row)
    > -- it seems not ;(
    > -----< Cut end
    > 
    > I'm not a realy postgres guru, but whith postgres 6.2 can i use this
    > function as operator too. If that was a bug, this letter is a bug report,
    > but if it isn't please help me!  The used postgres's vn: 6.3-2, it runs on a
    > linux (RH4.2;i386 + updates)
    
    We overload ~~ to allow indexing of LIKE operations.  Sorry.  I will add
    something to error on redefine of ~~.
    
    -- 
    Bruce Momjian                          |  830 Blythe Avenue
    maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
      +  If your life is a hard drive,     |  (610) 353-9879(w)
      +  Christ can be your backup.        |  (610) 853-3000(h)