Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id D7A9B632A3B for ; Fri, 19 Mar 2010 06:21:13 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 23730-07 for ; Fri, 19 Mar 2010 09:20:58 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp1.hi-media-techno.com (smtp1.hi-media-techno.com [195.158.241.85]) by mail.postgresql.org (Postfix) with ESMTP id 454176330C7 for ; Fri, 19 Mar 2010 06:21:03 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by smtp1.hi-media-techno.com (Postfix) with ESMTP id BCC2D93B92; Fri, 19 Mar 2010 10:21:01 +0100 (CET) Received: from smtp1.hi-media-techno.com ([127.0.0.1]) by localhost (smtp1.backbone.hi-media-techno.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xH-Kf6YpqLBZ; Fri, 19 Mar 2010 10:21:01 +0100 (CET) Received: from mail1.hi-media-techno.com (unknown [192.168.27.17]) by smtp1.hi-media-techno.com (Postfix) with ESMTP id 7303293B6C; Fri, 19 Mar 2010 10:21:01 +0100 (CET) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail1.hi-media-techno.com (Postfix) with ESMTP id 3C1DE91A47; Fri, 19 Mar 2010 10:21:01 +0100 (CET) X-Virus-Scanned: amavisd-new at mail1.hi-media-techno.com Received: from mail1.hi-media-techno.com ([127.0.0.1]) by localhost (mail1.hi-media-techno.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Iz5OXAWoDlme; Fri, 19 Mar 2010 10:21:01 +0100 (CET) Received: from dim (unknown [83.167.62.196]) by mail1.hi-media-techno.com (Postfix) with ESMTPSA id 08DAE2B43E; Fri, 19 Mar 2010 10:21:01 +0100 (CET) Received: by dim (Postfix, from userid 1000) id 10D1213F5F; Fri, 19 Mar 2010 10:16:01 +0100 (CET) From: Dimitri Fontaine To: Julius Tuskenis Cc: pgsql-admin@postgresql.org Subject: Re: operator does not exist Organization: Hi-Media References: <4BA32695.1090402@nsoft.lt> User-Mail-Address: dfontaine@hi-media.com Date: Fri, 19 Mar 2010 10:16:01 +0100 In-Reply-To: <4BA32695.1090402@nsoft.lt> (Julius Tuskenis's message of "Fri, 19 Mar 2010 09:24:05 +0200") Message-ID: <87d3z0wu26.fsf@hi-media-techno.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.473 tagged_above=-10 required=5 tests=AWL=0.126, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/135 X-Sequence-Number: 33934 Julius Tuskenis 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