diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-03-11 17:46:38 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-03-11 17:46:38 +0200 |
commit | d0e2b7ba95a58d6c0d3708bd5fa6e2b4c42f313d (patch) | |
tree | fec100cb44eaad64cd771ad28d3d77096d76093b | |
parent | c882cf051de8b54a830246c6eca1bef74c62e0d1 (diff) | |
parent | 66b5b9214b1c3490cdfa8a1b3d3240e3088178d2 (diff) | |
download | mariadb-git-bb-10.9-MDEV-27844.tar.gz |
Merge 10.9 and revert 1766a18e06a056155031dabefb88ce7f201ad921bb-10.9-MDEV-27844
40 files changed, 303 insertions, 137 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 003278fa31c..bc88dc8cef3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -172,12 +172,12 @@ fedora-clang: centos8: stage: build - image: centos:8 + image: quay.io/centos/centos:stream8 # CentOS 8 is deprecated, use this Stream8 instead variables: GIT_STRATEGY: fetch GIT_SUBMODULE_STRATEGY: normal script: - - yum install -y yum-utils rpm-build openssl-devel + - yum install -y yum-utils rpm-build openssl-devel pcre2-devel - yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm # dnf --enablerepo=powertools install Judy-devel #--> not found - dnf config-manager --set-enabled powertools @@ -186,7 +186,7 @@ centos8: # - package Judy-devel-1.0.5-18.module_el8.3.0+757+d382997d.i686 is filtered out by modular filtering # - package Judy-devel-1.0.5-18.module_el8.3.0+757+d382997d.x86_64 is filtered out by modular filtering # Solution: install Judy-devel directly from downloaded rpm file: - - yum install -y http://mirror.centos.org/centos/8/PowerTools/x86_64/os/Packages/Judy-devel-1.0.5-18.module_el8.3.0+757+d382997d.x86_64.rpm + - yum install -y http://vault.centos.org/centos/8/PowerTools/x86_64/os/Packages/Judy-devel-1.0.5-18.module_el8.3.0+757+d382997d.x86_64.rpm # Use eatmydata to speed up build - yum install -y https://github.com/stewartsmith/libeatmydata/releases/download/v129/libeatmydata-129-1.fc33.x86_64.rpm - yum install -y ccache # From EPEL @@ -226,7 +226,7 @@ centos7: # This repository does not have any .spec files, so install dependencies based on Fedora spec file - yum-builddep -y mariadb-server # ..with a few extra ones, as CentOS 7 is very old and these are added in newer MariaDB releases - - yum install -y yum-utils rpm-build gcc gcc-c++ bison libxml2-devel libevent-devel openssl-devel + - yum install -y yum-utils rpm-build gcc gcc-c++ bison libxml2-devel libevent-devel openssl-devel pcre2-devel - mkdir builddir; cd builddir - cmake -DRPM=$CI_JOB_NAME $CMAKE_FLAGS .. 2>&1 | tee -a ../build-$CI_JOB_NAME-$CI_COMMIT_REF_SLUG.log - make package -j 2 2>&1 | tee -a ../build-$CI_JOB_NAME-$CI_COMMIT_REF_SLUG.log diff --git a/CMakeLists.txt b/CMakeLists.txt index d07c25349af..091fb329686 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright (c) 2006, 2017, Oracle and/or its affiliates. -# Copyright (c) 2008, 2021, MariaDB Corporation. +# Copyright (c) 2008, 2022, 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 @@ -80,9 +80,11 @@ SET(MYSQL_PROJECT_NAME_DOCSTRING "MySQL project name") IF(CMAKE_VERSION VERSION_LESS "3.1") IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") ENDIF() ELSE() + SET(CMAKE_C_STANDARD 99) SET(CMAKE_CXX_STANDARD 11) ENDIF() diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index 9b543dc68ed..58eed048077 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -13,6 +13,14 @@ set -e source ./VERSION +CODENAME="$(lsb_release -sc)" +case "${CODENAME}" in + stretch) + # MDEV-28022 libzstd-dev-1.1.3 minimum version + sed -i -e '/libzstd-dev/d' debian/control + ;; +esac + # This file is invoked from Buildbot and Travis-CI to build deb packages. # As both of those CI systems have many parallel jobs that include different # parts of the test suite, we don't need to run the mysql-test-run at all when @@ -106,7 +114,6 @@ echo "Incrementing changelog and starting build scripts" UPSTREAM="${MYSQL_VERSION_MAJOR}.${MYSQL_VERSION_MINOR}.${MYSQL_VERSION_PATCH}${MYSQL_VERSION_EXTRA}" PATCHLEVEL="+maria" LOGSTRING="MariaDB build" -CODENAME="$(lsb_release -sc)" EPOCH="1:" VERSION="${EPOCH}${UPSTREAM}${PATCHLEVEL}~${CODENAME}" diff --git a/include/my_alloc.h b/include/my_alloc.h index 659cc16ea14..944dcb6e1bd 100644 --- a/include/my_alloc.h +++ b/include/my_alloc.h @@ -20,7 +20,7 @@ #ifndef _my_alloc_h #define _my_alloc_h -typedef unsigned int PSI_memory_key; +#include "mysql/psi/psi_base.h" #define ALLOC_MAX_BLOCK_TO_DROP 4096 #define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10 diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 7ae47ac836e..81b6206ae3e 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -238,7 +238,9 @@ typedef struct st_mysql_field { typedef char **MYSQL_ROW; typedef unsigned int MYSQL_FIELD_OFFSET; typedef unsigned long long my_ulonglong; +extern "C" { typedef unsigned int PSI_memory_key; +} extern "C" { typedef struct st_used_mem { diff --git a/include/mysql/psi/psi_abi_v1.h.pp b/include/mysql/psi/psi_abi_v1.h.pp index a1845ac62f6..ad2bf1d21dc 100644 --- a/include/mysql/psi/psi_abi_v1.h.pp +++ b/include/mysql/psi/psi_abi_v1.h.pp @@ -1,8 +1,8 @@ extern "C" { +typedef unsigned int PSI_memory_key; } extern "C" { struct PSI_thread; -typedef unsigned int PSI_memory_key; struct PSI_memory_info_v1 { PSI_memory_key *m_key; diff --git a/include/mysql/psi/psi_abi_v2.h.pp b/include/mysql/psi/psi_abi_v2.h.pp index a670e53a8b7..9188954885f 100644 --- a/include/mysql/psi/psi_abi_v2.h.pp +++ b/include/mysql/psi/psi_abi_v2.h.pp @@ -1,8 +1,8 @@ extern "C" { +typedef unsigned int PSI_memory_key; } extern "C" { struct PSI_thread; -typedef unsigned int PSI_memory_key; struct PSI_memory_info_v2 { int placeholder; diff --git a/include/mysql/psi/psi_base.h b/include/mysql/psi/psi_base.h index 7b4eaf80892..2bb1d8fc354 100644 --- a/include/mysql/psi/psi_base.h +++ b/include/mysql/psi/psi_base.h @@ -164,6 +164,13 @@ extern "C" { /** @} */ +/** + Instrumented memory key. + To instrument memory, a memory key must be obtained using @c register_memory. + Using a zero key always disable the instrumentation. +*/ +typedef unsigned int PSI_memory_key; + #ifdef __cplusplus } #endif diff --git a/include/mysql/psi/psi_memory.h b/include/mysql/psi/psi_memory.h index 9b968667d53..60d68f1a6dd 100644 --- a/include/mysql/psi/psi_memory.h +++ b/include/mysql/psi/psi_memory.h @@ -53,13 +53,6 @@ extern "C" { struct PSI_thread; -/** - Instrumented memory key. - To instrument memory, a memory key must be obtained using @c register_memory. - Using a zero key always disable the instrumentation. -*/ -typedef unsigned int PSI_memory_key; - #ifdef HAVE_PSI_1 /** diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result index e1670aff9ce..294b0623fc1 100644 --- a/mysql-test/main/create_or_replace.result +++ b/mysql-test/main/create_or_replace.result @@ -353,7 +353,8 @@ drop table test.t1; # create table t1 (i int); lock table t1 write; -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -364,7 +365,8 @@ ERROR 22001: Data too long for column 'a' at row 1 show tables; Tables_in_test t2 -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME create table t1 (i int); drop table t1; diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test index 4b954263a87..7fa08d13847 100644 --- a/mysql-test/main/create_or_replace.test +++ b/mysql-test/main/create_or_replace.test @@ -285,13 +285,15 @@ create table t1 (i int); lock table t1 write; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; --error ER_DATA_TOO_LONG create or replace table t1 (a char(1)) engine=Innodb select 'foo' as a; show tables; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; create table t1 (i int); drop table t1; diff --git a/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result b/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result index 135271d325e..971fae6208f 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result +++ b/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result @@ -104,6 +104,17 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc SHOW WARNINGS; Level Code Message Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly +CREATE TABLE t3 (a INT(11) DEFAULT NULL); +INSERT INTO t3 VALUES (1); +CREATE TABLE t4 (a INT(11) DEFAULT NULL, b BIGINT(20) DEFAULT uuid_short()) SELECT * FROM t3; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave +SHOW WARNINGS; +Level Code Message +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave +CREATE OR REPLACE TABLE t4 (a INT(11) DEFAULT NULL) SELECT * FROM t3; +SHOW WARNINGS; +Level Code Message DROP FUNCTION sf_bug50192; DROP TRIGGER tr_bug50192; -DROP TABLE t1, t2; +DROP TABLE t1, t2, t3, t4; diff --git a/mysql-test/suite/binlog/r/innodb_autoinc_lock_mode_binlog.result b/mysql-test/suite/binlog/r/innodb_autoinc_lock_mode_binlog.result new file mode 100644 index 00000000000..34426795665 --- /dev/null +++ b/mysql-test/suite/binlog/r/innodb_autoinc_lock_mode_binlog.result @@ -0,0 +1,25 @@ +select @@innodb_autoinc_lock_mode; +@@innodb_autoinc_lock_mode +2 +select @@binlog_format; +@@binlog_format +MIXED +create table t1 (a int not null auto_increment,b int, primary key (a)) engine=InnoDB; +insert into t1 values (NULL,1); +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment,b int, primary key (a)) engine=InnoDB +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Annotate_rows # # insert into t1 values (NULL,1) +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Xid # # COMMIT /* XID */ +set global binlog_format=STATEMENT; +connect con1,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK; +insert into t1 values (NULL,1); +insert into t1 values (NULL,1); +disconnect con1; +connection default; +set global binlog_format=MIXED; +DROP TABLE t1; diff --git a/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test index 70566da4cfa..578f0ff5fc8 100644 --- a/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test +++ b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test @@ -189,8 +189,20 @@ SHOW WARNINGS; SELECT sf_bug50192(); SHOW WARNINGS; +# The test proves MDEV-24617 fixes leave in force +# unsafe warnings in non-deterministic CREATE..SELECT cases. +# Below an inserted default value to `b` of the target table is replication +# unsafe. A warning must be out. +CREATE TABLE t3 (a INT(11) DEFAULT NULL); +INSERT INTO t3 VALUES (1); +CREATE TABLE t4 (a INT(11) DEFAULT NULL, b BIGINT(20) DEFAULT uuid_short()) SELECT * FROM t3; +SHOW WARNINGS; +# no warning out of a deterministic "rhs" of SELECT +CREATE OR REPLACE TABLE t4 (a INT(11) DEFAULT NULL) SELECT * FROM t3; +SHOW WARNINGS; + # cleanup DROP FUNCTION sf_bug50192; DROP TRIGGER tr_bug50192; -DROP TABLE t1, t2; +DROP TABLE t1, t2, t3, t4; diff --git a/mysql-test/suite/binlog/t/innodb_autoinc_lock_mode_binlog.opt b/mysql-test/suite/binlog/t/innodb_autoinc_lock_mode_binlog.opt new file mode 100644 index 00000000000..824f656cbd5 --- /dev/null +++ b/mysql-test/suite/binlog/t/innodb_autoinc_lock_mode_binlog.opt @@ -0,0 +1 @@ +--innodb_autoinc_lock_mode=2 diff --git a/mysql-test/suite/binlog/t/innodb_autoinc_lock_mode_binlog.test b/mysql-test/suite/binlog/t/innodb_autoinc_lock_mode_binlog.test new file mode 100644 index 00000000000..65f65eac4e4 --- /dev/null +++ b/mysql-test/suite/binlog/t/innodb_autoinc_lock_mode_binlog.test @@ -0,0 +1,19 @@ +--source include/have_innodb.inc +--source include/have_binlog_format_mixed.inc + +select @@innodb_autoinc_lock_mode; +select @@binlog_format; + +create table t1 (a int not null auto_increment,b int, primary key (a)) engine=InnoDB; +insert into t1 values (NULL,1); +--source include/show_binlog_events.inc + +set global binlog_format=STATEMENT; +--connect (con1,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK) +insert into t1 values (NULL,1); +insert into t1 values (NULL,1); +--disconnect con1 +--connection default + +set global binlog_format=MIXED; +DROP TABLE t1; diff --git a/mysql-test/suite/sql_sequence/binlog.result b/mysql-test/suite/sql_sequence/binlog.result index f01b3234e96..843cf74c2fa 100644 --- a/mysql-test/suite/sql_sequence/binlog.result +++ b/mysql-test/suite/sql_sequence/binlog.result @@ -12,6 +12,21 @@ select next value for s1, minimum_value from s1 where maximum_value> 4; next value for s1 minimum_value 4 1 alter sequence s1 maxvalue 1000; +optimize table s1; +Table Op Msg_type Msg_text +test.s1 optimize note The storage engine for the table doesn't support optimize +analyze table s1; +Table Op Msg_type Msg_text +test.s1 analyze status Engine-independent statistics collected +test.s1 analyze note The storage engine for the table doesn't support analyze +repair table s1; +Table Op Msg_type Msg_text +test.s1 repair status OK +check table s1; +Table Op Msg_type Msg_text +test.s1 check note The storage engine for the table doesn't support check +rename table s1 to tmp_s; +rename table tmp_s to s1; drop sequence s1; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info @@ -30,4 +45,14 @@ master-bin.000001 # Query # # COMMIT master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; alter sequence s1 maxvalue 1000 master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; optimize table s1 +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; analyze table s1 +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; repair table s1 +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; rename table s1 to tmp_s +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; rename table tmp_s to s1 +master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP SEQUENCE `s1` /* generated by server */ diff --git a/mysql-test/suite/sql_sequence/binlog.test b/mysql-test/suite/sql_sequence/binlog.test index 5f2d52d7864..6a12e670a1e 100644 --- a/mysql-test/suite/sql_sequence/binlog.test +++ b/mysql-test/suite/sql_sequence/binlog.test @@ -1,5 +1,5 @@ ---source include/have_udf.inc ---source include/have_log_bin.inc +--source include/have_sequence.inc +--source include/have_binlog_format_mixed_or_row.inc --source include/binlog_start_pos.inc # @@ -21,6 +21,17 @@ select next value for s1, minimum_value from s1 where maximum_value> 4; # alter sequence s1 maxvalue 1000; +# MDEV-24617 OPTIMIZE on a sequence causes unexpected +# ER_BINLOG_UNSAFE_STATEMENT The test below verifies no unsafe +# warnings anymore for any relavant commands that like OPTIMIZE can +# not produce ROW format events therefore the unsafe warning either. +optimize table s1; +analyze table s1; +repair table s1; +check table s1; +rename table s1 to tmp_s; +rename table tmp_s to s1; + drop sequence s1; --let $binlog_file = LAST diff --git a/sql/sql_class.cc b/sql/sql_class.cc index f5212f02137..4830e0faa3a 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2021, MariaDB Corporation. + Copyright (c) 2008, 2022, 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 @@ -6388,7 +6388,8 @@ int THD::decide_logging_format(TABLE_LIST *tables) blackhole_table_found= 1; if (share->non_determinstic_insert && - !(sql_command_flags[lex->sql_command] & CF_SCHEMA_CHANGE)) + (sql_command_flags[lex->sql_command] & CF_CAN_GENERATE_ROW_EVENTS + && !(sql_command_flags[lex->sql_command] & CF_SCHEMA_CHANGE))) has_write_tables_with_unsafe_statements= true; trans= table->file->has_transactions(); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 3bf6d9abf57..31b8836c618 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. - Copyright (c) 2009, 2021, MariaDB Corporation. + Copyright (c) 2009, 2022, 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 diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 79d48528574..3d8a7aac33f 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. - Copyright (c) 2010, 2021, MariaDB Corporation + Copyright (c) 2010, 2022, 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 diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 6da6a0e0b9e..06540fa74e5 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -380,6 +380,19 @@ IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" COMPILE_FLAGS "-O0" ) ENDIF() + +# Older gcc version insist on -mhtm flag for including the +# htmxlintrin.h header. This is also true for new gcc versions +# like 11.2.0 in Debian Sid +# s390x because of the way it defines the high level intrinsics +# as not-inline in the header file can only be included by one +# source file that has -mhtm enabled. +IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64|powerpc64|s390x") + ADD_COMPILE_FLAGS( + sync/srw_lock.cc + COMPILE_FLAGS "-mhtm" + ) +ENDIF() IF(MSVC) IF(CMAKE_SIZEOF_VOID_P EQUAL 8) ADD_COMPILE_FLAGS( diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index d6281073942..688be3722bf 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -2663,7 +2663,8 @@ ignore_block: after buf_zip_decompress() in this function. */ block->page.lock.s_lock(); state = block->page.state(); - ut_ad(state < buf_page_t::READ_FIX); + ut_ad(state < buf_page_t::READ_FIX + || state >= buf_page_t::WRITE_FIX); const page_id_t id{block->page.id()}; block->page.lock.s_unlock(); diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 04822c3cc00..090757ef7ce 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -1718,11 +1718,13 @@ inline void log_t::write_checkpoint(lsn_t end_lsn) noexcept mach_write_to_8(my_assume_aligned<8>(c + 8), end_lsn); mach_write_to_4(my_assume_aligned<4>(c + 60), my_crc32c(0, c, 60)); - lsn_t resizing= resize_lsn.load(std::memory_order_relaxed); + lsn_t resizing; #ifdef HAVE_PMEM if (is_pmem()) { + resizing= resize_lsn.load(std::memory_order_relaxed); + if (resizing > 1 && resizing <= next_checkpoint_lsn) { memcpy_aligned<64>(resize_buf + CHECKPOINT_1, c, 64); @@ -1737,6 +1739,7 @@ inline void log_t::write_checkpoint(lsn_t end_lsn) noexcept n_pending_checkpoint_writes++; latch.wr_unlock(); log_write_and_flush_prepare(); + resizing= resize_lsn.load(std::memory_order_relaxed); /* FIXME: issue an asynchronous write */ log.write(offset, {c, get_block_size()}); if (resizing > 1 && resizing <= next_checkpoint_lsn) @@ -1747,16 +1750,11 @@ inline void log_t::write_checkpoint(lsn_t end_lsn) noexcept resize_log.write(0, {buf, 4096}); aligned_free(buf); resize_log.write(CHECKPOINT_1, {c, get_block_size()}); - latch.wr_lock(SRW_LOCK_CALL); - /* FIXME: write and flush outside exclusive latch */ - ut_a(flush(write_buf<false>())); - } - else - { - if (srv_file_flush_method != SRV_O_DSYNC) - ut_a(log.flush()); - latch.wr_lock(SRW_LOCK_CALL); } + + if (srv_file_flush_method != SRV_O_DSYNC) + ut_a(log.flush()); + latch.wr_lock(SRW_LOCK_CALL); n_pending_checkpoint_writes--; resizing= resize_lsn.load(std::memory_order_relaxed); } diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 7ce737249f7..306600d9c2c 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -8730,13 +8730,14 @@ inline bool rollback_inplace_alter_table(Alter_inplace_info *ha_alter_info, const bool fts_exist= (ctx->new_table->flags2 & (DICT_TF2_FTS_HAS_DOC_ID | DICT_TF2_FTS)) || ctx->adding_fulltext_index(); - if (fts_exist) - { - fts_optimize_remove_table(ctx->new_table); - purge_sys.stop_FTS(*ctx->new_table); - } if (ctx->need_rebuild()) { + if (fts_exist) + { + fts_optimize_remove_table(ctx->new_table); + purge_sys.stop_FTS(*ctx->new_table); + } + dberr_t err= lock_table_for_trx(ctx->new_table, ctx->trx, LOCK_X); if (fts_exist) { @@ -8783,12 +8784,25 @@ inline bool rollback_inplace_alter_table(Alter_inplace_info *ha_alter_info, if (fts_exist) { + const dict_index_t *fts_index= nullptr; for (ulint a= 0; a < ctx->num_to_add_index; a++) { const dict_index_t *index = ctx->add_index[a]; if (index->type & DICT_FTS) - ut_a(!fts_lock_index_tables(ctx->trx, *index)); + fts_index= index; } + + /* Remove the fts table from fts_optimize_wq if there are + no FTS secondary index exist other than newly added one */ + if (fts_index && + (ib_vector_is_empty(prebuilt->table->fts->indexes) || + (ib_vector_size(prebuilt->table->fts->indexes) == 1 && + fts_index == static_cast<dict_index_t*>( + ib_vector_getp(prebuilt->table->fts->indexes, 0))))) + fts_optimize_remove_table(prebuilt->table); + + purge_sys.stop_FTS(*prebuilt->table); + ut_a(!fts_index || !fts_lock_index_tables(ctx->trx, *fts_index)); ut_a(!fts_lock_common_tables(ctx->trx, *ctx->new_table)); ut_a(!lock_sys_tables(ctx->trx)); } diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index 57ecc8ed3f5..7e20fc12cda 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -486,7 +486,7 @@ public: /** Write buf to ib_logfile0. @tparam release_latch whether to invoke latch.wr_unlock() @return the current log sequence number */ - template<bool release_latch> lsn_t write_buf() noexcept; + template<bool release_latch> inline lsn_t write_buf() noexcept; /** Create the log. */ void create(lsn_t lsn) noexcept; diff --git a/storage/innobase/include/transactional_lock_guard.h b/storage/innobase/include/transactional_lock_guard.h index 3167055630c..168a68977a7 100644 --- a/storage/innobase/include/transactional_lock_guard.h +++ b/storage/innobase/include/transactional_lock_guard.h @@ -18,8 +18,8 @@ this program; if not, write to the Free Software Foundation, Inc., #pragma once -#if defined __powerpc64__ && defined __clang__ && defined __linux__ -#elif defined __powerpc64__&&defined __GNUC__&&defined __linux__&&__GNUC__ > 4 +#if defined __powerpc64__ +#elif defined __s390__ #elif defined _MSC_VER && (defined _M_IX86 || defined _M_X64) && !defined(__clang__) #elif defined __GNUC__ && (defined __i386__ || defined __x86_64__) # if __GNUC__ >= 8 @@ -45,8 +45,8 @@ bool transactional_lock_enabled(); # include <immintrin.h> # if defined __GNUC__ && !defined __INTEL_COMPILER -# define TRANSACTIONAL_TARGET __attribute__((target("rtm"))) -# define TRANSACTIONAL_INLINE __attribute__((target("rtm"),always_inline)) +# define TRANSACTIONAL_TARGET __attribute__((target("rtm"),hot)) +# define TRANSACTIONAL_INLINE __attribute__((target("rtm"),hot,always_inline)) # else # define TRANSACTIONAL_TARGET /* nothing */ # define TRANSACTIONAL_INLINE /* nothing */ @@ -69,26 +69,33 @@ static inline bool xtest() { return have_transactional_memory && _xtest(); } TRANSACTIONAL_INLINE static inline void xabort() { _xabort(0); } TRANSACTIONAL_INLINE static inline void xend() { _xend(); } -# elif defined __powerpc64__ -# include <htmxlintrin.h> +# elif defined __powerpc64__ || defined __s390__ extern bool have_transactional_memory; bool transactional_lock_enabled(); -# define TRANSACTIONAL_TARGET __attribute__((target("htm"))) -# define TRANSACTIONAL_INLINE __attribute__((target("htm"),always_inline)) - -TRANSACTIONAL_INLINE static inline bool xbegin() -{ - return have_transactional_memory && - __TM_simple_begin() == _HTM_TBEGIN_STARTED; -} - +# define TRANSACTIONAL_TARGET __attribute__((hot)) +# define TRANSACTIONAL_INLINE __attribute__((hot,always_inline)) + +/** + Newer gcc compilers only provide __builtin_{htm} + functions when the -mhtm CFLAG is actually provided. So + we've got the option of including it globally, or + pushing down the inclusion of htmxlintrin.h to one + file with -mhtm enabled and removing the inline + optimization. + + Per FIXME in s390x's htmxlintrin.h, the __TM_simple_begin + isn't always_inline resulting in duplicate definitions if + it where included more than once. While xabort and xend + could be implemented here, we keep the implementation the + same as ppc64. + */ +TRANSACTIONAL_TARGET bool xbegin(); +TRANSACTIONAL_TARGET void xabort(); +TRANSACTIONAL_TARGET void xend(); # ifdef UNIV_DEBUG bool xtest(); # endif -TRANSACTIONAL_INLINE static inline void xabort() { __TM_abort(); } - -TRANSACTIONAL_INLINE static inline void xend() { __TM_end(); } # endif #endif diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index dad5d695964..83b78ebf385 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -733,7 +733,7 @@ ATTRIBUTE_COLD void log_t::resize_write_buf(size_t length) noexcept /** Write buf to ib_logfile0. @tparam release_latch whether to invoke latch.wr_unlock() @return the current log sequence number */ -template<bool release_latch> lsn_t log_t::write_buf() noexcept +template<bool release_latch> inline lsn_t log_t::write_buf() noexcept { #ifndef SUX_LOCK_GENERIC ut_ad(latch.is_write_locked()); @@ -777,16 +777,17 @@ template<bool release_latch> lsn_t log_t::write_buf() noexcept (We want to avoid memset() while holding mutex.) This block will be overwritten later, once records beyond the current LSN are generated. */ +# ifdef HAVE_valgrind MEM_MAKE_DEFINED(buf + length, get_block_size() - new_buf_free); + if (UNIV_LIKELY_NULL(resize_flush_buf)) + MEM_MAKE_DEFINED(resize_buf + length, get_block_size() - new_buf_free); +# endif buf[length]= 0; /* allow recovery to catch EOF faster */ length&= ~block_size_1; memcpy_aligned<16>(flush_buf, buf + length, (new_buf_free + 15) & ~15); if (UNIV_LIKELY_NULL(resize_flush_buf)) - { - MEM_MAKE_DEFINED(resize_buf + length, get_block_size() - new_buf_free); memcpy_aligned<16>(resize_flush_buf, resize_buf + length, (new_buf_free + 15) & ~15); - } length+= get_block_size(); #endif } @@ -813,8 +814,6 @@ template<bool release_latch> lsn_t log_t::write_buf() noexcept return lsn; } -template lsn_t log_t::write_buf<false>() noexcept; - bool log_t::flush(lsn_t lsn) noexcept { ut_ad(lsn >= get_flushed_lsn()); diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 2b5f082c830..f1145282e52 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -2476,7 +2476,8 @@ rollback: fts_optimize_add_table(table); } trx->rollback(); - row_mysql_unlock_data_dictionary(trx); + if (trx->dict_operation_lock_mode) + row_mysql_unlock_data_dictionary(trx); return err; } } diff --git a/storage/innobase/sync/srw_lock.cc b/storage/innobase/sync/srw_lock.cc index f406b04712a..339b431522c 100644 --- a/storage/innobase/sync/srw_lock.cc +++ b/storage/innobase/sync/srw_lock.cc @@ -54,32 +54,68 @@ bool transactional_lock_enabled() TRANSACTIONAL_TARGET bool xtest() { return have_transactional_memory && _xtest(); } # endif -#elif defined __powerpc64__ -# ifdef __linux__ -# include <sys/auxv.h> +#elif defined __powerpc64__ || defined __s390__ +# include <htmxlintrin.h> +# include <setjmp.h> +# include <signal.h> -# ifndef PPC_FEATURE2_HTM_NOSC -# define PPC_FEATURE2_HTM_NOSC 0x01000000 -# endif -# ifndef PPC_FEATURE2_HTM_NO_SUSPEND -# define PPC_FEATURE2_HTM_NO_SUSPEND 0x00080000 -# endif +__attribute__((target("htm"),hot)) +bool xbegin() +{ + return have_transactional_memory && + __TM_simple_begin() == _HTM_TBEGIN_STARTED; +} + +__attribute__((target("htm"),hot)) +void xabort() { __TM_abort(); } + +__attribute__((target("htm"),hot)) +void xend() { __TM_end(); } -# ifndef AT_HWCAP2 -# define AT_HWCAP2 26 -# endif -# endif bool have_transactional_memory; +static sigjmp_buf ill_jmp; +static void ill_handler(int sig) +{ + siglongjmp(ill_jmp, sig); +} +/** + Here we are testing we can do a transaction without SIGILL + and a 1 instruction store can succeed. +*/ +__attribute__((noinline)) +static void test_tm(bool *r) +{ + if (__TM_simple_begin() == _HTM_TBEGIN_STARTED) + { + *r= true; + __TM_end(); + } +} bool transactional_lock_enabled() { -# ifdef __linux__ - return getauxval(AT_HWCAP2) & - (PPC_FEATURE2_HTM_NOSC | PPC_FEATURE2_HTM_NO_SUSPEND); -# endif + bool r= false; + sigset_t oset; + struct sigaction ill_act, oact_ill; + + memset(&ill_act, 0, sizeof(ill_act)); + ill_act.sa_handler = ill_handler; + sigfillset(&ill_act.sa_mask); + sigdelset(&ill_act.sa_mask, SIGILL); + + sigprocmask(SIG_SETMASK, &ill_act.sa_mask, &oset); + sigaction(SIGILL, &ill_act, &oact_ill); + if (sigsetjmp(ill_jmp, 1) == 0) + { + test_tm(&r); + } + sigaction(SIGILL, &oact_ill, NULL); + sigprocmask(SIG_SETMASK, &oset, NULL); + return r; } # ifdef UNIV_DEBUG -TRANSACTIONAL_TARGET bool xtest() +__attribute__((target("htm"),hot)) +bool xtest() { return have_transactional_memory && _HTM_STATE (__builtin_ttest ()) == _HTM_TRANSACTIONAL; diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc index 6bd21b0f5b9..bfad53e691b 100644 --- a/storage/innobase/trx/trx0rec.cc +++ b/storage/innobase/trx/trx0rec.cc @@ -1951,7 +1951,7 @@ dberr_t trx_undo_report_rename(trx_t* trx, const dict_table_t* table) return err; } -TRANSACTIONAL_TARGET ATTRIBUTE_COLD ATTRIBUTE_NOINLINE +TRANSACTIONAL_TARGET ATTRIBUTE_NOINLINE /** @return whether the transaction holds an exclusive lock on a table */ static bool trx_has_lock_x(const trx_t &trx, dict_table_t& table) { diff --git a/storage/innobase/unittest/CMakeLists.txt b/storage/innobase/unittest/CMakeLists.txt index 1ab6157b4a9..7dd7c111baa 100644 --- a/storage/innobase/unittest/CMakeLists.txt +++ b/storage/innobase/unittest/CMakeLists.txt @@ -21,6 +21,13 @@ ADD_EXECUTABLE(innodb_fts-t innodb_fts-t.cc) TARGET_LINK_LIBRARIES(innodb_fts-t mysys mytap) ADD_DEPENDENCIES(innodb_fts-t GenError) MY_ADD_TEST(innodb_fts) +# See explanation in innobase/CmakeLists.txt +IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64|powerpc64|s390x") + ADD_COMPILE_FLAGS( + ../sync/srw_lock.cc + COMPILE_FLAGS "-mhtm" + ) +ENDIF() ADD_EXECUTABLE(innodb_sync-t innodb_sync-t.cc ../sync/srw_lock.cc) TARGET_LINK_LIBRARIES(innodb_sync-t mysys mytap) ADD_DEPENDENCIES(innodb_sync-t GenError) diff --git a/storage/maria/ma_check.h b/storage/maria/ma_check.h index 1c2a971098d..fa78ada6d38 100644 --- a/storage/maria/ma_check.h +++ b/storage/maria/ma_check.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 MariaDB Corporation AB +/* Copyright (C) 2019, 2022, MariaDB Corporation AB 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 @@ -20,17 +20,17 @@ in myisamchk.h */ -typedef struct st_sort_key_blocks /* Used when sorting */ +struct st_sort_key_blocks /* Used when sorting */ { uchar *buff, *end_pos; uchar lastkey[MARIA_MAX_POSSIBLE_KEY_BUFF]; uint last_length; int inited; -} MA_SORT_KEY_BLOCKS; +}; -typedef struct st_sort_ftbuf +struct st_sort_ftbuf { uchar *buf, *end; int count; uchar lastkey[MARIA_MAX_KEY_BUFF]; -} MA_SORT_FT_BUF; +}; diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index d6bdffa0f7e..4479b244ddf 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -150,21 +150,21 @@ struct st_maria_share; struct st_maria_handler; /* For referense */ struct st_maria_keydef; -typedef struct st_maria_key /* Internal info about a key */ +struct st_maria_key /* Internal info about a key */ { uchar *data; /* Data for key */ struct st_maria_keydef *keyinfo; /* Definition for key */ uint data_length; /* Length of key data */ uint ref_length; /* record ref + transid */ uint32 flag; /* 0 or SEARCH_PART_KEY */ -} MARIA_KEY; +}; -typedef struct st_maria_decode_tree /* Decode huff-table */ +struct st_maria_decode_tree /* Decode huff-table */ { uint16 *table; uint quick_table_bits; uchar *intervalls; -} MARIA_DECODE_TREE; +}; typedef struct s3_info S3_INFO; diff --git a/storage/maria/s3_func.h b/storage/maria/s3_func.h index bd5275494bc..a062131d5a5 100644 --- a/storage/maria/s3_func.h +++ b/storage/maria/s3_func.h @@ -1,6 +1,6 @@ #ifndef S3_FUNC_INCLUDED #define S3_FUNC_INCLUDED -/* Copyright (C) 2019, 2020 MariaDB Corporation Ab +/* Copyright (C) 2019, 2022, MariaDB Corporation Ab 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 @@ -41,7 +41,7 @@ extern TYPELIB s3_protocol_typelib; /* Store information about a s3 connection */ -typedef struct s3_info +struct s3_info { /* Connection strings */ LEX_CSTRING access_key, secret_key, region, bucket, host_name; @@ -63,7 +63,7 @@ typedef struct s3_info /* Protocol for the list bucket API call. 1 for Amazon, 2 for some others */ uint8_t protocol_version; -} S3_INFO; +}; /* flag + length is stored in this header */ diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index f48d1078000..c90d989c975 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2012, Oracle and/or its affiliates. - Copyright (c) 2017, MariaDB Corporation. + Copyright (c) 2017, 2022, 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 @@ -613,21 +613,21 @@ typedef struct st_mi_block_info /* Parameter to _mi_get_block_info */ } MI_BLOCK_INFO; -typedef struct st_sort_key_blocks /* Used when sorting */ +struct st_sort_key_blocks /* Used when sorting */ { uchar *buff, *end_pos; uchar lastkey[HA_MAX_POSSIBLE_KEY_BUFF]; uint last_length; int inited; -} SORT_KEY_BLOCKS; +}; -typedef struct st_sort_ftbuf +struct st_sort_ftbuf { uchar *buf, *end; int count; uchar lastkey[HA_MAX_KEY_BUFF]; -} SORT_FT_BUF; +}; /* bits in return from _mi_get_block_info */ diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index f6ae515954a..5b1d58319e9 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -10908,11 +10908,7 @@ void ha_spider::check_pre_call( ) || ( (skip_parallel_search & 2) && -#ifdef SPIDER_SQL_CACHE_IS_IN_LEX lex->sql_cache == LEX::SQL_NO_CACHE // for mysqldump -#else - select_lex && select_lex->sql_cache == SELECT_LEX::SQL_NO_CACHE // for mysqldump -#endif ) ) { use_pre_call = FALSE; diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 210bbd11665..4cb1788d66b 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -7929,7 +7929,6 @@ int spider_db_print_item_type( case Item::ROW_ITEM: DBUG_RETURN(spider_db_open_item_row((Item_row *) item, spider, str, alias, alias_length, dbton_id, use_fields, fields)); -#ifdef SPIDER_USE_CONST_ITEM_FOR_STRING_INT_REAL_DECIMAL_DATE_ITEM case Item::CONST_ITEM: { switch (item->cmp_type()) { @@ -7947,16 +7946,6 @@ int spider_db_print_item_type( DBUG_RETURN(spider_db_print_item_type_default(item, spider, str)); } } -#else - case Item::STRING_ITEM: - DBUG_RETURN(spider_db_open_item_string(item, field, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - case Item::INT_ITEM: - case Item::REAL_ITEM: - case Item::DECIMAL_ITEM: - DBUG_RETURN(spider_db_open_item_int(item, field, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); -#endif case Item::CACHE_ITEM: DBUG_RETURN(spider_db_open_item_cache((Item_cache *) item, field, spider, str, alias, alias_length, dbton_id, use_fields, fields)); diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index e604daef6c3..efa524cfd46 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -9940,29 +9940,16 @@ int spider_mbase_handler::append_select( wide_handler->lock_mode < 1) { /* no lock */ -#ifdef SPIDER_SQL_CACHE_IS_IN_LEX LEX *lex = wide_handler->trx->thd->lex; -#else - st_select_lex *select_lex = - &wide_handler->trx->thd->lex->select_lex; -#endif if ( -#ifdef SPIDER_SQL_CACHE_IS_IN_LEX lex->sql_cache == LEX::SQL_CACHE && -#else - select_lex->sql_cache == SELECT_LEX::SQL_CACHE && -#endif (spider->share->query_cache_sync & 1) ) { if (str->reserve(SPIDER_SQL_SQL_CACHE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_SQL_CACHE_STR, SPIDER_SQL_SQL_CACHE_LEN); } else if ( -#ifdef SPIDER_SQL_CACHE_IS_IN_LEX lex->sql_cache == LEX::SQL_NO_CACHE && -#else - select_lex->sql_cache == SELECT_LEX::SQL_NO_CACHE && -#endif (spider->share->query_cache_sync & 2) ) { if (str->reserve(SPIDER_SQL_SQL_NO_CACHE_LEN)) diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 956f6ca4d6e..72b49c6f832 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -28,8 +28,6 @@ #define HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT #define SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA #define SPIDER_MDEV_16246 -#define SPIDER_USE_CONST_ITEM_FOR_STRING_INT_REAL_DECIMAL_DATE_ITEM -#define SPIDER_SQL_CACHE_IS_IN_LEX #define SPIDER_LIKE_FUNC_HAS_GET_NEGATED #define SPIDER_I_S_USE_SHOW_FOR_COLUMN #endif /* SPD_ENVIRON_INCLUDED */ |