You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by bo...@apache.org on 2008/05/18 10:54:09 UTC
svn commit: r657516 - in /apr/apr-util/trunk/dbd: apr_dbd_mysql.c
apr_dbd_pgsql.c
Author: bojan
Date: Sun May 18 01:54:09 2008
New Revision: 657516
URL: http://svn.apache.org/viewvc?rev=657516&view=rev
Log:
Make sure PGSQL and MySQL drivers count rows from 1, not 0
Modified:
apr/apr-util/trunk/dbd/apr_dbd_mysql.c
apr/apr-util/trunk/dbd/apr_dbd_pgsql.c
Modified: apr/apr-util/trunk/dbd/apr_dbd_mysql.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbd/apr_dbd_mysql.c?rev=657516&r1=657515&r2=657516&view=diff
==============================================================================
--- apr/apr-util/trunk/dbd/apr_dbd_mysql.c (original)
+++ apr/apr-util/trunk/dbd/apr_dbd_mysql.c Sun May 18 01:54:09 2008
@@ -269,7 +269,7 @@
if (res->statement) {
if (res->random) {
if (rownum >= 0) {
- mysql_stmt_data_seek(res->statement, (my_ulonglong)rownum);
+ mysql_stmt_data_seek(res->statement, (my_ulonglong) --rownum);
}
}
ret = mysql_stmt_fetch(res->statement);
@@ -288,7 +288,7 @@
else {
if (res->random) {
if (rownum >= 0) {
- mysql_data_seek(res->res, (my_ulonglong) rownum);
+ mysql_data_seek(res->res, (my_ulonglong) --rownum);
}
}
r = mysql_fetch_row(res->res);
Modified: apr/apr-util/trunk/dbd/apr_dbd_pgsql.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbd/apr_dbd_pgsql.c?rev=657516&r1=657515&r2=657516&view=diff
==============================================================================
--- apr/apr-util/trunk/dbd/apr_dbd_pgsql.c (original)
+++ apr/apr-util/trunk/dbd/apr_dbd_pgsql.c Sun May 18 01:54:09 2008
@@ -231,14 +231,14 @@
row = apr_palloc(pool, sizeof(apr_dbd_row_t));
*rowp = row;
row->res = res;
- row->n = sequential ? 0 : rownum;
+ row->n = sequential ? 0 : --rownum;
}
else {
if ( sequential ) {
++row->n;
}
else {
- row->n = rownum;
+ row->n = --rownum;
}
}
Re: svn commit: r657516 - in
/apr/apr-util/trunk/dbd: apr_dbd_mysql.c apr_dbd_pgsql.c
Posted by Bojan Smojver <bo...@rexursive.com>.
On Sun, 2008-05-18 at 12:02 +0200, Ruediger Pluem wrote:
> Maybe we should return a driver independent error code in the case that the
> row number is < 1. A MySQL specific error code might be somewhat confusing
> to the user as it might tell him that he used -1 as a row number.
> BTW: As far as I see the old behaviour was not to seek at all if the row number
> was < 0. Was this intended?
I think so.
BTW, I think we'll have to do > 0 as you suggested because we cast into
(my_ulonglong), which if it gets value of -1 may become a really, really
big number thus potentially screwing a lot of things and giving
meaningless error messages back.
Anyhow, I'll do the > 0 now.
--
Bojan
Re: svn commit: r657516 - in /apr/apr-util/trunk/dbd: apr_dbd_mysql.c
apr_dbd_pgsql.c
Posted by Ruediger Pluem <rp...@apache.org>.
On 05/18/2008 11:39 AM, Bojan Smojver wrote:
> On Sun, 2008-05-18 at 11:24 +0200, Ruediger Pluem wrote:
>
>> I guess this should now be > 0?
>
> Depends, really. If we want things to break when users pass in 0, then
> it should be the way it is, provided MySQL returns an error when row it
> is given is -1. If we just want to not seek at all, then yes - we should
> make it > 0.
>
> Given that we're changing the semantics here, we just need to pick one.
> I'm cool either way.
>
Maybe we should return a driver independent error code in the case that the
row number is < 1. A MySQL specific error code might be somewhat confusing
to the user as it might tell him that he used -1 as a row number.
BTW: As far as I see the old behaviour was not to seek at all if the row number
was < 0. Was this intended?
Regards
RĂ¼diger
Re: svn commit: r657516 - in /apr/apr-util/trunk/dbd:
apr_dbd_mysql.c apr_dbd_pgsql.c
Posted by Bojan Smojver <bo...@rexursive.com>.
On Sun, 2008-05-18 at 11:24 +0200, Ruediger Pluem wrote:
> I guess this should now be > 0?
Depends, really. If we want things to break when users pass in 0, then
it should be the way it is, provided MySQL returns an error when row it
is given is -1. If we just want to not seek at all, then yes - we should
make it > 0.
Given that we're changing the semantics here, we just need to pick one.
I'm cool either way.
--
Bojan
Re: svn commit: r657516 - in /apr/apr-util/trunk/dbd: apr_dbd_mysql.c
apr_dbd_pgsql.c
Posted by Ruediger Pluem <rp...@apache.org>.
On 05/18/2008 10:54 AM, bojan@apache.org wrote:
> Author: bojan
> Date: Sun May 18 01:54:09 2008
> New Revision: 657516
>
> URL: http://svn.apache.org/viewvc?rev=657516&view=rev
> Log:
> Make sure PGSQL and MySQL drivers count rows from 1, not 0
>
> Modified:
> apr/apr-util/trunk/dbd/apr_dbd_mysql.c
> apr/apr-util/trunk/dbd/apr_dbd_pgsql.c
>
> Modified: apr/apr-util/trunk/dbd/apr_dbd_mysql.c
> URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbd/apr_dbd_mysql.c?rev=657516&r1=657515&r2=657516&view=diff
> ==============================================================================
> --- apr/apr-util/trunk/dbd/apr_dbd_mysql.c (original)
> +++ apr/apr-util/trunk/dbd/apr_dbd_mysql.c Sun May 18 01:54:09 2008
> @@ -269,7 +269,7 @@
> if (res->statement) {
> if (res->random) {
> if (rownum >= 0) {
I guess this should now be > 0?
> - mysql_stmt_data_seek(res->statement, (my_ulonglong)rownum);
> + mysql_stmt_data_seek(res->statement, (my_ulonglong) --rownum);
> }
> }
> ret = mysql_stmt_fetch(res->statement);
> @@ -288,7 +288,7 @@
> else {
> if (res->random) {
> if (rownum >= 0) {
Same as above.
> - mysql_data_seek(res->res, (my_ulonglong) rownum);
> + mysql_data_seek(res->res, (my_ulonglong) --rownum);
> }
> }
> r = mysql_fetch_row(res->res);
Regards
RĂ¼diger