Skip to content

Commit

Permalink
Merge branch 'master' into zimuxia/split-resions
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala committed Sep 3, 2019
2 parents dac8d5e + 06fc28f commit 6c38a18
Show file tree
Hide file tree
Showing 80 changed files with 1,505 additions and 255 deletions.
13 changes: 13 additions & 0 deletions cmd/explaintest/r/access_path_selection.result
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@ id count task operator info
IndexReader_11 1104.45 root index:Selection_10
└─Selection_10 1104.45 cop lt(test.access_path_selection.b, 3)
└─IndexScan_9 3323.33 cop table:access_path_selection, index:a, b, range:[-inf,3), keep order:false, stats:pseudo
explain select a, b from access_path_selection where a > 10 order by _tidb_rowid;
id count task operator info
Projection_6 3333.33 root test.access_path_selection.a, test.access_path_selection.b
└─TableReader_13 3333.33 root data:Selection_12
└─Selection_12 3333.33 cop gt(test.access_path_selection.a, 10)
└─TableScan_11 10000.00 cop table:access_path_selection, range:[-inf,+inf], keep order:true, stats:pseudo
explain select max(_tidb_rowid) from access_path_selection;
id count task operator info
StreamAgg_13 1.00 root funcs:max(test.access_path_selection._tidb_rowid)
└─Limit_17 1.00 root offset:0, count:1
└─TableReader_27 1.00 root data:Limit_26
└─Limit_26 1.00 cop offset:0, count:1
└─TableScan_25 1.25 cop table:access_path_selection, range:[-inf,+inf], keep order:true, desc, stats:pseudo
21 changes: 21 additions & 0 deletions cmd/explaintest/r/black_list.result
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ Selection_5 8000.00 root lt(test.t.a, 1)
delete from mysql.opt_rule_blacklist where name='predicate_push_down';
admin reload opt_rule_blacklist;

explain select * from t where a < 1;
id count task operator info
TableReader_7 3323.33 root data:Selection_6
└─Selection_6 3323.33 cop lt(test.t.a, 1)
└─TableScan_5 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
insert into mysql.expr_pushdown_blacklist values('<');
admin reload expr_pushdown_blacklist;

explain select * from t where a < 1;
id count task operator info
Selection_5 8000.00 root lt(test.t.a, 1)
└─TableReader_7 10000.00 root data:TableScan_6
└─TableScan_6 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
delete from mysql.expr_pushdown_blacklist where name='<';
admin reload expr_pushdown_blacklist;

explain select * from t where a < 1;
id count task operator info
TableReader_7 3323.33 root data:Selection_6
Expand All @@ -33,3 +49,8 @@ Selection_5 8000.00 root lt(test.t.a, 1)
delete from mysql.expr_pushdown_blacklist where name='lt';
admin reload expr_pushdown_blacklist;

explain select * from t where a < 1;
id count task operator info
TableReader_7 3323.33 root data:Selection_6
└─Selection_6 3323.33 cop lt(test.t.a, 1)
└─TableScan_5 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
36 changes: 16 additions & 20 deletions cmd/explaintest/r/explain_easy.result
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,13 @@ Projection_9 9990.00 root test.t1.c1
└─TableScan_18 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo
explain select (select count(1) k from t1 s where s.c1 = t1.c1 having k != 0) from t1;
id count task operator info
Projection_12 10000.00 root k
└─Projection_13 10000.00 root test.t1.c1, ifnull(5_col_0, 0)
└─MergeJoin_14 10000.00 root left outer join, left key:test.t1.c1, right key:test.s.c1
├─TableReader_17 10000.00 root data:TableScan_16
│ └─TableScan_16 10000.00 cop table:t1, range:[-inf,+inf], keep order:true, stats:pseudo
└─Projection_18 8000.00 root 1, test.s.c1
└─TableReader_20 10000.00 root data:TableScan_19
└─TableScan_19 10000.00 cop table:s, range:[-inf,+inf], keep order:true, stats:pseudo
Projection_12 10000.00 root ifnull(5_col_0, 0)
└─MergeJoin_13 10000.00 root left outer join, left key:test.t1.c1, right key:test.s.c1
├─TableReader_16 10000.00 root data:TableScan_15
│ └─TableScan_15 10000.00 cop table:t1, range:[-inf,+inf], keep order:true, stats:pseudo
└─Projection_17 8000.00 root 1, test.s.c1
└─TableReader_19 10000.00 root data:TableScan_18
└─TableScan_18 10000.00 cop table:s, range:[-inf,+inf], keep order:true, stats:pseudo
explain select * from information_schema.columns;
id count task operator info
MemTableScan_4 10000.00 root
Expand Down Expand Up @@ -648,22 +647,19 @@ id count task operator info
Sort_13 2.00 root a:asc
└─HashAgg_17 2.00 root group by:a, funcs:firstrow(join_agg_0)
└─Union_18 2.00 root
├─HashAgg_21 1.00 root group by:a, funcs:firstrow(a), firstrow(a)
│ └─Projection_22 1.00 root 0
│ └─TableDual_23 1.00 root rows:1
└─HashAgg_26 1.00 root group by:a, funcs:firstrow(a), firstrow(a)
└─Projection_27 1.00 root 1
└─TableDual_28 1.00 root rows:1
├─HashAgg_19 1.00 root group by:0, funcs:firstrow(0), firstrow(0)
│ └─TableDual_22 1.00 root rows:1
└─HashAgg_25 1.00 root group by:1, funcs:firstrow(1), firstrow(1)
└─TableDual_28 1.00 root rows:1
explain SELECT 0 AS a FROM dual UNION (SELECT 1 AS a FROM dual ORDER BY a);
id count task operator info
HashAgg_15 2.00 root group by:a, funcs:firstrow(join_agg_0)
└─Union_16 2.00 root
├─HashAgg_19 1.00 root group by:a, funcs:firstrow(a), firstrow(a)
│ └─Projection_20 1.00 root 0
│ └─TableDual_21 1.00 root rows:1
└─StreamAgg_26 1.00 root group by:a, funcs:firstrow(a), firstrow(a)
└─Projection_31 1.00 root 1
└─TableDual_32 1.00 root rows:1
├─HashAgg_17 1.00 root group by:0, funcs:firstrow(0), firstrow(0)
│ └─TableDual_20 1.00 root rows:1
└─StreamAgg_27 1.00 root group by:a, funcs:firstrow(a), firstrow(a)
└─Projection_32 1.00 root 1
└─TableDual_33 1.00 root rows:1
create table t (i int key, j int, unique key (i, j));
begin;
insert into t values (1, 1);
Expand Down
10 changes: 5 additions & 5 deletions cmd/explaintest/r/partition_pruning.result
Original file line number Diff line number Diff line change
Expand Up @@ -4010,11 +4010,11 @@ create table t1 (s1 int);
explain select 1 from t1 union all select 2;
id count task operator info
Union_8 10001.00 root
├─Projection_10 10000.00 root 1
│ └─TableReader_12 10000.00 root data:TableScan_11
│ └─TableScan_11 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo
└─Projection_14 1.00 root 2
└─TableDual_15 1.00 root rows:1
├─Projection_9 10000.00 root 1
│ └─TableReader_11 10000.00 root data:TableScan_10
│ └─TableScan_10 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo
└─Projection_12 1.00 root 2
└─TableDual_13 1.00 root rows:1
drop table t1;
create table t1 (a int)
partition by range(a) (
Expand Down
37 changes: 21 additions & 16 deletions cmd/explaintest/r/select.result
Original file line number Diff line number Diff line change
Expand Up @@ -382,24 +382,24 @@ drop table if exists t;
create table t(a int, b int);
explain select a != any (select a from t t2) from t t1;
id count task operator info
Projection_9 10000.00 root and(or(or(gt(col_count, 1), ne(test.t1.a, col_firstrow)), if(ne(agg_col_sum, 0), NULL, 0)), and(ne(agg_col_cnt, 0), if(isnull(test.t1.a), NULL, 1)))
└─HashLeftJoin_10 10000.00 root CARTESIAN inner join, inner:StreamAgg_17
├─TableReader_13 10000.00 root data:TableScan_12
│ └─TableScan_12 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo
└─StreamAgg_17 1.00 root funcs:firstrow(col_0), count(distinct col_1), sum(col_2), count(1)
└─Projection_27 10000.00 root test.t2.a, test.t2.a, cast(isnull(test.t2.a))
└─TableReader_24 10000.00 root data:TableScan_23
└─TableScan_23 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo
Projection_8 10000.00 root and(or(or(gt(col_count, 1), ne(test.t1.a, col_firstrow)), if(ne(agg_col_sum, 0), NULL, 0)), and(ne(agg_col_cnt, 0), if(isnull(test.t1.a), NULL, 1)))
└─HashLeftJoin_9 10000.00 root CARTESIAN inner join, inner:StreamAgg_16
├─TableReader_12 10000.00 root data:TableScan_11
│ └─TableScan_11 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo
└─StreamAgg_16 1.00 root funcs:firstrow(col_0), count(distinct col_1), sum(col_2), count(1)
└─Projection_26 10000.00 root test.t2.a, test.t2.a, cast(isnull(test.t2.a))
└─TableReader_23 10000.00 root data:TableScan_22
└─TableScan_22 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo
explain select a = all (select a from t t2) from t t1;
id count task operator info
Projection_9 10000.00 root or(and(and(le(col_count, 1), eq(test.t1.a, col_firstrow)), if(ne(agg_col_sum, 0), NULL, 1)), or(eq(agg_col_cnt, 0), if(isnull(test.t1.a), NULL, 0)))
└─HashLeftJoin_10 10000.00 root CARTESIAN inner join, inner:StreamAgg_17
├─TableReader_13 10000.00 root data:TableScan_12
│ └─TableScan_12 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo
└─StreamAgg_17 1.00 root funcs:firstrow(col_0), count(distinct col_1), sum(col_2), count(1)
└─Projection_27 10000.00 root test.t2.a, test.t2.a, cast(isnull(test.t2.a))
└─TableReader_24 10000.00 root data:TableScan_23
└─TableScan_23 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo
Projection_8 10000.00 root or(and(and(le(col_count, 1), eq(test.t1.a, col_firstrow)), if(ne(agg_col_sum, 0), NULL, 1)), or(eq(agg_col_cnt, 0), if(isnull(test.t1.a), NULL, 0)))
└─HashLeftJoin_9 10000.00 root CARTESIAN inner join, inner:StreamAgg_16
├─TableReader_12 10000.00 root data:TableScan_11
│ └─TableScan_11 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo
└─StreamAgg_16 1.00 root funcs:firstrow(col_0), count(distinct col_1), sum(col_2), count(1)
└─Projection_26 10000.00 root test.t2.a, test.t2.a, cast(isnull(test.t2.a))
└─TableReader_23 10000.00 root data:TableScan_22
└─TableScan_22 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo
drop table if exists t;
create table t(a int, b int);
drop table if exists s;
Expand Down Expand Up @@ -432,6 +432,11 @@ Projection_7 10000.00 root 6_aux_0
│ └─TableScan_9 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo
└─TableReader_12 10000.00 root data:TableScan_11
└─TableScan_11 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo
explain select 1 from (select sleep(1)) t;
id count task operator info
Projection_4 1.00 root 1
└─Projection_5 1.00 root sleep(1)
└─TableDual_6 1.00 root rows:1
drop table if exists t;
create table t(a int, b int);
explain select a from t order by rand();
Expand Down
9 changes: 4 additions & 5 deletions cmd/explaintest/r/topn_pushdown.result
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ explain select * from ((select 4 as a) union all (select 33 as a)) tmp order by
id count task operator info
TopN_17 1.00 root tmp.a:desc, offset:0, count:1
└─Union_21 2.00 root
├─Projection_22 1.00 root cast(a)
│ └─Projection_23 1.00 root 4
│ └─TableDual_24 1.00 root rows:1
└─Projection_26 1.00 root 33
└─TableDual_27 1.00 root rows:1
├─Projection_22 1.00 root cast(4)
│ └─TableDual_23 1.00 root rows:1
└─Projection_24 1.00 root 33
└─TableDual_25 1.00 root rows:1
4 changes: 2 additions & 2 deletions cmd/explaintest/r/tpch.result
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Sort_6 2.94 root tpch.lineitem.l_returnflag:asc, tpch.lineitem.l_linestatus:asc
└─Projection_8 2.94 root tpch.lineitem.l_returnflag, tpch.lineitem.l_linestatus, 3_col_0, 3_col_1, 3_col_2, 3_col_3, 3_col_4, 3_col_5, 3_col_6, 3_col_7
└─HashAgg_14 2.94 root group by:col_13, col_14, funcs:sum(col_0), sum(col_1), sum(col_2), sum(col_3), avg(col_4, col_5), avg(col_6, col_7), avg(col_8, col_9), count(col_10), firstrow(col_13), firstrow(col_14)
└─TableReader_15 2.94 root data:HashAgg_9
└─HashAgg_9 2.94 cop group by:tpch.lineitem.l_linestatus, tpch.lineitem.l_returnflag, funcs:sum(tpch.lineitem.l_quantity), sum(tpch.lineitem.l_extendedprice), sum(mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))), sum(mul(mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount)), plus(1, tpch.lineitem.l_tax))), avg(tpch.lineitem.l_quantity), avg(tpch.lineitem.l_extendedprice), avg(tpch.lineitem.l_discount), count(1)
└─HashAgg_9 2.94 cop group by:tpch.lineitem.l_linestatus, tpch.lineitem.l_returnflag, funcs:sum(tpch.lineitem.l_quantity), sum(tpch.lineitem.l_extendedprice), sum(mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount))), sum(mul(mul(tpch.lineitem.l_extendedprice, minus(1, tpch.lineitem.l_discount)), plus(1, tpch.lineitem.l_tax))), count(tpch.lineitem.l_quantity), sum(tpch.lineitem.l_quantity), count(tpch.lineitem.l_extendedprice), sum(tpch.lineitem.l_extendedprice), count(tpch.lineitem.l_discount), sum(tpch.lineitem.l_discount), count(1)
└─Selection_13 293795345.00 cop le(tpch.lineitem.l_shipdate, 1998-08-15)
└─TableScan_12 300005811.00 cop table:lineitem, range:[-inf,+inf], keep order:false
/*
Expand Down Expand Up @@ -981,7 +981,7 @@ Projection_16 1.00 root div(11_col_0, 7.0)
│ └─TableScan_31 300005811.00 cop table:lineitem, range:[-inf,+inf], keep order:false
└─HashAgg_40 9943040.00 root group by:col_3, funcs:avg(col_0, col_1), firstrow(col_3)
└─TableReader_41 9943040.00 root data:HashAgg_36
└─HashAgg_36 9943040.00 cop group by:tpch.lineitem.l_partkey, funcs:avg(tpch.lineitem.l_quantity)
└─HashAgg_36 9943040.00 cop group by:tpch.lineitem.l_partkey, funcs:count(tpch.lineitem.l_quantity), sum(tpch.lineitem.l_quantity)
└─TableScan_39 300005811.00 cop table:lineitem, range:[-inf,+inf], keep order:false
/*
Q18 Large Volume Customer Query
Expand Down
3 changes: 3 additions & 0 deletions cmd/explaintest/t/access_path_selection.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ explain select a, b from access_path_selection where a < 3;
# In this query, IDX_ab can't be used, so IDX_b is the best.
explain select a, b from access_path_selection where b < 3;
explain select a, b from access_path_selection where a < 3 and b < 3;
# _tidb_rowid should also be considered as PK.
explain select a, b from access_path_selection where a > 10 order by _tidb_rowid;
explain select max(_tidb_rowid) from access_path_selection;
16 changes: 15 additions & 1 deletion cmd/explaintest/t/black_list.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ admin reload opt_rule_blacklist;

explain select * from t where a < 1;

insert into mysql.expr_pushdown_blacklist values('<');

admin reload expr_pushdown_blacklist;

explain select * from t where a < 1;

delete from mysql.expr_pushdown_blacklist where name='<';

admin reload expr_pushdown_blacklist;

explain select * from t where a < 1;

insert into mysql.expr_pushdown_blacklist values('lt');

admin reload expr_pushdown_blacklist;
Expand All @@ -24,4 +36,6 @@ explain select * from t where a < 1;

delete from mysql.expr_pushdown_blacklist where name='lt';

admin reload expr_pushdown_blacklist;
admin reload expr_pushdown_blacklist;

explain select * from t where a < 1;
3 changes: 3 additions & 0 deletions cmd/explaintest/t/select.test
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ drop table t;
create table t(a int not null, b int);
explain select a in (select a from t t2 where t2.b = t1.b) from t t1;

# test sleep in subquery
explain select 1 from (select sleep(1)) t;

# test order by rand()
drop table if exists t;
create table t(a int, b int);
Expand Down
6 changes: 5 additions & 1 deletion ddl/column_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ func (s *testColumnChangeSuite) TearDownSuite(c *C) {
}

func (s *testColumnChangeSuite) TestColumnChange(c *C) {
d := testNewDDL(context.Background(), nil, s.store, nil, nil, testLease)
d := newDDL(
context.Background(),
WithStore(s.store),
WithLease(testLease),
)
defer d.Stop()
// create table t (c1 int, c2 int);
tblInfo := testTableInfo(c, d, "t", 2)
Expand Down
24 changes: 20 additions & 4 deletions ddl/column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ type testColumnSuite struct {

func (s *testColumnSuite) SetUpSuite(c *C) {
s.store = testCreateStore(c, "test_column")
s.d = testNewDDL(context.Background(), nil, s.store, nil, nil, testLease)
s.d = newDDL(
context.Background(),
WithStore(s.store),
WithLease(testLease),
)

s.dbInfo = testSchemaInfo(c, s.d, "test_column")
testCreateSchema(c, testNewContext(s.d), s.d, s.dbInfo)
Expand Down Expand Up @@ -753,7 +757,11 @@ func (s *testColumnSuite) testGetColumn(t table.Table, name string, isExist bool
}

func (s *testColumnSuite) TestAddColumn(c *C) {
d := testNewDDL(context.Background(), nil, s.store, nil, nil, testLease)
d := newDDL(
context.Background(),
WithStore(s.store),
WithLease(testLease),
)
tblInfo := testTableInfo(c, d, "t", 3)
ctx := testNewContext(d)

Expand Down Expand Up @@ -842,7 +850,11 @@ func (s *testColumnSuite) TestAddColumn(c *C) {
}

func (s *testColumnSuite) TestDropColumn(c *C) {
d := testNewDDL(context.Background(), nil, s.store, nil, nil, testLease)
d := newDDL(
context.Background(),
WithStore(s.store),
WithLease(testLease),
)
tblInfo := testTableInfo(c, d, "t", 4)
ctx := testNewContext(d)

Expand Down Expand Up @@ -919,7 +931,11 @@ func (s *testColumnSuite) TestDropColumn(c *C) {
}

func (s *testColumnSuite) TestModifyColumn(c *C) {
d := testNewDDL(context.Background(), nil, s.store, nil, nil, testLease)
d := newDDL(
context.Background(),
WithStore(s.store),
WithLease(testLease),
)
defer d.Stop()
tests := []struct {
origin string
Expand Down
Loading

0 comments on commit 6c38a18

Please sign in to comment.