summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/records.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_table.cc6
-rw-r--r--sql/sql_update.cc6
-rw-r--r--sql/table.cc3
8 files changed, 29 insertions, 25 deletions
diff --git a/sql/records.cc b/sql/records.cc
index 648f939cf73..5c495a16562 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -401,7 +401,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/sql_base.cc b/sql/sql_base.cc
index 19fabd27d72..03d8a925fc2 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -4706,7 +4706,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
temporary mem_root for new .frm parsing.
TODO: variables for size
*/
- init_sql_alloc(&new_frm_mem, 8024, 8024);
+ init_sql_alloc(&new_frm_mem, 8024, 0);
thd->current_tablenr= 0;
restart:
@@ -8648,14 +8648,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 84e88196f20..24b1828b177 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -332,7 +332,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 4f1c63930d6..47d78abdb68 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -827,7 +827,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())
continue;
if (num_rows >= offset_limit_cnt)
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index a960c63e782..d49be2e446c 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -3344,23 +3344,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;
}
@@ -3874,7 +3877,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_table.cc b/sql/sql_table.cc
index 222f6e07bc2..1b9ec320f7e 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -8078,7 +8078,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);
thd->row_count++;
if (++thd->progress.counter >= time_to_report_progress)
{
@@ -8106,7 +8107,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 a921a87884e..cf03cc597c8 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -506,7 +506,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)
{
@@ -621,7 +622,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 2d435b671e5..7a337521040 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -5759,8 +5759,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 */