Commit 7e882a60 authored by Monty's avatar Monty

Ensure that table->vcol_set is properly restored if used

Code in QUICK_RANGE_SELECT::init_ror_merged_scan() could theoretically
have caused crashes if this was ever called from an update or delete

This also found a bug in the vcol/range.result. file.
parent 08ff39dc
......@@ -4,6 +4,6 @@ create table t2 (a int, b int) engine=myisam;
insert into t2 values (1,2),(2,4);
select * from t1 inner join t2 on ( t2.b = t1.v or t2.a = t1.pk );
pk i v a b
1 1 0 1 2
2 2 0 2 4
1 1 2 1 2
2 2 4 2 4
drop table t1, t2;
......@@ -712,6 +712,7 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select,
handler *file;
MY_BITMAP *save_read_set, *save_write_set, *save_vcol_set;
Item *sort_cond;
ha_rows retval;
DBUG_ENTER("find_all_keys");
DBUG_PRINT("info",("using: %s",
(select ? select->quick ? "ranges" : "where":
......@@ -769,7 +770,7 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select,
if (quick_select)
{
if (select->quick->reset())
DBUG_RETURN(HA_POS_ERROR);
goto err;
}
DEBUG_SYNC(thd, "after_index_merge_phase1");
......@@ -806,7 +807,7 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select,
(void) file->extra(HA_EXTRA_NO_CACHE);
file->ha_rnd_end();
}
DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */
goto err; /* purecov: inspected */
}
bool write_record= false;
......@@ -854,7 +855,7 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select,
if (idx == param->max_keys_per_buffer)
{
if (write_keys(param, fs_info, idx, buffpek_pointers, tempfile))
DBUG_RETURN(HA_POS_ERROR);
goto err;
idx= 0;
indexpos++;
}
......@@ -880,12 +881,12 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select,
file->ha_rnd_end();
}
if (thd->is_error())
DBUG_RETURN(HA_POS_ERROR);
/* Signal we should use orignal column read and write maps */
sort_form->column_bitmaps_set(save_read_set, save_write_set, save_vcol_set);
if (thd->is_error())
DBUG_RETURN(HA_POS_ERROR);
DBUG_PRINT("test",("error: %d indexpos: %d",error,indexpos));
if (error != HA_ERR_END_OF_FILE)
{
......@@ -895,11 +896,15 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select,
if (indexpos && idx &&
write_keys(param, fs_info, idx, buffpek_pointers, tempfile))
DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */
const ha_rows retval=
my_b_inited(tempfile) ?
(ha_rows) (my_b_tell(tempfile)/param->rec_length) : idx;
retval= (my_b_inited(tempfile) ?
(ha_rows) (my_b_tell(tempfile)/param->rec_length) :
idx);
DBUG_PRINT("info", ("find_all_keys return %llu", (ulonglong) retval));
DBUG_RETURN(retval);
err:
sort_form->column_bitmaps_set(save_read_set, save_write_set, save_vcol_set);
DBUG_RETURN(HA_POS_ERROR);
} /* find_all_keys */
......
......@@ -1540,7 +1540,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler,
head->file= org_file;
/* Restore head->read_set (and write_set) to what they had before the call */
head->column_bitmaps_set(save_read_set, save_write_set);
head->column_bitmaps_set(save_read_set, save_write_set, save_vcol_set);
if (reset())
{
......@@ -11364,7 +11364,10 @@ int QUICK_RANGE_SELECT::reset()
buf_size/= 2;
}
if (!mrr_buf_desc)
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
{
error= HA_ERR_OUT_OF_MEM;
goto err;
}
/* Initialize the handler buffer. */
mrr_buf_desc->buffer= mrange_buff;
......
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