From 6b9db6d213fb8f564a5a9cd15e4fe694acdc6300 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Feb 2008 17:25:21 +0300 Subject: Valgrind errors in mysql_client_test. tests/mysql_client_test.c: Fix a memory leak. Run the test for Bug#28386 only if logging to tables is enabled. --- tests/mysql_client_test.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests') diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 7466f20fbdc..26c243d89a4 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -8985,6 +8985,7 @@ static void test_sqlmode() fprintf(stdout, "\n query: %s", query); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); + mysql_stmt_close(stmt); /* ANSI */ strmov(query, "SET SQL_MODE= \"ANSI\""); @@ -17334,12 +17335,36 @@ static void test_bug28386() int rc; MYSQL_STMT *stmt; MYSQL_RES *result; + MYSQL_ROW row; MYSQL_BIND bind; const char hello[]= "hello world!"; DBUG_ENTER("test_bug28386"); myheader("test_bug28386"); + rc= mysql_query(mysql, "select @@global.log_output"); + myquery(rc); + + result= mysql_store_result(mysql); + DIE_UNLESS(result); + + row= mysql_fetch_row(result); + if (! strstr(row[0], "TABLE")) + { + mysql_free_result(result); + if (! opt_silent) + printf("Skipping the test since logging to tables is not enabled\n"); + /* Log output is not to tables */ + return; + } + mysql_free_result(result); + + rc= mysql_query(mysql, "set @save_global_general_log=@@global.general_log"); + myquery(rc); + + rc= mysql_query(mysql, "set @@global.general_log=on"); + myquery(rc); + rc= mysql_query(mysql, "truncate mysql.general_log"); myquery(rc); @@ -17380,6 +17405,9 @@ static void test_bug28386() mysql_free_result(result); + rc= mysql_query(mysql, "set @@global.general_log=@save_global_general_log"); + myquery(rc); + DBUG_VOID_RETURN; } -- cgit v1.2.1