Commit b2e879cb authored by unknown's avatar unknown

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
parent 98e7d709
--log=$MYSQLTEST_VARDIR/log/master.log --log-output=FILE
--log=$MYSQLTEST_VARDIR/log/master.log --log-output=FILE,TABLE
......@@ -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;
}
......
......@@ -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 }
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment