Commit cc80a72c authored by sunny's avatar sunny

Fix a potential bug in ha_innodb.cc:innobase_query_is_update() where the

function can be called with "current_thd == NULL". Minor non-functional fix
in log0recv.c
parent 8184675a
...@@ -1254,18 +1254,6 @@ trx_is_interrupted( ...@@ -1254,18 +1254,6 @@ trx_is_interrupted(
return(trx && trx->mysql_thd && ((THD*) trx->mysql_thd)->killed); return(trx && trx->mysql_thd && ((THD*) trx->mysql_thd)->killed);
} }
/**************************************************************************
Obtain a pointer to the MySQL THD object, as in current_thd(). This
definition must match the one in sql/ha_innodb.cc! */
extern "C"
void*
innobase_current_thd(void)
/*======================*/
/* out: MySQL THD object */
{
return(current_thd);
}
/********************************************************************* /*********************************************************************
Call this when you have opened a new table handle in HANDLER, before you Call this when you have opened a new table handle in HANDLER, before you
call index_read_idx() etc. Actually, we can let the cursor stay open even call index_read_idx() etc. Actually, we can let the cursor stay open even
...@@ -7346,7 +7334,6 @@ innobase_get_at_most_n_mbchars( ...@@ -7346,7 +7334,6 @@ innobase_get_at_most_n_mbchars(
} }
} }
extern "C" {
/********************************************************************** /**********************************************************************
This function returns true if This function returns true if
...@@ -7356,33 +7343,34 @@ is either REPLACE or LOAD DATA INFILE REPLACE. ...@@ -7356,33 +7343,34 @@ is either REPLACE or LOAD DATA INFILE REPLACE.
2) SQL-query in the current thread 2) SQL-query in the current thread
is INSERT ON DUPLICATE KEY UPDATE. is INSERT ON DUPLICATE KEY UPDATE.
NOTE that /mysql/innobase/row/row0ins.c must contain the NOTE that storage/innobase/row/row0ins.c must contain the
prototype for this function ! */ prototype for this function ! */
extern "C"
ibool ibool
innobase_query_is_update(void) innobase_query_is_update(void)
/*==========================*/ /*==========================*/
{ {
THD* thd; THD* thd = current_thd;
thd = (THD *)innobase_current_thd();
if (thd->lex->sql_command == SQLCOM_REPLACE || if (!thd) {
thd->lex->sql_command == SQLCOM_REPLACE_SELECT || /* InnoDB's internal threads may run InnoDB stored procedures
(thd->lex->sql_command == SQLCOM_LOAD && that call this function. Then current_thd is not defined
thd->lex->duplicates == DUP_REPLACE)) { (it is probably NULL). */
return(1); return(FALSE);
} }
if (thd->lex->sql_command == SQLCOM_INSERT && switch (thd->lex->sql_command) {
thd->lex->duplicates == DUP_UPDATE) { case SQLCOM_REPLACE:
case SQLCOM_REPLACE_SELECT:
return(1); return(TRUE);
case SQLCOM_LOAD:
return(thd->lex->duplicates == DUP_REPLACE);
case SQLCOM_INSERT:
return(thd->lex->duplicates == DUP_UPDATE);
default:
return(FALSE);
} }
return(0);
}
} }
/*********************************************************************** /***********************************************************************
......
...@@ -191,6 +191,7 @@ recv_sys_empty_hash(void) ...@@ -191,6 +191,7 @@ recv_sys_empty_hash(void)
recv_sys->addr_hash = hash_create(buf_pool_get_curr_size() / 256); recv_sys->addr_hash = hash_create(buf_pool_get_curr_size() / 256);
} }
#ifndef UNIV_LOG_DEBUG
/************************************************************ /************************************************************
Frees the recovery system. */ Frees the recovery system. */
static static
...@@ -210,6 +211,7 @@ recv_sys_free(void) ...@@ -210,6 +211,7 @@ recv_sys_free(void)
mutex_exit(&(recv_sys->mutex)); mutex_exit(&(recv_sys->mutex));
} }
#endif /* UNIV_LOG_DEBUG */
/************************************************************ /************************************************************
Truncates possible corrupted or extra records from a log group. */ Truncates possible corrupted or extra records from a log group. */
......
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