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.
This commit is contained in:
parent
5441bbd3b1
commit
0f956a0676
@ -710,8 +710,6 @@ SELECT DISTINCT a FROM t1, t2 HAVING a > ' ' LIMIT ROWS EXAMINED 16;
|
||||
a
|
||||
USA
|
||||
CAN
|
||||
Warnings:
|
||||
Warning 1931 Query execution was interrupted. The query examined at least 17 rows, which exceeds LIMIT ROWS EXAMINED (16). The query result may be incomplete
|
||||
drop table t1,t2,t3;
|
||||
set @@optimizer_switch='default';
|
||||
|
||||
|
@ -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()))
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
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);
|
||||
}
|
||||
else if (result == HA_ERR_RECORD_DELETED)
|
||||
increment_statistics(&SSV::ha_read_rnd_deleted_count);
|
||||
else
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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 */
|
||||
|
||||
|
222
sql/opt_range.cc
222
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);
|
||||
|
||||
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;
|
||||
|
||||
do
|
||||
{
|
||||
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);
|
||||
|
||||
/* 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;
|
||||
|
||||
while (last_rowid_count < quick_selects.elements)
|
||||
/* Ok, current select 'caught up' and returned ref >= cur_ref */
|
||||
if (cmp > 0)
|
||||
{
|
||||
if (!(qr= quick_it++))
|
||||
/* Found a row with ref > cur_ref. Make it a new 'candidate' */
|
||||
if (cpk_quick)
|
||||
{
|
||||
quick_it.rewind();
|
||||
qr= quick_it++;
|
||||
}
|
||||
quick= qr->quick;
|
||||
|
||||
do
|
||||
{
|
||||
DBUG_EXECUTE_IF("innodb_quick_report_deadlock",
|
||||
DBUG_SET("+d,innodb_report_deadlock"););
|
||||
if (unlikely((error= quick->get_next())))
|
||||
while (!cpk_quick->row_in_ranges())
|
||||
{
|
||||
/* 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->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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
|
||||
/* 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)
|
||||
{
|
||||
while (!cpk_quick->row_in_ranges())
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
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++;
|
||||
}
|
||||
}
|
||||
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 */
|
||||
|
||||
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 (!queue.elements)
|
||||
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
||||
/* Ok, we have a queue with >= 1 scans */
|
||||
if (error != HA_ERR_END_OF_FILE)
|
||||
DBUG_RETURN(error);
|
||||
queue_remove_top(&queue);
|
||||
}
|
||||
else
|
||||
{
|
||||
quick->save_last_pos();
|
||||
queue_replace_top(&queue);
|
||||
}
|
||||
|
||||
quick= (QUICK_SELECT_I*)queue_top(&queue);
|
||||
memcpy(cur_rowid, quick->last_rowid, rowid_length);
|
||||
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);
|
||||
|
||||
/* 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);
|
||||
}
|
||||
tmp= cur_rowid;
|
||||
cur_rowid= prev_rowid;
|
||||
prev_rowid= tmp;
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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); }
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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++)
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user