Skip to content

Commit

Permalink
Reset connection support in mysqltest (port from mysql)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanja-byelkin committed Jun 25, 2018
1 parent bb82519 commit a8e1eef
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
28 changes: 28 additions & 0 deletions client/mysqltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ enum enum_commands {
Q_RESULT_FORMAT_VERSION,
Q_MOVE_FILE, Q_REMOVE_FILES_WILDCARD, Q_SEND_EVAL,
Q_ENABLE_PREPARE_WARNINGS, Q_DISABLE_PREPARE_WARNINGS,
Q_RESET_CONNECTION,
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
Q_COMMENT_WITH_COMMAND,
Expand Down Expand Up @@ -491,6 +492,7 @@ const char *command_names[]=
"send_eval",
"enable_prepare_warnings",
"disable_prepare_warnings",
"reset_connection",

0
};
Expand Down Expand Up @@ -6503,6 +6505,29 @@ void do_delimiter(struct st_command* command)
}


/*
do_reset_connection
DESCRIPTION
Reset the current session.
*/

static void do_reset_connection()
{
MYSQL *mysql = cur_con->mysql;

DBUG_ENTER("do_reset_connection");
if (mysql_reset_connection(mysql))
die("reset connection failed: %s", mysql_error(mysql));
if (cur_con->stmt)
{
mysql_stmt_close(cur_con->stmt);
cur_con->stmt= NULL;
}
DBUG_VOID_RETURN;
}


my_bool match_delimiter(int c, const char *delim, uint length)
{
uint i;
Expand Down Expand Up @@ -9543,6 +9568,9 @@ int main(int argc, char **argv)
case Q_PING:
handle_command_error(command, mysql_ping(cur_con->mysql), -1);
break;
case Q_RESET_CONNECTION:
do_reset_connection();
break;
case Q_SEND_SHUTDOWN:
handle_command_error(command,
mysql_shutdown(cur_con->mysql,
Expand Down
7 changes: 7 additions & 0 deletions mysql-test/r/reset_connection.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FLUSH STATUS;
SHOW local STATUS LIKE 'com_select';
Variable_name Value
Com_select 10
SHOW local STATUS LIKE 'com_select';
Variable_name Value
Com_select 0
23 changes: 23 additions & 0 deletions mysql-test/t/reset_connection.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FLUSH STATUS;

--disable_result_log
--disable_query_log

let $i = 10;
begin;
while ($i)
{
dec $i;
SELECT 1;
}
commit;

--enable_query_log
--enable_result_log

SHOW local STATUS LIKE 'com_select';

--reset_connection

SHOW local STATUS LIKE 'com_select';

0 comments on commit a8e1eef

Please sign in to comment.