diff options
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/sql/table.cc b/sql/table.cc index b85d23b2..88b65fe0 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -49,6 +49,7 @@ #ifdef WITH_WSREP #include "wsrep_schema.h" #endif +#include "log_event.h" // MAX_TABLE_MAP_ID /* For MySQL 5.7 virtual fields */ #define MYSQL57_GENERATED_FIELD 128 @@ -108,7 +109,7 @@ LEX_CSTRING MYSQL_PROC_NAME= {STRING_WITH_LEN("proc")}; */ static LEX_CSTRING parse_vcol_keyword= { STRING_WITH_LEN("PARSE_VCOL_EXPR ") }; -static std::atomic<ulong> last_table_id; +static std::atomic<ulonglong> last_table_id; /* Functions defined in this file */ @@ -384,17 +385,20 @@ TABLE_SHARE *alloc_table_share(const char *db, const char *table_name, DBUG_EXECUTE_IF("simulate_big_table_id", if (last_table_id < UINT_MAX32) - last_table_id= UINT_MAX32 - 1;); + last_table_id= UINT_MAX32-1;); /* - There is one reserved number that cannot be used. Remember to - change this when 6-byte global table id's are introduced. + Replication is using 6 bytes as table_map_id. Ensure that + the 6 lowest bytes are not 0. + We also have to ensure that we do not use the special value + UINT_MAX32 as this is used to mark a dummy event row event. See + comments in Rows_log_event::Rows_log_event(). */ do { share->table_map_id= last_table_id.fetch_add(1, std::memory_order_relaxed); - } while (unlikely(share->table_map_id == ~0UL || - share->table_map_id == 0)); + } while (unlikely((share->table_map_id & MAX_TABLE_MAP_ID) == 0) || + unlikely((share->table_map_id & MAX_TABLE_MAP_ID) == UINT_MAX32)); } DBUG_RETURN(share); } @@ -457,7 +461,7 @@ void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key, table_map_id is also used for MERGE tables to suppress repeated compatibility checks. */ - share->table_map_id= (ulong) thd->query_id; + share->table_map_id= (ulonglong) thd->query_id; DBUG_VOID_RETURN; } @@ -1286,12 +1290,11 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table, if (keypart->key_part_flag & HA_PART_KEY_SEG) { int length= keypart->length/keypart->field->charset()->mbmaxlen; + Field *kpf= table->field[keypart->field->field_index]; list_item= new (mem_root) Item_func_left(thd, - new (mem_root) Item_field(thd, keypart->field), + new (mem_root) Item_field(thd, kpf), new (mem_root) Item_int(thd, length)); list_item->fix_fields(thd, NULL); - keypart->field->vcol_info= - table->field[keypart->field->field_index]->vcol_info; } else list_item= new (mem_root) Item_field(thd, keypart->field); @@ -5958,7 +5961,7 @@ allocate: /* Create view fields translation table */ if (!(transl= - (Field_translator*)(thd->stmt_arena-> + (Field_translator*)(thd-> alloc(select->item_list.elements * sizeof(Field_translator))))) { @@ -7585,7 +7588,7 @@ inline void TABLE::mark_index_columns_for_read(uint index) always set and sometimes read. */ -void TABLE::mark_auto_increment_column() +void TABLE::mark_auto_increment_column(bool is_insert) { DBUG_ASSERT(found_next_number_field); /* @@ -7593,7 +7596,8 @@ void TABLE::mark_auto_increment_column() store() to check overflow of auto_increment values */ bitmap_set_bit(read_set, found_next_number_field->field_index); - bitmap_set_bit(write_set, found_next_number_field->field_index); + if (is_insert) + bitmap_set_bit(write_set, found_next_number_field->field_index); if (s->next_number_keypart) mark_index_columns_for_read(s->next_number_index); file->column_bitmaps_signal(); @@ -7718,7 +7722,7 @@ void TABLE::mark_columns_needed_for_update() else { if (found_next_number_field) - mark_auto_increment_column(); + mark_auto_increment_column(false); } if (file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) @@ -7794,7 +7798,7 @@ void TABLE::mark_columns_needed_for_insert() triggers->mark_fields_used(TRG_EVENT_INSERT); } if (found_next_number_field) - mark_auto_increment_column(); + mark_auto_increment_column(true); if (default_field) mark_default_fields_for_write(TRUE); if (s->versioned) @@ -10467,6 +10471,12 @@ bool Vers_history_point::check_unit(THD *thd) { if (!item) return false; + if (item->real_type() == Item::FIELD_ITEM) + { + my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0), + item->full_name(), "FOR SYSTEM_TIME"); + return true; + } if (item->fix_fields_if_needed(thd, &item)) return true; const Type_handler *t= item->this_item()->real_type_handler(); |