From 279c310b661f5e051b9f39eab61ec614aa1061f5 Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Tue, 20 Jun 2006 00:50:09 +0400 Subject: [PATCH 1/5] item_cmpfunc.cc, func_in.result, func_in.test: Reverted fix for bug#18360 --- mysql-test/r/func_in.result | 21 --------------------- mysql-test/t/func_in.test | 12 ------------ sql/item_cmpfunc.cc | 28 ++++++++-------------------- 3 files changed, 8 insertions(+), 53 deletions(-) diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index 0632dddb87e..3cf2afc83d1 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -202,24 +202,3 @@ select count(*) from t1 where id not in (1,2); count(*) 1 drop table t1; -create table t1 (f1 char(1), f2 int); -insert into t1 values (1,0),('a',1),('z',2); -select f1 from t1 where f1 in (1,'z'); -f1 -1 -z -select f2 from t1 where f2 in (1,'z'); -f2 -0 -1 -select f1 from t1 where 'z' in (1,f1); -f1 -z -select * from t1 where 'z' in (f2,f1); -f1 f2 -z 2 -select * from t1 where 1 in (f2,f1); -f1 f2 -1 0 -a 1 -drop table t1; diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 3481f2c7b11..2ffe5a2d5f7 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -109,16 +109,4 @@ select count(*) from t1 where id not in (1); select count(*) from t1 where id not in (1,2); drop table t1; -# -# Bug#18360 Incorrect type coercion in IN() results in false comparison -# -create table t1 (f1 char(1), f2 int); -insert into t1 values (1,0),('a',1),('z',2); -select f1 from t1 where f1 in (1,'z'); -select f2 from t1 where f2 in (1,'z'); -select f1 from t1 where 'z' in (1,f1); -select * from t1 where 'z' in (f2,f1); -select * from t1 where 1 in (f2,f1); -drop table t1; - # End of 4.1 tests diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 126037a24d8..5055b5f4197 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -78,9 +78,6 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems) NOTES Aggregation rules: - If all items are constants the type will be aggregated from all items. - If there are some non-constant items then only types of non-constant - items will be used for aggregation. If there are DATE/TIME fields/functions in the list and no string fields/functions in the list then: The INT_RESULT type will be used for aggregation instead of original @@ -167,34 +164,25 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) } } } - /* Reset to 0 on first occurence of non-const item. 1 otherwise */ - bool is_const= items[0]->const_item(); /* If the first item is a date/time function then its result should be compared as int */ if (field) - { - /* Suppose we are comparing dates and some non-constant items are present. */ + /* Suppose we are comparing dates */ type[0]= INT_RESULT; - is_const= 0; - } else type[0]= items[0]->result_type(); for (i= 0; i < nitems ; i++) { - if (!items[i]->const_item()) - { - Item_result result= field && items[i]->result_as_longlong() ? - INT_RESULT : items[i]->result_type(); - type[0]= is_const ? result : item_cmp_type(type[0], result); - is_const= 0; - } - else if (is_const) - type[0]= item_cmp_type(type[0], items[i]->result_type()); - else if (field) - convert_constant_item(thd, field, &items[i]); + Item_result result= items[i]->result_type(); + if (field && + ((!items[i]->const_item() && items[i]->result_as_longlong()) || + (items[i]->const_item() && convert_constant_item(thd, field, + &items[i])))) + result= INT_RESULT; + type[0]= item_cmp_type(type[0], result); } if (res == Item::FUNC_ITEM && field) From 7d9a179c16636bdd767c6bc5dffe71346b32006b Mon Sep 17 00:00:00 2001 From: "iggy@mysql.com" <> Date: Mon, 19 Jun 2006 22:19:05 -0400 Subject: [PATCH 2/5] Bug#19407 Test 'func_regexp' fails on Windows x64 --- regex/regexec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regex/regexec.c b/regex/regexec.c index b7ad83ba883..88bcc02323d 100644 --- a/regex/regexec.c +++ b/regex/regexec.c @@ -19,7 +19,7 @@ static int nope = 0; /* for use in asserts; shuts lint up */ /* macros for manipulating states, small version */ #define states long -#define states1 states /* for later use in regexec() decision */ +#define states1 long /* for later use in regexec() decision. Ensure Win64 definition is correct.*/ #define CLEAR(v) ((v) = 0) #define SET0(v, n) ((v) &= ~((states) 1 << (n))) #define SET1(v, n) ((v) |= (states) 1 << (n)) From 314b897fbf7e3f9831ffc6ce64b8bfb21746382a Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Tue, 20 Jun 2006 15:35:54 +0400 Subject: [PATCH 3/5] func_time.result: After merge fix --- mysql-test/r/func_time.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index f1da903ae98..5b24480f2e9 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -785,8 +785,8 @@ select f1 from t1 where "2006-1-1" between f1 and 'zzz'; f1 Warnings: Warning 1292 Incorrect date value: 'zzz' for column 'f1' at row 1 -Warning 1292 Truncated incorrect INTEGER value: 'zzz' -Warning 1292 Truncated incorrect INTEGER value: 'zzz' +Warning 1292 Truncated incorrect DOUBLE value: 'zzz' +Warning 1292 Truncated incorrect DOUBLE value: 'zzz' select f1 from t1 where makedate(2006,1) between date(f1) and date(f3); f1 2006-01-01 From 71f0fe3dcae3301837b1117ce7ec1f03b7b6e870 Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Tue, 20 Jun 2006 15:40:10 +0400 Subject: [PATCH 4/5] item_cmpfunc.cc: After merge fix --- sql/item_cmpfunc.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 165dab5e43a..6a27d08611e 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -179,6 +179,10 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) for (i= 0; i < nitems ; i++) { Item_result result= items[i]->result_type(); + /* + Use INT_RESULT as result type for DATE/TIME fields/functions and + for constants successfully converted to DATE/TIME + */ if (field && ((!items[i]->const_item() && items[i]->result_as_longlong()) || (items[i]->const_item() && convert_constant_item(thd, field, From 37e5ec9f5043875dada0bce0eb9f1028d24de1ba Mon Sep 17 00:00:00 2001 From: "elliot@mysql.com" <> Date: Tue, 20 Jun 2006 13:43:13 -0400 Subject: [PATCH 5/5] Applying patch from SergeyV Fixes bug#17264, for alter table on win32 for successfull operation completion it is used TL_WRITE(=10) lock instead of TL_WRITE_ALLOW_READ(=6), however here in innodb handler TL_WRTIE is lifted to TL_WRITE_ALLOW_WRITE, which causes race condition when several clients do alter table simultaneously. --- mysql-test/r/lock_multi.result | 6 ++++++ mysql-test/t/lock_multi.test | 26 ++++++++++++++++++++++++++ sql/ha_innodb.cc | 11 +++++++++++ 3 files changed, 43 insertions(+) diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result index 2cb122fb988..2188d58e526 100644 --- a/mysql-test/r/lock_multi.result +++ b/mysql-test/r/lock_multi.result @@ -67,3 +67,9 @@ Select_priv N use test; use test; +create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) engine=innodb; +lock tables t1 write; + alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // + alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // +unlock tables; +drop table t1; diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test index ee03088b8c3..905d0699e6a 100644 --- a/mysql-test/t/lock_multi.test +++ b/mysql-test/t/lock_multi.test @@ -171,4 +171,30 @@ use test; # connection default; +# +# Bug #17264: MySQL Server freeze +# +connection locker; +create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) engine=innodb; +lock tables t1 write; +connection writer; +--sleep 2 +delimiter //; +send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // +delimiter ;// +connection reader; +--sleep 2 +delimiter //; +send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // +delimiter ;// +connection locker; +--sleep 2 +unlock tables; +connection writer; +reap; +connection reader; +reap; +connection locker; +drop table t1; + # End of 5.0 tests diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 28cdfd23b6a..6aadce0191a 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -6684,6 +6684,17 @@ ha_innobase::store_lock( && !thd->tablespace_op && thd->lex->sql_command != SQLCOM_TRUNCATE && thd->lex->sql_command != SQLCOM_OPTIMIZE +#ifdef __WIN__ + /* + for alter table on win32 for succesfull operation + completion it is used TL_WRITE(=10) lock instead of + TL_WRITE_ALLOW_READ(=6), however here in innodb handler + TL_WRITE is lifted to TL_WRITE_ALLOW_WRITE, which causes + race condition when several clients do alter table + simultaneously (bug #17264). This fix avoids the problem. + */ + && thd->lex->sql_command != SQLCOM_ALTER_TABLE +#endif && thd->lex->sql_command != SQLCOM_CREATE_TABLE) { lock_type = TL_WRITE_ALLOW_WRITE;