summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2012-03-24 18:21:22 +0100
committerunknown <knielsen@knielsen-hq.org>2012-03-24 18:21:22 +0100
commit335de5db1834d3aeac507f18fcd5143c22150500 (patch)
tree95ac83922a28c81982c9ad89fcaba6c040b5111b /sql
parentb34cfe9327f2dcedb6bebfacdc2e757b6285426d (diff)
parentf72e0e686b2f3688fe98685107a293de5012be03 (diff)
downloadmariadb-git-335de5db1834d3aeac507f18fcd5143c22150500.tar.gz
Merge mariadb 5.3->mariadb 5.5
Diffstat (limited to 'sql')
-rw-r--r--sql/filesort.cc72
-rw-r--r--sql/item.cc25
-rw-r--r--sql/opt_range.cc2
-rw-r--r--sql/opt_subselect.cc10
-rw-r--r--sql/records.cc2
-rw-r--r--sql/signal_handler.cc2
-rw-r--r--sql/sql_base.cc13
-rw-r--r--sql/sql_delete.cc3
-rw-r--r--sql/sql_handler.cc3
-rw-r--r--sql/sql_join_cache.cc18
-rw-r--r--sql/sql_select.cc25
-rw-r--r--sql/sql_select.h32
-rw-r--r--sql/sql_show.cc11
-rw-r--r--sql/sql_table.cc6
-rw-r--r--sql/sql_update.cc6
-rw-r--r--sql/table.cc3
-rw-r--r--sql/table.h1
17 files changed, 132 insertions, 102 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc
index b4a172a70c4..c9b79701ea4 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -44,12 +44,11 @@ if (my_b_write((file),(uchar*) (from),param->ref_length)) \
/* functions defined in this file */
-static char **make_char_array(char **old_pos, register uint fields,
- uint length, myf my_flag);
static uchar *read_buffpek_from_file(IO_CACHE *buffer_file, uint count,
uchar *buf);
static ha_rows find_all_keys(SORTPARAM *param,SQL_SELECT *select,
- uchar * *sort_keys, IO_CACHE *buffer_file,
+ uchar * *sort_keys, uchar *sort_keys_buf,
+ IO_CACHE *buffer_file,
IO_CACHE *tempfile,IO_CACHE *indexfile);
static int write_keys(SORTPARAM *param,uchar * *sort_keys,
uint count, IO_CACHE *buffer_file, IO_CACHE *tempfile);
@@ -217,20 +216,30 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
memavl= thd->variables.sortbuff_size;
min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
+ if (!table_sort.sort_keys)
{
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
- param.keys=(uint) min(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
- break;
- old_memavl=memavl;
- if ((memavl=memavl/4*3) < min_sort_memory && old_memavl > min_sort_memory)
- memavl= min_sort_memory;
+ while (memavl >= min_sort_memory)
+ {
+ ulong old_memavl;
+ ulong keys= memavl/(param.rec_length+sizeof(char*));
+ table_sort.keys= (uint) min(records+1, keys);
+
+ DBUG_EXECUTE_IF("make_sort_keys_alloc_fail",
+ DBUG_SET("+d,simulate_out_of_memory"););
+
+ if ((table_sort.sort_keys=
+ (uchar**) my_malloc(table_sort.keys*(param.rec_length+sizeof(char*)),
+ MYF(0))))
+ break;
+ old_memavl=memavl;
+ if ((memavl=memavl/4*3) < min_sort_memory &&
+ old_memavl > min_sort_memory)
+ memavl= min_sort_memory;
+ }
}
+
sort_keys= table_sort.sort_keys;
+ param.keys= table_sort.keys - 1; /* TODO: check why we do this " - 1" */
if (memavl < min_sort_memory)
{
my_error(ER_OUT_OF_SORTMEMORY,MYF(ME_ERROR+ME_WAITTANG));
@@ -240,10 +249,10 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
DISK_BUFFER_SIZE, MYF(ME_ERROR | MY_WME)))
goto err;
- param.keys--; /* TODO: check why we do this */
param.sort_form= table;
param.end=(param.local_sortorder=sortorder)+s_length;
- if ((records=find_all_keys(&param,select,sort_keys, &buffpek_pointers,
+ if ((records=find_all_keys(&param,select,sort_keys,
+ (uchar *)(sort_keys+param.keys), &buffpek_pointers,
&tempfile, selected_records_file)) ==
HA_POS_ERROR)
goto err;
@@ -381,29 +390,6 @@ void filesort_free_buffers(TABLE *table, bool full)
table->sort.addon_field= NULL;
}
-/** Make a array of string pointers. */
-
-static char **make_char_array(char **old_pos, register uint fields,
- uint length, myf my_flag)
-{
- register char **pos;
- char *char_pos;
- DBUG_ENTER("make_char_array");
-
- DBUG_EXECUTE_IF("make_char_array_fail",
- DBUG_SET("+d,simulate_out_of_memory"););
-
- if (old_pos ||
- (old_pos= (char**) my_malloc((uint) fields*(length+sizeof(char*)),
- my_flag)))
- {
- pos=old_pos; char_pos=((char*) (pos+fields)) -length;
- while (fields--) *(pos++) = (char_pos+= length);
- }
-
- DBUG_RETURN(old_pos);
-} /* make_char_array */
-
/** Read 'count' number of buffer pointers into memory. */
@@ -518,7 +504,7 @@ static void dbug_print_record(TABLE *table, bool print_rowid)
*/
static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
- uchar **sort_keys,
+ uchar **sort_keys, uchar *sort_keys_buf,
IO_CACHE *buffpek_pointers,
IO_CACHE *tempfile, IO_CACHE *indexfile)
{
@@ -531,6 +517,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
volatile killed_state *killed= &thd->killed;
handler *file;
MY_BITMAP *save_read_set, *save_write_set, *save_vcol_set;
+ uchar *next_sort_key= sort_keys_buf;
DBUG_ENTER("find_all_keys");
DBUG_PRINT("info",("using: %s",
(select ? select->quick ? "ranges" : "where":
@@ -672,9 +659,12 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
if (write_keys(param,sort_keys,idx,buffpek_pointers,tempfile))
DBUG_RETURN(HA_POS_ERROR);
idx=0;
+ next_sort_key= sort_keys_buf;
indexpos++;
}
- make_sortkey(param,sort_keys[idx++],ref_pos);
+ sort_keys[idx++]= next_sort_key;
+ make_sortkey(param, next_sort_key, ref_pos);
+ next_sort_key+= param->rec_length;
}
else
file->unlock_row();
diff --git a/sql/item.cc b/sql/item.cc
index c4bb1a399ab..d5d5aeba970 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -2606,17 +2606,20 @@ void Item_field::fix_after_pullout(st_select_lex *new_parent, Item **ref)
{
if (new_parent == get_depended_from())
depended_from= NULL;
- Name_resolution_context *ctx= new Name_resolution_context();
- ctx->outer_context= NULL; // We don't build a complete name resolver
- ctx->table_list= NULL; // We rely on first_name_resolution_table instead
- ctx->select_lex= new_parent;
- ctx->first_name_resolution_table= context->first_name_resolution_table;
- ctx->last_name_resolution_table= context->last_name_resolution_table;
- ctx->error_processor= context->error_processor;
- ctx->error_processor_data= context->error_processor_data;
- ctx->resolve_in_select_list= context->resolve_in_select_list;
- ctx->security_ctx= context->security_ctx;
- this->context=ctx;
+ if (context)
+ {
+ Name_resolution_context *ctx= new Name_resolution_context();
+ ctx->outer_context= NULL; // We don't build a complete name resolver
+ ctx->table_list= NULL; // We rely on first_name_resolution_table instead
+ ctx->select_lex= new_parent;
+ ctx->first_name_resolution_table= context->first_name_resolution_table;
+ ctx->last_name_resolution_table= context->last_name_resolution_table;
+ ctx->error_processor= context->error_processor;
+ ctx->error_processor_data= context->error_processor_data;
+ ctx->resolve_in_select_list= context->resolve_in_select_list;
+ ctx->security_ctx= context->security_ctx;
+ this->context=ctx;
+ }
}
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 2e8b00982fc..c6ee117213d 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1396,7 +1396,7 @@ SEL_IMERGE::SEL_IMERGE(SEL_IMERGE *arg, uint cnt,
for (SEL_TREE **tree = trees, **arg_tree= arg->trees; tree < trees_next;
tree++, arg_tree++)
{
- if (!(*tree= new SEL_TREE(*arg_tree, FALSE, param)))
+ if (!(*tree= new SEL_TREE(*arg_tree, TRUE, param)))
goto mem_err;
}
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 1f6524e5afa..8656ca605ab 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -1267,7 +1267,10 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
(a theory: a next_local chain always starts with ::leaf_tables
because view's tables are inserted after the view)
*/
- for (tl= parent_lex->leaf_tables.head(); tl->next_local; tl= tl->next_local) ;
+
+ for (tl= (TABLE_LIST*)(parent_lex->table_list.first); tl->next_local; tl= tl->next_local)
+ {}
+
tl->next_local= subq_lex->leaf_tables.head();
/* A theory: no need to re-connect the next_global chain */
@@ -1480,7 +1483,7 @@ static bool convert_subq_to_jtbm(JOIN *parent_join,
(a theory: a next_local chain always starts with ::leaf_tables
because view's tables are inserted after the view)
*/
- for (tl= parent_lex->leaf_tables.head(); tl->next_local; tl= tl->next_local)
+ for (tl= (TABLE_LIST*)(parent_lex->table_list.first); tl->next_local; tl= tl->next_local)
{}
tl->next_local= jtbm;
@@ -4975,7 +4978,8 @@ bool JOIN::choose_subquery_plan(table_map join_tables)
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. */
+ /* The original QEP of the subquery. */
+ Join_plan_state save_qep(table_count);
/*
Compute and compare the costs of materialization and in-exists if both
diff --git a/sql/records.cc b/sql/records.cc
index 36bf184b350..d52481c36f5 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -461,7 +461,7 @@ int rr_sequential(READ_RECORD *info)
break;
}
}
- if (!tmp)
+ if (!tmp && info->table->vfield)
update_virtual_fields(info->thd, info->table);
return tmp;
}
diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc
index 0b5fce7758f..61b67c9d229 100644
--- a/sql/signal_handler.cc
+++ b/sql/signal_handler.cc
@@ -77,7 +77,7 @@ extern "C" sig_handler handle_fatal_signal(int sig)
curr_time= my_time(0);
localtime_r(&curr_time, &tm);
- fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d ",
+ my_safe_printf_stderr("%02d%02d%02d %2d:%02d:%02d ",
tm.tm_year % 100, tm.tm_mon+1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);
if (opt_expect_abort
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 9298d3ccb72..b5ede32e6fe 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -520,7 +520,7 @@ static void table_def_use_table(THD *thd, TABLE *table)
static void table_def_unuse_table(TABLE *table)
{
- THD *thd= table->in_use;
+ THD *thd __attribute__((unused))= table->in_use;
DBUG_ASSERT(table->in_use);
/* We shouldn't put the table to 'unused' list if the share is old. */
@@ -8803,14 +8803,9 @@ fill_record(THD * thd, List<Item> &fields, List<Item> &values,
}
/* Update virtual fields*/
thd->abort_on_warning= FALSE;
- if (vcol_table)
- {
- if (vcol_table->vfield)
- {
- if (update_virtual_fields(thd, vcol_table, TRUE))
- goto err;
- }
- }
+ if (vcol_table && vcol_table->vfield &&
+ update_virtual_fields(thd, vcol_table, TRUE))
+ goto err;
thd->abort_on_warning= save_abort_on_warning;
thd->no_errors= save_no_errors;
DBUG_RETURN(thd->is_error());
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index ff88bf7c0f8..cc358eca440 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -327,7 +327,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
while (!(error=info.read_record(&info)) && !thd->killed &&
! thd->is_error())
{
- update_virtual_fields(thd, table);
+ if (table->vfield)
+ update_virtual_fields(thd, table);
thd->examined_row_count++;
// thd->is_error() is tested to disallow delete row on error
if (!select || select->skip_record(thd) > 0)
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index c67618f0680..d03b38171fc 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -922,7 +922,8 @@ retry:
goto ok;
}
/* Generate values for virtual fields */
- update_virtual_fields(thd, table);
+ if (table->vfield)
+ update_virtual_fields(thd, table);
if (cond && !cond->val_int())
{
if (thd->is_error())
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index e0e1b175116..f953cf4df57 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -3345,23 +3345,26 @@ int JOIN_TAB_SCAN::next()
int skip_rc;
READ_RECORD *info= &join_tab->read_record;
SQL_SELECT *select= join_tab->cache_select;
+ TABLE *table= join_tab->table;
+ THD *thd= join->thd;
+
if (is_first_record)
is_first_record= FALSE;
else
err= info->read_record(info);
- if (!err)
- update_virtual_fields(join->thd, join_tab->table);
- while (!err && select && (skip_rc= select->skip_record(join->thd)) <= 0)
+ if (!err && table->vfield)
+ update_virtual_fields(thd, table);
+ while (!err && select && (skip_rc= select->skip_record(thd)) <= 0)
{
- if (join->thd->killed || skip_rc < 0)
+ if (thd->killed || skip_rc < 0)
return 1;
/*
Move to the next record if the last retrieved record does not
meet the condition pushed to the table join_tab.
*/
err= info->read_record(info);
- if (!err)
- update_virtual_fields(join->thd, join_tab->table);
+ if (!err && table->vfield)
+ update_virtual_fields(thd, table);
}
return err;
}
@@ -3875,7 +3878,8 @@ int JOIN_TAB_SCAN_MRR::next()
*/
DBUG_ASSERT(cache->buff <= (uchar *) (*ptr) &&
(uchar *) (*ptr) <= cache->end_pos);
- update_virtual_fields(join->thd, join_tab->table);
+ if (join_tab->table->vfield)
+ update_virtual_fields(join->thd, join_tab->table);
}
return rc;
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 8688932a81e..a26f4b47340 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -3085,12 +3085,11 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
key_map const_ref, eq_part;
bool has_expensive_keyparts;
TABLE **table_vector;
- JOIN_TAB *stat,*stat_end,*s,**stat_ref;
+ JOIN_TAB *stat,*stat_end,*s,**stat_ref, **stat_vector;
KEYUSE *keyuse,*start_keyuse;
table_map outer_join=0;
table_map no_rows_const_tables= 0;
SARGABLE_PARAM *sargables= 0;
- JOIN_TAB *stat_vector[MAX_TABLES+1];
List_iterator<TABLE_LIST> ti(tables_list);
TABLE_LIST *tables;
DBUG_ENTER("make_join_statistics");
@@ -3099,9 +3098,19 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
table_count=join->table_count;
stat=(JOIN_TAB*) join->thd->calloc(sizeof(JOIN_TAB)*(table_count));
- stat_ref=(JOIN_TAB**) join->thd->alloc(sizeof(JOIN_TAB*)*MAX_TABLES);
+ stat_ref=(JOIN_TAB**) join->thd->alloc(sizeof(JOIN_TAB*)*
+ (MAX_TABLES + table_count + 1));
+ stat_vector= stat_ref + MAX_TABLES;
table_vector=(TABLE**) join->thd->alloc(sizeof(TABLE*)*(table_count*2));
- if (!stat || !stat_ref || !table_vector)
+ join->positions= new (join->thd->mem_root) POSITION[(table_count+1)];
+ /*
+ best_positions is ok to allocate with alloc() as we copy things to it with
+ memcpy()
+ */
+ join->best_positions= (POSITION*) join->thd->alloc(sizeof(POSITION)*
+ (table_count +1));
+
+ if (join->thd->is_fatal_error)
DBUG_RETURN(1); // Eom /* purecov: inspected */
join->best_ref=stat_vector;
@@ -7634,7 +7643,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j,
if (keyuse->null_rejecting)
j->ref.null_rejecting |= 1 << i;
keyuse_uses_no_tables= keyuse_uses_no_tables && !keyuse->used_tables;
- if (!keyuse->used_tables && !thd->lex->describe)
+ if (!keyuse->val->used_tables() && !thd->lex->describe)
{ // Compare against constant
store_key_item tmp(thd,
keyinfo->key_part[i].field,
@@ -16257,7 +16266,8 @@ join_read_system(JOIN_TAB *tab)
empty_record(table); // Make empty record
return -1;
}
- update_virtual_fields(tab->join->thd, table);
+ if (table->vfield)
+ update_virtual_fields(tab->join->thd, table);
store_record(table,record[1]);
}
else if (!table->status) // Only happens with left join
@@ -16306,7 +16316,8 @@ join_read_const(JOIN_TAB *tab)
return report_error(table, error);
return -1;
}
- update_virtual_fields(tab->join->thd, table);
+ if (table->vfield)
+ update_virtual_fields(tab->join->thd, table);
store_record(table,record[1]);
}
else if (!(table->status & ~STATUS_NULL_ROW)) // Only happens with left join
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 2f7d31de404..53f2356853e 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -742,7 +742,7 @@ public:
Information about a position of table within a join order. Used in join
optimization.
*/
-typedef struct st_position
+typedef struct st_position :public Sql_alloc
{
/* The table that's put into join order */
JOIN_TAB *table;
@@ -844,23 +844,36 @@ protected:
*/
class Join_plan_state {
public:
- DYNAMIC_ARRAY keyuse; /* Copy of the JOIN::keyuse array. */
- POSITION best_positions[MAX_TABLES+1]; /* Copy of JOIN::best_positions */
+ DYNAMIC_ARRAY keyuse; /* Copy of the JOIN::keyuse array. */
+ POSITION *best_positions; /* Copy of JOIN::best_positions */
/* Copies of the JOIN_TAB::keyuse pointers for each JOIN_TAB. */
- KEYUSE *join_tab_keyuse[MAX_TABLES];
+ KEYUSE **join_tab_keyuse;
/* Copies of JOIN_TAB::checked_keys for each JOIN_TAB. */
- key_map join_tab_checked_keys[MAX_TABLES];
- SJ_MATERIALIZATION_INFO *sj_mat_info[MAX_TABLES];
+ key_map *join_tab_checked_keys;
+ SJ_MATERIALIZATION_INFO **sj_mat_info;
+ my_bool error;
public:
- Join_plan_state()
+ Join_plan_state(uint tables) : error(0)
{
keyuse.elements= 0;
keyuse.buffer= NULL;
+ best_positions= 0; /* To detect errors */
+ error= my_multi_malloc(MYF(MY_WME),
+ &best_positions,
+ sizeof(*best_positions) * (tables + 1),
+ &join_tab_keyuse,
+ sizeof(*join_tab_keyuse) * tables,
+ &join_tab_checked_keys,
+ sizeof(*join_tab_checked_keys) * tables,
+ &sj_mat_info,
+ sizeof(sj_mat_info) * tables,
+ NullS) == 0;
}
Join_plan_state(JOIN *join);
~Join_plan_state()
{
delete_dynamic(&keyuse);
+ my_free(best_positions);
}
};
@@ -958,7 +971,7 @@ public:
*/
ha_rows fetch_limit;
/* Finally picked QEP. This is result of join optimization */
- POSITION best_positions[MAX_TABLES+1];
+ POSITION *best_positions;
/******* Join optimization state members start *******/
/*
@@ -968,7 +981,7 @@ public:
TABLE_LIST *emb_sjm_nest;
/* Current join optimization state */
- POSITION positions[MAX_TABLES+1];
+ POSITION *positions;
/*
Bitmap of nested joins embedding the position at the end of the current
@@ -1238,6 +1251,7 @@ public:
exec_const_cond= 0;
group_optimized_away= 0;
no_rows_in_result_called= 0;
+ positions= best_positions= 0;
all_fields= fields_arg;
if (&fields_list != &fields_arg) /* Avoid valgrind-warning */
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index d64c7a6df52..38139bdec0c 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -3628,16 +3628,17 @@ end:
@retval 1 error
*/
-static int fill_schema_table_names(THD *thd, TABLE *table,
+static int fill_schema_table_names(THD *thd, TABLE_LIST *tables,
LEX_STRING *db_name, LEX_STRING *table_name,
bool with_i_schema)
{
+ TABLE *table= tables->table;
if (with_i_schema)
{
table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"),
system_charset_info);
}
- else
+ else if (tables->table_open_method != SKIP_OPEN_TABLE)
{
enum legacy_db_type not_used;
char path[FN_REFLEN + 1];
@@ -4199,7 +4200,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
/* SHOW TABLE NAMES command */
if (schema_table_idx == SCH_TABLE_NAMES)
{
- if (fill_schema_table_names(thd, tables->table, db_name,
+ if (fill_schema_table_names(thd, tables, db_name,
table_name, with_i_schema))
continue;
}
@@ -7498,6 +7499,8 @@ bool get_schema_tables_result(JOIN *join,
join->error= 1;
tab->read_record.table->file= table_list->table->file;
table_list->schema_table_state= executed_place;
+ if (!thd->is_error())
+ my_error(ER_UNKNOWN_ERROR, MYF(0));
break;
}
tab->read_record.table->file= table_list->table->file;
@@ -8385,7 +8388,7 @@ ST_SCHEMA_TABLE schema_tables[]=
get_all_tables, 0, get_schema_constraints_record, 3, 4, 0,
OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY},
{"TABLE_NAMES", table_names_fields_info, create_schema_table,
- get_all_tables, make_table_names_old_format, 0, 1, 2, 1, 0},
+ get_all_tables, make_table_names_old_format, 0, 1, 2, 1, OPTIMIZE_I_S_TABLE},
{"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
fill_schema_table_privileges, 0, 0, -1, -1, 0, 0},
{"TABLE_STATISTICS", table_stats_fields_info, create_schema_table,
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 01832036701..cf0e0e4c0ef 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -7274,7 +7274,8 @@ copy_data_between_tables(THD *thd, TABLE *from,TABLE *to,
error= 1;
break;
}
- update_virtual_fields(thd, from);
+ if (from->vfield)
+ update_virtual_fields(thd, from);
if (++thd->progress.counter >= time_to_report_progress)
{
time_to_report_progress+= MY_HOW_OFTEN_TO_WRITE/10;
@@ -7301,7 +7302,8 @@ copy_data_between_tables(THD *thd, TABLE *from,TABLE *to,
copy_ptr->do_copy(copy_ptr);
}
prev_insert_id= to->file->next_insert_id;
- update_virtual_fields(thd, to, TRUE);
+ if (to->vfield)
+ update_virtual_fields(thd, to, TRUE);
if (thd->is_error())
{
error= 1;
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 5fa30c91417..f9502589beb 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -559,7 +559,8 @@ int mysql_update(THD *thd,
while (!(error=info.read_record(&info)) && !thd->killed)
{
- update_virtual_fields(thd, table);
+ if (table->vfield)
+ update_virtual_fields(thd, table);
thd->examined_row_count++;
if (!select || (error= select->skip_record(thd)) > 0)
{
@@ -674,7 +675,8 @@ int mysql_update(THD *thd,
while (!(error=info.read_record(&info)) && !thd->killed)
{
- update_virtual_fields(thd, table);
+ if (table->vfield)
+ update_virtual_fields(thd, table);
thd->examined_row_count++;
if (!select || select->skip_record(thd) > 0)
{
diff --git a/sql/table.cc b/sql/table.cc
index c2d80cc651a..57e1930016e 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -6367,8 +6367,7 @@ int update_virtual_fields(THD *thd, TABLE *table, bool for_write)
DBUG_ENTER("update_virtual_fields");
Field **vfield_ptr, *vfield;
int error __attribute__ ((unused))= 0;
- if (!table || !table->vfield)
- DBUG_RETURN(0);
+ DBUG_ASSERT(table && table->vfield);
thd->reset_arena_for_cached_items(table->expr_arena);
/* Iterate over virtual fields in the table */
diff --git a/sql/table.h b/sql/table.h
index d2337022724..13b0274b3aa 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -303,6 +303,7 @@ typedef struct st_filesort_info
{
IO_CACHE *io_cache; /* If sorted through filesort */
uchar **sort_keys; /* Buffer for sorting keys */
+ uint keys; /* Number of key pointers in buffer */
uchar *buffpek; /* Buffer for buffpek structures */
uint buffpek_len; /* Max number of buffpeks in the buffer */
uchar *addon_buf; /* Pointer to a buffer if sorted with fields */