From 072fa008b8b0aaeebc830b40a07a5d2300311521 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Mon, 6 Aug 2018 18:45:30 +0200 Subject: [PATCH] Fix for CONC-351: If an ok packet doesn't contain session state tracking information, we need to clear session state information from previous ok packet. --- libmariadb/mariadb_lib.c | 3 +++ unittest/libmariadb/connection.c | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index b7316b21..d914de61 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -2100,6 +2100,9 @@ int ma_read_ok_packet(MYSQL *mysql, uchar *pos, ulong length) } } } + /* CONC-351: clear session state information */ + else if (mysql->server_capabilities & CLIENT_SESSION_TRACKING) + ma_clear_session_state(mysql); return(0); } diff --git a/unittest/libmariadb/connection.c b/unittest/libmariadb/connection.c index bcdf2bca..3f372afa 100644 --- a/unittest/libmariadb/connection.c +++ b/unittest/libmariadb/connection.c @@ -1528,7 +1528,31 @@ static int test_conc332(MYSQL *unused __attribute__((unused))) return OK; } +static int test_conc351(MYSQL *unused __attribute__((unused))) +{ + int rc; + const char *data; + size_t len; + MYSQL *mysql= mysql_init(NULL); + + my_test_connect(mysql, hostname, username, password, schema, + port, socketname, 0); + + FAIL_IF(mysql_errno(mysql), "Error during connect"); + + FAIL_IF(mysql_session_track_get_first(mysql, SESSION_TRACK_SCHEMA, &data, &len), "expected session track schema"); + + rc= mysql_query(mysql, "SET @a:=1"); + check_mysql_rc(rc, mysql); + + FAIL_IF(!mysql_session_track_get_first(mysql, SESSION_TRACK_SCHEMA, &data, &len), "expected no schema tracking information"); + + mysql_close(mysql); + return OK; +} + struct my_tests_st my_tests[] = { + {"test_conc351", test_conc351, TEST_CONNECTION_NONE, 0, NULL, NULL}, {"test_conc332", test_conc332, TEST_CONNECTION_NONE, 0, NULL, NULL}, #ifndef WIN32 {"test_conc327", test_conc327, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},