List:Commits« Previous MessageNext Message »
From:konstantin Date:August 14 2006 12:31pm
Subject:bk commit into 5.1 tree (kostja:1.2274)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of kostja. When kostja 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-08-14 16:30:57+04:00, kostja@stripped +10 -0
  Merge bk-internal.mysql.com:/home/bk/mysql-5.1
  into  bodhi.local:/opt/local/work/mysql-5.1-runtime-merge
  MERGE: 1.2272.1.3

  sql/mysql_priv.h@stripped, 2006-08-14 16:27:39+04:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.426.1.1

  sql/sql_base.cc@stripped, 2006-08-14 16:27:40+04:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.341.1.1

  sql/sql_db.cc@stripped, 2006-08-14 16:30:53+04:00, kostja@stripped +2 -3
    Manual merge.
    MERGE: 1.139.1.2

  sql/sql_delete.cc@stripped, 2006-08-14 16:27:40+04:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.189.1.1

  sql/sql_show.cc@stripped, 2006-08-14 16:30:53+04:00, kostja@stripped +0 -2
    Manual merge.
    MERGE: 1.359.1.2

  sql/sql_table.cc@stripped, 2006-08-14 16:30:53+04:00, kostja@stripped +0 -0
    Manual merge.
    MERGE: 1.364.1.1

  sql/sql_trigger.cc@stripped, 2006-08-14 16:27:41+04:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.63.1.2

  sql/sql_view.cc@stripped, 2006-08-14 16:27:41+04:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.99.1.2

  sql/sql_yacc.yy@stripped, 2006-08-14 16:27:42+04:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.488.1.6

  sql/table.cc@stripped, 2006-08-14 16:27:42+04:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.237.1.1

# 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:	kostja
# Host:	bodhi.local
# Root:	/opt/local/work/mysql-5.1-runtime-merge/RESYNC

--- 1.427/sql/mysql_priv.h	2006-08-14 16:31:08 +04:00
+++ 1.428/sql/mysql_priv.h	2006-08-14 16:31:08 +04:00
@@ -1017,8 +1017,6 @@ bool mysqld_show_create_db(THD *thd, cha
 void mysqld_list_processes(THD *thd,const char *user,bool verbose);
 int mysqld_show_status(THD *thd);
 int mysqld_show_variables(THD *thd,const char *wild);
-int mysql_find_files(THD *thd,List<char> *files, const char *db,
-                const char *path, const char *wild, bool dir);
 bool mysqld_show_storage_engines(THD *thd);
 bool mysqld_show_authors(THD *thd);
 bool mysqld_show_contributors(THD *thd);
@@ -1462,7 +1460,11 @@ bool is_keyword(const char *name, uint l
 #define MY_DB_OPT_FILE "db.opt"
 bool my_database_names_init(void);
 void my_database_names_free(void);
+bool check_db_dir_existence(const char *db_name);
 bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create);
+bool load_db_opt_by_name(THD *thd, const char *db_name,
+                         HA_CREATE_INFO *db_create_info);
+bool my_dbopt_init(void);
 void my_dbopt_cleanup(void);
 extern int creating_database; // How many database locks are made
 extern int creating_table;    // How many mysql_create_table() are running

--- 1.140/sql/sql_db.cc	2006-08-14 16:31:08 +04:00
+++ 1.141/sql/sql_db.cc	2006-08-14 16:31:08 +04:00
@@ -408,7 +408,6 @@ static bool write_db_opt(THD *thd, const
   create	Where to store the read options
 
   DESCRIPTION
-    For now, only default-character-set is read.
 
   RETURN VALUES
   0	File found
@@ -497,6 +496,52 @@ err1:
 
 
 /*
+  Retrieve database options by name. Load database options file or fetch from
+  cache.
+
+  SYNOPSIS
+    load_db_opt_by_name()
+    db_name         Database name
+    db_create_info  Where to store the database options
+
+  DESCRIPTION
+    load_db_opt_by_name() is a shortcut for load_db_opt().
+
+  NOTE
+    Although load_db_opt_by_name() (and load_db_opt()) returns status of
+    the operation, it is useless usually and should be ignored. The problem
+    is that there are 1) system databases ("mysql") and 2) virtual
+    databases ("information_schema"), which do not contain options file.
+    So, load_db_opt[_by_name]() returns FALSE for these databases, but this
+    is not an error.
+
+    load_db_opt[_by_name]() clears db_create_info structure in any case, so
+    even on failure it contains valid data. So, common use case is just
+    call load_db_opt[_by_name]() without checking return value and use
+    db_create_info right after that.
+
+  RETURN VALUES (read NOTE!)
+    FALSE   Success
+    TRUE    Failed to retrieve options
+*/
+
+bool load_db_opt_by_name(THD *thd, const char *db_name,
+                         HA_CREATE_INFO *db_create_info)
+{
+  char db_opt_path[FN_REFLEN];
+
+  /*
+    Pass an empty file name, and the database options file name as extension
+    to avoid table name to file name encoding.
+  */
+  (void) build_table_filename(db_opt_path, sizeof(db_opt_path),
+                              db_name, "", MY_DB_OPT_FILE, 0);
+
+  return load_db_opt(thd, db_opt_path, db_create_info);
+}
+
+
+/*
   Create a database
 
   SYNOPSIS
@@ -1254,8 +1299,6 @@ bool mysql_change_db(THD *thd, const cha
 {
   int path_length, db_length;
   char *db_name;
-  char	path[FN_REFLEN];
-  HA_CREATE_INFO create;
   bool system_db= 0;
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
   ulong db_access;
@@ -1324,15 +1367,14 @@ bool mysql_change_db(THD *thd, const cha
     }
   }
 #endif
-  path_length= build_table_filename(path, sizeof(path), db_name, "", "", 0);
-  if (path_length && path[path_length-1] == FN_LIBCHAR)
-    path[path_length-1]= '\0';                  // remove ending '\'
-  if (my_access(path,F_OK))
+
+  if (check_db_dir_existence(db_name))
   {
     my_error(ER_BAD_DB_ERROR, MYF(0), db_name);
     my_free(db_name, MYF(0));
     DBUG_RETURN(1);
   }
+
 end:
   x_free(thd->db);
   DBUG_ASSERT(db_name == NULL || db_name[0] != '\0');
@@ -1348,8 +1390,10 @@ end:
   }
   else
   {
-    strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE);
-    load_db_opt(thd, path, &create);
+    HA_CREATE_INFO create;
+
+    load_db_opt_by_name(thd, db_name, &create);
+
     thd->db_charset= create.default_table_charset ?
       create.default_table_charset :
       thd->variables.collation_server;
@@ -1667,4 +1711,32 @@ exit:
   pthread_mutex_unlock(&LOCK_lock_db);
 
   DBUG_RETURN(error);
+}
+
+/*
+  Check if there is directory for the database name.
+
+  SYNOPSIS
+    check_db_dir_existence()
+    db_name   database name
+
+  RETURN VALUES
+    FALSE   There is directory for the specified database name.
+    TRUE    The directory does not exist.
+*/
+
+bool check_db_dir_existence(const char *db_name)
+{
+  char db_dir_path[FN_REFLEN];
+  uint db_dir_path_len;
+
+  db_dir_path_len= build_table_filename(db_dir_path, sizeof(db_dir_path),
+                                        db_name, "", "", 0);
+
+  if (db_dir_path_len && db_dir_path[db_dir_path_len - 1] == FN_LIBCHAR)
+    db_dir_path[db_dir_path_len - 1]= 0;
+
+  /* Check access. */
+
+  return my_access(db_dir_path, F_OK);
 }

--- 1.190/sql/sql_delete.cc	2006-08-14 16:31:08 +04:00
+++ 1.191/sql/sql_delete.cc	2006-08-14 16:31:08 +04:00
@@ -100,6 +100,13 @@ bool mysql_delete(THD *thd, TABLE_LIST *
     }
     /* Handler didn't support fast delete; Delete rows one by one */
   }
+  if (conds)
+  {
+    Item::cond_result result;
+    conds= remove_eq_conds(thd, conds, &result);
+    if (result == Item::COND_FALSE)             // Impossible where
+      limit= 0;
+  }
 
 #ifdef WITH_PARTITION_STORAGE_ENGINE
   if (prune_partitions(thd, table, conds))

--- 1.360/sql/sql_show.cc	2006-08-14 16:31:08 +04:00
+++ 1.361/sql/sql_show.cc	2006-08-14 16:31:08 +04:00
@@ -455,9 +455,35 @@ bool mysqld_show_column_types(THD *thd)
 }
 
 
-int
-mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
-                 const char *wild, bool dir)
+/*
+  find_files() - find files in a given directory.
+
+  SYNOPSIS
+    find_files()
+    thd                 thread handler
+    files               put found files in this list
+    db                  database name to set in TABLE_LIST structure
+    path                path to database
+    wild                filter for found files
+    dir                 read databases in path if TRUE, read .frm files in
+                        database otherwise
+
+  RETURN
+    FIND_FILES_OK       success
+    FIND_FILES_OOM      out of memory error
+    FIND_FILES_DIR      no such directory, or directory can't be read
+*/
+
+enum find_files_result {
+  FIND_FILES_OK,
+  FIND_FILES_OOM,
+  FIND_FILES_DIR
+};
+
+static
+find_files_result
+find_files(THD *thd, List<char> *files, const char *db,
+           const char *path, const char *wild, bool dir)
 {
   uint i;
   char *ext;
@@ -467,7 +493,7 @@ mysql_find_files(THD *thd,List<char> *fi
   uint col_access=thd->col_access;
 #endif
   TABLE_LIST table_list;
-  DBUG_ENTER("mysql_find_files");
+  DBUG_ENTER("find_files");
 
   if (wild && !wild[0])
     wild=0;
@@ -480,7 +506,7 @@ mysql_find_files(THD *thd,List<char> *fi
       my_error(ER_BAD_DB_ERROR, MYF(ME_BELL+ME_WAITTANG), db);
     else
       my_error(ER_CANT_READ_DIR, MYF(ME_BELL+ME_WAITTANG), path, my_errno);
-    DBUG_RETURN(-1);
+    DBUG_RETURN(FIND_FILES_DIR);
   }
 
   for (i=0 ; i < (uint) dirp->number_off_files  ; i++)
@@ -552,7 +578,7 @@ mysql_find_files(THD *thd,List<char> *fi
     if (files->push_back(thd->strdup(file->name)))
     {
       my_dirend(dirp);
-      DBUG_RETURN(-1);
+      DBUG_RETURN(FIND_FILES_OOM);
     }
   }
   DBUG_PRINT("info",("found: %d files", files->elements));
@@ -560,7 +586,7 @@ mysql_find_files(THD *thd,List<char> *fi
 
   VOID(ha_find_files(thd,db,path,wild,dir,files));
 
-  DBUG_RETURN(0);
+  DBUG_RETURN(FIND_FILES_OK);
 }
 
 
@@ -654,13 +680,11 @@ bool mysqld_show_create_db(THD *thd, cha
 {
   Security_context *sctx= thd->security_ctx;
   int length;
-  char path[FN_REFLEN];
   char buff[2048];
   String buffer(buff, sizeof(buff), system_charset_info);
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
   uint db_access;
 #endif
-  bool found_libchar;
   HA_CREATE_INFO create;
   uint create_options = create_info ? create_info->options : 0;
   Protocol *protocol=thd->protocol;
@@ -689,22 +713,13 @@ bool mysqld_show_create_db(THD *thd, cha
   }
   else
   {
-    length= build_table_filename(path, sizeof(path), dbname, "", "", 0);
-    found_libchar= 0;
-    if (length && path[length-1] == FN_LIBCHAR)
-    {
-      found_libchar= 1;
-      path[length-1]=0;				// remove ending '\'
-    }
-    if (access(path,F_OK))
+    if (check_db_dir_existence(dbname))
     {
       my_error(ER_BAD_DB_ERROR, MYF(0), dbname);
       DBUG_RETURN(TRUE);
     }
-    if (found_libchar)
-      path[length-1]= FN_LIBCHAR;
-    strmov(path+length, MY_DB_OPT_FILE);
-    load_db_opt(thd, path, &create);
+
+    load_db_opt_by_name(thd, dbname, &create);
   }
   List<Item> field_list;
   field_list.push_back(new Item_empty_string("Database",NAME_LEN));
@@ -2353,8 +2368,8 @@ enum enum_schema_tables get_schema_table
                           wild string otherwise it's db name; 
 
   RETURN
-    1	                  error
-    0	                  success
+    zero                  success
+    non-zero              error
 */
 
 int make_db_list(THD *thd, List<char> *files,
@@ -2380,8 +2395,8 @@ int make_db_list(THD *thd, List<char> *f
       if (files->push_back(thd->strdup(information_schema_name.str)))
         return 1;
     }
-    return mysql_find_files(thd, files, NullS, mysql_data_home,
-                            idx_field_vals->db_value, 1);
+    return (find_files(thd, files, NullS, mysql_data_home,
+                       idx_field_vals->db_value, 1) != FIND_FILES_OK);
   }
 
   /*
@@ -2407,7 +2422,8 @@ int make_db_list(THD *thd, List<char> *f
   if (files->push_back(thd->strdup(information_schema_name.str)))
     return 1;
   *with_i_schema= 1;
-  return mysql_find_files(thd, files, NullS, mysql_data_home, NullS, 1);
+  return (find_files(thd, files, NullS,
+                     mysql_data_home, NullS, 1) != FIND_FILES_OK);
 }
 
 
@@ -2558,9 +2574,28 @@ int get_all_tables(THD *thd, TABLE_LIST 
         len= build_table_filename(path, sizeof(path), base_name, "", "", 0);
         end= path + len;
         len= FN_LEN - len;
-        if (mysql_find_files(thd, &files, base_name, 
-                             path, idx_field_vals.table_value, 0))
-          goto err;
+        find_files_result res= find_files(thd, &files, base_name, 
+                                          path, idx_field_vals.table_value, 0);
+        if (res != FIND_FILES_OK)
+        {
+          /*
+            Downgrade errors about problems with database directory to
+            warnings if this is not a 'SHOW' command.  Another thread
+            may have dropped database, and we may still have a name
+            for that directory.
+          */
+          if (res == FIND_FILES_DIR && lex->sql_command == SQLCOM_END)
+          {
+            push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                         thd->net.last_errno, thd->net.last_error);
+            thd->clear_error();
+            continue;
+          }
+          else
+          {
+            goto err;
+          }
+        }
         if (lower_case_table_names)
           orig_base_name= thd->strdup(base_name);
       }
@@ -2676,8 +2711,11 @@ bool store_schema_shemata(THD* thd, TABL
 
 int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
 {
-  char path[FN_REFLEN];
-  bool found_libchar;
+  /*
+    TODO: fill_schema_shemata() is called when new client is connected.
+    Returning error status in this case leads to client hangup.
+  */
+
   INDEX_FIELD_VALUES idx_field_vals;
   List<char> files;
   char *file_name;
@@ -2709,19 +2747,9 @@ int fill_schema_shemata(THD *thd, TABLE_
 	(grant_option && !check_grant_db(thd, file_name)))
 #endif
     {
-      length= build_table_filename(path, sizeof(path), file_name, "", "", 0);
-      found_libchar= 0;
-      if (length && path[length-1] == FN_LIBCHAR)
-      {
-	found_libchar= 1;
-	path[length-1]=0;			// remove ending '\'
-      }
+      load_db_opt_by_name(thd, file_name, &create);
 
-      if (found_libchar)
-	path[length-1]= FN_LIBCHAR;
-      strmov(path+length, MY_DB_OPT_FILE);
-      load_db_opt(thd, path, &create);
-      if (store_schema_shemata(thd, table, file_name, 
+      if (store_schema_shemata(thd, table, file_name,
                                create.default_table_charset))
         DBUG_RETURN(1);
     }
@@ -5111,7 +5139,12 @@ bool get_schema_tables_result(JOIN *join
 
       if (table_list->schema_table->fill_table(thd, table_list,
                                                tab->select_cond))
+      {
         result= 1;
+        join->error= 1;
+        table_list->is_schema_table_processed= TRUE;
+        break;
+      }
       table_list->is_schema_table_processed= TRUE;
     }
   }

--- 1.365/sql/sql_table.cc	2006-08-14 16:31:08 +04:00
+++ 1.366/sql/sql_table.cc	2006-08-14 16:31:08 +04:00
@@ -2993,13 +2993,17 @@ static int mysql_prepare_table(THD *thd,
 static void set_table_default_charset(THD *thd,
 				      HA_CREATE_INFO *create_info, char *db)
 {
+  /*
+    If the table character set was not given explicitly,
+    let's fetch the database default character set and
+    apply it to the table.
+  */
   if (!create_info->default_table_charset)
   {
     HA_CREATE_INFO db_info;
-    char path[FN_REFLEN];
-    /* Abuse build_table_filename() to build the path to the db.opt file */
-    build_table_filename(path, sizeof(path), db, "", MY_DB_OPT_FILE, 0);
-    load_db_opt(thd, path, &db_info);
+
+    load_db_opt_by_name(thd, db, &db_info);
+
     create_info->default_table_charset= db_info.default_table_charset;
   }
 }

--- 1.491/sql/sql_yacc.yy	2006-08-14 16:31:08 +04:00
+++ 1.492/sql/sql_yacc.yy	2006-08-14 16:31:08 +04:00
@@ -1530,7 +1530,7 @@ ev_sql_stmt:
             {
               sp_head *sp= lex->sphead;
               // return back to the original memory root ASAP
-              sp->init_strings(YYTHD, lex, NULL);
+              sp->init_strings(YYTHD, lex);
               sp->restore_thd_mem_root(YYTHD);
 
               lex->sp_chistics.suid= SP_IS_SUID;//always the definer!
@@ -1613,6 +1613,17 @@ create_function_tail:
 	  RETURNS_SYM udf_type SONAME_SYM TEXT_STRING_sys
 	  {
 	    LEX *lex=Lex;
+            if (lex->definer != NULL)
+            {
+              /*
+                 DEFINER is a concept meaningful when interpreting SQL code.
+                 UDF functions are compiled.
+                 Using DEFINER with UDF has therefore no semantic,
+                 and is considered a parsing error.
+              */
+	      my_error(ER_WRONG_USAGE, MYF(0), "SONAME", "DEFINER");
+              YYABORT;
+            }
 	    lex->sql_command = SQLCOM_CREATE_FUNCTION;
 	    lex->udf.name = lex->spname->m_name;
 	    lex->udf.returns=(Item_result) $2;
@@ -1642,6 +1653,7 @@ create_function_tail:
 	    sp= new sp_head();
 	    sp->reset_thd_mem_root(YYTHD);
 	    sp->init(lex);
+            sp->init_sp_name(YYTHD, lex->spname);
 
 	    sp->m_type= TYPE_ENUM_FUNCTION;
 	    lex->sphead= sp;
@@ -1707,7 +1719,7 @@ create_function_tail:
               YYABORT;
 
 	    lex->sql_command= SQLCOM_CREATE_SPFUNCTION;
-	    sp->init_strings(YYTHD, lex, lex->spname);
+	    sp->init_strings(YYTHD, lex);
             if (!(sp->m_flags & sp_head::HAS_RETURN))
             {
               my_error(ER_SP_NORETURN, MYF(0), sp->m_qname.str);
@@ -2302,9 +2314,12 @@ sp_proc_stmt_statement:
               sp_instr_stmt *i=new sp_instr_stmt(sp->instructions(),
                                                  lex->spcont, lex);
 
-              /* Extract the query statement from the tokenizer:
-                 The end is either lex->tok_end or tok->ptr. */
-              if (lex->ptr - lex->tok_end > 1)
+              /*
+                Extract the query statement from the tokenizer.  The
+                end is either lex->ptr, if there was no lookahead,
+                lex->tok_end otherwise.
+              */
+              if (yychar == YYEMPTY)
                 i->m_query.length= lex->ptr - sp->m_tmp_query;
               else
                 i->m_query.length= lex->tok_end - sp->m_tmp_query;
@@ -4457,7 +4472,7 @@ opt_bin_mod:
 	| BINARY { Lex->type|= BINCMP_FLAG; };
 
 opt_bin_charset:
-	/* empty */ { }
+        /* empty */ { Lex->charset= NULL; }
 	| ASCII_SYM	{ Lex->charset=&my_charset_latin1; }
 	| UNICODE_SYM
 	{
@@ -9702,7 +9717,12 @@ option_type_value:
                                          lex)))
                 YYABORT;
 
-              if (lex->ptr - lex->tok_end > 1)
+              /*
+                Extract the query statement from the tokenizer.  The
+                end is either lex->ptr, if there was no lookahead,
+                lex->tok_end otherwise.
+              */
+              if (yychar == YYEMPTY)
                 qbuff.length= lex->ptr - sp->m_tmp_query;
               else
                 qbuff.length= lex->tok_end - sp->m_tmp_query;
@@ -10973,7 +10993,7 @@ trigger_tail:
 	    YYABORT;
 	  sp->reset_thd_mem_root(YYTHD);
 	  sp->init(lex);
-
+          sp->init_sp_name(YYTHD, $3);
 	  lex->stmt_definition_begin= $2;
           lex->ident.str= $7;
           lex->ident.length= $10 - $7;
@@ -11001,7 +11021,7 @@ trigger_tail:
 	  sp_head *sp= lex->sphead;
 
 	  lex->sql_command= SQLCOM_CREATE_TRIGGER;
-	  sp->init_strings(YYTHD, lex, $3);
+	  sp->init_strings(YYTHD, lex);
 	  /* Restore flag if it was cleared above */
 
 	  YYTHD->client_capabilities |= $<ulong_num>13;
@@ -11049,13 +11069,14 @@ sp_tail:
 	    my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), "PROCEDURE");
 	    YYABORT;
 	  }
-	  
+
 	  lex->stmt_definition_begin= $2;
-	  
+
 	  /* Order is important here: new - reset - init */
 	  sp= new sp_head();
 	  sp->reset_thd_mem_root(YYTHD);
 	  sp->init(lex);
+          sp->init_sp_name(YYTHD, $3);
 
 	  sp->m_type= TYPE_ENUM_PROCEDURE;
 	  lex->sphead= sp;
@@ -11093,7 +11114,7 @@ sp_tail:
 	  LEX *lex= Lex;
 	  sp_head *sp= lex->sphead;
 
-	  sp->init_strings(YYTHD, lex, $3);
+	  sp->init_strings(YYTHD, lex);
 	  lex->sql_command= SQLCOM_CREATE_PROCEDURE;
           /*
             Restore flag if it was cleared above

--- 1.238/sql/table.cc	2006-08-14 16:31:09 +04:00
+++ 1.239/sql/table.cc	2006-08-14 16:31:09 +04:00
@@ -4046,13 +4046,27 @@ void st_table::mark_columns_needed_for_i
     st_table_list::reinit_before_use()
 */
 
-void st_table_list::reinit_before_use(THD * /* thd */)
+void st_table_list::reinit_before_use(THD *thd)
 {
   /*
     Reset old pointers to TABLEs: they are not valid since the tables
     were closed in the end of previous prepare or execute call.
   */
   table= 0;
+  /* Reset is_schema_table_processed value(needed for I_S tables */
+  is_schema_table_processed= FALSE;
+
+  TABLE_LIST *embedded; /* The table at the current level of nesting. */
+  TABLE_LIST *embedding= this; /* The parent nested table reference. */
+  do
+  {
+    embedded= embedding;
+    if (embedded->prep_on_expr)
+      embedded->on_expr= embedded->prep_on_expr->copy_andor_structure(thd);
+    embedding= embedded->embedding;
+  }
+  while (embedding &&
+         embedding->nested_join->join_list.head() == embedded);
 }
 
 

--- 1.100/sql/sql_view.cc	2006-08-14 16:31:09 +04:00
+++ 1.101/sql/sql_view.cc	2006-08-14 16:31:09 +04:00
@@ -186,8 +186,10 @@ fill_defined_view_parts (THD *thd, TABLE
   if (!open_table(thd, &decoy, thd->mem_root, &not_used, OPEN_VIEW_NO_PARSE) &&
       !decoy.view)
   {
+    /* It's a table */
     return TRUE;
   }
+
   if (!lex->definer)
   {
     view->definer.host= decoy.definer.host;
@@ -646,6 +648,7 @@ static int mysql_register_view(THD *thd,
   char md5[MD5_BUFF_LENGTH];
   bool can_be_merged;
   char dir_buff[FN_REFLEN], file_buff[FN_REFLEN], path_buff[FN_REFLEN];
+  const uchar *endp;
   LEX_STRING dir, file, path;
   DBUG_ENTER("mysql_register_view");
 
@@ -729,8 +732,9 @@ static int mysql_register_view(THD *thd,
   view->query.str= (char*)str.ptr();
   view->query.length= str.length()-1; // we do not need last \0
   view->source.str= thd->query + thd->lex->create_view_select_start;
-  view->source.length= (thd->query_length -
-                        thd->lex->create_view_select_start);
+  endp= (uchar*) view->source.str;
+  endp= skip_rear_comments(endp, (uchar*) (thd->query + thd->query_length));
+  view->source.length= endp - (uchar*) view->source.str;
   view->file_version= 1;
   view->calc_md5(md5);
   view->md5.str= md5;

--- 1.64/sql/sql_trigger.cc	2006-08-14 16:31:09 +04:00
+++ 1.65/sql/sql_trigger.cc	2006-08-14 16:31:09 +04:00
@@ -301,7 +301,10 @@ end:
           append_definer(thd, &log_query, &definer_user, &definer_host);
         }
 
-        log_query.append(thd->lex->stmt_definition_begin);
+        log_query.append(thd->lex->stmt_definition_begin,
+                         (char *)thd->lex->sphead->m_body_begin -
+                         thd->lex->stmt_definition_begin +
+                         thd->lex->sphead->m_body.length);
       }
 
       /* Such a statement can always go directly to binlog, no trans cache. */
@@ -1497,7 +1500,6 @@ bool Table_triggers_list::process_trigge
       new_field= record1_field;
       old_field= table->field;
     }
-
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
     Security_context *save_ctx;
 
@@ -1531,7 +1533,9 @@ bool Table_triggers_list::process_trigge
 #endif // NO_EMBEDDED_ACCESS_CHECKS
 
     thd->reset_sub_statement_state(&statement_state, SUB_STMT_TRIGGER);
-    err_status= sp_trigger->execute_function(thd, 0, 0, 0);
+    err_status= sp_trigger->execute_trigger
+      (thd, table->s->db.str, table->s->table_name.str,
+       &subject_table_grants[event][time_type]);
     thd->restore_sub_statement_state(&statement_state);
 
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
Thread
bk commit into 5.1 tree (kostja:1.2274)konstantin14 Aug