List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:February 25 2009 9:03am
Subject:bzr commit into mysql-5.1-bugteam branch (Davi.Arnaut:2818) Bug#41465
View as plain text  
#At file:///data0/my/darnaut/mysql-repo/work/41465-5.1/ based on revid:aelkin@strippedjmd7n

 2818 Davi Arnaut	2009-02-25
      Bug#41465: confusing error message when comment is too long
      
      The problem was that the server was trying to use the unknown
      error format string (ER_UNKNOWN_ERROR) to print messages about
      comments being too long, but the said format string does not
      accept arguments and will always default to "Unknown error".
      
      The solution is to introduce new error messages which are
      specific to the error conditions so that server wants to
      signal -- this also means that it's possible to translate
      those messages.
     @ mysql-test/r/strict.result
        Update test case result.
     @ mysql-test/t/strict.test
        U[date test case with new errors.
     @ sql/share/errmsg.txt
        Introduce new errors for long comments.
     @ sql/unireg.cc
        Use new errors.

    modified:
      mysql-test/r/strict.result
      mysql-test/t/strict.test
      sql/share/errmsg.txt
      sql/unireg.cc
=== modified file 'mysql-test/r/strict.result'
--- a/mysql-test/r/strict.result	2008-12-01 04:17:52 +0000
+++ b/mysql-test/r/strict.result	2009-02-25 09:00:30 +0000
@@ -1305,7 +1305,7 @@ set @@sql_mode='traditional';
 create table t1 (i int)
 comment '123456789*123456789*123456789*123456789*123456789*
          123456789*123456789*123456789*123456789*123456789*';
-ERROR HY000: Too long comment for table 't1'
+ERROR HY000: Comment for table 't1' is too long (max = 60)
 create table t1 (
 i int comment
 '123456789*123456789*123456789*123456789*
@@ -1315,7 +1315,7 @@ i int comment
  123456789*123456789*123456789*123456789*
  123456789*123456789*123456789*123456789*
  123456789*123456789*123456789*123456789*');
-ERROR HY000: Too long comment for field 'i'
+ERROR HY000: Comment for field 'i' is too long (max = 255)
 set @@sql_mode= @org_mode;
 create table t1
 (i int comment
@@ -1327,7 +1327,7 @@ create table t1
   123456789*123456789*123456789*123456789*
   123456789*123456789*123456789*123456789*');
 Warnings:
-Warning	1105	Unknown error
+Warning	1623	Comment for field 'i' is too long (max = 255)
 select column_name, column_comment from information_schema.columns where
 table_schema = 'test' and table_name = 't1';
 column_name	column_comment

=== modified file 'mysql-test/t/strict.test'
--- a/mysql-test/t/strict.test	2008-12-01 04:17:52 +0000
+++ b/mysql-test/t/strict.test	2009-02-25 09:00:30 +0000
@@ -1163,11 +1163,11 @@ set @@sql_mode= @org_mode;
 # Bug #13934 Silent truncation of table comments
 #
 set @@sql_mode='traditional';
---error 1105
+--error ER_TOO_LONG_TABLE_COMMENT
 create table t1 (i int)
 comment '123456789*123456789*123456789*123456789*123456789*
          123456789*123456789*123456789*123456789*123456789*';
---error 1105
+--error ER_TOO_LONG_FIELD_COMMENT
 create table t1 (
 i int comment
 '123456789*123456789*123456789*123456789*

=== modified file 'sql/share/errmsg.txt'
--- a/sql/share/errmsg.txt	2009-02-18 20:10:19 +0000
+++ b/sql/share/errmsg.txt	2009-02-25 09:00:30 +0000
@@ -6154,3 +6154,11 @@ WARN_PLUGIN_BUSY
 
 ER_VARIABLE_IS_READONLY
   eng "%s variable '%s' is read-only. Use SET %s to assign the value"
+
+ER_TOO_LONG_TABLE_COMMENT
+  eng "Comment for table '%-.64s' is too long (max = %lu)"
+  por "Coment�o para a tabela '%-.64s' �ongo demais (max = %lu)"
+
+ER_TOO_LONG_FIELD_COMMENT
+  eng "Comment for field '%-.64s' is too long (max = %lu)"
+  por "Coment�o para o campo '%-.64s' �ongo demais (max = %lu)"

=== modified file 'sql/unireg.cc'
--- a/sql/unireg.cc	2009-01-26 15:27:51 +0000
+++ b/sql/unireg.cc	2009-02-25 09:00:30 +0000
@@ -229,16 +229,16 @@ bool mysql_create_frm(THD *thd, const ch
                                               create_info->comment.length, 60);
   if (tmp_len < create_info->comment.length)
   {
-    (void) my_snprintf(buff, sizeof(buff), "Too long comment for table '%s'",
-                       table);
     if ((thd->variables.sql_mode &
          (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
     {
-      my_message(ER_UNKNOWN_ERROR, buff, MYF(0));
+      my_error(ER_TOO_LONG_TABLE_COMMENT, MYF(0), table, tmp_len);
       goto err;
     }
     push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                        ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), buff);
+                        ER_TOO_LONG_TABLE_COMMENT,
+                        ER(ER_TOO_LONG_TABLE_COMMENT),
+                        table, tmp_len);
     create_info->comment.length= tmp_len;
   }
 
@@ -613,17 +613,16 @@ static bool pack_header(uchar *forminfo,
                                                      255);
     if (tmp_len < field->comment.length)
     {
-      char buff[128];
-      (void) my_snprintf(buff,sizeof(buff), "Too long comment for field '%s'",
-                         field->field_name);
       if ((current_thd->variables.sql_mode &
 	   (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
       {
-        my_message(ER_UNKNOWN_ERROR, buff, MYF(0));
+        my_error(ER_TOO_LONG_FIELD_COMMENT, MYF(0), field->field_name, tmp_len);
 	DBUG_RETURN(1);
       }
       push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                          ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), buff);
+                          ER_TOO_LONG_FIELD_COMMENT,
+                          ER(ER_TOO_LONG_FIELD_COMMENT),
+                          field->field_name, tmp_len);
       field->comment.length= tmp_len;
     }
 

Attachment: [text/bzr-bundle] bzr/davi.arnaut@sun.com-20090225090030-hxy82inw3mvn94os.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (Davi.Arnaut:2818) Bug#41465Davi Arnaut25 Feb