mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Merge 5.5 into 10.0
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#ifndef SQL_COMMON_INCLUDED
|
||||
#define SQL_COMMON_INCLUDED
|
||||
/* Copyright (c) 2003, 2012, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2003, 2018, Oracle and/or its affiliates.
|
||||
Copyright (c) 2010, 2018, MariaDB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
@@ -1677,6 +1677,7 @@ revoke create, insert on mysqltest.t6 from mysqltest@localhost;
|
||||
drop user mysqltest@localhost;
|
||||
drop database mysqltest;
|
||||
use test;
|
||||
call mtr.add_suppression("Can't open and lock privilege tables");
|
||||
FLUSH PRIVILEGES without procs_priv table.
|
||||
RENAME TABLE mysql.procs_priv TO mysql.procs_gone;
|
||||
FLUSH PRIVILEGES;
|
||||
@@ -1765,8 +1766,6 @@ BEGIN
|
||||
SET @x = 0;
|
||||
REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
|
||||
END ;||
|
||||
Warnings:
|
||||
Warning 1404 Failed to grant EXECUTE and ALTER ROUTINE privileges
|
||||
SHOW GRANTS FOR 'user1'@'localhost';
|
||||
Grants for user1@localhost
|
||||
GRANT USAGE ON *.* TO 'user1'@'localhost'
|
||||
@@ -1776,6 +1775,7 @@ SHOW GRANTS FOR 'user2';
|
||||
Grants for user2@%
|
||||
GRANT USAGE ON *.* TO 'user2'@'%'
|
||||
GRANT CREATE, CREATE ROUTINE ON `db1`.* TO 'user2'@'%'
|
||||
GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `db1`.`proc2` TO 'user2'@'%'
|
||||
DROP PROCEDURE db1.proc1;
|
||||
DROP PROCEDURE db1.proc2;
|
||||
REVOKE ALL ON db1.* FROM 'user1'@'localhost';
|
||||
|
@@ -2362,6 +2362,99 @@ ec70316637232000158bbfc8bcbe5d60
|
||||
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
|
||||
|
@@ -2402,6 +2402,99 @@ ec70316637232000158bbfc8bcbe5d60
|
||||
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
|
||||
|
@@ -2032,4 +2032,20 @@ DROP VIEW v1;
|
||||
UNION
|
||||
(SELECT 2, 2);
|
||||
ERROR 42S02: Table 'test.v1' doesn't exist
|
||||
#
|
||||
# Bug#27197235 USER VARIABLE + UINON + DECIMAL COLUMN RETURNS
|
||||
# WRONG VALUES
|
||||
#
|
||||
SET NAMES utf8;
|
||||
SET @advertAcctId = 1000003;
|
||||
select @advertAcctId as a from dual union all select 1.0 from dual;
|
||||
a
|
||||
1000003.0
|
||||
1.0
|
||||
SET NAMES latin1;
|
||||
SET @advertAcctId = 1000003;
|
||||
select @advertAcctId as a from dual union all select 1.0 from dual;
|
||||
a
|
||||
1000003.0
|
||||
1.0
|
||||
End of 5.5 tests
|
||||
|
@@ -1651,6 +1651,9 @@ 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;
|
||||
FLUSH PRIVILEGES;
|
||||
|
@@ -2157,6 +2157,85 @@ 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
|
||||
|
@@ -1421,4 +1421,19 @@ DROP VIEW v1;
|
||||
UNION
|
||||
(SELECT 2, 2);
|
||||
|
||||
--echo #
|
||||
--echo # Bug#27197235 USER VARIABLE + UINON + DECIMAL COLUMN RETURNS
|
||||
--echo # WRONG VALUES
|
||||
--echo #
|
||||
|
||||
let $old_charset= `SELECT @@character_set_client`;
|
||||
|
||||
SET NAMES utf8;
|
||||
SET @advertAcctId = 1000003;
|
||||
select @advertAcctId as a from dual union all select 1.0 from dual;
|
||||
|
||||
eval SET NAMES $old_charset;
|
||||
SET @advertAcctId = 1000003;
|
||||
select @advertAcctId as a from dual union all select 1.0 from dual;
|
||||
|
||||
--echo End of 5.5 tests
|
||||
|
@@ -1462,6 +1462,7 @@ MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
|
||||
|
||||
if ((pkt_len= cli_safe_read(mysql)) == packet_error)
|
||||
DBUG_RETURN(0);
|
||||
if (pkt_len == 0) DBUG_RETURN(0);
|
||||
if (!(result=(MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA),
|
||||
MYF(MY_WME | MY_ZEROFILL))))
|
||||
{
|
||||
@@ -2579,6 +2580,9 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
|
||||
enum enum_ssl_init_error ssl_init_error;
|
||||
const char *cert_error;
|
||||
unsigned long ssl_error;
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
DBUG_ASSERT(0); // embedded should not do SSL connect
|
||||
#endif
|
||||
|
||||
/*
|
||||
Send mysql->client_flag, max_packet_size - unencrypted otherwise
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
|
||||
Copyright (c) 2000, 2018, Oracle and/or its affiliates.
|
||||
Copyright (c) 2010, 2018, MariaDB Corporation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -9649,6 +9649,7 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
|
||||
|
||||
if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
|
||||
{
|
||||
collation.set_numeric();
|
||||
decimals= MY_MIN(MY_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
|
||||
int item_int_part= item->decimal_int_part();
|
||||
int item_prec = MY_MAX(prev_decimal_int_part, item_int_part) + decimals;
|
||||
|
@@ -441,6 +441,7 @@ bool subquery_types_allow_materialization(Item_in_subselect *in_subs);
|
||||
static bool replace_where_subcondition(JOIN *, Item **, Item *, Item *, bool);
|
||||
static int subq_sj_candidate_cmp(Item_in_subselect* el1, Item_in_subselect* el2,
|
||||
void *arg);
|
||||
static void reset_equality_number_for_subq_conds(Item * cond);
|
||||
static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred);
|
||||
static bool convert_subq_to_jtbm(JOIN *parent_join,
|
||||
Item_in_subselect *subq_pred, bool *remove);
|
||||
@@ -815,6 +816,9 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
|
||||
details)
|
||||
* require that compared columns have exactly the same type. This is
|
||||
a temporary measure to avoid BUG#36752-type problems.
|
||||
|
||||
JOIN_TAB::keyuse_is_valid_for_access_in_chosen_plan expects that for Semi Join Materialization
|
||||
Scan all the items in the select list of the IN Subquery are of the type Item::FIELD_ITEM.
|
||||
*/
|
||||
|
||||
static
|
||||
@@ -1453,6 +1457,67 @@ static int subq_sj_candidate_cmp(Item_in_subselect* el1, Item_in_subselect* el2,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@brief
|
||||
reset the value of the field in_eqaulity_no for all Item_func_eq
|
||||
items in the where clause of the subquery.
|
||||
|
||||
Look for in_equality_no description in Item_func_eq class
|
||||
|
||||
DESCRIPTION
|
||||
Lets have an example:
|
||||
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 ))
|
||||
|
||||
So for such a query we have the parent, child and
|
||||
grandchild select.
|
||||
|
||||
So for the equality t2.b = t3.b we set the value for in_equality_no to
|
||||
0 according to its description. Wewe do the same for t1.a = t2.a.
|
||||
But when we look at the child select (with the grandchild select merged),
|
||||
the query would be
|
||||
|
||||
SELECT t1.a FROM t1 WHERE t1.a IN
|
||||
(SELECT t2.a FROM t2 where t2.b = t3.b and t3.c=27)
|
||||
|
||||
and then when the child select is merged into the parent select the query
|
||||
would look like
|
||||
|
||||
SELECT t1.a FROM t1, semi-join-nest(t2,t3)
|
||||
WHERE t1.a =t2.a and t2.b = t3.b and t3.c=27
|
||||
|
||||
Still we would have in_equality_no set for t2.b = t3.b
|
||||
though it does not take part in the semi-join equality for the parent select,
|
||||
so we should reset its value to UINT_MAX.
|
||||
|
||||
@param cond WHERE clause of the subquery
|
||||
*/
|
||||
|
||||
static void reset_equality_number_for_subq_conds(Item * cond)
|
||||
{
|
||||
if (!cond)
|
||||
return;
|
||||
if (cond->type() == Item::COND_ITEM)
|
||||
{
|
||||
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
|
||||
Item *item;
|
||||
while ((item=li++))
|
||||
{
|
||||
if (item->type() == Item::FUNC_ITEM &&
|
||||
((Item_func*)item)->functype()== Item_func::EQ_FUNC)
|
||||
((Item_func_eq*)item)->in_equality_no= UINT_MAX;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cond->type() == Item::FUNC_ITEM &&
|
||||
((Item_func*)cond)->functype()== Item_func::EQ_FUNC)
|
||||
((Item_func_eq*)cond)->in_equality_no= UINT_MAX;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
Convert a subquery predicate into a TABLE_LIST semi-join nest
|
||||
|
||||
@@ -1710,6 +1775,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
|
||||
*/
|
||||
sj_nest->sj_in_exprs= subq_pred->left_expr->cols();
|
||||
sj_nest->nested_join->sj_outer_expr_list.empty();
|
||||
reset_equality_number_for_subq_conds(sj_nest->sj_on_expr);
|
||||
|
||||
if (subq_pred->left_expr->cols() == 1)
|
||||
{
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2000, 2018, Oracle and/or its affiliates.
|
||||
Copyright (c) 2009, 2018, MariaDB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -9947,17 +9947,12 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
|
||||
if (!(combo=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
combo->user.str= sctx->user;
|
||||
combo->user.str= (char *) sctx->priv_user;
|
||||
|
||||
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_user_wild(combo->host.str= (char *) sctx->priv_host,
|
||||
combo->user.str)))
|
||||
goto found_acl;
|
||||
|
||||
mysql_mutex_unlock(&acl_cache->lock);
|
||||
|
@@ -8162,9 +8162,14 @@ bool JOIN_TAB::keyuse_is_valid_for_access_in_chosen_plan(JOIN *join,
|
||||
st_select_lex *sjm_sel= emb_sj_nest->sj_subq_pred->unit->first_select();
|
||||
for (uint i= 0; i < sjm_sel->item_list.elements; i++)
|
||||
{
|
||||
if (sjm_sel->ref_pointer_array[i] == keyuse->val)
|
||||
DBUG_ASSERT(sjm_sel->ref_pointer_array[i]->real_item()->type() == Item::FIELD_ITEM);
|
||||
if (keyuse->val->real_item()->type() == Item::FIELD_ITEM)
|
||||
{
|
||||
Field *field = ((Item_field*)sjm_sel->ref_pointer_array[i]->real_item())->field;
|
||||
if (field->eq(((Item_field*)keyuse->val->real_item())->field))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2000, 2012, Oracle and/or its affiliates.
|
||||
Copyright (c) 2000, 2018, Oracle and/or its affiliates.
|
||||
Copyright (c) 2009, 2017, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -1212,10 +1212,14 @@ int ha_myisam::repair(THD *thd, HA_CHECK ¶m, bool do_optimize)
|
||||
if (file->s->base.auto_key)
|
||||
update_auto_increment_key(¶m, file, 1);
|
||||
if (optimize_done)
|
||||
{
|
||||
mysql_mutex_lock(&share->intern_lock);
|
||||
error = update_state_info(¶m, file,
|
||||
UPDATE_TIME | UPDATE_OPEN_COUNT |
|
||||
(local_testflag &
|
||||
T_STATISTICS ? UPDATE_STAT : 0));
|
||||
mysql_mutex_unlock(&share->intern_lock);
|
||||
}
|
||||
info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE |
|
||||
HA_STATUS_CONST);
|
||||
if (rows != file->state->records && ! (param.testflag & T_VERY_SILENT))
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2000, 2018, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -4472,6 +4472,10 @@ int update_state_info(HA_CHECK *param, MI_INFO *info,uint update)
|
||||
int error;
|
||||
uint r_locks=share->r_locks,w_locks=share->w_locks;
|
||||
share->r_locks= share->w_locks= share->tot_locks= 0;
|
||||
|
||||
DBUG_EXECUTE_IF("simulate_incorrect_share_wlock_value",
|
||||
DEBUG_SYNC_C("after_share_wlock_set_to_0"););
|
||||
|
||||
error=_mi_writeinfo(info,WRITEINFO_NO_UNLOCK);
|
||||
share->r_locks=r_locks;
|
||||
share->w_locks=w_locks;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 2009, 2018, MariaDB Corporation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -236,6 +236,10 @@ int mi_lock_database(MI_INFO *info, int lock_type)
|
||||
info->invalidator=info->s->invalidator;
|
||||
share->w_locks++;
|
||||
share->tot_locks++;
|
||||
|
||||
DBUG_EXECUTE_IF("simulate_incorrect_share_wlock_value",
|
||||
DEBUG_SYNC_C("after_share_wlock_increment"););
|
||||
|
||||
info->s->in_use= list_add(info->s->in_use, &info->in_use);
|
||||
break;
|
||||
default:
|
||||
|
Reference in New Issue
Block a user