List:Commits« Previous MessageNext Message »
From:gkodinov Date:October 19 2006 2:37pm
Subject:bk commit into 5.0 tree (gkodinov:1.2282)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of gkodinov. When gkodinov 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-10-19 14:37:49+02:00, gkodinov@stripped +13 -0
  Merge dl145s.mysql.com:/data/bk/team_tree_merge/mysql-5.0
  into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt
  MERGE: 1.2258.44.23

  mysql-test/r/merge.result@stripped, 2006-10-19 14:37:44+02:00, gkodinov@stripped +0 -0
    Auto merged
    MERGE: 1.50.1.1

  mysql-test/r/myisam.result@stripped, 2006-10-19 14:37:44+02:00, gkodinov@stripped +0 -0
    Auto merged
    MERGE: 1.85.1.1

  mysql-test/r/select.result@stripped, 2006-10-19 14:37:44+02:00, gkodinov@stripped +0 -0
    Auto merged
    MERGE: 1.138.1.1

  mysql-test/r/view.result@stripped, 2006-10-19 14:37:44+02:00, gkodinov@stripped +0 -0
    Auto merged
    MERGE: 1.178.1.1

  sql/item_cmpfunc.cc@stripped, 2006-10-19 14:37:44+02:00, gkodinov@stripped +0 -0
    Auto merged
    MERGE: 1.221.1.1

  sql/item_cmpfunc.h@stripped, 2006-10-19 14:37:44+02:00, gkodinov@stripped +0 -0
    Auto merged
    MERGE: 1.131.1.1

  sql/mysql_priv.h@stripped, 2006-10-19 14:37:45+02:00, gkodinov@stripped +0 -0
    Auto merged
    MERGE: 1.412.2.2

  sql/opt_range.cc@stripped, 2006-10-19 14:37:45+02:00, gkodinov@stripped +0 -0
    Auto merged
    MERGE: 1.226.2.1

  sql/opt_range.h@stripped, 2006-10-19 14:37:45+02:00, gkodinov@stripped +0 -0
    Auto merged
    MERGE: 1.62.1.1

  sql/sql_select.cc@stripped, 2006-10-19 14:37:45+02:00, gkodinov@stripped +0 -0
    Auto merged
    MERGE: 1.458.1.5

  sql/sql_table.cc@stripped, 2006-10-19 14:37:45+02:00, gkodinov@stripped +0 -0
    Auto merged
    MERGE: 1.321.1.2

  sql/sql_update.cc@stripped, 2006-10-19 14:37:45+02:00, gkodinov@stripped +0 -0
    Auto merged
    MERGE: 1.197.3.1

  sql/table.cc@stripped, 2006-10-19 14:37:45+02:00, gkodinov@stripped +0 -0
    Auto merged
    MERGE: 1.232.1.2

# 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:	gkodinov
# Host:	dl145s.mysql.com
# Root:	/data/bk/team_tree_merge/MERGE/mysql-5.0-opt/RESYNC

--- 1.222/sql/item_cmpfunc.cc	2006-10-19 14:37:55 +02:00
+++ 1.223/sql/item_cmpfunc.cc	2006-10-19 14:37:55 +02:00
@@ -1078,6 +1078,8 @@
   if (Item_func_opt_neg::fix_fields(thd, ref))
     return 1;
 
+  thd->lex->current_select->between_count++;
+
   /* not_null_tables_cache == union(T1(e),T1(e1),T1(e2)) */
   if (pred_level && !negated)
     return 0;

--- 1.132/sql/item_cmpfunc.h	2006-10-19 14:37:55 +02:00
+++ 1.133/sql/item_cmpfunc.h	2006-10-19 14:37:55 +02:00
@@ -446,6 +446,7 @@
     negated= !negated;
     return this;
   }
+  bool subst_argument_checker(byte **arg) { return TRUE; }
 };
 
 

--- 1.415/sql/mysql_priv.h	2006-10-19 14:37:56 +02:00
+++ 1.416/sql/mysql_priv.h	2006-10-19 14:37:56 +02:00
@@ -659,6 +659,9 @@
 		   const char *table_name);
 void close_cached_table(THD *thd, TABLE *table);
 bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list);
+bool do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db,
+                      char *new_table_name, char *new_table_alias,
+                      bool skip_error);
 bool mysql_change_db(THD *thd,const char *name,bool no_access_check);
 void mysql_parse(THD *thd,char *inBuf,uint length);
 bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
@@ -722,7 +725,8 @@
 
 bool check_simple_select();
 
-SORT_FIELD * make_unireg_sortorder(ORDER *order, uint *length);
+SORT_FIELD * make_unireg_sortorder(ORDER *order, uint *length,
+                                  SORT_FIELD *sortorder);
 int setup_order(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
 		List<Item> &fields, List <Item> &all_fields, ORDER *order);
 int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,

--- 1.229/sql/opt_range.cc	2006-10-19 14:37:56 +02:00
+++ 1.230/sql/opt_range.cc	2006-10-19 14:37:56 +02:00
@@ -8372,6 +8372,7 @@
     quick->quick_prefix_select= NULL;
 
   quick->update_key_stat();
+  quick->adjust_prefix_ranges();
 
   DBUG_RETURN(quick);
 }
@@ -8598,6 +8599,42 @@
   if (insert_dynamic(&min_max_ranges, (gptr)&range))
     return TRUE;
   return FALSE;
+}
+
+
+/*
+  Opens the ranges if there are more conditions in quick_prefix_select than
+  the ones used for jumping through the prefixes.
+
+  SYNOPSIS
+    QUICK_GROUP_MIN_MAX_SELECT::adjust_prefix_ranges()
+
+  NOTES
+    quick_prefix_select is made over the conditions on the whole key.
+    It defines a number of ranges of length x. 
+    However when jumping through the prefixes we use only the the first 
+    few most significant keyparts in the range key. However if there
+    are more keyparts to follow the ones we are using we must make the 
+    condition on the key inclusive (because x < "ab" means 
+    x[0] < 'a' OR (x[0] == 'a' AND x[1] < 'b').
+    To achive the above we must turn off the NEAR_MIN/NEAR_MAX
+*/
+void QUICK_GROUP_MIN_MAX_SELECT::adjust_prefix_ranges ()
+{
+  if (quick_prefix_select &&
+      group_prefix_len < quick_prefix_select->max_used_key_length)
+  {
+    DYNAMIC_ARRAY *arr;
+    uint inx;
+
+    for (inx= 0, arr= &quick_prefix_select->ranges; inx < arr->elements; inx++)
+    {
+      QUICK_RANGE *range;
+
+      get_dynamic(arr, (gptr)&range, inx);
+      range->flag &= ~(NEAR_MIN | NEAR_MAX);
+    }
+  }
 }
 
 

--- 1.63/sql/opt_range.h	2006-10-19 14:37:56 +02:00
+++ 1.64/sql/opt_range.h	2006-10-19 14:37:56 +02:00
@@ -295,6 +295,7 @@
   friend class QUICK_SELECT_DESC;
   friend class QUICK_INDEX_MERGE_SELECT;
   friend class QUICK_ROR_INTERSECT_SELECT;
+  friend class QUICK_GROUP_MIN_MAX_SELECT;
 
   DYNAMIC_ARRAY ranges;     /* ordered array of range ptrs */
   QUICK_RANGE **cur_range;  /* current element in ranges  */
@@ -643,6 +644,7 @@
   ~QUICK_GROUP_MIN_MAX_SELECT();
   bool add_range(SEL_ARG *sel_range);
   void update_key_stat();
+  void adjust_prefix_ranges();
   bool alloc_buffers();
   int init();
   int reset();

--- 1.463/sql/sql_select.cc	2006-10-19 14:37:56 +02:00
+++ 1.464/sql/sql_select.cc	2006-10-19 14:37:56 +02:00
@@ -1137,17 +1137,28 @@
 
     tmp_table_param.hidden_field_count= (all_fields.elements -
 					 fields_list.elements);
+    ORDER *tmp_group= ((!simple_group && !procedure &&
+                        !(test_flags & TEST_NO_KEY_GROUP)) ? group_list :
+                                                             (ORDER*) 0);
+    /*
+      Pushing LIMIT to the temporary table creation is not applicable
+      when there is ORDER BY or GROUP BY or there is no GROUP BY, but
+      there are aggregate functions, because in all these cases we need
+      all result rows.
+    */
+    ha_rows tmp_rows_limit= ((order == 0 || skip_sort_order ||
+                              test(select_options & OPTION_BUFFER_RESULT)) &&
+                             !tmp_group &&
+                             !thd->lex->current_select->with_sum_func) ?
+                            select_limit : HA_POS_ERROR;
+
     if (!(exec_tmp_table1 =
 	  create_tmp_table(thd, &tmp_table_param, all_fields,
-			   ((!simple_group && !procedure &&
-			     !(test_flags & TEST_NO_KEY_GROUP)) ?
-			    group_list : (ORDER*) 0),
+                           tmp_group,
 			   group_list ? 0 : select_distinct,
 			   group_list && simple_group,
 			   select_options,
-			   (order == 0 || skip_sort_order || 
-                            test(select_options & OPTION_BUFFER_RESULT)) ? 
-                             select_limit : HA_POS_ERROR,
+                           tmp_rows_limit,
 			   (char *) "")))
       DBUG_RETURN(1);
 
@@ -8269,7 +8280,7 @@
       Field *field=((Item_field*) args[0])->field;
       if (field->flags & AUTO_INCREMENT_FLAG && !field->table->maybe_null &&
 	  (thd->options & OPTION_AUTO_IS_NULL) &&
-	  thd->insert_id() && thd->substitute_null_with_insert_id)
+          thd->current_insert_id && thd->substitute_null_with_insert_id)
       {
 #ifdef HAVE_QUERY_CACHE
 	query_cache_abort(&thd->net);
@@ -8277,9 +8288,16 @@
 	COND *new_cond;
 	if ((new_cond= new Item_func_eq(args[0],
 					new Item_int("last_insert_id()",
-						     thd->insert_id(),
+						     thd->current_insert_id,
 						     21))))
 	{
+          /*
+            Set THD::last_insert_id_used_bin_log manually, as this
+            statement uses LAST_INSERT_ID() in a sense, and should
+            issue LAST_INSERT_ID_EVENT.
+          */
+          thd->last_insert_id_used_bin_log= TRUE;
+
 	  cond=new_cond;
           /*
             Item_func_eq can't be fixed after creation so we do not check
@@ -9224,6 +9242,13 @@
                               thd->variables.max_heap_table_size) :
                           thd->variables.tmp_table_size)/ table->s->reclength);
   set_if_bigger(table->s->max_rows,1);		// For dummy start options
+  /*
+    Push the LIMIT clause to the temporary table creation, so that we
+    materialize only up to 'rows_limit' records instead of all result records.
+  */
+  set_if_smaller(table->s->max_rows, rows_limit);
+  param->end_write_records= rows_limit;
+
   keyinfo= param->keyinfo;
 
   if (group)
@@ -9351,19 +9376,6 @@
 	 (ha_base_keytype) key_part_info->type == HA_KEYTYPE_VARTEXT2) ?
 	0 : FIELDFLAG_BINARY;
     }
-  }
-
-  /*
-    Push the LIMIT clause to the temporary table creation, so that we
-    materialize only up to 'rows_limit' records instead of all result records.
-    This optimization is not applicable when there is GROUP BY or there is
-    no GROUP BY, but there are aggregate functions, because both must be
-    computed for all result rows.
-  */
-  if (!group && !thd->lex->current_select->with_sum_func)
-  {
-    set_if_smaller(table->s->max_rows, rows_limit);
-    param->end_write_records= rows_limit;
   }
 
   if (thd->is_fatal_error)				// If end of memory

--- 1.322/sql/sql_table.cc	2006-10-19 14:37:56 +02:00
+++ 1.323/sql/sql_table.cc	2006-10-19 14:37:56 +02:00
@@ -3155,9 +3155,10 @@
   ha_rows copied,deleted;
   ulonglong next_insert_id;
   uint db_create_options, used_fields;
-  enum db_type old_db_type,new_db_type;
+  enum db_type old_db_type, new_db_type, table_type;
   bool need_copy_table;
   bool no_table_reopen= FALSE, varchar= FALSE;
+  frm_type_enum frm_type;
   DBUG_ENTER("mysql_alter_table");
 
   thd->proc_info="init";
@@ -3175,6 +3176,51 @@
   if (alter_info->tablespace_op != NO_TABLESPACE_OP)
     DBUG_RETURN(mysql_discard_or_import_tablespace(thd,table_list,
 						   alter_info->tablespace_op));
+  sprintf(new_name_buff,"%s/%s/%s%s",mysql_data_home, db, table_name, reg_ext);
+  unpack_filename(new_name_buff, new_name_buff);
+  if (lower_case_table_names != 2)
+    my_casedn_str(files_charset_info, new_name_buff);
+  frm_type= mysql_frm_type(thd, new_name_buff, &table_type);
+  /* Rename a view */
+  if (frm_type == FRMTYPE_VIEW && !(alter_info->flags & ~ALTER_RENAME))
+  {
+    /*
+      Avoid problems with a rename on a table that we have locked or
+      if the user is trying to to do this in a transcation context
+    */
+
+    if (thd->locked_tables || thd->active_transaction())
+    {
+      my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
+                 ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
+      DBUG_RETURN(1);
+    }
+
+    if (wait_if_global_read_lock(thd,0,1))
+      DBUG_RETURN(1);
+    VOID(pthread_mutex_lock(&LOCK_open));
+    if (lock_table_names(thd, table_list))
+      goto view_err;
+    
+    error=0;
+    if (!do_rename(thd, table_list, new_db, new_name, new_name, 1))
+    {
+      if (mysql_bin_log.is_open())
+      {
+        thd->clear_error();
+        Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
+        mysql_bin_log.write(&qinfo);
+      }
+      send_ok(thd);
+    }
+
+    unlock_table_names(thd, table_list, (TABLE_LIST*) 0);
+
+view_err:
+    pthread_mutex_unlock(&LOCK_open);
+    start_waiting_global_read_lock(thd);
+    DBUG_RETURN(error);
+  }
   if (!(table=open_ltable(thd,table_list,TL_WRITE_ALLOW_READ)))
     DBUG_RETURN(TRUE);
 
@@ -4050,7 +4096,7 @@
     if (thd->lex->select_lex.setup_ref_array(thd, order_num) ||
 	setup_order(thd, thd->lex->select_lex.ref_pointer_array,
 		    &tables, fields, all_fields, order) ||
-	!(sortorder=make_unireg_sortorder(order, &length)) ||
+	!(sortorder=make_unireg_sortorder(order, &length, NULL)) ||
 	(from->sort.found_records = filesort(thd, from, sortorder, length,
 					     (SQL_SELECT *) 0, HA_POS_ERROR,
 					     &examined_rows)) ==

--- 1.200/sql/sql_update.cc	2006-10-19 14:37:56 +02:00
+++ 1.201/sql/sql_update.cc	2006-10-19 14:37:56 +02:00
@@ -311,7 +311,7 @@
 
       table->sort.io_cache = (IO_CACHE *) my_malloc(sizeof(IO_CACHE),
 						    MYF(MY_FAE | MY_ZEROFILL));
-      if (!(sortorder=make_unireg_sortorder(order, &length)) ||
+      if (!(sortorder=make_unireg_sortorder(order, &length, NULL)) ||
           (table->sort.found_records = filesort(thd, table, sortorder, length,
 						select, limit,
 						&examined_rows))

--- 1.236/sql/table.cc	2006-10-19 14:37:56 +02:00
+++ 1.237/sql/table.cc	2006-10-19 14:37:56 +02:00
@@ -1977,12 +1977,13 @@
             this expression will not be moved to WHERE condition (i.e. will
             be clean correctly for PS/SP)
           */
-          tbl->on_expr= and_conds(tbl->on_expr, where);
+          tbl->on_expr= and_conds(tbl->on_expr,
+                                  where->copy_andor_structure(thd));
           break;
         }
       }
       if (tbl == 0)
-        *conds= and_conds(*conds, where);
+        *conds= and_conds(*conds, where->copy_andor_structure(thd));
       if (arena)
         thd->restore_active_arena(arena, &backup);
       where_processed= TRUE;

--- 1.179/mysql-test/r/view.result	2006-10-19 14:37:56 +02:00
+++ 1.180/mysql-test/r/view.result	2006-10-19 14:37:56 +02:00
@@ -1306,9 +1306,9 @@
 delete from t1;
 load data infile '../std_data_ln/loaddata3.dat' ignore into table v1 fields terminated by '' enclosed by '' ignore 1 lines;
 Warnings:
-Warning	1264	Out of range value adjusted for column 'a' at row 3
+Warning	1366	Incorrect integer value: 'error      ' for column 'a' at row 3
 Error	1369	CHECK OPTION failed 'test.v1'
-Warning	1264	Out of range value adjusted for column 'a' at row 4
+Warning	1366	Incorrect integer value: 'wrong end  ' for column 'a' at row 4
 Error	1369	CHECK OPTION failed 'test.v1'
 select * from t1;
 a	b

--- 1.54/mysql-test/r/merge.result	2006-10-19 14:37:56 +02:00
+++ 1.55/mysql-test/r/merge.result	2006-10-19 14:37:56 +02:00
@@ -626,7 +626,7 @@
 EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
 AND file_code = '0000000115' LIMIT 1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ref	PRIMARY,files	PRIMARY	35	const,const	1	Using where
+1	SIMPLE	t2	const	PRIMARY,files	PRIMARY	35	const,const	1	
 DROP TABLE t2, t1;
 create table t1 (x int, y int, index xy(x, y));
 create table t2 (x int, y int, index xy(x, y));

--- 1.142/mysql-test/r/select.result	2006-10-19 14:37:56 +02:00
+++ 1.143/mysql-test/r/select.result	2006-10-19 14:37:56 +02:00
@@ -2734,7 +2734,7 @@
 INSERT INTO t1 VALUES (10);
 SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;
 i='1e+01'	i=1e+01	i in (1e+01,1e+01)	i in ('1e+01','1e+01')
-0	1	1	1
+1	1	1	1
 DROP TABLE t1;
 CREATE TABLE t1 (a int, b int);
 INSERT INTO t1 VALUES (1,1), (2,1), (4,10);

--- 1.87/mysql-test/r/myisam.result	2006-10-19 14:37:56 +02:00
+++ 1.88/mysql-test/r/myisam.result	2006-10-19 14:37:56 +02:00
@@ -1002,15 +1002,15 @@
 select sql_big_result v,count(c) from t1 group by v limit 10;
 v	count(c)
 a	1
-a	10
-b	10
-c	10
-d	10
-e	10
-f	10
-g	10
+a 	10
+b     	10
+c    	10
+d   	10
+e  	10
+f     	10
+g    	10
 h	10
-i	10
+i     	10
 select c,count(*) from t1 group by c limit 10;
 c	count(*)
 a	1
Thread
bk commit into 5.0 tree (gkodinov:1.2282)gkodinov19 Oct