|
From: Christian M. S. <chr...@st...> - 2003-08-26 07:03:42
|
=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
On Tuesday 26 August 2003 06.13, Markus Hoenicka wrote:
: Hi,
:
: I didn't get round to debug the problem, but if the loop below doesn't
: work as expected, it's a libdbi bug. dbi_result_next_row() checks
: whether currowidx is within the bounds of the result set and throws an
: error if it is too high. There is probably a hidden off-by-one
: error in the comparisons that we need to fix.
No It's not a bug. It's a feature ;)=20
Everytime the while loop checks the condition if it should loop one more ti=
me=20
the function dbi_conn_next_row() gets executed.=20
: while (dbi_result_next_row(result))
So say that there are 8 rows, when the 8 row are fetched the while loop=20
executes dbi_conn_next_row() one more time to check if it should go a 9:th=
=20
time, libdbi throws a DABIDX becouse you are trying to fetch row number 9 a=
nd=20
there are only 8 rows, returns 0 so the while loop stops.
So the question here is. Should this error check for BADIDX be taken out of=
=20
dbi_result_next_row() so that you can use it whitout errors thrown in a pla=
in=20
while loop.=20
While looking in to the problem I found something that is a bug.=20
dbi_result_seek_row() doesn't return -1 when dbd_seek_row() returns -1=20
indicating failure. It tryies to fetch the row anyway which is in my eyes a=
n=20
error (if the row can't be seeked we are fetching the wrong row).
=2D --- dbi_result.c.orig 2003-08-26 08:55:37.000000000 +0200
+++ dbi_result.c 2003-08-26 08:56:33.000000000 +0200
@@ -86,6 +86,7 @@
retval =3D result->conn->driver->functions->goto_row(result, row-1);
if (retval =3D=3D -1) {
_error_handler(result->conn, DBI_ERROR_DBD);
+ return -1;
}
retval =3D result->conn->driver->functions->fetch_row(result, row-1=
);
if (retval =3D=3D 0) {
Take it easy,
Christian
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE/SwZYj1ZSAMHYBOkRAp3AAKCpKstob/rPu80wPnkQ6AvV2myC9wCg79XC
OM7WGOh7CtjP/1cKpWOIlsE=3D
=3Dg9dh
=2D----END PGP SIGNATURE-----
|