Skip to content

Commit

Permalink
Merge 10.2 into bb-10.2-ext
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Jun 27, 2017
2 parents ed61fdd + 29624ea commit 43c77bb
Show file tree
Hide file tree
Showing 79 changed files with 2,849 additions and 264 deletions.
2 changes: 1 addition & 1 deletion mysql-test/r/derived.result
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ EXPLAIN SELECT * FROM (SELECT * FROM t1) AS table1,
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
1 PRIMARY <derived3> ref key0 key0 5 const 0
3 DERIVED t2 ALL NULL NULL NULL NULL 2 Using temporary
3 DERIVED t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary
Warnings:
Note 1249 Select 4 was reduced during optimization
DROP TABLE t1, t2;
Expand Down
266 changes: 264 additions & 2 deletions mysql-test/r/derived_cond_pushdown.result
Original file line number Diff line number Diff line change
Expand Up @@ -7250,6 +7250,7 @@ EXPLAIN
"materialized": {
"query_block": {
"select_id": 5,
"having_condition": "s > 2",
"filesort": {
"sort_key": "t4.d",
"temporary_table": {
Expand Down Expand Up @@ -7621,6 +7622,7 @@ EXPLAIN
"materialized": {
"query_block": {
"select_id": 3,
"having_condition": "s < 50",
"filesort": {
"sort_key": "t3.a",
"temporary_table": {
Expand Down Expand Up @@ -7771,9 +7773,14 @@ EXPLAIN
"select_id": 4,
"table": {
"table_name": "t",
"access_type": "ALL",
"access_type": "range",
"possible_keys": ["PRIMARY"],
"key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["pk"],
"rows": 2,
"filtered": 100
"filtered": 100,
"index_condition": "t.pk > 2"
}
}
}
Expand Down Expand Up @@ -8463,3 +8470,258 @@ WHERE row <> order_number;
row order_number
14 51
DROP TABLE sales_documents;
#
# MDEV-12845: pushdown from merged derived using equalities
#
create table t1 (a int);
insert into t1 values
(4), (8), (5), (3), (10), (2), (7);
create table t2 (b int, c int);
insert into t2 values
(2,1), (5,2), (2,2), (4,1), (4,3),
(5,3), (2,4), (4,6), (2,1);
create view v1 as
select b, sum(c) as s from t2 group by b;
create view v2 as
select distinct b, c from t2;
create view v3 as
select b, max(c) as m from t2 group by b;
select b
from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t
where b > 2;
b
4
5
explain format=json select b
from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t
where b > 2;
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows": 7,
"filtered": 100,
"attached_condition": "t1.a > 2 and t1.a is not null"
},
"table": {
"table_name": "<derived3>",
"access_type": "ref",
"possible_keys": ["key0"],
"key": "key0",
"key_length": "5",
"used_key_parts": ["b"],
"ref": ["test.t1.a"],
"rows": 2,
"filtered": 100,
"materialized": {
"query_block": {
"select_id": 3,
"filesort": {
"sort_key": "t2.b",
"temporary_table": {
"table": {
"table_name": "t2",
"access_type": "ALL",
"rows": 9,
"filtered": 100,
"attached_condition": "t2.b > 2"
}
}
}
}
}
}
}
}
select a
from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t
where a > 2;
a
4
5
explain format=json select a
from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t
where a > 2;
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows": 7,
"filtered": 100,
"attached_condition": "t1.a > 2 and t1.a is not null"
},
"table": {
"table_name": "<derived3>",
"access_type": "ref",
"possible_keys": ["key0"],
"key": "key0",
"key_length": "5",
"used_key_parts": ["b"],
"ref": ["test.t1.a"],
"rows": 2,
"filtered": 100,
"materialized": {
"query_block": {
"select_id": 3,
"filesort": {
"sort_key": "t2.b",
"temporary_table": {
"table": {
"table_name": "t2",
"access_type": "ALL",
"rows": 9,
"filtered": 100,
"attached_condition": "t2.b > 2"
}
}
}
}
}
}
}
}
select a
from ( select t1.a, v2.b, v2.c from t1, v2 where t1.a = v2.b ) as t
where a > 2;
a
4
4
4
5
5
explain format=json select a
from ( select t1.a, v2.b, v2.c from t1, v2 where t1.a = v2.b ) as t
where a > 2;
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows": 7,
"filtered": 100,
"attached_condition": "t1.a > 2 and t1.a is not null"
},
"table": {
"table_name": "<derived3>",
"access_type": "ref",
"possible_keys": ["key0"],
"key": "key0",
"key_length": "5",
"used_key_parts": ["b"],
"ref": ["test.t1.a"],
"rows": 2,
"filtered": 100,
"materialized": {
"query_block": {
"select_id": 3,
"temporary_table": {
"table": {
"table_name": "t2",
"access_type": "ALL",
"rows": 9,
"filtered": 100,
"attached_condition": "t2.b > 2"
}
}
}
}
}
}
}
select a
from ( select t1.a, v3.b, v3.m from t1, v3 where t1.a = v3.m ) as t
where a > 2;
a
4
3
explain format=json select a
from ( select t1.a, v3.b, v3.m from t1, v3 where t1.a = v3.m ) as t
where a > 2;
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows": 7,
"filtered": 100,
"attached_condition": "t1.a > 2 and t1.a is not null"
},
"table": {
"table_name": "<derived3>",
"access_type": "ref",
"possible_keys": ["key0"],
"key": "key0",
"key_length": "5",
"used_key_parts": ["m"],
"ref": ["test.t1.a"],
"rows": 2,
"filtered": 100,
"materialized": {
"query_block": {
"select_id": 3,
"having_condition": "m > 2",
"filesort": {
"sort_key": "t2.b",
"temporary_table": {
"table": {
"table_name": "t2",
"access_type": "ALL",
"rows": 9,
"filtered": 100
}
}
}
}
}
}
}
}
drop view v1,v2,v3;
drop table t1,t2;
#
# MDEV-13166: pushdown from merged derived
#
CREATE TABLE t1 (i int) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE VIEW v1 AS SELECT MAX(i) AS f FROM t1;
SELECT * FROM ( SELECT * FROM v1 ) AS sq WHERE f > 0;
f
2
explain format=json SELECT * FROM ( SELECT * FROM v1 ) AS sq WHERE f > 0;
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "<derived3>",
"access_type": "ALL",
"rows": 2,
"filtered": 100,
"attached_condition": "v1.f > 0",
"materialized": {
"query_block": {
"select_id": 3,
"having_condition": "f > 0",
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows": 2,
"filtered": 100
}
}
}
}
}
}
DROP VIEW v1;
DROP TABLE t1;
4 changes: 2 additions & 2 deletions mysql-test/r/derived_view.result
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 11,
"filtered": 100,
"attached_condition": "t1.f1 in (2,3)"
"attached_condition": "t1.f1 < 7 and t1.f1 in (2,3)"
}
}
}
Expand Down Expand Up @@ -1107,7 +1107,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
1 PRIMARY t2 ref a a 4 const 1 Using index
1 PRIMARY <derived2> ref key0 key0 8 const,const 1
2 DERIVED t3 ALL NULL NULL NULL NULL 12 Using temporary; Using filesort
2 DERIVED t3 ALL NULL NULL NULL NULL 12 Using where; Using temporary; Using filesort
SELECT * FROM t1, t2, v1 WHERE t2.a=t1.a AND t2.a=v1.a AND t2.a=v1.b;
a a a b
c c c c
Expand Down
22 changes: 22 additions & 0 deletions mysql-test/r/mdl.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# MDEV-12882 - Assertion `mdl_ticket->m_type == MDL_SHARED_UPGRADABLE ||
# mdl_ticket->m_type == MDL_SHARED_NO_WRITE ||
# mdl_ticket->m_type == MDL_SHARED_NO_READ_WRITE ||
# mdl_ticket->m_type == MDL_SHARED_READ'
# failed in MDL_context::upgrade_shared_lock
#
CREATE TABLE t1(a INT) ENGINE=InnoDB;
LOCK TABLES t1 WRITE CONCURRENT, t1 AS t2 READ;
SELECT * FROM information_schema.metadata_lock_info;
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
9 MDL_INTENTION_EXCLUSIVE NULL Global read lock
9 MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1
UNLOCK TABLES;
LOCK TABLES t1 AS t2 READ, t1 WRITE CONCURRENT;
SELECT * FROM information_schema.metadata_lock_info;
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
9 MDL_INTENTION_EXCLUSIVE NULL Global read lock
9 MDL_SHARED_WRITE NULL Table metadata lock test t1
9 MDL_SHARED_READ_ONLY NULL Table metadata lock test t1
UNLOCK TABLES;
DROP TABLE t1;
Loading

0 comments on commit 43c77bb

Please sign in to comment.