Commit af024409 authored by unknown's avatar unknown

Re-run fix-fields on condition if table was reopened in HANDLERREAD


sql/sql_base.cc:
  Added more comments
sql/sql_handler.cc:
  Re-run fix-fields on condition if table was reopened
parent 159eaf4f
...@@ -1012,10 +1012,20 @@ TABLE *find_locked_table(THD *thd, const char *db,const char *table_name) ...@@ -1012,10 +1012,20 @@ TABLE *find_locked_table(THD *thd, const char *db,const char *table_name)
/**************************************************************************** /****************************************************************************
** Reopen an table because the definition has changed. The date file for the Reopen an table because the definition has changed. The date file for the
** table is already closed. table is already closed.
** Returns 0 if ok.
** If table can't be reopened, the entry is unchanged. SYNOPSIS
reopen_table()
table Table to be opened
locked 1 if we have already a lock on LOCK_open
NOTES
table->query_id will be 0 if table was reopened
RETURN
0 ok
1 error ('table' is unchanged if table couldn't be reopened)
****************************************************************************/ ****************************************************************************/
bool reopen_table(TABLE *table,bool locked) bool reopen_table(TABLE *table,bool locked)
...@@ -1085,8 +1095,10 @@ bool reopen_table(TABLE *table,bool locked) ...@@ -1085,8 +1095,10 @@ bool reopen_table(TABLE *table,bool locked)
(*field)->table_name=table->table_name; (*field)->table_name=table->table_name;
} }
for (key=0 ; key < table->keys ; key++) for (key=0 ; key < table->keys ; key++)
{
for (part=0 ; part < table->key_info[key].usable_key_parts ; part++) for (part=0 ; part < table->key_info[key].usable_key_parts ; part++)
table->key_info[key].key_part[part].field->table= table; table->key_info[key].key_part[part].field->table= table;
}
VOID(pthread_cond_broadcast(&COND_refresh)); VOID(pthread_cond_broadcast(&COND_refresh));
error=0; error=0;
......
...@@ -437,9 +437,14 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ...@@ -437,9 +437,14 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
if (!lock) if (!lock)
goto err0; // mysql_lock_tables() printed error message already goto err0; // mysql_lock_tables() printed error message already
if (cond && ((!cond->fixed && if (cond)
cond->fix_fields(thd, tables, &cond)) || cond->check_cols(1))) {
goto err0; if (table->query_id != thd->query_id)
cond->cleanup(); // File was reopened
if ((!cond->fixed &&
cond->fix_fields(thd, tables, &cond)) || cond->check_cols(1))
goto err0;
}
if (keyname) if (keyname)
{ {
......
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