diff options
-rw-r--r-- | sql/filesort.cc | 4 | ||||
-rw-r--r-- | sql/opt_subselect.cc | 4 | ||||
-rw-r--r-- | sql/records.cc | 3 | ||||
-rw-r--r-- | sql/sql_select.cc | 3 | ||||
-rw-r--r-- | sql/table.cc | 41 | ||||
-rw-r--r-- | strings/ctype-simple.c | 13 |
6 files changed, 41 insertions, 27 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index c12337ee9be..0fe5f899351 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -569,7 +569,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, { if ((error= select->quick->get_next())) break; - if (!error) + if (!error && sort_form->vfield) update_virtual_fields(thd, sort_form); file->position(sort_form->record[0]); DBUG_EXECUTE_IF("debug_filesort", dbug_print_record(sort_form, TRUE);); @@ -588,7 +588,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, else { error=file->ha_rnd_next(sort_form->record[0]); - if (!error) + if (!error && sort_form->vfield) update_virtual_fields(thd, sort_form); if (!flag) { diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 4559b76764e..beb049ab66f 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -4933,7 +4933,6 @@ bool setup_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list, bool JOIN::choose_subquery_plan(table_map join_tables) { - Join_plan_state save_qep; /* The original QEP of the subquery. */ enum_reopt_result reopt_result= REOPT_NONE; Item_in_subselect *in_subs; @@ -4952,12 +4951,15 @@ bool JOIN::choose_subquery_plan(table_map join_tables) } else return false; + /* A strategy must be chosen earlier. */ DBUG_ASSERT(in_subs->has_strategy()); DBUG_ASSERT(in_to_exists_where || in_to_exists_having); DBUG_ASSERT(!in_to_exists_where || in_to_exists_where->fixed); DBUG_ASSERT(!in_to_exists_having || in_to_exists_having->fixed); + Join_plan_state save_qep; /* The original QEP of the subquery. */ + /* Compute and compare the costs of materialization and in-exists if both strategies are possible and allowed by the user (checked during the prepare diff --git a/sql/records.cc b/sql/records.cc index 10817dd8e51..648f939cf73 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -332,7 +332,8 @@ static int rr_quick(READ_RECORD *info) break; } } - update_virtual_fields(info->thd, info->table); + if (info->table->vfield) + update_virtual_fields(info->thd, info->table); return tmp; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f05e8ad34b2..b7c0156f65b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -15524,7 +15524,8 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab, DBUG_RETURN(NESTED_LOOP_KILLED); /* purecov: inspected */ } - update_virtual_fields(join->thd, join_tab->table); + if (join_tab->table->vfield) + update_virtual_fields(join->thd, join_tab->table); if (select_cond) { diff --git a/sql/table.cc b/sql/table.cc index 9174168bd68..2d435b671e5 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2241,30 +2241,35 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, /* Process virtual columns, if any. */ - if (!(vfield_ptr = (Field **) alloc_root(&outparam->mem_root, - (uint) ((share->vfields+1)* - sizeof(Field*))))) - goto err; - - outparam->vfield= vfield_ptr; - - for (field_ptr= outparam->field; *field_ptr; field_ptr++) + if (!share->vfields) + outparam->vfield= NULL; + else { - if ((*field_ptr)->vcol_info) + if (!(vfield_ptr = (Field **) alloc_root(&outparam->mem_root, + (uint) ((share->vfields+1)* + sizeof(Field*))))) + goto err; + + outparam->vfield= vfield_ptr; + + for (field_ptr= outparam->field; *field_ptr; field_ptr++) { - if (unpack_vcol_info_from_frm(thd, - outparam, - *field_ptr, - &(*field_ptr)->vcol_info->expr_str, - &error_reported)) + if ((*field_ptr)->vcol_info) { - error= 4; // in case no error is reported - goto err; + if (unpack_vcol_info_from_frm(thd, + outparam, + *field_ptr, + &(*field_ptr)->vcol_info->expr_str, + &error_reported)) + { + error= 4; // in case no error is reported + goto err; + } + *(vfield_ptr++)= *field_ptr; } - *(vfield_ptr++)= *field_ptr; } + *vfield_ptr= 0; // End marker } - *vfield_ptr= 0; // End marker #ifdef WITH_PARTITION_STORAGE_ENGINE if (share->partition_info_len && outparam->file) diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index f962b4f77cf..93439fa4c8e 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -307,6 +307,7 @@ void my_hash_sort_simple(CHARSET_INFO *cs, { register const uchar *sort_order=cs->sort_order; const uchar *end= key + len; + ulong n1, n2; /* Remove end space. We have to do this to be able to compare @@ -314,13 +315,17 @@ void my_hash_sort_simple(CHARSET_INFO *cs, */ while (end > key && end[-1] == ' ') end--; - + + n1= *nr1; + n2= *nr2; for (; key < (uchar*) end ; key++) { - nr1[0]^=(ulong) ((((uint) nr1[0] & 63)+nr2[0]) * - ((uint) sort_order[(uint) *key])) + (nr1[0] << 8); - nr2[0]+=3; + n1^=(ulong) ((((uint) n1 & 63)+n2) * + ((uint) sort_order[(uint) *key])) + (n1 << 8); + n2+=3; } + *nr1= n1; + *nr2= n2; } |