Date: Friday, October 20, 2006 @ 14:54:58
  Author: csaba
    Path: /cvsroot/carob/libmysequoia

Modified: src/CarobStmt.cpp (1.39 -> 1.40) test/TestMySQLAPI.cpp (1.41 ->
          1.42) test/TestMySQLAPI.hpp (1.17 -> 1.18)

Fill the is_null field in in mysql_stmt_fetch(). Fixes for LMS-27


-----------------------+
 src/CarobStmt.cpp     |    2 ++
 test/TestMySQLAPI.cpp |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 test/TestMySQLAPI.hpp |    2 ++
 3 files changed, 50 insertions(+)


Index: libmysequoia/src/CarobStmt.cpp
diff -u libmysequoia/src/CarobStmt.cpp:1.39 libmysequoia/src/CarobStmt.cpp:1.40
--- libmysequoia/src/CarobStmt.cpp:1.39 Fri Aug  4 15:49:56 2006
+++ libmysequoia/src/CarobStmt.cpp      Fri Oct 20 14:54:57 2006
@@ -760,6 +760,7 @@
   }
   else
   {
+    *bPtr->is_null = false;
     switch (fPtr->type)
     {
       case MYSQL_TYPE_TINY:
@@ -806,6 +807,7 @@
         getFromDateTime(bPtr, fPtr, buffer);
         break;
       case MYSQL_TYPE_NULL:
+        *bPtr->is_null = true;
         break;
       default:
         LOG4CXX_FATAL(logger, "This should never happen!!");
Index: libmysequoia/test/TestMySQLAPI.cpp
diff -u libmysequoia/test/TestMySQLAPI.cpp:1.41 
libmysequoia/test/TestMySQLAPI.cpp:1.42
--- libmysequoia/test/TestMySQLAPI.cpp:1.41     Wed Oct 18 16:23:41 2006
+++ libmysequoia/test/TestMySQLAPI.cpp  Fri Oct 20 14:54:57 2006
@@ -981,3 +981,49 @@
   CPPUNIT_ASSERT(mysql_real_connect(mysql, HOST, USER1, PASSWD1, DB1, 0, 0, 0) 
!= 0);
   CPPUNIT_ASSERT(mysql_real_escape_string(mysql, 0, 0, 0) == 0);
 }
+
+void TestMySQLAPI::bug_lms_27_test(void)
+{
+  MYSQL_STMT *stmt;
+  MYSQL_BIND outbind[2];
+  my_bool isnull_i = true;
+  my_bool isnull_j = false;
+  int i, j;
+  char *query = "select i,j from t1";
+
+  CPPUNIT_ASSERT(mysql_real_connect(mysql, HOST, USER1, PASSWD1, DB1, 0, 0, 0) 
!= 0);
+  mysql_query(mysql, "drop table t1");
+  CPPUNIT_ASSERT(mysql_query(mysql, "create table t1 (i int, j int)") == 0);
+  CPPUNIT_ASSERT(mysql_query(mysql, "insert into t1 (i) values (0),(1),(2)") 
== 0);
+
+  CPPUNIT_ASSERT((stmt = mysql_stmt_init(mysql)) != 0);
+  CPPUNIT_ASSERT(mysql_stmt_prepare(stmt, query, strlen(query)) == 0);
+  CPPUNIT_ASSERT(mysql_stmt_param_count(stmt) == 0);
+  
+  CPPUNIT_ASSERT(mysql_stmt_execute(stmt) == 0);
+  CPPUNIT_ASSERT(mysql_stmt_store_result(stmt) == 0);
+
+  memset(outbind, 0, sizeof(outbind));
+  outbind[0].buffer_type= MYSQL_TYPE_LONG;
+  outbind[0].buffer= (char *)&i;
+  outbind[0].is_null = &isnull_i;
+  outbind[1].buffer_type= MYSQL_TYPE_LONG;
+  outbind[1].buffer= (char *)&j;
+  outbind[1].is_null = &isnull_j;
+  CPPUNIT_ASSERT(mysql_stmt_bind_result(stmt, outbind) == 0);
+
+  CPPUNIT_ASSERT(mysql_stmt_fetch(stmt) == 0);
+  CPPUNIT_ASSERT(isnull_i == false);
+  CPPUNIT_ASSERT(isnull_j == true);
+  CPPUNIT_ASSERT(0 == i);
+  CPPUNIT_ASSERT(mysql_stmt_fetch(stmt) == 0);
+  CPPUNIT_ASSERT(isnull_i == false);
+  CPPUNIT_ASSERT(isnull_j == true);
+  CPPUNIT_ASSERT(1 == i);
+  CPPUNIT_ASSERT(mysql_stmt_fetch(stmt) == 0);
+  CPPUNIT_ASSERT(isnull_i == false);
+  CPPUNIT_ASSERT(isnull_j == true);
+  CPPUNIT_ASSERT(2 == i);
+
+  CPPUNIT_ASSERT(mysql_stmt_close(stmt) == 0); 
+}
Index: libmysequoia/test/TestMySQLAPI.hpp
diff -u libmysequoia/test/TestMySQLAPI.hpp:1.17 
libmysequoia/test/TestMySQLAPI.hpp:1.18
--- libmysequoia/test/TestMySQLAPI.hpp:1.17     Tue Oct  3 10:29:30 2006
+++ libmysequoia/test/TestMySQLAPI.hpp  Fri Oct 20 14:54:57 2006
@@ -64,6 +64,7 @@
     CPPUNIT_TEST (bug_lms_10_test);
     CPPUNIT_TEST (mysql_warning_count_test);
     CPPUNIT_TEST (bug_lms_24_test);
+    CPPUNIT_TEST (bug_lms_27_test);
   CPPUNIT_TEST_SUITE_END ();
 
 public:
@@ -105,6 +106,7 @@
   void bug_lms_10_test(void);
   void mysql_warning_count_test(void);
   void bug_lms_24_test(void);
+  void bug_lms_27_test(void);
 private:
   MYSQL *mysql;
 };

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to