diff options
author | Dmitry Shulga <dmitry.shulga@mariadb.com> | 2021-01-12 23:04:44 +0700 |
---|---|---|
committer | Dmitry Shulga <dmitry.shulga@mariadb.com> | 2021-01-12 23:04:44 +0700 |
commit | 43fb5f98cb52e345f3ff3606579e6cf33a706a9a (patch) | |
tree | 5246f39858a34d096c577ddeda37fbf963adb4b4 | |
parent | 8d8370e31d48e0bc6139c18770746f9959c21598 (diff) | |
download | mariadb-git-bb-10.2-MDEV-24208.tar.gz |
MDEV-24208 SHOW RELAYLOG EVENTS command is not supported in the prepared statement protocol yetbb-10.2-MDEV-24208
Added sending of metadata in response to preparing request for
the commands SQLCOM_SHOW_BINLOG_EVENTS, SQLCOM_SHOW_RELAYLOG_EVENTS
-rw-r--r-- | mysql-test/r/ps_show_log.result | 65 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_row_create_table.test | 5 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test | 6 | ||||
-rw-r--r-- | mysql-test/t/ps_show_log.test | 73 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 11 |
5 files changed, 149 insertions, 11 deletions
diff --git a/mysql-test/r/ps_show_log.result b/mysql-test/r/ps_show_log.result new file mode 100644 index 00000000000..54eabaeded6 --- /dev/null +++ b/mysql-test/r/ps_show_log.result @@ -0,0 +1,65 @@ +# +# MDEV-24208 SHOW RELAYLOG EVENTS command is not supported in the prepared +# statement protocol yet +# +CREATE USER u1; +include/master-slave.inc +[connection master] +connection master; +CREATE TABLE t1(n INT); +DROP TABLE t1; +connection slave; +PREPARE stmt_1 FROM 'SHOW BINLOG EVENTS'; +EXECUTE stmt_1; +Log_name Pos Event_type Server_id End_log_pos Info +# # Format_desc # # # +# # Gtid_list # # [] +# # Binlog_checkpoint # # # +# # Gtid # # GTID 0-1-1 +# # Query # # use `test`; CREATE TABLE t1(n INT) +# # Gtid # # GTID 0-1-2 +# # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */ +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the statement +# 'SHOW BINLOG EVENTS' were damaged. +EXECUTE stmt_1; +Log_name Pos Event_type Server_id End_log_pos Info +# # Format_desc # # # +# # Gtid_list # # [] +# # Binlog_checkpoint # # # +# # Gtid # # GTID 0-1-1 +# # Query # # use `test`; CREATE TABLE t1(n INT) +# # Gtid # # GTID 0-1-2 +# # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */ +DEALLOCATE PREPARE stmt_1; +connection slave; +PREPARE stmt_1 FROM 'SHOW RELAYLOG EVENTS'; +EXECUTE stmt_1; +Log_name Pos Event_type Server_id End_log_pos Info +slave-relay-bin.000001 # Format_desc # # # +slave-relay-bin.000001 # Rotate # # # +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the statement +# 'SHOW RELAYLOG EVENTS' were damaged. +EXECUTE stmt_1; +Log_name Pos Event_type Server_id End_log_pos Info +slave-relay-bin.000001 # Format_desc # # # +slave-relay-bin.000001 # Rotate # # # +DEALLOCATE PREPARE stmt_1; +# Create the user u1 without the REPLICATION SLAVE privilege required +# for running the statements SHOW BINLOG EVENTS/SHOW RELAYLOG EVENTS +# and check that attempt to execute the statements SHOW BINLOG EVENTS/ +# SHOW RELAYLOG EVENTS as a prepred statements by a user without required +# privileges results in error. +connect con2,localhost,u1,,test; +PREPARE stmt_1 FROM 'SHOW BINLOG EVENTS'; +EXECUTE stmt_1; +ERROR 42000: Access denied; you need (at least one of) the REPLICATION SLAVE privilege(s) for this operation +PREPARE stmt_1 FROM 'SHOW RELAYLOG EVENTS'; +EXECUTE stmt_1; +ERROR 42000: Access denied; you need (at least one of) the REPLICATION SLAVE privilege(s) for this operation +DEALLOCATE PREPARE stmt_1; +include/rpl_end.inc +connection default; +DROP USER u1; +# End of 10.2 tests diff --git a/mysql-test/suite/rpl/t/rpl_row_create_table.test b/mysql-test/suite/rpl/t/rpl_row_create_table.test index 65f14295c19..cb76d6c4dcb 100644 --- a/mysql-test/suite/rpl/t/rpl_row_create_table.test +++ b/mysql-test/suite/rpl/t/rpl_row_create_table.test @@ -7,11 +7,6 @@ connection slave; --source include/have_innodb.inc connection master; -# Bug#18326: Do not lock table for writing during prepare of statement -# The use of the ps protocol causes extra table maps in the binlog, so -# we disable the ps-protocol for this statement. ---disable_ps_protocol - # Set the default storage engine to different values on master and # slave. We need to stop the slave for the server variable to take # effect, since the variable is only read on start-up. diff --git a/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test b/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test index 71cd4a5b9ae..4d786794f5f 100644 --- a/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test +++ b/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test @@ -4,10 +4,4 @@ let $rename_event_pos= `select @binlog_start_pos + 819`; -# Bug#18326: Do not lock table for writing during prepare of statement -# The use of the ps protocol causes extra table maps in the binlog, so -# we disable the ps-protocol for this statement. - ---disable_ps_protocol -- source extra/rpl_tests/rpl_flsh_tbls.test ---enable_ps_protocol diff --git a/mysql-test/t/ps_show_log.test b/mysql-test/t/ps_show_log.test new file mode 100644 index 00000000000..95000d2d7e0 --- /dev/null +++ b/mysql-test/t/ps_show_log.test @@ -0,0 +1,73 @@ +--echo # +--echo # MDEV-24208 SHOW RELAYLOG EVENTS command is not supported in the prepared +--echo # statement protocol yet +--echo # + +CREATE USER u1; + +--source include/have_binlog_format_statement.inc +--source include/master-slave.inc +--connection master +CREATE TABLE t1(n INT); + +DROP TABLE t1; + +--sync_slave_with_master +PREPARE stmt_1 FROM 'SHOW BINLOG EVENTS'; + +--replace_column 2 # 4 # 5 # +--replace_regex /Server ver:.*Binlog ver: .*/#/ /slave-bin.*/#/ +EXECUTE stmt_1; + +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the statement +--echo # 'SHOW BINLOG EVENTS' were damaged. + +--replace_column 2 # 4 # 5 # +--replace_regex /Server ver:.*Binlog ver: .*/#/ /slave-bin.*/#/ +EXECUTE stmt_1; + +DEALLOCATE PREPARE stmt_1; + +--connection slave +PREPARE stmt_1 FROM 'SHOW RELAYLOG EVENTS'; +--replace_column 2 # 4 # 5 # +--replace_regex /Server ver:.*Binlog ver: .*/#/ /slave-relay-bin.*;pos=.*/#/ +EXECUTE stmt_1; + +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the statement +--echo # 'SHOW RELAYLOG EVENTS' were damaged. + +--replace_column 2 # 4 # 5 # +--replace_regex /Server ver:.*Binlog ver: .*/#/ /slave-relay-bin.*;pos=.*/#/ +EXECUTE stmt_1; + +DEALLOCATE PREPARE stmt_1; + +--echo # Create the user u1 without the REPLICATION SLAVE privilege required +--echo # for running the statements SHOW BINLOG EVENTS/SHOW RELAYLOG EVENTS +--echo # and check that attempt to execute the statements SHOW BINLOG EVENTS/ +--echo # SHOW RELAYLOG EVENTS as a prepred statements by a user without required +--echo # privileges results in error. + +--connect (con2,localhost,u1,,test) +PREPARE stmt_1 FROM 'SHOW BINLOG EVENTS'; + +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +EXECUTE stmt_1; + +PREPARE stmt_1 FROM 'SHOW RELAYLOG EVENTS'; + +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +EXECUTE stmt_1; + +DEALLOCATE PREPARE stmt_1; + +--source include/rpl_end.inc + +--connection default +# Clean up +DROP USER u1; + +--echo # End of 10.2 tests diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 3144b36ff77..efc17c2e681 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -119,6 +119,7 @@ When one supplies long data for a placeholder: #include <mysql_com.h> #endif #include "lock.h" // MYSQL_OPEN_FORCE_SHARED_MDL +#include "log_event.h" // class Log_event #include "sql_handler.h" #include "transaction.h" // trans_rollback_implicit #include "wsrep_mysqld.h" @@ -2522,6 +2523,16 @@ static bool check_prepared_statement(Prepared_statement *stmt) DBUG_RETURN(FALSE); } break; + case SQLCOM_SHOW_BINLOG_EVENTS: + case SQLCOM_SHOW_RELAYLOG_EVENTS: + { + List<Item> field_list; + Log_event::init_show_field_list(thd, &field_list); + + if ((res= send_stmt_metadata(thd, stmt, &field_list)) == 2) + DBUG_RETURN(FALSE); + } + break; #endif /* EMBEDDED_LIBRARY */ case SQLCOM_SHOW_CREATE_PROC: if ((res= mysql_test_show_create_routine(stmt, TYPE_ENUM_PROCEDURE)) == 2) |