List:Commits« Previous MessageNext Message »
From:jwinstead Date:May 21 2007 5:29pm
Subject:Connector/ODBC 3.51 commit: r429 - in trunk: . driver test
View as plain text  
Modified:
   trunk/ChangeLog
   trunk/driver/execute.c
   trunk/test/my_types.c
Log:
SQL_WVARCHAR and SQL_WLONGVARCHAR parameters were not properly quoted
and escaped. (Bug #16235)


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-05-18 17:07:33 UTC (rev 428)
+++ trunk/ChangeLog	2007-05-21 17:29:03 UTC (rev 429)
@@ -3,6 +3,8 @@
   Functionality added or changed:
 
   Bugs fixed:
+  * SQL_WVARCHAR and SQL_WLONGVARCHAR parameters were not properly quoted
+    and escaped. (Bug #16235)
   * SQLForeignKeys() did not properly escape wildcard characters in its
     table name parameters when retrieving information. (Bug #27723)
   * Calls to SQLSetPos() could cause the driver to incorrectly calculate the

Modified: trunk/driver/execute.c
===================================================================
--- trunk/driver/execute.c	2007-05-18 17:07:33 UTC (rev 428)
+++ trunk/driver/execute.c	2007-05-21 17:29:03 UTC (rev 429)
@@ -485,6 +485,8 @@
         case SQL_VARBINARY:
         case SQL_LONGVARBINARY:
         case SQL_WCHAR:
+        case SQL_WVARCHAR:
+        case SQL_WLONGVARCHAR:
             {
                 to= add_to_buffer(net,to,"'",1);
                 to= mysql_odbc_escape_string(mysql,

Modified: trunk/test/my_types.c
===================================================================
--- trunk/test/my_types.c	2007-05-18 17:07:33 UTC (rev 428)
+++ trunk/test/my_types.c	2007-05-21 17:29:03 UTC (rev 429)
@@ -440,6 +440,49 @@
 }
 
 
+/**
+ Bug #16235: ODBC driver doesn't format parameters correctly
+*/
+DECLARE_TEST(t_bug16235)
+{
+  SQLCHAR varchar[]= "a'b", text[]= "c'd", buff[10];
+  SQLLEN varchar_len= SQL_NTS, text_len= SQL_NTS;
+
+  ok_sql(hstmt, "DROP TABLE IF EXISTS t_bug16235");
+  ok_sql(hstmt, "CREATE TABLE t_bug16235 (a NVARCHAR(20), b TEXT)");
+
+  ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE));
+
+  ok_stmt(hstmt, SQLPrepare(hstmt, (SQLCHAR *)
+                            "INSERT INTO t_bug16235 VALUES (?,?)", SQL_NTS));
+  ok_stmt(hstmt, SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR,
+                                  SQL_WVARCHAR, 0, 0, varchar, sizeof(varchar),
+                                  &varchar_len));
+  ok_stmt(hstmt, SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR,
+                                  SQL_WLONGVARCHAR, 0, 0, text, sizeof(text),
+                                  &text_len));
+
+  ok_stmt(hstmt, SQLExecute(hstmt));
+
+  ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_UNBIND));
+  ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE));
+
+  ok_sql(hstmt, "SELECT * FROM t_bug16235");
+
+  ok_stmt(hstmt, SQLFetch(hstmt));
+  is_str(my_fetch_str(hstmt, buff, 1), "a'b", 3);
+  is_str(my_fetch_str(hstmt, buff, 2), "c'd", 3);
+
+  expect_stmt(hstmt, SQLFetch(hstmt), SQL_NO_DATA_FOUND);
+
+  ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE));
+
+  ok_sql(hstmt, "DROP TABLE IF EXISTS t_bug16235");
+
+  return OK;
+}
+
+
 BEGIN_TESTS
   ADD_TEST(t_longlong1)
   ADD_TEST(t_numeric)
@@ -447,6 +490,7 @@
   ADD_TEST(t_bigint)
   ADD_TEST(t_enumset)
   ADD_TEST(t_bug16917)
+  ADD_TEST(t_bug16235)
 END_TESTS
 
 

Thread
Connector/ODBC 3.51 commit: r429 - in trunk: . driver testjwinstead21 May