Description:
The following sequence of API calls is not more clear and needs to be acualized:
...
The following shows the method calls made during a nine-row table scan of the CSV engine:
ha_tina::store_lock
ha_tina::external_lock
ha_tina::info
ha_tina::rnd_init
ha_tina::extra - ENUM HA_EXTRA_CACHE Cache record in HA_rrnd()
ha_tina::rnd_next
ha_tina::rnd_next
ha_tina::rnd_next
ha_tina::rnd_next
ha_tina::rnd_next
ha_tina::rnd_next
ha_tina::rnd_next
ha_tina::rnd_next
ha_tina::rnd_next
ha_tina::extra - ENUM HA_EXTRA_NO_CACHE End caching of records (def)
ha_tina::external_lock
ha_tina::extra - ENUM HA_EXTRA_RESET Reset database to after open
...
When implementing the table scan like this without copying the code from CSV, then always the last row got lost. The very important information, that the last rnd_next must not contain values, but only the EOF is missing.
How to repeat:
int ha_tse::rnd_next(uchar *buf)
{
int rc= 0;
DBUG_ENTER("ha_tse::rnd_next");
int size;
int i;
int line_begin;
int line_end;
...
for (Field **field=table->field ; *field ; field++)
{
...
}
...
if (next_position >= local_saved_data_file_length)
DBUG_RETURN(HA_ERR_END_OF_FILE);
stats.records++;
next_position= line_begin;
DBUG_RETURN(rc);
}
instead of
int ha_tse::rnd_next(uchar *buf)
{
int rc= 0;
DBUG_ENTER("ha_tse::rnd_next");
int size;
int i;
int line_begin;
int line_end;
...
if (next_position >= local_saved_data_file_length)
DBUG_RETURN(HA_ERR_END_OF_FILE);
...
for (Field **field=table->field ; *field ; field++)
{
...
}
...
stats.records++;
next_position= line_begin;
DBUG_RETURN(rc);
}
Suggested fix:
Change the following algorithm as follows:
..
The following shows the method calls made during a nine-row table scan of the:
store_lock
external_lock
info
rnd_init
extra - ENUM HA_EXTRA_CACHE Cache record in HA_rrnd()
rnd_next
rnd_next
rnd_next
rnd_next
rnd_next
rnd_next
rnd_next
rnd_next
rnd_next
rnd_next (delivers only HA_ERR_END_OF_FILE, no values)
extra - ENUM HA_EXTRA_NO_CACHE End caching of records (def)
external_lock
extra - ENUM HA_EXTRA_RESET Reset database to after open