Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext
Browse files Browse the repository at this point in the history
Conflicts:
	sql/sp_rcontext.cc
  • Loading branch information
montywi committed Jan 21, 2018
2 parents c6cd64f + 6b7dcef commit 27a5d96
Show file tree
Hide file tree
Showing 18 changed files with 381 additions and 66 deletions.
1 change: 1 addition & 0 deletions BUILD/SETUP.sh
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,4 @@ gprof_compile_flags="-O2 -pg -g"

gprof_link_flags="--disable-shared $static_link"

disable_gprof_plugins="--with-zlib-dir=bundled --without-plugin-oqgraph --without-plugin-mroonga"
2 changes: 1 addition & 1 deletion BUILD/compile-pentium-gprof
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ path=`dirname $0`
. "$path/SETUP.sh"

extra_flags="$pentium_cflags $gprof_compile_flags"
extra_configs="$pentium_configs $debug_configs $gprof_link_flags $disable_64_bit_plugins"
extra_configs="$pentium_configs $debug_configs $gprof_link_flags $disable_64_bit_plugins $disable_gprof_plugins"

. "$path/FINISH.sh"
2 changes: 1 addition & 1 deletion BUILD/compile-pentium64-gcov
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export LDFLAGS="$gcov_link_flags"
extra_flags="$pentium64_cflags $max_cflags $gcov_compile_flags"
c_warnings="$c_warnings $debug_extra_warnings"
cxx_warnings="$cxx_warnings $debug_extra_warnings"
extra_configs="$pentium_configs $debug_configs $gcov_configs $max_configs"
extra_configs="$pentium_configs $debug_configs $gcov_configs $max_configs --without-oqgraph"

. "$path/FINISH.sh"
2 changes: 1 addition & 1 deletion BUILD/compile-pentium64-gprof
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ path=`dirname $0`
. "$path/SETUP.sh"

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

. "$path/FINISH.sh"
74 changes: 74 additions & 0 deletions mysql-test/r/cte_nonrecursive.result
Original file line number Diff line number Diff line change
Expand Up @@ -1295,3 +1295,77 @@ TERM03 TERM03
TERM01 NULL
NULL TERM04
drop table t1,t2;
#
# MDEV-14969: view using subquery with attached CTE
#
create table region (
r_regionkey int,
r_name char(25),
primary key (r_regionkey)
);
insert into region values
(0,'AFRICA'), (1,'AMERICA'), (2,'ASIA'), (3,'EUROPE'), (4,'MIDDLE EAST');
create table nation (
n_nationkey int,
n_name char(25),
n_regionkey int,
primary key (n_nationkey),
key i_n_regionkey (n_regionkey)
);
insert into nation values
(0,'ALGERIA',0), (1,'ARGENTINA',1), (2,'BRAZIL',1), (3,'CANADA',1),
(4,'EGYPT',4), (5,'ETHIOPIA',0), (6,'FRANCE',3), (7,'GERMANY',3),
(8,'INDIA',2), (9,'INDONESIA',2), (10,'IRAN',4), (11,'IRAQ',4),
(12,'JAPAN',2), (13,'JORDAN',4), (14,'KENYA',0), (15,'MOROCCO',0),
(16,'MOZAMBIQUE',0), (17,'PERU',1), (18,'CHINA',2), (19,'ROMANIA',3),
(20,'SAUDI ARABIA',4), (21,'VIETNAM',2), (22,'RUSSIA',3),
(23,'UNITED KINGDOM',3), (24,'UNITED STATES',1);
select * from nation n ,region r
where n.n_regionkey = r.r_regionkey and
r.r_regionkey in
(with t as (select * from region where r_regionkey <= 3 )
select r_regionkey from t where r_name <> "ASIA");
n_nationkey n_name n_regionkey r_regionkey r_name
0 ALGERIA 0 0 AFRICA
5 ETHIOPIA 0 0 AFRICA
14 KENYA 0 0 AFRICA
15 MOROCCO 0 0 AFRICA
16 MOZAMBIQUE 0 0 AFRICA
1 ARGENTINA 1 1 AMERICA
2 BRAZIL 1 1 AMERICA
3 CANADA 1 1 AMERICA
17 PERU 1 1 AMERICA
24 UNITED STATES 1 1 AMERICA
6 FRANCE 3 3 EUROPE
7 GERMANY 3 3 EUROPE
19 ROMANIA 3 3 EUROPE
22 RUSSIA 3 3 EUROPE
23 UNITED KINGDOM 3 3 EUROPE
create view v as
select * from nation n ,region r
where n.n_regionkey = r.r_regionkey and
r.r_regionkey in
(with t as (select * from region where r_regionkey <= 3)
select r_regionkey from t where r_name <> "ASIA");
show create view v;
View Create View character_set_client collation_connection
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
select * from v;
n_nationkey n_name n_regionkey r_regionkey r_name
0 ALGERIA 0 0 AFRICA
5 ETHIOPIA 0 0 AFRICA
14 KENYA 0 0 AFRICA
15 MOROCCO 0 0 AFRICA
16 MOZAMBIQUE 0 0 AFRICA
1 ARGENTINA 1 1 AMERICA
2 BRAZIL 1 1 AMERICA
3 CANADA 1 1 AMERICA
17 PERU 1 1 AMERICA
24 UNITED STATES 1 1 AMERICA
6 FRANCE 3 3 EUROPE
7 GERMANY 3 3 EUROPE
19 ROMANIA 3 3 EUROPE
22 RUSSIA 3 3 EUROPE
23 UNITED KINGDOM 3 3 EUROPE
drop view v;
drop table region, nation;
105 changes: 105 additions & 0 deletions mysql-test/suite/maria/max_length.result
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,108 @@ Table Op Msg_type Msg_text
test.t1 check warning Datafile is almost full, 268230656 of 268320768 used
test.t1 check status OK
drop table t1,t2;
create table t1 (
c1 int unsigned,
c2 char(80)
) Engine=ARIA ROW_FORMAT=FIXED min_rows=1000000;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(10) unsigned DEFAULT NULL,
`c2` char(80) DEFAULT NULL
) ENGINE=Aria DEFAULT CHARSET=latin1 MIN_ROWS=1000000 PAGE_CHECKSUM=1 ROW_FORMAT=FIXED
insert into t1 select seq,seq from seq_1_to_100000;
create or replace table t1 (
c1 int unsigned,
c2 char(80)
) Engine=ARIA ROW_FORMAT=FIXED;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(10) unsigned DEFAULT NULL,
`c2` char(80) DEFAULT NULL
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 ROW_FORMAT=FIXED
insert into t1 select seq,seq from seq_1_to_100000;
create or replace table t1 (
c1 int unsigned,
c2 char(80)
) Engine=ARIA ROW_FORMAT=PAGE TRANSACTIONAL=0;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(10) unsigned DEFAULT NULL,
`c2` char(80) DEFAULT NULL
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 ROW_FORMAT=PAGE TRANSACTIONAL=0
insert into t1 select seq,seq from seq_1_to_100000;
create or replace table t1 (
c1 int unsigned,
c2 char(80)
) Engine=ARIA ROW_FORMAT=FIXED MAX_ROWS=10;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(10) unsigned DEFAULT NULL,
`c2` char(80) DEFAULT NULL
) ENGINE=Aria DEFAULT CHARSET=latin1 MAX_ROWS=10 PAGE_CHECKSUM=1 ROW_FORMAT=FIXED
insert into t1 select seq,seq from seq_1_to_100000;
ERROR HY000: The table 't1' is full
select count(*) from t1;
count(*)
65535
create or replace table t1 (
c1 int unsigned,
c2 char(80)
) Engine=ARIA ROW_FORMAT=DYNAMIC MAX_ROWS=10;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(10) unsigned DEFAULT NULL,
`c2` char(80) DEFAULT NULL
) ENGINE=Aria DEFAULT CHARSET=latin1 MAX_ROWS=10 PAGE_CHECKSUM=1 ROW_FORMAT=DYNAMIC
insert into t1 select seq,seq from seq_1_to_100000;
ERROR HY000: The table 't1' is full
select count(*) from t1;
count(*)
3276
check table t1;
Table Op Msg_type Msg_text
test.t1 check warning Datafile is almost full, 65520 of 65535 used
test.t1 check status OK
create or replace table t1 (
c1 int unsigned,
c2 char(80)
) Engine=ARIA ROW_FORMAT=PAGE MAX_ROWS=10;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(10) unsigned DEFAULT NULL,
`c2` char(80) DEFAULT NULL
) ENGINE=Aria DEFAULT CHARSET=latin1 MAX_ROWS=10 PAGE_CHECKSUM=1 ROW_FORMAT=PAGE
insert into t1 select seq,seq from seq_1_to_100000;
select count(*) from t1;
count(*)
100000
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create or replace table t1 (
c1 int unsigned,
c2 char(80)
) Engine=ARIA ROW_FORMAT=PAGE MAX_ROWS=10;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(10) unsigned DEFAULT NULL,
`c2` char(80) DEFAULT NULL
) ENGINE=Aria DEFAULT CHARSET=latin1 MAX_ROWS=10 PAGE_CHECKSUM=1 ROW_FORMAT=PAGE
insert into t1 select seq,seq from seq_1_to_10000000;
ERROR HY000: The table 't1' is full
select count(*) from t1;
count(*)
6189940
check table t1;
Table Op Msg_type Msg_text
test.t1 check warning Datafile is almost full, 268320768 of 268320768 used
test.t1 check status OK
drop table t1;
72 changes: 72 additions & 0 deletions mysql-test/suite/maria/max_length.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# This test will use around 1.3G of disk space!

--source include/have_maria.inc
--source include/have_sequence.inc
--source include/big_test.inc

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

drop table t1,t2;

#
# Check that we don't get table-is-full
#

create table t1 (
c1 int unsigned,
c2 char(80)
) Engine=ARIA ROW_FORMAT=FIXED min_rows=1000000;
show create table t1;
insert into t1 select seq,seq from seq_1_to_100000;

create or replace table t1 (
c1 int unsigned,
c2 char(80)
) Engine=ARIA ROW_FORMAT=FIXED;
show create table t1;
insert into t1 select seq,seq from seq_1_to_100000;

create or replace table t1 (
c1 int unsigned,
c2 char(80)
) Engine=ARIA ROW_FORMAT=PAGE TRANSACTIONAL=0;
show create table t1;
insert into t1 select seq,seq from seq_1_to_100000;

#
# For these we should get table is full error
#

create or replace table t1 (
c1 int unsigned,
c2 char(80)
) Engine=ARIA ROW_FORMAT=FIXED MAX_ROWS=10;
show create table t1;
--error ER_RECORD_FILE_FULL
insert into t1 select seq,seq from seq_1_to_100000;
select count(*) from t1;

create or replace table t1 (
c1 int unsigned,
c2 char(80)
) Engine=ARIA ROW_FORMAT=DYNAMIC MAX_ROWS=10;
show create table t1;
--error ER_RECORD_FILE_FULL
insert into t1 select seq,seq from seq_1_to_100000;
select count(*) from t1;
check table t1;

# PAGE uses 3 byte pointers as minimum, which can handle up to 200M files

create or replace table t1 (
c1 int unsigned,
c2 char(80)
) Engine=ARIA ROW_FORMAT=PAGE MAX_ROWS=10;
show create table t1;
insert into t1 select seq,seq from seq_1_to_100000;
select count(*) from t1;
check table t1;
drop table t1;

create or replace table t1 (
c1 int unsigned,
c2 char(80)
) Engine=ARIA ROW_FORMAT=PAGE MAX_ROWS=10;
show create table t1;
--error ER_RECORD_FILE_FULL
insert into t1 select seq,seq from seq_1_to_10000000;
select count(*) from t1;
check table t1;
drop table t1;
47 changes: 47 additions & 0 deletions mysql-test/t/cte_nonrecursive.test
Original file line number Diff line number Diff line change
Expand Up @@ -882,3 +882,50 @@ union all
where c1.term is null);

drop table t1,t2;

--echo #
--echo # MDEV-14969: view using subquery with attached CTE
--echo #

create table region (
r_regionkey int,
r_name char(25),
primary key (r_regionkey)
);
insert into region values
(0,'AFRICA'), (1,'AMERICA'), (2,'ASIA'), (3,'EUROPE'), (4,'MIDDLE EAST');

create table nation (
n_nationkey int,
n_name char(25),
n_regionkey int,
primary key (n_nationkey),
key i_n_regionkey (n_regionkey)
);
insert into nation values
(0,'ALGERIA',0), (1,'ARGENTINA',1), (2,'BRAZIL',1), (3,'CANADA',1),
(4,'EGYPT',4), (5,'ETHIOPIA',0), (6,'FRANCE',3), (7,'GERMANY',3),
(8,'INDIA',2), (9,'INDONESIA',2), (10,'IRAN',4), (11,'IRAQ',4),
(12,'JAPAN',2), (13,'JORDAN',4), (14,'KENYA',0), (15,'MOROCCO',0),
(16,'MOZAMBIQUE',0), (17,'PERU',1), (18,'CHINA',2), (19,'ROMANIA',3),
(20,'SAUDI ARABIA',4), (21,'VIETNAM',2), (22,'RUSSIA',3),
(23,'UNITED KINGDOM',3), (24,'UNITED STATES',1);

select * from nation n ,region r
where n.n_regionkey = r.r_regionkey and
r.r_regionkey in
(with t as (select * from region where r_regionkey <= 3 )
select r_regionkey from t where r_name <> "ASIA");

create view v as
select * from nation n ,region r
where n.n_regionkey = r.r_regionkey and
r.r_regionkey in
(with t as (select * from region where r_regionkey <= 3)
select r_regionkey from t where r_name <> "ASIA");

show create view v;
select * from v;

drop view v;
drop table region, nation;
3 changes: 3 additions & 0 deletions sql/item_subselect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4357,6 +4357,9 @@ table_map subselect_union_engine::upper_select_const_tables()
void subselect_single_select_engine::print(String *str,
enum_query_type query_type)
{
With_clause* with_clause= select_lex->get_with_clause();
if (with_clause)
with_clause->print(str, query_type);
select_lex->print(get_thd(), str, query_type);
}

Expand Down
8 changes: 7 additions & 1 deletion sql/sp_rcontext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,27 @@ sp_rcontext *sp_rcontext::create(THD *thd,
Field *return_value_fld,
Row_definition_list &field_def_lst)
{
SELECT_LEX *save_current_select;
sp_rcontext *ctx= new (thd->mem_root) sp_rcontext(owner,
root_parsing_ctx,
return_value_fld,
thd->in_sub_stmt);
if (!ctx)
return NULL;

/* Reset current_select as it's checked in Item_ident::Item_ident */
save_current_select= thd->lex->current_select;
thd->lex->current_select= 0;

if (ctx->alloc_arrays(thd) ||
ctx->init_var_table(thd, field_def_lst) ||
ctx->init_var_items(thd, field_def_lst))
{
delete ctx;
return NULL;
ctx= 0;
}

thd->lex->current_select= save_current_select;
return ctx;
}

Expand Down
Loading

0 comments on commit 27a5d96

Please sign in to comment.