
[Commits] 4507064: MyRocks: MDEV-15911: Reduce debug logging on default levels in error log
by psergeyļ¼ askmonty.org 19 Apr '18
by psergeyļ¼ askmonty.org 19 Apr '18
19 Apr '18
revision-id: 45070647927a4ec4451a9833091ee21e2818a032
parent(s): 66c14d3a8d31e877ede75d23f96dc61a4aa12971
committer: Sergei Petrunia
branch nick: 10.2-r4
timestamp: 2018-04-19 14:11:53 +0300
message:
MyRocks: MDEV-15911: Reduce debug logging on default levels in error log
MyRocks internally will print non-critical messages to
sql_print_verbose_info() which will do what InnoDB does in similar cases:
check if (global_system_variables.log_warnings > 2).
---
sql/log.cc | 12 ++++++++----
sql/log.h | 1 +
storage/rocksdb/ha_rocksdb.cc | 34 +++++++++++++++++++++++-----------
storage/rocksdb/ha_rocksdb.h | 4 ++++
storage/rocksdb/rdb_datadic.cc | 8 ++++----
5 files changed, 40 insertions(+), 19 deletions(-)
diff --git a/sql/log.cc b/sql/log.cc
index f1a0834..7241aa6 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -8747,16 +8747,20 @@ void sql_print_information(const char *format, ...)
va_list args;
DBUG_ENTER("sql_print_information");
- if (disable_log_notes)
- DBUG_VOID_RETURN; // Skip notes during start/shutdown
-
va_start(args, format);
- error_log_print(INFORMATION_LEVEL, format, args);
+ sql_print_information_v(format, args);
va_end(args);
DBUG_VOID_RETURN;
}
+void sql_print_information_v(const char *format, va_list ap)
+{
+ if (disable_log_notes)
+ return; // Skip notes during start/shutdown
+
+ error_log_print(INFORMATION_LEVEL, format, ap);
+}
void
TC_LOG::run_prepare_ordered(THD *thd, bool all)
diff --git a/sql/log.h b/sql/log.h
index c09ae14..2a3912a 100644
--- a/sql/log.h
+++ b/sql/log.h
@@ -1075,6 +1075,7 @@ int vprint_msg_to_log(enum loglevel level, const char *format, va_list args);
void sql_print_error(const char *format, ...);
void sql_print_warning(const char *format, ...);
void sql_print_information(const char *format, ...);
+void sql_print_information_v(const char *format, va_list ap);
typedef void (*sql_print_message_func)(const char *format, ...);
extern sql_print_message_func sql_print_message_handlers[];
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index 18d5c6e..03086db 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -220,8 +220,8 @@ static int rocksdb_compact_column_family(THD *const thd,
if (const char *const cf = value->val_str(value, buff, &len)) {
auto cfh = cf_manager.get_cf(cf);
if (cfh != nullptr && rdb != nullptr) {
- sql_print_information("RocksDB: Manual compaction of column family: %s\n",
- cf);
+ sql_print_verbose_info("RocksDB: Manual compaction of column family: %s\n",
+ cf);
rdb->CompactRange(getCompactRangeOptions(), cfh, nullptr, nullptr);
}
}
@@ -7776,8 +7776,8 @@ int ha_rocksdb::check(THD *const thd, HA_CHECK_OPT *const check_opt) {
/* For each secondary index, check that we can get a PK value from it */
// NO_LINT_DEBUG
- sql_print_information("CHECKTABLE %s: Checking table %s", table_name,
- table_name);
+ sql_print_verbose_info("CHECKTABLE %s: Checking table %s", table_name,
+ table_name);
ha_rows UNINIT_VAR(row_checksums_at_start); // set/used iff first_index==true
ha_rows row_checksums = ha_rows(-1);
bool first_index = true;
@@ -7792,8 +7792,8 @@ int ha_rocksdb::check(THD *const thd, HA_CHECK_OPT *const check_opt) {
row_checksums_at_start = m_row_checksums_checked;
int res;
// NO_LINT_DEBUG
- sql_print_information("CHECKTABLE %s: Checking index %s", table_name,
- table->key_info[keyno].name);
+ sql_print_verbose_info("CHECKTABLE %s: Checking index %s", table_name,
+ table->key_info[keyno].name);
while (1) {
if (!rows)
res = index_first(table->record[0]);
@@ -7881,9 +7881,9 @@ int ha_rocksdb::check(THD *const thd, HA_CHECK_OPT *const check_opt) {
}
}
// NO_LINT_DEBUG
- sql_print_information("CHECKTABLE %s: ... %lld index entries checked "
- "(%lld had checksums)",
- table_name, rows, checksums);
+ sql_print_verbose_info("CHECKTABLE %s: ... %lld index entries checked "
+ "(%lld had checksums)",
+ table_name, rows, checksums);
if (first_index) {
row_checksums = m_row_checksums_checked - row_checksums_at_start;
@@ -7894,8 +7894,8 @@ int ha_rocksdb::check(THD *const thd, HA_CHECK_OPT *const check_opt) {
}
if (row_checksums != ha_rows(-1)) {
// NO_LINT_DEBUG
- sql_print_information("CHECKTABLE %s: %lld table records had checksums",
- table_name, row_checksums);
+ sql_print_verbose_info("CHECKTABLE %s: %lld table records had checksums",
+ table_name, row_checksums);
}
extra(HA_EXTRA_NO_KEYREAD);
@@ -12655,8 +12655,20 @@ double ha_rocksdb::read_time(uint index, uint ranges, ha_rows rows) {
DBUG_RETURN((rows / 20.0) + 1);
}
+void sql_print_verbose_info(const char *format, ...)
+{
+ va_list args;
+
+ if (global_system_variables.log_warnings > 2) {
+ va_start(args, format);
+ sql_print_information_v(format, args);
+ va_end(args);
+ }
+}
+
} // namespace myrocks
+
/**
Construct and emit duplicate key error message using information
from table's record buffer.
diff --git a/storage/rocksdb/ha_rocksdb.h b/storage/rocksdb/ha_rocksdb.h
index 31adef8..d929ca1 100644
--- a/storage/rocksdb/ha_rocksdb.h
+++ b/storage/rocksdb/ha_rocksdb.h
@@ -1415,4 +1415,8 @@ struct Rdb_inplace_alter_ctx : public my_core::inplace_alter_handler_ctx {
const int MYROCKS_MARIADB_PLUGIN_MATURITY_LEVEL= MariaDB_PLUGIN_MATURITY_GAMMA;
extern bool prevent_myrocks_loading;
+
+void sql_print_verbose_info(const char *format, ...);
+
} // namespace myrocks
+
diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc
index 68ad8e0..01dc2d6 100644
--- a/storage/rocksdb/rdb_datadic.cc
+++ b/storage/rocksdb/rdb_datadic.cc
@@ -4906,8 +4906,8 @@ void Rdb_dict_manager::add_create_index(
rocksdb::WriteBatch *const batch) const {
for (const auto &gl_index_id : gl_index_ids) {
// NO_LINT_DEBUG
- sql_print_information("RocksDB: Begin index creation (%u,%u)",
- gl_index_id.cf_id, gl_index_id.index_id);
+ sql_print_verbose_info("RocksDB: Begin index creation (%u,%u)",
+ gl_index_id.cf_id, gl_index_id.index_id);
start_create_index(batch, gl_index_id);
}
}
@@ -4986,8 +4986,8 @@ void Rdb_dict_manager::rollback_ongoing_index_creation() const {
for (const auto &gl_index_id : gl_index_ids) {
// NO_LINT_DEBUG
- sql_print_information("RocksDB: Removing incomplete create index (%u,%u)",
- gl_index_id.cf_id, gl_index_id.index_id);
+ sql_print_verbose_info("RocksDB: Removing incomplete create index (%u,%u)",
+ gl_index_id.cf_id, gl_index_id.index_id);
start_drop_index(batch, gl_index_id);
}
1
0

[Commits] 79d27ec: Mdev-10664 Add statuses about optimistic parallel replication stalls
by sachin 19 Apr '18
by sachin 19 Apr '18
19 Apr '18
revision-id: 79d27ec3f5acd20506a529f33068dd408c17f512 (mariadb-10.3.5-25-g79d27ec)
parent(s): ad647cc84ebf331d59b24e81bffe89be2f5b1ed7
author: Sachin Setiya
committer: Sachin Setiya
timestamp: 2018-04-19 14:03:20 +0530
message:
Mdev-10664 Add statuses about optimistic parallel replication stalls
In this commit we are adding three more status variable to SHOW SLAVE
STATUS. Slave_DDL_Events and Slave_Non_Transactional_Events.
Slave_DDL_Groups:- This status variable counts the occurrence of DDL
statements
Slave_Non_Transactional_Groups:- This variable count the occurrence
of non-transnational event group.
Slave_Transactional_Groups:- This variable count the occurrence
of transnational event group.
Patch Credit:- Kristian Nielsen
---
mysql-test/include/check-testcase.test | 5 +-
mysql-test/suite/multi_source/info_logs.result | 12 +-
mysql-test/suite/multi_source/multi_parallel.cnf | 6 +
.../suite/multi_source/multi_parallel.result | 67 +++++++++++
mysql-test/suite/multi_source/multi_parallel.test | 125 +++++++++++++++++++++
.../suite/multi_source/multi_parallel_loop.inc | 19 ++++
mysql-test/suite/multi_source/reset_slave.result | 8 +-
mysql-test/suite/multi_source/simple.result | 23 ++--
mysql-test/suite/multi_source/syntax.result | 6 +-
sql/log_event.cc | 15 +++
sql/rpl_mi.cc | 3 +-
sql/rpl_mi.h | 10 ++
sql/slave.cc | 24 ++++
13 files changed, 298 insertions(+), 25 deletions(-)
diff --git a/mysql-test/include/check-testcase.test b/mysql-test/include/check-testcase.test
index 4ca5398..3c164ee 100644
--- a/mysql-test/include/check-testcase.test
+++ b/mysql-test/include/check-testcase.test
@@ -70,10 +70,13 @@ if ($tmp)
--echo SQL_Delay 0
--echo SQL_Remaining_Delay NULL
--echo Slave_SQL_Running_State
+ --echo Slave_DDL_Groups #
+ --echo Slave_Non_Transactional_Groups #
+ --echo Slave_Transactional_Groups #
}
if (!$tmp) {
# Note: after WL#5177, fields 13-18 shall not be filtered-out.
- --replace_column 4 # 5 # 6 # 7 # 8 # 9 # 10 # 13 # 14 # 15 # 16 # 17 # 18 # 22 # 23 # 24 # 25 # 26 # 40 # 41 # 42 # 44 #
+ --replace_column 4 # 5 # 6 # 7 # 8 # 9 # 10 # 13 # 14 # 15 # 16 # 17 # 18 # 22 # 23 # 24 # 25 # 26 # 40 # 41 # 42 # 44 # 51 # 52 # 53 #
query_vertical
SHOW SLAVE STATUS;
}
diff --git a/mysql-test/suite/multi_source/info_logs.result b/mysql-test/suite/multi_source/info_logs.result
index e177c98..531a617 100644
--- a/mysql-test/suite/multi_source/info_logs.result
+++ b/mysql-test/suite/multi_source/info_logs.result
@@ -89,17 +89,17 @@ MASTER 2.2
# EOF
#
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats
Slave_h
eartbeat_period Gtid_Slave_Pos
- Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> relay.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 1 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 7 0 60.000
-MASTER 2.2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> relay-master@00202@002e2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space2> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_tra
nsaction
s Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+ Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> relay.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 1 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 7 0 60.000
+MASTER 2.2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> relay-master@00202@002e2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space2> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 7 0 60.000
include/wait_for_slave_to_start.inc
set default_master_connection = 'MASTER 2.2';
include/wait_for_slave_to_start.inc
set default_master_connection = '';
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats
Slave_h
eartbeat_period Gtid_Slave_Pos
- Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> relay.000004 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 1 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 6 0 60.000
-MASTER 2.2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> relay-master@00202@002e2.000004 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space2> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 6 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_tra
nsaction
s Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+ Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> relay.000004 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 1 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 6 0 60.000
+MASTER 2.2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> relay-master@00202@002e2.000004 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space2> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 6 0 60.000
#
# List of files matching '*info*' pattern
# after slave server restart
diff --git a/mysql-test/suite/multi_source/multi_parallel.cnf b/mysql-test/suite/multi_source/multi_parallel.cnf
new file mode 100644
index 0000000..0f0dc5c
--- /dev/null
+++ b/mysql-test/suite/multi_source/multi_parallel.cnf
@@ -0,0 +1,6 @@
+!include my.cnf
+[mysqld.1]
+gtid_domain_id=1
+
+[mysqld.2]
+gtid_domain_id=2
diff --git a/mysql-test/suite/multi_source/multi_parallel.result b/mysql-test/suite/multi_source/multi_parallel.result
new file mode 100644
index 0000000..b934934
--- /dev/null
+++ b/mysql-test/suite/multi_source/multi_parallel.result
@@ -0,0 +1,67 @@
+connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1;
+connect master2,127.0.0.1,root,,,$SERVER_MYPORT_2;
+connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3;
+set global slave_parallel_threads=10;
+change master 'master1' to
+master_port=MYPORT_1,
+master_host='127.0.0.1',
+master_user='root';
+change master 'master2' to
+master_port=MYPORT_2,
+master_host='127.0.0.1',
+master_user='root';
+start all slaves;
+Warnings:
+Note 1937 SLAVE 'master2' started
+Note 1937 SLAVE 'master1' started
+set default_master_connection = 'master1';
+include/wait_for_slave_to_start.inc
+set default_master_connection = 'master2';
+include/wait_for_slave_to_start.inc
+## Slave status variable
+set default_master_connection = 'master1';
+show status like 'slave_running';
+Variable_name Value
+Slave_running ON
+set default_master_connection = 'master2';
+show status like 'slave_running';
+Variable_name Value
+Slave_running ON
+#master 1
+connection master1;
+##Running CURD operation
+connection slave;
+Slave_DDL_Groups= 20;
+Slave_Non_Transactional_Groups= 20;
+Slave__Transactional_Groups= 0;
+#master 2
+connection master2;
+##Running CURD operation
+connection slave;
+Slave_DDL_Groups= 20;
+Slave_Non_Transactional_Groups= 20;
+Slave_Transactional_Groups= 0;
+#master 1
+connection master1;
+##Running CURD operation
+connection slave;
+Slave_DDL_Groups= 40;
+Slave_Non_Transactional_Groups= 20;
+Slave_Transactional_Groups= 20;
+stop all slaves;
+Warnings:
+Note 1938 SLAVE 'master2' stopped
+Note 1938 SLAVE 'master1' stopped
+set default_master_connection = 'master1';
+include/wait_for_slave_to_stop.inc
+set default_master_connection = 'master2';
+include/wait_for_slave_to_stop.inc
+set global slave_parallel_threads=0;
+include/reset_master_slave.inc
+disconnect slave;
+connection master1;
+include/reset_master_slave.inc
+disconnect master1;
+connection master2;
+include/reset_master_slave.inc
+disconnect master2;
diff --git a/mysql-test/suite/multi_source/multi_parallel.test b/mysql-test/suite/multi_source/multi_parallel.test
new file mode 100644
index 0000000..988ec43
--- /dev/null
+++ b/mysql-test/suite/multi_source/multi_parallel.test
@@ -0,0 +1,125 @@
+# This test file tests events counter like Slave_ddl_groups,
+# Slave_non_transactional_groups, Slave_transactional_groups
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+--let $rpl_server_count= 0
+
+--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1)
+--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2)
+--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
+
+#save state
+--let $par_thd= `select @@slave_parallel_threads;`
+
+set global slave_parallel_threads=10;
+
+--replace_result $SERVER_MYPORT_1 MYPORT_1
+eval change master 'master1' to
+master_port=$SERVER_MYPORT_1,
+master_host='127.0.0.1',
+master_user='root';
+
+--replace_result $SERVER_MYPORT_2 MYPORT_2
+eval change master 'master2' to
+master_port=$SERVER_MYPORT_2,
+master_host='127.0.0.1',
+master_user='root';
+
+
+#start all slaves
+
+start all slaves;
+
+set default_master_connection = 'master1';
+--source include/wait_for_slave_to_start.inc
+
+set default_master_connection = 'master2';
+--source include/wait_for_slave_to_start.inc
+
+--echo ## Slave status variable
+
+set default_master_connection = 'master1';
+show status like 'slave_running';
+
+set default_master_connection = 'master2';
+show status like 'slave_running';
+
+
+--echo #master 1
+--connection master1
+
+--let $loop_counter=10
+--let $table_engine=myisam
+--source multi_parallel_loop.inc
+--save_master_pos
+
+--connection slave
+
+--sync_with_master 0,'master1'
+--let $status= query_get_value(show slave 'master1' status, Slave_DDL_Groups, 1)
+--echo Slave_DDL_Groups= $status;
+
+--let $status= query_get_value(show slave 'master1' status, Slave_Non_Transactional_Groups, 1)
+--echo Slave_Non_Transactional_Groups= $status;
+
+--let $status= query_get_value(show slave 'master1' status, Slave_Transactional_Groups, 1)
+--echo Slave__Transactional_Groups= $status;
+
+--echo #master 2
+--connection master2
+
+--let $loop_counter=10
+--let $table_engine=myisam
+--source multi_parallel_loop.inc
+--save_master_pos
+
+--connection slave
+--sync_with_master 0,'master2'
+--let $status= query_get_value(show slave 'master2' status, Slave_DDL_Groups, 1)
+--echo Slave_DDL_Groups= $status;
+
+--let $status= query_get_value(show slave 'master2' status, Slave_Non_Transactional_Groups, 1)
+--echo Slave_Non_Transactional_Groups= $status;
+
+--let $status= query_get_value(show slave 'master2' status, Slave_Transactional_Groups, 1)
+--echo Slave_Transactional_Groups= $status;
+
+--echo #master 1
+--connection master1
+
+--let $loop_counter=10
+--let $table_engine=innodb
+--source multi_parallel_loop.inc
+--save_master_pos
+
+--connection slave
+
+--sync_with_master 0,'master1'
+--let $status= query_get_value(show slave 'master1' status, Slave_DDL_Groups, 1)
+--echo Slave_DDL_Groups= $status;
+
+--let $status= query_get_value(show slave 'master1' status, Slave_Non_Transactional_Groups, 1)
+--echo Slave_Non_Transactional_Groups= $status;
+
+--let $status= query_get_value(show slave 'master1' status, Slave_Transactional_Groups, 1)
+--echo Slave_Transactional_Groups= $status;
+
+
+# Cleanup
+stop all slaves;
+set default_master_connection = 'master1';
+--source include/wait_for_slave_to_stop.inc
+
+set default_master_connection = 'master2';
+--source include/wait_for_slave_to_stop.inc
+
+--eval set global slave_parallel_threads=$par_thd
+
+--source include/reset_master_slave.inc
+--disconnect slave
+--connection master1
+--source include/reset_master_slave.inc
+--disconnect master1
+--connection master2
+--source include/reset_master_slave.inc
+--disconnect master2
diff --git a/mysql-test/suite/multi_source/multi_parallel_loop.inc b/mysql-test/suite/multi_source/multi_parallel_loop.inc
new file mode 100644
index 0000000..bf692b2
--- /dev/null
+++ b/mysql-test/suite/multi_source/multi_parallel_loop.inc
@@ -0,0 +1,19 @@
+#create a table,insert data and drop table
+
+#parameters
+# loop_counter
+# table_engine
+--echo ##Running CURD operation
+--disable_query_log
+while ($loop_counter)
+{
+ #DDL statement
+ --eval create table t1(a int primary key) engine=$table_engine;
+
+ #non trans update statement
+ insert into t1 values(1);
+ insert into t1 values(2);
+ drop table t1;
+ --dec $loop_counter
+}
+--enable_query_log
diff --git a/mysql-test/suite/multi_source/reset_slave.result b/mysql-test/suite/multi_source/reset_slave.result
index 353970a..4f66c8f 100644
--- a/mysql-test/suite/multi_source/reset_slave.result
+++ b/mysql-test/suite/multi_source/reset_slave.result
@@ -13,15 +13,15 @@ insert into t1 values (1),(2);
connection slave;
stop slave 'master1';
show slave 'master1' status;
-Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State
- 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-master1.000002 <relay_log_pos> master-bin.000001 No No 0 0 <read_master_log_pos> <relay_log_space> None 0 No NULL No 0 0 1 No conservative 0 NULL
+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups
+ 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-master1.000002 <relay_log_pos> master-bin.000001 No No 0 0 <read_master_log_pos> <relay_log_space> None 0 No NULL No 0 0 1 No conservative 0 NULL 2 3 0
mysqld-relay-bin-master1.000001
mysqld-relay-bin-master1.000002
mysqld-relay-bin-master1.index
reset slave 'master1';
show slave 'master1' status;
-Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State
- 127.0.0.1 root MYPORT_1 60 4 <relay_log_pos> No No 0 0 0 <relay_log_space> None 0 No NULL No 0 0 1 No conservative 0 NULL
+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups
+ 127.0.0.1 root MYPORT_1 60 4 <relay_log_pos> No No 0 0 0 <relay_log_space> None 0 No NULL No 0 0 1 No conservative 0 NULL 2 3 0
reset slave 'master1' all;
show slave 'master1' status;
ERROR HY000: There is no master connection 'master1'
diff --git a/mysql-test/suite/multi_source/simple.result b/mysql-test/suite/multi_source/simple.result
index 419b995..93ea1c0 100644
--- a/mysql-test/suite/multi_source/simple.result
+++ b/mysql-test/suite/multi_source/simple.result
@@ -18,9 +18,9 @@ connection slave;
connection master2;
connection slave;
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats
Slave_h
eartbeat_period Gtid_Slave_Pos
-slave1 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave1.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 1 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 7 0 60.000
-slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_tra
nsaction
s Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+slave1 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave1.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 1 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 7 0 60.000
+slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 7 0 60.000
start all slaves;
stop slave 'slave1';
show slave 'slave1' status;
@@ -74,21 +74,24 @@ Parallel_Mode conservative
SQL_Delay 0
SQL_Remaining_Delay NULL
Slave_SQL_Running_State
+Slave_DDL_Groups 0
+Slave_Non_Transactional_Groups 0
+Slave_Transactional_Groups 0
reset slave 'slave1';
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats
Slave_h
eartbeat_period Gtid_Slave_Pos
-slave1 127.0.0.1 root MYPORT_1 60 4 <relay_log_pos> No No 0 0 0 <relay_log_space1> None 0 No NULL No 0 0 1 No conservative 0 NULL 0 1073741824 7 0 60.000
-slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_tra
nsaction
s Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+slave1 127.0.0.1 root MYPORT_1 60 4 <relay_log_pos> No No 0 0 0 <relay_log_space1> None 0 No NULL No 0 0 1 No conservative 0 NULL 0 0 0 0 1073741824 7 0 60.000
+slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 7 0 60.000
reset slave 'slave1' all;
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats
Slave_h
eartbeat_period Gtid_Slave_Pos
-slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_tra
nsaction
s Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 7 0 60.000
stop all slaves;
Warnings:
Note 1938 SLAVE 'slave2' stopped
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats
Slave_h
eartbeat_period Gtid_Slave_Pos
-slave2 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 No No 0 0 <read_master_log_pos> <relay_log_space1> None 0 No NULL No 0 0 2 No conservative 0 NULL 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_tra
nsaction
s Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+slave2 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 No No 0 0 <read_master_log_pos> <relay_log_space1> None 0 No NULL No 0 0 2 No conservative 0 NULL 0 0 0 0 1073741824 7 0 60.000
stop all slaves;
include/reset_master_slave.inc
disconnect slave;
diff --git a/mysql-test/suite/multi_source/syntax.result b/mysql-test/suite/multi_source/syntax.result
index a17a61d..35f4b30 100644
--- a/mysql-test/suite/multi_source/syntax.result
+++ b/mysql-test/suite/multi_source/syntax.result
@@ -1,11 +1,11 @@
include/master-slave.inc
[connection master]
show slave status;
-Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State
+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups
show slave '' status;
-Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State
+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats
Slave_h
eartbeat_period Gtid_Slave_Pos
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_tra
nsaction
s Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
#
# Check error handling
#
diff --git a/sql/log_event.cc b/sql/log_event.cc
index cd47cbb..67c58a1 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -53,6 +53,7 @@
#include "rpl_constants.h"
#include "sql_digest.h"
#include "zlib.h"
+#include "my_atomic.h"
#define my_b_write_string(A, B) my_b_write((A), (uchar*)(B), (uint) (sizeof(B) - 1))
@@ -7973,6 +7974,20 @@ Gtid_log_event::do_apply_event(rpl_group_info *rgi)
}
DBUG_ASSERT((bits & OPTION_GTID_BEGIN) == 0);
+
+ Master_info *mi=rgi->rli->mi;
+ switch (flags2 & (FL_DDL | FL_TRANSACTIONAL))
+ {
+ case FL_TRANSACTIONAL:
+ my_atomic_add64_explicit(&mi->total_trans_groups, 1, MY_MEMORY_ORDER_RELAXED);
+ break;
+ case FL_DDL:
+ my_atomic_add64_explicit(&mi->total_ddl_groups, 1, MY_MEMORY_ORDER_RELAXED);
+ break;
+ default:
+ my_atomic_add64_explicit(&mi->total_non_trans_groups, 1, MY_MEMORY_ORDER_RELAXED);
+ }
+
if (flags2 & FL_STANDALONE)
return 0;
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index 55a6671..1fc996b 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -42,7 +42,8 @@ Master_info::Master_info(LEX_CSTRING *connection_name_arg,
using_gtid(USE_GTID_NO), events_queued_since_last_gtid(0),
gtid_reconnect_event_skip_count(0), gtid_event_seen(false),
in_start_all_slaves(0), in_stop_all_slaves(0), in_flush_all_relay_logs(0),
- users(0), killed(0)
+ users(0), killed(0),
+ total_ddl_groups(0), total_non_trans_groups(0), total_trans_groups(0)
{
char *tmp;
host[0] = 0; user[0] = 0; password[0] = 0;
diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h
index 260c35e..54d6b5b 100644
--- a/sql/rpl_mi.h
+++ b/sql/rpl_mi.h
@@ -327,6 +327,16 @@ class Master_info : public Slave_reporting_capability
uint users; /* Active user for object */
uint killed;
+
+ /* No of DDL event group */
+ volatile uint64 total_ddl_groups;
+
+ /* No of non-transactional event group*/
+ volatile uint64 total_non_trans_groups;
+
+ /* No of transactional event group*/
+ volatile uint64 total_trans_groups;
+
/* domain-id based filter */
Domain_id_filter domain_id_filter;
diff --git a/sql/slave.cc b/sql/slave.cc
index bf70db6..a2cea8a 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -3121,6 +3121,19 @@ void show_master_info_get_fields(THD *thd, List<Item> *field_list,
field_list->push_back(new (mem_root)
Item_empty_string(thd, "Slave_SQL_Running_State",
20));
+ field_list->push_back(new (mem_root)
+ Item_return_int(thd, "Slave_DDL_Groups", 20,
+ MYSQL_TYPE_LONGLONG),
+ mem_root);
+ field_list->push_back(new (mem_root)
+ Item_return_int(thd, "Slave_Non_Transactional_Groups", 20,
+ MYSQL_TYPE_LONGLONG),
+ mem_root);
+ field_list->push_back(new (mem_root)
+ Item_return_int(thd, "Slave_Transactional_Groups", 20,
+ MYSQL_TYPE_LONGLONG),
+ mem_root);
+
if (full)
{
field_list->push_back(new (mem_root)
@@ -3351,6 +3364,17 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
// Slave_SQL_Running_State
protocol->store(slave_sql_running_state, &my_charset_bin);
+ uint64 events;
+ events= (uint64)my_atomic_load64_explicit((volatile int64 *)
+ &mi->total_ddl_groups, MY_MEMORY_ORDER_RELAXED);
+ protocol->store(events);
+ events= (uint64)my_atomic_load64_explicit((volatile int64 *)
+ &mi->total_non_trans_groups, MY_MEMORY_ORDER_RELAXED);
+ protocol->store(events);
+ events= (uint64)my_atomic_load64_explicit((volatile int64 *)
+ &mi->total_trans_groups, MY_MEMORY_ORDER_RELAXED);
+ protocol->store(events);
+
if (full)
{
protocol->store((uint32) mi->rli.retried_trans);
1
0

[Commits] f503b2a8e55: MDEV-15777: Support Early NULLs filtering-like restrictions in the range optimizer
by varunraiko1803ļ¼ gmail.com 19 Apr '18
by varunraiko1803ļ¼ gmail.com 19 Apr '18
19 Apr '18
revision-id: f503b2a8e55623726648bbb69bda92fbcebe75dd (mariadb-10.3.0-765-gf503b2a8e55)
parent(s): 91245909a2f0c89444ecb5af587284f53b7196ee
author: Varun Gupta
committer: Varun Gupta
timestamp: 2018-04-19 13:33:35 +0530
message:
MDEV-15777: Support Early NULLs filtering-like restrictions in the range optimizer
Improved patch with comments and test case added.
---
mysql-test/main/mdev15777.result | 65 ++++++++++++++++++++++++
mysql-test/main/mdev15777.test | 34 +++++++++++++
sql/opt_range.cc | 107 ++++++++++++++++++++++++++++++++++++++-
sql/opt_range.h | 3 ++
sql/sql_select.cc | 29 +++++++++--
5 files changed, 234 insertions(+), 4 deletions(-)
diff --git a/mysql-test/main/mdev15777.result b/mysql-test/main/mdev15777.result
new file mode 100644
index 00000000000..87167c16f6d
--- /dev/null
+++ b/mysql-test/main/mdev15777.result
@@ -0,0 +1,65 @@
+create table ten(a int);
+insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table one_k(a int);
+insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;
+create table one_m(a int);
+insert into one_m select A.a + B.a* 1000 from one_k A, one_k B;
+delete from one_m where a=0 limit 1;
+create table t1 (
+id int(10) unsigned NOT NULL AUTO_INCREMENT,
+filler varchar(100),
+subset_id int(11) DEFAULT NULL,
+PRIMARY KEY (id),
+KEY t1_subset_id (subset_id)
+);
+create table t1_subsets (
+id int(10) unsigned NOT NULL AUTO_INCREMENT,
+filler1 varchar(100),
+filler2 varchar(100),
+filler3 varchar(100),
+PRIMARY KEY (id)
+);
+insert into t1 select a,a, NULL from one_m where a < 50*1000;
+insert into t1_subsets select a,a,a,a from one_m where a < 500*1000 limit 499000;
+analyze format=json
+SELECT * FROM t1 WHERE t1.subset_id IN (SELECT t1_subsets.id FROM t1_subsets);
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": 0.0444,
+ "table": {
+ "table_name": "t1",
+ "access_type": "range",
+ "possible_keys": ["t1_subset_id"],
+ "key": "t1_subset_id",
+ "key_length": "5",
+ "used_key_parts": ["subset_id"],
+ "r_loops": 1,
+ "rows": 3,
+ "r_rows": 0,
+ "r_total_time_ms": 0.0146,
+ "filtered": 100,
+ "r_filtered": 100,
+ "index_condition": "t1.subset_id is not null"
+ },
+ "table": {
+ "table_name": "t1_subsets",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["id"],
+ "ref": ["test.t1.subset_id"],
+ "r_loops": 0,
+ "rows": 1,
+ "r_rows": null,
+ "filtered": 100,
+ "r_filtered": null,
+ "attached_condition": "t1.subset_id = t1_subsets.`id`",
+ "using_index": true
+ }
+ }
+}
+drop table t1,t1_subsets,ten,one_k,one_m;
diff --git a/mysql-test/main/mdev15777.test b/mysql-test/main/mdev15777.test
new file mode 100644
index 00000000000..ad5777aeecf
--- /dev/null
+++ b/mysql-test/main/mdev15777.test
@@ -0,0 +1,34 @@
+create table ten(a int);
+insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table one_k(a int);
+insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;
+
+create table one_m(a int);
+insert into one_m select A.a + B.a* 1000 from one_k A, one_k B;
+delete from one_m where a=0 limit 1;
+
+create table t1 (
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ filler varchar(100),
+ subset_id int(11) DEFAULT NULL,
+ PRIMARY KEY (id),
+ KEY t1_subset_id (subset_id)
+);
+
+create table t1_subsets (
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ filler1 varchar(100),
+ filler2 varchar(100),
+ filler3 varchar(100),
+ PRIMARY KEY (id)
+);
+
+insert into t1 select a,a, NULL from one_m where a < 50*1000;
+insert into t1_subsets select a,a,a,a from one_m where a < 500*1000 limit 499000;
+
+analyze format=json
+SELECT * FROM t1 WHERE t1.subset_id IN (SELECT t1_subsets.id FROM t1_subsets);
+drop table t1,t1_subsets,ten,one_k,one_m;
+
+
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 38dbed92a22..650b04166e7 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1184,6 +1184,7 @@ SQL_SELECT *make_select(TABLE *head, table_map const_tables,
select->const_tables=const_tables;
select->head=head;
select->cond= conds;
+ select->null_rejecting_conds= NULL;
if (filesort && my_b_inited(&filesort->io_cache))
{
@@ -2430,7 +2431,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
{
uchar buff[STACK_BUFF_ALLOC];
MEM_ROOT alloc;
- SEL_TREE *tree= NULL;
+ SEL_TREE *tree= NULL, *not_null_cond_tree= NULL;
KEY_PART *key_parts;
KEY *key_info;
PARAM param;
@@ -2539,6 +2540,12 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
TRP_GROUP_MIN_MAX *group_trp;
double best_read_time= read_time;
+ if (null_rejecting_conds)
+ {
+ not_null_cond_tree= null_rejecting_conds->get_mm_tree(¶m,
+ &null_rejecting_conds);
+ }
+
if (cond)
{
if ((tree= cond->get_mm_tree(¶m, &cond)))
@@ -2557,6 +2564,13 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
tree= NULL;
}
}
+ if (not_null_cond_tree)
+ {
+ if (!tree)
+ tree= not_null_cond_tree;
+ else
+ tree= tree_and(¶m, tree, not_null_cond_tree);
+ }
/*
Try to construct a QUICK_GROUP_MIN_MAX_SELECT.
@@ -14647,6 +14661,97 @@ void QUICK_GROUP_MIN_MAX_SELECT::add_keys_and_lengths(String *key_names,
add_key_and_length(key_names, used_lengths, &first);
}
+inline void add_cond(THD *thd, Item **e1, Item *e2)
+{
+ if (*e1)
+ {
+ if (!e2)
+ return;
+ Item *res;
+ if ((res= new (thd->mem_root) Item_cond_and(thd, *e1, e2)))
+ {
+ res->fix_fields(thd, 0);
+ res->update_used_tables();
+ *e1= res;
+ }
+ }
+ else
+ *e1= e2;
+}
+
+/*
+ Create null rejecting conditions for a table, for all the equalites
+ present in the WHERE clause of a query.
+
+ SYNOPSIS
+ make_null_rejecting_conds()
+ @param TABLE - Keys of this table will participate in null
+ rejecting conditions
+ @param keyuse_array - array that has all the equalites of the
+ WHERE clasuse
+
+ DESCRIPTION
+ This function creates null rejecting conditions for a table. These
+ conditions are created to do range analysis on them , the conditions
+ are of the form tbl.key.keypart IS NOT NULL.
+
+ IMPLEMENTATION
+ Lookup in the keyuse array to check if it has equalites that belong
+ to the given table. If yes then find out if the conditions are null
+ rejecting and accordingly create all the condition for the keys of a
+ given table and AND them.
+
+
+ RETURN
+ NOT NULL - Found null rejecting conditions for the given table
+ NULL - No null rejecting conditions for the given table
+*/
+
+Item* make_null_rejecting_conds(THD *thd, TABLE *table,
+ DYNAMIC_ARRAY *keyuse_array, key_map *const_keys)
+{
+ KEY *keyinfo;
+ Item *cond= NULL;
+ KEYUSE* keyuse;
+ for(uint i=0; i < keyuse_array->elements; i++)
+ {
+ KEYUSE* keyuse= (KEYUSE*)dynamic_array_ptr(keyuse_array, i);
+ if (keyuse->table == table)
+ {
+ keyinfo= keyuse->table->key_info+keyuse->key;
+ Field *field= keyinfo->key_part[keyuse->keypart].field;
+
+ /*
+ No need to add null-rejecting condition if we have a
+ keyuse element as
+ - table.key.keypart= const
+ - (table.key.keypart= tbl.otherfield or table.key.keypart IS NULL)
+ - table.key.keypart IS NOT NULLABLE
+ */
+
+ if (keyuse->val->const_item()
+ || !(keyuse->null_rejecting && field->maybe_null())
+ || keyuse->optimize & KEY_OPTIMIZE_REF_OR_NULL)
+ continue;
+
+ Item_field *field_item= new (thd->mem_root)Item_field(thd, field);
+ Item* not_null_item= new (thd->mem_root)Item_func_isnotnull(thd,
+ field_item);
+
+ /*
+ adding the key to const keys as we have the condition
+ as key.keypart IS NOT NULL
+ */
+
+ const_keys->set_bit(keyuse->key);
+ not_null_item->fix_fields(thd, 0);
+ not_null_item->update_used_tables();
+ add_cond(thd, &cond, not_null_item);
+ }
+ }
+ return cond;
+}
+
#ifndef DBUG_OFF
diff --git a/sql/opt_range.h b/sql/opt_range.h
index bd85a12d4a1..8ef0993e0af 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -1636,6 +1636,7 @@ class SQL_SELECT :public Sql_alloc {
/* See PARAM::possible_keys */
key_map possible_keys;
bool free_cond; /* Currently not used and always FALSE */
+ Item *null_rejecting_conds;
SQL_SELECT();
~SQL_SELECT();
@@ -1728,6 +1729,8 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond);
bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond);
#endif
void store_key_image_to_rec(Field *field, uchar *ptr, uint len);
+Item* make_null_rejecting_conds(THD *thd, TABLE *table,
+ DYNAMIC_ARRAY *keyuse_array, key_map *const_keys);
extern String null_string;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 796ea569e64..77a9e28501b 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -4242,6 +4242,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
SARGABLE_PARAM *sargables= 0;
List_iterator<TABLE_LIST> ti(tables_list);
TABLE_LIST *tables;
+ Item* null_rejecting_conds= NULL;
DBUG_ENTER("make_join_statistics");
table_count=join->table_count;
@@ -4783,6 +4784,9 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
add_group_and_distinct_keys(join, s);
s->table->cond_selectivity= 1.0;
+
+ null_rejecting_conds= make_null_rejecting_conds(join->thd, s->table,
+ keyuse_array, &s->const_keys);
/*
Perform range analysis if there are keys it could use (1).
@@ -4812,6 +4816,8 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
1, &error);
if (!select)
goto error;
+
+ select->null_rejecting_conds= null_rejecting_conds;
records= get_quick_record_count(join->thd, select, s->table,
&s->const_keys, join->row_limit);
/* Range analyzer could modify the condition. */
@@ -4824,6 +4830,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
s->needed_reg=select->needed_reg;
select->quick=0;
impossible_range= records == 0 && s->table->reginfo.impossible_range;
+ select->null_rejecting_conds= NULL;
}
if (!impossible_range)
{
@@ -4867,7 +4874,11 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
}
}
-
+ if (null_rejecting_conds)
+ {
+ delete null_rejecting_conds;
+ null_rejecting_conds= NULL;
+ }
if (pull_out_semijoin_tables(join))
DBUG_RETURN(TRUE);
@@ -5330,15 +5341,24 @@ add_key_field(JOIN *join,
If the condition has form "tbl.keypart = othertbl.field" and
othertbl.field can be NULL, there will be no matches if othertbl.field
has NULL value.
+
+ The field KEY_FIELD::null_rejecting is set to TRUE if we have both
+ the left and right hand side of the equality are NULLABLE
+
We use null_rejecting in add_not_null_conds() to add
'othertbl.field IS NOT NULL' to tab->select_cond.
+
+ We use null_rejecting in make_null_rejecting_conds() to add
+ tbl.keypart IS NOT NULL so we can do range analysis on this condition
+
*/
{
Item *real= (*value)->real_item();
if (((cond->functype() == Item_func::EQ_FUNC) ||
(cond->functype() == Item_func::MULT_EQUAL_FUNC)) &&
- (real->type() == Item::FIELD_ITEM) &&
+ (((real->type() == Item::FIELD_ITEM) &&
((Item_field*)real)->field->maybe_null())
+ ||(field->maybe_null())))
(*key_fields)->null_rejecting= true;
else
(*key_fields)->null_rejecting= false;
@@ -9794,7 +9814,10 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j,
uint maybe_null= MY_TEST(keyinfo->key_part[i].null_bit);
j->ref.items[i]=keyuse->val; // Save for cond removal
j->ref.cond_guards[i]= keyuse->cond_guard;
- if (keyuse->null_rejecting)
+ Item *real= (keyuse->val)->real_item();
+ if (keyuse->null_rejecting &&
+ (real->type() == Item::FIELD_ITEM) &&
+ ((Item_field*)real)->field->maybe_null())
j->ref.null_rejecting|= (key_part_map)1 << i;
keyuse_uses_no_tables= keyuse_uses_no_tables && !keyuse->used_tables;
/*
1
0

[Commits] ac82fe4: Mdev-10664 Add statuses about optimistic parallel replication stalls
by sachin 19 Apr '18
by sachin 19 Apr '18
19 Apr '18
revision-id: ac82fe41fd233d0883cbf0ca6088c6a282bea906 (mariadb-10.3.5-25-gac82fe4)
parent(s): ad647cc84ebf331d59b24e81bffe89be2f5b1ed7
author: Sachin Setiya
committer: Sachin Setiya
timestamp: 2018-04-19 12:19:40 +0530
message:
Mdev-10664 Add statuses about optimistic parallel replication stalls
In this commit we are adding three more status variable to SHOW SLAVE
STATUS. Slave_DDL_Events and Slave_Non_Transactional_Events.
Slave_DDL_Groups:- This status variable counts the occurrence of DDL
statements
Slave_Non_Transactional_Groups:- This variable count the occurrence
of non-transnational event group.
Slave_Transactional_Groups:- This variable count the occurrence
of transnational event group.
Patch Credit:- Kristian Nielsen
---
mysql-test/include/check-testcase.test | 5 +-
mysql-test/suite/multi_source/info_logs.result | 12 +-
mysql-test/suite/multi_source/multi_parallel.cnf | 6 +
.../suite/multi_source/multi_parallel.result | 67 +++++++++++
mysql-test/suite/multi_source/multi_parallel.test | 125 +++++++++++++++++++++
.../suite/multi_source/multi_parallel_loop.inc | 19 ++++
mysql-test/suite/multi_source/reset_slave.result | 8 +-
mysql-test/suite/multi_source/simple.result | 23 ++--
mysql-test/suite/multi_source/syntax.result | 6 +-
sql/log_event.cc | 15 +++
sql/rpl_mi.cc | 3 +-
sql/rpl_mi.h | 10 ++
sql/slave.cc | 24 ++++
13 files changed, 298 insertions(+), 25 deletions(-)
diff --git a/mysql-test/include/check-testcase.test b/mysql-test/include/check-testcase.test
index 4ca5398..3c164ee 100644
--- a/mysql-test/include/check-testcase.test
+++ b/mysql-test/include/check-testcase.test
@@ -70,10 +70,13 @@ if ($tmp)
--echo SQL_Delay 0
--echo SQL_Remaining_Delay NULL
--echo Slave_SQL_Running_State
+ --echo Slave_DDL_Groups #
+ --echo Slave_Non_Transactional_Groups #
+ --echo Slave_Transactional_Groups #
}
if (!$tmp) {
# Note: after WL#5177, fields 13-18 shall not be filtered-out.
- --replace_column 4 # 5 # 6 # 7 # 8 # 9 # 10 # 13 # 14 # 15 # 16 # 17 # 18 # 22 # 23 # 24 # 25 # 26 # 40 # 41 # 42 # 44 #
+ --replace_column 4 # 5 # 6 # 7 # 8 # 9 # 10 # 13 # 14 # 15 # 16 # 17 # 18 # 22 # 23 # 24 # 25 # 26 # 40 # 41 # 42 # 44 # 51 # 52 # 53 #
query_vertical
SHOW SLAVE STATUS;
}
diff --git a/mysql-test/suite/multi_source/info_logs.result b/mysql-test/suite/multi_source/info_logs.result
index e177c98..531a617 100644
--- a/mysql-test/suite/multi_source/info_logs.result
+++ b/mysql-test/suite/multi_source/info_logs.result
@@ -89,17 +89,17 @@ MASTER 2.2
# EOF
#
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats
Slave_h
eartbeat_period Gtid_Slave_Pos
- Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> relay.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 1 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 7 0 60.000
-MASTER 2.2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> relay-master@00202@002e2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space2> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_tra
nsaction
s Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+ Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> relay.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 1 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 7 0 60.000
+MASTER 2.2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> relay-master@00202@002e2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space2> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 7 0 60.000
include/wait_for_slave_to_start.inc
set default_master_connection = 'MASTER 2.2';
include/wait_for_slave_to_start.inc
set default_master_connection = '';
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats
Slave_h
eartbeat_period Gtid_Slave_Pos
- Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> relay.000004 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 1 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 6 0 60.000
-MASTER 2.2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> relay-master@00202@002e2.000004 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space2> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 6 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_tra
nsaction
s Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+ Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> relay.000004 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 1 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 6 0 60.000
+MASTER 2.2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> relay-master@00202@002e2.000004 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space2> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 6 0 60.000
#
# List of files matching '*info*' pattern
# after slave server restart
diff --git a/mysql-test/suite/multi_source/multi_parallel.cnf b/mysql-test/suite/multi_source/multi_parallel.cnf
new file mode 100644
index 0000000..0f0dc5c
--- /dev/null
+++ b/mysql-test/suite/multi_source/multi_parallel.cnf
@@ -0,0 +1,6 @@
+!include my.cnf
+[mysqld.1]
+gtid_domain_id=1
+
+[mysqld.2]
+gtid_domain_id=2
diff --git a/mysql-test/suite/multi_source/multi_parallel.result b/mysql-test/suite/multi_source/multi_parallel.result
new file mode 100644
index 0000000..ff87e0b
--- /dev/null
+++ b/mysql-test/suite/multi_source/multi_parallel.result
@@ -0,0 +1,67 @@
+connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1;
+connect master2,127.0.0.1,root,,,$SERVER_MYPORT_2;
+connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3;
+set global slave_parallel_threads=10;
+change master 'master1' to
+master_port=MYPORT_1,
+master_host='127.0.0.1',
+master_user='root';
+change master 'master2' to
+master_port=MYPORT_2,
+master_host='127.0.0.1',
+master_user='root';
+start all slaves;
+Warnings:
+Note 1937 SLAVE 'master2' started
+Note 1937 SLAVE 'master1' started
+set default_master_connection = 'master1';
+include/wait_for_slave_to_start.inc
+set default_master_connection = 'master2';
+include/wait_for_slave_to_start.inc
+## Slave status variable
+set default_master_connection = 'master1';
+show status like 'slave_running';
+Variable_name Value
+Slave_running ON
+set default_master_connection = 'master2';
+show status like 'slave_running';
+Variable_name Value
+Slave_running ON
+#master 1
+connection master1;
+##Running CURD operation
+connection slave;
+Slave_DDL_Groups= 20;
+Slave_Non_Transactional_Groups= 40;
+Slave__Transactional_Groups= 0;
+#master 2
+connection master2;
+##Running CURD operation
+connection slave;
+Slave_DDL_Groups= 20;
+Slave_Non_Transactional_Groups= 40;
+Slave_Transactional_Groups= 0;
+#master 1
+connection master1;
+##Running CURD operation
+connection slave;
+Slave_DDL_Groups= 40;
+Slave_Non_Transactional_Groups= 60;
+Slave_Transactional_Groups= 20;
+stop all slaves;
+Warnings:
+Note 1938 SLAVE 'master2' stopped
+Note 1938 SLAVE 'master1' stopped
+set default_master_connection = 'master1';
+include/wait_for_slave_to_stop.inc
+set default_master_connection = 'master2';
+include/wait_for_slave_to_stop.inc
+set global slave_parallel_threads=0;
+include/reset_master_slave.inc
+disconnect slave;
+connection master1;
+include/reset_master_slave.inc
+disconnect master1;
+connection master2;
+include/reset_master_slave.inc
+disconnect master2;
diff --git a/mysql-test/suite/multi_source/multi_parallel.test b/mysql-test/suite/multi_source/multi_parallel.test
new file mode 100644
index 0000000..988ec43
--- /dev/null
+++ b/mysql-test/suite/multi_source/multi_parallel.test
@@ -0,0 +1,125 @@
+# This test file tests events counter like Slave_ddl_groups,
+# Slave_non_transactional_groups, Slave_transactional_groups
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+--let $rpl_server_count= 0
+
+--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1)
+--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2)
+--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
+
+#save state
+--let $par_thd= `select @@slave_parallel_threads;`
+
+set global slave_parallel_threads=10;
+
+--replace_result $SERVER_MYPORT_1 MYPORT_1
+eval change master 'master1' to
+master_port=$SERVER_MYPORT_1,
+master_host='127.0.0.1',
+master_user='root';
+
+--replace_result $SERVER_MYPORT_2 MYPORT_2
+eval change master 'master2' to
+master_port=$SERVER_MYPORT_2,
+master_host='127.0.0.1',
+master_user='root';
+
+
+#start all slaves
+
+start all slaves;
+
+set default_master_connection = 'master1';
+--source include/wait_for_slave_to_start.inc
+
+set default_master_connection = 'master2';
+--source include/wait_for_slave_to_start.inc
+
+--echo ## Slave status variable
+
+set default_master_connection = 'master1';
+show status like 'slave_running';
+
+set default_master_connection = 'master2';
+show status like 'slave_running';
+
+
+--echo #master 1
+--connection master1
+
+--let $loop_counter=10
+--let $table_engine=myisam
+--source multi_parallel_loop.inc
+--save_master_pos
+
+--connection slave
+
+--sync_with_master 0,'master1'
+--let $status= query_get_value(show slave 'master1' status, Slave_DDL_Groups, 1)
+--echo Slave_DDL_Groups= $status;
+
+--let $status= query_get_value(show slave 'master1' status, Slave_Non_Transactional_Groups, 1)
+--echo Slave_Non_Transactional_Groups= $status;
+
+--let $status= query_get_value(show slave 'master1' status, Slave_Transactional_Groups, 1)
+--echo Slave__Transactional_Groups= $status;
+
+--echo #master 2
+--connection master2
+
+--let $loop_counter=10
+--let $table_engine=myisam
+--source multi_parallel_loop.inc
+--save_master_pos
+
+--connection slave
+--sync_with_master 0,'master2'
+--let $status= query_get_value(show slave 'master2' status, Slave_DDL_Groups, 1)
+--echo Slave_DDL_Groups= $status;
+
+--let $status= query_get_value(show slave 'master2' status, Slave_Non_Transactional_Groups, 1)
+--echo Slave_Non_Transactional_Groups= $status;
+
+--let $status= query_get_value(show slave 'master2' status, Slave_Transactional_Groups, 1)
+--echo Slave_Transactional_Groups= $status;
+
+--echo #master 1
+--connection master1
+
+--let $loop_counter=10
+--let $table_engine=innodb
+--source multi_parallel_loop.inc
+--save_master_pos
+
+--connection slave
+
+--sync_with_master 0,'master1'
+--let $status= query_get_value(show slave 'master1' status, Slave_DDL_Groups, 1)
+--echo Slave_DDL_Groups= $status;
+
+--let $status= query_get_value(show slave 'master1' status, Slave_Non_Transactional_Groups, 1)
+--echo Slave_Non_Transactional_Groups= $status;
+
+--let $status= query_get_value(show slave 'master1' status, Slave_Transactional_Groups, 1)
+--echo Slave_Transactional_Groups= $status;
+
+
+# Cleanup
+stop all slaves;
+set default_master_connection = 'master1';
+--source include/wait_for_slave_to_stop.inc
+
+set default_master_connection = 'master2';
+--source include/wait_for_slave_to_stop.inc
+
+--eval set global slave_parallel_threads=$par_thd
+
+--source include/reset_master_slave.inc
+--disconnect slave
+--connection master1
+--source include/reset_master_slave.inc
+--disconnect master1
+--connection master2
+--source include/reset_master_slave.inc
+--disconnect master2
diff --git a/mysql-test/suite/multi_source/multi_parallel_loop.inc b/mysql-test/suite/multi_source/multi_parallel_loop.inc
new file mode 100644
index 0000000..bf692b2
--- /dev/null
+++ b/mysql-test/suite/multi_source/multi_parallel_loop.inc
@@ -0,0 +1,19 @@
+#create a table,insert data and drop table
+
+#parameters
+# loop_counter
+# table_engine
+--echo ##Running CURD operation
+--disable_query_log
+while ($loop_counter)
+{
+ #DDL statement
+ --eval create table t1(a int primary key) engine=$table_engine;
+
+ #non trans update statement
+ insert into t1 values(1);
+ insert into t1 values(2);
+ drop table t1;
+ --dec $loop_counter
+}
+--enable_query_log
diff --git a/mysql-test/suite/multi_source/reset_slave.result b/mysql-test/suite/multi_source/reset_slave.result
index 353970a..4f66c8f 100644
--- a/mysql-test/suite/multi_source/reset_slave.result
+++ b/mysql-test/suite/multi_source/reset_slave.result
@@ -13,15 +13,15 @@ insert into t1 values (1),(2);
connection slave;
stop slave 'master1';
show slave 'master1' status;
-Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State
- 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-master1.000002 <relay_log_pos> master-bin.000001 No No 0 0 <read_master_log_pos> <relay_log_space> None 0 No NULL No 0 0 1 No conservative 0 NULL
+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups
+ 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-master1.000002 <relay_log_pos> master-bin.000001 No No 0 0 <read_master_log_pos> <relay_log_space> None 0 No NULL No 0 0 1 No conservative 0 NULL 2 3 0
mysqld-relay-bin-master1.000001
mysqld-relay-bin-master1.000002
mysqld-relay-bin-master1.index
reset slave 'master1';
show slave 'master1' status;
-Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State
- 127.0.0.1 root MYPORT_1 60 4 <relay_log_pos> No No 0 0 0 <relay_log_space> None 0 No NULL No 0 0 1 No conservative 0 NULL
+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups
+ 127.0.0.1 root MYPORT_1 60 4 <relay_log_pos> No No 0 0 0 <relay_log_space> None 0 No NULL No 0 0 1 No conservative 0 NULL 2 3 0
reset slave 'master1' all;
show slave 'master1' status;
ERROR HY000: There is no master connection 'master1'
diff --git a/mysql-test/suite/multi_source/simple.result b/mysql-test/suite/multi_source/simple.result
index 419b995..93ea1c0 100644
--- a/mysql-test/suite/multi_source/simple.result
+++ b/mysql-test/suite/multi_source/simple.result
@@ -18,9 +18,9 @@ connection slave;
connection master2;
connection slave;
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats
Slave_h
eartbeat_period Gtid_Slave_Pos
-slave1 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave1.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 1 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 7 0 60.000
-slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_tra
nsaction
s Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+slave1 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave1.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 1 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 7 0 60.000
+slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 7 0 60.000
start all slaves;
stop slave 'slave1';
show slave 'slave1' status;
@@ -74,21 +74,24 @@ Parallel_Mode conservative
SQL_Delay 0
SQL_Remaining_Delay NULL
Slave_SQL_Running_State
+Slave_DDL_Groups 0
+Slave_Non_Transactional_Groups 0
+Slave_Transactional_Groups 0
reset slave 'slave1';
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats
Slave_h
eartbeat_period Gtid_Slave_Pos
-slave1 127.0.0.1 root MYPORT_1 60 4 <relay_log_pos> No No 0 0 0 <relay_log_space1> None 0 No NULL No 0 0 1 No conservative 0 NULL 0 1073741824 7 0 60.000
-slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_tra
nsaction
s Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+slave1 127.0.0.1 root MYPORT_1 60 4 <relay_log_pos> No No 0 0 0 <relay_log_space1> None 0 No NULL No 0 0 1 No conservative 0 NULL 0 0 0 0 1073741824 7 0 60.000
+slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 7 0 60.000
reset slave 'slave1' all;
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats
Slave_h
eartbeat_period Gtid_Slave_Pos
-slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_tra
nsaction
s Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+slave2 Slave has read all relay log; waiting for the slave I/O thread to update it Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 2 No conservative 0 NULL Slave has read all relay log; waiting for the slave I/O thread to update it 0 0 0 0 1073741824 7 0 60.000
stop all slaves;
Warnings:
Note 1938 SLAVE 'slave2' stopped
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats
Slave_h
eartbeat_period Gtid_Slave_Pos
-slave2 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 No No 0 0 <read_master_log_pos> <relay_log_space1> None 0 No NULL No 0 0 2 No conservative 0 NULL 0 1073741824 7 0 60.000
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_tra
nsaction
s Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
+slave2 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 No No 0 0 <read_master_log_pos> <relay_log_space1> None 0 No NULL No 0 0 2 No conservative 0 NULL 0 0 0 0 1073741824 7 0 60.000
stop all slaves;
include/reset_master_slave.inc
disconnect slave;
diff --git a/mysql-test/suite/multi_source/syntax.result b/mysql-test/suite/multi_source/syntax.result
index a17a61d..35f4b30 100644
--- a/mysql-test/suite/multi_source/syntax.result
+++ b/mysql-test/suite/multi_source/syntax.result
@@ -1,11 +1,11 @@
include/master-slave.inc
[connection master]
show slave status;
-Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State
+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups
show slave '' status;
-Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State
+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups
show all slaves status;
-Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats
Slave_h
eartbeat_period Gtid_Slave_Pos
+Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_tra
nsaction
s Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos
#
# Check error handling
#
diff --git a/sql/log_event.cc b/sql/log_event.cc
index cd47cbb..acda255 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -53,6 +53,7 @@
#include "rpl_constants.h"
#include "sql_digest.h"
#include "zlib.h"
+#include "my_atomic.h"
#define my_b_write_string(A, B) my_b_write((A), (uchar*)(B), (uint) (sizeof(B) - 1))
@@ -7973,6 +7974,20 @@ Gtid_log_event::do_apply_event(rpl_group_info *rgi)
}
DBUG_ASSERT((bits & OPTION_GTID_BEGIN) == 0);
+
+ Master_info *mi=rgi->rli->mi;
+ switch (flags2 & (FL_DDL | FL_TRANSACTIONAL))
+ {
+ case FL_TRANSACTIONAL:
+ my_atomic_add64_explicit(&mi->total_trans_groups, 1, MY_MEMORY_ORDER_RELAXED);
+ break;
+ case FL_DDL:
+ my_atomic_add64_explicit(&mi->total_ddl_groups, 1, MY_MEMORY_ORDER_RELAXED);
+ //TODO add break when we start supporting Transactional DDL
+ default:
+ my_atomic_add64_explicit(&mi->total_non_trans_groups, 1, MY_MEMORY_ORDER_RELAXED);
+ }
+
if (flags2 & FL_STANDALONE)
return 0;
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index 55a6671..1fc996b 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -42,7 +42,8 @@ Master_info::Master_info(LEX_CSTRING *connection_name_arg,
using_gtid(USE_GTID_NO), events_queued_since_last_gtid(0),
gtid_reconnect_event_skip_count(0), gtid_event_seen(false),
in_start_all_slaves(0), in_stop_all_slaves(0), in_flush_all_relay_logs(0),
- users(0), killed(0)
+ users(0), killed(0),
+ total_ddl_groups(0), total_non_trans_groups(0), total_trans_groups(0)
{
char *tmp;
host[0] = 0; user[0] = 0; password[0] = 0;
diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h
index 260c35e..54d6b5b 100644
--- a/sql/rpl_mi.h
+++ b/sql/rpl_mi.h
@@ -327,6 +327,16 @@ class Master_info : public Slave_reporting_capability
uint users; /* Active user for object */
uint killed;
+
+ /* No of DDL event group */
+ volatile uint64 total_ddl_groups;
+
+ /* No of non-transactional event group*/
+ volatile uint64 total_non_trans_groups;
+
+ /* No of transactional event group*/
+ volatile uint64 total_trans_groups;
+
/* domain-id based filter */
Domain_id_filter domain_id_filter;
diff --git a/sql/slave.cc b/sql/slave.cc
index bf70db6..a2cea8a 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -3121,6 +3121,19 @@ void show_master_info_get_fields(THD *thd, List<Item> *field_list,
field_list->push_back(new (mem_root)
Item_empty_string(thd, "Slave_SQL_Running_State",
20));
+ field_list->push_back(new (mem_root)
+ Item_return_int(thd, "Slave_DDL_Groups", 20,
+ MYSQL_TYPE_LONGLONG),
+ mem_root);
+ field_list->push_back(new (mem_root)
+ Item_return_int(thd, "Slave_Non_Transactional_Groups", 20,
+ MYSQL_TYPE_LONGLONG),
+ mem_root);
+ field_list->push_back(new (mem_root)
+ Item_return_int(thd, "Slave_Transactional_Groups", 20,
+ MYSQL_TYPE_LONGLONG),
+ mem_root);
+
if (full)
{
field_list->push_back(new (mem_root)
@@ -3351,6 +3364,17 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
// Slave_SQL_Running_State
protocol->store(slave_sql_running_state, &my_charset_bin);
+ uint64 events;
+ events= (uint64)my_atomic_load64_explicit((volatile int64 *)
+ &mi->total_ddl_groups, MY_MEMORY_ORDER_RELAXED);
+ protocol->store(events);
+ events= (uint64)my_atomic_load64_explicit((volatile int64 *)
+ &mi->total_non_trans_groups, MY_MEMORY_ORDER_RELAXED);
+ protocol->store(events);
+ events= (uint64)my_atomic_load64_explicit((volatile int64 *)
+ &mi->total_trans_groups, MY_MEMORY_ORDER_RELAXED);
+ protocol->store(events);
+
if (full)
{
protocol->store((uint32) mi->rli.retried_trans);
1
0

[Commits] 346c8ab9533: MDEV-11975: SQLCOM_PREPARE of EXPLAIN & ANALYZE statement do not return correct metadata info
by Oleksandr Byelkin 18 Apr '18
by Oleksandr Byelkin 18 Apr '18
18 Apr '18
revision-id: 346c8ab9533a3de6a4cb348428402ffee2aa8da2 (mariadb-10.3.6-16-g346c8ab9533)
parent(s): cff60be7fe159fdcb2517ce8441610ad512aa7d0
author: Oleksandr Byelkin
committer: Oleksandr Byelkin
timestamp: 2018-04-18 19:34:12 +0200
message:
MDEV-11975: SQLCOM_PREPARE of EXPLAIN & ANALYZE statement do not return correct metadata info
Added metadate info after prepare EXPLAIN/ANALYZE.
---
mysql-test/main/mysql_client_test.result | 122 ++++++++++++
mysql-test/main/mysql_client_test.test | 7 +-
sql/sql_class.cc | 18 +-
sql/sql_class.h | 3 +-
sql/sql_explain.cc | 3 +-
sql/sql_parse.cc | 5 +-
sql/sql_prepare.cc | 24 ++-
sql/sql_prepare.h | 2 +
tests/mysql_client_test.c | 323 ++++++++++++++++++++++++++++++-
9 files changed, 493 insertions(+), 14 deletions(-)
diff --git a/mysql-test/main/mysql_client_test.result b/mysql-test/main/mysql_client_test.result
index 83ef8d442b3..20385acfa00 100644
--- a/mysql-test/main/mysql_client_test.result
+++ b/mysql-test/main/mysql_client_test.result
@@ -122,5 +122,127 @@ EOF
mysql_stmt_next_result(): 0; field_count: 0
# ------------------------------------
+# cat MYSQL_TMP_DIR/test_explain_meta.out.log
+# ------------------------------------
+SELECT number of fields: 1
+EXPALIN number of fields: 10
+ - 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
+ - 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
+ - 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
+ - 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
+ - 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
+ - 9: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
+EXPALIN JSON number of fields: 1
+ - 0: name: 'EXPLAIN'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
+ANALYZE number of fields: 13
+ - 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
+ - 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
+ - 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
+ - 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
+ - 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
+ - 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
+ - 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
+ - 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
+ - 12: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
+ANALYZE JSON number of fields: 1
+ - 0: name: 'ANALYZE'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
+EXPALIN INSERT number of fields: 10
+ - 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
+ - 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
+ - 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
+ - 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
+ - 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
+ - 9: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
+EXPALIN JSON INSERT number of fields: 1
+ - 0: name: 'EXPLAIN'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
+ANALYZE INSERT number of fields: 13
+ - 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
+ - 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
+ - 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
+ - 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
+ - 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
+ - 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
+ - 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
+ - 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
+ - 12: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
+ANALYZE JSON INSERT number of fields: 1
+ - 0: name: 'ANALYZE'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
+EXPALIN UPDATE number of fields: 10
+ - 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
+ - 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
+ - 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
+ - 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
+ - 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
+ - 9: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
+EXPALIN JSON UPDATE number of fields: 1
+ - 0: name: 'EXPLAIN'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
+ANALYZE UPDATE number of fields: 13
+ - 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
+ - 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
+ - 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
+ - 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
+ - 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
+ - 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
+ - 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
+ - 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
+ - 12: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
+ANALYZE JSON UPDATE number of fields: 1
+ - 0: name: 'ANALYZE'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
+EXPALIN DELETE number of fields: 10
+ - 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
+ - 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
+ - 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
+ - 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
+ - 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
+ - 9: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
+EXPALIN JSON DELETE number of fields: 1
+ - 0: name: 'EXPLAIN'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
+ANALYZE DELETE number of fields: 13
+ - 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
+ - 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
+ - 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
+ - 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
+ - 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
+ - 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
+ - 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
+ - 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
+ - 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
+ - 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
+ - 12: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
+ANALYZE JSON DELETE number of fields: 1
+ - 0: name: 'ANALYZE'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
+# ------------------------------------
+
+
SET @@global.general_log= @old_general_log;
SET @@global.slow_query_log= @old_slow_query_log;
diff --git a/mysql-test/main/mysql_client_test.test b/mysql-test/main/mysql_client_test.test
index 260473aa0d0..79ad9f84477 100644
--- a/mysql-test/main/mysql_client_test.test
+++ b/mysql-test/main/mysql_client_test.test
@@ -28,6 +28,11 @@ echo ok;
--cat_file $MYSQL_TMP_DIR/test_wl4435.out.log
--echo # ------------------------------------
--echo
-
+--echo # cat MYSQL_TMP_DIR/test_explain_meta.out.log
+--echo # ------------------------------------
+--cat_file $MYSQL_TMP_DIR/test_explain_meta.out.log
+--echo # ------------------------------------
+--echo
+--echo
SET @@global.general_log= @old_general_log;
SET @@global.slow_query_log= @old_slow_query_log;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 96485ed15ec..349ec576264 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -69,6 +69,7 @@
#include "wsrep_thd.h"
#include "sql_connect.h"
#include "my_atomic.h"
+#include "sql_prepare.h"
#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h>
@@ -2659,18 +2660,27 @@ CHANGED_TABLE_LIST* THD::changed_table_dup(const char *key, size_t key_length)
}
-int THD::send_explain_fields(select_result *result, uint8 explain_flags, bool is_analyze)
+int THD::send_explain_fields(select_result *result,
+ uint8 explain_flags,
+ bool is_analyze,
+ Prepared_statement *stmt)
{
List<Item> field_list;
+ int rc;
if (lex->explain_json)
make_explain_json_field_list(field_list, is_analyze);
else
make_explain_field_list(field_list, explain_flags, is_analyze);
result->prepare(field_list, NULL);
- return (result->send_result_set_metadata(field_list,
- Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF));
+ if (stmt)
+ rc= send_prep_stmt(stmt, result->field_count(field_list)) ||
+ result->send_result_set_metadata(field_list, Protocol::SEND_EOF);
+ else
+ rc= result->send_result_set_metadata(field_list,
+ Protocol::SEND_NUM_ROWS |
+ Protocol::SEND_EOF);
+ return(rc);
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index a7c33cbc504..706b72d9d06 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -2174,6 +2174,7 @@ struct QUERY_START_TIME_INFO
extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
+class Prepared_statement;
/**
@class THD
For each client connection we create a separate thread with THD serving as
@@ -3739,7 +3740,7 @@ class THD :public Statement,
void add_changed_table(const char *key, size_t key_length);
CHANGED_TABLE_LIST * changed_table_dup(const char *key, size_t key_length);
int send_explain_fields(select_result *result, uint8 explain_flags,
- bool is_analyze);
+ bool is_analyze, Prepared_statement *stmt);
void make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
bool is_analyze);
void make_explain_json_field_list(List<Item> &field_list, bool is_analyze);
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 5d977c6d5c2..96374fc1a33 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -164,7 +164,8 @@ int Explain_query::send_explain(THD *thd)
LEX *lex= thd->lex;
if (!(result= new (thd->mem_root) select_send(thd)) ||
- thd->send_explain_fields(result, lex->describe, lex->analyze_stmt))
+ thd->send_explain_fields(result, lex->describe, lex->analyze_stmt,
+ NULL))
return 1;
int res= 0;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 2593bac7462..fa8279d9d6f 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -6469,8 +6469,9 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
*/
if (!(result= new (thd->mem_root) select_send(thd)))
return 1; /* purecov: inspected */
- thd->send_explain_fields(result, lex->describe, lex->analyze_stmt);
-
+ thd->send_explain_fields(result, lex->describe, lex->analyze_stmt,
+ NULL);
+
/*
This will call optimize() for all parts of query. The query plan is
printed out below.
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 24f3cc66c6b..b9016e72410 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -356,7 +356,7 @@ find_prepared_statement(THD *thd, ulong id)
*/
#ifndef EMBEDDED_LIBRARY
-static bool send_prep_stmt(Prepared_statement *stmt, uint columns)
+bool send_prep_stmt(Prepared_statement *stmt, uint columns)
{
NET *net= &stmt->thd->net;
uchar buff[12];
@@ -394,7 +394,7 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns)
DBUG_RETURN(error);
}
#else
-static bool send_prep_stmt(Prepared_statement *stmt,
+bool send_prep_stmt(Prepared_statement *stmt,
uint columns __attribute__((unused)))
{
THD *thd= stmt->thd;
@@ -2500,8 +2500,24 @@ static bool check_prepared_statement(Prepared_statement *stmt)
break;
}
if (res == 0)
- DBUG_RETURN(stmt->is_sql_prepare() ?
- FALSE : (send_prep_stmt(stmt, 0) || thd->protocol->flush()));
+ {
+ if (!stmt->is_sql_prepare())
+ {
+ if (lex->describe || lex->analyze_stmt)
+ {
+ if (!lex->result &&
+ !(lex->result= new (stmt->mem_root) select_send(thd)))
+ DBUG_RETURN(TRUE);
+ res= thd->send_explain_fields(lex->result, lex->describe,
+ lex->analyze_stmt, stmt);
+ }
+ else
+ res= send_prep_stmt(stmt, 0);
+ if (!res)
+ thd->protocol->flush();
+ }
+ DBUG_RETURN(FALSE);
+ }
error:
DBUG_RETURN(TRUE);
}
diff --git a/sql/sql_prepare.h b/sql/sql_prepare.h
index ca040da341f..ce6d9df22d0 100644
--- a/sql/sql_prepare.h
+++ b/sql/sql_prepare.h
@@ -83,6 +83,8 @@ void mysqld_stmt_fetch(THD *thd, char *packet, uint packet_length);
void mysqld_stmt_reset(THD *thd, char *packet);
void mysql_stmt_get_longdata(THD *thd, char *pos, ulong packet_length);
void reinit_stmt_before_use(THD *thd, LEX *lex);
+class Prepared_statement;
+bool send_prep_stmt(Prepared_statement *stmt, uint columns);
my_bool bulk_parameters_iterations(THD *thd);
my_bool bulk_parameters_set(THD *thd);
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index e90453411cb..b2177c660de 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -1056,6 +1056,7 @@ static void test_wl4435_2()
rc= mysql_query(mysql, "DROP PROCEDURE p1");
myquery(rc);
}
+ mct_close_log();
}
@@ -20235,9 +20236,328 @@ static void test_proxy_header()
test_proxy_header_localhost();
test_proxy_header_ignore();
}
-
#endif
+static void print_metadata(MYSQL_RES *rs_metadata, int num_fields)
+{
+ MYSQL_FIELD *fields= mysql_fetch_fields(rs_metadata);
+
+ for (int i = 0; i < num_fields; ++i)
+ {
+ mct_log(" - %d: name: '%s'/'%s'; table: '%s'/'%s'; "
+ "db: '%s'; catalog: '%s'; length: %d; max_length: %d; "
+ "type: %d; decimals: %d\n",
+ (int) i,
+ (const char *) fields[i].name,
+ (const char *) fields[i].org_name,
+ (const char *) fields[i].table,
+ (const char *) fields[i].org_table,
+ (const char *) fields[i].db,
+ (const char *) fields[i].catalog,
+ (int) fields[i].length,
+ (int) fields[i].max_length,
+ (int) fields[i].type,
+ (int) fields[i].decimals);
+
+ }
+}
+
+static void test_explain_meta()
+{
+ MYSQL_STMT *stmt;
+ int num_fields;
+ char query[MAX_TEST_QUERY_LENGTH];
+ MYSQL_RES *rs_metadata;
+ int rc;
+
+ myheader("test_explain_meta");
+ mct_start_logging("test_explain_meta");
+
+ strmov(query, "SELECT 1");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("SELECT number of fields: %d\n", (int) num_fields);
+ if (num_fields != 1)
+ {
+ mct_close_log();
+ DIE("num_fields != 1");
+ }
+ mysql_stmt_close(stmt);
+
+ strmov(query, "EXPLAIN SELECT 1");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("EXPALIN number of fields: %d\n", (int) num_fields);
+ if (num_fields != 10)
+ {
+ mct_close_log();
+ DIE("num_fields != 10");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+ strmov(query, "EXPLAIN format=json SELECT 1");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("EXPALIN JSON number of fields: %d\n", (int) num_fields);
+ if (num_fields != 1)
+ {
+ mct_close_log();
+ DIE("num_fields != 1");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+
+ strmov(query, "ANALYZE SELECT 1");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("ANALYZE number of fields: %d\n", (int) num_fields);
+ if (num_fields != 13)
+ {
+ mct_close_log();
+ DIE("num_fields != 13");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+ strmov(query, "ANALYZE format=json SELECT 1");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("ANALYZE JSON number of fields: %d\n", (int) num_fields);
+ if (num_fields != 1)
+ {
+ mct_close_log();
+ DIE("num_fields != 1");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+ rc= mysql_query(mysql, "CREATE TABLE t1 (a int)");
+ myquery(rc);
+
+ strmov(query, "EXPLAIN INSERT INTO t1 values (1)");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("EXPALIN INSERT number of fields: %d\n", (int) num_fields);
+ if (num_fields != 10)
+ {
+ mct_close_log();
+ DIE("num_fields != 10");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+ strmov(query, "EXPLAIN format=json INSERT INTO t1 values(1)");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("EXPALIN JSON INSERT number of fields: %d\n", (int) num_fields);
+ if (num_fields != 1)
+ {
+ mct_close_log();
+ DIE("num_fields != 1");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+
+ strmov(query, "ANALYZE INSERT INTO t1 values(1)");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("ANALYZE INSERT number of fields: %d\n", (int) num_fields);
+ if (num_fields != 13)
+ {
+ mct_close_log();
+ DIE("num_fields != 13");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+ strmov(query, "ANALYZE format=json INSERT INTO t1 values(1)");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("ANALYZE JSON INSERT number of fields: %d\n", (int) num_fields);
+ if (num_fields != 1)
+ {
+ mct_close_log();
+ DIE("num_fields != 1");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+
+ strmov(query, "EXPLAIN UPDATE t1 set a=2");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("EXPALIN UPDATE number of fields: %d\n", (int) num_fields);
+ if (num_fields != 10)
+ {
+ mct_close_log();
+ DIE("num_fields != 10");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+ strmov(query, "EXPLAIN format=json UPDATE t1 set a=2");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("EXPALIN JSON UPDATE number of fields: %d\n", (int) num_fields);
+ if (num_fields != 1)
+ {
+ mct_close_log();
+ DIE("num_fields != 1");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+
+ strmov(query, "ANALYZE UPDATE t1 set a=2");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("ANALYZE UPDATE number of fields: %d\n", (int) num_fields);
+ if (num_fields != 13)
+ {
+ mct_close_log();
+ DIE("num_fields != 13");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+ strmov(query, "ANALYZE format=json UPDATE t1 set a=2");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("ANALYZE JSON UPDATE number of fields: %d\n", (int) num_fields);
+ if (num_fields != 1)
+ {
+ mct_close_log();
+ DIE("num_fields != 1");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+
+ strmov(query, "EXPLAIN DELETE FROM t1");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("EXPALIN DELETE number of fields: %d\n", (int) num_fields);
+ if (num_fields != 10)
+ {
+ mct_close_log();
+ DIE("num_fields != 10");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+ strmov(query, "EXPLAIN format=json DELETE FROM t1");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("EXPALIN JSON DELETE number of fields: %d\n", (int) num_fields);
+ if (num_fields != 1)
+ {
+ mct_close_log();
+ DIE("num_fields != 1");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+
+ strmov(query, "ANALYZE DELETE FROM t1");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("ANALYZE DELETE number of fields: %d\n", (int) num_fields);
+ if (num_fields != 13)
+ {
+ mct_close_log();
+ DIE("num_fields != 13");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+ strmov(query, "ANALYZE format=json DELETE FROM t1");
+ stmt= mysql_simple_prepare(mysql, query);
+ check_stmt(stmt);
+
+ rs_metadata= mysql_stmt_result_metadata(stmt);
+
+ num_fields= mysql_stmt_field_count(stmt);
+ mct_log("ANALYZE JSON DELETE number of fields: %d\n", (int) num_fields);
+ if (num_fields != 1)
+ {
+ mct_close_log();
+ DIE("num_fields != 1");
+ }
+ print_metadata(rs_metadata, num_fields);
+ mysql_stmt_close(stmt);
+
+ rc= mysql_query(mysql, "DROP TABLE t1");
+ myquery(rc);
+ mct_close_log();
+}
+
static struct my_tests_st my_tests[]= {
{ "disable_query_logs", disable_query_logs },
{ "test_view_sp_list_fields", test_view_sp_list_fields },
@@ -20524,6 +20844,7 @@ static struct my_tests_st my_tests[]= {
#ifndef EMBEDDED_LIBRARY
{ "test_proxy_header", test_proxy_header},
#endif
+ { "test_explain_meta", test_explain_meta },
{ 0, 0 }
};
1
0

[Commits] 8f428279c31: MDEV-15777:Support Early NULLs filtering-like restrictions in the range optimizer
by varunraiko1803ļ¼ gmail.com 18 Apr '18
by varunraiko1803ļ¼ gmail.com 18 Apr '18
18 Apr '18
revision-id: 8f428279c31d9a36e6a2089d70dd7600f769ec57 (mariadb-10.3.0-765-g8f428279c31)
parent(s): 91245909a2f0c89444ecb5af587284f53b7196ee
author: Varun Gupta
committer: Varun Gupta
timestamp: 2018-04-18 19:26:12 +0530
message:
MDEV-15777:Support Early NULLs filtering-like restrictions in the range optimizer
Initial patch
---
sql/mdev15864.sql | 29 ++++++++++++++++++
sql/opt_range.cc | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
sql/opt_range.h | 3 ++
sql/sql_select.cc | 13 ++++++--
sql/sql_select.h | 1 +
5 files changed, 133 insertions(+), 3 deletions(-)
diff --git a/sql/mdev15864.sql b/sql/mdev15864.sql
new file mode 100644
index 00000000000..a7c4037950d
--- /dev/null
+++ b/sql/mdev15864.sql
@@ -0,0 +1,29 @@
+create table ten(a int);
+insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table one_k(a int);
+insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;
+
+create table one_m(a int);
+insert into one_m select A.a + B.a* 1000 from one_k A, one_k B;
+delete from one_m where a=0 limit 1;
+
+create table t1 (
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ filler varchar(100),
+ subset_id int(11) DEFAULT NULL,
+ PRIMARY KEY (id),
+ KEY t1_subset_id (subset_id)
+);
+
+create table t1_subsets (
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ filler1 varchar(100),
+ filler2 varchar(100),
+ filler3 varchar(100),
+ PRIMARY KEY (id)
+);
+
+insert into t1 select a,a, NULL from one_m where a < 50*1000;
+insert into t1_subsets select a,a,a,a from one_m where a < 500*1000 limit 499000;
+analyze format=json select * from t1,t1_subsets where t1.subset_id IS NOT NULL and t1.subset_id= t1_subsets.id;
\ No newline at end of file
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 38dbed92a22..a6d8dc8ea3f 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1184,6 +1184,7 @@ SQL_SELECT *make_select(TABLE *head, table_map const_tables,
select->const_tables=const_tables;
select->head=head;
select->cond= conds;
+ select->null_rejecting_conds= NULL;
if (filesort && my_b_inited(&filesort->io_cache))
{
@@ -2430,7 +2431,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
{
uchar buff[STACK_BUFF_ALLOC];
MEM_ROOT alloc;
- SEL_TREE *tree= NULL;
+ SEL_TREE *tree= NULL, *not_null_cond_tree= NULL;
KEY_PART *key_parts;
KEY *key_info;
PARAM param;
@@ -2539,6 +2540,12 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
TRP_GROUP_MIN_MAX *group_trp;
double best_read_time= read_time;
+ if (null_rejecting_conds)
+ {
+ not_null_cond_tree= null_rejecting_conds->get_mm_tree(¶m,
+ &null_rejecting_conds);
+ }
+
if (cond)
{
if ((tree= cond->get_mm_tree(¶m, &cond)))
@@ -2557,6 +2564,13 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
tree= NULL;
}
}
+ if (not_null_cond_tree)
+ {
+ if (!tree)
+ tree= not_null_cond_tree;
+ else
+ tree= tree_and(¶m, tree, not_null_cond_tree);
+ }
/*
Try to construct a QUICK_GROUP_MIN_MAX_SELECT.
@@ -14647,6 +14661,80 @@ void QUICK_GROUP_MIN_MAX_SELECT::add_keys_and_lengths(String *key_names,
add_key_and_length(key_names, used_lengths, &first);
}
+inline void add_cond(THD *thd, Item **e1, Item *e2)
+{
+ if (*e1)
+ {
+ if (!e2)
+ return;
+ Item *res;
+ if ((res= new (thd->mem_root) Item_cond_and(thd, *e1, e2)))
+ {
+ res->fix_fields(thd, 0);
+ res->update_used_tables();
+ *e1= res;
+ }
+ }
+ else
+ *e1= e2;
+}
+
+
+COND* make_null_rejecting_conds(THD *thd, TABLE *table,
+ DYNAMIC_ARRAY *keyuse_array, key_map *const_keys)
+{
+ KEY *keyinfo, *keyinfo_keyuse;
+ KEY_PART_INFO *key_part;
+ COND *cond= NULL;
+ for (uint key=0; key< table->s->keys; key++)
+ {
+ keyinfo= table->key_info+key;
+ key_part= keyinfo->key_part;
+ /*
+ Only user degined key parts are required here because the extended
+ key parts we know would be from the primary key and all the key_parts
+ of the primary key are NOT NULL so no need to add such conditions
+ */
+ for (uint i=0; i < keyinfo->user_defined_key_parts; i++,key_part++)
+ {
+ for(uint j=0; j < keyuse_array->elements; j++)
+ {
+ KEYUSE* keyuse= (KEYUSE*)dynamic_array_ptr(keyuse_array, j);
+ if (keyuse->table == table && keyuse->key == key)
+ {
+ //generate equality
+ Field *field= key_part->field;
+ keyinfo_keyuse= keyuse->table->key_info+keyuse->key;
+ if (keyuse->val->const_item()
+ || keyuse->func_type == Item_func::EQUAL_FUNC
+ || keyuse->optimize & KEY_OPTIMIZE_REF_OR_NULL
+ )
+ continue;
+ if (!field->eq(keyinfo_keyuse->key_part[keyuse->keypart].field))
+ continue;
+ /*
+ Add checks here to ensure that only fields that can be NOT NULL are added
+ that is dont include
+ 1) keyparts defined as NOT NULL
+ 2) keyparts belong to Primary Key (these will be handled in case 1)
+ 3) equalities with <=> should not add NOT NULL for its fields[needs discussion]
+ */
+ if (field->flags & NOT_NULL_FLAG)
+ continue;
+ Item_field *field_item= new (thd->mem_root)Item_field(thd, key_part->field);
+ Item* not_null_item= new (thd->mem_root)Item_func_isnotnull(thd, field_item);
+ // adding the key to const keys as we have the condition as key.keypart IS NOT NULL
+ const_keys->set_bit(keyuse->key);
+ not_null_item->fix_fields(thd, 0);
+ not_null_item->update_used_tables();
+ add_cond(thd,&cond, not_null_item);
+ }
+ }
+ }
+ }
+ return cond;
+}
+
#ifndef DBUG_OFF
diff --git a/sql/opt_range.h b/sql/opt_range.h
index bd85a12d4a1..54f113c710d 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -1636,6 +1636,7 @@ class SQL_SELECT :public Sql_alloc {
/* See PARAM::possible_keys */
key_map possible_keys;
bool free_cond; /* Currently not used and always FALSE */
+ COND *null_rejecting_conds;
SQL_SELECT();
~SQL_SELECT();
@@ -1728,6 +1729,8 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond);
bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond);
#endif
void store_key_image_to_rec(Field *field, uchar *ptr, uint len);
+COND* make_null_rejecting_conds(THD *thd, TABLE *table,
+ DYNAMIC_ARRAY *keyuse_array, key_map *const_keys);
extern String null_string;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 796ea569e64..7abad3ffed9 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -4242,6 +4242,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
SARGABLE_PARAM *sargables= 0;
List_iterator<TABLE_LIST> ti(tables_list);
TABLE_LIST *tables;
+ COND* null_rejecting_conds= NULL;
DBUG_ENTER("make_join_statistics");
table_count=join->table_count;
@@ -4783,6 +4784,9 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
add_group_and_distinct_keys(join, s);
s->table->cond_selectivity= 1.0;
+
+// null_rejecting_conds= make_null_rejecting_conds(join->thd, s->table,
+// keyuse_array, &s->const_keys);
/*
Perform range analysis if there are keys it could use (1).
@@ -4812,6 +4816,8 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
1, &error);
if (!select)
goto error;
+
+// select->null_rejecting_conds= null_rejecting_conds;
records= get_quick_record_count(join->thd, select, s->table,
&s->const_keys, join->row_limit);
/* Range analyzer could modify the condition. */
@@ -4824,6 +4830,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
s->needed_reg=select->needed_reg;
select->quick=0;
impossible_range= records == 0 && s->table->reginfo.impossible_range;
+ select->null_rejecting_conds= NULL;
}
if (!impossible_range)
{
@@ -4832,7 +4839,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
*s->on_expr_ref ?
s->on_expr_ref : &join->conds);
if (s->table->reginfo.impossible_range)
- {
+ {
impossible_range= TRUE;
records= 0;
}
@@ -4867,7 +4874,8 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
}
}
-
+ if (null_rejecting_conds)
+ delete null_rejecting_conds;
if (pull_out_semijoin_tables(join))
DBUG_RETURN(TRUE);
@@ -5796,6 +5804,7 @@ add_keyuse(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field,
keyuse.cond_guard= key_field->cond_guard;
keyuse.sj_pred_no= key_field->sj_pred_no;
keyuse.validity_ref= 0;
+ keyuse.func_type= key_field->cond->functype();
return (insert_dynamic(keyuse_array,(uchar*) &keyuse));
}
diff --git a/sql/sql_select.h b/sql/sql_select.h
index f8911fbba01..7d2977e187f 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -78,6 +78,7 @@ typedef struct keyuse_t {
Otherwise it points to the enabling flag for this keyuse (true <=> enabled)
*/
bool *validity_ref;
+ Item_func::Functype func_type;
bool is_for_hash_join() { return is_hash_join_key_no(key); }
} KEYUSE;
1
0

[Commits] 602865f9f24: MDEV-13727 rpl.rpl_concurrency_error failed
by andrei.elkinļ¼ pp.inet.fi 18 Apr '18
by andrei.elkinļ¼ pp.inet.fi 18 Apr '18
18 Apr '18
revision-id: 602865f9f242a7ed5e3679af60a78698c03d93f5 (mariadb-10.3.6-14-g602865f9f24)
parent(s): 02e897ca57168059c6a74d1129158afea93aa875
author: Andrei Elkin
committer: Andrei Elkin
timestamp: 2018-04-18 13:04:46 +0300
message:
MDEV-13727 rpl.rpl_concurrency_error failed
The test actually revealed a flaw in MDEV-8305
which inadvertently enrolled the trigger and
stored function into slow query reporting aimed exclusively
to the stored procedure.
Specifically to the test, a query on the master was logged
with a timestamp of the query's top-level statement but its (post
update) trigger computed one more (later) timestamp which got
inserted into another table.
Master-vs-slave discrepancy became evident thanks to
different execution time of the trigger combined with the fact of the
logged master timestamp in the micro-second fraction format was
truncated on the slave. The latter means the slave execution of the query
always started earlier than on the master as far as the timestamp was concerned.
And when the fractional part was close to 1 the 2nd timestamp acquired by
MDEV-8305 piece of logics could overflow to next integer value.
That's how the master table appeared to be temporarly behind the slave's one.
Fixed with restoring the pre-MDEV-8305 behavior not to reset
the current statement's timestamp when the query is not from a stored procedure.
That is the trigger's or stored function's queries continue to use
the top-level statement's timestamp as they are supposed to.
---
mysql-test/main/func_time.result | 26 ++++++++++++++++++
mysql-test/main/func_time.test | 59 ++++++++++++++++++++++++++++++++++++++++
sql/sp_head.cc | 4 +--
3 files changed, 87 insertions(+), 2 deletions(-)
diff --git a/mysql-test/main/func_time.result b/mysql-test/main/func_time.result
index 2772f850ce9..9babfc6a48b 100644
--- a/mysql-test/main/func_time.result
+++ b/mysql-test/main/func_time.result
@@ -3484,3 +3484,29 @@ t1 CREATE TABLE `t1` (
`c5` varchar(100) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
+CREATE TABLE t_ts (a timestamp(6));
+CREATE TABLE t_trig (a timestamp(6));
+CREATE FUNCTION fn_sleep_before_now() returns int
+BEGIN
+INSERT INTO t_ts SET a= current_timestamp(6);
+RETURN 0;
+END//
+CREATE TRIGGER trg_insert_t_ts after INSERT on t_ts for each row
+BEGIN
+INSERT into t_trig set a= current_timestamp(6);
+END//
+SET @sav_slow_query_log= @@session.slow_query_log;
+SET @@session.slow_query_log= ON;
+SELECT current_timestamp(6),fn_sleep_before_now() INTO @ts_cur, @ts_func;
+SELECT a FROM t_ts LIMIT 1 into @ts_func;
+SELECT a FROM t_trig LIMIT 1 into @ts_trig;
+DELETE FROM t_ts;
+DELETE FROM t_trig;
+SET @@session.slow_query_log= OFF;
+SELECT current_timestamp(6),fn_sleep_before_now() INTO @ts_cur, @func_ts;
+SELECT a FROM t_ts LIMIT 1 into @ts_func;
+SELECT a FROM t_trig LIMIT 1 into @ts_trig;
+SET @@session.slow_query_log= @sav_slow_query_log;
+DROP FUNCTION fn_sleep_before_now;
+DROP TRIGGER trg_insert_t_ts;
+DROP TABLE t_ts, t_trig;
diff --git a/mysql-test/main/func_time.test b/mysql-test/main/func_time.test
index 5417cb20a92..ad207218969 100644
--- a/mysql-test/main/func_time.test
+++ b/mysql-test/main/func_time.test
@@ -2057,3 +2057,62 @@ EXECUTE IMMEDIATE
USING NULL, '10', 10, 10.0, 10e0, TIME'10:20:30';
SHOW CREATE TABLE t1;
DROP TABLE t1;
+
+
+############
+# MDEV-13727
+# Current timestamp functions inside stored functions must return the
+# value of the top-level statement's timestamp (its start time).
+# This must hold regardless of @@slow_query_log option.
+#
+
+CREATE TABLE t_ts (a timestamp(6));
+CREATE TABLE t_trig (a timestamp(6));
+delimiter //;
+CREATE FUNCTION fn_sleep_before_now() returns int
+BEGIN
+ INSERT INTO t_ts SET a= current_timestamp(6);
+ RETURN 0;
+END//
+CREATE TRIGGER trg_insert_t_ts after INSERT on t_ts for each row
+BEGIN
+ INSERT into t_trig set a= current_timestamp(6);
+END//
+delimiter ;//
+
+SET @sav_slow_query_log= @@session.slow_query_log;
+
+# @@slow_query_log ON check
+SET @@session.slow_query_log= ON;
+SELECT current_timestamp(6),fn_sleep_before_now() INTO @ts_cur, @ts_func;
+
+SELECT a FROM t_ts LIMIT 1 into @ts_func;
+SELECT a FROM t_trig LIMIT 1 into @ts_trig;
+if (!`SELECT @ts_cur = @ts_func and @ts_func = @ts_trig`)
+{
+ SELECT @ts_cur, @ts_func, @ts_trig;
+ --die Error: timestamps must be equal but they diverge
+}
+DELETE FROM t_ts;
+DELETE FROM t_trig;
+
+# @@slow_query_log OFF check
+SET @@session.slow_query_log= OFF;
+SELECT current_timestamp(6),fn_sleep_before_now() INTO @ts_cur, @func_ts;
+SELECT a FROM t_ts LIMIT 1 into @ts_func;
+SELECT a FROM t_trig LIMIT 1 into @ts_trig;
+if (!`SELECT @ts_cur = @ts_func and @ts_func = @ts_trig`)
+{
+ SELECT @ts_cur, @ts_func, @ts_trig;
+ --die Error: timestamps must be equal but they diverge
+}
+
+# Cleanup
+SET @@session.slow_query_log= @sav_slow_query_log;
+DROP FUNCTION fn_sleep_before_now;
+DROP TRIGGER trg_insert_t_ts;
+DROP TABLE t_ts, t_trig;
+
+#
+# End of MDEV-13727
+###################
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index f7847bae89d..90fe77e6158 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -3471,7 +3471,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
thd->profiling.set_query_source(m_query.str, m_query.length);
#endif
- if ((save_enable_slow_log= thd->enable_slow_log))
+ if ((save_enable_slow_log= thd->enable_slow_log) && !thd->in_sub_stmt)
{
/*
Save start time info for the CALL statement and overwrite it with the
@@ -3544,7 +3544,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
}
}
/* Restore the original query start time */
- if (thd->enable_slow_log)
+ if (thd->enable_slow_log && !thd->in_sub_stmt)
thd->restore_query_start_time(&time_info);
DBUG_RETURN(res || thd->is_error());
1
0

[Commits] a0817923a14: MDEV-15308: Assertion `ha_alter_info->alter_info->drop_list.elements > 0' failed in ha_innodb::prepare_inplace_alter_table
by jan 18 Apr '18
by jan 18 Apr '18
18 Apr '18
revision-id: a0817923a141650ff37d9f8358bc938556981c69 (mariadb-10.0.34-34-ga0817923a14)
parent(s): 226ec99a3ed662bace80d70dd7fefd0db7b4af0a
author: Jan Lindstrƶm
committer: Jan Lindstrƶm
timestamp: 2018-04-18 11:35:31 +0300
message:
MDEV-15308: Assertion `ha_alter_info->alter_info->drop_list.elements > 0' failed in ha_innodb::prepare_inplace_alter_table
Problem was thet when items were removed from drop_list alter_info
flags were not adjusted accordingly in all cases.
---
mysql-test/r/if_exists.result | 43 +++++++++++++++++++++++++++++++++++++++++++
mysql-test/t/if_exists.test | 33 +++++++++++++++++++++++++++++++++
sql/sql_table.cc | 8 +++++++-
3 files changed, 83 insertions(+), 1 deletion(-)
diff --git a/mysql-test/r/if_exists.result b/mysql-test/r/if_exists.result
new file mode 100644
index 00000000000..4cb718b9cfc
--- /dev/null
+++ b/mysql-test/r/if_exists.result
@@ -0,0 +1,43 @@
+CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB;
+ALTER TABLE t1 DROP FOREIGN KEY IF EXISTS fk, DROP COLUMN b;
+Warnings:
+Note 1091 Can't DROP 'fk'; check that column/key exists
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB;
+ALTER TABLE t1 DROP INDEX IF EXISTS fk, DROP COLUMN b;
+Warnings:
+Note 1091 Can't DROP 'fk'; check that column/key exists
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT, c INT, KEY(c)) ENGINE=InnoDB;
+ALTER TABLE t1 DROP FOREIGN KEY IF EXISTS fk, DROP COLUMN c;
+Warnings:
+Note 1091 Can't DROP 'fk'; check that column/key exists
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT, c INT, KEY c1(c)) ENGINE=InnoDB;
+ALTER TABLE t1 DROP FOREIGN KEY IF EXISTS fk, DROP INDEX c1;
+Warnings:
+Note 1091 Can't DROP 'fk'; check that column/key exists
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
diff --git a/mysql-test/t/if_exists.test b/mysql-test/t/if_exists.test
new file mode 100644
index 00000000000..420efaba150
--- /dev/null
+++ b/mysql-test/t/if_exists.test
@@ -0,0 +1,33 @@
+--source include/have_innodb.inc
+
+#
+# MDEV-15308: Assertion `ha_alter_info->alter_info->drop_list.elements > 0' failed in ha_innodb::prepare_inplace_alter_table
+#
+
+CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB;
+ALTER TABLE t1 DROP FOREIGN KEY IF EXISTS fk, DROP COLUMN b;
+SHOW CREATE TABLE t1;
+
+# Cleanup
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB;
+ALTER TABLE t1 DROP INDEX IF EXISTS fk, DROP COLUMN b;
+SHOW CREATE TABLE t1;
+
+# Cleanup
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT, b INT, c INT, KEY(c)) ENGINE=InnoDB;
+ALTER TABLE t1 DROP FOREIGN KEY IF EXISTS fk, DROP COLUMN c;
+SHOW CREATE TABLE t1;
+
+# Cleanup
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT, b INT, c INT, KEY c1(c)) ENGINE=InnoDB;
+ALTER TABLE t1 DROP FOREIGN KEY IF EXISTS fk, DROP INDEX c1;
+SHOW CREATE TABLE t1;
+
+# Cleanup
+DROP TABLE t1;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 607f20d2396..c33ac784d91 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -7430,6 +7430,9 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
if (table->s->tmp_table == NO_TMP_TABLE)
(void) delete_statistics_for_column(thd, table, field);
drop_it.remove();
+ if (alter_info->drop_list.is_empty())
+ alter_info->flags&= ~(Alter_info::ALTER_DROP_INDEX |
+ Alter_info::DROP_FOREIGN_KEY);
continue;
}
/* Check if field is changed */
@@ -7654,8 +7657,11 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
TRUE);
}
}
- }
+ }
drop_it.remove();
+ if (alter_info->drop_list.is_empty())
+ alter_info->flags&= ~(Alter_info::ALTER_DROP_INDEX |
+ Alter_info::DROP_FOREIGN_KEY);
continue;
}
1
0

[Commits] cff60be: MDEV-15899 Server crashes in st_join_table::is_inner_table_of_outer_join
by IgorBabaev 18 Apr '18
by IgorBabaev 18 Apr '18
18 Apr '18
revision-id: cff60be7fe159fdcb2517ce8441610ad512aa7d0 (mariadb-10.3.6-15-gcff60be)
parent(s): bb5f4967f54d3f458bec86fb1845405a0a88bc0f
author: Igor Babaev
committer: Igor Babaev
timestamp: 2018-04-17 23:39:40 -0700
message:
MDEV-15899 Server crashes in st_join_table::is_inner_table_of_outer_join
The crash happened because JOIN::check_for_splittable_materialized()
called by mistake the function JOIN_TAB::is_inner_table_of_outer_join()
instead of the function TABLE_LIST::is_inner_table_of_outer_join().
The former cannot be called before the call of make_outerjoin_info().
---
mysql-test/main/derived_cond_pushdown.result | 46 ++++++++++++++++++++++++++++
mysql-test/main/derived_cond_pushdown.test | 19 ++++++++++++
sql/opt_split.cc | 5 +--
3 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result
index 6887ad1..1b7aeda 100644
--- a/mysql-test/main/derived_cond_pushdown.result
+++ b/mysql-test/main/derived_cond_pushdown.result
@@ -15119,3 +15119,49 @@ Warnings:
Note 1003 /* select#1 */ select NULL AS `f`,`v2`.`f` AS `f` from `test`.`t1` `a` straight_join `test`.`t1` `b` join `test`.`v2` where 0
DROP VIEW v1,v2;
DROP TABLE t1;
+#
+# MDEV-15899: derived with WF without any key access
+#
+create table t1 (f1 int, f2 int, f4 int);
+insert into t1 values
+(3,1,1), (3,0,9), (0,1,8), (9,0,0), (3,0,9);
+with
+cte as (select median(f2) over (partition by f1) as k1 from t1 order by f1),
+cte1 as (select median(f4) over (partition by f1) as k2 from t1)
+select k1,k2 from cte1, cte;
+k1 k2
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+1.0000000000 8.0000000000
+1.0000000000 8.0000000000
+1.0000000000 8.0000000000
+1.0000000000 8.0000000000
+1.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+explain with
+cte as (select median(f2) over (partition by f1) as k1 from t1 order by f1),
+cte1 as (select median(f4) over (partition by f1) as k2 from t1)
+select k1,k2 from cte1, cte;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived3> ALL NULL NULL NULL NULL 5
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
+3 DERIVED t1 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
+2 DERIVED t1 ALL NULL NULL NULL NULL 5 Using temporary
+drop table t1;
diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test
index 234f889..2e2ec69 100644
--- a/mysql-test/main/derived_cond_pushdown.test
+++ b/mysql-test/main/derived_cond_pushdown.test
@@ -2671,3 +2671,22 @@ SELECT * FROM v1 JOIN v2 ON v1.f = v2.f;
DROP VIEW v1,v2;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-15899: derived with WF without any key access
+--echo #
+
+create table t1 (f1 int, f2 int, f4 int);
+insert into t1 values
+ (3,1,1), (3,0,9), (0,1,8), (9,0,0), (3,0,9);
+
+let $q=
+with
+cte as (select median(f2) over (partition by f1) as k1 from t1 order by f1),
+cte1 as (select median(f4) over (partition by f1) as k2 from t1)
+select k1,k2 from cte1, cte;
+
+eval $q;
+eval explain $q;
+
+drop table t1;
diff --git a/sql/opt_split.cc b/sql/opt_split.cc
index 063ca9f..b81556e 100644
--- a/sql/opt_split.cc
+++ b/sql/opt_split.cc
@@ -352,8 +352,9 @@ bool JOIN::check_for_splittable_materialized()
Field *ord_field= ((Item_field *) (ord_item->real_item()))->field;
- JOIN_TAB *tab= ord_field->table->reginfo.join_tab;
- if (tab->is_inner_table_of_outer_join())
+ /* Ignore fields from of inner tables of outer joins */
+ TABLE_LIST *tbl= ord_field->table->pos_in_table_list;
+ if (tbl->is_inner_table_of_outer_join())
continue;
List_iterator<Item> li(fields_list);
1
0

[Commits] 01aa068: MDEV-15899 Server crashes in st_join_table::is_inner_table_of_outer_join
by IgorBabaev 18 Apr '18
by IgorBabaev 18 Apr '18
18 Apr '18
revision-id: 01aa068699a77267515d097880b19fc2a70213eb (mariadb-10.3.6-15-g01aa068)
parent(s): bb5f4967f54d3f458bec86fb1845405a0a88bc0f
author: Igor Babaev
committer: Igor Babaev
timestamp: 2018-04-17 23:38:31 -0700
message:
MDEV-15899 Server crashes in st_join_table::is_inner_table_of_outer_join
The crash happened because JOIN::check_for_splittable_materialized()
called by mistake the function JOIN_TAB::is_inner_table_of_outer_join()
instead of the function TABLE_LIST::is_inner_table_of_outer_join().
The former cannot be called before the call of make_outerjoin_info().
---
mysql-test/main/derived_cond_pushdown.result | 37 ++++++++++++++++++++++++++++
mysql-test/main/derived_cond_pushdown.test | 15 +++++++++++
sql/opt_split.cc | 5 ++--
3 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result
index 6887ad1..99a15e8 100644
--- a/mysql-test/main/derived_cond_pushdown.result
+++ b/mysql-test/main/derived_cond_pushdown.result
@@ -15119,3 +15119,40 @@ Warnings:
Note 1003 /* select#1 */ select NULL AS `f`,`v2`.`f` AS `f` from `test`.`t1` `a` straight_join `test`.`t1` `b` join `test`.`v2` where 0
DROP VIEW v1,v2;
DROP TABLE t1;
+#
+# MDEV-15899: splittable table
+#
+create table t1 (f1 int, f2 int, f4 int);
+insert into t1 values
+(3,1,1), (3,0,9), (0,1,8), (9,0,0), (3,0,9);
+with
+cte as (select median(f2) over (partition by f1) as k1 from t1 order by f1),
+cte1 as (select median(f4) over (partition by f1) as k2 from t1)
+select k1,k2 from cte1, cte;
+k1 k2
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+1.0000000000 8.0000000000
+1.0000000000 8.0000000000
+1.0000000000 8.0000000000
+1.0000000000 8.0000000000
+1.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+drop table t1;
diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test
index 234f889..c609546 100644
--- a/mysql-test/main/derived_cond_pushdown.test
+++ b/mysql-test/main/derived_cond_pushdown.test
@@ -2671,3 +2671,18 @@ SELECT * FROM v1 JOIN v2 ON v1.f = v2.f;
DROP VIEW v1,v2;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-15899: splittable table
+--echo #
+
+create table t1 (f1 int, f2 int, f4 int);
+insert into t1 values
+ (3,1,1), (3,0,9), (0,1,8), (9,0,0), (3,0,9);
+
+with
+cte as (select median(f2) over (partition by f1) as k1 from t1 order by f1),
+cte1 as (select median(f4) over (partition by f1) as k2 from t1)
+select k1,k2 from cte1, cte;
+
+drop table t1;
diff --git a/sql/opt_split.cc b/sql/opt_split.cc
index 063ca9f..b81556e 100644
--- a/sql/opt_split.cc
+++ b/sql/opt_split.cc
@@ -352,8 +352,9 @@ bool JOIN::check_for_splittable_materialized()
Field *ord_field= ((Item_field *) (ord_item->real_item()))->field;
- JOIN_TAB *tab= ord_field->table->reginfo.join_tab;
- if (tab->is_inner_table_of_outer_join())
+ /* Ignore fields from of inner tables of outer joins */
+ TABLE_LIST *tbl= ord_field->table->pos_in_table_list;
+ if (tbl->is_inner_table_of_outer_join())
continue;
List_iterator<Item> li(fields_list);
1
0