List:Commits« Previous MessageNext Message »
From:dlenev Date:October 2 2006 7:41pm
Subject:bk commit into 5.1 tree (dlenev:1.2336)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of dlenev. When dlenev 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-02 21:41:35+04:00, dlenev@stripped +6 -0
  Merge bk-internal.mysql.com:/home/bk/mysql-5.1
  into  mockturtle.local:/home/dlenev/src/mysql-5.1-rt-merge
  MERGE: 1.2328.3.8

  mysql-test/r/ps.result@stripped, 2006-10-02 21:41:30+04:00, dlenev@stripped +0 -0
    Auto merged
    MERGE: 1.73.1.1

  mysql-test/t/ps.test@stripped, 2006-10-02 21:41:30+04:00, dlenev@stripped +0 -0
    Auto merged
    MERGE: 1.71.1.1

  sql/item.cc@stripped, 2006-10-02 21:41:31+04:00, dlenev@stripped +0 -0
    Auto merged
    MERGE: 1.211.1.2

  sql/mysql_priv.h@stripped, 2006-10-02 21:41:31+04:00, dlenev@stripped +0 -0
    Auto merged
    MERGE: 1.442.1.4

  sql/opt_range.cc@stripped, 2006-10-02 21:41:31+04:00, dlenev@stripped +0 -0
    Auto merged
    MERGE: 1.235.1.1

  sql/sql_select.cc@stripped, 2006-10-02 21:41:32+04:00, dlenev@stripped +0 -0
    Auto merged
    MERGE: 1.440.1.4

# 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:	dlenev
# Host:	mockturtle.local
# Root:	/home/dlenev/src/mysql-5.1-rt-merge/RESYNC

--- 1.212/sql/item.cc	2006-10-02 21:41:42 +04:00
+++ 1.213/sql/item.cc	2006-10-02 21:41:42 +04:00
@@ -1210,6 +1210,7 @@
     split_sum_func(thd, ref_pointer_array, fields);
   }
   else if ((type() == SUM_FUNC_ITEM || (used_tables() & ~PARAM_TABLE_BIT)) &&
+           type() != SUBSELECT_ITEM &&
            (type() != REF_ITEM ||
            ((Item_ref*)this)->ref_type() == Item_ref::VIEW_REF))
   {
@@ -5710,11 +5711,6 @@
   Item::cleanup();
 }
 
-
-/*
-  If item is a const function, calculate it and return a const item
-  The original item is freed if not returned
-*/
 
 Item_result item_cmp_type(Item_result a,Item_result b)
 {

--- 1.446/sql/mysql_priv.h	2006-10-02 21:41:42 +04:00
+++ 1.447/sql/mysql_priv.h	2006-10-02 21:41:42 +04:00
@@ -458,7 +458,8 @@
   NO_MATTER,
   IN_HAVING,
   SELECT_LIST,
-  IN_WHERE
+  IN_WHERE,
+  IN_ON
 };
 
 struct st_table;
@@ -1637,19 +1638,7 @@
 extern SHOW_COMP_OPTION have_partition_db;
 extern SHOW_COMP_OPTION have_merge_db;
 
-#ifdef WITH_CSV_STORAGE_ENGINE
-extern handlerton *tina_hton;
-#endif
-#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
-extern handlerton *ndbcluster_hton;
-#endif
-#ifdef WITH_PARTITION_STORAGE_ENGINE
 extern handlerton *partition_hton;
-#endif
-#ifdef WITH_MYISAMMRG_STORAGE_ENGINE
-extern handlerton *myisammrg_hton;
-#endif
-
 extern handlerton *myisam_hton;
 extern handlerton *heap_hton;
 

--- 1.236/sql/opt_range.cc	2006-10-02 21:41:42 +04:00
+++ 1.237/sql/opt_range.cc	2006-10-02 21:41:42 +04:00
@@ -7534,42 +7534,42 @@
 }
 
 
-bool QUICK_SELECT_I::check_if_keys_used(List<Item> *fields)
+bool QUICK_SELECT_I::is_keys_used(const MY_BITMAP *fields)
 {
-  return check_if_key_used(head, index, *fields);
+  return is_key_used(head, index, fields);
 }
 
-bool QUICK_INDEX_MERGE_SELECT::check_if_keys_used(List<Item> *fields)
+bool QUICK_INDEX_MERGE_SELECT::is_keys_used(const MY_BITMAP *fields)
 {
   QUICK_RANGE_SELECT *quick;
   List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects);
   while ((quick= it++))
   {
-    if (check_if_key_used(head, quick->index, *fields))
+    if (is_key_used(head, quick->index, fields))
       return 1;
   }
   return 0;
 }
 
-bool QUICK_ROR_INTERSECT_SELECT::check_if_keys_used(List<Item> *fields)
+bool QUICK_ROR_INTERSECT_SELECT::is_keys_used(const MY_BITMAP *fields)
 {
   QUICK_RANGE_SELECT *quick;
   List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects);
   while ((quick= it++))
   {
-    if (check_if_key_used(head, quick->index, *fields))
+    if (is_key_used(head, quick->index, fields))
       return 1;
   }
   return 0;
 }
 
-bool QUICK_ROR_UNION_SELECT::check_if_keys_used(List<Item> *fields)
+bool QUICK_ROR_UNION_SELECT::is_keys_used(const MY_BITMAP *fields)
 {
   QUICK_SELECT_I *quick;
   List_iterator_fast<QUICK_SELECT_I> it(quick_selects);
   while ((quick= it++))
   {
-    if (quick->check_if_keys_used(fields))
+    if (quick->is_keys_used(fields))
       return 1;
   }
   return 0;

--- 1.446/sql/sql_select.cc	2006-10-02 21:41:42 +04:00
+++ 1.447/sql/sql_select.cc	2006-10-02 21:41:42 +04: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);
 
@@ -9302,6 +9313,13 @@
                               thd->variables.max_heap_table_size) :
                           thd->variables.tmp_table_size)/ share->reclength);
   set_if_bigger(share->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(share->max_rows, rows_limit);
+  param->end_write_records= rows_limit;
+
   keyinfo= param->keyinfo;
 
   if (group)
@@ -9432,19 +9450,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.74/mysql-test/r/ps.result	2006-10-02 21:41:42 +04:00
+++ 1.75/mysql-test/r/ps.result	2006-10-02 21:41:42 +04:00
@@ -1291,6 +1291,27 @@
 i	j	i	i	j
 DEALLOCATE PREPARE stmt;
 DROP TABLE IF EXISTS t1, t2, t3;
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (i INT KEY);
+CREATE TABLE t2 (i INT);
+INSERT INTO t1 VALUES (1), (2);
+INSERT INTO t2 VALUES (1);
+PREPARE stmt FROM "SELECT t2.i FROM t1 LEFT JOIN t2 ON t2.i = t1.i
+                   WHERE t1.i = ?";
+SET @arg= 1;
+EXECUTE stmt USING @arg;
+i
+1
+SET @arg= 2;
+EXECUTE stmt USING @arg;
+i
+NULL
+SET @arg= 1;
+EXECUTE stmt USING @arg;
+i
+1
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1, t2;
 End of 5.0 tests.
 create procedure proc_1() reset query cache;
 call proc_1();

--- 1.72/mysql-test/t/ps.test	2006-10-02 21:41:42 +04:00
+++ 1.73/mysql-test/t/ps.test	2006-10-02 21:41:42 +04:00
@@ -1410,6 +1410,33 @@
 DROP TABLE IF EXISTS t1, t2, t3;
 
 
+#
+# BUG#21081: SELECT inside stored procedure returns wrong results
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (i INT KEY);
+CREATE TABLE t2 (i INT);
+
+INSERT INTO t1 VALUES (1), (2);
+INSERT INTO t2 VALUES (1);
+
+PREPARE stmt FROM "SELECT t2.i FROM t1 LEFT JOIN t2 ON t2.i = t1.i
+                   WHERE t1.i = ?";
+
+SET @arg= 1;
+EXECUTE stmt USING @arg;
+SET @arg= 2;
+EXECUTE stmt USING @arg;
+SET @arg= 1;
+EXECUTE stmt USING @arg;
+
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1, t2;
+
+
 --echo End of 5.0 tests.
 
 #
Thread
bk commit into 5.1 tree (dlenev:1.2336)dlenev2 Oct