BUG #3661: Missing equality comparator: string = integer

Lists: pgsql-bugs
From: "David Bachmann" <david(dot)bachmann(at)ersystems(dot)ch>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #3661: Missing equality comparator: string = integer
Date: 2007-10-09 15:49:28
Message-ID: 200710091549.l99FnSFu028067@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 3661
Logged by: David Bachmann
Email address: david(dot)bachmann(at)ersystems(dot)ch
PostgreSQL version: 8.3-beta1
Operating system: Windows XP
Description: Missing equality comparator: string = integer
Details:

This does not function any more under PG 8.3-beta1:

select '5'::varchar = 5;
ERROR: operator does not exist: character varying = integer

select '5'::char = 5;
ERROR: operator does not exist: character = integer

Note that this still works:
select '5' = 5;


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-bugs(at)postgresql(dot)org
Cc: "David Bachmann" <david(dot)bachmann(at)ersystems(dot)ch>
Subject: Re: BUG #3661: Missing equality comparator: string = integer
Date: 2007-10-09 17:04:49
Message-ID: 200710091904.49876.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Am Dienstag, 9. Oktober 2007 schrieb David Bachmann:
> This does not function any more under PG 8.3-beta1:
>
> select '5'::varchar = 5;
> ERROR: operator does not exist: character varying = integer

That is intentional. Fix your application by inserting appropriate explicit
casts.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/


From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "David Bachmann" <david(dot)bachmann(at)ersystems(dot)ch>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3661: Missing equality comparator: string = integer
Date: 2007-10-09 17:15:29
Message-ID: 162867790710091015u59786190j4a69aa3b1401a7ba@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

>
> This does not function any more under PG 8.3-beta1:
>
> select '5'::varchar = 5;
> ERROR: operator does not exist: character varying = integer
>
> select '5'::char = 5;
> ERROR: operator does not exist: character = integer

you cannot compare any character type and numeric type. If you wont to
do, you have to cast to text or use function to_char or to_numeric.

>
>
> Note that this still works:
> select '5' = 5;
>

It is integer = integer. Value in apostrophes doesn't mean 100% char
or varchar in Postgres. Pg detects unknown type (in apostrophes)
accordance with know type (integer)

try:
postgres=# select '5.0'=5;
ERROR: invalid input syntax for integer: "5a"

postgres=# select '5.0'=5;
ERROR: invalid input syntax for integer: "5.0"
postgres=# select '5.0'=5.0;
?column?
----------
t
(1 row)

> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>