Commit a40a569c 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 7fc2434c
......@@ -1254,18 +1254,6 @@ trx_is_interrupted(
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 index_read_idx() etc. Actually, we can let the cursor stay open even
......@@ -7346,7 +7334,6 @@ innobase_get_at_most_n_mbchars(
}
}
extern "C" {
/**********************************************************************
This function returns true if
......@@ -7356,33 +7343,34 @@ is either REPLACE or LOAD DATA INFILE REPLACE.
2) SQL-query in the current thread
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 ! */
extern "C"
ibool
innobase_query_is_update(void)
/*==========================*/
{
THD* thd;
thd = (THD *)innobase_current_thd();
THD* thd = current_thd;
if (thd->lex->sql_command == SQLCOM_REPLACE ||
thd->lex->sql_command == SQLCOM_REPLACE_SELECT ||
(thd->lex->sql_command == SQLCOM_LOAD &&
thd->lex->duplicates == DUP_REPLACE)) {
if (!thd) {
/* InnoDB's internal threads may run InnoDB stored procedures
that call this function. Then current_thd is not defined
(it is probably NULL). */
return(1);
return(FALSE);
}
if (thd->lex->sql_command == SQLCOM_INSERT &&
thd->lex->duplicates == DUP_UPDATE) {
return(1);
switch (thd->lex->sql_command) {
case SQLCOM_REPLACE:
case SQLCOM_REPLACE_SELECT:
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)
recv_sys->addr_hash = hash_create(buf_pool_get_curr_size() / 256);
}
#ifndef UNIV_LOG_DEBUG
/************************************************************
Frees the recovery system. */
static
......@@ -210,6 +211,7 @@ recv_sys_free(void)
mutex_exit(&(recv_sys->mutex));
}
#endif /* UNIV_LOG_DEBUG */
/************************************************************
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