Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X0cK2-0008ND-Dl for pgsql-bugs@arkaria.postgresql.org; Fri, 27 Jun 2014 20:00:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X0cK0-0004dI-RR for pgsql-bugs@arkaria.postgresql.org; Fri, 27 Jun 2014 20:00:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X0bo2-0003l9-50 for pgsql-bugs@postgresql.org; Fri, 27 Jun 2014 19:27:30 +0000 Received: from mail.bitmessage.ch ([146.228.112.252]) by magus.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X0bnx-0002Ax-Vx for pgsql-bugs@postgresql.org; Fri, 27 Jun 2014 19:27:29 +0000 Received: from BITMESSAGE (BITMESSAGE [127.0.0.1]) by mail.bitmessage.ch ; Fri, 27 Jun 2014 21:26:05 +0200 Mime-Version: 1.0 Date: Fri, 27 Jun 2014 19:26:03 +0000 Content-Type: multipart/alternative; boundary="----=_Part_543_836853027.1403897163" Message-ID: X-Mailer: AfterLogic webmail client From: BM-2cUR7NEMQCynXF7KDxiMP1J9CMpmKA5Bd5@bitmessage.ch Subject: Re: BUG #10785: error if using x>n AND x Cc: lunda@bitmessage.ch, pgsql-bugs@postgresql.org In-Reply-To: <28206.1403893186@sss.pgh.pa.us> References: <20140627135405.15694.38636@wrigleys.postgresql.org> <28206.1403893186@sss.pgh.pa.us> X-Priority: 3 (Normal) X-Pg-Spam-Score: -1.1 (-) 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 ------=_Part_543_836853027.1403897163 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: Quoted-Printable Yes, you're right. It is my fault. The "population" column contains non-n= umeric data.=0AThanks for reply.=0AOn Fri, Jun 27, 2014 at 20:18, "Tom La= ne" wrote:lunda@bitmessage.ch (mailto:lunda@bitmessage.ch) writes:=0ADOE= S NOT WORK (ERROR: invalid input syntax for integer: "tower"):=0Acreate = index planet_osm_point_city_50k_index on planet_osm_point using=0Agist(wa= y) where =0A(((capital IS NULL) OR (capital 'yes'::text)) AND =0A(place = =3D ANY ('{city,town}'::text[])) AND =0A(population IS NOT NULL) AND (pop= ulation ''::text) AND =0A(regexp_replace(population, '[., ]', '')::int >= =3D 50000) AND =0A(regexp_replace(population, '[., ]', '')::int < 100000)= );=0A=0AYou haven't provided nearly enough information for anyone else to= =0Areproduce this problem, but I suppose that the error occurs because=0A= you have some non-numeric entries in "population". You'll need to=0Acode= those tests more defensively, perhaps with a CASE that checks=0Athat the= string is numeric before trying to cast it.=0A=0AProbably the "working" = examples accidentally fail to fail because=0Aof the order the planner cho= oses to apply the qual expressions in.=0AIt's not a bug that they're not = necessarily done left-to-right; see=0Ahttp://www.postgresql.org/docs/9.3/= static/sql-expressions.html#SYNTAX-EXPRESS-EVAL (http://www.postgresql.or= g/docs/9.3/static/sql-expressions.html#SYNTAX-EXPRESS-EVAL)=0A=0A = regards, tom lane ------=_Part_543_836853027.1403897163 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: Quoted-Printable
Yes, you're right. It = is my fault. The "population" column contains non-numeric data.
Thanks= for reply.



On Fri, Jun 27, 2014 at 20:18, "Tom Lane" <= tgl@sss.pgh.pa.us> wrote:
lunda@bitmessage.ch writes:
DO= ES NOT WORK (ERROR:=C2=A0=C2=A0invalid input syntax for integer: "tower")= :
create index planet_osm_point_city_50k_index on planet_osm_point usi= ng
gist(way) where
(((capital IS NULL) OR (capital <> 'yes':= :text)) AND
(place =3D ANY ('{city,town}'::text[])) AND
(populati= on IS NOT NULL) AND (population <> ''::text) AND
(regexp_replac= e(population, '[., ]', '')::int >=3D 50000) AND
(regexp_replace(po= pulation, '[., ]', '')::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 no= n-numeric entries in "population".=C2=A0=C2=A0You'll need to
code thos= e tests more defensively, perhaps with a CASE that checks
that the str= ing is numeric before trying to cast it.

Probably the "working" ex= amples accidentally fail to fail because
of the order the planner choo= ses 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#SYNT= AX-EXPRESS-EVAL

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0regards, tom lane
------=_Part_543_836853027.1403897163--