Merge 10.4 into 10.5

This commit is contained in:
Marko Mäkelä 2021-03-08 10:16:20 +02:00
commit a5d3c1c819
20 changed files with 468 additions and 77 deletions

View file

@ -4537,13 +4537,12 @@ fail_before_log_copying_thread_start:
log_file_op = NULL;
pthread_mutex_destroy(&backup_mutex);
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 "
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)));
sum((values(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
#
# 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)));
--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 #

View file

@ -3867,6 +3867,32 @@ NULL
DROP VIEW v1;
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
#
#

View file

@ -2521,6 +2521,26 @@ SELECT NTH_VALUE(i1, i1) OVER (PARTITION BY i1) FROM v1;
DROP VIEW v1;
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 # End of 10.2 tests
--echo #

View file

@ -3873,6 +3873,32 @@ NULL
DROP VIEW v1;
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
#
#

View file

@ -3318,3 +3318,20 @@ c1 c2
9 3
DROP TABLE t1;
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 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);
# Corrupt tables
# restart
# Backup must fail due to page corruption
# Backup must fail due to page corruption
FOUND 1 /Database page corruption detected.*/ in backup.log
# "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 /completed OK!/ in backup.log
--- "innodb_corrupted_pages" file content: ---
test/t1_corrupted
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 t3_inc VALUES (3), (4), (5), (6), (7), (8), (9);
# 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: ---
test/t1_corrupted
6 8 9

View file

@ -59,7 +59,7 @@ EOF
--let corrupted_pages_file_filt = $MYSQLTEST_VARDIR/tmp/innodb_corrupted_pages_filt
--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
--error 1
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 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
--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
--enable_result_log
--let SEARCH_PATTERN=Database page corruption detected.*
--let SEARCH_FILE=$backuplog
--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: ---
perl;
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 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
--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
--disable_result_log
@ -161,6 +164,9 @@ EOF
--let SEARCH_PATTERN=Database page corruption detected.*
--let SEARCH_FILE=$backuplog
--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
--echo --- "innodb_corrupted_pages" file content: ---
perl;
@ -260,7 +266,6 @@ EOF
--echo # Full backup with --log-innodb-page-corruption
--disable_result_log
--error 1
--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --log-innodb-page-corruption --target-dir=$targetdir
--enable_result_log
--let corrupted_pages_file = $targetdir/innodb_corrupted_pages
@ -288,7 +293,6 @@ EOF
--echo # Incremental backup --log-innodb-page-corruption
--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
--disable_result_log
--let corrupted_pages_file = $incdir/innodb_corrupted_pages

View file

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

View file

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

View file

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

View file

@ -14247,6 +14247,7 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
{
table_map order_tables=order->item[0]->used_tables();
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
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->parsing_place= tvc_sl->parsing_place;
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;
item= new (thd->mem_root) Item_field(thd, &wrapper_sl->context,

View file

@ -4428,6 +4428,16 @@ n_field_mismatch:
} else {
fixed_size = dict_col_get_fixed_size(
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

View file

@ -13413,17 +13413,10 @@ innobase_drop_database(
@param[in,out] trx InnoDB data dictionary transaction
@param[in] from old table name
@param[in] to new table name
@param[in] commit whether to commit trx
@param[in] use_fk whether to parse and enforce FOREIGN KEY constraints
@param[in] commit whether to commit trx (and to enforce FOREIGN KEY)
@return DB_SUCCESS or error code */
inline
dberr_t
innobase_rename_table(
trx_t* trx,
const char* from,
const char* to,
bool commit,
bool use_fk)
inline dberr_t innobase_rename_table(trx_t *trx, const char *from,
const char *to, bool commit)
{
dberr_t error;
char norm_to[FN_REFLEN];
@ -13450,7 +13443,7 @@ innobase_rename_table(
}
error = row_rename_table_for_mysql(norm_from, norm_to, trx, commit,
use_fk);
commit);
if (error != DB_SUCCESS) {
if (error == DB_TABLE_NOT_FOUND
@ -13555,9 +13548,11 @@ int ha_innobase::truncate()
++trx->will_lock;
trx_set_dict_operation(trx, TRX_DICT_OP_TABLE);
row_mysql_lock_data_dictionary(trx);
dict_stats_wait_bg_to_stop_using_table(ib_table, trx);
int err = convert_error_code_to_mysql(
innobase_rename_table(trx, ib_table->name.m_name, temp_name,
false, false),
false),
ib_table->flags, m_user_thd);
if (err) {
trx_rollback_for_mysql(trx);
@ -13640,7 +13635,7 @@ ha_innobase::rename_table(
++trx->will_lock;
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");

View file

@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2019, MariaDB Corporation.
Copyright (c) 2017, 2021, MariaDB Corporation.
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
@ -804,12 +804,6 @@ struct row_prebuilt_t {
search key values from MySQL format
to InnoDB format.*/
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 */
TABLE* m_mysql_table;

View file

@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2020, MariaDB Corporation.
Copyright (c) 2015, 2021, MariaDB Corporation.
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
@ -963,9 +963,6 @@ row_create_prebuilt(
prebuilt->fts_doc_id_in_read_set = 0;
prebuilt->blob_heap = NULL;
prebuilt->m_no_prefetch = false;
prebuilt->m_read_virtual_key = false;
DBUG_RETURN(prebuilt);
}
@ -4174,7 +4171,6 @@ row_rename_table_for_mysql(
FOREIGN KEY constraints */
{
dict_table_t* table = NULL;
ibool dict_locked = FALSE;
dberr_t err = DB_ERROR;
mem_heap_t* heap = NULL;
const char** constraints_to_drop = NULL;
@ -4188,6 +4184,8 @@ row_rename_table_for_mysql(
ut_a(old_name != NULL);
ut_a(new_name != NULL);
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) {
return(DB_READ_ONLY);
@ -4206,8 +4204,6 @@ row_rename_table_for_mysql(
old_is_tmp = dict_table_t::is_temporary_name(old_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,
DICT_ERR_IGNORE_FK_NOKEY);
@ -4311,6 +4307,10 @@ row_rename_table_for_mysql(
}
if (!table->is_temporary()) {
if (commit) {
dict_stats_wait_bg_to_stop_using_table(table, trx);
}
err = trx_undo_report_rename(trx, table);
if (err != DB_SUCCESS) {
@ -4371,7 +4371,7 @@ row_rename_table_for_mysql(
ut_free(new_path);
}
if (err != DB_SUCCESS) {
goto end;
goto err_exit;
}
if (!new_is_tmp) {
@ -4515,8 +4515,8 @@ row_rename_table_for_mysql(
}
}
end:
if (err != DB_SUCCESS) {
err_exit:
if (err == DB_DUPLICATE_KEY) {
ib::error() << "Possible reasons:";
ib::error() << "(1) Table rename would cause two"
@ -4669,6 +4669,9 @@ funct_exit:
}
if (table != NULL) {
if (commit && !table->is_temporary()) {
table->stats_bg_flag &= ~BG_STAT_SHOULD_QUIT;
}
dict_table_close(table, dict_locked, FALSE);
}

View file

@ -2,7 +2,7 @@
Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2015, 2020, MariaDB Corporation.
Copyright (c) 2015, 2021, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@ -3025,8 +3025,7 @@ static bool row_sel_store_mysql_rec(
search or virtual key read is not requested. */
if (!rec_clust
|| !prebuilt->index->has_virtual()
|| (!prebuilt->read_just_key
&& !prebuilt->m_read_virtual_key)) {
|| !prebuilt->read_just_key) {
/* Initialize the NULL bit. */
if (templ->mysql_null_bit_mask) {
#if defined __GNUC__ && !defined __clang__ && __GNUC__ < 6
@ -3051,23 +3050,8 @@ static bool row_sel_store_mysql_rec(
const dfield_t* dfield = dtuple_get_nth_v_field(
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) {
#ifdef UNIV_DEBUG
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);
ut_ad("no ha_innopart in MariaDB" == 0);
continue;
}
@ -4284,8 +4268,7 @@ row_search_mvcc(
index key, if this is covered index scan or virtual key read is
requested. */
bool need_vrow = dict_index_has_virtual(prebuilt->index)
&& (prebuilt->read_just_key
|| prebuilt->m_read_virtual_key);
&& prebuilt->read_just_key;
/* Reset the new record lock info if READ UNCOMMITTED or
READ COMMITED isolation level is used. Then
@ -5397,7 +5380,6 @@ use_covering_index:
if ((match_mode == ROW_SEL_EXACT
|| prebuilt->n_rows_fetched >= MYSQL_FETCH_CACHE_THRESHOLD)
&& prebuilt->select_lock_type == LOCK_NONE
&& !prebuilt->m_no_prefetch
&& !prebuilt->templ_contains_blob
&& !prebuilt->clust_index_was_generated
&& !prebuilt->used_in_HANDLER