[Commits] 62bdb8ec966: Make sure MyRocks tables do not have stats.records=0 as that confuses the optimizer.
by Sergei Petrunia 05 Feb '19
by Sergei Petrunia 05 Feb '19
05 Feb '19
revision-id: 62bdb8ec966a0f44db82955a126b10c646fa6265 (mariadb-10.3.6-102-g62bdb8ec966)
parent(s): 33907360f56789cd9b467b40e66412eb0a0aff28
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2019-02-06 02:38:47 +0300
message:
Make sure MyRocks tables do not have stats.records=0 as that confuses the optimizer.
They generally don't have stats.records=0, the the statistics are computed
based on GetApproximateSizes and GetApproximateMemTableStats. Still, when
there's nothing on disk and only a few records are in the MemTable, it
is possible that both calls will return 0, and the optimizer will see
stats.records=0, which may cause "impossible range" condition (even if
records_in_range() returned a non-zero value)
---
storage/rocksdb/ha_rocksdb.cc | 5 +++++
storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index 9f73b95cb4d..a940e451f75 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -10755,6 +10755,11 @@ int ha_rocksdb::info(uint flag) {
stats.data_file_length += m_table_handler->m_mtcache_size;
}
+ // Do like InnoDB does. stats.records=0 confuses the optimizer
+ if (stats.records == 0 && !(flag & (HA_STATUS_TIME | HA_STATUS_OPEN))) {
+ stats.records++;
+ }
+
if (rocksdb_debug_optimizer_n_rows > 0)
stats.records = rocksdb_debug_optimizer_n_rows;
}
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result b/storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result
index 9bbbdec4794..228e1313e74 100644
--- a/storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result
+++ b/storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result
@@ -183,7 +183,7 @@ insert into linktable values (1,1,4,1,1,1,1,1,1);
set global rocksdb_force_flush_memtable_now = true;
explain select id1, id2, link_type, visibility, data, time, version from linktable where id1 = 1 and link_type = 1 and id2 in (1, 2);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE linktable range PRIMARY,id1_type PRIMARY 24 NULL 2 Using where
+1 SIMPLE linktable ref PRIMARY,id1_type PRIMARY 16 const,const 2 Using where
drop table linktable;
CREATE TABLE `linktable` (
`id1` bigint(20) unsigned NOT NULL DEFAULT '0',
@@ -205,6 +205,6 @@ insert into linktable values (1,1,4,1,1,1,1,1,1);
set global rocksdb_force_flush_memtable_now = true;
explain select id1, id2, link_type, visibility, data, time, version from linktable where id1 = 1 and link_type = 1 and id2 in (1, 2);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE linktable range PRIMARY,id1_type PRIMARY 24 NULL 2 Using where
+1 SIMPLE linktable ref PRIMARY,id1_type PRIMARY 16 const,const 2 Using where
drop table linktable;
DROP TABLE t1;
1
0
[Commits] 698df0a1ae0: MDEV-12009: Allow to force kill user threads/query which are flagged as high priority by Galera
by jan 05 Feb '19
by jan 05 Feb '19
05 Feb '19
revision-id: 698df0a1ae0f72199afb71dc560552ce00c4dc35 (mariadb-10.1.37-81-g698df0a1ae0)
parent(s): c889c8de46dfa1216a46656700e17ba5e1adfdc1
author: Jan Lindström
committer: Jan Lindström
timestamp: 2019-02-05 15:41:53 +0200
message:
MDEV-12009: Allow to force kill user threads/query which are flagged as high priority by Galera
As noted on kill_one_thread SUPER should be able to kill even
system threads i.e. threads/query flagged as high priority or
wsrep applier thread. Normal user, should not able to kill
threads/query flagged as high priority (BF) or wsrep applier
thread.
---
include/mysql/service_wsrep.h | 3 ++
.../suite/galera/r/galera_kill_applier.result | 4 ++
mysql-test/suite/galera/t/galera_kill_applier.cnf | 10 ++++
mysql-test/suite/galera/t/galera_kill_applier.test | 54 ++++++++++++++++++++--
sql/sql_parse.cc | 14 ++++--
sql/sql_plugin_services.ic | 3 +-
sql/wsrep_dummy.cc | 3 ++
sql/wsrep_mysqld.cc | 1 -
sql/wsrep_thd.cc | 9 ++++
sql/wsrep_thd.h | 2 +
10 files changed, 95 insertions(+), 8 deletions(-)
diff --git a/include/mysql/service_wsrep.h b/include/mysql/service_wsrep.h
index 63499dfbd1f..c8f45387f81 100644
--- a/include/mysql/service_wsrep.h
+++ b/include/mysql/service_wsrep.h
@@ -111,6 +111,7 @@ extern struct wsrep_service_st {
int (*wsrep_trx_order_before_func)(MYSQL_THD, MYSQL_THD);
void (*wsrep_unlock_rollback_func)();
void (*wsrep_set_data_home_dir_func)(const char *data_dir);
+ my_bool (*wsrep_thd_is_applier_func)(THD *thd);
} *wsrep_service;
#ifdef MYSQL_DYNAMIC_PLUGIN
@@ -153,6 +154,7 @@ extern struct wsrep_service_st {
#define wsrep_trx_order_before(T1,T2) wsrep_service->wsrep_trx_order_before_func(T1,T2)
#define wsrep_unlock_rollback() wsrep_service->wsrep_unlock_rollback_func()
#define wsrep_set_data_home_dir(A) wsrep_service->wsrep_set_data_home_dir_func(A)
+#define wsrep_thd_is_applier(T) wsrep_service->wsrep_thd_is_applier_func(T)
#define wsrep_debug get_wsrep_debug()
#define wsrep_log_conflicts get_wsrep_log_conflicts()
@@ -211,6 +213,7 @@ void wsrep_thd_set_conflict_state(THD *thd, enum wsrep_conflict_state state);
bool wsrep_thd_ignore_table(THD *thd);
void wsrep_unlock_rollback();
void wsrep_set_data_home_dir(const char *data_dir);
+my_bool wsrep_thd_is_applier(THD *thd);
#endif
diff --git a/mysql-test/suite/galera/r/galera_kill_applier.result b/mysql-test/suite/galera/r/galera_kill_applier.result
index fe4911639ed..89f8ead0b65 100644
--- a/mysql-test/suite/galera/r/galera_kill_applier.result
+++ b/mysql-test/suite/galera/r/galera_kill_applier.result
@@ -1,4 +1,8 @@
+CREATE USER foo@localhost;
+GRANT SELECT on test.* TO foo@localhost;
+# Open connection to the 1st node using 'test_user1' user.
Got one of the listed errors
Got one of the listed errors
Got one of the listed errors
Got one of the listed errors
+DROP USER foo@localhost;
diff --git a/mysql-test/suite/galera/t/galera_kill_applier.cnf b/mysql-test/suite/galera/t/galera_kill_applier.cnf
new file mode 100644
index 00000000000..f2563e66f2e
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_kill_applier.cnf
@@ -0,0 +1,10 @@
+!include ../galera_2nodes.cnf
+
+[mysqld.1]
+wsrep_provider_options='base_port=(a)mysqld.1.#galera_port;pc.ignore_sb=true'
+auto_increment_offset=1
+
+[mysqld.2]
+wsrep_provider_options='base_port=(a)mysqld.2.#galera_port;pc.ignore_sb=true'
+auto_increment_offset=2
+
diff --git a/mysql-test/suite/galera/t/galera_kill_applier.test b/mysql-test/suite/galera/t/galera_kill_applier.test
index e14a8b9af23..5e4a587fe57 100644
--- a/mysql-test/suite/galera/t/galera_kill_applier.test
+++ b/mysql-test/suite/galera/t/galera_kill_applier.test
@@ -1,14 +1,25 @@
#
# This test checks that applier threads are immune to KILL QUERY and KILL STATEMENT
+# when USER is not SUPER
#
--source include/galera_cluster.inc
---source include/have_innodb.inc
--connection node_1
+CREATE USER foo@localhost;
+GRANT SELECT on test.* TO foo@localhost;
+
--let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE != 'wsrep aborter idle' OR STATE IS NULL LIMIT 1`
+--let $aborter_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep aborter idle' LIMIT 1`
+
+--echo # Open connection to the 1st node using 'test_user1' user.
+--let $port_1= \$NODE_MYPORT_1
+--connect(foo_node_1,localhost,foo,,test,$port_1,)
+
+--connection foo_node_1
+
--disable_query_log
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
--eval KILL $applier_thread
@@ -16,11 +27,48 @@
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
--eval KILL QUERY $applier_thread
---let $aborter_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep aborter idle' LIMIT 1`
-
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
--eval KILL $aborter_thread
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
--eval KILL QUERY $aborter_thread
--enable_query_log
+
+#
+# SUPER can kill applier threads
+#
+--connection node_2
+
+--let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE != 'wsrep aborter idle' OR STATE IS NULL LIMIT 1`
+
+--disable_query_log
+--eval KILL $applier_thread
+--enable_query_log
+
+--let $aborter_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep aborter idle' LIMIT 1`
+
+--disable_query_log
+--eval KILL $aborter_thread
+--enable_query_log
+
+--source include/restart_mysqld.inc
+
+--connection node_2
+--let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE != 'wsrep aborter idle' OR STATE IS NULL LIMIT 1`
+
+--disable_query_log
+--eval KILL QUERY $applier_thread
+--enable_query_log
+
+--let $aborter_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep aborter idle' LIMIT 1`
+
+--disable_query_log
+--eval KILL QUERY $aborter_thread
+--enable_query_log
+
+--source include/restart_mysqld.inc
+
+--connection node_1
+--disconnect foo_node_1
+DROP USER foo@localhost;
+
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 3f6ce8356ce..83278559a9c 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -8297,11 +8297,19 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ
It's ok to also kill DELAYED threads with KILL_CONNECTION instead of
KILL_SYSTEM_THREAD; The difference is that KILL_CONNECTION may be
faster and do a harder kill than KILL_SYSTEM_THREAD;
+
+ Note that if thread is wsrep Brute Force or applier thread we
+ allow killing it only when we're SUPER.
*/
- if (((thd->security_ctx->master_access & SUPER_ACL) ||
- thd->security_ctx->user_matches(tmp->security_ctx)) &&
- !wsrep_thd_is_BF(tmp, false))
+ if ((thd->security_ctx->master_access & SUPER_ACL) ||
+ (thd->security_ctx->user_matches(tmp->security_ctx)
+#ifdef WITH_WSREP
+ &&
+ !tmp->wsrep_applier &&
+ !wsrep_thd_is_BF(tmp, false)
+#endif
+ ))
{
tmp->awake(kill_signal);
error=0;
diff --git a/sql/sql_plugin_services.ic b/sql/sql_plugin_services.ic
index 95301a5fbe8..a0d42c04dba 100644
--- a/sql/sql_plugin_services.ic
+++ b/sql/sql_plugin_services.ic
@@ -180,7 +180,8 @@ static struct wsrep_service_st wsrep_handler = {
wsrep_trx_is_aborting,
wsrep_trx_order_before,
wsrep_unlock_rollback,
- wsrep_set_data_home_dir
+ wsrep_set_data_home_dir,
+ wsrep_thd_is_applier,
};
static struct thd_specifics_service_st thd_specifics_handler=
diff --git a/sql/wsrep_dummy.cc b/sql/wsrep_dummy.cc
index 20b2bc81568..4595421ac3e 100644
--- a/sql/wsrep_dummy.cc
+++ b/sql/wsrep_dummy.cc
@@ -20,6 +20,9 @@
my_bool wsrep_thd_is_BF(THD *, my_bool)
{ return 0; }
+my_bool wsrep_thd_is_applier(THD *)
+{ return 0; }
+
int wsrep_trx_order_before(THD *, THD *)
{ return 0; }
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 0a988f4a3e6..22b383970c9 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -2469,7 +2469,6 @@ extern "C" void wsrep_thd_set_exec_mode(THD *thd, enum wsrep_exec_mode mode)
thd->wsrep_exec_mode= mode;
}
-
extern "C" void wsrep_thd_set_query_state(
THD *thd, enum wsrep_query_state state)
{
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index eb26da61282..492a3b67c68 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -596,6 +596,15 @@ my_bool wsrep_thd_is_BF(THD *thd, my_bool sync)
return status;
}
+my_bool wsrep_thd_is_applier(THD *thd)
+{
+ my_bool ret = FALSE;
+ if (thd) {
+ ret = thd->wsrep_applier;
+ }
+ return ret;
+}
+
extern "C"
my_bool wsrep_thd_is_BF_or_commit(void *thd_ptr, my_bool sync)
{
diff --git a/sql/wsrep_thd.h b/sql/wsrep_thd.h
index 5900668f3fb..f5fcb50280c 100644
--- a/sql/wsrep_thd.h
+++ b/sql/wsrep_thd.h
@@ -37,6 +37,7 @@ int wsrep_abort_thd(void *bf_thd_ptr, void *victim_thd_ptr,
*/
extern void wsrep_thd_set_PA_safe(void *thd_ptr, my_bool safe);
extern my_bool wsrep_thd_is_BF(THD *thd, my_bool sync);
+extern my_bool wsrep_thd_is_applier(THD *thd);
extern my_bool wsrep_thd_is_wsrep(void *thd_ptr);
enum wsrep_conflict_state wsrep_thd_conflict_state(void *thd_ptr, my_bool sync);
@@ -47,6 +48,7 @@ extern "C" int wsrep_thd_in_locking_session(void *thd_ptr);
#else /* WITH_WSREP */
#define wsrep_thd_is_BF(T, S) (0)
+#define wsrep_thd_is_applier(T) (0)
#define wsrep_abort_thd(X,Y,Z) do { } while(0)
#define wsrep_create_appliers(T) do { } while(0)
1
0
05 Feb '19
revision-id: c889c8de46dfa1216a46656700e17ba5e1adfdc1 (mariadb-10.1.37-80-gc889c8de46d)
parent(s): 27f1de5cb3ededcea5a54d43047b5c38c2965075
author: Jan Lindström
committer: Jan Lindström
timestamp: 2019-02-05 15:37:33 +0200
message:
MDEV-18464: Port kill_one_trx fixes from 10.4 to 10.1
Pushed the decision for innodb transaction and system
locking down to lock_trx_handle_wait() level. With this,
we can avoid releasing these mutexes for executions
where these mutexes were acquired upfront.
This patch will also fix BF aborting of native threads, e.g.
threads which have declared wsrep_on=OFF. Earlier, we have
used, for innodb trx locks, was_chosen_as_deadlock_victim
flag, for marking inodb transactions, which are victims for
wsrep BF abort. With native threads (wsrep_on==OFF), re-using
was_chosen_as_deadlock_victim flag may lead to inteference
with real deadlock, and to deal with this, the patch has added new
flag for marking wsrep BF aborts only: was_chosen_as_wsrep_victim
wsrep_thd_query()
Allow calling with NULL thd and when wsrep_on is false
innobase_kill_query()
Removed lock mutex and trx mutex code.
wsrep_innobase_kill_one_trx()
Code cleanup and we will now use new was_chosen_as_wsrep_victim
flag.
wsrep_append_foreign_key
wsrep_store_key_val_for_row
Code cleanup
wsrep_kill_victim()
Removed unnecessary code.
lock_trx_handle_wait_low()
New low lever function to handle lock waits.
lock_trx_handle_wait()
Taking lock mutex and trx mutex is pushed down to this
function.
---
include/mysql/service_wsrep.h | 4 +-
sql/wsrep_dummy.cc | 4 +-
sql/wsrep_mysqld.cc | 7 +-
storage/innobase/handler/ha_innodb.cc | 224 +++++++++++++-------------------
storage/innobase/include/trx0trx.h | 11 +-
storage/innobase/lock/lock0lock.cc | 44 +++++--
storage/innobase/row/row0sel.cc | 4 -
storage/innobase/trx/trx0roll.cc | 3 +
storage/innobase/trx/trx0trx.cc | 9 +-
storage/xtradb/handler/ha_innodb.cc | 237 +++++++++++++++-------------------
storage/xtradb/include/trx0trx.h | 11 +-
storage/xtradb/lock/lock0lock.cc | 44 +++++--
storage/xtradb/row/row0sel.cc | 4 -
storage/xtradb/trx/trx0roll.cc | 6 +-
storage/xtradb/trx/trx0trx.cc | 8 +-
15 files changed, 286 insertions(+), 334 deletions(-)
diff --git a/include/mysql/service_wsrep.h b/include/mysql/service_wsrep.h
index b51f154422f..63499dfbd1f 100644
--- a/include/mysql/service_wsrep.h
+++ b/include/mysql/service_wsrep.h
@@ -99,7 +99,7 @@ extern struct wsrep_service_st {
enum wsrep_conflict_state (*wsrep_thd_get_conflict_state_func)(MYSQL_THD);
my_bool (*wsrep_thd_is_BF_func)(MYSQL_THD , my_bool);
my_bool (*wsrep_thd_is_wsrep_func)(MYSQL_THD thd);
- char * (*wsrep_thd_query_func)(THD *thd);
+ const char * (*wsrep_thd_query_func)(THD *thd);
enum wsrep_query_state (*wsrep_thd_query_state_func)(THD *thd);
const char * (*wsrep_thd_query_state_str_func)(THD *thd);
int (*wsrep_thd_retry_counter_func)(THD *thd);
@@ -174,7 +174,7 @@ extern long wsrep_protocol_version;
bool wsrep_consistency_check(THD *thd);
bool wsrep_prepare_key(const unsigned char* cache_key, size_t cache_key_len, const unsigned char* row_id, size_t row_id_len, struct wsrep_buf* key, size_t* key_len);
-char *wsrep_thd_query(THD *thd);
+const char *wsrep_thd_query(THD *thd);
const char *wsrep_thd_conflict_state_str(THD *thd);
const char *wsrep_thd_exec_mode_str(THD *thd);
const char *wsrep_thd_query_state_str(THD *thd);
diff --git a/sql/wsrep_dummy.cc b/sql/wsrep_dummy.cc
index 5837ab4bed5..20b2bc81568 100644
--- a/sql/wsrep_dummy.cc
+++ b/sql/wsrep_dummy.cc
@@ -101,8 +101,8 @@ enum wsrep_conflict_state wsrep_thd_get_conflict_state(THD *)
my_bool wsrep_thd_is_wsrep(THD *)
{ return 0; }
-char *wsrep_thd_query(THD *)
-{ return 0; }
+const char *wsrep_thd_query(THD *)
+{ return "NULL"; }
enum wsrep_query_state wsrep_thd_query_state(THD *)
{ return QUERY_IDLE; }
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 47aea6d3824..0a988f4a3e6 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -2579,9 +2579,12 @@ extern "C" query_id_t wsrep_thd_query_id(THD *thd)
}
-char *wsrep_thd_query(THD *thd)
+const char *wsrep_thd_query(THD *thd)
{
- return (thd) ? thd->query() : NULL;
+ const char *query="NULL";
+ if (thd && thd->query())
+ query = thd->query();
+ return query;
}
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 702f84a52d1..fc97b1dc104 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -4,7 +4,7 @@ Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, 2009 Google Inc.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2012, Facebook Inc.
-Copyright (c) 2013, 2018, MariaDB Corporation.
+Copyright (c) 2013, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -4912,8 +4912,6 @@ static void innobase_kill_query(handlerton*, THD* thd, enum thd_kill_levels)
/* if victim has been signaled by BF thread and/or aborting
is already progressing, following query aborting is not necessary
any more.
- Also, BF thread should own trx mutex for the victim, which would
- conflict with trx_mutex_enter() below
*/
DBUG_VOID_RETURN;
}
@@ -4922,34 +4920,8 @@ static void innobase_kill_query(handlerton*, THD* thd, enum thd_kill_levels)
if (trx_t* trx = thd_to_trx(thd)) {
ut_ad(trx->mysql_thd == thd);
- switch (trx->abort_type) {
-#ifdef WITH_WSREP
- case TRX_WSREP_ABORT:
- break;
-#endif
- case TRX_SERVER_ABORT:
- if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
- lock_mutex_enter();
- }
- /* fall through */
- case TRX_REPLICATION_ABORT:
- trx_mutex_enter(trx);
- }
/* Cancel a pending lock request if there are any */
lock_trx_handle_wait(trx);
- switch (trx->abort_type) {
-#ifdef WITH_WSREP
- case TRX_WSREP_ABORT:
- break;
-#endif
- case TRX_SERVER_ABORT:
- if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
- lock_mutex_exit();
- }
- /* fall through */
- case TRX_REPLICATION_ABORT:
- trx_mutex_exit(trx);
- }
}
DBUG_VOID_RETURN;
@@ -6904,7 +6876,7 @@ wsrep_store_key_val_for_row(
if (key_part->null_bit) {
if (buff_space > 0) {
- if (record[key_part->null_offset]
+ if (record[key_part->null_offset]
& key_part->null_bit) {
*buff = 1;
part_is_null = TRUE;
@@ -6914,8 +6886,8 @@ wsrep_store_key_val_for_row(
buff++;
buff_space--;
} else {
- fprintf (stderr, "WSREP: key truncated: %s\n",
- wsrep_thd_query(thd));
+ WSREP_WARN("key truncated: %s",
+ wsrep_thd_query(thd));
}
}
if (!part_is_null) *key_is_null = FALSE;
@@ -6938,9 +6910,8 @@ wsrep_store_key_val_for_row(
if (part_is_null) {
true_len = key_len + 2;
if (true_len > buff_space) {
- fprintf (stderr,
- "WSREP: key truncated: %s\n",
- wsrep_thd_query(thd));
+ WSREP_WARN("key truncated: %s",
+ wsrep_thd_query(thd));
true_len = buff_space;
}
buff += true_len;
@@ -6980,7 +6951,7 @@ wsrep_store_key_val_for_row(
memcpy(sorted, data, true_len);
true_len = wsrep_innobase_mysql_sort(
- mysql_type, cs->number, sorted, true_len,
+ mysql_type, cs->number, sorted, true_len,
REC_VERSION_56_MAX_INDEX_COL_LEN);
if (wsrep_protocol_version > 1) {
@@ -6990,9 +6961,8 @@ wsrep_store_key_val_for_row(
actual data. The rest of the space was reset to zero
in the bzero() call above. */
if (true_len > buff_space) {
- fprintf (stderr,
- "WSREP: key truncated: %s\n",
- wsrep_thd_query(thd));
+ WSREP_WARN("key truncated: %s",
+ wsrep_thd_query(thd));
true_len = buff_space;
}
memcpy(buff, sorted, true_len);
@@ -7023,9 +6993,8 @@ wsrep_store_key_val_for_row(
if (part_is_null) {
true_len = key_len + 2;
if (true_len > buff_space) {
- fprintf (stderr,
- "WSREP: key truncated: %s\n",
- wsrep_thd_query(thd));
+ WSREP_WARN("key truncated: %s",
+ wsrep_thd_query(thd));
true_len = buff_space;
}
buff += true_len;
@@ -7077,9 +7046,8 @@ wsrep_store_key_val_for_row(
length of the BLOB prefix in the key value. */
if (wsrep_protocol_version > 1) {
if (true_len > buff_space) {
- fprintf (stderr,
- "WSREP: key truncated: %s\n",
- wsrep_thd_query(thd));
+ WSREP_WARN("key truncated: %s",
+ wsrep_thd_query(thd));
true_len = buff_space;
}
buff += true_len;
@@ -7106,9 +7074,8 @@ wsrep_store_key_val_for_row(
if (part_is_null) {
true_len = key_len;
if (true_len > buff_space) {
- fprintf (stderr,
- "WSREP: key truncated: %s\n",
- wsrep_thd_query(thd));
+ WSREP_WARN("key truncated: %s",
+ wsrep_thd_query(thd));
true_len = buff_space;
}
buff += true_len;
@@ -7153,9 +7120,8 @@ wsrep_store_key_val_for_row(
REC_VERSION_56_MAX_INDEX_COL_LEN);
if (true_len > buff_space) {
- fprintf (stderr,
- "WSREP: key truncated: %s\n",
- wsrep_thd_query(thd));
+ WSREP_WARN("key truncated: %s",
+ wsrep_thd_query(thd));
true_len = buff_space;
}
memcpy(buff, sorted, true_len);
@@ -8148,7 +8114,7 @@ ha_innobase::write_row(
&& num_write_row >= 10000) {
#ifdef WITH_WSREP
if (wsrep_on(user_thd) && sql_command == SQLCOM_LOAD) {
- WSREP_DEBUG("forced trx split for LOAD: %s",
+ WSREP_DEBUG("forced trx split for LOAD: %s",
wsrep_thd_query(user_thd));
}
#endif /* WITH_WSREP */
@@ -8365,14 +8331,12 @@ ha_innobase::write_row(
auto_inc_inserted &&
wsrep_drupal_282555_workaround &&
wsrep_thd_retry_counter(current_thd) == 0 &&
- !thd_test_options(current_thd,
- OPTION_NOT_AUTOCOMMIT |
+ !thd_test_options(current_thd,
+ OPTION_NOT_AUTOCOMMIT |
OPTION_BEGIN)) {
WSREP_DEBUG(
"retrying insert: %s",
- (*wsrep_thd_query(current_thd)) ?
- wsrep_thd_query(current_thd) :
- (char *)"void");
+ wsrep_thd_query(current_thd));
error= DB_SUCCESS;
wsrep_thd_set_conflict_state(
current_thd, MUST_ABORT);
@@ -10312,8 +10276,7 @@ wsrep_append_foreign_key(
((!foreign) ? "constraint" :
((!foreign->referenced_table) ?
"referenced table" : "foreign table")),
- (thd && wsrep_thd_query(thd)) ?
- wsrep_thd_query(thd) : "void");
+ wsrep_thd_query(thd));
return DB_ERROR;
}
@@ -10334,13 +10297,11 @@ wsrep_append_foreign_key(
wsrep_dict_foreign_find_index(
foreign->referenced_table, NULL,
foreign->referenced_col_names,
- foreign->n_fields,
+ foreign->n_fields,
foreign->foreign_index,
TRUE, FALSE);
}
- }
- else
- {
+ } else {
foreign->foreign_table =
dict_table_get_low(
foreign->foreign_table_name_lookup);
@@ -10351,7 +10312,7 @@ wsrep_append_foreign_key(
foreign->foreign_table, NULL,
foreign->foreign_col_names,
foreign->n_fields,
- foreign->referenced_index,
+ foreign->referenced_index,
TRUE, FALSE);
}
}
@@ -10364,8 +10325,7 @@ wsrep_append_foreign_key(
WSREP_WARN("FK: %s missing in query: %s",
(!foreign->referenced_table) ?
"referenced table" : "foreign table",
- (wsrep_thd_query(thd)) ?
- wsrep_thd_query(thd) : "void");
+ wsrep_thd_query(thd));
return DB_ERROR;
}
byte key[WSREP_MAX_SUPPORTED_KEY_LENGTH+1] = {'\0'};
@@ -10434,8 +10394,7 @@ wsrep_append_foreign_key(
wkey_part,
(size_t*)&wkey.key_parts_num)) {
WSREP_WARN("key prepare failed for cascaded FK: %s",
- (wsrep_thd_query(thd)) ?
- wsrep_thd_query(thd) : "void");
+ wsrep_thd_query(thd));
return DB_ERROR;
}
wsrep_t *wsrep= get_wsrep();
@@ -10449,8 +10408,7 @@ wsrep_append_foreign_key(
if (rcode) {
DBUG_PRINT("wsrep", ("row key failed: %zu", rcode));
WSREP_ERROR("Appending cascaded fk row key failed: %s, %lu",
- (wsrep_thd_query(thd)) ?
- wsrep_thd_query(thd) : "void", rcode);
+ wsrep_thd_query(thd),rcode);
return DB_ERROR;
}
@@ -10472,9 +10430,9 @@ wsrep_append_key(
DBUG_ENTER("wsrep_append_key");
bool const copy = true;
#ifdef WSREP_DEBUG_PRINT
- fprintf(stderr, "%s conn %ld, trx %llu, keylen %d, table %s\n Query: %s ",
+ fprintf(stderr, "%s conn %ld, trx " TRX_ID_FMT " , keylen %d, table %s\n Query: %s ",
(shared) ? "Shared" : "Exclusive",
- thd_get_thread_id(thd), (long long)trx->id, key_len,
+ thd_get_thread_id(thd), trx->id, key_len,
table_share->table_name.str, wsrep_thd_query(thd));
for (int i=0; i<key_len; i++) {
fprintf(stderr, "%hhX, ", key[i]);
@@ -10490,8 +10448,7 @@ wsrep_append_key(
wkey_part,
(size_t*)&wkey.key_parts_num)) {
WSREP_WARN("key prepare failed for: %s",
- (wsrep_thd_query(thd)) ?
- wsrep_thd_query(thd) : "void");
+ wsrep_thd_query(thd));
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
}
@@ -10506,8 +10463,7 @@ wsrep_append_key(
if (rcode) {
DBUG_PRINT("wsrep", ("row key failed: %d", rcode));
WSREP_WARN("Appending row key failed: %s, %d",
- (wsrep_thd_query(thd)) ?
- wsrep_thd_query(thd) : "void", rcode);
+ wsrep_thd_query(thd), rcode);
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
}
DBUG_RETURN(0);
@@ -10542,18 +10498,17 @@ ha_innobase::wsrep_append_keys(
const uchar* record0, /* in: row in MySQL format */
const uchar* record1) /* in: row in MySQL format */
{
- int rcode;
+ int rcode=0;
DBUG_ENTER("wsrep_append_keys");
bool key_appended = false;
trx_t *trx = thd_to_trx(thd);
if (table_share && table_share->tmp_table != NO_TMP_TABLE) {
- WSREP_DEBUG("skipping tmp table DML: THD: %lu tmp: %d SQL: %s",
+ WSREP_DEBUG("skipping tmp table DML: THD: %lu tmp: %d SQL: %s",
thd_get_thread_id(thd),
table_share->tmp_table,
- (wsrep_thd_query(thd)) ?
- wsrep_thd_query(thd) : "void");
+ wsrep_thd_query(thd));
DBUG_RETURN(0);
}
@@ -10569,13 +10524,11 @@ ha_innobase::wsrep_append_keys(
if (!is_null) {
rcode = wsrep_append_key(
- thd, trx, table_share, table, keyval,
+ thd, trx, table_share, table, keyval,
len, shared);
if (rcode) DBUG_RETURN(rcode);
- }
- else
- {
- WSREP_DEBUG("NULL key skipped (proto 0): %s",
+ } else {
+ WSREP_DEBUG("NULL key skipped (proto 0): %s",
wsrep_thd_query(thd));
}
} else {
@@ -10607,7 +10560,7 @@ ha_innobase::wsrep_append_keys(
if (!tab) {
WSREP_WARN("MySQL-InnoDB key mismatch %s %s",
- table->s->table_name.str,
+ table->s->table_name.str,
key_info->name);
}
/* !hasPK == table with no PK, must append all non-unique keys */
@@ -10617,32 +10570,30 @@ ha_innobase::wsrep_append_keys(
(!tab && referenced_by_foreign_key()))) {
len = wsrep_store_key_val_for_row(
- thd, table, i, key0,
- WSREP_MAX_SUPPORTED_KEY_LENGTH,
+ thd, table, i, key0,
+ WSREP_MAX_SUPPORTED_KEY_LENGTH,
record0, &is_null);
if (!is_null) {
rcode = wsrep_append_key(
- thd, trx, table_share, table,
+ thd, trx, table_share, table,
keyval0, len+1, shared);
if (rcode) DBUG_RETURN(rcode);
if (key_info->flags & HA_NOSAME || shared)
key_appended = true;
- }
- else
- {
- WSREP_DEBUG("NULL key skipped: %s",
+ } else {
+ WSREP_DEBUG("NULL key skipped: %s",
wsrep_thd_query(thd));
}
if (record1) {
len = wsrep_store_key_val_for_row(
- thd, table, i, key1,
+ thd, table, i, key1,
WSREP_MAX_SUPPORTED_KEY_LENGTH,
record1, &is_null);
if (!is_null && memcmp(key0, key1, len)) {
rcode = wsrep_append_key(
- thd, trx, table_share,
- table,
+ thd, trx, table_share,
+ table,
keyval1, len+1, shared);
if (rcode) DBUG_RETURN(rcode);
}
@@ -10657,8 +10608,8 @@ ha_innobase::wsrep_append_keys(
int rcode;
wsrep_calc_row_hash(digest, record0, table, prebuilt, thd);
- if ((rcode = wsrep_append_key(thd, trx, table_share, table,
- (const char*) digest, 16,
+ if ((rcode = wsrep_append_key(thd, trx, table_share, table,
+ (const char*) digest, 16,
shared))) {
DBUG_RETURN(rcode);
}
@@ -10666,9 +10617,9 @@ ha_innobase::wsrep_append_keys(
if (record1) {
wsrep_calc_row_hash(
digest, record1, table, prebuilt, thd);
- if ((rcode = wsrep_append_key(thd, trx, table_share,
+ if ((rcode = wsrep_append_key(thd, trx, table_share,
table,
- (const char*) digest,
+ (const char*) digest,
16, shared))) {
DBUG_RETURN(rcode);
}
@@ -18588,12 +18539,13 @@ wsrep_innobase_kill_one_trx(
ibool signal)
{
ut_ad(lock_mutex_own());
+ ut_ad(victim_trx);
ut_ad(trx_mutex_own(victim_trx));
ut_ad(bf_thd_ptr);
- ut_ad(victim_trx);
DBUG_ENTER("wsrep_innobase_kill_one_trx");
- THD *bf_thd = bf_thd_ptr ? (THD*) bf_thd_ptr : NULL;
+
+ THD *bf_thd = (THD *) bf_thd_ptr;
THD *thd = (THD *) victim_trx->mysql_thd;
int64_t bf_seqno = (bf_thd) ? wsrep_thd_trx_seqno(bf_thd) : 0;
@@ -18603,36 +18555,40 @@ wsrep_innobase_kill_one_trx(
DBUG_RETURN(1);
}
- if (!bf_thd) {
- DBUG_PRINT("wsrep", ("no BF thd for conflicting lock"));
- WSREP_WARN("no BF THD for trx: " TRX_ID_FMT,
- bf_trx ? bf_trx->id : 0);
- DBUG_RETURN(1);
- }
-
WSREP_LOG_CONFLICT(bf_thd, thd, TRUE);
- WSREP_DEBUG("BF kill (%lu, seqno: %lld), victim: (%lu) trx: "
- TRX_ID_FMT,
- signal, (long long)bf_seqno,
+ wsrep_thd_LOCK(thd);
+
+ WSREP_DEBUG("BF kill (" ULINTPF ", seqno: " INT64PF
+ "), victim: (%lu) trx: " TRX_ID_FMT,
+ signal, bf_seqno,
thd_get_thread_id(thd),
victim_trx->id);
- WSREP_DEBUG("Aborting query: %s conf %d trx: %" PRId64,
- (thd && wsrep_thd_query(thd)) ? wsrep_thd_query(thd) : "void",
- wsrep_thd_conflict_state(thd, FALSE),
+ WSREP_DEBUG("Aborting query: %s conflict_state %s trx: %" PRId64,
+ wsrep_thd_query(thd),
+ wsrep_thd_conflict_state_str(thd),
wsrep_thd_ws_handle(thd)->trx_id);
- wsrep_thd_LOCK(thd);
- DBUG_EXECUTE_IF("sync.wsrep_after_BF_victim_lock",
- {
- const char act[]=
- "now "
- "wait_for signal.wsrep_after_BF_victim_lock";
- DBUG_ASSERT(!debug_sync_set_action(bf_thd,
- STRING_WITH_LEN(act)));
- };);
+ WSREP_DEBUG("Exec mode %s query_state %s",
+ wsrep_thd_exec_mode_str(thd),
+ wsrep_thd_query_state_str(thd));
+
+ /*
+ * we mark with was_chosen_as_deadlock_victim transaction,
+ * which is already marked as BF victim
+ * lock_sys is held until this vicitm has aborted
+ */
+ victim_trx->lock.was_chosen_as_wsrep_victim = TRUE;
+ DBUG_EXECUTE_IF("sync.wsrep_after_BF_victim_lock",
+ {
+ const char act[]=
+ "now "
+ "wait_for signal.wsrep_after_BF_victim_lock";
+ DBUG_ASSERT(!debug_sync_set_action(bf_thd,
+ STRING_WITH_LEN(act)));
+ };);
if (wsrep_thd_query_state(thd) == QUERY_EXITING) {
WSREP_DEBUG("kill trx EXITING for " TRX_ID_FMT,
@@ -18642,9 +18598,9 @@ wsrep_innobase_kill_one_trx(
}
if(wsrep_thd_exec_mode(thd) != LOCAL_STATE) {
- WSREP_DEBUG("withdraw for BF trx: " TRX_ID_FMT ", state: %d",
+ WSREP_DEBUG("withdraw for BF trx: " TRX_ID_FMT ", state: %s",
victim_trx->id,
- wsrep_thd_get_conflict_state(thd));
+ wsrep_thd_conflict_state_str(thd));
}
switch (wsrep_thd_get_conflict_state(thd)) {
@@ -18661,8 +18617,8 @@ wsrep_innobase_kill_one_trx(
case ABORTED:
case ABORTING: // fall through
default:
- WSREP_DEBUG("victim " TRX_ID_FMT " in state %d",
- victim_trx->id, wsrep_thd_get_conflict_state(thd));
+ WSREP_DEBUG("victim " TRX_ID_FMT " in state %s",
+ victim_trx->id, wsrep_thd_conflict_state_str(thd));
wsrep_thd_UNLOCK(thd);
DBUG_RETURN(0);
break;
@@ -18765,9 +18721,9 @@ wsrep_innobase_kill_one_trx(
wsrep_thd_trx_seqno(thd));
DBUG_RETURN(0);
}
+
/* This will lock thd from proceeding after net_read() */
wsrep_thd_set_conflict_state(thd, ABORTING);
-
wsrep_lock_rollback();
if (wsrep_aborting_thd_contains(thd)) {
@@ -18807,24 +18763,22 @@ wsrep_abort_transaction(
my_bool signal)
{
DBUG_ENTER("wsrep_innobase_abort_thd");
-
+
trx_t* victim_trx = thd_to_trx(victim_thd);
trx_t* bf_trx = (bf_thd) ? thd_to_trx(bf_thd) : NULL;
WSREP_DEBUG("abort transaction: BF: %s victim: %s victim conf: %d",
- wsrep_thd_query(bf_thd),
- wsrep_thd_query(victim_thd),
- wsrep_thd_conflict_state(victim_thd, FALSE));
+ wsrep_thd_query(bf_thd),
+ wsrep_thd_query(victim_thd),
+ wsrep_thd_conflict_state(victim_thd, FALSE));
if (victim_trx) {
lock_mutex_enter();
trx_mutex_enter(victim_trx);
- victim_trx->abort_type = TRX_WSREP_ABORT;
int rcode = wsrep_innobase_kill_one_trx(bf_thd, bf_trx,
victim_trx, signal);
trx_mutex_exit(victim_trx);
lock_mutex_exit();
- victim_trx->abort_type = TRX_SERVER_ABORT;
wsrep_srv_conc_cancel_wait(victim_trx);
DBUG_RETURN(rcode);
} else {
diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index fe16b8272b8..9ff0f731b01 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2015, 2018, MariaDB Corporation.
+Copyright (c) 2015, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -624,6 +624,12 @@ struct trx_lock_t {
only be modified by the thread that is
serving the running transaction. */
+#ifdef WITH_WSREP
+ bool was_chosen_as_wsrep_victim;
+ /*!< high priority wsrep thread has
+ marked this trx to abort */
+#endif /* WITH_WSREP */
+
mem_heap_t* lock_heap; /*!< memory heap for trx_locks;
protected by lock_sys->mutex */
@@ -697,9 +703,6 @@ lock_sys->mutex and sometimes by trx->mutex. */
enum trx_abort_t {
TRX_SERVER_ABORT = 0,
-#ifdef WITH_WSREP
- TRX_WSREP_ABORT,
-#endif
TRX_REPLICATION_ABORT
};
diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc
index 3970a559a4c..1174cc50e1e 100644
--- a/storage/innobase/lock/lock0lock.cc
+++ b/storage/innobase/lock/lock0lock.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2014, 2018, MariaDB Corporation.
+Copyright (c) 2014, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -1793,10 +1793,8 @@ wsrep_kill_victim(
}
}
- lock->trx->abort_type = TRX_WSREP_ABORT;
wsrep_innobase_kill_one_trx(trx->mysql_thd,
(const trx_t*) trx, lock->trx, TRUE);
- lock->trx->abort_type = TRX_SERVER_ABORT;
}
}
}
@@ -7967,16 +7965,7 @@ lock_trx_release_locks(
lock_mutex_exit();
}
-/*********************************************************************//**
-Check whether the transaction has already been rolled back because it
-was selected as a deadlock victim, or if it has to wait then cancel
-the wait lock.
-@return DB_DEADLOCK, DB_LOCK_WAIT or DB_SUCCESS */
-UNIV_INTERN
-dberr_t
-lock_trx_handle_wait(
-/*=================*/
- trx_t* trx) /*!< in/out: trx lock state */
+static inline dberr_t lock_trx_handle_wait_low(trx_t* trx)
{
ut_ad(lock_mutex_own());
ut_ad(trx_mutex_own(trx));
@@ -7993,6 +7982,35 @@ lock_trx_handle_wait(
return DB_LOCK_WAIT;
}
+/*********************************************************************//**
+Check whether the transaction has already been rolled back because it
+was selected as a deadlock victim, or if it has to wait then cancel
+the wait lock.
+@return DB_DEADLOCK, DB_LOCK_WAIT or DB_SUCCESS */
+UNIV_INTERN
+dberr_t
+lock_trx_handle_wait(
+/*=================*/
+ trx_t* trx) /*!< in/out: trx lock state */
+{
+#ifdef WITH_WSREP
+ /* We already own mutexes */
+ if (trx->lock.was_chosen_as_wsrep_victim) {
+ return lock_trx_handle_wait_low(trx);
+ }
+#endif /* WITH_WSREP */
+ if (trx->abort_type != TRX_REPLICATION_ABORT) {
+ lock_mutex_enter();
+ }
+ trx_mutex_enter(trx);
+ dberr_t err = lock_trx_handle_wait_low(trx);
+ if (trx->abort_type != TRX_REPLICATION_ABORT) {
+ lock_mutex_exit();
+ }
+ trx_mutex_exit(trx);
+ return err;
+}
+
/*********************************************************************//**
Get the number of locks on a table.
@return number of locks */
diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc
index 06bf4cc30c0..855266686e6 100644
--- a/storage/innobase/row/row0sel.cc
+++ b/storage/innobase/row/row0sel.cc
@@ -4746,11 +4746,7 @@ row_search_for_mysql(
a deadlock and the transaction had to wait then
release the lock it is waiting on. */
- lock_mutex_enter();
- trx_mutex_enter(trx);
err = lock_trx_handle_wait(trx);
- lock_mutex_exit();
- trx_mutex_exit(trx);
switch (err) {
case DB_SUCCESS:
diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc
index 3fd71aff23a..be8b7d29350 100644
--- a/storage/innobase/trx/trx0roll.cc
+++ b/storage/innobase/trx/trx0roll.cc
@@ -370,6 +370,9 @@ trx_rollback_to_savepoint_for_mysql_low(
trx_mark_sql_stat_end(trx);
trx->op_info = "";
+#ifdef WITH_WSREP
+ trx->lock.was_chosen_as_wsrep_victim = FALSE;
+#endif
return(err);
}
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index f36aabba8b4..5c8a2c3c6f8 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2015, 2018, MariaDB Corporation.
+Copyright (c) 2015, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -168,6 +168,7 @@ trx_create(void)
#ifdef WITH_WSREP
trx->wsrep_event = NULL;
#endif /* WITH_WSREP */
+
return(trx);
}
@@ -1339,12 +1340,10 @@ trx_commit_in_memory(
ut_ad(!trx->in_ro_trx_list);
ut_ad(!trx->in_rw_trx_list);
+ trx->dict_operation = TRX_DICT_OP_NONE;
#ifdef WITH_WSREP
- if (trx->mysql_thd && wsrep_on(trx->mysql_thd)) {
- trx->lock.was_chosen_as_deadlock_victim = FALSE;
- }
+ trx->lock.was_chosen_as_wsrep_victim = FALSE;
#endif
- trx->dict_operation = TRX_DICT_OP_NONE;
trx->error_state = DB_SUCCESS;
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index d3be5155d27..f4e0420519e 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -5,7 +5,7 @@ Copyright (c) 2013, 2018, MariaDB Corporation.
Copyright (c) 2008, 2009 Google Inc.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2012, Facebook Inc.
-Copyright (c) 2013, 2018, MariaDB Corporation.
+Copyright (c) 2013, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -5517,43 +5517,15 @@ static void innobase_kill_query(handlerton*, THD* thd, enum thd_kill_levels)
/* if victim has been signaled by BF thread and/or aborting
is already progressing, following query aborting is not necessary
any more.
- Also, BF thread should own trx mutex for the victim, which would
- conflict with trx_mutex_enter() below
*/
DBUG_VOID_RETURN;
}
#endif /* WITH_WSREP */
+
if (trx_t* trx = thd_to_trx(thd)) {
ut_ad(trx->mysql_thd == thd);
-
- switch (trx->abort_type) {
-#ifdef WITH_WSREP
- case TRX_WSREP_ABORT:
- break;
-#endif
- case TRX_SERVER_ABORT:
- if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
- lock_mutex_enter();
- }
- /* fall through */
- case TRX_REPLICATION_ABORT:
- trx_mutex_enter(trx);
- }
/* Cancel a pending lock request if there are any */
lock_trx_handle_wait(trx);
- switch (trx->abort_type) {
-#ifdef WITH_WSREP
- case TRX_WSREP_ABORT:
- break;
-#endif
- case TRX_SERVER_ABORT:
- if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
- lock_mutex_exit();
- }
- /* fall through */
- case TRX_REPLICATION_ABORT:
- trx_mutex_exit(trx);
- }
}
DBUG_VOID_RETURN;
@@ -7473,7 +7445,7 @@ wsrep_store_key_val_for_row(
if (key_part->null_bit) {
if (buff_space > 0) {
- if (record[key_part->null_offset]
+ if (record[key_part->null_offset]
& key_part->null_bit) {
*buff = 1;
part_is_null = TRUE;
@@ -7483,8 +7455,8 @@ wsrep_store_key_val_for_row(
buff++;
buff_space--;
} else {
- fprintf (stderr, "WSREP: key truncated: %s\n",
- wsrep_thd_query(thd));
+ WSREP_WARN("key truncated: %s",
+ wsrep_thd_query(thd));
}
}
if (!part_is_null) *key_is_null = FALSE;
@@ -7507,9 +7479,8 @@ wsrep_store_key_val_for_row(
if (part_is_null) {
true_len = key_len + 2;
if (true_len > buff_space) {
- fprintf (stderr,
- "WSREP: key truncated: %s\n",
- wsrep_thd_query(thd));
+ WSREP_WARN("key truncated: %s\n",
+ wsrep_thd_query(thd));
true_len = buff_space;
}
buff += true_len;
@@ -7549,7 +7520,7 @@ wsrep_store_key_val_for_row(
memcpy(sorted, data, true_len);
true_len = wsrep_innobase_mysql_sort(
- mysql_type, cs->number, sorted, true_len,
+ mysql_type, cs->number, sorted, true_len,
REC_VERSION_56_MAX_INDEX_COL_LEN);
if (wsrep_protocol_version > 1) {
@@ -7559,9 +7530,8 @@ wsrep_store_key_val_for_row(
actual data. The rest of the space was reset to zero
in the bzero() call above. */
if (true_len > buff_space) {
- fprintf (stderr,
- "WSREP: key truncated: %s\n",
- wsrep_thd_query(thd));
+ WSREP_WARN("key truncated: %s\n",
+ wsrep_thd_query(thd));
true_len = buff_space;
}
memcpy(buff, sorted, true_len);
@@ -7592,9 +7562,8 @@ wsrep_store_key_val_for_row(
if (part_is_null) {
true_len = key_len + 2;
if (true_len > buff_space) {
- fprintf (stderr,
- "WSREP: key truncated: %s\n",
- wsrep_thd_query(thd));
+ WSREP_WARN("key truncated: %s",
+ wsrep_thd_query(thd));
true_len = buff_space;
}
buff += true_len;
@@ -7646,9 +7615,8 @@ wsrep_store_key_val_for_row(
length of the BLOB prefix in the key value. */
if (wsrep_protocol_version > 1) {
if (true_len > buff_space) {
- fprintf (stderr,
- "WSREP: key truncated: %s\n",
- wsrep_thd_query(thd));
+ WSREP_WARN("key truncated: %s",
+ wsrep_thd_query(thd));
true_len = buff_space;
}
buff += true_len;
@@ -7675,9 +7643,8 @@ wsrep_store_key_val_for_row(
if (part_is_null) {
true_len = key_len;
if (true_len > buff_space) {
- fprintf (stderr,
- "WSREP: key truncated: %s\n",
- wsrep_thd_query(thd));
+ WSREP_WARN("key truncated: %s",
+ wsrep_thd_query(thd));
true_len = buff_space;
}
buff += true_len;
@@ -7722,9 +7689,8 @@ wsrep_store_key_val_for_row(
REC_VERSION_56_MAX_INDEX_COL_LEN);
if (true_len > buff_space) {
- fprintf (stderr,
- "WSREP: key truncated: %s\n",
- wsrep_thd_query(thd));
+ WSREP_WARN("key truncated: %s",
+ wsrep_thd_query(thd));
true_len = buff_space;
}
memcpy(buff, sorted, true_len);
@@ -8731,7 +8697,7 @@ ha_innobase::write_row(
&& num_write_row >= 10000) {
#ifdef WITH_WSREP
if (wsrep_on(user_thd) && sql_command == SQLCOM_LOAD) {
- WSREP_DEBUG("forced trx split for LOAD: %s",
+ WSREP_DEBUG("forced trx split for LOAD: %s",
wsrep_thd_query(user_thd));
}
#endif /* WITH_WSREP */
@@ -8951,14 +8917,12 @@ ha_innobase::write_row(
auto_inc_inserted &&
wsrep_drupal_282555_workaround &&
wsrep_thd_retry_counter(current_thd) == 0 &&
- !thd_test_options(current_thd,
- OPTION_NOT_AUTOCOMMIT |
+ !thd_test_options(current_thd,
+ OPTION_NOT_AUTOCOMMIT |
OPTION_BEGIN)) {
WSREP_DEBUG(
"retrying insert: %s",
- (*wsrep_thd_query(current_thd)) ?
- wsrep_thd_query(current_thd) :
- (char *)"void");
+ wsrep_thd_query(current_thd));
error= DB_SUCCESS;
wsrep_thd_set_conflict_state(
current_thd, MUST_ABORT);
@@ -10866,7 +10830,7 @@ wsrep_append_foreign_key(
ulint rcode = DB_SUCCESS;
char cache_key[513] = {'\0'};
int cache_key_len;
- bool const copy = true;
+ bool const copy = true;
if (!wsrep_on(trx->mysql_thd) ||
wsrep_thd_exec_mode(thd) != LOCAL_STATE)
@@ -10880,8 +10844,7 @@ wsrep_append_foreign_key(
((!foreign) ? "constraint" :
((!foreign->referenced_table) ?
"referenced table" : "foreign table")),
- (thd && wsrep_thd_query(thd)) ?
- wsrep_thd_query(thd) : "void");
+ wsrep_thd_query(thd));
return DB_ERROR;
}
@@ -10902,7 +10865,7 @@ wsrep_append_foreign_key(
wsrep_dict_foreign_find_index(
foreign->referenced_table, NULL,
foreign->referenced_col_names,
- foreign->n_fields,
+ foreign->n_fields,
foreign->foreign_index,
TRUE, FALSE);
}
@@ -10919,7 +10882,7 @@ wsrep_append_foreign_key(
foreign->foreign_table, NULL,
foreign->foreign_col_names,
foreign->n_fields,
- foreign->referenced_index,
+ foreign->referenced_index,
TRUE, FALSE);
}
}
@@ -10932,8 +10895,7 @@ wsrep_append_foreign_key(
WSREP_WARN("FK: %s missing in query: %s",
(!foreign->referenced_table) ?
"referenced table" : "foreign table",
- (wsrep_thd_query(thd)) ?
- wsrep_thd_query(thd) : "void");
+ wsrep_thd_query(thd));
return DB_ERROR;
}
byte key[WSREP_MAX_SUPPORTED_KEY_LENGTH+1] = {'\0'};
@@ -11002,8 +10964,7 @@ wsrep_append_foreign_key(
wkey_part,
(size_t*)&wkey.key_parts_num)) {
WSREP_WARN("key prepare failed for cascaded FK: %s",
- (wsrep_thd_query(thd)) ?
- wsrep_thd_query(thd) : "void");
+ wsrep_thd_query(thd));
return DB_ERROR;
}
wsrep_t *wsrep= get_wsrep();
@@ -11017,8 +10978,7 @@ wsrep_append_foreign_key(
if (rcode) {
DBUG_PRINT("wsrep", ("row key failed: %zu", rcode));
WSREP_ERROR("Appending cascaded fk row key failed: %s, %lu",
- (wsrep_thd_query(thd)) ?
- wsrep_thd_query(thd) : "void", rcode);
+ wsrep_thd_query(thd), rcode);
return DB_ERROR;
}
@@ -11040,9 +11000,9 @@ wsrep_append_key(
DBUG_ENTER("wsrep_append_key");
bool const copy = true;
#ifdef WSREP_DEBUG_PRINT
- fprintf(stderr, "%s conn %ld, trx %llu, keylen %d, table %s\n Query: %s ",
+ fprintf(stderr, "%s conn %ld, trx " TRX_ID_FMT " , keylen %d, table %s\n Query: %s ",
(shared) ? "Shared" : "Exclusive",
- thd_get_thread_id(thd), (long long)trx->id, key_len,
+ thd_get_thread_id(thd), trx->id, key_len,
table_share->table_name.str, wsrep_thd_query(thd));
for (int i=0; i<key_len; i++) {
fprintf(stderr, "%hhX, ", key[i]);
@@ -11058,8 +11018,7 @@ wsrep_append_key(
wkey_part,
(size_t*)&wkey.key_parts_num)) {
WSREP_WARN("key prepare failed for: %s",
- (wsrep_thd_query(thd)) ?
- wsrep_thd_query(thd) : "void");
+ wsrep_thd_query(thd));
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
}
@@ -11074,8 +11033,7 @@ wsrep_append_key(
if (rcode) {
DBUG_PRINT("wsrep", ("row key failed: %d", rcode));
WSREP_WARN("Appending row key failed: %s, %d",
- (wsrep_thd_query(thd)) ?
- wsrep_thd_query(thd) : "void", rcode);
+ wsrep_thd_query(thd), rcode);
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
}
DBUG_RETURN(0);
@@ -11110,18 +11068,17 @@ ha_innobase::wsrep_append_keys(
const uchar* record0, /* in: row in MySQL format */
const uchar* record1) /* in: row in MySQL format */
{
- int rcode;
+ int rcode=0;
DBUG_ENTER("wsrep_append_keys");
bool key_appended = false;
trx_t *trx = thd_to_trx(thd);
if (table_share && table_share->tmp_table != NO_TMP_TABLE) {
- WSREP_DEBUG("skipping tmp table DML: THD: %lu tmp: %d SQL: %s",
+ WSREP_DEBUG("skipping tmp table DML: THD: %lu tmp: %d SQL: %s",
thd_get_thread_id(thd),
table_share->tmp_table,
- (wsrep_thd_query(thd)) ?
- wsrep_thd_query(thd) : "void");
+ wsrep_thd_query(thd));
DBUG_RETURN(0);
}
@@ -11137,13 +11094,11 @@ ha_innobase::wsrep_append_keys(
if (!is_null) {
rcode = wsrep_append_key(
- thd, trx, table_share, table, keyval,
+ thd, trx, table_share, table, keyval,
len, shared);
if (rcode) DBUG_RETURN(rcode);
- }
- else
- {
- WSREP_DEBUG("NULL key skipped (proto 0): %s",
+ } else {
+ WSREP_DEBUG("NULL key skipped (proto 0): %s",
wsrep_thd_query(thd));
}
} else {
@@ -11175,7 +11130,7 @@ ha_innobase::wsrep_append_keys(
if (!tab) {
WSREP_WARN("MySQL-InnoDB key mismatch %s %s",
- table->s->table_name.str,
+ table->s->table_name.str,
key_info->name);
}
/* !hasPK == table with no PK, must append all non-unique keys */
@@ -11185,32 +11140,30 @@ ha_innobase::wsrep_append_keys(
(!tab && referenced_by_foreign_key()))) {
len = wsrep_store_key_val_for_row(
- thd, table, i, key0,
- WSREP_MAX_SUPPORTED_KEY_LENGTH,
+ thd, table, i, key0,
+ WSREP_MAX_SUPPORTED_KEY_LENGTH,
record0, prebuilt, &is_null);
if (!is_null) {
rcode = wsrep_append_key(
- thd, trx, table_share, table,
+ thd, trx, table_share, table,
keyval0, len+1, shared);
if (rcode) DBUG_RETURN(rcode);
if (key_info->flags & HA_NOSAME || shared)
key_appended = true;
- }
- else
- {
- WSREP_DEBUG("NULL key skipped: %s",
+ } else {
+ WSREP_DEBUG("NULL key skipped: %s",
wsrep_thd_query(thd));
}
if (record1) {
len = wsrep_store_key_val_for_row(
- thd, table, i, key1,
+ thd, table, i, key1,
WSREP_MAX_SUPPORTED_KEY_LENGTH,
record1, prebuilt, &is_null);
if (!is_null && memcmp(key0, key1, len)) {
rcode = wsrep_append_key(
- thd, trx, table_share,
- table,
+ thd, trx, table_share,
+ table,
keyval1, len+1, shared);
if (rcode) DBUG_RETURN(rcode);
}
@@ -11225,8 +11178,8 @@ ha_innobase::wsrep_append_keys(
int rcode;
wsrep_calc_row_hash(digest, record0, table, prebuilt, thd);
- if ((rcode = wsrep_append_key(thd, trx, table_share, table,
- (const char*) digest, 16,
+ if ((rcode = wsrep_append_key(thd, trx, table_share, table,
+ (const char*) digest, 16,
shared))) {
DBUG_RETURN(rcode);
}
@@ -11234,9 +11187,9 @@ ha_innobase::wsrep_append_keys(
if (record1) {
wsrep_calc_row_hash(
digest, record1, table, prebuilt, thd);
- if ((rcode = wsrep_append_key(thd, trx, table_share,
+ if ((rcode = wsrep_append_key(thd, trx, table_share,
table,
- (const char*) digest,
+ (const char*) digest,
16, shared))) {
DBUG_RETURN(rcode);
}
@@ -19631,12 +19584,13 @@ wsrep_innobase_kill_one_trx(
ibool signal)
{
ut_ad(lock_mutex_own());
+ ut_ad(victim_trx);
ut_ad(trx_mutex_own(victim_trx));
ut_ad(bf_thd_ptr);
- ut_ad(victim_trx);
DBUG_ENTER("wsrep_innobase_kill_one_trx");
- THD *bf_thd = bf_thd_ptr ? (THD*) bf_thd_ptr : NULL;
+
+ THD *bf_thd = (THD *) bf_thd_ptr;
THD *thd = (THD *) victim_trx->mysql_thd;
int64_t bf_seqno = (bf_thd) ? wsrep_thd_trx_seqno(bf_thd) : 0;
@@ -19646,34 +19600,40 @@ wsrep_innobase_kill_one_trx(
DBUG_RETURN(1);
}
- if (!bf_thd) {
- DBUG_PRINT("wsrep", ("no BF thd for conflicting lock"));
- WSREP_WARN("no BF THD for trx: " TRX_ID_FMT,
- bf_trx ? bf_trx->id : 0);
- DBUG_RETURN(1);
- }
-
WSREP_LOG_CONFLICT(bf_thd, thd, TRUE);
- WSREP_DEBUG("BF kill (%lu, seqno: %lld), victim: (%lu) trx: "
- TRX_ID_FMT,
- signal, (long long)bf_seqno,
+ wsrep_thd_LOCK(thd);
+
+ WSREP_DEBUG("BF kill (" ULINTPF ", seqno: " INT64PF
+ "), victim: (%lu) trx: " TRX_ID_FMT,
+ signal, bf_seqno,
thd_get_thread_id(thd),
victim_trx->id);
- WSREP_DEBUG("Aborting query: %s",
- (thd && wsrep_thd_query(thd)) ? wsrep_thd_query(thd) : "void");
+ WSREP_DEBUG("Aborting query: %s conflict_state %s trx: %" PRId64,
+ wsrep_thd_query(thd),
+ wsrep_thd_conflict_state_str(thd),
+ wsrep_thd_ws_handle(thd)->trx_id);
- wsrep_thd_LOCK(thd);
- DBUG_EXECUTE_IF("sync.wsrep_after_BF_victim_lock",
- {
- const char act[]=
- "now "
- "wait_for signal.wsrep_after_BF_victim_lock";
- DBUG_ASSERT(!debug_sync_set_action(bf_thd,
- STRING_WITH_LEN(act)));
- };);
+ WSREP_DEBUG("Exec mode %s query_state %s",
+ wsrep_thd_exec_mode_str(thd),
+ wsrep_thd_query_state_str(thd));
+ /*
+ * we mark with was_chosen_as_deadlock_victim transaction,
+ * which is already marked as BF victim
+ * lock_sys is held until this vicitm has aborted
+ */
+ victim_trx->lock.was_chosen_as_wsrep_victim = TRUE;
+
+ DBUG_EXECUTE_IF("sync.wsrep_after_BF_victim_lock",
+ {
+ const char act[]=
+ "now "
+ "wait_for signal.wsrep_after_BF_victim_lock";
+ DBUG_ASSERT(!debug_sync_set_action(bf_thd,
+ STRING_WITH_LEN(act)));
+ };);
if (wsrep_thd_query_state(thd) == QUERY_EXITING) {
WSREP_DEBUG("kill trx EXITING for " TRX_ID_FMT,
@@ -19683,9 +19643,9 @@ wsrep_innobase_kill_one_trx(
}
if(wsrep_thd_exec_mode(thd) != LOCAL_STATE) {
- WSREP_DEBUG("withdraw for BF trx: " TRX_ID_FMT ", state: %d",
+ WSREP_DEBUG("withdraw for BF trx: " TRX_ID_FMT ", state: %s",
victim_trx->id,
- wsrep_thd_get_conflict_state(thd));
+ wsrep_thd_conflict_state_str(thd));
}
switch (wsrep_thd_get_conflict_state(thd)) {
@@ -19702,8 +19662,8 @@ wsrep_innobase_kill_one_trx(
case ABORTED:
case ABORTING: // fall through
default:
- WSREP_DEBUG("victim " TRX_ID_FMT " in state %d",
- victim_trx->id, wsrep_thd_get_conflict_state(thd));
+ WSREP_DEBUG("victim " TRX_ID_FMT " in state %s",
+ victim_trx->id, wsrep_thd_conflict_state_str(thd));
wsrep_thd_UNLOCK(thd);
DBUG_RETURN(0);
break;
@@ -19725,7 +19685,7 @@ wsrep_innobase_kill_one_trx(
wsrep_t *wsrep= get_wsrep();
rcode = wsrep->abort_pre_commit(
wsrep, bf_seqno,
- (wsrep_trx_id_t)victim_trx->id
+ (wsrep_trx_id_t)wsrep_thd_ws_handle(thd)->trx_id
);
switch (rcode) {
@@ -19806,9 +19766,9 @@ wsrep_innobase_kill_one_trx(
wsrep_thd_trx_seqno(thd));
DBUG_RETURN(0);
}
+
/* This will lock thd from proceeding after net_read() */
wsrep_thd_set_conflict_state(thd, ABORTING);
-
wsrep_lock_rollback();
if (wsrep_aborting_thd_contains(thd)) {
@@ -19839,26 +19799,31 @@ wsrep_innobase_kill_one_trx(
DBUG_RETURN(0);
}
-static int
-wsrep_abort_transaction(handlerton* hton, THD *bf_thd, THD *victim_thd,
- my_bool signal)
+static
+int
+wsrep_abort_transaction(
+ handlerton* hton,
+ THD *bf_thd,
+ THD *victim_thd,
+ my_bool signal)
{
DBUG_ENTER("wsrep_innobase_abort_thd");
+
trx_t* victim_trx = thd_to_trx(victim_thd);
trx_t* bf_trx = (bf_thd) ? thd_to_trx(bf_thd) : NULL;
- WSREP_DEBUG("abort transaction: BF: %s victim: %s",
- wsrep_thd_query(bf_thd),
- wsrep_thd_query(victim_thd));
+
+ WSREP_DEBUG("abort transaction: BF: %s victim: %s victim conf: %d",
+ wsrep_thd_query(bf_thd),
+ wsrep_thd_query(victim_thd),
+ wsrep_thd_conflict_state(victim_thd, FALSE));
if (victim_trx) {
lock_mutex_enter();
trx_mutex_enter(victim_trx);
- victim_trx->abort_type = TRX_WSREP_ABORT;
int rcode = wsrep_innobase_kill_one_trx(bf_thd, bf_trx,
victim_trx, signal);
trx_mutex_exit(victim_trx);
lock_mutex_exit();
- victim_trx->abort_type = TRX_SERVER_ABORT;
wsrep_srv_conc_cancel_wait(victim_trx);
DBUG_RETURN(rcode);
} else {
diff --git a/storage/xtradb/include/trx0trx.h b/storage/xtradb/include/trx0trx.h
index 77afde4c35c..fb3df1bd81b 100644
--- a/storage/xtradb/include/trx0trx.h
+++ b/storage/xtradb/include/trx0trx.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2015, 2018, MariaDB Corporation.
+Copyright (c) 2015, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -673,6 +673,12 @@ struct trx_lock_t {
only be modified by the thread that is
serving the running transaction. */
+#ifdef WITH_WSREP
+ bool was_chosen_as_wsrep_victim;
+ /*!< high priority wsrep thread has
+ marked this trx to abort */
+#endif /* WITH_WSREP */
+
mem_heap_t* lock_heap; /*!< memory heap for trx_locks;
protected by lock_sys->mutex */
@@ -746,9 +752,6 @@ lock_sys->mutex and sometimes by trx->mutex. */
enum trx_abort_t {
TRX_SERVER_ABORT = 0,
-#ifdef WITH_WSREP
- TRX_WSREP_ABORT,
-#endif
TRX_REPLICATION_ABORT
};
diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc
index 2183d281b78..4c32295f103 100644
--- a/storage/xtradb/lock/lock0lock.cc
+++ b/storage/xtradb/lock/lock0lock.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2014, 2018, MariaDB Corporation.
+Copyright (c) 2014, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -1804,10 +1804,8 @@ wsrep_kill_victim(
}
}
- lock->trx->abort_type = TRX_WSREP_ABORT;
wsrep_innobase_kill_one_trx(trx->mysql_thd,
(const trx_t*) trx, lock->trx, TRUE);
- lock->trx->abort_type = TRX_SERVER_ABORT;
}
}
}
@@ -8077,16 +8075,7 @@ lock_trx_release_locks(
lock_mutex_exit();
}
-/*********************************************************************//**
-Check whether the transaction has already been rolled back because it
-was selected as a deadlock victim, or if it has to wait then cancel
-the wait lock.
-@return DB_DEADLOCK, DB_LOCK_WAIT or DB_SUCCESS */
-UNIV_INTERN
-dberr_t
-lock_trx_handle_wait(
-/*=================*/
- trx_t* trx) /*!< in/out: trx lock state */
+static inline dberr_t lock_trx_handle_wait_low(trx_t* trx)
{
ut_ad(lock_mutex_own());
ut_ad(trx_mutex_own(trx));
@@ -8103,6 +8092,35 @@ lock_trx_handle_wait(
return DB_LOCK_WAIT;
}
+/*********************************************************************//**
+Check whether the transaction has already been rolled back because it
+was selected as a deadlock victim, or if it has to wait then cancel
+the wait lock.
+@return DB_DEADLOCK, DB_LOCK_WAIT or DB_SUCCESS */
+UNIV_INTERN
+dberr_t
+lock_trx_handle_wait(
+/*=================*/
+ trx_t* trx) /*!< in/out: trx lock state */
+{
+#ifdef WITH_WSREP
+ /* We already own mutexes */
+ if (trx->lock.was_chosen_as_wsrep_victim) {
+ return lock_trx_handle_wait_low(trx);
+ }
+#endif /* WITH_WSREP */
+ if (trx->abort_type != TRX_REPLICATION_ABORT) {
+ lock_mutex_enter();
+ }
+ trx_mutex_enter(trx);
+ dberr_t err = lock_trx_handle_wait_low(trx);
+ if (trx->abort_type != TRX_REPLICATION_ABORT) {
+ lock_mutex_exit();
+ }
+ trx_mutex_exit(trx);
+ return err;
+}
+
/*********************************************************************//**
Get the number of locks on a table.
@return number of locks */
diff --git a/storage/xtradb/row/row0sel.cc b/storage/xtradb/row/row0sel.cc
index b6b5d107885..87bc2aa2875 100644
--- a/storage/xtradb/row/row0sel.cc
+++ b/storage/xtradb/row/row0sel.cc
@@ -4755,11 +4755,7 @@ row_search_for_mysql(
a deadlock and the transaction had to wait then
release the lock it is waiting on. */
- lock_mutex_enter();
- trx_mutex_enter(trx);
err = lock_trx_handle_wait(trx);
- lock_mutex_exit();
- trx_mutex_exit(trx);
switch (err) {
case DB_SUCCESS:
diff --git a/storage/xtradb/trx/trx0roll.cc b/storage/xtradb/trx/trx0roll.cc
index 56b7120fa34..5e60725b9be 100644
--- a/storage/xtradb/trx/trx0roll.cc
+++ b/storage/xtradb/trx/trx0roll.cc
@@ -375,12 +375,8 @@ trx_rollback_to_savepoint_for_mysql_low(
trx_mark_sql_stat_end(trx);
trx->op_info = "";
-
#ifdef WITH_WSREP
- if (wsrep_on(trx->mysql_thd) &&
- trx->lock.was_chosen_as_deadlock_victim) {
- trx->lock.was_chosen_as_deadlock_victim = FALSE;
- }
+ trx->lock.was_chosen_as_wsrep_victim = FALSE;
#endif
return(err);
diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc
index 17cba81daf3..a3df14aeab0 100644
--- a/storage/xtradb/trx/trx0trx.cc
+++ b/storage/xtradb/trx/trx0trx.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2015, 2018, MariaDB Corporation.
+Copyright (c) 2015, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -1563,12 +1563,10 @@ trx_commit_in_memory(
ut_ad(!trx->in_ro_trx_list);
ut_ad(!trx->in_rw_trx_list);
+ trx->dict_operation = TRX_DICT_OP_NONE;
#ifdef WITH_WSREP
- if (trx->mysql_thd && wsrep_on(trx->mysql_thd)) {
- trx->lock.was_chosen_as_deadlock_victim = FALSE;
- }
+ trx->lock.was_chosen_as_wsrep_victim = FALSE;
#endif
- trx->dict_operation = TRX_DICT_OP_NONE;
trx->error_state = DB_SUCCESS;
1
0
[Commits] f53e795: MDEV-17599 ALTER TABLE DROP CONSTRAINT does not work for foreign keys.
by holyfoot@askmonty.org 05 Feb '19
by holyfoot@askmonty.org 05 Feb '19
05 Feb '19
revision-id: f53e795250133a622eb1c00271c073726ae3c7fc (mariadb-10.2.21-65-gf53e795)
parent(s): 227379988eac3c9ce7be626477f4d138dc34579d
committer: Alexey Botchkov
timestamp: 2019-02-05 11:24:19 +0400
message:
MDEV-17599 ALTER TABLE DROP CONSTRAINT does not work for foreign keys.
The list of table constraints doesn't include foreign keys and uniques.
So we replace DROP CONSTRAINT with DROP [FOREIGN] KEY in this case.
---
mysql-test/r/alter_table.result | 49 ++++++++++++++++++++++++++++++++++
mysql-test/t/alter_table.test | 17 ++++++++++++
sql/sql_table.cc | 58 +++++++++++++++++++++++++++++++++++++++++
sql/sql_yacc.yy | 9 +++++--
4 files changed, 131 insertions(+), 2 deletions(-)
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result
index dcee72e..f243d24 100644
--- a/mysql-test/r/alter_table.result
+++ b/mysql-test/r/alter_table.result
@@ -2456,5 +2456,54 @@ ERROR 23000: Duplicate entry '1' for key 'i'
UNLOCK TABLES;
DROP TABLE t1;
#
+# MDEV-17599 ALTER TABLE DROP CONSTRAINT does not work for foreign keys.
+#
+CREATE TABLE t1(id INT PRIMARY KEY, c1 INT) ENGINE= INNODB;
+CREATE TABLE t2(id INT PRIMARY KEY, c1 INT, c2 INT NOT NULL,
+CONSTRAINT sid FOREIGN KEY (`c1`) REFERENCES t1 (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
+CONSTRAINT UNIQUE `ui`(c2)) ENGINE= INNODB;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `id` int(11) NOT NULL,
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `ui` (`c2`),
+ KEY `sid` (`c1`),
+ CONSTRAINT `sid` FOREIGN KEY (`c1`) REFERENCES `t1` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+ALTER TABLE t2 DROP CONSTRAINT sid;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `id` int(11) NOT NULL,
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `ui` (`c2`),
+ KEY `sid` (`c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+ALTER TABLE t2 DROP CONSTRAINT ui;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `id` int(11) NOT NULL,
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY `sid` (`c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+ALTER TABLE t2 DROP CONSTRAINT PRIMARY KEY;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `id` int(11) NOT NULL,
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) NOT NULL,
+ KEY `sid` (`c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t2, t1;
+#
# End of 10.2 tests
#
diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test
index df077c8..e6caadc 100644
--- a/mysql-test/t/alter_table.test
+++ b/mysql-test/t/alter_table.test
@@ -2013,5 +2013,22 @@ DROP TABLE t1;
--echo #
+--echo # MDEV-17599 ALTER TABLE DROP CONSTRAINT does not work for foreign keys.
+--echo #
+
+CREATE TABLE t1(id INT PRIMARY KEY, c1 INT) ENGINE= INNODB;
+CREATE TABLE t2(id INT PRIMARY KEY, c1 INT, c2 INT NOT NULL,
+ CONSTRAINT sid FOREIGN KEY (`c1`) REFERENCES t1 (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
+ CONSTRAINT UNIQUE `ui`(c2)) ENGINE= INNODB;
+SHOW CREATE TABLE t2;
+ALTER TABLE t2 DROP CONSTRAINT sid;
+SHOW CREATE TABLE t2;
+ALTER TABLE t2 DROP CONSTRAINT ui;
+SHOW CREATE TABLE t2;
+ALTER TABLE t2 DROP CONSTRAINT PRIMARY KEY;
+SHOW CREATE TABLE t2;
+DROP TABLE t2, t1;
+
+--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index f27b610..1227f14 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -8979,6 +8979,64 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
THD_STAGE_INFO(thd, stage_setup);
+ if (alter_info->flags & Alter_info::ALTER_DROP_CHECK_CONSTRAINT)
+ {
+ /*
+ ALTER TABLE DROP CONSTRAINT
+ should be replaced with ... DROP [FOREIGN] KEY
+ if the constraint is the FOREIGN KEY or UNIQUE one.
+ */
+
+ List_iterator<Alter_drop> drop_it(alter_info->drop_list);
+ Alter_drop *drop;
+ List <FOREIGN_KEY_INFO> fk_child_key_list;
+ table->file->get_foreign_key_list(thd, &fk_child_key_list);
+
+ alter_info->flags&= ~Alter_info::ALTER_DROP_CHECK_CONSTRAINT;
+
+ while ((drop= drop_it++))
+ {
+ if (drop->type == Alter_drop::CHECK_CONSTRAINT)
+ {
+ {
+ /* Test if there is a FOREIGN KEY with this name. */
+ FOREIGN_KEY_INFO *f_key;
+ List_iterator<FOREIGN_KEY_INFO> fk_key_it(fk_child_key_list);
+
+ while ((f_key= fk_key_it++))
+ {
+ if (my_strcasecmp(system_charset_info, f_key->foreign_id->str,
+ drop->name) == 0)
+ {
+ drop->type= Alter_drop::FOREIGN_KEY;
+ alter_info->flags|= Alter_info::DROP_FOREIGN_KEY;
+ goto do_continue;
+ }
+ }
+ }
+
+ {
+ /* Test if there is an UNIQUE with this name. */
+ uint n_key;
+
+ for (n_key=0; n_key < table->s->keys; n_key++)
+ {
+ if ((table->key_info[n_key].flags & HA_NOSAME) &&
+ my_strcasecmp(system_charset_info,
+ drop->name, table->key_info[n_key].name) == 0)
+ {
+ drop->type= Alter_drop::KEY;
+ alter_info->flags|= Alter_info::ALTER_DROP_INDEX;
+ goto do_continue;
+ }
+ }
+ }
+ }
+ alter_info->flags|= Alter_info::ALTER_DROP_CHECK_CONSTRAINT;
+do_continue:;
+ }
+ }
+
handle_if_exists_options(thd, table, alter_info);
/*
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 480c2e9..14d084e 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1741,7 +1741,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
IDENT_sys TEXT_STRING_sys TEXT_STRING_literal
NCHAR_STRING opt_component key_cache_name
sp_opt_label BIN_NUM label_ident TEXT_STRING_filesystem ident_or_empty
- opt_constraint constraint opt_ident ident_table_alias
+ opt_constraint opt_constraint_no_id constraint opt_ident ident_table_alias
%type <lex_str_ptr>
opt_table_alias
@@ -6123,6 +6123,11 @@ check_constraint:
}
;
+opt_constraint_no_id:
+ /* Empty */ {}
+ | CONSTRAINT {}
+ ;
+
opt_constraint:
/* empty */ { $$= null_lex_str; }
| constraint { $$= $1; }
@@ -7653,7 +7658,7 @@ alter_list_item:
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
lex->alter_info.flags|= Alter_info::DROP_FOREIGN_KEY;
}
- | DROP PRIMARY_SYM KEY_SYM
+ | DROP opt_constraint_no_id PRIMARY_SYM KEY_SYM
{
LEX *lex=Lex;
Alter_drop *ad= (new (thd->mem_root)
1
0
05 Feb '19
revision-id: 33907360f56789cd9b467b40e66412eb0a0aff28 (mariadb-10.3.6-101-g3390736)
parent(s): 07b7b2e4efb82a50e4575c309bf6987975c4607f
author: Igor Babaev
committer: Igor Babaev
timestamp: 2019-02-04 22:44:33 -0800
message:
MDEV-16188 Post-merge corrections and adjustments
---
mysql-test/include/gis_keys.inc | 4 +-
mysql-test/main/gis.result | 10 +-
mysql-test/suite/gcol/inc/gcol_select.inc | 2 +-
mysql-test/suite/gcol/r/gcol_keys_myisam.result | 2 +-
mysql-test/suite/gcol/r/gcol_select_innodb.result | 16 +--
mysql-test/suite/gcol/r/gcol_select_myisam.result | 38 ++---
mysql-test/suite/heap/heap.result | 2 +-
mysql-test/suite/heap/heap_btree.result | 20 +--
mysql-test/suite/heap/heap_hash.result | 8 +-
mysql-test/suite/innodb/r/innodb-isolation.result | 6 +-
mysql-test/suite/innodb/r/innodb_gis.result | 10 +-
.../innodb/r/innodb_skip_innodb_is_tables.result | 3 +
mysql-test/suite/innodb/r/mdev-117.result | 2 +
mysql-test/suite/innodb/r/monitor.result | 15 +-
mysql-test/suite/innodb_gis/r/0.result | 10 +-
mysql-test/suite/innodb_gis/r/1.result | 10 +-
mysql-test/suite/innodb_gis/r/gis.result | 10 +-
.../suite/innodb_gis/r/rtree_estimate.result | 6 +-
mysql-test/suite/innodb_gis/t/rtree_estimate.test | 1 +
mysql-test/suite/maria/icp.result | 16 ++-
mysql-test/suite/maria/ps_maria.result | 2 +-
mysql-test/suite/parts/r/optimizer.result | 4 +-
.../sys_vars/r/sysvars_server_embedded.result | 22 ++-
.../sys_vars/r/sysvars_server_notembedded.result | 2 +-
mysql-test/suite/vcol/inc/vcol_select.inc | 2 +-
mysql-test/suite/vcol/r/vcol_select_innodb.result | 16 +--
mysql-test/suite/vcol/r/vcol_select_myisam.result | 32 ++---
sql/sys_vars.cc | 2 +-
.../mysql-test/connect/r/mysql_index.result | 156 ++++++++++-----------
.../connect/mysql-test/connect/r/part_file.result | 9 +-
.../connect/mysql-test/connect/t/mysql_index.test | 4 +-
.../connect/mysql-test/connect/t/part_file.test | 4 +-
storage/innobase/srv/srv0mon.cc | 2 +-
storage/myisam/mi_range.c | 6 +-
34 files changed, 242 insertions(+), 212 deletions(-)
diff --git a/mysql-test/include/gis_keys.inc b/mysql-test/include/gis_keys.inc
index cc8ec68..388c7b4 100644
--- a/mysql-test/include/gis_keys.inc
+++ b/mysql-test/include/gis_keys.inc
@@ -27,8 +27,8 @@ SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
# the "most rows covered" rule doesn't kick in anymore
# now EXPLAIN shows the index used on the table
# and we're getting the wrong result again
-INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)'));
-INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)'));
+INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(3 4)'));
+INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(3 4)'));
EXPLAIN
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
diff --git a/mysql-test/main/gis.result b/mysql-test/main/gis.result
index 7695cef..1919555 100644
--- a/mysql-test/main/gis.result
+++ b/mysql-test/main/gis.result
@@ -964,29 +964,29 @@ id select_type table type possible_keys key key_len ref rows Extra
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
1
-INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)'));
-INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)'));
+INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(3 4)'));
+INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(3 4)'));
EXPLAIN
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
-2
+1
EXPLAIN
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref p p 28 const # Using where
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
-2
+1
EXPLAIN
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
-2
+1
DROP TABLE t1, t2;
End of 5.0 tests
#
diff --git a/mysql-test/suite/gcol/inc/gcol_select.inc b/mysql-test/suite/gcol/inc/gcol_select.inc
index efaffd5..7dcbcc7 100644
--- a/mysql-test/suite/gcol/inc/gcol_select.inc
+++ b/mysql-test/suite/gcol/inc/gcol_select.inc
@@ -35,7 +35,7 @@ insert into t2 (a) values (1);
create table t3 (a int primary key,
b int generated always as (-a) virtual,
c int generated always as (-a) stored unique);
-insert into t3 (a) values (2),(1),(3);
+insert into t3 (a) values (2),(1),(3),(5),(4),(7);
analyze table t1,t2,t3;
--echo # select_type=SIMPLE, type=system
diff --git a/mysql-test/suite/gcol/r/gcol_keys_myisam.result b/mysql-test/suite/gcol/r/gcol_keys_myisam.result
index 8ef6736..91bd8fc 100644
--- a/mysql-test/suite/gcol/r/gcol_keys_myisam.result
+++ b/mysql-test/suite/gcol/r/gcol_keys_myisam.result
@@ -205,7 +205,7 @@ outr.col_varchar_nokey in ('c', 'x', 'i')
AND (outr.col_time_key IS NULL OR
outr.col_datetime_key = '2009-09-27');
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE outr ALL col_time_key,col_datetime_key NULL NULL NULL 4 x
+1 SIMPLE outr index_merge col_time_key,col_datetime_key col_time_key,col_datetime_key 4,6 NULL 2 x
SELECT
outr.col_time_key AS x
FROM c AS outr
diff --git a/mysql-test/suite/gcol/r/gcol_select_innodb.result b/mysql-test/suite/gcol/r/gcol_select_innodb.result
index 983e1fb..8288588 100644
--- a/mysql-test/suite/gcol/r/gcol_select_innodb.result
+++ b/mysql-test/suite/gcol/r/gcol_select_innodb.result
@@ -17,7 +17,7 @@ insert into t2 (a) values (1);
create table t3 (a int primary key,
b int generated always as (-a) virtual,
c int generated always as (-a) stored unique);
-insert into t3 (a) values (2),(1),(3);
+insert into t3 (a) values (2),(1),(3),(5),(4),(7);
analyze table t1,t2,t3;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
@@ -79,8 +79,8 @@ a b c
3 -3 -3
explain select * from t1 where b in (select c from t3);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 index c c 5 NULL 3 Using index
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
+1 PRIMARY t3 ref c c 5 test.t1.b 1 Using index
# select_type=PRIMARY, type=range,ref
select * from t1 where c in (select c from t3 where c between -2 and -1);
a b c
@@ -89,7 +89,7 @@ a b c
2 -2 -2
explain select * from t1 where c in (select c from t3 where c between -2 and -1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 index c c 5 NULL 3 Using where; Using index
+1 PRIMARY t3 index c c 5 NULL 6 Using where; Using index
1 PRIMARY t1 ALL c NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
# select_type=UNION, type=system
# select_type=UNION RESULT, type=<union1,2>
@@ -173,7 +173,7 @@ a b c
2 -2 -2
explain select * from t3 where b between -2 and -1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where
# SELECT * FROM tbl_name WHERE <indexed gcol expr>
select * from t3 where c between -2 and -1;
a b c
@@ -236,7 +236,7 @@ a b c
2 -2 -2
explain select * from t3 where b between -2 and -1 order by a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 index NULL PRIMARY 4 NULL 3 Using where
+1 SIMPLE t3 index NULL PRIMARY 4 NULL 6 Using where
# SELECT * FROM tbl_name WHERE <non-indexed gcol expr> ORDER BY <non-indexed gcol>
select * from t3 where b between -2 and -1 order by b;
a b c
@@ -244,7 +244,7 @@ a b c
1 -1 -1
explain select * from t3 where b between -2 and -1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
+1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where; Using filesort
# SELECT * FROM tbl_name WHERE <indexed gcol expr> ORDER BY <non-indexed gcol>
select * from t3 where c between -2 and -1 order by b;
a b c
@@ -260,7 +260,7 @@ a b c
1 -1 -1
explain select * from t3 where b between -2 and -1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
+1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where; Using filesort
# SELECT * FROM tbl_name WHERE <indexed gcol expr> ORDER BY <indexed gcol>
select * from t3 where c between -2 and -1 order by c;
a b c
diff --git a/mysql-test/suite/gcol/r/gcol_select_myisam.result b/mysql-test/suite/gcol/r/gcol_select_myisam.result
index e823458..039484b 100644
--- a/mysql-test/suite/gcol/r/gcol_select_myisam.result
+++ b/mysql-test/suite/gcol/r/gcol_select_myisam.result
@@ -17,7 +17,7 @@ insert into t2 (a) values (1);
create table t3 (a int primary key,
b int generated always as (-a) virtual,
c int generated always as (-a) stored unique);
-insert into t3 (a) values (2),(1),(3);
+insert into t3 (a) values (2),(1),(3),(5),(4),(7);
analyze table t1,t2,t3;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
@@ -60,7 +60,7 @@ a b c
1 -1 -1
explain select * from t3 where c>=-1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range c c 5 NULL 2 Using index condition
+1 SIMPLE t3 range c c 5 NULL 1 Using index condition
# select_type=SIMPLE, type=ref
select * from t1,t3 where t1.c=t3.c and t3.c=-1;
a b c a b c
@@ -79,8 +79,8 @@ a b c
3 -3 -3
explain select * from t1 where b in (select c from t3);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 index c c 5 NULL 3 Using index
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
+1 PRIMARY t3 ref c c 5 test.t1.b 1 Using index
# select_type=PRIMARY, type=range,ref
select * from t1 where c in (select c from t3 where c between -2 and -1);
a b c
@@ -89,7 +89,7 @@ a b c
2 -2 -2
explain select * from t1 where c in (select c from t3 where c between -2 and -1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 index c c 5 NULL 3 Using where; Using index
+1 PRIMARY t3 index c c 5 NULL 6 Using where; Using index
1 PRIMARY t1 ref c c 5 test.t3.c 1
# select_type=UNION, type=system
# select_type=UNION RESULT, type=<union1,2>
@@ -165,7 +165,7 @@ a b c
2 -2 -2
explain select * from t3 where a between 1 and 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using index condition
+1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 2 Using index condition
# SELECT * FROM tbl_name WHERE <non-indexed gcol expr>
select * from t3 where b between -2 and -1;
a b c
@@ -173,7 +173,7 @@ a b c
2 -2 -2
explain select * from t3 where b between -2 and -1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where
# SELECT * FROM tbl_name WHERE <indexed gcol expr>
select * from t3 where c between -2 and -1;
a b c
@@ -181,7 +181,7 @@ a b c
2 -2 -2
explain select * from t3 where c between -2 and -1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range c c 5 NULL 1 Using index condition
+1 SIMPLE t3 range c c 5 NULL 2 Using index condition
# bug#20022189: WL411:DEBUG ASSERT AT FIELD_LONG::VAL_INT IN SQL/FIELD.CC
CREATE TABLE t4 (
`pk` int(11) NOT NULL ,
@@ -211,7 +211,7 @@ a b c
1 -1 -1
explain select * from t3 where a between 1 and 2 order by c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Using filesort
+1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using filesort
# SELECT * FROM tbl_name WHERE <non-indexed gcol expr> ORDER BY <non-gcol>
select * from t3 where b between -2 and -1 order by a;
a b c
@@ -219,7 +219,7 @@ a b c
2 -2 -2
explain select * from t3 where b between -2 and -1 order by a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
+1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where; Using filesort
# SELECT * FROM tbl_name WHERE <indexed gcol expr> ORDER BY <non-gcol>
select * from t3 where c between -2 and -1 order by a;
a b c
@@ -227,7 +227,7 @@ a b c
2 -2 -2
explain select * from t3 where c between -2 and -1 order by a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using filesort
+1 SIMPLE t3 range c c 5 NULL 2 Using index condition; Using filesort
# SELECT * FROM tbl_name WHERE <non-indexed gcol expr> ORDER BY <non-indexed gcol>
select * from t3 where b between -2 and -1 order by b;
a b c
@@ -235,7 +235,7 @@ a b c
1 -1 -1
explain select * from t3 where b between -2 and -1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
+1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where; Using filesort
# SELECT * FROM tbl_name WHERE <indexed gcol expr> ORDER BY <non-indexed gcol>
select * from t3 where c between -2 and -1 order by b;
a b c
@@ -243,7 +243,7 @@ a b c
1 -1 -1
explain select * from t3 where c between -2 and -1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using filesort
+1 SIMPLE t3 range c c 5 NULL 2 Using index condition; Using filesort
# SELECT * FROM tbl_name WHERE <non-indexed gcol expr> ORDER BY <indexed gcol>
select * from t3 where b between -2 and -1 order by c;
a b c
@@ -251,7 +251,7 @@ a b c
1 -1 -1
explain select * from t3 where b between -2 and -1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
+1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where; Using filesort
# SELECT * FROM tbl_name WHERE <indexed gcol expr> ORDER BY <indexed gcol>
select * from t3 where c between -2 and -1 order by c;
a b c
@@ -259,7 +259,7 @@ a b c
1 -1 -1
explain select * from t3 where c between -2 and -1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range c c 5 NULL 1 Using index condition
+1 SIMPLE t3 range c c 5 NULL 2 Using index condition
# SELECT sum(<non-indexed gcol>) FROM tbl_name GROUP BY <non-indexed gcol>
select sum(b) from t1 group by b;
sum(b)
@@ -794,15 +794,15 @@ KEY (col_int_key)
INSERT INTO cc (col_int_nokey) VALUES (0),(1),(7),(0),(4),(5);
EXPLAIN SELECT pk FROM cc WHERE col_int_key > 3;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE cc ALL col_int_key NULL NULL NULL 6 #
+1 SIMPLE cc range col_int_key col_int_key 5 NULL 3 #
SELECT pk FROM cc WHERE col_int_key > 3;
pk
-3
5
6
+3
EXPLAIN SELECT pk FROM cc WHERE col_int_key > 3 ORDER BY 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE cc ALL col_int_key NULL NULL NULL 6 #
+1 SIMPLE cc range col_int_key col_int_key 5 NULL 3 #
SELECT pk FROM cc WHERE col_int_key > 3 ORDER BY 1;
pk
3
@@ -1211,7 +1211,7 @@ FROM t0 AS a0, t0 AS a1, t0 AS a2;
EXPLAIN SELECT * FROM t1
WHERE i1 > 41 AND i1 <= 43;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx idx 4 NULL 19 Using index condition
+1 SIMPLE t1 range idx idx 4 NULL 20 Using index condition
SELECT * FROM t1
WHERE i1 > 41 AND i1 <= 43;
pk i1 i2 v1 v2
diff --git a/mysql-test/suite/heap/heap.result b/mysql-test/suite/heap/heap.result
index 320966d..326142a 100644
--- a/mysql-test/suite/heap/heap.result
+++ b/mysql-test/suite/heap/heap.result
@@ -66,7 +66,7 @@ a
alter table t1 engine=myisam;
explain select * from t1 where a in (869751,736494,226312,802616);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
+1 SIMPLE t1 index uniq_id uniq_id 4 NULL 5 Using where; Using index
drop table t1;
create table t1 (x int not null, y int not null, key x (x), unique y (y))
engine=heap;
diff --git a/mysql-test/suite/heap/heap_btree.result b/mysql-test/suite/heap/heap_btree.result
index 83d1bcb..28292d9 100644
--- a/mysql-test/suite/heap/heap_btree.result
+++ b/mysql-test/suite/heap/heap_btree.result
@@ -48,8 +48,8 @@ a
alter table t1 add unique uniq_id using BTREE (a);
select * from t1 where a > 736494;
a
-802616
869751
+802616
select * from t1 where a = 736494;
a
736494
@@ -59,14 +59,14 @@ a
869751
select * from t1 where a in (869751,736494,226312,802616);
a
-226312
+869751
736494
+226312
802616
-869751
alter table t1 engine=myisam;
explain select * from t1 where a in (869751,736494,226312,802616);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
+1 SIMPLE t1 index uniq_id uniq_id 4 NULL 5 Using where; Using index
drop table t1;
create table t1 (x int not null, y int not null, key x using BTREE (x,y), unique y using BTREE (y))
engine=heap;
@@ -178,7 +178,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range btn btn 10 NULL 1 Using where
explain select * from t1 where btn like "h%";
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range btn btn 10 NULL # Using where
+1 SIMPLE t1 ALL btn NULL NULL NULL # Using where
explain select * from t1 where btn like "a%";
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range btn btn 10 NULL 1 Using where
@@ -350,11 +350,11 @@ insert into t1 values (869751),(736494),(226312),(802616),(728912);
alter table t1 add unique uniq_id using BTREE (a);
select 0+a from t1 where a > 736494;
0+a
-802616
869751
+802616
explain select 0+a from t1 where a > 736494;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range uniq_id uniq_id 8 NULL 3 Using where
+1 SIMPLE t1 ALL uniq_id NULL NULL NULL 5 Using where
select 0+a from t1 where a = 736494;
0+a
736494
@@ -370,13 +370,13 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uniq_id uniq_id 8 NULL 2 Using where
select 0+a from t1 where a in (869751,736494,226312,802616);
0+a
-226312
+869751
736494
+226312
802616
-869751
explain select 0+a from t1 where a in (869751,736494,226312,802616);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range uniq_id uniq_id 8 NULL 4 Using where
+1 SIMPLE t1 ALL uniq_id NULL NULL NULL 5 Using where
drop table t1;
End of 5.3 tests
create table t1 (id int, a varchar(300) not null, key using btree(a)) engine=heap;
diff --git a/mysql-test/suite/heap/heap_hash.result b/mysql-test/suite/heap/heap_hash.result
index 55d4358..4f96827 100644
--- a/mysql-test/suite/heap/heap_hash.result
+++ b/mysql-test/suite/heap/heap_hash.result
@@ -66,7 +66,7 @@ a
alter table t1 engine=myisam;
explain select * from t1 where a in (869751,736494,226312,802616);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
+1 SIMPLE t1 index uniq_id uniq_id 4 NULL 5 Using where; Using index
drop table t1;
create table t1 (x int not null, y int not null, key x using HASH (x), unique y using HASH (y))
engine=heap;
@@ -428,13 +428,13 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uniq_id uniq_id 8 NULL 2 Using where
select 0+a from t1 where a in (869751,736494,226312,802616);
0+a
-226312
+869751
736494
+226312
802616
-869751
explain select 0+a from t1 where a in (869751,736494,226312,802616);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range uniq_id uniq_id 8 NULL 4 Using where
+1 SIMPLE t1 ALL uniq_id NULL NULL NULL 5 Using where
drop table t1;
End of 5.3 tests
#
diff --git a/mysql-test/suite/innodb/r/innodb-isolation.result b/mysql-test/suite/innodb/r/innodb-isolation.result
index ce9c530..a308f10 100644
--- a/mysql-test/suite/innodb/r/innodb-isolation.result
+++ b/mysql-test/suite/innodb/r/innodb-isolation.result
@@ -963,15 +963,15 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 12 #
EXPLAIN SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 8 #
+1 PRIMARY t1 index PRIMARY k2 5 NULL 12 #
2 SUBQUERY t1 index NULL k2 5 NULL 12 #
EXPLAIN SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 8 #
+1 PRIMARY t1 index PRIMARY k2 5 NULL 12 #
2 SUBQUERY t1 index NULL k2 5 NULL 12 #
EXPLAIN SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 7 #
+1 PRIMARY t1 index PRIMARY k2 5 NULL 12 #
2 SUBQUERY t1 index NULL k2 5 NULL 12 #
#
# Make all indexes in t2 obsolete to the active repeatable read transaction
diff --git a/mysql-test/suite/innodb/r/innodb_gis.result b/mysql-test/suite/innodb/r/innodb_gis.result
index f8b02bb..162219c 100644
--- a/mysql-test/suite/innodb/r/innodb_gis.result
+++ b/mysql-test/suite/innodb/r/innodb_gis.result
@@ -560,29 +560,29 @@ id select_type table type possible_keys key key_len ref rows Extra
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
1
-INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)'));
-INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)'));
+INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(3 4)'));
+INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(3 4)'));
EXPLAIN
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
-2
+1
EXPLAIN
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref p p 28 const # Using where
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
-2
+1
EXPLAIN
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
-2
+1
DROP TABLE t1, t2;
End of 5.0 tests
#
diff --git a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result
index a90cd22..8640783 100644
--- a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result
+++ b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result
@@ -286,6 +286,9 @@ icp_attempts icp 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL disabled
icp_no_match icp 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL disabled counter Index push-down condition does not match
icp_out_of_range icp 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL disabled counter Index push-down condition out of range
icp_match icp 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL disabled counter Index push-down condition matches
+pk-filter checks pk-filter 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL disabled counter Number of lookups into PK-filters
+pk-filter_positive pk-filter 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL disabled counter PK-filter test is positive
+pk-filter_negative pk-filter 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL disabled counter PK-filter test is negative
select * from information_schema.innodb_ft_default_stopword;
value
a
diff --git a/mysql-test/suite/innodb/r/mdev-117.result b/mysql-test/suite/innodb/r/mdev-117.result
index 979f1ae..39a1fc5 100644
--- a/mysql-test/suite/innodb/r/mdev-117.result
+++ b/mysql-test/suite/innodb/r/mdev-117.result
@@ -12,6 +12,8 @@ DELETE IGNORE FROM t1;;
connection con1;
DELETE FROM t1 WHERE col_int_key IN (1, 40000000);
connection default;
+Warnings:
+Warning 1205 Lock wait timeout exceeded; try restarting transaction
disconnect con1;
drop table t1;
SET GLOBAL innodb_lock_wait_timeout=default;
diff --git a/mysql-test/suite/innodb/r/monitor.result b/mysql-test/suite/innodb/r/monitor.result
index 4a72a37..a160eb5 100644
--- a/mysql-test/suite/innodb/r/monitor.result
+++ b/mysql-test/suite/innodb/r/monitor.result
@@ -251,6 +251,9 @@ icp_attempts disabled
icp_no_match disabled
icp_out_of_range disabled
icp_match disabled
+pk-filter checks disabled
+pk-filter_positive disabled
+pk-filter_negative disabled
set global innodb_monitor_enable = all;
select name from information_schema.innodb_metrics where status!='enabled';
name
@@ -461,7 +464,7 @@ max_count_reset, min_count_reset, count_reset, status
from information_schema.innodb_metrics
where name like "dml%";
name max_count min_count count max_count_reset min_count_reset count_reset status
-dml_reads 4 NULL 4 4 NULL 4 enabled
+dml_reads 2 NULL 2 2 NULL 2 enabled
dml_inserts 1 NULL 1 1 NULL 1 enabled
dml_deletes 0 NULL 0 0 NULL 0 enabled
dml_updates 2 NULL 2 2 NULL 2 enabled
@@ -475,7 +478,7 @@ max_count_reset, min_count_reset, count_reset, status
from information_schema.innodb_metrics
where name like "dml%";
name max_count min_count count max_count_reset min_count_reset count_reset status
-dml_reads 6 NULL 6 6 NULL 6 enabled
+dml_reads 4 NULL 4 4 NULL 4 enabled
dml_inserts 1 NULL 1 1 NULL 1 enabled
dml_deletes 2 NULL 2 2 NULL 2 enabled
dml_updates 2 NULL 2 2 NULL 2 enabled
@@ -489,7 +492,7 @@ max_count_reset, min_count_reset, count_reset, status
from information_schema.innodb_metrics
where name like "dml%";
name max_count min_count count max_count_reset min_count_reset count_reset status
-dml_reads 6 NULL 6 0 NULL 0 enabled
+dml_reads 4 NULL 4 0 NULL 0 enabled
dml_inserts 1 NULL 1 0 NULL 0 enabled
dml_deletes 2 NULL 2 0 NULL 0 enabled
dml_updates 2 NULL 2 0 NULL 0 enabled
@@ -505,7 +508,7 @@ max_count_reset, min_count_reset, count_reset, status
from information_schema.innodb_metrics
where name like "dml%";
name max_count min_count count max_count_reset min_count_reset count_reset status
-dml_reads 8 NULL 8 2 NULL 2 enabled
+dml_reads 6 NULL 6 2 NULL 2 enabled
dml_inserts 3 NULL 3 2 NULL 2 enabled
dml_deletes 4 NULL 4 2 NULL 2 enabled
dml_updates 2 NULL 2 0 NULL 0 enabled
@@ -519,7 +522,7 @@ max_count_reset, min_count_reset, count_reset, status
from information_schema.innodb_metrics
where name like "dml%";
name max_count min_count count max_count_reset min_count_reset count_reset status
-dml_reads 8 NULL 8 2 NULL 2 enabled
+dml_reads 6 NULL 6 2 NULL 2 enabled
dml_inserts 3 NULL 3 2 NULL 2 enabled
dml_deletes 4 NULL 4 2 NULL 2 enabled
dml_updates 2 NULL 2 0 NULL 0 enabled
@@ -533,7 +536,7 @@ max_count_reset, min_count_reset, count_reset, status
from information_schema.innodb_metrics
where name like "dml%";
name max_count min_count count max_count_reset min_count_reset count_reset status
-dml_reads 8 NULL 8 2 NULL 2 disabled
+dml_reads 6 NULL 6 2 NULL 2 disabled
dml_inserts 3 NULL 3 2 NULL 2 disabled
dml_deletes 4 NULL 4 2 NULL 2 disabled
dml_updates 2 NULL 2 0 NULL 0 disabled
diff --git a/mysql-test/suite/innodb_gis/r/0.result b/mysql-test/suite/innodb_gis/r/0.result
index ffe4230..6dd2cd1 100644
--- a/mysql-test/suite/innodb_gis/r/0.result
+++ b/mysql-test/suite/innodb_gis/r/0.result
@@ -560,29 +560,29 @@ id select_type table type possible_keys key key_len ref rows Extra
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
1
-INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)'));
-INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)'));
+INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(3 4)'));
+INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(3 4)'));
EXPLAIN
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
-2
+1
EXPLAIN
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref p p 28 const # Using where
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
-2
+1
EXPLAIN
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
-2
+1
DROP TABLE t1, t2;
End of 5.0 tests
#
diff --git a/mysql-test/suite/innodb_gis/r/1.result b/mysql-test/suite/innodb_gis/r/1.result
index 84e7bec..8de9fd3 100644
--- a/mysql-test/suite/innodb_gis/r/1.result
+++ b/mysql-test/suite/innodb_gis/r/1.result
@@ -943,29 +943,29 @@ id select_type table type possible_keys key key_len ref rows Extra
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
1
-INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)'));
-INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)'));
+INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(3 4)'));
+INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(3 4)'));
EXPLAIN
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
-2
+1
EXPLAIN
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref p p 28 const # Using where
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
-2
+1
EXPLAIN
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
-2
+1
DROP TABLE t1, t2;
End of 5.0 tests
#
diff --git a/mysql-test/suite/innodb_gis/r/gis.result b/mysql-test/suite/innodb_gis/r/gis.result
index 65d1e94..6929afd 100644
--- a/mysql-test/suite/innodb_gis/r/gis.result
+++ b/mysql-test/suite/innodb_gis/r/gis.result
@@ -939,29 +939,29 @@ id select_type table type possible_keys key key_len ref rows Extra
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
1
-INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)'));
-INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)'));
+INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(3 4)'));
+INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(3 4)'));
EXPLAIN
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
-2
+1
EXPLAIN
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref p p 28 const # Using where
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
-2
+1
EXPLAIN
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
-2
+1
DROP TABLE t1, t2;
End of 5.0 tests
#
diff --git a/mysql-test/suite/innodb_gis/r/rtree_estimate.result b/mysql-test/suite/innodb_gis/r/rtree_estimate.result
index dafcc40..edb3777 100644
--- a/mysql-test/suite/innodb_gis/r/rtree_estimate.result
+++ b/mysql-test/suite/innodb_gis/r/rtree_estimate.result
@@ -30,7 +30,7 @@ ST_AsText(g)
POINT(10 10)
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRDisjoint(g, @g1);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range g g 34 NULL 2 Using where
+1 SIMPLE t1 ALL g NULL NULL NULL 3 Using where
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
ST_AsText(g)
POINT(10 10)
@@ -75,14 +75,14 @@ POINT(10 10)
POLYGON((5 5,20 5,20 21,5 21,5 5))
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRIntersects(g, @g2);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range g g 34 NULL 2 Using where
+1 SIMPLE t1 ALL g NULL NULL NULL 3 Using where
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
ST_AsText(g)
POINT(10 10)
POLYGON((5 5,20 5,20 21,5 21,5 5))
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range g g 34 NULL 2 Using where
+1 SIMPLE t1 ALL g NULL NULL NULL 3 Using where
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
ST_AsText(g)
POINT(10 10)
diff --git a/mysql-test/suite/innodb_gis/t/rtree_estimate.test b/mysql-test/suite/innodb_gis/t/rtree_estimate.test
index 4caa5fe..7038799 100644
--- a/mysql-test/suite/innodb_gis/t/rtree_estimate.test
+++ b/mysql-test/suite/innodb_gis/t/rtree_estimate.test
@@ -15,6 +15,7 @@ SET @g1 = ST_GeomFromText('POINT(10 10)');
SET @g2 = ST_GeomFromText('POLYGON((5 5, 20 5, 20 21, 5 21, 5 5))');
SET @g3 = ST_GeomFromText('POLYGON((1.79769e+308 1.79769e+308, 20 5, -1.79769e+308 -1.79769e+308, 1.79769e+308 1.79769e+308))');
+
# Test empty table
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRContains(g, @g1);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
diff --git a/mysql-test/suite/maria/icp.result b/mysql-test/suite/maria/icp.result
index 8fc93e8..14517fe 100644
--- a/mysql-test/suite/maria/icp.result
+++ b/mysql-test/suite/maria/icp.result
@@ -409,7 +409,7 @@ WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240
ORDER BY c1
LIMIT 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range PRIMARY,k1 k1 5 NULL 4 Using where
+1 SIMPLE t1 range PRIMARY,k1 PRIMARY 4 NULL 3 Using index condition; Using where; Rowid-ordered scan; Using filesort
DROP TABLE t1;
#
#
@@ -590,6 +590,12 @@ i1 INTEGER NOT NULL,
PRIMARY KEY (pk)
);
INSERT INTO t2 VALUES (4,1);
+ANALYZE TABLE t1,t2;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
EXPLAIN
SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1
WHERE t2.pk <> t1.d1 AND t2.pk = 4;
@@ -795,6 +801,12 @@ INSERT INTO t2 (g,h) VALUES
(0,'p'),(0,'f'),(0,'p'),(7,'d'),(7,'f'),(5,'j'),
(3,'e'),(1,'u'),(4,'v'),(9,'u'),(6,'i'),(1,'x'),
(7,'f'),(5,'j'),(3,'e'),(1,'u'),(4,'v'),(9,'u');
+ANALYZE TABLE t1,t2;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status Table is already up to date
SET @save_optimize_switch=@@optimizer_switch;
SET optimizer_switch='materialization=on';
EXPLAIN
@@ -804,7 +816,7 @@ AND (EXISTS (SELECT * FROM t1, t2 WHERE a = f AND h <= t.e AND a > t.b)
OR a = 0 AND h < 'z' );
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t ALL PRIMARY,c NULL NULL NULL 64 Using where
-1 PRIMARY t2 ref g g 5 test.t.c 19 Using where
+1 PRIMARY t2 ref g g 5 test.t.c 18 Using where
2 DEPENDENT SUBQUERY t1 index PRIMARY PRIMARY 4 NULL 64 Using where; Using index
2 DEPENDENT SUBQUERY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where
SELECT COUNT(*) FROM t1 AS t, t2
diff --git a/mysql-test/suite/maria/ps_maria.result b/mysql-test/suite/maria/ps_maria.result
index bd5f2b4..6f5d557 100644
--- a/mysql-test/suite/maria/ps_maria.result
+++ b/mysql-test/suite/maria/ps_maria.result
@@ -1161,7 +1161,7 @@ def possible_keys 253 4_OR_8_K 0 Y 0 39 8
def key 253 64 0 Y 0 39 8
def key_len 253 4_OR_8_K 0 Y 0 39 8
def ref 253 2048 0 Y 0 39 8
-def rows 8 10 1 Y 32928 0 63
+def rows 253 64 1 Y 0 39 8
def Extra 253 255 0 N 1 39 8
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t9 ALL NULL NULL NULL NULL 2
diff --git a/mysql-test/suite/parts/r/optimizer.result b/mysql-test/suite/parts/r/optimizer.result
index 465c6c7..42d85db 100644
--- a/mysql-test/suite/parts/r/optimizer.result
+++ b/mysql-test/suite/parts/r/optimizer.result
@@ -25,7 +25,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 2 Using where; Using index
EXPLAIN SELECT a, MAX(b) FROM t2 WHERE a IN (10,100) GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range a a 5 NULL 2 Using where; Using index for group-by
+1 SIMPLE t2 range a a 5 NULL 2 Using where; Using index
FLUSH status;
SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100) GROUP BY a;
a MAX(b)
@@ -41,5 +41,5 @@ a MAX(b)
# Should be no more than 4 reads.
SHOW status LIKE 'handler_read_key';
Variable_name Value
-Handler_read_key 4
+Handler_read_key 2
DROP TABLE t1, t2;
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
index 926ac8b..ddaa495 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
@@ -2252,6 +2252,20 @@ NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
+VARIABLE_NAME MAX_ROWID_FILTER_SIZE
+SESSION_VALUE 131072
+GLOBAL_VALUE 131072
+GLOBAL_VALUE_ORIGIN COMPILE-TIME
+DEFAULT_VALUE 131072
+VARIABLE_SCOPE SESSION
+VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_COMMENT The maximum size of the container of a rowid filter
+NUMERIC_MIN_VALUE 1024
+NUMERIC_MAX_VALUE 18446744073709551615
+NUMERIC_BLOCK_SIZE 1
+ENUM_VALUE_LIST NULL
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME MAX_SEEKS_FOR_KEY
SESSION_VALUE 4294967295
GLOBAL_VALUE 4294967295
@@ -2729,17 +2743,17 @@ ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OPTIMIZER_SWITCH
-SESSION_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
-GLOBAL_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
+SESSION_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
+GLOBAL_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
GLOBAL_VALUE_ORIGIN COMPILE-TIME
-DEFAULT_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
+DEFAULT_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
VARIABLE_SCOPE SESSION
VARIABLE_TYPE FLAGSET
VARIABLE_COMMENT Fine-tune the optimizer behavior
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
-ENUM_VALUE_LIST index_merge,index_merge_union,index_merge_sort_union,index_merge_intersection,index_merge_sort_intersection,engine_condition_pushdown,index_condition_pushdown,derived_merge,derived_with_keys,firstmatch,loosescan,materialization,in_to_exists,semijoin,partial_match_rowid_merge,partial_match_table_scan,subquery_cache,mrr,mrr_cost_based,mrr_sort_keys,outer_join_with_cache,semijoin_with_cache,join_cache_incremental,join_cache_hashed,join_cache_bka,optimize_join_buffer_size,table_elimination,extended_keys,exists_to_in,orderby_uses_equalities,condition_pushdown_for_derived,split_materialized,condition_pushdown_for_subquery,default
+ENUM_VALUE_LIST index_merge,index_merge_union,index_merge_sort_union,index_merge_intersection,index_merge_sort_intersection,engine_condition_pushdown,index_condition_pushdown,derived_merge,derived_with_keys,firstmatch,loosescan,materialization,in_to_exists,semijoin,partial_match_rowid_merge,partial_match_table_scan,subquery_cache,mrr,mrr_cost_based,mrr_sort_keys,outer_join_with_cache,semijoin_with_cache,join_cache_incremental,join_cache_hashed,join_cache_bka,optimize_join_buffer_size,table_elimination,extended_keys,exists_to_in,orderby_uses_equalities,condition_pushdown_for_derived,split_materialized,condition_pushdown_for_subquery,rowid_filter,default
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OPTIMIZER_USE_CONDITION_SELECTIVITY
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
index 4f1b898..6c57061 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
@@ -2483,7 +2483,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 131072
VARIABLE_SCOPE SESSION
VARIABLE_TYPE BIGINT UNSIGNED
-VARIABLE_COMMENT The maximum number of rows that fit in memory
+VARIABLE_COMMENT The maximum size of the container of a rowid filter
NUMERIC_MIN_VALUE 1024
NUMERIC_MAX_VALUE 18446744073709551615
NUMERIC_BLOCK_SIZE 1
diff --git a/mysql-test/suite/vcol/inc/vcol_select.inc b/mysql-test/suite/vcol/inc/vcol_select.inc
index 0641e14..cbd1f2c 100644
--- a/mysql-test/suite/vcol/inc/vcol_select.inc
+++ b/mysql-test/suite/vcol/inc/vcol_select.inc
@@ -35,7 +35,7 @@ insert into t2 (a) values (1);
create table t3 (a int primary key,
b int as (-a),
c int as (-a) persistent unique);
-insert into t3 (a) values (2),(1),(3);
+insert into t3 (a) values (2),(1),(3),(5),(4),(7);
--echo # select_type=SIMPLE, type=system
diff --git a/mysql-test/suite/vcol/r/vcol_select_innodb.result b/mysql-test/suite/vcol/r/vcol_select_innodb.result
index 63c35ba..6ebdd87 100644
--- a/mysql-test/suite/vcol/r/vcol_select_innodb.result
+++ b/mysql-test/suite/vcol/r/vcol_select_innodb.result
@@ -9,7 +9,7 @@ insert into t2 (a) values (1);
create table t3 (a int primary key,
b int as (-a),
c int as (-a) persistent unique);
-insert into t3 (a) values (2),(1),(3);
+insert into t3 (a) values (2),(1),(3),(5),(4),(7);
# select_type=SIMPLE, type=system
select * from t2;
a b c
@@ -63,8 +63,8 @@ a b c
3 -3 -3
explain select * from t1 where b in (select c from t3);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 index c c 5 NULL 3 Using index
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
+1 PRIMARY t3 ref c c 5 test.t1.b 1 Using index
# select_type=PRIMARY, type=range,ref
select * from t1 where c in (select c from t3 where c between -2 and -1);
a b c
@@ -73,7 +73,7 @@ a b c
1 -1 -1
explain select * from t1 where c in (select c from t3 where c between -2 and -1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 index c c 5 NULL 3 Using where; Using index
+1 PRIMARY t3 index c c 5 NULL 6 Using where; Using index
1 PRIMARY t1 ALL c NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
# select_type=UNION, type=system
# select_type=UNION RESULT, type=<union1,2>
@@ -160,7 +160,7 @@ a b c
2 -2 -2
explain select * from t3 where b between -2 and -1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where
# SELECT * FROM tbl_name WHERE <indexed vcol expr>
select * from t3 where c between -2 and -1;
a b c
@@ -192,7 +192,7 @@ a b c
2 -2 -2
explain select * from t3 where b between -2 and -1 order by a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 index NULL PRIMARY 4 NULL 3 Using where
+1 SIMPLE t3 index NULL PRIMARY 4 NULL 6 Using where
# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-indexed vcol>
select * from t3 where b between -2 and -1 order by b;
a b c
@@ -200,7 +200,7 @@ a b c
1 -1 -1
explain select * from t3 where b between -2 and -1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
+1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where; Using filesort
# SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <non-indexed vcol>
select * from t3 where c between -2 and -1 order by b;
a b c
@@ -216,7 +216,7 @@ a b c
1 -1 -1
explain select * from t3 where b between -2 and -1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
+1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where; Using filesort
# SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <indexed vcol>
select * from t3 where c between -2 and -1 order by c;
a b c
diff --git a/mysql-test/suite/vcol/r/vcol_select_myisam.result b/mysql-test/suite/vcol/r/vcol_select_myisam.result
index be3ea81..4e21582 100644
--- a/mysql-test/suite/vcol/r/vcol_select_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_select_myisam.result
@@ -9,7 +9,7 @@ insert into t2 (a) values (1);
create table t3 (a int primary key,
b int as (-a),
c int as (-a) persistent unique);
-insert into t3 (a) values (2),(1),(3);
+insert into t3 (a) values (2),(1),(3),(5),(4),(7);
# select_type=SIMPLE, type=system
select * from t2;
a b c
@@ -44,7 +44,7 @@ a b c
1 -1 -1
explain select * from t3 where c>=-1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range c c 5 NULL 2 Using index condition
+1 SIMPLE t3 range c c 5 NULL 1 Using index condition
# select_type=SIMPLE, type=ref
select * from t1,t3 where t1.c=t3.c and t3.c=-1;
a b c a b c
@@ -63,8 +63,8 @@ a b c
3 -3 -3
explain select * from t1 where b in (select c from t3);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 index c c 5 NULL 3 Using index
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
+1 PRIMARY t3 ref c c 5 test.t1.b 2 Using index
# select_type=PRIMARY, type=range,ref
select * from t1 where c in (select c from t3 where c between -2 and -1);
a b c
@@ -73,8 +73,8 @@ a b c
1 -1 -1
explain select * from t1 where c in (select c from t3 where c between -2 and -1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 index c c 5 NULL 3 Using where; Using index
-1 PRIMARY t1 ref c c 5 test.t3.c 2
+1 PRIMARY t1 range c c 5 NULL 3 Using index condition
+1 PRIMARY t3 index c c 5 NULL 6 Using where; Using index; Using join buffer (flat, BNL join)
# select_type=UNION, type=system
# select_type=UNION RESULT, type=<union1,2>
select * from t1 union select * from t2;
@@ -152,7 +152,7 @@ a b c
2 -2 -2
explain select * from t3 where a between 1 and 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using index condition
+1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 2 Using index condition
# SELECT * FROM tbl_name WHERE <non-indexed vcol expr>
select * from t3 where b between -2 and -1;
a b c
@@ -160,7 +160,7 @@ a b c
1 -1 -1
explain select * from t3 where b between -2 and -1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where
# SELECT * FROM tbl_name WHERE <indexed vcol expr>
select * from t3 where c between -2 and -1;
a b c
@@ -168,7 +168,7 @@ a b c
1 -1 -1
explain select * from t3 where c between -2 and -1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range c c 5 NULL 1 Using index condition
+1 SIMPLE t3 range c c 5 NULL 2 Using index condition
# SELECT * FROM tbl_name WHERE <non-vcol expr> ORDER BY <indexed vcol>
select * from t3 where a between 1 and 2 order by c;
a b c
@@ -176,7 +176,7 @@ a b c
1 -1 -1
explain select * from t3 where a between 1 and 2 order by c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Using filesort
+1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using filesort
# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-vcol>
select * from t3 where b between -2 and -1 order by a;
a b c
@@ -184,7 +184,7 @@ a b c
2 -2 -2
explain select * from t3 where b between -2 and -1 order by a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
+1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where; Using filesort
# SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <non-vcol>
select * from t3 where c between -2 and -1 order by a;
a b c
@@ -192,7 +192,7 @@ a b c
2 -2 -2
explain select * from t3 where c between -2 and -1 order by a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using filesort
+1 SIMPLE t3 range c c 5 NULL 2 Using index condition; Using filesort
# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-indexed vcol>
select * from t3 where b between -2 and -1 order by b;
a b c
@@ -200,7 +200,7 @@ a b c
1 -1 -1
explain select * from t3 where b between -2 and -1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
+1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where; Using filesort
# SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <non-indexed vcol>
select * from t3 where c between -2 and -1 order by b;
a b c
@@ -208,7 +208,7 @@ a b c
1 -1 -1
explain select * from t3 where c between -2 and -1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using filesort
+1 SIMPLE t3 range c c 5 NULL 2 Using index condition; Using filesort
# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <indexed vcol>
select * from t3 where b between -2 and -1 order by c;
a b c
@@ -216,7 +216,7 @@ a b c
1 -1 -1
explain select * from t3 where b between -2 and -1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
+1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where; Using filesort
# SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <indexed vcol>
select * from t3 where c between -2 and -1 order by c;
a b c
@@ -224,7 +224,7 @@ a b c
1 -1 -1
explain select * from t3 where c between -2 and -1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range c c 5 NULL 1 Using index condition
+1 SIMPLE t3 range c c 5 NULL 2 Using index condition
# SELECT sum(<non-indexed vcol>) FROM tbl_name GROUP BY <non-indexed vcol>
select sum(b) from t1 group by b;
sum(b)
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 575af82..195f937 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -6184,7 +6184,7 @@ static Sys_var_enum Sys_secure_timestamp(
static Sys_var_ulonglong Sys_max_rowid_filter_size(
"max_rowid_filter_size",
- "The maximum number of rows that fit in memory",
+ "The maximum size of the container of a rowid filter",
SESSION_VAR(max_rowid_filter_size), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(1024, (ulonglong)~(intptr)0), DEFAULT(128*1024),
BLOCK_SIZE(1));
diff --git a/storage/connect/mysql-test/connect/r/mysql_index.result b/storage/connect/mysql-test/connect/r/mysql_index.result
index dd18645..b0c88b1 100644
--- a/storage/connect/mysql-test/connect/r/mysql_index.result
+++ b/storage/connect/mysql-test/connect/r/mysql_index.result
@@ -45,10 +45,9 @@ id msg
SELECT * FROM t2 WHERE id IN (2,4) AND msg = 'Two';
id msg
2 Two
-SELECT * FROM t2 WHERE id > 3;
+SELECT * FROM t2 WHERE id > 4;
id msg
5 Cinq
-4 Four
6 Six
SELECT * FROM t2 WHERE id >= 3;
id msg
@@ -60,10 +59,9 @@ SELECT * FROM t2 WHERE id < 3;
id msg
1 Un
2 Two
-SELECT * FROM t2 WHERE id < 3 OR id > 4;
+SELECT * FROM t2 WHERE id < 2 OR id > 4;
id msg
1 Un
-2 Two
5 Cinq
6 Six
SELECT * FROM t2 WHERE id <= 3;
@@ -166,141 +164,141 @@ matricule nom prenom sexe aanais mmnais ddentree ddnom brut net service sitmat f
4974 LONES GERARD 1 1959 10 1979-01-01 1994-12-01 16081 12916.70 0 M SANS
SELECT matricule, nom, prenom FROM t2 WHERE nom IN ('FOCH','MOGADOR');
matricule nom prenom
+3368 MOGADOR ALAIN
1977 FOCH BERNADETTE
-5707 FOCH DENIS
+4080 FOCH SERGE
2552 FOCH FRANCK
+5707 FOCH DENIS
2634 FOCH JOCELYNE
5765 FOCH ROBERT
-4080 FOCH SERGE
-3368 MOGADOR ALAIN
SELECT matricule, nom, prenom FROM t2 WHERE nom = 'FOCH' OR nom = 'MOGADOR';
matricule nom prenom
+3368 MOGADOR ALAIN
1977 FOCH BERNADETTE
-5707 FOCH DENIS
+4080 FOCH SERGE
2552 FOCH FRANCK
+5707 FOCH DENIS
2634 FOCH JOCELYNE
5765 FOCH ROBERT
-4080 FOCH SERGE
-3368 MOGADOR ALAIN
SELECT matricule, nom, prenom FROM t2 WHERE nom < 'ADDAX';
matricule nom prenom
-4552 ABBADIE MONIQUE
-307 ABBAYE ANNICK
-6627 ABBAYE GERALD
-7961 ABBE KATIA
1340 ABBE MICHELE
-9270 ABBE SOPHIE
+2728 ABOUT CATHERINE MARIE
+895 ABORD CHANTAL
+4038 ADAM JANICK
+6627 ABBAYE GERALD
+6124 ABELIAS DELIA
+4552 ABBADIE MONIQUE
+8673 ABEL JEAN PIERRE
+3395 ADAM JEAN CLAUDE
2945 ABBEVILLE PASCAL
-8596 ABEBERRY PATRICK
+115 ACHILLE JACQUES
6399 ABEILLES RENE
-8673 ABEL JEAN PIERRE
-6124 ABELIAS DELIA
-6314 ABERDEN EVELYNE
-895 ABORD CHANTAL
-2728 ABOUT CATHERINE MARIE
+8596 ABEBERRY PATRICK
+9270 ABBE SOPHIE
398 ABREUVOIR JEAN LUC
-1122 ACACIAS SERGE
+7961 ABBE KATIA
+307 ABBAYE ANNICK
+6314 ABERDEN EVELYNE
1644 ACARDIE BEATE
-115 ACHILLE JACQUES
-4038 ADAM JANICK
-3395 ADAM JEAN CLAUDE
+1122 ACACIAS SERGE
SELECT matricule, nom, prenom FROM t2 WHERE nom <= 'ABEL';
matricule nom prenom
-4552 ABBADIE MONIQUE
-307 ABBAYE ANNICK
-6627 ABBAYE GERALD
-7961 ABBE KATIA
1340 ABBE MICHELE
-9270 ABBE SOPHIE
+6627 ABBAYE GERALD
+4552 ABBADIE MONIQUE
+8673 ABEL JEAN PIERRE
2945 ABBEVILLE PASCAL
-8596 ABEBERRY PATRICK
6399 ABEILLES RENE
-8673 ABEL JEAN PIERRE
+8596 ABEBERRY PATRICK
+9270 ABBE SOPHIE
+7961 ABBE KATIA
+307 ABBAYE ANNICK
SELECT matricule, nom, prenom FROM t2 WHERE nom > 'YVON';
matricule nom prenom
9742 YZENGREMER MICHEL
-8738 ZILINA JEAN LOUIS
5357 ZOLA BERNARD
5441 ZOLA BRIGITTE
-1325 ZOLA CHRISTINE
-4859 ZORI CATHERINE
4102 ZOUAVES ALAIN
+4859 ZORI CATHERINE
+1325 ZOLA CHRISTINE
+8738 ZILINA JEAN LOUIS
SELECT matricule, nom, prenom FROM t2 WHERE nom >= 'YVON';
matricule nom prenom
-5389 YVON CAROLE
9742 YZENGREMER MICHEL
-8738 ZILINA JEAN LOUIS
5357 ZOLA BERNARD
+5389 YVON CAROLE
5441 ZOLA BRIGITTE
-1325 ZOLA CHRISTINE
-4859 ZORI CATHERINE
4102 ZOUAVES ALAIN
+4859 ZORI CATHERINE
+1325 ZOLA CHRISTINE
+8738 ZILINA JEAN LOUIS
SELECT matricule, nom, prenom FROM t2 WHERE nom <= 'ABEL' OR nom > 'YVON';
matricule nom prenom
-4552 ABBADIE MONIQUE
-307 ABBAYE ANNICK
-6627 ABBAYE GERALD
-7961 ABBE KATIA
-1340 ABBE MICHELE
-9270 ABBE SOPHIE
-2945 ABBEVILLE PASCAL
-8596 ABEBERRY PATRICK
-6399 ABEILLES RENE
-8673 ABEL JEAN PIERRE
9742 YZENGREMER MICHEL
-8738 ZILINA JEAN LOUIS
+1340 ABBE MICHELE
5357 ZOLA BERNARD
+6627 ABBAYE GERALD
+4552 ABBADIE MONIQUE
5441 ZOLA BRIGITTE
-1325 ZOLA CHRISTINE
-4859 ZORI CATHERINE
4102 ZOUAVES ALAIN
+8673 ABEL JEAN PIERRE
+4859 ZORI CATHERINE
+2945 ABBEVILLE PASCAL
+1325 ZOLA CHRISTINE
+6399 ABEILLES RENE
+8596 ABEBERRY PATRICK
+9270 ABBE SOPHIE
+7961 ABBE KATIA
+307 ABBAYE ANNICK
+8738 ZILINA JEAN LOUIS
SELECT matricule, nom, prenom FROM t2 WHERE nom > 'HELEN' AND nom < 'HEROS';
matricule nom prenom
-9096 HELENA PHILIPPE
-3309 HELENE ISABELLE
-8365 HELIOTROPES LISE
-4666 HELLEN PIERRE
-5781 HELSINKI DANIELLE
+2085 HEOL GUY PAUL
+2673 HENNER LILIANE
+7093 HERAULTS DANIEL
7626 HENIN PHILIPPE
+403 HERMITTE PHILIPPE
4254 HENIN SERGE
-2673 HENNER LILIANE
+4666 HELLEN PIERRE
+3309 HELENE ISABELLE
+9749 HEROLD ISABELLE
9716 HENRI JACQUES
-2085 HEOL GUY PAUL
-2579 HERANDIERE PIERRE
-7093 HERAULTS DANIEL
+1291 HERMITAGE XAVIER
+8365 HELIOTROPES LISE
4050 HERBILLON FRANCOIS
9231 HERBILLON MADELEINE
-1291 HERMITAGE XAVIER
+9096 HELENA PHILIPPE
+5781 HELSINKI DANIELLE
+2579 HERANDIERE PIERRE
6185 HERMITTE FRANCOIS
-403 HERMITTE PHILIPPE
-9749 HEROLD ISABELLE
SELECT matricule, nom, prenom FROM t2 WHERE nom BETWEEN 'HELEN' AND 'HEROS';
matricule nom prenom
-6199 HELEN MARTIAL
-9096 HELENA PHILIPPE
-3309 HELENE ISABELLE
-8365 HELIOTROPES LISE
-4666 HELLEN PIERRE
-5781 HELSINKI DANIELLE
+2085 HEOL GUY PAUL
+2673 HENNER LILIANE
+7093 HERAULTS DANIEL
7626 HENIN PHILIPPE
+403 HERMITTE PHILIPPE
4254 HENIN SERGE
-2673 HENNER LILIANE
+4666 HELLEN PIERRE
+3309 HELENE ISABELLE
+9749 HEROLD ISABELLE
9716 HENRI JACQUES
-2085 HEOL GUY PAUL
-2579 HERANDIERE PIERRE
-7093 HERAULTS DANIEL
+1291 HERMITAGE XAVIER
+8365 HELIOTROPES LISE
4050 HERBILLON FRANCOIS
9231 HERBILLON MADELEINE
-1291 HERMITAGE XAVIER
-6185 HERMITTE FRANCOIS
-403 HERMITTE PHILIPPE
-9749 HEROLD ISABELLE
8445 HEROS SYLVIE
+9096 HELENA PHILIPPE
+5781 HELSINKI DANIELLE
+2579 HERANDIERE PIERRE
+6199 HELEN MARTIAL
+6185 HERMITTE FRANCOIS
SELECT matricule, nom, prenom FROM t2 WHERE nom BETWEEN 'HELEN' AND 'HEROS' AND prenom = 'PHILIPPE';
matricule nom prenom
-9096 HELENA PHILIPPE
7626 HENIN PHILIPPE
403 HERMITTE PHILIPPE
+9096 HELENA PHILIPPE
SELECT matricule, nom, prenom FROM t2 ORDER BY nom LIMIT 10;
matricule nom prenom
4552 ABBADIE MONIQUE
diff --git a/storage/connect/mysql-test/connect/r/part_file.result b/storage/connect/mysql-test/connect/r/part_file.result
index c679ed9..3dabd94 100644
--- a/storage/connect/mysql-test/connect/r/part_file.result
+++ b/storage/connect/mysql-test/connect/r/part_file.result
@@ -145,14 +145,11 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
SELECT * FROM t1 WHERE id = 10;
rwid rnum prtn tbn fid id msg
1 1 2 t1 part2 10 ten
-EXPLAIN PARTITIONS SELECT * FROM t1 WHERE id >= 10;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE id >= 40;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 2,3 range PRIMARY PRIMARY 4 NULL 7 Using where
-SELECT * FROM t1 WHERE id >= 10;
+1 SIMPLE t1 2,3 range PRIMARY PRIMARY 4 NULL 4 Using where
+SELECT * FROM t1 WHERE id >= 40;
rwid rnum prtn tbn fid id msg
-1 1 2 t1 part2 10 ten
-3 3 2 t1 part2 20 twenty
-4 4 2 t1 part2 35 thirty five
2 2 2 t1 part2 40 forty
1 1 3 t1 part3 60 sixty
3 3 3 t1 part3 72 seventy two
diff --git a/storage/connect/mysql-test/connect/t/mysql_index.test b/storage/connect/mysql-test/connect/t/mysql_index.test
index 81fdcad..74dc48f 100644
--- a/storage/connect/mysql-test/connect/t/mysql_index.test
+++ b/storage/connect/mysql-test/connect/t/mysql_index.test
@@ -49,10 +49,10 @@ SELECT * FROM t2;
SELECT * FROM t2 WHERE id = 3;
SELECT * FROM t2 WHERE id IN (2,4);
SELECT * FROM t2 WHERE id IN (2,4) AND msg = 'Two';
-SELECT * FROM t2 WHERE id > 3;
+SELECT * FROM t2 WHERE id > 4;
SELECT * FROM t2 WHERE id >= 3;
SELECT * FROM t2 WHERE id < 3;
-SELECT * FROM t2 WHERE id < 3 OR id > 4;
+SELECT * FROM t2 WHERE id < 2 OR id > 4;
SELECT * FROM t2 WHERE id <= 3;
SELECT * FROM t2 WHERE id BETWEEN 3 AND 5;
SELECT * FROM t2 WHERE id > 2 AND id < 6;
diff --git a/storage/connect/mysql-test/connect/t/part_file.test b/storage/connect/mysql-test/connect/t/part_file.test
index 8ee43a9..2e5127f 100644
--- a/storage/connect/mysql-test/connect/t/part_file.test
+++ b/storage/connect/mysql-test/connect/t/part_file.test
@@ -82,8 +82,8 @@ SELECT * FROM t1;
SELECT * FROM t1 order by id;
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE id = 10;
SELECT * FROM t1 WHERE id = 10;
-EXPLAIN PARTITIONS SELECT * FROM t1 WHERE id >= 10;
-SELECT * FROM t1 WHERE id >= 10;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE id >= 40;
+SELECT * FROM t1 WHERE id >= 40;
SELECT count(*) FROM t1 WHERE id < 10;
SELECT case when id < 10 then 1 when id < 50 then 2 else 3 end as pn, count(*) FROM t1 group by pn;
SELECT prtn, count(*) FROM t1 group by prtn;
diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc
index 4d796d9..8bc9673 100644
--- a/storage/innobase/srv/srv0mon.cc
+++ b/storage/innobase/srv/srv0mon.cc
@@ -1414,7 +1414,7 @@ static monitor_info_t innodb_counter_info[] =
MONITOR_NONE,
MONITOR_DEFAULT_START, MONITOR_PK_FILTER_POSITIVE},
- {"pk-filter_negarive", "pk-filter", "PK-filter test is negative",
+ {"pk-filter_negative", "pk-filter", "PK-filter test is negative",
MONITOR_NONE,
MONITOR_DEFAULT_START, MONITOR_PK_FILTER_NEGATIVE},
diff --git a/storage/myisam/mi_range.c b/storage/myisam/mi_range.c
index 185f2ca..a464b3d 100644
--- a/storage/myisam/mi_range.c
+++ b/storage/myisam/mi_range.c
@@ -103,7 +103,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx,
max_key->keypart_map, max_key->flag)
: (double) info->state->records);
res= (end_pos < start_pos ? (ha_rows) 0 :
- (end_pos == start_pos ? (ha_rows) 1 : end_pos-start_pos));
+ (end_pos == start_pos ? (ha_rows) 1 : (ha_rows) (end_pos-start_pos)));
if (start_pos == HA_POS_ERROR || end_pos == HA_POS_ERROR)
res=HA_POS_ERROR;
else
@@ -111,7 +111,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx,
diff= end_pos - start_pos;
if (diff >= 0)
{
- if (!(res= (diff + 0.5)))
+ if (!(res= (ha_rows) (diff + 0.5)))
res= 1;
}
else
@@ -208,7 +208,7 @@ static double _mi_record_pos(MI_INFO *info, const uchar *key,
DBUG_PRINT("exit",("pos: %g",(pos*info->state->records)));
DBUG_RETURN(pos*info->state->records);
}
- DBUG_RETURN(HA_POS_ERROR);
+ DBUG_RETURN((double) (HA_POS_ERROR));
}
1
0
[Commits] f706a820ba8: MDEV-12009: Allow to force kill user threads/query which are flagged as high priority by Galera
by jan 04 Feb '19
by jan 04 Feb '19
04 Feb '19
revision-id: f706a820ba88159e17640f71d369f54ebd8fe5aa (mariadb-10.1.37-81-gf706a820ba8)
parent(s): 0bd8d9946831635325a8b72aec9433c769d4deb0
author: Jan Lindström
committer: Jan Lindström
timestamp: 2019-02-04 20:22:26 +0200
message:
MDEV-12009: Allow to force kill user threads/query which are flagged as high priority by Galera
As noted on kill_one_thread SUPER should be able to kill even
system threads i.e. threads/query flagged as high priority or
wsrep applier thread. Normal user, should not able to kill
threads/query flagged as high priority (BF) or wsrep applier
thread.
---
include/mysql/service_wsrep.h | 3 ++
.../suite/galera/r/galera_kill_applier.result | 4 ++
mysql-test/suite/galera/t/galera_kill_applier.cnf | 10 ++++
mysql-test/suite/galera/t/galera_kill_applier.test | 54 ++++++++++++++++++++--
sql/sql_parse.cc | 14 ++++--
sql/sql_plugin_services.ic | 3 +-
sql/wsrep_dummy.cc | 3 ++
sql/wsrep_mysqld.cc | 1 -
sql/wsrep_thd.cc | 9 ++++
sql/wsrep_thd.h | 2 +
10 files changed, 95 insertions(+), 8 deletions(-)
diff --git a/include/mysql/service_wsrep.h b/include/mysql/service_wsrep.h
index b51f154422f..6a83feaff55 100644
--- a/include/mysql/service_wsrep.h
+++ b/include/mysql/service_wsrep.h
@@ -111,6 +111,7 @@ extern struct wsrep_service_st {
int (*wsrep_trx_order_before_func)(MYSQL_THD, MYSQL_THD);
void (*wsrep_unlock_rollback_func)();
void (*wsrep_set_data_home_dir_func)(const char *data_dir);
+ my_bool (*wsrep_thd_is_applier_func)(THD *thd);
} *wsrep_service;
#ifdef MYSQL_DYNAMIC_PLUGIN
@@ -153,6 +154,7 @@ extern struct wsrep_service_st {
#define wsrep_trx_order_before(T1,T2) wsrep_service->wsrep_trx_order_before_func(T1,T2)
#define wsrep_unlock_rollback() wsrep_service->wsrep_unlock_rollback_func()
#define wsrep_set_data_home_dir(A) wsrep_service->wsrep_set_data_home_dir_func(A)
+#define wsrep_thd_is_applier(T) wsrep_service->wsrep_thd_is_applier_func(T)
#define wsrep_debug get_wsrep_debug()
#define wsrep_log_conflicts get_wsrep_log_conflicts()
@@ -211,6 +213,7 @@ void wsrep_thd_set_conflict_state(THD *thd, enum wsrep_conflict_state state);
bool wsrep_thd_ignore_table(THD *thd);
void wsrep_unlock_rollback();
void wsrep_set_data_home_dir(const char *data_dir);
+my_bool wsrep_thd_is_applier(THD *thd);
#endif
diff --git a/mysql-test/suite/galera/r/galera_kill_applier.result b/mysql-test/suite/galera/r/galera_kill_applier.result
index fe4911639ed..89f8ead0b65 100644
--- a/mysql-test/suite/galera/r/galera_kill_applier.result
+++ b/mysql-test/suite/galera/r/galera_kill_applier.result
@@ -1,4 +1,8 @@
+CREATE USER foo@localhost;
+GRANT SELECT on test.* TO foo@localhost;
+# Open connection to the 1st node using 'test_user1' user.
Got one of the listed errors
Got one of the listed errors
Got one of the listed errors
Got one of the listed errors
+DROP USER foo@localhost;
diff --git a/mysql-test/suite/galera/t/galera_kill_applier.cnf b/mysql-test/suite/galera/t/galera_kill_applier.cnf
new file mode 100644
index 00000000000..f2563e66f2e
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_kill_applier.cnf
@@ -0,0 +1,10 @@
+!include ../galera_2nodes.cnf
+
+[mysqld.1]
+wsrep_provider_options='base_port=(a)mysqld.1.#galera_port;pc.ignore_sb=true'
+auto_increment_offset=1
+
+[mysqld.2]
+wsrep_provider_options='base_port=(a)mysqld.2.#galera_port;pc.ignore_sb=true'
+auto_increment_offset=2
+
diff --git a/mysql-test/suite/galera/t/galera_kill_applier.test b/mysql-test/suite/galera/t/galera_kill_applier.test
index e14a8b9af23..5e4a587fe57 100644
--- a/mysql-test/suite/galera/t/galera_kill_applier.test
+++ b/mysql-test/suite/galera/t/galera_kill_applier.test
@@ -1,14 +1,25 @@
#
# This test checks that applier threads are immune to KILL QUERY and KILL STATEMENT
+# when USER is not SUPER
#
--source include/galera_cluster.inc
---source include/have_innodb.inc
--connection node_1
+CREATE USER foo@localhost;
+GRANT SELECT on test.* TO foo@localhost;
+
--let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE != 'wsrep aborter idle' OR STATE IS NULL LIMIT 1`
+--let $aborter_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep aborter idle' LIMIT 1`
+
+--echo # Open connection to the 1st node using 'test_user1' user.
+--let $port_1= \$NODE_MYPORT_1
+--connect(foo_node_1,localhost,foo,,test,$port_1,)
+
+--connection foo_node_1
+
--disable_query_log
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
--eval KILL $applier_thread
@@ -16,11 +27,48 @@
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
--eval KILL QUERY $applier_thread
---let $aborter_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep aborter idle' LIMIT 1`
-
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
--eval KILL $aborter_thread
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
--eval KILL QUERY $aborter_thread
--enable_query_log
+
+#
+# SUPER can kill applier threads
+#
+--connection node_2
+
+--let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE != 'wsrep aborter idle' OR STATE IS NULL LIMIT 1`
+
+--disable_query_log
+--eval KILL $applier_thread
+--enable_query_log
+
+--let $aborter_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep aborter idle' LIMIT 1`
+
+--disable_query_log
+--eval KILL $aborter_thread
+--enable_query_log
+
+--source include/restart_mysqld.inc
+
+--connection node_2
+--let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE != 'wsrep aborter idle' OR STATE IS NULL LIMIT 1`
+
+--disable_query_log
+--eval KILL QUERY $applier_thread
+--enable_query_log
+
+--let $aborter_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep aborter idle' LIMIT 1`
+
+--disable_query_log
+--eval KILL QUERY $aborter_thread
+--enable_query_log
+
+--source include/restart_mysqld.inc
+
+--connection node_1
+--disconnect foo_node_1
+DROP USER foo@localhost;
+
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 3f6ce8356ce..83278559a9c 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -8297,11 +8297,19 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ
It's ok to also kill DELAYED threads with KILL_CONNECTION instead of
KILL_SYSTEM_THREAD; The difference is that KILL_CONNECTION may be
faster and do a harder kill than KILL_SYSTEM_THREAD;
+
+ Note that if thread is wsrep Brute Force or applier thread we
+ allow killing it only when we're SUPER.
*/
- if (((thd->security_ctx->master_access & SUPER_ACL) ||
- thd->security_ctx->user_matches(tmp->security_ctx)) &&
- !wsrep_thd_is_BF(tmp, false))
+ if ((thd->security_ctx->master_access & SUPER_ACL) ||
+ (thd->security_ctx->user_matches(tmp->security_ctx)
+#ifdef WITH_WSREP
+ &&
+ !tmp->wsrep_applier &&
+ !wsrep_thd_is_BF(tmp, false)
+#endif
+ ))
{
tmp->awake(kill_signal);
error=0;
diff --git a/sql/sql_plugin_services.ic b/sql/sql_plugin_services.ic
index 95301a5fbe8..a0d42c04dba 100644
--- a/sql/sql_plugin_services.ic
+++ b/sql/sql_plugin_services.ic
@@ -180,7 +180,8 @@ static struct wsrep_service_st wsrep_handler = {
wsrep_trx_is_aborting,
wsrep_trx_order_before,
wsrep_unlock_rollback,
- wsrep_set_data_home_dir
+ wsrep_set_data_home_dir,
+ wsrep_thd_is_applier,
};
static struct thd_specifics_service_st thd_specifics_handler=
diff --git a/sql/wsrep_dummy.cc b/sql/wsrep_dummy.cc
index 5837ab4bed5..1f130e2b9a2 100644
--- a/sql/wsrep_dummy.cc
+++ b/sql/wsrep_dummy.cc
@@ -20,6 +20,9 @@
my_bool wsrep_thd_is_BF(THD *, my_bool)
{ return 0; }
+my_bool wsrep_thd_is_applier(THD *)
+{ return 0; }
+
int wsrep_trx_order_before(THD *, THD *)
{ return 0; }
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 47aea6d3824..85112967b7b 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -2469,7 +2469,6 @@ extern "C" void wsrep_thd_set_exec_mode(THD *thd, enum wsrep_exec_mode mode)
thd->wsrep_exec_mode= mode;
}
-
extern "C" void wsrep_thd_set_query_state(
THD *thd, enum wsrep_query_state state)
{
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index eb26da61282..492a3b67c68 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -596,6 +596,15 @@ my_bool wsrep_thd_is_BF(THD *thd, my_bool sync)
return status;
}
+my_bool wsrep_thd_is_applier(THD *thd)
+{
+ my_bool ret = FALSE;
+ if (thd) {
+ ret = thd->wsrep_applier;
+ }
+ return ret;
+}
+
extern "C"
my_bool wsrep_thd_is_BF_or_commit(void *thd_ptr, my_bool sync)
{
diff --git a/sql/wsrep_thd.h b/sql/wsrep_thd.h
index 5900668f3fb..f5fcb50280c 100644
--- a/sql/wsrep_thd.h
+++ b/sql/wsrep_thd.h
@@ -37,6 +37,7 @@ int wsrep_abort_thd(void *bf_thd_ptr, void *victim_thd_ptr,
*/
extern void wsrep_thd_set_PA_safe(void *thd_ptr, my_bool safe);
extern my_bool wsrep_thd_is_BF(THD *thd, my_bool sync);
+extern my_bool wsrep_thd_is_applier(THD *thd);
extern my_bool wsrep_thd_is_wsrep(void *thd_ptr);
enum wsrep_conflict_state wsrep_thd_conflict_state(void *thd_ptr, my_bool sync);
@@ -47,6 +48,7 @@ extern "C" int wsrep_thd_in_locking_session(void *thd_ptr);
#else /* WITH_WSREP */
#define wsrep_thd_is_BF(T, S) (0)
+#define wsrep_thd_is_applier(T) (0)
#define wsrep_abort_thd(X,Y,Z) do { } while(0)
#define wsrep_create_appliers(T) do { } while(0)
1
0
04 Feb '19
revision-id: 0bd8d9946831635325a8b72aec9433c769d4deb0 (mariadb-10.1.37-80-g0bd8d994683)
parent(s): 27f1de5cb3ededcea5a54d43047b5c38c2965075
author: Jan Lindström
committer: Jan Lindström
timestamp: 2019-02-04 20:01:08 +0200
message:
MDEV-18464: Port kill_one_trx fixes from 10.4 to 10.1
Pushed the decision for innodb transaction and system
locking down to lock_trx_handle_wait() level. With this,
we can avoid releasing these mutexes for executions
where these mutexes were acquired upfront.
This patch will also fix BF aborting of native threads, e.g.
threads which have declared wsrep_on=OFF. Earlier, we have
used, for innodb trx locks, was_chosen_as_deadlock_victim
flag, for marking inodb transactions, which are victims for
wsrep BF abort. With native threads (wsrep_on==OFF), re-using
was_chosen_as_deadlock_victim flag may lead to inteference
with real deadlock, and to deal with this, the patch has added new
flag for marking wsrep BF aborts only: was_chosen_as_wsrep_victim
innobase_kill_query()
Removed lock mutex and trx mutex code.
wsrep_innobase_kill_one_trx()
Code cleanup and we will now use new was_chosen_as_wsrep_victim
flag.
wsrep_kill_victim()
Removed unnecessary code.
lock_trx_handle_wait_low()
New low lever function to handle lock waits.
lock_trx_handle_wait()
Taking lock mutex and trx mutex is pushed down to this
function.
---
storage/innobase/handler/ha_innodb.cc | 72 ++++++++++------------------------
storage/innobase/include/trx0trx.h | 9 +++--
storage/innobase/lock/lock0lock.cc | 42 ++++++++++++++------
storage/innobase/row/row0sel.cc | 4 --
storage/innobase/trx/trx0roll.cc | 3 ++
storage/innobase/trx/trx0trx.cc | 9 +++--
storage/xtradb/handler/ha_innodb.cc | 73 +++++++++++------------------------
storage/xtradb/include/trx0trx.h | 11 ++++--
storage/xtradb/lock/lock0lock.cc | 42 ++++++++++++++------
storage/xtradb/row/row0sel.cc | 4 --
storage/xtradb/trx/trx0roll.cc | 6 +--
storage/xtradb/trx/trx0trx.cc | 8 ++--
12 files changed, 130 insertions(+), 153 deletions(-)
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 702f84a52d1..7f2dff51440 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -4912,8 +4912,6 @@ static void innobase_kill_query(handlerton*, THD* thd, enum thd_kill_levels)
/* if victim has been signaled by BF thread and/or aborting
is already progressing, following query aborting is not necessary
any more.
- Also, BF thread should own trx mutex for the victim, which would
- conflict with trx_mutex_enter() below
*/
DBUG_VOID_RETURN;
}
@@ -4922,34 +4920,8 @@ static void innobase_kill_query(handlerton*, THD* thd, enum thd_kill_levels)
if (trx_t* trx = thd_to_trx(thd)) {
ut_ad(trx->mysql_thd == thd);
- switch (trx->abort_type) {
-#ifdef WITH_WSREP
- case TRX_WSREP_ABORT:
- break;
-#endif
- case TRX_SERVER_ABORT:
- if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
- lock_mutex_enter();
- }
- /* fall through */
- case TRX_REPLICATION_ABORT:
- trx_mutex_enter(trx);
- }
/* Cancel a pending lock request if there are any */
lock_trx_handle_wait(trx);
- switch (trx->abort_type) {
-#ifdef WITH_WSREP
- case TRX_WSREP_ABORT:
- break;
-#endif
- case TRX_SERVER_ABORT:
- if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
- lock_mutex_exit();
- }
- /* fall through */
- case TRX_REPLICATION_ABORT:
- trx_mutex_exit(trx);
- }
}
DBUG_VOID_RETURN;
@@ -18593,7 +18565,7 @@ wsrep_innobase_kill_one_trx(
ut_ad(victim_trx);
DBUG_ENTER("wsrep_innobase_kill_one_trx");
- THD *bf_thd = bf_thd_ptr ? (THD*) bf_thd_ptr : NULL;
+ THD *bf_thd = (THD *) bf_thd_ptr;
THD *thd = (THD *) victim_trx->mysql_thd;
int64_t bf_seqno = (bf_thd) ? wsrep_thd_trx_seqno(bf_thd) : 0;
@@ -18603,27 +18575,28 @@ wsrep_innobase_kill_one_trx(
DBUG_RETURN(1);
}
- if (!bf_thd) {
- DBUG_PRINT("wsrep", ("no BF thd for conflicting lock"));
- WSREP_WARN("no BF THD for trx: " TRX_ID_FMT,
- bf_trx ? bf_trx->id : 0);
- DBUG_RETURN(1);
- }
-
WSREP_LOG_CONFLICT(bf_thd, thd, TRUE);
- WSREP_DEBUG("BF kill (%lu, seqno: %lld), victim: (%lu) trx: "
- TRX_ID_FMT,
- signal, (long long)bf_seqno,
+ wsrep_thd_LOCK(thd);
+
+ WSREP_DEBUG("BF kill (" ULINTPF ", seqno: " INT64PF
+ "), victim: (%lu) trx: " TRX_ID_FMT,
+ signal, bf_seqno,
thd_get_thread_id(thd),
victim_trx->id);
- WSREP_DEBUG("Aborting query: %s conf %d trx: %" PRId64,
- (thd && wsrep_thd_query(thd)) ? wsrep_thd_query(thd) : "void",
- wsrep_thd_conflict_state(thd, FALSE),
+ WSREP_DEBUG("Aborting query: %s conflict_state %s trx: %" PRId64,
+ (wsrep_thd_query(thd) ? wsrep_thd_query(thd) : "void"),
+ wsrep_thd_conflict_state_str(thd),
wsrep_thd_ws_handle(thd)->trx_id);
- wsrep_thd_LOCK(thd);
+ /*
+ * we mark with was_chosen_as_deadlock_victim transaction,
+ * which is already marked as BF victim
+ * lock_sys is held until this vicitm has aborted
+ */
+ victim_trx->lock.was_chosen_as_wsrep_victim = TRUE;
+
DBUG_EXECUTE_IF("sync.wsrep_after_BF_victim_lock",
{
const char act[]=
@@ -18633,7 +18606,6 @@ wsrep_innobase_kill_one_trx(
STRING_WITH_LEN(act)));
};);
-
if (wsrep_thd_query_state(thd) == QUERY_EXITING) {
WSREP_DEBUG("kill trx EXITING for " TRX_ID_FMT,
victim_trx->id);
@@ -18642,9 +18614,9 @@ wsrep_innobase_kill_one_trx(
}
if(wsrep_thd_exec_mode(thd) != LOCAL_STATE) {
- WSREP_DEBUG("withdraw for BF trx: " TRX_ID_FMT ", state: %d",
+ WSREP_DEBUG("withdraw for BF trx: " TRX_ID_FMT ", state: %s",
victim_trx->id,
- wsrep_thd_get_conflict_state(thd));
+ wsrep_thd_conflict_state_str(thd));
}
switch (wsrep_thd_get_conflict_state(thd)) {
@@ -18661,8 +18633,8 @@ wsrep_innobase_kill_one_trx(
case ABORTED:
case ABORTING: // fall through
default:
- WSREP_DEBUG("victim " TRX_ID_FMT " in state %d",
- victim_trx->id, wsrep_thd_get_conflict_state(thd));
+ WSREP_DEBUG("victim " TRX_ID_FMT " in state %s",
+ victim_trx->id, wsrep_thd_conflict_state_str(thd));
wsrep_thd_UNLOCK(thd);
DBUG_RETURN(0);
break;
@@ -18765,9 +18737,9 @@ wsrep_innobase_kill_one_trx(
wsrep_thd_trx_seqno(thd));
DBUG_RETURN(0);
}
+
/* This will lock thd from proceeding after net_read() */
wsrep_thd_set_conflict_state(thd, ABORTING);
-
wsrep_lock_rollback();
if (wsrep_aborting_thd_contains(thd)) {
@@ -18819,12 +18791,10 @@ wsrep_abort_transaction(
if (victim_trx) {
lock_mutex_enter();
trx_mutex_enter(victim_trx);
- victim_trx->abort_type = TRX_WSREP_ABORT;
int rcode = wsrep_innobase_kill_one_trx(bf_thd, bf_trx,
victim_trx, signal);
trx_mutex_exit(victim_trx);
lock_mutex_exit();
- victim_trx->abort_type = TRX_SERVER_ABORT;
wsrep_srv_conc_cancel_wait(victim_trx);
DBUG_RETURN(rcode);
} else {
diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index fe16b8272b8..50405fee69b 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -624,6 +624,12 @@ struct trx_lock_t {
only be modified by the thread that is
serving the running transaction. */
+#ifdef WITH_WSREP
+ bool was_chosen_as_wsrep_victim;
+ /*!< high priority wsrep thread has
+ marked this trx to abort */
+#endif /* WITH_WSREP */
+
mem_heap_t* lock_heap; /*!< memory heap for trx_locks;
protected by lock_sys->mutex */
@@ -697,9 +703,6 @@ lock_sys->mutex and sometimes by trx->mutex. */
enum trx_abort_t {
TRX_SERVER_ABORT = 0,
-#ifdef WITH_WSREP
- TRX_WSREP_ABORT,
-#endif
TRX_REPLICATION_ABORT
};
diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc
index 3970a559a4c..dcf5b5ecfd0 100644
--- a/storage/innobase/lock/lock0lock.cc
+++ b/storage/innobase/lock/lock0lock.cc
@@ -1793,10 +1793,8 @@ wsrep_kill_victim(
}
}
- lock->trx->abort_type = TRX_WSREP_ABORT;
wsrep_innobase_kill_one_trx(trx->mysql_thd,
(const trx_t*) trx, lock->trx, TRUE);
- lock->trx->abort_type = TRX_SERVER_ABORT;
}
}
}
@@ -7967,16 +7965,7 @@ lock_trx_release_locks(
lock_mutex_exit();
}
-/*********************************************************************//**
-Check whether the transaction has already been rolled back because it
-was selected as a deadlock victim, or if it has to wait then cancel
-the wait lock.
-@return DB_DEADLOCK, DB_LOCK_WAIT or DB_SUCCESS */
-UNIV_INTERN
-dberr_t
-lock_trx_handle_wait(
-/*=================*/
- trx_t* trx) /*!< in/out: trx lock state */
+static inline dberr_t lock_trx_handle_wait_low(trx_t* trx)
{
ut_ad(lock_mutex_own());
ut_ad(trx_mutex_own(trx));
@@ -7993,6 +7982,35 @@ lock_trx_handle_wait(
return DB_LOCK_WAIT;
}
+/*********************************************************************//**
+Check whether the transaction has already been rolled back because it
+was selected as a deadlock victim, or if it has to wait then cancel
+the wait lock.
+@return DB_DEADLOCK, DB_LOCK_WAIT or DB_SUCCESS */
+UNIV_INTERN
+dberr_t
+lock_trx_handle_wait(
+/*=================*/
+ trx_t* trx) /*!< in/out: trx lock state */
+{
+#ifdef WITH_WSREP
+ /* We already own mutexes */
+ if (trx->lock.was_chosen_as_wsrep_victim) {
+ return lock_trx_handle_wait_low(trx);
+ }
+#endif /* WITH_WSREP */
+ if (trx->abort_type != TRX_REPLICATION_ABORT) {
+ lock_mutex_enter();
+ }
+ trx_mutex_enter(trx);
+ dberr_t err = lock_trx_handle_wait_low(trx);
+ if (trx->abort_type != TRX_REPLICATION_ABORT) {
+ lock_mutex_exit();
+ }
+ trx_mutex_exit(trx);
+ return err;
+}
+
/*********************************************************************//**
Get the number of locks on a table.
@return number of locks */
diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc
index 06bf4cc30c0..855266686e6 100644
--- a/storage/innobase/row/row0sel.cc
+++ b/storage/innobase/row/row0sel.cc
@@ -4746,11 +4746,7 @@ row_search_for_mysql(
a deadlock and the transaction had to wait then
release the lock it is waiting on. */
- lock_mutex_enter();
- trx_mutex_enter(trx);
err = lock_trx_handle_wait(trx);
- lock_mutex_exit();
- trx_mutex_exit(trx);
switch (err) {
case DB_SUCCESS:
diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc
index 3fd71aff23a..be8b7d29350 100644
--- a/storage/innobase/trx/trx0roll.cc
+++ b/storage/innobase/trx/trx0roll.cc
@@ -370,6 +370,9 @@ trx_rollback_to_savepoint_for_mysql_low(
trx_mark_sql_stat_end(trx);
trx->op_info = "";
+#ifdef WITH_WSREP
+ trx->lock.was_chosen_as_wsrep_victim = FALSE;
+#endif
return(err);
}
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index f36aabba8b4..f79ca7a2bc0 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -168,6 +168,9 @@ trx_create(void)
#ifdef WITH_WSREP
trx->wsrep_event = NULL;
#endif /* WITH_WSREP */
+
+ trx->abort_type = TRX_SERVER_ABORT;
+
return(trx);
}
@@ -1339,12 +1342,10 @@ trx_commit_in_memory(
ut_ad(!trx->in_ro_trx_list);
ut_ad(!trx->in_rw_trx_list);
+ trx->dict_operation = TRX_DICT_OP_NONE;
#ifdef WITH_WSREP
- if (trx->mysql_thd && wsrep_on(trx->mysql_thd)) {
- trx->lock.was_chosen_as_deadlock_victim = FALSE;
- }
+ trx->lock.was_chosen_as_wsrep_victim = FALSE;
#endif
- trx->dict_operation = TRX_DICT_OP_NONE;
trx->error_state = DB_SUCCESS;
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index d3be5155d27..09a8d36709d 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -5517,43 +5517,15 @@ static void innobase_kill_query(handlerton*, THD* thd, enum thd_kill_levels)
/* if victim has been signaled by BF thread and/or aborting
is already progressing, following query aborting is not necessary
any more.
- Also, BF thread should own trx mutex for the victim, which would
- conflict with trx_mutex_enter() below
*/
DBUG_VOID_RETURN;
}
#endif /* WITH_WSREP */
+
if (trx_t* trx = thd_to_trx(thd)) {
ut_ad(trx->mysql_thd == thd);
-
- switch (trx->abort_type) {
-#ifdef WITH_WSREP
- case TRX_WSREP_ABORT:
- break;
-#endif
- case TRX_SERVER_ABORT:
- if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
- lock_mutex_enter();
- }
- /* fall through */
- case TRX_REPLICATION_ABORT:
- trx_mutex_enter(trx);
- }
/* Cancel a pending lock request if there are any */
lock_trx_handle_wait(trx);
- switch (trx->abort_type) {
-#ifdef WITH_WSREP
- case TRX_WSREP_ABORT:
- break;
-#endif
- case TRX_SERVER_ABORT:
- if (!wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
- lock_mutex_exit();
- }
- /* fall through */
- case TRX_REPLICATION_ABORT:
- trx_mutex_exit(trx);
- }
}
DBUG_VOID_RETURN;
@@ -19636,7 +19608,7 @@ wsrep_innobase_kill_one_trx(
ut_ad(victim_trx);
DBUG_ENTER("wsrep_innobase_kill_one_trx");
- THD *bf_thd = bf_thd_ptr ? (THD*) bf_thd_ptr : NULL;
+ THD *bf_thd = (THD *) bf_thd_ptr;
THD *thd = (THD *) victim_trx->mysql_thd;
int64_t bf_seqno = (bf_thd) ? wsrep_thd_trx_seqno(bf_thd) : 0;
@@ -19646,25 +19618,28 @@ wsrep_innobase_kill_one_trx(
DBUG_RETURN(1);
}
- if (!bf_thd) {
- DBUG_PRINT("wsrep", ("no BF thd for conflicting lock"));
- WSREP_WARN("no BF THD for trx: " TRX_ID_FMT,
- bf_trx ? bf_trx->id : 0);
- DBUG_RETURN(1);
- }
-
WSREP_LOG_CONFLICT(bf_thd, thd, TRUE);
- WSREP_DEBUG("BF kill (%lu, seqno: %lld), victim: (%lu) trx: "
- TRX_ID_FMT,
- signal, (long long)bf_seqno,
+ wsrep_thd_LOCK(thd);
+
+ WSREP_DEBUG("BF kill (" ULINTPF ", seqno: " INT64PF
+ "), victim: (%lu) trx: " TRX_ID_FMT,
+ signal, bf_seqno,
thd_get_thread_id(thd),
victim_trx->id);
- WSREP_DEBUG("Aborting query: %s",
- (thd && wsrep_thd_query(thd)) ? wsrep_thd_query(thd) : "void");
+ WSREP_DEBUG("Aborting query: %s conflict_state %s trx: %" PRId64,
+ (wsrep_thd_query(thd) ? wsrep_thd_query(thd) : "void"),
+ wsrep_thd_conflict_state_str(thd),
+ wsrep_thd_ws_handle(thd)->trx_id);
+
+ /*
+ * we mark with was_chosen_as_deadlock_victim transaction,
+ * which is already marked as BF victim
+ * lock_sys is held until this vicitm has aborted
+ */
+ victim_trx->lock.was_chosen_as_wsrep_victim = TRUE;
- wsrep_thd_LOCK(thd);
DBUG_EXECUTE_IF("sync.wsrep_after_BF_victim_lock",
{
const char act[]=
@@ -19683,9 +19658,9 @@ wsrep_innobase_kill_one_trx(
}
if(wsrep_thd_exec_mode(thd) != LOCAL_STATE) {
- WSREP_DEBUG("withdraw for BF trx: " TRX_ID_FMT ", state: %d",
+ WSREP_DEBUG("withdraw for BF trx: " TRX_ID_FMT ", state: %s",
victim_trx->id,
- wsrep_thd_get_conflict_state(thd));
+ wsrep_thd_conflict_state_str(thd));
}
switch (wsrep_thd_get_conflict_state(thd)) {
@@ -19702,8 +19677,8 @@ wsrep_innobase_kill_one_trx(
case ABORTED:
case ABORTING: // fall through
default:
- WSREP_DEBUG("victim " TRX_ID_FMT " in state %d",
- victim_trx->id, wsrep_thd_get_conflict_state(thd));
+ WSREP_DEBUG("victim " TRX_ID_FMT " in state %s",
+ victim_trx->id, wsrep_thd_conflict_state_str(thd));
wsrep_thd_UNLOCK(thd);
DBUG_RETURN(0);
break;
@@ -19806,9 +19781,9 @@ wsrep_innobase_kill_one_trx(
wsrep_thd_trx_seqno(thd));
DBUG_RETURN(0);
}
+
/* This will lock thd from proceeding after net_read() */
wsrep_thd_set_conflict_state(thd, ABORTING);
-
wsrep_lock_rollback();
if (wsrep_aborting_thd_contains(thd)) {
@@ -19853,12 +19828,10 @@ wsrep_abort_transaction(handlerton* hton, THD *bf_thd, THD *victim_thd,
if (victim_trx) {
lock_mutex_enter();
trx_mutex_enter(victim_trx);
- victim_trx->abort_type = TRX_WSREP_ABORT;
int rcode = wsrep_innobase_kill_one_trx(bf_thd, bf_trx,
victim_trx, signal);
trx_mutex_exit(victim_trx);
lock_mutex_exit();
- victim_trx->abort_type = TRX_SERVER_ABORT;
wsrep_srv_conc_cancel_wait(victim_trx);
DBUG_RETURN(rcode);
} else {
diff --git a/storage/xtradb/include/trx0trx.h b/storage/xtradb/include/trx0trx.h
index 77afde4c35c..5c11d3ae292 100644
--- a/storage/xtradb/include/trx0trx.h
+++ b/storage/xtradb/include/trx0trx.h
@@ -673,6 +673,12 @@ struct trx_lock_t {
only be modified by the thread that is
serving the running transaction. */
+#ifdef WITH_WSREP
+ bool was_chosen_as_wsrep_victim;
+ /*!< high priority wsrep thread has
+ marked this trx to abort */
+#endif /* WITH_WSREP */
+
mem_heap_t* lock_heap; /*!< memory heap for trx_locks;
protected by lock_sys->mutex */
@@ -746,10 +752,7 @@ lock_sys->mutex and sometimes by trx->mutex. */
enum trx_abort_t {
TRX_SERVER_ABORT = 0,
-#ifdef WITH_WSREP
- TRX_WSREP_ABORT,
-#endif
- TRX_REPLICATION_ABORT
+ TRX_REPLICATION_ABORT = 1
};
struct trx_t{
diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc
index 2183d281b78..53bd6e77fe8 100644
--- a/storage/xtradb/lock/lock0lock.cc
+++ b/storage/xtradb/lock/lock0lock.cc
@@ -1804,10 +1804,8 @@ wsrep_kill_victim(
}
}
- lock->trx->abort_type = TRX_WSREP_ABORT;
wsrep_innobase_kill_one_trx(trx->mysql_thd,
(const trx_t*) trx, lock->trx, TRUE);
- lock->trx->abort_type = TRX_SERVER_ABORT;
}
}
}
@@ -8077,16 +8075,7 @@ lock_trx_release_locks(
lock_mutex_exit();
}
-/*********************************************************************//**
-Check whether the transaction has already been rolled back because it
-was selected as a deadlock victim, or if it has to wait then cancel
-the wait lock.
-@return DB_DEADLOCK, DB_LOCK_WAIT or DB_SUCCESS */
-UNIV_INTERN
-dberr_t
-lock_trx_handle_wait(
-/*=================*/
- trx_t* trx) /*!< in/out: trx lock state */
+static inline dberr_t lock_trx_handle_wait_low(trx_t* trx)
{
ut_ad(lock_mutex_own());
ut_ad(trx_mutex_own(trx));
@@ -8103,6 +8092,35 @@ lock_trx_handle_wait(
return DB_LOCK_WAIT;
}
+/*********************************************************************//**
+Check whether the transaction has already been rolled back because it
+was selected as a deadlock victim, or if it has to wait then cancel
+the wait lock.
+@return DB_DEADLOCK, DB_LOCK_WAIT or DB_SUCCESS */
+UNIV_INTERN
+dberr_t
+lock_trx_handle_wait(
+/*=================*/
+ trx_t* trx) /*!< in/out: trx lock state */
+{
+#ifdef WITH_WSREP
+ /* We already own mutexes */
+ if (trx->lock.was_chosen_as_wsrep_victim) {
+ return lock_trx_handle_wait_low(trx);
+ }
+#endif /* WITH_WSREP */
+ if (trx->abort_type != TRX_REPLICATION_ABORT) {
+ lock_mutex_enter();
+ }
+ trx_mutex_enter(trx);
+ dberr_t err = lock_trx_handle_wait_low(trx);
+ if (trx->abort_type != TRX_REPLICATION_ABORT) {
+ lock_mutex_exit();
+ }
+ trx_mutex_exit(trx);
+ return err;
+}
+
/*********************************************************************//**
Get the number of locks on a table.
@return number of locks */
diff --git a/storage/xtradb/row/row0sel.cc b/storage/xtradb/row/row0sel.cc
index b6b5d107885..87bc2aa2875 100644
--- a/storage/xtradb/row/row0sel.cc
+++ b/storage/xtradb/row/row0sel.cc
@@ -4755,11 +4755,7 @@ row_search_for_mysql(
a deadlock and the transaction had to wait then
release the lock it is waiting on. */
- lock_mutex_enter();
- trx_mutex_enter(trx);
err = lock_trx_handle_wait(trx);
- lock_mutex_exit();
- trx_mutex_exit(trx);
switch (err) {
case DB_SUCCESS:
diff --git a/storage/xtradb/trx/trx0roll.cc b/storage/xtradb/trx/trx0roll.cc
index 56b7120fa34..5e60725b9be 100644
--- a/storage/xtradb/trx/trx0roll.cc
+++ b/storage/xtradb/trx/trx0roll.cc
@@ -375,12 +375,8 @@ trx_rollback_to_savepoint_for_mysql_low(
trx_mark_sql_stat_end(trx);
trx->op_info = "";
-
#ifdef WITH_WSREP
- if (wsrep_on(trx->mysql_thd) &&
- trx->lock.was_chosen_as_deadlock_victim) {
- trx->lock.was_chosen_as_deadlock_victim = FALSE;
- }
+ trx->lock.was_chosen_as_wsrep_victim = FALSE;
#endif
return(err);
diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc
index 17cba81daf3..81ffbc6e4e1 100644
--- a/storage/xtradb/trx/trx0trx.cc
+++ b/storage/xtradb/trx/trx0trx.cc
@@ -304,6 +304,8 @@ trx_create(void)
trx->wsrep_event = NULL;
#endif /* WITH_WSREP */
+ trx->abort_type = TRX_SERVER_ABORT;
+
return(trx);
}
@@ -1563,12 +1565,10 @@ trx_commit_in_memory(
ut_ad(!trx->in_ro_trx_list);
ut_ad(!trx->in_rw_trx_list);
+ trx->dict_operation = TRX_DICT_OP_NONE;
#ifdef WITH_WSREP
- if (trx->mysql_thd && wsrep_on(trx->mysql_thd)) {
- trx->lock.was_chosen_as_deadlock_victim = FALSE;
- }
+ trx->lock.was_chosen_as_wsrep_victim = FALSE;
#endif
- trx->dict_operation = TRX_DICT_OP_NONE;
trx->error_state = DB_SUCCESS;
1
0
[Commits] 1ed1b7794fd: Merge remote-tracking branch 'connect/11.2' into 10.2
by Oleksandr Byelkin 04 Feb '19
by Oleksandr Byelkin 04 Feb '19
04 Feb '19
revision-id: 1ed1b7794fd0eba99932f43dc3f6ce1c6cdfda5d (mariadb-10.2.21-57-g1ed1b7794fd)
parent(s): 564f63ccf78678dffc32841381deb19954dd36e3 a0e26599a3a772ccaa06410c722a770e300b5bb8
author: Oleksandr Byelkin
committer: Oleksandr Byelkin
timestamp: 2019-02-04 16:09:42 +0100
message:
Merge remote-tracking branch 'connect/11.2' into 10.2
storage/connect/ha_connect.cc | 41 ++++++++++++++++----
storage/connect/jsonudf.cpp | 49 +++++++++++++++++++++++-
storage/connect/jsonudf.h | 5 +++
storage/connect/tabext.cpp | 43 ++++++++++++++++++++-
storage/connect/tabext.h | 5 ++-
storage/connect/tabjdbc.cpp | 89 ++++++++++++++++++++++++++-----------------
storage/connect/tabjson.cpp | 8 ++--
7 files changed, 188 insertions(+), 52 deletions(-)
1
0
[Commits] c19bb963d7d: MDEV-17783: AddressSanitizer: stack-buffer-overflow in table_cond_selectivity with
by Varun 04 Feb '19
by Varun 04 Feb '19
04 Feb '19
revision-id: c19bb963d7dcd1b3000a1aaa90eb1a606fc1957d (mariadb-10.0.37-73-gc19bb963d7d)
parent(s): d9d83f1d92b696ef56f4944df036b8a78364ebb4
author: Varun Gupta
committer: Varun Gupta
timestamp: 2019-02-04 18:53:32 +0530
message:
MDEV-17783: AddressSanitizer: stack-buffer-overflow in table_cond_selectivity with
optimizer_use_condition_selectivity > 1, join_cache_level >2
This case happens when we pick hash-join in best_access_path but the number of keyparts
in the hash_key are > MAX_REF_PARTS.
Not allowing hash-join when the keyparts are greater than MAX_REF_PARTS.
---
mysql-test/r/selectivity.result | 14 ++++++++++++++
mysql-test/r/selectivity_innodb.result | 14 ++++++++++++++
mysql-test/t/selectivity.test | 17 +++++++++++++++++
sql/sql_select.cc | 3 +++
4 files changed, 48 insertions(+)
diff --git a/mysql-test/r/selectivity.result b/mysql-test/r/selectivity.result
index 6af4f9a9ace..b8d54fa12a6 100644
--- a/mysql-test/r/selectivity.result
+++ b/mysql-test/r/selectivity.result
@@ -1640,3 +1640,17 @@ set @@use_stat_tables= @save_use_stat_tables;
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
drop table t1;
drop function f1;
+#
+# MDEV-17783: AddressSanitizer: stack-buffer-overflow in table_cond_selectivity
+# with optimizer_use_condition_selectivity > 1, join_cache_level >2
+#
+set @save_join_cache_level= @@join_cache_level;
+set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+set join_cache_level=3;
+set optimizer_use_condition_selectivity=2;
+CREATE TABLE t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, c16 int, c17 int, c18 int, c19 int, c20 int, c21 int, c22 int, c23 int, c24 int, c25 int, c26 int, c27 int, c28 int, c29 int, c30 int, c31 int, c32 int, c33 int, c34 int);
+SELECT * FROM t1 WHERE (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30, c31, c32, c33, c34) IN (SELECT * FROM t1) ;
+c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34
+set join_cache_level= @save_join_cache_level;
+set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+drop table t1;
diff --git a/mysql-test/r/selectivity_innodb.result b/mysql-test/r/selectivity_innodb.result
index e0ed2865f13..9536e4eede7 100644
--- a/mysql-test/r/selectivity_innodb.result
+++ b/mysql-test/r/selectivity_innodb.result
@@ -1644,6 +1644,20 @@ set @@use_stat_tables= @save_use_stat_tables;
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
drop table t1;
drop function f1;
+#
+# MDEV-17783: AddressSanitizer: stack-buffer-overflow in table_cond_selectivity
+# with optimizer_use_condition_selectivity > 1, join_cache_level >2
+#
+set @save_join_cache_level= @@join_cache_level;
+set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+set join_cache_level=3;
+set optimizer_use_condition_selectivity=2;
+CREATE TABLE t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, c16 int, c17 int, c18 int, c19 int, c20 int, c21 int, c22 int, c23 int, c24 int, c25 int, c26 int, c27 int, c28 int, c29 int, c30 int, c31 int, c32 int, c33 int, c34 int);
+SELECT * FROM t1 WHERE (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30, c31, c32, c33, c34) IN (SELECT * FROM t1) ;
+c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34
+set join_cache_level= @save_join_cache_level;
+set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+drop table t1;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
set @tmp_ust= @@use_stat_tables;
set @tmp_oucs= @@optimizer_use_condition_selectivity;
diff --git a/mysql-test/t/selectivity.test b/mysql-test/t/selectivity.test
index 557a4e92bca..102459dd7d7 100644
--- a/mysql-test/t/selectivity.test
+++ b/mysql-test/t/selectivity.test
@@ -1100,3 +1100,20 @@ set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectiv
drop table t1;
drop function f1;
+--echo #
+--echo # MDEV-17783: AddressSanitizer: stack-buffer-overflow in table_cond_selectivity
+--echo # with optimizer_use_condition_selectivity > 1, join_cache_level >2
+--echo #
+
+set @save_join_cache_level= @@join_cache_level;
+set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+set join_cache_level=3;
+set optimizer_use_condition_selectivity=2;
+
+CREATE TABLE t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, c16 int, c17 int, c18 int, c19 int, c20 int, c21 int, c22 int, c23 int, c24 int, c25 int, c26 int, c27 int, c28 int, c29 int, c30 int, c31 int, c32 int, c33 int, c34 int);
+
+SELECT * FROM t1 WHERE (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30, c31, c32, c33, c34) IN (SELECT * FROM t1) ;
+
+set join_cache_level= @save_join_cache_level;
+set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+drop table t1;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 6fafbbb11df..dbf607516da 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -5775,6 +5775,7 @@ best_access_path(JOIN *join,
bool best_uses_jbuf= FALSE;
MY_BITMAP *eq_join_set= &s->table->eq_join_set;
KEYUSE *hj_start_key= 0;
+ uint hash_key_parts=0;
disable_jbuf= disable_jbuf || idx == join->const_tables;
@@ -5820,6 +5821,7 @@ best_access_path(JOIN *join,
if (!hj_start_key)
hj_start_key= keyuse;
bitmap_set_bit(eq_join_set, keyuse->keypart);
+ ++hash_key_parts;
}
keyuse++;
continue;
@@ -6186,6 +6188,7 @@ best_access_path(JOIN *join,
if (idx > join->const_tables && best_key == 0 &&
(join->allowed_join_cache_types & JOIN_CACHE_HASHED_BIT) &&
join->max_allowed_join_cache_level > 2 &&
+ hash_key_parts <= MAX_REF_PARTS &&
!bitmap_is_clear_all(eq_join_set) && !disable_jbuf &&
(!s->emb_sj_nest ||
join->allowed_semijoin_with_cache) && // (1)
1
0
[Commits] ce91482: MDEV-17599 ALTER TABLE DROP CONSTRAINT does not work for foreign keys.
by holyfoot@askmonty.org 04 Feb '19
by holyfoot@askmonty.org 04 Feb '19
04 Feb '19
revision-id: ce91482df1af6935f81a2142d0ee9391feab2454 (mariadb-10.2.21-45-gce91482)
parent(s): 97930df13c0e403940969ebb47398760b59f753c
committer: Alexey Botchkov
timestamp: 2019-02-04 12:57:57 +0400
message:
MDEV-17599 ALTER TABLE DROP CONSTRAINT does not work for foreign keys.
The list of table constraints doesn't include foreign keys and uniques.
So we replace DROP CONSTRAINT with DROP [FOREIGN] KEY in this case.
---
mysql-test/r/alter_table.result | 49 ++++++++++++++++++++++++++++++++++
mysql-test/t/alter_table.test | 17 ++++++++++++
sql/sql_table.cc | 58 +++++++++++++++++++++++++++++++++++++++++
sql/sql_yacc.yy | 9 +++++--
4 files changed, 131 insertions(+), 2 deletions(-)
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result
index dcee72e..f243d24 100644
--- a/mysql-test/r/alter_table.result
+++ b/mysql-test/r/alter_table.result
@@ -2456,5 +2456,54 @@ ERROR 23000: Duplicate entry '1' for key 'i'
UNLOCK TABLES;
DROP TABLE t1;
#
+# MDEV-17599 ALTER TABLE DROP CONSTRAINT does not work for foreign keys.
+#
+CREATE TABLE t1(id INT PRIMARY KEY, c1 INT) ENGINE= INNODB;
+CREATE TABLE t2(id INT PRIMARY KEY, c1 INT, c2 INT NOT NULL,
+CONSTRAINT sid FOREIGN KEY (`c1`) REFERENCES t1 (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
+CONSTRAINT UNIQUE `ui`(c2)) ENGINE= INNODB;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `id` int(11) NOT NULL,
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `ui` (`c2`),
+ KEY `sid` (`c1`),
+ CONSTRAINT `sid` FOREIGN KEY (`c1`) REFERENCES `t1` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+ALTER TABLE t2 DROP CONSTRAINT sid;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `id` int(11) NOT NULL,
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `ui` (`c2`),
+ KEY `sid` (`c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+ALTER TABLE t2 DROP CONSTRAINT ui;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `id` int(11) NOT NULL,
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY `sid` (`c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+ALTER TABLE t2 DROP CONSTRAINT PRIMARY KEY;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `id` int(11) NOT NULL,
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) NOT NULL,
+ KEY `sid` (`c1`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t2, t1;
+#
# End of 10.2 tests
#
diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test
index df077c8..e6caadc 100644
--- a/mysql-test/t/alter_table.test
+++ b/mysql-test/t/alter_table.test
@@ -2013,5 +2013,22 @@ DROP TABLE t1;
--echo #
+--echo # MDEV-17599 ALTER TABLE DROP CONSTRAINT does not work for foreign keys.
+--echo #
+
+CREATE TABLE t1(id INT PRIMARY KEY, c1 INT) ENGINE= INNODB;
+CREATE TABLE t2(id INT PRIMARY KEY, c1 INT, c2 INT NOT NULL,
+ CONSTRAINT sid FOREIGN KEY (`c1`) REFERENCES t1 (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
+ CONSTRAINT UNIQUE `ui`(c2)) ENGINE= INNODB;
+SHOW CREATE TABLE t2;
+ALTER TABLE t2 DROP CONSTRAINT sid;
+SHOW CREATE TABLE t2;
+ALTER TABLE t2 DROP CONSTRAINT ui;
+SHOW CREATE TABLE t2;
+ALTER TABLE t2 DROP CONSTRAINT PRIMARY KEY;
+SHOW CREATE TABLE t2;
+DROP TABLE t2, t1;
+
+--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 1b426f8..bd6ab9e 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -8993,6 +8993,64 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
THD_STAGE_INFO(thd, stage_setup);
+
+ if (alter_info->flags & Alter_info::ALTER_DROP_CHECK_CONSTRAINT)
+ {
+ /*
+ ALTER TABLE DROP CONSTRAINT
+ should be replaced with ... DROP FOREIGN KEY
+ if the constraint is the FOREIGN KEY one.
+ */
+
+ List_iterator<Alter_drop> drop_it(alter_info->drop_list);
+ Alter_drop *drop;
+ alter_info->flags&= ~Alter_info::ALTER_DROP_CHECK_CONSTRAINT;
+
+ while ((drop= drop_it++))
+ {
+ if (drop->type == Alter_drop::CHECK_CONSTRAINT)
+ {
+ {
+ /* Test if there is a FOREIGN KEY with this name. */
+ List <FOREIGN_KEY_INFO> fk_child_key_list;
+ FOREIGN_KEY_INFO *f_key;
+ table->file->get_foreign_key_list(thd, &fk_child_key_list);
+ List_iterator<FOREIGN_KEY_INFO> fk_key_it(fk_child_key_list);
+
+ while ((f_key= fk_key_it++))
+ {
+ if (my_strcasecmp(system_charset_info, f_key->foreign_id->str,
+ drop->name) == 0)
+ {
+ drop->type= Alter_drop::FOREIGN_KEY;
+ alter_info->flags|= Alter_info::DROP_FOREIGN_KEY;
+ goto do_continue;
+ }
+ }
+ }
+
+ {
+ /* Test if there is an UNIQUE with this name. */
+ uint n_key;
+
+ for (n_key=0; n_key < table->s->keys; n_key++)
+ {
+ if ((table->key_info[n_key].flags & HA_NOSAME) &&
+ my_strcasecmp(system_charset_info,
+ drop->name, table->key_info[n_key].name) == 0)
+ {
+ drop->type= Alter_drop::KEY;
+ alter_info->flags|= Alter_info::ALTER_DROP_INDEX;
+ goto do_continue;
+ }
+ }
+ }
+ }
+ alter_info->flags|= Alter_info::ALTER_DROP_CHECK_CONSTRAINT;
+do_continue:;
+ }
+ }
+
handle_if_exists_options(thd, table, alter_info);
/*
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index b2b9cb4..cc6670b 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1741,7 +1741,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
IDENT_sys TEXT_STRING_sys TEXT_STRING_literal
NCHAR_STRING opt_component key_cache_name
sp_opt_label BIN_NUM label_ident TEXT_STRING_filesystem ident_or_empty
- opt_constraint constraint opt_ident ident_table_alias
+ opt_constraint opt_constraint_no_id constraint opt_ident ident_table_alias
%type <lex_str_ptr>
opt_table_alias
@@ -6123,6 +6123,11 @@ check_constraint:
}
;
+opt_constraint_no_id:
+ /* Empty */ {}
+ | CONSTRAINT {}
+ ;
+
opt_constraint:
/* empty */ { $$= null_lex_str; }
| constraint { $$= $1; }
@@ -7653,7 +7658,7 @@ alter_list_item:
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
lex->alter_info.flags|= Alter_info::DROP_FOREIGN_KEY;
}
- | DROP PRIMARY_SYM KEY_SYM
+ | DROP opt_constraint_no_id PRIMARY_SYM KEY_SYM
{
LEX *lex=Lex;
Alter_drop *ad= (new (thd->mem_root)
1
0