revision-id: a8cb4aafe955e69d5f1435e04e109b1e265cc446 (mariadb-25.3.19-11-ga8cb4aaf)
parent(s): b57c7363abe8b353211fcf4cecda19accc37f29d
author: Jan Lindström
committer: Jan Lindström
timestamp: 2018-09-12 12:31:03 +0300
message:
Add SUSE 15.
---
scripts/packages/galera.spec | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/scripts/packages/galera.spec b/scripts/packages/galera.spec
index a5caaa30..33cec5b2 100644
--- a/scripts/packages/galera.spec
+++ b/scripts/packages/galera.spec
@@ -39,7 +39,9 @@
%if 0%{?suse_version} == 1320
%define dist .suse13.2
%endif
-
+%if 0%{?suse_version} == 1500
+%define dist .suse15.0
+%endif
Name: %{name}
Summary: Galera: a synchronous multi-master wsrep provider (replication engine)
1
0
12 Sep '18
revision-id: 0e5e0ea67724d144f38d4c1b10bb95e86c48a579 (mariadb-10.2.16-128-g0e5e0ea6772)
parent(s): e1951723fa45b35c1849416d01162776b6b02838
author: Jan Lindström
committer: Jan Lindström
timestamp: 2018-09-12 11:25:47 +0300
message:
Fix test galera#505 galera library version check.
Test requires galera library version 25.3.24.
---
mysql-test/suite/galera/t/galera#505.test | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/mysql-test/suite/galera/t/galera#505.test b/mysql-test/suite/galera/t/galera#505.test
index 78cdf53db74..785b1411596 100644
--- a/mysql-test/suite/galera/t/galera#505.test
+++ b/mysql-test/suite/galera/t/galera#505.test
@@ -2,22 +2,16 @@
--source include/galera_cluster.inc
---disable_query_log
-select CAST(REGEXP_REPLACE(variable_value,'^(\\d+)\\.(\\d+)\\.(\\d+)(r\\d+)','\\3') AS UNSIGNED) FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'wsrep_provider_version' INTO @GALERA_VERSION;
-
-# Make sure that the test is operating on the right version of galera library.
---let $galera_version=24
-eval SET @REQUIRED_GALERA_VERSION='$galera_version';
-
-SELECT @GALERA_VERSION, @REQUIRED_GALERA_VERSION;
+--connection node_1
-if (!`SELECT (@GALERA_VERSION < @REQUIRED_GALERA_VERSION)`)
-{
- skip Test requires Galera library version 25.3.$galera_version;
-}
+SET SESSION wsrep_sync_wait=0;
+--disable_result_log
+--disable_query_log
+--let $galera_version=25.3.24
+source ../../wsrep/include/check_galera_version.inc;
+--enable_result_log
--enable_query_log
-
---connection node_1
+SET SESSION wsrep_sync_wait=DEFAULT;
# Convert "... pc.weight = N; ..." to "N; ..."
--let $s1 = `SELECT SUBSTR(@@wsrep_provider_options, LOCATE('pc.weight =', @@wsrep_provider_options) + LENGTH('pc.weight = '))`
1
0
revision-id: e1951723fa45b35c1849416d01162776b6b02838 (mariadb-10.2.16-127-ge1951723fa4)
parent(s): 2062fe42d328c2e12d4c0ebaa2d7b4b727326ae4
author: Jan Lindström
committer: Jan Lindström
timestamp: 2018-09-12 09:34:09 +0300
message:
Fix merge error.
---
scripts/wsrep_sst_rsync.sh | 4 ++--
sql/wsrep_mysqld.cc | 6 +-----
sql/wsrep_sst.cc | 14 +++++++++++---
3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh
index b754bfb46dd..73b1f4f649d 100644
--- a/scripts/wsrep_sst_rsync.sh
+++ b/scripts/wsrep_sst_rsync.sh
@@ -190,7 +190,7 @@ fi
# --exclude '*.[0-9][0-9][0-9][0-9][0-9][0-9]' --exclude '*.index')
# New filter - exclude everything except dirs (schemas) and innodb files
-FILTER=(-f '- /lost+found'
+FILTER="-f '- /lost+found'
-f '- /.fseventsd'
-f '- /.Trashes'
-f '+ /wsrep_sst_binlog.tar'
@@ -198,7 +198,7 @@ FILTER=(-f '- /lost+found'
-f '- $INNODB_DATA_HOME_DIR/ibdata*'
-f '+ /undo*'
-f '+ /*/'
- -f '- /*')
+ -f '- /*'"
SSTKEY=$(parse_cnf sst tkey "")
SSTCERT=$(parse_cnf sst tcert "")
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 815804366bc..0ddc4520cee 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -74,10 +74,7 @@ const char *wsrep_start_position;
const char *wsrep_data_home_dir;
const char *wsrep_dbug_option;
const char *wsrep_notify_cmd;
-const char *wsrep_sst_method;
-const char *wsrep_sst_receive_address;
-const char *wsrep_sst_donor;
-const char *wsrep_sst_auth;
+
my_bool wsrep_debug; // Enable debug level logging
my_bool wsrep_convert_LOCK_to_trx; // Convert locking sessions to trx
my_bool wsrep_auto_increment_control; // Control auto increment variables
@@ -89,7 +86,6 @@ my_bool wsrep_log_conflicts;
my_bool wsrep_load_data_splitting; // Commit load data every 10K intervals
my_bool wsrep_slave_UK_checks; // Slave thread does UK checks
my_bool wsrep_slave_FK_checks; // Slave thread does FK checks
-my_bool wsrep_sst_donor_rejects_queries;
my_bool wsrep_restart_slave; // Should mysql slave thread be
// restarted, when node joins back?
my_bool wsrep_desync; // De(re)synchronize the node from the
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index 28e9ba234b2..3790c81d398 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -38,8 +38,14 @@ static char wsrep_defaults_file[FN_REFLEN * 2 + 10 + 30 +
sizeof(WSREP_SST_OPT_CONF_SUFFIX) +
sizeof(WSREP_SST_OPT_CONF_EXTRA)] = {0};
+const char* wsrep_sst_method = WSREP_SST_DEFAULT;
+const char* wsrep_sst_receive_address = WSREP_SST_ADDRESS_AUTO;
+const char* wsrep_sst_donor = "";
+const char* wsrep_sst_auth = NULL;
+
// container for real auth string
static const char* sst_auth_real = NULL;
+my_bool wsrep_sst_donor_rejects_queries = FALSE;
bool wsrep_sst_method_check (sys_var *self, THD* thd, set_var* var)
{
@@ -157,7 +163,7 @@ void wsrep_sst_auth_free()
bool wsrep_sst_auth_update (sys_var *self, THD* thd, enum_var_type type)
{
- return sst_auth_real_set (wsrep_sst_auth);
+ return sst_auth_real_set (wsrep_sst_auth);
}
void wsrep_sst_auth_init ()
@@ -172,9 +178,11 @@ bool wsrep_sst_donor_check (sys_var *self, THD* thd, set_var* var)
bool wsrep_sst_donor_update (sys_var *self, THD* thd, enum_var_type type)
{
- return 0;
+ return 0;
}
+static wsrep_uuid_t cluster_uuid = WSREP_UUID_UNDEFINED;
+
bool wsrep_before_SE()
{
return (wsrep_provider != NULL
@@ -304,7 +312,7 @@ bool wsrep_sst_received (wsrep_t* const wsrep,
}
if (memcmp(&local_uuid, &uuid, sizeof(wsrep_uuid_t)) ||
- local_seqno < seqno)
+ local_seqno < seqno || seqno < 0)
{
do_update= true;
}
1
0
revision-id: 2062fe42d328c2e12d4c0ebaa2d7b4b727326ae4 (mariadb-10.2.16-126-g2062fe42d32)
parent(s): 4d991abd4fc7f60e758ec46301b0dd2bee71245c f1bcfbb4373e40dda2c18c137f76fc6ff32e1a45
author: Oleksandr Byelkin
committer: Oleksandr Byelkin
timestamp: 2018-09-11 21:38:23 +0200
message:
Merge branch '10.1' into 10.2
config.h.cmake | 8 +-
extra/mariabackup/fil_cur.cc | 66 +-
include/my_atomic.h | 2 +-
include/mysql/service_wsrep.h | 3 +
include/service_versions.h | 2 +-
include/wsrep.h | 5 +
mysql-test/extra/binlog_tests/binlog.test | 1 -
mysql-test/extra/rpl_tests/rpl_foreign_key.test | 60 -
mysql-test/mysql-test-run.pl | 197 +-
mysql-test/r/flush.result | 24 +
mysql-test/r/gis.result | 16 +
mysql-test/r/group_min_max.result | 28 +
mysql-test/r/join.result | 6 +-
mysql-test/r/query_cache_innodb.result | 2 +-
mysql-test/r/selectivity.result | 48 +-
mysql-test/r/selectivity_innodb.result | 48 +-
mysql-test/r/sp.result | 17 +
mysql-test/r/stat_tables.result | 13 +
mysql-test/r/stat_tables_innodb.result | 13 +
mysql-test/suite/galera/disabled.def | 3 +
mysql-test/suite/galera/r/MW-336.result | 58 +
mysql-test/suite/galera/r/MW-44.result | 21 +-
mysql-test/suite/galera/r/galera#505.result | 5 +
mysql-test/suite/galera/r/galera_defaults.result | 68 -
.../galera/r/galera_ist_innodb_flush_logs.result | 96 -
.../suite/galera/r/galera_ist_mysqldump.result | 106 +
mysql-test/suite/galera/r/galera_ist_rsync.result | 101 +
.../suite/galera/r/galera_ist_xtrabackup-v2.result | 96 -
.../suite/galera/r/galera_sst_rsync2,debug.rdiff | 103 +
mysql-test/suite/galera/r/galera_sst_rsync2.result | 262 +
.../r/galera_sst_xtrabackup-v2_data_dir.result | 262 +
.../suite/galera/r/galera_var_slave_threads.result | 78 +
mysql-test/suite/galera/r/mysql-wsrep#332.result | 111 +
mysql-test/suite/galera/suite.pm | 2 +
mysql-test/suite/galera/t/MW-336.test | 126 +-
mysql-test/suite/galera/t/MW-44.test | 18 +-
mysql-test/suite/galera/t/galera#505.test | 32 +
mysql-test/suite/galera/t/galera_defaults.test | 13 +-
.../suite/galera/t/galera_ist_mysqldump.test | 2 +
.../suite/galera/t/galera_ist_xtrabackup-v2.test | 5 +
mysql-test/suite/galera/t/galera_sst_rsync2.cnf | 15 +
mysql-test/suite/galera/t/galera_sst_rsync2.test | 12 +
.../galera/t/galera_sst_xtrabackup-v2_data_dir.cnf | 16 +
.../t/galera_sst_xtrabackup-v2_data_dir.test | 23 +
.../suite/galera/t/galera_var_slave_threads.test | 10 +
mysql-test/suite/galera/t/mysql-wsrep#332.test | 113 +
.../suite/galera_3nodes/r/galera_pc_weight.result | 31 +-
.../suite/galera_3nodes/t/galera_pc_weight.test | 55 +-
mysql-test/suite/innodb/r/foreign-keys.result | 73 +
mysql-test/suite/innodb/r/foreign_key.result | 23 +
mysql-test/suite/innodb/r/innodb-lock.result | 33 +
mysql-test/suite/innodb/t/foreign-keys.test | 87 +
mysql-test/suite/innodb/t/foreign_key.test | 24 +
mysql-test/suite/innodb/t/innodb-lock.test | 74 +-
mysql-test/suite/maria/create.result | 33 +
mysql-test/suite/maria/create.test | 42 +
mysql-test/suite/maria/maria.result | 4 +
mysql-test/suite/maria/maria.test | 10 +
.../suite/rpl/r/rpl_foreign_key_innodb.result | 3 +-
mysql-test/suite/rpl/t/rpl_foreign_key_innodb.test | 62 +-
.../suite/wsrep/include/check_galera_version.inc | 20 +-
mysql-test/suite/wsrep/r/variables.result | 56 +-
mysql-test/suite/wsrep/t/variables.test | 18 +-
mysql-test/t/flush.test | 32 +
mysql-test/t/gis.test | 15 +
mysql-test/t/group_min_max.test | 17 +
mysql-test/t/join.test | 3 +-
mysql-test/t/selectivity.test | 36 +
mysql-test/t/sp.test | 21 +
mysql-test/t/stat_tables.test | 12 +
scripts/galera_new_cluster.sh | 3 -
scripts/mysql_install_db.sh | 2 +-
scripts/wsrep_sst_common.sh | 11 +
scripts/wsrep_sst_rsync.sh | 42 +-
scripts/wsrep_sst_xtrabackup-v2.sh | 28 +-
sql/events.cc | 2 +
sql/field.cc | 17 +-
sql/handler.cc | 4 +-
sql/item.cc | 10 +-
sql/log.cc | 8 +-
sql/log_event.cc | 5 -
sql/mysqld.cc | 2 +-
sql/mysqld.h | 1 +
sql/opt_range.cc | 27 +-
sql/sql_alter.cc | 20 +-
sql/sql_base.cc | 160 +-
sql/sql_base.h | 6 +-
sql/sql_parse.cc | 2 +
sql/sql_plugin_services.ic | 3 +-
sql/sql_reload.cc | 13 +-
sql/sql_select.cc | 2 +-
sql/sql_statistics.cc | 3 +
sql/sql_statistics.h | 29 +-
sql/sql_table.cc | 64 +-
sql/sql_trigger.cc | 8 +-
sql/sql_truncate.cc | 2 +-
sql/table.cc | 7 +
sql/table.h | 25 +-
sql/table_cache.cc | 2 -
sql/wsrep_dummy.cc | 3 +
sql/wsrep_hton.cc | 9 +-
sql/wsrep_mysqld.cc | 289 +-
sql/wsrep_mysqld.h | 5 +-
sql/wsrep_sst.cc | 39 +-
sql/wsrep_sst.h | 1 +
sql/wsrep_var.cc | 4 +-
storage/connect/filamdbf.cpp | 4 +-
storage/connect/inihandl.cpp | 2 +-
storage/connect/javaconn.cpp | 2 +-
storage/innobase/btr/btr0scrub.cc | 2 +-
storage/innobase/handler/ha_innodb.cc | 6 +-
storage/innobase/include/univ.i | 3 +-
storage/maria/ma_blockrec.c | 18 +-
storage/maria/ma_norec.c | 4 +-
storage/mroonga/ha_mroonga.cpp | 9 +-
storage/mroonga/ha_mroonga.hpp | 4 -
storage/mroonga/vendor/groonga/lib/expr.c | 2 +-
storage/tokudb/CMakeLists.txt | 8 +-
storage/tokudb/PerconaFT/CMakeLists.txt | 8 +-
.../cmake_modules/TokuSetupCompiler.cmake | 3 +
.../tokudb/PerconaFT/ft/cachetable/cachetable.cc | 21 +-
.../tokudb/PerconaFT/ft/cachetable/cachetable.h | 8 +-
.../tokudb/PerconaFT/ft/ft-cachetable-wrappers.cc | 3 -
storage/tokudb/PerconaFT/ft/ft-test-helpers.cc | 3 -
storage/tokudb/PerconaFT/ft/ft.h | 3 +
storage/tokudb/PerconaFT/ft/node.cc | 2 +
.../PerconaFT/ft/serialize/block_allocator.cc | 2 +-
.../tokudb/PerconaFT/ft/tests/cachetable-4357.cc | 4 -
.../tokudb/PerconaFT/ft/tests/cachetable-4365.cc | 4 -
.../tokudb/PerconaFT/ft/tests/cachetable-5097.cc | 6 +-
.../tokudb/PerconaFT/ft/tests/cachetable-5978-2.cc | 7 +-
.../tokudb/PerconaFT/ft/tests/cachetable-5978.cc | 13 +-
.../PerconaFT/ft/tests/cachetable-all-write.cc | 5 +-
.../ft/tests/cachetable-checkpoint-pending.cc | 8 +-
.../ft/tests/cachetable-checkpoint-pinned-nodes.cc | 6 +-
.../ft/tests/cachetable-cleaner-checkpoint.cc | 5 +-
.../ft/tests/cachetable-cleaner-checkpoint2.cc | 5 +-
.../cachetable-cleaner-thread-attrs-accumulate.cc | 8 +-
.../cachetable-cleaner-thread-everything-pinned.cc | 5 +-
...etable-cleaner-thread-nothing-needs-flushing.cc | 5 +-
.../cachetable-cleaner-thread-same-fullhash.cc | 7 +-
.../ft/tests/cachetable-cleaner-thread-simple.cc | 7 +-
.../ft/tests/cachetable-clock-eviction.cc | 9 +-
.../ft/tests/cachetable-clock-eviction2.cc | 9 +-
.../ft/tests/cachetable-clock-eviction3.cc | 9 +-
.../ft/tests/cachetable-clock-eviction4.cc | 9 +-
.../ft/tests/cachetable-clone-checkpoint.cc | 5 +-
.../cachetable-clone-partial-fetch-pinned-node.cc | 7 +-
.../ft/tests/cachetable-clone-partial-fetch.cc | 7 +-
.../ft/tests/cachetable-clone-pin-nonblocking.cc | 7 +-
.../ft/tests/cachetable-clone-unpin-remove.cc | 5 +-
.../ft/tests/cachetable-eviction-close-test.cc | 4 -
.../ft/tests/cachetable-eviction-close-test2.cc | 4 -
.../ft/tests/cachetable-eviction-getandpin-test.cc | 14 +-
.../tests/cachetable-eviction-getandpin-test2.cc | 12 +-
.../ft/tests/cachetable-fetch-inducing-evictor.cc | 15 +-
.../ft/tests/cachetable-flush-during-cleaner.cc | 3 +-
.../ft/tests/cachetable-getandpin-test.cc | 8 +-
.../cachetable-kibbutz_and_flush_cachefile.cc | 3 +-
.../PerconaFT/ft/tests/cachetable-partial-fetch.cc | 18 +-
.../ft/tests/cachetable-pin-checkpoint.cc | 6 -
.../cachetable-pin-nonblocking-checkpoint-clean.cc | 9 +-
.../ft/tests/cachetable-prefetch-close-test.cc | 2 -
.../ft/tests/cachetable-prefetch-getandpin-test.cc | 12 +-
.../ft/tests/cachetable-put-checkpoint.cc | 9 -
.../PerconaFT/ft/tests/cachetable-simple-clone.cc | 7 +-
.../PerconaFT/ft/tests/cachetable-simple-clone2.cc | 5 +-
.../PerconaFT/ft/tests/cachetable-simple-close.cc | 20 +-
.../ft/tests/cachetable-simple-maybe-get-pin.cc | 3 +-
.../ft/tests/cachetable-simple-pin-cheap.cc | 9 +-
.../ft/tests/cachetable-simple-pin-dep-nodes.cc | 8 +-
.../cachetable-simple-pin-nonblocking-cheap.cc | 19 +-
.../ft/tests/cachetable-simple-pin-nonblocking.cc | 13 +-
.../PerconaFT/ft/tests/cachetable-simple-pin.cc | 11 +-
.../ft/tests/cachetable-simple-put-dep-nodes.cc | 6 +-
.../cachetable-simple-read-pin-nonblocking.cc | 13 +-
.../ft/tests/cachetable-simple-read-pin.cc | 13 +-
.../cachetable-simple-unpin-remove-checkpoint.cc | 7 +-
.../PerconaFT/ft/tests/cachetable-simple-verify.cc | 5 +-
.../tokudb/PerconaFT/ft/tests/cachetable-test.cc | 22 +-
.../ft/tests/cachetable-unpin-and-remove-test.cc | 4 +-
.../cachetable-unpin-remove-and-checkpoint.cc | 6 +-
.../PerconaFT/ft/tests/cachetable-unpin-test.cc | 2 -
storage/tokudb/PerconaFT/ft/tests/test-TDB2-pe.cc | 178 +
storage/tokudb/PerconaFT/ft/tests/test-TDB89.cc | 208 +
storage/tokudb/PerconaFT/ft/txn/rollback-apply.cc | 2 +
storage/tokudb/PerconaFT/ft/txn/rollback.cc | 2 +-
storage/tokudb/PerconaFT/ftcxx/malloc_utils.cpp | 2 +-
storage/tokudb/PerconaFT/ftcxx/malloc_utils.hpp | 2 +-
storage/tokudb/PerconaFT/portability/memory.cc | 14 +-
storage/tokudb/PerconaFT/portability/toku_assert.h | 2 +-
.../tokudb/PerconaFT/portability/toku_debug_sync.h | 3 +-
.../PerconaFT/portability/toku_instr_mysql.cc | 6 +-
.../PerconaFT/portability/toku_instrumentation.h | 6 +-
.../PerconaFT/portability/toku_portability.h | 2 +-
.../tokudb/PerconaFT/portability/toku_race_tools.h | 2 +-
storage/tokudb/PerconaFT/src/tests/get_last_key.cc | 32 +-
storage/tokudb/PerconaFT/src/ydb.cc | 3 +
storage/tokudb/PerconaFT/src/ydb_lib.cc | 2 +-
storage/tokudb/PerconaFT/util/dmt.cc | 4 +-
storage/tokudb/PerconaFT/util/minicron.cc | 3 +-
storage/tokudb/PerconaFT/util/scoped_malloc.cc | 2 +-
.../util/tests/minicron-change-period-data-race.cc | 66 +
storage/tokudb/ha_tokudb.cc | 325 +-
storage/tokudb/ha_tokudb.h | 92 +-
storage/tokudb/ha_tokudb_admin.cc | 8 +-
storage/tokudb/ha_tokudb_alter_55.cc | 4 +
storage/tokudb/ha_tokudb_alter_56.cc | 265 +-
storage/tokudb/ha_tokudb_alter_common.cc | 6 +-
storage/tokudb/ha_tokudb_update.cc | 96 +-
storage/tokudb/hatoku_cmp.cc | 33 +-
storage/tokudb/hatoku_cmp.h | 14 +-
storage/tokudb/hatoku_defines.h | 51 +-
storage/tokudb/hatoku_hton.cc | 183 +-
storage/tokudb/hatoku_hton.h | 25 +-
storage/tokudb/mysql-test/rpl/disabled.def | 1 +
.../r/rpl_mixed_replace_into.result | 0
.../rpl/r/rpl_parallel_tokudb_delete_pk.result | 9 +
...pl_parallel_tokudb_update_pk_uc0_lookup0.result | 9 +
.../rpl/r/rpl_parallel_tokudb_write_pk.result | 6 +
.../r/rpl_row_replace_into.result | 0
.../r/rpl_stmt_replace_into.result | 0
.../mysql-test/rpl/r/rpl_xa_interleave.result | 59 +
.../t/rpl_mixed_replace_into.test | 0
.../t/rpl_row_replace_into.test | 0
.../t/rpl_stmt_replace_into.test | 0
.../tokudb/mysql-test/rpl/t/rpl_xa_interleave.test | 103 +
.../tokudb/include/fast_update_gen_footer.inc | 2 +
.../include/fast_update_gen_footer_silent.inc | 9 +
.../tokudb/include/fast_update_gen_header.inc | 6 +
.../mysql-test/tokudb/include/fast_update_int.inc | 48 +
.../tokudb/include/fast_upsert_gen_header.inc | 6 +
.../mysql-test/tokudb/include/fast_upsert_int.inc | 19 +
.../tokudb/mysql-test/tokudb/include/have_mrr.inc | 0
.../tokudb/include/setup_fast_update_upsert.inc | 8 +
.../tokudb/mysql-test/tokudb/r/compressions.result | 11 +
.../tokudb/r/fast_update_binlog_mixed.result | 225 +-
.../tokudb/r/fast_update_binlog_row.result | 19 +-
.../tokudb/r/fast_update_binlog_statement.result | 222 +-
.../mysql-test/tokudb/r/fast_update_blobs.result | 18253 +---------
.../r/fast_update_blobs_fixed_varchar.result | 33026 ------------------
.../tokudb/r/fast_update_blobs_with_varchar.result | 32771 +-----------------
.../mysql-test/tokudb/r/fast_update_char.result | 60 +-
.../tokudb/r/fast_update_deadlock.result | 19 +-
.../tokudb/r/fast_update_decr_floor.result | 314 +-
.../r/fast_update_disable_slow_update.result | 7 -
.../mysql-test/tokudb/r/fast_update_error.result | 12 +-
.../mysql-test/tokudb/r/fast_update_int.result | 562 +-
.../tokudb/r/fast_update_int_bounds.result | 52 +-
.../mysql-test/tokudb/r/fast_update_key.result | 54 +-
.../mysql-test/tokudb/r/fast_update_sqlmode.result | 21 +-
.../tokudb/r/fast_update_uint_bounds.result | 36 +-
.../mysql-test/tokudb/r/fast_update_varchar.result | 13575 +-------
.../mysql-test/tokudb/r/fast_upsert_bin_pad.result | Bin 659 -> 738 bytes
.../mysql-test/tokudb/r/fast_upsert_char.result | 24 +-
.../tokudb/r/fast_upsert_deadlock.result | 19 +-
.../mysql-test/tokudb/r/fast_upsert_int.result | 428 +-
.../mysql-test/tokudb/r/fast_upsert_key.result | 43 +-
.../mysql-test/tokudb/r/fast_upsert_sqlmode.result | 23 +-
.../mysql-test/tokudb/r/fast_upsert_values.result | 18 +-
.../tokudb/mysql-test/tokudb/r/tokudb_mrr.result | 326 +
storage/tokudb/mysql-test/tokudb/suite.pm | 6 +
.../tokudb/mysql-test/tokudb/t/compressions.test | 68 +
storage/tokudb/mysql-test/tokudb/t/disabled.def | 24 -
.../tokudb/t/fast_update_binlog_mixed-master.opt | 2 +
.../tokudb/t/fast_update_binlog_mixed.test | 15 +-
.../tokudb/t/fast_update_binlog_row-master.opt | 2 +
.../tokudb/t/fast_update_binlog_row.test | 19 +-
.../t/fast_update_binlog_statement-master.opt | 2 +
.../tokudb/t/fast_update_binlog_statement.test | 15 +-
.../mysql-test/tokudb/t/fast_update_blobs.py | 57 -
.../mysql-test/tokudb/t/fast_update_blobs.test | 18575 +----------
.../tokudb/t/fast_update_blobs_fixed_varchar.py | 63 -
.../tokudb/t/fast_update_blobs_fixed_varchar.test | 33287 -------------------
.../tokudb/t/fast_update_blobs_with_varchar.py | 62 -
.../tokudb/t/fast_update_blobs_with_varchar.test | 33115 +-----------------
.../mysql-test/tokudb/t/fast_update_char.test | 66 +-
.../mysql-test/tokudb/t/fast_update_deadlock.test | 21 +-
.../mysql-test/tokudb/t/fast_update_decr_floor.py | 58 -
.../tokudb/t/fast_update_decr_floor.test | 409 +-
.../tokudb/t/fast_update_disable_slow_update.test | 17 -
.../mysql-test/tokudb/t/fast_update_error.test | 16 +-
.../tokudb/mysql-test/tokudb/t/fast_update_int.py | 77 -
.../mysql-test/tokudb/t/fast_update_int.test | 682 +-
.../tokudb/t/fast_update_int_bounds.test | 55 +-
.../mysql-test/tokudb/t/fast_update_key.test | 63 +-
.../mysql-test/tokudb/t/fast_update_sqlmode.test | 25 +-
.../tokudb/t/fast_update_uint_bounds.test | 42 +-
.../mysql-test/tokudb/t/fast_update_varchar.py | 63 -
.../mysql-test/tokudb/t/fast_update_varchar.test | 7390 +---
.../mysql-test/tokudb/t/fast_upsert_bin_pad.test | 19 +-
.../mysql-test/tokudb/t/fast_upsert_char.test | 27 +-
.../mysql-test/tokudb/t/fast_upsert_deadlock.test | 22 +-
.../tokudb/mysql-test/tokudb/t/fast_upsert_int.py | 50 -
.../mysql-test/tokudb/t/fast_upsert_int.test | 486 +-
.../mysql-test/tokudb/t/fast_upsert_key.test | 46 +-
.../mysql-test/tokudb/t/fast_upsert_sqlmode.test | 27 +-
.../mysql-test/tokudb/t/fast_upsert_values.test | 21 +-
storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test | 73 +
.../tokudb/mysql-test/tokudb_bugs/r/PS-3773.result | 8 +
.../r/alter_table_comment_rebuild_data.result | 177 +
.../tokudb/mysql-test/tokudb_bugs/t/PS-3773.test | 26 +
.../t/alter_table_comment_rebuild_data.test | 188 +
storage/tokudb/tokudb_debug.h | 5 -
storage/tokudb/tokudb_dir_cmd.h | 6 +-
storage/tokudb/tokudb_information_schema.cc | 74 +-
storage/tokudb/tokudb_sysvars.cc | 122 +-
storage/tokudb/tokudb_sysvars.h | 16 +-
storage/tokudb/tokudb_thread.h | 26 +-
storage/tokudb/tokudb_update_fun.cc | 230 +-
storage/xtradb/btr/btr0scrub.cc | 2 +-
storage/xtradb/buf/buf0buf.cc | 2 +-
storage/xtradb/fil/fil0crypt.cc | 2 +-
storage/xtradb/handler/ha_innodb.cc | 41 +-
storage/xtradb/handler/handler0alter.cc | 20 +-
storage/xtradb/include/univ.i | 3 +-
storage/xtradb/row/row0mysql.cc | 4 +-
317 files changed, 7124 insertions(+), 195472 deletions(-)
diff --cc config.h.cmake
index 3e5a9a95397,52d837fad2a..607132796a6
--- a/config.h.cmake
+++ b/config.h.cmake
@@@ -569,12 -666,6 +569,6 @@@
#cmakedefine WSREP_PROC_INFO 1
#endif
- #ifdef _AIX
- /*
- AIX includes inttypes.h from sys/types.h
- Explicitly request format macros before the first inclusion of inttypes.h
- */
--#define __STDC_FORMAT_MACROS
- #endif
++// #define __STDC_FORMAT_MACROS
#endif
diff --cc extra/mariabackup/fil_cur.cc
index be2e0593129,be4a625342b..f5b3db1e184
--- a/extra/mariabackup/fil_cur.cc
+++ b/extra/mariabackup/fil_cur.cc
@@@ -341,42 -343,45 +341,42 @@@ read_retry
/* check pages for corruption and re-read if necessary. i.e. in case of
partially written pages */
for (page = cursor->buf, i = 0; i < npages;
- page += cursor->page_size, i++) {
- ib_int64_t page_no = cursor->buf_page_no + i;
-
- bool checksum_ok = fil_space_verify_crypt_checksum(page, cursor->zip_size,space, (ulint)page_no);
-
- if (!checksum_ok &&
- buf_page_is_corrupted(true, page, cursor->zip_size,space)) {
-
- if (cursor->is_system &&
- page_no >= (ib_int64_t)FSP_EXTENT_SIZE &&
- page_no < (ib_int64_t) FSP_EXTENT_SIZE * 3) {
- /* skip doublewrite buffer pages */
- xb_a(cursor->page_size == UNIV_PAGE_SIZE);
- msg("[%02u] mariabackup: "
- "Page " UINT64PF " is a doublewrite buffer page, "
- "skipping.\n", cursor->thread_n, page_no);
- } else {
- 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;
- }
- msg("[%02u] mariabackup: "
- "Database page corruption detected at page "
- UINT64PF ", retrying...\n", cursor->thread_n,
- page_no);
-
- os_thread_sleep(100000);
-
- goto read_retry;
- }
- }
- cursor->buf_read += cursor->page_size;
- cursor->buf_npages++;
+ 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 (!fil_space_verify_crypt_checksum(
- page, cursor->page_size, space->id, page_no)
- && buf_page_is_corrupted(true, page,
- cursor->page_size,
- 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;
- 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++;
++ 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 (!fil_space_verify_crypt_checksum(
++ page, cursor->page_size, space->id, page_no)
++ && buf_page_is_corrupted(true, page,
++ cursor->page_size,
++ 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;
++ 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++;
}
posix_fadvise(cursor->file, offset, to_read, POSIX_FADV_DONTNEED);
diff --cc mysql-test/r/group_min_max.result
index b3b660c4170,777780f8400..f200f70dd8b
--- a/mysql-test/r/group_min_max.result
+++ b/mysql-test/r/group_min_max.result
@@@ -3733,6 -3733,34 +3733,34 @@@ id MIN(a) MAX(a
4 2001-01-04 2001-01-04
DROP TABLE t1;
#
+ # MDEV-17039: Query plan changes when we use GROUP BY optimization with optimizer_use_condition_selectivity=4
+ # and use_stat_tables= PREFERABLY
+ #
+ CREATE TABLE t1 (a INT, b INT,c INT DEFAULT 0, INDEX (a,b));
+ INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5),
+ (2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
+ set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+ set @save_use_stat_tables= @@use_stat_tables;
+ set @@optimizer_use_condition_selectivity=4;
+ set @@use_stat_tables=PREFERABLY;
+ explain extended SELECT a FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a);
+ id select_type table type possible_keys key key_len ref rows filtered Extra
+ 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 8 100.00
+ 1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 2 100.00 Using index
+ 2 MATERIALIZED t1 range NULL a 5 NULL 8 100.00 Using index for group-by
+ Warnings:
-Note 1003 select `test`.`t1_outer`.`a` AS `a` from <materialize> (select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a`) join `test`.`t1` `t1_outer` where (`test`.`t1_outer`.`a` = `<subquery2>`.`max(b)`)
++Note 1003 select `test`.`t1_outer`.`a` AS `a` from <materialize> (select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a`) join `test`.`t1` `t1_outer` where `test`.`t1_outer`.`a` = `<subquery2>`.`max(b)`
+ set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+ set @@use_stat_tables=@save_use_stat_tables;
+ explain extended SELECT a FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a);
+ id select_type table type possible_keys key key_len ref rows filtered Extra
+ 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 8 100.00
+ 1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 2 100.00 Using index
+ 2 MATERIALIZED t1 range NULL a 5 NULL 8 100.00 Using index for group-by
+ Warnings:
-Note 1003 select `test`.`t1_outer`.`a` AS `a` from <materialize> (select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a`) join `test`.`t1` `t1_outer` where (`test`.`t1_outer`.`a` = `<subquery2>`.`max(b)`)
++Note 1003 select `test`.`t1_outer`.`a` AS `a` from <materialize> (select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a`) join `test`.`t1` `t1_outer` where `test`.`t1_outer`.`a` = `<subquery2>`.`max(b)`
+ drop table t1;
+ #
# End of 10.0 tests
#
#
diff --cc mysql-test/r/query_cache_innodb.result
index 643a065612f,00000000000..146a6fbc289
mode 100644,000000..100644
--- a/mysql-test/r/query_cache_innodb.result
+++ b/mysql-test/r/query_cache_innodb.result
@@@ -1,90 -1,0 +1,90 @@@
+#
+# MDEV-12485: foreign key on delete cascade stale entries with
+# query cache enabled
+#
+SET NAMES utf8;
+set global query_cache_type=1;
+set global query_cache_size=1024*1024;
+set query_cache_type=1;
+create table t1 ( id int unsigned auto_increment, primary key(id) ) engine=innodb;
+create table t2 ( t2id int unsigned, id int unsigned, primary key(t2id, id), foreign key (`id`) references t1(`id`) on delete cascade ) engine=innodb;
+insert into t1 values (1);
+insert into t2 values (1,1);
+select * from t2;
+t2id id
+1 1
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 1
+delete from t1;
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 0
+select * from t2;
+t2id id
+optimize table t2;
+Table Op Msg_type Msg_text
+test.t2 optimize note Table does not support optimize, doing recreate + analyze instead
+test.t2 optimize status OK
+select * from t2;
+t2id id
+drop table t2;
+drop table t1;
+create database `testdatabase$ї`;
+use `testdatabase$ї`;
+create table `t1$ї` ( id int unsigned auto_increment, primary key(id) ) engine=innodb;
+create table `t2$ї` ( t2id int unsigned, id int unsigned, primary key(t2id, id), foreign key (`id`) references `t1$ї`(`id`) on delete cascade ) engine=innodb;
+insert into `t1$ї` values (1);
+insert into `t2$ї`values (1,1);
+select * from `t2$ї`;
+t2id id
+1 1
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 1
+delete from `t1$ї`;
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 0
+select * from `t2$ї`;
+t2id id
+optimize table `t2$ї`;
+Table Op Msg_type Msg_text
+testdatabase$ї.t2$ї optimize note Table does not support optimize, doing recreate + analyze instead
+testdatabase$ї.t2$ї optimize status OK
+select * from `t2$ї`;
+t2id id
+use test;
+drop database `testdatabase$ї`;
+SET NAMES default;
+create database `#mysql50#-`;
+use `#mysql50#-`;
+create table `#mysql50#t-1` ( id int unsigned auto_increment, primary key(id) ) engine=innodb;
+create table `#mysql50#t-2` ( t2id int unsigned, id int unsigned, primary key(t2id, id), foreign key (`id`) references `#mysql50#t-1`(`id`) on delete cascade ) engine=innodb;
+insert into `#mysql50#t-1` values (1);
+insert into `#mysql50#t-2`values (1,1);
+select * from `#mysql50#t-2`;
+t2id id
+1 1
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 1
+delete from `#mysql50#t-1`;
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 0
+select * from `#mysql50#t-2`;
+t2id id
+optimize table `#mysql50#t-2`;
+Table Op Msg_type Msg_text
+#mysql50#-.#mysql50#t-2 optimize note Table does not support optimize, doing recreate + analyze instead
+#mysql50#-.#mysql50#t-2 optimize status OK
+select * from `#mysql50#t-2`;
+t2id id
+use test;
+drop database `#mysql50#-`;
+SET NAMES default;
- FOUND 12 /\[ERROR\] Invalid \(old\?\) table or database name/ in mysqld.1.err
++FOUND 8 /\[ERROR\] Invalid \(old\?\) table or database name/ in mysqld.1.err
+set global query_cache_type=DEFAULT;
+set global query_cache_size=DEFAULT;
+End of 10.2 tests
diff --cc mysql-test/r/selectivity_innodb.result
index 849217116ea,d3e71088f87..249ac264fd6
--- a/mysql-test/r/selectivity_innodb.result
+++ b/mysql-test/r/selectivity_innodb.result
@@@ -789,9 -789,9 +789,9 @@@ set optimizer_use_condition_selectivity
explain extended
select * from t1 where a < 1 and a > 7;
id select_type table type possible_keys key key_len ref rows filtered Extra
- 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 8 100.00 Using where
Warnings:
- Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` < 1) and (`test`.`t1`.`a` > 7))
++Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` < 1 and `test`.`t1`.`a` > 7
select * from t1 where a < 1 and a > 7;
a
drop table t1;
@@@ -1516,9 -1516,9 +1516,9 @@@ col
explain extended
select * from t2 where col1 < 'b' and col1 > 'd';
id select_type table type possible_keys key key_len ref rows filtered Extra
- 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+ 1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where
Warnings:
- Note 1003 select `test`.`t2`.`col1` AS `col1` from `test`.`t2` where 0
-Note 1003 select `test`.`t2`.`col1` AS `col1` from `test`.`t2` where ((`test`.`t2`.`col1` < 'b') and (`test`.`t2`.`col1` > 'd'))
++Note 1003 select `test`.`t2`.`col1` AS `col1` from `test`.`t2` where `test`.`t2`.`col1` < 'b' and `test`.`t2`.`col1` > 'd'
drop table t1,t2;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set use_stat_tables=@save_use_stat_tables;
diff --cc mysql-test/suite/galera/disabled.def
index 9be8e73f06b,40b4065c3db..ec3ae5f3907
--- a/mysql-test/suite/galera/disabled.def
+++ b/mysql-test/suite/galera/disabled.def
@@@ -30,10 -30,7 +30,13 @@@ query_cache : MDEV-15805 Test failure o
MW-416 : MDEV-13549 Galera test failures
galera_wan : MDEV-13549 Galera test failures
MW-388 : MDEV-13549 Galera test failures
+galera.MW-44 : MDEV-15809 Test failure on galera.MW-44
+galera.galera_pc_ignore_sb : MDEV-15811 Test failure on galera_pc_ignore_sb
+galera_kill_applier : race condition at the start of the test
+galera_ist_progress: MDEV-15236 galera_ist_progress fails when trying to read transfer status
+pxc-421: Lock timeout exceeded
galera_sst_mysqldump_with_key : MDEV-16890 Galera test failure
+galera.galera_kill_ddl : MDEV-17108 Test failure on galera.galera_kill_ddl
+ galera.galera_binlog_stmt_autoinc : MDEV-17106 Test failure on galera.galera_binlog_stmt_autoinc
+ galera.galera_kill_ddl : MDEV-17108 Test failure on galera.galera_kill_ddl
+ galera.galera_var_node_address : MDEV-17151 Galera test failure on galera.galera_var_node_address
diff --cc mysql-test/suite/galera/r/MW-336.result
index 0bf8d9d3909,81e8eae0eb3..5590815651a
--- a/mysql-test/suite/galera/r/MW-336.result
+++ b/mysql-test/suite/galera/r/MW-336.result
@@@ -1,40 -1,31 +1,98 @@@
CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB;
++<<<<<<< HEAD
+connection node_1;
++||||||| merged common ancestors
++=======
+ INSERT INTO t1 values(0);
++>>>>>>> 10.1
SET GLOBAL wsrep_slave_threads = 10;
SET GLOBAL wsrep_slave_threads = 1;
++<<<<<<< HEAD
+connection node_2;
+INSERT INTO t1 VALUES (1);
+connection node_1;
++||||||| merged common ancestors
++INSERT INTO t1 VALUES (1);
++=======
+ # Wait 10 slave threads to start 1
+ # Generate 12 replication events
+ SELECT COUNT(*) FROM t1;
+ COUNT(*)
+ 13
+ # Wait 9 slave threads to exit 1
++>>>>>>> 10.1
SET GLOBAL wsrep_slave_threads = 10;
+ # Wait 10 slave threads to start 2
SET GLOBAL wsrep_slave_threads = 20;
+ # Wait 20 slave threads to start 3
SET GLOBAL wsrep_slave_threads = 1;
++<<<<<<< HEAD
+connection node_2;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+INSERT INTO t1 VALUES (3);
+INSERT INTO t1 VALUES (4);
+INSERT INTO t1 VALUES (5);
+INSERT INTO t1 VALUES (6);
+INSERT INTO t1 VALUES (7);
+INSERT INTO t1 VALUES (8);
+INSERT INTO t1 VALUES (9);
+connection node_1;
++||||||| merged common ancestors
++INSERT INTO t1 VALUES (1);
++INSERT INTO t1 VALUES (2);
++INSERT INTO t1 VALUES (3);
++INSERT INTO t1 VALUES (4);
++INSERT INTO t1 VALUES (5);
++INSERT INTO t1 VALUES (6);
++INSERT INTO t1 VALUES (7);
++INSERT INTO t1 VALUES (8);
++INSERT INTO t1 VALUES (9);
++=======
+ # Generate 40 replication events
+ SELECT COUNT(*) FROM t1;
+ COUNT(*)
+ 53
+ # Wait 10 slave threads to exit 3
++>>>>>>> 10.1
SET GLOBAL wsrep_slave_threads = 10;
SET GLOBAL wsrep_slave_threads = 0;
Warnings:
Warning 1292 Truncated incorrect wsrep_slave_threads value: '0'
++<<<<<<< HEAD
+connection node_2;
+INSERT INTO t1 VALUES (10);
+INSERT INTO t1 VALUES (11);
+INSERT INTO t1 VALUES (12);
+INSERT INTO t1 VALUES (13);
+INSERT INTO t1 VALUES (14);
+INSERT INTO t1 VALUES (15);
+INSERT INTO t1 VALUES (16);
+INSERT INTO t1 VALUES (17);
+INSERT INTO t1 VALUES (18);
+INSERT INTO t1 VALUES (19);
+INSERT INTO t1 VALUES (20);
+connection node_1;
+SET GLOBAL wsrep_slave_threads = 1;
++||||||| merged common ancestors
++INSERT INTO t1 VALUES (10);
++INSERT INTO t1 VALUES (11);
++INSERT INTO t1 VALUES (12);
++INSERT INTO t1 VALUES (13);
++INSERT INTO t1 VALUES (14);
++INSERT INTO t1 VALUES (15);
++INSERT INTO t1 VALUES (16);
++INSERT INTO t1 VALUES (17);
++INSERT INTO t1 VALUES (18);
++INSERT INTO t1 VALUES (19);
++INSERT INTO t1 VALUES (20);
++SET GLOBAL wsrep_slave_threads = 1;
++=======
+ # Wait 10 slave threads to start 3
+ # Generate 12 replication events
+ SELECT COUNT(*) FROM t1;
+ COUNT(*)
+ 65
+ # Wait 10 slave threads to exit 4
++>>>>>>> 10.1
DROP TABLE t1;
diff --cc mysql-test/suite/galera/r/galera_ist_mysqldump.result
index 58a3ca297f8,e254a1b195b..a33ad2d55cb
--- a/mysql-test/suite/galera/r/galera_ist_mysqldump.result
+++ b/mysql-test/suite/galera/r/galera_ist_mysqldump.result
@@@ -5,12 -4,9 +5,17 @@@ connection node_1
CREATE USER 'sst';
GRANT ALL PRIVILEGES ON *.* TO 'sst';
SET GLOBAL wsrep_sst_auth = 'sst:';
+connection node_2;
SET GLOBAL wsrep_sst_method = 'mysqldump';
++<<<<<<< HEAD
+connection node_1;
+connection node_2;
++||||||| merged common ancestors
++=======
+ call mtr.add_suppression("WSREP: wsrep_sst_method is set to 'mysqldump' yet mysqld bind_address is set to .*");
++>>>>>>> 10.1
Performing State Transfer on a server that has been shut down cleanly and restarted
+connection node_1;
CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
@@@ -199,120 -180,12 +204,221 @@@ COUNT(*) =
DROP TABLE t1;
COMMIT;
SET AUTOCOMMIT=ON;
++<<<<<<< HEAD
+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;
+connection node_1;
++||||||| merged common ancestors
++Performing State Transfer on a server that has been killed and restarted
++while a DDL was in progress on it
++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');
++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';
++ALTER TABLE t1 ADD COLUMN f2 INTEGER;
++SET wsrep_sync_wait = 0;
++Killing server ...
++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');
++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');
++Performing --wsrep-recover ...
++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;
++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;
++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;
++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;
++=======
++>>>>>>> 10.1
CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query");
DROP USER sst;
+connection node_2;
CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query");
CALL mtr.add_suppression("InnoDB: Error: Table \"mysql\"\\.\"innodb_index_stats\" not found");
-CALL mtr.add_suppression("InnoDB: New log files created");
-CALL mtr.add_suppression("InnoDB: Creating foreign key constraint system tables");
CALL mtr.add_suppression("Can't open and lock time zone table");
CALL mtr.add_suppression("Can't open and lock privilege tables");
CALL mtr.add_suppression("Info table is not ready to be used");
diff --cc mysql-test/suite/galera/r/galera_ist_rsync.result
index 9c0d78d96e9,099d944d491..84eeac4093d
--- a/mysql-test/suite/galera/r/galera_ist_rsync.result
+++ b/mysql-test/suite/galera/r/galera_ist_rsync.result
@@@ -285,111 -259,3 +285,212 @@@ COUNT(*) =
DROP TABLE t1;
COMMIT;
SET AUTOCOMMIT=ON;
++<<<<<<< HEAD
+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;
++||||||| merged common ancestors
++Performing State Transfer on a server that has been killed and restarted
++while a DDL was in progress on it
++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');
++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';
++ALTER TABLE t1 ADD COLUMN f2 INTEGER;
++SET wsrep_sync_wait = 0;
++Killing server ...
++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');
++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');
++Performing --wsrep-recover ...
++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;
++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;
++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;
++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;
++=======
++>>>>>>> 10.1
diff --cc mysql-test/suite/galera/r/galera_var_slave_threads.result
index 3f0a63ab9d7,c7c6af2098f..787e7da43d5
--- a/mysql-test/suite/galera/r/galera_var_slave_threads.result
+++ b/mysql-test/suite/galera/r/galera_var_slave_threads.result
@@@ -13,85 -11,26 +13,163 @@@ SELECT @@wsrep_slave_threads = 1
@@wsrep_slave_threads = 1
1
SET GLOBAL wsrep_slave_threads = 1;
-SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user';
-COUNT(*) = 2
-1
-SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%';
-COUNT(*) = 1
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%';
+COUNT(*)
1
SET GLOBAL wsrep_slave_threads = 64;
+connection node_1;
INSERT INTO t1 VALUES (1);
-SELECT COUNT(*) = 1 FROM t1;
-COUNT(*) = 1
+connection node_2;
+SET GLOBAL wsrep_slave_threads = 1;
++<<<<<<< HEAD
+connection node_1;
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+INSERT INTO t2 VALUES (DEFAULT);
+connection node_2;
+SELECT COUNT(*) FROM t2;
+COUNT(*)
+64
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%';
+COUNT(*)
++||||||| merged common ancestors
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++INSERT INTO t2 VALUES (DEFAULT);
++SELECT COUNT(*) = 64 FROM t2;
++COUNT(*) = 64
+ 1
+ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%';
+ COUNT(*) = 1
-1
-SET GLOBAL wsrep_slave_threads = 1;
++=======
+ SELECT COUNT(*) = 64 FROM t2;
+ COUNT(*) = 64
+ 1
+ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%';
+ COUNT(*) = 1
++>>>>>>> 10.1
1
SET GLOBAL wsrep_slave_threads = 1;
DROP TABLE t1;
diff --cc mysql-test/suite/galera/t/MW-336.test
index 8cd363aa019,749ffe671be..89c3e6e9e2d
--- a/mysql-test/suite/galera/t/MW-336.test
+++ b/mysql-test/suite/galera/t/MW-336.test
@@@ -14,54 -19,105 +19,129 @@@ SET GLOBAL wsrep_slave_threads = 1
--source include/wait_condition.inc
--connection node_2
- INSERT INTO t1 VALUES (1);
+ # Wait until inserts are replicated
+ --let $wait_condition = SELECT COUNT(*) = 1 FROM t1;
+ --source include/wait_condition.inc
+ --echo # Generate 12 replication events
+ --disable_query_log
+ --disable_result_log
+ --let $count = 12
+ while ($count)
+ {
+ INSERT INTO t1 VALUES (1);
+ --dec $count
+ }
+ --enable_result_log
+ --enable_query_log
--connection node_1
+ # Wait until inserts are replicated
+ --let $wait_condition = SELECT COUNT(*) = 13 FROM t1;
+ --source include/wait_condition.inc
+
+ SELECT COUNT(*) FROM t1;
+
+ --echo # Wait 9 slave threads to exit 1
+ # Wait until appliers exit
+ --let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
+ --source include/wait_condition.inc
+
SET GLOBAL wsrep_slave_threads = 10;
++<<<<<<< HEAD
+--let $wait_condition = SELECT COUNT(*) = 11 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
++||||||| merged common ancestors
++--let $wait_condition = SELECT COUNT(*) = 11 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user';
++=======
+
+ --echo # Wait 10 slave threads to start 2
+ --let $wait_condition = SELECT COUNT(*) = 11 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user';
++>>>>>>> 10.1
--source include/wait_condition.inc
SET GLOBAL wsrep_slave_threads = 20;
++<<<<<<< HEAD
+--let $wait_condition = SELECT COUNT(*) = 21 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
++||||||| merged common ancestors
++--let $wait_condition = SELECT COUNT(*) = 21 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user';
++=======
+
+ --echo # Wait 20 slave threads to start 3
+ --let $wait_condition = SELECT COUNT(*) = 21 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user';
++>>>>>>> 10.1
--source include/wait_condition.inc
SET GLOBAL wsrep_slave_threads = 1;
--connection node_2
- INSERT INTO t1 VALUES (1);
- INSERT INTO t1 VALUES (2);
- INSERT INTO t1 VALUES (3);
- INSERT INTO t1 VALUES (4);
- INSERT INTO t1 VALUES (5);
- INSERT INTO t1 VALUES (6);
- INSERT INTO t1 VALUES (7);
- INSERT INTO t1 VALUES (8);
- INSERT INTO t1 VALUES (9);
-
+ --echo # Generate 40 replication events
+ --disable_query_log
+ --disable_result_log
+ --let $count = 40
+ while ($count)
+ {
+ INSERT INTO t1 VALUES (1);
+ --dec $count
+ }
+ --enable_query_log
+ --enable_result_log
--connection node_1
++<<<<<<< HEAD
+--let $wait_condition = SELECT COUNT(*) = 12 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
++||||||| merged common ancestors
++--let $wait_condition = SELECT COUNT(*) = 12 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user';
++=======
+
+ # Wait until inserts are replicated
+ --let $wait_condition = SELECT COUNT(*) = 53 FROM t1;
+ --source include/wait_condition.inc
+
+ SELECT COUNT(*) FROM t1;
+
+ --echo # Wait 10 slave threads to exit 3
+ # Wait until appliers exit
+ --let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
++>>>>>>> 10.1
--source include/wait_condition.inc
SET GLOBAL wsrep_slave_threads = 10;
SET GLOBAL wsrep_slave_threads = 0;
+ --echo # Wait 10 slave threads to start 3
+ --let $wait_timeout=600
+ --let $wait_condition = SELECT COUNT(*) = 11 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
+ --source include/wait_condition.inc
+
--connection node_2
- INSERT INTO t1 VALUES (10);
- INSERT INTO t1 VALUES (11);
- INSERT INTO t1 VALUES (12);
- INSERT INTO t1 VALUES (13);
- INSERT INTO t1 VALUES (14);
- INSERT INTO t1 VALUES (15);
- INSERT INTO t1 VALUES (16);
- INSERT INTO t1 VALUES (17);
- INSERT INTO t1 VALUES (18);
- INSERT INTO t1 VALUES (19);
- INSERT INTO t1 VALUES (20);
+ --echo # Generate 12 replication events
+ --disable_query_log
+ --disable_result_log
+ --let $count = 12
+ while ($count)
+ {
+ INSERT INTO t1 VALUES (1);
+ --dec $count
+ }
+ --enable_result_log
+ --enable_query_log
--connection node_1
++<<<<<<< HEAD
+--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
++||||||| merged common ancestors
++--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user';
++=======
+ # Wait until inserts are replicated
+ --let $wait_condition = SELECT COUNT(*) = 65 FROM t1;
++>>>>>>> 10.1
--source include/wait_condition.inc
- SET GLOBAL wsrep_slave_threads = 1;
+ SELECT COUNT(*) FROM t1;
+
+ --echo # Wait 10 slave threads to exit 4
+ # Wait until appliers exit
+ --let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
+ --source include/wait_condition.inc
+
+ --connection node_1
DROP TABLE t1;
diff --cc mysql-test/suite/galera/t/MW-44.test
index e8caa28c80e,5bc5fa9dab8..eb50be1a53b
--- a/mysql-test/suite/galera/t/MW-44.test
+++ b/mysql-test/suite/galera/t/MW-44.test
@@@ -6,23 -6,20 +6,22 @@@
--source include/have_innodb.inc
--connection node_1
- SET GLOBAL general_log='OFF';
TRUNCATE TABLE mysql.general_log;
- --let $wait_condition = SELECT COUNT(*) = 0 FROM mysql.general_log;
- --source include/wait_condition.inc
+--sleep 1
--connection node_2
- SET GLOBAL general_log='OFF';
TRUNCATE TABLE mysql.general_log;
- --let $wait_condition = SELECT COUNT(*) = 0 FROM mysql.general_log;
+ --let $wait_condition = SELECT COUNT(*) = 0 FROM mysql.general_log WHERE argument LIKE 'TRUNCATE%';
--source include/wait_condition.inc
+ SELECT Argument FROM mysql.general_log;
+--sleep 1
--connection node_1
- SET GLOBAL general_log='ON';
- SELECT argument from mysql.general_log WHERE argument NOT LIKE 'SELECT%';
+ --let $wait_condition = SELECT COUNT(*) = 0 FROM mysql.general_log WHERE argument LIKE 'TRUNCATE%';
+ --source include/wait_condition.inc
+ SELECT Argument FROM mysql.general_log;
+ SET GLOBAL general_log='ON';
SET SESSION wsrep_osu_method=TOI;
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
SET SESSION wsrep_osu_method=RSU;
diff --cc mysql-test/suite/galera/t/galera_var_slave_threads.test
index e5986f7ee12,1cee845b6ab..80edcb2aff9
--- a/mysql-test/suite/galera/t/galera_var_slave_threads.test
+++ b/mysql-test/suite/galera/t/galera_var_slave_threads.test
@@@ -33,8 -34,15 +33,14 @@@ SET GLOBAL wsrep_slave_threads = 64
INSERT INTO t1 VALUES (1);
--connection node_2
+ --let $wait_timeout=600
+ --let $wait_condition = SELECT COUNT(*) = 1 FROM t1;
+ --source include/wait_condition.inc
+
+ SELECT COUNT(*) = 1 FROM t1;
+
---let $wait_condition = SELECT COUNT(*) = @@wsrep_slave_threads + 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user';
+--let $wait_condition = SELECT COUNT(*) = @@wsrep_slave_threads + 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
--source include/wait_condition.inc
-SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%';
#
# Reduce the number of slave threads. The change is not immediate -- a thread will only exit after a replication event
@@@ -51,13 -61,18 +59,15 @@@ while ($count
INSERT INTO t2 VALUES (DEFAULT);
--dec $count
}
+ --enable_query_log
+ --enable_result_log
--connection node_2
---let $wait_condition = SELECT COUNT(*) = 64 FROM t2;
---source include/wait_condition.inc
+SELECT COUNT(*) FROM t2;
-SELECT COUNT(*) = 64 FROM t2;
-
---let $wait_condition = SELECT COUNT(*) = @@wsrep_slave_threads + 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user';
+--let $wait_condition = SELECT COUNT(*) = @@wsrep_slave_threads + 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%')
--source include/wait_condition.inc
-SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%';
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%';
--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig
diff --cc mysql-test/suite/innodb/r/foreign-keys.result
index 0cb53f52a6c,66fc00e34d0..4402c5ca2fe
--- a/mysql-test/suite/innodb/r/foreign-keys.result
+++ b/mysql-test/suite/innodb/r/foreign-keys.result
@@@ -17,37 -17,73 +17,110 @@@ drop table title, department, people
create table t1 (a int primary key, b int) engine=innodb;
create table t2 (c int primary key, d int,
foreign key (d) references t1 (a) on update cascade) engine=innodb;
+ insert t1 values (1,1),(2,2),(3,3);
+ insert t2 values (4,1),(5,2),(6,3);
+ flush table t2 with read lock;
+ connect con1,localhost,root;
+ delete from t1 where a=2;
+ ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`d`) REFERENCES `t1` (`a`) ON UPDATE CASCADE)
+ update t1 set a=10 where a=1;
+ connection default;
+ unlock tables;
+ connection con1;
+ connection default;
+ lock table t2 write;
+ connection con1;
+ delete from t1 where a=2;
+ connection default;
+ unlock tables;
+ connection con1;
+ ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`d`) REFERENCES `t1` (`a`) ON UPDATE CASCADE)
+ connection default;
+ unlock tables;
+ disconnect con1;
+ create user foo;
+ grant select,update on test.t1 to foo;
+ connect foo,localhost,foo;
+ update t1 set a=30 where a=3;
+ disconnect foo;
+ connection default;
+ select * from t2;
+ c d
+ 5 2
+ 4 10
+ 6 30
+ drop table t2, t1;
+ drop user foo;
+ create table t1 (f1 int primary key) engine=innodb;
+ create table t2 (f2 int primary key) engine=innodb;
+ create table t3 (f3 int primary key, foreign key (f3) references t2(f2)) engine=innodb;
+ insert into t1 values (1),(2),(3),(4),(5);
+ insert into t2 values (1),(2),(3),(4),(5);
+ insert into t3 values (1),(2),(3),(4),(5);
+ connect con1,localhost,root;
+ set debug_sync='alter_table_before_rename_result_table signal g1 wait_for g2';
+ alter table t2 add constraint foreign key (f2) references t1(f1) on delete cascade on update cascade;
+ connection default;
+ set debug_sync='before_execute_sql_command wait_for g1';
+ update t1 set f1 = f1 + 100000 limit 2;
+ connect con2,localhost,root;
+ kill query UPDATE;
+ disconnect con2;
+ connection default;
+ ERROR 70100: Query execution was interrupted
+ set debug_sync='now signal g2';
+ connection con1;
+ show create table t2;
+ Table Create Table
+ t2 CREATE TABLE `t2` (
+ `f2` int(11) NOT NULL,
+ PRIMARY KEY (`f2`),
+ CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`) ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1
+ disconnect con1;
+ connection default;
+ select * from t2 where f2 not in (select f1 from t1);
+ f2
+ select * from t3 where f3 not in (select f2 from t2);
+ f3
+ drop table t3;
+ drop table t2;
+ drop table t1;
+ set debug_sync='reset';
++create table t1 (a int primary key, b int) engine=innodb;
++create table t2 (c int primary key, d int,
++foreign key (d) references t1 (a) on update cascade) engine=innodb;
+insert t1 values (1,1),(2,2),(3,3);
+insert t2 values (4,1),(5,2),(6,3);
+flush table t2 with read lock;
+connect con1,localhost,root;
+delete from t1 where a=2;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`d`) REFERENCES `t1` (`a`) ON UPDATE CASCADE)
+update t1 set a=10 where a=1;
+connection default;
+unlock tables;
+connection con1;
+connection default;
+lock table t2 write;
+connection con1;
+delete from t1 where a=2;
+connection default;
+unlock tables;
+connection con1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`d`) REFERENCES `t1` (`a`) ON UPDATE CASCADE)
+connection default;
+unlock tables;
+disconnect con1;
+create user foo;
+grant select,update on test.t1 to foo;
+connect foo,localhost,foo;
+update t1 set a=30 where a=3;
+disconnect foo;
+connection default;
+select * from t2;
+c d
+5 2
+4 10
+6 30
+drop table t2, t1;
+drop user foo;
diff --cc mysql-test/suite/innodb/r/foreign_key.result
index 5838c3a1fd5,0d04f27f51f..e68b0f85d8b
--- a/mysql-test/suite/innodb/r/foreign_key.result
+++ b/mysql-test/suite/innodb/r/foreign_key.result
@@@ -1,155 -1,3 +1,156 @@@
++<<<<<<< HEAD
+#
+# Bug #19027905 ASSERT RET.SECOND DICT_CREATE_FOREIGN_CONSTRAINTS_LOW
+# DICT_CREATE_FOREIGN_CONSTR
+#
+create table t1 (f1 int primary key) engine=InnoDB;
+create table t2 (f1 int primary key,
+constraint c1 foreign key (f1) references t1(f1),
+constraint c1 foreign key (f1) references t1(f1)) engine=InnoDB;
+ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
+create table t2 (f1 int primary key,
+constraint c1 foreign key (f1) references t1(f1)) engine=innodb;
+alter table t2 add constraint c1 foreign key (f1) references t1(f1);
+ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 121 "Duplicate key on write or update")
+set foreign_key_checks = 0;
+alter table t2 add constraint c1 foreign key (f1) references t1(f1);
+ERROR HY000: Duplicate FOREIGN KEY constraint name 'test/c1'
+drop table t2, t1;
+#
+# Bug #20031243 CREATE TABLE FAILS TO CHECK IF FOREIGN KEY COLUMN
+# NULL/NOT NULL MISMATCH
+#
+set foreign_key_checks = 1;
+show variables like 'foreign_key_checks';
+Variable_name Value
+foreign_key_checks ON
+CREATE TABLE t1
+(a INT NOT NULL,
+b INT NOT NULL,
+INDEX idx(a)) ENGINE=InnoDB;
+CREATE TABLE t2
+(a INT KEY,
+b INT,
+INDEX ind(b),
+FOREIGN KEY (b) REFERENCES t1(a) ON DELETE CASCADE ON UPDATE CASCADE)
+ENGINE=InnoDB;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) NOT NULL,
+ KEY `idx` (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(11) NOT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ KEY `ind` (`b`),
+ CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`a`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (1, 80);
+INSERT INTO t1 VALUES (2, 81);
+INSERT INTO t1 VALUES (3, 82);
+INSERT INTO t1 VALUES (4, 83);
+INSERT INTO t1 VALUES (5, 84);
+INSERT INTO t2 VALUES (51, 1);
+INSERT INTO t2 VALUES (52, 2);
+INSERT INTO t2 VALUES (53, 3);
+INSERT INTO t2 VALUES (54, 4);
+INSERT INTO t2 VALUES (55, 5);
+SELECT a, b FROM t1 ORDER BY a;
+a b
+1 80
+2 81
+3 82
+4 83
+5 84
+SELECT a, b FROM t2 ORDER BY a;
+a b
+51 1
+52 2
+53 3
+54 4
+55 5
+INSERT INTO t2 VALUES (56, 6);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`a`) ON DELETE CASCADE ON UPDATE CASCADE)
+ALTER TABLE t1 CHANGE a id INT;
+SELECT id, b FROM t1 ORDER BY id;
+id b
+1 80
+2 81
+3 82
+4 83
+5 84
+SELECT a, b FROM t2 ORDER BY a;
+a b
+51 1
+52 2
+53 3
+54 4
+55 5
+# Operations on child table
+INSERT INTO t2 VALUES (56, 6);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)
+UPDATE t2 SET b = 99 WHERE a = 51;
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)
+DELETE FROM t2 WHERE a = 53;
+SELECT id, b FROM t1 ORDER BY id;
+id b
+1 80
+2 81
+3 82
+4 83
+5 84
+SELECT a, b FROM t2 ORDER BY a;
+a b
+51 1
+52 2
+54 4
+55 5
+# Operations on parent table
+DELETE FROM t1 WHERE id = 1;
+UPDATE t1 SET id = 50 WHERE id = 5;
+SELECT id, b FROM t1 ORDER BY id;
+id b
+2 81
+3 82
+4 83
+50 84
+SELECT a, b FROM t2 ORDER BY a;
+a b
+52 2
+54 4
+55 50
+DROP TABLE t2, t1;
+#
+# bug#25126722 FOREIGN KEY CONSTRAINT NAME IS NULL AFTER RESTART
+# base bug#24818604 [GR]
+#
+CREATE TABLE t1 (c1 INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t2 (c1 INT PRIMARY KEY, FOREIGN KEY (c1) REFERENCES t1(c1))
+ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+SELECT unique_constraint_name FROM information_schema.referential_constraints
+WHERE table_name = 't2';
+unique_constraint_name
+PRIMARY
+SELECT unique_constraint_name FROM information_schema.referential_constraints
+WHERE table_name = 't2';
+unique_constraint_name
+PRIMARY
+SELECT * FROM t1;
+c1
+1
+SELECT unique_constraint_name FROM information_schema.referential_constraints
+WHERE table_name = 't2';
+unique_constraint_name
+PRIMARY
+DROP TABLE t2;
+DROP TABLE t1;
SET FOREIGN_KEY_CHECKS=0;
CREATE TABLE staff (
staff_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
@@@ -169,151 -17,3 +170,173 @@@ SET FOREIGN_KEY_CHECKS=DEFAULT
LOCK TABLE staff WRITE;
UNLOCK TABLES;
DROP TABLES staff, store;
+SET FOREIGN_KEY_CHECKS=1;
+#
+# MDEV-13246 Stale rows despite ON DELETE CASCADE constraint
+#
+CREATE TABLE users (
+id int unsigned AUTO_INCREMENT PRIMARY KEY,
+name varchar(32) NOT NULL DEFAULT ''
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE matchmaking_groups (
+id bigint unsigned AUTO_INCREMENT PRIMARY KEY,
+host_user_id int unsigned NOT NULL UNIQUE,
+CONSTRAINT FOREIGN KEY (host_user_id) REFERENCES users (id)
+ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE matchmaking_group_users (
+matchmaking_group_id bigint unsigned NOT NULL,
+user_id int unsigned NOT NULL,
+PRIMARY KEY (matchmaking_group_id,user_id),
+UNIQUE KEY user_id (user_id),
+CONSTRAINT FOREIGN KEY (matchmaking_group_id)
+REFERENCES matchmaking_groups (id) ON DELETE CASCADE ON UPDATE CASCADE,
+CONSTRAINT FOREIGN KEY (user_id)
+REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE matchmaking_group_maps (
+matchmaking_group_id bigint unsigned NOT NULL,
+map_id tinyint unsigned NOT NULL,
+PRIMARY KEY (matchmaking_group_id,map_id),
+CONSTRAINT FOREIGN KEY (matchmaking_group_id)
+REFERENCES matchmaking_groups (id) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+INSERT INTO users VALUES (NULL,'foo'),(NULL,'bar');
+INSERT INTO matchmaking_groups VALUES (10,1),(11,2);
+INSERT INTO matchmaking_group_users VALUES (10,1),(11,2);
+INSERT INTO matchmaking_group_maps VALUES (10,55),(11,66);
+BEGIN;
+UPDATE users SET name = 'qux' WHERE id = 1;
+connect con1,localhost,root,,;
+SET innodb_lock_wait_timeout= 1;
+DELETE FROM matchmaking_groups WHERE id = 10;
+connection default;
+COMMIT;
+SELECT * FROM matchmaking_group_users WHERE matchmaking_group_id NOT IN (SELECT id FROM matchmaking_groups);
+matchmaking_group_id user_id
+SELECT * FROM matchmaking_group_maps WHERE matchmaking_group_id NOT IN (SELECT id FROM matchmaking_groups);
+matchmaking_group_id map_id
+SELECT * FROM users;
+id name
+1 qux
+2 bar
+DROP TABLE
+matchmaking_group_maps, matchmaking_group_users, matchmaking_groups, users;
+#
+# MDEV-13331 FK DELETE CASCADE does not honor innodb_lock_wait_timeout
+#
+CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t2 (
+id INT NOT NULL PRIMARY KEY,
+ref_id INT NOT NULL DEFAULT 0,
+f INT NULL,
+FOREIGN KEY (ref_id) REFERENCES t1 (id) ON DELETE CASCADE
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1),(2);
+INSERT INTO t2 VALUES (1,1,10),(2,2,20);
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `id` int(11) NOT NULL,
+ `ref_id` int(11) NOT NULL DEFAULT 0,
+ `f` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ KEY `ref_id` (`ref_id`),
+ CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`ref_id`) REFERENCES `t1` (`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+connection con1;
+BEGIN;
+UPDATE t2 SET f = 11 WHERE id = 1;
+connection default;
+SET innodb_lock_wait_timeout= 1;
+DELETE FROM t1 WHERE id = 1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection con1;
+COMMIT;
+disconnect con1;
+connection default;
+SELECT * FROM t2;
+id ref_id f
+1 1 11
+2 2 20
+DELETE FROM t1 WHERE id = 1;
+SELECT * FROM t2;
+id ref_id f
+2 2 20
+DROP TABLE t2, t1;
+#
+# MDEV-15199 Referential integrity broken in ON DELETE CASCADE
+#
+CREATE TABLE member (id int AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO member VALUES (1);
+CREATE TABLE address (
+id int AUTO_INCREMENT PRIMARY KEY,
+member_id int NOT NULL,
+KEY address_FI_1 (member_id),
+CONSTRAINT address_FK_1 FOREIGN KEY (member_id) REFERENCES member (id)
+ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB;
+INSERT INTO address VALUES (2,1);
+CREATE TABLE payment_method (
+id int AUTO_INCREMENT PRIMARY KEY,
+member_id int NOT NULL,
+cardholder_address_id int DEFAULT NULL,
+KEY payment_method_FI_1 (member_id),
+KEY payment_method_FI_2 (cardholder_address_id),
+CONSTRAINT payment_method_FK_1 FOREIGN KEY (member_id) REFERENCES member (id) ON DELETE CASCADE ON UPDATE CASCADE,
+CONSTRAINT payment_method_FK_2 FOREIGN KEY (cardholder_address_id) REFERENCES address (id) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB;
+INSERT INTO payment_method VALUES (3,1,2);
+BEGIN;
+UPDATE member SET id=42;
+SELECT * FROM member;
+id
+42
+SELECT * FROM address;
+id member_id
+2 42
+SELECT * FROM payment_method;
+id member_id cardholder_address_id
+3 42 2
+DELETE FROM member;
+COMMIT;
+SELECT * FROM member;
+id
+SELECT * FROM address;
+id member_id
+SELECT * FROM payment_method;
+id member_id cardholder_address_id
+DROP TABLE payment_method,address,member;
+#
+# Bug #26958695 INNODB NESTED STORED FIELD WITH CONSTRAINT KEY
+# PRODUCE BROKEN TABLE (no bug in MariaDB)
+#
+create table t1(f1 int,f2 int, primary key(f1), key(f2, f1))engine=innodb;
+create table t2(f1 int, f2 int as (2) stored, f3 int as (f2) stored,
+foreign key(f1) references t1(f2) on update set NULL)
+engine=innodb;
+insert into t1 values(1, 1);
+insert into t2(f1) values(1);
+drop table t2, t1;
++||||||| merged common ancestors
++=======
++SET FOREIGN_KEY_CHECKS=0;
++CREATE TABLE staff (
++staff_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
++store_id TINYINT UNSIGNED NOT NULL,
++PRIMARY KEY (staff_id),
++KEY idx_fk_store_id (store_id),
++CONSTRAINT fk_staff_store FOREIGN KEY (store_id) REFERENCES store (store_id) ON DELETE RESTRICT ON UPDATE CASCADE
++) ENGINE=InnoDB;
++CREATE TABLE store (
++store_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
++manager_staff_id TINYINT UNSIGNED NOT NULL,
++PRIMARY KEY (store_id),
++UNIQUE KEY idx_unique_manager (manager_staff_id),
++CONSTRAINT fk_store_staff FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id) ON DELETE RESTRICT ON UPDATE CASCADE
++) ENGINE=InnoDB;
++SET FOREIGN_KEY_CHECKS=DEFAULT;
++LOCK TABLE staff WRITE;
++UNLOCK TABLES;
++DROP TABLES staff, store;
++>>>>>>> 10.1
diff --cc mysql-test/suite/innodb/r/innodb-lock.result
index e63a7cd1505,5806535d6f0..81d7f5b0e42
--- a/mysql-test/suite/innodb/r/innodb-lock.result
+++ b/mysql-test/suite/innodb/r/innodb-lock.result
@@@ -2,11 -2,7 +2,16 @@@ set global innodb_table_locks=1
select @@innodb_table_locks;
@@innodb_table_locks
1
++<<<<<<< HEAD
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+drop table if exists t1;
++||||||| merged common ancestors
++drop table if exists t1;
++=======
++>>>>>>> 10.1
set @@innodb_table_locks=1;
+connection con1;
create table t1 (id integer, x integer) engine=INNODB;
insert into t1 values(0, 0);
set autocommit=0;
@@@ -122,7 -108,32 +127,35 @@@ connection con1
a b
3 1
COMMIT;
+disconnect con1;
+disconnect con2;
+connection default;
DROP TABLE t1;
+ #
+ # MDEV-11080 InnoDB: Failing assertion:
+ # table->n_waiting_or_granted_auto_inc_locks > 0
+ #
+ CREATE TABLE t1 (pk INTEGER AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
+ INSERT INTO t1 VALUES (NULL),(NULL);
+ CREATE TABLE t2 LIKE t1;
+ BEGIN;
+ BEGIN;
+ DELETE FROM t2;
+ LOCK TABLE t2 READ;;
+ SET innodb_lock_wait_timeout= 1, lock_wait_timeout= 2;
+ INSERT INTO t2 SELECT * FROM t1;
+ COMMIT;
+ UNLOCK TABLES;
+ DROP TABLE t1, t2;
+ #
+ # MDEV-16709 InnoDB: Error: trx already had an AUTO-INC lock
+ #
+ CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB
+ PARTITION BY key (pk) PARTITIONS 2;
+ CREATE TABLE t2 (a INT) ENGINE=InnoDB;
+ INSERT INTO t2 VALUES (1),(2),(3),(4),(5),(6);
+ CREATE TABLE t3 (b INT) ENGINE=InnoDB;
+ INSERT INTO t3 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9);
+ INSERT t1 SELECT NULL FROM t2;
+ INSERT t1 SELECT NULL FROM t3;
+ DROP TABLE t1, t2, t3;
diff --cc mysql-test/suite/innodb/t/foreign-keys.test
index e77e1e761c7,7ef440b260b..35da5a5d075
--- a/mysql-test/suite/innodb/t/foreign-keys.test
+++ b/mysql-test/suite/innodb/t/foreign-keys.test
@@@ -35,38 -38,76 +38,122 @@@ create table t2 (c int primary key, d i
insert t1 values (1,1),(2,2),(3,3);
insert t2 values (4,1),(5,2),(6,3);
flush table t2 with read lock; # this takes MDL_SHARED_NO_WRITE
+ connect (con1,localhost,root);
+ --error ER_ROW_IS_REFERENCED_2
+ delete from t1 where a=2;
+ send update t1 set a=10 where a=1;
+ connection default;
+ let $wait_condition= select 1 from information_schema.processlist where state='Waiting for table metadata lock';
+ source include/wait_condition.inc;
+ unlock tables;
+ connection con1;
+ reap;
+ connection default;
+ lock table t2 write; # this takes MDL_SHARED_NO_READ_WRITE
+ connection con1;
+ send delete from t1 where a=2;
+ connection default;
+ let $wait_condition= select 1 from information_schema.processlist where state='Waiting for table metadata lock';
+ source include/wait_condition.inc;
+ unlock tables;
+ connection con1;
+ --error ER_ROW_IS_REFERENCED_2
+ reap;
+ connection default;
+ unlock tables;
+ disconnect con1;
+
+ # but privileges should not be checked
+ create user foo;
+ grant select,update on test.t1 to foo;
+ connect(foo,localhost,foo);
+ update t1 set a=30 where a=3;
+ disconnect foo;
+ connection default;
+ select * from t2;
+ drop table t2, t1;
+ drop user foo;
+
+ #
+ # MDEV-16465 Invalid (old?) table or database name or hang in ha_innobase::delete_table and log semaphore wait upon concurrent DDL with foreign keys
+ #
+ create table t1 (f1 int primary key) engine=innodb;
+ create table t2 (f2 int primary key) engine=innodb;
+ create table t3 (f3 int primary key, foreign key (f3) references t2(f2)) engine=innodb;
+ insert into t1 values (1),(2),(3),(4),(5);
+ insert into t2 values (1),(2),(3),(4),(5);
+ insert into t3 values (1),(2),(3),(4),(5);
+ connect con1,localhost,root;
+ set debug_sync='alter_table_before_rename_result_table signal g1 wait_for g2';
+ send alter table t2 add constraint foreign key (f2) references t1(f1) on delete cascade on update cascade;
+ connection default;
+ let $conn=`select connection_id()`;
+ set debug_sync='before_execute_sql_command wait_for g1';
+ send update t1 set f1 = f1 + 100000 limit 2;
+ connect con2,localhost,root;
+ let $wait_condition= select 1 from information_schema.processlist where state='Waiting for table metadata lock' and info like 'update t1 %';
+ source include/wait_condition.inc;
+ --replace_result $conn UPDATE
+ eval kill query $conn;
+ disconnect con2;
+ connection default;
+ error ER_QUERY_INTERRUPTED;
+ reap;
+ set debug_sync='now signal g2';
+ connection con1;
+ reap;
+ show create table t2;
+ disconnect con1;
+ connection default;
+ select * from t2 where f2 not in (select f1 from t1);
+ select * from t3 where f3 not in (select f2 from t2);
+ drop table t3;
+ drop table t2;
+ drop table t1;
+ set debug_sync='reset';
++
++#
++# FK and prelocking:
++# child table accesses (reads and writes) wait for locks.
++#
++create table t1 (a int primary key, b int) engine=innodb;
++create table t2 (c int primary key, d int,
++ foreign key (d) references t1 (a) on update cascade) engine=innodb;
++insert t1 values (1,1),(2,2),(3,3);
++insert t2 values (4,1),(5,2),(6,3);
++flush table t2 with read lock; # this takes MDL_SHARED_NO_WRITE
+connect (con1,localhost,root);
+--error ER_ROW_IS_REFERENCED_2
+delete from t1 where a=2;
+send update t1 set a=10 where a=1;
+connection default;
+let $wait_condition= select 1 from information_schema.processlist where state='Waiting for table metadata lock';
+source include/wait_condition.inc;
+unlock tables;
+connection con1;
+reap;
+connection default;
+lock table t2 write; # this takes MDL_SHARED_NO_READ_WRITE
+connection con1;
+send delete from t1 where a=2;
+connection default;
+let $wait_condition= select 1 from information_schema.processlist where state='Waiting for table metadata lock';
+source include/wait_condition.inc;
+unlock tables;
+connection con1;
+--error ER_ROW_IS_REFERENCED_2
+reap;
+connection default;
+unlock tables;
+disconnect con1;
+
+# but privileges should not be checked
+create user foo;
+grant select,update on test.t1 to foo;
+connect(foo,localhost,foo);
+update t1 set a=30 where a=3;
+disconnect foo;
+connection default;
+select * from t2;
+drop table t2, t1;
+drop user foo;
diff --cc mysql-test/suite/innodb/t/foreign_key.test
index b586f3e9406,223a1596883..7a8a9295ee7
--- a/mysql-test/suite/innodb/t/foreign_key.test
+++ b/mysql-test/suite/innodb/t/foreign_key.test
@@@ -1,291 -1,25 +1,315 @@@
--source include/have_innodb.inc
+--source include/count_sessions.inc
+
+--echo #
+--echo # Bug #19027905 ASSERT RET.SECOND DICT_CREATE_FOREIGN_CONSTRAINTS_LOW
+--echo # DICT_CREATE_FOREIGN_CONSTR
+--echo #
+
+create table t1 (f1 int primary key) engine=InnoDB;
+--error ER_CANT_CREATE_TABLE
+create table t2 (f1 int primary key,
+constraint c1 foreign key (f1) references t1(f1),
+constraint c1 foreign key (f1) references t1(f1)) engine=InnoDB;
+create table t2 (f1 int primary key,
+ constraint c1 foreign key (f1) references t1(f1)) engine=innodb;
+
+--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
+--error ER_CANT_CREATE_TABLE
+alter table t2 add constraint c1 foreign key (f1) references t1(f1);
+
+set foreign_key_checks = 0;
+--error ER_DUP_CONSTRAINT_NAME
+alter table t2 add constraint c1 foreign key (f1) references t1(f1);
+
+drop table t2, t1;
+
+--echo #
+--echo # Bug #20031243 CREATE TABLE FAILS TO CHECK IF FOREIGN KEY COLUMN
+--echo # NULL/NOT NULL MISMATCH
+--echo #
+
+set foreign_key_checks = 1;
+show variables like 'foreign_key_checks';
+
+CREATE TABLE t1
+(a INT NOT NULL,
+ b INT NOT NULL,
+ INDEX idx(a)) ENGINE=InnoDB;
+
+CREATE TABLE t2
+(a INT KEY,
+ b INT,
+ INDEX ind(b),
+ FOREIGN KEY (b) REFERENCES t1(a) ON DELETE CASCADE ON UPDATE CASCADE)
+ ENGINE=InnoDB;
+
+show create table t1;
+show create table t2;
+
+INSERT INTO t1 VALUES (1, 80);
+INSERT INTO t1 VALUES (2, 81);
+INSERT INTO t1 VALUES (3, 82);
+INSERT INTO t1 VALUES (4, 83);
+INSERT INTO t1 VALUES (5, 84);
+
+INSERT INTO t2 VALUES (51, 1);
+INSERT INTO t2 VALUES (52, 2);
+INSERT INTO t2 VALUES (53, 3);
+INSERT INTO t2 VALUES (54, 4);
+INSERT INTO t2 VALUES (55, 5);
+
+SELECT a, b FROM t1 ORDER BY a;
+SELECT a, b FROM t2 ORDER BY a;
+
+--error ER_NO_REFERENCED_ROW_2
+INSERT INTO t2 VALUES (56, 6);
+
+ALTER TABLE t1 CHANGE a id INT;
+
+SELECT id, b FROM t1 ORDER BY id;
+SELECT a, b FROM t2 ORDER BY a;
+
+--echo # Operations on child table
+--error ER_NO_REFERENCED_ROW_2
+INSERT INTO t2 VALUES (56, 6);
+--error ER_NO_REFERENCED_ROW_2
+UPDATE t2 SET b = 99 WHERE a = 51;
+DELETE FROM t2 WHERE a = 53;
+SELECT id, b FROM t1 ORDER BY id;
+SELECT a, b FROM t2 ORDER BY a;
+
+--echo # Operations on parent table
+DELETE FROM t1 WHERE id = 1;
+UPDATE t1 SET id = 50 WHERE id = 5;
+SELECT id, b FROM t1 ORDER BY id;
+SELECT a, b FROM t2 ORDER BY a;
+
+DROP TABLE t2, t1;
+
+--echo #
+--echo # bug#25126722 FOREIGN KEY CONSTRAINT NAME IS NULL AFTER RESTART
+--echo # base bug#24818604 [GR]
+--echo #
+
+CREATE TABLE t1 (c1 INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t2 (c1 INT PRIMARY KEY, FOREIGN KEY (c1) REFERENCES t1(c1))
+ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+
+SELECT unique_constraint_name FROM information_schema.referential_constraints
+WHERE table_name = 't2';
+
+--source include/restart_mysqld.inc
+
+SELECT unique_constraint_name FROM information_schema.referential_constraints
+WHERE table_name = 't2';
+
+SELECT * FROM t1;
+
+SELECT unique_constraint_name FROM information_schema.referential_constraints
+WHERE table_name = 't2';
+
+DROP TABLE t2;
+DROP TABLE t1;
+
+#
+# MDEV-12669 Circular foreign keys cause a loop and OOM upon LOCK TABLE
+#
+SET FOREIGN_KEY_CHECKS=0;
+CREATE TABLE staff (
+ staff_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
+ store_id TINYINT UNSIGNED NOT NULL,
+ PRIMARY KEY (staff_id),
+ KEY idx_fk_store_id (store_id),
+ CONSTRAINT fk_staff_store FOREIGN KEY (store_id) REFERENCES store (store_id) ON DELETE RESTRICT ON UPDATE CASCADE
+) ENGINE=InnoDB;
+CREATE TABLE store (
+ store_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
+ manager_staff_id TINYINT UNSIGNED NOT NULL,
+ PRIMARY KEY (store_id),
+ UNIQUE KEY idx_unique_manager (manager_staff_id),
+ CONSTRAINT fk_store_staff FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id) ON DELETE RESTRICT ON UPDATE CASCADE
+) ENGINE=InnoDB;
+SET FOREIGN_KEY_CHECKS=DEFAULT;
+
+LOCK TABLE staff WRITE;
+UNLOCK TABLES;
+DROP TABLES staff, store;
+SET FOREIGN_KEY_CHECKS=1;
+
+--echo #
+--echo # MDEV-13246 Stale rows despite ON DELETE CASCADE constraint
+--echo #
+
+CREATE TABLE users (
+ id int unsigned AUTO_INCREMENT PRIMARY KEY,
+ name varchar(32) NOT NULL DEFAULT ''
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE matchmaking_groups (
+ id bigint unsigned AUTO_INCREMENT PRIMARY KEY,
+ host_user_id int unsigned NOT NULL UNIQUE,
+ CONSTRAINT FOREIGN KEY (host_user_id) REFERENCES users (id)
+ ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE matchmaking_group_users (
+ matchmaking_group_id bigint unsigned NOT NULL,
+ user_id int unsigned NOT NULL,
+ PRIMARY KEY (matchmaking_group_id,user_id),
+ UNIQUE KEY user_id (user_id),
+ CONSTRAINT FOREIGN KEY (matchmaking_group_id)
+ REFERENCES matchmaking_groups (id) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT FOREIGN KEY (user_id)
+ REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE matchmaking_group_maps (
+ matchmaking_group_id bigint unsigned NOT NULL,
+ map_id tinyint unsigned NOT NULL,
+ PRIMARY KEY (matchmaking_group_id,map_id),
+ CONSTRAINT FOREIGN KEY (matchmaking_group_id)
+ REFERENCES matchmaking_groups (id) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+INSERT INTO users VALUES (NULL,'foo'),(NULL,'bar');
+INSERT INTO matchmaking_groups VALUES (10,1),(11,2);
+INSERT INTO matchmaking_group_users VALUES (10,1),(11,2);
+INSERT INTO matchmaking_group_maps VALUES (10,55),(11,66);
+
+BEGIN;
+UPDATE users SET name = 'qux' WHERE id = 1;
+
+--connect (con1,localhost,root,,)
+SET innodb_lock_wait_timeout= 1;
+DELETE FROM matchmaking_groups WHERE id = 10;
+
+--connection default
+COMMIT;
+--sorted_result
+SELECT * FROM matchmaking_group_users WHERE matchmaking_group_id NOT IN (SELECT id FROM matchmaking_groups);
+--sorted_result
+SELECT * FROM matchmaking_group_maps WHERE matchmaking_group_id NOT IN (SELECT id FROM matchmaking_groups);
+--sorted_result
+SELECT * FROM users;
+
+DROP TABLE
+matchmaking_group_maps, matchmaking_group_users, matchmaking_groups, users;
+
+--echo #
+--echo # MDEV-13331 FK DELETE CASCADE does not honor innodb_lock_wait_timeout
+--echo #
+
+CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
+
+CREATE TABLE t2 (
+ id INT NOT NULL PRIMARY KEY,
+ ref_id INT NOT NULL DEFAULT 0,
+ f INT NULL,
+ FOREIGN KEY (ref_id) REFERENCES t1 (id) ON DELETE CASCADE
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES (1),(2);
+INSERT INTO t2 VALUES (1,1,10),(2,2,20);
+
+SHOW CREATE TABLE t2;
+
+--connection con1
+BEGIN;
+UPDATE t2 SET f = 11 WHERE id = 1;
+
+--connection default
+SET innodb_lock_wait_timeout= 1;
+--error ER_LOCK_WAIT_TIMEOUT
+DELETE FROM t1 WHERE id = 1;
+
+--connection con1
+COMMIT;
+--disconnect con1
+
+--connection default
+SELECT * FROM t2;
+DELETE FROM t1 WHERE id = 1;
+SELECT * FROM t2;
+DROP TABLE t2, t1;
+
+--echo #
+--echo # MDEV-15199 Referential integrity broken in ON DELETE CASCADE
+--echo #
+
+CREATE TABLE member (id int AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO member VALUES (1);
+CREATE TABLE address (
+ id int AUTO_INCREMENT PRIMARY KEY,
+ member_id int NOT NULL,
+ KEY address_FI_1 (member_id),
+ CONSTRAINT address_FK_1 FOREIGN KEY (member_id) REFERENCES member (id)
+ ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB;
+
+INSERT INTO address VALUES (2,1);
+CREATE TABLE payment_method (
+ id int AUTO_INCREMENT PRIMARY KEY,
+ member_id int NOT NULL,
+ cardholder_address_id int DEFAULT NULL,
+ KEY payment_method_FI_1 (member_id),
+ KEY payment_method_FI_2 (cardholder_address_id),
+ CONSTRAINT payment_method_FK_1 FOREIGN KEY (member_id) REFERENCES member (id) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT payment_method_FK_2 FOREIGN KEY (cardholder_address_id) REFERENCES address (id) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB;
+
+INSERT INTO payment_method VALUES (3,1,2);
+
+BEGIN;
+UPDATE member SET id=42;
+SELECT * FROM member;
+SELECT * FROM address;
+SELECT * FROM payment_method;
+DELETE FROM member;
+COMMIT;
+SELECT * FROM member;
+SELECT * FROM address;
+SELECT * FROM payment_method;
+
+DROP TABLE payment_method,address,member;
+
+--echo #
+--echo # Bug #26958695 INNODB NESTED STORED FIELD WITH CONSTRAINT KEY
+--echo # PRODUCE BROKEN TABLE (no bug in MariaDB)
+--echo #
+create table t1(f1 int,f2 int, primary key(f1), key(f2, f1))engine=innodb;
+create table t2(f1 int, f2 int as (2) stored, f3 int as (f2) stored,
+ foreign key(f1) references t1(f2) on update set NULL)
+engine=innodb;
+insert into t1 values(1, 1);
+insert into t2(f1) values(1);
+drop table t2, t1;
+
+--source include/wait_until_count_sessions.inc
+
+ #
+ # MDEV-12669 Circular foreign keys cause a loop and OOM upon LOCK TABLE
+ #
+ SET FOREIGN_KEY_CHECKS=0;
+ CREATE TABLE staff (
+ staff_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
+ store_id TINYINT UNSIGNED NOT NULL,
+ PRIMARY KEY (staff_id),
+ KEY idx_fk_store_id (store_id),
+ CONSTRAINT fk_staff_store FOREIGN KEY (store_id) REFERENCES store (store_id) ON DELETE RESTRICT ON UPDATE CASCADE
+ ) ENGINE=InnoDB;
+ CREATE TABLE store (
+ store_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
+ manager_staff_id TINYINT UNSIGNED NOT NULL,
+ PRIMARY KEY (store_id),
+ UNIQUE KEY idx_unique_manager (manager_staff_id),
+ CONSTRAINT fk_store_staff FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id) ON DELETE RESTRICT ON UPDATE CASCADE
+ ) ENGINE=InnoDB;
+ SET FOREIGN_KEY_CHECKS=DEFAULT;
+
+ LOCK TABLE staff WRITE;
+ UNLOCK TABLES;
+ DROP TABLES staff, store;
diff --cc mysql-test/suite/rpl/r/rpl_foreign_key_innodb.result
index 120ae018d2f,efe8155ec08..7f2a82f1efb
--- a/mysql-test/suite/rpl/r/rpl_foreign_key_innodb.result
+++ b/mysql-test/suite/rpl/r/rpl_foreign_key_innodb.result
@@@ -40,11 -36,8 +40,10 @@@ connection master
SET FOREIGN_KEY_CHECKS=0;
DROP TABLE IF EXISTS t1,t2,t3;
SET FOREIGN_KEY_CHECKS=1;
+connection slave;
+connection master;
create table t1 (b int primary key) engine = INNODB;
- create table t2 (a int primary key, b int, foreign key (b) references t1(b))
- engine = INNODB;
+ create table t2 (a int primary key, b int, foreign key (b) references t1(b)) engine = INNODB;
insert into t1 set b=1;
insert into t2 set a=1, b=1;
set foreign_key_checks=0;
diff --cc sql/field.cc
index 9ca9663f066,ecb383a9575..a1a8ca41698
--- a/sql/field.cc
+++ b/sql/field.cc
@@@ -9815,15 -9782,20 +9815,20 @@@ void Column_definition::create_length_t
}
break;
case MYSQL_TYPE_NEWDECIMAL:
- key_length= pack_length=
- my_decimal_get_binary_size(my_decimal_length_to_precision((uint)length,
- decimals,
- flags &
- UNSIGNED_FLAG),
- decimals);
+ {
+ /*
+ This code must be identical to code in
+ Field_new_decimal::Field_new_decimal as otherwise the record layout
+ gets out of sync.
+ */
- uint precision= my_decimal_length_to_precision(length, decimals,
++ uint precision= my_decimal_length_to_precision((uint)length, decimals,
+ flags & UNSIGNED_FLAG);
+ set_if_smaller(precision, DECIMAL_MAX_PRECISION);
+ key_length= pack_length= my_decimal_get_binary_size(precision, decimals);
break;
+ }
default:
- key_length= pack_length= calc_pack_length(sql_type, length);
+ key_length= pack_length= calc_pack_length(sql_type, (uint)length);
break;
}
}
diff --cc sql/log.cc
index fa1fe3d808c,767070799a9..053c0f16c6c
--- a/sql/log.cc
+++ b/sql/log.cc
@@@ -1668,14 -1677,14 +1668,14 @@@ static int binlog_close_connection(hand
uchar *buf;
size_t len=0;
wsrep_write_cache_buf(cache, &buf, &len);
- WSREP_WARN("binlog trx cache not empty (%lu bytes) @ connection close %lld",
- (ulong) len, (longlong) thd->thread_id);
- WSREP_WARN("binlog trx cache not empty (%zu bytes) @ connection close %lu",
- len, thd->thread_id);
++ WSREP_WARN("binlog trx cache not empty (%zu bytes) @ connection close %lld",
++ len, (longlong) thd->thread_id);
if (len > 0) wsrep_dump_rbr_buf(thd, buf, len);
cache = cache_mngr->get_binlog_cache_log(false);
wsrep_write_cache_buf(cache, &buf, &len);
- WSREP_WARN("binlog stmt cache not empty (%lu bytes) @ connection close %lld",
- (ulong) len, (longlong) thd->thread_id);
- WSREP_WARN("binlog stmt cache not empty (%zu bytes) @ connection close %lu",
- len, thd->thread_id);
++ WSREP_WARN("binlog stmt cache not empty (%zu bytes) @ connection close %lld",
++ len, (longlong) thd->thread_id);
if (len > 0) wsrep_dump_rbr_buf(thd, buf, len);
}
#endif /* WITH_WSREP */
diff --cc sql/log_event.cc
index ff3efcc62a3,e1912ad4620..04a616d0006
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@@ -8726,12 -7911,7 +8726,7 @@@ User_var_log_event(const char* buf, uin
Old events will not have this extra byte, thence,
we keep the flags set to UNDEF_F.
*/
- uint bytes_read= ((val + val_len) - buf_start);
+ size_t bytes_read= (val + val_len) - buf_start;
- if (bytes_read > size_t(event_len))
- {
- error= true;
- goto err;
- }
if ((data_written - bytes_read) > 0)
{
flags= (uint) *(buf + UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
diff --cc sql/sql_alter.cc
index dbb138ed9ab,0accc04c10d..c8bc3952b61
--- a/sql/sql_alter.cc
+++ b/sql/sql_alter.cc
@@@ -306,12 -305,19 +306,17 @@@ bool Sql_cmd_alter_table::execute(THD *
thd->enable_slow_log= opt_log_slow_admin_statements;
#ifdef WITH_WSREP
- if ((!thd->is_current_stmt_binlog_format_row() ||
- TABLE *find_temporary_table(THD *thd, const TABLE_LIST *tl);
-
+ if (WSREP(thd) &&
+ (!thd->is_current_stmt_binlog_format_row() ||
- !find_temporary_table(thd, first_table)))
+ !thd->find_temporary_table(first_table)))
{
- WSREP_TO_ISOLATION_BEGIN(((lex->name.str) ? select_lex->db : NULL),
- ((lex->name.str) ? lex->name.str : NULL),
- first_table);
+ WSREP_TO_ISOLATION_BEGIN_ALTER(((lex->name.str) ? select_lex->db : NULL),
+ ((lex->name.str) ? lex->name.str : NULL),
+ first_table,
+ &alter_info);
+
+ thd->variables.auto_increment_offset = 1;
+ thd->variables.auto_increment_increment = 1;
}
#endif /* WITH_WSREP */
diff --cc sql/sql_base.cc
index cae5b4a3f7d,dc1122ffad8..52474116fa6
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@@ -1460,6 -2122,66 +1461,66 @@@ open_table_get_mdl_lock(THD *thd, Open_
}
+ /**
+ Check if the given table is actually a VIEW that was LOCK-ed
+
+ @param thd Thread context.
+ @param t Table to check.
+
+ @retval TRUE The 't'-table is a locked view
+ needed to remedy problem before retrying again.
+ @retval FALSE 't' was not locked, not a VIEW or an error happened.
+ */
+ bool is_locked_view(THD *thd, TABLE_LIST *t)
+ {
+ DBUG_ENTER("check_locked_view");
+ /*
+ Is this table a view and not a base table?
+ (it is work around to allow to open view with locked tables,
+ real fix will be made after definition cache will be made)
+
+ Since opening of view which was not explicitly locked by LOCK
+ TABLES breaks metadata locking protocol (potentially can lead
+ to deadlocks) it should be disallowed.
+ */
+ if (thd->mdl_context.is_lock_owner(MDL_key::TABLE,
+ t->db, t->table_name,
+ MDL_SHARED))
+ {
+ char path[FN_REFLEN + 1];
+ build_table_filename(path, sizeof(path) - 1,
+ t->db, t->table_name, reg_ext, 0);
+ /*
+ Note that we can't be 100% sure that it is a view since it's
+ possible that we either simply have not found unused TABLE
+ instance in THD::open_tables list or were unable to open table
+ during prelocking process (in this case in theory we still
+ should hold shared metadata lock on it).
+ */
+ if (dd_frm_is_view(thd, path))
+ {
+ /*
+ If parent_l of the table_list is non null then a merge table
+ has this view as child table, which is not supported.
+ */
+ if (t->parent_l)
+ {
+ my_error(ER_WRONG_MRG_TABLE, MYF(0));
+ DBUG_RETURN(FALSE);
+ }
+
- if (!tdc_open_view(thd, t, t->alias, CHECK_METADATA_VERSION))
++ if (!tdc_open_view(thd, t, CHECK_METADATA_VERSION))
+ {
+ DBUG_ASSERT(t->view != 0);
+ DBUG_RETURN(TRUE); // VIEW
+ }
+ }
+ }
+
+ DBUG_RETURN(FALSE);
+ }
+
+
/**
Open a base table.
@@@ -4213,8 -4874,8 +4246,9 @@@ handle_routine(THD *thd, Query_tables_l
@note this can be changed to use a hash, instead of scanning the linked
list, if the performance of this function will ever become an issue
*/
- static bool table_already_fk_prelocked(TABLE_LIST *tl, LEX_STRING *db,
- LEX_STRING *table, thr_lock_type lock_type)
++
+ bool table_already_fk_prelocked(TABLE_LIST *tl, LEX_STRING *db,
+ LEX_STRING *table, thr_lock_type lock_type)
{
for (; tl; tl= tl->next_global )
{
diff --cc sql/sql_base.h
index 4f99111cbd9,94294e3aa43..37cc9e8e8f1
--- a/sql/sql_base.h
+++ b/sql/sql_base.h
@@@ -138,8 -145,11 +139,10 @@@ thr_lock_type read_lock_type_for_table(
bool routine_modifies_data);
my_bool mysql_rm_tmp_tables(void);
-bool rm_temporary_table(handlerton *base, const char *path);
void close_tables_for_reopen(THD *thd, TABLE_LIST **tables,
const MDL_savepoint &start_of_statement_svp);
+ bool table_already_fk_prelocked(TABLE_LIST *tl, LEX_STRING *db,
+ LEX_STRING *table, thr_lock_type lock_type);
TABLE_LIST *find_table_in_list(TABLE_LIST *table,
TABLE_LIST *TABLE_LIST::*link,
const char *db_name,
@@@ -295,8 -332,11 +298,9 @@@ bool tdc_open_view(THD *thd, TABLE_LIS
TABLE *find_table_for_mdl_upgrade(THD *thd, const char *db,
const char *table_name,
- bool no_error);
+ int *p_error);
+ void mark_tmp_table_for_reuse(TABLE *table);
-int update_virtual_fields(THD *thd, TABLE *table,
- enum enum_vcol_update_mode vcol_update_mode= VCOL_UPDATE_FOR_READ);
int dynamic_column_error_message(enum_dyncol_func_result rc);
/* open_and_lock_tables with optional derived handling */
diff --cc sql/sql_parse.cc
index dd16200539d,add059340c9..3231c4b730f
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@@ -7797,9 -7262,10 +7797,11 @@@ static void wsrep_mysql_parse(THD *thd
"WAIT_FOR wsrep_retry_autocommit_continue";
DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act)));
});
+ WSREP_DEBUG("Retry autocommit query: %s", thd->query());
}
+
- mysql_parse(thd, rawbuf, length, parser_state);
+ mysql_parse(thd, rawbuf, length, parser_state, is_com_multi,
+ is_next_command);
if (WSREP(thd)) {
/* wsrep BF abort in query exec phase */
diff --cc sql/sql_table.cc
index dbcab9bb870,da65f168d84..4aed06e3590
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@@ -3371,75 -3464,6 +3371,79 @@@ mysql_prepare_create_table(THD *thd, HA
if (prepare_blob_field(thd, sql_field))
DBUG_RETURN(TRUE);
+ /*
+ Convert the default value from client character
+ set into the column character set if necessary.
+ We can only do this for constants as we have not yet run fix_fields.
+ */
+ if (sql_field->default_value &&
+ sql_field->default_value->expr->basic_const_item() &&
+ (!sql_field->field ||
+ sql_field->field->default_value != sql_field->default_value) &&
+ save_cs != sql_field->default_value->expr->collation.collation &&
+ (sql_field->sql_type == MYSQL_TYPE_VAR_STRING ||
+ sql_field->sql_type == MYSQL_TYPE_STRING ||
+ sql_field->sql_type == MYSQL_TYPE_SET ||
+ sql_field->sql_type == MYSQL_TYPE_TINY_BLOB ||
+ sql_field->sql_type == MYSQL_TYPE_MEDIUM_BLOB ||
+ sql_field->sql_type == MYSQL_TYPE_LONG_BLOB ||
+ sql_field->sql_type == MYSQL_TYPE_BLOB ||
+ sql_field->sql_type == MYSQL_TYPE_ENUM))
+ {
+ Item *item;
+ if (!(item= sql_field->default_value->expr->
+ safe_charset_converter(thd, save_cs)))
+ {
+ /* Could not convert */
+ my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
+ DBUG_RETURN(TRUE);
+ }
+ /* Fix for prepare statement */
+ thd->change_item_tree(&sql_field->default_value->expr, item);
+ }
+
++ /* Virtual fields are always NULL */
++ if (sql_field->vcol_info)
++ sql_field->flags&= ~NOT_NULL_FLAG;
++
+ if (sql_field->default_value &&
+ sql_field->default_value->expr->basic_const_item() &&
+ (sql_field->sql_type == MYSQL_TYPE_SET ||
+ sql_field->sql_type == MYSQL_TYPE_ENUM))
+ {
+ StringBuffer<MAX_FIELD_WIDTH> str;
+ String *def= sql_field->default_value->expr->val_str(&str);
+ bool not_found;
+ if (def == NULL) /* SQL "NULL" maps to NULL */
+ {
+ not_found= sql_field->flags & NOT_NULL_FLAG;
+ }
+ else
+ {
+ not_found= false;
+ if (sql_field->sql_type == MYSQL_TYPE_SET)
+ {
+ char *not_used;
+ uint not_used2;
+ find_set(sql_field->interval, def->ptr(), def->length(),
+ sql_field->charset, ¬_used, ¬_used2, ¬_found);
+ }
+ else /* MYSQL_TYPE_ENUM */
+ {
+ def->length(sql_field->charset->cset->lengthsp(sql_field->charset,
+ def->ptr(), def->length()));
+ not_found= !find_type2(sql_field->interval, def->ptr(),
+ def->length(), sql_field->charset);
+ }
+ }
+
+ if (not_found)
+ {
+ my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
+ DBUG_RETURN(TRUE);
+ }
+ }
+
if (!(sql_field->flags & NOT_NULL_FLAG))
null_fields++;
@@@ -9477,27 -9132,73 +9481,79 @@@ bool mysql_alter_table(THD *thd,char *n
tbl.init_one_table(alter_ctx.new_db, strlen(alter_ctx.new_db),
alter_ctx.tmp_name, strlen(alter_ctx.tmp_name),
alter_ctx.tmp_name, TL_READ_NO_INSERT);
- /* Table is in thd->temporary_tables */
- if (open_temporary_table(thd, &tbl))
+ /*
+ Table can be found in the list of open tables in THD::all_temp_tables
+ list.
+ */
- tbl.table= thd->find_temporary_table(&tbl);
++ if ((tbl.table= thd->find_temporary_table(&tbl)) == NULL)
+ goto err_new_table_cleanup;
new_table= tbl.table;
+ DBUG_ASSERT(new_table);
}
else
{
- /* table is a normal table: Create temporary table in same directory */
- /* Open our intermediate table. */
- new_table= open_table_uncached(thd, new_db_type, &frm,
- alter_ctx.get_tmp_path(),
- alter_ctx.new_db, alter_ctx.tmp_name,
- true, true);
+ /*
+ table is a normal table: Create temporary table in same directory.
+ Open our intermediate table.
+ */
+ new_table=
+ thd->create_and_open_tmp_table(new_db_type, &frm,
+ alter_ctx.get_tmp_path(),
+ alter_ctx.new_db, alter_ctx.tmp_name,
+ true);
+ if (!new_table)
+ goto err_new_table_cleanup;
+
+ /*
+ Normally, an attempt to modify an FK parent table will cause
+ FK children to be prelocked, so the table-being-altered cannot
+ be modified by a cascade FK action, because ALTER holds a lock
+ and prelocking will wait.
+
+ But if a new FK is being added by this very ALTER, then the target
+ table is not locked yet (it's a temporary table). So, we have to
+ lock FK parents explicitly.
+ */
+ if (alter_info->flags & Alter_info::ADD_FOREIGN_KEY)
+ {
+ List <FOREIGN_KEY_INFO> fk_list;
+ List_iterator<FOREIGN_KEY_INFO> fk_list_it(fk_list);
+ FOREIGN_KEY_INFO *fk;
+
+ /* tables_opened can be > 1 only for MERGE tables */
+ DBUG_ASSERT(tables_opened == 1);
+ DBUG_ASSERT(&table_list->next_global == thd->lex->query_tables_last);
+
+ new_table->file->get_foreign_key_list(thd, &fk_list);
+ while ((fk= fk_list_it++))
+ {
+ if (lower_case_table_names)
+ {
+ char buf[NAME_LEN];
+ uint len;
+ strmake_buf(buf, fk->referenced_db->str);
+ len = my_casedn_str(files_charset_info, buf);
+ thd->make_lex_string(fk->referenced_db, buf, len);
+ strmake_buf(buf, fk->referenced_table->str);
+ len = my_casedn_str(files_charset_info, buf);
+ thd->make_lex_string(fk->referenced_table, buf, len);
+ }
+ if (table_already_fk_prelocked(table_list, fk->referenced_db,
+ fk->referenced_table, TL_READ_NO_INSERT))
+ continue;
+
+ TABLE_LIST *tl= (TABLE_LIST *) thd->alloc(sizeof(TABLE_LIST));
+ tl->init_one_table_for_prelocking(fk->referenced_db->str, fk->referenced_db->length,
+ fk->referenced_table->str, fk->referenced_table->length,
+ NULL, TL_READ_NO_INSERT, false, NULL, 0,
+ &thd->lex->query_tables_last);
+ }
+
+ if (open_tables(thd, &table_list->next_global, &tables_opened, 0,
+ &alter_prelocking_strategy))
+ goto err_new_table_cleanup;
+ }
}
- if (!new_table)
- goto err_new_table_cleanup;
/*
Note: In case of MERGE table, we do not attach children. We do not
copy data for MERGE tables. Only the children have data.
diff --cc sql/table.h
index c0cca1026ea,ca32234579f..fc3102fc9a5
--- a/sql/table.h
+++ b/sql/table.h
@@@ -1507,14 -1517,15 +1507,15 @@@ typedef struct st_foreign_key_inf
} FOREIGN_KEY_INFO;
LEX_CSTRING *fk_option_name(enum_fk_option opt);
+ bool fk_modifies_child(enum_fk_option opt);
-#define MY_I_S_MAYBE_NULL 1
-#define MY_I_S_UNSIGNED 2
+#define MY_I_S_MAYBE_NULL 1U
+#define MY_I_S_UNSIGNED 2U
-#define SKIP_OPEN_TABLE 0 // do not open table
-#define OPEN_FRM_ONLY 1 // open FRM file only
-#define OPEN_FULL_TABLE 2 // open FRM,MYD, MYI files
+#define SKIP_OPEN_TABLE 0U // do not open table
+#define OPEN_FRM_ONLY 1U // open FRM file only
+#define OPEN_FULL_TABLE 2U // open FRM,MYD, MYI files
typedef struct st_field_info
{
@@@ -1792,6 -1808,6 +1798,7 @@@ struct TABLE_LIS
*last_ptr= &next_global;
}
++
/*
List of tables local to a subquery (used by SQL_I_List). Considers
views as leaves (unlike 'next_leaf' below). Created at parse time
@@@ -2399,9 -2400,17 +2406,19 @@@
return false;
}
void set_lock_type(THD* thd, enum thr_lock_type lock);
+ void check_pushable_cond_for_table(Item *cond);
+ Item *build_pushable_cond_for_table(THD *thd, Item *cond);
+ void remove_join_columns()
+ {
+ if (join_columns)
+ {
+ join_columns->empty();
+ join_columns= NULL;
+ is_join_columns_complete= FALSE;
+ }
+ }
+
private:
bool prep_check_option(THD *thd, uint8 check_opt_type);
bool prep_where(THD *thd, Item **conds, bool no_where_clause);
diff --cc sql/wsrep_mysqld.cc
index 326b5928366,1b2d7fe04e6..815804366bc
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@@ -1395,6 -1408,67 +1435,67 @@@ create_view_query(THD *thd, uchar** buf
return wsrep_to_buf_helper(thd, buff.ptr(), buff.length(), buf, buf_len);
}
+ /*
+ Rewrite DROP TABLE for TOI. Temporary tables are eliminated from
+ the query as they are visible only to client connection.
+
+ TODO: See comments for sql_base.cc:drop_temporary_table() and refine
+ the function to deal with transactional locked tables.
+ */
+ static int wsrep_drop_table_query(THD* thd, uchar** buf, size_t* buf_len)
+ {
+
+ LEX* lex= thd->lex;
+ SELECT_LEX* select_lex= &lex->select_lex;
+ TABLE_LIST* first_table= select_lex->table_list.first;
+ String buff;
+
+ DBUG_ASSERT(!lex->create_info.tmp_table());
+
+ bool found_temp_table= false;
+ for (TABLE_LIST* table= first_table; table; table= table->next_global)
+ {
- if (find_temporary_table(thd, table->db, table->table_name))
++ if (thd->find_temporary_table(table->db, table->table_name))
+ {
+ found_temp_table= true;
+ break;
+ }
+ }
+
+ if (found_temp_table)
+ {
+ buff.append("DROP TABLE ");
+ if (lex->check_exists)
+ buff.append("IF EXISTS ");
+
+ for (TABLE_LIST* table= first_table; table; table= table->next_global)
+ {
- if (!find_temporary_table(thd, table->db, table->table_name))
++ if (!thd->find_temporary_table(table->db, table->table_name))
+ {
+ append_identifier(thd, &buff, table->db, strlen(table->db));
+ buff.append(".");
+ append_identifier(thd, &buff, table->table_name,
+ strlen(table->table_name));
+ buff.append(",");
+ }
+ }
+
+ /* Chop the last comma */
+ buff.chop();
+ buff.append(" /* generated by wsrep */");
+
+ WSREP_DEBUG("Rewrote '%s' as '%s'", thd->query(), buff.ptr());
+
+ return wsrep_to_buf_helper(thd, buff.ptr(), buff.length(), buf, buf_len);
+ }
+ else
+ {
+ return wsrep_to_buf_helper(thd, thd->query(), thd->query_length(),
+ buf, buf_len);
+ }
+ }
+
+
/* Forward declarations. */
static int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len);
static int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len);
diff --cc storage/innobase/btr/btr0scrub.cc
index 376a106bf8a,2e667e64d0b..578f9438eb8
--- a/storage/innobase/btr/btr0scrub.cc
+++ b/storage/innobase/btr/btr0scrub.cc
@@@ -144,13 -143,12 +144,13 @@@ btr_scrub_lock_dict_func(ulint space_id
os_thread_sleep(250000);
time_t now = time(0);
+
if (now >= last + 30) {
fprintf(stderr,
- "WARNING: %s:%u waited %ld seconds for"
+ "WARNING: %s:%u waited " TIMETPF " seconds for"
- " dict_sys lock, space: %lu"
+ " dict_sys lock, space: " ULINTPF
" lock_to_close_table: %d\n",
- file, line, now - start, space_id,
+ file, line, long(now - start), space_id,
lock_to_close_table);
last = now;
diff --cc storage/innobase/handler/ha_innodb.cc
index b363b4ff52e,084272124b7..4bed93b3a9e
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@@ -14963,9 -14427,9 +14963,9 @@@ get_foreign_key_info
/* Referenced (parent) table name */
ptr = dict_remove_db_name(foreign->referenced_table_name);
- len = filename_to_tablename(ptr, name_buff, sizeof(name_buff));
+ len = filename_to_tablename(ptr, name_buff, sizeof(name_buff), 1);
f_key_info.referenced_table = thd_make_lex_string(
- thd, 0, name_buff, static_cast<unsigned int>(len), 1);
+ thd, 0, name_buff, len, 1);
/* Dependent (child) database name */
len = dict_get_db_name_len(foreign->foreign_table_name);
@@@ -14979,9 -14443,9 +14979,9 @@@
/* Dependent (child) table name */
ptr = dict_remove_db_name(foreign->foreign_table_name);
- len = filename_to_tablename(ptr, name_buff, sizeof(name_buff));
+ len = filename_to_tablename(ptr, name_buff, sizeof(name_buff), 1);
f_key_info.foreign_table = thd_make_lex_string(
- thd, 0, name_buff, static_cast<unsigned int>(len), 1);
+ thd, 0, name_buff, len, 1);
do {
ptr = foreign->foreign_col_names[i];
diff --cc storage/innobase/include/univ.i
index 10eb83289da,e4503672375..9864832cac5
--- a/storage/innobase/include/univ.i
+++ b/storage/innobase/include/univ.i
@@@ -75,51 -79,65 +75,50 @@@ the virtual method table (vtable) in GC
# define ha_innobase ha_innodb
#endif /* MYSQL_DYNAMIC_PLUGIN */
-#if (defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)) && !defined(MYSQL_SERVER) && !defined(__WIN__)
-# undef __WIN__
-# define __WIN__
-
+#if defined(_WIN32)
# include <windows.h>
+#endif /* _WIN32 */
-# ifdef _NT_
-# define __NT__
-# endif
+/* Include a minimum number of SQL header files so that few changes
+made in SQL code cause a complete InnoDB rebuild. These headers are
+used throughout InnoDB but do not include too much themselves. They
+support cross-platform development and expose comonly used SQL names. */
-#else
-/* The defines used with MySQL */
+#include <my_global.h>
-/* Include two header files from MySQL to make the Unix flavor used
-in compiling more Posix-compatible. These headers also define __WIN__
-if we are compiling on Windows. */
+/* JAN: TODO: missing 5.7 header */
+#ifdef HAVE_MY_THREAD_H
+//# include <my_thread.h>
+#endif
-#ifndef UNIV_HOTBACKUP
-# include <my_global.h>
-# include <my_pthread.h>
-#endif /* UNIV_HOTBACKUP */
+#ifndef UNIV_INNOCHECKSUM
+# include <m_string.h>
+# include <mysqld_error.h>
+#endif /* !UNIV_INNOCHECKSUM */
/* Include <sys/stat.h> to get S_I... macros defined for os0file.cc */
-# include <sys/stat.h>
-# if !defined(__WIN__)
-# include <sys/mman.h> /* mmap() for os0proc.cc */
-# endif
-
-/* Include the header file generated by GNU autoconf */
-# ifndef __WIN__
-# ifndef UNIV_HOTBACKUP
-# include "my_config.h"
-# endif /* UNIV_HOTBACKUP */
-# endif
+#include <sys/stat.h>
-# ifdef HAVE_SCHED_H
-# include <sched.h>
-# endif
-
-/* We only try to do explicit inlining of functions with gcc and
-Sun Studio */
-
-# ifdef HAVE_PREAD
-# define HAVE_PWRITE
-# endif
-
-#endif /* #if (defined(WIN32) || ... */
+#ifndef _WIN32
+# include <sys/mman.h> /* mmap() for os0proc.cc */
+# include <sched.h>
+# include "my_config.h"
+#endif
-#ifndef __WIN__
+#include <stdint.h>
- #define __STDC_FORMAT_MACROS /* Enable C99 printf format macros */
#include <inttypes.h>
-#endif /* !__WIN__ */
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include "my_pthread.h"
/* Following defines are to enable performance schema
-instrumentation in each of four InnoDB modules if
+instrumentation in each of five InnoDB modules if
HAVE_PSI_INTERFACE is defined. */
-#if defined HAVE_PSI_INTERFACE && !defined UNIV_HOTBACKUP
+#ifdef HAVE_PSI_INTERFACE
# define UNIV_PFS_MUTEX
# define UNIV_PFS_RWLOCK
-
# define UNIV_PFS_IO
# define UNIV_PFS_THREAD
@@@ -452,23 -452,43 +451,25 @@@ typedef ssize_t lint
/* Use the integer types and formatting strings defined in Visual Studio. */
# define UINT32PF "%u"
# define INT64PF "%lld"
-# define UINT64PF "%llu"
+# define UINT64scan "llu"
+# define UINT64PFx "%016llx"
+#elif defined __APPLE__
+/* Apple prefers to call the 64-bit types 'long long'
+in both 32-bit and 64-bit environments. */
+# define UINT32PF "%" PRIu32
+# define INT64PF "%lld"
+# define UINT64scan "llu"
# define UINT64PFx "%016llx"
+ # define TIMETPF "%ld"
-typedef __int64 ib_int64_t;
-typedef unsigned __int64 ib_uint64_t;
-typedef unsigned __int32 ib_uint32_t;
#else
/* Use the integer types and formatting strings defined in the C99 standard. */
# define UINT32PF "%" PRIu32
# define INT64PF "%" PRId64
-# define UINT64PF "%" PRIu64
+# define UINT64scan PRIu64
# define UINT64PFx "%016" PRIx64
+ # define TIMETPF "%" PRIdFAST32
-typedef int64_t ib_int64_t;
-typedef uint64_t ib_uint64_t;
-typedef uint32_t ib_uint32_t;
#endif
-#define IB_ID_FMT UINT64PF
-
-/* Type used for all log sequence number storage and arithmetics */
-typedef ib_uint64_t lsn_t;
-
-#ifdef _WIN64
-typedef unsigned __int64 ulint;
-typedef __int64 lint;
-# define ULINTPF UINT64PF
-#else
-typedef unsigned long int ulint;
-typedef long int lint;
-# define ULINTPF "%lu"
-#endif /* _WIN64 */
-
-#ifndef UNIV_HOTBACKUP
-typedef unsigned long long int ullint;
-#endif /* UNIV_HOTBACKUP */
-
#ifdef UNIV_INNOCHECKSUM
extern bool strict_verify;
extern FILE* log_file;
diff --cc storage/tokudb/ha_tokudb.cc
index 91041ec6df4,61c7011252b..d5b4adcd745
--- a/storage/tokudb/ha_tokudb.cc
+++ b/storage/tokudb/ha_tokudb.cc
@@@ -5893,10 -5942,12 +5929,11 @@@ int ha_tokudb::rnd_pos(uchar * buf, uch
DBT* key = get_pos(&db_pos, pos);
unpack_entire_row = true;
- ha_statistic_increment(&SSV::ha_read_rnd_count);
tokudb_active_index = MAX_KEY;
- // test rpl slave by inducing a delay before the point query
THD *thd = ha_thd();
+ #if defined(TOKU_INCLUDE_RFR) && TOKU_INCLUDE_RFR
+ // test rpl slave by inducing a delay before the point query
if (thd->slave_thread && (in_rpl_delete_rows || in_rpl_update_rows)) {
DBUG_EXECUTE_IF("tokudb_crash_if_rpl_looks_up_row", DBUG_ASSERT(0););
uint64_t delay_ms = tokudb::sysvars::rpl_lookup_rows_delay(thd);
diff --cc storage/tokudb/ha_tokudb_alter_56.cc
index ba1afbf091a,b579d00f67b..46da873d750
--- a/storage/tokudb/ha_tokudb_alter_56.cc
+++ b/storage/tokudb/ha_tokudb_alter_56.cc
@@@ -446,16 -476,13 +476,13 @@@ enum_alter_inplace_result ha_tokudb::ch
setup_kc_info(altered_table, ctx->altered_table_kc_info) == 0) {
// change column length
- if (change_length_is_supported(
- table,
- altered_table,
- ha_alter_info, ctx)) {
+ if (change_length_is_supported(table, altered_table, ctx)) {
result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
}
- } else if ((ctx->handler_flags & Alter_inplace_info::ALTER_COLUMN_TYPE) &&
+ } else if ((ctx->handler_flags & Alter_inplace_info::ALTER_STORED_COLUMN_TYPE) &&
only_flags(
ctx->handler_flags,
- Alter_inplace_info::ALTER_COLUMN_TYPE +
+ Alter_inplace_info::ALTER_STORED_COLUMN_TYPE +
Alter_inplace_info::ALTER_COLUMN_DEFAULT) &&
table->s->fields == altered_table->s->fields &&
find_changed_fields(
@@@ -911,9 -929,10 +929,10 @@@ bool ha_tokudb::commit_inplace_alter_ta
ha_alter_info->group_commit_ctx = NULL;
}
#endif
+ #if defined(TOKU_INCLUDE_WRITE_FRM_DATA) && TOKU_INCLUDE_WRITE_FRM_DATA
#if (50500 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50599) || \
- (100000 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 100199)
+ (100000 <= MYSQL_VERSION_ID)
- #if WITH_PARTITION_STORAGE_ENGINE
+ #if defined(WITH_PARTITION_STORAGE_ENGINE) && WITH_PARTITION_STORAGE_ENGINE
if (TOKU_PARTITION_WRITE_FRM_DATA || altered_table->part_info == NULL) {
#else
if (true) {
@@@ -1578,22 -1548,11 +1548,11 @@@ static bool change_field_type_is_suppor
return false;
} else if (old_type == MYSQL_TYPE_VARCHAR) {
// varchar(X) -> varchar(Y) and varbinary(X) -> varbinary(Y) expansion
- // where X < 256 <= Y the ALTER_COLUMN_TYPE handler flag is set for
+ // where X < 256 <= Y the ALTER_STORED_COLUMN_TYPE handler flag is set for
// these cases
- return change_varchar_length_is_supported(
- old_field,
- new_field,
- table,
- altered_table,
- ha_alter_info,
- ctx);
+ return change_varchar_length_is_supported(old_field, new_field, ctx);
} else if (old_type == MYSQL_TYPE_BLOB && new_type == MYSQL_TYPE_BLOB) {
- return change_blob_length_is_supported(
- table,
- altered_table,
- old_field,
- new_field,
- ctx);
+ return change_blob_length_is_supported(old_field, new_field, ctx);
} else
return false;
}
diff --cc storage/tokudb/hatoku_defines.h
index 2f058797993,ab9e0f79ef8..ced3254199f
--- a/storage/tokudb/hatoku_defines.h
+++ b/storage/tokudb/hatoku_defines.h
@@@ -69,8 -74,20 +74,20 @@@ Copyright (c) 2006, 2015, Percona and/o
#pragma interface /* gcc class implementation */
#endif
- #if 100000 <= MYSQL_VERSION_ID
+ // TOKU_INCLUDE_WRITE_FRM_DATA, TOKU_PARTITION_WRITE_FRM_DATA, and
+ // TOKU_INCLUDE_DISCOVER_FRM all work together as two opposing sides
+ // of the same functionality. The 'WRITE' includes functionality to
+ // write a copy of every tables .frm data into the tables status dictionary on
+ // CREATE or ALTER. When WRITE is in, the .frm data is also verified whenever a
+ // table is opened.
+ //
+ // The 'DISCOVER' then implements the MySQL table discovery API which reads
+ // this same data and returns it back to MySQL.
+ // In most cases, they should all be in or out without mixing. There may be
+ // extreme cases though where one side (WRITE) is supported but perhaps
+ // 'DISCOVERY' may not be, thus the need for individual indicators.
-#if 100000 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 100199
++#if 100000 <= MYSQL_VERSION_ID
// mariadb 10.0
#define TOKU_USE_DB_TYPE_TOKUDB 1
#define TOKU_INCLUDE_ALTER_56 1
diff --cc storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_delete_pk.result
index a85d2155725,48ea60013ad..2a44954d9a0
--- a/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_delete_pk.result
+++ b/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_delete_pk.result
@@@ -1,16 -1,8 +1,25 @@@
include/master-slave.inc
[connection master]
+connection master;
drop table if exists t;
+connection slave;
show variables like 'tokudb_rpl_%';
Variable_name Value
++<<<<<<< HEAD
+tokudb_rpl_check_readonly ON
+tokudb_rpl_lookup_rows OFF
+tokudb_rpl_lookup_rows_delay 10000
+tokudb_rpl_unique_checks OFF
+tokudb_rpl_unique_checks_delay 10000
+connection master;
++||||||| merged common ancestors
++tokudb_rpl_check_readonly ON
++tokudb_rpl_lookup_rows OFF
++tokudb_rpl_lookup_rows_delay 10000
++tokudb_rpl_unique_checks OFF
++tokudb_rpl_unique_checks_delay 10000
++=======
++>>>>>>> 10.1
create table t (a bigint not null, primary key(a)) engine=tokudb;
insert into t values (1);
insert into t values (2),(3);
diff --cc storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_update_pk_uc0_lookup0.result
index 991ad8d1c48,10375677c8d..970cd2ee38e
--- a/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_update_pk_uc0_lookup0.result
+++ b/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_update_pk_uc0_lookup0.result
@@@ -1,16 -1,8 +1,25 @@@
include/master-slave.inc
[connection master]
+connection master;
drop table if exists t;
+connection slave;
show variables like 'tokudb_rpl_%';
Variable_name Value
++<<<<<<< HEAD
+tokudb_rpl_check_readonly ON
+tokudb_rpl_lookup_rows OFF
+tokudb_rpl_lookup_rows_delay 10000
+tokudb_rpl_unique_checks OFF
+tokudb_rpl_unique_checks_delay 10000
+connection master;
++||||||| merged common ancestors
++tokudb_rpl_check_readonly ON
++tokudb_rpl_lookup_rows OFF
++tokudb_rpl_lookup_rows_delay 10000
++tokudb_rpl_unique_checks OFF
++tokudb_rpl_unique_checks_delay 10000
++=======
++>>>>>>> 10.1
create table t (a bigint not null, b bigint not null, primary key(a)) engine=tokudb;
insert into t values (1,0);
insert into t values (2,0),(3,0);
diff --cc storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_write_pk.result
index 1de619eb4ec,1cb047bbf62..c725c051a2b
--- a/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_write_pk.result
+++ b/storage/tokudb/mysql-test/rpl/r/rpl_parallel_tokudb_write_pk.result
@@@ -1,13 -1,8 +1,19 @@@
include/master-slave.inc
[connection master]
+connection master;
drop table if exists t;
+connection slave;
show variables like 'tokudb_rpl_unique_checks%';
Variable_name Value
++<<<<<<< HEAD
+tokudb_rpl_unique_checks OFF
+tokudb_rpl_unique_checks_delay 5000
+connection master;
++||||||| merged common ancestors
++tokudb_rpl_unique_checks OFF
++tokudb_rpl_unique_checks_delay 5000
++=======
++>>>>>>> 10.1
create table t (a bigint not null, primary key(a)) engine=tokudb;
insert into t values (1);
insert into t values (2),(3);
1
0
[Commits] 1372596f5e6: MDEV-16990:server crashes in base_list_iterator::next
by varunraiko1803@gmail.com 11 Sep '18
by varunraiko1803@gmail.com 11 Sep '18
11 Sep '18
revision-id: 1372596f5e6e8b12a709e5eeacac2a2d6acd4ff1 (mariadb-10.2.16-126-g1372596f5e6)
parent(s): 4d991abd4fc7f60e758ec46301b0dd2bee71245c
author: Varun Gupta
committer: Varun Gupta
timestamp: 2018-09-11 14:12:40 +0530
message:
MDEV-16990:server crashes in base_list_iterator::next
When we have a query which has implicit_grouping then we are sure that we would end up with only one
row so there is no point to do DISTINCT computation
---
mysql-test/r/win.result | 12 ++++++++++++
mysql-test/t/win.test | 10 ++++++++++
sql/sql_select.cc | 2 +-
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result
index e4b2d223a02..aef9b613433 100644
--- a/mysql-test/r/win.result
+++ b/mysql-test/r/win.result
@@ -3314,3 +3314,15 @@ COUNT(DISTINCT t2.a2) rank() OVER (ORDER BY t2.b1)
1 2
1 3
DROP TABLE t1,t2;
+#
+# MDEV-16990: server crashes in base_list_iterator::next
+#
+CREATE TABLE t1(i int);
+insert into t1 values (1),(2);
+SELECT DISTINCT row_number() OVER (), MAX(1) FROM t1;
+row_number() OVER () MAX(1)
+1 1
+SELECT DISTINCT BIT_AND(0) OVER (), MAX(1) FROM t1;
+BIT_AND(0) OVER () MAX(1)
+0 1
+drop table t1;
diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test
index f47237ee59e..1617e85caf4 100644
--- a/mysql-test/t/win.test
+++ b/mysql-test/t/win.test
@@ -2082,3 +2082,13 @@ SELECT COUNT(DISTINCT t2.a2),
rank() OVER (ORDER BY t2.b1)
FROM t2 ,t1 GROUP BY t2.b1 ORDER BY t1.a1;
DROP TABLE t1,t2;
+
+--echo #
+--echo # MDEV-16990: server crashes in base_list_iterator::next
+--echo #
+
+CREATE TABLE t1(i int);
+insert into t1 values (1),(2);
+SELECT DISTINCT row_number() OVER (), MAX(1) FROM t1;
+SELECT DISTINCT BIT_AND(0) OVER (), MAX(1) FROM t1;
+drop table t1;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 0124a782de0..efc13276424 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2731,7 +2731,7 @@ bool JOIN::make_aggr_tables_info()
remove_duplicates() assumes there is a preceding computation step (and
in the degenerate join, there's none)
*/
- if (top_join_tab_count)
+ if (top_join_tab_count && tables_list)
curr_tab->distinct= true;
having= NULL;
1
0
revision-id: c8bb43a9385cdb7a27f0702742a8d1e08a85befd (mariadb-10.2.16-128-gc8bb43a)
parent(s): 4d9ec7cb6c83c571115bde59d72f02b494764755
committer: Alexey Botchkov
timestamp: 2018-09-11 14:37:45 +0400
message:
MDEV-17121 JSON_ARRAY_APPEND.
Extra comma added to the result when an json array is empty.
---
include/json_lib.h | 6 ++++++
mysql-test/r/func_json.result | 6 ++++++
mysql-test/t/func_json.test | 7 +++++++
sql/item_jsonfunc.cc | 6 ++++--
strings/json_lib.c | 25 +++++++++++++++++++++++++
5 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/include/json_lib.h b/include/json_lib.h
index 567b04d..e9c1090 100644
--- a/include/json_lib.h
+++ b/include/json_lib.h
@@ -319,6 +319,12 @@ int json_skip_to_level(json_engine_t *j, int level);
json_skip_to_level((json_engine), (json_engine)->stack_p)
+/*
+ works as json_skip_level() but also counts items on the current
+ level skipped.
+*/
+int json_skip_level_and_count(json_engine_t *j, int *n_items_skipped);
+
#define json_skip_array_item json_skip_key
/*
diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result
index e8b2fac..9c7a106 100644
--- a/mysql-test/r/func_json.result
+++ b/mysql-test/r/func_json.result
@@ -790,3 +790,9 @@ JSON_SET('{}', '$.a', _utf8 0xC3B6, '$.b', _utf8 0xC3B6)
SELECT JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6');
JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6')
{"a": "�", "x": 1, "b": "�"}
+#
+# MDEV-17121 JSON_ARRAY_APPEND
+#
+select json_array_append('[ ]', '$', 'aue');
+json_array_append('[ ]', '$', 'aue')
+["aue"]
diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test
index fd5e3d7..e27128a 100644
--- a/mysql-test/t/func_json.test
+++ b/mysql-test/t/func_json.test
@@ -448,3 +448,10 @@ SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6);
SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6, '$.b', _utf8 0xC3B6);
SELECT JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6');
+
+--echo #
+--echo # MDEV-17121 JSON_ARRAY_APPEND
+--echo #
+
+select json_array_append('[ ]', '$', 'aue');
+
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc
index 4a83764..1da5393 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -1621,13 +1621,15 @@ String *Item_func_json_array_append::val_str(String *str)
if (je.value_type == JSON_VALUE_ARRAY)
{
- if (json_skip_level(&je))
+ int n_items;
+ if (json_skip_level_and_count(&je, &n_items))
goto js_error;
ar_end= je.s.c_str - je.sav_c_len;
str_rest_len= js->length() - (ar_end - (const uchar *) js->ptr());
str->q_append(js->ptr(), ar_end-(const uchar *) js->ptr());
- str->append(", ", 2);
+ if (n_items)
+ str->append(", ", 2);
if (append_json_value(str, args[n_arg+1], &tmp_val))
goto return_null; /* Out of memory. */
diff --git a/strings/json_lib.c b/strings/json_lib.c
index f6b4f15..1c0ff4b 100644
--- a/strings/json_lib.c
+++ b/strings/json_lib.c
@@ -1197,6 +1197,31 @@ int json_skip_to_level(json_engine_t *j, int level)
}
+#define json_skip_level(json_engine) \
+ json_skip_to_level((json_engine), (json_engine)->stack_p)
+
+
+/*
+ works as json_skip_level() but also counts items on the current
+ level skipped.
+*/
+int json_skip_level_and_count(json_engine_t *j, int *n_items_skipped)
+{
+ int level= j->stack_p;
+
+ *n_items_skipped= 0;
+ while (json_scan_next(j) == 0)
+ {
+ if (j->stack_p < level)
+ return 0;
+ if (j->stack_p == level && j->state == JST_VALUE)
+ (*n_items_skipped)++;
+ }
+
+ return 1;
+}
+
+
int json_skip_key(json_engine_t *j)
{
if (json_read_value(j))
1
0
[Commits] 89457121565: MDEV-13743: galera_toi_truncate may fail with: query 'reap' succeeded - should have failed with errno 1213
by jan 11 Sep '18
by jan 11 Sep '18
11 Sep '18
revision-id: 89457121565a8ea34d76590313bf57a2470995ef (mariadb-10.1.35-46-g89457121565)
parent(s): 21829bd743f487280dba918857259b9971a8afbf
author: Jan Lindström
committer: Jan Lindström
timestamp: 2018-09-11 11:21:29 +0300
message:
MDEV-13743: galera_toi_truncate may fail with: query 'reap' succeeded - should have failed with errno 1213
Replace sleep with wait condition and increase the size of the
insert.
---
mysql-test/suite/galera/r/galera_toi_truncate.result | 3 ++-
mysql-test/suite/galera/t/galera_toi_truncate.test | 13 ++++++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/mysql-test/suite/galera/r/galera_toi_truncate.result b/mysql-test/suite/galera/r/galera_toi_truncate.result
index f52316f3cbc..65889dd858a 100644
--- a/mysql-test/suite/galera/r/galera_toi_truncate.result
+++ b/mysql-test/suite/galera/r/galera_toi_truncate.result
@@ -2,7 +2,8 @@ CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
SET SESSION wsrep_retry_autocommit = 0;
-INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;;
+INSERT INTO t1(f1) SELECT 1 FROM ten as a1, ten AS a2;
+INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6, ten AS a7;;
TRUNCATE TABLE t1;;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
SELECT COUNT(*) = 0 FROM t1;
diff --git a/mysql-test/suite/galera/t/galera_toi_truncate.test b/mysql-test/suite/galera/t/galera_toi_truncate.test
index 59ef5c2028f..7a7e9255a8a 100644
--- a/mysql-test/suite/galera/t/galera_toi_truncate.test
+++ b/mysql-test/suite/galera/t/galera_toi_truncate.test
@@ -16,14 +16,21 @@ INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
-# Insert 100K rows
+# Insert 1m rows
--connection node_2
+--let $wait_condition = SELECT COUNT(*) = 10 FROM ten;
+--source include/wait_condition.inc
+
# Prevent autocommit retring from masking the deadlock error we expect to get
SET SESSION wsrep_retry_autocommit = 0;
---send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;
+INSERT INTO t1(f1) SELECT 1 FROM ten as a1, ten AS a2;
+--send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6, ten AS a7;
--connection node_1
---sleep 1
+# Wait for a above insert to start
+--let $wait_condition = SELECT COUNT(*) >= 100 from t1;
+--source include/wait_condition.inc
+
--send TRUNCATE TABLE t1;
--connection node_1
1
0
[Commits] 5b6dd6d: MDEV-15890 Strange error message if you try to FLUSH TABLES <view> after LOCK TABLES <view>.
by holyfoot@askmonty.org 11 Sep '18
by holyfoot@askmonty.org 11 Sep '18
11 Sep '18
revision-id: 5b6dd6d305f8828c513ef48725ed01b4407e9e12 (mariadb-10.1.35-42-g5b6dd6d)
parent(s): f01c4a10d74397220d7b7ffb724e6f52d3ab42a5
committer: Alexey Botchkov
timestamp: 2018-09-11 10:38:46 +0400
message:
MDEV-15890 Strange error message if you try to FLUSH TABLES <view> after LOCK TABLES <view>.
LOCK view WRITE shouldn't block FLUSH view.
So we set the view's mdl_request type to it's tables.
---
mysql-test/r/flush.result | 1 -
mysql-test/r/lock.result | 4 ++--
mysql-test/r/lock_multi.result | 9 ++++-----
mysql-test/r/lock_sync.result | 6 +-----
.../sys_vars/r/delayed_insert_limit_func.result | 4 ++--
.../sys_vars/r/sql_low_priority_updates_func.result | 4 ++--
.../suite/sys_vars/t/delayed_insert_limit_func.test | 20 ++++++--------------
.../sys_vars/t/sql_low_priority_updates_func.test | 4 ++--
mysql-test/t/flush.test | 1 -
mysql-test/t/lock.test | 4 ++--
mysql-test/t/lock_multi.test | 14 +++++++++-----
mysql-test/t/lock_sync.test | 8 ++------
sql/sql_view.cc | 3 +--
13 files changed, 33 insertions(+), 49 deletions(-)
diff --git a/mysql-test/r/flush.result b/mysql-test/r/flush.result
index 2d7b81b..4e4aec4 100644
--- a/mysql-test/r/flush.result
+++ b/mysql-test/r/flush.result
@@ -508,7 +508,6 @@ ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
UNLOCK TABLES;
LOCK TABLES v1 WRITE;
FLUSH TABLES v1;
-ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
UNLOCK TABLES;
LOCK TABLES v1 READ;
FLUSH TABLES t1;
diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result
index 0dcc0de..b6f19d1 100644
--- a/mysql-test/r/lock.result
+++ b/mysql-test/r/lock.result
@@ -136,7 +136,7 @@ select * from t1;
ERROR HY000: Table 't1' was not locked with LOCK TABLES
unlock tables;
create or replace view v_bug5719 as select * from t1;
-lock tables v_bug5719 write;
+lock tables v_bug5719 read;
select * from v_bug5719;
a
@@ -299,7 +299,7 @@ create table t2 (j int);
#
# Try to perform DDL on table which is locked through view.
create view v1 as select * from t2;
-lock tables t1 write, v1 write;
+lock tables t1 write, v1 read;
flush table t2;
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
drop table t2;
diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result
index 12960a4..4df415b 100644
--- a/mysql-test/r/lock_multi.result
+++ b/mysql-test/r/lock_multi.result
@@ -276,15 +276,14 @@ DROP VIEW IF EXISTS v1;
#
# Test 1: LOCK TABLES v1 WRITE, t1 READ;
#
-# Thanks to the fact that we no longer allow DDL on tables
-# which are locked for write implicitly, the exact scenario
-# in which assert was failing is no longer repeatable.
CREATE TABLE t1 ( f1 integer );
CREATE VIEW v1 AS SELECT f1 FROM t1 ;
+# Connection 2
LOCK TABLES v1 WRITE, t1 READ;
FLUSH TABLE t1;
-ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
-UNLOCK TABLES;
+# Connection 1
+LOCK TABLES t1 WRITE;
+FLUSH TABLE t1;
DROP TABLE t1;
DROP VIEW v1;
#
diff --git a/mysql-test/r/lock_sync.result b/mysql-test/r/lock_sync.result
index 219cc08..8143f3f 100644
--- a/mysql-test/r/lock_sync.result
+++ b/mysql-test/r/lock_sync.result
@@ -648,9 +648,6 @@ set debug_sync= 'RESET';
set @old_general_log = @@global.general_log;
set @@global.general_log= OFF;
create table t1 (i int) engine=InnoDB;
-# We have to use view in order to make LOCK TABLES avoid
-# acquiring SNRW metadata lock on table.
-create view v1 as select * from t1;
insert into t1 values (1);
# Prepare user lock which will be used for resuming execution of
# the first statement after it acquires TL_WRITE_ALLOW_WRITE lock.
@@ -673,7 +670,7 @@ select count(*) > 0 from t1 as a, t1 as b for update;;
# acquiring lock for the the first instance of 't1'.
set debug_sync= 'now WAIT_FOR parked';
# Send LOCK TABLE statement which will try to get TL_WRITE lock on 't1':
-lock table v1 write;;
+lock table t1 write concurrent;;
# Switch to connection 'default'.
# Wait until this LOCK TABLES statement starts waiting for table lock.
# Allow SELECT ... FOR UPDATE to resume.
@@ -703,7 +700,6 @@ unlock tables;
# Do clean-up.
set debug_sync= 'RESET';
set @@global.general_log= @old_general_log;
-drop view v1;
drop table t1;
#
# Bug#50821 Deadlock between LOCK TABLES and ALTER TABLE
diff --git a/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result b/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result
index eeb7a28..6076d02 100644
--- a/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result
+++ b/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result
@@ -13,7 +13,7 @@ INSERT INTO t1 VALUES('3','1','1');
INSERT INTO t1 VALUES('4','1','1');
INSERT INTO t1 VALUES('5','1','1');
INSERT INTO t1 VALUES('6','1','1');
-LOCK TABLE v1 WRITE;
+LOCK TABLE v1 READ;
** Connection con1 **
INSERT DELAYED INTO t1 VALUES('7','1','1');
INSERT DELAYED INTO t1 VALUES('8','1','1');
@@ -82,7 +82,7 @@ INSERT INTO t1 VALUES('3');
INSERT INTO t1 VALUES('4');
INSERT INTO t1 VALUES('5');
INSERT INTO t1 VALUES('6');
-LOCK TABLE v1 WRITE;
+LOCK TABLE v1 READ;
** Connection con1 **
Asynchronous execute
INSERT DELAYED INTO t1 VALUES('7');
diff --git a/mysql-test/suite/sys_vars/r/sql_low_priority_updates_func.result b/mysql-test/suite/sys_vars/r/sql_low_priority_updates_func.result
index fe76c2c..e9758e2 100644
--- a/mysql-test/suite/sys_vars/r/sql_low_priority_updates_func.result
+++ b/mysql-test/suite/sys_vars/r/sql_low_priority_updates_func.result
@@ -20,7 +20,7 @@ INSERT INTO t1 VALUES('3');
INSERT INTO t1 VALUES('4');
INSERT INTO t1 VALUES('5');
INSERT INTO t1 VALUES('6');
-LOCK TABLE v1 WRITE;
+LOCK TABLE v1 WRITE CONCURRENT;
** Connection con1 **
** Asynchronous Execution **
UPDATE t1 SET a = CONCAT(a,"-updated");|
@@ -56,7 +56,7 @@ INSERT INTO t1 VALUES('3');
INSERT INTO t1 VALUES('4');
INSERT INTO t1 VALUES('5');
INSERT INTO t1 VALUES('6');
-LOCK TABLE v1 WRITE;
+LOCK TABLE v1 READ;
** Connection con1 **
** Asynchronous Execution **
UPDATE t1 SET a = CONCAT(a,"-updated");|
diff --git a/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test b/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test
index 427f273..e83c48b 100644
--- a/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test
+++ b/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test
@@ -61,7 +61,7 @@ INSERT INTO t1 VALUES('4','1','1');
INSERT INTO t1 VALUES('5','1','1');
INSERT INTO t1 VALUES('6','1','1');
-LOCK TABLE v1 WRITE;
+LOCK TABLE v1 READ;
--echo ** Connection con1 **
connection con1;
@@ -110,9 +110,8 @@ delimiter ;|
--echo ** Connection con0 **
connection con0;
let $wait_condition=
- SELECT variable_value > @@global.delayed_insert_limit
- FROM information_schema.global_status
- WHERE variable_name like 'Not_flushed_delayed_rows';
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = 'Waiting for table level lock' AND user='delayed';
--source include/wait_condition.inc
let $my_select= SELECT COUNT(*) FROM t1;
send;
@@ -137,13 +136,6 @@ connection con0;
--echo Asynchronous "reap" result
--echo The next result suffers from
--echo '# Bug#35386 insert delayed inserts 1 + limit rows instead of just limit rows'
-#
-# on UNLOCK TABLES both SELECT in the con0 and delayed insert thread in the
-# con1 were awaken. There's no FIFO for TL_WRITE_DELAYED and TL_READ,
-# so either the first delayed_insert_limit rows will be inserted
-# before select (which will see 21 row) or select will go first (and see 6 rows)
-#
---replace_result 6 21
reap;
--echo ** Connection default **
@@ -173,7 +165,7 @@ INSERT INTO t1 VALUES('4');
INSERT INTO t1 VALUES('5');
INSERT INTO t1 VALUES('6');
-LOCK TABLE v1 WRITE;
+LOCK TABLE v1 READ;
--echo ** Connection con1 **
connection con1;
@@ -204,8 +196,8 @@ delimiter ;|
--echo ** Connection con0 **
connection con0;
let $wait_condition=
- SELECT variable_value > 0 FROM information_schema.global_status
- WHERE variable_name like 'Not_flushed_delayed_rows';
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = 'Waiting for table level lock' AND user='delayed';
--source include/wait_condition.inc
--echo Asynchronous execute
# Due to performance and server behaveiour the test observes values between 6 and 22.
diff --git a/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test b/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test
index ba13558..5d7d6cb 100644
--- a/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test
+++ b/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test
@@ -70,7 +70,7 @@ INSERT INTO t1 VALUES('4');
INSERT INTO t1 VALUES('5');
INSERT INTO t1 VALUES('6');
-LOCK TABLE v1 WRITE;
+LOCK TABLE v1 WRITE CONCURRENT;
--echo ** Connection con1 **
connection con1;
@@ -144,7 +144,7 @@ INSERT INTO t1 VALUES('4');
INSERT INTO t1 VALUES('5');
INSERT INTO t1 VALUES('6');
-LOCK TABLE v1 WRITE;
+LOCK TABLE v1 READ;
--echo ** Connection con1 **
connection con1;
diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test
index 7736574..11a1ac2 100644
--- a/mysql-test/t/flush.test
+++ b/mysql-test/t/flush.test
@@ -724,7 +724,6 @@ FLUSH TABLES v1;
UNLOCK TABLES;
LOCK TABLES v1 WRITE;
---error ER_TABLE_NOT_LOCKED_FOR_WRITE
FLUSH TABLES v1;
UNLOCK TABLES;
diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test
index 6cfaf9f..734fcd8 100644
--- a/mysql-test/t/lock.test
+++ b/mysql-test/t/lock.test
@@ -192,7 +192,7 @@ drop view v_bug5719;
select * from t1;
unlock tables;
create or replace view v_bug5719 as select * from t1;
-lock tables v_bug5719 write;
+lock tables v_bug5719 read;
select * from v_bug5719;
--echo
--echo Allowed to use an underlying table under LOCK TABLES <view>
@@ -370,7 +370,7 @@ create table t2 (j int);
--echo #
--echo # Try to perform DDL on table which is locked through view.
create view v1 as select * from t2;
-lock tables t1 write, v1 write;
+lock tables t1 write, v1 read;
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
flush table t2;
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test
index efd0fe5..ee73c2e 100644
--- a/mysql-test/t/lock_multi.test
+++ b/mysql-test/t/lock_multi.test
@@ -771,17 +771,21 @@ DROP VIEW IF EXISTS v1;
--echo #
--echo # Test 1: LOCK TABLES v1 WRITE, t1 READ;
--echo #
---echo # Thanks to the fact that we no longer allow DDL on tables
---echo # which are locked for write implicitly, the exact scenario
---echo # in which assert was failing is no longer repeatable.
CREATE TABLE t1 ( f1 integer );
CREATE VIEW v1 AS SELECT f1 FROM t1 ;
+--echo # Connection 2
+connect (con2,localhost,root);
LOCK TABLES v1 WRITE, t1 READ;
---error ER_TABLE_NOT_LOCKED_FOR_WRITE
FLUSH TABLE t1;
-UNLOCK TABLES;
+disconnect con2;
+--source include/wait_until_disconnected.inc
+
+--echo # Connection 1
+connection default;
+LOCK TABLES t1 WRITE;
+FLUSH TABLE t1; # Assertion happened here
# Cleanup
DROP TABLE t1;
diff --git a/mysql-test/t/lock_sync.test b/mysql-test/t/lock_sync.test
index ef79cc2..0e0aa8f 100644
--- a/mysql-test/t/lock_sync.test
+++ b/mysql-test/t/lock_sync.test
@@ -909,9 +909,6 @@ set @old_general_log = @@global.general_log;
set @@global.general_log= OFF;
create table t1 (i int) engine=InnoDB;
---echo # We have to use view in order to make LOCK TABLES avoid
---echo # acquiring SNRW metadata lock on table.
-create view v1 as select * from t1;
insert into t1 values (1);
--echo # Prepare user lock which will be used for resuming execution of
--echo # the first statement after it acquires TL_WRITE_ALLOW_WRITE lock.
@@ -942,14 +939,14 @@ connection con_bug45143_3;
--echo # acquiring lock for the the first instance of 't1'.
set debug_sync= 'now WAIT_FOR parked';
--echo # Send LOCK TABLE statement which will try to get TL_WRITE lock on 't1':
---send lock table v1 write;
+--send lock table t1 write concurrent;
--echo # Switch to connection 'default'.
connection default;
--echo # Wait until this LOCK TABLES statement starts waiting for table lock.
let $wait_condition= select count(*)= 1 from information_schema.processlist
where state= 'Waiting for table level lock' and
- info='lock table v1 write';
+ info='lock table t1 write concurrent';
--source include/wait_condition.inc
--echo # Allow SELECT ... FOR UPDATE to resume.
--echo # Since it already has TL_WRITE_ALLOW_WRITE lock on the first instance
@@ -993,7 +990,6 @@ disconnect con_bug45143_2;
disconnect con_bug45143_3;
set debug_sync= 'RESET';
set @@global.general_log= @old_general_log;
-drop view v1;
drop table t1;
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 6bd6b6a..d7a2a6b 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -1534,8 +1534,7 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table,
for (tbl= view_main_select_tables; tbl; tbl= tbl->next_local)
{
tbl->lock_type= table->lock_type;
- tbl->mdl_request.set_type((tbl->lock_type >= TL_WRITE_ALLOW_WRITE) ?
- MDL_SHARED_WRITE : MDL_SHARED_READ);
+ tbl->mdl_request.set_type(table->mdl_request.type);
}
/*
If the view is mergeable, we might want to
1
0
[Commits] 21829bd743f: MDEV-17106: Test failure on galera.galera_binlog_stmt_autoinc
by jan 11 Sep '18
by jan 11 Sep '18
11 Sep '18
revision-id: 21829bd743f487280dba918857259b9971a8afbf (mariadb-10.1.35-45-g21829bd743f)
parent(s): bdaace9b3073ff72d1cbcc510ae5541d043a5072
author: Jan Lindström
committer: Jan Lindström
timestamp: 2018-09-11 08:19:16 +0300
message:
MDEV-17106: Test failure on galera.galera_binlog_stmt_autoinc
Add missing test case with proper wait conditions for expected
node contents.
---
mysql-test/suite/galera/disabled.def | 3 +-
.../galera/r/galera_binlog_stmt_autoinc.result | 147 +++++++++++++
.../suite/galera/t/galera_binlog_stmt_autoinc.test | 230 +++++++++++++++++++++
3 files changed, 378 insertions(+), 2 deletions(-)
diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def
index 40b4065c3db..bd9070683d4 100644
--- a/mysql-test/suite/galera/disabled.def
+++ b/mysql-test/suite/galera/disabled.def
@@ -31,6 +31,5 @@ MW-416 : MDEV-13549 Galera test failures
galera_wan : MDEV-13549 Galera test failures
MW-388 : MDEV-13549 Galera test failures
galera_sst_mysqldump_with_key : MDEV-16890 Galera test failure
-galera.galera_binlog_stmt_autoinc : MDEV-17106 Test failure on galera.galera_binlog_stmt_autoinc
galera.galera_kill_ddl : MDEV-17108 Test failure on galera.galera_kill_ddl
-galera.galera_var_node_address : MDEV-17151 Galera test failure on galera.galera_var_node_address
+
diff --git a/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result b/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result
new file mode 100644
index 00000000000..8e8b79b168f
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result
@@ -0,0 +1,147 @@
+SET GLOBAL wsrep_forced_binlog_format='STATEMENT';
+SET GLOBAL wsrep_forced_binlog_format='STATEMENT';
+CREATE TABLE t1 (
+i int(11) NOT NULL AUTO_INCREMENT,
+c char(32) DEFAULT 'dummy_text',
+PRIMARY KEY (i)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+insert into t1(i) values(null);
+select * from t1;
+i c
+3 dummy_text
+insert into t1(i) values(null), (null), (null);
+select * from t1;
+i c
+3 dummy_text
+5 dummy_text
+7 dummy_text
+9 dummy_text
+select * from t1;
+i c
+3 dummy_text
+5 dummy_text
+7 dummy_text
+9 dummy_text
+SET GLOBAL wsrep_forced_binlog_format='none';
+SET GLOBAL wsrep_forced_binlog_format='none';
+drop table t1;
+SET SESSION binlog_format='STATEMENT';
+show variables like 'binlog_format';
+Variable_name Value
+binlog_format STATEMENT
+SET GLOBAL wsrep_auto_increment_control='OFF';
+SET SESSION auto_increment_increment = 3;
+SET SESSION auto_increment_offset = 1;
+CREATE TABLE t1 (
+i int(11) NOT NULL AUTO_INCREMENT,
+c char(32) DEFAULT 'dummy_text',
+PRIMARY KEY (i)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+insert into t1(i) values(null);
+select * from t1;
+i c
+4 dummy_text
+insert into t1(i) values(null), (null), (null);
+select * from t1;
+i c
+4 dummy_text
+7 dummy_text
+10 dummy_text
+13 dummy_text
+select * from t1;
+i c
+4 dummy_text
+7 dummy_text
+10 dummy_text
+13 dummy_text
+SET GLOBAL wsrep_auto_increment_control='ON';
+SET SESSION binlog_format='ROW';
+show variables like 'binlog_format';
+Variable_name Value
+binlog_format ROW
+show variables like '%auto_increment%';
+Variable_name Value
+auto_increment_increment 2
+auto_increment_offset 1
+wsrep_auto_increment_control ON
+SET GLOBAL wsrep_auto_increment_control='OFF';
+show variables like '%auto_increment%';
+Variable_name Value
+auto_increment_increment 2
+auto_increment_offset 1
+wsrep_auto_increment_control OFF
+SET GLOBAL wsrep_auto_increment_control='ON';
+drop table t1;
+SET GLOBAL wsrep_forced_binlog_format='ROW';
+SET GLOBAL wsrep_forced_binlog_format='ROW';
+CREATE TABLE t1 (
+i int(11) NOT NULL AUTO_INCREMENT,
+c char(32) DEFAULT 'dummy_text',
+PRIMARY KEY (i)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+insert into t1(i) values(null);
+select * from t1;
+i c
+3 dummy_text
+insert into t1(i) values(null), (null), (null);
+select * from t1;
+i c
+3 dummy_text
+5 dummy_text
+7 dummy_text
+9 dummy_text
+select * from t1;
+i c
+3 dummy_text
+5 dummy_text
+7 dummy_text
+9 dummy_text
+SET GLOBAL wsrep_forced_binlog_format='none';
+SET GLOBAL wsrep_forced_binlog_format='none';
+drop table t1;
+SET SESSION binlog_format='ROW';
+show variables like 'binlog_format';
+Variable_name Value
+binlog_format ROW
+SET GLOBAL wsrep_auto_increment_control='OFF';
+SET SESSION auto_increment_increment = 3;
+SET SESSION auto_increment_offset = 1;
+CREATE TABLE t1 (
+i int(11) NOT NULL AUTO_INCREMENT,
+c char(32) DEFAULT 'dummy_text',
+PRIMARY KEY (i)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+insert into t1(i) values(null);
+select * from t1;
+i c
+4 dummy_text
+insert into t1(i) values(null), (null), (null);
+select * from t1;
+i c
+4 dummy_text
+7 dummy_text
+10 dummy_text
+13 dummy_text
+select * from t1;
+i c
+4 dummy_text
+7 dummy_text
+10 dummy_text
+13 dummy_text
+SET GLOBAL wsrep_auto_increment_control='ON';
+show variables like 'binlog_format';
+Variable_name Value
+binlog_format ROW
+show variables like '%auto_increment%';
+Variable_name Value
+auto_increment_increment 2
+auto_increment_offset 1
+wsrep_auto_increment_control ON
+SET GLOBAL wsrep_auto_increment_control='OFF';
+show variables like '%auto_increment%';
+Variable_name Value
+auto_increment_increment 2
+auto_increment_offset 1
+wsrep_auto_increment_control OFF
+SET GLOBAL wsrep_auto_increment_control='ON';
+drop table t1;
diff --git a/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test b/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test
new file mode 100644
index 00000000000..d3889a89016
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test
@@ -0,0 +1,230 @@
+##
+## Tests the auto-increment with binlog in STATEMENT mode.
+##
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--let $node_1=node_1
+--let $node_2=node_2
+--source include/auto_increment_offset_save.inc
+
+##
+## Verify the correct operation of the auto-increment when the binlog
+## format artificially set to the 'STATEMENT' (although this mode is
+## not recommended in the current version):
+##
+
+--connection node_2
+SET GLOBAL wsrep_forced_binlog_format='STATEMENT';
+
+--connection node_1
+SET GLOBAL wsrep_forced_binlog_format='STATEMENT';
+
+CREATE TABLE t1 (
+ i int(11) NOT NULL AUTO_INCREMENT,
+ c char(32) DEFAULT 'dummy_text',
+ PRIMARY KEY (i)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+insert into t1(i) values(null);
+
+select * from t1;
+
+insert into t1(i) values(null), (null), (null);
+
+select * from t1;
+
+--connection node_2
+--let $wait_condition = SELECT COUNT(*) = 4 FROM t1;
+--source include/wait_condition.inc
+select * from t1;
+
+SET GLOBAL wsrep_forced_binlog_format='none';
+
+--connection node_1
+
+SET GLOBAL wsrep_forced_binlog_format='none';
+
+drop table t1;
+
+##
+## Check the operation when the automatic control over the auto-increment
+## settings is switched off, that is, when we use the increment step and
+## the offset specified by the user. In the current session, the binlog
+## format is set to 'STATEMENT'. It is important that the values of the
+## auto-increment options does not changed on other node - it allows us
+## to check the correct transmission of the auto-increment options to
+## other nodes:
+##
+
+--disable_warnings
+SET SESSION binlog_format='STATEMENT';
+--enable_warnings
+
+show variables like 'binlog_format';
+
+SET GLOBAL wsrep_auto_increment_control='OFF';
+
+SET SESSION auto_increment_increment = 3;
+SET SESSION auto_increment_offset = 1;
+
+CREATE TABLE t1 (
+ i int(11) NOT NULL AUTO_INCREMENT,
+ c char(32) DEFAULT 'dummy_text',
+ PRIMARY KEY (i)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+insert into t1(i) values(null);
+
+select * from t1;
+
+insert into t1(i) values(null), (null), (null);
+
+select * from t1;
+
+--connection node_2
+--let $wait_condition = SELECT COUNT(*) = 4 FROM t1;
+--source include/wait_condition.inc
+
+select * from t1;
+
+--connection node_1
+
+##
+## Verify the return to automatic calculation of the step
+## and offset of the auto-increment:
+##
+
+SET GLOBAL wsrep_auto_increment_control='ON';
+
+SET SESSION binlog_format='ROW';
+
+show variables like 'binlog_format';
+show variables like '%auto_increment%';
+
+##
+## Verify the recovery of original user-defined values after
+## stopping the automatic control over auto-increment:
+##
+
+SET GLOBAL wsrep_auto_increment_control='OFF';
+
+show variables like '%auto_increment%';
+
+##
+## Restore original options and drop test table:
+##
+
+SET GLOBAL wsrep_auto_increment_control='ON';
+
+drop table t1;
+
+##
+## Verify the correct operation of the auto-increment when the binlog
+## format set to the 'ROW':
+##
+
+--connection node_2
+SET GLOBAL wsrep_forced_binlog_format='ROW';
+
+--connection node_1
+SET GLOBAL wsrep_forced_binlog_format='ROW';
+
+CREATE TABLE t1 (
+ i int(11) NOT NULL AUTO_INCREMENT,
+ c char(32) DEFAULT 'dummy_text',
+ PRIMARY KEY (i)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+insert into t1(i) values(null);
+
+select * from t1;
+
+insert into t1(i) values(null), (null), (null);
+
+select * from t1;
+
+--connection node_2
+--let $wait_condition = SELECT COUNT(*) = 4 FROM t1;
+--source include/wait_condition.inc
+
+select * from t1;
+
+SET GLOBAL wsrep_forced_binlog_format='none';
+
+--connection node_1
+
+SET GLOBAL wsrep_forced_binlog_format='none';
+
+drop table t1;
+
+##
+## Check the operation when the automatic control over the auto-increment
+## settings is switched off, that is, when we use the increment step and
+## the offset specified by the user. In the current session, the binlog
+## format is set to 'ROW'. It is important that the values of the
+## auto-increment options does not changed on other node - it allows us
+## to check the correct transmission of the auto-increment options to
+## other nodes:
+##
+
+SET SESSION binlog_format='ROW';
+
+show variables like 'binlog_format';
+
+SET GLOBAL wsrep_auto_increment_control='OFF';
+
+SET SESSION auto_increment_increment = 3;
+SET SESSION auto_increment_offset = 1;
+
+CREATE TABLE t1 (
+ i int(11) NOT NULL AUTO_INCREMENT,
+ c char(32) DEFAULT 'dummy_text',
+ PRIMARY KEY (i)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+insert into t1(i) values(null);
+
+select * from t1;
+
+insert into t1(i) values(null), (null), (null);
+
+select * from t1;
+
+--connection node_2
+--let $wait_condition = SELECT COUNT(*) = 4 FROM t1;
+--source include/wait_condition.inc
+
+select * from t1;
+
+--connection node_1
+
+##
+## Verify the return to automatic calculation of the step
+## and offset of the auto-increment:
+##
+
+SET GLOBAL wsrep_auto_increment_control='ON';
+
+show variables like 'binlog_format';
+show variables like '%auto_increment%';
+
+##
+## Verify the recovery of original user-defined values after
+## stopping the automatic control over auto-increment:
+##
+
+SET GLOBAL wsrep_auto_increment_control='OFF';
+
+show variables like '%auto_increment%';
+
+##
+## Restore original options and drop test table:
+##
+
+SET GLOBAL wsrep_auto_increment_control='ON';
+
+drop table t1;
+
+--source include/auto_increment_offset_restore.inc
1
0
10 Sep '18
revision-id: bba7cc26ef9485c74ee399488e9fe3aad98b96f3 (mariadb-10.2.16-126-gbba7cc26ef9)
parent(s): 4d991abd4fc7f60e758ec46301b0dd2bee71245c
author: Varun
committer: Varun
timestamp: 2018-09-10 13:29:54 +0530
message:
MDEV-16990:server crashes in base_list_iterator::next
When we have a query which has implicit_grouping then we are sure that we would end up with only one
row so there is no point to do DISTINCT computation.
---
mysql-test/r/win.result | 12 ++++++++++++
mysql-test/t/win.test | 10 ++++++++++
sql/sql_select.cc | 2 +-
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result
index e4b2d223a02..aef9b613433 100644
--- a/mysql-test/r/win.result
+++ b/mysql-test/r/win.result
@@ -3314,3 +3314,15 @@ COUNT(DISTINCT t2.a2) rank() OVER (ORDER BY t2.b1)
1 2
1 3
DROP TABLE t1,t2;
+#
+# MDEV-16990: server crashes in base_list_iterator::next
+#
+CREATE TABLE t1(i int);
+insert into t1 values (1),(2);
+SELECT DISTINCT row_number() OVER (), MAX(1) FROM t1;
+row_number() OVER () MAX(1)
+1 1
+SELECT DISTINCT BIT_AND(0) OVER (), MAX(1) FROM t1;
+BIT_AND(0) OVER () MAX(1)
+0 1
+drop table t1;
diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test
index f47237ee59e..1617e85caf4 100644
--- a/mysql-test/t/win.test
+++ b/mysql-test/t/win.test
@@ -2082,3 +2082,13 @@ SELECT COUNT(DISTINCT t2.a2),
rank() OVER (ORDER BY t2.b1)
FROM t2 ,t1 GROUP BY t2.b1 ORDER BY t1.a1;
DROP TABLE t1,t2;
+
+--echo #
+--echo # MDEV-16990: server crashes in base_list_iterator::next
+--echo #
+
+CREATE TABLE t1(i int);
+insert into t1 values (1),(2);
+SELECT DISTINCT row_number() OVER (), MAX(1) FROM t1;
+SELECT DISTINCT BIT_AND(0) OVER (), MAX(1) FROM t1;
+drop table t1;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 0124a782de0..9770d5a34f0 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2731,7 +2731,7 @@ bool JOIN::make_aggr_tables_info()
remove_duplicates() assumes there is a preceding computation step (and
in the degenerate join, there's none)
*/
- if (top_join_tab_count)
+ if (top_join_tab_count && const_tables != top_join_tab_count)
curr_tab->distinct= true;
having= NULL;
1
0