diff options
author | Monty <monty@mariadb.org> | 2017-01-05 01:07:03 +0200 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2017-01-11 09:19:45 +0200 |
commit | 135e144479c70d8e470e67fd95e4b17051127952 (patch) | |
tree | 1fbca0bf595cae0ee787192e2948c8690220844d /sql/filesort.cc | |
parent | de22cd3fe5caa1db8839701e45f379b3b5be7328 (diff) | |
download | mariadb-git-135e144479c70d8e470e67fd95e4b17051127952.tar.gz |
MDEV-11598 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed
Found and fixed 2 problems:
- Filesort addon fields didn't mark virtual columns properly
- multi-range-read calculated vcol bitmap but was not using it.
This caused wrong vcol field to be calculated on read, which caused the assert.
Diffstat (limited to 'sql/filesort.cc')
-rw-r--r-- | sql/filesort.cc | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index 2210dc569df..6046693cba1 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -716,7 +716,7 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, TABLE *sort_form; handler *file; MY_BITMAP *save_read_set, *save_write_set, *save_vcol_set; - + Item *sort_cond; DBUG_ENTER("find_all_keys"); DBUG_PRINT("info",("using: %s", (select ? select->quick ? "ranges" : "where": @@ -754,22 +754,22 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, /* Remember original bitmaps */ save_read_set= sort_form->read_set; save_write_set= sort_form->write_set; - save_vcol_set= sort_form->vcol_set; + save_vcol_set= sort_form->vcol_set; + /* Set up temporary column read map for columns used by sort */ bitmap_clear_all(&sort_form->tmp_set); - /* Temporary set for register_used_fields and register_field_in_read_map */ - sort_form->read_set= &sort_form->tmp_set; + sort_form->column_bitmaps_set(&sort_form->tmp_set, &sort_form->tmp_set, + &sort_form->tmp_set); register_used_fields(param); if (quick_select) - select->quick->add_used_key_part_to_set(sort_form->read_set); + select->quick->add_used_key_part_to_set(); - Item *sort_cond= !select ? - 0 : !select->pre_idx_push_select_cond ? - select->cond : select->pre_idx_push_select_cond; + sort_cond= (!select ? 0 : + (!select->pre_idx_push_select_cond ? + select->cond : select->pre_idx_push_select_cond)); if (sort_cond) sort_cond->walk(&Item::register_field_in_read_map, 1, sort_form); - sort_form->column_bitmaps_set(&sort_form->tmp_set, &sort_form->tmp_set, - &sort_form->tmp_set); + sort_form->file->column_bitmaps_signal(); if (quick_select) { @@ -1259,7 +1259,6 @@ static void register_used_fields(Sort_param *param) { reg1 SORT_FIELD *sort_field; TABLE *table=param->sort_form; - MY_BITMAP *bitmap= table->read_set; for (sort_field= param->local_sortorder ; sort_field != param->end ; @@ -1269,14 +1268,7 @@ static void register_used_fields(Sort_param *param) if ((field= sort_field->field)) { if (field->table == table) - { - if (field->vcol_info) - { - Item *vcol_item= field->vcol_info->expr; - vcol_item->walk(&Item::register_field_in_read_map, 1, 0); - } - bitmap_set_bit(bitmap, field->field_index); - } + field->register_field_in_read_map(); } else { // Item @@ -1289,7 +1281,7 @@ static void register_used_fields(Sort_param *param) SORT_ADDON_FIELD *addonf= param->addon_field; Field *field; for ( ; (field= addonf->field) ; addonf++) - bitmap_set_bit(bitmap, field->field_index); + field->register_field_in_read_map(); } else { |