diff options
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 85 |
1 files changed, 72 insertions, 13 deletions
diff --git a/sql/table.cc b/sql/table.cc index 1a4875bde81..6d207bc847b 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2652,11 +2652,9 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, { auto field_type= handler->real_field_type(); - if (DBUG_EVALUATE_IF("error_vers_wrong_type", 1, 0)) - field_type= MYSQL_TYPE_BLOB; + DBUG_EXECUTE_IF("error_vers_wrong_type", field_type= MYSQL_TYPE_BLOB;); - switch (field_type) - { + switch (field_type) { case MYSQL_TYPE_TIMESTAMP2: break; case MYSQL_TYPE_LONGLONG: @@ -3340,7 +3338,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, share->column_bitmap_size * bitmap_count))) goto err; - my_bitmap_init(&share->all_set, bitmaps, share->fields, FALSE); + my_bitmap_init(&share->all_set, bitmaps, share->fields); bitmap_set_all(&share->all_set); if (share->check_set) { @@ -3351,7 +3349,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, my_bitmap_init(share->check_set, (my_bitmap_map*) ((uchar*) bitmaps + share->column_bitmap_size), - share->fields, FALSE); + share->fields); bitmap_clear_all(share->check_set); } @@ -4314,6 +4312,8 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share, thd->restore_active_arena(&part_func_arena, &backup_arena); goto partititon_err; } + if (parse_engine_part_options(thd, outparam)) + goto err; outparam->part_info->is_auto_partitioned= share->auto_partitioned; DBUG_PRINT("info", ("autopartitioned: %u", share->auto_partitioned)); /* @@ -4370,26 +4370,26 @@ partititon_err: goto err; my_bitmap_init(&outparam->def_read_set, - (my_bitmap_map*) bitmaps, share->fields, FALSE); + (my_bitmap_map*) bitmaps, share->fields); bitmaps+= bitmap_size; my_bitmap_init(&outparam->def_write_set, - (my_bitmap_map*) bitmaps, share->fields, FALSE); + (my_bitmap_map*) bitmaps, share->fields); bitmaps+= bitmap_size; my_bitmap_init(&outparam->has_value_set, - (my_bitmap_map*) bitmaps, share->fields, FALSE); + (my_bitmap_map*) bitmaps, share->fields); bitmaps+= bitmap_size; my_bitmap_init(&outparam->tmp_set, - (my_bitmap_map*) bitmaps, share->fields, FALSE); + (my_bitmap_map*) bitmaps, share->fields); bitmaps+= bitmap_size; my_bitmap_init(&outparam->eq_join_set, - (my_bitmap_map*) bitmaps, share->fields, FALSE); + (my_bitmap_map*) bitmaps, share->fields); bitmaps+= bitmap_size; my_bitmap_init(&outparam->cond_set, - (my_bitmap_map*) bitmaps, share->fields, FALSE); + (my_bitmap_map*) bitmaps, share->fields); bitmaps+= bitmap_size; my_bitmap_init(&outparam->def_rpl_write_set, - (my_bitmap_map*) bitmaps, share->fields, FALSE); + (my_bitmap_map*) bitmaps, share->fields); outparam->default_column_bitmaps(); outparam->cond_selectivity= 1.0; @@ -9269,6 +9269,62 @@ bool TABLE::validate_default_values_of_unset_fields(THD *thd) const } +/* + Check assignment compatibility of a value list against an explicitly + specified field list, e.g. + INSERT INTO t1 (a,b) VALUES (1,2); +*/ +bool TABLE::check_assignability_explicit_fields(List<Item> fields, + List<Item> values, + bool ignore) +{ + DBUG_ENTER("TABLE::check_assignability_explicit_fields"); + DBUG_ASSERT(fields.elements == values.elements); + + List_iterator<Item> fi(fields); + List_iterator<Item> vi(values); + Item *f, *value; + while ((f= fi++) && (value= vi++)) + { + Item_field *item_field= f->field_for_view_update(); + if (!item_field) + { + /* + A non-updatable field of a view found. + This scenario is caught later and an error is raised. + We could eventually move error reporting here. For now just continue. + */ + continue; + } + if (value->check_assignability_to(item_field->field, ignore)) + DBUG_RETURN(true); + } + DBUG_RETURN(false); +} + + +/* + Check assignment compatibility for a value list against + all visible fields of the table, e.g. + INSERT INTO t1 VALUES (1,2); +*/ +bool TABLE::check_assignability_all_visible_fields(List<Item> &values, + bool ignore) const +{ + DBUG_ENTER("TABLE::check_assignability_all_visible_fields"); + DBUG_ASSERT(s->visible_fields == values.elements); + + List_iterator<Item> vi(values); + for (uint i= 0; i < s->fields; i++) + { + if (!field[i]->invisible && + (vi++)->check_assignability_to(field[i], ignore)) + DBUG_RETURN(true); + } + DBUG_RETURN(false); +} + + bool TABLE::insert_all_rows_into_tmp_table(THD *thd, TABLE *tmp_table, TMP_TABLE_PARAM *tmp_table_param, @@ -9953,6 +10009,9 @@ bool TR_table::update(ulonglong start_id, ulonglong end_id) int error= table->file->ha_write_row(table->record[0]); if (unlikely(error)) table->file->print_error(error, MYF(0)); + /* extra() is used to apply the bulk insert operation + on mysql/transaction_registry table */ + table->file->extra(HA_EXTRA_IGNORE_INSERT); return error; } |