on reading: if we get lastrecord set to true from index_query,
we want to exit the loop after processing that record rather than
set at_eof and keep going (because that makes a core dump).