pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: digoal@126.com
To: pgsql-bugs@postgresql.org
Subject: BUG #13449: Auto type cast (int -> numeric) non-reasonable, will case performance problem
Date: Wed, 17 Jun 2015 02:17:07 +0000
Message-ID: <20150617021707.2740.62807@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      13449
Logged by:          digoal
Email address:      digoal@126.com
PostgreSQL version: 9.4.4
Operating system:   CentOS 6.x x64
Description:        

When i use an big digital, it auto convert to numeric. and there is no
int&numeric operator, so left opr auto convert to numeric also.
for exp:
postgres=# create table t3(id int);
CREATE TABLE
postgres=# insert into t3 select generate_series(1,10000000);
INSERT 0 10000000
postgres=# create index idx_t3_id on t3(id);
CREATE INDEX
postgres=# explain analyze select * from t3 where
id>999999999999999999999999999999999;
                                                             QUERY PLAN     
                                                       
------------------------------------------------------------------------------------------------------------------------------------
 Index Only Scan using idx_t3_id on t3  (cost=0.43..238213.43 rows=3333333
width=4) (actual time=4052.914..4052.914 rows=0 loops=1)
   Filter: ((id)::numeric > '999999999999999999999999999999999'::numeric)
   Rows Removed by Filter: 10000000
   Heap Fetches: 10000000
 Planning time: 0.283 ms
 Execution time: 4052.944 ms
(6 rows)

postgres=# explain analyze select * from t3 where
id=999999999999999999999999999999999;
                                                            QUERY PLAN      
                                                     
----------------------------------------------------------------------------------------------------------------------------------
 Index Only Scan using idx_t3_id on t3  (cost=0.43..238213.43 rows=50000
width=4) (actual time=3907.391..3907.391 rows=0 loops=1)
   Filter: ((id)::numeric = '999999999999999999999999999999999'::numeric)
   Rows Removed by Filter: 10000000
   Heap Fetches: 10000000
 Planning time: 0.103 ms
 Execution time: 3907.421 ms
(6 rows)

I think ,this case, PostgreSQL should convert
999999999999999999999999999999999 to the same type with column id's type
int. and raise error. 

there is some problem, user can use this to SQL injection attack or other
things, Oops, Application has ability to filter the overflow digital, but i
think PostgreSQL also has responsibility to prevent overflow occure.


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



view thread (2+ messages)  latest in thread

Message-ID: <20150617021707.2740.62807@wrigleys.postgresql.org>
Permalink:  ../20150617021707.2740.62807@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20150617021707.2740.62807@wrigleys.postgresql.org

 · 

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: digoal@126.com
  Subject: Re: BUG #13449: Auto type cast (int -> numeric) non-reasonable, will case performance problem
  In-Reply-To: <20150617021707.2740.62807@wrigleys.postgresql.org>
  References: <20150617021707.2740.62807@wrigleys.postgresql.org>

* 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