Never pass NULL to innobase_get_stmt()
This commit is contained in:
parent
71cd205956
commit
408ef65f84
@ -2265,16 +2265,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;
|
||||
if (thd) {
|
||||
stmt = thd_query_string(thd);
|
||||
if (stmt) {
|
||||
*length = stmt->length;
|
||||
query = stmt->str;
|
||||
}
|
||||
if (const LEX_STRING *stmt = thd_query_string(thd)) {
|
||||
*length = stmt->length;
|
||||
return stmt->str;
|
||||
}
|
||||
return (query);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**********************************************************************//**
|
||||
|
@ -909,12 +909,18 @@ lock_reset_lock_and_trx_wait(
|
||||
const char* stmt2=NULL;
|
||||
size_t stmt_len;
|
||||
trx_id_t trx_id = 0;
|
||||
stmt = innobase_get_stmt(lock->trx->mysql_thd, &stmt_len);
|
||||
stmt = lock->trx->mysql_thd
|
||||
? innobase_get_stmt(lock->trx->mysql_thd, &stmt_len)
|
||||
: NULL;
|
||||
|
||||
if (lock->trx->lock.wait_lock &&
|
||||
lock->trx->lock.wait_lock->trx) {
|
||||
trx_id = lock->trx->lock.wait_lock->trx->id;
|
||||
stmt2 = innobase_get_stmt(lock->trx->lock.wait_lock->trx->mysql_thd, &stmt_len);
|
||||
stmt2 = lock->trx->lock.wait_lock->trx->mysql_thd
|
||||
? innobase_get_stmt(
|
||||
lock->trx->lock.wait_lock
|
||||
->trx->mysql_thd, &stmt_len)
|
||||
: NULL;
|
||||
}
|
||||
|
||||
ib_logf(IB_LOG_LEVEL_INFO,
|
||||
@ -5586,13 +5592,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];
|
||||
|
@ -2591,16 +2591,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;
|
||||
if (thd) {
|
||||
stmt = thd_query_string(thd);
|
||||
if (stmt) {
|
||||
*length = stmt->length;
|
||||
query = stmt->str;
|
||||
}
|
||||
if (const LEX_STRING *stmt = thd_query_string(thd)) {
|
||||
*length = stmt->length;
|
||||
return stmt->str;
|
||||
}
|
||||
return (query);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**********************************************************************//**
|
||||
|
@ -921,12 +921,18 @@ lock_reset_lock_and_trx_wait(
|
||||
const char* stmt2=NULL;
|
||||
size_t stmt_len;
|
||||
trx_id_t trx_id = 0;
|
||||
stmt = innobase_get_stmt(lock->trx->mysql_thd, &stmt_len);
|
||||
stmt = lock->trx->mysql_thd
|
||||
? innobase_get_stmt(lock->trx->mysql_thd, &stmt_len)
|
||||
: NULL;
|
||||
|
||||
if (lock->trx->lock.wait_lock &&
|
||||
lock->trx->lock.wait_lock->trx) {
|
||||
trx_id = lock->trx->lock.wait_lock->trx->id;
|
||||
stmt2 = innobase_get_stmt(lock->trx->lock.wait_lock->trx->mysql_thd, &stmt_len);
|
||||
stmt2 = lock->trx->lock.wait_lock->trx->mysql_thd
|
||||
? innobase_get_stmt(
|
||||
lock->trx->lock.wait_lock
|
||||
->trx->mysql_thd, &stmt_len)
|
||||
: NULL;
|
||||
}
|
||||
|
||||
ib_logf(IB_LOG_LEVEL_INFO,
|
||||
@ -5636,13 +5642,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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user