diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-04-14 00:09:11 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2018-05-12 10:16:45 +0200 |
commit | 0f956a0676849bdd9c98bc45867b1965909f24f3 (patch) | |
tree | 6bd2e8bc586918c2344973a5b4a961552c140259 /sql | |
parent | 5441bbd3b1f9e4d0232f8df83a79c51638e51a58 (diff) | |
download | mariadb-git-0f956a0676849bdd9c98bc45867b1965909f24f3.tar.gz |
cleanup: hide HA_ERR_RECORD_DELETED in ha_rnd_next()
it's internal storage engine error, don't let it leak
into the upper layer.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/filesort.cc | 39 | ||||
-rw-r--r-- | sql/ha_partition.cc | 10 | ||||
-rw-r--r-- | sql/handler.cc | 35 | ||||
-rw-r--r-- | sql/item_subselect.cc | 15 | ||||
-rw-r--r-- | sql/log_event.cc | 19 | ||||
-rw-r--r-- | sql/log_event_old.cc | 29 | ||||
-rw-r--r-- | sql/multi_range_read.cc | 6 | ||||
-rw-r--r-- | sql/opt_range.cc | 214 | ||||
-rw-r--r-- | sql/records.cc | 25 | ||||
-rw-r--r-- | sql/records.h | 2 | ||||
-rw-r--r-- | sql/rpl_rli.cc | 4 | ||||
-rw-r--r-- | sql/sql_delete.cc | 5 | ||||
-rw-r--r-- | sql/sql_handler.cc | 2 | ||||
-rw-r--r-- | sql/sql_partition.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 11 | ||||
-rw-r--r-- | sql/sql_statistics.cc | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 2 | ||||
-rw-r--r-- | sql/sql_union.cc | 5 | ||||
-rw-r--r-- | sql/sql_update.cc | 2 |
19 files changed, 144 insertions, 287 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index 83edfadee2d..b2c88cda7b3 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -705,10 +705,9 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, Bounded_queue<uchar, uchar> *pq, ha_rows *found_rows) { - int error,flag,quick_select; - uint idx,indexpos,ref_length; - uchar *ref_pos,*next_pos,ref_buff[MAX_REFLENGTH]; - my_off_t record; + int error, quick_select; + uint idx, indexpos; + uchar *ref_pos, *next_pos, ref_buff[MAX_REFLENGTH]; TABLE *sort_form; handler *file; MY_BITMAP *save_read_set, *save_write_set, *save_vcol_set; @@ -723,14 +722,10 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, error=quick_select=0; sort_form=param->sort_form; file=sort_form->file; - ref_length=param->ref_length; ref_pos= ref_buff; quick_select=select && select->quick; - record=0; *found_rows= 0; - flag= ((file->ha_table_flags() & HA_REC_NOT_IN_SEQ) || quick_select); - if (flag) - ref_pos= &file->ref[0]; + ref_pos= &file->ref[0]; next_pos=ref_pos; DBUG_EXECUTE_IF("show_explain_in_find_all_keys", @@ -778,27 +773,13 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, for (;;) { if (quick_select) - { - if (unlikely((error= select->quick->get_next()))) - break; - file->position(sort_form->record[0]); - DBUG_EXECUTE_IF("debug_filesort", dbug_print_record(sort_form, TRUE);); - } + error= select->quick->get_next(); else /* Not quick-select */ - { - { - error= file->ha_rnd_next(sort_form->record[0]); - if (!flag) - { - my_store_ptr(ref_pos,ref_length,record); // Position to row - record+= sort_form->s->db_record_offset; - } - else if (likely(!error)) - file->position(sort_form->record[0]); - } - if (unlikely(error && error != HA_ERR_RECORD_DELETED)) - break; - } + error= file->ha_rnd_next(sort_form->record[0]); + if (unlikely(error)) + break; + file->position(sort_form->record[0]); + DBUG_EXECUTE_IF("debug_filesort", dbug_print_record(sort_form, TRUE);); if (unlikely(thd->check_killed())) { diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index c119e379998..005f7461425 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2089,8 +2089,6 @@ int ha_partition::copy_partitions(ulonglong * const copied, { if ((result= file->ha_rnd_next(m_rec0))) { - if (result == HA_ERR_RECORD_DELETED) - continue; //Probably MyISAM if (result != HA_ERR_END_OF_FILE) goto error; /* @@ -5070,9 +5068,6 @@ int ha_partition::rnd_next(uchar *buf) /* if we get here, then the current partition ha_rnd_next returned failure */ - if (result == HA_ERR_RECORD_DELETED) - continue; // Probably MyISAM - if (result != HA_ERR_END_OF_FILE) goto end_dont_reset_start_part; // Return error @@ -6927,9 +6922,6 @@ int ha_partition::ft_read(uchar *buf) /* if we get here, then the current partition ft_next returned failure */ - if (result == HA_ERR_RECORD_DELETED) - continue; // Probably MyISAM - if (result != HA_ERR_END_OF_FILE) goto end_dont_reset_start_part; // Return error @@ -10656,8 +10648,6 @@ int ha_partition::check_misplaced_rows(uint read_part_id, bool do_repair) { if ((result= m_file[read_part_id]->ha_rnd_next(m_rec0))) { - if (result == HA_ERR_RECORD_DELETED) - continue; if (result != HA_ERR_END_OF_FILE) break; diff --git a/sql/handler.cc b/sql/handler.cc index 7323d4c1d9d..be0e82efebf 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2759,19 +2759,27 @@ int handler::ha_rnd_next(uchar *buf) m_lock_type != F_UNLCK); DBUG_ASSERT(inited == RND); - TABLE_IO_WAIT(tracker, m_psi, PSI_TABLE_FETCH_ROW, MAX_KEY, 0, - { result= rnd_next(buf); }) - if (!result) + do { - update_rows_read(); - if (table->vfield && buf == table->record[0]) - table->update_virtual_fields(this, VCOL_UPDATE_FOR_READ); - increment_statistics(&SSV::ha_read_rnd_next_count); - } - else if (result == HA_ERR_RECORD_DELETED) - increment_statistics(&SSV::ha_read_rnd_deleted_count); + TABLE_IO_WAIT(tracker, m_psi, PSI_TABLE_FETCH_ROW, MAX_KEY, 0, + { result= rnd_next(buf); }) + if (result != HA_ERR_RECORD_DELETED) + break; + status_var_increment(table->in_use->status_var.ha_read_rnd_deleted_count); + } while (!table->in_use->check_killed()); + + if (result == HA_ERR_RECORD_DELETED) + result= HA_ERR_ABORTED_BY_USER; else + { + if (!result) + { + update_rows_read(); + if (table->vfield && buf == table->record[0]) + table->update_virtual_fields(this, VCOL_UPDATE_FOR_READ); + } increment_statistics(&SSV::ha_read_rnd_next_count); + } table->status=result ? STATUS_NOT_FOUND: 0; DBUG_RETURN(result); @@ -2789,7 +2797,9 @@ int handler::ha_rnd_pos(uchar *buf, uchar *pos) TABLE_IO_WAIT(tracker, m_psi, PSI_TABLE_FETCH_ROW, MAX_KEY, 0, { result= rnd_pos(buf, pos); }) increment_statistics(&SSV::ha_read_rnd_count); - if (!result) + if (result == HA_ERR_RECORD_DELETED) + result= HA_ERR_KEY_NOT_FOUND; + else if (!result) { update_rows_read(); if (table->vfield && buf == table->record[0]) @@ -2996,8 +3006,7 @@ int handler::read_first_row(uchar * buf, uint primary_key) { if (likely(!(error= ha_rnd_init(1)))) { - while ((error= ha_rnd_next(buf)) == HA_ERR_RECORD_DELETED) - /* skip deleted row */; + error= ha_rnd_next(buf); const int end_error= ha_rnd_end(); if (likely(!error)) error= end_error; diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index ea248405a22..69b819e08f3 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -3937,11 +3937,6 @@ int subselect_uniquesubquery_engine::scan_table() error=table->file->ha_rnd_next(table->record[0]); if (unlikely(error)) { - if (error == HA_ERR_RECORD_DELETED) - { - error= 0; - continue; - } if (error == HA_ERR_END_OF_FILE) { error= 0; @@ -6232,11 +6227,6 @@ subselect_rowid_merge_engine::init(MY_BITMAP *non_null_key_parts, while (TRUE) { error= tmp_table->file->ha_rnd_next(tmp_table->record[0]); - if (unlikely(error == HA_ERR_RECORD_DELETED)) - { - /* We get this for duplicate records that should not be in tmp_table. */ - continue; - } /* This is a temp table that we fully own, there should be no other cause to stop the iteration than EOF. @@ -6681,11 +6671,6 @@ bool subselect_table_scan_engine::partial_match() error= tmp_table->file->ha_rnd_next(tmp_table->record[0]); if (unlikely(error)) { - if (error == HA_ERR_RECORD_DELETED) - { - error= 0; - continue; - } if (error == HA_ERR_END_OF_FILE) { error= 0; diff --git a/sql/log_event.cc b/sql/log_event.cc index 28ce1fa2586..7a6d0a1821b 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -13210,8 +13210,6 @@ Rows_log_event::write_row(rpl_group_info *rgi, if (unlikely(error)) { DBUG_PRINT("info",("rnd_pos() returns error %d",error)); - if (error == HA_ERR_RECORD_DELETED) - error= HA_ERR_KEY_NOT_FOUND; table->file->print_error(error, MYF(0)); DBUG_RETURN(error); } @@ -13245,8 +13243,6 @@ Rows_log_event::write_row(rpl_group_info *rgi, if (unlikely(error)) { DBUG_PRINT("info",("index_read_idx() returns %s", HA_ERR(error))); - if (error == HA_ERR_RECORD_DELETED) - error= HA_ERR_KEY_NOT_FOUND; table->file->print_error(error, MYF(0)); DBUG_RETURN(error); } @@ -13746,8 +13742,6 @@ int Rows_log_event::find_row(rpl_group_info *rgi) if (unlikely(error)) { DBUG_PRINT("info",("rnd_pos returns error %d",error)); - if (error == HA_ERR_RECORD_DELETED) - error= HA_ERR_KEY_NOT_FOUND; table->file->print_error(error, MYF(0)); } DBUG_RETURN(error); @@ -13813,8 +13807,6 @@ int Rows_log_event::find_row(rpl_group_info *rgi) HA_READ_KEY_EXACT)))) { DBUG_PRINT("info",("no record matching the key found in the table")); - if (error == HA_ERR_RECORD_DELETED) - error= HA_ERR_KEY_NOT_FOUND; table->file->print_error(error, MYF(0)); table->file->ha_index_end(); goto end; @@ -13890,9 +13882,6 @@ int Rows_log_event::find_row(rpl_group_info *rgi) { while ((error= table->file->ha_index_next(table->record[0]))) { - /* We just skip records that has already been deleted */ - if (unlikely(error == HA_ERR_RECORD_DELETED)) - continue; DBUG_PRINT("info",("no record matching the given row found")); table->file->print_error(error, MYF(0)); table->file->ha_index_end(); @@ -13919,7 +13908,6 @@ int Rows_log_event::find_row(rpl_group_info *rgi) /* Continue until we find the right record or have made a full loop */ do { - restart_rnd_next: error= table->file->ha_rnd_next(table->record[0]); if (unlikely(error)) @@ -13935,13 +13923,6 @@ int Rows_log_event::find_row(rpl_group_info *rgi) table->file->ha_rnd_end(); goto end; - /* - If the record was deleted, we pick the next one without doing - any comparisons. - */ - case HA_ERR_RECORD_DELETED: - goto restart_rnd_next; - default: DBUG_PRINT("info", ("Failed to get next record" " (rnd_next returns %d)",error)); diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index 6154f30070f..66c4c2bef42 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -513,8 +513,6 @@ replace_record(THD *thd, TABLE *table, if (unlikely(error)) { DBUG_PRINT("info",("rnd_pos() returns error %d",error)); - if (error == HA_ERR_RECORD_DELETED) - error= HA_ERR_KEY_NOT_FOUND; table->file->print_error(error, MYF(0)); DBUG_RETURN(error); } @@ -542,8 +540,6 @@ replace_record(THD *thd, TABLE *table, if (unlikely(error)) { DBUG_PRINT("info", ("index_read_idx() returns error %d", error)); - if (error == HA_ERR_RECORD_DELETED) - error= HA_ERR_KEY_NOT_FOUND; table->file->print_error(error, MYF(0)); DBUG_RETURN(error); } @@ -741,9 +737,6 @@ static int find_and_fetch_row(TABLE *table, uchar *key) while ((error= table->file->ha_index_next(table->record[1]))) { - /* We just skip records that has already been deleted */ - if (unlikely(error == HA_ERR_RECORD_DELETED)) - continue; table->file->print_error(error, MYF(0)); table->file->ha_index_end(); DBUG_RETURN(error); @@ -767,7 +760,6 @@ static int find_and_fetch_row(TABLE *table, uchar *key) /* Continue until we find the right record or have made a full loop */ do { - restart_rnd_next: error= table->file->ha_rnd_next(table->record[1]); DBUG_DUMP("record[0]", table->record[0], table->s->reclength); @@ -777,13 +769,6 @@ static int find_and_fetch_row(TABLE *table, uchar *key) case 0: break; - /* - If the record was deleted, we pick the next one without doing - any comparisons. - */ - case HA_ERR_RECORD_DELETED: - goto restart_rnd_next; - case HA_ERR_END_OF_FILE: if (++restart_count < 2) { @@ -1995,8 +1980,6 @@ Old_rows_log_event::write_row(rpl_group_info *rgi, const bool overwrite) if (unlikely(error)) { DBUG_PRINT("info",("rnd_pos() returns error %d",error)); - if (error == HA_ERR_RECORD_DELETED) - error= HA_ERR_KEY_NOT_FOUND; table->file->print_error(error, MYF(0)); DBUG_RETURN(error); } @@ -2030,8 +2013,6 @@ Old_rows_log_event::write_row(rpl_group_info *rgi, const bool overwrite) if (unlikely(error)) { DBUG_PRINT("info",("index_read_idx() returns error %d", error)); - if (error == HA_ERR_RECORD_DELETED) - error= HA_ERR_KEY_NOT_FOUND; table->file->print_error(error, MYF(0)); DBUG_RETURN(error); } @@ -2191,8 +2172,6 @@ int Old_rows_log_event::find_row(rpl_group_info *rgi) if (unlikely(error)) { DBUG_PRINT("info",("rnd_pos returns error %d",error)); - if (error == HA_ERR_RECORD_DELETED) - error= HA_ERR_KEY_NOT_FOUND; table->file->print_error(error, MYF(0)); } DBUG_RETURN(error); @@ -2254,8 +2233,6 @@ int Old_rows_log_event::find_row(rpl_group_info *rgi) HA_READ_KEY_EXACT)))) { DBUG_PRINT("info",("no record matching the key found in the table")); - if (error == HA_ERR_RECORD_DELETED) - error= HA_ERR_KEY_NOT_FOUND; table->file->print_error(error, MYF(0)); table->file->ha_index_end(); DBUG_RETURN(error); @@ -2325,9 +2302,6 @@ int Old_rows_log_event::find_row(rpl_group_info *rgi) { while (unlikely(error= table->file->ha_index_next(table->record[0]))) { - /* We just skip records that has already been deleted */ - if (error == HA_ERR_RECORD_DELETED) - continue; DBUG_PRINT("info",("no record matching the given row found")); table->file->print_error(error, MYF(0)); (void) table->file->ha_index_end(); @@ -2360,9 +2334,6 @@ int Old_rows_log_event::find_row(rpl_group_info *rgi) case 0: break; - case HA_ERR_RECORD_DELETED: - goto restart_rnd_next; - case HA_ERR_END_OF_FILE: if (++restart_count < 2) { diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index ec3c85b34c4..cf587ef4acd 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -757,12 +757,6 @@ int Mrr_ordered_rndpos_reader::get_next(range_id_t *range_info) res= file->ha_rnd_pos(file->get_table()->record[0], rowid_buffer->read_ptr1); - if (res == HA_ERR_RECORD_DELETED) - { - /* not likely to get this code with current storage engines, but still */ - continue; - } - if (res) return res; /* Some fatal error */ diff --git a/sql/opt_range.cc b/sql/opt_range.cc index c7c0ba25efe..8422917065f 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -11166,103 +11166,100 @@ int QUICK_ROR_INTERSECT_SELECT::get_next() uint last_rowid_count=0; DBUG_ENTER("QUICK_ROR_INTERSECT_SELECT::get_next"); - do + /* Get a rowid for first quick and save it as a 'candidate' */ + qr= quick_it++; + quick= qr->quick; + error= quick->get_next(); + if (cpk_quick) { - /* Get a rowid for first quick and save it as a 'candidate' */ - qr= quick_it++; - quick= qr->quick; - error= quick->get_next(); - if (cpk_quick) + while (!error && !cpk_quick->row_in_ranges()) { - while (!error && !cpk_quick->row_in_ranges()) - { - quick->file->unlock_row(); /* row not in range; unlock */ - error= quick->get_next(); - } + quick->file->unlock_row(); /* row not in range; unlock */ + error= quick->get_next(); } - if (unlikely(error)) - DBUG_RETURN(error); + } + if (unlikely(error)) + DBUG_RETURN(error); - /* Save the read key tuple */ - key_copy(qr->key_tuple, record, head->key_info + quick->index, - quick->max_used_key_length); + /* Save the read key tuple */ + key_copy(qr->key_tuple, record, head->key_info + quick->index, + quick->max_used_key_length); + + quick->file->position(quick->record); + memcpy(last_rowid, quick->file->ref, head->file->ref_length); + last_rowid_count= 1; + quick_with_last_rowid= quick; - quick->file->position(quick->record); - memcpy(last_rowid, quick->file->ref, head->file->ref_length); - last_rowid_count= 1; - quick_with_last_rowid= quick; + while (last_rowid_count < quick_selects.elements) + { + if (!(qr= quick_it++)) + { + quick_it.rewind(); + qr= quick_it++; + } + quick= qr->quick; - while (last_rowid_count < quick_selects.elements) + do { - if (!(qr= quick_it++)) + DBUG_EXECUTE_IF("innodb_quick_report_deadlock", + DBUG_SET("+d,innodb_report_deadlock");); + if (unlikely((error= quick->get_next()))) { - quick_it.rewind(); - qr= quick_it++; + /* On certain errors like deadlock, trx might be rolled back.*/ + if (!thd->transaction_rollback_request) + quick_with_last_rowid->file->unlock_row(); + DBUG_RETURN(error); } - quick= qr->quick; - - do + quick->file->position(quick->record); + cmp= head->file->cmp_ref(quick->file->ref, last_rowid); + if (cmp < 0) { - DBUG_EXECUTE_IF("innodb_quick_report_deadlock", - DBUG_SET("+d,innodb_report_deadlock");); - if (unlikely((error= quick->get_next()))) - { - /* On certain errors like deadlock, trx might be rolled back.*/ - if (!thd->transaction_rollback_request) - quick_with_last_rowid->file->unlock_row(); - DBUG_RETURN(error); - } - quick->file->position(quick->record); - cmp= head->file->cmp_ref(quick->file->ref, last_rowid); - if (cmp < 0) - { - /* This row is being skipped. Release lock on it. */ - quick->file->unlock_row(); - } - } while (cmp < 0); + /* This row is being skipped. Release lock on it. */ + quick->file->unlock_row(); + } + } while (cmp < 0); - key_copy(qr->key_tuple, record, head->key_info + quick->index, - quick->max_used_key_length); + key_copy(qr->key_tuple, record, head->key_info + quick->index, + quick->max_used_key_length); - /* Ok, current select 'caught up' and returned ref >= cur_ref */ - if (cmp > 0) + /* Ok, current select 'caught up' and returned ref >= cur_ref */ + if (cmp > 0) + { + /* Found a row with ref > cur_ref. Make it a new 'candidate' */ + if (cpk_quick) { - /* Found a row with ref > cur_ref. Make it a new 'candidate' */ - if (cpk_quick) + while (!cpk_quick->row_in_ranges()) { - while (!cpk_quick->row_in_ranges()) + quick->file->unlock_row(); /* row not in range; unlock */ + if (unlikely((error= quick->get_next()))) { - quick->file->unlock_row(); /* row not in range; unlock */ - if (unlikely((error= quick->get_next()))) - { - /* On certain errors like deadlock, trx might be rolled back.*/ - if (!thd->transaction_rollback_request) - quick_with_last_rowid->file->unlock_row(); - DBUG_RETURN(error); - } + /* On certain errors like deadlock, trx might be rolled back.*/ + if (!thd->transaction_rollback_request) + quick_with_last_rowid->file->unlock_row(); + DBUG_RETURN(error); } - quick->file->position(quick->record); } - memcpy(last_rowid, quick->file->ref, head->file->ref_length); - quick_with_last_rowid->file->unlock_row(); - last_rowid_count= 1; - quick_with_last_rowid= quick; - - //save the fields here - key_copy(qr->key_tuple, record, head->key_info + quick->index, - quick->max_used_key_length); - } - else - { - /* current 'candidate' row confirmed by this select */ - last_rowid_count++; + quick->file->position(quick->record); } + memcpy(last_rowid, quick->file->ref, head->file->ref_length); + quick_with_last_rowid->file->unlock_row(); + last_rowid_count= 1; + quick_with_last_rowid= quick; + + //save the fields here + key_copy(qr->key_tuple, record, head->key_info + quick->index, + quick->max_used_key_length); } + else + { + /* current 'candidate' row confirmed by this select */ + last_rowid_count++; + } + } - /* We get here if we got the same row ref in all scans. */ - if (need_to_fetch_row) - error= head->file->ha_rnd_pos(head->record[0], last_rowid); - } while (error == HA_ERR_RECORD_DELETED); + /* We get here if we got the same row ref in all scans. */ + if (need_to_fetch_row) + error= head->file->ha_rnd_pos(head->record[0], last_rowid); if (!need_to_fetch_row) { @@ -11306,44 +11303,41 @@ int QUICK_ROR_UNION_SELECT::get_next() do { - do - { - if (!queue.elements) - DBUG_RETURN(HA_ERR_END_OF_FILE); - /* Ok, we have a queue with >= 1 scans */ + if (!queue.elements) + DBUG_RETURN(HA_ERR_END_OF_FILE); + /* Ok, we have a queue with >= 1 scans */ - quick= (QUICK_SELECT_I*)queue_top(&queue); - memcpy(cur_rowid, quick->last_rowid, rowid_length); + quick= (QUICK_SELECT_I*)queue_top(&queue); + memcpy(cur_rowid, quick->last_rowid, rowid_length); - /* put into queue rowid from the same stream as top element */ - if ((error= quick->get_next())) - { - if (error != HA_ERR_END_OF_FILE) - DBUG_RETURN(error); - queue_remove_top(&queue); - } - else - { - quick->save_last_pos(); - queue_replace_top(&queue); - } + /* put into queue rowid from the same stream as top element */ + if ((error= quick->get_next())) + { + if (error != HA_ERR_END_OF_FILE) + DBUG_RETURN(error); + queue_remove_top(&queue); + } + else + { + quick->save_last_pos(); + queue_replace_top(&queue); + } - if (!have_prev_rowid) - { - /* No rows have been returned yet */ - dup_row= FALSE; - have_prev_rowid= TRUE; - } - else - dup_row= !head->file->cmp_ref(cur_rowid, prev_rowid); - } while (dup_row); + if (!have_prev_rowid) + { + /* No rows have been returned yet */ + dup_row= FALSE; + have_prev_rowid= TRUE; + } + else + dup_row= !head->file->cmp_ref(cur_rowid, prev_rowid); + } while (dup_row); - tmp= cur_rowid; - cur_rowid= prev_rowid; - prev_rowid= tmp; + tmp= cur_rowid; + cur_rowid= prev_rowid; + prev_rowid= tmp; - error= head->file->ha_rnd_pos(quick->record, prev_rowid); - } while (error == HA_ERR_RECORD_DELETED); + error= head->file->ha_rnd_pos(quick->record, prev_rowid); DBUG_RETURN(error); } diff --git a/sql/records.cc b/sql/records.cc index 244d3b4d962..59601ae99f3 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -217,7 +217,6 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table, info->select=select; info->print_error=print_error; info->unlock_row= rr_unlock_row; - info->ignore_not_found_rows= 0; table->status= 0; /* Rows are always found */ tempfile= 0; @@ -365,11 +364,8 @@ static int rr_quick(READ_RECORD *info) int tmp; while ((tmp= info->select->quick->get_next())) { - if (info->thd->killed || (tmp != HA_ERR_RECORD_DELETED)) - { - tmp= rr_handle_error(info, tmp); - break; - } + tmp= rr_handle_error(info, tmp); + break; } return tmp; } @@ -484,15 +480,8 @@ int rr_sequential(READ_RECORD *info) int tmp; while ((tmp= info->table->file->ha_rnd_next(info->record))) { - /* - rnd_next can return RECORD_DELETED for MyISAM when one thread is - reading and another deleting without locks. - */ - if (info->thd->killed || (tmp != HA_ERR_RECORD_DELETED)) - { - tmp= rr_handle_error(info, tmp); - break; - } + tmp= rr_handle_error(info, tmp); + break; } return tmp; } @@ -508,8 +497,7 @@ static int rr_from_tempfile(READ_RECORD *info) if (!(tmp= info->table->file->ha_rnd_pos(info->record,info->ref_pos))) break; /* The following is extremely unlikely to happen */ - if (tmp == HA_ERR_RECORD_DELETED || - (tmp == HA_ERR_KEY_NOT_FOUND && info->ignore_not_found_rows)) + if (tmp == HA_ERR_KEY_NOT_FOUND) continue; tmp= rr_handle_error(info, tmp); break; @@ -560,8 +548,7 @@ int rr_from_pointers(READ_RECORD *info) break; /* The following is extremely unlikely to happen */ - if (tmp == HA_ERR_RECORD_DELETED || - (tmp == HA_ERR_KEY_NOT_FOUND && info->ignore_not_found_rows)) + if (tmp == HA_ERR_KEY_NOT_FOUND) continue; tmp= rr_handle_error(info, tmp); break; diff --git a/sql/records.h b/sql/records.h index 940c88ca0c7..f6a5069840d 100644 --- a/sql/records.h +++ b/sql/records.h @@ -67,7 +67,7 @@ struct READ_RECORD uchar *cache,*cache_pos,*cache_end,*read_positions; struct st_sort_addon_field *addon_field; /* Pointer to the fields info */ struct st_io_cache *io_cache; - bool print_error, ignore_not_found_rows; + bool print_error; void (*unpack)(struct st_sort_addon_field *, uchar *, uchar *); int read_record() { return read_record_func(this); } diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 13efed9bea6..70b5832b274 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -1549,9 +1549,7 @@ scan_one_gtid_slave_pos_table(THD *thd, HASH *hash, DYNAMIC_ARRAY *array, if ((err= table->file->ha_rnd_next(table->record[0]))) { - if (err == HA_ERR_RECORD_DELETED) - continue; - else if (err == HA_ERR_END_OF_FILE) + if (err == HA_ERR_END_OF_FILE) break; else { diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 52796f03440..af0e167e42d 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -1421,11 +1421,6 @@ int multi_delete::do_table_deletes(TABLE *table, SORT_INFO *sort_info, FALSE))) DBUG_RETURN(1); - /* - Ignore any rows not found in reference tables as they may already have - been deleted by foreign key handling - */ - info.ignore_not_found_rows= 1; bool will_batch= !table->file->start_bulk_delete(); while (likely(!(local_error= info.read_record())) && likely(!thd->killed)) { diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 09883d8a0bd..187a7462c87 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -941,8 +941,6 @@ retry: if (unlikely(error)) { - if (error == HA_ERR_RECORD_DELETED) - continue; if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) { /* Don't give error in the log file for some expected problems */ diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 58583781676..c2534a9962e 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -4110,8 +4110,6 @@ bool verify_data_with_partition(TABLE *table, TABLE *part_table, { if (unlikely((error= file->ha_rnd_next(table->record[0])))) { - if (error == HA_ERR_RECORD_DELETED) - continue; if (error == HA_ERR_END_OF_FILE) error= 0; else diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 799828cd38e..bf6c2a49aba 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -22532,11 +22532,6 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field, } if (unlikely(error)) { - if (error == HA_ERR_RECORD_DELETED) - { - error= file->ha_rnd_next(record); - continue; - } if (error == HA_ERR_END_OF_FILE) break; goto err; @@ -22563,8 +22558,6 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field, { if (unlikely((error= file->ha_rnd_next(record)))) { - if (error == HA_ERR_RECORD_DELETED) - continue; if (error == HA_ERR_END_OF_FILE) break; goto err; @@ -22655,8 +22648,6 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table, } if (unlikely((error= file->ha_rnd_next(record)))) { - if (error == HA_ERR_RECORD_DELETED) - continue; if (error == HA_ERR_END_OF_FILE) break; goto err; @@ -27067,8 +27058,6 @@ ulong check_selectivity(THD *thd, } if (unlikely(error)) { - if (error == HA_ERR_RECORD_DELETED) - continue; if (error == HA_ERR_END_OF_FILE) break; goto err; diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 37d994e8de7..7bb03740bf4 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -2743,11 +2743,7 @@ int collect_statistics_for_table(THD *thd, TABLE *table) break; if (rc) - { - if (rc == HA_ERR_RECORD_DELETED) - continue; break; - } for (field_ptr= table->field; *field_ptr; field_ptr++) { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4da5b593a1a..ccf68b1d06e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -10599,8 +10599,6 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, int error= t->file->ha_rnd_next(t->record[0]); if (unlikely(error)) { - if (error == HA_ERR_RECORD_DELETED) - continue; break; } if (t->s->null_bytes) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 7c43436a370..caba0e24c91 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -280,11 +280,6 @@ bool select_unit::send_eof() error= 0; break; } - if (unlikely(error == HA_ERR_RECORD_DELETED)) - { - error= 0; - continue; - } break; } if (table->field[0]->val_int() != curr_step) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 0b613336f69..26bd1d79d69 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -2598,8 +2598,6 @@ int multi_update::do_updates() { if (local_error == HA_ERR_END_OF_FILE) break; - if (local_error == HA_ERR_RECORD_DELETED) - continue; // May happen on dup key err_table= tmp_table; goto err; } |