mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
mysql-5.5.29 merge
This commit is contained in:
@@ -2334,18 +2334,25 @@ int handler::read_first_row(uchar * buf, uint primary_key)
|
||||
if (stats.deleted < 10 || primary_key >= MAX_KEY ||
|
||||
!(index_flags(primary_key, 0, 0) & HA_READ_ORDER))
|
||||
{
|
||||
if ((!(error= ha_rnd_init(1))))
|
||||
if (!(error= ha_rnd_init(1)))
|
||||
{
|
||||
while ((error= ha_rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
|
||||
(void) ha_rnd_end();
|
||||
while ((error= ha_rnd_next(buf)) == HA_ERR_RECORD_DELETED)
|
||||
/* skip deleted row */;
|
||||
const int end_error= ha_rnd_end();
|
||||
if (!error)
|
||||
error= end_error;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Find the first row through the primary key */
|
||||
if (!(error = ha_index_init(primary_key, 0)))
|
||||
if (!(error= ha_index_init(primary_key, 0)))
|
||||
{
|
||||
error= ha_index_first(buf);
|
||||
(void) ha_index_end();
|
||||
const int end_error= ha_index_end();
|
||||
if (!error)
|
||||
error= end_error;
|
||||
}
|
||||
}
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
@@ -2744,7 +2751,15 @@ void handler::get_auto_increment(ulonglong offset, ulonglong increment,
|
||||
table->mark_columns_used_by_index_no_reset(table->s->next_number_index,
|
||||
table->read_set);
|
||||
column_bitmaps_signal();
|
||||
ha_index_init(table->s->next_number_index, 1);
|
||||
|
||||
if (ha_index_init(table->s->next_number_index, 1))
|
||||
{
|
||||
/* This should never happen, assert in debug, and fail in release build */
|
||||
DBUG_ASSERT(0);
|
||||
*first_value= ULONGLONG_MAX;
|
||||
return;
|
||||
}
|
||||
|
||||
if (table->s->next_number_keypart == 0)
|
||||
{ // Autoincrement at key-start
|
||||
error=ha_index_last(table->record[1]);
|
||||
@@ -2775,13 +2790,25 @@ void handler::get_auto_increment(ulonglong offset, ulonglong increment,
|
||||
}
|
||||
|
||||
if (error)
|
||||
nr=1;
|
||||
{
|
||||
if (error == HA_ERR_END_OF_FILE || error == HA_ERR_KEY_NOT_FOUND)
|
||||
{
|
||||
/* No entry found, start with 1. */
|
||||
nr= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
DBUG_ASSERT(0);
|
||||
nr= ULONGLONG_MAX;
|
||||
}
|
||||
}
|
||||
else
|
||||
nr= ((ulonglong) table->next_number_field->
|
||||
val_int_offset(table->s->rec_buff_length)+1);
|
||||
ha_index_end();
|
||||
(void) extra(HA_EXTRA_NO_KEYREAD);
|
||||
*first_value= nr;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user