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