Commit 04a78106 authored by unknown's avatar unknown

A fix and a test case for Bug#12734 " prepared statement may

return incorrect result set for a select SQL request"


mysql-test/r/ps.result:
  Test results fixed (Bug#12734)
mysql-test/t/ps.test:
  A test case for Bug#12734
sql/item_cmpfunc.cc:
  Reset canDoTurboBM in Item_func_like::cleanup()
sql/item_cmpfunc.h:
  Add Item_func_like::cleanup()
parent 4e195cbd
...@@ -718,3 +718,37 @@ execute stmt; ...@@ -718,3 +718,37 @@ execute stmt;
drop table t1; drop table t1;
set names default; set names default;
deallocate prepare stmt; deallocate prepare stmt;
create table t1 (
word_id mediumint(8) unsigned not null default '0',
formatted varchar(20) not null default ''
);
insert into t1 values
(80,'pendant'), (475,'pretendants'), (989,'tendances'),
(1019,'cependant'),(1022,'abondance'),(1205,'independants'),
(13,'lessiver'),(25,'lambiner'),(46,'situer'),(71,'terminer'),
(82,'decrocher');
select count(*) from t1 where formatted like '%NDAN%';
count(*)
6
select count(*) from t1 where formatted like '%ER';
count(*)
5
prepare stmt from "select count(*) from t1 where formatted like ?";
set @like="%NDAN%";
execute stmt using @like;
count(*)
6
set @like="%ER";
execute stmt using @like;
count(*)
5
set @like="%NDAN%";
execute stmt using @like;
count(*)
6
set @like="%ER";
execute stmt using @like;
count(*)
5
deallocate prepare stmt;
drop table t1;
...@@ -746,5 +746,35 @@ drop table t1; ...@@ -746,5 +746,35 @@ drop table t1;
set names default; set names default;
deallocate prepare stmt; deallocate prepare stmt;
#
# A test case for Bug#12734 "prepared statement may return incorrect result
# set for a select SQL request": test that canDoTurboBM is reset for each
# execute of a prepared statement.
#
create table t1 (
word_id mediumint(8) unsigned not null default '0',
formatted varchar(20) not null default ''
);
insert into t1 values
(80,'pendant'), (475,'pretendants'), (989,'tendances'),
(1019,'cependant'),(1022,'abondance'),(1205,'independants'),
(13,'lessiver'),(25,'lambiner'),(46,'situer'),(71,'terminer'),
(82,'decrocher');
select count(*) from t1 where formatted like '%NDAN%';
select count(*) from t1 where formatted like '%ER';
prepare stmt from "select count(*) from t1 where formatted like ?";
set @like="%NDAN%";
execute stmt using @like;
set @like="%ER";
execute stmt using @like;
set @like="%NDAN%";
execute stmt using @like;
set @like="%ER";
execute stmt using @like;
deallocate prepare stmt;
drop table t1;
# End of 4.1 tests # End of 4.1 tests
...@@ -2524,6 +2524,12 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref) ...@@ -2524,6 +2524,12 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref)
return 0; return 0;
} }
void Item_func_like::cleanup()
{
canDoTurboBM= FALSE;
Item_bool_func2::cleanup();
}
#ifdef USE_REGEX #ifdef USE_REGEX
bool bool
......
...@@ -911,6 +911,7 @@ class Item_func_like :public Item_bool_func2 ...@@ -911,6 +911,7 @@ class Item_func_like :public Item_bool_func2
cond_result eq_cmp_result() const { return COND_TRUE; } cond_result eq_cmp_result() const { return COND_TRUE; }
const char *func_name() const { return "like"; } const char *func_name() const { return "like"; }
bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref); bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref);
void cleanup();
}; };
#ifdef USE_REGEX #ifdef USE_REGEX
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment