diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-06-21 09:07:40 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-06-21 09:07:40 +0300 |
commit | c9a85fb1b14d9944920ebdb3514c48ea57e1647d (patch) | |
tree | 922d11920b800072a90ebfba68ce23640500fb84 | |
parent | 068246c006b8f691982194529a32bff7eb010694 (diff) | |
parent | 773a07b65517327add6348c045cee14bdf489fe0 (diff) | |
download | mariadb-git-c9a85fb1b14d9944920ebdb3514c48ea57e1647d.tar.gz |
Merge 10.2 into 10.3
43 files changed, 426 insertions, 161 deletions
diff --git a/README.md b/README.md index 053831e4cd7..d208d171377 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ Code status: ------------ -* [![Travis CI status](https://secure.travis-ci.org/MariaDB/server.png?branch=10.3)](https://travis-ci.org/MariaDB/server) travis-ci.org (10.3 branch) * [![Appveyor CI status](https://ci.appveyor.com/api/projects/status/4u6pexmtpuf8jq66?svg=true)](https://ci.appveyor.com/project/rasmushoj/server) ci.appveyor.com ## MariaDB: drop-in replacement for MySQL @@ -76,5 +75,3 @@ https://bugs.mysql.com The code for MariaDB, including all revision history, can be found at: https://github.com/MariaDB/server - -*************************************************************************** diff --git a/client/mysqltest.cc b/client/mysqltest.cc index dc42afd30a4..ad1eb29ab70 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -90,6 +90,8 @@ static my_bool non_blocking_api_enabled= 0; #define QUERY_PRINT_ORIGINAL_FLAG 4 +#define CLOSED_CONNECTION "-closed_connection-" + #ifndef HAVE_SETENV static int setenv(const char *name, const char *value, int overwrite); #endif @@ -5597,11 +5599,12 @@ void do_close_connection(struct st_command *command) my_free(con->name); /* - When the connection is closed set name to "-closed_connection-" + When the connection is closed set name to CLOSED_CONNECTION to make it possible to reuse the connection name. */ - if (!(con->name = my_strdup("-closed_connection-", MYF(MY_WME)))) + if (!(con->name = my_strdup(CLOSED_CONNECTION, MYF(MY_WME)))) die("Out of memory"); + con->name_len= sizeof(CLOSED_CONNECTION)-1; if (con == cur_con) { @@ -5985,7 +5988,7 @@ void do_connect(struct st_command *command) con_slot= next_con; else { - if (!(con_slot= find_connection_by_name("-closed_connection-"))) + if (!(con_slot= find_connection_by_name(CLOSED_CONNECTION))) die("Connection limit exhausted, you can have max %d connections", opt_max_connections); my_free(con_slot->name); @@ -8600,7 +8603,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) log_file.flush(); dynstr_set(&ds_res, 0); - if (view_protocol_enabled && + if (view_protocol_enabled && mysql && complete_query && match_re(&view_re, query)) { @@ -8646,7 +8649,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) dynstr_free(&query_str); } - if (sp_protocol_enabled && + if (sp_protocol_enabled && mysql && complete_query && match_re(&sp_re, query)) { @@ -9009,7 +9012,7 @@ static void dump_backtrace(void) struct st_connection *conn= cur_con; fprintf(stderr, "read_command_buf (%p): ", read_command_buf); - my_safe_print_str(read_command_buf, sizeof(read_command_buf)); + fprintf(stderr, "%.*s\n", (int)read_command_buflen, read_command_buf); fputc('\n', stderr); if (conn) diff --git a/cmake/do_abi_check.cmake b/cmake/do_abi_check.cmake index 43d8b15a7ab..0ad0fa39670 100644 --- a/cmake/do_abi_check.cmake +++ b/cmake/do_abi_check.cmake @@ -74,7 +74,9 @@ FOREACH(file ${ABI_HEADERS}) FILE(REMOVE ${tmpfile}) EXECUTE_PROCESS( COMMAND diff -w ${file}.pp ${abi_check_out} RESULT_VARIABLE result) - IF(NOT ${result} EQUAL 0) + IF(result MATCHES "No such file or directory") + MESSAGE("Command 'diff' not found. ABI check for ${file} skipped.") + ELSEIF(NOT result EQUAL 0) IF(ABI_UPDATE) EXECUTE_PROCESS(COMMAND mv -v ${abi_check_out} ${file}.pp) ELSE(ABI_UPDATE) @@ -84,4 +86,3 @@ FOREACH(file ${ABI_HEADERS}) ENDIF() FILE(REMOVE ${abi_check_out}) ENDFOREACH() - diff --git a/cmake/os/OpenBSD.cmake b/cmake/os/OpenBSD.cmake new file mode 100644 index 00000000000..c8b91944275 --- /dev/null +++ b/cmake/os/OpenBSD.cmake @@ -0,0 +1,22 @@ +# Copyright (C) 2012 Monty Program Ab, 2021 Brad Smith +# +# 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 Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# This file includes OpenBSD specific options and quirks, related to system checks + +# Find libexecinfo (library that contains backtrace_symbols etc) +FIND_LIBRARY(EXECINFO NAMES execinfo) +IF(EXECINFO) + SET(LIBEXECINFO ${EXECINFO}) +ENDIF() diff --git a/libmariadb b/libmariadb -Subproject 180c543704d627a50a52aaf60e24ca14e0ec468 +Subproject 802ce584a26fdc0ba67fcf35e277bf3c7440956 diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result index 317f39526c8..7f0c2b88a41 100644 --- a/mysql-test/main/win.result +++ b/mysql-test/main/win.result @@ -3892,6 +3892,25 @@ id rn 1 1 drop table t1; # +# MDEV-25630: Crash with window function in left expr of IN subquery +# +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT lag(i) over (ORDER BY i) IN ( SELECT 1 FROM t1 a) FROM t1; +lag(i) over (ORDER BY i) IN ( SELECT 1 FROM t1 a) +NULL +1 +0 +DROP TABLE t1; +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT sum(i) over () IN ( SELECT 1 FROM t1 a) FROM t1; +sum(i) over () IN ( SELECT 1 FROM t1 a) +0 +0 +0 +DROP TABLE t1; +# # End of 10.2 tests # # diff --git a/mysql-test/main/win.test b/mysql-test/main/win.test index a83698ce0d4..2e859007d0f 100644 --- a/mysql-test/main/win.test +++ b/mysql-test/main/win.test @@ -2543,6 +2543,20 @@ order by rn desc; drop table t1; --echo # +--echo # MDEV-25630: Crash with window function in left expr of IN subquery +--echo # + +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT lag(i) over (ORDER BY i) IN ( SELECT 1 FROM t1 a) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT sum(i) over () IN ( SELECT 1 FROM t1 a) FROM t1; +DROP TABLE t1; + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result b/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result index f5a91fb352e..7d0267d5057 100644 --- a/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result +++ b/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result @@ -1,9 +1,3 @@ -SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; -NAME -SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; -NAME -SET GLOBAL innodb_file_per_table = ON; -set global innodb_compression_algorithm = 1; create database enctests; use enctests; create table t1(a int not null primary key, b char(200)) engine=innodb; diff --git a/mysql-test/suite/encryption/r/key_version_rotation.result b/mysql-test/suite/encryption/r/key_version_rotation.result new file mode 100644 index 00000000000..1a295abfe8d --- /dev/null +++ b/mysql-test/suite/encryption/r/key_version_rotation.result @@ -0,0 +1,19 @@ +create table t1(f1 int not null)engine=innodb; +create table t2(f1 int not null)engine=innodb; +insert into t1 select * from seq_1_to_100; +insert into t2 select * from seq_1_to_100; +# Enable encryption +set global innodb_encrypt_tables=ON; +# Create a new table and it is added to rotation list +create table t3(f1 int not null)engine=innodb; +insert into t3 select * from seq_1_to_100; +# Increase the version and it should set rotation +# variable for the encryption plugin +set global debug_key_management_version=10; +select @@debug_key_management_version; +@@debug_key_management_version +10 +# Decrease the key version and Disable the encryption +set global debug_key_management_version=1; +set global innodb_encrypt_tables=off; +DROP TABLE t1, t2, t3; diff --git a/mysql-test/suite/encryption/r/tempfiles_encrypted.result b/mysql-test/suite/encryption/r/tempfiles_encrypted.result index 1047dde635b..c8078d72153 100644 --- a/mysql-test/suite/encryption/r/tempfiles_encrypted.result +++ b/mysql-test/suite/encryption/r/tempfiles_encrypted.result @@ -3898,6 +3898,25 @@ id rn 1 1 drop table t1; # +# MDEV-25630: Crash with window function in left expr of IN subquery +# +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT lag(i) over (ORDER BY i) IN ( SELECT 1 FROM t1 a) FROM t1; +lag(i) over (ORDER BY i) IN ( SELECT 1 FROM t1 a) +NULL +1 +0 +DROP TABLE t1; +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT sum(i) over () IN ( SELECT 1 FROM t1 a) FROM t1; +sum(i) over () IN ( SELECT 1 FROM t1 a) +0 +0 +0 +DROP TABLE t1; +# # End of 10.2 tests # # diff --git a/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test b/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test index dffabaf97f1..96b62f7c05b 100644 --- a/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test +++ b/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test @@ -3,9 +3,6 @@ # not embedded because of restarts -- source include/not_embedded.inc -SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; -SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; - let $encryption = `SELECT @@innodb_encrypt_tables`; SET GLOBAL innodb_file_per_table = ON; # zlib diff --git a/mysql-test/suite/encryption/t/key_version_rotation.opt b/mysql-test/suite/encryption/t/key_version_rotation.opt new file mode 100644 index 00000000000..d7933f0f943 --- /dev/null +++ b/mysql-test/suite/encryption/t/key_version_rotation.opt @@ -0,0 +1,2 @@ +--innodb-tablespaces-encryption +--plugin-load-add=$DEBUG_KEY_MANAGEMENT_SO diff --git a/mysql-test/suite/encryption/t/key_version_rotation.test b/mysql-test/suite/encryption/t/key_version_rotation.test new file mode 100644 index 00000000000..d36d47251a1 --- /dev/null +++ b/mysql-test/suite/encryption/t/key_version_rotation.test @@ -0,0 +1,41 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_sequence.inc + +create table t1(f1 int not null)engine=innodb; +create table t2(f1 int not null)engine=innodb; +insert into t1 select * from seq_1_to_100; +insert into t2 select * from seq_1_to_100; + +let $restart_parameters=--innodb_encrypt_tables=0 --innodb_encryption_threads=1 --innodb_encryption_rotate_key_age=9; +--source include/restart_mysqld.inc + +--echo # Enable encryption + +set global innodb_encrypt_tables=ON; +--let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'` +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc +--echo # Create a new table and it is added to rotation list +create table t3(f1 int not null)engine=innodb; +insert into t3 select * from seq_1_to_100; + +--echo # Increase the version and it should set rotation +--echo # variable for the encryption plugin + +set global debug_key_management_version=10; +select @@debug_key_management_version; +--let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'` +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc + +--echo # Decrease the key version and Disable the encryption +set global debug_key_management_version=1; +set global innodb_encrypt_tables=off; + +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +--source include/wait_condition.inc +DROP TABLE t1, t2, t3; diff --git a/mysql-test/suite/gcol/r/innodb_virtual_index.result b/mysql-test/suite/gcol/r/innodb_virtual_index.result index 70c9d10a68b..2e9b762500d 100644 --- a/mysql-test/suite/gcol/r/innodb_virtual_index.result +++ b/mysql-test/suite/gcol/r/innodb_virtual_index.result @@ -262,3 +262,37 @@ CHECK TABLE t1; Table Op Msg_type Msg_text test.t1 check status OK DROP TABLE t1; +# +# MDEV-25872 InnoDB: Assertion failure in row_merge_read_clustered_index +# upon ALTER on table with indexed virtual columns +# +CREATE TABLE t1 ( +id BIGINT AUTO_INCREMENT PRIMARY KEY, +a INT, +va INT ZEROFILL AS (a) VIRTUAL, +b TIMESTAMP, +c CHAR(204), +vc CHAR(8), +KEY(vc,c(64),b,va) +) ENGINE=InnoDB CHARACTER SET utf32; +INSERT INTO t1 (id) SELECT NULL FROM seq_1_to_75; +INSERT IGNORE INTO t1 (id, a) VALUES (NULL, -1); +Warnings: +Warning 1264 Out of range value for column 'va' at row 1 +ALTER TABLE t1 FORCE; +ERROR 22003: Out of range value for column 'va' at row 1 +DROP TABLE t1; +# +# MDEV-24713 Assertion `dict_table_is_comp(index->table)' failed +# in row_merge_buf_add() +# +CREATE TABLE t1 (id INT PRIMARY KEY, a CHAR(3), +b CHAR(8) AS (a) VIRTUAL, KEY(b)) +ROW_FORMAT=REDUNDANT ENGINE=InnoDB +CHARACTER SET utf8; +INSERT INTO t1 (id,a) VALUES (1,'foo'); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +DROP TABLE t1; diff --git a/mysql-test/suite/gcol/t/innodb_virtual_index.opt b/mysql-test/suite/gcol/t/innodb_virtual_index.opt new file mode 100644 index 00000000000..c3f4a891cca --- /dev/null +++ b/mysql-test/suite/gcol/t/innodb_virtual_index.opt @@ -0,0 +1 @@ +--innodb_sort_buffer_size=64k diff --git a/mysql-test/suite/gcol/t/innodb_virtual_index.test b/mysql-test/suite/gcol/t/innodb_virtual_index.test index 353841840dc..94c3b7f9204 100644 --- a/mysql-test/suite/gcol/t/innodb_virtual_index.test +++ b/mysql-test/suite/gcol/t/innodb_virtual_index.test @@ -1,4 +1,5 @@ --source include/have_innodb.inc +--source include/have_sequence.inc # Ensure that the history list length will actually be decremented by purge. SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency; @@ -281,3 +282,35 @@ ROLLBACK; SELECT * FROM t1; CHECK TABLE t1; DROP TABLE t1; + +--echo # +--echo # MDEV-25872 InnoDB: Assertion failure in row_merge_read_clustered_index +--echo # upon ALTER on table with indexed virtual columns +--echo # + +CREATE TABLE t1 ( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + a INT, + va INT ZEROFILL AS (a) VIRTUAL, + b TIMESTAMP, + c CHAR(204), + vc CHAR(8), + KEY(vc,c(64),b,va) +) ENGINE=InnoDB CHARACTER SET utf32; +INSERT INTO t1 (id) SELECT NULL FROM seq_1_to_75; +INSERT IGNORE INTO t1 (id, a) VALUES (NULL, -1); +--error ER_WARN_DATA_OUT_OF_RANGE +ALTER TABLE t1 FORCE; +DROP TABLE t1; + +--echo # +--echo # MDEV-24713 Assertion `dict_table_is_comp(index->table)' failed +--echo # in row_merge_buf_add() +--echo # +CREATE TABLE t1 (id INT PRIMARY KEY, a CHAR(3), + b CHAR(8) AS (a) VIRTUAL, KEY(b)) + ROW_FORMAT=REDUNDANT ENGINE=InnoDB + CHARACTER SET utf8; +INSERT INTO t1 (id,a) VALUES (1,'foo'); +OPTIMIZE TABLE t1; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb-alter.result b/mysql-test/suite/innodb/r/innodb-alter.result index 3bbc4bd3b63..cce8a060b0e 100644 --- a/mysql-test/suite/innodb/r/innodb-alter.result +++ b/mysql-test/suite/innodb/r/innodb-alter.result @@ -1049,10 +1049,13 @@ a 10 DROP TABLE t1; CREATE TABLE t1 (a INT NOT NULL DEFAULT 0) ENGINE=InnoDB; +SET @save_allowed = @@GLOBAL.innodb_instant_alter_column_allowed; +SET GLOBAL innodb_instant_alter_column_allowed=never; iNSERT INTO t1 VALUES (10); ALTER TABLE t1 ADD b DATE NOT NULL DEFAULT if(unix_timestamp()>1,TIMESTAMP'2001-01-01 10:20:30',0); affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 +SET GLOBAL innodb_instant_alter_column_allowed=@save_allowed; SELECT * FROM t1; a b 10 2001-01-01 diff --git a/mysql-test/suite/innodb/t/innodb-alter.test b/mysql-test/suite/innodb/t/innodb-alter.test index df2cd1707dc..e0ee5a04ac4 100644 --- a/mysql-test/suite/innodb/t/innodb-alter.test +++ b/mysql-test/suite/innodb/t/innodb-alter.test @@ -652,10 +652,13 @@ DROP TABLE t1; # DATETIME-to-DATE truncation is OK CREATE TABLE t1 (a INT NOT NULL DEFAULT 0) ENGINE=InnoDB; +SET @save_allowed = @@GLOBAL.innodb_instant_alter_column_allowed; +SET GLOBAL innodb_instant_alter_column_allowed=never; iNSERT INTO t1 VALUES (10); --enable_info ALTER TABLE t1 ADD b DATE NOT NULL DEFAULT if(unix_timestamp()>1,TIMESTAMP'2001-01-01 10:20:30',0); --disable_info +SET GLOBAL innodb_instant_alter_column_allowed=@save_allowed; SELECT * FROM t1; DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/r/misc_debug.result b/mysql-test/suite/innodb_fts/r/misc_debug.result index 41f8d08ea7d..9f13822ecda 100644 --- a/mysql-test/suite/innodb_fts/r/misc_debug.result +++ b/mysql-test/suite/innodb_fts/r/misc_debug.result @@ -31,19 +31,17 @@ DROP TABLE t2, t1; # CREATE TABLE t1(a INT, b TEXT, c TEXT, FULLTEXT INDEX(b)) ENGINE=InnoDB; connect con1,localhost,root,,test; -SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL s1 WAIT_FOR g1'; +SET DEBUG_DBUG="+d,innodb_OOM_inplace_alter"; SET DEBUG_SYNC='innodb_commit_inplace_alter_table_enter SIGNAL s2 WAIT_FOR g2'; ALTER TABLE t1 ADD FULLTEXT(c); connection default; -SET DEBUG_SYNC='now WAIT_FOR s1'; -KILL QUERY @id; -SET DEBUG_SYNC='now SIGNAL g1 WAIT_FOR s2'; +SET DEBUG_SYNC='now WAIT_FOR s2'; START TRANSACTION; SELECT * FROM t1; a b c -SET DEBUG_SYNC='now SIGNAL s2'; +SET DEBUG_SYNC='now SIGNAL g2'; connection con1; -ERROR 70100: Query execution was interrupted +ERROR HY000: Out of memory. disconnect con1; connection default; SET DEBUG_SYNC=RESET; diff --git a/mysql-test/suite/innodb_fts/t/misc_debug.test b/mysql-test/suite/innodb_fts/t/misc_debug.test index 90cb84976ce..c8542152d4d 100644 --- a/mysql-test/suite/innodb_fts/t/misc_debug.test +++ b/mysql-test/suite/innodb_fts/t/misc_debug.test @@ -60,20 +60,16 @@ DROP TABLE t2, t1; --echo # CREATE TABLE t1(a INT, b TEXT, c TEXT, FULLTEXT INDEX(b)) ENGINE=InnoDB; connect(con1,localhost,root,,test); -let $ID= `SELECT @id := CONNECTION_ID()`; -SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL s1 WAIT_FOR g1'; +SET DEBUG_DBUG="+d,innodb_OOM_inplace_alter"; SET DEBUG_SYNC='innodb_commit_inplace_alter_table_enter SIGNAL s2 WAIT_FOR g2'; send ALTER TABLE t1 ADD FULLTEXT(c); connection default; -SET DEBUG_SYNC='now WAIT_FOR s1'; -let $ignore= `SELECT @id := $ID`; -KILL QUERY @id; -SET DEBUG_SYNC='now SIGNAL g1 WAIT_FOR s2'; +SET DEBUG_SYNC='now WAIT_FOR s2'; START TRANSACTION; SELECT * FROM t1; -SET DEBUG_SYNC='now SIGNAL s2'; +SET DEBUG_SYNC='now SIGNAL g2'; connection con1; ---error ER_QUERY_INTERRUPTED +--error ER_OUT_OF_RESOURCES reap; disconnect con1; connection default; diff --git a/mysql-test/suite/mariabackup/auth_plugin_win.result b/mysql-test/suite/mariabackup/auth_plugin_win.result index 7a623be147f..caf5d8df87d 100644 --- a/mysql-test/suite/mariabackup/auth_plugin_win.result +++ b/mysql-test/suite/mariabackup/auth_plugin_win.result @@ -1,5 +1,5 @@ INSTALL SONAME 'auth_named_pipe'; CREATE USER 'USERNAME' IDENTIFIED WITH named_pipe; -GRANT ALL PRIVILEGES ON *.* to USERNAME; +GRANT ALL PRIVILEGES ON *.* to 'USERNAME'; DROP USER 'USERNAME'; UNINSTALL SONAME 'auth_named_pipe'; diff --git a/mysql-test/suite/mariabackup/auth_plugin_win.test b/mysql-test/suite/mariabackup/auth_plugin_win.test index 9c8cd5ad411..70ae74b7028 100644 --- a/mysql-test/suite/mariabackup/auth_plugin_win.test +++ b/mysql-test/suite/mariabackup/auth_plugin_win.test @@ -18,7 +18,7 @@ INSTALL SONAME 'auth_named_pipe'; --replace_result $USERNAME USERNAME eval CREATE USER '$USERNAME' IDENTIFIED WITH named_pipe; --replace_result $USERNAME USERNAME -eval GRANT ALL PRIVILEGES ON *.* to $USERNAME; +eval GRANT ALL PRIVILEGES ON *.* to '$USERNAME'; let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; --disable_result_log diff --git a/mysql-test/suite/plugins/r/unix_socket.result b/mysql-test/suite/plugins/r/unix_socket.result index 0e08794fbe6..096b736cd68 100644 --- a/mysql-test/suite/plugins/r/unix_socket.result +++ b/mysql-test/suite/plugins/r/unix_socket.result @@ -2,7 +2,7 @@ install plugin unix_socket soname 'auth_socket.so'; # # with named user # -create user USER identified via unix_socket; +create user 'USER' identified via unix_socket; # # name match = ok # @@ -12,7 +12,7 @@ USER@localhost USER@% test # # name does not match = failure # -drop user USER; +drop user 'USER'; # # and now with anonymous user # diff --git a/mysql-test/suite/plugins/t/unix_socket.test b/mysql-test/suite/plugins/t/unix_socket.test index bd0323c0274..75409ec70b4 100644 --- a/mysql-test/suite/plugins/t/unix_socket.test +++ b/mysql-test/suite/plugins/t/unix_socket.test @@ -12,9 +12,9 @@ eval install plugin unix_socket soname '$AUTH_SOCKET_SO'; --echo # with named user --echo # ---let $replace=create user $USER ---replace_result $replace "create user USER" -eval create user $USER identified via unix_socket; +--let $replace=create user '$USER' +--replace_result $replace "create user 'USER'" +eval create user '$USER' identified via unix_socket; --write_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt --let $replace1=$USER@localhost @@ -34,9 +34,9 @@ EOF --error 1 --exec $MYSQL_TEST -u foobar --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt ---let $replace=drop user $USER ---replace_result $replace "drop user USER" -eval drop user $USER; +--let $replace=drop user '$USER' +--replace_result $replace "drop user 'USER'" +eval drop user '$USER'; --echo # --echo # and now with anonymous user diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index 41b586f44ab..33930316f08 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -1384,7 +1384,7 @@ static void copy_to_read_buffer(IO_CACHE *write_cache, static int _my_b_seq_read(IO_CACHE *info, uchar *Buffer, size_t Count) { - size_t length, diff_length, left_length= 0, save_count, max_length; + size_t length, diff_length, save_count, max_length; my_off_t pos_in_file; save_count=Count; @@ -1435,7 +1435,6 @@ static int _my_b_seq_read(IO_CACHE *info, uchar *Buffer, size_t Count) */ goto read_append_buffer; } - left_length+=length; diff_length=0; } diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index 05944ef6035..4dedecb439f 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -1190,7 +1190,6 @@ trim_string() check_pid() { local pid_file="$1" - local remove=${2:-0} if [ -r "$pid_file" ]; then local pid=$(cat "$pid_file" 2>/dev/null) if [ -n "$pid" ]; then @@ -1201,6 +1200,7 @@ check_pid() fi fi fi + local remove=${2:-0} if [ $remove -eq 1 ]; then rm -f "$pid_file" fi @@ -1223,7 +1223,7 @@ check_pid() # cleanup_pid() { - local pid="$1" + local pid=$1 local pid_file="${2:-}" local config="${3:-}" @@ -1241,8 +1241,9 @@ cleanup_pid() round=8 force=1 kill -9 $pid >/dev/null 2>&1 + sleep 0.5 else - return 1; + return 1 fi fi done @@ -1254,7 +1255,7 @@ cleanup_pid() fi [ -n "$pid_file" ] && [ -f "$pid_file" ] && rm -f "$pid_file" - [ -n "$config" ] && [ -f "$config" ] && rm -f "$config" + [ -n "$config" ] && [ -f "$config" ] && rm -f "$config" return 0 } diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index 7f97d9e8dea..339a8fcf4a5 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -741,15 +741,15 @@ recv_joiner() fi # check donor supplied secret - SECRET=$(grep -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | cut -d ' ' -f 2) + SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | cut -d ' ' -f 2) if [ "$SECRET" != "$MY_SECRET" ]; then wsrep_log_error "Donor does not know my secret!" wsrep_log_info "Donor:'$SECRET', my:'$MY_SECRET'" exit 32 fi - # remove secret from magic file - grep -v -- "$SECRET_TAG " "$MAGIC_FILE" > "$MAGIC_FILE.new" + # remove secret from the magic file + grep -v -F -- "$SECRET_TAG " "$MAGIC_FILE" > "$MAGIC_FILE.new" mv "$MAGIC_FILE.new" "$MAGIC_FILE" fi } diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 19a4d19fded..fc9f5017937 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -68,6 +68,8 @@ cleanup_joiner() if [ "$WSREP_SST_OPT_ROLE" = 'joiner' ]; then wsrep_cleanup_progress_file fi + + [ -f "$SST_PID" ] && rm -f "$SST_PID" } check_pid_and_port() @@ -281,6 +283,7 @@ then *) wsrep_log_error "Unrecognized ssl-mode option: '$SSLMODE'" exit 22 # EINVAL + ;; esac if [ -z "$CAFILE_OPT" ]; then wsrep_log_error "Can't have ssl-mode='$SSLMODE' without CA file" @@ -426,7 +429,7 @@ EOF exit 255 # unknown error fi - # second, we transfer InnoDB log files + # second, we transfer InnoDB and Aria log files rsync ${STUNNEL:+--rsh="$STUNNEL"} \ --owner --group --perms --links --specials \ --ignore-times --inplace --dirs --delete --quiet \ @@ -499,7 +502,22 @@ elif [ "$WSREP_SST_OPT_ROLE" = 'joiner' ] then check_sockets_utils - # give some time for lingering stunnel from previous SST to complete + SST_PID="$WSREP_SST_OPT_DATA/wsrep_rsync_sst.pid" + + # give some time for previous SST to complete: + check_round=0 + while check_pid "$SST_PID" 0 + do + wsrep_log_info "previous SST is not completed, waiting for it to exit" + check_round=$(( check_round + 1 )) + if [ $check_round -eq 10 ]; then + wsrep_log_error "previous SST script still running." + exit 114 # EALREADY + fi + sleep 1 + done + + # give some time for stunnel from the previous SST to complete: check_round=0 while check_pid "$STUNNEL_PID" 1 do @@ -516,7 +534,7 @@ then RSYNC_PID="$WSREP_SST_OPT_DATA/$MODULE.pid" RSYNC_CONF="$WSREP_SST_OPT_DATA/$MODULE.conf" - # give some time for lingering rsync from previous SST to complete + # give some time for rsync from the previous SST to complete: check_round=0 while check_pid "$RSYNC_PID" 1 do @@ -583,12 +601,14 @@ EOF RSYNC_ADDR="*" fi + echo $$ > "$SST_PID" + if [ -z "$STUNNEL" ] then rsync --daemon --no-detach --port "$RSYNC_PORT" --config "$RSYNC_CONF" $RSYNC_EXTRA_ARGS & RSYNC_REAL_PID=$! - TRANSFER_REAL_PID="$RSYNC_REAL_PID" - TRANSFER_PID=$RSYNC_PID + TRANSFER_REAL_PID=$RSYNC_REAL_PID + TRANSFER_PID="$RSYNC_PID" else # Let's check if the path to the config file contains a space? if [ "${RSYNC_CONF#* }" = "$RSYNC_CONF" ]; then @@ -631,8 +651,8 @@ EOF fi stunnel "$STUNNEL_CONF" & STUNNEL_REAL_PID=$! - TRANSFER_REAL_PID="$STUNNEL_REAL_PID" - TRANSFER_PID=$STUNNEL_PID + TRANSFER_REAL_PID=$STUNNEL_REAL_PID + TRANSFER_PID="$STUNNEL_PID" fi if [ "${SSLMODE#VERIFY}" != "$SSLMODE" ] @@ -691,35 +711,49 @@ EOF # Clean up old binlog files first rm -f "$BINLOG_FILENAME".[0-9]* - [ -f "$binlog_index" ] && rm "$binlog_index" + [ -f "$binlog_index" ] && rm -f "$binlog_index" + + # Create a temporary file: + tmpdir=$(parse_cnf '--mysqld|sst' 'tmpdir') + if [ -z "$tmpdir" ]; then + tmpfile="$(mktemp)" + else + tmpfile=$(mktemp "--tmpdir=$tmpdir") + fi wsrep_log_info "Extracting binlog files:" - tar -xvf "$BINLOG_TAR_FILE" >> _binlog_tmp_files_$! + if ! tar -xvf "$BINLOG_TAR_FILE" > "$tmpfile"; then + wsrep_log_error "Error unpacking tar file with binlog files" + rm -f "$tmpfile" + exit 32 + fi + + # Rebuild binlog index: while read bin_file; do echo "$BINLOG_DIRNAME/$bin_file" >> "$binlog_index" - done < _binlog_tmp_files_$! - rm -f _binlog_tmp_files_$! + done < "$tmpfile" + rm -f "$tmpfile" cd "$OLD_PWD" fi fi - if [ -r "$MAGIC_FILE" ] - then - # check donor supplied secret - SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | cut -d ' ' -f 2) - if [ "$SECRET" != "$MY_SECRET" ]; then - wsrep_log_error "Donor does not know my secret!" - wsrep_log_info "Donor:'$SECRET', my:'$MY_SECRET'" - exit 32 + if [ -r "$MAGIC_FILE" ]; then + if [ -n "$MY_SECRET" ]; then + # check donor supplied secret + SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | cut -d ' ' -f 2) + if [ "$SECRET" != "$MY_SECRET" ]; then + wsrep_log_error "Donor does not know my secret!" + wsrep_log_info "Donor:'$SECRET', my:'$MY_SECRET'" + exit 32 + fi + # remove secret from the magic file, and output + # the UUID:seqno & wsrep_gtid_domain_id: + grep -v -F -- "$SECRET_TAG " "$MAGIC_FILE" + else + # Output the UUID:seqno and wsrep_gtid_domain_id: + cat "$MAGIC_FILE" fi - - # remove secret from magic file - grep -v -F -- "$SECRET_TAG " "$MAGIC_FILE" > "$MAGIC_FILE.new" - - mv "$MAGIC_FILE.new" "$MAGIC_FILE" - # UUID:seqno & wsrep_gtid_domain_id is received here. - cat "$MAGIC_FILE" # Output : UUID:seqno wsrep_gtid_domain_id else # this message should cause joiner to abort echo "rsync process ended without creating '$MAGIC_FILE'" diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc index 2ebe1f5bb69..f35485f9acf 100644 --- a/sql/event_scheduler.cc +++ b/sql/event_scheduler.cc @@ -434,7 +434,7 @@ Event_scheduler::start(int *err_no) scheduler_thd= NULL; deinit_event_thread(new_thd); - delete scheduler_param_value; + my_free(scheduler_param_value); ret= true; } diff --git a/sql/item.cc b/sql/item.cc index d5a4b4363d3..f91705bfaff 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -8601,6 +8601,7 @@ Item_cache_wrapper::Item_cache_wrapper(THD *thd, Item *item_arg): with_field= orig_item->with_field; name= item_arg->name; m_with_subquery= orig_item->with_subquery(); + with_window_func= orig_item->with_window_func; if ((expr_value= orig_item->get_cache(thd))) expr_value->setup(thd, orig_item); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 413c422eace..9ebd765f1b2 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1359,6 +1359,9 @@ bool Item_in_optimizer::fix_fields(THD *thd, Item **ref) maybe_null=1; m_with_subquery= true; with_sum_func= with_sum_func || args[1]->with_sum_func; + with_window_func= args[0]->with_window_func; + // The subquery cannot have window functions aggregated in this select + DBUG_ASSERT(!args[1]->with_window_func); with_field= with_field || args[1]->with_field; with_param= args[0]->with_param || args[1]->with_param; used_tables_and_const_cache_join(args[1]); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7f4c6d24b8d..7a97ae5294f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4500,7 +4500,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, int error= 0; TABLE *UNINIT_VAR(table); /* inited in all loops */ uint i,table_count,const_count,key; - table_map found_const_table_map, all_table_map, found_ref, refs; + table_map found_const_table_map, all_table_map; key_map const_ref, eq_part; bool has_expensive_keyparts; TABLE **table_vector; @@ -4763,7 +4763,6 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, { ref_changed = 0; more_const_tables_found: - found_ref=0; /* We only have to loop from stat_vector + const_count as @@ -4853,7 +4852,6 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, key=keyuse->key; s->keys.set_bit(key); // TODO: remove this ? - refs=0; const_ref.clear_all(); eq_part.clear_all(); has_expensive_keyparts= false; @@ -4869,8 +4867,6 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, if (keyuse->val->is_expensive()) has_expensive_keyparts= true; } - else - refs|=keyuse->used_tables; eq_part.set_bit(keyuse->keypart); } keyuse++; @@ -4922,8 +4918,6 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, found_const_table_map|= table->map; break; } - else - found_ref|= refs; // Table is const if all refs are const } else if (base_const_ref == base_eq_part) s->const_keys.set_bit(key); @@ -27248,7 +27242,6 @@ static bool get_range_limit_read_cost(const JOIN_TAB *tab, */ if (tab) { - key_part_map const_parts= 0; key_part_map map= 1; uint kp; /* Find how many key parts would be used by ref(const) */ @@ -27256,7 +27249,6 @@ static bool get_range_limit_read_cost(const JOIN_TAB *tab, { if (!(table->const_key_parts[keynr] & map)) break; - const_parts |= map; } if (kp > 0) diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index f0f0351e20a..bf428c19191 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -55,6 +55,9 @@ UNIV_INTERN uint srv_n_fil_crypt_threads_started = 0; /** At this age or older a space/page will be rotated */ UNIV_INTERN uint srv_fil_crypt_rotate_key_age; +/** Whether the encryption plugin does key rotation */ +static bool srv_encrypt_rotate; + /** Event to signal FROM the key rotation threads. */ static os_event_t fil_crypt_event; @@ -136,6 +139,14 @@ fil_space_crypt_t::key_get_latest_version(void) if (is_key_found()) { key_version = encryption_key_get_latest_version(key_id); + /* InnoDB does dirty read of srv_fil_crypt_rotate_key_age. + It doesn't matter because srv_encrypt_rotate + can be set to true only once */ + if (!srv_encrypt_rotate + && key_version > srv_fil_crypt_rotate_key_age) { + srv_encrypt_rotate = true; + } + srv_stats.n_key_requests.inc(); key_found = key_version; } @@ -1000,13 +1011,11 @@ static bool fil_crypt_start_encrypting_space(fil_space_t* space) /* 4 - sync tablespace before publishing crypt data */ bool success = false; - ulint sum_pages = 0; do { ulint n_pages = 0; success = buf_flush_lists(ULINT_MAX, end_lsn, &n_pages); buf_flush_wait_batch_end(NULL, BUF_FLUSH_LIST); - sum_pages += n_pages; } while (!success); /* 5 - publish crypt data */ @@ -1379,46 +1388,63 @@ fil_crypt_return_iops( fil_crypt_update_total_stat(state); } -/** Return the next tablespace from rotation_list. +bool fil_crypt_must_default_encrypt() +{ + return !srv_fil_crypt_rotate_key_age || !srv_encrypt_rotate; +} + +/** Return the next tablespace from default_encrypt_tables. @param space previous tablespace (NULL to start from the start) @param recheck whether the removal condition needs to be rechecked after the encryption parameters were changed @param encrypt expected state of innodb_encrypt_tables @return the next tablespace to process (n_pending_ops incremented) @retval NULL if this was the last */ -inline fil_space_t *fil_system_t::keyrotate_next(fil_space_t *space, - bool recheck, bool encrypt) +inline fil_space_t *fil_system_t::default_encrypt_next( + fil_space_t *space, bool recheck, bool encrypt) { ut_ad(mutex_own(&mutex)); sized_ilist<fil_space_t, rotation_list_tag_t>::iterator it= - space && space->is_in_rotation_list ? space : rotation_list.begin(); + space && space->is_in_default_encrypt + ? space + : default_encrypt_tables.begin(); const sized_ilist<fil_space_t, rotation_list_tag_t>::iterator end= - rotation_list.end(); + default_encrypt_tables.end(); if (space) { const bool released= !space->release(); - if (space->is_in_rotation_list) + if (space->is_in_default_encrypt) { while (++it != end && (!UT_LIST_GET_LEN(it->chain) || it->is_stopping())); - /* If one of the encryption threads already started the encryption - of the table then don't remove the unencrypted spaces from rotation list + /* If one of the encryption threads already started + the encryption of the table then don't remove the + unencrypted spaces from default encrypt list. - If there is a change in innodb_encrypt_tables variables value then - don't remove the last processed tablespace from the rotation list. */ + If there is a change in innodb_encrypt_tables variables + value then don't remove the last processed tablespace + from the default encrypt list. */ if (released && (!recheck || space->crypt_data) && !encrypt == !srv_encrypt_tables) { - ut_a(!rotation_list.empty()); - rotation_list.remove(*space); - space->is_in_rotation_list= false; + ut_a(!default_encrypt_tables.empty()); + default_encrypt_tables.remove(*space); + space->is_in_default_encrypt= false; } } } + else while (it != end && + (!UT_LIST_GET_LEN(it->chain) || it->is_stopping())) + { + /* Find the next suitable default encrypt table if + beginning of default_encrypt_tables list has been scheduled + to be deleted */ + it++; + } while (it != end) { @@ -1443,8 +1469,8 @@ static fil_space_t *fil_space_next(fil_space_t *space, bool recheck, { mutex_enter(&fil_system.mutex); - if (!srv_fil_crypt_rotate_key_age) - space= fil_system.keyrotate_next(space, recheck, encrypt); + if (fil_crypt_must_default_encrypt()) + space= fil_system.default_encrypt_next(space, recheck, encrypt); else if (!space) { space= UT_LIST_GET_FIRST(fil_system.space_list); @@ -2331,9 +2357,9 @@ fil_crypt_set_thread_cnt( } } -/** Initialize the tablespace rotation_list +/** Initialize the tablespace default_encrypt_tables if innodb_encryption_rotate_key_age=0. */ -static void fil_crypt_rotation_list_fill() +static void fil_crypt_default_encrypt_tables_fill() { ut_ad(mutex_own(&fil_system.mutex)); @@ -2341,7 +2367,7 @@ static void fil_crypt_rotation_list_fill() space != NULL; space = UT_LIST_GET_NEXT(space_list, space)) { if (space->purpose != FIL_TYPE_TABLESPACE - || space->is_in_rotation_list + || space->is_in_default_encrypt || UT_LIST_GET_LEN(space->chain) == 0 || !space->acquire()) { continue; @@ -2381,8 +2407,8 @@ static void fil_crypt_rotation_list_fill() } } - fil_system.rotation_list.push_back(*space); - space->is_in_rotation_list = true; + fil_system.default_encrypt_tables.push_back(*space); + space->is_in_default_encrypt = true; next: space->release(); } @@ -2399,7 +2425,7 @@ fil_crypt_set_rotate_key_age( mutex_enter(&fil_system.mutex); srv_fil_crypt_rotate_key_age = val; if (val == 0) { - fil_crypt_rotation_list_fill(); + fil_crypt_default_encrypt_tables_fill(); } mutex_exit(&fil_system.mutex); os_event_set(fil_crypt_threads_event); @@ -2429,8 +2455,8 @@ fil_crypt_set_encrypt_tables( srv_encrypt_tables = val; - if (srv_fil_crypt_rotate_key_age == 0) { - fil_crypt_rotation_list_fill(); + if (fil_crypt_must_default_encrypt()) { + fil_crypt_default_encrypt_tables_fill(); } mutex_exit(&fil_system.mutex); diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 3d4d65eccfd..b045f8b16b8 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1199,9 +1199,9 @@ fil_space_detach( space->is_in_unflushed_spaces = false; } - if (space->is_in_rotation_list) { - fil_system.rotation_list.remove(*space); - space->is_in_rotation_list = false; + if (space->is_in_default_encrypt) { + fil_system.default_encrypt_tables.remove(*space); + space->is_in_default_encrypt = false; } UT_LIST_REMOVE(fil_system.space_list, space); @@ -1408,16 +1408,19 @@ fil_space_create( fil_system.max_assigned_id = id; } + const bool rotate = + (purpose == FIL_TYPE_TABLESPACE + && (mode == FIL_ENCRYPTION_ON + || mode == FIL_ENCRYPTION_OFF || srv_encrypt_tables) + && fil_crypt_must_default_encrypt()); + /* Inform key rotation that there could be something to do */ - if (purpose == FIL_TYPE_TABLESPACE - && !srv_fil_crypt_rotate_key_age && fil_crypt_threads_event && - (mode == FIL_ENCRYPTION_ON || mode == FIL_ENCRYPTION_OFF || - srv_encrypt_tables)) { + if (rotate) { /* Key rotation is not enabled, need to inform background encryption threads. */ - fil_system.rotation_list.push_back(*space); - space->is_in_rotation_list = true; + fil_system.default_encrypt_tables.push_back(*space); + space->is_in_default_encrypt = true; mutex_exit(&fil_system.mutex); os_event_set(fil_crypt_threads_event); } else { diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 155aab0011d..b11e62cff5f 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, 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 the terms of the GNU General Public License as published by the Free Software @@ -2586,7 +2586,6 @@ fsp_reserve_free_extents( ulint n_free; ulint n_free_up; ulint reserve; - size_t total_reserved = 0; ut_ad(mtr); *n_reserved = n_ext; @@ -2667,8 +2666,7 @@ try_again: return(true); } try_to_extend: - if (ulint n = fsp_try_extend_data_file(space, space_header, mtr)) { - total_reserved += n; + if (fsp_try_extend_data_file(space, space_header, mtr)) { goto try_again; } diff --git a/storage/innobase/include/fil0crypt.h b/storage/innobase/include/fil0crypt.h index 870858b4ccd..c7f74b743aa 100644 --- a/storage/innobase/include/fil0crypt.h +++ b/storage/innobase/include/fil0crypt.h @@ -497,4 +497,10 @@ bool fil_space_verify_crypt_checksum(const byte* page, const page_size_t& page_size) MY_ATTRIBUTE((warn_unused_result)); +/** Add the tablespace to the rotation list if +innodb_encrypt_rotate_key_age is 0 or encryption plugin does +not do key version rotation +@return whether the tablespace should be added to rotation list */ +bool fil_crypt_must_default_encrypt(); + #endif /* fil0crypt_h */ diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 6a184fe6f94..7e21b00a35e 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2020, MariaDB Corporation. +Copyright (c) 2013, 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 @@ -170,7 +170,7 @@ public: bool is_in_unflushed_spaces; /** Checks that this tablespace needs key rotation. */ - bool is_in_rotation_list; + bool is_in_default_encrypt; /** True if the device this filespace is on supports atomic writes */ bool atomic_write_supported; @@ -683,9 +683,9 @@ public: record has been written since the latest redo log checkpoint. Protected only by log_sys.mutex. */ - ilist<fil_space_t, rotation_list_tag_t> rotation_list; - /*!< list of all file spaces needing - key rotation.*/ + + /** List of all file spaces need key rotation */ + ilist<fil_space_t, rotation_list_tag_t> default_encrypt_tables; bool space_id_reuse_warned; /*!< whether fil_space_create() @@ -698,15 +698,15 @@ public: @retval NULL if the tablespace does not exist or cannot be read */ fil_space_t* read_page0(ulint id); - /** Return the next tablespace from rotation_list. + /** Return the next tablespace from default_encrypt_tables list. @param space previous tablespace (NULL to start from the start) @param recheck whether the removal condition needs to be rechecked after the encryption parameters were changed @param encrypt expected state of innodb_encrypt_tables @return the next tablespace to process (n_pending_ops incremented) @retval NULL if this was the last */ - inline fil_space_t* keyrotate_next(fil_space_t *space, bool recheck, - bool encrypt); + inline fil_space_t* default_encrypt_next( + fil_space_t *space, bool recheck, bool encrypt); }; /** The tablespace memory cache. */ diff --git a/storage/innobase/include/trx0types.h b/storage/innobase/include/trx0types.h index 2aaec580d65..58b746ca189 100644 --- a/storage/innobase/include/trx0types.h +++ b/storage/innobase/include/trx0types.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2014, 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 @@ -91,8 +91,6 @@ enum trx_dict_op_t { struct trx_t; /** The locks and state of an active transaction */ struct trx_lock_t; -/** Signal */ -struct trx_sig_t; /** Rollback segment */ struct trx_rseg_t; /** Transaction undo log */ diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index 3d9bc6f0ab1..68f721248b9 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2010, 2016, 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 @@ -770,7 +770,6 @@ DECLARE_THREAD(fts_parallel_tokenization)( row_merge_block_t** crypt_block; pfs_os_file_t tmpfd[FTS_NUM_AUX_INDEX]; ulint mycount[FTS_NUM_AUX_INDEX]; - ib_uint64_t total_rec = 0; ulint num_doc_processed = 0; doc_id_t last_doc_id = 0; mem_heap_t* blob_heap = NULL; @@ -1039,7 +1038,6 @@ exit: goto func_exit; } - total_rec += merge_file[i]->n_rec; os_file_close(tmpfd[i]); } diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 9e84f9db033..e99710abe38 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -524,7 +524,9 @@ row_merge_buf_add( DBUG_ENTER("row_merge_buf_add"); if (buf->n_tuples >= buf->max_tuples) { - DBUG_RETURN(0); +error: + n_row_added = 0; + goto end; } DBUG_EXECUTE_IF( @@ -689,7 +691,10 @@ row_merge_buf_add( continue; } - if (field->len != UNIV_SQL_NULL + /* innobase_get_computed_value() sets the + length of the virtual column field. */ + if (v_col == NULL + && field->len != UNIV_SQL_NULL && col->mtype == DATA_MYSQL && col->len != field->len) { if (conv_heap != NULL) { @@ -845,11 +850,6 @@ end: if (vcol_storage.innobase_record) innobase_free_row_for_vcol(&vcol_storage); DBUG_RETURN(n_row_added); - -error: - if (vcol_storage.innobase_record) - innobase_free_row_for_vcol(&vcol_storage); - DBUG_RETURN(0); } /*************************************************************//** @@ -2692,16 +2692,18 @@ write_buffers: new_table, psort_info, row, ext, &doc_id, conv_heap, &err, &v_heap, eval_table, trx)))) { - /* An empty buffer should have enough - room for at least one record. */ - ut_error; - } - - if (err != DB_SUCCESS) { - break; + /* An empty buffer should have enough + room for at least one record. */ + ut_ad(err == DB_COMPUTE_VALUE_FAILED + || err == DB_OUT_OF_MEMORY + || err == DB_TOO_BIG_RECORD); + } else if (err == DB_SUCCESS) { + file->n_rec += rows_added; + continue; } - file->n_rec += rows_added; + trx->error_key_num = i; + break; } } diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 0f4d79032f8..8cf2e79e970 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -4202,7 +4202,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, const char * name, my_bool rep_quick) { int got_error; - uint i,key, total_key_length, istep; + uint i,key, istep; ha_rows start_records; my_off_t new_header_length,del; File new_file; @@ -4364,7 +4364,9 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, _ma_check_print_error(param,"Not enough memory for key!"); goto err; } - total_key_length=0; +#ifdef USING_SECOND_APPROACH + uint total_key_length=0; +#endif rec_per_key_part= param->new_rec_per_key_part; share->state.state.records=share->state.state.del=share->state.split=0; share->state.state.empty=0; @@ -4433,7 +4435,9 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, if (keyseg->flag & HA_NULL_PART) sort_param[i].key_length++; } +#ifdef USING_SECOND_APPROACH total_key_length+=sort_param[i].key_length; +#endif if (sort_param[i].keyinfo->flag & HA_FULLTEXT) { diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 199f46edcff..9b4067ffa0c 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -2612,7 +2612,7 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, const char * name, int rep_quick) { int got_error; - uint i,key, total_key_length, istep; + uint i,key, istep; ulong rec_length; ha_rows start_records; my_off_t new_header_length,del; @@ -2798,7 +2798,9 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, mi_check_print_error(param,"Not enough memory for key!"); goto err; } - total_key_length=0; +#ifdef USING_SECOND_APPROACH + uint total_key_length=0; +#endif rec_per_key_part= param->rec_per_key_part; info->state->records=info->state->del=share->state.split=0; info->state->empty=0; @@ -2867,7 +2869,9 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, if (keyseg->flag & HA_NULL_PART) sort_param[i].key_length++; } +#ifdef USING_SECOND_APPROACH total_key_length+=sort_param[i].key_length; +#endif if (sort_param[i].keyinfo->flag & HA_FULLTEXT) { diff --git a/support-files/rpm/server-posttrans.sh b/support-files/rpm/server-posttrans.sh index 1525b592735..3250423da8f 100644 --- a/support-files/rpm/server-posttrans.sh +++ b/support-files/rpm/server-posttrans.sh @@ -3,7 +3,7 @@ if [ -r %{restart_flag} ] ; then # only restart the server if it was alredy running if [ -x /usr/bin/systemctl ] ; then /usr/bin/systemctl daemon-reload > /dev/null 2>&1 - if [ /usr/bin/systemctl is-active mysql ]; then + if /usr/bin/systemctl is-active mysql; then /usr/bin/systemctl restart mysql > /dev/null 2>&1 else /usr/bin/systemctl try-restart mariadb.service > /dev/null 2>&1 |