revision-id: 47ddf342e37006db1763d9f6c80ff8d2658a3822 (mariadb-10.0.35-74-g47ddf342e37) parent(s): c631060713a2af2890284feb7aea96c0cf4ba49f fceda2dab6f8ea6c042f910cbc1d07d5df0cbc3c author: Oleksandr Byelkin committer: Oleksandr Byelkin timestamp: 2018-07-30 13:00:42 +0200 message: Merge branch '5.5' into 10.0 include/sql_common.h | 2 +- mysql-test/r/grant.result | 4 +- mysql-test/r/subselect_mat.result | 93 ++++++++++++++++++++++++++++++++++++ mysql-test/r/subselect_sj_mat.result | 93 ++++++++++++++++++++++++++++++++++++ mysql-test/r/union.result | 16 +++++++ mysql-test/t/grant.test | 3 ++ mysql-test/t/subselect_sj_mat.test | 79 ++++++++++++++++++++++++++++++ mysql-test/t/union.test | 15 ++++++ sql-common/client.c | 4 ++ sql/item.cc | 3 +- sql/opt_subselect.cc | 66 +++++++++++++++++++++++++ sql/sql_acl.cc | 13 ++--- sql/sql_select.cc | 9 +++- storage/myisam/ha_myisam.cc | 6 ++- storage/myisam/mi_check.c | 6 ++- storage/myisam/mi_locking.c | 6 ++- 16 files changed, 400 insertions(+), 18 deletions(-) diff --cc mysql-test/r/subselect_mat.result index ff09da022b4,eca3b760b65..05c4efff920 --- a/mysql-test/r/subselect_mat.result +++ b/mysql-test/r/subselect_mat.result @@@ -2362,77 -2360,100 +2362,170 @@@ ec70316637232000158bbfc8bcbe5d6 ebb4620037332000158bbfc8bcbe5d89 DROP TABLE t1,t2,t3; set optimizer_switch=@save_optimizer_switch; + # + # MDEV-16751: Server crashes in st_join_table::cleanup or + # TABLE_LIST::is_with_table_recursive_reference with join_cache_level>2 + # + set @save_join_cache_level= @@join_cache_level; + set join_cache_level=4; + CREATE TABLE t1 ( id int NOT NULL); + INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19); + CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL) ; + INSERT INTO t2 VALUES (11,11),(12,12),(13,13); + explain + SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); + id select_type table type possible_keys key key_len ref rows Extra + 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 + 1 PRIMARY t1 hash_ALL NULL #hash#$hj 4 test.t2.i1 9 Using where; Using join buffer (flat, BNLH join) + 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where + SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); + 1 + 1 + 1 + 1 + set @@join_cache_level= @save_join_cache_level; + alter table t1 add key(id); + explain + SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); + id select_type table type possible_keys key key_len ref rows Extra + 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 + 1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index + 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where + SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); + 1 + 1 + 1 + 1 + drop table t1,t2; + # + # MDEV-15454: Nested SELECT IN returns wrong results + # + CREATE TABLE t1 ( a int NOT NULL PRIMARY KEY); + CREATE TABLE t2 ( a int, b int ); + INSERT INTO t2 VALUES (7878, 96),(3465, 96),(1403, 96),(4189, 96),(8732, 96), (5,96); + CREATE TABLE t3 (c int unsigned NOT NULL, b int unsigned NOT NULL, PRIMARY KEY (c,b)); + INSERT INTO t3 (c, b) VALUES (27, 96); + CREATE PROCEDURE prepare_data() + BEGIN + DECLARE i INT DEFAULT 1; + WHILE i < 1000 DO + INSERT INTO t1 (a) VALUES (i); + INSERT INTO t2 (a,b) VALUES (i,56); + INSERT INTO t3 (c,b) VALUES (i,i); + SET i = i + 1; + END WHILE; + END$$ + CALL prepare_data(); + SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27); + a + 7878 + 3465 + 1403 + 4189 + 8732 + 5 + set @save_optimizer_switch= @@optimizer_switch; + SET optimizer_switch='materialization=off'; + SELECT t1.a FROM t1 + WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5; + a + 5 + SET optimizer_switch='materialization=on'; + SELECT t1.a FROM t1 + WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5; + a + 5 + drop procedure prepare_data; + set @@optimizer_switch= @save_optimizer_switch; + drop table t1,t2,t3; + CREATE TABLE t1 ( id int NOT NULL, key(id)); + INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19); + CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL); + INSERT INTO t2 VALUES (11,11),(12,12),(13,13); + CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2; + explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); + id select_type table type possible_keys key key_len ref rows Extra + 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 + 1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index + 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where + SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); + 1 + 1 + 1 + 1 + drop table t1,t2; + drop view v1; # End of 5.5 tests +# +# MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT +# +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, c int); +insert into t1 +select A.a+B.a*10+C.a*100, A.a+B.a*10+C.a*100, A.a+B.a*10+C.a*100 +from t0 A, t0 B, t0 C; +create table t2 (a int, b int, c int); +insert into t2 select A.a, A.a, A.a from t1 A; +insert into t2 select * from t2; +insert into t2 select * from t2; +create table t3 as select * from t2 limit 1; +# The testcase only makes sense if the following uses Materialization: +explain +select * from t1 where (a,b) in (select max(a),b from t2 group by b); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 1000 Using where +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 test.t1.a,test.t1.b 1 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 4000 Using temporary +flush status; +replace into t3 +select * from t1 where (a,b) in (select max(a),b from t2 group by b); +# Sequential reads: +# 1K is read from t1 +# 4K is read from t2 +# 1K groups is read from the tmp. table +# +# Lookups: +# 4K lookups in group by table +# 1K lookups in temp.table +# +# Writes: +# 2x 1K writes to temporary tables (grouping table and subquery materialization table +# +# The point is that neither counter should be in the millions (this +# will happen if Materialization is not used +show status where Variable_name like 'Handler_read%' or Variable_name like 'Handler_%write%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 5000 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_retry 0 +Handler_read_rnd 0 +Handler_read_rnd_deleted 0 +Handler_read_rnd_next 6003 +Handler_tmp_write 2000 +Handler_write 1000 +drop table t0,t1,t2,t3; +# +# MDEV-7971: Assertion `name != __null' failed in ACL_internal_schema_registry::lookup +# on 2nd execution os PS with multi-table update +# +CREATE TABLE t1 (f1 INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (f2 INT); +INSERT INTO t2 VALUES (3),(4); +CREATE TABLE t3 (f3 INT); +INSERT INTO t3 VALUES (5),(6); +PREPARE stmt FROM ' + UPDATE t1, t2 + SET f1 = 5 + WHERE 8 IN ( SELECT MIN(f3) FROM t3 ) +'; +EXECUTE stmt; +EXECUTE stmt; +DROP TABLE t1,t2,t3; set @subselect_mat_test_optimizer_switch_value=null; set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off'; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; diff --cc mysql-test/r/subselect_sj_mat.result index 4feab0c78b0,180c182a51a..05d54c7086f --- a/mysql-test/r/subselect_sj_mat.result +++ b/mysql-test/r/subselect_sj_mat.result @@@ -2402,74 -2400,97 +2402,167 @@@ ec70316637232000158bbfc8bcbe5d6 ebb4620037332000158bbfc8bcbe5d89 DROP TABLE t1,t2,t3; set optimizer_switch=@save_optimizer_switch; + # + # MDEV-16751: Server crashes in st_join_table::cleanup or + # TABLE_LIST::is_with_table_recursive_reference with join_cache_level>2 + # + set @save_join_cache_level= @@join_cache_level; + set join_cache_level=4; + CREATE TABLE t1 ( id int NOT NULL); + INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19); + CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL) ; + INSERT INTO t2 VALUES (11,11),(12,12),(13,13); + explain + SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); + id select_type table type possible_keys key key_len ref rows Extra + 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 + 1 PRIMARY t1 hash_ALL NULL #hash#$hj 4 test.t2.i1 9 Using where; Using join buffer (flat, BNLH join) + 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where + SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); + 1 + 1 + 1 + 1 + set @@join_cache_level= @save_join_cache_level; + alter table t1 add key(id); + explain + SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); + id select_type table type possible_keys key key_len ref rows Extra + 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 + 1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index + 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where + SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); + 1 + 1 + 1 + 1 + drop table t1,t2; + # + # MDEV-15454: Nested SELECT IN returns wrong results + # + CREATE TABLE t1 ( a int NOT NULL PRIMARY KEY); + CREATE TABLE t2 ( a int, b int ); + INSERT INTO t2 VALUES (7878, 96),(3465, 96),(1403, 96),(4189, 96),(8732, 96), (5,96); + CREATE TABLE t3 (c int unsigned NOT NULL, b int unsigned NOT NULL, PRIMARY KEY (c,b)); + INSERT INTO t3 (c, b) VALUES (27, 96); + CREATE PROCEDURE prepare_data() + BEGIN + DECLARE i INT DEFAULT 1; + WHILE i < 1000 DO + INSERT INTO t1 (a) VALUES (i); + INSERT INTO t2 (a,b) VALUES (i,56); + INSERT INTO t3 (c,b) VALUES (i,i); + SET i = i + 1; + END WHILE; + END$$ + CALL prepare_data(); + SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27); + a + 7878 + 3465 + 1403 + 4189 + 8732 + 5 + set @save_optimizer_switch= @@optimizer_switch; + SET optimizer_switch='materialization=off'; + SELECT t1.a FROM t1 + WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5; + a + 5 + SET optimizer_switch='materialization=on'; + SELECT t1.a FROM t1 + WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5; + a + 5 + drop procedure prepare_data; + set @@optimizer_switch= @save_optimizer_switch; + drop table t1,t2,t3; + CREATE TABLE t1 ( id int NOT NULL, key(id)); + INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19); + CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL); + INSERT INTO t2 VALUES (11,11),(12,12),(13,13); + CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2; + explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); + id select_type table type possible_keys key key_len ref rows Extra + 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 + 1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index + 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where + SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); + 1 + 1 + 1 + 1 + drop table t1,t2; + drop view v1; # End of 5.5 tests +# +# MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT +# +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, c int); +insert into t1 +select A.a+B.a*10+C.a*100, A.a+B.a*10+C.a*100, A.a+B.a*10+C.a*100 +from t0 A, t0 B, t0 C; +create table t2 (a int, b int, c int); +insert into t2 select A.a, A.a, A.a from t1 A; +insert into t2 select * from t2; +insert into t2 select * from t2; +create table t3 as select * from t2 limit 1; +# The testcase only makes sense if the following uses Materialization: +explain +select * from t1 where (a,b) in (select max(a),b from t2 group by b); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 1000 Using where +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 test.t1.a,test.t1.b 1 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 4000 Using temporary +flush status; +replace into t3 +select * from t1 where (a,b) in (select max(a),b from t2 group by b); +# Sequential reads: +# 1K is read from t1 +# 4K is read from t2 +# 1K groups is read from the tmp. table +# +# Lookups: +# 4K lookups in group by table +# 1K lookups in temp.table +# +# Writes: +# 2x 1K writes to temporary tables (grouping table and subquery materialization table +# +# The point is that neither counter should be in the millions (this +# will happen if Materialization is not used +show status where Variable_name like 'Handler_read%' or Variable_name like 'Handler_%write%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 5000 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_retry 0 +Handler_read_rnd 0 +Handler_read_rnd_deleted 0 +Handler_read_rnd_next 6003 +Handler_tmp_write 2000 +Handler_write 1000 +drop table t0,t1,t2,t3; +# +# MDEV-7971: Assertion `name != __null' failed in ACL_internal_schema_registry::lookup +# on 2nd execution os PS with multi-table update +# +CREATE TABLE t1 (f1 INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (f2 INT); +INSERT INTO t2 VALUES (3),(4); +CREATE TABLE t3 (f3 INT); +INSERT INTO t3 VALUES (5),(6); +PREPARE stmt FROM ' + UPDATE t1, t2 + SET f1 = 5 + WHERE 8 IN ( SELECT MIN(f3) FROM t3 ) +'; +EXECUTE stmt; +EXECUTE stmt; +DROP TABLE t1,t2,t3; diff --cc mysql-test/t/grant.test index b51f37899b8,5de3328944a..156a55e0466 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@@ -1651,8 -1659,12 +1651,11 @@@ use test # # Bug#16470 crash on grant if old grant tables # + + call mtr.add_suppression("Can't open and lock privilege tables"); + --echo FLUSH PRIVILEGES without procs_priv table. RENAME TABLE mysql.procs_priv TO mysql.procs_gone; ---error ER_NO_SUCH_TABLE FLUSH PRIVILEGES; --echo Assigning privileges without procs_priv table. CREATE DATABASE mysqltest1; diff --cc mysql-test/t/subselect_sj_mat.test index c626d88e6ff,c82c1e7acec..1e10505e9f5 --- a/mysql-test/t/subselect_sj_mat.test +++ b/mysql-test/t/subselect_sj_mat.test @@@ -2157,71 -2151,83 +2157,150 @@@ eval $q DROP TABLE t1,t2,t3; set optimizer_switch=@save_optimizer_switch; + --echo # + --echo # MDEV-16751: Server crashes in st_join_table::cleanup or + --echo # TABLE_LIST::is_with_table_recursive_reference with join_cache_level>2 + --echo # + + set @save_join_cache_level= @@join_cache_level; + set join_cache_level=4; + CREATE TABLE t1 ( id int NOT NULL); + INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19); + + CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL) ; + INSERT INTO t2 VALUES (11,11),(12,12),(13,13); + + explain + SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); + SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); + + set @@join_cache_level= @save_join_cache_level; + alter table t1 add key(id); + + explain + SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); + SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2); + + drop table t1,t2; + + --echo # + --echo # MDEV-15454: Nested SELECT IN returns wrong results + --echo # + + CREATE TABLE t1 ( a int NOT NULL PRIMARY KEY); + + CREATE TABLE t2 ( a int, b int ); + INSERT INTO t2 VALUES (7878, 96),(3465, 96),(1403, 96),(4189, 96),(8732, 96), (5,96); + + CREATE TABLE t3 (c int unsigned NOT NULL, b int unsigned NOT NULL, PRIMARY KEY (c,b)); + INSERT INTO t3 (c, b) VALUES (27, 96); + + DELIMITER $$; + CREATE PROCEDURE prepare_data() + BEGIN + DECLARE i INT DEFAULT 1; + WHILE i < 1000 DO + INSERT INTO t1 (a) VALUES (i); + INSERT INTO t2 (a,b) VALUES (i,56); + INSERT INTO t3 (c,b) VALUES (i,i); + SET i = i + 1; + END WHILE; + END$$ + DELIMITER ;$$ + + CALL prepare_data(); + + SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27); + + set @save_optimizer_switch= @@optimizer_switch; + SET optimizer_switch='materialization=off'; + + SELECT t1.a FROM t1 + WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5; + + SET optimizer_switch='materialization=on'; + + SELECT t1.a FROM t1 + WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5; + + drop procedure prepare_data; + set @@optimizer_switch= @save_optimizer_switch; + drop table t1,t2,t3; + + CREATE TABLE t1 ( id int NOT NULL, key(id)); + INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19); + CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL); + INSERT INTO t2 VALUES (11,11),(12,12),(13,13); + CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2; + explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); + SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1); + drop table t1,t2; + drop view v1; --echo # End of 5.5 tests +--echo # +--echo # MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT +--echo # +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1 (a int, b int, c int); +insert into t1 +select A.a+B.a*10+C.a*100, A.a+B.a*10+C.a*100, A.a+B.a*10+C.a*100 +from t0 A, t0 B, t0 C; + +create table t2 (a int, b int, c int); +insert into t2 select A.a, A.a, A.a from t1 A; +insert into t2 select * from t2; +insert into t2 select * from t2; + +create table t3 as select * from t2 limit 1; + +--echo # The testcase only makes sense if the following uses Materialization: +explain +select * from t1 where (a,b) in (select max(a),b from t2 group by b); + +flush status; +replace into t3 +select * from t1 where (a,b) in (select max(a),b from t2 group by b); +--echo # Sequential reads: +--echo # 1K is read from t1 +--echo # 4K is read from t2 +--echo # 1K groups is read from the tmp. table +--echo # +--echo # Lookups: +--echo # 4K lookups in group by table +--echo # 1K lookups in temp.table +--echo # +--echo # Writes: +--echo # 2x 1K writes to temporary tables (grouping table and subquery materialization table +--echo # +--echo # The point is that neither counter should be in the millions (this +--echo # will happen if Materialization is not used +show status where Variable_name like 'Handler_read%' or Variable_name like 'Handler_%write%'; + +drop table t0,t1,t2,t3; + +--echo # +--echo # MDEV-7971: Assertion `name != __null' failed in ACL_internal_schema_registry::lookup +--echo # on 2nd execution os PS with multi-table update +--echo # +CREATE TABLE t1 (f1 INT); +INSERT INTO t1 VALUES (1),(2); + +CREATE TABLE t2 (f2 INT); +INSERT INTO t2 VALUES (3),(4); + +CREATE TABLE t3 (f3 INT); +INSERT INTO t3 VALUES (5),(6); + +PREPARE stmt FROM ' + UPDATE t1, t2 + SET f1 = 5 + WHERE 8 IN ( SELECT MIN(f3) FROM t3 ) +'; + +EXECUTE stmt; +EXECUTE stmt; + +DROP TABLE t1,t2,t3; + diff --cc sql/item.cc index 49973d48912,33c35f8c3e0..70f3e387b57 --- a/sql/item.cc +++ b/sql/item.cc @@@ -9649,10 -9655,11 +9649,11 @@@ bool Item_type_holder::join_types(THD * if (Field::result_merge_type(fld_type) == DECIMAL_RESULT) { + collation.set_numeric(); - decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE); + decimals= MY_MIN(MY_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE); int item_int_part= item->decimal_int_part(); - int item_prec = max(prev_decimal_int_part, item_int_part) + decimals; - int precision= min(item_prec, DECIMAL_MAX_PRECISION); + int item_prec = MY_MAX(prev_decimal_int_part, item_int_part) + decimals; + int precision= MY_MIN(item_prec, DECIMAL_MAX_PRECISION); unsigned_flag&= item->unsigned_flag; max_length= my_decimal_precision_to_length_no_truncation(precision, decimals, diff --cc sql/sql_acl.cc index b957b5713d2,24740a0695a..fa0f4ad1563 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@@ -9951,13 -7189,8 +9951,8 @@@ bool sp_grant_privileges(THD *thd, cons mysql_mutex_lock(&acl_cache->lock); - if ((au= find_user_wild(combo->host.str=(char*)sctx->host_or_ip, combo->user.str))) - goto found_acl; - if ((au= find_user_wild(combo->host.str=(char*)sctx->host, combo->user.str))) - goto found_acl; - if ((au= find_user_wild(combo->host.str=(char*)sctx->ip, combo->user.str))) - goto found_acl; - if ((au= find_user_wild(combo->host.str=(char*)"%", combo->user.str))) - if ((au= find_acl_user(combo->host.str= (char *) sctx->priv_host, - combo->user.str, FALSE))) ++ if ((au= find_user_wild(combo->host.str= (char *) sctx->priv_host, ++ combo->user.str))) goto found_acl; mysql_mutex_unlock(&acl_cache->lock);