Bug #47820 storage/ndb/test/src/SqlClient.cpp doesn't compile on windows
Submitted: 5 Oct 2009 5:27 Modified: 7 Oct 2009 6:08
Reporter: jack andrews Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Tests: Cluster Severity:S3 (Non-critical)
Version:mysql-5.1-telco-7.0 OS:Windows
Assigned to: jack andrews CPU Architecture:Any

[5 Oct 2009 5:27] jack andrews
Description:
in source file:

   uint params= mysql_stmt_param_count(stmt);
   MYSQL_BIND bind_param[params];

params is not constant, so VC++ won't create the array

How to repeat:
.

Suggested fix:
===================================================================
--- atrt47466.orig/storage/ndb/test/src/SqlClient.cpp	2009-10-05 13:46:53.000000000 +1100
+++ atrt47466/storage/ndb/test/src/SqlClient.cpp	2009-10-05 15:14:34.363000000 +1100
@@ -172,7 +172,8 @@
   }
 
   uint params= mysql_stmt_param_count(stmt);
-  MYSQL_BIND bind_param[params];
+  MYSQL_BIND *bind_param;
+  malloc(sizeof(MYSQL_BIND) * params);
   bzero(bind_param, sizeof(bind_param));
 
   for(uint i= 0; i < mysql_stmt_param_count(stmt); i++)
@@ -242,7 +243,8 @@
   {
     MYSQL_FIELD *fields= mysql_fetch_fields(res);
     uint num_fields= mysql_num_fields(res);
-    MYSQL_BIND bind_result[num_fields];
+    MYSQL_BIND *bind_result;
+    malloc(sizeof(MYSQL_BIND) * num_fields);
     bzero(bind_result, sizeof(bind_result));
 
     for (uint i= 0; i < num_fields; i++)

--
[5 Oct 2009 5:34] jack andrews
here's the patch.  it uses alloca to create the array on 
the stack, just like the original code did:

Index: atrt47466/storage/ndb/test/src/SqlClient.cpp
===================================================================
--- atrt47466.orig/storage/ndb/test/src/SqlClient.cpp   2009-10-05 13:46:53.000000000 +1100
+++ atrt47466/storage/ndb/test/src/SqlClient.cpp        2009-10-05 16:31:34.744000000 +1100
@@ -172,7 +172,7 @@
   }

   uint params= mysql_stmt_param_count(stmt);
-  MYSQL_BIND bind_param[params];
+  MYSQL_BIND *bind_param= (MYSQL_BIND *)alloca(sizeof(MYSQL_BIND) * params);
   bzero(bind_param, sizeof(bind_param));

   for(uint i= 0; i < mysql_stmt_param_count(stmt); i++)
@@ -242,7 +242,7 @@
   {
     MYSQL_FIELD *fields= mysql_fetch_fields(res);
     uint num_fields= mysql_num_fields(res);
-    MYSQL_BIND bind_result[num_fields];
+    MYSQL_BIND *bind_result= (MYSQL_BIND *)alloca(sizeof(MYSQL_BIND) * num_fields);
     bzero(bind_result, sizeof(bind_result));

     for (uint i= 0; i < num_fields; i++)
[7 Oct 2009 6:08] jack andrews
sqlclient.cpp is not included in Makefile.am and so is not needed in CMakeLists.txt.

removing sqlclient.cpp fixed the problem