Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/10.2' into 10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Barkov committed Apr 22, 2017
2 parents ef6e03d + 54a995c commit 530396c
Show file tree
Hide file tree
Showing 82 changed files with 2,247 additions and 1,892 deletions.
2 changes: 2 additions & 0 deletions mysql-test/r/check_constraint.result
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ create table t1 (a int, b int, check(a>0));
alter table t1 drop column a;
ERROR 42S22: Unknown column 'a' in 'CHECK'
drop table t1;
create or replace table t1( c1 int auto_increment primary key, check( c1 > 0 or c1 is null ) );
ERROR HY000: Function or expression 'AUTO_INCREMENT' cannot be used in the CHECK clause of `c1`
create table t1 (a int check (@b in (select user from mysql.user)));
ERROR HY000: Function or expression 'select ...' cannot be used in the CHECK clause of `a`
create table t1 (a int check (a > @b));
Expand Down
210 changes: 210 additions & 0 deletions mysql-test/r/cte_recursive.result
Original file line number Diff line number Diff line change
Expand Up @@ -2560,3 +2560,213 @@ m
m1
m2
drop table value_nodes, module_nodes, module_arguments, module_results;
#
# mdev-12519: recursive references in subqueries
#
create table t1 (lp char(4) not null, rp char(4) not null);
insert into t1 values
('p1','p2'), ('p2','p3'), ('p3','p4'), ('p4','p5'),
('p2','p7'), ('p7','p8'), ('p8','p3'), ('p8','p4');
set standard_compliant_cte=0;
with recursive
reachables(p) as
(
select lp from t1 where lp = 'p1'
union
select t1.rp from reachables, t1
where t1.lp = reachables.p
)
select * from reachables;
p
p1
p2
p3
p7
p4
p8
p5
with recursive
reachables(p) as
(
select lp from t1 where lp = 'p1'
union
select t1.rp from reachables, t1
where 'p3' not in (select * from reachables) and
t1.lp = reachables.p
)
select * from reachables;
p
p1
p2
p3
p7
with recursive
reachables(p) as
(
select lp from t1 where lp = 'p1'
union
select t1.rp from reachables, t1
where 'p3' not in (select p from reachables where p <= 'p5'
union
select p from reachables where p > 'p5') and
t1.lp = reachables.p
)
select * from reachables;
p
p1
p2
p3
p7
prepare stmt from "
with recursive
reachables(p) as
(
select lp from t1 where lp = 'p1'
union
select t1.rp from reachables, t1
where 'p3' not in (select p from reachables where p <= 'p5'
union
select p from reachables where p > 'p5') and
t1.lp = reachables.p
)
select * from reachables;
";
execute stmt;
p
p1
p2
p3
p7
execute stmt;
p
p1
p2
p3
p7
deallocate prepare stmt;
drop table t1;
create table objects(v char(4) not null);
insert into objects values
('v1'), ('v2'), ('v3'), ('v4'), ('v5'),
('v6'), ('v7'), ('v8'), ('v9'), ('v10');
create table modules(m char(4) not null);
insert into modules values
('m1'), ('m2'), ('m3'), ('m4');
create table module_arguments(m char(4) not null, v char(4) not null);
insert into module_arguments values
('m1','v3'), ('m1','v9'),
('m2','v4'), ('m2','v7'),
('m3','v6'), ('m4','v2');
create table module_results(m char(4) not null, v char(4) not null);
insert into module_results values
('m1','v4'),
('m2','v1'), ('m2','v6'),
('m3','v10'), ('m4','v7');
set standard_compliant_cte=0;
with recursive
reached_objects as
(
select v, 'init' as m from objects where v in ('v3','v7','v9')
union
select module_results.v, module_results.m from module_results, applied_modules
where module_results.m = applied_modules.m
),
applied_modules as
(
select * from modules where 1=0
union
select modules.m
from
modules
where
not exists (select * from module_arguments
where module_arguments.m = modules.m and
module_arguments.v not in
(select v from reached_objects))
)
select * from reached_objects;
v m
v3 init
v7 init
v9 init
v4 m1
v1 m2
v6 m2
v10 m3
with recursive
reached_objects as
(
select v, 'init' as m from objects where v in ('v3','v7','v9')
union
select module_results.v, module_results.m from module_results, applied_modules
where module_results.m = applied_modules.m
),
applied_modules as
(
select * from modules where 1=0
union
select modules.m
from
modules
where
'v6' not in (select v from reached_objects) and
not exists (select * from module_arguments
where module_arguments.m = modules.m and
module_arguments.v not in
(select v from reached_objects))
)
select * from reached_objects;
v m
v3 init
v7 init
v9 init
v4 m1
v1 m2
v6 m2
prepare stmt from "
with recursive
reached_objects as
(
select v, 'init' as m from objects where v in ('v3','v7','v9')
union
select module_results.v, module_results.m from module_results, applied_modules
where module_results.m = applied_modules.m
),
applied_modules as
(
select * from modules where 1=0
union
select modules.m
from
modules
where
'v6' not in (select v from reached_objects) and
not exists (select * from module_arguments
where module_arguments.m = modules.m and
module_arguments.v not in
(select v from reached_objects))
)
select * from reached_objects;
";
execute stmt;
v m
v3 init
v7 init
v9 init
v4 m1
v1 m2
v6 m2
execute stmt;
v m
v3 init
v7 init
v9 init
v4 m1
v1 m2
v6 m2
deallocate prepare stmt;
drop table objects, modules, module_arguments, module_results;
set standard_compliant_cte=default;
select @@standard_compliant_cte;
@@standard_compliant_cte
1
15 changes: 15 additions & 0 deletions mysql-test/r/default.result
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,21 @@ SELECT * FROM t1;
a b c
2003-02-01 2003-05-01 12:05:55 128885
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 ( col INT DEFAULT ( 1 LIKE ( NOW() BETWEEN '2000-01-01' AND '2012-12-12' ) ) );
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`col` int(11) DEFAULT (1 like (current_timestamp() between '2000-01-01' and '2012-12-12'))
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SET timestamp = UNIX_TIMESTAMP( '2004-04-04' );
INSERT INTO t1 VALUES( DEFAULT );
SET timestamp = DEFAULT;
INSERT INTO t1 VALUES( DEFAULT );
SELECT * FROM t1;
col
1
0
DROP TABLE t1;
#
# Hybrid type functions
#
Expand Down
28 changes: 14 additions & 14 deletions mysql-test/r/derived_cond_pushdown.result
Original file line number Diff line number Diff line change
Expand Up @@ -7134,7 +7134,7 @@ EXPLAIN
{
"query_block": {
"select_id": 1,
"const_condition": "0 or <in_optimizer>(2,<exists>(subquery#3))",
"const_condition": "2 < 2 or <in_optimizer>(2,<exists>(subquery#3))",
"table": {
"table_name": "t1",
"access_type": "system",
Expand Down Expand Up @@ -7218,7 +7218,7 @@ EXPLAIN
{
"query_block": {
"select_id": 1,
"const_condition": "0 or <in_optimizer>(2,<exists>(subquery#3))",
"const_condition": "2 < 2 or <in_optimizer>(2,<exists>(subquery#3))",
"table": {
"table_name": "t1",
"access_type": "system",
Expand Down Expand Up @@ -7684,7 +7684,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 2,
"filtered": 100,
"attached_condition": "v1.b = 2",
"attached_condition": "v1.b = count(t2.c)",
"materialized": {
"query_block": {
"select_id": 3,
Expand Down Expand Up @@ -7741,7 +7741,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 2,
"filtered": 100,
"attached_condition": "v1.f = 2",
"attached_condition": "v1.f = count(t.pk)",
"materialized": {
"query_block": {
"select_id": 3,
Expand All @@ -7761,7 +7761,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 2,
"filtered": 100,
"attached_condition": "v2.pk > 2"
"attached_condition": "v2.pk > count(t.pk)"
},
"buffer_type": "flat",
"buffer_size": "256Kb",
Expand Down Expand Up @@ -7820,7 +7820,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 3,
"filtered": 100,
"attached_condition": "sq.i = 3",
"attached_condition": "sq.i = min(t2.j)",
"materialized": {
"query_block": {
"select_id": 2,
Expand Down Expand Up @@ -7877,7 +7877,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 3,
"filtered": 100,
"attached_condition": "sq.i = 2.7100000381469727",
"attached_condition": "sq.i = min(t2.j)",
"materialized": {
"query_block": {
"select_id": 2,
Expand Down Expand Up @@ -7929,7 +7929,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 3,
"filtered": 100,
"attached_condition": "sq.i = 3.21",
"attached_condition": "sq.i = min(t2.j)",
"materialized": {
"query_block": {
"select_id": 2,
Expand Down Expand Up @@ -7981,7 +7981,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 3,
"filtered": 100,
"attached_condition": "sq.i = 'aa'",
"attached_condition": "sq.i = min(t2.j)",
"materialized": {
"query_block": {
"select_id": 2,
Expand Down Expand Up @@ -8035,7 +8035,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 3,
"filtered": 100,
"attached_condition": "sq.i = 2007-05-28 00:00:00",
"attached_condition": "sq.i = min(t2.j)",
"materialized": {
"query_block": {
"select_id": 2,
Expand Down Expand Up @@ -8087,7 +8087,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 3,
"filtered": 100,
"attached_condition": "sq.i = 2007-05-28",
"attached_condition": "sq.i = min(t2.j)",
"materialized": {
"query_block": {
"select_id": 2,
Expand Down Expand Up @@ -8139,7 +8139,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 3,
"filtered": 100,
"attached_condition": "sq.i = 10:00:02",
"attached_condition": "sq.i = min(t2.j)",
"materialized": {
"query_block": {
"select_id": 2,
Expand Down Expand Up @@ -8230,7 +8230,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 2,
"filtered": 100,
"attached_condition": "v1.c = NULL",
"attached_condition": "v1.c = min(t2.c)",
"materialized": {
"query_block": {
"select_id": 3,
Expand Down Expand Up @@ -8333,7 +8333,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 2,
"filtered": 100,
"attached_condition": "<cache>(<in_optimizer>(1,<exists>(subquery#2))) or v1.c = 'foo'",
"attached_condition": "<in_optimizer>(1,<exists>(subquery#2)) or v1.c = 'foo'",
"materialized": {
"query_block": {
"select_id": 3,
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/r/explain_json.result
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ EXPLAIN
"ref": ["func"],
"rows": 2,
"filtered": 100,
"attached_condition": "trigcond(<cache>(outer_t1.a) = t1.a or t1.a is null)",
"attached_condition": "trigcond(outer_t1.a = t1.a or t1.a is null)",
"using_index": true
}
},
Expand All @@ -827,7 +827,7 @@ EXPLAIN
"buffer_type": "flat",
"buffer_size": "256Kb",
"join_type": "BNL",
"attached_condition": "t2.b <> outer_t1.a and trigcond(<cache>(outer_t1.a) = t1.a or t1.a is null)"
"attached_condition": "t2.b <> outer_t1.a and trigcond(outer_t1.a = t1.a or t1.a is null)"
}
}
}
Expand Down Expand Up @@ -1108,7 +1108,7 @@ EXPLAIN
"access_type": "ALL",
"rows": 2,
"filtered": 100,
"attached_condition": "(case when convert(t1.a using utf8) = <cache>(_utf8'a' collate utf8_bin) then NULL else t1.a end)"
"attached_condition": "(case when convert(t1.a using utf8) = _utf8'a' collate utf8_bin then NULL else t1.a end)"
}
}
}
Expand Down
Loading

0 comments on commit 530396c

Please sign in to comment.