MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:gluh Date:July 18 2006 1:44pm
Subject:bk commit into 5.1 tree (gluh:1.2259)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 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@stripped, 2006-07-18 18:43:55+05:00, gluh@stripped +16 -0
  Merge myoffice.izhnet.ru:/usr/home/gluh/MySQL/tmp_merge
  into  myoffice.izhnet.ru:/usr/home/gluh/MySQL/5.1
  MERGE: 1.1810.1694.89

  mysql-test/r/sp_notembedded.result@stripped, 2006-07-18 18:32:26+05:00, gluh@stripped +0 -0
    Auto merged
    MERGE: 1.3.1.1

  mysql-test/r/strict.result@stripped, 2006-07-18 18:32:26+05:00, gluh@stripped +0 -0
    Auto merged
    MERGE: 1.25.1.2

  mysql-test/t/strict.test@stripped, 2006-07-18 18:32:26+05:00, gluh@stripped +0 -0
    Auto merged
    MERGE: 1.19.1.2

  sql/handler.h@stripped, 2006-07-18 18:34:46+05:00, gluh@stripped +1 -1
    manual merge
    MERGE: 1.138.2.34

  sql/item.cc@stripped, 2006-07-18 18:32:27+05:00, gluh@stripped +0 -0
    Auto merged
    MERGE: 1.113.1.113

  sql/item.h@stripped, 2006-07-18 18:32:27+05:00, gluh@stripped +0 -0
    Auto merged
    MERGE: 1.183.1.19

  sql/mysql_priv.h@stripped, 2006-07-18 18:32:27+05:00, gluh@stripped +0 -0
    Auto merged
    MERGE: 1.290.1.106

  sql/sql_acl.cc@stripped, 2006-07-18 18:32:27+05:00, gluh@stripped +0 -0
    Auto merged
    MERGE: 1.128.1.70

  sql/sql_parse.cc@stripped, 2006-07-18 18:32:28+05:00, gluh@stripped +0 -0
    Auto merged
    MERGE: 1.426.1.132

  sql/sql_show.cc@stripped, 2006-07-18 18:32:28+05:00, gluh@stripped +0 -0
    Auto merged
    MERGE: 1.253.1.70

  sql/sql_table.cc@stripped, 2006-07-18 18:32:28+05:00, gluh@stripped +0 -0
    Auto merged
    MERGE: 1.239.1.78

  sql/sql_yacc.yy@stripped, 2006-07-18 18:32:29+05:00, gluh@stripped +0 -0
    Auto merged
    MERGE: 1.371.1.102

  sql/table.cc@stripped, 2006-07-18 18:36:38+05:00, gluh@stripped +1 -2
    manual merge
    MERGE: 1.160.1.65

  sql/table.h@stripped, 2006-07-18 18:32:29+05:00, gluh@stripped +0 -0
    Auto merged
    MERGE: 1.102.1.27

  sql/unireg.cc@stripped, 2006-07-18 18:39:45+05:00, gluh@stripped +2 -2
    manual merge
    MERGE: 1.53.1.22

  tests/mysql_client_test.c@stripped, 2006-07-18 18:40:38+05:00, gluh@stripped +0 -0
    SCCS merged
    MERGE: 1.167.1.22

# 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:	myoffice.izhnet.ru
# Root:	/usr/home/gluh/MySQL/5.1/RESYNC

--- 1.224/sql/handler.h	2006-07-18 18:44:05 +05:00
+++ 1.225/sql/handler.h	2006-07-18 18:44:05 +05:00
@@ -725,7 +725,9 @@
 {
   CHARSET_INFO *table_charset, *default_table_charset;
   LEX_STRING connect_string;
-  const char *comment,*password, *tablespace;
+  const char *password, *tablespace;
+  LEX_STRING comment;
+  const char *password;
   const char *data_file_name, *index_file_name;
   const char *alias;
   ulonglong max_rows,min_rows;

--- 1.199/sql/item.cc	2006-07-18 18:44:05 +05:00
+++ 1.200/sql/item.cc	2006-07-18 18:44:05 +05:00
@@ -1501,7 +1501,18 @@
 }
 
 
-
+void Item_ident_for_show::make_field(Send_field *tmp_field)
+{
+  tmp_field->table_name= tmp_field->org_table_name= table_name;
+  tmp_field->db_name= db_name;
+  tmp_field->col_name= tmp_field->org_col_name= field->field_name;
+  tmp_field->charsetnr= field->charset()->number;
+  tmp_field->length=field->field_length;
+  tmp_field->type=field->type();
+  tmp_field->flags= field->table->maybe_null ? 
+    (field->flags & ~NOT_NULL_FLAG) : field->flags;
+  tmp_field->decimals= 0;
+}
 
 /**********************************************/
 

--- 1.205/sql/item.h	2006-07-18 18:44:05 +05:00
+++ 1.206/sql/item.h	2006-07-18 18:44:05 +05:00
@@ -1199,6 +1199,28 @@
                             bool any_privileges);
 };
 
+
+class Item_ident_for_show :public Item
+{
+public:
+  Field *field;
+  const char *db_name;
+  const char *table_name;
+
+  Item_ident_for_show(Field *par_field, const char *db_arg,
+                      const char *table_name_arg)
+    :field(par_field), db_name(db_arg), table_name(table_name_arg)
+  {}
+
+  enum Type type() const { return FIELD_ITEM; }
+  double val_real() { return field->val_real(); }
+  longlong val_int() { return field->val_int(); }
+  String *val_str(String *str) { return field->val_str(str); }
+  my_decimal *val_decimal(my_decimal *dec) { return field->val_decimal(dec); }
+  void make_field(Send_field *tmp_field);
+};
+
+
 class Item_equal;
 class COND_EQUAL;
 

--- 1.420/sql/mysql_priv.h	2006-07-18 18:44:05 +05:00
+++ 1.421/sql/mysql_priv.h	2006-07-18 18:44:05 +05:00
@@ -555,6 +555,7 @@
 void get_default_definer(THD *thd, LEX_USER *definer);
 LEX_USER *create_default_definer(THD *thd);
 LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name);
+LEX_USER *get_current_user(THD *thd, LEX_USER *user);
 
 enum enum_mysql_completiontype {
   ROLLBACK_RELEASE=-2, ROLLBACK=1,  ROLLBACK_AND_CHAIN=7,

--- 1.200/sql/sql_acl.cc	2006-07-18 18:44:05 +05:00
+++ 1.201/sql/sql_acl.cc	2006-07-18 18:44:05 +05:00
@@ -2906,7 +2906,7 @@
 {
   ulong column_priv= 0;
   List_iterator <LEX_USER> str_list (user_list);
-  LEX_USER *Str;
+  LEX_USER *Str, *tmp_Str;
   TABLE_LIST tables[3];
   bool create_new_users=0;
   char *db_name, *table_name;
@@ -3032,10 +3032,15 @@
   thd->mem_root= &memex;
   grant_version++;
 
-  while ((Str = str_list++))
+  while ((tmp_Str = str_list++))
   {
     int error;
     GRANT_TABLE *grant_table;
+    if (!(Str= get_current_user(thd, tmp_Str)))
+    {
+      result= TRUE;
+      continue;
+    }  
     if (Str->host.length > HOSTNAME_LENGTH ||
 	Str->user.length > USERNAME_LENGTH)
     {
@@ -3171,7 +3176,7 @@
 			 bool revoke_grant, bool no_error)
 {
   List_iterator <LEX_USER> str_list (user_list);
-  LEX_USER *Str;
+  LEX_USER *Str, *tmp_Str;
   TABLE_LIST tables[2];
   bool create_new_users=0, result=0;
   char *db_name, *table_name;
@@ -3239,10 +3244,15 @@
 
   DBUG_PRINT("info",("now time to iterate and add users"));
 
-  while ((Str= str_list++))
+  while ((tmp_Str= str_list++))
   {
     int error;
     GRANT_NAME *grant_name;
+    if (!(Str= get_current_user(thd, tmp_Str)))
+    {
+      result= TRUE;
+      continue;
+    }  
     if (Str->host.length > HOSTNAME_LENGTH ||
 	Str->user.length > USERNAME_LENGTH)
     {
@@ -3311,7 +3321,7 @@
                  ulong rights, bool revoke_grant)
 {
   List_iterator <LEX_USER> str_list (list);
-  LEX_USER *Str;
+  LEX_USER *Str, *tmp_Str;
   char tmp_db[NAME_LEN+1];
   bool create_new_users=0;
   TABLE_LIST tables[2];
@@ -3370,8 +3380,13 @@
   grant_version++;
 
   int result=0;
-  while ((Str = str_list++))
+  while ((tmp_Str = str_list++))
   {
+    if (!(Str= get_current_user(thd, tmp_Str)))
+    {
+      result= TRUE;
+      continue;
+    }  
     if (Str->host.length > HOSTNAME_LENGTH ||
 	Str->user.length > USERNAME_LENGTH)
     {
@@ -5334,7 +5349,7 @@
   int result;
   String wrong_users;
   ulong sql_mode;
-  LEX_USER *user_name;
+  LEX_USER *user_name, *tmp_user_name;
   List_iterator <LEX_USER> user_list(list);
   TABLE_LIST tables[GRANT_TABLES];
   DBUG_ENTER("mysql_create_user");
@@ -5346,8 +5361,13 @@
   rw_wrlock(&LOCK_grant);
   VOID(pthread_mutex_lock(&acl_cache->lock));
 
-  while ((user_name= user_list++))
+  while ((tmp_user_name= user_list++))
   {
+    if (!(user_name= get_current_user(thd, tmp_user_name)))
+    {
+      result= TRUE;
+      continue;
+    }  
     /*
       Search all in-memory structures and grant tables
       for a mention of the new user name.
@@ -5393,7 +5413,7 @@
 {
   int result;
   String wrong_users;
-  LEX_USER *user_name;
+  LEX_USER *user_name, *tmp_user_name;
   List_iterator <LEX_USER> user_list(list);
   TABLE_LIST tables[GRANT_TABLES];
   DBUG_ENTER("mysql_drop_user");
@@ -5405,8 +5425,14 @@
   rw_wrlock(&LOCK_grant);
   VOID(pthread_mutex_lock(&acl_cache->lock));
 
-  while ((user_name= user_list++))
+  while ((tmp_user_name= user_list++))
   {
+    user_name= get_current_user(thd, tmp_user_name);
+    if (!(user_name= get_current_user(thd, tmp_user_name)))
+    {
+      result= TRUE;
+      continue;
+    }  
     if (handle_grant_data(tables, 1, user_name, NULL) <= 0)
     {
       append_user(&wrong_users, user_name);
@@ -5443,8 +5469,8 @@
 {
   int result;
   String wrong_users;
-  LEX_USER *user_from;
-  LEX_USER *user_to;
+  LEX_USER *user_from, *tmp_user_from;
+  LEX_USER *user_to, *tmp_user_to;
   List_iterator <LEX_USER> user_list(list);
   TABLE_LIST tables[GRANT_TABLES];
   DBUG_ENTER("mysql_rename_user");
@@ -5456,9 +5482,19 @@
   rw_wrlock(&LOCK_grant);
   VOID(pthread_mutex_lock(&acl_cache->lock));
 
-  while ((user_from= user_list++))
+  while ((tmp_user_from= user_list++))
   {
-    user_to= user_list++;
+    if (!(user_from= get_current_user(thd, tmp_user_from)))
+    {
+      result= TRUE;
+      continue;
+    }  
+    tmp_user_to= user_list++;
+    if (!(user_to= get_current_user(thd, tmp_user_to)))
+    {
+      result= TRUE;
+      continue;
+    }  
     DBUG_ASSERT(user_to != 0); /* Syntax enforces pairs of users. */
 
     /*
@@ -5513,10 +5549,15 @@
   rw_wrlock(&LOCK_grant);
   VOID(pthread_mutex_lock(&acl_cache->lock));
 
-  LEX_USER *lex_user;
+  LEX_USER *lex_user, *tmp_lex_user;
   List_iterator <LEX_USER> user_list(list);
-  while ((lex_user=user_list++))
+  while ((tmp_lex_user= user_list++))
   {
+    if (!(lex_user= get_current_user(thd, tmp_lex_user)))
+    {
+      result= -1;
+      continue;
+    }  
     if (!find_acl_user(lex_user->host.str, lex_user->user.str, TRUE))
     {
       sql_print_error("REVOKE ALL PRIVILEGES, GRANT: User '%s'@'%s' does not "

--- 1.570/sql/sql_parse.cc	2006-07-18 18:44:05 +05:00
+++ 1.571/sql/sql_parse.cc	2006-07-18 18:44:06 +05:00
@@ -4070,11 +4070,13 @@
 
     if (thd->security_ctx->user)              // If not replication
     {
-      LEX_USER *user;
+      LEX_USER *user, *tmp_user;
 
       List_iterator <LEX_USER> user_list(lex->users_list);
-      while ((user= user_list++))
+      while ((tmp_user= user_list++))
       {
+        if (!(user= get_current_user(thd, tmp_user)))
+          goto error;
         if (specialflag & SPECIAL_NO_RESOLVE &&
             hostname_requires_resolving(user->host.str))
           push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
@@ -4156,9 +4158,13 @@
 	if (lex->sql_command == SQLCOM_GRANT)
 	{
 	  List_iterator <LEX_USER> str_list(lex->users_list);
-	  LEX_USER *user;
-	  while ((user=str_list++))
+	  LEX_USER *user, *tmp_user;
+	  while ((tmp_user=str_list++))
+          {
+            if (!(user= get_current_user(thd, tmp_user)))
+              goto error;
 	    reset_mqh(user);
+          }
 	}
       }
     }
@@ -4213,13 +4219,18 @@
   }
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
   case SQLCOM_SHOW_GRANTS:
+  {
+    LEX_USER *grant_user= get_current_user(thd, lex->grant_user);
+    if (!grant_user)
+      goto error;
     if ((thd->security_ctx->priv_user &&
-	 !strcmp(thd->security_ctx->priv_user, lex->grant_user->user.str)) ||
+	 !strcmp(thd->security_ctx->priv_user, grant_user->user.str)) ||
 	!check_access(thd, SELECT_ACL, "mysql",0,1,0,0))
     {
-      res = mysql_show_grants(thd,lex->grant_user);
+      res = mysql_show_grants(thd, grant_user);
     }
     break;
+  }
 #endif
   case SQLCOM_HA_OPEN:
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
@@ -7787,4 +7798,35 @@
   definer->host= *host_name;
 
   return definer;
+}
+
+
+/*
+  Retuns information about user or current user.
+
+  SYNOPSIS
+    get_current_user()
+    thd         [in] thread handler
+    user        [in] user
+
+  RETURN
+    On success, return a valid pointer to initialized
+    LEX_USER, which contains user information.
+    On error, return 0.
+*/
+
+LEX_USER *get_current_user(THD *thd, LEX_USER *user)
+{
+  LEX_USER *curr_user;
+  if (!user->user.str)  // current_user
+  {
+    if (!(curr_user= (LEX_USER*) thd->alloc(sizeof(LEX_USER))))
+    {
+      my_error(ER_OUTOFMEMORY, MYF(0), sizeof(LEX_USER));
+      return 0;
+    }
+    get_default_definer(thd, curr_user);
+    return curr_user;
+  }
+  return user;
 }

--- 1.356/sql/sql_show.cc	2006-07-18 18:44:06 +05:00
+++ 1.357/sql/sql_show.cc	2006-07-18 18:44:06 +05:00
@@ -770,7 +770,14 @@
   {
     if (!wild || !wild[0] || 
         !wild_case_compare(system_charset_info, field->field_name,wild))
-      field_list.push_back(new Item_field(field));
+    {
+      if (table_list->view)
+        field_list.push_back(new Item_ident_for_show(field,
+                                                     table_list->view_db.str,
+                                                     table_list->view_name.str));
+      else
+        field_list.push_back(new Item_field(field));
+    }
   }
   restore_record(table, s->default_values);              // Get empty record
   table->use_all_columns();
@@ -1345,10 +1352,10 @@
       packet->append(buff, (uint) (end - buff));
     }
     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)
     {
@@ -2901,11 +2908,14 @@
                              (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.358/sql/sql_table.cc	2006-07-18 18:44:06 +05:00
+++ 1.359/sql/sql_table.cc	2006-07-18 18:44:06 +05:00
@@ -5479,8 +5479,11 @@
     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.487/sql/sql_yacc.yy	2006-07-18 18:44:06 +05:00
+++ 1.488/sql/sql_yacc.yy	2006-07-18 18:44:06 +05:00
@@ -3880,7 +3880,7 @@
 	| 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
           {
@@ -8353,24 +8353,10 @@
 	  {
 	    LEX *lex=Lex;
 	    lex->sql_command= SQLCOM_SHOW_GRANTS;
-	    THD *thd= lex->thd;
-            Security_context *sctx= thd->security_ctx;
 	    LEX_USER *curr_user;
-            if (!(curr_user= (LEX_USER*) thd->alloc(sizeof(st_lex_user))))
+            if (!(curr_user= (LEX_USER*) lex->thd->alloc(sizeof(st_lex_user))))
               YYABORT;
-            curr_user->user.str= sctx->priv_user;
-            curr_user->user.length= strlen(sctx->priv_user);
-            if (*sctx->priv_host != 0)
-            {
-              curr_user->host.str= sctx->priv_host;
-              curr_user->host.length= strlen(sctx->priv_host);
-            }
-            else
-            {
-              curr_user->host.str= (char *) "%";
-              curr_user->host.length= 1;
-            }
-            curr_user->password=null_lex_str;
+            bzero(curr_user, sizeof(st_lex_user));
 	    lex->grant_user= curr_user;
 	  }
 	| GRANTS FOR_SYM user
@@ -9317,22 +9303,14 @@
 	  }
 	| CURRENT_USER optional_braces
 	{
-          THD *thd= YYTHD;
-          Security_context *sctx= thd->security_ctx;
-          if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
+          if (!($$=(LEX_USER*) YYTHD->alloc(sizeof(st_lex_user))))
             YYABORT;
-          $$->user.str= sctx->priv_user;
-          $$->user.length= strlen(sctx->priv_user);
-          if (*sctx->priv_host != 0)
-          {
-            $$->host.str= sctx->priv_host;
-            $$->host.length= strlen(sctx->priv_host);
-          }
-          else
-          {
-            $$->host.str= (char *) "%";
-            $$->host.length= 1;
-          }
+          /* 
+            empty LEX_USER means current_user and 
+            will be handled in the  get_current_user() function
+            later
+          */
+          bzero($$, sizeof(LEX_USER));
 	};
 
 /* Keyword that we allow for identifiers (except SP labels) */

--- 1.232/sql/table.cc	2006-07-18 18:44:06 +05:00
+++ 1.233/sql/table.cc	2006-07-18 18:44:06 +05:00
@@ -743,7 +743,9 @@
   int_length= uint2korr(head+274);
   share->null_fields= uint2korr(head+282);
   com_length= uint2korr(head+284);
-  share->comment= strdup_root(&share->mem_root, (char*) head+47);
+  share->comment.length=  (int) (head[46]);
+  share->comment.str= strmake_root(&share->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.143/sql/table.h	2006-07-18 18:44:06 +05:00
+++ 1.144/sql/table.h	2006-07-18 18:44:06 +05:00
@@ -134,7 +134,7 @@
   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 */
 
   MY_BITMAP all_set;

--- 1.82/sql/unireg.cc	2006-07-18 18:44:06 +05:00
+++ 1.83/sql/unireg.cc	2006-07-18 18:44:06 +05:00
@@ -77,7 +77,7 @@
 		      handler *db_file)
 {
   LEX_STRING str_db_type;
-  uint reclength,info_length,screens,key_info_length,maxlength,i;
+  uint reclength, info_length, screens, key_info_length, maxlength, tmp_len, i;
   ulong key_buff_length;
   File file;
   ulong filepos, data_offset;
@@ -170,10 +170,30 @@
   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;
 #ifdef WITH_PARTITION_STORAGE_ENGINE
   if (part_info)
   {
@@ -182,6 +202,7 @@
   }
 #endif
   int2store(fileinfo+59,db_file->extra_rec_buf_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))
@@ -524,6 +545,27 @@
   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.30/mysql-test/r/strict.result	2006-07-18 18:44:06 +05:00
+++ 1.31/mysql-test/r/strict.result	2006-07-18 18:44:06 +05:00
@@ -1298,3 +1298,49 @@
 ) 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.21/mysql-test/t/strict.test	2006-07-18 18:44:06 +05:00
+++ 1.22/mysql-test/t/strict.test	2006-07-18 18:44:06 +05:00
@@ -1155,3 +1155,42 @@
 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;

--- 1.4/mysql-test/r/sp_notembedded.result	2006-07-18 18:44:06 +05:00
+++ 1.5/mysql-test/r/sp_notembedded.result	2006-07-18 18:44:06 +05:00
@@ -208,3 +208,17 @@
 drop procedure bug10100pc|
 drop view v1|
 drop table t3|
+drop procedure if exists bug15298_1;
+drop procedure if exists bug15298_2;
+grant all privileges on test.* to 'mysqltest_1'@'localhost';
+create procedure 15298_1 () sql security definer show grants for current_user;
+create procedure 15298_2 () sql security definer show grants;
+call 15298_1();
+Grants for root@localhost
+GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
+call 15298_2();
+Grants for root@localhost
+GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
+drop user mysqltest_1@localhost;
+drop procedure 15298_1;
+drop procedure 15298_2;

--- 1.198/tests/mysql_client_test.c	2006-07-18 18:44:06 +05:00
+++ 1.199/tests/mysql_client_test.c	2006-07-18 18:44:06 +05:00
@@ -8311,6 +8311,39 @@
 }
 
 
+static void test_bug19671()
+{
+  MYSQL_RES *result;
+  int rc;
+  myheader("test_bug19671");
+
+  rc= mysql_query(mysql, "drop table if exists t1");
+  myquery(rc);
+
+  rc= mysql_query(mysql, "drop view if exists v1");
+  myquery(rc);
+
+  rc= mysql_query(mysql, "create table t1(f1 int)");
+  myquery(rc);
+
+  rc= mysql_query(mysql, "create view v1 as select va.* from t1 va");
+  myquery(rc);
+
+  result= mysql_list_fields(mysql, "v1", NULL);
+  mytest(result);
+
+  rc= my_process_result_set(result);
+  DIE_UNLESS(rc == 0);
+
+  verify_prepare_field(result, 0, "f1", "f1", MYSQL_TYPE_LONG,
+                       "v1", "v1", current_db, 11, "0");
+
+  mysql_free_result(result);
+  myquery(mysql_query(mysql, "drop view v1"));
+  myquery(mysql_query(mysql, "drop table t1"));
+}
+
+
 /* Test a memory ovverun bug */
 
 static void test_mem_overun()
@@ -15455,6 +15488,7 @@
   { "test_bug14169", test_bug14169 },
   { "test_bug17667", test_bug17667 },
   { "test_mysql_insert_id", test_mysql_insert_id },
+  { "test_bug19671", test_bug19671},
   { 0, 0 }
 };
 
Thread
bk commit into 5.1 tree (gluh:1.2259)gluh18 Jul