List:Commits« Previous MessageNext Message »
From:Guilhem Bichot Date:May 2 2011 8:31am
Subject:[Resend] bzr commit into mysql-5.1 branch (guilhem.bichot:3673) Bug#11755168
View as plain text  
[This commit e-mail is a repeat.]

#At file:///home/mysql_src/bzrrepos_new/5.1-2/ based on
revid:guilhem.bichot@stripped

 3673 Guilhem Bichot	2011-05-02
      Fix for BUG#11755168 '46895: test "outfile_loaddata" fails (reproducible)'.
      In sql_class.cc, 'row_count', of type 'ha_rows', was used as last argument for
      ER_TRUNCATED_WRONG_VALUE_FOR_FIELD which is
      "Incorrect %-.32s value: '%-.128s' for column '%.192s' at row %ld".
      So 'ha_rows' was used as 'long'.
      On SPARC32 Solaris builds, 'long' is 4 bytes and 'ha_rows' is 'longlong' i.e. 8
bytes.
      So the printf-like code was reading only the first 4 bytes.
      Because the CPU is big-endian, 1LL is 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01
      so the first four bytes yield 0. So the warning message had "row 0" instead of
      "row 1" in test outfile_loaddata.test:
      -Warning	1366	Incorrect string value: '\xE1\xE2\xF7' for column 'b' at row 1
      +Warning	1366	Incorrect string value: '\xE1\xE2\xF7' for column 'b' at row 0
      
      All error-messaging functions which internally invoke some printf-life function
      are potential candidate for such mistakes.
      One apparently easy way to catch such mistakes is to use
      ATTRIBUTE_FORMAT (from my_attribute.h).
      But this works only when call site has both:
      a) the format as a string literal
      b) the types of arguments.
      So:
        func(ER(ER_BLAH), 10);
      will silently not be checked, because ER(ER_BLAH) is not known at
      compile time (it is known at run-time, and depends on the chosen
      language).
      And
        func("%s", a va_list argument);
      has the same problem, as the *real* type of arguments is not
      known at this site at compile time (it's known in some caller).
      Moreover,
        func(ER(ER_BLAH));
      though possibly correct (if ER(ER_BLAH) has no '%' markers), will not
      compile (gcc says "error: format not a string literal and no format
      arguments").
      
      Consequences:
      1) ATTRIBUTE_FORMAT is here added only to functions which in practice
      take "string literal" formats: "my_error_reporter" and "print_admin_msg".
      2) it cannot be added to the other functions: my_error(),
      push_warning_printf(), Table_check_intact::report_error(),
      general_log_print().
      
      To do a one-time check of functions listed in (2), the following
      "static code analysis" has been done:
      1) replace
        my_error(ER_xxx, arguments for substitution in format)
      with the equivalent
        my_printf_error(ER_xxx,ER(ER_xxx), arguments for substitution in
      format),
      so that we have ER(ER_xxx) and the arguments *in the same call site*
      2) add ATTRIBUTE_FORMAT to push_warning_printf(),
      Table_check_intact::report_error(), general_log_print()
      3) replace ER(xxx) with the hard-coded English text found in
      errmsg.txt (like: ER(ER_UNKNOWN_ERROR) is replaced with
      "Unknown error"), so that a call site has the format as string literal
      4) this way, ATTRIBUTE_FORMAT can effectively do its job
      5) compile, fix errors detected by ATTRIBUTE_FORMAT
      6) revert steps 1-2-3.
      The present patch has no compiler error when submitted again to the
      static code analysis above.
      It cannot catch all problems though: see Field::set_warning(), in
      which a call to push_warning_printf() has a variable error
      (thus, not replacable by a string literal); I checked set_warning() calls
      by hand though.
      
      See also WL 5883 for one proposal to avoid such bugs from appearing
      again in the future.
      
      The issues fixed in the patch are:
      a) mismatch in types (like 'int' passed to '%ld')
      b) more arguments passed than specified in the format.
      This patch resolves mismatches by changing the type/number of arguments,
      not by changing error messages of sql/share/errmsg.txt. The latter would be wrong,
      per the following old rule: errmsg.txt must be as stable as possible; no insertions
      or deletions of messages, no changes of type or number of printf-like format
specifiers,
      are allowed, as long as the change impacts a message already released in a GA
version.
      If this rule is not followed:
      - Connectors, which use error message numbers, will be confused (by
insertions/deletions
      of messages)
      - using errmsg.sys of MySQL 5.1.n with mysqld of MySQL 5.1.(n+1)
      could produce wrong messages or crash; such usage can easily happen if
      installing 5.1.(n+1) while /etc/my.cnf still has --language=/path/to/5.1.n/xxx;
      or if copying mysqld from 5.1.(n+1) into a 5.1.n installation.
      When fixing b), I have verified that the superfluous arguments were not used in the
format
      in the first 5.1 GA (5.1.30 'bteam@astra04-20081114162938-z8mctjp6st27uobm').
      Had they been used, then passing them today, even if the message doesn't use them
      anymore, would have been necessary, as explained above.
     @ include/my_getopt.h
        this function pointer is used only with "string literal" formats, so we can add
        ATTRIBUTE_FORMAT.
     @ mysql-test/collections/default.experimental
        test should pass now
     @ sql/derror.cc
        by having a format as string literal, ATTRIBUTE_FORMAT check becomes effective.
     @ sql/events.cc
        Change justified by the following excerpt from sql/share/errmsg.txt:
        ER_EVENT_SAME_NAME
                eng "Same old and new event name"
        ER_EVENT_SET_VAR_ERROR
                eng "Error during starting/stopping of the scheduler. Error code %u"
     @ sql/field.cc
        ER_TOO_BIG_SCALE 42000 S1009
                eng "Too big scale %d specified for column '%-.192s'. Maximum is %lu."
        ER_TOO_BIG_PRECISION 42000 S1009
                eng "Too big precision %d specified for column '%-.192s'. Maximum is %lu."
        ER_TOO_BIG_DISPLAYWIDTH 42000 S1009
                eng "Display width out of range for column '%-.192s' (max = %lu)"
     @ sql/ha_ndbcluster.cc
        ER_OUTOFMEMORY HY001 S1001
                eng "Out of memory; restart server and try again (needed %d bytes)"
        (sizeof() returns size_t)
     @ sql/ha_ndbcluster_binlog.cc
        Too many arguments for:
        ER_GET_ERRMSG  
                eng "Got error %d '%-.100s' from %s"
        Patch by Jonas Oreland.
     @ sql/ha_partition.cc
        print_admin_msg() is used only with a literal as format, so ATTRIBUTE_FORMAT
        works.
     @ sql/handler.cc
        ER_OUTOFMEMORY HY001 S1001
                eng "Out of memory; restart server and try again (needed %d bytes)"
        (sizeof() returns size_t)
     @ sql/item_create.cc
        ER_TOO_BIG_SCALE 42000 S1009
                eng "Too big scale %d specified for column '%-.192s'. Maximum is %lu."
        ER_TOO_BIG_PRECISION 42000 S1009
                eng "Too big precision %d specified for column '%-.192s'. Maximum is %lu."
        'c_len' and 'c_dec' are char*, passed as %d !! We don't know their value
        (as strtoul() failed), but they are likely big, so we use INT_MAX.
        'len' is ulong.
     @ sql/item_func.cc
        ER_WARN_DATA_OUT_OF_RANGE 22003 
                eng "Out of range value for column '%s' at row %ld"
        ER_CANT_FIND_UDF  
                eng "Can't load function '%-.192s'"
     @ sql/item_strfunc.cc
        ER_TOO_BIG_FOR_UNCOMPRESS  
                eng "Uncompressed data size too large; the maximum size is %d (probably,
length of uncompressed data was corrupted)"
        max_allowed_packet is ulong.
     @ sql/mysql_priv.h
        sql_print_message_func is a function _pointer_.
     @ sql/sp_head.cc
        ER_SP_RECURSION_LIMIT
                eng "Recursive limit %d (as set by the max_sp_recursion_depth variable)
was exceeded for routine %.192s"
        max_sp_recursion_depth is ulong
     @ sql/sql_acl.cc
        ER_PASSWORD_NO_MATCH 42000 
                eng "Can't find any matching row in the user table"
        ER_CANT_CREATE_USER_WITH_GRANT 42000
                eng "You are not allowed to create a user with GRANT"
     @ sql/sql_base.cc
        ER_NOT_KEYFILE  
                eng "Incorrect key file for table '%-.200s'; try to repair it"
        ER_TOO_MANY_TABLES  
                eng "Too many tables; MySQL can only use %d tables in a join"
        MAX_TABLES is size_t.
     @ sql/sql_binlog.cc
        ER_UNKNOWN_ERROR  
                eng "Unknown error"
     @ sql/sql_class.cc
        ER_TRUNCATED_WRONG_VALUE_FOR_FIELD  
                eng "Incorrect %-.32s value: '%-.128s' for column '%.192s' at row %ld"
        WARN_DATA_TRUNCATED 01000 
                eng "Data truncated for column '%s' at row %ld"
     @ sql/sql_connect.cc
        ER_HANDSHAKE_ERROR 08S01 
                eng "Bad handshake"
        ER_BAD_HOST_ERROR 08S01 
                eng "Can't get hostname for your address"
     @ sql/sql_insert.cc
        ER_WRONG_VALUE_COUNT_ON_ROW 21S01 
                eng "Column count doesn't match value count at row %ld"
     @ sql/sql_parse.cc
        ER_WARN_HOSTNAME_WONT_WORK  
                eng "MySQL is started in --skip-name-resolve mode; you must restart it
without this switch for this grant to work"
        ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT
        	eng "Too high level of nesting for select"
        ER_UNKNOWN_ERROR  
                eng "Unknown error"
     @ sql/sql_partition.cc
        ER_OUTOFMEMORY HY001 S1001
                eng "Out of memory; restart server and try again (needed %d bytes)"
     @ sql/sql_plugin.cc
        ER_OUTOFMEMORY HY001 S1001
                eng "Out of memory; restart server and try again (needed %d bytes)"
     @ sql/sql_prepare.cc
        ER_OUTOFMEMORY HY001 S1001
                eng "Out of memory; restart server and try again (needed %d bytes)"
        ER_UNKNOWN_STMT_HANDLER  
                eng "Unknown prepared statement handler (%.*s) given to %s"
        length value (for '%.*s') must be 'int', per the doc of printf()
        and the code of my_vsnprintf().
     @ sql/sql_show.cc
        ER_OUTOFMEMORY HY001 S1001
                eng "Out of memory; restart server and try again (needed %d bytes)"
     @ sql/sql_table.cc
        ER_TOO_BIG_FIELDLENGTH 42000 S1009
                eng "Column length too big for column '%-.192s' (max = %lu); use BLOB or
TEXT instead"
     @ sql/table.cc
        ER_NOT_FORM_FILE  
                eng "Incorrect information in file: '%-.200s'"
        ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE
                eng "Column count of mysql.%s is wrong. Expected %d, found %d. Created
with MySQL %d, now running %d. Please use mysql_upgrade to fix this error."
        table->s->mysql_version is ulong.
     @ sql/unireg.cc
        ER_TOO_LONG_TABLE_COMMENT
          eng "Comment for table '%-.64s' is too long (max = %lu)"
        ER_TOO_LONG_FIELD_COMMENT
          eng "Comment for field '%-.64s' is too long (max = %lu)"
        ER_TOO_BIG_ROWSIZE 42000 
                eng "Row size too large. The maximum row size for the used table type, not
counting BLOBs, is %ld. You have to change some columns to TEXT or BLOBs"

    modified:
      include/my_getopt.h
      mysql-test/collections/default.experimental
      sql/derror.cc
      sql/events.cc
      sql/field.cc
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster_binlog.cc
      sql/ha_partition.cc
      sql/handler.cc
      sql/item_create.cc
      sql/item_func.cc
      sql/item_strfunc.cc
      sql/mysql_priv.h
      sql/sp_head.cc
      sql/sql_acl.cc
      sql/sql_base.cc
      sql/sql_binlog.cc
      sql/sql_class.cc
      sql/sql_connect.cc
      sql/sql_insert.cc
      sql/sql_parse.cc
      sql/sql_partition.cc
      sql/sql_plugin.cc
      sql/sql_prepare.cc
      sql/sql_show.cc
      sql/sql_table.cc
      sql/table.cc
      sql/unireg.cc
=== modified file 'include/my_getopt.h'
--- a/include/my_getopt.h	2010-06-10 20:16:43 +0000
+++ b/include/my_getopt.h	2011-05-02 08:22:29 +0000
@@ -59,7 +59,9 @@ struct my_option
 };
 
 typedef my_bool (*my_get_one_option)(int, const struct my_option *, char *);
-typedef void (*my_error_reporter)(enum loglevel level, const char *format, ...);
+typedef void (*my_error_reporter)(enum loglevel level, const char *format, ...)
+  ATTRIBUTE_FORMAT_FPTR(printf, 2, 3);
+
 /**
   Used to retrieve a reference to the object (variable) that holds the value
   for the given option. For example, if var_type is GET_UINT, the function

=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	2011-04-18 19:59:15 +0000
+++ b/mysql-test/collections/default.experimental	2011-05-02 08:22:29 +0000
@@ -19,7 +19,6 @@ innodb_plugin.*  @solaris               
 main.ctype_gbk_binlog  @solaris          # Bug#46010: main.ctype_gbk_binlog fails
sporadically : Table 't2' already exists
 main.func_str  @solaris                  # joro: Bug#40928
 main.sp @solaris                         # joro : Bug#54138
-main.outfile_loaddata @solaris           # joro : Bug #46895
 
 ndb.*                                    # joro : NDB tests marked as experimental as
agreed with bochklin
 

=== modified file 'sql/derror.cc'
--- a/sql/derror.cc	2007-10-09 21:56:32 +0000
+++ b/sql/derror.cc	2011-05-02 08:22:29 +0000
@@ -96,7 +96,6 @@ static bool read_texts(const char *file_
   char name[FN_REFLEN];
   uchar *buff;
   uchar head[32],*pos;
-  const char *errmsg;
   DBUG_ENTER("read_texts");
 
   LINT_INIT(buff);
@@ -168,18 +167,9 @@ Check that the above file is the right v
   DBUG_RETURN(0);
 
 err:
-  switch (funktpos) {
-  case 2:
-    errmsg= "Not enough memory for messagefile '%s'";
-    break;
-  case 1:
-    errmsg= "Can't read from messagefile '%s'";
-    break;
-  default:
-    errmsg= "Can't find messagefile '%s'";
-    break;
-  }
-  sql_print_error(errmsg, name);
+  sql_print_error((funktpos == 2) ? "Not enough memory for messagefile '%s'" :
+                  ((funktpos == 1) ? "Can't read from messagefile '%s'" :
+                   "Can't find messagefile '%s'"), name);
 err1:
   if (file != FERR)
     VOID(my_close(file,MYF(MY_WME)));

=== modified file 'sql/events.cc'
--- a/sql/events.cc	2010-03-28 08:37:47 +0000
+++ b/sql/events.cc	2011-05-02 08:22:29 +0000
@@ -547,7 +547,7 @@ Events::update_event(THD *thd, Event_par
          !sortcmp_lex_string(parse_data->name, *new_name,
                              system_charset_info))
     {
-      my_error(ER_EVENT_SAME_NAME, MYF(0), parse_data->name.str);
+      my_error(ER_EVENT_SAME_NAME, MYF(0));
       DBUG_RETURN(TRUE);
     }
 
@@ -1150,7 +1150,7 @@ Events::switch_event_scheduler_state(enu
 
   if (ret)
   {
-    my_error(ER_EVENT_SET_VAR_ERROR, MYF(0));
+    my_error(ER_EVENT_SET_VAR_ERROR, MYF(0), 0);
     goto end;
   }
 

=== modified file 'sql/field.cc'
--- a/sql/field.cc	2011-04-12 10:01:33 +0000
+++ b/sql/field.cc	2011-05-02 08:22:29 +0000
@@ -9585,7 +9585,7 @@ bool Create_field::init(THD *thd, char *
   if (decimals >= NOT_FIXED_DEC)
   {
     my_error(ER_TOO_BIG_SCALE, MYF(0), decimals, fld_name,
-             NOT_FIXED_DEC-1);
+             static_cast<ulong>(NOT_FIXED_DEC - 1));
     DBUG_RETURN(TRUE);
   }
 
@@ -9655,8 +9655,8 @@ bool Create_field::init(THD *thd, char *
     my_decimal_trim(&length, &decimals);
     if (length > DECIMAL_MAX_PRECISION)
     {
-      my_error(ER_TOO_BIG_PRECISION, MYF(0), length, fld_name,
-               DECIMAL_MAX_PRECISION);
+      my_error(ER_TOO_BIG_PRECISION, MYF(0), static_cast<int>(length),
+               fld_name, static_cast<ulong>(DECIMAL_MAX_PRECISION));
       DBUG_RETURN(TRUE);
     }
     if (length < decimals)
@@ -9881,7 +9881,7 @@ bool Create_field::init(THD *thd, char *
       if (length > MAX_BIT_FIELD_LENGTH)
       {
         my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), fld_name,
-                 MAX_BIT_FIELD_LENGTH);
+                 static_cast<ulong>(MAX_BIT_FIELD_LENGTH));
         DBUG_RETURN(TRUE);
       }
       pack_length= (length + 7) / 8;

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2010-10-19 22:36:59 +0000
+++ b/sql/ha_ndbcluster.cc	2011-05-02 08:22:29 +0000
@@ -8411,7 +8411,7 @@ NDB_SHARE *ndbcluster_get_share(const ch
       DBUG_PRINT("error", ("get_share: failed to alloc share"));
       if (!have_lock)
         pthread_mutex_unlock(&ndbcluster_mutex);
-      my_error(ER_OUTOFMEMORY, MYF(0), sizeof(*share));
+      my_error(ER_OUTOFMEMORY, MYF(0), static_cast<int>(sizeof(*share)));
       DBUG_RETURN(0);
     }
   }

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2009-10-16 10:29:42 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2011-05-02 08:22:29 +0000
@@ -1198,12 +1198,14 @@ ndbcluster_update_slock(THD *thd,
   }
 
   if (ndb_error)
+  {
+    char buf[1024];
+    my_snprintf(buf, sizeof(buf), "Could not release lock on '%s.%s'",
+                db, table_name);
     push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
                         ER_GET_ERRMSG, ER(ER_GET_ERRMSG),
-                        ndb_error->code,
-                        ndb_error->message,
-                        "Could not release lock on '%s.%s'",
-                        db, table_name);
+                        ndb_error->code, ndb_error->message, buf);
+  }
   if (trans)
     ndb->closeTransaction(trans);
   ndb->setDatabaseName(save_db);

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2011-04-26 08:21:09 +0000
+++ b/sql/ha_partition.cc	2011-05-02 08:22:29 +0000
@@ -1026,6 +1026,10 @@ static int handle_opt_part(THD *thd, HA_
 static bool print_admin_msg(THD* thd, const char* msg_type,
                             const char* db_name, const char* table_name,
                             const char* op_name, const char *fmt, ...)
+  ATTRIBUTE_FORMAT(printf, 6, 7);
+static bool print_admin_msg(THD* thd, const char* msg_type,
+                            const char* db_name, const char* table_name,
+                            const char* op_name, const char *fmt, ...)
 {
   va_list args;
   Protocol *protocol= thd->protocol;

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2011-04-20 15:52:33 +0000
+++ b/sql/handler.cc	2011-05-02 08:22:29 +0000
@@ -275,7 +275,7 @@ handler *get_ha_partition(partition_info
   }
   else
   {
-    my_error(ER_OUTOFMEMORY, MYF(0), sizeof(ha_partition));
+    my_error(ER_OUTOFMEMORY, MYF(0), static_cast<int>(sizeof(ha_partition)));
   }
   DBUG_RETURN(((handler*) partition));
 }
@@ -1604,7 +1604,8 @@ int ha_recover(HASH *commit_list)
   }
   if (!info.list)
   {
-    sql_print_error(ER(ER_OUTOFMEMORY), info.len*sizeof(XID));
+    sql_print_error(ER(ER_OUTOFMEMORY),
+                    static_cast<int>(info.len*sizeof(XID)));
     DBUG_RETURN(1);
   }
 

=== modified file 'sql/item_create.cc'
--- a/sql/item_create.cc	2010-07-02 18:30:47 +0000
+++ b/sql/item_create.cc	2011-05-02 08:22:29 +0000
@@ -5083,8 +5083,8 @@ create_func_cast(THD *thd, Item *a, Cast
       decoded_size= strtoul(c_len, NULL, 10);
       if (errno != 0)
       {
-        my_error(ER_TOO_BIG_PRECISION, MYF(0), c_len, a->name,
-                 DECIMAL_MAX_PRECISION);
+        my_error(ER_TOO_BIG_PRECISION, MYF(0), INT_MAX, a->name,
+                 static_cast<ulong>(DECIMAL_MAX_PRECISION));
         return NULL;
       }
       len= decoded_size;
@@ -5097,8 +5097,8 @@ create_func_cast(THD *thd, Item *a, Cast
       decoded_size= strtoul(c_dec, NULL, 10);
       if ((errno != 0) || (decoded_size > UINT_MAX))
       {
-        my_error(ER_TOO_BIG_SCALE, MYF(0), c_dec, a->name,
-                 DECIMAL_MAX_SCALE);
+        my_error(ER_TOO_BIG_SCALE, MYF(0), INT_MAX, a->name,
+                 static_cast<ulong>(DECIMAL_MAX_SCALE));
         return NULL;
       }
       dec= decoded_size;
@@ -5111,14 +5111,14 @@ create_func_cast(THD *thd, Item *a, Cast
     }
     if (len > DECIMAL_MAX_PRECISION)
     {
-      my_error(ER_TOO_BIG_PRECISION, MYF(0), len, a->name,
-               DECIMAL_MAX_PRECISION);
+      my_error(ER_TOO_BIG_PRECISION, MYF(0), static_cast<int>(len), a->name,
+               static_cast<ulong>(DECIMAL_MAX_PRECISION));
       return 0;
     }
     if (dec > DECIMAL_MAX_SCALE)
     {
       my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->name,
-               DECIMAL_MAX_SCALE);
+               static_cast<ulong>(DECIMAL_MAX_SCALE));
       return 0;
     }
     res= new (thd->mem_root) Item_decimal_typecast(a, len, dec);

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2011-04-20 07:39:20 +0000
+++ b/sql/item_func.cc	2011-05-02 08:22:29 +0000
@@ -1066,7 +1066,7 @@ err:
   push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
                       ER_WARN_DATA_OUT_OF_RANGE,
                       ER(ER_WARN_DATA_OUT_OF_RANGE),
-                      name, 1);
+                      name, 1L);
   return dec;
 }
 
@@ -2851,7 +2851,7 @@ udf_handler::fix_fields(THD *thd, Item_r
 
   if (!tmp_udf)
   {
-    my_error(ER_CANT_FIND_UDF, MYF(0), u_d->name.str, errno);
+    my_error(ER_CANT_FIND_UDF, MYF(0), u_d->name.str);
     DBUG_RETURN(TRUE);
   }
   u_d=tmp_udf;

=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc	2011-03-03 15:39:26 +0000
+++ b/sql/item_strfunc.cc	2011-05-02 08:22:29 +0000
@@ -3465,7 +3465,8 @@ String *Item_func_uncompress::val_str(St
     push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR,
 			ER_TOO_BIG_FOR_UNCOMPRESS,
 			ER(ER_TOO_BIG_FOR_UNCOMPRESS),
-                        current_thd->variables.max_allowed_packet);
+                        static_cast<int>(current_thd->variables.
+                                         max_allowed_packet));
     goto err;
   }
   if (buffer.realloc((uint32)new_size))

=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2011-03-15 11:36:12 +0000
+++ b/sql/mysql_priv.h	2011-05-02 08:22:29 +0000
@@ -829,7 +829,7 @@ void sql_print_warning(const char *forma
 void sql_print_information(const char *format, ...)
   ATTRIBUTE_FORMAT(printf, 1, 2);
 typedef void (*sql_print_message_func)(const char *format, ...)
-  ATTRIBUTE_FORMAT(printf, 1, 2);
+  ATTRIBUTE_FORMAT_FPTR(printf, 1, 2);
 extern sql_print_message_func sql_print_message_handlers[];
 
 int error_log_print(enum loglevel level, const char *format,

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2010-11-11 04:52:51 +0000
+++ b/sql/sp_head.cc	2011-05-02 08:22:29 +0000
@@ -1060,7 +1060,7 @@ void sp_head::recursion_level_error(THD 
   if (m_type == TYPE_ENUM_PROCEDURE)
   {
     my_error(ER_SP_RECURSION_LIMIT, MYF(0),
-             thd->variables.max_sp_recursion_depth,
+             static_cast<int>(thd->variables.max_sp_recursion_depth),
              m_name.str);
   }
   else

=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc	2011-02-07 12:06:22 +0000
+++ b/sql/sql_acl.cc	2011-05-02 08:22:29 +0000
@@ -1970,13 +1970,12 @@ static int replace_user_table(THD *thd, 
     */
     else if (!password_len && no_auto_create)
     {
-      my_error(ER_PASSWORD_NO_MATCH, MYF(0), combo.user.str, combo.host.str);
+      my_error(ER_PASSWORD_NO_MATCH, MYF(0));
       goto end;
     }
     else if (!can_create_user)
     {
-      my_error(ER_CANT_CREATE_USER_WITH_GRANT, MYF(0),
-               thd->security_ctx->user, thd->security_ctx->host_or_ip);
+      my_error(ER_CANT_CREATE_USER_WITH_GRANT, MYF(0));
       goto end;
     }
     old_row_exists = 0;

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2011-03-29 08:09:05 +0000
+++ b/sql/sql_base.cc	2011-05-02 08:22:29 +0000
@@ -4008,7 +4008,7 @@ retry:
      {
        /* Give right error message */
        thd->clear_error();
-       my_error(ER_NOT_KEYFILE, MYF(0), share->table_name.str, my_errno);
+       my_error(ER_NOT_KEYFILE, MYF(0), share->table_name.str);
        sql_print_error("Couldn't repair table: %s.%s", share->db.str,
                        share->table_name.str);
        if (entry->file)
@@ -7686,7 +7686,7 @@ bool setup_tables(THD *thd, Name_resolut
   }
   if (tablenr > MAX_TABLES)
   {
-    my_error(ER_TOO_MANY_TABLES,MYF(0),MAX_TABLES);
+    my_error(ER_TOO_MANY_TABLES, MYF(0), static_cast<int>(MAX_TABLES));
     DBUG_RETURN(1);
   }
   for (table_list= tables;

=== modified file 'sql/sql_binlog.cc'
--- a/sql/sql_binlog.cc	2010-11-28 09:43:36 +0000
+++ b/sql/sql_binlog.cc	2011-05-02 08:22:29 +0000
@@ -232,7 +232,7 @@ void mysql_client_binlog_statement(THD* 
           TODO: Maybe a better error message since the BINLOG statement
           now contains several events.
         */
-        my_error(ER_UNKNOWN_ERROR, MYF(0), "Error executing BINLOG statement");
+        my_error(ER_UNKNOWN_ERROR, MYF(0));
         goto end;
       }
     }

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2010-10-23 12:55:44 +0000
+++ b/sql/sql_class.cc	2011-05-02 08:22:29 +0000
@@ -2040,7 +2040,7 @@ bool select_export::send_data(List<Item>
                             ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
                             ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
                             "string", printable_buff,
-                            item->name, row_count);
+                            item->name, static_cast<long>(row_count));
       }
       else if (from_end_pos < res->ptr() + res->length())
       { 
@@ -2049,7 +2049,7 @@ bool select_export::send_data(List<Item>
         */
         push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                             WARN_DATA_TRUNCATED, ER(WARN_DATA_TRUNCATED),
-                            item->full_name(), row_count);
+                            item->full_name(), static_cast<long>(row_count));
       }
       cvt_str.length(bytes);
       res= &cvt_str;

=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc	2011-02-18 13:12:36 +0000
+++ b/sql/sql_connect.cc	2011-05-02 08:22:29 +0000
@@ -342,7 +342,7 @@ check_user(THD *thd, enum enum_server_co
       passwd_len != SCRAMBLE_LENGTH &&
       passwd_len != SCRAMBLE_LENGTH_323)
   {
-    my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
+    my_error(ER_HANDSHAKE_ERROR, MYF(0));
     DBUG_RETURN(1);
   }
 
@@ -373,7 +373,7 @@ check_user(THD *thd, enum enum_server_co
         my_net_read(net) != SCRAMBLE_LENGTH_323 + 1)
     {
       inc_host_errors(&thd->remote.sin_addr);
-      my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
+      my_error(ER_HANDSHAKE_ERROR, MYF(0));
       DBUG_RETURN(1);
     }
     /* Final attempt to check the user based on reply */
@@ -686,7 +686,7 @@ static int check_connection(THD *thd)
 
     if (vio_peer_addr(net->vio, ip, &thd->peer_port))
     {
-      my_error(ER_BAD_HOST_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
+      my_error(ER_BAD_HOST_ERROR, MYF(0));
       return 1;
     }
     if (!(thd->main_security_ctx.ip= my_strdup(ip,MYF(MY_WME))))
@@ -786,8 +786,7 @@ static int check_connection(THD *thd)
 	pkt_len < MIN_HANDSHAKE_SIZE)
     {
       inc_host_errors(&thd->remote.sin_addr);
-      my_error(ER_HANDSHAKE_ERROR, MYF(0),
-               thd->main_security_ctx.host_or_ip);
+      my_error(ER_HANDSHAKE_ERROR, MYF(0));
       return 1;
     }
   }
@@ -831,7 +830,7 @@ static int check_connection(THD *thd)
     if (!ssl_acceptor_fd)
     {
       inc_host_errors(&thd->remote.sin_addr);
-      my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
+      my_error(ER_HANDSHAKE_ERROR, MYF(0));
       return 1;
     }
     DBUG_PRINT("info", ("IO layer change in progress..."));
@@ -839,7 +838,7 @@ static int check_connection(THD *thd)
     {
       DBUG_PRINT("error", ("Failed to accept new SSL connection"));
       inc_host_errors(&thd->remote.sin_addr);
-      my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
+      my_error(ER_HANDSHAKE_ERROR, MYF(0));
       return 1;
     }
     DBUG_PRINT("info", ("Reading user information over SSL layer"));
@@ -849,7 +848,7 @@ static int check_connection(THD *thd)
       DBUG_PRINT("error", ("Failed to read user information (pkt_len= %lu)",
 			   pkt_len));
       inc_host_errors(&thd->remote.sin_addr);
-      my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
+      my_error(ER_HANDSHAKE_ERROR, MYF(0));
       return 1;
     }
   }
@@ -858,7 +857,7 @@ static int check_connection(THD *thd)
   if (end >= (char*) net->read_pos+ pkt_len +2)
   {
     inc_host_errors(&thd->remote.sin_addr);
-    my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
+    my_error(ER_HANDSHAKE_ERROR, MYF(0));
     return 1;
   }
 
@@ -896,7 +895,7 @@ static int check_connection(THD *thd)
   if (passwd + passwd_len + db_len > (char *)net->read_pos + pkt_len)
   {
     inc_host_errors(&thd->remote.sin_addr);
-    my_error(ER_HANDSHAKE_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
+    my_error(ER_HANDSHAKE_ERROR, MYF(0));
     return 1;
   }
 

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2011-01-28 12:09:15 +0000
+++ b/sql/sql_insert.cc	2011-05-02 08:22:29 +0000
@@ -3780,7 +3780,7 @@ select_create::prepare(List<Item> &value
 
   if (table->s->fields < values.elements)
   {
-    my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), 1);
+    my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), 1L);
     DBUG_RETURN(-1);
   }
 

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2011-03-03 08:25:37 +0000
+++ b/sql/sql_parse.cc	2011-05-02 08:22:29 +0000
@@ -3981,8 +3981,7 @@ end_with_restore_list:
             hostname_requires_resolving(user->host.str))
           push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                               ER_WARN_HOSTNAME_WONT_WORK,
-                              ER(ER_WARN_HOSTNAME_WONT_WORK),
-                              user->host.str);
+                              ER(ER_WARN_HOSTNAME_WONT_WORK));
         // Are we trying to change a password of another user
         DBUG_ASSERT(user->host.str != 0);
         if (strcmp(thd->security_ctx->user, user->user.str) ||
@@ -5889,7 +5888,7 @@ mysql_new_select(LEX *lex, bool move_dow
   lex->nest_level++;
   if (lex->nest_level > (int) MAX_SELECT_NESTING)
   {
-    my_error(ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT,MYF(0),MAX_SELECT_NESTING);
+    my_error(ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT, MYF(0));
     DBUG_RETURN(1);
   }
   select_lex->nest_level= lex->nest_level;
@@ -6936,7 +6935,7 @@ bool reload_acl_and_cache(THD *thd, ulon
           When an error is returned, my_message may have not been called and
           the client will hang waiting for a response.
         */
-        my_error(ER_UNKNOWN_ERROR, MYF(0), "FLUSH PRIVILEGES failed");
+        my_error(ER_UNKNOWN_ERROR, MYF(0));
       }
     }
 

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2011-02-22 21:03:32 +0000
+++ b/sql/sql_partition.cc	2011-05-02 08:22:29 +0000
@@ -6571,7 +6571,7 @@ void set_key_field_ptr(KEY *key_info, co
 
 void mem_alloc_error(size_t size)
 {
-  my_error(ER_OUTOFMEMORY, MYF(0), size);
+  my_error(ER_OUTOFMEMORY, MYF(0), static_cast<int>(size));
 }
 
 #ifdef WITH_PARTITION_STORAGE_ENGINE

=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	2010-12-02 07:14:43 +0000
+++ b/sql/sql_plugin.cc	2011-05-02 08:22:29 +0000
@@ -494,10 +494,11 @@ static st_plugin_dl *plugin_dl_add(const
     if (!cur)
     {
       free_plugin_mem(&plugin_dl);
+      const int needed= plugin_dl.dl.length;
       if (report & REPORT_TO_USER)
-        my_error(ER_OUTOFMEMORY, MYF(0), plugin_dl.dl.length);
+        my_error(ER_OUTOFMEMORY, MYF(0), needed);
       if (report & REPORT_TO_LOG)
-        sql_print_error(ER(ER_OUTOFMEMORY), plugin_dl.dl.length);
+        sql_print_error(ER(ER_OUTOFMEMORY), needed);
       DBUG_RETURN(0);
     }
     /*
@@ -519,10 +520,11 @@ static st_plugin_dl *plugin_dl_add(const
   if (! (plugin_dl.dl.str= (char*) my_malloc(plugin_dl.dl.length, MYF(0))))
   {
     free_plugin_mem(&plugin_dl);
+    const int needed= plugin_dl.dl.length;
     if (report & REPORT_TO_USER)
-      my_error(ER_OUTOFMEMORY, MYF(0), plugin_dl.dl.length);
+      my_error(ER_OUTOFMEMORY, MYF(0), needed);
     if (report & REPORT_TO_LOG)
-      sql_print_error(ER(ER_OUTOFMEMORY), plugin_dl.dl.length);
+      sql_print_error(ER(ER_OUTOFMEMORY), needed);
     DBUG_RETURN(0);
   }
   plugin_dl.dl.length= copy_and_convert(plugin_dl.dl.str, plugin_dl.dl.length,
@@ -533,10 +535,11 @@ static st_plugin_dl *plugin_dl_add(const
   if (! (tmp= plugin_dl_insert_or_reuse(&plugin_dl)))
   {
     free_plugin_mem(&plugin_dl);
+    const int needed= sizeof(struct st_plugin_dl);
     if (report & REPORT_TO_USER)
-      my_error(ER_OUTOFMEMORY, MYF(0), sizeof(struct st_plugin_dl));
+      my_error(ER_OUTOFMEMORY, MYF(0), needed);
     if (report & REPORT_TO_LOG)
-      sql_print_error(ER(ER_OUTOFMEMORY), sizeof(struct st_plugin_dl));
+      sql_print_error(ER(ER_OUTOFMEMORY), needed);
     DBUG_RETURN(0);
   }
   DBUG_RETURN(tmp);

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2011-03-15 11:36:12 +0000
+++ b/sql/sql_prepare.cc	2011-05-02 08:22:29 +0000
@@ -1375,7 +1375,7 @@ static int mysql_test_select(Prepared_st
 
   if (!lex->result && !(lex->result= new (stmt->mem_root) select_send))
   {
-    my_error(ER_OUTOFMEMORY, MYF(0), sizeof(select_send));
+    my_error(ER_OUTOFMEMORY, MYF(0), static_cast<int>(sizeof(select_send)));
     goto error;
   }
 
@@ -2478,7 +2478,7 @@ void mysqld_stmt_execute(THD *thd, char 
   if (!(stmt= find_prepared_statement(thd, stmt_id)))
   {
     char llbuf[22];
-    my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), sizeof(llbuf),
+    my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), static_cast<int>(sizeof(llbuf)),
              llstr(stmt_id, llbuf), "mysqld_stmt_execute");
     DBUG_VOID_RETURN;
   }
@@ -2536,7 +2536,7 @@ void mysql_sql_stmt_execute(THD *thd)
   if (!(stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name)))
   {
     my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0),
-             name->length, name->str, "EXECUTE");
+             static_cast<int>(name->length), name->str, "EXECUTE");
     DBUG_VOID_RETURN;
   }
 
@@ -2578,7 +2578,7 @@ void mysqld_stmt_fetch(THD *thd, char *p
   if (!(stmt= find_prepared_statement(thd, stmt_id)))
   {
     char llbuf[22];
-    my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), sizeof(llbuf),
+    my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), static_cast<int>(sizeof(llbuf)),
              llstr(stmt_id, llbuf), "mysqld_stmt_fetch");
     DBUG_VOID_RETURN;
   }
@@ -2645,7 +2645,7 @@ void mysqld_stmt_reset(THD *thd, char *p
   if (!(stmt= find_prepared_statement(thd, stmt_id)))
   {
     char llbuf[22];
-    my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), sizeof(llbuf),
+    my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), static_cast<int>(sizeof(llbuf)),
              llstr(stmt_id, llbuf), "mysqld_stmt_reset");
     DBUG_VOID_RETURN;
   }
@@ -2720,7 +2720,7 @@ void mysql_sql_stmt_close(THD *thd)
 
   if (! (stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name)))
     my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0),
-             name->length, name->str, "DEALLOCATE PREPARE");
+             static_cast<int>(name->length), name->str, "DEALLOCATE
PREPARE");
   else if (stmt->is_in_use())
     my_error(ER_PS_NO_RECURSION, MYF(0));
   else

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2011-04-04 13:04:15 +0000
+++ b/sql/sql_show.cc	2011-05-02 08:22:29 +0000
@@ -7150,7 +7150,7 @@ static TABLE_LIST *get_trigger_table_imp
 
   if (!(table= (TABLE_LIST *)thd->calloc(sizeof(TABLE_LIST))))
   {
-    my_error(ER_OUTOFMEMORY, MYF(0), sizeof(TABLE_LIST));
+    my_error(ER_OUTOFMEMORY, MYF(0), static_cast<int>(sizeof(TABLE_LIST)));
     return NULL;
   }
 

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2010-11-10 08:32:42 +0000
+++ b/sql/sql_table.cc	2011-05-02 08:22:29 +0000
@@ -2451,7 +2451,8 @@ int prepare_create_field(Create_field *s
           MAX_FIELD_CHARLENGTH)
       {
         my_printf_error(ER_TOO_BIG_FIELDLENGTH, ER(ER_TOO_BIG_FIELDLENGTH),
-                        MYF(0), sql_field->field_name, MAX_FIELD_CHARLENGTH);
+                        MYF(0), sql_field->field_name,
+                        static_cast<ulong>(MAX_FIELD_CHARLENGTH));
         DBUG_RETURN(1);
       }
     }
@@ -3494,7 +3495,8 @@ static bool prepare_blob_field(THD *thd,
                                                       MODE_STRICT_ALL_TABLES)))
     {
       my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), sql_field->field_name,
-               MAX_FIELD_VARCHARLENGTH / sql_field->charset->mbmaxlen);
+               static_cast<ulong>(MAX_FIELD_VARCHARLENGTH /
+                                  sql_field->charset->mbmaxlen));
       DBUG_RETURN(1);
     }
     sql_field->sql_type= MYSQL_TYPE_BLOB;

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2011-02-22 21:03:32 +0000
+++ b/sql/table.cc	2011-05-02 08:22:29 +0000
@@ -2265,7 +2265,7 @@ void open_table_error(TABLE_SHARE *share
   default:				/* Better wrong error than none */
   case 4:
     strxmov(buff, share->normalized_path.str, reg_ext, NullS);
-    my_error(ER_NOT_FORM_FILE, errortype, buff, 0);
+    my_error(ER_NOT_FORM_FILE, errortype, buff);
     break;
   }
   DBUG_VOID_RETURN;
@@ -2835,7 +2835,8 @@ Table_check_intact::check(TABLE *table, 
       report_error(ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE,
                    ER(ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE),
                    table->alias, table_def->count, table->s->fields,
-                   table->s->mysql_version, MYSQL_VERSION_ID);
+                   static_cast<int>(table->s->mysql_version),
+                   MYSQL_VERSION_ID);
       DBUG_RETURN(TRUE);
     }
     else if (MYSQL_VERSION_ID == table->s->mysql_version)

=== modified file 'sql/unireg.cc'
--- a/sql/unireg.cc	2010-06-10 20:16:43 +0000
+++ b/sql/unireg.cc	2011-05-02 08:22:29 +0000
@@ -234,16 +234,17 @@ bool mysql_create_frm(THD *thd, const ch
                                               create_info->comment.length, 60);
   if (tmp_len < create_info->comment.length)
   {
+    const ulong too_long= tmp_len;
     if ((thd->variables.sql_mode &
          (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
     {
-      my_error(ER_TOO_LONG_TABLE_COMMENT, MYF(0), table, tmp_len);
+      my_error(ER_TOO_LONG_TABLE_COMMENT, MYF(0), table, too_long);
       goto err;
     }
     push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                         ER_TOO_LONG_TABLE_COMMENT,
                         ER(ER_TOO_LONG_TABLE_COMMENT),
-                        table, tmp_len);
+                        table, too_long);
     create_info->comment.length= tmp_len;
   }
 
@@ -618,16 +619,18 @@ static bool pack_header(uchar *forminfo,
                                                      255);
     if (tmp_len < field->comment.length)
     {
+      const ulong too_long= tmp_len;
       if ((current_thd->variables.sql_mode &
 	   (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
       {
-        my_error(ER_TOO_LONG_FIELD_COMMENT, MYF(0), field->field_name, tmp_len);
+        my_error(ER_TOO_LONG_FIELD_COMMENT, MYF(0), field->field_name,
+                 too_long);
 	DBUG_RETURN(1);
       }
       push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                           ER_TOO_LONG_FIELD_COMMENT,
                           ER(ER_TOO_LONG_FIELD_COMMENT),
-                          field->field_name, tmp_len);
+                          field->field_name, too_long);
       field->comment.length= tmp_len;
     }
 
@@ -711,7 +714,7 @@ static bool pack_header(uchar *forminfo,
 
   if (reclength > (ulong) file->max_record_length())
   {
-    my_error(ER_TOO_BIG_ROWSIZE, MYF(0), (uint) file->max_record_length());
+    my_error(ER_TOO_BIG_ROWSIZE, MYF(0),
static_cast<long>(file->max_record_length()));
     DBUG_RETURN(1);
   }
   /* Hack to avoid bugs with small static rows in MySQL */


Attachment: [text/bzr-bundle] bzr/guilhem.bichot@oracle.com-20110502082229-jr9el93oktezevrb.bundle
Thread
[Resend] bzr commit into mysql-5.1 branch (guilhem.bichot:3673) Bug#11755168Guilhem Bichot2 May