MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:gluh Date:June 29 2006 1:39pm
Subject:bk commit into 5.0 tree (gluh:1.2211) 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.2211 06/06/29 18:39:34 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/06/29 18:39:28 gluh@stripped +45 -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.129 06/06/29 18:39:28 gluh@stripped +1 -1
    Table 'comment' is changed from char* to LEX_STRING

  sql/table.cc
    1.224 06/06/29 18:39:28 gluh@stripped +3 -1
    Table 'comment' is changed from char* to LEX_STRING

  sql/sql_yacc.yy
    1.473 06/06/29 18:39:28 gluh@stripped +1 -1
    Table 'comment' is changed from char* to LEX_STRING

  sql/sql_table.cc
    1.317 06/06/29 18:39:28 gluh@stripped +5 -2
    Table 'comment' is changed from char* to LEX_STRING

  sql/sql_show.cc
    1.322 06/06/29 18:39:28 gluh@stripped +8 -5
    Table 'comment' is changed from char* to LEX_STRING

  sql/handler.h
    1.172 06/06/29 18:39:27 gluh@stripped +2 -1
    Table 'comment' is changed from char* to LEX_STRING

  mysql-test/t/strict.test
    1.21 06/06/29 18:39:27 gluh@stripped +39 -0
    test case

  mysql-test/r/strict.result
    1.27 06/06/29 18:39:27 gluh@stripped +46 -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/Merge/5.0-kt

--- 1.171/sql/handler.h	Fri Jun  2 12:02:48 2006
+++ 1.172/sql/handler.h	Thu Jun 29 18:39:27 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.321/sql/sql_show.cc	Thu Jun 29 16:52:40 2006
+++ 1.322/sql/sql_show.cc	Thu Jun 29 18:39:28 2006
@@ -1080,10 +1080,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)
     {
@@ -2547,11 +2547,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.316/sql/sql_table.cc	Tue Jun 27 04:34:07 2006
+++ 1.317/sql/sql_table.cc	Thu Jun 29 18:39:28 2006
@@ -3598,8 +3598,11 @@ 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.length;
+  }
 
   table->file->update_create_info(create_info);
   if ((create_info->table_options &

--- 1.472/sql/sql_yacc.yy	Thu Jun 29 15:49:11 2006
+++ 1.473/sql/sql_yacc.yy	Thu Jun 29 18:39:28 2006
@@ -2529,7 +2529,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.223/sql/table.cc	Mon Jun 26 07:48:10 2006
+++ 1.224/sql/table.cc	Thu Jun 29 18:39:28 2006
@@ -410,7 +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));
 

--- 1.128/sql/table.h	Tue Jun 27 15:56:13 2006
+++ 1.129/sql/table.h	Thu Jun 29 18:39:28 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	Thu Jun 29 18:39:28 2006
@@ -76,7 +76,7 @@ bool mysql_create_frm(THD *thd, my_strin
 		      handler *db_file)
 {
   LEX_STRING str_db_type;
-  uint reclength,info_length,screens,key_info_length,maxlength;
+  uint reclength, info_length, screens, key_info_length, maxlength, tmp_len;
   ulong key_buff_length;
   File file;
   ulong filepos, data_offset;
@@ -143,10 +143,30 @@ 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
 
+  tmp_len= system_charset_info->cset->charpos(system_charset_info,
+                                              create_info->comment.str,
+                                              create_info->comment.str +
+                                              create_info->comment.length, 60);
+  if (tmp_len < create_info->comment.length)
+  {
+    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= tmp_len;
+  }
+
+  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 +469,27 @@ static bool pack_header(uchar *forminfo,
   create_field *field;
   while ((field=it++))
   {
+
+    uint tmp_len= system_charset_info->cset->charpos(system_charset_info,
+                                                     field->comment.str,
+                                                     field->comment.str +
+                                                     field->comment.length, 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));
+	DBUG_RETURN(1);
+      }
+      push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                          ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), buff);
+      field->comment.length= tmp_len;
+    }
+
     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	Thu Jun 29 18:39:27 2006
@@ -1298,3 +1298,49 @@ 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;

--- 1.20/mysql-test/t/strict.test	Tue May 23 13:27:39 2006
+++ 1.21/mysql-test/t/strict.test	Thu Jun 29 18:39:27 2006
@@ -1155,3 +1155,42 @@ 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;
Thread
bk commit into 5.0 tree (gluh:1.2211) BUG#13934gluh29 Jun