List:Commits« Previous MessageNext Message »
From:jbalint Date:July 30 2007 7:37pm
Subject:Connector/ODBC 3.51 commit: r614 - in trunk: . driver test
View as plain text  
Modified:
   trunk/ChangeLog
   trunk/driver/options.c
   trunk/driver/results.c
   trunk/test/my_cursor.c
Log:
fix for bug#6741, add support for SQL_ATTR_ROW_BIND_OFFSET_PTR for normal cursors


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-07-30 18:58:08 UTC (rev 613)
+++ trunk/ChangeLog	2007-07-30 19:37:04 UTC (rev 614)
@@ -24,6 +24,8 @@
   * Tables from the mysql database (catalog) were listed as SYSTEM TABLES
     by SQLTables() even when a different catalog was being queried. This
     also introduced errors due to the fix for Bug #26934.  (Bug #28662)
+  * Added support for SQL_ATTR_ROW_BIND_OFFSET_PTR in normal cursors.
+    (Bug #6741)
 
 ----
 

Modified: trunk/driver/options.c
===================================================================
--- trunk/driver/options.c	2007-07-30 18:58:08 UTC (rev 613)
+++ trunk/driver/options.c	2007-07-30 19:37:04 UTC (rev 614)
@@ -134,7 +134,7 @@
             break;
 
         case SQL_ATTR_ROW_BIND_OFFSET_PTR:
-            options->bind_offset= (SQLINTEGER *)ValuePtr;
+            options->bind_offset= (SQLLEN *)ValuePtr;
             break;
 
         case 1226:/* MS SQL Server Extension */
@@ -233,9 +233,7 @@
             break;
 
         case SQL_ATTR_ROW_BIND_OFFSET_PTR:
-            *((SQLINTEGER *) ValuePtr)= options->bind_offset ?
-                                        *(options->bind_offset):
-                                        0;
+            *((SQLLEN *) ValuePtr)= options->bind_offset;
             break;
 
         case SQL_ATTR_ROW_OPERATION_PTR: /* need to support this ....*/

Modified: trunk/driver/results.c
===================================================================
--- trunk/driver/results.c	2007-07-30 18:58:08 UTC (rev 613)
+++ trunk/driver/results.c	2007-07-30 19:37:04 UTC (rev 614)
@@ -1372,8 +1372,9 @@
             {
                 if ( bind->rgbValue || bind->pcbValue )
                 {
-                    ulong offset,pcb_offset;
+                    SQLLEN offset,pcb_offset;
                     SQLLEN pcbValue;
+
                     if ( stmt->stmt_options.bind_type == SQL_BIND_BY_COLUMN )
                     {
                         offset= bind->cbValueMax*i;
@@ -1381,7 +1382,16 @@
                     }
                     else
                         pcb_offset= offset= stmt->stmt_options.bind_type*i;
+
+                    /* apply SQL_ATTR_ROW_BIND_OFFSET_PTR */
+                    if (stmt->stmt_options.bind_offset)
+                    {
+                      offset     += *stmt->stmt_options.bind_offset;
+                      pcb_offset += *stmt->stmt_options.bind_offset;
+                    }
+
                     stmt->getdata_offset= (ulong) ~0L;
+
                     if ( (tmp_res= sql_get_data( stmt,
                                                  bind->fCType,
                                                  bind->field,
@@ -1401,7 +1411,7 @@
                             res= SQL_ERROR;
                     }
                     if (bind->pcbValue)
-                      *(bind->pcbValue + pcb_offset) = pcbValue;
+                      *(bind->pcbValue + (pcb_offset / sizeof(SQLLEN))) = pcbValue;
                 }
                 if ( lengths )
                     lengths++;

Modified: trunk/test/my_cursor.c
===================================================================
--- trunk/test/my_cursor.c	2007-07-30 18:58:08 UTC (rev 613)
+++ trunk/test/my_cursor.c	2007-07-30 19:37:04 UTC (rev 614)
@@ -2486,6 +2486,62 @@
 }
 
 
+/*
+ * Bug 6741 - SQL_ATTR_ROW_BIND_OFFSET_PTR is not supported
+ * It was supported for use in some batch operations, but not
+ * standard cursor operations.
+ */
+DECLARE_TEST(bug6741)
+{
+  const int vals = 5;
+  int i;
+  SQLLEN offset;
+  struct {
+    SQLINTEGER xval;
+    SQLLEN ylen;
+  } results[vals];
+
+  ok_sql(hstmt, "drop table if exists t_bug6741");
+  ok_sql(hstmt, "create table t_bug6741 (x int, y int)");
+
+  ok_sql(hstmt, "insert into t_bug6741 values (0,0),(1,NULL),(2,2),(3,NULL),(4,4)");
+  ok_sql(hstmt, "select x,y from t_bug6741 order by x");
+
+  ok_stmt(hstmt, SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_BIND_OFFSET_PTR,
+          &offset, SQL_IS_UINTEGER));
+  ok_stmt(hstmt, SQLBindCol(hstmt, 1, SQL_C_LONG, &results[0].xval, 0, NULL));
+  ok_stmt(hstmt, SQLBindCol(hstmt, 2, SQL_C_LONG, NULL, 0, &results[0].ylen));
+
+  /* fetch all the data */
+  for(i = 0; i < vals; ++i)
+  {
+    offset = i * sizeof(results[0]);
+    ok_stmt(hstmt, SQLFetch(hstmt));
+  }
+  expect_stmt(hstmt, SQLFetch(hstmt), SQL_NO_DATA_FOUND);
+
+  /* verify it */
+  for(i = 0; i < vals; ++i)
+  {
+    printf("xval[%d] = %d\n", i, results[i].xval);
+    printf("ylen[%d] = %d\n", i, results[i].ylen);
+    is_num(results[i].xval, i);
+    if(i % 2)
+    {
+      is_num(results[i].ylen, SQL_NULL_DATA);
+    }
+    else
+    {
+      is_num(results[i].ylen, sizeof(SQLINTEGER));
+    }
+  }
+
+  ok_sql(hstmt, "drop table if exists t_bug6741");
+
+  return OK;
+}
+
+
 BEGIN_TESTS
   ADD_TEST(my_positioned_cursor)
   ADD_TEST(my_setpos_cursor)
@@ -2524,6 +2580,7 @@
   ADD_TEST(tmysql_pcbvalue)
   ADD_TEST(t_bug28255)
   ADD_TEST(bug10563)
+  ADD_TEST(bug6741)
 END_TESTS
 
 

Thread
Connector/ODBC 3.51 commit: r614 - in trunk: . driver testjbalint30 Jul