Commit a9c52ff7 authored by unknown's avatar unknown

Fix wrong usage of constant which could cause mysqld to use index when doing...

Fix wrong usage of constant which could cause mysqld to use index when doing an update/delete on small tables.
code cleanup


Docs/manual.texi:
  changelog
sql/ha_innobase.cc:
  Removed compiler warning
sql/slave.cc:
  Cleanup comments and indentation for suppressing connect warnings
sql/sql_db.cc:
  clean up comment
sql/sql_delete.cc:
  Fix wrong usage of constant which could cause mysqld to use index when doing an update/delete on small tables.
sql/sql_update.cc:
  Fix wrong usage of constant which could cause mysqld to use index when doing an update/delete on small tables.
parent 887aaff9
......@@ -46928,6 +46928,8 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.52
@itemize @bullet
@item
Don't write slave-timeout reconnects to the error log.
@item
Fixed bug with slave net read timeouting
@item
Fixed bug in ALTERing TABLE of BDB type.
......@@ -1990,7 +1990,7 @@ ha_innobase::change_active_index(
InnoDB */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
KEY* key;
KEY* key=0;
statistic_increment(ha_read_key_count, &LOCK_status);
......@@ -2011,7 +2011,7 @@ ha_innobase::change_active_index(
if (!prebuilt->index) {
fprintf(stderr,
"InnoDB: Could not find key n:o %u with name %s from dict cache\n"
"InnoDB: for table %s\n", keynr, key->name, prebuilt->table->name);
"InnoDB: for table %s\n", keynr, key ? key->name : "NULL", prebuilt->table->name);
return(1);
}
......
......@@ -55,7 +55,7 @@ inline bool slave_killed(THD* thd);
static int init_slave_thread(THD* thd);
static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi);
static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi,
bool suppress_prints_as_normal_reconnect_after_timeout);
bool suppress_warnings);
static int safe_sleep(THD* thd, int sec);
static int request_table_dump(MYSQL* mysql, char* db, char* table);
static int create_table_from_dump(THD* thd, NET* net, const char* db,
......@@ -839,13 +839,15 @@ command");
return 0;
}
/* We set suppress_prints_as_normal_reconnect_after_timeout TRUE
when a normal net read timeout has caused us to try a reconnect.
We do not want to print anything to the error log in this case
because this a anormal event in an idle server. */
static uint read_event(MYSQL* mysql, MASTER_INFO *mi,
bool* suppress_prints_as_normal_reconnect_after_timeout)
/*
We set suppress_warnings TRUE when a normal net read timeout has
caused us to try a reconnect. We do not want to print anything to
the error log in this case because this a anormal event in an idle
server.
*/
static uint read_event(MYSQL* mysql, MASTER_INFO *mi, bool* suppress_warnings)
{
uint len = packet_error;
......@@ -855,21 +857,22 @@ static uint read_event(MYSQL* mysql, MASTER_INFO *mi,
if (disconnect_slave_event_count && !(events_till_disconnect--))
return packet_error;
#endif
*suppress_prints_as_normal_reconnect_after_timeout = 0;
*suppress_warnings= 0;
len = mc_net_safe_read(mysql);
if (len == packet_error || (long) len < 1)
{
if (mc_mysql_errno(mysql) == ER_NET_READ_INTERRUPTED) {
/* We are trying a normal reconnect after a read timeout;
if (mc_mysql_errno(mysql) == ER_NET_READ_INTERRUPTED)
{
/*
We are trying a normal reconnect after a read timeout;
we suppress prints to .err file as long as the reconnect
happens without problems */
*suppress_prints_as_normal_reconnect_after_timeout = TRUE;
happens without problems
*/
*suppress_warnings= TRUE;
}
if (!(*suppress_prints_as_normal_reconnect_after_timeout))
else
sql_print_error("Error reading packet from server: %s (\
server_errno=%d)",
mc_mysql_error(mysql), mc_mysql_errno(mysql));
......@@ -1380,15 +1383,13 @@ try again, log '%s' at postion %s", RPL_LOG_NAME,
while(!slave_killed(thd))
{
bool suppress_prints_as_normal_reconnect_after_timeout = 0;
bool suppress_warnings= 0;
thd->proc_info = "Reading master update";
uint event_len = read_event(mysql, &glob_mi,
&suppress_prints_as_normal_reconnect_after_timeout);
uint event_len = read_event(mysql, &glob_mi, &suppress_warnings);
if(slave_killed(thd))
{
suppress_prints_as_normal_reconnect_after_timeout = 0;
sql_print_error("Slave thread killed while reading event");
goto err;
}
......@@ -1397,7 +1398,6 @@ try again, log '%s' at postion %s", RPL_LOG_NAME,
{
if(mc_mysql_errno(mysql) == ER_NET_PACKET_TOO_LARGE)
{
suppress_prints_as_normal_reconnect_after_timeout = 0;
sql_print_error("Log entry on master is longer than \
max_allowed_packet on slave. Slave thread will be aborted. If the entry is \
really supposed to be that long, restart the server with a higher value of \
......@@ -1415,7 +1415,6 @@ max_allowed_packet. The current value is %ld", max_allowed_packet);
if(slave_killed(thd))
{
suppress_prints_as_normal_reconnect_after_timeout = 0;
sql_print_error("Slave thread killed while waiting to \
reconnect after a failed read");
goto err;
......@@ -1423,21 +1422,19 @@ reconnect after a failed read");
thd->proc_info = "Reconnecting after a failed read";
last_failed_pos= glob_mi.pos;
if (!suppress_prints_as_normal_reconnect_after_timeout)
if (!suppress_warnings)
sql_print_error("Slave: Failed reading log event, \
reconnecting to retry, log '%s' position %s", RPL_LOG_NAME,
llstr(last_failed_pos, llbuff));
if(safe_reconnect(thd, mysql, &glob_mi,
suppress_prints_as_normal_reconnect_after_timeout)
suppress_warnings)
|| slave_killed(thd))
{
suppress_prints_as_normal_reconnect_after_timeout = 0;
sql_print_error("Slave thread killed during or after a \
reconnect done to recover from failed read");
goto err;
}
suppress_prints_as_normal_reconnect_after_timeout = 0;
goto connected;
} // if(event_len == packet_error)
......@@ -1550,7 +1547,7 @@ static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi)
*/
static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi,
bool suppress_prints_as_normal_reconnect_after_timeout)
bool suppress_warnings)
{
int slave_was_killed;
int last_errno= -2; // impossible error
......@@ -1570,7 +1567,7 @@ static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi,
/* Don't repeat last error */
if (mc_mysql_errno(mysql) != last_errno)
{
suppress_prints_as_normal_reconnect_after_timeout = 0;
suppress_warnings= 0;
sql_print_error("Slave thread: error re-connecting to master: \
%s, last_errno=%d, retry in %d sec",
mc_mysql_error(mysql), last_errno=mc_mysql_errno(mysql),
......@@ -1587,7 +1584,7 @@ static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi,
if (!slave_was_killed)
{
if (!suppress_prints_as_normal_reconnect_after_timeout)
if (!suppress_warnings)
sql_print_error("Slave: reconnected to master '%s@%s:%d',\
replication resumed in log '%s' at position %s", glob_mi.user,
glob_mi.host, glob_mi.port,
......
......@@ -166,11 +166,12 @@ void mysql_rm_db(THD *thd,char *db,bool if_exists)
if ((deleted=mysql_rm_known_files(thd, dirp, path,0)) >= 0)
{
/* If there are running queries on the tables, MySQL needs to get
/*
If there are running queries on the tables, MySQL needs to get
access to LOCK_open to end them. InnoDB on the other hand waits
for the queries to end before dropping the database. That is why we
must do the dropping with LOCK_open released. */
must do the dropping with LOCK_open released.
*/
VOID(pthread_mutex_unlock(&LOCK_open));
ha_drop_database(path);
VOID(pthread_mutex_lock(&LOCK_open));
......
......@@ -169,7 +169,7 @@ int mysql_delete(THD *thd,TABLE_LIST *table_list,COND *conds,ha_rows limit,
select=make_select(table,0,0,conds,&error);
if (error)
DBUG_RETURN(-1);
if ((select && select->check_quick(test(thd->options & SQL_SAFE_UPDATES),
if ((select && select->check_quick(test(thd->options & OPTION_SAFE_UPDATES),
limit)) ||
!limit)
{
......
......@@ -110,7 +110,7 @@ int mysql_update(THD *thd,TABLE_LIST *table_list,List<Item> &fields,
table->used_keys=0;
select=make_select(table,0,0,conds,&error);
if (error ||
(select && select->check_quick(test(thd->options & SQL_SAFE_UPDATES),
(select && select->check_quick(test(thd->options & OPTION_SAFE_UPDATES),
limit)) ||
!limit)
{
......
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