diff --git a/test/tap/tests/mysql-init_connect-t.cpp b/test/tap/tests/mysql-init_connect-t.cpp new file mode 100644 index 000000000..f5fc2f1db --- /dev/null +++ b/test/tap/tests/mysql-init_connect-t.cpp @@ -0,0 +1,113 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include "tap.h" +#include "command_line.h" +#include "utils.h" + +inline unsigned long long monotonic_time() { + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return (((unsigned long long) ts.tv_sec) * 1000000) + (ts.tv_nsec / 1000); +} + +int main(int argc, char** argv) { + CommandLine cl; + + if(cl.getEnv()) + return exit_status(); + + plan(7); + + MYSQL* mysqladmin = mysql_init(NULL); + if (!mysqladmin) + return exit_status(); + + if (!mysql_real_connect(mysqladmin, cl.host, cl.admin_username, cl.admin_password, NULL, cl.admin_port, NULL, 0)) { + fprintf(stderr, "File %s, line %d, Error: %s\n", + __FILE__, __LINE__, mysql_error(mysqladmin)); + return exit_status(); + } + + MYSQL* mysql = mysql_init(NULL); + if (!mysql) + return exit_status(); + + if (!mysql_real_connect(mysql, cl.host, cl.username, cl.password, NULL, cl.port, NULL, 0)) { + fprintf(stderr, "Failed to connect to database: Error: %s\n", + mysql_error(mysql)); + return exit_status(); + } + diag("Setting mysql-init_connect to DO 1"); + MYSQL_QUERY(mysqladmin, "UPDATE global_variables SET variable_value='DO 1' WHERE variable_name = 'mysql-init_connect'"); + MYSQL_QUERY(mysqladmin, "load mysql variables to runtime"); + + MYSQL_RES *res; + + { + const char *q = "SELECT /* create_new_connection=1 */ 100"; + diag("Running query: %s", q); + MYSQL_QUERY(mysql, q); + res = mysql_store_result(mysql); + MYSQL_ROW row; + unsigned long long num_rows = mysql_num_rows(res); + ok(num_rows == 1, "mysql_num_rows() , expected: 1 , actual: %llu", num_rows); + while ((row = mysql_fetch_row(res))) { + ok(strcmp(row[0],"100")==0, "row: expected: \"100\" , actual: \"%s\"", row[0]); + } + mysql_free_result(res); + } + + diag("Setting mysql-init_connect to SELECT 1"); + MYSQL_QUERY(mysqladmin, "UPDATE global_variables SET variable_value='SELECT 1' WHERE variable_name = 'mysql-init_connect'"); + MYSQL_QUERY(mysqladmin, "load mysql variables to runtime"); + + { + const char *q = "SELECT /* create_new_connection=1 */ 200"; + diag("Running query: %s", q); + MYSQL_QUERY(mysql, q); + res = mysql_store_result(mysql); + MYSQL_ROW row; + unsigned long long num_rows = mysql_num_rows(res); + ok(num_rows == 1, "mysql_num_rows() , expected: 1 , actual: %llu", num_rows); + while ((row = mysql_fetch_row(res))) { + ok(strcmp(row[0],"200")==0, "row: expected: \"200\" , actual: \"%s\"", row[0]); + } + mysql_free_result(res); + } + + diag("Setting mysql-init_connect to SELECT SLEEP(3)"); + MYSQL_QUERY(mysqladmin, "UPDATE global_variables SET variable_value='SELECT SLEEP(3)' WHERE variable_name = 'mysql-init_connect'"); + MYSQL_QUERY(mysqladmin, "load mysql variables to runtime"); + + { + const char *q = "SELECT /* create_new_connection=1 */ 300"; + diag("Running query: %s", q); + unsigned long long begin = monotonic_time(); + MYSQL_QUERY(mysql, q); + res = mysql_store_result(mysql); + MYSQL_ROW row; + unsigned long long num_rows = mysql_num_rows(res); + ok(num_rows == 1, "mysql_num_rows() , expected: 1 , actual: %llu", num_rows); + while ((row = mysql_fetch_row(res))) { + ok(strcmp(row[0],"300")==0, "row: expected: \"300\" , actual: \"%s\"", row[0]); + } + mysql_free_result(res); + unsigned long long end = monotonic_time(); + unsigned long time_diff_ms = (end-begin)/1000; + ok(time_diff_ms>2900 && time_diff_ms < 3200 , "Total query execution time should be around 3 seconds. Actual : %llums", time_diff_ms); + + } + + mysql_close(mysql); + mysql_close(mysqladmin); + + return exit_status(); +} + diff --git a/test/tap/tests/mysql_stmt_send_long_data-t.cpp b/test/tap/tests/mysql_stmt_send_long_data-t.cpp new file mode 100644 index 000000000..d14a7e102 --- /dev/null +++ b/test/tap/tests/mysql_stmt_send_long_data-t.cpp @@ -0,0 +1,251 @@ +#include +#include +#include +#include +#include +#include + +#include "tap.h" +#include "command_line.h" +#include "utils.h" + +const int NUM_EXECUTIONS = 10; + +std::string select_query = "SELECT /* hostgroup=0 */ * FROM test.sbtest1 WHERE id = ?"; + +std::string insert_query[4] = { + "INSERT INTO test.sbtest1 (id) VALUES (?)", + "INSERT INTO test.sbtest1 (id, k) VALUES (?,?)", + "INSERT INTO test.sbtest1 (id, k, c) VALUES (?,?,?)", + "INSERT INTO test.sbtest1 (id, k, c, pad) VALUES (?,?,?,?)" +// "SELECT /*+ MAX_EXECUTION_TIME(10) */ COUNT(*) FROM test.sbtest1 a JOIN test.sbtest1 b WHERE (a.id+b.id)%2" , +// "SELECT COUNT(*) FROM (SELECT a.* FROM test.sbtest1 a JOIN test.sbtest1 b WHERE (a.id+b.id)%2 LIMIT 1000) t" , +// "SELECT a.* FROM test.sbtest1 a JOIN test.sbtest1 b WHERE (a.id+b.id)%2 LIMIT 10000" +}; + +int idx = 0; +int idx2 = 0; +int k = 0; + +int main(int argc, char** argv) { + CommandLine cl; + + int plans = 4 * 3; // 4 INSERT queries each of them triggers a SELECT and a data comparison + plans *= NUM_EXECUTIONS; + plans += 5; // prepares + plans += (4 * NUM_EXECUTIONS / 5); //mysql_stmt_reset() + + plan(plans); + + if (cl.getEnv()) { + diag("Failed to get the required environmental variables."); + return -1; + } + + MYSQL* mysql = mysql_init(NULL); + if (!mysql) { + fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(mysql)); + return exit_status(); + } + + if (!mysql_real_connect(mysql, cl.host, cl.username, cl.password, NULL, cl.port, NULL, 0)) { + fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(mysql)); + return exit_status(); + } + + idx = 1000; + if (create_table_test_sbtest1(idx,mysql)) { + fprintf(stderr, "File %s, line %d, Error: create_table_test_sbtest1() failed\n", __FILE__, __LINE__); + return exit_status(); + } + idx++; + + MYSQL_STMT* stmt[4]; + MYSQL_STMT* select_stmt; + for (int i=0; i<4; i++) { + // Initialize and prepare the statement + stmt[i]= mysql_stmt_init(mysql); + if (!stmt[i]) { + diag("mysql_stmt_init(), out of memory\n"); + return exit_status(); + } + if (mysql_stmt_prepare(stmt[i], insert_query[i].c_str(), strlen(insert_query[i].c_str()))) { + diag("insert_query: %s", insert_query[i].c_str()); + ok(false, "mysql_stmt_prepare at line %d failed: %s", __LINE__ , mysql_error(mysql)); + mysql_close(mysql); + mysql_library_end(); + return exit_status(); + } else { + ok(true, "Prepare succeeded: %s", insert_query[i].c_str()); + } + } + + select_stmt = mysql_stmt_init(mysql); + if (!select_stmt) { + diag("mysql_stmt_init(), out of memory\n"); + return exit_status(); + } + if (mysql_stmt_prepare(select_stmt, select_query.c_str(), strlen(select_query.c_str()))) { + diag("select_query: %s", select_query.c_str()); + ok(false, "mysql_stmt_prepare at line %d failed: %s", __LINE__ , mysql_error(mysql)); + mysql_close(mysql); + mysql_library_end(); + return exit_status(); + } else { + ok(true, "Prepare succeeded: %s", select_query.c_str()); + } + + int rc = 0; + + for (int n = 0; n < NUM_EXECUTIONS; n++) { + MYSQL_BIND bind[4]; + for (int i=0; i<4; i++) { + if ((n*4+i)%5==0) { + // sometime we also run mysql_stmt_reset() to test the code + rc = mysql_stmt_reset(stmt[i]); + ok(rc==0, "mysql_stmt_reset() for stmt %d returned: %s" , i , (rc == 0 ? "" : mysql_stmt_error(stmt[i]))); + if (rc) + return exit_status(); + } + if (i==0) + k=0; + else { + k=n+7+i; + } + long unsigned c_length; + long unsigned pad_length; + memset(bind, 0, sizeof(bind)); + bind[0].buffer_type= MYSQL_TYPE_LONG; + bind[0].buffer= (char *)&idx; + bind[0].is_null= 0; + bind[0].length= 0; + bind[1].buffer_type= MYSQL_TYPE_LONG; + bind[1].buffer= (char *)&k; + bind[1].is_null= 0; + bind[1].length= 0; + diag("Executing: %s", insert_query[i].c_str()); + if (i>=2) { + bind[2].buffer_type= MYSQL_TYPE_STRING; + bind[2].length= &c_length; + bind[2].is_null= 0; + bind[3].buffer_type= MYSQL_TYPE_STRING; + bind[3].length= &pad_length; + bind[3].is_null= 0; + } + if (mysql_stmt_bind_param(stmt[i], bind)) { + diag("mysql_stmt_bind_param() for stmt %d failed: %s", i, mysql_stmt_error(stmt[i])); + return exit_status(); + } + // here we keep record of what we wrote + std::string p2 = ""; + std::string p3 = ""; + for (int j=2; j<4; j++) { + if (j<=i) { + for (int k=0; k<1 + rand()%3 + (j==2 ? 3 : 0) ; k++) { // we send multiple chunks + std::string s = "HelloWorld" + std::to_string(idx2++); + if (j==2) { + p2 += s; + } else { + p3 += s; + } + if (mysql_stmt_send_long_data(stmt[i], j, s.c_str(), s.length())) { + diag("mysql_stmt_send_long_data() for stmt %d and param %d failed: %s", i, j, mysql_stmt_error(stmt[i])); + return exit_status(); + } + } + } + } + rc = mysql_stmt_execute(stmt[i]); + if (rc!=0) { + diag("mysql_stmt_execute() for stmt %d failed: %s", i, mysql_stmt_error(stmt[i])); + } + ok(rc==0, "mysql_stmt_execute for stmt %d", i); + if (rc==0) { + MYSQL_BIND bind[4]; + unsigned long length[4]; + memset(bind, 0, sizeof(bind)); + bind[0].buffer_type= MYSQL_TYPE_LONG; + bind[0].buffer= (char *)&idx; + bind[0].is_null= 0; + bind[0].length= 0; + if (mysql_stmt_bind_param(select_stmt, bind)) { + diag("mysql_stmt_bind_param() on SELECT for stmt %d failed: %s", i, mysql_stmt_error(select_stmt)); + return exit_status(); + } + rc = mysql_stmt_execute(select_stmt); + ok(rc==0, "mysql_stmt_execute on SELECT for stmt %d", i); + if (rc!=0) { + diag("mysql_stmt_execute() on SELECT for stmt %d failed: %s", i, mysql_stmt_error(select_stmt)); + } else { + MYSQL_RES *prepare_meta_result; + prepare_meta_result = mysql_stmt_result_metadata(select_stmt); + memset(bind, 0, sizeof(bind)); + int id, k_i; + + char is_null[4]; + char error[4]; + + char str_data_c[256]; + char str_data_pad[256]; + bind[0].buffer_type= MYSQL_TYPE_LONG; + bind[0].buffer= (char *)&id; + bind[0].is_null= &is_null[0]; + bind[0].length= &length[0]; + bind[0].error= &error[0]; + bind[1].buffer_type= MYSQL_TYPE_LONG; + bind[1].buffer= (char *)&k_i; + bind[1].is_null= &is_null[1]; + bind[1].length= &length[1]; + bind[1].error= &error[1]; + bind[2].buffer_type= MYSQL_TYPE_STRING; + bind[2].buffer= (char *)str_data_c; + bind[2].buffer_length= 256; + bind[2].is_null= &is_null[2]; + bind[2].length= &length[2]; + bind[2].error= &error[2]; + bind[3].buffer_type= MYSQL_TYPE_STRING; + bind[3].buffer= (char *)str_data_pad; + bind[3].buffer_length= 256; + bind[3].is_null= &is_null[3]; + bind[3].length= &length[3]; + bind[3].error= &error[3]; + + if (mysql_stmt_bind_result(select_stmt, bind)) { + diag("mysql_stmt_bind_result() on SELECT for stmt %d failed: %s", i, mysql_stmt_error(select_stmt)); + return exit_status(); + } + if (mysql_stmt_store_result(select_stmt)) { + diag("mysql_stmt_store_result() on SELECT for stmt %d failed: %s", i, mysql_stmt_error(select_stmt)); + return exit_status(); + } + //sleep(1); + if (mysql_stmt_fetch(select_stmt)) { + diag("mysql_stmt_fetch() on SELECT for stmt %d failed: %s", i, mysql_stmt_error(select_stmt)); + return exit_status(); + } + diag("Expected: id=%d, k=%d, c=%s, pad=%s", idx, k, p2.c_str(), p3.c_str()); + diag("Retrieved: id=%d, k=%d, c=%s, pad=%s", id, k_i, str_data_c, str_data_pad); + int dm = 0; + if (idx==id && k == k_i && strcmp(p2.c_str(),str_data_c)==0 && strcmp(p3.c_str(),str_data_pad)==0) { + dm=1; + } + ok(dm==1, "Data match: %s", (dm == 1 ? "YES" : "NO . See output above")); + mysql_free_result(prepare_meta_result); + mysql_stmt_free_result(select_stmt); + } + } +// } + //rc = mysql_stmt_store_result(stmt[i]); + //mysql_stmt_free_result(stmt[i]); + idx++; + } + } + for (int i=0; i<4; i++) { + if (mysql_stmt_close(stmt[i])) { + ok(false, "mysql_stmt_close at line %d failed: %s\n", __LINE__ , mysql_error(mysql)); + } + } + mysql_close(mysql); + + return exit_status(); +} diff --git a/test/tap/tests/test-query_timeout-t.cpp b/test/tap/tests/test-query_timeout-t.cpp new file mode 100644 index 000000000..822ba78f4 --- /dev/null +++ b/test/tap/tests/test-query_timeout-t.cpp @@ -0,0 +1,55 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include "tap.h" +#include "command_line.h" +#include "utils.h" + +inline unsigned long long monotonic_time() { + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return (((unsigned long long) ts.tv_sec) * 1000000) + (ts.tv_nsec / 1000); +} + + +int main(int argc, char** argv) { + CommandLine cl; + + if(cl.getEnv()) + return exit_status(); + + plan(1); + + MYSQL* mysql = mysql_init(NULL); + if (!mysql) + return exit_status(); + + if (!mysql_real_connect(mysql, cl.host, cl.username, cl.password, NULL, cl.port, NULL, 0)) { + fprintf(stderr, "Failed to connect to database: Error: %s\n", + mysql_error(mysql)); + return exit_status(); + } + + const char *q = "SELECT /* query_timeout=3300 */ SLEEP(10)"; + diag("Running query; %s", q); + unsigned long long begin = monotonic_time(); + MYSQL_QUERY(mysql, q); + MYSQL_RES * res = mysql_store_result(mysql); + mysql_free_result(res); + unsigned long long end = monotonic_time(); + + unsigned long time_diff_ms = (end-begin)/1000; + + ok(time_diff_ms>3100 && time_diff_ms<3500 , "Query should be interrupted at around 3300ms . Exact time: %llums", time_diff_ms); + + mysql_close(mysql); + + return exit_status(); +} + diff --git a/test/tap/tests/test-throttle_max_bytes_per_second_to_client-t.cpp b/test/tap/tests/test-throttle_max_bytes_per_second_to_client-t.cpp new file mode 100644 index 000000000..649c14d9a --- /dev/null +++ b/test/tap/tests/test-throttle_max_bytes_per_second_to_client-t.cpp @@ -0,0 +1,80 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include "tap.h" +#include "command_line.h" +#include "utils.h" + +inline unsigned long long monotonic_time() { + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return (((unsigned long long) ts.tv_sec) * 1000000) + (ts.tv_nsec / 1000); +} + + +int main(int argc, char** argv) { + CommandLine cl; + + if(cl.getEnv()) + return exit_status(); + + plan(1); + + MYSQL* mysqladmin = mysql_init(NULL); + if (!mysqladmin) + return exit_status(); + + if (!mysql_real_connect(mysqladmin, cl.host, cl.admin_username, cl.admin_password, NULL, cl.admin_port, NULL, 0)) { + fprintf(stderr, "File %s, line %d, Error: %s\n", + __FILE__, __LINE__, mysql_error(mysqladmin)); + return exit_status(); + } + diag("Setting mysql-throttle_max_bytes_per_second_to_client=150000"); + diag("Client will read from ProxySQL at no more than 150KB/s"); + MYSQL_QUERY(mysqladmin, "SET mysql-throttle_max_bytes_per_second_to_client=150000"); + MYSQL_QUERY(mysqladmin, "load mysql variables to runtime"); + + MYSQL* mysql = mysql_init(NULL); + if (!mysql) + return exit_status(); + + if (!mysql_real_connect(mysql, cl.host, cl.username, cl.password, NULL, cl.port, NULL, 0)) { + fprintf(stderr, "Failed to connect to database: Error: %s\n", + mysql_error(mysql)); + return exit_status(); + } + MYSQL_RES *res; + if (create_table_test_sbtest1(100,mysql)) { + fprintf(stderr, "File %s, line %d, Error: create_table_test_sbtest1() failed\n", __FILE__, __LINE__); + return exit_status(); + } + diag("Waiting few seconds for replication..."); + sleep(2); + MYSQL_QUERY(mysql, "USE test"); + + const char *q = "SELECT a.*, b.* FROM sbtest1 a JOIN sbtest1 b"; + diag("Running query; %s", q); + unsigned long long begin = monotonic_time(); + MYSQL_QUERY(mysql, q); + res = mysql_store_result(mysql); + mysql_free_result(res); + unsigned long long end = monotonic_time(); + + unsigned long time_diff_ms = (end-begin)/1000; + + ok(time_diff_ms>20000, "Total query execution time should be more than 20 seconds : %llums", time_diff_ms); + + MYSQL_QUERY(mysqladmin, "SET mysql-throttle_max_bytes_per_second_to_client=0"); + MYSQL_QUERY(mysqladmin, "load mysql variables to runtime"); + mysql_close(mysql); + mysql_close(mysqladmin); + + return exit_status(); +} + diff --git a/test/tap/tests/test_enforce_autocommit_on_reads-t.cpp b/test/tap/tests/test_enforce_autocommit_on_reads-t.cpp new file mode 100644 index 000000000..1dbc62af7 --- /dev/null +++ b/test/tap/tests/test_enforce_autocommit_on_reads-t.cpp @@ -0,0 +1,267 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include "tap.h" +#include "command_line.h" +#include "utils.h" + +/* +This test includes a lot of repetitive checks that could have been organized into functions. +But they have been left in this way to easily identify the failed check +*/ + + +int main(int argc, char** argv) { + CommandLine cl; + + if(cl.getEnv()) + return exit_status(); + + plan(96); + diag("Testing mysql-enforce_autocommit_on_reads"); + + MYSQL* mysqladmin = mysql_init(NULL); + if (!mysqladmin) + return exit_status(); + + if (!mysql_real_connect(mysqladmin, cl.host, cl.admin_username, cl.admin_password, NULL, cl.admin_port, NULL, 0)) { + fprintf(stderr, "File %s, line %d, Error: %s\n", + __FILE__, __LINE__, mysql_error(mysqladmin)); + return exit_status(); + } + + MYSQL_QUERY(mysqladmin, "SET mysql-enforce_autocommit_on_reads=0"); + MYSQL_QUERY(mysqladmin, "load mysql variables to runtime"); + + MYSQL* mysql = mysql_init(NULL); + if (!mysql) + return exit_status(); + + if (!mysql_real_connect(mysql, cl.host, cl.username, cl.password, NULL, cl.port, NULL, 0)) { + fprintf(stderr, "Failed to connect to database: Error: %s\n", + mysql_error(mysql)); + return exit_status(); + } + MYSQL_RES *res; + if (create_table_test_sbtest1(100,mysql)) { + fprintf(stderr, "File %s, line %d, Error: create_table_test_sbtest1() failed\n", __FILE__, __LINE__); + return exit_status(); + } + diag("Waiting few seconds for replication..."); + sleep(2); + MYSQL_QUERY(mysql, "USE test"); + + + MYSQL_QUERY(mysql, "set autocommit=0"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "SELECT * FROM sbtest1 WHERE id=1"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + MYSQL_QUERY(mysql, "set autocommit=0"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "SELECT * FROM sbtest1 WHERE id=2 FOR UPDATE"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 1) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + MYSQL_QUERY(mysql, "set autocommit=0"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "SELECT * FROM sbtest1 WHERE id=2 LOCK IN SHARE MODE"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 1) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + MYSQL_QUERY(mysql, "set autocommit=1"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "SELECT * FROM sbtest1 WHERE id=1"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + MYSQL_QUERY(mysql, "set autocommit=1"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "SELECT * FROM sbtest1 WHERE id=2 FOR UPDATE"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + MYSQL_QUERY(mysql, "set autocommit=1"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "SELECT * FROM sbtest1 WHERE id=2 LOCK IN SHARE MODE"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + MYSQL_QUERY(mysql, "set autocommit=0"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "UPDATE sbtest1 SET k=k+1 WHERE id=2"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 1) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + MYSQL_QUERY(mysql, "set autocommit=1"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "UPDATE sbtest1 SET k=k+1 WHERE id=2"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + + + MYSQL_QUERY(mysqladmin, "SET mysql-enforce_autocommit_on_reads=1"); + MYSQL_QUERY(mysqladmin, "load mysql variables to runtime"); + + MYSQL_QUERY(mysql, "set autocommit=0"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "SELECT * FROM sbtest1 WHERE id=1"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 1) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + MYSQL_QUERY(mysql, "set autocommit=0"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "SELECT * FROM sbtest1 WHERE id=2 FOR UPDATE"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 1) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + MYSQL_QUERY(mysql, "set autocommit=0"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "SELECT * FROM sbtest1 WHERE id=2 LOCK IN SHARE MODE"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 1) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + MYSQL_QUERY(mysql, "set autocommit=1"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "SELECT * FROM sbtest1 WHERE id=1"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + MYSQL_QUERY(mysql, "set autocommit=1"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "SELECT * FROM sbtest1 WHERE id=2 FOR UPDATE"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + MYSQL_QUERY(mysql, "set autocommit=1"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "SELECT * FROM sbtest1 WHERE id=2 LOCK IN SHARE MODE"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + MYSQL_QUERY(mysql, "set autocommit=0"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "UPDATE sbtest1 SET k=k+1 WHERE id=2"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 1) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 0) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + MYSQL_QUERY(mysql, "set autocommit=1"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + MYSQL_QUERY(mysql, "UPDATE sbtest1 SET k=k+1 WHERE id=2"); + res = mysql_store_result(mysql); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + mysql_free_result(res); + MYSQL_QUERY(mysql, "COMMIT"); + ok(((mysql->server_status & SERVER_STATUS_AUTOCOMMIT) == 2) , "Line: %d: server_status: %u , AUTOCOMMIT %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_AUTOCOMMIT); + ok(((mysql->server_status & SERVER_STATUS_IN_TRANS) == 0) , "Line: %d, server_status: %u , IN_TRANS = %d", __LINE__ , mysql->server_status, mysql->server_status & SERVER_STATUS_IN_TRANS); + + + MYSQL_QUERY(mysqladmin, "SET mysql-enforce_autocommit_on_reads=0"); + MYSQL_QUERY(mysqladmin, "load mysql variables to runtime"); + + mysql_close(mysql); + mysql_close(mysqladmin); + + return exit_status(); +} +