pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: jose soares <jose@sferacarta.com>
To: Nikolay Mijaylov <nmmm@nmmm.nu>
Cc: pgsql-general <pgsql-general@postgresql.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Fw: Whats happen here?
Date: Tue, 07 Dec 1999 15:44:12 +0100
Message-ID: <384D1D3B.2BF89CBB@sferacarta.com> (raw)
References: <002001bf3ffd$17309980$ce2a18c3@skillbrokers.bg>

Try this:

drop function char_eq_varchar(bpchar,varchar);
create function char_eq_varchar(bpchar,varchar) returns bool as
'
declare
 i2 text;
 i1 text;
begin
 i1:= trim($1);
 i2:= $2;
 if i1 = i2 then
 return TRUE;
 else
 return FALSE;
 end if;
end;
' language 'plpgsql';


drop operator = (bpchar,"varchar");
create operator = (
        leftarg=bpchar,
        rightarg="varchar",
        procedure=char_eq_varchar,
        commutator='=',
        negator='<>',
        restrict=eqsel,
        join=eqjoinsel
        );

drop table x;
drop table y;
create table x(a char(20));
create table y(a varchar(5));
insert into x values('a');
insert into y values('a');
select * from x, y where x.a = y.a;
a                   |a
--------------------+-
a                   |a
(1 row)


Jose'


Nikolay Mijaylov ha scritto:

> > Whats happen here?
> > -------------------------
> >
> > root=> \dt
> >
> > Database    = root
> >  +------------------+----------------------------------+----------+
> >  |  Owner           |             Relation             |   Type   |
> >  +------------------+----------------------------------+----------+
> >  | root             | x                                | table    |
> >  | root             | y                                | table    |
> >  +------------------+----------------------------------+----------+
> > root=> \d x
> >
> > Table    = x
> >
> +----------------------------------+----------------------------------+-----
> > --+
> > |              Field               |              Type                |
> > Length|
> >
> +----------------------------------+----------------------------------+-----
> > --+
> > | a                                | char()                           |
> > 20 |
> >
> +----------------------------------+----------------------------------+-----
> > --+
> > root=> \d y
> >
> > Table    = y
> >
> +----------------------------------+----------------------------------+-----
> > --+
> > |              Field               |              Type                |
> > Length|
> >
> +----------------------------------+----------------------------------+-----
> > --+
> > | a                                | varchar()                        |
> > 5 |
> >
> +----------------------------------+----------------------------------+-----
> > --+
> > root=>select * from x a, y b where a.a = b.a;
> > ERROR:  There is more than one possible operator '=' for types 'bpchar'
> and
> > 'varchar'
> >         You will have to retype this query using an explicit cast
> >
> >
> >
> > root=> select * from x a, y b where text(a.a) = text(b.b);
> >ERROR:  There is more than one possible operator '=' for types 'bpchar' and
> 'varchar'
> >        You will have to retype this query using an explicit cast
> >
> > --------------------------------------------------------------
> > The reboots are for hardware upgrades!
> > "http://www.nmmm.nu; <nmmm@nmmm.nu>
> >
> >
>
> ************

view thread (4+ messages)  latest in thread

Message-ID: <384D1D3B.2BF89CBB@sferacarta.com>
Permalink:  ../384D1D3B.2BF89CBB@sferacarta.com/
Also on:    postgresql.org/message-id/384D1D3B.2BF89CBB@sferacarta.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: jose@sferacarta.com, nmmm@nmmm.nu, pgsql-general@postgresql.org
  Subject: Re: [SQL] Fw: Whats happen here?
  In-Reply-To: <384D1D3B.2BF89CBB@sferacarta.com>
  References: <002001bf3ffd$17309980$ce2a18c3@skillbrokers.bg> <384D1D3B.2BF89CBB@sferacarta.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox