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

  mysql-test/r/ps.result@stripped, 2006-10-02 22:53:06+04:00, dlenev@stripped +0 -0
    Auto merged
    MERGE: 1.72.1.1

  mysql-test/t/ps.test@stripped, 2006-10-02 22:53:06+04:00, dlenev@stripped +0 -0
    Auto merged
    MERGE: 1.69.1.1

  sql/item.cc@stripped, 2006-10-02 22:53:07+04:00, dlenev@stripped +0 -0
    Auto merged
    MERGE: 1.234.1.1

  sql/mysql_priv.h@stripped, 2006-10-02 22:53:07+04:00, dlenev@stripped +0 -0
    Auto merged
    MERGE: 1.410.1.3

  sql/sql_select.cc@stripped, 2006-10-02 22:53:07+04:00, dlenev@stripped +0 -0
    Auto merged
    MERGE: 1.454.1.3

  sql/sql_update.cc@stripped, 2006-10-02 22:53:07+04:00, dlenev@stripped +0 -0
    Auto merged
    MERGE: 1.197.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:	dlenev
# Host:	mockturtle.local
# Root:	/home/dlenev/src/mysql-5.0-rt-merge/RESYNC

--- 1.235/sql/item.cc	2006-10-02 22:53:16 +04:00
+++ 1.236/sql/item.cc	2006-10-02 22:53:16 +04:00
@@ -3745,6 +3745,7 @@
     I.e. we can drop 'field'.
    */
   field= result_field= 0;
+  null_value= FALSE;
   DBUG_VOID_RETURN;
 }
 

--- 1.412/sql/mysql_priv.h	2006-10-02 22:53:16 +04:00
+++ 1.413/sql/mysql_priv.h	2006-10-02 22:53:16 +04:00
@@ -1114,7 +1114,7 @@
                  uint key_length);
 bool key_cmp_if_same(TABLE *form,const byte *key,uint index,uint key_length);
 void key_unpack(String *to,TABLE *form,uint index);
-bool check_if_key_used(TABLE *table, uint idx, List<Item> &fields);
+bool is_key_used(TABLE *table, uint idx, List<Item> &fields);
 int key_cmp(KEY_PART_INFO *key_part, const byte *key, uint key_length);
 
 bool init_errmessage(void);
@@ -1229,7 +1229,6 @@
 extern bool opt_disable_networking, opt_skip_show_db;
 extern my_bool opt_character_set_client_handshake;
 extern bool volatile abort_loop, shutdown_in_progress, grant_option;
-extern bool mysql_proc_table_exists;
 extern uint volatile thread_count, thread_running, global_read_lock;
 extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types;
 extern my_bool opt_safe_show_db, opt_local_infile;

--- 1.460/sql/sql_select.cc	2006-10-02 22:53:16 +04:00
+++ 1.461/sql/sql_select.cc	2006-10-02 22:53:16 +04:00
@@ -1134,17 +1134,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);
 
@@ -9104,6 +9115,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)
@@ -9231,19 +9249,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.198/sql/sql_update.cc	2006-10-02 22:53:16 +04:00
+++ 1.199/sql/sql_update.cc	2006-10-02 22:53:16 +04:00
@@ -568,7 +568,7 @@
     thd->row_count_func=
       (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
     send_ok(thd, (ulong) thd->row_count_func,
-	    thd->insert_id_used ? thd->insert_id() : 0L,buff);
+	    thd->insert_id_used ? thd->last_insert_id : 0L,buff);
     DBUG_PRINT("info",("%d records updated",updated));
   }
   thd->count_cuted_fields= CHECK_FIELD_IGNORE;		/* calc cuted fields */
@@ -1561,6 +1561,6 @@
   thd->row_count_func=
     (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
   ::send_ok(thd, (ulong) thd->row_count_func,
-	    thd->insert_id_used ? thd->insert_id() : 0L,buff);
+	    thd->insert_id_used ? thd->last_insert_id : 0L,buff);
   return FALSE;
 }

--- 1.74/mysql-test/r/ps.result	2006-10-02 22:53:16 +04:00
+++ 1.75/mysql-test/r/ps.result	2006-10-02 22:53:16 +04:00
@@ -1358,4 +1358,25 @@
 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.

--- 1.71/mysql-test/t/ps.test	2006-10-02 22:53:16 +04:00
+++ 1.72/mysql-test/t/ps.test	2006-10-02 22:53:16 +04:00
@@ -1410,4 +1410,31 @@
 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.0 tree (dlenev:1.2272)dlenev2 Oct