pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #10785: error if using x>n AND x<m in where clause, BETWEEN n AND m works as supposed
3+ messages / 3 participants
[nested] [flat]

* BUG #10785: error if using x>n AND x<m in where clause, BETWEEN n AND m works as supposed
@ 2014-06-27 13:54  lunda@bitmessage.ch
  0 siblings, 1 reply; 3+ messages in thread

From: lunda@bitmessage.ch @ 2014-06-27 13:54 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      10785
Logged by:          j.l.
Email address:      lunda@bitmessage.ch
PostgreSQL version: 9.3.4
Operating system:   Linux 64bit (ubuntu 12.04)
Description:        

DOES WORK:
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));

DOES WORK:
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 between 50000 and 99999));

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));


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #10785: error if using x>n AND x<m in where clause, BETWEEN n AND m works as supposed
@ 2014-06-27 18:19  Tom Lane <tgl@sss.pgh.pa.us>
  parent: lunda@bitmessage.ch
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2014-06-27 18:19 UTC (permalink / raw)
  To: lunda@bitmessage.ch; +Cc: pgsql-bugs

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #10785: error if using x>n AND x<m in where clause, BETWEEN n AND m works as supposed
@ 2014-06-27 19:26  BM-2cUR7NEMQCynXF7KDxiMP1J9CMpmKA5Bd5@bitmessage.ch
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: BM-2cUR7NEMQCynXF7KDxiMP1J9CMpmKA5Bd5@bitmessage.ch @ 2014-06-27 19:26 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: lunda@bitmessage.ch; pgsql-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

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2014-06-27 19:26 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-06-27 13:54 BUG #10785: error if using x>n AND x<m in where clause, BETWEEN n AND m works as supposed lunda@bitmessage.ch
2014-06-27 18:19 ` Tom Lane <tgl@sss.pgh.pa.us>
2014-06-27 19:26   ` BM-2cUR7NEMQCynXF7KDxiMP1J9CMpmKA5Bd5@bitmessage.ch

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