Commit 4754f88c authored by Marko Mäkelä's avatar Marko Mäkelä

Never pass NULL to innobase_get_stmt()

parent 7972da8a
......@@ -1998,15 +1998,11 @@ innobase_get_stmt(
THD* thd, /*!< in: MySQL thread handle */
size_t* length) /*!< out: length of the SQL statement */
{
const char* query = NULL;
LEX_STRING *stmt = NULL;
ut_ad(thd != NULL);
stmt = thd_query_string(thd);
if (stmt) {
if (const LEX_STRING *stmt = thd_query_string(thd)) {
*length = stmt->length;
query = stmt->str;
return stmt->str;
}
return (query);
return NULL;
}
/**********************************************************************//**
......
......@@ -4742,13 +4742,11 @@ lock_rec_unlock(
trx_mutex_exit(trx);
stmt = innobase_get_stmt(trx->mysql_thd, &stmt_len);
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Error: unlock row could not"
" find a %lu mode lock on the record\n",
(ulong) lock_mode);
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: current statement: %.*s\n",
ib_logf(IB_LOG_LEVEL_ERROR,
"unlock row could not find a %u mode lock on the record;"
" statement=%.*s",
lock_mode,
(int) stmt_len, stmt);
return;
......
......@@ -503,7 +503,9 @@ fill_trx_row(
row->trx_mysql_thread_id = thd_get_thread_id(trx->mysql_thd);
stmt = innobase_get_stmt(trx->mysql_thd, &stmt_len);
stmt = trx->mysql_thd
? innobase_get_stmt(trx->mysql_thd, &stmt_len)
: NULL;
if (stmt != NULL) {
char query[TRX_I_S_TRX_QUERY_MAX_LEN + 1];
......
......@@ -2324,15 +2324,11 @@ innobase_get_stmt(
THD* thd, /*!< in: MySQL thread handle */
size_t* length) /*!< out: length of the SQL statement */
{
const char* query = NULL;
LEX_STRING *stmt = NULL;
ut_ad(thd != NULL);
stmt = thd_query_string(thd);
if (stmt) {
if (const LEX_STRING *stmt = thd_query_string(thd)) {
*length = stmt->length;
query = stmt->str;
return stmt->str;
}
return (query);
return NULL;
}
/**********************************************************************//**
......
......@@ -4788,13 +4788,11 @@ lock_rec_unlock(
trx_mutex_exit(trx);
stmt = innobase_get_stmt(trx->mysql_thd, &stmt_len);
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Error: unlock row could not"
" find a %lu mode lock on the record\n",
(ulong) lock_mode);
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: current statement: %.*s\n",
ib_logf(IB_LOG_LEVEL_ERROR,
"unlock row could not find a %u mode lock on the record;"
" statement=%.*s",
lock_mode,
(int) stmt_len, stmt);
return;
......
......@@ -507,7 +507,9 @@ fill_trx_row(
row->trx_mysql_thread_id = thd_get_thread_id(trx->mysql_thd);
stmt = innobase_get_stmt(trx->mysql_thd, &stmt_len);
stmt = trx->mysql_thd
? innobase_get_stmt(trx->mysql_thd, &stmt_len)
: NULL;
if (stmt != NULL) {
char query[TRX_I_S_TRX_QUERY_MAX_LEN + 1];
......
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