List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:July 27 2009 3:31pm
Subject:bzr commit into mysql-5.0-bugteam branch (davi:2790) Bug#20023
View as plain text  
# At a local mysql-5.0-bugteam repository of davi

 2790 Davi Arnaut	2009-07-27
      Bug#20023: mysql_change_user() resets the value of SQL_BIG_SELECTS
      
      Post-merge fix: test case could fail due to a conversion of the
      max_join_size value to a integer. Fixed by preserving the value
      as a string for comparison purposes.
     @ tests/mysql_client_test.c
        Preserve max_join_size value as a string instead of converting
        it to a integer -- value can be larger then the type used.

    modified:
      tests/mysql_client_test.c
=== modified file 'tests/mysql_client_test.c'
--- a/tests/mysql_client_test.c	2009-07-16 12:37:38 +0000
+++ b/tests/mysql_client_test.c	2009-07-27 15:31:28 +0000
@@ -16270,33 +16270,46 @@ static void bug20023_change_user(MYSQL *
                            opt_db ? opt_db : "test"));
 }
 
-static void bug20023_query_int_variable(MYSQL *con,
+static void bug20023_query_str_variable(MYSQL *con,
                                         const char *var_name,
-                                        int *var_value)
+                                        char *str,
+                                        size_t len)
 {
   MYSQL_RES *rs;
   MYSQL_ROW row;
 
   char query_buffer[MAX_TEST_QUERY_LENGTH];
 
-  my_snprintf(query_buffer,
-          sizeof (query_buffer),
-          "SELECT @@%s",
-          (const char *) var_name);
+  my_snprintf(query_buffer, sizeof (query_buffer),
+              "SELECT @@%s", var_name);
 
   DIE_IF(mysql_query(con, query_buffer));
   DIE_UNLESS(rs= mysql_store_result(con));
   DIE_UNLESS(row= mysql_fetch_row(rs));
-  *var_value= atoi(row[0]);
+  my_snprintf(str, len, "%s", row[0]);
   mysql_free_result(rs);
 }
 
+static void bug20023_query_int_variable(MYSQL *con,
+                                        const char *var_name,
+                                        int *var_value)
+{
+  char str[32];
+  bug20023_query_str_variable(con, var_name, str, sizeof(str));
+  *var_value= atoi(str);
+}
+
 static void test_bug20023()
 {
   MYSQL con;
 
   int sql_big_selects_orig;
-  int max_join_size_orig;
+  /*
+    Type of max_join_size is ha_rows, which might be ulong or off_t
+    depending on the platform or configure options. Preserve the string
+    to avoid type overflow pitfalls.
+  */
+  char max_join_size_orig[32];
 
   int sql_big_selects_2;
   int sql_big_selects_3;
@@ -16326,9 +16339,10 @@ static void test_bug20023()
                               "session.sql_big_selects",
                               &sql_big_selects_orig);
 
-  bug20023_query_int_variable(&con,
+  bug20023_query_str_variable(&con,
                               "global.max_join_size",
-                              &max_join_size_orig);
+                              max_join_size_orig,
+                              sizeof(max_join_size_orig));
 
   /***********************************************************************
    Test that COM_CHANGE_USER resets the SQL_BIG_SELECTS to the initial value.
@@ -16405,8 +16419,8 @@ static void test_bug20023()
 
   my_snprintf(query_buffer,
            sizeof (query_buffer),
-           "SET @@global.max_join_size = %d",
-           (int) max_join_size_orig);
+           "SET @@global.max_join_size = %s",
+           max_join_size_orig);
 
   DIE_IF(mysql_query(&con, query_buffer));
   DIE_IF(mysql_query(&con, "SET @@session.max_join_size = default"));


Attachment: [text/bzr-bundle] bzr/davi.arnaut@sun.com-20090727153128-crryyur2zp86a82m.bundle
Thread
bzr commit into mysql-5.0-bugteam branch (davi:2790) Bug#20023Davi Arnaut27 Jul