Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X0akT-0003BZ-AP for pgsql-bugs@arkaria.postgresql.org; Fri, 27 Jun 2014 18:19:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X0akS-0003Yy-7Z for pgsql-bugs@arkaria.postgresql.org; Fri, 27 Jun 2014 18:19:44 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X0akR-0003Ys-Eh for pgsql-bugs@postgresql.org; Fri, 27 Jun 2014 18:19:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X0akO-0004Tv-9K for pgsql-bugs@postgresql.org; Fri, 27 Jun 2014 18:19:41 +0000 Received: from pro.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s5RIJaO1022433; Fri, 27 Jun 2014 14:19:37 -0400 From: Tom Lane To: lunda@bitmessage.ch cc: pgsql-bugs@postgresql.org Subject: Re: BUG #10785: error if using x>n AND x References: <20140627135405.15694.38636@wrigleys.postgresql.org> Comments: In-reply-to lunda@bitmessage.ch message dated "Fri, 27 Jun 2014 13:54:05 -0000" Date: Fri, 27 Jun 2014 11:19:46 -0700 Message-ID: <28206.1403893186@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org lunda@bitmessage.ch writes: > DOES NOT WORK (ERROR: invalid input syntax for integer: "tower"): > create index planet_osm_point_city_50k_index on planet_osm_point using > gist(way) where > (((capital IS NULL) OR (capital <> 'yes'::text)) AND > (place = ANY ('{city,town}'::text[])) AND > (population IS NOT NULL) AND (population <> ''::text) AND > (regexp_replace(population, '[., ]', '')::int >= 50000) AND > (regexp_replace(population, '[., ]', '')::int < 100000)); You haven't provided nearly enough information for anyone else to reproduce this problem, but I suppose that the error occurs because you have some non-numeric entries in "population". You'll need to code those tests more defensively, perhaps with a CASE that checks that the string is numeric before trying to cast it. Probably the "working" examples accidentally fail to fail because of the order the planner chooses to apply the qual expressions in. It's not a bug that they're not necessarily done left-to-right; see http://www.postgresql.org/docs/9.3/static/sql-expressions.html#SYNTAX-EXPRESS-EVAL regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs