List:Commits« Previous MessageNext Message »
From:Chad MILLER Date:May 2 2006 3:31am
Subject:bk commit into 5.1 tree (cmiller:1.2383)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of cmiller. When cmiller 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.2383 06/05/01 23:31:01 cmiller@zippy.(none) +3 -0
  Merge bk-internal.mysql.com:/home/bk/mysql-5.1-new
  into  zippy.(none):/home/cmiller/work/mysql/mysql-5.1-new__bug17667

  sql/sql_parse.cc
    1.538 06/05/01 23:30:46 cmiller@zippy.(none) +0 -0
    Auto merged

  mysys/Makefile.am
    1.77 06/05/01 23:30:45 cmiller@zippy.(none) +0 -0
    Auto merged

  include/my_sys.h
    1.191 06/05/01 23:30:45 cmiller@zippy.(none) +0 -0
    Auto merged

# 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:	cmiller
# Host:	zippy.(none)
# Root:	/home/cmiller/work/mysql/mysql-5.1-new__bug17667/RESYNC

--- 1.190/include/my_sys.h	2006-04-19 21:05:35 -04:00
+++ 1.191/include/my_sys.h	2006-05-01 23:30:45 -04:00
@@ -601,6 +601,11 @@
 				    const char *sFile, uint uLine,
 				    myf MyFlag);
 
+/* implemented in my_memmem.c */
+extern void *my_memmem(const void *haystack, size_t haystacklen,
+    const void *needle, size_t needlelen);
+
+
 #ifdef __WIN__
 extern int my_access(const char *path, int amode);
 extern File my_sopen(const char *path, int oflag, int shflag, int pmode);

--- 1.76/mysys/Makefile.am	2006-04-11 03:11:26 -04:00
+++ 1.77/mysys/Makefile.am	2006-05-01 23:30:45 -04:00
@@ -53,6 +53,7 @@
 			charset.c charset-def.c my_bitmap.c my_bit.c md5.c \
 			my_gethostbyname.c rijndael.c my_aes.c sha1.c \
 			my_handler.c my_netware.c my_largepage.c \
+			my_memmem.c \
 			my_windac.c my_access.c base64.c
 EXTRA_DIST =		thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
 			thr_mutex.c thr_rwlock.c \

--- 1.537/sql/sql_parse.cc	2006-04-10 14:58:17 -04:00
+++ 1.538/sql/sql_parse.cc	2006-05-01 23:30:46 -04:00
@@ -68,7 +68,6 @@
 static bool check_db_used(THD *thd,TABLE_LIST *tables);
 static bool check_multi_update_lock(THD *thd);
 static void remove_escape(char *name);
-static void refresh_status(THD *thd);
 
 const char *any_db="*any*";	// Special symbol for check_access
 
@@ -118,10 +117,6 @@
 #if !defined( DBUG_OFF)
   MessageBox(NULL,"Test signal","DBUG",MB_OK);
 #endif
-#if defined(OS2)
-  fprintf(stderr, "Test signal %d\n", sig_ptr);
-  fflush(stderr);
-#endif
 }
 static void init_signals(void)
 {
@@ -1013,6 +1008,7 @@
 
   char *user= end;
   char *passwd= strend(user)+1;
+  uint user_len= passwd - user - 1;
   char *db= passwd;
   char db_buff[NAME_LEN+1];                     // buffer to store db in utf8
   char user_buff[USERNAME_LENGTH+1];		// buffer to store user in utf8
@@ -1027,22 +1023,37 @@
     *passwd++ : strlen(passwd);
   db= thd->client_capabilities & CLIENT_CONNECT_WITH_DB ?
     db + passwd_len + 1 : 0;
+  uint db_len= db ? strlen(db) : 0;
+
+  if (passwd + passwd_len + db_len > (char *)net->read_pos + pkt_len)
+  {
+    inc_host_errors(&thd->remote.sin_addr);
+    return ER_HANDSHAKE_ERROR;
+  }
 
   /* Since 4.1 all database names are stored in utf8 */
   if (db)
   {
     db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1,
                              system_charset_info,
-                             db, strlen(db),
+                             db, db_len,
                              thd->charset(), &dummy_errors)]= 0;
     db= db_buff;
   }
 
-  user_buff[copy_and_convert(user_buff, sizeof(user_buff)-1,
-                             system_charset_info, user, strlen(user),
-                             thd->charset(), &dummy_errors)]= '\0';
+  user_buff[user_len= copy_and_convert(user_buff, sizeof(user_buff)-1,
+                                       system_charset_info, user, user_len,
+                                       thd->charset(), &dummy_errors)]= '\0';
   user= user_buff;
 
+  /* If username starts and ends in "'", chop them off */
+  if (user_len > 1 && user[0] == '\'' && user[user_len - 1] == '\'')
+  {
+    user[user_len-1]= 0;
+    user++;
+    user_len-= 2;
+  }
+
   if (thd->main_security_ctx.user)
     x_free(thd->main_security_ctx.user);
   if (!(thd->main_security_ctx.user= my_strdup(user, MYF(0))))
@@ -1092,7 +1103,7 @@
 
   pthread_detach_this_thread();
 
-#if !defined( __WIN__) && !defined(OS2)	// Win32 calls this in pthread_create
+#if !defined( __WIN__) // Win32 calls this in pthread_create
   /* The following calls needs to be done before we call DBUG_ macros */
   if (!(test_flags & TEST_NO_THREADS) & my_thread_init())
   {
@@ -1116,7 +1127,7 @@
 
 #if defined(__WIN__)
   init_signals();
-#elif !defined(OS2) && !defined(__NETWARE__)
+#elif !defined(__NETWARE__)
   sigset_t set;
   VOID(sigemptyset(&set));			// Get mask in use
   VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
@@ -1240,7 +1251,7 @@
 #ifndef EMBEDDED_LIBRARY
   pthread_detach_this_thread();
   thd->thread_stack= (char*) &thd;
-#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
+#if !defined(__WIN__) && !defined(__NETWARE__)
   sigset_t set;
   VOID(sigemptyset(&set));			// Get mask in use
   VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
@@ -1611,7 +1622,17 @@
   {
     char *db, *tbl_name;
     uint db_len= *(uchar*) packet;
+    if (db_len >= packet_length || db_len > NAME_LEN)
+    {
+      my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
+      break;
+    }
     uint tbl_len= *(uchar*) (packet + db_len + 1);
+    if (db_len+tbl_len+2 > packet_length || tbl_len > NAME_LEN)
+    {
+      my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
+      break;
+    }
 
     statistic_increment(thd->status_var.com_other, &LOCK_status);
     thd->enable_slow_log= opt_log_slow_admin_statements;
@@ -1969,9 +1990,7 @@
 #ifdef __WIN__
     sleep(1);					// must wait after eof()
 #endif
-#ifndef OS2
     send_eof(thd);				// This is for 'quit request'
-#endif
     close_connection(thd, 0, 1);
     close_thread_tables(thd);			// Free before kill
     kill_mysql();
@@ -2991,6 +3010,11 @@
 #else
     {
       ulong priv=0;
+      ulong priv_needed= ALTER_ACL;
+      /* We also require DROP priv for ALTER TABLE ... DROP PARTITION */
+      if (lex->alter_info.flags & ALTER_DROP_PARTITION)
+        priv_needed|= DROP_ACL;
+
       if (lex->name && (!lex->name[0] || strlen(lex->name) > NAME_LEN))
       {
 	my_error(ER_WRONG_TABLE_NAME, MYF(0), lex->name);
@@ -3015,7 +3039,7 @@
         else
           select_lex->db= first_table->db;
       }
-      if (check_access(thd, ALTER_ACL, first_table->db,
+      if (check_access(thd, priv_needed, first_table->db,
 		       &first_table->grant.privilege, 0, 0,
                        test(first_table->schema_table)) ||
 	  check_access(thd,INSERT_ACL | CREATE_ACL,select_lex->db,&priv,0,0,
@@ -3026,7 +3050,7 @@
 	goto error;				/* purecov: inspected */
       if (grant_option)
       {
-	if (check_grant(thd, ALTER_ACL, all_tables, 0, UINT_MAX, 0))
+	if (check_grant(thd, priv_needed, all_tables, 0, UINT_MAX, 0))
 	  goto error;
 	if (lex->name && !test_all_bits(priv,INSERT_ACL | CREATE_ACL))
 	{					// Rename of table
@@ -5725,48 +5749,17 @@
   }
   else
   {
-    Name_resolution_context *outer_context;
     if (lex->current_select->order_list.first && !lex->current_select->braces)
     {
       my_error(ER_WRONG_USAGE, MYF(0), "UNION", "ORDER BY");
       DBUG_RETURN(1);
     }
     select_lex->include_neighbour(lex->current_select);
-    /*
-      we are not sure that we have one level of SELECTs above, so we take
-      outer_context address from first select of unit
-    */
-    outer_context=
-      select_lex->master_unit()->first_select()->context.outer_context;
-    SELECT_LEX_UNIT *unit= select_lex->master_unit();
-    SELECT_LEX *fake= unit->fake_select_lex;
-    if (!fake)
-    {
-      /*
-	as far as we included SELECT_LEX for UNION unit should have
-	fake SELECT_LEX for UNION processing
-      */
-      if (!(fake= unit->fake_select_lex= new (thd->mem_root) SELECT_LEX()))
-        DBUG_RETURN(1);
-      fake->include_standalone(unit,
-			       (SELECT_LEX_NODE**)&unit->fake_select_lex);
-      fake->select_number= INT_MAX;
-      fake->parent_lex= lex; /* Used in init_query. */
-      fake->make_empty_select();
-      fake->linkage= GLOBAL_OPTIONS_TYPE;
-      fake->select_limit= 0;
-
-      fake->context.outer_context= outer_context;
-      /* allow item list resolving in fake select for ORDER BY */
-      fake->context.resolve_in_select_list= TRUE;
-      fake->context.select_lex= fake;
-      /*
-        Remove the name resolution context of the fake select from the
-        context stack.
-       */
-      lex->pop_context();
-    }
-    select_lex->context.outer_context= outer_context;
+    SELECT_LEX_UNIT *unit= select_lex->master_unit();                              
+    if (!unit->fake_select_lex && unit->add_fake_select_lex(lex->thd))
+      DBUG_RETURN(1);
+    select_lex->context.outer_context= 
+                unit->first_select()->context.outer_context;
   }
 
   select_lex->master_unit()->global_parameters= select_lex;
@@ -6551,6 +6544,68 @@
 
 
 /*
+  Create a fake SELECT_LEX for a unit
+
+  SYNOPSIS:
+    add_fake_select_lex()
+    thd			   thread handle
+
+  DESCRIPTION
+    The method create a fake SELECT_LEX object for a unit.
+    This object is created for any union construct containing a union
+    operation and also for any single select union construct of the form
+    (SELECT ... ORDER BY order_list [LIMIT n]) ORDER BY ... 
+    or of the form
+    (SELECT ... ORDER BY LIMIT n) ORDER BY ...
+  
+  NOTES
+    The object is used to retrieve rows from the temporary table
+    where the result on the union is obtained.
+
+  RETURN VALUES
+    1     on failure to create the object
+    0     on success
+*/
+
+bool st_select_lex_unit::add_fake_select_lex(THD *thd)
+{
+  SELECT_LEX *first_sl= first_select();
+  DBUG_ENTER("add_fake_select_lex");
+  DBUG_ASSERT(!fake_select_lex);
+
+  if (!(fake_select_lex= new (thd->mem_root) SELECT_LEX()))
+      DBUG_RETURN(1);
+  fake_select_lex->include_standalone(this, 
+                                      (SELECT_LEX_NODE**)&fake_select_lex);
+  fake_select_lex->select_number= INT_MAX;
+  fake_select_lex->parent_lex= thd->lex; /* Used in init_query. */
+  fake_select_lex->make_empty_select();
+  fake_select_lex->linkage= GLOBAL_OPTIONS_TYPE;
+  fake_select_lex->select_limit= 0;
+
+  fake_select_lex->context.outer_context=first_sl->context.outer_context;
+  /* allow item list resolving in fake select for ORDER BY */
+  fake_select_lex->context.resolve_in_select_list= TRUE;
+  fake_select_lex->context.select_lex= fake_select_lex;
+
+  if (!first_sl->next_select())
+  {
+    /* 
+      This works only for 
+      (SELECT ... ORDER BY list [LIMIT n]) ORDER BY order_list [LIMIT m],
+      (SELECT ... LIMIT n) ORDER BY order_list [LIMIT m]
+      just before the parser starts processing order_list
+    */ 
+    global_parameters= fake_select_lex;
+    fake_select_lex->no_table_names_allowed= 1;
+    thd->lex->current_select= fake_select_lex;
+  }
+  thd->lex->pop_context();
+  DBUG_RETURN(0);
+}
+
+
+/*
   Push a new name resolution context for a JOIN ... ON clause to the
   context stack of a query block.
 
@@ -6903,26 +6958,6 @@
     send_ok(thd);
   else
     my_error(error, MYF(0), id);
-}
-
-
-/* Clear most status variables */
-
-static void refresh_status(THD *thd)
-{
-  pthread_mutex_lock(&LOCK_status);
-
-  /* We must update the global status before cleaning up the thread */
-  add_to_status(&global_status_var, &thd->status_var);
-  bzero((char*) &thd->status_var, sizeof(thd->status_var));
-
-  for (SHOW_VAR *ptr= status_vars; ptr->name; ptr++)
-    if (ptr->type == SHOW_LONG) // note that SHOW_LONG_NOFLUSH variables are not reset
-      *(ulong*) ptr->value= 0;
-
-  /* Reset the counters of all key caches (default and named). */
-  process_key_caches(reset_key_cache_counters);
-  pthread_mutex_unlock(&LOCK_status);
 }
 
 
Thread
bk commit into 5.1 tree (cmiller:1.2383)Chad MILLER2 May