pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: BM-2cUR7NEMQCynXF7KDxiMP1J9CMpmKA5Bd5@bitmessage.ch
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: lunda@bitmessage.ch
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #10785: error if using x>n AND x<m in where clause, BETWEEN n AND m works as supposed
Date: Fri, 27 Jun 2014 19:26:03 +0000
Message-ID: <cf66d059753444c7ec4b00295dd8b0b9@bitmessage.ch> (raw)
In-Reply-To: <28206.1403893186@sss.pgh.pa.us>
References: <20140627135405.15694.38636@wrigleys.postgresql.org>
	<28206.1403893186@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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"  wrote:lunda@bitmessage.ch (mailto: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 (http://www.postgresql.org/docs/9.3/static/sql-expressions.html#SYNTAX-EXPRESS-EVAL)

         regards, tom lane

view thread (3+ messages)

Message-ID: <cf66d059753444c7ec4b00295dd8b0b9@bitmessage.ch>
Permalink:  ../cf66d059753444c7ec4b00295dd8b0b9@bitmessage.ch/
Also on:    postgresql.org/message-id/cf66d059753444c7ec4b00295dd8b0b9@bitmessage.ch

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: BM-2cUR7NEMQCynXF7KDxiMP1J9CMpmKA5Bd5@bitmessage.ch, tgl@sss.pgh.pa.us, lunda@bitmessage.ch
  Subject: Re: BUG #10785: error if using x>n AND x<m in where clause, BETWEEN n AND m works as supposed
  In-Reply-To: <cf66d059753444c7ec4b00295dd8b0b9@bitmessage.ch>
  References: <20140627135405.15694.38636@wrigleys.postgresql.org> <28206.1403893186@sss.pgh.pa.us> <cf66d059753444c7ec4b00295dd8b0b9@bitmessage.ch>

* 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