Bug #24986 Calls to handler::rnd_init and handler::index_init ignore return value
Submitted: 12 Dec 2006 0:29 Modified: 31 Oct 2011 14:00
Reporter: Sean Pringle Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S2 (Serious)
Version:4.1, 5.0 OS:Any
Assigned to: Ramil Kalimullin CPU Architecture:Any
Tags: bfsm_2006_12_21, bfsm_2007_04_19, bfsm_2007_10_25

[12 Dec 2006 0:29] Sean Pringle
Description:
init_read_record ignores the return value of handler::rnd_init in 4.0 and the return value of ha_rnd_init in 5.0.

Additionally, init_read_record returns void. Anything that call it, such as join_init_read_record, cannot return an error until read_record is called.

How to repeat:
From init_read_record in 4.0.26

else
{
DBUG_PRINT("info",("using rr_sequential"));
info->read_record=rr_sequential;
table->file->rnd_init();

From init_read_record in 5.0.30

if (tempfile && my_b_inited(tempfile)) // Test if ref-records was used
{
DBUG_PRINT("info",("using rr_from_tempfile"));
info->read_record= (table->sort.addon_field ?
rr_unpack_from_tempfile : rr_from_tempfile);
info->io_cache=tempfile;
reinit_io_cache(info->io_cache,READ_CACHE,0L,0,0);
info->ref_pos=table->file->ref;
if (!table->file->inited)
table->file->ha_rnd_init(0);

Suggested fix:
Given that rnd_init and ha_rnd_init can return a value indicating an error, why is the return value ignored? The result of this appears to be that handler::rnd_next may be called after handler::rnd_init has returned an error.
[12 Dec 2006 12:07] MySQL Verification Team
Thank you for the bug report.
[21 May 2010 0:19] Omer Barnir
triage: setting back to I3 following automatic update - issue affects facebook (issue indirectly related from facebook added)
[31 Oct 2011 14:00] Paul DuBois
Internal change, no user impact. No changelog entry needed.