diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2018-12-20 09:52:34 +0100 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2019-04-25 18:02:31 +0200 |
commit | 4e01bc8c963d9513625dd984cd1aca24b8a7b516 (patch) | |
tree | 9814be2b0ce45c9833328b63cf403d76d1e24c50 /sql/sql_insert.cc | |
parent | 3dffdee667666df9ade9f2c458bf1ea495ffba02 (diff) | |
download | mariadb-git-4e01bc8c963d9513625dd984cd1aca24b8a7b516.tar.gz |
MDEV-16240: Assertion `0' failed in row_sel_convert_mysql_key_to_innobasebb-10.2-MDEV-16240
Set table in row ID position mode before using this function.
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index c623336fdba..4005153cb64 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -881,7 +881,12 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, #endif /* EMBEDDED_LIBRARY */ { if (duplic != DUP_ERROR || ignore) + { table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); + if (table->file->ha_table_flags() & HA_DUPLICATE_POS && + table->file->ha_rnd_init_with_error(0)) + goto abort; + } /** This is a simple check for the case when the table has a trigger that reads from it, or when the statement invokes a stored function @@ -942,7 +947,10 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, { DBUG_PRINT("info", ("iteration %llu", iteration)); if (iteration && bulk_parameters_set(thd)) - goto abort; + { + error= 1; + goto values_loop_end; + } while ((values= its++)) { @@ -1094,7 +1102,11 @@ values_loop_end: error=1; } if (duplic != DUP_ERROR || ignore) + { table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); + if (table->file->ha_table_flags() & HA_DUPLICATE_POS) + table->file->ha_rnd_end(); + } transactional_table= table->file->has_transactions(); @@ -1705,6 +1717,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) goto err; if (table->file->ha_table_flags() & HA_DUPLICATE_POS) { + DBUG_ASSERT(table->file->inited == handler::RND); if (table->file->ha_rnd_pos(table->record[1],table->file->dup_ref)) goto err; } @@ -3177,6 +3190,9 @@ bool Delayed_insert::handle_inserts(void) max_rows= ULONG_MAX; // Do as much as possible } + if (table->file->ha_rnd_init_with_error(0)) + goto err; + /* We can't use row caching when using the binary log because if we get a crash, then binary log will contain rows that are not yet @@ -3352,6 +3368,8 @@ bool Delayed_insert::handle_inserts(void) } } + table->file->ha_rnd_end(); + if (WSREP((&thd))) thd_proc_info(&thd, "insert done"); else @@ -3649,7 +3667,12 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u) thd->cuted_fields=0; if (info.ignore || info.handle_duplicates != DUP_ERROR) + { table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); + if (table->file->ha_table_flags() & HA_DUPLICATE_POS && + table->file->ha_rnd_init_with_error(0)) + DBUG_RETURN(1); + } if (info.handle_duplicates == DUP_REPLACE && (!table->triggers || !table->triggers->has_delete_triggers())) table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE); @@ -3818,6 +3841,9 @@ bool select_insert::prepare_eof() if (!error && thd->is_error()) error= thd->get_stmt_da()->sql_errno(); + if (info.ignore || info.handle_duplicates != DUP_ERROR) + if (table->file->ha_table_flags() & HA_DUPLICATE_POS) + table->file->ha_rnd_end(); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); @@ -3929,6 +3955,11 @@ void select_insert::abort_result_set() { if (thd->locked_tables_mode <= LTM_LOCK_TABLES) table->file->ha_end_bulk_insert(); + if (table->file->inited) + table->file->ha_rnd_end(); + table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); + table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); + /* If at least one row has been inserted/modified and will stay in the table (the table doesn't have transactions) we must write to @@ -4341,7 +4372,12 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u) restore_record(table,s->default_values); // Get empty record thd->cuted_fields=0; if (info.ignore || info.handle_duplicates != DUP_ERROR) + { table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); + if (table->file->ha_table_flags() & HA_DUPLICATE_POS && + table->file->ha_rnd_init_with_error(0)) + DBUG_RETURN(1); + } if (info.handle_duplicates == DUP_REPLACE && (!table->triggers || !table->triggers->has_delete_triggers())) table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE); @@ -4522,9 +4558,6 @@ bool select_create::send_eof() */ exit_done= 1; // Avoid double calls - table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); - table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); - send_ok_packet(); if (m_plock) @@ -4600,13 +4633,6 @@ void select_create::abort_result_set() thd->locked_tables_list.unlock_locked_table(thd, create_info->mdl_ticket); } - if (m_plock) - { - mysql_unlock_tables(thd, *m_plock); - *m_plock= NULL; - m_plock= NULL; - } - if (table) { bool tmp_table= table->s->tmp_table; @@ -4617,9 +4643,21 @@ void select_create::abort_result_set() thd->restore_tmp_table_share(saved_tmp_table_share); } + if (table->file->inited && + (info.ignore || info.handle_duplicates != DUP_ERROR) && + (table->file->ha_table_flags() & HA_DUPLICATE_POS)) + table->file->ha_rnd_end(); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); table->auto_increment_field_not_null= FALSE; + + if (m_plock) + { + mysql_unlock_tables(thd, *m_plock); + *m_plock= NULL; + m_plock= NULL; + } + drop_open_table(thd, table, create_table->db, create_table->table_name); table=0; // Safety if (thd->log_current_statement && mysql_bin_log.is_open()) |