On Sat, May 16, 2009 at 03:28:10AM -0400, Vyacheslav Akhmechet wrote:
> Are calls to rnd_init and index_init ever interleaved? That is, could
> there be a situation in which index_init is called after rnd_init but
> prior to rnd_end? Similarly, could rnd_init be called between the
> calls to index_init and index_end?
No. One can be reasonably sure about this as the SQL layer calls
handler::ha_index_init() / ha_index_end()/etc which use asserts to guard
againist situation where one calls ha_index_init() and then calls
ha_rnd_init() without having called ha_index_end() before.
> The reason I'm asking is that I always access the data through an
> index (rnd_next just walks the index), and the act of walking the
> index requires a cursor/iterator-type object. I want to know if I can
> get away with a single cursor object per handler instance, or if I'll
> have to maintain multiple simultaneous cursors (one for
> rnd_init/rnd_next/rnd_end series, one for
> index_init/index_next/index_end, etc.)
Currently, one ha_something object == one 'cursor'. When the SQL layer needs
to have multiple cursors open at the same time, it calls handler->clone()
and then uses the second obtained handler* object to run the second scan.
Sergey Petrunia, Software Developer
Monty Program AB, http://askmonty.org