List:Commits« Previous MessageNext Message »
From:jwinstead Date:August 2 2007 9:49pm
Subject:Connector/ODBC 3.51 commit: r628 - in trunk: driver test test/include
View as plain text  
Modified:
   trunk/driver/catalog.c
   trunk/driver/myutil.h
   trunk/test/include/mytest3.h
   trunk/test/my_types.c
Log:
Fix testing of BIT type, and whether it is considered a numeric type when
it has more than one bit.


Modified: trunk/driver/catalog.c
===================================================================
--- trunk/driver/catalog.c	2007-08-02 17:04:03 UTC (rev 627)
+++ trunk/driver/catalog.c	2007-08-02 19:49:27 UTC (rev 628)
@@ -917,7 +917,7 @@
         else
         {
           char *def= alloc_root(alloc, strlen(field->def) + 3);
-          if (is_numeric_mysql_type(field->type))
+          if (is_numeric_mysql_type(field))
             sprintf(def, "%s", field->def);
           else
             sprintf(def, "'%s'", field->def);

Modified: trunk/driver/myutil.h
===================================================================
--- trunk/driver/myutil.h	2007-08-02 17:04:03 UTC (rev 627)
+++ trunk/driver/myutil.h	2007-08-02 19:49:27 UTC (rev 628)
@@ -125,10 +125,11 @@
   ((type) == SQL_BINARY || (type) == SQL_VARBINARY || \
    (type) == SQL_LONGVARBINARY)
 
-#define is_numeric_mysql_type(type) \
-  ((type) <= MYSQL_TYPE_NULL || (type) == MYSQL_TYPE_LONGLONG || \
-   (type) == MYSQL_TYPE_INT24 || (type) == MYSQL_TYPE_BIT || \
-   (type) == MYSQL_TYPE_NEWDECIMAL)
+#define is_numeric_mysql_type(field) \
+  ((field)->type <= MYSQL_TYPE_NULL || (field)->type == MYSQL_TYPE_LONGLONG || \
+   (field)->type == MYSQL_TYPE_INT24 || \
+   ((field)->type == MYSQL_TYPE_BIT && (field)->length == 1) || \
+   (field)->type == MYSQL_TYPE_NEWDECIMAL)
 
 SQLRETURN SQL_API my_SQLBindParameter(SQLHSTMT hstmt,SQLUSMALLINT ipar,
 				      SQLSMALLINT fParamType,

Modified: trunk/test/include/mytest3.h
===================================================================
--- trunk/test/include/mytest3.h	2007-08-02 17:04:03 UTC (rev 627)
+++ trunk/test/include/mytest3.h	2007-08-02 19:49:27 UTC (rev 628)
@@ -483,10 +483,11 @@
 SQLINTEGER my_fetch_int(SQLHSTMT hstmt, SQLUSMALLINT irow)
 {
     SQLINTEGER nData;
+    SQLLEN len;
 
-    SQLGetData(hstmt,irow,SQL_INTEGER,&nData,0,NULL);
-    printMessage(" my_fetch_int: %ld\n", (long int)nData);
-    return(nData);
+    SQLGetData(hstmt, irow, SQL_INTEGER, &nData, 0, &len);
+    printMessage(" my_fetch_int: %ld (%ld)\n", (long int)nData, len);
+    return (len != SQL_NULL_DATA) ? nData : 0;
 }
 /**
   return string data, by fetching it

Modified: trunk/test/my_types.c
===================================================================
--- trunk/test/my_types.c	2007-08-02 17:04:03 UTC (rev 627)
+++ trunk/test/my_types.c	2007-08-02 19:49:27 UTC (rev 628)
@@ -640,6 +640,7 @@
 {
   SQLCHAR col[10];
   SQLINTEGER type;
+  SQLLEN len;
 
   ok_sql(hstmt, "DROP TABLE IF EXISTS t_bit");
   ok_sql(hstmt, "CREATE TABLE t_bit (a BIT(1), b BIT(17))");
@@ -653,7 +654,8 @@
   is_num(my_fetch_int(hstmt, 5), SQL_BIT); /* DATA_TYPE */
   is_num(my_fetch_int(hstmt, 7), 1); /* COLUMN_SIZE */
   is_num(my_fetch_int(hstmt, 8), 1); /* BUFFER_LENGTH */
-  is_num(my_fetch_int(hstmt, 16), 1); /* CHAR_OCTET_LENGTH */
+  ok_stmt(hstmt, SQLGetData(hstmt, 16, SQL_C_LONG, &type, 0, &len));
+  is_num(len, SQL_NULL_DATA); /* CHAR_OCTET_LENGTH */
 
   ok_stmt(hstmt, SQLFetch(hstmt));
 

Thread
Connector/ODBC 3.51 commit: r628 - in trunk: driver test test/includejwinstead2 Aug