apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject svn commit: r657676 - in /apr/apr-util/branches/1.3.x: dbd/apr_dbd_mysql.c dbd/apr_dbd_pgsql.c include/apr_dbd.h
Date Sun, 18 May 2008 22:48:54 GMT
Author: bojan
Date: Sun May 18 15:48:54 2008
New Revision: 657676

URL: http://svn.apache.org/viewvc?rev=657676&view=rev
Log:
Backport r657516, r657528, r657530, r657641 and r657643 from the trunk.
Make sure PGSQL and MySQL drivers count rows from 1, not 0.

Modified:
    apr/apr-util/branches/1.3.x/dbd/apr_dbd_mysql.c
    apr/apr-util/branches/1.3.x/dbd/apr_dbd_pgsql.c
    apr/apr-util/branches/1.3.x/include/apr_dbd.h

Modified: apr/apr-util/branches/1.3.x/dbd/apr_dbd_mysql.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/dbd/apr_dbd_mysql.c?rev=657676&r1=657675&r2=657676&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/dbd/apr_dbd_mysql.c (original)
+++ apr/apr-util/branches/1.3.x/dbd/apr_dbd_mysql.c Sun May 18 15:48:54 2008
@@ -268,8 +268,8 @@
 
     if (res->statement) {
         if (res->random) {
-            if (rownum >= 0) {
-                mysql_stmt_data_seek(res->statement, (my_ulonglong)rownum);
+            if (rownum > 0) {
+                mysql_stmt_data_seek(res->statement, (my_ulonglong) --rownum);
             }
         }
         ret = mysql_stmt_fetch(res->statement);
@@ -287,8 +287,8 @@
     }
     else {
         if (res->random) {
-            if (rownum >= 0) {
-                mysql_data_seek(res->res, (my_ulonglong) rownum);
+            if (rownum > 0) {
+                mysql_data_seek(res->res, (my_ulonglong) --rownum);
             }
         }
         r = mysql_fetch_row(res->res);

Modified: apr/apr-util/branches/1.3.x/dbd/apr_dbd_pgsql.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/dbd/apr_dbd_pgsql.c?rev=657676&r1=657675&r2=657676&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/dbd/apr_dbd_pgsql.c (original)
+++ apr/apr-util/branches/1.3.x/dbd/apr_dbd_pgsql.c Sun May 18 15:48:54 2008
@@ -231,14 +231,23 @@
         row = apr_palloc(pool, sizeof(apr_dbd_row_t));
         *rowp = row;
         row->res = res;
-        row->n = sequential ? 0 : rownum;
+        if ( sequential ) {
+            row->n = 0;
+        }
+        else {
+            if (rownum > 0) {
+                row->n = --rownum;
+            }
+        }
     }
     else {
         if ( sequential ) {
             ++row->n;
         }
         else {
-            row->n = rownum;
+            if (rownum > 0) {
+                row->n = --rownum;
+            }
         }
     }
 

Modified: apr/apr-util/branches/1.3.x/include/apr_dbd.h
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/include/apr_dbd.h?rev=657676&r1=657675&r2=657676&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/include/apr_dbd.h (original)
+++ apr/apr-util/branches/1.3.x/include/apr_dbd.h Sun May 18 15:48:54 2008
@@ -314,8 +314,8 @@
  *  @param pool - pool to allocate the row
  *  @param res - result set pointer
  *  @param row - pointer to row pointer.  May point to NULL on entry
- *  @param rownum - row number, or -1 for "next row".  Ignored if random
- *                  access is not supported.
+ *  @param rownum - row number (counting from 1), or -1 for "next row".
+ *                  Ignored if random access is not supported.
  *  @return 0 for success, -1 for rownum out of range or data finished
  */
 APU_DECLARE(int) apr_dbd_get_row(const apr_dbd_driver_t *driver, apr_pool_t *pool,



Mime
View raw message