Skip to content

Commit 27a5d96

Browse files
committed
Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext
Conflicts: sql/sp_rcontext.cc
2 parents c6cd64f + 6b7dcef commit 27a5d96

18 files changed

+381
-66
lines changed

BUILD/SETUP.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,3 +307,4 @@ gprof_compile_flags="-O2 -pg -g"
307307

308308
gprof_link_flags="--disable-shared $static_link"
309309

310+
disable_gprof_plugins="--with-zlib-dir=bundled --without-plugin-oqgraph --without-plugin-mroonga"

BUILD/compile-pentium-gprof

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ path=`dirname $0`
1919
. "$path/SETUP.sh"
2020

2121
extra_flags="$pentium_cflags $gprof_compile_flags"
22-
extra_configs="$pentium_configs $debug_configs $gprof_link_flags $disable_64_bit_plugins"
22+
extra_configs="$pentium_configs $debug_configs $gprof_link_flags $disable_64_bit_plugins $disable_gprof_plugins"
2323

2424
. "$path/FINISH.sh"

BUILD/compile-pentium64-gcov

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ export LDFLAGS="$gcov_link_flags"
2828
extra_flags="$pentium64_cflags $max_cflags $gcov_compile_flags"
2929
c_warnings="$c_warnings $debug_extra_warnings"
3030
cxx_warnings="$cxx_warnings $debug_extra_warnings"
31-
extra_configs="$pentium_configs $debug_configs $gcov_configs $max_configs"
31+
extra_configs="$pentium_configs $debug_configs $gcov_configs $max_configs --without-oqgraph"
3232

3333
. "$path/FINISH.sh"

BUILD/compile-pentium64-gprof

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ path=`dirname $0`
2020
. "$path/SETUP.sh"
2121

2222
extra_flags="$pentium64_cflags $gprof_compile_flags"
23-
extra_configs="$pentium_configs $max_configs $gprof_link_flags --with-zlib-dir=bundled"
23+
extra_configs="$pentium_configs $max_configs $gprof_link_flags $disable_gprof_plugins"
2424

2525
. "$path/FINISH.sh"

mysql-test/r/cte_nonrecursive.result

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,3 +1295,77 @@ TERM03 TERM03
12951295
TERM01 NULL
12961296
NULL TERM04
12971297
drop table t1,t2;
1298+
#
1299+
# MDEV-14969: view using subquery with attached CTE
1300+
#
1301+
create table region (
1302+
r_regionkey int,
1303+
r_name char(25),
1304+
primary key (r_regionkey)
1305+
);
1306+
insert into region values
1307+
(0,'AFRICA'), (1,'AMERICA'), (2,'ASIA'), (3,'EUROPE'), (4,'MIDDLE EAST');
1308+
create table nation (
1309+
n_nationkey int,
1310+
n_name char(25),
1311+
n_regionkey int,
1312+
primary key (n_nationkey),
1313+
key i_n_regionkey (n_regionkey)
1314+
);
1315+
insert into nation values
1316+
(0,'ALGERIA',0), (1,'ARGENTINA',1), (2,'BRAZIL',1), (3,'CANADA',1),
1317+
(4,'EGYPT',4), (5,'ETHIOPIA',0), (6,'FRANCE',3), (7,'GERMANY',3),
1318+
(8,'INDIA',2), (9,'INDONESIA',2), (10,'IRAN',4), (11,'IRAQ',4),
1319+
(12,'JAPAN',2), (13,'JORDAN',4), (14,'KENYA',0), (15,'MOROCCO',0),
1320+
(16,'MOZAMBIQUE',0), (17,'PERU',1), (18,'CHINA',2), (19,'ROMANIA',3),
1321+
(20,'SAUDI ARABIA',4), (21,'VIETNAM',2), (22,'RUSSIA',3),
1322+
(23,'UNITED KINGDOM',3), (24,'UNITED STATES',1);
1323+
select * from nation n ,region r
1324+
where n.n_regionkey = r.r_regionkey and
1325+
r.r_regionkey in
1326+
(with t as (select * from region where r_regionkey <= 3 )
1327+
select r_regionkey from t where r_name <> "ASIA");
1328+
n_nationkey n_name n_regionkey r_regionkey r_name
1329+
0 ALGERIA 0 0 AFRICA
1330+
5 ETHIOPIA 0 0 AFRICA
1331+
14 KENYA 0 0 AFRICA
1332+
15 MOROCCO 0 0 AFRICA
1333+
16 MOZAMBIQUE 0 0 AFRICA
1334+
1 ARGENTINA 1 1 AMERICA
1335+
2 BRAZIL 1 1 AMERICA
1336+
3 CANADA 1 1 AMERICA
1337+
17 PERU 1 1 AMERICA
1338+
24 UNITED STATES 1 1 AMERICA
1339+
6 FRANCE 3 3 EUROPE
1340+
7 GERMANY 3 3 EUROPE
1341+
19 ROMANIA 3 3 EUROPE
1342+
22 RUSSIA 3 3 EUROPE
1343+
23 UNITED KINGDOM 3 3 EUROPE
1344+
create view v as
1345+
select * from nation n ,region r
1346+
where n.n_regionkey = r.r_regionkey and
1347+
r.r_regionkey in
1348+
(with t as (select * from region where r_regionkey <= 3)
1349+
select r_regionkey from t where r_name <> "ASIA");
1350+
show create view v;
1351+
View Create View character_set_client collation_connection
1352+
v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `n`.`n_nationkey` AS `n_nationkey`,`n`.`n_name` AS `n_name`,`n`.`n_regionkey` AS `n_regionkey`,`r`.`r_regionkey` AS `r_regionkey`,`r`.`r_name` AS `r_name` from (`nation` `n` join `region` `r`) where `n`.`n_regionkey` = `r`.`r_regionkey` and `r`.`r_regionkey` in (with t as (select `region`.`r_regionkey` AS `r_regionkey`,`region`.`r_name` AS `r_name` from `region` where `region`.`r_regionkey` <= 3)select `t`.`r_regionkey` from `t` where `t`.`r_name` <> 'ASIA') latin1 latin1_swedish_ci
1353+
select * from v;
1354+
n_nationkey n_name n_regionkey r_regionkey r_name
1355+
0 ALGERIA 0 0 AFRICA
1356+
5 ETHIOPIA 0 0 AFRICA
1357+
14 KENYA 0 0 AFRICA
1358+
15 MOROCCO 0 0 AFRICA
1359+
16 MOZAMBIQUE 0 0 AFRICA
1360+
1 ARGENTINA 1 1 AMERICA
1361+
2 BRAZIL 1 1 AMERICA
1362+
3 CANADA 1 1 AMERICA
1363+
17 PERU 1 1 AMERICA
1364+
24 UNITED STATES 1 1 AMERICA
1365+
6 FRANCE 3 3 EUROPE
1366+
7 GERMANY 3 3 EUROPE
1367+
19 ROMANIA 3 3 EUROPE
1368+
22 RUSSIA 3 3 EUROPE
1369+
23 UNITED KINGDOM 3 3 EUROPE
1370+
drop view v;
1371+
drop table region, nation;

mysql-test/suite/maria/max_length.result

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,108 @@ Table Op Msg_type Msg_text
5454
test.t1 check warning Datafile is almost full, 268230656 of 268320768 used
5555
test.t1 check status OK
5656
drop table t1,t2;
57+
create table t1 (
58+
c1 int unsigned,
59+
c2 char(80)
60+
) Engine=ARIA ROW_FORMAT=FIXED min_rows=1000000;
61+
show create table t1;
62+
Table Create Table
63+
t1 CREATE TABLE `t1` (
64+
`c1` int(10) unsigned DEFAULT NULL,
65+
`c2` char(80) DEFAULT NULL
66+
) ENGINE=Aria DEFAULT CHARSET=latin1 MIN_ROWS=1000000 PAGE_CHECKSUM=1 ROW_FORMAT=FIXED
67+
insert into t1 select seq,seq from seq_1_to_100000;
68+
create or replace table t1 (
69+
c1 int unsigned,
70+
c2 char(80)
71+
) Engine=ARIA ROW_FORMAT=FIXED;
72+
show create table t1;
73+
Table Create Table
74+
t1 CREATE TABLE `t1` (
75+
`c1` int(10) unsigned DEFAULT NULL,
76+
`c2` char(80) DEFAULT NULL
77+
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 ROW_FORMAT=FIXED
78+
insert into t1 select seq,seq from seq_1_to_100000;
79+
create or replace table t1 (
80+
c1 int unsigned,
81+
c2 char(80)
82+
) Engine=ARIA ROW_FORMAT=PAGE TRANSACTIONAL=0;
83+
show create table t1;
84+
Table Create Table
85+
t1 CREATE TABLE `t1` (
86+
`c1` int(10) unsigned DEFAULT NULL,
87+
`c2` char(80) DEFAULT NULL
88+
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 ROW_FORMAT=PAGE TRANSACTIONAL=0
89+
insert into t1 select seq,seq from seq_1_to_100000;
90+
create or replace table t1 (
91+
c1 int unsigned,
92+
c2 char(80)
93+
) Engine=ARIA ROW_FORMAT=FIXED MAX_ROWS=10;
94+
show create table t1;
95+
Table Create Table
96+
t1 CREATE TABLE `t1` (
97+
`c1` int(10) unsigned DEFAULT NULL,
98+
`c2` char(80) DEFAULT NULL
99+
) ENGINE=Aria DEFAULT CHARSET=latin1 MAX_ROWS=10 PAGE_CHECKSUM=1 ROW_FORMAT=FIXED
100+
insert into t1 select seq,seq from seq_1_to_100000;
101+
ERROR HY000: The table 't1' is full
102+
select count(*) from t1;
103+
count(*)
104+
65535
105+
create or replace table t1 (
106+
c1 int unsigned,
107+
c2 char(80)
108+
) Engine=ARIA ROW_FORMAT=DYNAMIC MAX_ROWS=10;
109+
show create table t1;
110+
Table Create Table
111+
t1 CREATE TABLE `t1` (
112+
`c1` int(10) unsigned DEFAULT NULL,
113+
`c2` char(80) DEFAULT NULL
114+
) ENGINE=Aria DEFAULT CHARSET=latin1 MAX_ROWS=10 PAGE_CHECKSUM=1 ROW_FORMAT=DYNAMIC
115+
insert into t1 select seq,seq from seq_1_to_100000;
116+
ERROR HY000: The table 't1' is full
117+
select count(*) from t1;
118+
count(*)
119+
3276
120+
check table t1;
121+
Table Op Msg_type Msg_text
122+
test.t1 check warning Datafile is almost full, 65520 of 65535 used
123+
test.t1 check status OK
124+
create or replace table t1 (
125+
c1 int unsigned,
126+
c2 char(80)
127+
) Engine=ARIA ROW_FORMAT=PAGE MAX_ROWS=10;
128+
show create table t1;
129+
Table Create Table
130+
t1 CREATE TABLE `t1` (
131+
`c1` int(10) unsigned DEFAULT NULL,
132+
`c2` char(80) DEFAULT NULL
133+
) ENGINE=Aria DEFAULT CHARSET=latin1 MAX_ROWS=10 PAGE_CHECKSUM=1 ROW_FORMAT=PAGE
134+
insert into t1 select seq,seq from seq_1_to_100000;
135+
select count(*) from t1;
136+
count(*)
137+
100000
138+
check table t1;
139+
Table Op Msg_type Msg_text
140+
test.t1 check status OK
141+
drop table t1;
142+
create or replace table t1 (
143+
c1 int unsigned,
144+
c2 char(80)
145+
) Engine=ARIA ROW_FORMAT=PAGE MAX_ROWS=10;
146+
show create table t1;
147+
Table Create Table
148+
t1 CREATE TABLE `t1` (
149+
`c1` int(10) unsigned DEFAULT NULL,
150+
`c2` char(80) DEFAULT NULL
151+
) ENGINE=Aria DEFAULT CHARSET=latin1 MAX_ROWS=10 PAGE_CHECKSUM=1 ROW_FORMAT=PAGE
152+
insert into t1 select seq,seq from seq_1_to_10000000;
153+
ERROR HY000: The table 't1' is full
154+
select count(*) from t1;
155+
count(*)
156+
6189940
157+
check table t1;
158+
Table Op Msg_type Msg_text
159+
test.t1 check warning Datafile is almost full, 268320768 of 268320768 used
160+
test.t1 check status OK
161+
drop table t1;

mysql-test/suite/maria/max_length.test

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# This test will use around 1.3G of disk space!
33

44
--source include/have_maria.inc
5+
--source include/have_sequence.inc
56
--source include/big_test.inc
67

78
drop table if exists t1,t2;
@@ -50,3 +51,74 @@ insert into t1 (v,b) select v,b from t2;
5051
check table t1;
5152

5253
drop table t1,t2;
54+
55+
#
56+
# Check that we don't get table-is-full
57+
#
58+
59+
create table t1 (
60+
c1 int unsigned,
61+
c2 char(80)
62+
) Engine=ARIA ROW_FORMAT=FIXED min_rows=1000000;
63+
show create table t1;
64+
insert into t1 select seq,seq from seq_1_to_100000;
65+
66+
create or replace table t1 (
67+
c1 int unsigned,
68+
c2 char(80)
69+
) Engine=ARIA ROW_FORMAT=FIXED;
70+
show create table t1;
71+
insert into t1 select seq,seq from seq_1_to_100000;
72+
73+
create or replace table t1 (
74+
c1 int unsigned,
75+
c2 char(80)
76+
) Engine=ARIA ROW_FORMAT=PAGE TRANSACTIONAL=0;
77+
show create table t1;
78+
insert into t1 select seq,seq from seq_1_to_100000;
79+
80+
#
81+
# For these we should get table is full error
82+
#
83+
84+
create or replace table t1 (
85+
c1 int unsigned,
86+
c2 char(80)
87+
) Engine=ARIA ROW_FORMAT=FIXED MAX_ROWS=10;
88+
show create table t1;
89+
--error ER_RECORD_FILE_FULL
90+
insert into t1 select seq,seq from seq_1_to_100000;
91+
select count(*) from t1;
92+
93+
create or replace table t1 (
94+
c1 int unsigned,
95+
c2 char(80)
96+
) Engine=ARIA ROW_FORMAT=DYNAMIC MAX_ROWS=10;
97+
show create table t1;
98+
--error ER_RECORD_FILE_FULL
99+
insert into t1 select seq,seq from seq_1_to_100000;
100+
select count(*) from t1;
101+
check table t1;
102+
103+
# PAGE uses 3 byte pointers as minimum, which can handle up to 200M files
104+
105+
create or replace table t1 (
106+
c1 int unsigned,
107+
c2 char(80)
108+
) Engine=ARIA ROW_FORMAT=PAGE MAX_ROWS=10;
109+
show create table t1;
110+
insert into t1 select seq,seq from seq_1_to_100000;
111+
select count(*) from t1;
112+
check table t1;
113+
drop table t1;
114+
115+
create or replace table t1 (
116+
c1 int unsigned,
117+
c2 char(80)
118+
) Engine=ARIA ROW_FORMAT=PAGE MAX_ROWS=10;
119+
show create table t1;
120+
--error ER_RECORD_FILE_FULL
121+
insert into t1 select seq,seq from seq_1_to_10000000;
122+
select count(*) from t1;
123+
check table t1;
124+
drop table t1;

mysql-test/t/cte_nonrecursive.test

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,3 +882,50 @@ union all
882882
where c1.term is null);
883883

884884
drop table t1,t2;
885+
886+
--echo #
887+
--echo # MDEV-14969: view using subquery with attached CTE
888+
--echo #
889+
890+
create table region (
891+
r_regionkey int,
892+
r_name char(25),
893+
primary key (r_regionkey)
894+
);
895+
insert into region values
896+
(0,'AFRICA'), (1,'AMERICA'), (2,'ASIA'), (3,'EUROPE'), (4,'MIDDLE EAST');
897+
898+
create table nation (
899+
n_nationkey int,
900+
n_name char(25),
901+
n_regionkey int,
902+
primary key (n_nationkey),
903+
key i_n_regionkey (n_regionkey)
904+
);
905+
insert into nation values
906+
(0,'ALGERIA',0), (1,'ARGENTINA',1), (2,'BRAZIL',1), (3,'CANADA',1),
907+
(4,'EGYPT',4), (5,'ETHIOPIA',0), (6,'FRANCE',3), (7,'GERMANY',3),
908+
(8,'INDIA',2), (9,'INDONESIA',2), (10,'IRAN',4), (11,'IRAQ',4),
909+
(12,'JAPAN',2), (13,'JORDAN',4), (14,'KENYA',0), (15,'MOROCCO',0),
910+
(16,'MOZAMBIQUE',0), (17,'PERU',1), (18,'CHINA',2), (19,'ROMANIA',3),
911+
(20,'SAUDI ARABIA',4), (21,'VIETNAM',2), (22,'RUSSIA',3),
912+
(23,'UNITED KINGDOM',3), (24,'UNITED STATES',1);
913+
914+
select * from nation n ,region r
915+
where n.n_regionkey = r.r_regionkey and
916+
r.r_regionkey in
917+
(with t as (select * from region where r_regionkey <= 3 )
918+
select r_regionkey from t where r_name <> "ASIA");
919+
920+
create view v as
921+
select * from nation n ,region r
922+
where n.n_regionkey = r.r_regionkey and
923+
r.r_regionkey in
924+
(with t as (select * from region where r_regionkey <= 3)
925+
select r_regionkey from t where r_name <> "ASIA");
926+
927+
show create view v;
928+
select * from v;
929+
930+
drop view v;
931+
drop table region, nation;

sql/item_subselect.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4357,6 +4357,9 @@ table_map subselect_union_engine::upper_select_const_tables()
43574357
void subselect_single_select_engine::print(String *str,
43584358
enum_query_type query_type)
43594359
{
4360+
With_clause* with_clause= select_lex->get_with_clause();
4361+
if (with_clause)
4362+
with_clause->print(str, query_type);
43604363
select_lex->print(get_thd(), str, query_type);
43614364
}
43624365

sql/sp_rcontext.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,27 @@ sp_rcontext *sp_rcontext::create(THD *thd,
6868
Field *return_value_fld,
6969
Row_definition_list &field_def_lst)
7070
{
71+
SELECT_LEX *save_current_select;
7172
sp_rcontext *ctx= new (thd->mem_root) sp_rcontext(owner,
7273
root_parsing_ctx,
7374
return_value_fld,
7475
thd->in_sub_stmt);
7576
if (!ctx)
7677
return NULL;
7778

79+
/* Reset current_select as it's checked in Item_ident::Item_ident */
80+
save_current_select= thd->lex->current_select;
81+
thd->lex->current_select= 0;
82+
7883
if (ctx->alloc_arrays(thd) ||
7984
ctx->init_var_table(thd, field_def_lst) ||
8085
ctx->init_var_items(thd, field_def_lst))
8186
{
8287
delete ctx;
83-
return NULL;
88+
ctx= 0;
8489
}
8590

91+
thd->lex->current_select= save_current_select;
8692
return ctx;
8793
}
8894

0 commit comments

Comments
 (0)