List:Commits« Previous MessageNext Message »
From:jwinstead Date:May 3 2007 7:29pm
Subject:Connector/ODBC 3.51 commit: r399 - in trunk: . driver
View as plain text  
Modified:
   trunk/ChangeLog
   trunk/driver/cursor.c
   trunk/driver/handle.c
   trunk/driver/myodbc3.h
   trunk/driver/results.c
Log:
The row status array given to SQLExtendedFetch() was being stored as
SQL_ATTR_ROW_STATUS_PTR, which could cause it to be used when it should not.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-05-03 18:17:17 UTC (rev 398)
+++ trunk/ChangeLog	2007-05-03 19:29:24 UTC (rev 399)
@@ -3,6 +3,9 @@
   Functionality added or changed:
 
   Bugs fixed:
+  * The row status array given to SQLExtendedFetch() was being stored
+    as SQL_ATTR_ROW_STATUS_PTR, which could cause it to be used when it
+    should not.
   * SQLSetPos() would not update a row unless all columns were bound,
     but it should only require that at least one column is bound and
     not set to be ignored.

Modified: trunk/driver/cursor.c
===================================================================
--- trunk/driver/cursor.c	2007-05-03 18:17:17 UTC (rev 398)
+++ trunk/driver/cursor.c	2007-05-03 19:29:24 UTC (rev 399)
@@ -297,6 +297,11 @@
     else if ( stmt->affected_rows > 1 )
         return set_error(stmt,MYERR_01S04,NULL,0);
 
+    /*
+      This conly comes from SQLExecute(), not SQLSetPos() or
+      SQLBulkOperations(), so we don't have to worry about the row status
+      set by SQLExtendedFetch().
+    */
     else if ( stmt->stmt_options.rowStatusPtr )
     {
         SQLUSMALLINT *ptr= stmt->stmt_options.rowStatusPtr+stmt->current_row;
@@ -317,24 +322,34 @@
 static SQLRETURN update_setpos_status(STMT FAR *stmt, SQLINTEGER irow,
                                       my_ulonglong rows, SQLUSMALLINT status)
 {
-    stmt->affected_rows= stmt->dbc->mysql.affected_rows= rows;
+  stmt->affected_rows= stmt->dbc->mysql.affected_rows= rows;
 
-    if ( irow && rows > 1 )
-        return set_error(stmt,MYERR_01S04,NULL,0);
+  if (irow && rows > 1)
+      return set_error(stmt,MYERR_01S04,NULL,0);
 
-    /*
-      If all rows successful, then only update status..else
-      don't update...just for the sake of performance..
-    */
-    else if ( stmt->stmt_options.rowStatusPtr )
-    {
-        SQLUSMALLINT *ptr= stmt->stmt_options.rowStatusPtr;
-        SQLUSMALLINT *end= ptr+rows;
+  /*
+    If all rows successful, then only update status..else
+    don't update...just for the sake of performance..
+  */
+  if (stmt->stmt_options.rowStatusPtr)
+  {
+    SQLUSMALLINT *ptr= stmt->stmt_options.rowStatusPtr;
+    SQLUSMALLINT *end= ptr+rows;
 
-        for ( ; ptr != end ; ptr++ )
-            *ptr= status;
-    }
-    return SQL_SUCCESS;
+    for ( ; ptr != end; ptr++)
+        *ptr= status;
+  }
+
+  if (stmt->stmt_options.rowStatusPtr_ex)
+  {
+    SQLUSMALLINT *ptr= stmt->stmt_options.rowStatusPtr_ex;
+    SQLUSMALLINT *end= ptr+rows;
+
+    for ( ; ptr != end; ptr++)
+        *ptr= status;
+  }
+
+  return SQL_SUCCESS;
 }
 
 
@@ -1245,11 +1260,16 @@
     stmt->affected_rows= stmt->dbc->mysql.affected_rows= insert_count;
 
     /* update row status pointer(s) */
-    if ( stmt->stmt_options.rowStatusPtr )
+    if (stmt->stmt_options.rowStatusPtr)
     {
-        for ( count= insert_count; count--; )
-            stmt->stmt_options.rowStatusPtr[count]= SQL_ROW_ADDED;
+      for (count= insert_count; count--; )
+        stmt->stmt_options.rowStatusPtr[count]= SQL_ROW_ADDED;
     }
+    if (stmt->stmt_options.rowStatusPtr_ex)
+    {
+      for (count= insert_count; count--; )
+        stmt->stmt_options.rowStatusPtr_ex[count]= SQL_ROW_ADDED;
+    }
 
     return SQL_SUCCESS;
 }
@@ -1415,6 +1435,8 @@
                 */
                 sqlRet= my_SQLExtendedFetch(hstmt, SQL_FETCH_ABSOLUTE, irow,
                                             stmt->stmt_options.rowsFetchedPtr,
+                                            stmt->stmt_options.rowStatusPtr_ex ?
+                                            stmt->stmt_options.rowStatusPtr_ex :
                                             stmt->stmt_options.rowStatusPtr, 0);
                 break;
             }

Modified: trunk/driver/handle.c
===================================================================
--- trunk/driver/handle.c	2007-05-03 18:17:17 UTC (rev 398)
+++ trunk/driver/handle.c	2007-05-03 19:29:24 UTC (rev 399)
@@ -378,6 +378,7 @@
     reset_ptr(options->rowOperationPtr);
     reset_ptr(options->rowsFetchedPtr);
     reset_ptr(options->rowStatusPtr);
+    reset_ptr(options->rowStatusPtr_ex);
 }
 
 /*

Modified: trunk/driver/myodbc3.h
===================================================================
--- trunk/driver/myodbc3.h	2007-05-03 18:17:17 UTC (rev 398)
+++ trunk/driver/myodbc3.h	2007-05-03 19:29:24 UTC (rev 399)
@@ -179,6 +179,7 @@
                   *bind_offset;
   SQLUSMALLINT	  *paramStatusPtr;
   SQLUSMALLINT	  *rowStatusPtr;
+  SQLUSMALLINT	  *rowStatusPtr_ex; /* set by SQLExtendedFetch */
   SQLUSMALLINT	  *rowOperationPtr;
   my_bool	   retrieve_data;
 } STMT_OPTIONS;

Modified: trunk/driver/results.c
===================================================================
--- trunk/driver/results.c	2007-05-03 18:17:17 UTC (rev 398)
+++ trunk/driver/results.c	2007-05-03 19:29:24 UTC (rev 399)
@@ -1419,13 +1419,16 @@
                 stmt->result_lengths= mysql_fetch_lengths(stmt->result);
             stmt->current_values= values;
         }
-        if ( rgfRowStatus )
-            rgfRowStatus[i]= SQL_ROW_SUCCESS;
 
-        if ( upd_status && stmt->stmt_options.rowStatusPtr )
-            stmt->stmt_options.rowStatusPtr[i]= SQL_ROW_SUCCESS;
+        if (rgfRowStatus)
+          rgfRowStatus[i]= SQL_ROW_SUCCESS;
+        /*
+          No need to update rowStatusPtr_ex, it's the same as rgfRowStatus.
+        */
+        if (upd_status && stmt->stmt_options.rowStatusPtr)
+          stmt->stmt_options.rowStatusPtr[i]= SQL_ROW_SUCCESS;
 
-        if ( stmt->bind )             /* Should always be true */
+        if (stmt->bind)             /* Should always be true */
         {
             ulong *lengths= stmt->result_lengths;
             BIND *bind,*end;
@@ -1479,6 +1482,9 @@
         for ( ; i < stmt->stmt_options.rows_in_set ; i++ )
             rgfRowStatus[i]= SQL_ROW_NOROW;
 
+    /*
+      No need to update rowStatusPtr_ex, it's the same as rgfRowStatus.
+    */
     if ( upd_status && stmt->stmt_options.rowStatusPtr )
         for ( ; i < stmt->stmt_options.rows_in_set ; i++ )
             stmt->stmt_options.rowStatusPtr[i]= SQL_ROW_NOROW;
@@ -1520,8 +1526,7 @@
 
     MYODBCDbgEnter;
 
-    if (!options->rowStatusPtr && rgfRowStatus)
-      options->rowStatusPtr= rgfRowStatus;
+    options->rowStatusPtr_ex= rgfRowStatus;
 
     MYODBCDbgReturnReturn( my_SQLExtendedFetch( hstmt,
                                 fFetchType,
@@ -1548,6 +1553,8 @@
 
     MYODBCDbgEnter;
 
+    options->rowStatusPtr_ex= NULL;
+
     result= my_SQLExtendedFetch( StatementHandle, 
                                  FetchOrientation,
                                  FetchOffset,
@@ -1570,6 +1577,8 @@
 
     MYODBCDbgEnter;
 
+    options->rowStatusPtr_ex= NULL;
+
     result= my_SQLExtendedFetch(StatementHandle, SQL_FETCH_NEXT,
                                 0,
                                 options->rowsFetchedPtr,

Thread
Connector/ODBC 3.51 commit: r399 - in trunk: . driverjwinstead3 May