Commit 08e9e6a7 authored by Sergey Petrunya's avatar Sergey Petrunya

BUG#882472: subselect4.test fails in current 5.3

- The problem was that the value of READ_RECORD::file was not updated when the underlying table
  was temporary and was converted from heap to myisam. Resolved by eliminating READ_RECORD::file,
  always use READ_RECORD::table->file
parent fa36a742
Branches unavailable
Tags unavailable
No related merge requests found
...@@ -59,7 +59,6 @@ void init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table, ...@@ -59,7 +59,6 @@ void init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table,
bzero((char*) info,sizeof(*info)); bzero((char*) info,sizeof(*info));
info->thd= thd; info->thd= thd;
info->table= table; info->table= table;
info->file= table->file;
info->record= table->record[0]; info->record= table->record[0];
info->print_error= print_error; info->print_error= print_error;
info->unlock_row= rr_unlock_row; info->unlock_row= rr_unlock_row;
...@@ -169,7 +168,6 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table, ...@@ -169,7 +168,6 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
bzero((char*) info,sizeof(*info)); bzero((char*) info,sizeof(*info));
info->thd=thd; info->thd=thd;
info->table=table; info->table=table;
info->file= table->file;
info->forms= &info->table; /* Only one table */ info->forms= &info->table; /* Only one table */
if (table->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE && if (table->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE &&
...@@ -291,9 +289,9 @@ void end_read_record(READ_RECORD *info) ...@@ -291,9 +289,9 @@ void end_read_record(READ_RECORD *info)
{ {
filesort_free_buffers(info->table,0); filesort_free_buffers(info->table,0);
if (info->table->created) if (info->table->created)
(void) info->file->extra(HA_EXTRA_NO_CACHE); (void) info->table->file->extra(HA_EXTRA_NO_CACHE);
if (info->read_record != rr_quick) // otherwise quick_range does it if (info->read_record != rr_quick) // otherwise quick_range does it
(void) info->file->ha_index_or_rnd_end(); (void) info->table->file->ha_index_or_rnd_end();
info->table=0; info->table=0;
} }
} }
...@@ -352,7 +350,7 @@ static int rr_quick(READ_RECORD *info) ...@@ -352,7 +350,7 @@ static int rr_quick(READ_RECORD *info)
static int rr_index_first(READ_RECORD *info) static int rr_index_first(READ_RECORD *info)
{ {
int tmp= info->file->ha_index_first(info->record); int tmp= info->table->file->ha_index_first(info->record);
info->read_record= rr_index; info->read_record= rr_index;
if (tmp) if (tmp)
tmp= rr_handle_error(info, tmp); tmp= rr_handle_error(info, tmp);
...@@ -378,7 +376,7 @@ static int rr_index_first(READ_RECORD *info) ...@@ -378,7 +376,7 @@ static int rr_index_first(READ_RECORD *info)
static int rr_index(READ_RECORD *info) static int rr_index(READ_RECORD *info)
{ {
int tmp= info->file->ha_index_next(info->record); int tmp= info->table->file->ha_index_next(info->record);
if (tmp) if (tmp)
tmp= rr_handle_error(info, tmp); tmp= rr_handle_error(info, tmp);
return tmp; return tmp;
...@@ -388,7 +386,7 @@ static int rr_index(READ_RECORD *info) ...@@ -388,7 +386,7 @@ static int rr_index(READ_RECORD *info)
int rr_sequential(READ_RECORD *info) int rr_sequential(READ_RECORD *info)
{ {
int tmp; int tmp;
while ((tmp= info->file->ha_rnd_next(info->record))) while ((tmp= info->table->file->ha_rnd_next(info->record)))
{ {
/* /*
rnd_next can return RECORD_DELETED for MyISAM when one thread is rnd_next can return RECORD_DELETED for MyISAM when one thread is
...@@ -413,7 +411,7 @@ static int rr_from_tempfile(READ_RECORD *info) ...@@ -413,7 +411,7 @@ static int rr_from_tempfile(READ_RECORD *info)
{ {
if (my_b_read(info->io_cache,info->ref_pos,info->ref_length)) if (my_b_read(info->io_cache,info->ref_pos,info->ref_length))
return -1; /* End of file */ return -1; /* End of file */
if (!(tmp= info->file->ha_rnd_pos(info->record,info->ref_pos))) if (!(tmp= info->table->file->ha_rnd_pos(info->record,info->ref_pos)))
break; break;
/* The following is extremely unlikely to happen */ /* The following is extremely unlikely to happen */
if (tmp == HA_ERR_RECORD_DELETED || if (tmp == HA_ERR_RECORD_DELETED ||
...@@ -464,7 +462,7 @@ static int rr_from_pointers(READ_RECORD *info) ...@@ -464,7 +462,7 @@ static int rr_from_pointers(READ_RECORD *info)
cache_pos= info->cache_pos; cache_pos= info->cache_pos;
info->cache_pos+= info->ref_length; info->cache_pos+= info->ref_length;
if (!(tmp= info->file->ha_rnd_pos(info->record,cache_pos))) if (!(tmp= info->table->file->ha_rnd_pos(info->record,cache_pos)))
break; break;
/* The following is extremely unlikely to happen */ /* The following is extremely unlikely to happen */
...@@ -597,7 +595,7 @@ static int rr_from_cache(READ_RECORD *info) ...@@ -597,7 +595,7 @@ static int rr_from_cache(READ_RECORD *info)
record=uint3korr(position); record=uint3korr(position);
position+=3; position+=3;
record_pos=info->cache+record*info->reclength; record_pos=info->cache+record*info->reclength;
if ((error=(int16) info->file->ha_rnd_pos(record_pos,info->ref_pos))) if ((error=(int16) info->table->file->ha_rnd_pos(record_pos,info->ref_pos)))
{ {
record_pos[info->error_offset]=1; record_pos[info->error_offset]=1;
shortstore(record_pos,error); shortstore(record_pos,error);
......
...@@ -8675,7 +8675,7 @@ void set_join_cache_denial(JOIN_TAB *join_tab) ...@@ -8675,7 +8675,7 @@ void set_join_cache_denial(JOIN_TAB *join_tab)
void rr_unlock_row(st_join_table *tab) void rr_unlock_row(st_join_table *tab)
{ {
READ_RECORD *info= &tab->read_record; READ_RECORD *info= &tab->read_record;
info->file->unlock_row(); info->table->file->unlock_row();
} }
...@@ -9349,7 +9349,6 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) ...@@ -9349,7 +9349,6 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
TABLE *table=tab->table; TABLE *table=tab->table;
uint jcl= tab->used_join_cache_level; uint jcl= tab->used_join_cache_level;
tab->read_record.table= table; tab->read_record.table= table;
tab->read_record.file=table->file;
tab->read_record.unlock_row= rr_unlock_row; tab->read_record.unlock_row= rr_unlock_row;
tab->sorted= sorted; tab->sorted= sorted;
sorted= 0; // only first must be sorted sorted= 0; // only first must be sorted
...@@ -15719,7 +15718,7 @@ int join_read_key2(THD *thd, JOIN_TAB *tab, TABLE *table, TABLE_REF *table_ref) ...@@ -15719,7 +15718,7 @@ int join_read_key2(THD *thd, JOIN_TAB *tab, TABLE *table, TABLE_REF *table_ref)
*/ */
if (tab && tab->ref.has_record && tab->ref.use_count == 0) if (tab && tab->ref.has_record && tab->ref.use_count == 0)
{ {
tab->read_record.file->unlock_row(); tab->read_record.table->file->unlock_row();
table_ref->has_record= FALSE; table_ref->has_record= FALSE;
} }
error=table->file->ha_index_read_map(table->record[0], error=table->file->ha_index_read_map(table->record[0],
...@@ -15905,7 +15904,7 @@ join_init_quick_read_record(JOIN_TAB *tab) ...@@ -15905,7 +15904,7 @@ join_init_quick_read_record(JOIN_TAB *tab)
int init_read_record_seq(JOIN_TAB *tab) int init_read_record_seq(JOIN_TAB *tab)
{ {
tab->read_record.read_record= rr_sequential; tab->read_record.read_record= rr_sequential;
if (tab->read_record.file->ha_rnd_init_with_error(1)) if (tab->read_record.table->file->ha_rnd_init_with_error(1))
return 1; return 1;
return (*tab->read_record.read_record)(&tab->read_record); return (*tab->read_record.read_record)(&tab->read_record);
} }
...@@ -15972,7 +15971,6 @@ join_read_first(JOIN_TAB *tab) ...@@ -15972,7 +15971,6 @@ join_read_first(JOIN_TAB *tab)
tab->table->status=0; tab->table->status=0;
tab->read_record.read_record=join_read_next; tab->read_record.read_record=join_read_next;
tab->read_record.table=table; tab->read_record.table=table;
tab->read_record.file=table->file;
tab->read_record.index=tab->index; tab->read_record.index=tab->index;
tab->read_record.record=table->record[0]; tab->read_record.record=table->record[0];
if (!table->file->inited) if (!table->file->inited)
...@@ -15993,7 +15991,7 @@ static int ...@@ -15993,7 +15991,7 @@ static int
join_read_next(READ_RECORD *info) join_read_next(READ_RECORD *info)
{ {
int error; int error;
if ((error= info->file->ha_index_next(info->record))) if ((error= info->table->file->ha_index_next(info->record)))
return report_error(info->table, error); return report_error(info->table, error);
return 0; return 0;
...@@ -16011,7 +16009,6 @@ join_read_last(JOIN_TAB *tab) ...@@ -16011,7 +16009,6 @@ join_read_last(JOIN_TAB *tab)
tab->table->status=0; tab->table->status=0;
tab->read_record.read_record=join_read_prev; tab->read_record.read_record=join_read_prev;
tab->read_record.table=table; tab->read_record.table=table;
tab->read_record.file=table->file;
tab->read_record.index=tab->index; tab->read_record.index=tab->index;
tab->read_record.record=table->record[0]; tab->read_record.record=table->record[0];
if (!table->file->inited) if (!table->file->inited)
...@@ -16029,7 +16026,7 @@ static int ...@@ -16029,7 +16026,7 @@ static int
join_read_prev(READ_RECORD *info) join_read_prev(READ_RECORD *info)
{ {
int error; int error;
if ((error= info->file->ha_index_prev(info->record))) if ((error= info->table->file->ha_index_prev(info->record)))
return report_error(info->table, error); return report_error(info->table, error);
return 0; return 0;
} }
...@@ -16063,7 +16060,7 @@ static int ...@@ -16063,7 +16060,7 @@ static int
join_ft_read_next(READ_RECORD *info) join_ft_read_next(READ_RECORD *info)
{ {
int error; int error;
if ((error= info->file->ha_ft_read(info->table->record[0]))) if ((error= info->table->file->ha_ft_read(info->table->record[0])))
return report_error(info->table, error); return report_error(info->table, error);
return 0; return 0;
} }
......
...@@ -6747,11 +6747,11 @@ bool get_schema_tables_result(JOIN *join, ...@@ -6747,11 +6747,11 @@ bool get_schema_tables_result(JOIN *join,
{ {
result= 1; result= 1;
join->error= 1; join->error= 1;
tab->read_record.file= table_list->table->file; tab->read_record.table->file= table_list->table->file;
table_list->schema_table_state= executed_place; table_list->schema_table_state= executed_place;
break; break;
} }
tab->read_record.file= table_list->table->file; tab->read_record.table->file= table_list->table->file;
table_list->schema_table_state= executed_place; table_list->schema_table_state= executed_place;
} }
} }
......
...@@ -149,7 +149,7 @@ struct READ_RECORD { /* Parameter to read_record */ ...@@ -149,7 +149,7 @@ struct READ_RECORD { /* Parameter to read_record */
typedef int (*Read_func)(READ_RECORD*); typedef int (*Read_func)(READ_RECORD*);
typedef void (*Unlock_row_func)(st_join_table *); typedef void (*Unlock_row_func)(st_join_table *);
struct st_table *table; /* Head-form */ struct st_table *table; /* Head-form */
handler *file; // handler *file_;
struct st_table **forms; /* head and ref forms */ struct st_table **forms; /* head and ref forms */
Read_func read_record; Read_func read_record;
......
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