1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge 10.5 into 10.6

This commit is contained in:
Marko Mäkelä
2021-03-08 10:51:31 +02:00
20 changed files with 466 additions and 75 deletions

View File

@@ -4521,13 +4521,12 @@ fail_before_log_copying_thread_start:
log_file_op = NULL; log_file_op = NULL;
pthread_mutex_destroy(&backup_mutex); pthread_mutex_destroy(&backup_mutex);
pthread_cond_destroy(&scanned_lsn_cond); pthread_cond_destroy(&scanned_lsn_cond);
if (opt_log_innodb_page_corruption && !corrupted_pages.empty()) { if (!corrupted_pages.empty()) {
ut_ad(opt_log_innodb_page_corruption);
msg("Error: corrupted innodb pages are found and logged to " msg("Error: corrupted innodb pages are found and logged to "
MB_CORRUPTED_PAGES_FILE " file"); MB_CORRUPTED_PAGES_FILE " file");
return false;
} }
else return(true);
return(true);
} }

View File

@@ -2885,6 +2885,181 @@ drop table t1,t2,t3;
select sum((values(1))); select sum((values(1)));
sum((values(1))) sum((values(1)))
1 1
#
# MDEV-22786: Nested table values constructors
#
values ((values (2)));
(values (2))
2
values ((values (2)), (5), (select 4));
(values (2)) 5 (select 4)
2 5 4
values ((7), (values (2)), (5), (select 4));
7 (values (2)) 5 (select 4)
7 2 5 4
values ((values (2))) union values ((values (3)));
(values (2))
2
3
values ((values (2))), ((values (3)));
(values (2))
2
3
values ((values (2))), ((select 4)), ((values (3)));
(values (2))
2
4
3
values ((values (4)), (values (5))), ((values (1)), (values (7)));
(values (4)) (values (5))
4 5
1 7
values ((values (4)), (select 5)), ((select 1), (values (7)));
(values (4)) (select 5)
4 5
1 7
values ((select 2)) union values ((values (3)));
(select 2)
2
3
values ((values (2))) union values((select 3));
(values (2))
2
3
values ((values (2))) union all values ((values (2)));
(values (2))
2
2
values ((values (4)), (values (5))), ((values (1)), (values (7)))
union
values ((values (4)), (select 5)), ((select 2), (values (8)));
(values (4)) (values (5))
4 5
1 7
2 8
values ((values (4)), (values (5))), ((values (1)), (values (7)))
union all
values ((values (4)), (select 5)), ((select 2), (values (8)));
(values (4)) (values (5))
4 5
1 7
4 5
2 8
values ((values (1) union values (1)));
(values (1) union values (1))
1
values ((values (1) union values (1) union values (1)));
(values (1) union values (1) union values (1))
1
values ((values ((values (4)))));
(values ((values (4))))
4
values ((values ((select 5))));
(values ((select 5)))
5
values ((select (values (4))), (values ((values(5)))));
(select (values (4))) (values ((values(5))))
4 5
values ((select (values (4))), (values ((select 5))));
(select (values (4))) (values ((select 5)))
4 5
values ((select (values (4))), (values ((values(5)))))
union
values ((select (values (4))), (values ((select 7))));
(select (values (4))) (values ((values(5))))
4 5
4 7
values ((values (2))), ((values ((values (4)))));
(values (2))
2
4
values ((values (2))), ((values ((select 4))));
(values (2))
2
4
values ((values (2))), ((values ((values (4)))))
union
values ((values (8))), ((values ((select 4))));
(values (2))
2
4
8
values ((values (2))), ((values ((values (4)))))
union all
values ((values (8))), ((values ((select 4))));
(values (2))
2
4
8
4
select * from (values ((values (2)))) dt;
(values (2))
2
select * from (values ((values (2)), (5), (select 4))) dt;
(values (2)) 5 (select 4)
2 5 4
select * from (values ((values (2))) union values ((values (3)))) dt;
(values (2))
2
3
select * from (values ((values (2))), ((values (3)))) dt;
(values (2))
2
3
select * from (values ((values (2))), ((values (3)))) dt;
(values (2))
2
3
select * from (values ((values (2))), ((select 4)), ((values (3)))) dt;
(values (2))
2
4
3
create table t1 (a int);
insert into t1 values (3), (7), (1);
values ((values ((select a from t1 where a=7))));
(values ((select a from t1 where a=7)))
7
values ((values ((select (values(2)) from t1 where a=8))));
(values ((select (values(2)) from t1 where a=8)))
NULL
values ((values ((select a from t1 where a=7))))
union
values ((values ((select (values(2)) from t1 where a=8))));
(values ((select a from t1 where a=7)))
7
NULL
values ((values ((select a from t1 where a in ((values (7)))))));
(values ((select a from t1 where a in ((values (7))))))
7
values ((values ((select a from t1 where a in ((values (7), (8)))))));
(values ((select a from t1 where a in ((values (7), (8))))))
7
values ((values
((select a from t1 where a in (values (7) union values (8))))));
(values
((select a from t1 where a in (values (7) union values (8)))))
7
values ((values ((select (values(2)) from t1 where a=8))));
(values ((select (values(2)) from t1 where a=8)))
NULL
values ((select (values(2)) from t1 where a<7));
ERROR 21000: Subquery returns more than 1 row
select * from (values ((values ((select a from t1 where a=7))))) dt;
(values ((select a from t1 where a=7)))
7
select * from (values ((values ((select (values(2)) from t1 where a=8))))) dt;
(values ((select (values(2)) from t1 where a=8)))
NULL
insert into t1(a) values ((values (2))), ((values (3)));
select * from t1;
a
3
7
1
2
3
drop table t1;
End of 10.3 tests End of 10.3 tests
# #
# MDEV-22610 Crash in INSERT INTO t1 (VALUES (DEFAULT) UNION VALUES (DEFAULT)) # MDEV-22610 Crash in INSERT INTO t1 (VALUES (DEFAULT) UNION VALUES (DEFAULT))

View File

@@ -1522,6 +1522,112 @@ drop table t1,t2,t3;
select sum((values(1))); select sum((values(1)));
--echo #
--echo # MDEV-22786: Nested table values constructors
--echo #
values ((values (2)));
values ((values (2)), (5), (select 4));
values ((7), (values (2)), (5), (select 4));
values ((values (2))) union values ((values (3)));
values ((values (2))), ((values (3)));
values ((values (2))), ((select 4)), ((values (3)));
values ((values (4)), (values (5))), ((values (1)), (values (7)));
values ((values (4)), (select 5)), ((select 1), (values (7)));
values ((select 2)) union values ((values (3)));
values ((values (2))) union values((select 3));
values ((values (2))) union all values ((values (2)));
values ((values (4)), (values (5))), ((values (1)), (values (7)))
union
values ((values (4)), (select 5)), ((select 2), (values (8)));
values ((values (4)), (values (5))), ((values (1)), (values (7)))
union all
values ((values (4)), (select 5)), ((select 2), (values (8)));
values ((values (1) union values (1)));
values ((values (1) union values (1) union values (1)));
values ((values ((values (4)))));
values ((values ((select 5))));
values ((select (values (4))), (values ((values(5)))));
values ((select (values (4))), (values ((select 5))));
values ((select (values (4))), (values ((values(5)))))
union
values ((select (values (4))), (values ((select 7))));
values ((values (2))), ((values ((values (4)))));
values ((values (2))), ((values ((select 4))));
values ((values (2))), ((values ((values (4)))))
union
values ((values (8))), ((values ((select 4))));
values ((values (2))), ((values ((values (4)))))
union all
values ((values (8))), ((values ((select 4))));
select * from (values ((values (2)))) dt;
select * from (values ((values (2)), (5), (select 4))) dt;
select * from (values ((values (2))) union values ((values (3)))) dt;
select * from (values ((values (2))), ((values (3)))) dt;
select * from (values ((values (2))), ((values (3)))) dt;
select * from (values ((values (2))), ((select 4)), ((values (3)))) dt;
create table t1 (a int);
insert into t1 values (3), (7), (1);
values ((values ((select a from t1 where a=7))));
values ((values ((select (values(2)) from t1 where a=8))));
values ((values ((select a from t1 where a=7))))
union
values ((values ((select (values(2)) from t1 where a=8))));
values ((values ((select a from t1 where a in ((values (7)))))));
values ((values ((select a from t1 where a in ((values (7), (8)))))));
values ((values
((select a from t1 where a in (values (7) union values (8))))));
values ((values ((select (values(2)) from t1 where a=8))));
--error ER_SUBQUERY_NO_1_ROW
values ((select (values(2)) from t1 where a<7));
select * from (values ((values ((select a from t1 where a=7))))) dt;
select * from (values ((values ((select (values(2)) from t1 where a=8))))) dt;
insert into t1(a) values ((values (2))), ((values (3)));
select * from t1;
drop table t1;
--echo End of 10.3 tests --echo End of 10.3 tests
--echo # --echo #

View File

@@ -3867,6 +3867,32 @@ NULL
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1,t2; DROP TABLE t1,t2;
# #
# MDEV-25032 Window functions without column references get removed from ORDER BY
#
create table t1 (id int, score double);
insert into t1 values
(1, 5),
(1, 6),
(1, 6),
(1, 6),
(1, 7),
(1, 8.1),
(1, 9),
(1, 10);
select id, row_number() over () rn
from t1
order by rn desc;
id rn
1 8
1 7
1 6
1 5
1 4
1 3
1 2
1 1
drop table t1;
#
# End of 10.2 tests # End of 10.2 tests
# #
# #

View File

@@ -2521,6 +2521,26 @@ SELECT NTH_VALUE(i1, i1) OVER (PARTITION BY i1) FROM v1;
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1,t2; DROP TABLE t1,t2;
--echo #
--echo # MDEV-25032 Window functions without column references get removed from ORDER BY
--echo #
create table t1 (id int, score double);
insert into t1 values
(1, 5),
(1, 6),
(1, 6),
(1, 6),
(1, 7),
(1, 8.1),
(1, 9),
(1, 10);
select id, row_number() over () rn
from t1
order by rn desc;
drop table t1;
--echo # --echo #
--echo # End of 10.2 tests --echo # End of 10.2 tests
--echo # --echo #

View File

@@ -3873,6 +3873,32 @@ NULL
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1,t2; DROP TABLE t1,t2;
# #
# MDEV-25032 Window functions without column references get removed from ORDER BY
#
create table t1 (id int, score double);
insert into t1 values
(1, 5),
(1, 6),
(1, 6),
(1, 6),
(1, 7),
(1, 8.1),
(1, 9),
(1, 10);
select id, row_number() over () rn
from t1
order by rn desc;
id rn
1 8
1 7
1 6
1 5
1 4
1 3
1 2
1 1
drop table t1;
#
# End of 10.2 tests # End of 10.2 tests
# #
# #

View File

@@ -3318,3 +3318,20 @@ c1 c2
9 3 9 3
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
#
# MDEV-24748 Extern field check missing
# in btr_index_rec_validate()
#
CREATE TABLE t1 (pk INT, c1 char(255),
c2 char(255), c3 char(255), c4 char(255),
c5 char(255), c6 char(255), c7 char(255),
c8 char(255), primary key (pk)
) CHARACTER SET utf32 ENGINE=InnoDB;
INSERT INTO t1 VALUES
(1, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'),
(2, 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p');
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
ALTER TABLE t1 FORCE;
DROP TABLE t1;

View File

@@ -2585,3 +2585,21 @@ SELECT * FROM t2;
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
--echo #
--echo # MDEV-24748 Extern field check missing
--echo # in btr_index_rec_validate()
--echo #
CREATE TABLE t1 (pk INT, c1 char(255),
c2 char(255), c3 char(255), c4 char(255),
c5 char(255), c6 char(255), c7 char(255),
c8 char(255), primary key (pk)
) CHARACTER SET utf32 ENGINE=InnoDB;
INSERT INTO t1 VALUES
(1, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'),
(2, 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p');
CHECK TABLE t1;
ALTER TABLE t1 FORCE;
# Cleanup
DROP TABLE t1;

View File

@@ -23,11 +23,12 @@ INSERT INTO t6_corrupted_to_drop VALUES (3), (4), (5), (6), (7), (8), (9);
INSERT INTO t7_corrupted_to_alter VALUES (3), (4), (5), (6), (7), (8), (9); INSERT INTO t7_corrupted_to_alter VALUES (3), (4), (5), (6), (7), (8), (9);
# Corrupt tables # Corrupt tables
# restart # restart
# Backup must fail due to page corruption # Backup must fail due to page corruption
FOUND 1 /Database page corruption detected.*/ in backup.log FOUND 1 /Database page corruption detected.*/ in backup.log
# "innodb_corrupted_pages" file must not exist # "innodb_corrupted_pages" file must not exist
# Backup must fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option # Backup must not fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option
FOUND 1 /Database page corruption detected.*/ in backup.log FOUND 1 /Database page corruption detected.*/ in backup.log
FOUND 1 /completed OK!/ in backup.log
--- "innodb_corrupted_pages" file content: --- --- "innodb_corrupted_pages" file content: ---
test/t1_corrupted test/t1_corrupted
6 8 9 6 8 9
@@ -44,7 +45,7 @@ INSERT INTO t1_inc_corrupted VALUES (3), (4), (5), (6), (7), (8), (9);
INSERT INTO t2_inc_corrupted VALUES (3), (4), (5), (6), (7), (8), (9); INSERT INTO t2_inc_corrupted VALUES (3), (4), (5), (6), (7), (8), (9);
INSERT INTO t3_inc VALUES (3), (4), (5), (6), (7), (8), (9); INSERT INTO t3_inc VALUES (3), (4), (5), (6), (7), (8), (9);
# restart # restart
# Backup must fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option # Backup must not fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option
--- "innodb_corrupted_pages" file content: --- --- "innodb_corrupted_pages" file content: ---
test/t1_corrupted test/t1_corrupted
6 8 9 6 8 9

View File

@@ -59,7 +59,7 @@ EOF
--let corrupted_pages_file_filt = $MYSQLTEST_VARDIR/tmp/innodb_corrupted_pages_filt --let corrupted_pages_file_filt = $MYSQLTEST_VARDIR/tmp/innodb_corrupted_pages_filt
--let perl_result_file=$MYSQLTEST_VARDIR/tmp/perl_result --let perl_result_file=$MYSQLTEST_VARDIR/tmp/perl_result
--echo # Backup must fail due to page corruption --echo # Backup must fail due to page corruption
--disable_result_log --disable_result_log
--error 1 --error 1
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir > $backuplog; exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir > $backuplog;
@@ -80,15 +80,19 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=
--let after_copy_test_t7_corrupted_to_alter=ALTER TABLE test.t7_corrupted_to_alter ADD COLUMN (d INT) --let after_copy_test_t7_corrupted_to_alter=ALTER TABLE test.t7_corrupted_to_alter ADD COLUMN (d INT)
--let add_corrupted_page_for_test_t7_corrupted_to_alter=3 --let add_corrupted_page_for_test_t7_corrupted_to_alter=3
--echo # Backup must fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option --echo # Backup must not fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option
--disable_result_log --disable_result_log
--error 1
--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --log-innodb-page-corruption --target-dir=$targetdir --dbug=+d,mariabackup_events,mariabackup_inject_code > $backuplog --exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --log-innodb-page-corruption --target-dir=$targetdir --dbug=+d,mariabackup_events,mariabackup_inject_code > $backuplog
--enable_result_log --enable_result_log
--let SEARCH_PATTERN=Database page corruption detected.* --let SEARCH_PATTERN=Database page corruption detected.*
--let SEARCH_FILE=$backuplog --let SEARCH_FILE=$backuplog
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--let SEARCH_PATTERN=completed OK!
--let SEARCH_FILE=$backuplog
--source include/search_pattern_in_file.inc
--echo --- "innodb_corrupted_pages" file content: --- --echo --- "innodb_corrupted_pages" file content: ---
perl; perl;
do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl"; do "$ENV{MTR_SUITE_DIR}/include/corrupt-page.pl";
@@ -145,9 +149,8 @@ EOF
--let after_copy_test_t7_inc_corrupted_to_alter=ALTER TABLE test.t7_inc_corrupted_to_alter ADD COLUMN (d INT) --let after_copy_test_t7_inc_corrupted_to_alter=ALTER TABLE test.t7_inc_corrupted_to_alter ADD COLUMN (d INT)
--let add_corrupted_page_for_test_t7_inc_corrupted_to_alter=3 --let add_corrupted_page_for_test_t7_inc_corrupted_to_alter=3
--echo # Backup must fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option --echo # Backup must not fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option
--disable_result_log --disable_result_log
--error 1
--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --log-innodb-page-corruption --target-dir=$incdir --incremental-basedir=$targetdir --dbug=+d,mariabackup_events,mariabackup_inject_code > $backuplog --exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --log-innodb-page-corruption --target-dir=$incdir --incremental-basedir=$targetdir --dbug=+d,mariabackup_events,mariabackup_inject_code > $backuplog
--disable_result_log --disable_result_log
@@ -161,6 +164,9 @@ EOF
--let SEARCH_PATTERN=Database page corruption detected.* --let SEARCH_PATTERN=Database page corruption detected.*
--let SEARCH_FILE=$backuplog --let SEARCH_FILE=$backuplog
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--let SEARCH_PATTERN=completed OK!
--source include/search_pattern_in_file.inc
--let corrupted_pages_file = $incdir/innodb_corrupted_pages --let corrupted_pages_file = $incdir/innodb_corrupted_pages
--echo --- "innodb_corrupted_pages" file content: --- --echo --- "innodb_corrupted_pages" file content: ---
perl; perl;
@@ -260,7 +266,6 @@ EOF
--echo # Full backup with --log-innodb-page-corruption --echo # Full backup with --log-innodb-page-corruption
--disable_result_log --disable_result_log
--error 1
--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --log-innodb-page-corruption --target-dir=$targetdir --exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --log-innodb-page-corruption --target-dir=$targetdir
--enable_result_log --enable_result_log
--let corrupted_pages_file = $targetdir/innodb_corrupted_pages --let corrupted_pages_file = $targetdir/innodb_corrupted_pages
@@ -288,7 +293,6 @@ EOF
--echo # Incremental backup --log-innodb-page-corruption --echo # Incremental backup --log-innodb-page-corruption
--disable_result_log --disable_result_log
--error 1
--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --log-innodb-page-corruption --target-dir=$incdir --incremental-basedir=$targetdir --dbug=+d,mariabackup_events,mariabackup_inject_code > $backuplog --exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --log-innodb-page-corruption --target-dir=$incdir --incremental-basedir=$targetdir --dbug=+d,mariabackup_events,mariabackup_inject_code > $backuplog
--disable_result_log --disable_result_log
--let corrupted_pages_file = $incdir/innodb_corrupted_pages --let corrupted_pages_file = $incdir/innodb_corrupted_pages

View File

@@ -48,10 +48,10 @@ sub start_test {
my ($command, %tests, $prefix); my ($command, %tests, $prefix);
for (@ctest_list) { for (@ctest_list) {
chomp; chomp;
if (/^\d+: Test command: +([^ \t]+)/) { if (/^\d+: Test command: +([^ \t]+.*)/) {
$command= $1; $command= $1;
$prefix= /libmariadb/ ? 'conc_' : ''; $prefix= /libmariadb/ ? 'conc_' : '';
} elsif (/^ +Test +#\d+: ([^ \t]+)/) { } elsif (/^ +Test +#\d+: ([^ \t]+.*)/) {
if ($command ne "NOT_AVAILABLE" && $command ne "/bin/sh") { if ($command ne "NOT_AVAILABLE" && $command ne "/bin/sh") {
$tests{$prefix.$1}=$command; $tests{$prefix.$1}=$command;
} }

View File

@@ -3024,6 +3024,8 @@ void st_select_lex::init_select()
with_dep= 0; with_dep= 0;
join= 0; join= 0;
lock_type= TL_READ_DEFAULT; lock_type= TL_READ_DEFAULT;
save_many_values.empty();
save_insert_list= 0;
tvc= 0; tvc= 0;
in_funcs.empty(); in_funcs.empty();
curr_tvc_name= 0; curr_tvc_name= 0;
@@ -9578,7 +9580,6 @@ bool LEX::last_field_generated_always_as_row_end()
VERS_SYS_END_FLAG); VERS_SYS_END_FLAG);
} }
void st_select_lex_unit::reset_distinct() void st_select_lex_unit::reset_distinct()
{ {
union_distinct= NULL; union_distinct= NULL;
@@ -9594,6 +9595,20 @@ void st_select_lex_unit::reset_distinct()
} }
void LEX::save_values_list_state()
{
current_select->save_many_values= many_values;
current_select->save_insert_list= insert_list;
}
void LEX::restore_values_list_state()
{
many_values= current_select->save_many_values;
insert_list= current_select->save_insert_list;
}
void st_select_lex_unit::fix_distinct() void st_select_lex_unit::fix_distinct()
{ {
if (union_distinct && this != union_distinct->master_unit()) if (union_distinct && this != union_distinct->master_unit())
@@ -10102,6 +10117,7 @@ bool LEX::parsed_insert_select(SELECT_LEX *first_select)
bool LEX::parsed_TVC_start() bool LEX::parsed_TVC_start()
{ {
SELECT_LEX *sel; SELECT_LEX *sel;
save_values_list_state();
many_values.empty(); many_values.empty();
insert_list= 0; insert_list= 0;
if (!(sel= alloc_select(TRUE)) || if (!(sel= alloc_select(TRUE)) ||
@@ -10115,14 +10131,13 @@ bool LEX::parsed_TVC_start()
SELECT_LEX *LEX::parsed_TVC_end() SELECT_LEX *LEX::parsed_TVC_end()
{ {
SELECT_LEX *res= pop_select(); // above TVC select SELECT_LEX *res= pop_select(); // above TVC select
if (!(res->tvc= if (!(res->tvc=
new (thd->mem_root) table_value_constr(many_values, new (thd->mem_root) table_value_constr(many_values,
res, res,
res->options))) res->options)))
return NULL; return NULL;
many_values.empty(); restore_values_list_state();
return res; return res;
} }

View File

@@ -1331,6 +1331,8 @@ public:
/* it is for correct printing SELECT options */ /* it is for correct printing SELECT options */
thr_lock_type lock_type; thr_lock_type lock_type;
List<List_item> save_many_values;
List<Item> *save_insert_list;
table_value_constr *tvc; table_value_constr *tvc;
bool in_tvc; bool in_tvc;
@@ -4517,13 +4519,6 @@ public:
return false; return false;
} }
void tvc_start()
{
field_list.empty();
many_values.empty();
insert_list= 0;
}
SELECT_LEX_UNIT *alloc_unit(); SELECT_LEX_UNIT *alloc_unit();
SELECT_LEX *alloc_select(bool is_select); SELECT_LEX *alloc_select(bool is_select);
SELECT_LEX_UNIT *create_unit(SELECT_LEX*); SELECT_LEX_UNIT *create_unit(SELECT_LEX*);
@@ -4589,6 +4584,8 @@ public:
bool distinct); bool distinct);
SELECT_LEX *parsed_subselect(SELECT_LEX_UNIT *unit); SELECT_LEX *parsed_subselect(SELECT_LEX_UNIT *unit);
bool parsed_insert_select(SELECT_LEX *firs_select); bool parsed_insert_select(SELECT_LEX *firs_select);
void save_values_list_state();
void restore_values_list_state();
bool parsed_TVC_start(); bool parsed_TVC_start();
SELECT_LEX *parsed_TVC_end(); SELECT_LEX *parsed_TVC_end();
TABLE_LIST *parsed_derived_table(SELECT_LEX_UNIT *unit, TABLE_LIST *parsed_derived_table(SELECT_LEX_UNIT *unit,

View File

@@ -14260,6 +14260,7 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
{ {
table_map order_tables=order->item[0]->used_tables(); table_map order_tables=order->item[0]->used_tables();
if (order->item[0]->with_sum_func() || if (order->item[0]->with_sum_func() ||
order->item[0]->with_window_func ||
/* /*
If the outer table of an outer join is const (either by itself or If the outer table of an outer join is const (either by itself or
after applying WHERE condition), grouping on a field from such a after applying WHERE condition), grouping on a field from such a

View File

@@ -704,6 +704,8 @@ st_select_lex *wrap_tvc(THD *thd, st_select_lex *tvc_sl,
wrapper_sl->nest_level= tvc_sl->nest_level; wrapper_sl->nest_level= tvc_sl->nest_level;
wrapper_sl->parsing_place= tvc_sl->parsing_place; wrapper_sl->parsing_place= tvc_sl->parsing_place;
wrapper_sl->set_linkage(tvc_sl->get_linkage()); wrapper_sl->set_linkage(tvc_sl->get_linkage());
wrapper_sl->exclude_from_table_unique_test=
tvc_sl->exclude_from_table_unique_test;
lex->current_select= wrapper_sl; lex->current_select= wrapper_sl;
item= new (thd->mem_root) Item_field(thd, &wrapper_sl->context, item= new (thd->mem_root) Item_field(thd, &wrapper_sl->context,

View File

@@ -4442,6 +4442,16 @@ n_field_mismatch:
} else { } else {
fixed_size = dict_col_get_fixed_size( fixed_size = dict_col_get_fixed_size(
field->col, page_is_comp(page)); field->col, page_is_comp(page));
if (rec_offs_nth_extern(offsets, i)) {
const byte* data = rec_get_nth_field(
rec, offsets, i, &len);
len -= BTR_EXTERN_FIELD_REF_SIZE;
ulint extern_len = mach_read_from_4(
data + len + BTR_EXTERN_LEN + 4);
if (fixed_size == extern_len) {
continue;
}
}
} }
/* Note that if fixed_size != 0, it equals the /* Note that if fixed_size != 0, it equals the

View File

@@ -13211,17 +13211,10 @@ innobase_drop_database(
@param[in,out] trx InnoDB data dictionary transaction @param[in,out] trx InnoDB data dictionary transaction
@param[in] from old table name @param[in] from old table name
@param[in] to new table name @param[in] to new table name
@param[in] commit whether to commit trx @param[in] commit whether to commit trx (and to enforce FOREIGN KEY)
@param[in] use_fk whether to parse and enforce FOREIGN KEY constraints
@return DB_SUCCESS or error code */ @return DB_SUCCESS or error code */
inline inline dberr_t innobase_rename_table(trx_t *trx, const char *from,
dberr_t const char *to, bool commit)
innobase_rename_table(
trx_t* trx,
const char* from,
const char* to,
bool commit,
bool use_fk)
{ {
dberr_t error; dberr_t error;
char norm_to[FN_REFLEN]; char norm_to[FN_REFLEN];
@@ -13248,7 +13241,7 @@ innobase_rename_table(
} }
error = row_rename_table_for_mysql(norm_from, norm_to, trx, commit, error = row_rename_table_for_mysql(norm_from, norm_to, trx, commit,
use_fk); commit);
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
if (error == DB_TABLE_NOT_FOUND if (error == DB_TABLE_NOT_FOUND
@@ -13353,9 +13346,11 @@ int ha_innobase::truncate()
++trx->will_lock; ++trx->will_lock;
trx_set_dict_operation(trx, TRX_DICT_OP_TABLE); trx_set_dict_operation(trx, TRX_DICT_OP_TABLE);
row_mysql_lock_data_dictionary(trx); row_mysql_lock_data_dictionary(trx);
dict_stats_wait_bg_to_stop_using_table(ib_table, trx);
int err = convert_error_code_to_mysql( int err = convert_error_code_to_mysql(
innobase_rename_table(trx, ib_table->name.m_name, temp_name, innobase_rename_table(trx, ib_table->name.m_name, temp_name,
false, false), false),
ib_table->flags, m_user_thd); ib_table->flags, m_user_thd);
if (err) { if (err) {
trx_rollback_for_mysql(trx); trx_rollback_for_mysql(trx);
@@ -13438,7 +13433,7 @@ ha_innobase::rename_table(
++trx->will_lock; ++trx->will_lock;
trx_set_dict_operation(trx, TRX_DICT_OP_INDEX); trx_set_dict_operation(trx, TRX_DICT_OP_INDEX);
dberr_t error = innobase_rename_table(trx, from, to, true, true); dberr_t error = innobase_rename_table(trx, from, to, true);
DEBUG_SYNC(thd, "after_innobase_rename_table"); DEBUG_SYNC(thd, "after_innobase_rename_table");

View File

@@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2020, MariaDB Corporation. Copyright (c) 2017, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@@ -805,12 +805,6 @@ struct row_prebuilt_t {
search key values from MySQL format search key values from MySQL format
to InnoDB format.*/ to InnoDB format.*/
uint srch_key_val_len; /*!< Size of search key */ uint srch_key_val_len; /*!< Size of search key */
/** Disable prefetch. */
bool m_no_prefetch;
/** Return materialized key for secondary index scan */
bool m_read_virtual_key;
/** The MySQL table object */ /** The MySQL table object */
TABLE* m_mysql_table; TABLE* m_mysql_table;

View File

@@ -958,9 +958,6 @@ row_create_prebuilt(
prebuilt->fts_doc_id_in_read_set = 0; prebuilt->fts_doc_id_in_read_set = 0;
prebuilt->blob_heap = NULL; prebuilt->blob_heap = NULL;
prebuilt->m_no_prefetch = false;
prebuilt->m_read_virtual_key = false;
DBUG_RETURN(prebuilt); DBUG_RETURN(prebuilt);
} }
@@ -4073,7 +4070,6 @@ row_rename_table_for_mysql(
FOREIGN KEY constraints */ FOREIGN KEY constraints */
{ {
dict_table_t* table = NULL; dict_table_t* table = NULL;
ibool dict_locked = FALSE;
dberr_t err = DB_ERROR; dberr_t err = DB_ERROR;
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
const char** constraints_to_drop = NULL; const char** constraints_to_drop = NULL;
@@ -4087,6 +4083,8 @@ row_rename_table_for_mysql(
ut_a(old_name != NULL); ut_a(old_name != NULL);
ut_a(new_name != NULL); ut_a(new_name != NULL);
ut_ad(trx->state == TRX_STATE_ACTIVE); ut_ad(trx->state == TRX_STATE_ACTIVE);
const bool dict_locked = trx->dict_operation_lock_mode == RW_X_LATCH;
ut_ad(!commit || dict_locked);
if (high_level_read_only) { if (high_level_read_only) {
return(DB_READ_ONLY); return(DB_READ_ONLY);
@@ -4105,8 +4103,6 @@ row_rename_table_for_mysql(
old_is_tmp = dict_table_t::is_temporary_name(old_name); old_is_tmp = dict_table_t::is_temporary_name(old_name);
new_is_tmp = dict_table_t::is_temporary_name(new_name); new_is_tmp = dict_table_t::is_temporary_name(new_name);
dict_locked = trx->dict_operation_lock_mode == RW_X_LATCH;
table = dict_table_open_on_name(old_name, dict_locked, FALSE, table = dict_table_open_on_name(old_name, dict_locked, FALSE,
DICT_ERR_IGNORE_FK_NOKEY); DICT_ERR_IGNORE_FK_NOKEY);
@@ -4210,6 +4206,10 @@ row_rename_table_for_mysql(
} }
if (!table->is_temporary()) { if (!table->is_temporary()) {
if (commit) {
dict_stats_wait_bg_to_stop_using_table(table, trx);
}
err = trx_undo_report_rename(trx, table); err = trx_undo_report_rename(trx, table);
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
@@ -4237,7 +4237,7 @@ row_rename_table_for_mysql(
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
// Assume the caller guarantees destination name doesn't exist. // Assume the caller guarantees destination name doesn't exist.
ut_ad(err != DB_DUPLICATE_KEY); ut_ad(err != DB_DUPLICATE_KEY);
goto end; goto err_exit;
} }
if (!new_is_tmp) { if (!new_is_tmp) {
@@ -4381,8 +4381,8 @@ row_rename_table_for_mysql(
} }
} }
end:
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
err_exit:
if (err == DB_DUPLICATE_KEY) { if (err == DB_DUPLICATE_KEY) {
ib::error() << "Possible reasons:"; ib::error() << "Possible reasons:";
ib::error() << "(1) Table rename would cause two" ib::error() << "(1) Table rename would cause two"
@@ -4535,6 +4535,9 @@ funct_exit:
} }
if (table != NULL) { if (table != NULL) {
if (commit && !table->is_temporary()) {
table->stats_bg_flag &= ~BG_STAT_SHOULD_QUIT;
}
dict_table_close(table, dict_locked, FALSE); dict_table_close(table, dict_locked, FALSE);
} }

View File

@@ -3039,8 +3039,7 @@ static bool row_sel_store_mysql_rec(
search or virtual key read is not requested. */ search or virtual key read is not requested. */
if (!rec_clust if (!rec_clust
|| !prebuilt->index->has_virtual() || !prebuilt->index->has_virtual()
|| (!prebuilt->read_just_key || !prebuilt->read_just_key) {
&& !prebuilt->m_read_virtual_key)) {
/* Initialize the NULL bit. */ /* Initialize the NULL bit. */
if (templ->mysql_null_bit_mask) { if (templ->mysql_null_bit_mask) {
#if defined __GNUC__ && !defined __clang__ && __GNUC__ < 6 #if defined __GNUC__ && !defined __clang__ && __GNUC__ < 6
@@ -3065,23 +3064,8 @@ static bool row_sel_store_mysql_rec(
const dfield_t* dfield = dtuple_get_nth_v_field( const dfield_t* dfield = dtuple_get_nth_v_field(
vrow, col->v_pos); vrow, col->v_pos);
/* If this is a partitioned table, it might request
InnoDB to fill out virtual column data for serach
index key values while other non key columns are also
getting selected. The non-key virtual columns may
not be materialized and we should skip them. */
if (dfield_get_type(dfield)->mtype == DATA_MISSING) { if (dfield_get_type(dfield)->mtype == DATA_MISSING) {
#ifdef UNIV_DEBUG ut_ad("no ha_innopart in MariaDB" == 0);
ulint prefix;
#endif /* UNIV_DEBUG */
ut_ad(prebuilt->m_read_virtual_key);
/* If it is part of index key the data should
have been materialized. */
ut_ad(dict_index_get_nth_col_or_prefix_pos(
prebuilt->index, col->v_pos, false,
true, &prefix) == ULINT_UNDEFINED);
continue; continue;
} }
@@ -4304,8 +4288,7 @@ row_search_mvcc(
index key, if this is covered index scan or virtual key read is index key, if this is covered index scan or virtual key read is
requested. */ requested. */
bool need_vrow = dict_index_has_virtual(prebuilt->index) bool need_vrow = dict_index_has_virtual(prebuilt->index)
&& (prebuilt->read_just_key && prebuilt->read_just_key;
|| prebuilt->m_read_virtual_key);
/* Reset the new record lock info if READ UNCOMMITTED or /* Reset the new record lock info if READ UNCOMMITTED or
READ COMMITED isolation level is used. Then READ COMMITED isolation level is used. Then
@@ -5464,7 +5447,6 @@ use_covering_index:
if ((match_mode == ROW_SEL_EXACT if ((match_mode == ROW_SEL_EXACT
|| prebuilt->n_rows_fetched >= MYSQL_FETCH_CACHE_THRESHOLD) || prebuilt->n_rows_fetched >= MYSQL_FETCH_CACHE_THRESHOLD)
&& prebuilt->select_lock_type == LOCK_NONE && prebuilt->select_lock_type == LOCK_NONE
&& !prebuilt->m_no_prefetch
&& !prebuilt->templ_contains_blob && !prebuilt->templ_contains_blob
&& !prebuilt->clust_index_was_generated && !prebuilt->clust_index_was_generated
&& !prebuilt->used_in_HANDLER && !prebuilt->used_in_HANDLER