MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:gluh Date:May 30 2006 8:53am
Subject:bk commit into 5.0 tree (gluh:1.2154) BUG#13934
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of gluh. When gluh does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2154 06/05/30 13:53:30 gluh@stripped +9 -0
  Fix for bug#13934 Silent truncation of table comments
  Table comment: issue a warning(error in traditional mode) if length of comment > 60 symbols
  Column comment: issue a warning(error in traditional mode) if length of comment > 255 symbols
  Table 'comment' is changed from char* to LEX_STRING

  sql/unireg.cc
    1.75 06/05/30 13:53:22 gluh@stripped +39 -4
    Fix for bug#13934 Silent truncation of table comments
    Table comment: issue a warning(error in traditional mode) if length of comment > 60 symbols
    Column comment: issue a warning(error in traditional mode) if length of comment > 255 symbols

  sql/table.h
    1.128 06/05/30 13:53:22 gluh@stripped +1 -1
    Table 'comment' is changed from char* to LEX_STRING

  sql/table.cc
    1.221 06/05/30 13:53:22 gluh@stripped +3 -2
    Table 'comment' is changed from char* to LEX_STRING

  sql/sql_yacc.yy
    1.470 06/05/30 13:53:22 gluh@stripped +1 -1
    Table 'comment' is changed from char* to LEX_STRING

  sql/sql_table.cc
    1.312 06/05/30 13:53:22 gluh@stripped +6 -2
    Table 'comment' is changed from char* to LEX_STRING

  sql/sql_show.cc
    1.318 06/05/30 13:53:22 gluh@stripped +8 -5
    Table 'comment' is changed from char* to LEX_STRING

  sql/handler.h
    1.171 06/05/30 13:53:22 gluh@stripped +2 -1
    Table 'comment' is changed from char* to LEX_STRING

  mysql-test/t/strict.test
    1.21 06/05/30 13:53:22 gluh@stripped +40 -0
    test case

  mysql-test/r/strict.result
    1.27 06/05/30 13:53:22 gluh@stripped +47 -0
    test case

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	gluh
# Host:	eagle.intranet.mysql.r18.ru
# Root:	/home/gluh/MySQL/Bugs/5.0.19599

--- 1.170/sql/handler.h	Wed May 10 01:34:24 2006
+++ 1.171/sql/handler.h	Tue May 30 13:53:22 2006
@@ -428,7 +428,8 @@ typedef struct st_ha_create_information
 {
   CHARSET_INFO *table_charset, *default_table_charset;
   LEX_STRING connect_string;
-  const char *comment,*password;
+  LEX_STRING comment;
+  const char *password;
   const char *data_file_name, *index_file_name;
   const char *alias;
   ulonglong max_rows,min_rows;

--- 1.317/sql/sql_show.cc	Tue May 23 12:45:19 2006
+++ 1.318/sql/sql_show.cc	Tue May 30 13:53:22 2006
@@ -1071,10 +1071,10 @@ store_create_info(THD *thd, TABLE_LIST *
       packet->append(ha_row_type[(uint) share->row_type]);
     }
     table->file->append_create_info(packet);
-    if (share->comment && share->comment[0])
+    if (share->comment.length)
     {
       packet->append(STRING_WITH_LEN(" COMMENT="));
-      append_unescaped(packet, share->comment, strlen(share->comment));
+      append_unescaped(packet, share->comment.str, share->comment.length);
     }
     if (share->connect_string.length)
     {
@@ -2518,11 +2518,14 @@ static int get_schema_tables_record(THD 
                              (uint) (ptr-option_buff)-1), cs);
     {
       char *comment;
-      comment= show_table->file->update_table_comment(share->comment);
+      comment= show_table->file->update_table_comment(share->comment.str);
       if (comment)
       {
-        table->field[20]->store(comment, strlen(comment), cs);
-        if (comment != share->comment)
+        table->field[20]->store(comment,
+                                (comment == share->comment.str ?
+                                 share->comment.length : 
+                                 strlen(comment)), cs);
+        if (comment != share->comment.str)
           my_free(comment, MYF(0));
       }
     }

--- 1.311/sql/sql_table.cc	Wed May 24 15:13:36 2006
+++ 1.312/sql/sql_table.cc	Tue May 30 13:53:22 2006
@@ -3583,8 +3583,12 @@ bool mysql_alter_table(THD *thd,char *ne
     goto err;
   }
   create_info->db_type=new_db_type;
-  if (!create_info->comment)
-    create_info->comment= table->s->comment;
+  if (!create_info->comment.str)
+  {
+    create_info->comment.str= table->s->comment.str;
+    create_info->comment.length= (table->s->comment.str ?
+                                  table->s->comment.length : 0);
+  }
 
   table->file->update_create_info(create_info);
   if ((create_info->table_options &

--- 1.469/sql/sql_yacc.yy	Mon May 15 01:51:02 2006
+++ 1.470/sql/sql_yacc.yy	Tue May 30 13:53:22 2006
@@ -2511,7 +2511,7 @@ create_table_option:
 	| MIN_ROWS opt_equal ulonglong_num	{ Lex->create_info.min_rows= $3; Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;}
 	| AVG_ROW_LENGTH opt_equal ulong_num	{ Lex->create_info.avg_row_length=$3; Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;}
 	| PASSWORD opt_equal TEXT_STRING_sys	{ Lex->create_info.password=$3.str; Lex->create_info.used_fields|= HA_CREATE_USED_PASSWORD; }
-	| COMMENT_SYM opt_equal TEXT_STRING_sys	{ Lex->create_info.comment=$3.str; Lex->create_info.used_fields|= HA_CREATE_USED_COMMENT; }
+	| COMMENT_SYM opt_equal TEXT_STRING_sys	{ Lex->create_info.comment=$3; Lex->create_info.used_fields|= HA_CREATE_USED_COMMENT; }
 	| AUTO_INC opt_equal ulonglong_num	{ Lex->create_info.auto_increment_value=$3; Lex->create_info.used_fields|= HA_CREATE_USED_AUTO;}
         | PACK_KEYS_SYM opt_equal ulong_num
           {

--- 1.220/sql/table.cc	Fri May 26 13:54:23 2006
+++ 1.221/sql/table.cc	Tue May 30 13:53:22 2006
@@ -410,8 +410,9 @@ int openfrm(THD *thd, const char *name, 
   int_length= uint2korr(head+274);
   share->null_fields= uint2korr(head+282);
   com_length= uint2korr(head+284);
-  share->comment= strdup_root(&outparam->mem_root, (char*) head+47);
-
+  share->comment.length=  (int) (head[46]);
+  share->comment.str= strmake_root(&outparam->mem_root, (char*) head+47,
+                                   share->comment.length);
   DBUG_PRINT("info",("i_count: %d  i_parts: %d  index: %d  n_length: %d  int_length: %d  com_length: %d", interval_count,interval_parts, share->keys,n_length,int_length, com_length));
 
   if (!(field_ptr = (Field **)

--- 1.127/sql/table.h	Wed May 10 18:40:15 2006
+++ 1.128/sql/table.h	Tue May 30 13:53:22 2006
@@ -124,7 +124,7 @@ typedef struct st_table_share
 #endif
   uint	*blob_field;			/* Index to blobs in Field arrray*/
   byte	*default_values;		/* row with default values */
-  char	*comment;			/* Comment about table */
+  LEX_STRING comment;			/* Comment about table */
   CHARSET_INFO *table_charset;		/* Default charset of string fields */
 
   /* A pair "database_name\0table_name\0", widely used as simply a db name */

--- 1.74/sql/unireg.cc	Thu Nov  3 15:20:07 2005
+++ 1.75/sql/unireg.cc	Tue May 30 13:53:22 2006
@@ -143,10 +143,27 @@ bool mysql_create_frm(THD *thd, my_strin
   fileinfo[26]= (uchar) test((create_info->max_rows == 1) &&
 			     (create_info->min_rows == 1) && (keys == 0));
   int2store(fileinfo+28,key_info_length);
-  strmake((char*) forminfo+47,create_info->comment ? create_info->comment : "",
-	  60);
-  forminfo[46]=(uchar) strlen((char*)forminfo+47);	// Length of comment
-
+  if (system_charset_info->cset->numchars(system_charset_info,
+					  create_info->comment.str,
+					  create_info->comment.str +
+					  create_info->comment.length) > 60)
+  {
+    char buff[128];
+    (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));
+      goto err;
+    }
+    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                        ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), buff);
+    create_info->comment.length= 60*system_charset_info->mbmaxlen;
+  }
+  strmake((char*) forminfo+47, create_info->comment.str ?
+          create_info->comment.str : "", create_info->comment.length);
+  forminfo[46]=(uchar) create_info->comment.length;
   if (my_pwrite(file,(byte*) fileinfo,64,0L,MYF_RW) ||
       my_pwrite(file,(byte*) keybuff,key_info_length,
 		(ulong) uint2korr(fileinfo+6),MYF_RW))
@@ -449,6 +466,24 @@ static bool pack_header(uchar *forminfo,
   create_field *field;
   while ((field=it++))
   {
+    if (system_charset_info->cset->numchars(system_charset_info,
+					    field->comment.str,
+					    field->comment.str +
+					    field->comment.length) > 255)
+    {
+      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));
+	DBUG_RETURN(1);
+      }
+      push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                          ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), buff);
+      field->comment.length= 255*system_charset_info->mbmaxlen;
+    }
     totlength+= field->length;
     com_length+= field->comment.length;
     if (MTYP_TYPENR(field->unireg_check) == Field::NOEMPTY ||

--- 1.26/mysql-test/r/strict.result	Tue May 23 13:27:39 2006
+++ 1.27/mysql-test/r/strict.result	Tue May 30 13:53:22 2006
@@ -1298,3 +1298,50 @@ t2	CREATE TABLE `t2` (
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t2,t1;
 set @@sql_mode= @org_mode;
+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'
+create table t1 (
+i int comment
+'123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*');
+ERROR HY000: Too long comment for field 'i'
+set @@sql_mode= @org_mode;
+create table t1
+(i int comment
+'123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*');
+Warnings:
+Warning	1105	Unknown error
+select column_name, column_comment from information_schema.columns where
+table_schema = 'test' and table_name = 't1';
+column_name	column_comment
+i	123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*
+drop table t1;
+set names utf8;
+create table t1 (i int)
+comment '123456789*123456789*123456789*123456789*123456789*123456789*';
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `i` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='123456789*123456789*123456789*123456789*123456789*123456789*'
+drop table t1;
+set names default;

--- 1.20/mysql-test/t/strict.test	Tue May 23 13:27:39 2006
+++ 1.21/mysql-test/t/strict.test	Tue May 30 13:53:22 2006
@@ -1155,3 +1155,43 @@ create table t2 select date from t1;
 show create table t2;
 drop table t2,t1;
 set @@sql_mode= @org_mode;
+
+#
+# Bug #13934 Silent truncation of table comments
+#
+set @@sql_mode='traditional';
+--error 1105
+create table t1 (i int)
+comment '123456789*123456789*123456789*123456789*123456789*
+         123456789*123456789*123456789*123456789*123456789*';
+--error 1105
+create table t1 (
+i int comment
+'123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*');
+set @@sql_mode= @org_mode;
+create table t1
+(i int comment
+ '123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*
+  123456789*123456789*123456789*123456789*');
+
+select column_name, column_comment from information_schema.columns where
+table_schema = 'test' and table_name = 't1';
+drop table t1;
+
+set names utf8;
+create table t1 (i int)
+comment '123456789*123456789*123456789*123456789*123456789*123456789*';
+show create table t1;
+drop table t1;
+set names default;
Thread
bk commit into 5.0 tree (gluh:1.2154) BUG#13934gluh30 May