Skip to content

Commit 94462aa

Browse files
committed
bugfix: remove broken insert t values () optimization
* wrong results for 5.7 and 10.1- vcols, and for indexed vcols * only helps in rare cases and only minimally
1 parent 56c1f8d commit 94462aa

File tree

7 files changed

+2
-21
lines changed

7 files changed

+2
-21
lines changed

sql/sql_base.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7762,7 +7762,6 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
77627762
List_iterator_fast<Item> f(fields),v(values);
77637763
Item *value, *fld;
77647764
Item_field *field;
7765-
TABLE *vcol_table= 0;
77667765
bool save_abort_on_warning= thd->abort_on_warning;
77677766
bool save_no_errors= thd->no_errors;
77687767
DBUG_ENTER("fill_record");
@@ -7788,8 +7787,6 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
77887787
table_arg->auto_increment_field_not_null= FALSE;
77897788
f.rewind();
77907789
}
7791-
else
7792-
vcol_table= thd->lex->unit.insert_table_with_stored_vcol;
77937790

77947791
while ((fld= f++))
77957792
{
@@ -7822,17 +7819,15 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
78227819
goto err;
78237820
}
78247821
rfield->set_explicit_default(value);
7825-
DBUG_ASSERT(vcol_table == 0 || vcol_table == table);
7826-
vcol_table= table;
78277822
}
78287823

78297824
if (!update && table_arg->default_field &&
78307825
table_arg->update_default_fields(0, ignore_errors))
78317826
goto err;
78327827
/* Update virtual fields */
78337828
thd->abort_on_warning= FALSE;
7834-
if (vcol_table && vcol_table->vfield &&
7835-
vcol_table->update_virtual_fields(VCOL_UPDATE_FOR_WRITE))
7829+
if (table_arg->vfield &&
7830+
table_arg->update_virtual_fields(VCOL_UPDATE_FOR_WRITE))
78367831
goto err;
78377832
thd->abort_on_warning= save_abort_on_warning;
78387833
thd->no_errors= save_no_errors;

sql/sql_insert.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,8 +1522,6 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
15221522

15231523
if (!table)
15241524
table= table_list->table;
1525-
if (table->s->has_virtual_stored_fields)
1526-
thd->lex->unit.insert_table_with_stored_vcol= table;
15271525

15281526
if (!select_insert)
15291527
{

sql/sql_lex.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2074,7 +2074,6 @@ void st_select_lex_unit::init_query()
20742074
item_list.empty();
20752075
describe= 0;
20762076
found_rows_for_union= 0;
2077-
insert_table_with_stored_vcol= 0;
20782077
derived= 0;
20792078
is_view= false;
20802079
with_clause= 0;

sql/sql_lex.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -682,13 +682,6 @@ class st_select_lex_unit: public st_select_lex_node {
682682
bool describe; /* union exec() called for EXPLAIN */
683683
Procedure *last_procedure; /* Pointer to procedure, if such exists */
684684

685-
/*
686-
Insert table with stored virtual columns.
687-
This is used only in those rare cases
688-
when the list of inserted values is empty.
689-
*/
690-
TABLE *insert_table_with_stored_vcol;
691-
692685
bool columns_are_renamed;
693686

694687
void init_query();

sql/sql_load.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
410410

411411
table->prepare_triggers_for_insert_stmt_or_event();
412412
table->mark_columns_needed_for_insert();
413-
if (table->s->has_virtual_stored_fields)
414-
thd->lex->unit.insert_table_with_stored_vcol= table;
415413

416414
uint tot_length=0;
417415
bool use_blobs= 0, use_vars= 0;

sql/table.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2231,7 +2231,6 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
22312231
DBUG_ASSERT(!reg_field->vcol_info);
22322232
reg_field->vcol_info= vcol_info;
22332233
share->virtual_fields++;
2234-
share->has_virtual_stored_fields=true; // For insert/load data
22352234
break;
22362235
case 2: // Default expression
22372236
vcol_info->stored_in_db= 1;

sql/table.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,6 @@ struct TABLE_SHARE
685685
bool table_creation_was_logged;
686686
bool non_determinstic_insert;
687687
bool vcols_need_refixing;
688-
bool has_virtual_stored_fields;
689688
bool check_set_initialized;
690689
bool has_update_default_function;
691690
ulong table_map_id; /* for row-based replication */

0 commit comments

Comments
 (0)