From 6c3f1f661c6df622a9dc39d59e9a48e6709a6d44 Mon Sep 17 00:00:00 2001 From: Lena Startseva Date: Thu, 10 Feb 2022 16:04:44 +0700 Subject: [PATCH] MDEV-27691: make working view-protocol Added ability to disable/enable (--disable_view_protocol/--enable_view_protocol) view-protocol in tests. When the option "--disable_view_protocol" is used util connections are closed. Added new test for checking view-protocol --- client/mysqltest.cc | 23 ++++++++++++++++++++++ mysql-test/include/have_view_protocol.inc | 6 ++++++ mysql-test/main/check_view_protocol.result | 19 ++++++++++++++++++ mysql-test/main/check_view_protocol.test | 21 ++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 mysql-test/include/have_view_protocol.inc create mode 100644 mysql-test/main/check_view_protocol.result create mode 100644 mysql-test/main/check_view_protocol.test diff --git a/client/mysqltest.cc b/client/mysqltest.cc index bca35b74a64..855c325c49c 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -155,6 +155,7 @@ static struct property prop_list[] = { { &display_session_track_info, 0, 1, 1, "$ENABLED_STATE_CHANGE_INFO" }, { &display_metadata, 0, 0, 0, "$ENABLED_METADATA" }, { &ps_protocol_enabled, 0, 0, 0, "$ENABLED_PS_PROTOCOL" }, + { &view_protocol_enabled, 0, 0, 0, "$ENABLED_VIEW_PROTOCOL"}, { &disable_query_log, 0, 0, 1, "$ENABLED_QUERY_LOG" }, { &disable_result_log, 0, 0, 1, "$ENABLED_RESULT_LOG" }, { &disable_warnings, 0, 0, 1, "$ENABLED_WARNINGS" } @@ -169,6 +170,7 @@ enum enum_prop { P_SESSION_TRACK, P_META, P_PS, + P_VIEW, P_QUERY, P_RESULT, P_WARN, @@ -374,6 +376,7 @@ enum enum_commands { Q_LOWERCASE, Q_START_TIMER, Q_END_TIMER, Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL, + Q_DISABLE_VIEW_PROTOCOL, Q_ENABLE_VIEW_PROTOCOL, Q_ENABLE_NON_BLOCKING_API, Q_DISABLE_NON_BLOCKING_API, Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT, Q_IF, @@ -460,6 +463,8 @@ const char *command_names[]= "character_set", "disable_ps_protocol", "enable_ps_protocol", + "disable_view_protocol", + "enable_view_protocol", "enable_non_blocking_api", "disable_non_blocking_api", "disable_reconnect", @@ -1397,6 +1402,16 @@ void close_connections() DBUG_VOID_RETURN; } +void close_util_connections() +{ + DBUG_ENTER("close_util_connections"); + if (cur_con->util_mysql) + { + mysql_close(cur_con->util_mysql); + cur_con->util_mysql = 0; + } + DBUG_VOID_RETURN; +} void close_statements() { @@ -9664,6 +9679,14 @@ int main(int argc, char **argv) case Q_ENABLE_PS_PROTOCOL: set_property(command, P_PS, ps_protocol); break; + case Q_DISABLE_VIEW_PROTOCOL: + set_property(command, P_VIEW, 0); + /* Close only util connections */ + close_util_connections(); + break; + case Q_ENABLE_VIEW_PROTOCOL: + set_property(command, P_VIEW, view_protocol); + break; case Q_DISABLE_NON_BLOCKING_API: non_blocking_api_enabled= 0; break; diff --git a/mysql-test/include/have_view_protocol.inc b/mysql-test/include/have_view_protocol.inc new file mode 100644 index 00000000000..6b1436a7a7a --- /dev/null +++ b/mysql-test/include/have_view_protocol.inc @@ -0,0 +1,6 @@ +# The file with expected results fits only to a run with +# view-protocol. +if (`SELECT $VIEW_PROTOCOL = 0`) +{ + --skip Test requires view-protocol +} \ No newline at end of file diff --git a/mysql-test/main/check_view_protocol.result b/mysql-test/main/check_view_protocol.result new file mode 100644 index 00000000000..697bc759498 --- /dev/null +++ b/mysql-test/main/check_view_protocol.result @@ -0,0 +1,19 @@ +flush status; +create table t1 (a int); +insert into t1 (a) values (1); +create table t2 (b int); +insert into t2 (b) values (2); +select * from t1; +a +1 +show status like 'Opened_views'; +Variable_name Value +Opened_views 1 +flush status; +select * from t2; +b +2 +show status like 'Opened_views'; +Variable_name Value +Opened_views 0 +drop table t1, t2; diff --git a/mysql-test/main/check_view_protocol.test b/mysql-test/main/check_view_protocol.test new file mode 100644 index 00000000000..c4d5670669c --- /dev/null +++ b/mysql-test/main/check_view_protocol.test @@ -0,0 +1,21 @@ +-- source include/have_view_protocol.inc + +flush status; + +create table t1 (a int); +insert into t1 (a) values (1); +create table t2 (b int); +insert into t2 (b) values (2); +select * from t1; +show status like 'Opened_views'; + +flush status; +--disable_view_protocol +select * from t2; +--enable_view_protocol + +show status like 'Opened_views'; + +drop table t1, t2; + +