From: Dimitri Fontaine <dfontaine@hi-media.com>
To: Julius Tuskenis <julius@nsoft.lt>
Cc: pgsql-admin@postgresql.org
Subject: Re: operator does not exist
Date: Fri, 19 Mar 2010 10:16:01 +0100
Message-ID: <87d3z0wu26.fsf@hi-media-techno.com> (raw)
In-Reply-To: <4BA32695.1090402@nsoft.lt>
References: <4BA32695.1090402@nsoft.lt>
Julius Tuskenis <julius@nsoft.lt> writes:
> select '1' = 1 results in true
This is a undecorated literal, which PostgreSQL will cast as integer
when it discovers that's what makes sense.
> while select sum(msg_price) from messages where msg_itemid = 0 results in
> error:
> ERROR: operator does not exist: character varying = integer
> LINE 1: select sum(msg_price) from messages where msg_itemid = 0
Here, msg_itemid is known to be a varchar, and 0 is a numeric literal,
which is in the range of an integer, so the type is resolved as an
integer. Now the = operator does not exist for varchar, integer.
> I will add the operator ant then we'll fix the queries, but is the first
> example ok? Should it not raise error ?
Not as written. Try to decorate the literal to force PostgreSQL into
considering it of the type you have in mind:
SELECT text '1' = 1;
Or even do a cast, this way:
SELECT '1'::text = 1;
Regards,
--
dim
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 using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: dfontaine@hi-media.com, julius@nsoft.lt
Subject: Re: operator does not exist
In-Reply-To: <87d3z0wu26.fsf@hi-media-techno.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