Skip to content
Permalink
Browse files
Never pass NULL to innobase_get_stmt()
  • Loading branch information
dr-m committed May 17, 2017
1 parent 7972da8 commit 4754f88
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 30 deletions.
@@ -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];

0 comments on commit 4754f88

Please sign in to comment.