summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-01-06 17:43:02 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-01-06 17:43:02 +0200
commit734510a44d690dfb94264e1d2775ee1cb6f3ebb9 (patch)
tree0ccc317bf9462ca95cd1277b4ce65a7fda5fe315
parent2465d3e00b2f18c7d4967f9bb10438883682787d (diff)
parentfaf206a848684bc0f87c93a2b47a55063bbccc6c (diff)
downloadmariadb-git-734510a44d690dfb94264e1d2775ee1cb6f3ebb9.tar.gz
Merge 10.3 into 10.4
-rw-r--r--.gitignore2
-rw-r--r--CMakeLists.txt1
-rw-r--r--Docs/README-wsrep50
-rw-r--r--cmake/cpack_rpm.cmake2
-rw-r--r--cmake/mariadb_connector_c.cmake5
-rw-r--r--cmake/zlib.cmake5
-rwxr-xr-xdebian/autobake-deb.sh2
-rw-r--r--debian/control2
-rw-r--r--debian/mariadb-server-10.4.install2
-rw-r--r--extra/mariabackup/fil_cur.cc183
-rw-r--r--extra/mariabackup/xtrabackup.cc61
-rw-r--r--extra/mariabackup/xtrabackup.h2
m---------libmariadb0
-rw-r--r--man/wsrep_sst_xtrabackup-v2.12
-rw-r--r--man/wsrep_sst_xtrabackup.12
-rw-r--r--mysql-test/main/alter_table_errors.result19
-rw-r--r--mysql-test/main/alter_table_errors.test11
-rw-r--r--mysql-test/main/check.result10
-rw-r--r--mysql-test/main/check.test12
-rw-r--r--mysql-test/main/func_group_innodb.result24
-rw-r--r--mysql-test/main/func_group_innodb.test19
-rw-r--r--mysql-test/main/func_hybrid_type.result18
-rw-r--r--mysql-test/main/func_hybrid_type.test16
-rw-r--r--mysql-test/main/func_math.result33
-rw-r--r--mysql-test/main/func_math.test25
-rw-r--r--mysql-test/main/grant5.result7
-rw-r--r--mysql-test/main/grant5.test11
-rw-r--r--mysql-test/main/innodb_ext_key.result1
-rw-r--r--mysql-test/main/innodb_ext_key.test1
-rw-r--r--mysql-test/main/mysqldump.result6
-rw-r--r--mysql-test/main/mysqldump.test2
-rw-r--r--mysql-test/main/partition_alter.test2
-rw-r--r--mysql-test/main/partition_innodb.result23
-rw-r--r--mysql-test/main/partition_innodb.test25
-rw-r--r--mysql-test/main/ps_error.result73
-rw-r--r--mysql-test/main/ps_error.test66
-rw-r--r--mysql-test/main/range_innodb.result18
-rw-r--r--mysql-test/main/range_innodb.test17
-rw-r--r--mysql-test/main/read_only.result16
-rw-r--r--mysql-test/main/read_only.test23
-rw-r--r--mysql-test/main/sp.result35
-rw-r--r--mysql-test/main/sp.test34
-rw-r--r--mysql-test/main/udf.result14
-rw-r--r--mysql-test/main/udf.test13
-rw-r--r--mysql-test/main/win.result23
-rw-r--r--mysql-test/main/win.test19
-rw-r--r--mysql-test/std_data/mdev17909#P#p20181029.MYD0
-rw-r--r--mysql-test/std_data/mdev17909#P#p20181029.MYIbin0 -> 1024 bytes
-rw-r--r--mysql-test/std_data/mdev17909#P#p20181128.MYD0
-rw-r--r--mysql-test/std_data/mdev17909#P#p20181128.MYIbin0 -> 1024 bytes
-rw-r--r--mysql-test/std_data/mdev17909.frmbin0 -> 3284 bytes
-rw-r--r--mysql-test/std_data/mdev17909.parbin0 -> 48 bytes
-rw-r--r--mysql-test/suite/encryption/r/innodb-bad-key-change.result1
-rw-r--r--mysql-test/suite/encryption/r/innodb-encryption-disable.result1
-rw-r--r--mysql-test/suite/encryption/r/innodb-missing-key.result1
-rw-r--r--mysql-test/suite/encryption/t/innodb-bad-key-change.test1
-rw-r--r--mysql-test/suite/encryption/t/innodb-encryption-disable.test1
-rw-r--r--mysql-test/suite/encryption/t/innodb-missing-key.test1
-rw-r--r--mysql-test/suite/galera/r/galera_autoinc_sst_mariabackup.result2
-rw-r--r--mysql-test/suite/galera/r/galera_ist_innodb_flush_logs.result204
-rw-r--r--mysql-test/suite/galera/t/galera_autoinc_sst_mariabackup.cnf1
-rw-r--r--mysql-test/suite/galera/t/galera_autoinc_sst_mariabackup.test8
-rw-r--r--mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.cnf13
-rw-r--r--mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.test13
-rw-r--r--mysql-test/suite/galera/t/galera_ist_mariabackup_innodb_flush_logs.test1
-rw-r--r--mysql-test/suite/innodb/disabled.def1
-rw-r--r--mysql-test/suite/innodb/include/crc32.pl33
-rw-r--r--mysql-test/suite/innodb/r/data_types.result12
-rw-r--r--mysql-test/suite/innodb/r/innodb-alter-debug.result23
-rw-r--r--mysql-test/suite/innodb/r/innodb-alter.result21
-rw-r--r--mysql-test/suite/innodb/t/data_types.test11
-rw-r--r--mysql-test/suite/innodb/t/innodb-alter-debug.test32
-rw-r--r--mysql-test/suite/innodb/t/innodb-alter.test13
-rw-r--r--mysql-test/suite/mariabackup/encrypted_page_compressed.opt6
-rw-r--r--mysql-test/suite/mariabackup/encrypted_page_compressed.result7
-rw-r--r--mysql-test/suite/mariabackup/encrypted_page_compressed.test48
-rw-r--r--mysql-test/suite/mariabackup/encrypted_page_corruption.result4
-rw-r--r--mysql-test/suite/mariabackup/encrypted_page_corruption.test43
-rw-r--r--mysql-test/suite/mariabackup/huge_lsn.opt4
-rw-r--r--mysql-test/suite/mariabackup/partition_partial.opt1
-rw-r--r--mysql-test/suite/mariabackup/partition_partial.result31
-rw-r--r--mysql-test/suite/mariabackup/partition_partial.test44
-rw-r--r--mysql-test/suite/mariabackup/unencrypted_page_compressed.result11
-rw-r--r--mysql-test/suite/mariabackup/unencrypted_page_compressed.test50
-rw-r--r--mysql-test/suite/rpl/r/rpl_idempotency.result17
-rw-r--r--mysql-test/suite/rpl/t/rpl_idempotency.test21
-rw-r--r--mysql-test/suite/storage_engine/type_bool.result4
-rw-r--r--mysql-test/suite/sys_vars/r/wsrep_sst_method_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/t/wsrep_sst_method_basic.test5
-rw-r--r--mysql-test/suite/vcol/r/upgrade.result16
-rw-r--r--mysql-test/suite/vcol/t/upgrade.test15
-rw-r--r--scripts/CMakeLists.txt2
-rw-r--r--scripts/wsrep_sst_xtrabackup-v2.sh1260
-rw-r--r--scripts/wsrep_sst_xtrabackup.sh692
-rw-r--r--sql/ha_sequence.cc2
-rw-r--r--sql/handler.h12
-rw-r--r--sql/item.cc4
-rw-r--r--sql/item_func.cc12
-rw-r--r--sql/partition_info.cc4
-rw-r--r--sql/sql_acl.cc6
-rw-r--r--sql/sql_const.h12
-rw-r--r--sql/sql_db.cc9
-rw-r--r--sql/sql_db.h3
-rw-r--r--sql/sql_parse.cc4
-rw-r--r--sql/sql_select.cc4
-rw-r--r--sql/sql_signal.cc10
-rw-r--r--sql/sql_table.cc16
-rw-r--r--sql/table.cc10
-rw-r--r--sql/temporary_tables.cc50
-rw-r--r--sql/wsrep_sst.cc21
-rw-r--r--sql/wsrep_sst.h3
-rw-r--r--storage/connect/global.h6
-rw-r--r--storage/connect/ha_connect.cc4
-rw-r--r--storage/connect/jsonudf.cpp12
-rw-r--r--storage/connect/mysql-test/connect/r/jdbc_oracle.result18
-rw-r--r--storage/connect/plugutil.cpp28
-rw-r--r--storage/connect/reldef.cpp11
-rw-r--r--storage/connect/tabfmt.h2
-rw-r--r--storage/connect/tabjson.cpp10
-rw-r--r--storage/connect/tabjson.h6
-rw-r--r--storage/connect/tabodbc.cpp317
-rw-r--r--storage/connect/tabxml.cpp13
-rw-r--r--storage/connect/tabxml.h5
-rw-r--r--storage/connect/user_connect.cc4
-rw-r--r--storage/innobase/btr/btr0cur.cc15
-rw-r--r--storage/innobase/buf/buf0buf.cc4
-rw-r--r--storage/innobase/dict/dict0mem.cc29
-rw-r--r--storage/innobase/fil/fil0pagecompress.cc8
-rw-r--r--storage/innobase/gis/gis0sea.cc2
-rw-r--r--storage/innobase/handler/ha_innodb.cc191
-rw-r--r--storage/innobase/handler/handler0alter.cc21
-rw-r--r--storage/innobase/include/dict0mem.h4
-rw-r--r--storage/innobase/os/os0event.cc21
-rw-r--r--storage/innobase/row/row0mysql.cc17
-rw-r--r--storage/innobase/srv/srv0srv.cc2
-rw-r--r--storage/innobase/ut/ut0dbg.cc2
-rw-r--r--storage/rocksdb/CMakeLists.txt4
-rw-r--r--storage/rocksdb/ha_rocksdb.cc1
-rwxr-xr-xstorage/rocksdb/myrocks_hotbackup.py (renamed from storage/rocksdb/myrocks_hotbackup)2
-rw-r--r--storage/tokudb/CMakeLists.txt47
-rw-r--r--storage/tokudb/mysql-test/tokudb/disabled.def4
-rw-r--r--[-rwxr-xr-x]storage/tokudb/mysql-test/tokudb/t/change_column_bin.py0
-rw-r--r--[-rwxr-xr-x]storage/tokudb/mysql-test/tokudb/t/change_column_bin_rename.py0
-rw-r--r--[-rwxr-xr-x]storage/tokudb/mysql-test/tokudb/t/change_column_char.py0
-rw-r--r--[-rwxr-xr-x]storage/tokudb/mysql-test/tokudb/t/change_column_char_binary.py0
-rw-r--r--[-rwxr-xr-x]storage/tokudb/mysql-test/tokudb/t/change_column_char_charbinary.py0
-rw-r--r--[-rwxr-xr-x]storage/tokudb/mysql-test/tokudb/t/change_column_char_rename.py0
-rw-r--r--[-rwxr-xr-x]storage/tokudb/mysql-test/tokudb/t/change_column_int.py0
-rw-r--r--[-rwxr-xr-x]storage/tokudb/mysql-test/tokudb/t/change_column_int_key.py0
-rw-r--r--[-rwxr-xr-x]storage/tokudb/mysql-test/tokudb/t/change_column_int_not_supported.py0
-rw-r--r--[-rwxr-xr-x]storage/tokudb/mysql-test/tokudb/t/change_column_int_rename.py0
-rw-r--r--unittest/mysys/lf-t.c5
-rw-r--r--unittest/mysys/my_atomic-t.c17
-rw-r--r--unittest/mysys/thr_template.c31
-rw-r--r--unittest/mysys/waiting_threads-t.c4
155 files changed, 2047 insertions, 2618 deletions
diff --git a/.gitignore b/.gitignore
index 9c2e1d7a8c0..54fdfdae31b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -129,8 +129,6 @@ scripts/wsrep_sst_mysqldump
scripts/wsrep_sst_rsync
scripts/wsrep_sst_rsync_wan
scripts/wsrep_sst_mariabackup
-scripts/wsrep_sst_xtrabackup
-scripts/wsrep_sst_xtrabackup-v2
scripts/maria_add_gis_sp.sql
scripts/maria_add_gis_sp_bootstrap.sql
scripts/galera_new_cluster
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5415efb66db..a139c9e5fa4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -342,6 +342,7 @@ MYSQL_CHECK_SSL()
MYSQL_CHECK_READLINE()
SET(MALLOC_LIBRARY "system")
+SET(PYTHON_SHEBANG "/usr/bin/env python")
CHECK_PCRE()
diff --git a/Docs/README-wsrep b/Docs/README-wsrep
index 6bb329e9396..166901e111f 100644
--- a/Docs/README-wsrep
+++ b/Docs/README-wsrep
@@ -60,7 +60,7 @@ CONTENTS:
Wsrep API developed by Codership Oy is a modern generic (database-agnostic)
replication API for transactional databases with a goal to make database
replication/logging subsystem completely modular and pluggable. It is developed
-with flexibility and completeness in mind to satisfy broad range of modern
+with flexibility and completeness in mind to satisfy a broad range of modern
replication scenarios. It is equally suitable for synchronous and asynchronous,
master-slave and multi-master replication.
@@ -87,7 +87,7 @@ Upgrade from mysql-server-5.0 to mysql-wsrep is not supported yet, please
upgrade to mysql-server-5.1 first.
If you're installing over an existing mysql installation, mysql-server-wsrep
-will conflict with mysql-server-5.1 package, so remove it first:
+will conflict with the mysql-server-5.1 package, so remove it first:
$ sudo apt-get remove mysql-server-5.1 mysql-server-core-5.1
@@ -105,7 +105,7 @@ For example, installation of required packages on Debian Lenny:
$ sudo apt-get install psmisc
$ sudo apt-get -t lenny-backports install mysql-client-5.1
-Now you should be able to install mysql-wsrep package:
+Now you should be able to install the mysql-wsrep package:
$ sudo dpkg -i <mysql-server-wsrep DEB>
@@ -137,7 +137,7 @@ Additional packages to consider (if not yet installed):
* galera (multi-master replication provider, https://launchpad.net/galera)
* MySQL-client-community (for connecting to server and mysqldump-based SST)
* rsync (for rsync-based SST)
- * xtrabackup and nc (for xtrabackup-based SST)
+ * mariabackup and nc (for mariabackup-based SST)
2.2 Upgrade system tables.
@@ -150,7 +150,7 @@ and can be ignored unless specific functionality is needed.
3. FIRST TIME SETUP
Unless you're upgrading an already installed mysql-wsrep package, you will need
-to set up a few things to prepare server for operation.
+to set up a few things to prepare the server for operation.
3.1 CONFIGURATION FILES
@@ -162,7 +162,7 @@ to set up a few things to prepare server for operation.
* Make sure system-wide my.cnf contains "!includedir /etc/mysql/conf.d/" line.
* Edit /etc/mysql/conf.d/wsrep.cnf and set wsrep_provider option by specifying
- a path to provider library. If you don't have a provider, leave it as it is.
+ a path to the provider library. If you don't have a provider, leave it as it is.
* When a new node joins the cluster it'll have to receive a state snapshot from
one of the peers. This requires a privileged MySQL account with access from
@@ -267,7 +267,7 @@ innodb_autoinc_lock_mode=2
This is a required parameter. Without it INSERTs into tables with
AUTO_INCREMENT column may fail.
autoinc lock modes 0 and 1 can cause unresolved deadlock, and make
- system unresponsive.
+ the system unresponsive.
innodb_locks_unsafe_for_binlog=1
This option is required for parallel applying.
@@ -299,14 +299,14 @@ wsrep_node_address=
results (multiple network interfaces, NAT, etc.)
If not explicitly overridden by wsrep_sst_receive_address, the <address> part
will be used to listen for SST (see below). And the whole <address>[:port]
- will be passed to wsrep provider to be used as a base address in its
+ will be passed to the wsrep provider to be used as a base address in its
communications.
wsrep_node_name=
Human readable node name (for easier log reading only). Defaults to hostname.
wsrep_slave_threads=1
- Number of threads dedicated to processing of writesets from other nodes.
+ The number of threads dedicated to the processing of writesets from other nodes.
For best performance should be few per CPU core.
wsrep_dbug_option
@@ -326,7 +326,7 @@ wsrep_convert_LOCK_to_trx=0
wsrep_retry_autocommit=1
Retry autocommit queries and single statement transactions should they fail
certification test. This is analogous to rescheduling an autocommit query
- should it go into deadlock with other transactions in the database lock
+ should it go into a deadlock with other transactions in the database lock
manager.
wsrep_auto_increment_control=1
@@ -357,7 +357,7 @@ wsrep_OSU_method=TOI
is not replicating and may be unable to process replication events (due to
table lock). Once DDL operation is complete, the node will catch up and sync
with the cluster to become fully operational again. The DDL statement or
- its effects are not replicated, so it is user's responsibility to manually
+ its effects are not replicated, so it is the user's responsibility to manually
perform this operation on each of the nodes.
wsrep_forced_binlog_format=none
@@ -380,14 +380,14 @@ to join or start a cluster.
wsrep_sst_method=rsync
What method to use to copy database state to a newly joined node. Supported
methods:
- - mysqldump: slow (except for small datasets) but allows for upgrade
- between major MySQL versions or InnoDB features.
- - rsync: much faster on large datasets (default).
- - rsync_wan: same as rsync but with deltaxfer to minimize network traffic.
- - xtrabackup: very fast and practically non-blocking SST method based on
- Percona's xtrabackup tool.
-
- (for xtrabackup to work the following settings must be present in my.cnf
+ - mysqldump: slow (except for small datasets) but allows for upgrade
+ between major MySQL versions or InnoDB features.
+ - rsync: much faster on large datasets (default).
+ - rsync_wan: same as rsync but with deltaxfer to minimize network traffic.
+ - mariabackup: very fast and practically non-blocking SST method based on
+ mariabackup tool (enhanced version of Percona's xtrabackup).
+
+ (for mariabackup to work the following settings must be present in my.cnf
on all nodes:
[mysqld]
wsrep_sst_auth=root:<root password>
@@ -412,8 +412,8 @@ wsrep_sst_auth=
wsrep_sst_donor=
A name of the node which should serve as state snapshot donor. This allows
- to control which node will serve state snapshot request. By default the
- most suitable node is chosen by wsrep provider. This is the same as given in
+ controlling which node will serve the state snapshot request. By default the
+ most suitable node is chosen by the wsrep provider. This is the same as given in
wsrep_node_name.
@@ -423,7 +423,7 @@ wsrep_sst_donor=
for the database. They change the database structure and are non-
transactional.
- Release 22.3 brings a new method for performing schema upgrades. User can
+ Release 22.3 brings a new method for performing schema upgrades. A user can
now choose whether to use the traditional total order isolation or new
rolling schema upgrade method. The OSU method choice is done by global
parameter: 'wsrep_OSU_method'.
@@ -439,7 +439,7 @@ wsrep_sst_donor=
6.2 Rolling Schema Upgrade (RSU)
- Rolling schema upgrade is new DDL processing method, where DDL will be
+ Rolling schema upgrade is a new DDL processing method, where DDL will be
processed locally for the node. The node is disconnected of the replication
for the duration of the DDL processing, so that there is only DDL statement
processing in the node and it does not block the rest of the cluster. When
@@ -468,7 +468,7 @@ wsrep_sst_donor=
* LOCK/UNLOCK TABLES cannot be supported in multi-master setups.
* lock functions (GET_LOCK(), RELEASE_LOCK()... )
-4) Query log cannot be directed to table. If you enable query logging,
+4) Query log cannot be directed to a table. If you enable query logging,
you must forward the log to a file:
log_output = FILE
Use general_log and general_log_file to choose query logging and the
@@ -480,7 +480,7 @@ wsrep_sst_donor=
6) Due to cluster level optimistic concurrency control, transaction issuing
COMMIT may still be aborted at that stage. There can be two transactions.
writing to same rows and committing in separate cluster nodes, and only one
- of the them can successfully commit. The failing one will be aborted.
+ of them can successfully commit. The failing one will be aborted.
For cluster level aborts, MySQL/galera cluster gives back deadlock error.
code (Error: 1213 SQLSTATE: 40001 (ER_LOCK_DEADLOCK)).
diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake
index d96638ed5df..36d426257ea 100644
--- a/cmake/cpack_rpm.cmake
+++ b/cmake/cpack_rpm.cmake
@@ -214,6 +214,8 @@ ELSEIF(RPM MATCHES "fedora" OR RPM MATCHES "(rhel|centos)7")
ALTERNATIVE_NAME("server" "mariadb-server")
ALTERNATIVE_NAME("server" "mysql-compat-server")
ALTERNATIVE_NAME("test" "mariadb-test")
+ELSEIF(RPM MATCHES "(rhel|centos)8")
+ SET(PYTHON_SHEBANG "/usr/bin/python3")
ENDIF()
# workaround for lots of perl dependencies added by rpmbuild
diff --git a/cmake/mariadb_connector_c.cmake b/cmake/mariadb_connector_c.cmake
index c36087cb862..368a6cc8da5 100644
--- a/cmake/mariadb_connector_c.cmake
+++ b/cmake/mariadb_connector_c.cmake
@@ -6,10 +6,7 @@ ENDIF()
SET(CONC_WITH_SIGNCODE ${SIGNCODE})
SET(SIGN_OPTIONS ${SIGNTOOL_PARAMETERS})
-
-IF(NOT TARGET zlib)
- SET(CONC_WITH_EXTERNAL_ZLIB ON)
-ENDIF()
+SET(CONC_WITH_EXTERNAL_ZLIB ON)
IF(SSL_DEFINES MATCHES "YASSL")
IF(WIN32)
diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake
index 4b7faacc466..e269c473f36 100644
--- a/cmake/zlib.cmake
+++ b/cmake/zlib.cmake
@@ -34,11 +34,6 @@ ENDMACRO()
MACRO (MYSQL_CHECK_ZLIB_WITH_COMPRESS)
- # For NDBCLUSTER: Use bundled zlib by default
- IF (NOT WITH_ZLIB)
- SET(WITH_ZLIB "bundled" CACHE STRING "By default use bundled zlib on this platform")
- ENDIF()
-
IF(WITH_ZLIB STREQUAL "bundled")
MYSQL_USE_BUNDLED_ZLIB()
ELSE()
diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh
index 1c72ad28a3d..7b518742d54 100755
--- a/debian/autobake-deb.sh
+++ b/debian/autobake-deb.sh
@@ -102,7 +102,7 @@ fi
# AWS SDK also requires the build machine to have network access and git, so
# it cannot be part of the base version included in Linux distros, but a pure
# custom built plugin.
-if [[ $GCCVERSION -gt 40800 ]] && [[ ! $TRAVIS ]] && wget --timeout 15 --tries 1 --quiet --output-document /dev/null https://github.com/
+if [[ $GCCVERSION -gt 40800 ]] && [[ ! $TRAVIS ]] && [[ -x "$(command -v git)" ]] && timeout 3s bash -c 'sed -n q </dev/tcp/github.com/22'
then
cat <<EOF >> debian/control
diff --git a/debian/control b/debian/control
index c990f4cfe5a..1588ade9153 100644
--- a/debian/control
+++ b/debian/control
@@ -594,7 +594,7 @@ Description: OQGraph storage engine for MariaDB
Package: mariadb-plugin-tokudb
Architecture: amd64
-Depends: libjemalloc1 (>= 3.0.0~),
+Depends: libjemalloc1 (>= 3.0.0~) | libjemalloc2,
mariadb-server-10.4 (= ${binary:Version}),
${misc:Depends},
${shlibs:Depends}
diff --git a/debian/mariadb-server-10.4.install b/debian/mariadb-server-10.4.install
index f115b212c98..e0f83fbe95b 100644
--- a/debian/mariadb-server-10.4.install
+++ b/debian/mariadb-server-10.4.install
@@ -36,8 +36,6 @@ usr/bin/wsrep_sst_common
usr/bin/wsrep_sst_mariabackup
usr/bin/wsrep_sst_mysqldump
usr/bin/wsrep_sst_rsync
-usr/bin/wsrep_sst_xtrabackup
-usr/bin/wsrep_sst_xtrabackup-v2
usr/lib/mysql/plugin/auth_ed25519.so
usr/lib/mysql/plugin/auth_pam.so
usr/lib/mysql/plugin/auth_pam_tool_dir/auth_pam_tool
diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc
index 27d957693ed..953b3aa0653 100644
--- a/extra/mariabackup/fil_cur.cc
+++ b/extra/mariabackup/fil_cur.cc
@@ -31,6 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "fil_cur.h"
#include "fil0crypt.h"
+#include "fil0pagecompress.h"
#include "common.h"
#include "read_filt.h"
#include "xtrabackup.h"
@@ -260,6 +261,8 @@ xb_fil_cur_open(
mutex_exit(&fil_system.mutex);
}
+ /*msg("crypt: %s,%u\n", node->name, node->space->crypt_data->type);*/
+
cursor->space_size = (ulint)(cursor->statinfo.st_size
/ page_size.physical());
@@ -270,6 +273,107 @@ xb_fil_cur_open(
return(XB_FIL_CUR_SUCCESS);
}
+static bool page_is_corrupted(const byte *page, ulint page_no,
+ const xb_fil_cur_t *cursor,
+ const fil_space_t *space)
+{
+ byte tmp_frame[UNIV_PAGE_SIZE_MAX];
+ byte tmp_page[UNIV_PAGE_SIZE_MAX];
+ const ulint page_size = cursor->page_size.physical();
+ ulint page_type = mach_read_from_2(page + FIL_PAGE_TYPE);
+
+ /* We ignore the doublewrite buffer pages.*/
+ if (cursor->space_id == TRX_SYS_SPACE
+ && page_no >= FSP_EXTENT_SIZE
+ && page_no < FSP_EXTENT_SIZE * 3) {
+ return false;
+ }
+
+ /* Validate page number. */
+ if (mach_read_from_4(page + FIL_PAGE_OFFSET) != page_no
+ && cursor->space_id != TRX_SYS_SPACE) {
+ /* On pages that are not all zero, the
+ page number must match.
+
+ There may be a mismatch on tablespace ID,
+ because files may be renamed during backup.
+ We disable the page number check
+ on the system tablespace, because it may consist
+ of multiple files, and here we count the pages
+ from the start of each file.)
+
+ The first 38 and last 8 bytes are never encrypted. */
+ const ulint* p = reinterpret_cast<const ulint*>(page);
+ const ulint* const end = reinterpret_cast<const ulint*>(
+ page + page_size);
+ do {
+ if (*p++) {
+ return true;
+ }
+ } while (p != end);
+
+ /* Whole zero page is valid. */
+ return false;
+ }
+
+ /* Validate encrypted pages. The first page is never encrypted.
+ In the system tablespace, the first page would be written with
+ FIL_PAGE_FILE_FLUSH_LSN at shutdown, and if the LSN exceeds
+ 4,294,967,295, the mach_read_from_4() below would wrongly
+ interpret the page as encrypted. We prevent that by checking
+ page_no first. */
+ if (page_no
+ && mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION)
+ && (opt_backup_encrypted
+ || (space->crypt_data
+ && space->crypt_data->type != CRYPT_SCHEME_UNENCRYPTED))) {
+
+ if (!fil_space_verify_crypt_checksum(page, cursor->page_size))
+ return true;
+
+ /* Compressed encrypted need to be decrypted
+ and decompressed for verification. */
+ if (page_type != FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED
+ && !opt_extended_validation)
+ return false;
+
+ memcpy(tmp_page, page, page_size);
+
+ bool decrypted = false;
+ if (!space->crypt_data
+ || space->crypt_data->type == CRYPT_SCHEME_UNENCRYPTED
+ || !fil_space_decrypt(space, tmp_frame, tmp_page,
+ &decrypted)) {
+ return true;
+ }
+
+ if (page_type != FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) {
+ return buf_page_is_corrupted(true, tmp_page,
+ cursor->page_size, space);
+ }
+ }
+
+ if (page_type == FIL_PAGE_PAGE_COMPRESSED) {
+ memcpy(tmp_page, page, page_size);
+ }
+
+ if (page_type == FIL_PAGE_PAGE_COMPRESSED
+ || page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) {
+ ulint decomp = fil_page_decompress(tmp_frame, tmp_page);
+ page_type = mach_read_from_2(tmp_page + FIL_PAGE_TYPE);
+
+ return (!decomp
+ || (decomp != srv_page_size
+ && cursor->page_size.is_compressed())
+ || page_type == FIL_PAGE_PAGE_COMPRESSED
+ || page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED
+ || buf_page_is_corrupted(true, tmp_page,
+ cursor->page_size, space));
+ }
+
+ return buf_page_is_corrupted(true, page, cursor->page_size, space);
+}
+
/************************************************************************
Reads and verifies the next block of pages from the source
file. Positions the cursor after the last read non-corrupted page.
@@ -288,8 +392,6 @@ xb_fil_cur_read(
xb_fil_cur_result_t ret;
ib_int64_t offset;
ib_int64_t to_read;
- byte tmp_frame[UNIV_PAGE_SIZE_MAX];
- byte tmp_page[UNIV_PAGE_SIZE_MAX];
const ulint page_size = cursor->page_size.physical();
xb_ad(!cursor->is_system() || page_size == srv_page_size);
@@ -327,7 +429,7 @@ xb_fil_cur_read(
xb_a((to_read & (page_size - 1)) == 0);
- npages = (ulint) (to_read / cursor->page_size.physical());
+ npages = (ulint) (to_read / page_size);
retry_count = 10;
ret = XB_FIL_CUR_SUCCESS;
@@ -344,7 +446,7 @@ read_retry:
cursor->buf_read = 0;
cursor->buf_npages = 0;
cursor->buf_offset = offset;
- cursor->buf_page_no = (ulint)(offset / cursor->page_size.physical());
+ cursor->buf_page_no = (ulint)(offset / page_size);
if (!os_file_read(IORequestRead, cursor->file, cursor->buf, offset,
(ulint) to_read)) {
@@ -357,58 +459,29 @@ read_retry:
page += page_size, i++) {
ulint page_no = cursor->buf_page_no + i;
- if (cursor->space_id == TRX_SYS_SPACE &&
- page_no >= FSP_EXTENT_SIZE &&
- page_no < FSP_EXTENT_SIZE * 3) {
- /* We ignore the doublewrite buffer pages */
- } else if (mach_read_from_4(
- page
- + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION)
- && space->crypt_data
- && space->crypt_data->type
- != CRYPT_SCHEME_UNENCRYPTED
- && fil_space_verify_crypt_checksum(
- page, cursor->page_size)) {
- ut_ad(mach_read_from_4(page + FIL_PAGE_SPACE_ID)
- == space->id);
-
- bool decrypted = false;
-
- memcpy(tmp_page, page, page_size);
-
- if (!fil_space_decrypt(space, tmp_frame,
- tmp_page, &decrypted)
- || buf_page_is_corrupted(true, tmp_page,
- cursor->page_size,
- space)) {
- goto corrupted;
+ if (page_is_corrupted(page, page_no, cursor, space)){
+ retry_count--;
+
+ if (retry_count == 0) {
+ msg("[%02u] mariabackup: "
+ "Error: failed to read page after "
+ "10 retries. File %s seems to be "
+ "corrupted.\n", cursor->thread_n,
+ cursor->abs_path);
+ ret = XB_FIL_CUR_ERROR;
+ buf_page_print(page, cursor->page_size);
+ break;
}
- } else if (buf_page_is_corrupted(true, page, cursor->page_size,
- space)) {
-corrupted:
- retry_count--;
- if (retry_count == 0) {
- msg("[%02u] mariabackup: "
- "Error: failed to read page after "
- "10 retries. File %s seems to be "
- "corrupted.\n", cursor->thread_n,
- cursor->abs_path);
- ret = XB_FIL_CUR_ERROR;
- break;
- }
-
- if (retry_count == 9) {
- msg("[%02u] mariabackup: "
- "Database page corruption detected at page "
- ULINTPF ", retrying...\n",
- cursor->thread_n, page_no);
- }
-
- os_thread_sleep(100000);
- goto read_retry;
- }
- cursor->buf_read += page_size;
- cursor->buf_npages++;
+ msg("[%02u] mariabackup: "
+ "Database page corruption detected at page "
+ ULINTPF ", retrying...\n", cursor->thread_n,
+ page_no);
+
+ os_thread_sleep(100000);
+ goto read_retry;
+ }
+ cursor->buf_read += page_size;
+ cursor->buf_npages++;
}
posix_fadvise(cursor->file, offset, to_read, POSIX_FADV_DONTNEED);
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index 3cde6123345..2e64479a1eb 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -200,6 +200,8 @@ static char* log_ignored_opt;
extern my_bool opt_use_ssl;
my_bool opt_ssl_verify_server_cert;
+my_bool opt_extended_validation;
+my_bool opt_backup_encrypted;
/* === metadata of backup === */
#define XTRABACKUP_METADATA_FILENAME "xtrabackup_checkpoints"
@@ -759,6 +761,8 @@ enum options_xtrabackup
OPT_XTRA_DATABASES,
OPT_XTRA_DATABASES_FILE,
OPT_XTRA_PARALLEL,
+ OPT_XTRA_EXTENDED_VALIDATION,
+ OPT_XTRA_BACKUP_ENCRYPTED,
OPT_XTRA_STREAM,
OPT_XTRA_COMPRESS,
OPT_XTRA_COMPRESS_THREADS,
@@ -1216,6 +1220,22 @@ struct my_option xb_server_options[] =
(G_PTR*) &xtrabackup_parallel, (G_PTR*) &xtrabackup_parallel, 0, GET_INT,
REQUIRED_ARG, 1, 1, INT_MAX, 0, 0, 0},
+ {"extended_validation", OPT_XTRA_EXTENDED_VALIDATION,
+ "Enable extended validation for Innodb data pages during backup phase. "
+ "Will slow down backup considerably, in case encryption is used. "
+ "May fail if tables are created during the backup.",
+ (G_PTR*)&opt_extended_validation,
+ (G_PTR*)&opt_extended_validation,
+ 0, GET_BOOL, NO_ARG, FALSE, 0, 0, 0, 0, 0},
+
+ {"backup_encrypted", OPT_XTRA_BACKUP_ENCRYPTED,
+ "In --backup, assume that nonzero key_version implies that the page"
+ " is encrypted. Use --backup --skip-backup-encrypted to allow"
+ " copying unencrypted that were originally created before MySQL 5.1.48.",
+ (G_PTR*)&opt_backup_encrypted,
+ (G_PTR*)&opt_backup_encrypted,
+ 0, GET_BOOL, NO_ARG, TRUE, 0, 0, 0, 0, 0},
+
{"log", OPT_LOG, "Ignored option for MySQL option compatibility",
(G_PTR*) &log_ignored_opt, (G_PTR*) &log_ignored_opt, 0,
GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
@@ -1452,7 +1472,7 @@ debug_sync_point(const char *name)
}
-static std::vector<std::string> tables_for_export;
+static std::set<std::string> tables_for_export;
static void append_export_table(const char *dbname, const char *tablename, bool is_remote)
{
@@ -1464,7 +1484,15 @@ static void append_export_table(const char *dbname, const char *tablename, bool
char *p=strrchr(buf, '.');
if (p) *p=0;
- tables_for_export.push_back(ut_get_name(0,buf));
+ std::string name=ut_get_name(0, buf);
+ /* Strip partition name comment from table name, if any */
+ if (ends_with(name.c_str(), "*/"))
+ {
+ size_t pos= name.rfind("/*");
+ if (pos != std::string::npos)
+ name.resize(pos);
+ }
+ tables_for_export.insert(name);
}
}
@@ -1479,9 +1507,10 @@ static int create_bootstrap_file()
fputs("SET NAMES UTF8;\n",f);
enumerate_ibd_files(append_export_table);
- for (size_t i= 0; i < tables_for_export.size(); i++)
+ for (std::set<std::string>::iterator it = tables_for_export.begin();
+ it != tables_for_export.end(); it++)
{
- const char *tab = tables_for_export[i].c_str();
+ const char *tab = it->c_str();
fprintf(f,
"BEGIN NOT ATOMIC "
"DECLARE CONTINUE HANDLER FOR NOT FOUND,SQLEXCEPTION BEGIN END;"
@@ -1511,7 +1540,7 @@ static int prepare_export()
snprintf(cmdline, sizeof cmdline,
IF_WIN("\"","") "\"%s\" --mysqld \"%s\" "
" --defaults-extra-file=./backup-my.cnf --defaults-group-suffix=%s --datadir=."
- " --innodb --innodb-fast-shutdown=0"
+ " --innodb --innodb-fast-shutdown=0 --loose-partition"
" --innodb_purge_rseg_truncate_frequency=1 --innodb-buffer-pool-size=%llu"
" --console --skip-log-error --bootstrap < " BOOTSTRAP_FILENAME IF_WIN("\"",""),
mariabackup_exe,
@@ -1523,7 +1552,7 @@ static int prepare_export()
sprintf(cmdline,
IF_WIN("\"","") "\"%s\" --mysqld"
" --defaults-file=./backup-my.cnf --defaults-group-suffix=%s --datadir=."
- " --innodb --innodb-fast-shutdown=0"
+ " --innodb --innodb-fast-shutdown=0 --loose-partition"
" --innodb_purge_rseg_truncate_frequency=1 --innodb-buffer-pool-size=%llu"
" --console --log-error= --bootstrap < " BOOTSTRAP_FILENAME IF_WIN("\"",""),
mariabackup_exe,
@@ -3354,8 +3383,15 @@ xb_load_tablespaces()
return(DB_ERROR);
}
- err = srv_sys_space.open_or_create(false, false, &sum_of_new_sizes,
- &flush_lsn);
+ for (int i= 0; i < 10; i++) {
+ err = srv_sys_space.open_or_create(false, false, &sum_of_new_sizes,
+ &flush_lsn);
+ if (err == DB_PAGE_CORRUPTED || err == DB_CORRUPTION) {
+ my_sleep(1000);
+ }
+ else
+ break;
+ }
if (err != DB_SUCCESS) {
msg("mariabackup: Could not open data files.\n");
@@ -6413,3 +6449,12 @@ static int get_exepath(char *buf, size_t size, const char *argv0)
return my_realpath(buf, argv0, 0);
}
+
+
+#if defined (__SANITIZE_ADDRESS__) && defined (__linux__)
+/* Avoid LeakSanitizer's false positives. */
+const char* __asan_default_options()
+{
+ return "detect_leaks=0";
+}
+#endif
diff --git a/extra/mariabackup/xtrabackup.h b/extra/mariabackup/xtrabackup.h
index 857c253f803..c16e19d1b18 100644
--- a/extra/mariabackup/xtrabackup.h
+++ b/extra/mariabackup/xtrabackup.h
@@ -111,6 +111,8 @@ extern my_bool opt_noversioncheck;
extern my_bool opt_no_backup_locks;
extern my_bool opt_decompress;
extern my_bool opt_remove_original;
+extern my_bool opt_extended_validation;
+extern my_bool opt_backup_encrypted;
extern my_bool opt_lock_ddl_per_table;
extern char *opt_incremental_history_name;
diff --git a/libmariadb b/libmariadb
-Subproject 334964f0711c3fd027f634a239eee57bc912f7f
+Subproject 34f8887af03d022416dd6593de91d0706e57f46
diff --git a/man/wsrep_sst_xtrabackup-v2.1 b/man/wsrep_sst_xtrabackup-v2.1
index 3f95e3eef0d..c8dde2f0640 100644
--- a/man/wsrep_sst_xtrabackup-v2.1
+++ b/man/wsrep_sst_xtrabackup-v2.1
@@ -13,4 +13,6 @@ wsrep_sst_xtrabackup-v2 \- xtrabackup\-based state snapshot transfer
.SH DESCRIPTION
Use: xtrabackup-based state snapshot transfer\.
.PP
+Note that the xtrabackup-v2 method is deprecated after version 10\.1, with newer versions you should use mariabackup instead\.
+.PP
For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/
diff --git a/man/wsrep_sst_xtrabackup.1 b/man/wsrep_sst_xtrabackup.1
index c171a7cf954..1fe5037d8b7 100644
--- a/man/wsrep_sst_xtrabackup.1
+++ b/man/wsrep_sst_xtrabackup.1
@@ -13,4 +13,6 @@ wsrep_sst_xtrabackup \- xtrabackup\-based state snapshot transfer
.SH DESCRIPTION
Use: xtrabackup-based state snapshot transfer\.
.PP
+Note that the xtrabackup method is deprecated after version 10\.1, with newer versions you should use mariabackup instead\.
+.PP
For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/
diff --git a/mysql-test/main/alter_table_errors.result b/mysql-test/main/alter_table_errors.result
index 020a30304d0..b26409e3d05 100644
--- a/mysql-test/main/alter_table_errors.result
+++ b/mysql-test/main/alter_table_errors.result
@@ -8,3 +8,22 @@ t CREATE TABLE `t` (
`v` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t;
+create temporary table t1 (a int, v int as (a));
+alter table t1 change column a b int, algorithm=inplace;
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
+show create table t1;
+Table Create Table
+t1 CREATE TEMPORARY TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `v` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+create temporary table t2 (a int, v int as (a));
+lock table t2 write;
+alter table t2 change column a b int, algorithm=inplace;
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
+show create table t2;
+Table Create Table
+t2 CREATE TEMPORARY TABLE `t2` (
+ `a` int(11) DEFAULT NULL,
+ `v` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
diff --git a/mysql-test/main/alter_table_errors.test b/mysql-test/main/alter_table_errors.test
index d9982ac26f4..8fa65b0f330 100644
--- a/mysql-test/main/alter_table_errors.test
+++ b/mysql-test/main/alter_table_errors.test
@@ -8,3 +8,14 @@ create table t (a int, v int as (a)) engine=innodb;
alter table t change column a b tinyint, algorithm=inplace;
show create table t;
drop table t;
+
+create temporary table t1 (a int, v int as (a));
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+alter table t1 change column a b int, algorithm=inplace;
+show create table t1;
+
+create temporary table t2 (a int, v int as (a));
+lock table t2 write;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+alter table t2 change column a b int, algorithm=inplace;
+show create table t2;
diff --git a/mysql-test/main/check.result b/mysql-test/main/check.result
index e3dcda773f4..e882a4cdbe6 100644
--- a/mysql-test/main/check.result
+++ b/mysql-test/main/check.result
@@ -85,3 +85,13 @@ t1 CREATE TABLE `t1` (
`c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
+create temporary table t1 (
+id int not null auto_increment primary key,
+f int not null default 0
+);
+insert into t1 () values ();
+alter ignore table t1 add constraint check (f > 0);
+Warnings:
+Warning 4025 CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1`
+alter table t1;
+drop table t1;
diff --git a/mysql-test/main/check.test b/mysql-test/main/check.test
index cce8fd34c9c..475a7996a09 100644
--- a/mysql-test/main/check.test
+++ b/mysql-test/main/check.test
@@ -103,3 +103,15 @@ CREATE OR REPLACE TABLE t1 (a INT, b INT, c INT, CHECK (a+b>0)) ENGINE=MyISAM;
ALTER TABLE t1 DROP COLUMN b, DROP CONSTRAINT `CONSTRAINT_1`;
SHOW CREATE TABLE t1;
DROP TABLE t1;
+
+#
+# MDEV-16903 Assertion `!auto_increment_field_not_null' failed in TABLE::init after unsuccessful attempt to add CHECK constraint on temporary table
+#
+create temporary table t1 (
+ id int not null auto_increment primary key,
+ f int not null default 0
+);
+insert into t1 () values ();
+alter ignore table t1 add constraint check (f > 0);
+alter table t1;
+drop table t1;
diff --git a/mysql-test/main/func_group_innodb.result b/mysql-test/main/func_group_innodb.result
index a2251f2b348..141d7ccff3a 100644
--- a/mysql-test/main/func_group_innodb.result
+++ b/mysql-test/main/func_group_innodb.result
@@ -246,4 +246,28 @@ EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL b 263 NULL 2 Using index for group-by
DROP TABLE t1;
+#
+# MDEV-17589: Stack-buffer-overflow with indexed varchar (utf8) field
+#
+CREATE TABLE t1 (v1 varchar(1020), v2 varchar(2), v3 varchar(2),
+KEY k1 (v3,v2,v1)) ENGINE=InnoDB CHARACTER SET=utf8 ROW_FORMAT=DYNAMIC;
+INSERT INTO t1 VALUES ('king', 'qu','qu'), ('bad','go','go');
+explain
+SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu';
+MIN(t1.v1)
+king
+drop table t1;
+CREATE TABLE t1 (v1 varchar(1024) CHARACTER SET utf8, KEY v1 (v1)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+INSERT INTO t1 VALUES ('king'), ('bad');
+explain
+SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x;
+MIN(x.v1)
+NULL
+drop table t1;
End of 5.5 tests
diff --git a/mysql-test/main/func_group_innodb.test b/mysql-test/main/func_group_innodb.test
index 1d175f85ed9..c4914b97641 100644
--- a/mysql-test/main/func_group_innodb.test
+++ b/mysql-test/main/func_group_innodb.test
@@ -192,4 +192,23 @@ EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b;
DROP TABLE t1;
+--echo #
+--echo # MDEV-17589: Stack-buffer-overflow with indexed varchar (utf8) field
+--echo #
+
+CREATE TABLE t1 (v1 varchar(1020), v2 varchar(2), v3 varchar(2),
+ KEY k1 (v3,v2,v1)) ENGINE=InnoDB CHARACTER SET=utf8 ROW_FORMAT=DYNAMIC;
+INSERT INTO t1 VALUES ('king', 'qu','qu'), ('bad','go','go');
+explain
+SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu';
+SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu';
+drop table t1;
+
+CREATE TABLE t1 (v1 varchar(1024) CHARACTER SET utf8, KEY v1 (v1)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+INSERT INTO t1 VALUES ('king'), ('bad');
+explain
+SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x;
+SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x;
+drop table t1;
+
--echo End of 5.5 tests
diff --git a/mysql-test/main/func_hybrid_type.result b/mysql-test/main/func_hybrid_type.result
index a86fd8d1d6f..129d49776a8 100644
--- a/mysql-test/main/func_hybrid_type.result
+++ b/mysql-test/main/func_hybrid_type.result
@@ -3753,6 +3753,24 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
#
+# MDEV-17759 Assertion `precision > 0' failed in decimal_bin_size upon CREATE TABLE .. SELECT
+#
+SET sql_mode='';
+CREATE TABLE t1 (d DECIMAL(43,0) UNSIGNED);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 AS SELECT
+IFNULL(SLEEP(0.01), NULL DIV d) AS f0,
+IFNULL(SLEEP(0.01), '' DIV d) AS f1
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `f0` decimal(1,0) DEFAULT NULL,
+ `f1` decimal(1,0) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1, t2;
+SET sql_mode=DEFAULT;
+#
# End of 10.3 tests
#
#
diff --git a/mysql-test/main/func_hybrid_type.test b/mysql-test/main/func_hybrid_type.test
index 6b32f331d34..5281d846584 100644
--- a/mysql-test/main/func_hybrid_type.test
+++ b/mysql-test/main/func_hybrid_type.test
@@ -612,6 +612,22 @@ SHOW CREATE TABLE t1;
DROP TABLE t1;
--echo #
+--echo # MDEV-17759 Assertion `precision > 0' failed in decimal_bin_size upon CREATE TABLE .. SELECT
+--echo #
+
+SET sql_mode='';
+CREATE TABLE t1 (d DECIMAL(43,0) UNSIGNED);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 AS SELECT
+ IFNULL(SLEEP(0.01), NULL DIV d) AS f0,
+ IFNULL(SLEEP(0.01), '' DIV d) AS f1
+FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+SET sql_mode=DEFAULT;
+
+
+--echo #
--echo # End of 10.3 tests
--echo #
diff --git a/mysql-test/main/func_math.result b/mysql-test/main/func_math.result
index 832ca69d3ea..eafee43e2a2 100644
--- a/mysql-test/main/func_math.result
+++ b/mysql-test/main/func_math.result
@@ -1285,3 +1285,36 @@ E59B9BE4BA94E585AD 2914501801
E4B883E585ABE4B99D 2374586519
DROP TABLE t1;
SET NAMES default;
+#
+# MDEV-17759 Assertion `precision > 0' failed in decimal_bin_size upon CREATE TABLE .. SELECT
+#
+SET sql_mode='';
+CREATE TABLE t1 (d DECIMAL(43,0) UNSIGNED);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 AS SELECT
+NULL DIV d AS d_null,
+'' DIV d AS d_empty_string,
+X'32' DIV d AS d_hex_string2,
+X'3232' DIV d AS d_hex_string4,
+TIME(0) DIV d AS d_time,
+CURRENT_DATE DIV d AS d_date,
+CURRENT_TIMESTAMP DIV d AS d_datetime
+FROM t1;
+Warnings:
+Warning 1292 Truncated incorrect DECIMAL value: ''
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `d_null` int(1) unsigned DEFAULT NULL,
+ `d_empty_string` int(1) unsigned DEFAULT NULL,
+ `d_hex_string2` int(1) unsigned DEFAULT NULL,
+ `d_hex_string4` int(2) unsigned DEFAULT NULL,
+ `d_time` int(7) unsigned DEFAULT NULL,
+ `d_date` int(8) unsigned DEFAULT NULL,
+ `d_datetime` bigint(14) unsigned DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1, t2;
+SET sql_mode=DEFAULT;
+#
+# End of 10.3 tests
+#
diff --git a/mysql-test/main/func_math.test b/mysql-test/main/func_math.test
index a2c54b58a67..bf95cfd7868 100644
--- a/mysql-test/main/func_math.test
+++ b/mysql-test/main/func_math.test
@@ -897,3 +897,28 @@ LOAD DATA INFILE '../../std_data/loaddata_utf8.dat' INTO TABLE t1 CHARACTER SET
SELECT HEX(a), CRC32(a) from t1;
DROP TABLE t1;
SET NAMES default;
+
+--echo #
+--echo # MDEV-17759 Assertion `precision > 0' failed in decimal_bin_size upon CREATE TABLE .. SELECT
+--echo #
+
+SET sql_mode='';
+CREATE TABLE t1 (d DECIMAL(43,0) UNSIGNED);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 AS SELECT
+ NULL DIV d AS d_null,
+ '' DIV d AS d_empty_string,
+ X'32' DIV d AS d_hex_string2,
+ X'3232' DIV d AS d_hex_string4,
+ TIME(0) DIV d AS d_time,
+ CURRENT_DATE DIV d AS d_date,
+ CURRENT_TIMESTAMP DIV d AS d_datetime
+FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+SET sql_mode=DEFAULT;
+
+
+--echo #
+--echo # End of 10.3 tests
+--echo #
diff --git a/mysql-test/main/grant5.result b/mysql-test/main/grant5.result
index 5df4a669a0c..5bf7b2d1934 100644
--- a/mysql-test/main/grant5.result
+++ b/mysql-test/main/grant5.result
@@ -18,6 +18,13 @@ ERROR 42000: Access denied for user 'test'@'%' to database 'mysql'
connection default;
drop user test, foo;
drop role foo;
+CREATE TABLE t1 (a INT);
+LOCK TABLE t1 WRITE;
+REVOKE EXECUTE ON PROCEDURE sp FROM u;
+ERROR HY000: Table 'procs_priv' was not locked with LOCK TABLES
+REVOKE PROCESS ON *.* FROM u;
+ERROR HY000: Table 'db' was not locked with LOCK TABLES
+DROP TABLE t1;
create user u1@h identified with 'mysql_native_password' using 'pwd';
ERROR HY000: Password hash should be a 41-digit hexadecimal number
create user u1@h identified with 'mysql_native_password' using password('pwd');
diff --git a/mysql-test/main/grant5.test b/mysql-test/main/grant5.test
index 4e89bad9775..daf972dbe4b 100644
--- a/mysql-test/main/grant5.test
+++ b/mysql-test/main/grant5.test
@@ -24,6 +24,17 @@ drop user test, foo;
drop role foo;
#
+# MDEV-17975 Assertion `! is_set()' or `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed upon REVOKE under LOCK TABLE
+#
+CREATE TABLE t1 (a INT);
+LOCK TABLE t1 WRITE;
+--error ER_TABLE_NOT_LOCKED
+REVOKE EXECUTE ON PROCEDURE sp FROM u;
+--error ER_TABLE_NOT_LOCKED
+REVOKE PROCESS ON *.* FROM u;
+DROP TABLE t1;
+
+#
# MDEV-12321 authentication plugin: SET PASSWORD support
#
error ER_PASSWD_LENGTH;
diff --git a/mysql-test/main/innodb_ext_key.result b/mysql-test/main/innodb_ext_key.result
index f9210bd168c..db08d1148b8 100644
--- a/mysql-test/main/innodb_ext_key.result
+++ b/mysql-test/main/innodb_ext_key.result
@@ -1091,6 +1091,7 @@ from
t0 A, t0 B, t0 C;
drop table t0,t1;
#
+#
# MDEV-10360: Extended keys: index properties depend on index order
#
create table t0 (a int);
diff --git a/mysql-test/main/innodb_ext_key.test b/mysql-test/main/innodb_ext_key.test
index a721943e8bc..4104ac5f787 100644
--- a/mysql-test/main/innodb_ext_key.test
+++ b/mysql-test/main/innodb_ext_key.test
@@ -726,6 +726,7 @@ if ($rows < 2)
drop table t0,t1;
--echo #
+--echo #
--echo # MDEV-10360: Extended keys: index properties depend on index order
--echo #
create table t0 (a int);
diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result
index 1a3b927f981..c40aa271465 100644
--- a/mysql-test/main/mysqldump.result
+++ b/mysql-test/main/mysqldump.result
@@ -4335,12 +4335,12 @@ second ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL E
show create event ee1;
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
ee1 UTC CREATE DEFINER=`root`@`localhost` EVENT `ee1` ON SCHEDULE AT '2035-12-31 20:01:23' ON COMPLETION NOT PRESERVE ENABLE DO set @a=5 latin1 latin1_swedish_ci latin1_swedish_ci
-create event ee2 on schedule at '2018-12-31 21:01:23' do set @a=5;
+create event ee2 on schedule at '2030-12-31 21:01:22' do set @a=5;
create event ee3 on schedule at '2030-12-31 22:01:23' do set @a=5;
show events;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
second ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
-second ee2 root@localhost UTC ONE TIME 2018-12-31 21:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+second ee2 root@localhost UTC ONE TIME 2030-12-31 21:01:22 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
second ee3 root@localhost UTC ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
drop database second;
create database third;
@@ -4348,7 +4348,7 @@ use third;
show events;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
third ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
-third ee2 root@localhost UTC ONE TIME 2018-12-31 21:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
+third ee2 root@localhost UTC ONE TIME 2030-12-31 21:01:22 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
third ee3 root@localhost UTC ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
drop database third;
set time_zone = 'SYSTEM';
diff --git a/mysql-test/main/mysqldump.test b/mysql-test/main/mysqldump.test
index 57462fcf2e2..e2d9cc74d32 100644
--- a/mysql-test/main/mysqldump.test
+++ b/mysql-test/main/mysqldump.test
@@ -1810,7 +1810,7 @@ show create event ee1;
## prove three works (with spaces and tabs on the end)
# start with one from the previous restore
-create event ee2 on schedule at '2018-12-31 21:01:23' do set @a=5;
+create event ee2 on schedule at '2030-12-31 21:01:22' do set @a=5;
create event ee3 on schedule at '2030-12-31 22:01:23' do set @a=5;
show events;
--exec $MYSQL_DUMP --events second > $MYSQLTEST_VARDIR/tmp/bug16853-2.sql
diff --git a/mysql-test/main/partition_alter.test b/mysql-test/main/partition_alter.test
index 62a3e1c0777..91ae67e2f7b 100644
--- a/mysql-test/main/partition_alter.test
+++ b/mysql-test/main/partition_alter.test
@@ -79,7 +79,6 @@ partition p1 values less than ('2016-10-18'),
partition p2 values less than ('2020-10-19'));
insert t1 values (0, '2000-01-02', 0);
insert t1 values (1, '2020-01-02', 10);
---replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
--error ER_CONSTRAINT_FAILED
alter table t1 add check (b in (0, 1));
alter table t1 add check (b in (0, 10));
@@ -96,7 +95,6 @@ partition p1 values less than ('2016-10-18'),
partition p2 values less than ('2020-10-19'));
insert t1 values (0, '2000-01-02', 0);
insert t1 values (1, '2020-01-02', 10);
---replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
--error ER_CONSTRAINT_FAILED
alter table t1 add check (b in (0, 1));
alter table t1 add check (b in (0, 10));
diff --git a/mysql-test/main/partition_innodb.result b/mysql-test/main/partition_innodb.result
index 7d26e5fe216..e91d3767fcc 100644
--- a/mysql-test/main/partition_innodb.result
+++ b/mysql-test/main/partition_innodb.result
@@ -955,6 +955,26 @@ test_jfg test_jfg11
test_jfg test_jfg12#P#p1000
test_jfg test_jfg12#P#pmax
DROP DATABASE test_jfg;
+create table t1 (a int) engine=innodb;
+create table t2 (
+b int,
+c int,
+d bit not null default 0,
+v bit as (d) virtual,
+key (b,v)
+) engine=innodb partition by hash (b);
+insert into t1 values (1),(2);
+insert into t2 (b,c,d) values (1,1,0),(2,2,0);
+explain select t1.* from t1 join t2 on (v = a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 index NULL b 7 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
+select t1.* from t1 join t2 on (v = a);
+a
+drop table t1, t2;
+#
+# End of 10.2 tests
+#
#
# MDEV-16241 Assertion `inited==RND' failed in handler::ha_rnd_end()
#
@@ -966,3 +986,6 @@ SELECT COUNT(*) FROM t1 WHERE x IS NULL AND y IS NULL AND z IS NULL;
COUNT(*)
2
DROP TABLE t1;
+#
+# End of 10.3 tests
+#
diff --git a/mysql-test/main/partition_innodb.test b/mysql-test/main/partition_innodb.test
index 4b4662da47b..57d644d293d 100644
--- a/mysql-test/main/partition_innodb.test
+++ b/mysql-test/main/partition_innodb.test
@@ -1048,6 +1048,27 @@ database_name = 'test_jfg';
DROP DATABASE test_jfg;
+#
+# MDEV-17755 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index) || (!(ptr >= table->record[0] && ptr < table->record[0] + table->s->reclength)))' failed in Field_bit::val_int upon SELECT with JOIN, partitions, indexed virtual column
+#
+create table t1 (a int) engine=innodb;
+create table t2 (
+ b int,
+ c int,
+ d bit not null default 0,
+ v bit as (d) virtual,
+ key (b,v)
+) engine=innodb partition by hash (b);
+insert into t1 values (1),(2);
+insert into t2 (b,c,d) values (1,1,0),(2,2,0);
+explain select t1.* from t1 join t2 on (v = a);
+select t1.* from t1 join t2 on (v = a);
+drop table t1, t2;
+
+--echo #
+--echo # End of 10.2 tests
+--echo #
+
--echo #
--echo # MDEV-16241 Assertion `inited==RND' failed in handler::ha_rnd_end()
--echo #
@@ -1057,3 +1078,7 @@ PARTITION BY SYSTEM_TIME (PARTITION p1 HISTORY, PARTITION pn CURRENT);
INSERT INTO t1 VALUES (1, 7, 8, 9), (2, NULL, NULL, NULL), (3, NULL, NULL, NULL);
SELECT COUNT(*) FROM t1 WHERE x IS NULL AND y IS NULL AND z IS NULL;
DROP TABLE t1;
+
+--echo #
+--echo # End of 10.3 tests
+--echo #
diff --git a/mysql-test/main/ps_error.result b/mysql-test/main/ps_error.result
new file mode 100644
index 00000000000..c3c312e82f5
--- /dev/null
+++ b/mysql-test/main/ps_error.result
@@ -0,0 +1,73 @@
+#
+# MDEV-17741 Assertion `thd->Item_change_list::is_empty()' failed in mysql_parse after unsuccessful PS
+#
+SET SQL_MODE= 'STRICT_ALL_TABLES';
+CREATE TABLE t1 (a INT);
+PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0";
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: 'foo'
+EXECUTE stmt;
+ERROR 22007: Truncated incorrect INTEGER value: 'foo'
+SELECT a FROM t1 GROUP BY NULL WITH ROLLUP;
+a
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+SET SQL_MODE= 'STRICT_ALL_TABLES';
+CREATE TABLE t1 (a INT);
+PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0";
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: 'foo'
+EXECUTE stmt;
+ERROR 22007: Truncated incorrect INTEGER value: 'foo'
+SET @a = REPLACE( @@global.optimizer_switch, '=on', '=off' ) ;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+#
+# MDEV-17738 Server crashes in Item::delete_self on closing connection after unsuccessful PS
+#
+SET SQL_MODE='STRICT_ALL_TABLES';
+PREPARE stmt FROM "CREATE TABLE ps AS SELECT 1 FROM DUAL WHERE 'foo' && 0";
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: 'foo'
+EXECUTE stmt;
+ERROR 22007: Truncated incorrect INTEGER value: 'foo'
+SELECT 'All done';
+All done
+All done
+SET SQL_MODE=DEFAULT;
+SET SQL_MODE='STRICT_ALL_TABLES';
+PREPARE stmt FROM "CREATE TABLE ps AS SELECT 1 FROM DUAL WHERE 'foo' && 0";
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: 'foo'
+EXECUTE stmt;
+ERROR 22007: Truncated incorrect INTEGER value: 'foo'
+DEALLOCATE PREPARE stmt;
+SELECT 'All done';
+All done
+All done
+SET SQL_MODE=DEFAULT;
+SET SQL_MODE= 'STRICT_ALL_TABLES';
+CREATE TABLE t1 (a INT);
+PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0";
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: 'foo'
+EXECUTE stmt;
+ERROR 22007: Truncated incorrect INTEGER value: 'foo'
+SELECT a FROM t1 GROUP BY a;
+a
+SELECT * FROM t1;
+a
+DROP TABLE t1;
+SET SQL_MODE=DEFAULT;
+SET SQL_MODE= 'STRICT_ALL_TABLES';
+CREATE TABLE t1 (a INT);
+PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0";
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: 'foo'
+EXECUTE stmt;
+ERROR 22007: Truncated incorrect INTEGER value: 'foo'
+SELECT a FROM t1 GROUP BY a;
+a
+INSERT t1 SELECT * FROM ( SELECT * FROM t1 ) sq;
+DROP TABLE t1;
+SET SQL_MODE=DEFAULT;
diff --git a/mysql-test/main/ps_error.test b/mysql-test/main/ps_error.test
new file mode 100644
index 00000000000..5efb5d36137
--- /dev/null
+++ b/mysql-test/main/ps_error.test
@@ -0,0 +1,66 @@
+#
+# Tests related to PS returning errors rather than doing successfull execution
+#
+
+--echo #
+--echo # MDEV-17741 Assertion `thd->Item_change_list::is_empty()' failed in mysql_parse after unsuccessful PS
+--echo #
+
+SET SQL_MODE= 'STRICT_ALL_TABLES';
+CREATE TABLE t1 (a INT);
+PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0";
+--error ER_TRUNCATED_WRONG_VALUE
+EXECUTE stmt;
+SELECT a FROM t1 GROUP BY NULL WITH ROLLUP;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+SET SQL_MODE= 'STRICT_ALL_TABLES';
+CREATE TABLE t1 (a INT);
+PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0";
+--error ER_TRUNCATED_WRONG_VALUE
+EXECUTE stmt;
+SET @a = REPLACE( @@global.optimizer_switch, '=on', '=off' ) ;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+
+--echo #
+--echo # MDEV-17738 Server crashes in Item::delete_self on closing connection after unsuccessful PS
+--echo #
+
+SET SQL_MODE='STRICT_ALL_TABLES';
+PREPARE stmt FROM "CREATE TABLE ps AS SELECT 1 FROM DUAL WHERE 'foo' && 0";
+--error ER_TRUNCATED_WRONG_VALUE
+EXECUTE stmt;
+--source include/restart_mysqld.inc
+SELECT 'All done';
+SET SQL_MODE=DEFAULT;
+
+SET SQL_MODE='STRICT_ALL_TABLES';
+PREPARE stmt FROM "CREATE TABLE ps AS SELECT 1 FROM DUAL WHERE 'foo' && 0";
+--error ER_TRUNCATED_WRONG_VALUE
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+SELECT 'All done';
+SET SQL_MODE=DEFAULT;
+
+SET SQL_MODE= 'STRICT_ALL_TABLES';
+CREATE TABLE t1 (a INT);
+PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0";
+--error ER_TRUNCATED_WRONG_VALUE
+EXECUTE stmt;
+SELECT a FROM t1 GROUP BY a;
+SELECT * FROM t1;
+DROP TABLE t1;
+SET SQL_MODE=DEFAULT;
+
+SET SQL_MODE= 'STRICT_ALL_TABLES';
+CREATE TABLE t1 (a INT);
+PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0";
+--error ER_TRUNCATED_WRONG_VALUE
+EXECUTE stmt;
+SELECT a FROM t1 GROUP BY a;
+INSERT t1 SELECT * FROM ( SELECT * FROM t1 ) sq;
+DROP TABLE t1;
+SET SQL_MODE=DEFAULT;
diff --git a/mysql-test/main/range_innodb.result b/mysql-test/main/range_innodb.result
index 2ede6351957..ae25adf1a19 100644
--- a/mysql-test/main/range_innodb.result
+++ b/mysql-test/main/range_innodb.result
@@ -38,3 +38,21 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 10
1 SIMPLE t2 range a,b b 5 NULL 201 Using where; Using join buffer (flat, BNL join)
drop table t0,t1,t2;
+CREATE TABLE t1 (
+pk INT PRIMARY KEY, f1 INT, f2 CHAR(1), f3 CHAR(1),
+KEY(f1), KEY(f2)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+(1,4,'v',NULL),(2,6,'v',NULL),(3,7,'c',NULL),(4,1,'e',NULL),(5,0,'x',NULL),
+(6,7,'i',NULL),(7,7,'e',NULL),(8,1,'p',NULL),(9,7,'s',NULL),(10,1,'j',NULL),
+(11,5,'z',NULL),(12,2,'c',NULL),(13,0,'a',NULL),(14,1,'q',NULL),(15,8,'y',NULL),
+(16,1,'m',NULL),(17,1,'r',NULL),(18,9,'v',NULL),(19,1,'n',NULL);
+CREATE TABLE t2 (f4 INT, f5 CHAR(1)) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (4,'q'),(NULL,'j');
+SELECT * FROM t1 AS t1_1, t1 AS t1_2, t2
+WHERE f5 = t1_2.f2 AND ( t1_1.f1 = 103 AND t1_1.f2 = 'o' OR t1_1.pk < f4 );
+pk f1 f2 f3 pk f1 f2 f3 f4 f5
+1 4 v NULL 14 1 q NULL 4 q
+2 6 v NULL 14 1 q NULL 4 q
+3 7 c NULL 14 1 q NULL 4 q
+drop table t1,t2;
diff --git a/mysql-test/main/range_innodb.test b/mysql-test/main/range_innodb.test
index f76794814ef..605006587cc 100644
--- a/mysql-test/main/range_innodb.test
+++ b/mysql-test/main/range_innodb.test
@@ -45,3 +45,20 @@ explain select * from t0 left join t2 on t2.a <t0.a and t2.b between 50 and 250;
drop table t0,t1,t2;
+CREATE TABLE t1 (
+ pk INT PRIMARY KEY, f1 INT, f2 CHAR(1), f3 CHAR(1),
+ KEY(f1), KEY(f2)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES
+(1,4,'v',NULL),(2,6,'v',NULL),(3,7,'c',NULL),(4,1,'e',NULL),(5,0,'x',NULL),
+(6,7,'i',NULL),(7,7,'e',NULL),(8,1,'p',NULL),(9,7,'s',NULL),(10,1,'j',NULL),
+(11,5,'z',NULL),(12,2,'c',NULL),(13,0,'a',NULL),(14,1,'q',NULL),(15,8,'y',NULL),
+(16,1,'m',NULL),(17,1,'r',NULL),(18,9,'v',NULL),(19,1,'n',NULL);
+
+CREATE TABLE t2 (f4 INT, f5 CHAR(1)) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (4,'q'),(NULL,'j');
+
+SELECT * FROM t1 AS t1_1, t1 AS t1_2, t2
+WHERE f5 = t1_2.f2 AND ( t1_1.f1 = 103 AND t1_1.f2 = 'o' OR t1_1.pk < f4 );
+drop table t1,t2;
diff --git a/mysql-test/main/read_only.result b/mysql-test/main/read_only.result
index 2029413c0f0..83dfada5f29 100644
--- a/mysql-test/main/read_only.result
+++ b/mysql-test/main/read_only.result
@@ -170,11 +170,24 @@ flush privileges;
drop database mysqltest_db1;
set global read_only= @start_read_only;
#
+# MDEV-16987 - ALTER DATABASE possible in read-only mode
+#
+CREATE USER user1@localhost;
+GRANT ALTER ON test1.* TO user1@localhost;
+CREATE DATABASE test1;
+SET GLOBAL read_only=1;
+ALTER DATABASE test1 CHARACTER SET utf8;
+ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
+SET GLOBAL read_only=0;
+DROP DATABASE test1;
+DROP USER user1@localhost;
+USE test;
+# End of 5.5 tests
+#
# WL#5968 Implement START TRANSACTION READ (WRITE|ONLY);
#
#
# Test interaction with read_only system variable.
-DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (1), (2);
CREATE USER user1;
@@ -211,3 +224,4 @@ connection default;
DROP USER user1;
SET GLOBAL read_only= 0;
DROP TABLE t1;
+# End of 10.0 tests
diff --git a/mysql-test/main/read_only.test b/mysql-test/main/read_only.test
index a05f813346e..5314b11154f 100644
--- a/mysql-test/main/read_only.test
+++ b/mysql-test/main/read_only.test
@@ -283,6 +283,23 @@ flush privileges;
drop database mysqltest_db1;
set global read_only= @start_read_only;
+--echo #
+--echo # MDEV-16987 - ALTER DATABASE possible in read-only mode
+--echo #
+CREATE USER user1@localhost;
+GRANT ALTER ON test1.* TO user1@localhost;
+CREATE DATABASE test1;
+SET GLOBAL read_only=1;
+change_user user1;
+--error ER_OPTION_PREVENTS_STATEMENT
+ALTER DATABASE test1 CHARACTER SET utf8;
+change_user root;
+SET GLOBAL read_only=0;
+DROP DATABASE test1;
+DROP USER user1@localhost;
+USE test;
+
+--echo # End of 5.5 tests
--echo #
--echo # WL#5968 Implement START TRANSACTION READ (WRITE|ONLY);
@@ -291,10 +308,6 @@ set global read_only= @start_read_only;
--echo #
--echo # Test interaction with read_only system variable.
---disable_warnings
-DROP TABLE IF EXISTS t1;
---enable_warnings
-
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (1), (2);
@@ -344,3 +357,5 @@ DROP TABLE t1;
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
+
+--echo # End of 10.0 tests
diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result
index b110ab670ae..39bc09e21d6 100644
--- a/mysql-test/main/sp.result
+++ b/mysql-test/main/sp.result
@@ -8708,3 +8708,38 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
DROP FUNCTION f1;
+#
+# MDEV-16036: Debug assertion failed in resignal on create
+# temporary table
+#
+set @save_sql_mode= @@sql_mode;
+set sql_mode='ORACLE';
+CREATE or replace procedure p4()
+AS
+CONTINUE HANDLER FOR SQLWARNING
+BEGIN
+NULL;
+END;
+EXIT HANDLER FOR OTHERS -- SQLEXCEPTION
+BEGIN
+GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
+SELECT @sqlstate, @errno, @text;
+SHOW WARNINGS;
+RESIGNAL; -- cause DBG_ASSERT failed
+END;
+BEGIN
+CREATE TEMPORARY TABLE IF NOT EXISTS t1(origine VARCHAR2(10) NOT NULL);
+END
+/
+call p4();
+call p4();
+@sqlstate @errno @text
+42S01 1050 Table 't1' already exists
+Level Code Message
+Note 1050 Table 't1' already exists
+Warnings:
+Note 1050 Table 't1' already exists
+drop procedure p4;
+drop table t1;
+set @@sql_mode=@save_sql_mode;
+# End of 10.3 tests
diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test
index 721855895c7..230e9c8bb18 100644
--- a/mysql-test/main/sp.test
+++ b/mysql-test/main/sp.test
@@ -10239,3 +10239,37 @@ CREATE TABLE t1 AS SELECT f1() AS c1, COALESCE(f1()) AS c2, CONCAT(f1()) AS c3;
SHOW CREATE TABLE t1;
DROP TABLE t1;
DROP FUNCTION f1;
+
+--echo #
+--echo # MDEV-16036: Debug assertion failed in resignal on create
+--echo # temporary table
+--echo #
+
+set @save_sql_mode= @@sql_mode;
+set sql_mode='ORACLE';
+delimiter /;
+CREATE or replace procedure p4()
+AS
+ CONTINUE HANDLER FOR SQLWARNING
+ BEGIN
+ NULL;
+ END;
+ EXIT HANDLER FOR OTHERS -- SQLEXCEPTION
+ BEGIN
+ GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
+ SELECT @sqlstate, @errno, @text;
+ SHOW WARNINGS;
+ RESIGNAL; -- cause DBG_ASSERT failed
+ END;
+BEGIN
+ CREATE TEMPORARY TABLE IF NOT EXISTS t1(origine VARCHAR2(10) NOT NULL);
+END
+/
+delimiter ;/
+call p4();
+call p4();
+drop procedure p4;
+drop table t1;
+set @@sql_mode=@save_sql_mode;
+
+--echo # End of 10.3 tests
diff --git a/mysql-test/main/udf.result b/mysql-test/main/udf.result
index 13eb186135b..6655982a38f 100644
--- a/mysql-test/main/udf.result
+++ b/mysql-test/main/udf.result
@@ -465,6 +465,20 @@ a b
Hello HL
DROP FUNCTION METAPHON;
DROP TABLE t1;
+#
+# MDEV-15424: Unreasonal SQL Error (1356) on select from view
+#
+CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
+create table t1(a int , b int);
+insert into t1 values(100, 54), (200, 199);
+create view v1 as select myfunc_int(max(a) over (order by b) , b) from t1;
+select * from v1;
+myfunc_int(max(a) over (order by b) , b)
+154
+399
+drop view v1;
+drop function myfunc_int;
+drop table t1;
MDEV-15073: Generic UDAF parser code in server for windows functions
diff --git a/mysql-test/main/udf.test b/mysql-test/main/udf.test
index 43d66dc68e2..bb8493135aa 100644
--- a/mysql-test/main/udf.test
+++ b/mysql-test/main/udf.test
@@ -529,6 +529,19 @@ DROP FUNCTION METAPHON;
#SELECT * FROM t1;
DROP TABLE t1;
+--echo #
+--echo # MDEV-15424: Unreasonal SQL Error (1356) on select from view
+--echo #
+--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB
+eval CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_SO";
+create table t1(a int , b int);
+insert into t1 values(100, 54), (200, 199);
+create view v1 as select myfunc_int(max(a) over (order by b) , b) from t1;
+select * from v1;
+drop view v1;
+drop function myfunc_int;
+drop table t1;
+
--echo
--echo MDEV-15073: Generic UDAF parser code in server for windows functions
--echo
diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result
index ce8c1311222..279404968bf 100644
--- a/mysql-test/main/win.result
+++ b/mysql-test/main/win.result
@@ -3471,7 +3471,25 @@ MIN(b1) OVER ()
1
drop table t1;
#
-# Start of 10.3 tests
+# MDEV-15424: Unreasonal SQL Error (1356) on select from view
+#
+create table t1 (id int, n1 int);
+insert into t1 values (1,1), (2,1), (3,2), (4,4);
+create view v1 as SELECT ifnull(max(n1) over (partition by n1),'aaa') FROM t1;
+explain select * from v1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
+2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using temporary
+select * from v1;
+ifnull(max(n1) over (partition by n1),'aaa')
+1
+1
+2
+4
+drop table t1;
+drop view v1;
+#
+# End of 10.2 tests
#
#
# MDEV-16489 when lead() returns null on a datetime field, the result is treated as the literal string '[NULL]'
@@ -3491,6 +3509,9 @@ d x
00:00:02 NULL
DROP TABLE t1;
#
+# End of 10.3 tests
+#
+#
# MDEV-16722: Assertion `type() != NULL_ITEM' failed
#
create table t1 (a int);
diff --git a/mysql-test/main/win.test b/mysql-test/main/win.test
index 0254667579a..19e83ea8c41 100644
--- a/mysql-test/main/win.test
+++ b/mysql-test/main/win.test
@@ -2229,7 +2229,20 @@ SELECT DISTINCT MIN(b1) OVER () FROM t1;
drop table t1;
--echo #
---echo # Start of 10.3 tests
+--echo # MDEV-15424: Unreasonal SQL Error (1356) on select from view
+--echo #
+
+create table t1 (id int, n1 int);
+insert into t1 values (1,1), (2,1), (3,2), (4,4);
+
+create view v1 as SELECT ifnull(max(n1) over (partition by n1),'aaa') FROM t1;
+explain select * from v1;
+select * from v1;
+drop table t1;
+drop view v1;
+
+--echo #
+--echo # End of 10.2 tests
--echo #
--echo #
@@ -2247,6 +2260,10 @@ SELECT *, LEAD(d) OVER (ORDER BY d) AS x FROM t1;
DROP TABLE t1;
--echo #
+--echo # End of 10.3 tests
+--echo #
+
+--echo #
--echo # MDEV-16722: Assertion `type() != NULL_ITEM' failed
--echo #
diff --git a/mysql-test/std_data/mdev17909#P#p20181029.MYD b/mysql-test/std_data/mdev17909#P#p20181029.MYD
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/mysql-test/std_data/mdev17909#P#p20181029.MYD
diff --git a/mysql-test/std_data/mdev17909#P#p20181029.MYI b/mysql-test/std_data/mdev17909#P#p20181029.MYI
new file mode 100644
index 00000000000..dcdd088b4dc
--- /dev/null
+++ b/mysql-test/std_data/mdev17909#P#p20181029.MYI
Binary files differ
diff --git a/mysql-test/std_data/mdev17909#P#p20181128.MYD b/mysql-test/std_data/mdev17909#P#p20181128.MYD
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/mysql-test/std_data/mdev17909#P#p20181128.MYD
diff --git a/mysql-test/std_data/mdev17909#P#p20181128.MYI b/mysql-test/std_data/mdev17909#P#p20181128.MYI
new file mode 100644
index 00000000000..dcdd088b4dc
--- /dev/null
+++ b/mysql-test/std_data/mdev17909#P#p20181128.MYI
Binary files differ
diff --git a/mysql-test/std_data/mdev17909.frm b/mysql-test/std_data/mdev17909.frm
new file mode 100644
index 00000000000..575ecd2c70f
--- /dev/null
+++ b/mysql-test/std_data/mdev17909.frm
Binary files differ
diff --git a/mysql-test/std_data/mdev17909.par b/mysql-test/std_data/mdev17909.par
new file mode 100644
index 00000000000..d9141dd0dee
--- /dev/null
+++ b/mysql-test/std_data/mdev17909.par
Binary files differ
diff --git a/mysql-test/suite/encryption/r/innodb-bad-key-change.result b/mysql-test/suite/encryption/r/innodb-bad-key-change.result
index 179be43cc41..5812ff6dce9 100644
--- a/mysql-test/suite/encryption/r/innodb-bad-key-change.result
+++ b/mysql-test/suite/encryption/r/innodb-bad-key-change.result
@@ -3,6 +3,7 @@ call mtr.add_suppression("Plugin 'file_key_management' registration.*failed");
call mtr.add_suppression("InnoDB: Table `test`\\.`t[12]` (has an unreadable root page|is corrupted)");
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[12]\\.ibd' cannot be decrypted\\.");
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
+call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=3\\] in file .*test.t1.ibd looks corrupted; key_version=1");
call mtr.add_suppression("File '.*mysql-test.std_data.keysbad3\\.txt' not found");
# Start server with keys2.txt
SET GLOBAL innodb_file_per_table = ON;
diff --git a/mysql-test/suite/encryption/r/innodb-encryption-disable.result b/mysql-test/suite/encryption/r/innodb-encryption-disable.result
index d8d37ba7493..94b47103dd0 100644
--- a/mysql-test/suite/encryption/r/innodb-encryption-disable.result
+++ b/mysql-test/suite/encryption/r/innodb-encryption-disable.result
@@ -1,6 +1,7 @@
call mtr.add_suppression("InnoDB: Table `test`\\.`t[15]` (has an unreadable root page|is corrupted)");
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[15]\\.ibd' cannot be decrypted\\.");
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
+call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=3\\] in file .*test.t[15].ibd looks corrupted; key_version=1");
call mtr.add_suppression("Couldn't load plugins from 'file_key_management");
create table t5 (
`intcol1` int(32) DEFAULT NULL,
diff --git a/mysql-test/suite/encryption/r/innodb-missing-key.result b/mysql-test/suite/encryption/r/innodb-missing-key.result
index 32ae29ca76b..6f4a45d817a 100644
--- a/mysql-test/suite/encryption/r/innodb-missing-key.result
+++ b/mysql-test/suite/encryption/r/innodb-missing-key.result
@@ -1,6 +1,7 @@
call mtr.add_suppression("InnoDB: Table `test`\\.`t1` (has an unreadable root page|is corrupted)");
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\.");
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
+call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file .*test.t[12].ibd looks corrupted; key_version=1");
# Start server with keys2.txt
CREATE TABLE t1(a int not null primary key auto_increment, b varchar(128)) engine=innodb ENCRYPTED=YES ENCRYPTION_KEY_ID=19;
CREATE TABLE t2(a int not null primary key auto_increment, b varchar(128)) engine=innodb ENCRYPTED=YES ENCRYPTION_KEY_ID=1;
diff --git a/mysql-test/suite/encryption/t/innodb-bad-key-change.test b/mysql-test/suite/encryption/t/innodb-bad-key-change.test
index 5c424d8752b..a832880c494 100644
--- a/mysql-test/suite/encryption/t/innodb-bad-key-change.test
+++ b/mysql-test/suite/encryption/t/innodb-bad-key-change.test
@@ -13,6 +13,7 @@ call mtr.add_suppression("Plugin 'file_key_management' registration.*failed");
call mtr.add_suppression("InnoDB: Table `test`\\.`t[12]` (has an unreadable root page|is corrupted)");
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[12]\\.ibd' cannot be decrypted\\.");
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
+call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=3\\] in file .*test.t1.ibd looks corrupted; key_version=1");
call mtr.add_suppression("File '.*mysql-test.std_data.keysbad3\\.txt' not found");
--echo # Start server with keys2.txt
diff --git a/mysql-test/suite/encryption/t/innodb-encryption-disable.test b/mysql-test/suite/encryption/t/innodb-encryption-disable.test
index 0994078788e..6d6f1c40d4c 100644
--- a/mysql-test/suite/encryption/t/innodb-encryption-disable.test
+++ b/mysql-test/suite/encryption/t/innodb-encryption-disable.test
@@ -10,6 +10,7 @@
call mtr.add_suppression("InnoDB: Table `test`\\.`t[15]` (has an unreadable root page|is corrupted)");
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[15]\\.ibd' cannot be decrypted\\.");
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
+call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=3\\] in file .*test.t[15].ibd looks corrupted; key_version=1");
# Suppression for builds where file_key_management plugin is linked statically
call mtr.add_suppression("Couldn't load plugins from 'file_key_management");
diff --git a/mysql-test/suite/encryption/t/innodb-missing-key.test b/mysql-test/suite/encryption/t/innodb-missing-key.test
index cf851a54def..c2a73d594b4 100644
--- a/mysql-test/suite/encryption/t/innodb-missing-key.test
+++ b/mysql-test/suite/encryption/t/innodb-missing-key.test
@@ -10,6 +10,7 @@
call mtr.add_suppression("InnoDB: Table `test`\\.`t1` (has an unreadable root page|is corrupted)");
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\.");
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
+call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file .*test.t[12].ibd looks corrupted; key_version=1");
--echo # Start server with keys2.txt
-- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
diff --git a/mysql-test/suite/galera/r/galera_autoinc_sst_mariabackup.result b/mysql-test/suite/galera/r/galera_autoinc_sst_mariabackup.result
index d0fac1e3d14..91f45c93257 100644
--- a/mysql-test/suite/galera/r/galera_autoinc_sst_mariabackup.result
+++ b/mysql-test/suite/galera/r/galera_autoinc_sst_mariabackup.result
@@ -1,4 +1,6 @@
connection node_1;
+connection node_2;
+connection node_1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
CREATE PROCEDURE p1 ()
BEGIN
diff --git a/mysql-test/suite/galera/r/galera_ist_innodb_flush_logs.result b/mysql-test/suite/galera/r/galera_ist_innodb_flush_logs.result
new file mode 100644
index 00000000000..481a85711be
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_ist_innodb_flush_logs.result
@@ -0,0 +1,204 @@
+Performing State Transfer on a server that has been killed and restarted
+connection node_1;
+CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+COMMIT;
+connection node_2;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+COMMIT;
+Killing server ...
+connection node_1;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+COMMIT;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+connect node_1a_galera_st_kill_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+connection node_2;
+Performing --wsrep-recover ...
+Starting server ...
+Using --wsrep-start-position when starting mysqld ...
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+COMMIT;
+connection node_1;
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+COMMIT;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+COMMIT;
+connection node_1a_galera_st_kill_slave;
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+ROLLBACK;
+SELECT COUNT(*) = 35 FROM t1;
+COUNT(*) = 35
+1
+SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
+COUNT(*) = 0
+1
+COMMIT;
+SET AUTOCOMMIT=ON;
+connection node_1;
+SELECT COUNT(*) = 35 FROM t1;
+COUNT(*) = 35
+1
+SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
+COUNT(*) = 0
+1
+DROP TABLE t1;
+COMMIT;
+SET AUTOCOMMIT=ON;
+Performing State Transfer on a server that has been killed and restarted
+while a DDL was in progress on it
+connection node_1;
+CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+connection node_2;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+COMMIT;
+SET GLOBAL debug_dbug = 'd,sync.alter_opened_table';
+connection node_1;
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+connection node_2;
+SET wsrep_sync_wait = 0;
+Killing server ...
+connection node_1;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 (f1) VALUES ('node1_committed_during');
+INSERT INTO t1 (f1) VALUES ('node1_committed_during');
+INSERT INTO t1 (f1) VALUES ('node1_committed_during');
+INSERT INTO t1 (f1) VALUES ('node1_committed_during');
+INSERT INTO t1 (f1) VALUES ('node1_committed_during');
+COMMIT;
+START TRANSACTION;
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+connect node_1a_galera_st_kill_slave_ddl, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+connection node_2;
+Performing --wsrep-recover ...
+connection node_2;
+Starting server ...
+Using --wsrep-start-position when starting mysqld ...
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 (f1) VALUES ('node2_committed_after');
+INSERT INTO t1 (f1) VALUES ('node2_committed_after');
+INSERT INTO t1 (f1) VALUES ('node2_committed_after');
+INSERT INTO t1 (f1) VALUES ('node2_committed_after');
+INSERT INTO t1 (f1) VALUES ('node2_committed_after');
+COMMIT;
+connection node_1;
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+COMMIT;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 (f1) VALUES ('node1_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_committed_after');
+COMMIT;
+connection node_1a_galera_st_kill_slave_ddl;
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+ROLLBACK;
+SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
+COUNT(*) = 2
+1
+SELECT COUNT(*) = 35 FROM t1;
+COUNT(*) = 35
+1
+SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
+COUNT(*) = 0
+1
+COMMIT;
+SET AUTOCOMMIT=ON;
+connection node_1;
+SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
+COUNT(*) = 2
+1
+SELECT COUNT(*) = 35 FROM t1;
+COUNT(*) = 35
+1
+SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
+COUNT(*) = 0
+1
+DROP TABLE t1;
+COMMIT;
+SET AUTOCOMMIT=ON;
+SET GLOBAL debug_dbug = $debug_orig;
diff --git a/mysql-test/suite/galera/t/galera_autoinc_sst_mariabackup.cnf b/mysql-test/suite/galera/t/galera_autoinc_sst_mariabackup.cnf
index 7e557717744..bd6bf9d4f98 100644
--- a/mysql-test/suite/galera/t/galera_autoinc_sst_mariabackup.cnf
+++ b/mysql-test/suite/galera/t/galera_autoinc_sst_mariabackup.cnf
@@ -9,4 +9,3 @@ wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore
[mysqld.2]
wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true'
-
diff --git a/mysql-test/suite/galera/t/galera_autoinc_sst_mariabackup.test b/mysql-test/suite/galera/t/galera_autoinc_sst_mariabackup.test
index 731059dc584..9d5f821a170 100644
--- a/mysql-test/suite/galera/t/galera_autoinc_sst_mariabackup.test
+++ b/mysql-test/suite/galera/t/galera_autoinc_sst_mariabackup.test
@@ -8,6 +8,10 @@
--source include/have_innodb.inc
--source include/have_mariabackup.inc
+--let $node_1=node_1
+--let $node_2=node_2
+--source include/auto_increment_offset_save.inc
+
--connection node_1
--let $connection_id = `SELECT CONNECTION_ID()`
@@ -94,3 +98,7 @@ DROP TABLE t1;
CALL mtr.add_suppression("gcs_caused\\(\\) returned -1 \\(Operation not permitted\\)");
CALL mtr.add_suppression("WSREP: Action message in non-primary configuration from member 0");
+
+--let $node_1=node_1a
+--let $node_2=node_2a
+--source include/auto_increment_offset_restore.inc
diff --git a/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.cnf b/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.cnf
new file mode 100644
index 00000000000..7979b23e085
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.cnf
@@ -0,0 +1,13 @@
+!include ../galera_2nodes.cnf
+
+[mysqld]
+wsrep_sst_method=mariabackup
+wsrep_sst_auth=root:
+
+innodb_flush_log_at_trx_commit=0
+
+[mysqld.1]
+wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true'
+
+[mysqld.2]
+wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true'
diff --git a/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.test b/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.test
new file mode 100644
index 00000000000..fd362a26840
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.test
@@ -0,0 +1,13 @@
+#
+# This test performs server kill and IST while innodb_flush_logs_on_trx_commit = 0
+# This confirms that IST can properly catch up even in the face of relaxed single-node durability
+#
+#
+
+--source include/big_test.inc
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+--source include/have_mariabackup.inc
+
+--source suite/galera/include/galera_st_kill_slave.inc
+--source suite/galera/include/galera_st_kill_slave_ddl.inc
diff --git a/mysql-test/suite/galera/t/galera_ist_mariabackup_innodb_flush_logs.test b/mysql-test/suite/galera/t/galera_ist_mariabackup_innodb_flush_logs.test
index 07838702deb..fd362a26840 100644
--- a/mysql-test/suite/galera/t/galera_ist_mariabackup_innodb_flush_logs.test
+++ b/mysql-test/suite/galera/t/galera_ist_mariabackup_innodb_flush_logs.test
@@ -7,6 +7,7 @@
--source include/big_test.inc
--source include/galera_cluster.inc
--source include/have_innodb.inc
+--source include/have_mariabackup.inc
--source suite/galera/include/galera_st_kill_slave.inc
--source suite/galera/include/galera_st_kill_slave_ddl.inc
diff --git a/mysql-test/suite/innodb/disabled.def b/mysql-test/suite/innodb/disabled.def
index 35c941f8af7..aea780e26d8 100644
--- a/mysql-test/suite/innodb/disabled.def
+++ b/mysql-test/suite/innodb/disabled.def
@@ -11,3 +11,4 @@
##############################################################################
create-index-debug : MDEV-13680 InnoDB may crash when btr_page_alloc() fails
+alter_inplace_perfschema : MDEV-17748 nnodb.alter_inplace_perfschema fails in buildbot with wrong result
diff --git a/mysql-test/suite/innodb/include/crc32.pl b/mysql-test/suite/innodb/include/crc32.pl
new file mode 100644
index 00000000000..c2bce09dd36
--- /dev/null
+++ b/mysql-test/suite/innodb/include/crc32.pl
@@ -0,0 +1,33 @@
+# The following is Public Domain / Creative Commons CC0 from
+# http://billauer.co.il/blog/2011/05/perl-crc32-crc-xs-module/
+
+sub mycrc32 {
+ my ($input, $init_value, $polynomial) = @_;
+
+ $init_value = 0 unless (defined $init_value);
+ $polynomial = 0xedb88320 unless (defined $polynomial);
+
+ my @lookup_table;
+
+ for (my $i=0; $i<256; $i++) {
+ my $x = $i;
+ for (my $j=0; $j<8; $j++) {
+ if ($x & 1) {
+ $x = ($x >> 1) ^ $polynomial;
+ } else {
+ $x = $x >> 1;
+ }
+ }
+ push @lookup_table, $x;
+ }
+
+ my $crc = $init_value ^ 0xffffffff;
+
+ foreach my $x (unpack ('C*', $input)) {
+ $crc = (($crc >> 8) & 0xffffff) ^ $lookup_table[ ($crc ^ $x) & 0xff ];
+ }
+
+ $crc = $crc ^ 0xffffffff;
+
+ return $crc;
+}
diff --git a/mysql-test/suite/innodb/r/data_types.result b/mysql-test/suite/innodb/r/data_types.result
index 4e919e37cee..1394431b09d 100644
--- a/mysql-test/suite/innodb/r/data_types.result
+++ b/mysql-test/suite/innodb/r/data_types.result
@@ -77,7 +77,9 @@ t1_VARCHAR_500_BINARY VARCHAR(500) BINARY,
t1_YEAR_2 YEAR(2),
t1_YEAR_4 YEAR(4),
t1_CHAR_0 CHAR(0),
-t1_MYSQL_0 CHAR(0) CHARACTER SET utf8
+t1_MYSQL_0 CHAR(0) CHARACTER SET utf8,
+t1_VARCHAR_0 VARCHAR(0),
+t1_VARMYSQL_0 VARCHAR(0) CHARACTER SET utf8
) ENGINE=InnoDB;
Warnings:
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
@@ -151,10 +153,12 @@ t1_TINYINT DATA_INT
t1_TINYINT_UNSIGNED DATA_INT UNSIGNED
t1_TINYTEXT DATA_BLOB
t1_VARBINARY_100 DATA_BINARY
+t1_VARCHAR_0 DATA_VARCHAR
t1_VARCHAR_10 DATA_VARCHAR
t1_VARCHAR_10_BINARY DATA_VARMYSQL
t1_VARCHAR_500 DATA_VARCHAR
t1_VARCHAR_500_BINARY DATA_VARMYSQL
+t1_VARMYSQL_0 DATA_VARMYSQL
t1_YEAR_2 DATA_INT UNSIGNED
t1_YEAR_4 DATA_INT UNSIGNED
DROP TABLE t1;
@@ -164,3 +168,9 @@ DROP TABLE t1;
CREATE TABLE t1 (c CHAR(0), KEY(c)) ENGINE=InnoDB;
INSERT INTO t1 VALUES ('');
DROP TABLE t1;
+#
+# MDEV-18039 Assertion failed in btr_node_ptr_max_size for VARCHAR(0)
+#
+CREATE TABLE t1 (c VARCHAR(0), KEY(c)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES ('');
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/innodb-alter-debug.result b/mysql-test/suite/innodb/r/innodb-alter-debug.result
index 73037247272..51ba58aa1ef 100644
--- a/mysql-test/suite/innodb/r/innodb-alter-debug.result
+++ b/mysql-test/suite/innodb/r/innodb-alter-debug.result
@@ -75,3 +75,26 @@ connection default;
ERROR 23000: Duplicate entry '1' for key 'a'
SET DEBUG_SYNC='RESET';
DROP TABLE t1;
+#
+# MDEV-17470 Orphan temporary files after interrupted ALTER
+# cause InnoDB: Operating system error number 17 and eventual
+# fatal error 71
+#
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, i INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL,1),(NULL,2),(NULL,3),(NULL,4),(NULL,5),(NULL,6),(NULL,7),(NULL,8);
+INSERT INTO t1 SELECT NULL, i FROM t1;
+INSERT INTO t1 SELECT NULL, i FROM t1;
+INSERT INTO t1 SELECT NULL, i FROM t1;
+INSERT INTO t1 SELECT NULL, i FROM t1;
+INSERT INTO t1 SELECT NULL, i FROM t1;
+LOCK TABLE t1 READ;
+connect con1,localhost,root,,test;
+ALTER TABLE t1 FORCE, ALGORITHM=COPY;
+connection default;
+kill query @id;
+connection con1;
+ERROR 70100: Query execution was interrupted
+disconnect con1;
+connection default;
+UNLOCK TABLES;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/innodb-alter.result b/mysql-test/suite/innodb/r/innodb-alter.result
index 7b0a43297e0..d73bd154ee2 100644
--- a/mysql-test/suite/innodb/r/innodb-alter.result
+++ b/mysql-test/suite/innodb/r/innodb-alter.result
@@ -881,6 +881,27 @@ NAME
a
b
DROP TABLE t1;
+# and an MDEV-18041 regression related to indexes prefixes
+create table `test` (
+`test_old` varchar(255) NOT NULL,
+`other` varchar(255) NOT NULL,
+PRIMARY KEY (`test_old`,`other`),
+UNIQUE KEY uk (`test_old`(100), `other`)
+) ENGINE=InnoDB;
+select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new');
+name pos
+test_old 0
+other 1
+test_old 0
+other 1
+alter table `test` CHANGE COLUMN `test_old` `test_new` varchar(255) NOT NULL;
+select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new');
+name pos
+test_new 0
+other 1
+test_new 0
+other 1
+drop table `test`;
#
# BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN
# DICT_MEM_TABLE_COL_RENAME_LOW
diff --git a/mysql-test/suite/innodb/t/data_types.test b/mysql-test/suite/innodb/t/data_types.test
index c8e80c9db27..cfdd5201af2 100644
--- a/mysql-test/suite/innodb/t/data_types.test
+++ b/mysql-test/suite/innodb/t/data_types.test
@@ -90,7 +90,9 @@ CREATE TABLE t1
t1_YEAR_2 YEAR(2),
t1_YEAR_4 YEAR(4),
t1_CHAR_0 CHAR(0),
- t1_MYSQL_0 CHAR(0) CHARACTER SET utf8
+ t1_MYSQL_0 CHAR(0) CHARACTER SET utf8,
+ t1_VARCHAR_0 VARCHAR(0),
+ t1_VARMYSQL_0 VARCHAR(0) CHARACTER SET utf8
) ENGINE=InnoDB;
INSERT INTO t1 () VALUES ();
@@ -127,3 +129,10 @@ DROP TABLE t1;
CREATE TABLE t1 (c CHAR(0), KEY(c)) ENGINE=InnoDB;
INSERT INTO t1 VALUES ('');
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-18039 Assertion failed in btr_node_ptr_max_size for VARCHAR(0)
+--echo #
+CREATE TABLE t1 (c VARCHAR(0), KEY(c)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES ('');
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/innodb-alter-debug.test b/mysql-test/suite/innodb/t/innodb-alter-debug.test
index 5c8025265e5..00300bfdccc 100644
--- a/mysql-test/suite/innodb/t/innodb-alter-debug.test
+++ b/mysql-test/suite/innodb/t/innodb-alter-debug.test
@@ -98,5 +98,37 @@ SET DEBUG_SYNC='RESET';
DROP TABLE t1;
+--echo #
+--echo # MDEV-17470 Orphan temporary files after interrupted ALTER
+--echo # cause InnoDB: Operating system error number 17 and eventual
+--echo # fatal error 71
+--echo #
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, i INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL,1),(NULL,2),(NULL,3),(NULL,4),(NULL,5),(NULL,6),(NULL,7),(NULL,8);
+INSERT INTO t1 SELECT NULL, i FROM t1;
+INSERT INTO t1 SELECT NULL, i FROM t1;
+INSERT INTO t1 SELECT NULL, i FROM t1;
+INSERT INTO t1 SELECT NULL, i FROM t1;
+INSERT INTO t1 SELECT NULL, i FROM t1;
+
+LOCK TABLE t1 READ;
+
+--connect (con1,localhost,root,,test)
+let $ID= `SELECT @id := CONNECTION_ID()`;
+send ALTER TABLE t1 FORCE, ALGORITHM=COPY;
+
+--connection default
+let $wait_condition= select 1 from information_schema.processlist where state='Waiting for table metadata lock';
+source include/wait_condition.inc;
+let $ignore= `SELECT @id := $ID`;
+kill query @id;
+--connection con1
+--error ER_QUERY_INTERRUPTED
+reap;
+--disconnect con1
+--connection default
+UNLOCK TABLES;
+DROP TABLE t1;
+
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/innodb/t/innodb-alter.test b/mysql-test/suite/innodb/t/innodb-alter.test
index a7f1eb56dce..918972eed9f 100644
--- a/mysql-test/suite/innodb/t/innodb-alter.test
+++ b/mysql-test/suite/innodb/t/innodb-alter.test
@@ -545,6 +545,19 @@ SELECT C.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS C INNER JOIN
WHERE T.NAME='test/t1';
DROP TABLE t1;
+--echo # and an MDEV-18041 regression related to indexes prefixes
+create table `test` (
+ `test_old` varchar(255) NOT NULL,
+ `other` varchar(255) NOT NULL,
+ PRIMARY KEY (`test_old`,`other`),
+ UNIQUE KEY uk (`test_old`(100), `other`)
+) ENGINE=InnoDB;
+
+select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new');
+alter table `test` CHANGE COLUMN `test_old` `test_new` varchar(255) NOT NULL;
+select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new');
+drop table `test`;
+
--echo #
--echo # BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN
diff --git a/mysql-test/suite/mariabackup/encrypted_page_compressed.opt b/mysql-test/suite/mariabackup/encrypted_page_compressed.opt
new file mode 100644
index 00000000000..e5a02a1a1c9
--- /dev/null
+++ b/mysql-test/suite/mariabackup/encrypted_page_compressed.opt
@@ -0,0 +1,6 @@
+--innodb-encryption-rotate-key-age=2
+--innodb-encryption-threads=4
+--innodb-tablespaces-encryption
+--plugin-load-add=$FILE_KEY_MANAGEMENT_SO
+--loose-file-key-management
+--loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/logkey.txt
diff --git a/mysql-test/suite/mariabackup/encrypted_page_compressed.result b/mysql-test/suite/mariabackup/encrypted_page_compressed.result
new file mode 100644
index 00000000000..293addd2b03
--- /dev/null
+++ b/mysql-test/suite/mariabackup/encrypted_page_compressed.result
@@ -0,0 +1,7 @@
+call mtr.add_suppression("InnoDB: Table `test`.`t1` has an unreadable root page");
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, c char(200)) ENGINE=InnoDB page_compressed=yes encrypted=yes;
+insert into t1(b, c) values("mariadb", "mariabackup");
+# Corrupt the table
+# xtrabackup backup
+FOUND 1 /Database page corruption detected.*/ in backup.log
+drop table t1;
diff --git a/mysql-test/suite/mariabackup/encrypted_page_compressed.test b/mysql-test/suite/mariabackup/encrypted_page_compressed.test
new file mode 100644
index 00000000000..b4ca7eded14
--- /dev/null
+++ b/mysql-test/suite/mariabackup/encrypted_page_compressed.test
@@ -0,0 +1,48 @@
+source include/have_file_key_management.inc;
+call mtr.add_suppression("InnoDB: Table `test`.`t1` has an unreadable root page");
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, c char(200)) ENGINE=InnoDB page_compressed=yes encrypted=yes;
+insert into t1(b, c) values("mariadb", "mariabackup");
+
+let $MYSQLD_DATADIR=`select @@datadir`;
+let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd;
+let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
+
+--source include/shutdown_mysqld.inc
+
+--echo # Corrupt the table
+
+perl;
+use strict;
+use warnings;
+use Fcntl qw(:DEFAULT :seek);
+
+my $ibd_file = $ENV{'t1_IBD'};
+
+my $chunk;
+my $page_size = $ENV{'INNODB_PAGE_SIZE'};
+
+sysopen IBD_FILE, $ibd_file, O_RDWR || die "Unable to open $ibd_file";
+sysseek IBD_FILE, $page_size * 3 + 75, SEEK_CUR;
+$chunk = '\xAA\xAA\xAA\xAA';
+syswrite IBD_FILE, $chunk, 4;
+
+close IBD_FILE;
+EOF
+
+--source include/start_mysqld.inc
+
+echo # xtrabackup backup;
+--disable_result_log
+let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
+let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log;
+--error 1
+exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir > $backuplog;
+--enable_result_log
+
+--let SEARCH_PATTERN=Database page corruption detected.*
+--let SEARCH_FILE=$backuplog
+--source include/search_pattern_in_file.inc
+remove_file $backuplog;
+
+drop table t1;
+rmdir $targetdir;
diff --git a/mysql-test/suite/mariabackup/encrypted_page_corruption.result b/mysql-test/suite/mariabackup/encrypted_page_corruption.result
index 8ae34b2a6f0..9a6202a5ea1 100644
--- a/mysql-test/suite/mariabackup/encrypted_page_corruption.result
+++ b/mysql-test/suite/mariabackup/encrypted_page_corruption.result
@@ -1,8 +1,8 @@
-call mtr.add_suppression("\\[ERROR\\] InnoDB: The page .* in file .* cannot be decrypted.");
+call mtr.add_suppression("\\[ERROR\\] InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=3\\] in file '.*test.t1\\.ibd' cannot be decrypted.");
call mtr.add_suppression("\\[ERROR\\] InnoDB: Table `test`\\.`t1` has an unreadable root page");
CREATE TABLE t1(c VARCHAR(128)) ENGINE INNODB, encrypted=yes;
insert into t1 select repeat('a',100);
# Corrupt the table
# xtrabackup backup
-FOUND 1 /Database page corruption detected/ in backup.log
+FOUND 1 /Database page corruption detected.*/ in backup.log
drop table t1;
diff --git a/mysql-test/suite/mariabackup/encrypted_page_corruption.test b/mysql-test/suite/mariabackup/encrypted_page_corruption.test
index 923875275e6..4491c235ac4 100644
--- a/mysql-test/suite/mariabackup/encrypted_page_corruption.test
+++ b/mysql-test/suite/mariabackup/encrypted_page_corruption.test
@@ -1,12 +1,13 @@
--source include/have_file_key_management.inc
+--source include/innodb_page_size.inc
-call mtr.add_suppression("\\[ERROR\\] InnoDB: The page .* in file .* cannot be decrypted.");
+call mtr.add_suppression("\\[ERROR\\] InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=3\\] in file '.*test.t1\\.ibd' cannot be decrypted.");
call mtr.add_suppression("\\[ERROR\\] InnoDB: Table `test`\\.`t1` has an unreadable root page");
CREATE TABLE t1(c VARCHAR(128)) ENGINE INNODB, encrypted=yes;
insert into t1 select repeat('a',100);
-let $MYSQLD_DATADIR=`select @@datadir`;
-let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd;
+let MYSQLD_DATADIR=`select @@datadir`;
+let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
--source include/shutdown_mysqld.inc
@@ -16,17 +17,29 @@ perl;
use strict;
use warnings;
use Fcntl qw(:DEFAULT :seek);
+do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl";
-my $ibd_file = $ENV{'t1_IBD'};
+my $page_size = $ENV{INNODB_PAGE_SIZE};
-my $chunk;
-my $len;
+sysopen IBD_FILE, "$ENV{MYSQLD_DATADIR}/test/t1.ibd", O_RDWR
+|| die "Cannot open t1.ibd\n";
+sysread(IBD_FILE, $_, 38) || die "Cannot read t1.ibd\n";
+my $space = unpack("x[34]N", $_);
+sysseek(IBD_FILE, $page_size * 3, SEEK_SET) || die "Cannot seek t1.ibd\n";
-sysopen IBD_FILE, $ibd_file, O_RDWR || die "Unable to open $ibd_file";
-sysseek IBD_FILE, 16384 * 3, SEEK_CUR;
-$chunk = '\xAA\xAA\xAA\xAA';
-syswrite IBD_FILE, $chunk, 4;
+my $head = pack("Nx[18]", 3); # better to have a valid page number
+my $body = chr(0) x ($page_size - 38 - 8);
+# Calculate innodb_checksum_algorithm=crc32 for the unencrypted page.
+# The following bytes are excluded:
+# bytes 0..3 (the checksum is stored there)
+# bytes 26..37 (encryption key version, post-encryption checksum, tablespace id)
+# bytes $page_size-8..$page_size-1 (checksum, LSB of FIL_PAGE_LSN)
+my $polynomial = 0x82f63b78; # CRC-32C
+my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial);
+
+my $page= pack("N",$ck).$head.pack("NNN",1,$ck,$space).$body.pack("Nx[4]",$ck);
+die unless syswrite(IBD_FILE, $page, $page_size) == $page_size;
close IBD_FILE;
EOF
@@ -38,14 +51,20 @@ let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log;
--disable_result_log
--error 1
-exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir > $backuplog;
+exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --extended-validation --target-dir=$targetdir > $backuplog;
--enable_result_log
---let SEARCH_PATTERN=Database page corruption detected
+--let SEARCH_PATTERN=Database page corruption detected.*
--let SEARCH_FILE=$backuplog
--source include/search_pattern_in_file.inc
remove_file $backuplog;
+rmdir $targetdir;
+
+# Due to very constructed nature of the "corruption" (faking checksums), the "corruption" won't be found without --extended-validation
+--disable_result_log
+exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir;
+--enable_result_log
drop table t1;
rmdir $targetdir;
diff --git a/mysql-test/suite/mariabackup/huge_lsn.opt b/mysql-test/suite/mariabackup/huge_lsn.opt
index 74a6450a1ef..c65b76fb7d2 100644
--- a/mysql-test/suite/mariabackup/huge_lsn.opt
+++ b/mysql-test/suite/mariabackup/huge_lsn.opt
@@ -1,4 +1,8 @@
--innodb-encrypt-log=ON
+--innodb-tablespaces-encryption
+--innodb-encrypt-tables=ON
+--innodb-encryption-rotate-key-age=1
+--innodb-encryption-threads=4
--plugin-load-add=$FILE_KEY_MANAGEMENT_SO
--loose-file-key-management
--loose-file-key-management-filekey=FILE:$MTR_SUITE_DIR/filekeys-data.key
diff --git a/mysql-test/suite/mariabackup/partition_partial.opt b/mysql-test/suite/mariabackup/partition_partial.opt
new file mode 100644
index 00000000000..508cf185695
--- /dev/null
+++ b/mysql-test/suite/mariabackup/partition_partial.opt
@@ -0,0 +1 @@
+--innodb --loose-partition
diff --git a/mysql-test/suite/mariabackup/partition_partial.result b/mysql-test/suite/mariabackup/partition_partial.result
new file mode 100644
index 00000000000..62b7adf75f8
--- /dev/null
+++ b/mysql-test/suite/mariabackup/partition_partial.result
@@ -0,0 +1,31 @@
+CREATE TABLE t1(i INT) ENGINE INNODB
+PARTITION BY RANGE (i)
+(PARTITION p1 VALUES LESS THAN (100),
+PARTITION p2 VALUES LESS THAN (200),
+PARTITION p3 VALUES LESS THAN (300),
+PARTITION p4 VALUES LESS THAN (400));
+INSERT INTO t1 VALUES (1), (101), (201), (301);
+# xtrabackup backup
+INSERT INTO t1 VALUES (1), (101), (201), (301);
+# xtrabackup prepare
+CREATE TABLE t1_placeholder (i INT) ENGINE INNODB;
+ALTER TABLE t1_placeholder DISCARD TABLESPACE;
+ALTER TABLE t1_placeholder IMPORT TABLESPACE;
+ALTER TABLE t1 EXCHANGE PARTITION p4 WITH TABLE t1_placeholder;
+ALTER TABLE t1_placeholder DISCARD TABLESPACE;
+ALTER TABLE t1_placeholder IMPORT TABLESPACE;
+ALTER TABLE t1 EXCHANGE PARTITION p3 WITH TABLE t1_placeholder;
+ALTER TABLE t1_placeholder DISCARD TABLESPACE;
+ALTER TABLE t1_placeholder IMPORT TABLESPACE;
+ALTER TABLE t1 EXCHANGE PARTITION p2 WITH TABLE t1_placeholder;
+ALTER TABLE t1_placeholder DISCARD TABLESPACE;
+ALTER TABLE t1_placeholder IMPORT TABLESPACE;
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t1_placeholder;
+SELECT * FROM t1;
+i
+1
+101
+201
+301
+DROP TABLE t1;
+DROP TABLE t1_placeholder;
diff --git a/mysql-test/suite/mariabackup/partition_partial.test b/mysql-test/suite/mariabackup/partition_partial.test
new file mode 100644
index 00000000000..8e288ec997f
--- /dev/null
+++ b/mysql-test/suite/mariabackup/partition_partial.test
@@ -0,0 +1,44 @@
+#--source include/innodb_page_size.inc
+
+# import partitioned table from table from partial backup
+
+CREATE TABLE t1(i INT) ENGINE INNODB
+PARTITION BY RANGE (i)
+(PARTITION p1 VALUES LESS THAN (100),
+ PARTITION p2 VALUES LESS THAN (200),
+ PARTITION p3 VALUES LESS THAN (300),
+ PARTITION p4 VALUES LESS THAN (400));
+
+INSERT INTO t1 VALUES (1), (101), (201), (301);
+
+echo # xtrabackup backup;
+
+let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
+--disable_result_log
+exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup "--tables=test.t1" --target-dir=$targetdir;
+--enable_result_log
+INSERT INTO t1 VALUES (1), (101), (201), (301);
+
+
+echo # xtrabackup prepare;
+--disable_result_log
+exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.1 --prepare --export --target-dir=$targetdir;
+--enable_result_log
+
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+CREATE TABLE t1_placeholder (i INT) ENGINE INNODB;
+let $i=4;
+while($i)
+{
+ eval ALTER TABLE t1_placeholder DISCARD TABLESPACE;
+ copy_file $targetdir/test/t1#P#p$i.cfg $MYSQLD_DATADIR/test/t1_placeholder.cfg;
+ copy_file $targetdir/test/t1#P#p$i.ibd $MYSQLD_DATADIR/test/t1_placeholder.ibd;
+ eval ALTER TABLE t1_placeholder IMPORT TABLESPACE;
+ eval ALTER TABLE t1 EXCHANGE PARTITION p$i WITH TABLE t1_placeholder;
+ dec $i;
+}
+SELECT * FROM t1;
+DROP TABLE t1;
+DROP TABLE t1_placeholder;
+rmdir $targetdir;
diff --git a/mysql-test/suite/mariabackup/unencrypted_page_compressed.result b/mysql-test/suite/mariabackup/unencrypted_page_compressed.result
new file mode 100644
index 00000000000..71eac085769
--- /dev/null
+++ b/mysql-test/suite/mariabackup/unencrypted_page_compressed.result
@@ -0,0 +1,11 @@
+call mtr.add_suppression("InnoDB: Table `test`.`t1` has an unreadable root page");
+SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, c char(200)) ENGINE=InnoDB page_compressed=yes;
+insert into t1(b, c) values("mariadb", "mariabackup");
+InnoDB 0 transactions not purged
+# Corrupt the table
+# xtrabackup backup
+FOUND 1 /Database page corruption detected.*/ in backup.log
+drop table t1;
+Warnings:
+Warning 192 Table test/t1 in file ./test/t1.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table.
diff --git a/mysql-test/suite/mariabackup/unencrypted_page_compressed.test b/mysql-test/suite/mariabackup/unencrypted_page_compressed.test
new file mode 100644
index 00000000000..b41d177e572
--- /dev/null
+++ b/mysql-test/suite/mariabackup/unencrypted_page_compressed.test
@@ -0,0 +1,50 @@
+call mtr.add_suppression("InnoDB: Table `test`.`t1` has an unreadable root page");
+SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, c char(200)) ENGINE=InnoDB page_compressed=yes;
+insert into t1(b, c) values("mariadb", "mariabackup");
+--source ../innodb/include/wait_all_purged.inc
+
+let $MYSQLD_DATADIR=`select @@datadir`;
+let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd;
+let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
+
+--source include/shutdown_mysqld.inc
+
+--echo # Corrupt the table
+
+perl;
+use strict;
+use warnings;
+use Fcntl qw(:DEFAULT :seek);
+
+my $ibd_file = $ENV{'t1_IBD'};
+
+my $chunk;
+my $page_size = $ENV{'INNODB_PAGE_SIZE'};
+
+sysopen IBD_FILE, $ibd_file, O_RDWR || die "Unable to open $ibd_file";
+sysseek IBD_FILE, 16384 * 3 + 75, SEEK_CUR;
+$chunk = '\xAA\xAA\xAA\xAA';
+syswrite IBD_FILE, $chunk, 4;
+
+close IBD_FILE;
+EOF
+
+--let $restart_parameters= --skip-innodb-buffer-pool-load-at-startup
+--source include/start_mysqld.inc
+
+echo # xtrabackup backup;
+--disable_result_log
+let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
+let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log;
+--error 1
+exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir > $backuplog;
+--enable_result_log
+
+--let SEARCH_PATTERN=Database page corruption detected.*
+--let SEARCH_FILE=$backuplog
+--source include/search_pattern_in_file.inc
+remove_file $backuplog;
+
+drop table t1;
+rmdir $targetdir;
diff --git a/mysql-test/suite/rpl/r/rpl_idempotency.result b/mysql-test/suite/rpl/r/rpl_idempotency.result
index a9485ca8933..09e084ce448 100644
--- a/mysql-test/suite/rpl/r/rpl_idempotency.result
+++ b/mysql-test/suite/rpl/r/rpl_idempotency.result
@@ -79,8 +79,25 @@ a
-3
1
include/check_slave_no_error.inc
+connection slave;
+drop table t1, t2;
connection master;
DROP TABLE t1, t2;
connection slave;
+include/check_slave_no_error.inc
+create database d;
+create database e;
+connection master;
+create database d;
+create database if not exists e;
+connection slave;
+include/check_slave_no_error.inc
+drop database d;
+drop database e;
+connection master;
+drop database d;
+drop database if exists e;
+connection slave;
+include/check_slave_no_error.inc
SET @@global.slave_exec_mode= @old_slave_exec_mode;
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_idempotency.test b/mysql-test/suite/rpl/t/rpl_idempotency.test
index fcfe6f65e6d..12dec236d45 100644
--- a/mysql-test/suite/rpl/t/rpl_idempotency.test
+++ b/mysql-test/suite/rpl/t/rpl_idempotency.test
@@ -77,9 +77,30 @@ SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;
--source include/check_slave_no_error.inc
+connection slave;
+drop table t1, t2;
+
connection master;
DROP TABLE t1, t2;
sync_slave_with_master;
+--source include/check_slave_no_error.inc
+create database d;
+create database e;
+
+connection master;
+create database d;
+create database if not exists e;
+
+sync_slave_with_master;
+--source include/check_slave_no_error.inc
+drop database d;
+drop database e;
+
+connection master;
+drop database d;
+drop database if exists e;
+sync_slave_with_master;
+--source include/check_slave_no_error.inc
SET @@global.slave_exec_mode= @old_slave_exec_mode;
diff --git a/mysql-test/suite/storage_engine/type_bool.result b/mysql-test/suite/storage_engine/type_bool.result
index 87308ed63fc..10cfc08102f 100644
--- a/mysql-test/suite/storage_engine/type_bool.result
+++ b/mysql-test/suite/storage_engine/type_bool.result
@@ -42,8 +42,8 @@ b1 b2
0 0
INSERT INTO t1 (b1,b2) VALUES ('a','b');
Warnings:
-Warning 1366 Incorrect integer value: 'a' for column 'b1' at row 1
-Warning 1366 Incorrect integer value: 'b' for column 'b2' at row 1
+Warning 1366 Incorrect integer value: 'a' for column `test`.`t1`.`b1` at row 1
+Warning 1366 Incorrect integer value: 'b' for column `test`.`t1`.`b2` at row 1
SELECT b1,b2 FROM t1;
b1 b2
-1 -2
diff --git a/mysql-test/suite/sys_vars/r/wsrep_sst_method_basic.result b/mysql-test/suite/sys_vars/r/wsrep_sst_method_basic.result
index cbdac640c36..51f167b8f47 100644
--- a/mysql-test/suite/sys_vars/r/wsrep_sst_method_basic.result
+++ b/mysql-test/suite/sys_vars/r/wsrep_sst_method_basic.result
@@ -33,6 +33,10 @@ SET @@global.wsrep_sst_method="xtrabackup-v2";
SELECT @@global.wsrep_sst_method;
@@global.wsrep_sst_method
xtrabackup-v2
+SET @@global.wsrep_sst_method="mariabackup";
+SELECT @@global.wsrep_sst_method;
+@@global.wsrep_sst_method
+mariabackup
SET @@global.wsrep_sst_method=default;
SELECT @@global.wsrep_sst_method;
@@global.wsrep_sst_method
diff --git a/mysql-test/suite/sys_vars/t/wsrep_sst_method_basic.test b/mysql-test/suite/sys_vars/t/wsrep_sst_method_basic.test
index 3f40a3922dd..be038eb4baf 100644
--- a/mysql-test/suite/sys_vars/t/wsrep_sst_method_basic.test
+++ b/mysql-test/suite/sys_vars/t/wsrep_sst_method_basic.test
@@ -23,10 +23,15 @@ SET @@global.wsrep_sst_method=rsync;
SELECT @@global.wsrep_sst_method;
SET @@global.wsrep_sst_method=mysqldump;
SELECT @@global.wsrep_sst_method;
+# The xtrabackup and xtrabackup-v2 methods are obsolete,
+# but we can still select them (they will be automatically
+# replaced to mariabackup):
SET @@global.wsrep_sst_method=xtrabackup;
SELECT @@global.wsrep_sst_method;
SET @@global.wsrep_sst_method="xtrabackup-v2";
SELECT @@global.wsrep_sst_method;
+SET @@global.wsrep_sst_method="mariabackup";
+SELECT @@global.wsrep_sst_method;
SET @@global.wsrep_sst_method=default;
SELECT @@global.wsrep_sst_method;
diff --git a/mysql-test/suite/vcol/r/upgrade.result b/mysql-test/suite/vcol/r/upgrade.result
index 75684bf0e41..527bc5f3abf 100644
--- a/mysql-test/suite/vcol/r/upgrade.result
+++ b/mysql-test/suite/vcol/r/upgrade.result
@@ -16,3 +16,19 @@ select * from vcol_autoinc;
pk v3
1 1
drop table vcol_autoinc;
+check table t1 for upgrade;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+flush tables;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `Date` datetime(6) NOT NULL,
+ `Data` varbinary(2000) NOT NULL,
+ `a` varchar(100) GENERATED ALWAYS AS (column_get(`Data`,1 as char(100) charset latin1)) VIRTUAL,
+ PRIMARY KEY (`Date`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+ PARTITION BY RANGE (to_days(`Date`))
+(PARTITION `p20181029` VALUES LESS THAN (737361) ENGINE = MyISAM,
+ PARTITION `p20181128` VALUES LESS THAN (737391) ENGINE = MyISAM)
+drop table t1;
diff --git a/mysql-test/suite/vcol/t/upgrade.test b/mysql-test/suite/vcol/t/upgrade.test
index 3e221747dfa..146495d8ed0 100644
--- a/mysql-test/suite/vcol/t/upgrade.test
+++ b/mysql-test/suite/vcol/t/upgrade.test
@@ -11,3 +11,18 @@ select * from vcol_autoinc;
insert vcol_autoinc (pk) values (1);
select * from vcol_autoinc;
drop table vcol_autoinc;
+
+#
+# MDEV-17909 Problem by MariaDB Update 10.1.32 -> 10.2.19 (Incorrect information in file: .frm)
+#
+source include/have_partition.inc;
+copy_file std_data/mdev17909#P#p20181029.MYD $datadir/test/t1#P#p20181029.MYD;
+copy_file std_data/mdev17909#P#p20181029.MYI $datadir/test/t1#P#p20181029.MYI;
+copy_file std_data/mdev17909#P#p20181128.MYD $datadir/test/t1#P#p20181128.MYD;
+copy_file std_data/mdev17909#P#p20181128.MYI $datadir/test/t1#P#p20181128.MYI;
+copy_file std_data/mdev17909.frm $datadir/test/t1.frm;
+copy_file std_data/mdev17909.par $datadir/test/t1.par;
+check table t1 for upgrade;
+flush tables;
+show create table t1;
+drop table t1;
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index fcb13be5c25..eca5b7ad3e5 100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -274,8 +274,6 @@ ELSE()
SET(WSREP_SCRIPTS
wsrep_sst_mysqldump
wsrep_sst_rsync
- wsrep_sst_xtrabackup
- wsrep_sst_xtrabackup-v2
wsrep_sst_mariabackup
)
# The following script is sourced from other SST scripts, so it should
diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh
deleted file mode 100644
index 2de384806b2..00000000000
--- a/scripts/wsrep_sst_xtrabackup-v2.sh
+++ /dev/null
@@ -1,1260 +0,0 @@
-#!/bin/bash -ue
-# Copyright (C) 2013 Percona Inc
-#
-# 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; see the file COPYING. If not, write to the
-# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
-# MA 02110-1301 USA.
-
-# Documentation: http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
-# Make sure to read that before proceeding!
-
-
-
-
-. $(dirname $0)/wsrep_sst_common
-
-ealgo=""
-ekey=""
-ekeyfile=""
-encrypt=0
-nproc=1
-ecode=0
-ssyslog=""
-ssystag=""
-XTRABACKUP_PID=""
-tca=""
-tcert=""
-tkey=""
-sockopt=""
-progress=""
-ttime=0
-totime=0
-ecmd=""
-rlimit=""
-# Initially
-stagemsg="${WSREP_SST_OPT_ROLE}"
-cpat=""
-ib_home_dir=""
-ib_log_dir=""
-ib_undo_dir=""
-
-sfmt="tar"
-strmcmd=""
-tfmt=""
-tcmd=""
-rebuild=0
-rebuildcmd=""
-payload=0
-pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' "
-pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE "
-STATDIR=""
-uextra=0
-disver=""
-
-tmpopts=""
-itmpdir=""
-xtmpdir=""
-
-scomp=""
-sdecomp=""
-ssl_dhparams=""
-
-ssl_cert=""
-ssl_ca=""
-ssl_key=""
-
-if pv --help 2>/dev/null | grep -q FORMAT;then
- pvopts+=$pvformat
-fi
-pcmd="pv $pvopts"
-declare -a RC
-
-INNOBACKUPEX_BIN=innobackupex
-DATA="${WSREP_SST_OPT_DATA}"
-INFO_FILE="xtrabackup_galera_info"
-IST_FILE="xtrabackup_ist"
-MAGIC_FILE="${DATA}/${INFO_FILE}"
-
-# Setting the path for ss and ip
-export PATH="/usr/sbin:/sbin:$PATH"
-
-OS=$(uname)
-
-if ! which lsof > /dev/null; then
- wsrep_log_error "lsof tool not found in PATH! Make sure you have it installed."
- exit 2 # ENOENT
-fi
-
-timeit(){
- local stage=$1
- shift
- local cmd="$@"
- local x1 x2 took extcode
-
- if [[ $ttime -eq 1 ]];then
- x1=$(date +%s)
- wsrep_log_info "Evaluating $cmd"
- eval "$cmd"
- extcode=$?
- x2=$(date +%s)
- took=$(( x2-x1 ))
- wsrep_log_info "NOTE: $stage took $took seconds"
- totime=$(( totime+took ))
- else
- wsrep_log_info "Evaluating $cmd"
- eval "$cmd"
- extcode=$?
- fi
- return $extcode
-}
-
-get_keys()
-{
- # $encrypt -eq 1 is for internal purposes only
- if [[ $encrypt -ge 2 || $encrypt -eq -1 ]];then
- return
- fi
-
- if [[ $encrypt -eq 0 ]];then
- if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then
- wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html "
- fi
- return
- fi
-
- if [[ $sfmt == 'tar' ]];then
- wsrep_log_info "NOTE: Xtrabackup-based encryption - encrypt=1 - cannot be enabled with tar format"
- encrypt=-1
- return
- fi
-
- wsrep_log_info "Xtrabackup based encryption enabled in my.cnf - Supported only from Xtrabackup 2.1.4"
-
- if [[ -z $ealgo ]];then
- wsrep_log_error "FATAL: Encryption algorithm empty from my.cnf, bailing out"
- exit 3
- fi
-
- if [[ -z $ekey && ! -r $ekeyfile ]];then
- wsrep_log_error "FATAL: Either key or keyfile must be readable"
- exit 3
- fi
-
- if [[ -z $ekey ]];then
- ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key-file=$ekeyfile"
- else
- wsrep_log_warning "Using the 'encrypt-key' option causes the encryption key"
- wsrep_log_warning "to be set via the command-line and is considered insecure."
- wsrep_log_warning "It is recommended to use the 'encrypt-key-file' option instead."
-
- ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key=$ekey"
- fi
-
- if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- ecmd+=" -d"
- fi
-
- stagemsg+="-XB-Encrypted"
-}
-
-#
-# If the ssl_dhparams variable is already set, uses that as a source
-# of dh parameters for OpenSSL. Otherwise, looks for dhparams.pem in the
-# datadir, and creates it there if it can't find the file.
-# No input parameters
-#
-check_for_dhparams()
-{
- if [[ -z "$ssl_dhparams" ]]; then
- if ! [[ -r "$DATA/dhparams.pem" ]]; then
- wsrep_check_programs openssl
- wsrep_log_info "Could not find dhparams file, creating $DATA/dhparams.pem"
-
- if ! openssl dhparam -out "$DATA/dhparams.pem" 2048 >/dev/null 2>&1
- then
- wsrep_log_error "******** FATAL ERROR ********************************* "
- wsrep_log_error "* Could not create the dhparams.pem file with OpenSSL. "
- wsrep_log_error "****************************************************** "
- exit 22
- fi
- fi
- ssl_dhparams="$DATA/dhparams.pem"
- fi
-}
-
-#
-# verifies that the certificate matches the private key
-# doing this will save us having to wait for a timeout that would
-# otherwise occur.
-#
-# 1st param: path to the cert
-# 2nd param: path to the private key
-#
-verify_cert_matches_key()
-{
- local cert_path=$1
- local key_path=$2
-
- wsrep_check_programs openssl diff
-
- # generate the public key from the cert and the key
- # they should match (otherwise we can't create an SSL connection)
- if ! diff <(openssl x509 -in "$cert_path" -pubkey -noout) <(openssl rsa -in "$key_path" -pubout 2>/dev/null) >/dev/null 2>&1
- then
- wsrep_log_error "******** FATAL ERROR ************************* "
- wsrep_log_error "* The certifcate and private key do not match. "
- wsrep_log_error "* Please check your certificate and key files. "
- wsrep_log_error "********************************************** "
- exit 22
- fi
-}
-
-# Checks to see if the file exists
-# If the file does not exist (or cannot be read), issues an error
-# and exits
-#
-# 1st param: file name to be checked (for read access)
-# 2nd param: 1st error message (header)
-# 3rd param: 2nd error message (footer, optional)
-#
-verify_file_exists()
-{
- local file_path=$1
- local error_message1=$2
- local error_message2=$3
-
- if ! [[ -r "$file_path" ]]; then
- wsrep_log_error "******** FATAL ERROR ************************* "
- wsrep_log_error "* $error_message1 "
- wsrep_log_error "* Could not find/access : $file_path "
-
- if ! [[ -z "$error_message2" ]]; then
- wsrep_log_error "* $error_message2 "
- fi
-
- wsrep_log_error "********************************************** "
- exit 22
- fi
-}
-
-get_transfer()
-{
- TSST_PORT=${WSREP_SST_OPT_PORT:-4444}
-
- if [[ $tfmt == 'nc' ]];then
- wsrep_check_programs nc
-
- if [[ $encrypt -eq 2 || $encrypt -eq 3 || $encrypt -eq 4 ]]; then
- wsrep_log_error "******** FATAL ERROR *********************** "
- wsrep_log_error "* Using SSL encryption (encrypt= 2, 3, or 4) "
- wsrep_log_error "* is not supported when using nc(netcat). "
- wsrep_log_error "******************************************** "
- exit 22
- fi
-
- wsrep_log_info "Using netcat as streamer"
- if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- if nc -h 2>&1 | grep -q ncat; then
- # Ncat
- tcmd="nc $sockopt -l ${TSST_PORT}"
- elif nc -h 2>&1 | grep -q -- '-d\>';then
- # Debian netcat
- tcmd="nc $sockopt -dl ${TSST_PORT}"
- else
- # traditional netcat
- tcmd="nc $sockopt -l -p ${TSST_PORT}"
- fi
- else
- if nc -h 2>&1 | grep -q ncat;then
- # Ncat
- tcmd="nc ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}"
- elif nc -h 2>&1 | grep -q -- '-d\>';then
- # Debian netcat
- tcmd="nc ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}"
- else
- # traditional netcat
- tcmd="nc -q0 ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}"
- fi
- fi
- else
- tfmt='socat'
- wsrep_log_info "Using socat as streamer"
- wsrep_check_programs socat
-
- donor_extra=""
- joiner_extra=""
- if [[ $encrypt -eq 2 || $encrypt -eq 3 || $encrypt -eq 4 ]]; then
- if ! socat -V | grep -q WITH_OPENSSL; then
- wsrep_log_error "******** FATAL ERROR ****************** "
- wsrep_log_error "* socat is not openssl enabled. "
- wsrep_log_error "* Unable to encrypt SST communications. "
- wsrep_log_error "*************************************** "
- exit 2
- fi
-
- # Determine the socat version
- SOCAT_VERSION=`socat -V 2>&1 | grep -oe '[0-9]\.[0-9][\.0-9]*' | head -n1`
- if [[ -z "$SOCAT_VERSION" ]]; then
- wsrep_log_error "******** FATAL ERROR **************** "
- wsrep_log_error "* Cannot determine the socat version. "
- wsrep_log_error "************************************* "
- exit 2
- fi
-
- # socat versions < 1.7.3 will have 512-bit dhparams (too small)
- # so create 2048-bit dhparams and send that as a parameter
- # socat version >= 1.7.3, checks to see if the peername matches the hostname
- # set commonname="" to disable the peername checks
- #
- if ! check_for_version "$SOCAT_VERSION" "1.7.3"; then
- if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]]; then
- # dhparams check (will create ssl_dhparams if needed)
- check_for_dhparams
- joiner_extra=",dhparam=$ssl_dhparams"
- fi
- fi
- if check_for_version "$SOCAT_VERSION" "1.7.3"; then
- donor_extra=',commonname=""'
- fi
- fi
-
- if [[ $encrypt -eq 2 ]]; then
- wsrep_log_warning "**** WARNING **** encrypt=2 is deprecated and will be removed in a future release"
- wsrep_log_info "Using openssl based encryption with socat: with crt and ca"
-
- verify_file_exists "$tcert" "Both certificate and CA files are required." \
- "Please check the 'tcert' option. "
- verify_file_exists "$tca" "Both certificate and CA files are required." \
- "Please check the 'tca' option. "
-
- stagemsg+="-OpenSSL-Encrypted-2"
- if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- wsrep_log_info "Decrypting with CERT: $tcert, CA: $tca"
- tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tcert},cafile=${tca}${joiner_extra}${sockopt} stdio"
- else
- wsrep_log_info "Encrypting with CERT: $tcert, CA: $tca"
- tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=${tcert},cafile=${tca}${donor_extra}${sockopt}"
- fi
- elif [[ $encrypt -eq 3 ]];then
- wsrep_log_warning "**** WARNING **** encrypt=3 is deprecated and will be removed in a future release"
- wsrep_log_info "Using openssl based encryption with socat: with key and crt"
-
- verify_file_exists "$tcert" "Both certificate and key files are required." \
- "Please check the 'tcert' option. "
- verify_file_exists "$tkey" "Both certificate and key files are required." \
- "Please check the 'tkey' option. "
-
- stagemsg+="-OpenSSL-Encrypted-3"
- if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- wsrep_log_info "Decrypting with CERT: $tcert, KEY: $tkey"
- tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tcert},key=${tkey},verify=0${joiner_extra}${sockopt} stdio"
- else
- wsrep_log_info "Encrypting with CERT: $tcert, KEY: $tkey"
- tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=${tcert},key=${tkey},verify=0${sockopt}"
- fi
- elif [[ $encrypt -eq 4 ]]; then
- wsrep_log_info "Using openssl based encryption with socat: with key, crt, and ca"
-
- verify_file_exists "$ssl_ca" "CA, certificate, and key files are required." \
- "Please check the 'ssl-ca' option. "
- verify_file_exists "$ssl_cert" "CA, certificate, and key files are required." \
- "Please check the 'ssl-cert' option. "
- verify_file_exists "$ssl_key" "CA, certificate, and key files are required." \
- "Please check the 'ssl-key' option. "
-
- # Check to see that the key matches the cert
- verify_cert_matches_key $ssl_cert $ssl_key
-
- stagemsg+="-OpenSSL-Encrypted-4"
- if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]]; then
- wsrep_log_info "Decrypting with CERT: $ssl_cert, KEY: $ssl_key, CA: $ssl_ca"
- tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${ssl_cert},key=${ssl_key},cafile=${ssl_ca},verify=1${joiner_extra}${sockopt} stdio"
- else
- wsrep_log_info "Encrypting with CERT: $ssl_cert, KEY: $ssl_key, CA: $ssl_ca"
- tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=${ssl_cert},key=${ssl_key},cafile=${ssl_ca},verify=1${donor_extra}${sockopt}"
- fi
-
- else
- if [[ $encrypt -eq 1 ]]; then
- wsrep_log_warning "**** WARNING **** encrypt=1 is deprecated and will be removed in a future release"
- fi
-
- if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]]; then
- tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio"
- else
- tcmd="socat -u stdio TCP:${WSREP_SST_OPT_HOST}:${TSST_PORT}${sockopt}"
- fi
- fi
- fi
-}
-
-get_footprint()
-{
- pushd $WSREP_SST_OPT_DATA 1>/dev/null
- payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c -s | awk 'END { print $1 }')
- if $MY_PRINT_DEFAULTS xtrabackup | grep -q -- "--compress";then
- # QuickLZ has around 50% compression ratio
- # When compression/compaction used, the progress is only an approximate.
- payload=$(( payload*1/2 ))
- fi
- popd 1>/dev/null
- pcmd+=" -s $payload"
- adjust_progress
-}
-
-adjust_progress()
-{
-
- if ! command -v pv >/dev/null;then
- wsrep_log_error "pv not found in path: $PATH"
- wsrep_log_error "Disabling all progress/rate-limiting"
- pcmd=""
- rlimit=""
- progress=""
- return
- fi
-
- if [[ -n $progress && $progress != '1' ]];then
- if [[ -e $progress ]];then
- pcmd+=" 2>>$progress"
- else
- pcmd+=" 2>$progress"
- fi
- elif [[ -z $progress && -n $rlimit ]];then
- # When rlimit is non-zero
- pcmd="pv -q"
- fi
-
- if [[ -n $rlimit && "$WSREP_SST_OPT_ROLE" == "donor" ]];then
- wsrep_log_info "Rate-limiting SST to $rlimit"
- pcmd+=" -L \$rlimit"
- fi
-}
-
-read_cnf()
-{
- sfmt=$(parse_cnf sst streamfmt "xbstream")
- tfmt=$(parse_cnf sst transferfmt "socat")
- tca=$(parse_cnf sst tca "")
- tcert=$(parse_cnf sst tcert "")
- tkey=$(parse_cnf sst tkey "")
- encrypt=$(parse_cnf sst encrypt 0)
- sockopt=$(parse_cnf sst sockopt "")
- progress=$(parse_cnf sst progress "")
- rebuild=$(parse_cnf sst rebuild 0)
- ttime=$(parse_cnf sst time 0)
- if [ "${OS}" = "FreeBSD" ]; then
- cpat=$(parse_cnf sst cpat '.*\.pem$|.*init\.ok$|.*galera\.cache$|.*sst_in_progress$|.*\.sst$|.*gvwstate\.dat$|.*grastate\.dat$|.*\.err$|.*\.log$|.*RPM_UPGRADE_MARKER$|.*RPM_UPGRADE_HISTORY$')
- else
- cpat=$(parse_cnf sst cpat '.*\.pem$\|.*init\.ok$\|.*galera\.cache$\|.*sst_in_progress$\|.*\.sst$\|.*gvwstate\.dat$\|.*grastate\.dat$\|.*\.err$\|.*\.log$\|.*RPM_UPGRADE_MARKER$\|.*RPM_UPGRADE_HISTORY$')
- fi
- ealgo=$(parse_cnf xtrabackup encrypt "")
- ekey=$(parse_cnf xtrabackup encrypt-key "")
- ekeyfile=$(parse_cnf xtrabackup encrypt-key-file "")
- scomp=$(parse_cnf sst compressor "")
- sdecomp=$(parse_cnf sst decompressor "")
-
-
- # Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
- if [[ -z $ealgo ]];then
- ealgo=$(parse_cnf sst encrypt-algo "")
- ekey=$(parse_cnf sst encrypt-key "")
- ekeyfile=$(parse_cnf sst encrypt-key-file "")
- fi
-
- # Pull the parameters needed for encrypt=4
- ssl_ca=$(parse_cnf sst ssl-ca "")
- if [[ -z "$ssl_ca" ]]; then
- ssl_ca=$(parse_cnf --mysqld ssl-ca "")
- fi
- ssl_cert=$(parse_cnf sst ssl-cert "")
- if [[ -z "$ssl_cert" ]]; then
- ssl_cert=$(parse_cnf --mysqld ssl-cert "")
- fi
- ssl_key=$(parse_cnf sst ssl-key "")
- if [[ -z "$ssl_key" ]]; then
- ssl_key=$(parse_cnf --mysqld ssl-key "")
- fi
-
- rlimit=$(parse_cnf sst rlimit "")
- uextra=$(parse_cnf sst use-extra 0)
- iopts=$(parse_cnf sst inno-backup-opts "")
- iapts=$(parse_cnf sst inno-apply-opts "")
- impts=$(parse_cnf sst inno-move-opts "")
- stimeout=$(parse_cnf sst sst-initial-timeout 100)
- ssyslog=$(parse_cnf sst sst-syslog 0)
- ssystag=$(parse_cnf mysqld_safe syslog-tag "${SST_SYSLOG_TAG:-}")
- ssystag+="-"
-
- if [[ $ssyslog -ne -1 ]];then
- if $MY_PRINT_DEFAULTS mysqld_safe | grep -q -- "--syslog";then
- ssyslog=1
- fi
- fi
-}
-
-get_stream()
-{
- if [[ $sfmt == 'xbstream' ]];then
- wsrep_log_info "Streaming with xbstream"
- if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- strmcmd="xbstream -x"
- else
- strmcmd="xbstream -c \${INFO_FILE}"
- fi
- else
- sfmt="tar"
- wsrep_log_info "Streaming with tar"
- if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- strmcmd="tar xfi - "
- else
- strmcmd="tar cf - \${INFO_FILE} "
- fi
-
- fi
-}
-
-get_proc()
-{
- set +e
- nproc=$(grep -c processor /proc/cpuinfo)
- [[ -z $nproc || $nproc -eq 0 ]] && nproc=1
- set -e
-}
-
-sig_joiner_cleanup()
-{
- wsrep_log_error "Removing $MAGIC_FILE file due to signal"
- rm -f "$MAGIC_FILE"
-}
-
-cleanup_joiner()
-{
- # Since this is invoked just after exit NNN
- local estatus=$?
- if [[ $estatus -ne 0 ]];then
- wsrep_log_error "Cleanup after exit with status:$estatus"
- elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
- wsrep_log_info "Removing the sst_in_progress file"
- wsrep_cleanup_progress_file
- fi
- if [[ -n $progress && -p $progress ]];then
- wsrep_log_info "Cleaning up fifo file $progress"
- rm $progress
- fi
- if [[ -n ${STATDIR:-} ]];then
- [[ -d $STATDIR ]] && rm -rf $STATDIR
- fi
-
- # Final cleanup
- pgid=$(ps -o pgid= $$ | grep -o '[0-9]*')
-
- # This means no setsid done in mysqld.
- # We don't want to kill mysqld here otherwise.
- if [[ $$ -eq $pgid ]];then
-
- # This means a signal was delivered to the process.
- # So, more cleanup.
- if [[ $estatus -ge 128 ]];then
- kill -KILL -$$ || true
- fi
-
- fi
-
- exit $estatus
-}
-
-check_pid()
-{
- local pid_file="$1"
- [ -r "$pid_file" ] && ps -p $(cat "$pid_file") >/dev/null 2>&1
-}
-
-cleanup_donor()
-{
- # Since this is invoked just after exit NNN
- local estatus=$?
- if [[ $estatus -ne 0 ]];then
- wsrep_log_error "Cleanup after exit with status:$estatus"
- fi
-
- if [[ -n ${XTRABACKUP_PID:-} ]];then
- if check_pid $XTRABACKUP_PID
- then
- wsrep_log_error "xtrabackup process is still running. Killing... "
- kill_xtrabackup
- fi
-
- fi
- rm -f ${DATA}/${IST_FILE} || true
-
- if [[ -n $progress && -p $progress ]];then
- wsrep_log_info "Cleaning up fifo file $progress"
- rm -f $progress || true
- fi
-
- wsrep_log_info "Cleaning up temporary directories"
-
- if [[ -n $xtmpdir ]];then
- [[ -d $xtmpdir ]] && rm -rf $xtmpdir || true
- fi
-
- if [[ -n $itmpdir ]];then
- [[ -d $itmpdir ]] && rm -rf $itmpdir || true
- fi
-
- # Final cleanup
- pgid=$(ps -o pgid= $$ | grep -o '[0-9]*')
-
- # This means no setsid done in mysqld.
- # We don't want to kill mysqld here otherwise.
- if [[ $$ -eq $pgid ]];then
-
- # This means a signal was delivered to the process.
- # So, more cleanup.
- if [[ $estatus -ge 128 ]];then
- kill -KILL -$$ || true
- fi
-
- fi
-
- exit $estatus
-
-}
-
-kill_xtrabackup()
-{
- local PID=$(cat $XTRABACKUP_PID)
- [ -n "$PID" -a "0" != "$PID" ] && kill $PID && (kill $PID && kill -9 $PID) || :
- wsrep_log_info "Removing xtrabackup pid file $XTRABACKUP_PID"
- rm -f "$XTRABACKUP_PID" || true
-}
-
-# waits ~1 minute for nc/socat to open the port and then reports ready
-# (regardless of timeout)
-wait_for_listen()
-{
- local HOST=$1
- local PORT=$2
- local MODULE=$3
- local LSOF_OUT
-
- for i in {1..300}
- do
- LSOF_OUT=$(lsof -sTCP:LISTEN -i TCP:${PORT} -a -c nc -c socat -F c 2> /dev/null || :)
- [ -n "${LSOF_OUT}" ] && break
- sleep 0.2
- done
-
- echo "ready ${HOST}:${PORT}/${MODULE}//${WSREP_SST_OPT_SST_VER:-1}"
-}
-
-check_extra()
-{
- local use_socket=1
- if [[ $uextra -eq 1 ]];then
- if [ $(parse_cnf --mysqld thread-handling) = 'pool-of-threads'];then
- local eport=$(parse_cnf --mysqld extra-port)
- if [[ -n $eport ]];then
- # Xtrabackup works only locally.
- # Hence, setting host to 127.0.0.1 unconditionally.
- wsrep_log_info "SST through extra_port $eport"
- INNOEXTRA+=" --host=127.0.0.1 --port=$eport "
- use_socket=0
- else
- wsrep_log_error "Extra port $eport null, failing"
- exit 1
- fi
- else
- wsrep_log_info "Thread pool not set, ignore the option use_extra"
- fi
- fi
- if [[ $use_socket -eq 1 ]] && [[ -n "${WSREP_SST_OPT_SOCKET}" ]];then
- INNOEXTRA+=" --socket=${WSREP_SST_OPT_SOCKET}"
- fi
-}
-
-recv_joiner()
-{
- local dir=$1
- local msg=$2
- local tmt=$3
- local checkf=$4
- local ltcmd
-
- if [[ ! -d ${dir} ]];then
- # This indicates that IST is in progress
- return
- fi
-
- pushd ${dir} 1>/dev/null
- set +e
-
- if [[ $tmt -gt 0 ]] && command -v timeout >/dev/null;then
- if timeout --help | grep -q -- '-k';then
- ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd"
- else
- ltcmd="timeout -s9 $tmt $tcmd"
- fi
- timeit "$msg" "$ltcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
- else
- timeit "$msg" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
- fi
-
- set -e
- popd 1>/dev/null
-
- if [[ ${RC[0]} -eq 124 ]];then
- wsrep_log_error "Possible timeout in receving first data from donor in gtid stage"
- exit 32
- fi
-
- for ecode in "${RC[@]}";do
- if [[ $ecode -ne 0 ]];then
- wsrep_log_error "Error while getting data from donor node: " \
- "exit codes: ${RC[@]}"
- exit 32
- fi
- done
-
- if [[ $checkf -eq 1 && ! -r "${MAGIC_FILE}" ]];then
- # this message should cause joiner to abort
- wsrep_log_error "xtrabackup process ended without creating '${MAGIC_FILE}'"
- wsrep_log_info "Contents of datadir"
- wsrep_log_info "$(ls -l ${dir}/*)"
- exit 32
- fi
-}
-
-
-send_donor()
-{
- local dir=$1
- local msg=$2
-
- pushd ${dir} 1>/dev/null
- set +e
- timeit "$msg" "$strmcmd | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
- set -e
- popd 1>/dev/null
-
-
- for ecode in "${RC[@]}";do
- if [[ $ecode -ne 0 ]];then
- wsrep_log_error "Error while getting data from donor node: " \
- "exit codes: ${RC[@]}"
- exit 32
- fi
- done
-
-}
-
-# Returns the version string in a standardized format
-# Input "1.2.3" => echoes "010203"
-# Wrongly formatted values => echoes "000000"
-normalize_version()
-{
- local major=0
- local minor=0
- local patch=0
-
- # Only parses purely numeric version numbers, 1.2.3
- # Everything after the first three values are ignored
- if [[ $1 =~ ^([0-9]+)\.([0-9]+)\.?([0-9]*)([\.0-9])*$ ]]; then
- major=${BASH_REMATCH[1]}
- minor=${BASH_REMATCH[2]}
- patch=${BASH_REMATCH[3]}
- fi
-
- printf %02d%02d%02d $major $minor $patch
-}
-
-# Compares two version strings
-# The first parameter is the version to be checked
-# The second parameter is the minimum version required
-# Returns 1 (failure) if $1 >= $2, 0 (success) otherwise
-check_for_version()
-{
- local local_version_str="$( normalize_version $1 )"
- local required_version_str="$( normalize_version $2 )"
-
- if [[ "$local_version_str" < "$required_version_str" ]]; then
- return 1
- else
- return 0
- fi
-}
-
-monitor_process()
-{
- local sst_stream_pid=$1
-
- while true ; do
-
- if ! ps --pid "${WSREP_SST_OPT_PARENT}" &>/dev/null; then
- wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
- kill -- -"${WSREP_SST_OPT_PARENT}"
- exit 32
- fi
-
- if ! ps --pid "${sst_stream_pid}" &>/dev/null; then
- break
- fi
-
- sleep 0.1
-
- done
-}
-
-
-wsrep_check_programs "$INNOBACKUPEX_BIN"
-
-# check the version, we require XB-2.4 to ensure that we can pass the
-# datadir via the command-line option
-XB_REQUIRED_VERSION="2.3.5"
-
-XB_VERSION=`$INNOBACKUPEX_BIN --version 2>&1 | grep -oe '[0-9]\.[0-9][\.0-9]*' | head -n1`
-if [[ -z $XB_VERSION ]]; then
- wsrep_log_error "FATAL: Cannot determine the $INNOBACKUPEX_BIN version. Needs xtrabackup-$XB_REQUIRED_VERSION or higher to perform SST"
- exit 2
-fi
-
-if ! check_for_version $XB_VERSION $XB_REQUIRED_VERSION; then
- wsrep_log_error "FATAL: The $INNOBACKUPEX_BIN version is $XB_VERSION. Needs xtrabackup-$XB_REQUIRED_VERSION or higher to perform SST"
- exit 2
-fi
-
-
-rm -f "${MAGIC_FILE}"
-
-if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then
- wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}"
- exit 22
-fi
-
-read_cnf
-
-if ${INNOBACKUPEX_BIN} /tmp --help 2>/dev/null | grep -q -- '--version-check'; then
- disver="--no-version-check"
-fi
-
-if [[ ${FORCE_FTWRL:-0} -eq 1 ]];then
- wsrep_log_info "Forcing FTWRL due to environment variable FORCE_FTWRL equal to $FORCE_FTWRL"
- iopts+=" --no-backup-locks "
-fi
-
-
-INNOEXTRA=""
-
-if [[ $ssyslog -eq 1 ]];then
-
- if ! command -v logger >/dev/null;then
- wsrep_log_error "logger not in path: $PATH. Ignoring"
- else
-
- wsrep_log_info "Logging all stderr of SST/Innobackupex to syslog"
-
- exec 2> >(logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE)
-
- wsrep_log_error()
- {
- logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
- }
-
- wsrep_log_info()
- {
- logger -p daemon.info -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
- }
-
- INNOAPPLY="2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply "
- INNOMOVE="2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move "
- INNOBACKUP="2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)"
- fi
-
-else
- INNOAPPLY="&>\${DATA}/innobackup.prepare.log"
- INNOMOVE="&>\${DATA}/innobackup.move.log"
- INNOBACKUP="2>\${DATA}/innobackup.backup.log"
-fi
-
-get_stream
-get_transfer
-
-INNODB_DATA_HOME_DIR=${INNODB_DATA_HOME_DIR:-""}
-# Try to set INNODB_DATA_HOME_DIR from the command line:
-if [ ! -z "$INNODB_DATA_HOME_DIR_ARG" ]; then
- INNODB_DATA_HOME_DIR=$INNODB_DATA_HOME_DIR_ARG
-fi
-# if INNODB_DATA_HOME_DIR env. variable is not set, try to get it from my.cnf
-if [ -z "$INNODB_DATA_HOME_DIR" ]; then
- INNODB_DATA_HOME_DIR=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-data-home-dir '')
-fi
-if [ -z "$INNODB_DATA_HOME_DIR" ]; then
- INNODB_DATA_HOME_DIR=$(parse_cnf --mysqld innodb-data-home-dir "")
-fi
-if [ ! -z "$INNODB_DATA_HOME_DIR" ]; then
- INNOEXTRA+=" --innodb-data-home-dir=$INNODB_DATA_HOME_DIR"
-fi
-
-if [ -n "$INNODB_DATA_HOME_DIR" ]; then
- # handle both relative and absolute paths
- INNODB_DATA_HOME_DIR=$(cd $DATA; mkdir -p "$INNODB_DATA_HOME_DIR"; cd $INNODB_DATA_HOME_DIR; pwd -P)
-else
- # default to datadir
- INNODB_DATA_HOME_DIR=$(cd $DATA; pwd -P)
-fi
-
-INNOAPPLY="${INNOBACKUPEX_BIN} $disver $iapts \$INNOEXTRA --apply-log \$rebuildcmd \${DATA} ${INNOAPPLY}"
-INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} ${INNOMOVE}"
-INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir ${INNOBACKUP}"
-
-if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
-then
- trap cleanup_donor EXIT
-
- if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
- then
- usrst=0
- if [[ -z $WSREP_SST_OPT_SST_VER ]];then
- wsrep_log_error "Upgrade joiner to 5.6.21 or higher for backup locks support"
- wsrep_log_error "The joiner is not supported for this version of donor"
- exit 93
- fi
-
- if [[ -z $(parse_cnf --mysqld tmpdir "") && -z $(parse_cnf xtrabackup tmpdir "") ]];then
- xtmpdir=$(mktemp -d)
- tmpopts=" --tmpdir=$xtmpdir "
- wsrep_log_info "Using $xtmpdir as xtrabackup temporary directory"
- fi
-
- itmpdir=$(mktemp -d)
- wsrep_log_info "Using $itmpdir as innobackupex temporary directory"
-
- if [[ -n "${WSREP_SST_OPT_USER:-}" && "$WSREP_SST_OPT_USER" != "(null)" ]]; then
- INNOEXTRA+=" --user=$WSREP_SST_OPT_USER"
- usrst=1
- fi
-
- if [ -n "${WSREP_SST_OPT_PSWD:-}" ]; then
- INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD"
- elif [[ $usrst -eq 1 ]];then
- # Empty password, used for testing, debugging etc.
- INNOEXTRA+=" --password="
- fi
-
- get_keys
- check_extra
-
- wsrep_log_info "Streaming GTID file before SST"
-
- # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
- # (separated by a space).
- echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
-
- ttcmd="$tcmd"
-
- if [[ $encrypt -eq 1 ]];then
- if [[ -n $scomp ]];then
- tcmd=" \$ecmd | $scomp | $tcmd "
- else
- tcmd=" \$ecmd | $tcmd "
- fi
- elif [[ -n $scomp ]];then
- tcmd=" $scomp | $tcmd "
- fi
-
- send_donor $DATA "${stagemsg}-gtid"
-
- # Restore the transport commmand to its original state
- tcmd="$ttcmd"
- if [[ -n $progress ]];then
- get_footprint
- tcmd="$pcmd | $tcmd"
- elif [[ -n $rlimit ]];then
- adjust_progress
- tcmd="$pcmd | $tcmd"
- fi
-
- wsrep_log_info "Sleeping before data transfer for SST"
- sleep 10
-
- wsrep_log_info "Streaming the backup to joiner at ${WSREP_SST_OPT_HOST} ${WSREP_SST_OPT_PORT:-4444}"
-
- # Add compression to the head of the stream (if specified)
- if [[ -n $scomp ]]; then
- tcmd="$scomp | $tcmd"
- fi
-
- # Add encryption to the head of the stream (if specified)
- if [[ $encrypt -eq 1 ]]; then
- tcmd=" \$ecmd | $tcmd "
- fi
-
- set +e
- timeit "${stagemsg}-SST" "$INNOBACKUP | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
- set -e
-
- if [ ${RC[0]} -ne 0 ]; then
- wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \
- "Check ${DATA}/innobackup.backup.log"
- exit 22
- elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
- wsrep_log_error "$tcmd finished with error: ${RC[1]}"
- exit 22
- fi
-
- # innobackupex implicitly writes PID to fixed location in $xtmpdir
- XTRABACKUP_PID="$xtmpdir/xtrabackup_pid"
-
-
- else # BYPASS FOR IST
-
- wsrep_log_info "Bypassing the SST for IST"
- echo "continue" # now server can resume updating data
-
- # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
- # (separated by a space).
- echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
- echo "1" > "${DATA}/${IST_FILE}"
- get_keys
- if [[ $encrypt -eq 1 ]];then
- if [[ -n $scomp ]];then
- tcmd=" \$ecmd | $scomp | $tcmd "
- else
- tcmd=" \$ecmd | $tcmd "
- fi
- elif [[ -n $scomp ]];then
- tcmd=" $scomp | $tcmd "
- fi
- strmcmd+=" \${IST_FILE}"
-
- send_donor $DATA "${stagemsg}-IST"
-
- fi
-
- echo "done ${WSREP_SST_OPT_GTID}"
- wsrep_log_info "Total time on donor: $totime seconds"
-
-elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ]
-then
- [[ -e $SST_PROGRESS_FILE ]] && wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE"
- [[ -n $SST_PROGRESS_FILE ]] && touch $SST_PROGRESS_FILE
-
- ib_home_dir=$INNODB_DATA_HOME_DIR
- ib_log_dir=$(parse_cnf --mysqld innodb-log-group-home-dir "")
- ib_undo_dir=$(parse_cnf --mysqld innodb-undo-directory "")
-
- stagemsg="Joiner-Recv"
-
- sencrypted=1
- nthreads=1
-
- MODULE="xtrabackup_sst"
-
- rm -f "${DATA}/${IST_FILE}"
-
- # May need xtrabackup_checkpoints later on
- rm -f ${DATA}/xtrabackup_binary ${DATA}/xtrabackup_galera_info ${DATA}/xtrabackup_logfile
-
- wait_for_listen ${WSREP_SST_OPT_HOST} ${WSREP_SST_OPT_PORT:-4444} ${MODULE} &
-
- trap sig_joiner_cleanup HUP PIPE INT TERM
- trap cleanup_joiner EXIT
-
- if [[ -n $progress ]];then
- adjust_progress
- tcmd+=" | $pcmd"
- fi
-
- get_keys
- if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then
- if [[ -n $sdecomp ]];then
- strmcmd=" $sdecomp | \$ecmd | $strmcmd"
- else
- strmcmd=" \$ecmd | $strmcmd"
- fi
- elif [[ -n $sdecomp ]];then
- strmcmd=" $sdecomp | $strmcmd"
- fi
-
- STATDIR=$(mktemp -d)
- MAGIC_FILE="${STATDIR}/${INFO_FILE}"
- recv_joiner $STATDIR "${stagemsg}-gtid" $stimeout 1
-
-
- if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null
- then
- wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
- exit 32
- fi
-
- if [ ! -r "${STATDIR}/${IST_FILE}" ]
- then
-
- if [[ -d ${DATA}/.sst ]];then
- wsrep_log_info "WARNING: Stale temporary SST directory: ${DATA}/.sst from previous state transfer. Removing"
- rm -rf ${DATA}/.sst
- fi
- mkdir -p ${DATA}/.sst
- (recv_joiner $DATA/.sst "${stagemsg}-SST" 0 0) &
- jpid=$!
- wsrep_log_info "Proceeding with SST"
-
-
- wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories"
- if [ "${OS}" = "FreeBSD" ]; then
- find -E $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+
- else
- find $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+
- fi
-
- tempdir=$(parse_cnf --mysqld log-bin "")
- if [[ -n ${tempdir:-} ]];then
- binlog_dir=$(dirname $tempdir)
- binlog_file=$(basename $tempdir)
- if [[ -n ${binlog_dir:-} && $binlog_dir != '.' && $binlog_dir != $DATA ]];then
- pattern="$binlog_dir/$binlog_file\.[0-9]+$"
- wsrep_log_info "Cleaning the binlog directory $binlog_dir as well"
- find $binlog_dir -maxdepth 1 -type f -regex $pattern -exec rm -fv {} 1>&2 \+ || true
- rm $binlog_dir/*.index || true
- fi
- fi
-
-
-
- TDATA=${DATA}
- DATA="${DATA}/.sst"
-
-
- MAGIC_FILE="${DATA}/${INFO_FILE}"
- wsrep_log_info "Waiting for SST streaming to complete!"
- monitor_process $jpid
-
- get_proc
-
- if [[ ! -s ${DATA}/xtrabackup_checkpoints ]];then
- wsrep_log_error "xtrabackup_checkpoints missing, failed innobackupex/SST on donor"
- exit 2
- fi
-
- # Rebuild indexes for compact backups
- if grep -q 'compact = 1' ${DATA}/xtrabackup_checkpoints;then
- wsrep_log_info "Index compaction detected"
- rebuild=1
- fi
-
- if [[ $rebuild -eq 1 ]];then
- nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc)
- wsrep_log_info "Rebuilding during prepare with $nthreads threads"
- rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads"
- fi
-
- if test -n "$(find ${DATA} -maxdepth 1 -type f -name '*.qp' -print -quit)";then
-
- wsrep_log_info "Compressed qpress files found"
-
- if ! command -v qpress >/dev/null;then
- wsrep_log_error "qpress not found in path: $PATH"
- exit 22
- fi
-
- if [[ -n $progress ]] && pv --help | grep -q 'line-mode';then
- count=$(find ${DATA} -type f -name '*.qp' | wc -l)
- count=$(( count*2 ))
- if pv --help | grep -q FORMAT;then
- pvopts="-f -s $count -l -N Decompression -F '%N => Rate:%r Elapsed:%t %e Progress: [%b/$count]'"
- else
- pvopts="-f -s $count -l -N Decompression"
- fi
- pcmd="pv $pvopts"
- adjust_progress
- dcmd="$pcmd | xargs -n 2 qpress -T${nproc}d"
- else
- dcmd="xargs -n 2 qpress -T${nproc}d"
- fi
-
-
- # Decompress the qpress files
- wsrep_log_info "Decompression with $nproc threads"
- timeit "Joiner-Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd"
- extcode=$?
-
- if [[ $extcode -eq 0 ]];then
- wsrep_log_info "Removing qpress files after decompression"
- find ${DATA} -type f -name '*.qp' -delete
- if [[ $? -ne 0 ]];then
- wsrep_log_error "Something went wrong with deletion of qpress files. Investigate"
- fi
- else
- wsrep_log_error "Decompression failed. Exit code: $extcode"
- exit 22
- fi
- fi
-
-
- if [[ ! -z $WSREP_SST_OPT_BINLOG ]];then
-
- BINLOG_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG)
- BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
-
- # To avoid comparing data directory and BINLOG_DIRNAME
- mv $DATA/${BINLOG_FILENAME}.* $BINLOG_DIRNAME/ 2>/dev/null || true
-
- pushd $BINLOG_DIRNAME &>/dev/null
- for bfiles in $(ls -1 ${BINLOG_FILENAME}.[0-9]*);do
- echo ${BINLOG_DIRNAME}/${bfiles} >> ${BINLOG_FILENAME}.index
- done
- popd &> /dev/null
-
- fi
-
- wsrep_log_info "Preparing the backup at ${DATA}"
- timeit "Xtrabackup prepare stage" "$INNOAPPLY"
-
- if [ $? -ne 0 ];
- then
- wsrep_log_error "${INNOBACKUPEX_BIN} apply finished with errors. Check ${DATA}/innobackup.prepare.log"
- exit 22
- fi
-
- MAGIC_FILE="${TDATA}/${INFO_FILE}"
- set +e
- rm $TDATA/innobackup.prepare.log $TDATA/innobackup.move.log
- set -e
- wsrep_log_info "Moving the backup to ${TDATA}"
- timeit "Xtrabackup move stage" "$INNOMOVE"
- if [[ $? -eq 0 ]];then
- wsrep_log_info "Move successful, removing ${DATA}"
- rm -rf $DATA
- DATA=${TDATA}
- else
- wsrep_log_error "Move failed, keeping ${DATA} for further diagnosis"
- wsrep_log_error "Check ${DATA}/innobackup.move.log for details"
- exit 22
- fi
-
-
- else
- wsrep_log_info "${IST_FILE} received from donor: Running IST"
- fi
-
- if [[ ! -r ${MAGIC_FILE} ]];then
- wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable"
- exit 2
- fi
- wsrep_log_info "Galera co-ords from recovery: $(cat ${MAGIC_FILE})"
- cat "${MAGIC_FILE}" # Output : UUID:seqno wsrep_gtid_domain_id
- wsrep_log_info "Total time on joiner: $totime seconds"
-fi
-
-exit 0
diff --git a/scripts/wsrep_sst_xtrabackup.sh b/scripts/wsrep_sst_xtrabackup.sh
deleted file mode 100644
index 41ed4485de5..00000000000
--- a/scripts/wsrep_sst_xtrabackup.sh
+++ /dev/null
@@ -1,692 +0,0 @@
-#!/bin/bash -ue
-# Copyright (C) 2013 Percona Inc
-#
-# 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; see the file COPYING. If not, write to the
-# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
-# MA 02110-1301 USA.
-
-# Optional dependencies and options documented here: http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
-# Make sure to read that before proceeding!
-
-
-
-
-. $(dirname $0)/wsrep_sst_common
-
-ealgo=""
-ekey=""
-ekeyfile=""
-encrypt=0
-nproc=1
-ecode=0
-XTRABACKUP_PID=""
-tcert=""
-tpem=""
-sockopt=""
-progress=""
-ttime=0
-totime=0
-lsn="${WSREP_SST_OPT_LSN}"
-incremental=0
-ecmd=""
-rlimit=""
-
-sfmt="tar"
-strmcmd=""
-tfmt=""
-tcmd=""
-rebuild=0
-rebuildcmd=""
-payload=0
-pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' "
-pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE "
-uextra=0
-
-if pv --help 2>/dev/null | grep -q FORMAT;then
- pvopts+=$pvformat
-fi
-pcmd="pv $pvopts"
-declare -a RC
-
-INNOBACKUPEX_BIN=innobackupex
-DATA="${WSREP_SST_OPT_DATA}"
-INFO_FILE="xtrabackup_galera_info"
-IST_FILE="xtrabackup_ist"
-MAGIC_FILE="${DATA}/${INFO_FILE}"
-
-# Setting the path for ss and ip
-export PATH="/usr/sbin:/sbin:$PATH"
-
-timeit(){
- local stage=$1
- shift
- local cmd="$@"
- local x1 x2 took extcode
-
- if [[ $ttime -eq 1 ]];then
- x1=$(date +%s)
- wsrep_log_info "Evaluating $cmd"
- eval "$cmd"
- extcode=$?
- x2=$(date +%s)
- took=$(( x2-x1 ))
- wsrep_log_info "NOTE: $stage took $took seconds"
- totime=$(( totime+took ))
- else
- wsrep_log_info "Evaluating $cmd"
- eval "$cmd"
- extcode=$?
- fi
- return $extcode
-}
-
-get_keys()
-{
- if [[ $encrypt -eq 2 ]];then
- return
- fi
-
- if [[ $encrypt -eq 0 ]];then
- if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then
- wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html "
- fi
- return
- fi
-
- if [[ $sfmt == 'tar' ]];then
- wsrep_log_info "NOTE: Xtrabackup-based encryption - encrypt=1 - cannot be enabled with tar format"
- encrypt=0
- return
- fi
-
- wsrep_log_info "Xtrabackup based encryption enabled in my.cnf - Supported only from Xtrabackup 2.1.4"
-
- if [[ -z $ealgo ]];then
- wsrep_log_error "FATAL: Encryption algorithm empty from my.cnf, bailing out"
- exit 3
- fi
-
- if [[ -z $ekey && ! -r $ekeyfile ]];then
- wsrep_log_error "FATAL: Either key or keyfile must be readable"
- exit 3
- fi
-
- if [[ -z $ekey ]];then
- ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key-file=$ekeyfile"
- else
- ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key=$ekey"
- fi
-
- if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- ecmd+=" -d"
- fi
-}
-
-get_transfer()
-{
- TSST_PORT=${WSREP_SST_OPT_PORT:-4444}
-
- if [[ $tfmt == 'nc' ]];then
- wsrep_check_programs nc
- wsrep_log_info "Using netcat as streamer"
- if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- if nc -h 2>&1 | grep -q ncat;then
- # Ncat
- tcmd="nc -l ${TSST_PORT}"
- elif nc -h 2>&1 | grep -q -- '-d\>';then
- # Debian netcat
- tcmd="nc -dl ${TSST_PORT}"
- else
- # traditional netcat
- tcmd="nc -l -p ${TSST_PORT}"
- fi
- else
- if nc -h 2>&1 | grep -q ncat;then
- # Ncat
- tcmd="nc ${REMOTEIP} ${TSST_PORT}"
- elif nc -h 2>&1 | grep -q -- '-d\>';then
- # Debian netcat
- tcmd="nc ${REMOTEIP} ${TSST_PORT}"
- else
- # traditional netcat
- tcmd="nc -q0 ${REMOTEIP} ${TSST_PORT}"
- fi
- fi
- else
- tfmt='socat'
- wsrep_check_programs socat
- wsrep_log_info "Using socat as streamer"
-
- if [[ $encrypt -eq 2 ]] && ! socat -V | grep -q OPENSSL;then
- wsrep_log_info "NOTE: socat is not openssl enabled, falling back to plain transfer"
- encrypt=0
- fi
-
- if [[ $encrypt -eq 2 ]];then
- wsrep_log_info "Using openssl based encryption with socat"
- if [[ -z $tpem || -z $tcert ]];then
- wsrep_log_error "Both PEM and CRT files required"
- exit 22
- fi
- if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- wsrep_log_info "Decrypting with PEM $tpem, CA: $tcert"
- tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=$tpem,cafile=${tcert}${sockopt} stdio"
- else
- wsrep_log_info "Encrypting with PEM $tpem, CA: $tcert"
- tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=$tpem,cafile=${tcert}${sockopt}"
- fi
- else
- if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio"
- else
- tcmd="socat -u stdio TCP:${WSREP_SST_OPT_HOST}:${TSST_PORT}${sockopt}"
- fi
- fi
- fi
-
-}
-
-get_footprint()
-{
- pushd $WSREP_SST_OPT_DATA 1>/dev/null
- payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c -s | awk 'END { print $1 }')
- if $MY_PRINT_DEFAULTS xtrabackup | grep -q -- "--compress";then
- # QuickLZ has around 50% compression ratio
- # When compression/compaction used, the progress is only an approximate.
- payload=$(( payload*1/2 ))
- fi
- popd 1>/dev/null
- pcmd+=" -s $payload"
- adjust_progress
-}
-
-adjust_progress()
-{
- if [[ -n $progress && $progress != '1' ]];then
- if [[ -e $progress ]];then
- pcmd+=" 2>>$progress"
- else
- pcmd+=" 2>$progress"
- fi
- elif [[ -z $progress && -n $rlimit ]];then
- # When rlimit is non-zero
- pcmd="pv -q"
- fi
-
- if [[ -n $rlimit && "$WSREP_SST_OPT_ROLE" == "donor" ]];then
- wsrep_log_info "Rate-limiting SST to $rlimit"
- pcmd+=" -L \$rlimit"
- fi
-}
-
-read_cnf()
-{
- sfmt=$(parse_cnf sst streamfmt "tar")
- tfmt=$(parse_cnf sst transferfmt "socat")
- tcert=$(parse_cnf sst tca "")
- tpem=$(parse_cnf sst tcert "")
- encrypt=$(parse_cnf sst encrypt 0)
- sockopt=$(parse_cnf sst sockopt "")
- progress=$(parse_cnf sst progress "")
- rebuild=$(parse_cnf sst rebuild 0)
- ttime=$(parse_cnf sst time 0)
- incremental=$(parse_cnf sst incremental 0)
- ealgo=$(parse_cnf xtrabackup encrypt "")
- ekey=$(parse_cnf xtrabackup encrypt-key "")
- ekeyfile=$(parse_cnf xtrabackup encrypt-key-file "")
-
- # Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
- if [[ -z $ealgo ]];then
- ealgo=$(parse_cnf sst encrypt-algo "")
- ekey=$(parse_cnf sst encrypt-key "")
- ekeyfile=$(parse_cnf sst encrypt-key-file "")
- fi
- rlimit=$(parse_cnf sst rlimit "")
- uextra=$(parse_cnf sst use_extra 0)
-}
-
-get_stream()
-{
- if [[ $sfmt == 'xbstream' ]];then
- wsrep_log_info "Streaming with xbstream"
- if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- strmcmd="xbstream -x"
- else
- strmcmd="xbstream -c \${INFO_FILE} \${IST_FILE}"
- fi
- else
- sfmt="tar"
- wsrep_log_info "Streaming with tar"
- if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- strmcmd="tar xfi - --recursive-unlink -h"
- else
- strmcmd="tar cf - \${INFO_FILE} \${IST_FILE}"
- fi
-
- fi
-}
-
-get_proc()
-{
- set +e
- nproc=$(grep -c processor /proc/cpuinfo)
- [[ -z $nproc || $nproc -eq 0 ]] && nproc=1
- set -e
-}
-
-sig_joiner_cleanup()
-{
- wsrep_log_error "Removing $MAGIC_FILE file due to signal"
- rm -f "$MAGIC_FILE"
-}
-
-cleanup_joiner()
-{
- # Since this is invoked just after exit NNN
- local estatus=$?
- if [[ $estatus -ne 0 ]];then
- wsrep_log_error "Cleanup after exit with status:$estatus"
- fi
- if [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
- wsrep_log_info "Removing the sst_in_progress file"
- wsrep_cleanup_progress_file
- fi
- if [[ -n $progress && -p $progress ]];then
- wsrep_log_info "Cleaning up fifo file $progress"
- rm $progress
- fi
-}
-
-check_pid()
-{
- local pid_file="$1"
- [ -r "$pid_file" ] && ps -p $(cat "$pid_file") >/dev/null 2>&1
-}
-
-cleanup_donor()
-{
- # Since this is invoked just after exit NNN
- local estatus=$?
- if [[ $estatus -ne 0 ]];then
- wsrep_log_error "Cleanup after exit with status:$estatus"
- fi
-
- if [[ -n $XTRABACKUP_PID ]];then
- if check_pid $XTRABACKUP_PID
- then
- wsrep_log_error "xtrabackup process is still running. Killing... "
- kill_xtrabackup
- fi
-
- rm -f $XTRABACKUP_PID
- fi
- rm -f ${DATA}/${IST_FILE}
-
- if [[ -n $progress && -p $progress ]];then
- wsrep_log_info "Cleaning up fifo file $progress"
- rm $progress
- fi
-}
-
-kill_xtrabackup()
-{
- local PID=$(cat $XTRABACKUP_PID)
- [ -n "$PID" -a "0" != "$PID" ] && kill $PID && (kill $PID && kill -9 $PID) || :
- rm -f "$XTRABACKUP_PID"
-}
-
-# waits ~10 seconds for nc to open the port and then reports ready
-# (regardless of timeout)
-wait_for_listen()
-{
- local PORT=$1
- local ADDR=$2
- local MODULE=$3
- for i in {1..50}
- do
- ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break
- sleep 0.2
- done
- if [[ $incremental -eq 1 ]];then
- echo "ready ${ADDR}/${MODULE}/$lsn"
- else
- echo "ready ${ADDR}/${MODULE}"
- fi
-}
-
-check_extra()
-{
- local use_socket=1
- if [[ $uextra -eq 1 ]];then
- if [ $(parse_cnf --mysqld thread-handling) = 'pool-of-threads'];then
- local eport=$(parse_cnf --mysqld extra-port)
- if [[ -n $eport ]];then
- # Xtrabackup works only locally.
- # Hence, setting host to 127.0.0.1 unconditionally.
- wsrep_log_info "SST through extra_port $eport"
- INNOEXTRA+=" --host=127.0.0.1 --port=$eport "
- use_socket=0
- else
- wsrep_log_error "Extra port $eport null, failing"
- exit 1
- fi
- else
- wsrep_log_info "Thread pool not set, ignore the option use_extra"
- fi
- fi
- if [[ $use_socket -eq 1 ]] && [[ -n "${WSREP_SST_OPT_SOCKET}" ]];then
- INNOEXTRA+=" --socket=${WSREP_SST_OPT_SOCKET}"
- fi
-}
-
-wsrep_check_programs "innobackupex"
-
-rm -f "${MAGIC_FILE}"
-
-if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then
- wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}"
- exit 22
-fi
-
-read_cnf
-get_stream
-get_transfer
-
-INNOEXTRA=""
-INNOAPPLY="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} --apply-log \$rebuildcmd \${DATA} &>\${DATA}/innobackup.prepare.log"
-INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} \$INNOEXTRA --galera-info --stream=\$sfmt \${TMPDIR} 2>\${DATA}/innobackup.backup.log"
-
-if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
-then
- trap cleanup_donor EXIT
-
- if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
- then
- usrst=0
- TMPDIR="${TMPDIR:-/tmp}"
-
- if [[ -n "${WSREP_SST_OPT_USER:-}" && "$WSREP_SST_OPT_USER" != "(null)" ]]; then
- INNOEXTRA+=" --user=$WSREP_SST_OPT_USER"
- usrst=1
- fi
-
- if [ -n "${WSREP_SST_OPT_PSWD:-}" ]; then
- INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD"
- elif [[ $usrst -eq 1 ]];then
- # Empty password, used for testing, debugging etc.
- INNOEXTRA+=" --password="
- fi
-
- get_keys
- if [[ $encrypt -eq 1 ]];then
- if [[ -n $ekey ]];then
- INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey "
- else
- INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile "
- fi
- fi
-
- if [[ -n $lsn ]];then
- INNOEXTRA+=" --incremental --incremental-lsn=$lsn "
- fi
-
- check_extra
-
- wsrep_log_info "Streaming the backup to joiner at ${WSREP_SST_OPT_HOST} ${WSREP_SST_OPT_PORT}"
-
- if [[ -n $progress ]];then
- get_footprint
- tcmd="$pcmd | $tcmd"
- elif [[ -n $rlimit ]];then
- adjust_progress
- tcmd="$pcmd | $tcmd"
- fi
-
- set +e
- timeit "Donor-Transfer" "$INNOBACKUP | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
- set -e
-
- if [ ${RC[0]} -ne 0 ]; then
- wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \
- "Check ${DATA}/innobackup.backup.log"
- exit 22
- elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
- wsrep_log_error "$tcmd finished with error: ${RC[1]}"
- exit 22
- fi
-
- # innobackupex implicitly writes PID to fixed location in ${TMPDIR}
- XTRABACKUP_PID="${TMPDIR}/xtrabackup_pid"
-
- else # BYPASS FOR IST
-
- wsrep_log_info "Bypassing the SST for IST"
- echo "continue" # now server can resume updating data
-
- # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
- # (separated by a space)
- echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
- echo "1" > "${DATA}/${IST_FILE}"
- get_keys
- pushd ${DATA} 1>/dev/null
- set +e
- if [[ $encrypt -eq 1 ]];then
- tcmd=" $ecmd | $tcmd"
- fi
- timeit "Donor-IST-Unencrypted-transfer" "$strmcmd | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
- set -e
- popd 1>/dev/null
-
- for ecode in "${RC[@]}";do
- if [[ $ecode -ne 0 ]];then
- wsrep_log_error "Error while streaming data to joiner node: " \
- "exit codes: ${RC[@]}"
- exit 1
- fi
- done
- fi
-
- echo "done ${WSREP_SST_OPT_GTID}"
- wsrep_log_info "Total time on donor: $totime seconds"
-
-elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ]
-then
- [[ -e $SST_PROGRESS_FILE ]] && wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE"
- touch $SST_PROGRESS_FILE
-
- if [[ ! -e ${DATA}/ibdata1 ]];then
- incremental=0
- fi
-
- if [[ $incremental -eq 1 ]];then
- wsrep_log_info "Incremental SST enabled"
- #lsn=$(/pxc/bin/mysqld $WSREP_SST_OPT_CONF --basedir=/pxc --wsrep-recover 2>&1 | grep -o 'log sequence number .*' | cut -d " " -f 4 | head -1)
- lsn=$(grep to_lsn xtrabackup_checkpoints | cut -d= -f2 | tr -d ' ')
- wsrep_log_info "Recovered LSN: $lsn"
- fi
-
- sencrypted=1
- nthreads=1
-
- MODULE="xtrabackup_sst"
-
- # May need xtrabackup_checkpoints later on
- rm -f ${DATA}/xtrabackup_binary ${DATA}/xtrabackup_galera_info ${DATA}/xtrabackup_logfile
-
- ADDR="${WSREP_SST_OPT_HOST}:${WSREP_SST_OPT_PORT:-4444}"
-
- wait_for_listen ${WSREP_SST_OPT_PORT:-4444} ${ADDR} ${MODULE} &
-
- trap sig_joiner_cleanup HUP PIPE INT TERM
- trap cleanup_joiner EXIT
-
- if [[ -n $progress ]];then
- adjust_progress
- tcmd+=" | $pcmd"
- fi
-
- if [[ $incremental -eq 1 ]];then
- BDATA=$DATA
- DATA=$(mktemp -d)
- MAGIC_FILE="${DATA}/${INFO_FILE}"
- fi
-
- get_keys
- set +e
- if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then
- strmcmd=" $ecmd | $strmcmd"
- fi
-
- pushd ${DATA} 1>/dev/null
- timeit "Joiner-Recv-Unencrypted" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
- popd 1>/dev/null
-
- set -e
-
- if [[ $sfmt == 'xbstream' ]];then
- # Special handling till lp:1193240 is fixed"
- if [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
- wsrep_log_error "Xbstream failed"
- wsrep_log_error "Data directory ${DATA} may not be empty: lp:1193240" \
- "Manual intervention required in that case"
- exit 32
- fi
- fi
-
- wait %% # join for wait_for_listen thread
-
- for ecode in "${RC[@]}";do
- if [[ $ecode -ne 0 ]];then
- wsrep_log_error "Error while getting data from donor node: " \
- "exit codes: ${RC[@]}"
- exit 32
- fi
- done
-
- if [ ! -r "${MAGIC_FILE}" ]
- then
- # this message should cause joiner to abort
- wsrep_log_error "xtrabackup process ended without creating '${MAGIC_FILE}'"
- wsrep_log_info "Contents of datadir"
- wsrep_log_info "$(ls -l ${DATA}/**/*)"
- exit 32
- fi
-
- if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null
- then
- wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
- exit 32
- fi
-
- if [ ! -r "${DATA}/${IST_FILE}" ]
- then
- wsrep_log_info "Proceeding with SST"
- wsrep_log_info "Removing existing ib_logfile files"
- if [[ $incremental -ne 1 ]];then
- rm -f ${DATA}/ib_logfile*
- else
- rm -f ${BDATA}/ib_logfile*
- fi
-
- get_proc
-
- # Rebuild indexes for compact backups
- if grep -q 'compact = 1' ${DATA}/xtrabackup_checkpoints;then
- wsrep_log_info "Index compaction detected"
- rebuild=1
- fi
-
- if [[ $rebuild -eq 1 ]];then
- nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc)
- wsrep_log_info "Rebuilding during prepare with $nthreads threads"
- rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads"
- fi
-
- if test -n "$(find ${DATA} -maxdepth 1 -type f -name '*.qp' -print -quit)";then
-
- wsrep_log_info "Compressed qpress files found"
-
- if ! command -v qpress >/dev/null;then
- wsrep_log_error "qpress not found in path: $PATH"
- exit 22
- fi
-
- if [[ -n $progress ]] && pv --help | grep -q 'line-mode';then
- count=$(find ${DATA} -type f -name '*.qp' | wc -l)
- count=$(( count*2 ))
- if pv --help | grep -q FORMAT;then
- pvopts="-f -s $count -l -N Decompression -F '%N => Rate:%r Elapsed:%t %e Progress: [%b/$count]'"
- else
- pvopts="-f -s $count -l -N Decompression"
- fi
- pcmd="pv $pvopts"
- adjust_progress
- dcmd="$pcmd | xargs -n 2 qpress -T${nproc}d"
- else
- dcmd="xargs -n 2 qpress -T${nproc}d"
- fi
-
- wsrep_log_info "Removing existing ibdata1 file"
- rm -f ${DATA}/ibdata1
-
- # Decompress the qpress files
- wsrep_log_info "Decompression with $nproc threads"
- timeit "Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd"
- extcode=$?
-
- if [[ $extcode -eq 0 ]];then
- wsrep_log_info "Removing qpress files after decompression"
- find ${DATA} -type f -name '*.qp' -delete
- if [[ $? -ne 0 ]];then
- wsrep_log_error "Something went wrong with deletion of qpress files. Investigate"
- fi
- else
- wsrep_log_error "Decompression failed. Exit code: $extcode"
- exit 22
- fi
- fi
-
- if [[ $incremental -eq 1 ]];then
- # Added --ibbackup=xtrabackup_55 because it fails otherwise citing connection issues.
- INNOAPPLY="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} \
- --ibbackup=xtrabackup_55 --apply-log $rebuildcmd --redo-only $BDATA --incremental-dir=${DATA} &>>${BDATA}/innobackup.prepare.log"
- fi
-
- wsrep_log_info "Preparing the backup at ${DATA}"
- timeit "Xtrabackup prepare stage" "$INNOAPPLY"
-
- if [[ $incremental -eq 1 ]];then
- wsrep_log_info "Cleaning up ${DATA} after incremental SST"
- [[ -d ${DATA} ]] && rm -rf ${DATA}
- DATA=$BDATA
- fi
-
- if [ $? -ne 0 ];
- then
- wsrep_log_error "${INNOBACKUPEX_BIN} finished with errors. Check ${DATA}/innobackup.prepare.log"
- exit 22
- fi
- else
- wsrep_log_info "${IST_FILE} received from donor: Running IST"
- fi
-
- if [[ ! -r ${MAGIC_FILE} ]];then
- wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable"
- exit 2
- fi
-
- cat "${MAGIC_FILE}" # Output : UUID:seqno wsrep_gtid_domain_id
- wsrep_log_info "Total time on joiner: $totime seconds"
-fi
-
-exit 0
diff --git a/sql/ha_sequence.cc b/sql/ha_sequence.cc
index d5064af16c3..a199892f971 100644
--- a/sql/ha_sequence.cc
+++ b/sql/ha_sequence.cc
@@ -114,7 +114,7 @@ int ha_sequence::open(const char *name, int mode, uint flags)
if (unlikely((error= table->s->sequence->read_initial_values(table))))
file->ha_close();
}
- else
+ else if (!table->s->tmp_table)
table->m_needs_reopen= true;
/*
diff --git a/sql/handler.h b/sql/handler.h
index a0739d75aaf..fc6246c38a1 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -430,6 +430,12 @@ enum enum_alter_inplace_result {
#define HA_KEY_NULL_LENGTH 1
#define HA_KEY_BLOB_LENGTH 2
+/* Maximum length of any index lookup key, in bytes */
+
+#define MAX_KEY_LENGTH (MAX_DATA_LENGTH_FOR_KEY \
+ +(MAX_REF_PARTS \
+ *(HA_KEY_NULL_LENGTH + HA_KEY_BLOB_LENGTH)))
+
#define HA_LEX_CREATE_TMP_TABLE 1U
#define HA_CREATE_TMP_ALTER 8U
#define HA_LEX_CREATE_SEQUENCE 16U
@@ -3801,14 +3807,14 @@ public:
uint max_key_parts() const
{ return MY_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
uint max_key_length() const
- { return MY_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
+ { return MY_MIN(MAX_DATA_LENGTH_FOR_KEY, max_supported_key_length()); }
uint max_key_part_length() const
- { return MY_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
+ { return MY_MIN(MAX_DATA_LENGTH_FOR_KEY, max_supported_key_part_length()); }
virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
virtual uint max_supported_keys() const { return 0; }
virtual uint max_supported_key_parts() const { return MAX_REF_PARTS; }
- virtual uint max_supported_key_length() const { return MAX_KEY_LENGTH; }
+ virtual uint max_supported_key_length() const { return MAX_DATA_LENGTH_FOR_KEY; }
virtual uint max_supported_key_part_length() const { return 255; }
virtual uint min_record_length(uint options) const { return 1; }
diff --git a/sql/item.cc b/sql/item.cc
index ed9c78e5525..4387d67e615 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -8071,7 +8071,9 @@ void Item_ref::print(String *str, enum_query_type query_type)
{
if (ref)
{
- if ((*ref)->type() != Item::CACHE_ITEM && ref_type() != VIEW_REF &&
+ if ((*ref)->type() != Item::CACHE_ITEM &&
+ (*ref)->type() != Item::WINDOW_FUNC_ITEM &&
+ ref_type() != VIEW_REF &&
!table_name && name.str && alias_name_used)
{
THD *thd= current_thd;
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 1f949a4445b..60216684c53 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1615,13 +1615,9 @@ longlong Item_func_int_div::val_int()
bool Item_func_int_div::fix_length_and_dec()
{
- Item_result argtype= args[0]->result_type();
- /* use precision ony for the data type it is applicable for and valid */
- uint32 char_length= args[0]->max_char_length() -
- (argtype == DECIMAL_RESULT || argtype == INT_RESULT ?
- args[0]->decimals : 0);
- fix_char_length(char_length > MY_INT64_NUM_DECIMAL_DIGITS ?
- MY_INT64_NUM_DECIMAL_DIGITS : char_length);
+ uint32 prec= args[0]->decimal_int_part();
+ set_if_smaller(prec, MY_INT64_NUM_DECIMAL_DIGITS);
+ fix_char_length(prec);
maybe_null=1;
unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag;
return false;
@@ -3169,6 +3165,8 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
func->maybe_null=1;
if (with_sum_func_cache)
with_sum_func_cache->join_with_sum_func(item);
+ func->with_window_func= func->with_window_func ||
+ item->with_window_func;
func->with_field= func->with_field || item->with_field;
func->with_param= func->with_param || item->with_param;
func->With_subquery_cache::join(item);
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index e24038f96ab..0ac4014a669 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -1516,12 +1516,12 @@ bool partition_info::check_partition_field_length()
for (i= 0; i < num_part_fields; i++)
store_length+= get_partition_field_store_length(part_field_array[i]);
- if (store_length > MAX_KEY_LENGTH)
+ if (store_length > MAX_DATA_LENGTH_FOR_KEY)
DBUG_RETURN(TRUE);
store_length= 0;
for (i= 0; i < num_subpart_fields; i++)
store_length+= get_partition_field_store_length(subpart_field_array[i]);
- if (store_length > MAX_KEY_LENGTH)
+ if (store_length > MAX_DATA_LENGTH_FOR_KEY)
DBUG_RETURN(TRUE);
DBUG_RETURN(FALSE);
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 85b54009219..3c31be5bd36 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -6614,7 +6614,8 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list,
{
List_iterator <LEX_USER> str_list (user_list);
LEX_USER *Str, *tmp_Str;
- bool create_new_users= 0, result;
+ bool create_new_users= 0;
+ int result;
const char *db_name, *table_name;
DBUG_ENTER("mysql_routine_grant");
@@ -7047,7 +7048,8 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
List_iterator <LEX_USER> str_list (list);
LEX_USER *Str, *tmp_Str, *proxied_user= NULL;
char tmp_db[SAFE_NAME_LEN+1];
- bool create_new_users=0, result;
+ bool create_new_users=0;
+ int result;
DBUG_ENTER("mysql_grant");
if (lower_case_table_names && db)
diff --git a/sql/sql_const.h b/sql/sql_const.h
index be26de872df..82f3b9c21f2 100644
--- a/sql/sql_const.h
+++ b/sql/sql_const.h
@@ -33,7 +33,17 @@
#define MAX_SYS_VAR_LENGTH 32
#define MAX_KEY MAX_INDEXES /* Max used keys */
#define MAX_REF_PARTS 32 /* Max parts used as ref */
-#define MAX_KEY_LENGTH 3072 /* max possible key */
+
+/*
+ Maximum length of the data part of an index lookup key.
+
+ The "data part" is defined as the value itself, not including the
+ NULL-indicator bytes or varchar length bytes ("the Extras"). We need this
+ value because there was a bug where length of the Extras were not counted.
+
+ You probably need MAX_KEY_LENGTH, not this constant.
+*/
+#define MAX_DATA_LENGTH_FOR_KEY 3072
#if SIZEOF_OFF_T > 4
#define MAX_REFLENGTH 8 /* Max length for record ref */
#else
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 5f826e37a76..55c51dbe151 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -764,8 +764,7 @@ exit:
}
-int mysql_create_db(THD *thd, const LEX_CSTRING *db,
- const DDL_options_st &options,
+int mysql_create_db(THD *thd, const LEX_CSTRING *db, DDL_options_st options,
const Schema_specification_st *create_info)
{
/*
@@ -773,6 +772,9 @@ int mysql_create_db(THD *thd, const LEX_CSTRING *db,
to it, we need to use a copy to make execution prepared statement- safe.
*/
Schema_specification_st tmp(*create_info);
+ if (thd->slave_thread &&
+ slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT)
+ options.add(DDL_options::OPT_IF_NOT_EXISTS);
return mysql_create_db_internal(thd, db, options, &tmp, false);
}
@@ -1047,6 +1049,9 @@ exit:
bool mysql_rm_db(THD *thd, const LEX_CSTRING *db, bool if_exists)
{
+ if (thd->slave_thread &&
+ slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT)
+ if_exists= true;
return mysql_rm_db_internal(thd, db, if_exists, false);
}
diff --git a/sql/sql_db.h b/sql/sql_db.h
index 7de6c2a9c99..c0646bd65f0 100644
--- a/sql/sql_db.h
+++ b/sql/sql_db.h
@@ -20,8 +20,7 @@
class THD;
-int mysql_create_db(THD *thd, const LEX_CSTRING *db,
- const DDL_options_st &options,
+int mysql_create_db(THD *thd, const LEX_CSTRING *db, DDL_options_st options,
const Schema_specification_st *create);
bool mysql_alter_db(THD *thd, const LEX_CSTRING *db,
const Schema_specification_st *create);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 312608e1395..7d6f71cda21 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -566,7 +566,7 @@ void init_update_queries(void)
sql_command_flags[SQLCOM_CREATE_PACKAGE_BODY]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_DROP_PACKAGE_BODY]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_ALTER_DB_UPGRADE]= CF_AUTO_COMMIT_TRANS;
- sql_command_flags[SQLCOM_ALTER_DB]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
+ sql_command_flags[SQLCOM_ALTER_DB]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS | CF_DB_CHANGE;
sql_command_flags[SQLCOM_RENAME_TABLE]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS;
sql_command_flags[SQLCOM_DROP_INDEX]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS;
sql_command_flags[SQLCOM_CREATE_VIEW]= CF_CHANGES_DATA | CF_REEXECUTION_FRAGILE |
@@ -1486,7 +1486,7 @@ static bool deny_updates_if_read_only_option(THD *thd, TABLE_LIST *all_tables)
if (lex->sql_command == SQLCOM_DROP_TABLE && lex->tmp_table())
DBUG_RETURN(FALSE);
- /* Check if we created or dropped databases */
+ /* Check if we created, dropped, or renamed a database */
if ((sql_command_flags[lex->sql_command] & CF_DB_CHANGE))
DBUG_RETURN(TRUE);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 04baf5737c6..978f0785887 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -20275,6 +20275,10 @@ test_if_quick_select(JOIN_TAB *tab)
delete tab->select->quick;
tab->select->quick=0;
+
+ if (tab->table->file->inited != handler::NONE)
+ tab->table->file->ha_index_or_rnd_end();
+
int res= tab->select->test_quick_select(tab->join->thd, tab->keys,
(table_map) 0, HA_POS_ERROR, 0,
FALSE, /*remove where parts*/FALSE);
diff --git a/sql/sql_signal.cc b/sql/sql_signal.cc
index 83abaebd4fd..359b5e45f01 100644
--- a/sql/sql_signal.cc
+++ b/sql/sql_signal.cc
@@ -343,13 +343,15 @@ bool Sql_cmd_common_signal::raise_condition(THD *thd, Sql_condition *cond)
if (eval_signal_informations(thd, cond))
DBUG_RETURN(result);
- /* SIGNAL should not signal WARN_LEVEL_NOTE */
- DBUG_ASSERT((cond->m_level == Sql_condition::WARN_LEVEL_WARN) ||
- (cond->m_level == Sql_condition::WARN_LEVEL_ERROR));
+ /* SIGNAL should not signal WARN_LEVEL_NOTE, but RESIGNAL can */
+ DBUG_ASSERT(cond->m_level == Sql_condition::WARN_LEVEL_ERROR ||
+ cond->m_level != Sql_condition::WARN_LEVEL_NOTE ||
+ sql_command_code() == SQLCOM_RESIGNAL);
(void) thd->raise_condition(cond);
- if (cond->m_level == Sql_condition::WARN_LEVEL_WARN)
+ if (cond->m_level == Sql_condition::WARN_LEVEL_WARN ||
+ cond->m_level == Sql_condition::WARN_LEVEL_NOTE)
{
my_ok(thd);
result= FALSE;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 666c6fb325a..f200f6f8c6d 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -10398,14 +10398,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
error= 1;
break;
}
- if (to->next_number_field)
- {
- if (auto_increment_field_copied)
- to->auto_increment_field_not_null= TRUE;
- else
- to->next_number_field->reset();
- }
-
+
for (Copy_field *copy_ptr=copy ; copy_ptr != copy_end ; copy_ptr++)
{
copy_ptr->do_copy(copy_ptr);
@@ -10443,6 +10436,13 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
if (keep_versioned && to->versioned(VERS_TRX_ID))
to->vers_write= false;
+ if (to->next_number_field)
+ {
+ if (auto_increment_field_copied)
+ to->auto_increment_field_not_null= TRUE;
+ else
+ to->next_number_field->reset();
+ }
error= to->file->ha_write_row(to->record[0]);
to->auto_increment_field_not_null= FALSE;
if (unlikely(error))
diff --git a/sql/table.cc b/sql/table.cc
index 0a40c5fb341..488d05b1a22 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1075,7 +1075,7 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table,
while (pos < end)
{
uint type, expr_length;
- if (table->s->mysql_version >= 100202)
+ if (table->s->frm_version >= FRM_VER_EXPRESSSIONS)
{
uint field_nr, name_length;
/* see pack_expression() for how data is stored */
@@ -2308,7 +2308,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
uint pk_part_length= key_first_info->key_part[i].store_length;
if (keyinfo->ext_key_part_map & 1<<i)
{
- if (ext_key_length + pk_part_length > MAX_KEY_LENGTH)
+ if (ext_key_length + pk_part_length > MAX_DATA_LENGTH_FOR_KEY)
{
add_keyparts_for_this_key= i;
break;
@@ -2318,9 +2318,9 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
}
}
- if (add_keyparts_for_this_key < (keyinfo->ext_key_parts -
- keyinfo->user_defined_key_parts))
- {
+ if (add_keyparts_for_this_key < keyinfo->ext_key_parts -
+ keyinfo->user_defined_key_parts)
+ {
share->ext_key_parts-= keyinfo->ext_key_parts;
key_part_map ext_key_part_map= keyinfo->ext_key_part_map;
keyinfo->ext_key_parts= keyinfo->user_defined_key_parts;
diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc
index 1c8af5eaf66..917a85e6c3b 100644
--- a/sql/temporary_tables.cc
+++ b/sql/temporary_tables.cc
@@ -1041,39 +1041,28 @@ TABLE *THD::find_temporary_table(const char *key, uint key_length,
/* A matching TMP_TABLE_SHARE is found. */
All_share_tables_list::Iterator tables_it(share->all_tmp_tables);
- while ((table= tables_it++))
+ bool found= false;
+ while (!found && (table= tables_it++))
{
switch (state)
{
- case TMP_TABLE_IN_USE:
- if (table->query_id > 0)
- {
- result= table;
- goto done;
- }
- break;
- case TMP_TABLE_NOT_IN_USE:
- if (table->query_id == 0)
- {
- result= table;
- goto done;
- }
- break;
- case TMP_TABLE_ANY:
- {
- result= table;
- goto done;
- }
- break;
- default: /* Invalid */
- DBUG_ASSERT(0);
- goto done;
+ case TMP_TABLE_IN_USE: found= table->query_id > 0; break;
+ case TMP_TABLE_NOT_IN_USE: found= table->query_id == 0; break;
+ case TMP_TABLE_ANY: found= true; break;
}
}
+ if (table && unlikely(table->m_needs_reopen))
+ {
+ share->all_tmp_tables.remove(table);
+ free_temporary_table(table);
+ it.rewind();
+ continue;
+ }
+ result= table;
+ break;
}
}
-done:
if (locked)
{
DBUG_ASSERT(m_tmp_tables_locked);
@@ -1154,8 +1143,7 @@ TABLE *THD::open_temporary_table(TMP_TABLE_SHARE *share,
@return Success false
Failure true
*/
-bool THD::find_and_use_tmp_table(const TABLE_LIST *tl,
- TABLE **out_table)
+bool THD::find_and_use_tmp_table(const TABLE_LIST *tl, TABLE **out_table)
{
DBUG_ENTER("THD::find_and_use_tmp_table");
@@ -1165,11 +1153,9 @@ bool THD::find_and_use_tmp_table(const TABLE_LIST *tl,
key_length= create_tmp_table_def_key(key, tl->get_db_name(),
tl->get_table_name());
- result=
- use_temporary_table(find_temporary_table(key, key_length,
- TMP_TABLE_NOT_IN_USE),
- out_table);
-
+ result= use_temporary_table(find_temporary_table(key, key_length,
+ TMP_TABLE_NOT_IN_USE),
+ out_table);
DBUG_RETURN(result);
}
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index 24306e37ca3..0a2424fa069 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -803,6 +803,7 @@ ssize_t wsrep_sst_prepare (void** msg)
{
const char* addr_in= NULL;
const char* addr_out= NULL;
+ const char* method;
if (!strcmp(wsrep_sst_method, WSREP_SST_SKIP))
{
@@ -861,7 +862,8 @@ ssize_t wsrep_sst_prepare (void** msg)
}
ssize_t addr_len= -ENOSYS;
- if (!strcmp(wsrep_sst_method, WSREP_SST_MYSQLDUMP))
+ method = wsrep_sst_method;
+ if (!strcmp(method, WSREP_SST_MYSQLDUMP))
{
addr_len= sst_prepare_mysqldump (addr_in, &addr_out);
if (addr_len < 0) unireg_abort(1);
@@ -871,6 +873,13 @@ ssize_t wsrep_sst_prepare (void** msg)
/*! A heuristic workaround until we learn how to stop and start engines */
if (SE_initialized)
{
+ if (!strcmp(method, WSREP_SST_XTRABACKUP) ||
+ !strcmp(method, WSREP_SST_XTRABACKUPV2))
+ {
+ WSREP_WARN("The %s SST method is deprecated, so it is automatically "
+ "replaced by %s", method, WSREP_SST_MARIABACKUP);
+ method = WSREP_SST_MARIABACKUP;
+ }
// we already did SST at initializaiton, now engines are running
// sql_print_information() is here because the message is too long
// for WSREP_INFO.
@@ -880,28 +889,28 @@ ssize_t wsrep_sst_prepare (void** msg)
"Wsrep provider won't be able to fall back to it "
"if other means of state transfer are unavailable. "
"In that case you will need to restart the server.",
- wsrep_sst_method);
+ method);
*msg = 0;
return 0;
}
- addr_len = sst_prepare_other (wsrep_sst_method, sst_auth_real,
+ addr_len = sst_prepare_other (method, sst_auth_real,
addr_in, &addr_out);
if (addr_len < 0)
{
WSREP_ERROR("Failed to prepare for '%s' SST. Unrecoverable.",
- wsrep_sst_method);
+ method);
unireg_abort(1);
}
}
- size_t const method_len(strlen(wsrep_sst_method));
+ size_t const method_len(strlen(method));
size_t const msg_len (method_len + addr_len + 2 /* + auth_len + 1*/);
*msg = malloc (msg_len);
if (NULL != *msg) {
char* const method_ptr(reinterpret_cast<char*>(*msg));
- strcpy (method_ptr, wsrep_sst_method);
+ strcpy (method_ptr, method);
char* const addr_ptr(method_ptr + method_len + 1);
strcpy (addr_ptr, addr_out);
diff --git a/sql/wsrep_sst.h b/sql/wsrep_sst.h
index cc0f1f5389d..29724a00797 100644
--- a/sql/wsrep_sst.h
+++ b/sql/wsrep_sst.h
@@ -49,6 +49,9 @@
#define WSREP_SST_MYSQLDUMP "mysqldump"
#define WSREP_SST_RSYNC "rsync"
#define WSREP_SST_SKIP "skip"
+#define WSREP_SST_MARIABACKUP "mariabackup"
+#define WSREP_SST_XTRABACKUP "xtrabackup"
+#define WSREP_SST_XTRABACKUPV2 "xtrabackupv2"
#define WSREP_SST_DEFAULT WSREP_SST_RSYNC
#define WSREP_SST_ADDRESS_AUTO "AUTO"
#define WSREP_SST_AUTH_MASK "********"
diff --git a/storage/connect/global.h b/storage/connect/global.h
index 36e8a311124..dc1e149745f 100644
--- a/storage/connect/global.h
+++ b/storage/connect/global.h
@@ -219,11 +219,11 @@ DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR prefix, LPCSTR name, LPCSTR dir);
DllExport BOOL PlugIsAbsolutePath(LPCSTR path);
DllExport bool AllocSarea(PGLOBAL, uint);
DllExport void FreeSarea(PGLOBAL);
-DllExport BOOL PlugSubSet(PGLOBAL, void *, uint);
+DllExport BOOL PlugSubSet(void *, uint);
+DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t);
DllExport char *PlugDup(PGLOBAL g, const char *str);
DllExport void *MakePtr(void *, OFFSET);
DllExport void htrc(char const *fmt, ...);
-//DllExport int GetTraceValue(void);
DllExport uint GetTraceValue(void);
#if defined(__cplusplus)
@@ -233,6 +233,6 @@ DllExport uint GetTraceValue(void);
/***********************************************************************/
/* Non exported routine declarations. */
/***********************************************************************/
-void *PlugSubAlloc(PGLOBAL, void *, size_t); // Does throw
+//void *PlugSubAlloc(PGLOBAL, void *, size_t); // Does throw
/*-------------------------- End of Global.H --------------------------*/
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index d3f89aca910..7599765c07a 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -4187,7 +4187,7 @@ int ha_connect::rnd_pos(uchar *buf, uchar *pos)
rc= rnd_next(buf);
} else {
PGLOBAL g = GetPlug((table) ? table->in_use : NULL, xp);
- strcpy(g->Message, "Not supported by this table type");
+// strcpy(g->Message, "Not supported by this table type");
my_message(ER_ILLEGAL_HA, g->Message, MYF(0));
rc= HA_ERR_INTERNAL_ERROR;
} // endif SetRecpos
@@ -7305,7 +7305,7 @@ maria_declare_plugin(connect)
PLUGIN_LICENSE_GPL,
connect_init_func, /* Plugin Init */
connect_done_func, /* Plugin Deinit */
- 0x0107, /* version number (1.05) */
+ 0x0106, /* version number (1.06) */
NULL, /* status variables */
connect_system_variables, /* system variables */
"1.06.0008", /* string version */
diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp
index 145c48b81d5..07a67e37379 100644
--- a/storage/connect/jsonudf.cpp
+++ b/storage/connect/jsonudf.cpp
@@ -3056,7 +3056,7 @@ my_bool json_array_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
PGLOBAL g = (PGLOBAL)initid->ptr;
- PlugSubSet(g, g->Sarea, g->Sarea_Size);
+ PlugSubSet(g->Sarea, g->Sarea_Size);
g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JAR);
g->N = (int)n;
return false;
@@ -3099,7 +3099,7 @@ void json_array_grp_clear(UDF_INIT *initid, char*, char*)
{
PGLOBAL g = (PGLOBAL)initid->ptr;
- PlugSubSet(g, g->Sarea, g->Sarea_Size);
+ PlugSubSet(g->Sarea, g->Sarea_Size);
g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JAR);
g->N = GetJsonGroupSize();
} // end of json_array_grp_clear
@@ -3133,7 +3133,7 @@ my_bool json_object_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
PGLOBAL g = (PGLOBAL)initid->ptr;
- PlugSubSet(g, g->Sarea, g->Sarea_Size);
+ PlugSubSet(g->Sarea, g->Sarea_Size);
g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JOB);
g->N = (int)n;
return false;
@@ -3170,7 +3170,7 @@ void json_object_grp_clear(UDF_INIT *initid, char*, char*)
{
PGLOBAL g = (PGLOBAL)initid->ptr;
- PlugSubSet(g, g->Sarea, g->Sarea_Size);
+ PlugSubSet(g->Sarea, g->Sarea_Size);
g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JOB);
g->N = GetJsonGroupSize();
} // end of json_object_grp_clear
@@ -4419,7 +4419,7 @@ char *json_file(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else if (initid->const_item)
g->N = 1;
- PlugSubSet(g, g->Sarea, g->Sarea_Size);
+ PlugSubSet(g->Sarea, g->Sarea_Size);
fn = MakePSZ(g, args, 0);
if (args->arg_count > 1) {
@@ -5663,7 +5663,7 @@ char *jbin_file(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (bsp && !bsp->Changed)
goto fin;
- PlugSubSet(g, g->Sarea, g->Sarea_Size);
+ PlugSubSet(g->Sarea, g->Sarea_Size);
g->Xchk = NULL;
fn = MakePSZ(g, args, 0);
pretty = (args->arg_count > 2 && args->args[2]) ? (int)*(longlong*)args->args[2] : 3;
diff --git a/storage/connect/mysql-test/connect/r/jdbc_oracle.result b/storage/connect/mysql-test/connect/r/jdbc_oracle.result
index 2e36891a037..ec314c5f072 100644
--- a/storage/connect/mysql-test/connect/r/jdbc_oracle.result
+++ b/storage/connect/mysql-test/connect/r/jdbc_oracle.result
@@ -8,12 +8,19 @@ SELECT * FROM t2 WHERE command = 'drop table employee';
command number message
drop table employee 0 Execute: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
+Warnings:
+Warning 1105 Execute: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
+
SELECT * FROM t2 WHERE command = 'create table employee (id int not null, name varchar(32), title char(16), salary number(8,2))';
command number message
create table employee (id int not null, name varchar(32), title char(16), salary number(8,2)) 0 Affected rows
+Warnings:
+Warning 1105 Affected rows
SELECT * FROM t2 WHERE command = "insert into employee values(4567,'Johnson', 'Engineer', 12560.50)";
command number message
insert into employee values(4567,'Johnson', 'Engineer', 12560.50) 1 Affected rows
+Warnings:
+Warning 1105 Affected rows
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=tables
CONNECTION='jdbc:oracle:thin:@localhost:1521:xe'
OPTION_LIST='User=system,Password=manager';
@@ -27,8 +34,8 @@ OPTION_LIST='User=system,Password=manager';
SELECT * FROM t1;
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
NULL SYSTEM EMPLOYEE ID 3 NUMBER 38 0 0 10 0 NULL
-NULL SYSTEM EMPLOYEE NAME 12 VARCHAR2 32 0 0 10 1 NULL
-NULL SYSTEM EMPLOYEE TITLE 1 CHAR 16 0 0 10 1 NULL
+NULL SYSTEM EMPLOYEE NAME 12 VARCHAR2 32 0 NULL 10 1 NULL
+NULL SYSTEM EMPLOYEE TITLE 1 CHAR 16 0 NULL 10 1 NULL
NULL SYSTEM EMPLOYEE SALARY 3 NUMBER 8 0 2 10 1 NULL
DROP TABLE t1;
CREATE SERVER 'oracle' FOREIGN DATA WRAPPER 'oracle.jdbc.driver.OracleDriver' OPTIONS (
@@ -52,7 +59,7 @@ Note 1105 EMPLOYEE: 1 affected rows
SELECT * FROM t1;
ID NAME TITLE SALARY
4567 Trump Engineer 12560.50
-6214 Clinton Retired 0.00
+6214 Clinton Retired NULL
DELETE FROM t1 WHERE id = 6214;
Warnings:
Note 1105 EMPLOYEE: 1 affected rows
@@ -63,8 +70,7 @@ DROP TABLE t1;
SELECT * FROM t2 WHERE command = 'drop table employee';
command number message
drop table employee 0 Affected rows
+Warnings:
+Warning 1105 Affected rows
DROP TABLE t2;
DROP SERVER 'oracle';
-SET GLOBAL connect_jvm_path=NULL;
-SET GLOBAL connect_class_path=NULL;
-SET GLOBAL time_zone = SYSTEM;
diff --git a/storage/connect/plugutil.cpp b/storage/connect/plugutil.cpp
index 887527e38ab..048f00be75f 100644
--- a/storage/connect/plugutil.cpp
+++ b/storage/connect/plugutil.cpp
@@ -514,27 +514,31 @@ void FreeSarea(PGLOBAL g)
/* Here there should be some verification done such as validity of */
/* the address and size not larger than memory size. */
/***********************************************************************/
-BOOL PlugSubSet(PGLOBAL g __attribute__((unused)), void *memp, uint size)
+BOOL PlugSubSet(void *memp, uint size)
{
PPOOLHEADER pph = (PPOOLHEADER)memp;
pph->To_Free = (OFFSET)sizeof(POOLHEADER);
pph->FreeBlk = size - pph->To_Free;
-
return FALSE;
} /* end of PlugSubSet */
/***********************************************************************/
+/* Use it to export a function that do throwing. */
+/***********************************************************************/
+void *DoThrow(int n)
+{
+ throw n;
+} /* end of DoThrow */
+
+/***********************************************************************/
/* Program for sub-allocating one item in a storage area. */
-/* Note: SubAlloc routines of OS/2 are no more used to increase the */
-/* code portability and avoid problems when a grammar compiled under */
-/* one version of OS/2 is used under another version. */
-/* The simple way things are done here is also based on the fact */
-/* that no freeing of suballocated blocks is permitted in Plug. */
+/* The simple way things are done here is based on the fact */
+/* that no freeing of suballocated blocks is permitted in CONNECT. */
/***********************************************************************/
void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
- {
- PPOOLHEADER pph; /* Points on area header. */
+{
+ PPOOLHEADER pph; /* Points on area header. */
if (!memp)
/*******************************************************************/
@@ -559,8 +563,8 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
if (trace(1))
htrc("PlugSubAlloc: %s\n", g->Message);
- throw 1234;
- } /* endif size OS32 code */
+ DoThrow(1234);
+ } /* endif size OS32 code */
/*********************************************************************/
/* Do the suballocation the simplest way. */
@@ -574,7 +578,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
memp, pph->To_Free, pph->FreeBlk);
return (memp);
- } /* end of PlugSubAlloc */
+} /* end of PlugSubAlloc */
/***********************************************************************/
/* Program for sub-allocating and copying a string in a storage area. */
diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp
index e4f169575f8..30d8063d1a6 100644
--- a/storage/connect/reldef.cpp
+++ b/storage/connect/reldef.cpp
@@ -522,8 +522,15 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
// Get the function returning an instance of the external DEF class
if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) {
- sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), getname);
- FreeLibrary((HMODULE)Hdll);
+ char buf[256];
+ DWORD rc = GetLastError();
+
+ sprintf(g->Message, MSG(PROCADD_ERROR), rc, getname);
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
+ (LPTSTR)buf, sizeof(buf), NULL);
+ strcat(strcat(g->Message, ": "), buf);
+ FreeLibrary((HMODULE)Hdll);
return NULL;
} // endif getdef
#else // !__WIN__
diff --git a/storage/connect/tabfmt.h b/storage/connect/tabfmt.h
index 396bba568ff..10f0757c60b 100644
--- a/storage/connect/tabfmt.h
+++ b/storage/connect/tabfmt.h
@@ -13,7 +13,7 @@ typedef class TDBFMT *PTDBFMT;
/***********************************************************************/
/* Functions used externally. */
/***********************************************************************/
-PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info);
+DllExport PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info);
/***********************************************************************/
/* CSV table. */
diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp
index 9e4f5ab987d..d20e793ff88 100644
--- a/storage/connect/tabjson.cpp
+++ b/storage/connect/tabjson.cpp
@@ -299,7 +299,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
memset(G, 0, sizeof(GLOBAL));
G->Sarea_Size = tdp->Lrecl * 10;
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
- PlugSubSet(G, G->Sarea, G->Sarea_Size);
+ PlugSubSet(G->Sarea, G->Sarea_Size);
G->jump_level = 0;
tjnp->SetG(G);
@@ -670,7 +670,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
memset(G, 0, sizeof(GLOBAL));
G->Sarea_Size = Lrecl * 10;
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
- PlugSubSet(G, G->Sarea, G->Sarea_Size);
+ PlugSubSet(G->Sarea, G->Sarea_Size);
G->jump_level = 0;
((TDBJSN*)tdbp)->G = G;
} else {
@@ -963,7 +963,7 @@ int TDBJSN::ReadDB(PGLOBAL g)
return rc;
// Recover the memory used for parsing
- PlugSubSet(G, G->Sarea, G->Sarea_Size);
+ PlugSubSet(G->Sarea, G->Sarea_Size);
if ((Row = ParseJson(G, To_Line, strlen(To_Line), &Pretty, &Comma))) {
Row = FindRow(g);
@@ -1079,13 +1079,13 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
} // end of PrepareWriting
/***********************************************************************/
-/* WriteDB: Data Base write routine for DOS access method. */
+/* WriteDB: Data Base write routine for JSON access method. */
/***********************************************************************/
int TDBJSN::WriteDB(PGLOBAL g)
{
int rc = TDBDOS::WriteDB(g);
- PlugSubSet(G, G->Sarea, G->Sarea_Size);
+ PlugSubSet(G->Sarea, G->Sarea_Size);
Row->Clear();
return rc;
} // end of WriteDB
diff --git a/storage/connect/tabjson.h b/storage/connect/tabjson.h
index 2ff72905e86..fcbfe4ed1ec 100644
--- a/storage/connect/tabjson.h
+++ b/storage/connect/tabjson.h
@@ -1,11 +1,11 @@
/*************** tabjson H Declares Source Code File (.H) **************/
/* Name: tabjson.h Version 1.3 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
+/* (C) Copyright to the author Olivier BERTRAND 2014 - 2018 */
/* */
/* This file contains the JSON classes declares. */
/***********************************************************************/
-#include "osutil.h"
+//#include "osutil.h" // Unuseful and bad for OEM
#include "block.h"
#include "colblk.h"
#include "json.h"
@@ -16,7 +16,7 @@ typedef class JSONDEF *PJDEF;
typedef class TDBJSON *PJTDB;
typedef class JSONCOL *PJCOL;
class TDBJSN;
-PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info);
+DllExport PQRYRES JSONColumns(PGLOBAL, PCSZ, PCSZ, PTOS, bool);
/***********************************************************************/
/* The JSON tree node. Can be an Object or an Array. */
diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp
index fddfb0c0420..0fa117c3d2f 100644
--- a/storage/connect/tabodbc.cpp
+++ b/storage/connect/tabodbc.cpp
@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 2000-2017 */
+/* (C) Copyright to the author Olivier BERTRAND 2000-2018 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -95,23 +95,23 @@ bool ExactInfo(void);
/* Constructor. */
/***********************************************************************/
ODBCDEF::ODBCDEF(void)
- {
+{
Connect = NULL;
Catver = 0;
UseCnc = false;
- } // end of ODBCDEF constructor
+} // end of ODBCDEF constructor
/***********************************************************************/
/* DefineAM: define specific AM block values from XDB file. */
/***********************************************************************/
bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
- {
+{
Desc = Connect = GetStringCatInfo(g, "Connect", NULL);
if (!Connect && !Catfunc) {
sprintf(g->Message, "Missing connection for ODBC table %s", Name);
return true;
- } // endif Connect
+ } // endif Connect
if (EXTDEF::DefineAM(g, am, poff))
return true;
@@ -123,13 +123,13 @@ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Qto= GetIntCatInfo("QueryTimeout", DEFAULT_QUERY_TIMEOUT);
UseCnc = GetBoolCatInfo("UseDSN", false);
return false;
- } // end of DefineAM
+} // end of DefineAM
/***********************************************************************/
/* GetTable: makes a new Table Description Block. */
/***********************************************************************/
PTDB ODBCDEF::GetTable(PGLOBAL g, MODE m)
- {
+{
PTDB tdbp = NULL;
/*********************************************************************/
@@ -158,10 +158,10 @@ PTDB ODBCDEF::GetTable(PGLOBAL g, MODE m)
tdbp = new(g) TDBMUL(tdbp);
else if (Multiple == 2)
strcpy(g->Message, MSG(NO_ODBC_MUL));
- } // endswitch Catfunc
+ } // endswitch Catfunc
return tdbp;
- } // end of GetTable
+} // end of GetTable
/* -------------------------- Class TDBODBC -------------------------- */
@@ -169,7 +169,7 @@ PTDB ODBCDEF::GetTable(PGLOBAL g, MODE m)
/* Implementation of the TDBODBC class. */
/***********************************************************************/
TDBODBC::TDBODBC(PODEF tdp) : TDBEXT(tdp)
- {
+{
Ocp = NULL;
Cnp = NULL;
@@ -191,19 +191,19 @@ TDBODBC::TDBODBC(PODEF tdp) : TDBEXT(tdp)
Ops.UseCnc = false;
} // endif tdp
- } // end of TDBODBC standard constructor
+} // end of TDBODBC standard constructor
TDBODBC::TDBODBC(PTDBODBC tdbp) : TDBEXT(tdbp)
- {
+{
Ocp = tdbp->Ocp; // is that right ?
Cnp = tdbp->Cnp;
Connect = tdbp->Connect;
Ops = tdbp->Ops;
- } // end of TDBODBC copy constructor
+} // end of TDBODBC copy constructor
// Method
PTDB TDBODBC::Clone(PTABS t)
- {
+{
PTDB tp;
PODBCCOL cp1, cp2;
PGLOBAL g = t->G; // Is this really useful ???
@@ -213,18 +213,18 @@ PTDB TDBODBC::Clone(PTABS t)
for (cp1 = (PODBCCOL)Columns; cp1; cp1 = (PODBCCOL)cp1->GetNext()) {
cp2 = new(g) ODBCCOL(cp1, tp); // Make a copy
NewPointer(t, cp1, cp2);
- } // endfor cp1
+ } // endfor cp1
return tp;
- } // end of CopyOne
+} // end of CopyOne
/***********************************************************************/
/* Allocate ODBC column description block. */
/***********************************************************************/
PCOL TDBODBC::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
- {
+{
return new(g) ODBCCOL(cdp, this, cprec, n);
- } // end of MakeCol
+} // end of MakeCol
/***********************************************************************/
/* Extract the filename from connect string and return it. */
@@ -232,7 +232,7 @@ PCOL TDBODBC::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
/* with a place holder to be used by SetFile. */
/***********************************************************************/
PCSZ TDBODBC::GetFile(PGLOBAL g)
- {
+{
if (Connect) {
char *p1, *p2;
int i;
@@ -263,18 +263,18 @@ PCSZ TDBODBC::GetFile(PGLOBAL g)
memcpy(MulConn, Connect, p1 - Connect);
MulConn[p1 - Connect] = '\0';
strcat(strcat(MulConn, "%s"), (p2) ? p2 : ";");
- } // endif p1
+ } // endif p1
- } // endif Connect
+ } // endif Connect
return (DBQ) ? DBQ : (PSZ)"???";
- } // end of GetFile
+} // end of GetFile
/***********************************************************************/
/* Set DBQ and get the new file name into the connect string. */
/***********************************************************************/
void TDBODBC::SetFile(PGLOBAL g, PCSZ fn)
- {
+{
if (MulConn) {
int n = strlen(MulConn) + strlen(fn) - 1;
@@ -283,20 +283,20 @@ void TDBODBC::SetFile(PGLOBAL g, PCSZ fn)
// of having to reallocate it is reduced.
BufSize = n + 6;
Connect = (char*)PlugSubAlloc(g, NULL, BufSize);
- } // endif n
+ } // endif n
// Make the complete connect string
sprintf(Connect, MulConn, fn);
- } // endif MultConn
+ } // endif MultConn
DBQ = PlugDup(g, fn);
- } // end of SetFile
+} // end of SetFile
/***********************************************************************/
/* MakeInsert: make the Insert statement used with ODBC connection. */
/***********************************************************************/
bool TDBODBC::MakeInsert(PGLOBAL g)
- {
+{
PCSZ schmp = NULL;
char *catp = NULL, buf[NAM_LEN * 3];
int len = 0;
@@ -377,7 +377,7 @@ bool TDBODBC::MakeInsert(PGLOBAL g)
} else
Query->Append(buf);
- } // endfor colp
+ } // endfor colp
Query->Append(") VALUES (");
@@ -390,32 +390,32 @@ bool TDBODBC::MakeInsert(PGLOBAL g)
Query->RepLast(')');
return oom;
- } // end of MakeInsert
+} // end of MakeInsert
/***********************************************************************/
/* ODBC Bind Parameter function. */
/***********************************************************************/
bool TDBODBC::BindParameters(PGLOBAL g)
- {
- PODBCCOL colp;
+{
+ PODBCCOL colp;
- for (colp = (PODBCCOL)Columns; colp; colp = (PODBCCOL)colp->Next) {
- colp->AllocateBuffers(g, 0);
+ for (colp = (PODBCCOL)Columns; colp; colp = (PODBCCOL)colp->Next) {
+ colp->AllocateBuffers(g, 0);
- if (Ocp->BindParam(colp))
- return true;
+ if (Ocp->BindParam(colp))
+ return true;
- } // endfor colp
+ } // endfor colp
- return false;
- } // end of BindParameters
+ return false;
+} // end of BindParameters
#if 0
/***********************************************************************/
/* MakeUpdate: make the SQL statement to send to ODBC connection. */
/***********************************************************************/
char *TDBODBC::MakeUpdate(PGLOBAL g)
- {
+{
char *qc, *stmt = NULL, cmd[8], tab[96], end[1024];
stmt = (char*)PlugSubAlloc(g, NULL, strlen(Qrystr) + 64);
@@ -440,60 +440,60 @@ char *TDBODBC::MakeUpdate(PGLOBAL g)
strcat(stmt, end);
return stmt;
- } // end of MakeUpdate
+} // end of MakeUpdate
/***********************************************************************/
/* MakeDelete: make the SQL statement to send to ODBC connection. */
/***********************************************************************/
char *TDBODBC::MakeDelete(PGLOBAL g)
- {
- char *qc, *stmt = NULL, cmd[8], from[8], tab[96], end[512];
-
- stmt = (char*)PlugSubAlloc(g, NULL, strlen(Qrystr) + 64);
- memset(end, 0, sizeof(end));
-
- if (sscanf(Qrystr, "%s %s `%[^`]`%511c", cmd, from, tab, end) > 2 ||
- sscanf(Qrystr, "%s %s \"%[^\"]\"%511c", cmd, from, tab, end) > 2)
- qc = Ocp->GetQuoteChar();
- else if (sscanf(Qrystr, "%s %s %s%511c", cmd, from, tab, end) > 2)
- qc = (Quoted) ? Quote : "";
- else {
- strcpy(g->Message, "Cannot use this DELETE command");
- return NULL;
- } // endif sscanf
-
- assert(!stricmp(cmd, "delete") && !stricmp(from, "from"));
- strcat(strcat(strcat(strcpy(stmt, "DELETE FROM "), qc), TableName), qc);
-
- if (*end) {
- for (int i = 0; end[i]; i++)
- if (end[i] == '`')
- end[i] = *qc;
-
- strcat(stmt, end);
- } // endif end
-
- return stmt;
- } // end of MakeDelete
+{
+ char *qc, *stmt = NULL, cmd[8], from[8], tab[96], end[512];
+
+ stmt = (char*)PlugSubAlloc(g, NULL, strlen(Qrystr) + 64);
+ memset(end, 0, sizeof(end));
+
+ if (sscanf(Qrystr, "%s %s `%[^`]`%511c", cmd, from, tab, end) > 2 ||
+ sscanf(Qrystr, "%s %s \"%[^\"]\"%511c", cmd, from, tab, end) > 2)
+ qc = Ocp->GetQuoteChar();
+ else if (sscanf(Qrystr, "%s %s %s%511c", cmd, from, tab, end) > 2)
+ qc = (Quoted) ? Quote : "";
+ else {
+ strcpy(g->Message, "Cannot use this DELETE command");
+ return NULL;
+ } // endif sscanf
+
+ assert(!stricmp(cmd, "delete") && !stricmp(from, "from"));
+ strcat(strcat(strcat(strcpy(stmt, "DELETE FROM "), qc), TableName), qc);
+
+ if (*end) {
+ for (int i = 0; end[i]; i++)
+ if (end[i] == '`')
+ end[i] = *qc;
+
+ strcat(stmt, end);
+ } // endif end
+
+ return stmt;
+} // end of MakeDelete
#endif // 0
/***********************************************************************/
/* ResetSize: call by TDBMUL when calculating size estimate. */
/***********************************************************************/
void TDBODBC::ResetSize(void)
- {
+{
MaxSize = -1;
if (Ocp && Ocp->IsOpen())
Ocp->Close();
- } // end of ResetSize
+} // end of ResetSize
/***********************************************************************/
/* ODBC Cardinality: returns table size in number of rows. */
/***********************************************************************/
int TDBODBC::Cardinality(PGLOBAL g)
- {
+{
if (!g)
return (Mode == MODE_ANY && !Srcdef) ? 1 : 0;
@@ -526,7 +526,7 @@ int TDBODBC::Cardinality(PGLOBAL g)
Cardinal = 10; // To make MySQL happy
return Cardinal;
- } // end of Cardinality
+} // end of Cardinality
/***********************************************************************/
/* ODBC Access Method opening routine. */
@@ -535,7 +535,7 @@ int TDBODBC::Cardinality(PGLOBAL g)
/* join block of next table if it exists or else are discarted. */
/***********************************************************************/
bool TDBODBC::OpenDB(PGLOBAL g)
- {
+{
bool rc = true;
if (trace(1))
@@ -571,7 +571,7 @@ bool TDBODBC::OpenDB(PGLOBAL g)
Fpos = 0;
Curpos = 1;
return false;
- } // endif use
+ } // endif use
/*********************************************************************/
/* Open an ODBC connection for this table. */
@@ -593,7 +593,7 @@ bool TDBODBC::OpenDB(PGLOBAL g)
Use = USE_OPEN; // Do it now in case we are recursively called
/*********************************************************************/
- /* Make the command and allocate whatever is used for getting results. */
+ /* Make the command and allocate whatever is used for getting results*/
/*********************************************************************/
if (Mode == MODE_READ || Mode == MODE_READX) {
if (Memory > 1 && !Srcdef) {
@@ -624,7 +624,7 @@ bool TDBODBC::OpenDB(PGLOBAL g)
} else
return true;
- } // endif Memory
+ } // endif Memory
if (!(rc = MakeSQL(g, false))) {
for (PODBCCOL colp = (PODBCCOL)Columns; colp;
@@ -635,7 +635,7 @@ bool TDBODBC::OpenDB(PGLOBAL g)
rc = (Mode == MODE_READ)
? ((Rows = Ocp->ExecDirectSQL(Query->GetStr(), (PODBCCOL)Columns)) < 0)
: false;
- } // endif rc
+ } // endif rc
} else if (Mode == MODE_INSERT) {
if (!(rc = MakeInsert(g))) {
@@ -645,7 +645,7 @@ bool TDBODBC::OpenDB(PGLOBAL g)
} else
rc = BindParameters(g);
- } // endif rc
+ } // endif rc
} else if (Mode == MODE_UPDATE || Mode == MODE_DELETE) {
rc = false; // wait for CheckCond before calling MakeCommand(g);
@@ -655,30 +655,30 @@ bool TDBODBC::OpenDB(PGLOBAL g)
if (rc) {
Ocp->Close();
return true;
- } // endif rc
+ } // endif rc
/*********************************************************************/
/* Reset statistics values. */
/*********************************************************************/
num_read = num_there = num_eq[0] = num_eq[1] = 0;
return false;
- } // end of OpenDB
+} // end of OpenDB
#if 0
/***********************************************************************/
/* GetRecpos: return the position of last read record. */
/***********************************************************************/
int TDBODBC::GetRecpos(void)
- {
+{
return Fpos;
- } // end of GetRecpos
+} // end of GetRecpos
#endif // 0
/***********************************************************************/
/* SetRecpos: set the position of next read record. */
/***********************************************************************/
bool TDBODBC::SetRecpos(PGLOBAL g, int recpos)
- {
+{
if (Ocp->m_Full) {
Fpos = 0;
CurNum = recpos - 1;
@@ -696,14 +696,15 @@ bool TDBODBC::SetRecpos(PGLOBAL g, int recpos)
} // endif recpos
} else {
- strcpy(g->Message, "This action requires a scrollable cursor");
+ strcpy(g->Message,
+ "This action requires Memory setting or a scrollable cursor");
return true;
} // endif's
// Indicate the table position was externally set
Placed = true;
return false;
- } // end of SetRecpos
+} // end of SetRecpos
/***********************************************************************/
/* Data Base indexed read routine for ODBC access method. */
@@ -721,7 +722,7 @@ bool TDBODBC::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr)
Rows = Ocp->ExecDirectSQL((char*)Query->GetStr(), (PODBCCOL)Columns);
Mode = MODE_READ;
return (Rows < 0);
- } // endif key
+ } // endif key
return false;
} else {
@@ -737,7 +738,7 @@ bool TDBODBC::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr)
if ((To_CondFil = hc->CheckCond(g, To_CondFil, Cond)))
PlugSubAlloc(g, NULL, strlen(To_CondFil->Body) + 1);
- } // endif active_index
+ } // endif active_index
if (To_CondFil)
if (Query->Append(" AND ") || Query->Append(To_CondFil->Body)) {
@@ -762,7 +763,7 @@ bool TDBODBC::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr)
/* VRDNDOS: Data Base read routine for odbc access method. */
/***********************************************************************/
int TDBODBC::ReadDB(PGLOBAL g)
- {
+{
int rc;
if (trace(2))
@@ -784,7 +785,7 @@ int TDBODBC::ReadDB(PGLOBAL g)
} else
return RC_FX; // Error
- } // endif Mode
+ } // endif Mode
/*********************************************************************/
/* Now start the reading process. */
@@ -813,7 +814,7 @@ int TDBODBC::ReadDB(PGLOBAL g)
Qrp->Nblin++;
Fpos++; // Used for memory and pos
- } // endif rc
+ } // endif rc
} // endif Placed
@@ -821,13 +822,13 @@ int TDBODBC::ReadDB(PGLOBAL g)
htrc(" Read: Rbuf=%d rc=%d\n", Rbuf, rc);
return rc;
- } // end of ReadDB
+} // end of ReadDB
/***********************************************************************/
/* Data Base Insert write routine for ODBC access method. */
/***********************************************************************/
int TDBODBC::WriteDB(PGLOBAL g)
- {
+{
int n = Ocp->ExecuteSQL();
if (n < 0) {
@@ -837,13 +838,13 @@ int TDBODBC::WriteDB(PGLOBAL g)
AftRows += n;
return RC_OK;
- } // end of WriteDB
+} // end of WriteDB
/***********************************************************************/
/* Data Base delete line routine for ODBC access method. */
/***********************************************************************/
int TDBODBC::DeleteDB(PGLOBAL g, int irc)
- {
+{
if (irc == RC_FX) {
if (!Query && MakeCommand(g))
return RC_FX;
@@ -863,13 +864,13 @@ int TDBODBC::DeleteDB(PGLOBAL g, int irc)
} else
return RC_OK; // Ignore
- } // end of DeleteDB
+} // end of DeleteDB
/***********************************************************************/
/* Data Base close routine for ODBC access method. */
/***********************************************************************/
void TDBODBC::CloseDB(PGLOBAL g)
- {
+{
if (Ocp)
Ocp->Close();
@@ -877,7 +878,7 @@ void TDBODBC::CloseDB(PGLOBAL g)
if (trace(1))
htrc("ODBC CloseDB: closing %s\n", Name);
- } // end of CloseDB
+} // end of CloseDB
/* --------------------------- ODBCCOL ------------------------------- */
@@ -886,33 +887,33 @@ void TDBODBC::CloseDB(PGLOBAL g)
/***********************************************************************/
ODBCCOL::ODBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
: EXTCOL(cdp, tdbp, cprec, i, am)
- {
+{
// Set additional ODBC access method information for column.
Slen = 0;
StrLen = &Slen;
Sqlbuf = NULL;
- } // end of ODBCCOL constructor
+} // end of ODBCCOL constructor
/***********************************************************************/
/* ODBCCOL private constructor. */
/***********************************************************************/
ODBCCOL::ODBCCOL(void) : EXTCOL()
- {
+{
Slen = 0;
StrLen = &Slen;
Sqlbuf = NULL;
- } // end of ODBCCOL constructor
+} // end of ODBCCOL constructor
/***********************************************************************/
/* ODBCCOL constructor used for copying columns. */
/* tdbp is the pointer to the new table descriptor. */
/***********************************************************************/
ODBCCOL::ODBCCOL(ODBCCOL *col1, PTDB tdbp) : EXTCOL(col1, tdbp)
- {
+{
Slen = col1->Slen;
StrLen = col1->StrLen;
Sqlbuf = col1->Sqlbuf;
- } // end of ODBCCOL copy constructor
+} // end of ODBCCOL copy constructor
/***********************************************************************/
/* ReadColumn: when SQLFetch is used there is nothing to do as the */
@@ -920,7 +921,7 @@ ODBCCOL::ODBCCOL(ODBCCOL *col1, PTDB tdbp) : EXTCOL(col1, tdbp)
/* when calculating MaxSize (Bufp is NULL even when Rows is not). */
/***********************************************************************/
void ODBCCOL::ReadColumn(PGLOBAL g)
- {
+{
PTDBODBC tdbp = (PTDBODBC)To_Tdb;
int i = tdbp->Fpos - 1, n = tdbp->CurNum;
@@ -953,7 +954,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g)
else
Value->SetValue_pvblk(Blkp, n);
- } // endif Bufp
+ } // endif Bufp
if (Buf_Type == TYPE_DATE) {
struct tm dbtime;
@@ -980,7 +981,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g)
htrc("ODBC Column %s: rows=%d buf=%p type=%d value=%s\n",
Name, tdbp->Rows, Bufp, Buf_Type, Value->GetCharString(buf));
- } // endif trace
+ } // endif trace
put:
if (tdbp->Memory != 2)
@@ -997,7 +998,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g)
} else
Crp->Kdata->SetValue(Value, i);
- } // end of ReadColumn
+} // end of ReadColumn
/***********************************************************************/
/* AllocateBuffers: allocate the extended buffer for SQLExtendedFetch */
@@ -1005,7 +1006,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g)
/* for the ending null character. */
/***********************************************************************/
void ODBCCOL::AllocateBuffers(PGLOBAL g, int rows)
- {
+{
if (Buf_Type == TYPE_DATE)
Sqlbuf = (TIMESTAMP_STRUCT*)PlugSubAlloc(g, NULL,
sizeof(TIMESTAMP_STRUCT));
@@ -1019,31 +1020,31 @@ void ODBCCOL::AllocateBuffers(PGLOBAL g, int rows)
Blkp = AllocValBlock(g, NULL, Buf_Type, rows, GetBuflen(),
GetScale(), true, false, false);
Bufp = Blkp->GetValPointer();
- } // endelse
+ } // endelse
if (rows > 1)
StrLen = (SQLLEN *)PlugSubAlloc(g, NULL, rows * sizeof(SQLLEN));
- } // end of AllocateBuffers
+} // end of AllocateBuffers
/***********************************************************************/
/* Returns the buffer to use for Fetch or Extended Fetch. */
/***********************************************************************/
void *ODBCCOL::GetBuffer(DWORD rows)
- {
+{
if (rows && To_Tdb) {
assert(rows == (DWORD)((TDBODBC*)To_Tdb)->Rows);
return Bufp;
} else
return (Buf_Type == TYPE_DATE) ? Sqlbuf : Value->GetTo_Val();
- } // end of GetBuffer
+} // end of GetBuffer
/***********************************************************************/
/* Returns the buffer length to use for Fetch or Extended Fetch. */
/***********************************************************************/
SWORD ODBCCOL::GetBuflen(void)
- {
+{
SWORD flen;
switch (Buf_Type) {
@@ -1059,13 +1060,13 @@ SWORD ODBCCOL::GetBuflen(void)
} // endswitch Buf_Type
return flen;
- } // end of GetBuflen
+} // end of GetBuflen
/***********************************************************************/
/* WriteColumn: make sure the bind buffer is updated. */
/***********************************************************************/
void ODBCCOL::WriteColumn(PGLOBAL g)
- {
+{
/*********************************************************************/
/* Do convert the column value if necessary. */
/*********************************************************************/
@@ -1095,7 +1096,7 @@ void ODBCCOL::WriteColumn(PGLOBAL g)
*StrLen = (Value->IsNull()) ? SQL_NULL_DATA :
(IsTypeChar(Buf_Type)) ? SQL_NTS : 0;
- } // end of WriteColumn
+} // end of WriteColumn
/* -------------------------- Class TDBXDBC -------------------------- */
@@ -1119,7 +1120,7 @@ TDBXDBC::TDBXDBC(PTDBXDBC tdbp) : TDBODBC(tdbp)
} // end of TDBXDBC copy constructor
PTDB TDBXDBC::Clone(PTABS t)
- {
+{
PTDB tp;
PXSRCCOL cp1, cp2;
PGLOBAL g = t->G; // Is this really useful ???
@@ -1129,29 +1130,29 @@ PTDB TDBXDBC::Clone(PTABS t)
for (cp1 = (PXSRCCOL)Columns; cp1; cp1 = (PXSRCCOL)cp1->GetNext()) {
cp2 = new(g) XSRCCOL(cp1, tp); // Make a copy
NewPointer(t, cp1, cp2);
- } // endfor cp1
+ } // endfor cp1
return tp;
- } // end of CopyOne
+} // end of CopyOne
/***********************************************************************/
/* Allocate XSRC column description block. */
/***********************************************************************/
PCOL TDBXDBC::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
- {
+{
PXSRCCOL colp = new(g) XSRCCOL(cdp, this, cprec, n);
if (!colp->Flag)
Cmdcol = colp->GetName();
return colp;
- } // end of MakeCol
+} // end of MakeCol
/***********************************************************************/
/* MakeCMD: make the SQL statement to send to ODBC connection. */
/***********************************************************************/
PCMD TDBXDBC::MakeCMD(PGLOBAL g)
- {
+{
PCMD xcmd = NULL;
if (To_CondFil) {
@@ -1171,14 +1172,14 @@ PCMD TDBXDBC::MakeCMD(PGLOBAL g)
xcmd = new(g) CMD(g, Srcdef);
return xcmd;
- } // end of MakeCMD
+} // end of MakeCMD
#if 0
/***********************************************************************/
/* ODBC Bind Parameter function. */
/***********************************************************************/
bool TDBXDBC::BindParameters(PGLOBAL g)
- {
+{
PODBCCOL colp;
for (colp = (PODBCCOL)Columns; colp; colp = (PODBCCOL)colp->Next) {
@@ -1190,19 +1191,19 @@ bool TDBXDBC::BindParameters(PGLOBAL g)
} // endfor colp
return false;
- } // end of BindParameters
+} // end of BindParameters
#endif // 0
/***********************************************************************/
/* XDBC GetMaxSize: returns table size (not always one row). */
/***********************************************************************/
int TDBXDBC::GetMaxSize(PGLOBAL g)
- {
+{
if (MaxSize < 0)
MaxSize = 10; // Just a guess
return MaxSize;
- } // end of GetMaxSize
+} // end of GetMaxSize
/***********************************************************************/
/* ODBC Access Method opening routine. */
@@ -1211,7 +1212,7 @@ int TDBXDBC::GetMaxSize(PGLOBAL g)
/* join block of next table if it exists or else are discarted. */
/***********************************************************************/
bool TDBXDBC::OpenDB(PGLOBAL g)
- {
+{
bool rc = false;
if (trace(1))
@@ -1221,7 +1222,7 @@ bool TDBXDBC::OpenDB(PGLOBAL g)
if (Use == USE_OPEN) {
strcpy(g->Message, "Multiple execution is not allowed");
return true;
- } // endif use
+ } // endif use
/*********************************************************************/
/* Open an ODBC connection for this table. */
@@ -1243,7 +1244,7 @@ bool TDBXDBC::OpenDB(PGLOBAL g)
if (Mode != MODE_READ && Mode != MODE_READX) {
strcpy(g->Message, "No INSERT/DELETE/UPDATE of XDBC tables");
return true;
- } // endif Mode
+ } // endif Mode
/*********************************************************************/
/* Get the command to execute. */
@@ -1256,13 +1257,13 @@ bool TDBXDBC::OpenDB(PGLOBAL g)
Rows = 1;
return false;
- } // end of OpenDB
+} // end of OpenDB
/***********************************************************************/
/* ReadDB: Data Base read routine for xdbc access method. */
/***********************************************************************/
int TDBXDBC::ReadDB(PGLOBAL g)
- {
+{
if (Cmdlist) {
if (!Query)
Query = new(g)STRING(g, 0, Cmdlist->Cmd);
@@ -1280,25 +1281,25 @@ int TDBXDBC::ReadDB(PGLOBAL g)
return RC_EF;
} // endif Cmdlist
- } // end of ReadDB
+} // end of ReadDB
/***********************************************************************/
-/* Data Base delete line routine for ODBC access method. */
+/* Data Base write line routine for XDBC access method. */
/***********************************************************************/
int TDBXDBC::WriteDB(PGLOBAL g)
- {
+{
strcpy(g->Message, "Execsrc tables are read only");
return RC_FX;
- } // end of DeleteDB
+} // end of DeleteDB
/***********************************************************************/
-/* Data Base delete line routine for ODBC access method. */
+/* Data Base delete line routine for XDBC access method. */
/***********************************************************************/
int TDBXDBC::DeleteDB(PGLOBAL g, int irc)
- {
+{
strcpy(g->Message, MSG(NO_ODBC_DELETE));
return RC_FX;
- } // end of DeleteDB
+} // end of DeleteDB
/* --------------------------- XSRCCOL ------------------------------- */
@@ -1307,25 +1308,25 @@ int TDBXDBC::DeleteDB(PGLOBAL g, int irc)
/***********************************************************************/
XSRCCOL::XSRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
: ODBCCOL(cdp, tdbp, cprec, i, am)
- {
+{
// Set additional ODBC access method information for column.
Flag = cdp->GetOffset();
- } // end of XSRCCOL constructor
+} // end of XSRCCOL constructor
/***********************************************************************/
/* XSRCCOL constructor used for copying columns. */
/* tdbp is the pointer to the new table descriptor. */
/***********************************************************************/
XSRCCOL::XSRCCOL(XSRCCOL *col1, PTDB tdbp) : ODBCCOL(col1, tdbp)
- {
+{
Flag = col1->Flag;
- } // end of XSRCCOL copy constructor
+} // end of XSRCCOL copy constructor
/***********************************************************************/
/* ReadColumn: set column value according to Flag. */
/***********************************************************************/
void XSRCCOL::ReadColumn(PGLOBAL g)
- {
+{
PTDBXDBC tdbp = (PTDBXDBC)To_Tdb;
switch (Flag) {
@@ -1335,15 +1336,15 @@ void XSRCCOL::ReadColumn(PGLOBAL g)
default: Value->SetValue_psz("Invalid Flag"); break;
} // endswitch Flag
- } // end of ReadColumn
+} // end of ReadColumn
/***********************************************************************/
/* WriteColumn: Should never be called. */
/***********************************************************************/
void XSRCCOL::WriteColumn(PGLOBAL g)
- {
+{
// Should never be called
- } // end of WriteColumn
+} // end of WriteColumn
/* ---------------------------TDBDRV class --------------------------- */
@@ -1351,9 +1352,9 @@ void XSRCCOL::WriteColumn(PGLOBAL g)
/* GetResult: Get the list of ODBC drivers. */
/***********************************************************************/
PQRYRES TDBDRV::GetResult(PGLOBAL g)
- {
+{
return ODBCDrivers(g, Maxres, false);
- } // end of GetResult
+} // end of GetResult
/* ---------------------------TDBSRC class --------------------------- */
@@ -1361,9 +1362,9 @@ PQRYRES TDBDRV::GetResult(PGLOBAL g)
/* GetResult: Get the list of ODBC data sources. */
/***********************************************************************/
PQRYRES TDBSRC::GetResult(PGLOBAL g)
- {
+{
return ODBCDataSources(g, Maxres, false);
- } // end of GetResult
+} // end of GetResult
/* ---------------------------TDBOTB class --------------------------- */
@@ -1371,7 +1372,7 @@ PQRYRES TDBSRC::GetResult(PGLOBAL g)
/* TDBOTB class constructor. */
/***********************************************************************/
TDBOTB::TDBOTB(PODEF tdp) : TDBDRV(tdp)
- {
+{
Dsn = tdp->GetConnect();
Schema = tdp->GetTabschema();
Tab = tdp->GetTabname();
@@ -1381,15 +1382,15 @@ TDBOTB::TDBOTB(PODEF tdp) : TDBDRV(tdp)
Ops.Cto = tdp->Cto;
Ops.Qto = tdp->Qto;
Ops.UseCnc = tdp->UseCnc;
- } // end of TDBOTB constructor
+} // end of TDBOTB constructor
/***********************************************************************/
/* GetResult: Get the list of ODBC tables. */
/***********************************************************************/
PQRYRES TDBOTB::GetResult(PGLOBAL g)
- {
+{
return ODBCTables(g, Dsn, Schema, Tab, Tabtyp, Maxres, false, &Ops);
- } // end of GetResult
+} // end of GetResult
/* ---------------------------TDBOCL class --------------------------- */
@@ -1405,8 +1406,8 @@ TDBOCL::TDBOCL(PODEF tdp) : TDBOTB(tdp)
/* GetResult: Get the list of ODBC table columns. */
/***********************************************************************/
PQRYRES TDBOCL::GetResult(PGLOBAL g)
- {
+{
return ODBCColumns(g, Dsn, Schema, Tab, Colpat, Maxres, false, &Ops);
- } // end of GetResult
+} // end of GetResult
/* ------------------------ End of Tabodbc --------------------------- */
diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp
index 16bc9f91017..573339bce35 100644
--- a/storage/connect/tabxml.cpp
+++ b/storage/connect/tabxml.cpp
@@ -682,6 +682,14 @@ PTDB TDBXML::Clone(PTABS t)
} // end of Clone
/***********************************************************************/
+/* Must not be in tabxml.h because of OEM tables */
+/***********************************************************************/
+const CHARSET_INFO *TDBXML::data_charset()
+{
+ return &my_charset_utf8_general_ci;
+} // end of data_charset
+
+/***********************************************************************/
/* Allocate XML column description block. */
/***********************************************************************/
PCOL TDBXML::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
@@ -2209,8 +2217,9 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
TDBXCT::TDBXCT(PXMLDEF tdp) : TDBCAT(tdp)
{
Topt = tdp->GetTopt();
- Db = (char*)tdp->GetDB();
- Tabn = tdp->Tabname;
+ //Db = (char*)tdp->GetDB();
+ Db = (char*)tdp->Schema;
+ Tabn = tdp->Tabname;
} // end of TDBXCT constructor
/***********************************************************************/
diff --git a/storage/connect/tabxml.h b/storage/connect/tabxml.h
index f55b7d98de7..102767e965a 100644
--- a/storage/connect/tabxml.h
+++ b/storage/connect/tabxml.h
@@ -9,6 +9,8 @@ typedef class XMLDEF *PXMLDEF;
typedef class TDBXML *PTDBXML;
typedef class XMLCOL *PXMLCOL;
+DllExport PQRYRES XMLColumns(PGLOBAL, char *, char *, PTOS, bool);
+
/* --------------------------- XML classes --------------------------- */
/***********************************************************************/
@@ -100,8 +102,7 @@ class DllExport TDBXML : public TDBASE {
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
virtual int CheckWrite(PGLOBAL g) {Checked = true; return 0;}
- virtual const CHARSET_INFO *data_charset()
- {return &my_charset_utf8_general_ci;}
+ virtual const CHARSET_INFO *data_charset();
protected:
// Members
diff --git a/storage/connect/user_connect.cc b/storage/connect/user_connect.cc
index e2d3b664aeb..a2a8faf9b38 100644
--- a/storage/connect/user_connect.cc
+++ b/storage/connect/user_connect.cc
@@ -107,7 +107,7 @@ bool user_connect::user_init()
g= PlugInit(NULL, worksize);
// Check whether the initialization is complete
- if (!g || !g->Sarea || PlugSubSet(g, g->Sarea, g->Sarea_Size)
+ if (!g || !g->Sarea || PlugSubSet(g->Sarea, g->Sarea_Size)
|| !(dup= PlgMakeUser(g))) {
if (g)
printf("%s\n", g->Message);
@@ -172,7 +172,7 @@ bool user_connect::CheckCleanup(bool force)
} // endif worksize
- PlugSubSet(g, g->Sarea, g->Sarea_Size);
+ PlugSubSet(g->Sarea, g->Sarea_Size);
g->Xchk = NULL;
g->Createas = 0;
g->Alchecked = 0;
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index 24e9642c0b8..9e951f8f78b 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -1055,9 +1055,20 @@ static ulint btr_node_ptr_max_size(const dict_index_t* index)
field_max_size = dict_col_get_max_size(col);
if (UNIV_UNLIKELY(!field_max_size)) {
switch (col->mtype) {
+ case DATA_VARCHAR:
+ if (!comp
+ && (!strcmp(index->table->name.m_name,
+ "SYS_FOREIGN")
+ || !strcmp(index->table->name.m_name,
+ "SYS_FOREIGN_COLS"))) {
+ break;
+ }
+ /* fall through */
+ case DATA_VARMYSQL:
case DATA_CHAR:
case DATA_MYSQL:
- /* CHAR(0) is a possible data type.
+ /* CHAR(0) and VARCHAR(0) are possible
+ data type definitions in MariaDB.
The InnoDB internal SQL parser maps
CHAR to DATA_VARCHAR, so DATA_CHAR (or
DATA_MYSQL) is only coming from the
@@ -1073,6 +1084,7 @@ static ulint btr_node_ptr_max_size(const dict_index_t* index)
}
continue;
}
+
/* SYS_FOREIGN.ID is defined as CHAR in the
InnoDB internal SQL parser, which translates
into the incorrect VARCHAR(0). InnoDB does
@@ -1089,6 +1101,7 @@ static ulint btr_node_ptr_max_size(const dict_index_t* index)
|| !strcmp(index->table->name.m_name,
"SYS_FOREIGN_COLS"));
ut_ad(!comp);
+ ut_ad(col->mtype == DATA_VARCHAR);
rec_max_size += (srv_page_size == UNIV_PAGE_SIZE_MAX)
? REDUNDANT_REC_MAX_DATA_SIZE
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 5da61183e80..4bfcdb27f76 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -518,13 +518,13 @@ decompress_with_slot:
/* Verify encryption checksum before we even try to
decrypt. */
if (!fil_space_verify_crypt_checksum(dst_frame, bpage->size)) {
+decrypt_failed:
ib::error() << "Encrypted page " << bpage->id
<< " in file " << space->chain.start->name
<< " looks corrupted; key_version="
<< mach_read_from_4(
FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION
+ dst_frame);
-decrypt_failed:
/* Mark page encrypted in case it should be. */
if (space->crypt_data->type
!= CRYPT_SCHEME_UNENCRYPTED) {
@@ -4387,7 +4387,7 @@ loop:
<< ". The most probable cause"
" of this error may be that the"
" table has been corrupted."
- " See https://mariadb.com/kb/en/library/xtradbinnodb-recovery-modes/";
+ " See https://mariadb.com/kb/en/library/innodb-recovery-modes/";
}
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc
index 485c0f22577..3d373bf37d8 100644
--- a/storage/innobase/dict/dict0mem.cc
+++ b/storage/innobase/dict/dict0mem.cc
@@ -34,7 +34,6 @@ Created 1/8/1996 Heikki Tuuri
#include "mach0data.h"
#include "dict0dict.h"
#include "fts0priv.h"
-#include "ut0crc32.h"
#include "lock0lock.h"
#include "sync0sync.h"
#include "row0row.h"
@@ -82,10 +81,6 @@ const char table_name_t::part_suffix[4]
= "#P#";
#endif
-/** An interger randomly initialized at startup used to make a temporary
-table name as unuique as possible. */
-static ib_uint32_t dict_temp_file_num;
-
/** Display an identifier.
@param[in,out] s output stream
@param[in] id_name SQL identifier (other than table name)
@@ -1112,35 +1107,15 @@ dict_mem_create_temporary_tablename(
ut_ad(dbend);
size_t dblen = size_t(dbend - dbtab) + 1;
- /* Increment a randomly initialized number for each temp file. */
- my_atomic_add32((int32*) &dict_temp_file_num, 1);
-
- size = dblen + (sizeof(TEMP_FILE_PREFIX) + 3 + 20 + 1 + 10);
+ size = dblen + (sizeof(TEMP_FILE_PREFIX) + 3 + 20);
name = static_cast<char*>(mem_heap_alloc(heap, size));
memcpy(name, dbtab, dblen);
snprintf(name + dblen, size - dblen,
- TEMP_FILE_PREFIX_INNODB UINT64PF "-" UINT32PF,
- id, dict_temp_file_num);
+ TEMP_FILE_PREFIX_INNODB UINT64PF, id);
return(name);
}
-/** Initialize dict memory variables */
-void
-dict_mem_init(void)
-{
- /* Initialize a randomly distributed temporary file number */
- ib_uint32_t now = static_cast<ib_uint32_t>(ut_time());
-
- const byte* buf = reinterpret_cast<const byte*>(&now);
-
- dict_temp_file_num = ut_crc32(buf, sizeof(now));
-
- DBUG_PRINT("dict_mem_init",
- ("Starting Temporary file number is " UINT32PF,
- dict_temp_file_num));
-}
-
/** Validate the search order in the foreign key set.
@param[in] fk_set the foreign key set to be validated
@return true if search order is fine in the set, false otherwise. */
diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc
index 9d90c287ffc..57bb736d230 100644
--- a/storage/innobase/fil/fil0pagecompress.cc
+++ b/storage/innobase/fil/fil0pagecompress.cc
@@ -328,14 +328,14 @@ ulint fil_page_decompress(byte* tmp_buf, byte* buf)
case PAGE_ZLIB_ALGORITHM:
{
uLong len = srv_page_size;
- if (Z_OK != uncompress(tmp_buf, &len,
+ if (Z_OK == uncompress(tmp_buf, &len,
buf + header_len,
uLong(actual_size))
- && len != srv_page_size) {
- return 0;
+ && len == srv_page_size) {
+ break;
}
}
- break;
+ return 0;
#ifdef HAVE_LZ4
case PAGE_LZ4_ALGORITHM:
if (LZ4_decompress_safe(reinterpret_cast<const char*>(buf)
diff --git a/storage/innobase/gis/gis0sea.cc b/storage/innobase/gis/gis0sea.cc
index 27b0794c510..a406acabf6e 100644
--- a/storage/innobase/gis/gis0sea.cc
+++ b/storage/innobase/gis/gis0sea.cc
@@ -772,7 +772,7 @@ rtr_page_get_father_node_ptr(
error << ". You should dump + drop + reimport the table to"
" fix the corruption. If the crash happens at"
" database startup, see "
- "https://mariadb.com/kb/en/library/xtradbinnodb-recovery-modes/"
+ "https://mariadb.com/kb/en/library/innodb-recovery-modes/"
" about forcing"
" recovery. Then dump + drop + reimport.";
}
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index b3ac1d43ade..71736488ac5 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -248,10 +248,10 @@ void set_my_errno(int err)
errno = err;
}
-static uint mysql_fields(const TABLE *table)
+static uint omits_virtual_cols(const TABLE_SHARE &share)
{
- return table->s->frm_version < FRM_VER_EXPRESSSIONS
- ? table->s->stored_fields : table->s->fields;
+ return share.frm_version < FRM_VER_EXPRESSSIONS &&
+ share.virtual_fields;
}
/** Checks whether the file name belongs to a partition of a table.
@@ -6112,12 +6112,13 @@ no_such_table:
DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
}
- size_t n_fields = mysql_fields(table);
+ size_t n_fields = omits_virtual_cols(*table_share)
+ ? table_share->stored_fields : table_share->fields;
size_t n_cols = dict_table_get_n_user_cols(ib_table)
+ dict_table_get_n_v_cols(ib_table)
- !!DICT_TF2_FLAG_IS_SET(ib_table, DICT_TF2_FTS_HAS_DOC_ID);
- if (n_cols != n_fields) {
+ if (UNIV_UNLIKELY(n_cols != n_fields)) {
ib::warn() << "Table " << norm_name << " contains "
<< n_cols << " user"
" defined columns in InnoDB, but " << n_fields
@@ -7277,6 +7278,10 @@ build_template_needs_field(
{
const Field* field = table->field[i];
+ if (innobase_is_v_fld(field) && omits_virtual_cols(*table->s)) {
+ return NULL;
+ }
+
if (!index_contains) {
if (read_just_key) {
/* If this is a 'key read', we do not need
@@ -7301,7 +7306,6 @@ build_template_needs_field(
if (fetch_primary_key_cols
&& dict_table_col_in_clustered_key(index->table, i - num_v)) {
/* This field is needed in the query */
-
return(field);
}
@@ -7354,17 +7358,11 @@ build_template_field(
templ = prebuilt->mysql_template + prebuilt->n_template++;
UNIV_MEM_INVALID(templ, sizeof *templ);
-
- if (innobase_is_v_fld(field)) {
- templ->is_virtual = true;
- col = &dict_table_get_nth_v_col(index->table, v_no)->m_col;
- } else {
- templ->is_virtual = false;
- col = dict_table_get_nth_col(index->table, i);
- }
+ templ->is_virtual = innobase_is_v_fld(field);
if (!templ->is_virtual) {
templ->col_no = i;
+ col = dict_table_get_nth_col(index->table, i);
templ->clust_rec_field_no = dict_col_get_clust_pos(
col, clust_index);
/* If clustered index record field is not found, lets print out
@@ -7403,7 +7401,7 @@ build_template_field(
<< table->field[j]->field_name.str;
}
- ib::error() << "Clustered record field for column " << i
+ ib::fatal() << "Clustered record field for column " << i
<< " not found table n_user_defined "
<< clust_index->n_user_defined_cols
<< " index n_user_defined "
@@ -7420,8 +7418,6 @@ build_template_field(
<< table->s->stored_fields
<< " query "
<< innobase_get_stmt_unsafe(current_thd, &size);
-
- ut_a(templ->clust_rec_field_no != ULINT_UNDEFINED);
}
templ->rec_field_is_prefix = FALSE;
templ->rec_prefix_field_no = ULINT_UNDEFINED;
@@ -7439,6 +7435,8 @@ build_template_field(
&templ->rec_prefix_field_no);
}
} else {
+ ut_ad(!omits_virtual_cols(*table->s));
+ col = &dict_table_get_nth_v_col(index->table, v_no)->m_col;
templ->clust_rec_field_no = v_no;
templ->rec_prefix_field_no = ULINT_UNDEFINED;
@@ -7522,10 +7520,8 @@ ha_innobase::build_template(
{
dict_index_t* index;
dict_index_t* clust_index;
- ulint n_fields;
ibool fetch_all_in_key = FALSE;
ibool fetch_primary_key_cols = FALSE;
- ulint i;
if (m_prebuilt->select_lock_type == LOCK_X || m_prebuilt->table->no_rollback()) {
/* We always retrieve the whole clustered index record if we
@@ -7580,7 +7576,8 @@ ha_innobase::build_template(
/* Below we check column by column if we need to access
the clustered index. */
- n_fields = (ulint) mysql_fields(table);
+ const bool skip_virtual = omits_virtual_cols(*table_share);
+ const ulint n_fields = table_share->fields;
if (!m_prebuilt->mysql_template) {
m_prebuilt->mysql_template = (mysql_row_templ_t*)
@@ -7600,25 +7597,25 @@ ha_innobase::build_template(
/* Note that in InnoDB, i is the column number in the table.
MySQL calls columns 'fields'. */
+ ulint num_v = 0;
+
if (active_index != MAX_KEY
&& active_index == pushed_idx_cond_keyno) {
- ulint num_v = 0;
-
/* Push down an index condition or an end_range check. */
- for (i = 0; i < n_fields; i++) {
- ibool index_contains;
-
- if (innobase_is_v_fld(table->field[i])) {
- index_contains = dict_index_contains_col_or_prefix(
- index, num_v, true);
- if (index_contains)
- {
- m_prebuilt->n_template = 0;
- goto no_icp;
- }
- } else {
- index_contains = dict_index_contains_col_or_prefix(
- index, i - num_v, false);
+ for (ulint i = 0; i < n_fields; i++) {
+ const Field* field = table->field[i];
+ const bool is_v = innobase_is_v_fld(field);
+ if (is_v && skip_virtual) {
+ num_v++;
+ continue;
+ }
+ ibool index_contains
+ = dict_index_contains_col_or_prefix(
+ index, is_v ? num_v : i - num_v, is_v);
+ if (is_v && index_contains) {
+ m_prebuilt->n_template = 0;
+ num_v = 0;
+ goto no_icp;
}
/* Test if an end_range or an index condition
@@ -7636,17 +7633,10 @@ ha_innobase::build_template(
the subset
field->part_of_key.is_set(active_index)
which would be acceptable if end_range==NULL. */
- bool is_v = innobase_is_v_fld(table->field[i]);
if (build_template_needs_field_in_icp(
index, m_prebuilt, index_contains,
is_v ? num_v : i - num_v, is_v)) {
- /* Needed in ICP */
- const Field* field;
- mysql_row_templ_t* templ;
-
- if (whole_row) {
- field = table->field[i];
- } else {
+ if (!whole_row) {
field = build_template_needs_field(
index_contains,
m_prebuilt->read_just_key,
@@ -7654,15 +7644,16 @@ ha_innobase::build_template(
fetch_primary_key_cols,
index, table, i, num_v);
if (!field) {
- if (innobase_is_v_fld(
- table->field[i])) {
+ if (is_v) {
num_v++;
}
continue;
}
}
- templ = build_template_field(
+ ut_ad(!is_v);
+
+ mysql_row_templ_t* templ= build_template_field(
m_prebuilt, clust_index, index,
table, field, i - num_v, 0);
@@ -7737,7 +7728,8 @@ ha_innobase::build_template(
< m_prebuilt->index->n_uniq);
*/
}
- if (innobase_is_v_fld(table->field[i])) {
+
+ if (is_v) {
num_v++;
}
}
@@ -7749,29 +7741,24 @@ ha_innobase::build_template(
/* Include the fields that are not needed in index condition
pushdown. */
- for (i = 0; i < n_fields; i++) {
+ for (ulint i = 0; i < n_fields; i++) {
mysql_row_templ_t* templ;
- ibool index_contains;
-
- if (innobase_is_v_fld(table->field[i])) {
- index_contains = dict_index_contains_col_or_prefix(
- index, num_v, true);
- } else {
- index_contains = dict_index_contains_col_or_prefix(
- index, i - num_v, false);
+ const Field* field = table->field[i];
+ const bool is_v = innobase_is_v_fld(field);
+ if (is_v && skip_virtual) {
+ num_v++;
+ continue;
}
- bool is_v = innobase_is_v_fld(table->field[i]);
+ ibool index_contains
+ = dict_index_contains_col_or_prefix(
+ index, is_v ? num_v : i - num_v, is_v);
if (!build_template_needs_field_in_icp(
index, m_prebuilt, index_contains,
is_v ? num_v : i - num_v, is_v)) {
/* Not needed in ICP */
- const Field* field;
-
- if (whole_row) {
- field = table->field[i];
- } else {
+ if (!whole_row) {
field = build_template_needs_field(
index_contains,
m_prebuilt->read_just_key,
@@ -7779,7 +7766,7 @@ ha_innobase::build_template(
fetch_primary_key_cols,
index, table, i, num_v);
if (!field) {
- if (innobase_is_v_fld(table->field[i])) {
+ if (is_v) {
num_v++;
}
continue;
@@ -7789,8 +7776,9 @@ ha_innobase::build_template(
templ = build_template_field(
m_prebuilt, clust_index, index,
table, field, i - num_v, num_v);
+ ut_ad(templ->is_virtual == (ulint)is_v);
- if (templ->is_virtual) {
+ if (is_v) {
num_v++;
}
}
@@ -7800,21 +7788,26 @@ ha_innobase::build_template(
} else {
no_icp:
mysql_row_templ_t* templ;
- ulint num_v = 0;
/* No index condition pushdown */
m_prebuilt->idx_cond = NULL;
+ ut_ad(num_v == 0);
- for (i = 0; i < n_fields; i++) {
- const Field* field;
+ for (ulint i = 0; i < n_fields; i++) {
+ const Field* field = table->field[i];
+ const bool is_v = innobase_is_v_fld(field);
if (whole_row) {
+ if (is_v && skip_virtual) {
+ num_v++;
+ continue;
+ }
/* Even this is whole_row, if the seach is
on a virtual column, and read_just_key is
set, and field is not in this index, we
will not try to fill the value since they
are not stored in such index nor in the
cluster index. */
- if (innobase_is_v_fld(table->field[i])
+ if (is_v
&& m_prebuilt->read_just_key
&& !dict_index_contains_col_or_prefix(
m_prebuilt->index, num_v, true))
@@ -7825,12 +7818,10 @@ no_icp:
num_v++;
continue;
}
-
- field = table->field[i];
} else {
ibool contain;
- if (!innobase_is_v_fld(table->field[i])) {
+ if (!is_v) {
contain = dict_index_contains_col_or_prefix(
index, i - num_v,
false);
@@ -7849,7 +7840,7 @@ no_icp:
fetch_primary_key_cols,
index, table, i, num_v);
if (!field) {
- if (innobase_is_v_fld(table->field[i])) {
+ if (is_v) {
num_v++;
}
continue;
@@ -7859,7 +7850,8 @@ no_icp:
templ = build_template_field(
m_prebuilt, clust_index, index,
table, field, i - num_v, num_v);
- if (templ->is_virtual) {
+ ut_ad(templ->is_virtual == (ulint)is_v);
+ if (is_v) {
num_v++;
}
}
@@ -7868,8 +7860,7 @@ no_icp:
if (index != clust_index && m_prebuilt->need_to_access_clustered) {
/* Change rec_field_no's to correspond to the clustered index
record */
- for (i = 0; i < m_prebuilt->n_template; i++) {
-
+ for (ulint i = 0; i < m_prebuilt->n_template; i++) {
mysql_row_templ_t* templ
= &m_prebuilt->mysql_template[i];
@@ -8297,13 +8288,12 @@ calc_row_difference(
ulint n_changed = 0;
dfield_t dfield;
dict_index_t* clust_index;
- uint i;
ibool changes_fts_column = FALSE;
ibool changes_fts_doc_col = FALSE;
trx_t* const trx = prebuilt->trx;
doc_id_t doc_id = FTS_NULL_DOC_ID;
ulint num_v = 0;
- uint n_fields = mysql_fields(table);
+ const bool skip_virtual = omits_virtual_cols(*table->s);
ut_ad(!srv_read_only_mode);
@@ -8313,16 +8303,15 @@ calc_row_difference(
/* We use upd_buff to convert changed fields */
buf = (byte*) upd_buff;
- for (i = 0; i < n_fields; i++) {
+ for (uint i = 0; i < table->s->fields; i++) {
field = table->field[i];
- bool is_virtual = innobase_is_v_fld(field);
- dict_col_t* col;
-
- if (is_virtual) {
- col = &prebuilt->table->v_cols[num_v].m_col;
- } else {
- col = &prebuilt->table->cols[i - num_v];
+ const bool is_virtual = innobase_is_v_fld(field);
+ if (is_virtual && skip_virtual) {
+ continue;
}
+ dict_col_t* col = is_virtual
+ ? &prebuilt->table->v_cols[num_v].m_col
+ : &prebuilt->table->cols[i - num_v];
o_ptr = (const byte*) old_row + get_field_offset(table, field);
n_ptr = (const byte*) new_row + get_field_offset(table, field);
@@ -8678,33 +8667,25 @@ wsrep_calc_row_hash(
dictionary */
row_prebuilt_t* prebuilt) /*!< in: InnoDB prebuilt struct */
{
- Field* field;
- enum_field_types field_mysql_type;
- uint n_fields;
ulint len;
const byte* ptr;
- ulint col_type;
- uint i;
void *ctx = alloca(my_md5_context_size());
my_md5_init(ctx);
- n_fields = mysql_fields(table);
-
- for (i = 0; i < n_fields; i++) {
+ for (uint i = 0; i < table->s->fields; i++) {
byte null_byte=0;
byte true_byte=1;
- field = table->field[i];
+ const Field* field = table->field[i];
+ if (innobase_is_v_fld(field)) {
+ continue;
+ }
ptr = (const byte*) row + get_field_offset(table, field);
len = field->pack_length();
- field_mysql_type = field->type();
-
- col_type = prebuilt->table->cols[i].mtype;
-
- switch (col_type) {
+ switch (prebuilt->table->cols[i].mtype) {
case DATA_BLOB:
ptr = row_mysql_read_blob_ref(&len, ptr, len);
@@ -8714,7 +8695,7 @@ wsrep_calc_row_hash(
case DATA_VARCHAR:
case DATA_BINARY:
case DATA_VARMYSQL:
- if (field_mysql_type == MYSQL_TYPE_VARCHAR) {
+ if (field->type() == MYSQL_TYPE_VARCHAR) {
/* This is a >= 5.0.3 type true VARCHAR where
the real payload data length is stored in
1 or 2 bytes */
@@ -10616,9 +10597,9 @@ create_table_check_doc_id_col(
ULINT_UNDEFINED if column is of the
wrong type/name/size */
{
- uint n_fields = mysql_fields(form);
+ ut_ad(!omits_virtual_cols(*form->s));
- for (ulint i = 0; i < n_fields; i++) {
+ for (ulint i = 0; i < form->s->fields; i++) {
const Field* field;
ulint col_type;
ulint col_len;
@@ -21070,7 +21051,7 @@ const char* BUG_REPORT_MSG =
const char* FORCE_RECOVERY_MSG =
"Please refer to "
- "https://mariadb.com/kb/en/library/xtradbinnodb-recovery-modes/"
+ "https://mariadb.com/kb/en/library/innodb-recovery-modes/"
" for information about forcing recovery.";
const char* ERROR_CREATING_MSG =
@@ -21088,7 +21069,7 @@ const char* SET_TRANSACTION_MSG =
"Please refer to https://mariadb.com/kb/en/library/set-transaction/";
const char* INNODB_PARAMETERS_MSG =
- "Please refer to https://mariadb.com/kb/en/library/xtradbinnodb-server-system-variables/";
+ "Please refer to https://mariadb.com/kb/en/library/innodb-system-variables/";
/**********************************************************************
Converts an identifier from my_charset_filename to UTF-8 charset.
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index ba17febeda9..3ceb3017ab3 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -8767,6 +8767,14 @@ err_exit:
index != NULL;
index = dict_table_get_next_index(index)) {
+ bool has_prefixes = false;
+ for (size_t i = 0; i < dict_index_get_n_fields(index); i++) {
+ if (dict_index_get_nth_field(index, i)->prefix_len) {
+ has_prefixes = true;
+ break;
+ }
+ }
+
for (ulint i = 0; i < dict_index_get_n_fields(index); i++) {
const dict_field_t& f = index->fields[i];
DBUG_ASSERT(!f.name == f.col->is_dropped());
@@ -8778,26 +8786,19 @@ err_exit:
info = pars_info_create();
+ ulint pos = has_prefixes ? i << 16 | f.prefix_len : i;
+
pars_info_add_ull_literal(info, "indexid", index->id);
- pars_info_add_int4_literal(info, "nth", i);
+ pars_info_add_int4_literal(info, "nth", pos);
pars_info_add_str_literal(info, "new", to);
error = que_eval_sql(
info,
"PROCEDURE RENAME_SYS_FIELDS_PROC () IS\n"
"BEGIN\n"
-
"UPDATE SYS_FIELDS SET COL_NAME=:new\n"
"WHERE INDEX_ID=:indexid\n"
"AND POS=:nth;\n"
-
- /* Try again, in case there is a prefix_len
- encoded in SYS_FIELDS.POS */
-
- "UPDATE SYS_FIELDS SET COL_NAME=:new\n"
- "WHERE INDEX_ID=:indexid\n"
- "AND POS>=65536*:nth AND POS<65536*(:nth+1);\n"
-
"END;\n",
FALSE, trx);
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index e18897df21a..7c9e22296fa 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -495,10 +495,6 @@ dict_mem_create_temporary_tablename(
const char* dbtab,
table_id_t id);
-/** Initialize dict memory variables */
-void
-dict_mem_init(void);
-
/** SQL identifier name wrapper for pretty-printing */
class id_name_t
{
diff --git a/storage/innobase/os/os0event.cc b/storage/innobase/os/os0event.cc
index 4453faedb71..7588020c8db 100644
--- a/storage/innobase/os/os0event.cc
+++ b/storage/innobase/os/os0event.cc
@@ -31,8 +31,6 @@ Created 2012-09-23 Sunny Bains
#include <synchapi.h>
#endif /* _WIN32 */
-#include <list>
-
#ifdef _WIN32
/** Native condition variable. */
typedef CONDITION_VARIABLE os_cond_t;
@@ -41,9 +39,6 @@ typedef CONDITION_VARIABLE os_cond_t;
typedef pthread_cond_t os_cond_t;
#endif /* _WIN32 */
-typedef std::list<os_event_t, ut_allocator<os_event_t> > os_event_list_t;
-typedef os_event_list_t::iterator event_iter_t;
-
/** InnoDB condition variable. */
struct os_event {
os_event() UNIV_NOTHROW;
@@ -123,7 +118,10 @@ struct os_event {
/** @return true if the event is in the signalled state. */
bool is_set() const UNIV_NOTHROW
{
- return(m_set);
+ mutex.enter();
+ bool is_set = m_set;
+ mutex.exit();
+ return is_set;
}
private:
@@ -221,16 +219,13 @@ private:
int64_t signal_count; /*!< this is incremented
each time the event becomes
signaled */
- EventMutex mutex; /*!< this mutex protects
+ mutable EventMutex mutex; /*!< this mutex protects
the next fields */
os_cond_t cond_var; /*!< condition variable is
used in waiting for the event */
-public:
- event_iter_t event_iter; /*!< For O(1) removal from
- list */
protected:
// Disable copying
os_event(const os_event&);
@@ -528,8 +523,6 @@ os_event_destroy(
os_event_t& event) /*!< in/own: event to free */
{
- if (event != NULL) {
- UT_DELETE(event);
- event = NULL;
- }
+ UT_DELETE(event);
+ event = NULL;
}
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index c88bfcb7e1c..0822dc44ef7 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -3315,6 +3315,7 @@ row_drop_table_for_mysql(
pars_info_t* info = NULL;
mem_heap_t* heap = NULL;
+
DBUG_ENTER("row_drop_table_for_mysql");
DBUG_PRINT("row_drop_table_for_mysql", ("table: '%s'", name));
@@ -3345,10 +3346,16 @@ row_drop_table_for_mysql(
| DICT_ERR_IGNORE_CORRUPT));
if (!table) {
- err = DB_TABLE_NOT_FOUND;
- goto funct_exit_all_freed;
+ if (locked_dictionary) {
+ row_mysql_unlock_data_dictionary(trx);
+ }
+ trx->op_info = "";
+ DBUG_RETURN(DB_TABLE_NOT_FOUND);
}
+ const bool is_temp_name = strstr(table->name.m_name,
+ "/" TEMP_FILE_PREFIX);
+
if (table->is_temporary()) {
ut_ad(table->space == fil_system.temp_space);
for (dict_index_t* index = dict_table_get_first_index(table);
@@ -3404,7 +3411,6 @@ row_drop_table_for_mysql(
/* make sure background stats thread is not running on the table */
ut_ad(!(table->stats_bg_flag & BG_STAT_IN_PROGRESS));
-
if (!table->no_rollback()) {
if (table->space != fil_system.sys_space) {
#ifdef BTR_CUR_HASH_ADAPT
@@ -3420,7 +3426,7 @@ row_drop_table_for_mysql(
hold the InnoDB dictionary lock, we will drop any
adaptive hash index entries upfront. */
while (buf_LRU_drop_page_hash_for_tablespace(table)) {
- if (trx_is_interrupted(trx)
+ if ((!is_temp_name && trx_is_interrupted(trx))
|| srv_shutdown_state
!= SRV_SHUTDOWN_NONE) {
err = DB_INTERRUPTED;
@@ -3511,7 +3517,6 @@ row_drop_table_for_mysql(
}
}
-
DBUG_EXECUTE_IF("row_drop_table_add_to_background", goto defer;);
/* TODO: could we replace the counter n_foreign_key_checks_running
@@ -3522,7 +3527,7 @@ row_drop_table_for_mysql(
if (table->n_foreign_key_checks_running > 0) {
defer:
- if (!strstr(table->name.m_name, "/" TEMP_FILE_PREFIX)) {
+ if (!is_temp_name) {
heap = mem_heap_create(FN_REFLEN);
const char* tmp_name
= dict_mem_create_temporary_tablename(
diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc
index b2989a22037..bf347562c71 100644
--- a/storage/innobase/srv/srv0srv.cc
+++ b/storage/innobase/srv/srv0srv.cc
@@ -1070,8 +1070,6 @@ srv_init()
trx_i_s_cache_init(trx_i_s_cache);
ut_crc32_init();
-
- dict_mem_init();
}
/*********************************************************************//**
diff --git a/storage/innobase/ut/ut0dbg.cc b/storage/innobase/ut/ut0dbg.cc
index 56a2eb80337..05b27060a9b 100644
--- a/storage/innobase/ut/ut0dbg.cc
+++ b/storage/innobase/ut/ut0dbg.cc
@@ -52,7 +52,7 @@ ut_dbg_assertion_failed(
" or crashes, even\n"
"InnoDB: immediately after the mysqld startup, there may be\n"
"InnoDB: corruption in the InnoDB tablespace. Please refer to\n"
- "InnoDB: https://mariadb.com/kb/en/library/xtradbinnodb-recovery-modes/\n"
+ "InnoDB: https://mariadb.com/kb/en/library/innodb-recovery-modes/\n"
"InnoDB: about forcing recovery.\n", stderr);
fflush(stderr);
diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt
index 090763a2ece..6bb8c9f6d67 100644
--- a/storage/rocksdb/CMakeLists.txt
+++ b/storage/rocksdb/CMakeLists.txt
@@ -221,7 +221,9 @@ TARGET_LINK_LIBRARIES(sst_dump rocksdblib)
MYSQL_ADD_EXECUTABLE(mysql_ldb tools/mysql_ldb.cc COMPONENT rocksdb-engine)
TARGET_LINK_LIBRARIES(mysql_ldb rocksdb_tools rocksdb_aux_lib dbug)
-INSTALL_SCRIPT(myrocks_hotbackup COMPONENT rocksdb-engine)
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/myrocks_hotbackup.py
+ ${CMAKE_CURRENT_BINARY_DIR}/myrocks_hotbackup @ONLY)
+INSTALL_SCRIPT(${CMAKE_CURRENT_BINARY_DIR}/myrocks_hotbackup COMPONENT rocksdb-engine)
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET_TARGET_PROPERTIES(rocksdb_tools sst_dump mysql_ldb PROPERTIES COMPILE_FLAGS -frtti)
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index 38b33a41565..9f73b95cb4d 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -3770,7 +3770,6 @@ static int rocksdb_commit(handlerton* hton, THD* thd, bool commit_tx)
We get here when committing a statement within a transaction.
*/
tx->make_stmt_savepoint_permanent();
- tx->make_stmt_savepoint_permanent();
}
if (my_core::thd_tx_isolation(thd) <= ISO_READ_COMMITTED) {
diff --git a/storage/rocksdb/myrocks_hotbackup b/storage/rocksdb/myrocks_hotbackup.py
index ef1e934f3fd..69c75b7cbfd 100755
--- a/storage/rocksdb/myrocks_hotbackup
+++ b/storage/rocksdb/myrocks_hotbackup.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!@PYTHON_SHEBANG@
from __future__ import division
from optparse import OptionParser
diff --git a/storage/tokudb/CMakeLists.txt b/storage/tokudb/CMakeLists.txt
index 86463c2997e..3b4e4fb967e 100644
--- a/storage/tokudb/CMakeLists.txt
+++ b/storage/tokudb/CMakeLists.txt
@@ -49,34 +49,43 @@ CHECK_JEMALLOC()
IF(NOT LIBJEMALLOC)
MESSAGE(WARNING "TokuDB is enabled, but jemalloc is not. This configuration is not supported")
+ELSEIF(LIBJEMALLOC STREQUAL jemalloc_pic)
+ CHECK_CXX_SOURCE_COMPILES(
+"
+#include <jemalloc/jemalloc.h>
+#if JEMALLOC_VERSION_MAJOR < 5
+int main() { return 0; }
+#else
+#error
+#endif
+" JEMALLOC_OK)
+ IF (NOT JEMALLOC_OK)
+ MESSAGE(FATAL_ERROR "static jemalloc_pic.a can only be used up to jemalloc 4")
+ ENDIF()
ELSEIF(LIBJEMALLOC STREQUAL jemalloc)
FIND_LIBRARY(LIBJEMALLOC_SO jemalloc)
IF(NOT LIBJEMALLOC_SO)
MESSAGE(FATAL_ERROR "jemalloc is present, but cannot be found?")
ENDIF()
GET_FILENAME_COMPONENT(LIBJEMALLOC_PATH ${LIBJEMALLOC_SO} REALPATH CACHE)
-ENDIF()
-IF(LIBJEMALLOC_PATH AND (RPM OR DEB))
- UNSET(LIBJEMALLOC)
- GET_DIRECTORY_PROPERTY(V DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITION CPACK_RPM_tokudb-engine_PACKAGE_REQUIRES)
- SET(CPACK_RPM_tokudb-engine_PACKAGE_REQUIRES "${V} jemalloc" PARENT_SCOPE)
- SET(systemd_env "Environment=\"LD_PRELOAD=${LIBJEMALLOC_PATH}\"") #"
- SET(cnf_malloc_lib "malloc-lib=${LIBJEMALLOC_PATH}")
-ELSEIF(LIBJEMALLOC_PATH)
- SET(systemd_env "#Environment=\"LD_PRELOAD=${LIBJEMALLOC_PATH}\"") #"
- SET(cnf_malloc_lib "#malloc-lib=${LIBJEMALLOC_PATH}")
-ELSE()
- SET(systemd_env "#Environment=\"LD_PRELOAD=/path/to/libjemalloc.so\"") #"
- SET(cnf_malloc_lib "#malloc-lib=/path/to/libjemalloc.so")
+ IF(RPM OR DEB)
+ UNSET(LIBJEMALLOC)
+ GET_DIRECTORY_PROPERTY(V DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITION CPACK_RPM_tokudb-engine_PACKAGE_REQUIRES)
+ SET(CPACK_RPM_tokudb-engine_PACKAGE_REQUIRES "${V} jemalloc" PARENT_SCOPE)
+ ENDIF()
+
+ IF(INSTALL_SYSCONFDIR)
+ SET(systemd_env "Environment=\"LD_PRELOAD=${LIBJEMALLOC_PATH}\"")
+ SET(cnf_malloc_lib "malloc-lib=${LIBJEMALLOC_PATH}")
+ CONFIGURE_FILE(tokudb.conf.in tokudb.conf @ONLY)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tokudb.conf
+ DESTINATION ${INSTALL_SYSCONFDIR}/systemd/system/mariadb.service.d/
+ COMPONENT tokudb-engine)
+ ENDIF()
ENDIF()
+
CONFIGURE_FILE(tokudb.cnf.in tokudb.cnf @ONLY)
-CONFIGURE_FILE(tokudb.conf.in tokudb.conf @ONLY)
-IF(INSTALL_SYSCONFDIR)
- INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tokudb.conf
- DESTINATION ${INSTALL_SYSCONFDIR}/systemd/system/mariadb.service.d/
- COMPONENT tokudb-engine)
-ENDIF()
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-shadow")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-vla" DEBUG)
diff --git a/storage/tokudb/mysql-test/tokudb/disabled.def b/storage/tokudb/mysql-test/tokudb/disabled.def
index 89f6992d26d..4f759001151 100644
--- a/storage/tokudb/mysql-test/tokudb/disabled.def
+++ b/storage/tokudb/mysql-test/tokudb/disabled.def
@@ -30,5 +30,5 @@ i_s_tokudb_lock_waits_released: unstable, race conditions
i_s_tokudb_locks_released: unstable, race conditions
row_format: n/a
nonflushing_analyze_debug: Freezes in MariaDB 10.0
-tokudb.change_column_all_1000_1: We are too lazy to fix this properly
-tokudb.change_column_all_1000_10: We are too lazy to fix this properly
+change_column_all_1000_1: We are too lazy to fix this properly
+change_column_all_1000_10: We are too lazy to fix this properly
diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_bin.py b/storage/tokudb/mysql-test/tokudb/t/change_column_bin.py
index 2c7d8dd9a54..2c7d8dd9a54 100755..100644
--- a/storage/tokudb/mysql-test/tokudb/t/change_column_bin.py
+++ b/storage/tokudb/mysql-test/tokudb/t/change_column_bin.py
diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_bin_rename.py b/storage/tokudb/mysql-test/tokudb/t/change_column_bin_rename.py
index 6bd5de38fe8..6bd5de38fe8 100755..100644
--- a/storage/tokudb/mysql-test/tokudb/t/change_column_bin_rename.py
+++ b/storage/tokudb/mysql-test/tokudb/t/change_column_bin_rename.py
diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_char.py b/storage/tokudb/mysql-test/tokudb/t/change_column_char.py
index c53442ade50..c53442ade50 100755..100644
--- a/storage/tokudb/mysql-test/tokudb/t/change_column_char.py
+++ b/storage/tokudb/mysql-test/tokudb/t/change_column_char.py
diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_char_binary.py b/storage/tokudb/mysql-test/tokudb/t/change_column_char_binary.py
index e92797918d5..e92797918d5 100755..100644
--- a/storage/tokudb/mysql-test/tokudb/t/change_column_char_binary.py
+++ b/storage/tokudb/mysql-test/tokudb/t/change_column_char_binary.py
diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_char_charbinary.py b/storage/tokudb/mysql-test/tokudb/t/change_column_char_charbinary.py
index 065e37b186d..065e37b186d 100755..100644
--- a/storage/tokudb/mysql-test/tokudb/t/change_column_char_charbinary.py
+++ b/storage/tokudb/mysql-test/tokudb/t/change_column_char_charbinary.py
diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_char_rename.py b/storage/tokudb/mysql-test/tokudb/t/change_column_char_rename.py
index fe73fce0d53..fe73fce0d53 100755..100644
--- a/storage/tokudb/mysql-test/tokudb/t/change_column_char_rename.py
+++ b/storage/tokudb/mysql-test/tokudb/t/change_column_char_rename.py
diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_int.py b/storage/tokudb/mysql-test/tokudb/t/change_column_int.py
index 6f69156e260..6f69156e260 100755..100644
--- a/storage/tokudb/mysql-test/tokudb/t/change_column_int.py
+++ b/storage/tokudb/mysql-test/tokudb/t/change_column_int.py
diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_int_key.py b/storage/tokudb/mysql-test/tokudb/t/change_column_int_key.py
index fd7e5868c40..fd7e5868c40 100755..100644
--- a/storage/tokudb/mysql-test/tokudb/t/change_column_int_key.py
+++ b/storage/tokudb/mysql-test/tokudb/t/change_column_int_key.py
diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_int_not_supported.py b/storage/tokudb/mysql-test/tokudb/t/change_column_int_not_supported.py
index 1708c65efde..1708c65efde 100755..100644
--- a/storage/tokudb/mysql-test/tokudb/t/change_column_int_not_supported.py
+++ b/storage/tokudb/mysql-test/tokudb/t/change_column_int_not_supported.py
diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_int_rename.py b/storage/tokudb/mysql-test/tokudb/t/change_column_int_rename.py
index 5222564a9a2..5222564a9a2 100755..100644
--- a/storage/tokudb/mysql-test/tokudb/t/change_column_int_rename.py
+++ b/storage/tokudb/mysql-test/tokudb/t/change_column_int_rename.py
diff --git a/unittest/mysys/lf-t.c b/unittest/mysys/lf-t.c
index abfa74877f8..7070da648a8 100644
--- a/unittest/mysys/lf-t.c
+++ b/unittest/mysys/lf-t.c
@@ -48,9 +48,6 @@ pthread_handler_t test_lf_pinbox(void *arg)
pins= lf_pinbox_get_pins(&lf_allocator.pinbox);
}
lf_pinbox_put_pins(pins);
- pthread_mutex_lock(&mutex);
- if (!--running_threads) pthread_cond_signal(&cond);
- pthread_mutex_unlock(&mutex);
if (with_my_thread_init)
my_thread_end();
@@ -105,7 +102,6 @@ pthread_handler_t test_lf_alloc(void *arg)
bad|= lf_allocator.mallocs - lf_alloc_pool_count(&lf_allocator);
#endif
}
- if (!--running_threads) pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex);
if (with_my_thread_init)
@@ -172,7 +168,6 @@ pthread_handler_t test_lf_hash(void *arg)
lf_hash.size, inserts, scans);
bad|= lf_hash.count;
}
- if (!--running_threads) pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex);
if (with_my_thread_init)
my_thread_end();
diff --git a/unittest/mysys/my_atomic-t.c b/unittest/mysys/my_atomic-t.c
index 79e93b36ad9..7a7fbaeecd1 100644
--- a/unittest/mysys/my_atomic-t.c
+++ b/unittest/mysys/my_atomic-t.c
@@ -29,9 +29,6 @@ pthread_handler_t test_atomic_add(void *arg)
my_atomic_add32(&bad, x);
my_atomic_add32(&bad, -x);
}
- pthread_mutex_lock(&mutex);
- if (!--running_threads) pthread_cond_signal(&cond);
- pthread_mutex_unlock(&mutex);
return 0;
}
@@ -47,13 +44,6 @@ pthread_handler_t test_atomic_add64(void *arg)
my_atomic_add64(&a64, x);
my_atomic_add64(&a64, -x);
}
- pthread_mutex_lock(&mutex);
- if (!--running_threads)
- {
- bad= (a64 != 0);
- pthread_cond_signal(&cond);
- }
- pthread_mutex_unlock(&mutex);
return 0;
}
@@ -83,9 +73,6 @@ pthread_handler_t test_atomic_fas(void *arg)
my_atomic_add32(&bad, -x);
- pthread_mutex_lock(&mutex);
- if (!--running_threads) pthread_cond_signal(&cond);
- pthread_mutex_unlock(&mutex);
return 0;
}
@@ -109,9 +96,6 @@ pthread_handler_t test_atomic_cas(void *arg)
ok= my_atomic_cas32(&bad, &y, y-x);
} while (!ok) ;
}
- pthread_mutex_lock(&mutex);
- if (!--running_threads) pthread_cond_signal(&cond);
- pthread_mutex_unlock(&mutex);
return 0;
}
@@ -142,4 +126,5 @@ void do_tests()
}
a64=0;
test_concurrently("my_atomic_add64", test_atomic_add64, THREADS, CYCLES);
+ bad= (a64 != 0);
}
diff --git a/unittest/mysys/thr_template.c b/unittest/mysys/thr_template.c
index 83c7432c823..3a57ed091e9 100644
--- a/unittest/mysys/thr_template.c
+++ b/unittest/mysys/thr_template.c
@@ -20,35 +20,34 @@
#include <tap.h>
volatile uint32 bad;
-pthread_attr_t thr_attr;
pthread_mutex_t mutex;
-pthread_cond_t cond;
-uint running_threads;
void do_tests();
void test_concurrently(const char *test, pthread_handler handler, int n, int m)
{
- pthread_t t;
+ pthread_t *threads= malloc(n * sizeof(pthread_t));
+ int i;
ulonglong now= my_interval_timer();
+ assert(threads);
bad= 0;
diag("Testing %s with %d threads, %d iterations... ", test, n, m);
- for (running_threads= n ; n ; n--)
+ for (i= n; i; i--)
{
- if (pthread_create(&t, &thr_attr, handler, &m) != 0)
+ if (pthread_create(&threads[i], 0, handler, &m) != 0)
{
diag("Could not create thread");
abort();
}
}
- pthread_mutex_lock(&mutex);
- while (running_threads)
- pthread_cond_wait(&cond, &mutex);
- pthread_mutex_unlock(&mutex);
+
+ for (i= n; i; i--)
+ pthread_join(threads[i], 0);
now= my_interval_timer() - now;
+ free(threads);
ok(!bad, "tested %s in %g secs (%d)", test, ((double)now)/1e9, bad);
}
@@ -60,9 +59,6 @@ int main(int argc __attribute__((unused)), char **argv)
DBUG_SET_INITIAL(argv[1]);
pthread_mutex_init(&mutex, 0);
- pthread_cond_init(&cond, 0);
- pthread_attr_init(&thr_attr);
- pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
#define CYCLES 3000
#define THREADS 30
@@ -71,16 +67,7 @@ int main(int argc __attribute__((unused)), char **argv)
do_tests();
- /*
- workaround until we know why it crashes randomly on some machine
- (BUG#22320).
- */
-#ifdef NOT_USED
- sleep(2);
-#endif
pthread_mutex_destroy(&mutex);
- pthread_cond_destroy(&cond);
- pthread_attr_destroy(&thr_attr);
my_end(0);
return exit_status();
}
diff --git a/unittest/mysys/waiting_threads-t.c b/unittest/mysys/waiting_threads-t.c
index 01fc850cb96..a2cb7a51c85 100644
--- a/unittest/mysys/waiting_threads-t.c
+++ b/unittest/mysys/waiting_threads-t.c
@@ -136,10 +136,8 @@ retry:
pthread_mutex_unlock(&lock);
pthread_mutex_unlock(& thds[id].lock);
wt_thd_destroy(& thds[id].thd);
-
- if (!--running_threads) /* now, signal when everybody is done with deinit */
- pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex);
+
DBUG_PRINT("wt", ("exiting"));
my_thread_end();
return 0;