From 683f91a287c25ee3175013a69fb36925dd656fea Mon Sep 17 00:00:00 2001 From: Marek Kulik Date: Wed, 25 Aug 2021 09:15:24 +0200 Subject: [PATCH 01/10] Fix mysql_setpermission hostname logic Changes: - Don't include port in connection parameters with 'localhost' hostname More info: The hostname, if not specified or specified as '' or 'localhost', will default to a MySQL server running on the local machine using the default for the UNIX socket. To connect to a MySQL server on the local machine via TCP, you must specify the loopback IP address (127.0.0.1) as the host. Reported issue: https://bugzilla.redhat.com/show_bug.cgi?id=1976224 --- scripts/mysql_setpermission.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh index 71462d28622..01b3d5e7e90 100644 --- a/scripts/mysql_setpermission.sh +++ b/scripts/mysql_setpermission.sh @@ -52,6 +52,7 @@ use strict; use vars qw($dbh $sth $hostname $opt_user $opt_password $opt_help $opt_host $opt_socket $opt_port $host $version); +my $sqlport = ""; my $sqlhost = ""; my $user = ""; @@ -84,9 +85,13 @@ if ($opt_password eq '') print "\n"; } +# Using port argument with 'localhost' will cause an error +if ($sqlhost ne "localhost") { + $sqlport = ":port=$opt_port"; +} # make the connection to MariaDB -$dbh= DBI->connect("DBI:mysql:mysql:host=$sqlhost:port=$opt_port:mysql_socket=$opt_socket",$opt_user,$opt_password, {PrintError => 0}) || +$dbh= DBI->connect("DBI:mysql:mysql:host=$sqlhost$sqlport:mysql_socket=$opt_socket",$opt_user,$opt_password, {PrintError => 0}) || die("Can't make a connection to the mysql server.\n The error: $DBI::errstr"); # the start of the program From c45aeeab38125e59c84c2d7a78e8465e0964e5b5 Mon Sep 17 00:00:00 2001 From: Marek Kulik Date: Wed, 25 Aug 2021 09:18:29 +0200 Subject: [PATCH 02/10] Remove FLUSH PRIVILEGES from mysql_setpermission FLUSH PRIVILEGES hasn't been needed for very many years. --- scripts/mysql_setpermission.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh index 01b3d5e7e90..7c0ef575db7 100644 --- a/scripts/mysql_setpermission.sh +++ b/scripts/mysql_setpermission.sh @@ -283,7 +283,6 @@ sub addall { $sth = $dbh->do("REVOKE ALL ON $db.* FROM \'$user\'\@\'$host\'") || die $dbh->errstr; } } - $dbh->do("FLUSH PRIVILEGES") || print STDERR "Can't flush privileges\n"; print "Everything is inserted and mysql privileges have been reloaded.\n\n"; } From c9851d35adb1675ce204b2c77ac57da9023792ac Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 25 Aug 2021 22:12:15 +0300 Subject: [PATCH 03/10] Fixed failing maria.repair test Backported patch from MariaDB 10.6 The issue was that the using session_mem_used to break a test does not guarantee where the test breaks, which gives different results depending on the environment or how MariaDB is compield. --- mysql-test/suite/maria/repair.result | 7 ------- mysql-test/suite/maria/repair.test | 2 ++ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/mysql-test/suite/maria/repair.result b/mysql-test/suite/maria/repair.result index 296f251aa36..722d9f28712 100644 --- a/mysql-test/suite/maria/repair.result +++ b/mysql-test/suite/maria/repair.result @@ -29,12 +29,5 @@ CREATE TABLE t1 (i INT) ENGINE=Aria; INSERT INTO t1 VALUES (1); SET max_session_mem_used=50000; REPAIR LOCAL TABLE t1 USE_FRM; -Table Op Msg_type Msg_text -t1 repair error Failed to open partially repaired table -Warnings: -Error 1290 The MariaDB server is running with the --max-thread-mem-used=50000 option so it cannot execute this statement REPAIR LOCAL TABLE t1; -Table Op Msg_type Msg_text -test.t1 repair Error The MariaDB server is running with the --max-thread-mem-used=50000 option so it cannot execute this statement -test.t1 repair error Corrupt DROP TABLE t1; diff --git a/mysql-test/suite/maria/repair.test b/mysql-test/suite/maria/repair.test index 13165269b76..571f861c512 100644 --- a/mysql-test/suite/maria/repair.test +++ b/mysql-test/suite/maria/repair.test @@ -36,6 +36,8 @@ DROP TABLE t1; CREATE TABLE t1 (i INT) ENGINE=Aria; INSERT INTO t1 VALUES (1); SET max_session_mem_used=50000; +--disable_result_log REPAIR LOCAL TABLE t1 USE_FRM; REPAIR LOCAL TABLE t1; +--enable_result_log DROP TABLE t1; From b378ddb3d3c3af75195d328018259369671bb029 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 25 Aug 2021 22:16:19 +0300 Subject: [PATCH 04/10] MDEV 22785 Crash with prepared statements and NEXTVAL() The problem was that a PREARE followed by a non prepared statement using DEFAULT NEXT_VALUE() could change table->next_local to point to a not persitent memory aria. The next EXECUTE would then try to use the wrong pointer, which could cause a crash. Fixed by reseting the pointer to it's old value when doing EXECUTE. --- BUILD/SETUP.sh | 2 +- mysql-test/suite/sql_sequence/default.result | 10 ++++++++++ mysql-test/suite/sql_sequence/default.test | 12 ++++++++++++ sql/sql_base.cc | 20 +++++++++++++++----- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index 8a7238c359f..bbf3aba1438 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -211,7 +211,7 @@ fi max_no_embedded_configs="$SSL_LIBRARY --with-plugins=max" max_no_qc_configs="$SSL_LIBRARY --with-plugins=max --without-query-cache" -max_configs="$SSL_LIBRARY --with-plugins=max --with-embedded-server --with-libevent --without-plugin=plugin_file_key_management --with-plugin-rocksdb=dynamic --with-plugin-test_sql_discovery=DYNAMIC" +max_configs="$SSL_LIBRARY --with-plugins=max --with-embedded-server --with-libevent --without-plugin=plugin_file_key_management --with-plugin-rocksdb=dynamic --without-plugin-tokudb --with-plugin-test_sql_discovery=DYNAMIC" all_configs="$SSL_LIBRARY --with-plugins=max --with-embedded-server --with-innodb_plugin --with-libevent" # diff --git a/mysql-test/suite/sql_sequence/default.result b/mysql-test/suite/sql_sequence/default.result index 37d536d9020..2f048c9e4e2 100644 --- a/mysql-test/suite/sql_sequence/default.result +++ b/mysql-test/suite/sql_sequence/default.result @@ -185,3 +185,13 @@ ALTER TABLE t1 add column d int default next value for s_not_exits; ERROR 42S02: Table 'test.s_not_exits' doesn't exist drop table t1; drop sequence s1; +# +# MDEV 22785 Crash with prepared statements and NEXTVAL() +# +CREATE SEQUENCE s; +CREATE TABLE t1 (id int NOT NULL DEFAULT NEXTVAL(s), PRIMARY KEY (id)); +PREPARE stmt FROM " INSERT INTO t1 () values ()"; +INSERT INTO t1 () values (); +EXECUTE stmt; +DROP TABLE t1; +DROP SEQUENCE s; diff --git a/mysql-test/suite/sql_sequence/default.test b/mysql-test/suite/sql_sequence/default.test index 017165c1a80..e7c13211013 100644 --- a/mysql-test/suite/sql_sequence/default.test +++ b/mysql-test/suite/sql_sequence/default.test @@ -123,3 +123,15 @@ ALTER TABLE t1 add column c int; ALTER TABLE t1 add column d int default next value for s_not_exits; drop table t1; drop sequence s1; + +--echo # +--echo # MDEV 22785 Crash with prepared statements and NEXTVAL() +--echo # +CREATE SEQUENCE s; +CREATE TABLE t1 (id int NOT NULL DEFAULT NEXTVAL(s), PRIMARY KEY (id)); +PREPARE stmt FROM " INSERT INTO t1 () values ()"; +INSERT INTO t1 () values (); +EXECUTE stmt; +# Cleanup +DROP TABLE t1; +DROP SEQUENCE s; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 2b06cf27d9b..f5eb0857d54 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4450,13 +4450,13 @@ bool table_already_fk_prelocked(TABLE_LIST *tl, LEX_CSTRING *db, } -static bool internal_table_exists(TABLE_LIST *global_list, - const char *table_name) +static TABLE_LIST *internal_table_exists(TABLE_LIST *global_list, + const char *table_name) { do { if (global_list->table_name.str == table_name) - return 1; + return global_list; } while ((global_list= global_list->next_global)); return 0; } @@ -4471,13 +4471,23 @@ add_internal_tables(THD *thd, Query_tables_list *prelocking_ctx, do { + TABLE_LIST *tmp __attribute__((unused)); DBUG_PRINT("info", ("table name: %s", tables->table_name.str)); /* Skip table if already in the list. Can happen with prepared statements */ - if (tables->next_local && - internal_table_exists(global_table_list, tables->table_name.str)) + if ((tmp= internal_table_exists(global_table_list, + tables->table_name.str))) + { + /* + Use the original value for the next local, used by the + original prepared statement. We cannot trust the original + next_local value as it may have been changed by a previous + statement using the same table. + */ + tables->next_local= tmp; continue; + } TABLE_LIST *tl= (TABLE_LIST *) thd->alloc(sizeof(TABLE_LIST)); if (!tl) From 228630f61ac10240c367176601bd05bdb20ea8e0 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 25 Aug 2021 16:53:39 +1000 Subject: [PATCH 05/10] rocksdb: disable on arm64 except for Linux Thanks to Theodore Brockman on Zulip for noticing on an OSX ARM64 and testing this patch. Per https://github.com/google/cpu_features/pull/150/files CMAKE_SYSTEM_PROCESSOR is arm64 on Apple. Without this, compulation error: [ 80%] Building CXX object storage/rocksdb/CMakeFiles/rocksdblib.dir/rocksdb/util/crc32c.cc.o /mariadb/storage/rocksdb/rocksdb/util/crc32c.cc:500:18: error: use of undeclared identifier 'isSSE42' has_fast_crc = isSSE42(); ^ /mariadb/storage/rocksdb/rocksdb/util/crc32c.cc:1230:7: error: use of undeclared identifier 'isSSE42' if (isSSE42()) { ^ /mariadb/storage/rocksdb/rocksdb/util/crc32c.cc:1231:9: error: use of undeclared identifier 'isPCLMULQDQ' if (isPCLMULQDQ()) { ^ This can be reverted when the RocksDB submodule is updated. https://github.com/facebook/rocksdb/commit/ee4bd4780b321ddb5f92a0f4eb956f2a2ebd60dc --- storage/rocksdb/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index e2b0d9df547..1db314b93db 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -44,6 +44,15 @@ IF (WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4) SKIP_ROCKSDB_PLUGIN("32-Bit Windows are temporarily disabled") ENDIF() +# +# Also, disable on ARM64 when not Linux +# Requires submodule update to v6.16.3 +# containing commit https://github.com/facebook/rocksdb/commit/ee4bd4780b321ddb5f92a0f4eb956f2a2ebd60dc +# +IF(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm64|aarch64)" AND NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") + SKIP_ROCKSDB_PLUGIN("ARM64 disabled on all except Linux") +ENDIF() + # This plugin needs recent C++ compilers (it is using C++11 features) # Skip build for the old compilers SET(CXX11_FLAGS) From fe2a7048e7c7345f0e011ef800346d744402bb2d Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 26 Aug 2021 15:13:48 +0200 Subject: [PATCH 06/10] typo fixed --- extra/mariabackup/xtrabackup.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 6f4ad7d9e17..12cfdb6c284 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -3405,7 +3405,7 @@ static void xb_load_single_table_tablespace(const char *dirname, delete file; if (err != DB_SUCCESS && xtrabackup_backup && !is_empty_file) { - die("Failed to not validate first page of the file %s, error %d",name, (int)err); + die("Failed to validate first page of the file %s, error %d",name, (int)err); } ut_free(name); From 600e4949062e848e035e2649792a8fed963e6a91 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 29 Aug 2021 09:33:00 +0200 Subject: [PATCH 07/10] mtr: fix the check where a combination is pre-selected if all options from a combination from the combinations file are already present in the server's list of options, then don't try to run tests in other combinations from this file. old behavior was: if at least one option from a combination is already present in the list... --- mysql-test/lib/My/Options.pm | 22 +++++++--------------- mysql-test/lib/mtr_cases.pm | 6 ++++-- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/mysql-test/lib/My/Options.pm b/mysql-test/lib/My/Options.pm index 6e0efe862e7..5827e0666a6 100644 --- a/mysql-test/lib/My/Options.pm +++ b/mysql-test/lib/My/Options.pm @@ -140,24 +140,16 @@ sub diff { } -sub is_set { - my ($opts, $set_opts)= @_; +sub is_subset { + my ($set, $subset)= @_; + my %cache = map { _split_option($_) } @$set; - foreach my $opt (@$opts){ - - my ($opt_name1, $value1)= _split_option($opt); - - foreach my $set_opt (@$set_opts){ - my ($opt_name2, $value2)= _split_option($set_opt); - - if ($opt_name1 eq $opt_name2 and $value1 eq $value2){ - # Option already set - return 1; - } - } + for (@$subset){ + my ($name, $value)= _split_option($_); + return 0 unless exists $cache{$name} and $cache{$name} eq $value; } - return 0; + return 1; } diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index 8c94c281edf..27803ff1d85 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -623,8 +623,10 @@ sub make_combinations($$@) { # Skip all other combinations if the values they change # are already fixed in master_opt or slave_opt - if (My::Options::is_set($test->{master_opt}, $comb->{comb_opt}) && - My::Options::is_set($test->{slave_opt}, $comb->{comb_opt}) ){ + # (empty combinations are not considered a subset of anything) + if (@{$comb->{comb_opt}} && + My::Options::is_subset($test->{master_opt}, $comb->{comb_opt}) && + My::Options::is_subset($test->{slave_opt}, $comb->{comb_opt}) ){ $test_combs->{$comb->{name}} = 2; From 969edf02c5ba7cfef1dbf6f8257b79745205dd0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 30 Aug 2021 11:10:43 +0300 Subject: [PATCH 08/10] Update libmariadb --- libmariadb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmariadb b/libmariadb index 0cc16f18c1d..42cb1e442c4 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit 0cc16f18c1d87bbe6e360eaf578fcedeb9479114 +Subproject commit 42cb1e442c43902e2866bea38d15f2ed1f5d38b3 From fda704c82c982c554ca0f0d28cb08ca972c4ddd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 30 Aug 2021 11:52:59 +0300 Subject: [PATCH 09/10] Fix GCC 11 -Wmaybe-uninitialized for PLUGIN_PERFSCHEMA init_mutex_v1_t: Stop lying that the mutex parameter is const. GCC 11.2.0 assumes that it is and could complain about any mysql_mutex_t being uninitialized even after mysql_mutex_init() as long as PLUGIN_PERFSCHEMA is enabled. init_rwlock_v1_t, init_cond_v1_t: Remove untruthful const qualifiers. Note: init_socket_v1_t is expecting that the socket fd has already been created before PSI_SOCKET_CALL(init_socket), and therefore that parameter really is being treated as a pointer to const. --- include/mysql/psi/psi.h | 6 +++--- include/mysql/psi/psi_abi_v1.h.pp | 6 +++--- mysys/psi_noop.c | 6 +++--- storage/perfschema/pfs.cc | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/mysql/psi/psi.h b/include/mysql/psi/psi.h index 3f7b04b0841..4fa9c3842a8 100644 --- a/include/mysql/psi/psi.h +++ b/include/mysql/psi/psi.h @@ -1134,7 +1134,7 @@ typedef void (*register_socket_v1_t) @return an instrumented mutex */ typedef struct PSI_mutex* (*init_mutex_v1_t) - (PSI_mutex_key key, const void *identity); + (PSI_mutex_key key, void *identity); /** Mutex instrumentation destruction API. @@ -1149,7 +1149,7 @@ typedef void (*destroy_mutex_v1_t)(struct PSI_mutex *mutex); @return an instrumented rwlock */ typedef struct PSI_rwlock* (*init_rwlock_v1_t) - (PSI_rwlock_key key, const void *identity); + (PSI_rwlock_key key, void *identity); /** Rwlock instrumentation destruction API. @@ -1164,7 +1164,7 @@ typedef void (*destroy_rwlock_v1_t)(struct PSI_rwlock *rwlock); @return an instrumented cond */ typedef struct PSI_cond* (*init_cond_v1_t) - (PSI_cond_key key, const void *identity); + (PSI_cond_key key, void *identity); /** Cond instrumentation destruction API. diff --git a/include/mysql/psi/psi_abi_v1.h.pp b/include/mysql/psi/psi_abi_v1.h.pp index 17ac0271da2..162c5bcccd1 100644 --- a/include/mysql/psi/psi_abi_v1.h.pp +++ b/include/mysql/psi/psi_abi_v1.h.pp @@ -300,13 +300,13 @@ typedef void (*register_statement_v1_t) typedef void (*register_socket_v1_t) (const char *category, struct PSI_socket_info_v1 *info, int count); typedef struct PSI_mutex* (*init_mutex_v1_t) - (PSI_mutex_key key, const void *identity); + (PSI_mutex_key key, void *identity); typedef void (*destroy_mutex_v1_t)(struct PSI_mutex *mutex); typedef struct PSI_rwlock* (*init_rwlock_v1_t) - (PSI_rwlock_key key, const void *identity); + (PSI_rwlock_key key, void *identity); typedef void (*destroy_rwlock_v1_t)(struct PSI_rwlock *rwlock); typedef struct PSI_cond* (*init_cond_v1_t) - (PSI_cond_key key, const void *identity); + (PSI_cond_key key, void *identity); typedef void (*destroy_cond_v1_t)(struct PSI_cond *cond); typedef struct PSI_socket* (*init_socket_v1_t) (PSI_socket_key key, const my_socket *fd, diff --git a/mysys/psi_noop.c b/mysys/psi_noop.c index 1cf544be0e1..b20aae84849 100644 --- a/mysys/psi_noop.c +++ b/mysys/psi_noop.c @@ -86,7 +86,7 @@ static void register_socket_noop(const char *category NNN, } static PSI_mutex* -init_mutex_noop(PSI_mutex_key key NNN, const void *identity NNN) +init_mutex_noop(PSI_mutex_key key NNN, void *identity NNN) { return NULL; } @@ -97,7 +97,7 @@ static void destroy_mutex_noop(PSI_mutex* mutex NNN) } static PSI_rwlock* -init_rwlock_noop(PSI_rwlock_key key NNN, const void *identity NNN) +init_rwlock_noop(PSI_rwlock_key key NNN, void *identity NNN) { return NULL; } @@ -108,7 +108,7 @@ static void destroy_rwlock_noop(PSI_rwlock* rwlock NNN) } static PSI_cond* -init_cond_noop(PSI_cond_key key NNN, const void *identity NNN) +init_cond_noop(PSI_cond_key key NNN, void *identity NNN) { return NULL; } diff --git a/storage/perfschema/pfs.cc b/storage/perfschema/pfs.cc index dbad7e966a5..2a484bea7f2 100644 --- a/storage/perfschema/pfs.cc +++ b/storage/perfschema/pfs.cc @@ -1496,7 +1496,7 @@ static void register_socket_v1(const char *category, @sa PSI_v1::init_mutex. */ static PSI_mutex* -init_mutex_v1(PSI_mutex_key key, const void *identity) +init_mutex_v1(PSI_mutex_key key, void *identity) { INIT_BODY_V1(mutex, key, identity); } @@ -1519,7 +1519,7 @@ static void destroy_mutex_v1(PSI_mutex* mutex) @sa PSI_v1::init_rwlock. */ static PSI_rwlock* -init_rwlock_v1(PSI_rwlock_key key, const void *identity) +init_rwlock_v1(PSI_rwlock_key key, void *identity) { INIT_BODY_V1(rwlock, key, identity); } @@ -1542,7 +1542,7 @@ static void destroy_rwlock_v1(PSI_rwlock* rwlock) @sa PSI_v1::init_cond. */ static PSI_cond* -init_cond_v1(PSI_cond_key key, const void *identity) +init_cond_v1(PSI_cond_key key, void *identity) { INIT_BODY_V1(cond, key, identity); } From ceb40ef45b735f7e35aa87306b220a8493f4d754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 30 Aug 2021 14:26:27 +0300 Subject: [PATCH 10/10] MDEV-26504 THD::copy_db_to() fails to return true if THD::db is null THD::copy_db_to(): Always return true if the output parameter was left uninitialized. This fixes a regression that was caused by commit 7d0d934ca642e485b2c008727dc20c83e26cce10 (MDEV-16473). MariaDB Server 10.3 and later were unaffected by this bug thanks to commit a7e352b54ddfaf91c92951d605cb02a4ffd2676b. Possibly this bug only affects mysql_list_fields() in the Embedded Server (libmysqld). This bug was found by GCC 11.2.0 in CMAKE_BUILD_TYPE=RelWithDebInfo. --- sql/sql_class.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sql/sql_class.h b/sql/sql_class.h index 50ab3c56ca9..5f871f9caf6 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -4003,10 +4003,8 @@ public: for any CTE references. */ if (!lex->with_cte_resolution) - { my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); - return TRUE; - } + return TRUE; } else {