Hi!
On Aug 07, Alexey Botchkov wrote:
> 2708 Alexey Botchkov 2008-08-07
> Bug#38005 Partitions: error with insert select.
...
> Fixed by returning EOF from ha_myisam::index_first for empty tables.
>
> === modified file 'storage/myisam/ha_myisam.cc'
> --- a/storage/myisam/ha_myisam.cc 2008-03-28 10:14:27 +0000
> +++ b/storage/myisam/ha_myisam.cc 2008-08-07 04:51:43 +0000
> @@ -1653,7 +1653,9 @@ int ha_myisam::index_first(uchar *buf)
> {
> DBUG_ASSERT(inited==INDEX);
> ha_statistic_increment(&SSV::ha_read_first_count);
> - int error=mi_rfirst(file, buf, active_index);
> +
> + int error= (file->state->records == 0) ?
> + HA_ERR_END_OF_FILE : mi_rfirst(file, buf, active_index);
> table->status=error ? STATUS_NOT_FOUND: 0;
> return error;
> }
> @@ -1662,7 +1664,8 @@ int ha_myisam::index_last(uchar *buf)
> {
> DBUG_ASSERT(inited==INDEX);
> ha_statistic_increment(&SSV::ha_read_last_count);
> - int error=mi_rlast(file, buf, active_index);
> + int error= (file->state->records == 0) ?
> + HA_ERR_END_OF_FILE : mi_rlast(file, buf, active_index);
> table->status=error ? STATUS_NOT_FOUND: 0;
> return error;
> }
As we discussed on IRC it's a problem in ha_partition - it should
disable an index if it's disabled at least in one partition. Assuming
that the index can be disabled only because the table is empty is
incorrect.
CUrrently ha_partition may declare the index disabled or enabled
depending on the order of partitions. It's obvisouly a bug.
Regards / Mit vielen Grüssen,
Sergei
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@stripped>
/ /|_/ / // /\ \/ /_/ / /__ Principal Software Engineer/Server Architect
/_/ /_/\_, /___/\___\_\___/ Sun Microsystems GmbH, HRB München 161028
<___/ Sonnenallee 1, 85551 Kirchheim-Heimstetten
Geschäftsführer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer
Vorsitzender des Aufsichtsrates: Martin Häring