diff options
author | unknown <davi@mysql.com/endora.local> | 2008-02-25 07:48:02 -0300 |
---|---|---|
committer | unknown <davi@mysql.com/endora.local> | 2008-02-25 07:48:02 -0300 |
commit | b2e879cbe83f0157f36e2d44aa4290572ee63886 (patch) | |
tree | 015d9e1bd0360bfceeb9247d6e470bf931540aff | |
parent | 98e7d709bb61e9ac7a507956a15fbe887e372066 (diff) | |
download | mariadb-git-b2e879cbe83f0157f36e2d44aa4290572ee63886.tar.gz |
Bug#28386 the general log is incomplete
The problem is that the commands COM_STMT_CLOSE, COM_STMT_RESET,
COM_STMT_SEND_LONG_DATA weren't being logged to the general log.
The solution is to log the general log the aforementioned commands.
mysql-test/t/mysql_client_test-master.opt:
Also log to table.
sql/sql_prepare.cc:
Log COM_STMT_CLOSE, COM_STMT_RESET and COM_STMT_SEND_LONG_DATA.
tests/mysql_client_test.c:
Add test case for Bug#28386
-rw-r--r-- | mysql-test/t/mysql_client_test-master.opt | 2 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 6 | ||||
-rw-r--r-- | tests/mysql_client_test.c | 60 |
3 files changed, 67 insertions, 1 deletions
diff --git a/mysql-test/t/mysql_client_test-master.opt b/mysql-test/t/mysql_client_test-master.opt index 2dfcc4a2fb9..4c683f7f0a2 100644 --- a/mysql-test/t/mysql_client_test-master.opt +++ b/mysql-test/t/mysql_client_test-master.opt @@ -1 +1 @@ ---log=$MYSQLTEST_VARDIR/log/master.log --log-output=FILE +--log=$MYSQLTEST_VARDIR/log/master.log --log-output=FILE,TABLE diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index c06c68df8d3..a027ffe9daa 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2533,6 +2533,8 @@ void mysql_stmt_reset(THD *thd, char *packet) stmt->state= Query_arena::PREPARED; + general_log_print(thd, thd->command, NullS); + my_ok(thd); DBUG_VOID_RETURN; @@ -2562,6 +2564,7 @@ void mysql_stmt_close(THD *thd, char *packet) */ DBUG_ASSERT(! (stmt->flags & (uint) Prepared_statement::IS_IN_USE)); (void) stmt->deallocate(); + general_log_print(thd, thd->command, NullS); thd->main_da.disable_status(); @@ -2669,6 +2672,9 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) stmt->last_errno= ER_OUTOFMEMORY; sprintf(stmt->last_error, ER(ER_OUTOFMEMORY), 0); } + + general_log_print(thd, thd->command, NullS); + DBUG_VOID_RETURN; } diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index d85a40f7393..01177ffed3c 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -17313,6 +17313,65 @@ static void test_bug31669() DBUG_VOID_RETURN; } + +/** + Bug#28386 the general log is incomplete +*/ + +static void test_bug28386() +{ + int rc; + MYSQL_STMT *stmt; + MYSQL_RES *result; + MYSQL_BIND bind; + const char hello[]= "hello world!"; + + DBUG_ENTER("test_bug28386"); + myheader("test_bug28386"); + + rc= mysql_query(mysql, "truncate mysql.general_log"); + myquery(rc); + + stmt= mysql_simple_prepare(mysql, "SELECT ?"); + check_stmt(stmt); + + memset(&bind, 0, sizeof(bind)); + + bind.buffer_type= MYSQL_TYPE_STRING; + bind.buffer= (void *) hello; + bind.buffer_length= sizeof(hello); + + mysql_stmt_bind_param(stmt, &bind); + mysql_stmt_send_long_data(stmt, 0, hello, sizeof(hello)); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + rc= my_process_stmt_result(stmt); + DIE_UNLESS(rc == 1); + + rc= mysql_stmt_reset(stmt); + check_execute(stmt, rc); + + rc= mysql_stmt_close(stmt); + DIE_UNLESS(!rc); + + rc= mysql_query(mysql, "select * from mysql.general_log where " + "command_type='Close stmt' or " + "command_type='Reset stmt' or " + "command_type='Long Data'"); + myquery(rc); + + result= mysql_store_result(mysql); + mytest(result); + + DIE_UNLESS(mysql_num_rows(result) == 3); + + mysql_free_result(result); + + DBUG_VOID_RETURN; +} + /* Read and parse arguments and MySQL options from my.cnf */ @@ -17618,6 +17677,7 @@ static struct my_tests_st my_tests[]= { { "test_bug20023", test_bug20023 }, { "test_bug31418", test_bug31418 }, { "test_bug31669", test_bug31669 }, + { "test_bug28386", test_bug28386 }, { 0, 0 } }; |