diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-10-10 21:30:40 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-10-10 21:30:40 +0300 |
commit | 09afd3da1a80e403b5375845770dde61832afa50 (patch) | |
tree | a157942b08fc3d6bf97e2af3ae6e1d2e2ecbfc3e /sql | |
parent | 0f7732d1d1d898f1a9051858932c18bcc9d6f2b4 (diff) | |
parent | 4cdb72f2372b27e1fbbc573812240c1e29128c8f (diff) | |
download | mariadb-git-09afd3da1a80e403b5375845770dde61832afa50.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_partition.h | 20 | ||||
-rw-r--r-- | sql/handler.cc | 6 | ||||
-rw-r--r-- | sql/handler.h | 18 | ||||
-rw-r--r-- | sql/log_event.cc | 2 | ||||
-rw-r--r-- | sql/sql_insert.cc | 9 | ||||
-rw-r--r-- | sql/sql_table.cc | 6 | ||||
-rw-r--r-- | sql/table.cc | 32 |
7 files changed, 69 insertions, 24 deletions
diff --git a/sql/ha_partition.h b/sql/ha_partition.h index de5b4f2a66f..6407a607fe7 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -92,6 +92,7 @@ public: bool auto_inc_initialized; mysql_mutex_t auto_inc_mutex; /**< protecting auto_inc val */ ulonglong next_auto_inc_val; /**< first non reserved value */ + ulonglong prev_auto_inc_val; /**< stored next_auto_inc_val */ /** Hash of partition names. Initialized in the first ha_partition::open() for the table_share. After that it is read-only, i.e. no locking required. @@ -103,6 +104,7 @@ public: Partition_share() : auto_inc_initialized(false), next_auto_inc_val(0), + prev_auto_inc_val(0), partition_name_hash_initialized(false), partition_names(NULL) { @@ -371,6 +373,24 @@ private: MY_BITMAP m_locked_partitions; /** Stores shared auto_increment etc. */ Partition_share *part_share; + /** Fix spurious -Werror=overloaded-virtual in GCC 9 */ + virtual void restore_auto_increment(ulonglong prev_insert_id) + { + handler::restore_auto_increment(prev_insert_id); + } + /** Store and restore next_auto_inc_val over duplicate key errors. */ + virtual void store_auto_increment() + { + DBUG_ASSERT(part_share); + part_share->prev_auto_inc_val= part_share->next_auto_inc_val; + handler::store_auto_increment(); + } + virtual void restore_auto_increment() + { + DBUG_ASSERT(part_share); + part_share->next_auto_inc_val= part_share->prev_auto_inc_val; + handler::restore_auto_increment(); + } /** Temporary storage for new partitions Handler_shares during ALTER */ List<Parts_share_refs> m_new_partitions_share_refs; /** Sorted array of partition ids in descending order of number of rows. */ diff --git a/sql/handler.cc b/sql/handler.cc index fe0af08c8cf..72b11098060 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -7512,13 +7512,15 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info, return false; } + if (!(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING)) { List_iterator_fast<Create_field> it(alter_info->create_list); while (Create_field *f= it++) { - if (f->change.length && f->flags & VERS_SYSTEM_FIELD) + if (f->flags & VERS_SYSTEM_FIELD) { - my_error(ER_VERS_ALTER_SYSTEM_FIELD, MYF(0), f->field_name.str); + my_error(ER_VERS_DUPLICATE_ROW_START_END, MYF(0), + f->flags & VERS_SYS_START_FLAG ? "START" : "END", f->field_name.str); return true; } } diff --git a/sql/handler.h b/sql/handler.h index 46de5e5f017..2d25568488b 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -3122,6 +3122,10 @@ private: */ Handler_share **ha_share; + /** Stores next_insert_id for handling duplicate key errors. */ + ulonglong m_prev_insert_id; + + public: handler(handlerton *ht_arg, TABLE_SHARE *share_arg) :table_share(share_arg), table(0), @@ -3146,7 +3150,7 @@ public: auto_inc_intervals_count(0), m_psi(NULL), set_top_table_fields(FALSE), top_table(0), top_table_field(0), top_table_fields(0), - m_lock_type(F_UNLCK), ha_share(NULL) + m_lock_type(F_UNLCK), ha_share(NULL), m_prev_insert_id(0) { DBUG_PRINT("info", ("handler created F_UNLCK %d F_RDLCK %d F_WRLCK %d", @@ -3809,7 +3813,7 @@ public: DBUG_PRINT("info",("auto_increment: next value %lu", (ulong)id)); next_insert_id= id; } - void restore_auto_increment(ulonglong prev_insert_id) + virtual void restore_auto_increment(ulonglong prev_insert_id) { /* Insertion of a row failed, re-use the lastly generated auto_increment @@ -3825,6 +3829,16 @@ public: insert_id_for_cur_row; } + /** Store and restore next_insert_id over duplicate key errors. */ + virtual void store_auto_increment() + { + m_prev_insert_id= next_insert_id; + } + virtual void restore_auto_increment() + { + restore_auto_increment(m_prev_insert_id); + } + virtual void update_create_info(HA_CREATE_INFO *create_info) {} int check_old_types(); virtual int assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt) diff --git a/sql/log_event.cc b/sql/log_event.cc index 53762e0d6c0..e31713468e0 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -13489,6 +13489,7 @@ Rows_log_event::write_row(rpl_group_info *rgi, { ulong sec_part; bitmap_set_bit(table->read_set, table->vers_start_field()->field_index); + table->file->column_bitmaps_signal(); // Check whether a row came from unversioned table and fix vers fields. if (table->vers_start_field()->get_timestamp(&sec_part) == 0 && sec_part == 0) table->vers_update_fields(); @@ -14049,6 +14050,7 @@ int Rows_log_event::find_row(rpl_group_info *rgi) table->vers_end_field()->set_max(); m_vers_from_plain= true; } + table->file->column_bitmaps_signal(); } DBUG_PRINT("info",("looking for the following record")); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index fe6c5fa8ec4..7528239ca7b 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1697,7 +1697,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) int error, trg_error= 0; char *key=0; MY_BITMAP *save_read_set, *save_write_set; - ulonglong prev_insert_id= table->file->next_insert_id; + table->file->store_auto_increment(); ulonglong insert_id_for_cur_row= 0; ulonglong prev_insert_id_for_cur_row= 0; DBUG_ENTER("write_record"); @@ -1848,7 +1848,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) if (res == VIEW_CHECK_ERROR) goto before_trg_err; - table->file->restore_auto_increment(prev_insert_id); + table->file->restore_auto_increment(); info->touched++; if (different_records) { @@ -1949,6 +1949,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) if (table->versioned(VERS_TRX_ID)) { bitmap_set_bit(table->write_set, table->vers_start_field()->field_index); + table->file->column_bitmaps_signal(); table->vers_start_field()->store(0, false); } if (unlikely(error= table->file->ha_update_row(table->record[1], @@ -2041,7 +2042,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) if (!(thd->variables.old_behavior & OLD_MODE_NO_DUP_KEY_WARNINGS_WITH_IGNORE)) table->file->print_error(error, MYF(ME_WARNING)); - table->file->restore_auto_increment(prev_insert_id); + table->file->restore_auto_increment(); goto ok_or_after_trg_err; } @@ -2064,7 +2065,7 @@ err: table->file->print_error(error,MYF(0)); before_trg_err: - table->file->restore_auto_increment(prev_insert_id); + table->file->restore_auto_increment(); if (key) my_safe_afree(key, table->s->max_unique_length); table->column_bitmaps_set(save_read_set, save_write_set); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 5c6875b00c0..bb6caef0ebb 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -8274,12 +8274,6 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, alter_ctx->datetime_field= def; alter_ctx->error_if_not_empty= TRUE; } - if (def->flags & VERS_SYSTEM_FIELD && - !(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING)) - { - my_error(ER_VERS_NOT_VERSIONED, MYF(0), table->s->table_name.str); - goto err; - } if (!def->after.str) new_create_list.push_back(def, thd->mem_root); else diff --git a/sql/table.cc b/sql/table.cc index 718d0dce072..663a65d321a 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -6931,15 +6931,16 @@ void TABLE::mark_columns_needed_for_delete() } } - if (need_signal) - file->column_bitmaps_signal(); - if (s->versioned) { bitmap_set_bit(read_set, s->vers.start_fieldno); bitmap_set_bit(read_set, s->vers.end_fieldno); bitmap_set_bit(write_set, s->vers.end_fieldno); + need_signal= true; } + + if (need_signal) + file->column_bitmaps_signal(); } @@ -6952,7 +6953,7 @@ void TABLE::mark_columns_needed_for_delete() updated columns to be read. If this is no the case, we do like in the delete case and mark - if neeed, either the primary key column or all columns to be read. + if needed, either the primary key column or all columns to be read. (see mark_columns_needed_for_delete() for details) If the engine has HA_REQUIRES_KEY_COLUMNS_FOR_DELETE, we will @@ -7010,14 +7011,18 @@ void TABLE::mark_columns_needed_for_update() need_signal= true; } } - /* - For System Versioning we have to read all columns since we will store - a copy of previous row with modified Sys_end column back to a table. - */ if (s->versioned) { - // We will copy old columns to a new row. - use_all_columns(); + /* + For System Versioning we have to read all columns since we store + a copy of previous row with modified row_end back to a table. + + Without write_set versioning.rpl,row is unstable until MDEV-16370 is + applied. + */ + bitmap_union(read_set, &s->all_set); + bitmap_union(write_set, &s->all_set); + need_signal= true; } if (check_constraints) { @@ -8457,7 +8462,10 @@ void TABLE::vers_update_fields() if (versioned(VERS_TIMESTAMP)) { if (!vers_write) + { + file->column_bitmaps_signal(); return; + } if (vers_start_field()->store_timestamp(in_use->query_start(), in_use->query_start_sec_part())) DBUG_ASSERT(0); @@ -8465,11 +8473,15 @@ void TABLE::vers_update_fields() else { if (!vers_write) + { + file->column_bitmaps_signal(); return; + } } vers_end_field()->set_max(); bitmap_set_bit(read_set, vers_end_field()->field_index); + file->column_bitmaps_signal(); } |