Skip to content

Commit

Permalink
Merge 10.3 into 10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Mar 8, 2021
2 parents 39e2c95 + ecc1cd2 commit a26e7a3
Show file tree
Hide file tree
Showing 16 changed files with 184 additions and 75 deletions.
7 changes: 3 additions & 4 deletions extra/mariabackup/xtrabackup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4672,13 +4672,12 @@ static bool xtrabackup_backup_func()
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);
}


Expand Down
26 changes: 26 additions & 0 deletions mysql-test/main/win.result
Original file line number Diff line number Diff line change
Expand Up @@ -3866,6 +3866,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
#
#
Expand Down
20 changes: 20 additions & 0 deletions mysql-test/main/win.test
Original file line number Diff line number Diff line change
Expand Up @@ -2522,6 +2522,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 #
Expand Down
26 changes: 26 additions & 0 deletions mysql-test/suite/encryption/r/tempfiles_encrypted.result
Original file line number Diff line number Diff line change
Expand Up @@ -3872,6 +3872,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
#
#
Expand Down
17 changes: 17 additions & 0 deletions mysql-test/suite/innodb/r/innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -3319,3 +3319,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;
18 changes: 18 additions & 0 deletions mysql-test/suite/innodb/t/innodb.test
Original file line number Diff line number Diff line change
Expand Up @@ -2592,3 +2592,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;
7 changes: 4 additions & 3 deletions mysql-test/suite/mariabackup/log_page_corruption.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
18 changes: 11 additions & 7 deletions mysql-test/suite/mariabackup/log_page_corruption.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down Expand Up @@ -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

Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/suite/unit/suite.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion sql/sql_select.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2009, 2020, MariaDB Corporation.
Copyright (c) 2009, 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
Expand Down Expand Up @@ -14140,6 +14140,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
Expand Down
12 changes: 11 additions & 1 deletion storage/innobase/btr/btr0btr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2014, 2020, MariaDB Corporation.
Copyright (c) 2014, 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
Expand Down Expand Up @@ -4666,6 +4666,16 @@ btr_index_rec_validate(
} 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
Expand Down
30 changes: 20 additions & 10 deletions storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -887,15 +887,14 @@ fil_space_extend_must_retry(
}
}

/*******************************************************************//**
Reserves the fil_system.mutex and tries to make sure we can open at least one
/** Reserves the fil_system.mutex and tries to make sure we can open at least one
file while holding it. This should be called before calling
fil_node_prepare_for_io(), because that function may need to open a file. */
fil_node_prepare_for_io(), because that function may need to open a file.
@param[in] space_id tablespace id
@return whether the tablespace is usable for io */
static
void
fil_mutex_enter_and_prepare_for_io(
/*===============================*/
ulint space_id) /*!< in: space id */
bool
fil_mutex_enter_and_prepare_for_io(ulint space_id)
{
for (ulint count = 0;;) {
mutex_enter(&fil_system.mutex);
Expand All @@ -908,7 +907,7 @@ fil_mutex_enter_and_prepare_for_io(
fil_space_t* space = fil_space_get_by_id(space_id);

if (space == NULL) {
break;
return false;
}

fil_node_t* node = UT_LIST_GET_LAST(space->chain);
Expand All @@ -923,6 +922,10 @@ fil_mutex_enter_and_prepare_for_io(
the insert buffer. The insert buffer is in
tablespace 0, and we cannot end up waiting in
this function. */
} else if (space->is_stopping() && !space->is_being_truncated) {
/* If the tablespace is being deleted then InnoDB
shouldn't prepare the tablespace for i/o */
return false;
} else if (!node || node->is_open()) {
/* If the file is already open, no need to do
anything; if the space does not exist, we handle the
Expand Down Expand Up @@ -994,6 +997,8 @@ fil_mutex_enter_and_prepare_for_io(

break;
}

return true;
}

/** Try to extend a tablespace if it is smaller than the specified size.
Expand All @@ -1010,7 +1015,10 @@ fil_space_extend(
bool success;

do {
fil_mutex_enter_and_prepare_for_io(space->id);
if (!fil_mutex_enter_and_prepare_for_io(space->id)) {
success = false;
break;
}
} while (fil_space_extend_must_retry(
space, UT_LIST_GET_LAST(space->chain), size,
&success));
Expand Down Expand Up @@ -1365,7 +1373,9 @@ fil_space_t* fil_system_t::read_page0(ulint id)

/* It is possible that the tablespace is dropped while we are
not holding the mutex. */
fil_mutex_enter_and_prepare_for_io(id);
if (!fil_mutex_enter_and_prepare_for_io(id)) {
return NULL;
}

fil_space_t* space = fil_space_get_by_id(id);

Expand Down
Loading

0 comments on commit a26e7a3

Please sign in to comment.