Commit [814d7e] Maximize Restore History

dbi: resolve bogus seeking into dbd

I have a query result that, when iteratively seeked with
dbi_result_next_row() and read with dbi_result_get_string(), yields
these 15 values (1-based row indices shown in parentheses):

B-W(1) BAY(2) BER(3) BRE(4) HAM(5) HES(6) M-V(7) NDS(8)
NRW(9) RLP(10) SAR(11) SAC(12) S-A(13) S-H(14) THU(15)

Now, when using dbi_result_seek_row() to seek to arbitrary rows
(given in parentheses), dbi_result_get_string() can return incorrect
values. In particular, I have observed:

B-W(1) S-H(14) B-W(1) THU(2)

What happens:

* row 1 is not already present, dbd_goto_row(1) is executed,
the row data retrieved, and result->currowidx set to 1
* row 14 is not already present, a goto_row(14) is executed,
the row data retrieved, and result->currowidx set to 14
* row 1 is already present, result->currowidx set to 1
* row 2 is not already present, dbd_goto_row(2) is NOT executed,
because of rowidx == currowidx + 1 [2 == 2].
So the next mysql row fetched is row 15, rather than 2.

result->currowidx is a high-level pointer that always gets updated.
But we do need to track the pointer that the DBD has, as well.

After applying this patch, the seeked results correctly yield:

B-W(1) S-H(14) B-W(1) BAY(2)

Jan Engelhardt Jan Engelhardt 2014-05-01

changed include
changed include/dbi
changed include/dbi/dbi-dev.h
changed src
changed src/dbd_helper.c
changed src/dbi_result.c
include
Directory.
include/dbi
Directory.
include/dbi/dbi-dev.h Diff Switch to side-by-side view
Loading...
src
Directory.
src/dbd_helper.c Diff Switch to side-by-side view
Loading...
src/dbi_result.c Diff Switch to side-by-side view
Loading...