MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:gluh Date:April 3 2006 10:13am
Subject:bk commit into 5.0 tree (gluh:1.2132) 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.2132 06/04/03 15:13:42 gluh@stripped +3 -0
  Fix for bug#13934 Silent truncation of table comments
   Table comment: generate warning(error in traditional mode) if length of comment > 60 symbols
   Column comment: genearte warning(error in traditional mode) if length of comment > 255 symbols

  sql/unireg.cc
    1.75 06/04/03 15:12:16 gluh@stripped +33 -1
    Fix for bug#13934 Silent truncation of table comments
     Table comment: generate warning(error in traditional mode) if length of comment > 60 symbols
     Column comment: genearte warning(error in traditional mode) if length of comment > 255 symbols

  mysql-test/t/strict.test
    1.20 06/04/03 15:12:16 gluh@stripped +39 -0
    Fix for bug#13934 Silent truncation of table comments
     test case

  mysql-test/r/strict.result
    1.26 06/04/03 15:12:16 gluh@stripped +48 -0
    Fix for bug#13934 Silent truncation of table comments
     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.13934

--- 1.74/sql/unireg.cc	Thu Nov  3 15:20:07 2005
+++ 1.75/sql/unireg.cc	Mon Apr  3 15:12:16 2006
@@ -84,6 +84,7 @@ bool mysql_create_frm(THD *thd, my_strin
   TYPELIB formnames;
   uchar *screen_buff;
   char buff[2];
+  ulong comment_length;
   DBUG_ENTER("mysql_create_frm");
 
   formnames.type_names=0;
@@ -143,8 +144,24 @@ 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);
+  comment_length= create_info->comment ? strlen(create_info->comment) : 0;
+  if (system_charset_info->cset->numchars(system_charset_info,
+					  create_info->comment,
+					  create_info->comment +
+					  comment_length) > 60)
+  {
+    if ((thd->variables.sql_mode &
+         (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
+    {
+      my_error(ER_TOO_LONG_IDENT, MYF(0), create_info->comment);
+      goto err;
+    }
+    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                        ER_TOO_LONG_IDENT, ER(ER_TOO_LONG_IDENT),
+			create_info->comment);
+  }
   strmake((char*) forminfo+47,create_info->comment ? create_info->comment : "",
-	  60);
+	  comment_length);
   forminfo[46]=(uchar) strlen((char*)forminfo+47);	// Length of comment
 
   if (my_pwrite(file,(byte*) fileinfo,64,0L,MYF_RW) ||
@@ -449,6 +466,21 @@ 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)
+    {
+      if ((current_thd->variables.sql_mode &
+	   (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
+      {
+	my_error(ER_TOO_LONG_IDENT, MYF(0), field->comment.str);
+	DBUG_RETURN(1);
+      }
+      push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+			  ER_TOO_LONG_IDENT, ER(ER_TOO_LONG_IDENT),
+			  field->comment.str);
+    }
     totlength+= field->length;
     com_length+= field->comment.length;
     if (MTYP_TYPENR(field->unireg_check) == Field::NOEMPTY ||

--- 1.25/mysql-test/r/strict.result	Wed Sep 14 03:41:37 2005
+++ 1.26/mysql-test/r/strict.result	Mon Apr  3 15:12:16 2006
@@ -1288,3 +1288,51 @@ ERROR 22001: Data too long for column 'a
 select * from t1;
 a
 drop table t1;
+set @@sql_mode='traditional';
+create table t1 (i int)
+comment '123456789*123456789*123456789*123456789*123456789*
+         123456789*123456789*123456789*123456789*123456789*';
+ERROR 42000: Identifier name '123456789*123456789*123456789*123456789*123456789*
+         123456789*123456789*123456789*123456789*' is too long
+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 42000: Identifier name '123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456' is too long
+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	1059	Identifier name '123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456' is too long
+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*
+ 123
+drop table t1;
+set names utf8;
+create table t1 (i int)
+comment '123456789*123456789*123456789*123456789*123456789*123456789*';
+drop table t1;
+set names default;

--- 1.19/mysql-test/t/strict.test	Wed Sep 14 03:41:37 2005
+++ 1.20/mysql-test/t/strict.test	Mon Apr  3 15:12:16 2006
@@ -1145,3 +1145,42 @@ create table t1(a bit(2));
 insert into t1 values(b'101');
 select * from t1;
 drop table t1;
+
+#
+# Bug #13934 Silent truncation of table comments
+#
+set @@sql_mode='traditional';
+--error 1059
+create table t1 (i int)
+comment '123456789*123456789*123456789*123456789*123456789*
+         123456789*123456789*123456789*123456789*123456789*';
+--error 1059
+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*';
+drop table t1;
+set names default;
Thread
bk commit into 5.0 tree (gluh:1.2132) BUG#13934gluh3 Apr