diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index de20f102b073d19484065d874b1a403ef2124cb2..897e2c495b3b58db1a999ec8bc8e6a5e6828bdfd 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -191,4 +191,21 @@ execute stmt1 using @arg00; select m from t1; m 1 +deallocate prepare stmt1; +drop table t1; +create table t1 (id int(10) unsigned NOT NULL default '0', +name varchar(64) NOT NULL default '', +PRIMARY KEY (id), UNIQUE KEY `name` (`name`)); +insert into t1 values (1,'1'),(2,'2'),(3,'3'),(4,'4'),(5,'5'),(6,'6'),(7,'7'); +prepare stmt1 from 'select name from t1 where id=? or id=?'; +set @id1=1,@id2=6; +execute stmt1 using @id1, @id2; +name +1 +6 +select name from t1 where id=1 or id=6; +name +1 +6 +deallocate prepare stmt1; drop table t1; diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 5af65242e7b1733e7d85a134b0807b759badabf5..a3232fb15e9047f83e997493ea272aaf8b60b353 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -178,4 +178,19 @@ drop table t1; prepare stmt1 from ' create table t1 (m int) as select ? as m ' ; execute stmt1 using @arg00; select m from t1; +deallocate prepare stmt1; +drop table t1; + +# +# eq() for parameters +# +create table t1 (id int(10) unsigned NOT NULL default '0', + name varchar(64) NOT NULL default '', + PRIMARY KEY (id), UNIQUE KEY `name` (`name`)); +insert into t1 values (1,'1'),(2,'2'),(3,'3'),(4,'4'),(5,'5'),(6,'6'),(7,'7'); +prepare stmt1 from 'select name from t1 where id=? or id=?'; +set @id1=1,@id2=6; +execute stmt1 using @id1, @id2; +select name from t1 where id=1 or id=6; +deallocate prepare stmt1; drop table t1; diff --git a/sql/item.h b/sql/item.h index 235b15c56fc6c1eeed233a6bb7cdc5b36697f84e..70663546880aadb5e027e5f7f63b36dd9e63a817 100644 --- a/sql/item.h +++ b/sql/item.h @@ -525,6 +525,8 @@ public: virtual table_map used_tables() const { return state != NO_VALUE ? (table_map)0 : PARAM_TABLE_BIT; } void print(String *str) { str->append('?'); } + /* parameter never equal to other parameter of other item */ + bool eq(const Item *item, bool binary_cmp) const { return 0; } }; class Item_int :public Item_num