List:Commits« Previous MessageNext Message »
From:konstantin Date:November 1 2006 10:08pm
Subject:bk commit into 4.1 tree (kostja:1.2539)
View as plain text  
Below is the list of changes that have just been committed into a local
4.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-11-02 01:08:39+03:00, kostja@stripped +13 -0
  Merge bk-internal.mysql.com:/home/bk/mysql-4.1
  into  bodhi.local:/opt/local/work/mysql-4.1-runtime
  MERGE: 1.2522.66.5

  mysql-test/r/ps.result@stripped, 2006-11-02 01:08:27+03:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.49.1.3

  mysql-test/t/func_gconcat.test@stripped, 2006-11-02 01:08:27+03:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.37.1.1

  sql/item_func.cc@stripped, 2006-11-02 01:08:27+03:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.262.2.1

  sql/item_func.h@stripped, 2006-11-02 01:08:27+03:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.131.1.1

  sql/item_sum.cc@stripped, 2006-11-02 01:08:27+03:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.148.1.1

  sql/log_event.cc@stripped, 2006-11-02 01:08:28+03:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.188.1.1

  sql/mysql_priv.h@stripped, 2006-11-02 01:08:28+03:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.380.1.2

  sql/mysqld.cc@stripped, 2006-11-02 01:08:28+03:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.616.1.1

  sql/set_var.cc@stripped, 2006-11-02 01:08:29+03:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.186.1.1

  sql/sql_class.h@stripped, 2006-11-02 01:08:29+03:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.287.2.1

  sql/sql_delete.cc@stripped, 2006-11-02 01:08:29+03:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.139.1.1

  sql/sql_select.cc@stripped, 2006-11-02 01:08:31+03:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.459.3.1

  sql/sql_update.cc@stripped, 2006-11-02 01:08:32+03:00, kostja@stripped +0 -0
    Auto merged
    MERGE: 1.156.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-4.1-runtime/RESYNC

--- 1.266/sql/item_func.cc	2006-11-02 01:08:51 +03:00
+++ 1.267/sql/item_func.cc	2006-11-02 01:08:51 +03:00
@@ -2250,6 +2250,30 @@ longlong Item_func_release_lock::val_int
 }
 
 
+bool Item_func_last_insert_id::fix_fields(THD *thd, TABLE_LIST *tables,
+                                          Item **ref)
+{
+  DBUG_ASSERT(fixed == 0);
+
+  if (Item_int_func::fix_fields(thd, tables, ref))
+    return TRUE;
+
+  if (arg_count == 0)
+  {
+    /*
+      As this statement calls LAST_INSERT_ID(), set
+      THD::last_insert_id_used.
+    */
+    thd->last_insert_id_used= TRUE;
+    null_value= FALSE;
+  }
+
+  thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
+
+  return FALSE;
+}
+
+
 longlong Item_func_last_insert_id::val_int()
 {
   DBUG_ASSERT(fixed == 1);
@@ -2259,11 +2283,12 @@ longlong Item_func_last_insert_id::val_i
     longlong value=args[0]->val_int();
     thd->insert_id(value);
     null_value=args[0]->null_value;
+    return value;
   }
-  else
-    thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
-  return thd->last_insert_id_used ? thd->current_insert_id : thd->insert_id();
+
+  return thd->current_insert_id;
 }
+
 
 /* This function is just used to test speed of different functions */
 

--- 1.133/sql/item_func.h	2006-11-02 01:08:51 +03:00
+++ 1.134/sql/item_func.h	2006-11-02 01:08:51 +03:00
@@ -758,6 +758,7 @@ public:
   longlong val_int();
   const char *func_name() const { return "last_insert_id"; }
   void fix_length_and_dec() { if (arg_count) max_length= args[0]->max_length; }
+  bool fix_fields(THD *thd, TABLE_LIST *tables, Item **ref);
 };
 
 class Item_func_benchmark :public Item_int_func

--- 1.149/sql/item_sum.cc	2006-11-02 01:08:51 +03:00
+++ 1.150/sql/item_sum.cc	2006-11-02 01:08:51 +03:00
@@ -312,6 +312,7 @@ longlong Item_sum_count::val_int()
 void Item_sum_count::cleanup()
 {
   DBUG_ENTER("Item_sum_count::cleanup");
+  clear();
   Item_sum_int::cleanup();
   used_table_cache= ~(table_map) 0;
   DBUG_VOID_RETURN;

--- 1.190/sql/log_event.cc	2006-11-02 01:08:51 +03:00
+++ 1.191/sql/log_event.cc	2006-11-02 01:08:51 +03:00
@@ -2255,7 +2255,6 @@ int Intvar_log_event::exec_event(struct 
 {
   switch (type) {
   case LAST_INSERT_ID_EVENT:
-    thd->last_insert_id_used = 1;
     thd->last_insert_id = val;
     break;
   case INSERT_ID_EVENT:

--- 1.382/sql/mysql_priv.h	2006-11-02 01:08:51 +03:00
+++ 1.383/sql/mysql_priv.h	2006-11-02 01:08:51 +03:00
@@ -95,6 +95,8 @@ MY_LOCALE *my_locale_by_name(const char 
 #define MAX_ACCEPT_RETRY	10	// Test accept this many times
 #define MAX_FIELDS_BEFORE_HASH	32
 #define USER_VARS_HASH_SIZE     16
+#define TABLE_OPEN_CACHE_MIN    64
+#define TABLE_OPEN_CACHE_DEFAULT 64
 #define STACK_MIN_SIZE		8192	// Abort if less stack during eval.
 #define STACK_BUFF_ALLOC	64	// For stack overrun checks
 #ifndef MYSQLD_NET_RETRY_COUNT

--- 1.618/sql/mysqld.cc	2006-11-02 01:08:51 +03:00
+++ 1.619/sql/mysqld.cc	2006-11-02 01:08:51 +03:00
@@ -2526,19 +2526,43 @@ static int init_common_variables(const c
 
   /* connections and databases needs lots of files */
   {
-    uint files, wanted_files;
+    uint files, wanted_files, max_open_files;
 
-    wanted_files= 10+(uint) max(max_connections*5,
-				 max_connections+table_cache_size*2);
-    set_if_bigger(wanted_files, open_files_limit);
-    files= my_set_max_open_files(wanted_files);
+    /* MyISAM requires two file handles per table. */
+    wanted_files= 10+max_connections+table_cache_size*2;
+    /*
+      We are trying to allocate no less than max_connections*5 file
+      handles (i.e. we are trying to set the limit so that they will
+      be available).  In addition, we allocate no less than how much
+      was already allocated.  However below we report a warning and
+      recompute values only if we got less file handles than were
+      explicitly requested.  No warning and re-computation occur if we
+      can't get max_connections*5 but still got no less than was
+      requested (value of wanted_files).
+    */
+    max_open_files= max(max(wanted_files, max_connections*5),
+                        open_files_limit);
+    files= my_set_max_open_files(max_open_files);
 
     if (files < wanted_files)
     {
       if (!open_files_limit)
       {
-	max_connections=	(ulong) min((files-10),max_connections);
-	table_cache_size= (ulong) max((files-10-max_connections)/2,64);
+        /*
+          If we have requested too much file handles than we bring
+          max_connections in supported bounds.
+        */
+        max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
+                                     max_connections);
+        /*
+          Decrease table_cache_size according to max_connections, but
+          not below TABLE_OPEN_CACHE_MIN.  Outer min() ensures that we
+          never increase table_cache_size automatically (that could
+          happen if max_connections is decreased above).
+        */
+        table_cache_size= (ulong) min(max((files-10-max_connections)/2,
+                                          TABLE_OPEN_CACHE_MIN),
+                                      table_cache_size);    
 	DBUG_PRINT("warning",
 		   ("Changed limits: max_open_files: %u  max_connections: %ld  table_cache: %ld",
 		    files, max_connections, table_cache_size));
@@ -5511,8 +5535,8 @@ The minimum value for this variable is 4
    0, 0, 0, 0},
   {"table_cache", OPT_TABLE_CACHE,
    "The number of open tables for all threads.", (gptr*) &table_cache_size,
-   (gptr*) &table_cache_size, 0, GET_ULONG, REQUIRED_ARG, 64, 1, 512*1024L,
-   0, 1, 0},
+   (gptr*) &table_cache_size, 0, GET_ULONG, REQUIRED_ARG,
+   TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
   {"thread_cache_size", OPT_THREAD_CACHE_SIZE,
    "How many threads we should keep in a cache for reuse.",
    (gptr*) &thread_cache_size, (gptr*) &thread_cache_size, 0, GET_ULONG,

--- 1.289/sql/sql_class.h	2006-11-02 01:08:51 +03:00
+++ 1.290/sql/sql_class.h	2006-11-02 01:08:51 +03:00
@@ -835,17 +835,29 @@ public:
     generated auto_increment value in handler.cc
   */
   ulonglong  next_insert_id;
+
   /*
-    The insert_id used for the last statement or set by SET LAST_INSERT_ID=#
-    or SELECT LAST_INSERT_ID(#).  Used for binary log and returned by
-    LAST_INSERT_ID()
+    At the beginning of the statement last_insert_id holds the first
+    generated value of the previous statement.  During statement
+    execution it is updated to the value just generated, but then
+    restored to the value that was generated first, so for the next
+    statement it will again be "the first generated value of the
+    previous statement".
+
+    It may also be set with "LAST_INSERT_ID(expr)" or
+    "@@LAST_INSERT_ID= expr", but the effect of such setting will be
+    seen only in the next statement.
   */
   ulonglong  last_insert_id;
+
   /*
-    Set to the first value that LAST_INSERT_ID() returned for the last
-    statement.  When this is set, last_insert_id_used is set to true.
+    current_insert_id remembers the first generated value of the
+    previous statement, and does not change during statement
+    execution.  Its value returned from LAST_INSERT_ID() and
+    @@LAST_INSERT_ID.
   */
   ulonglong  current_insert_id;
+
   ulonglong  limit_found_rows;
   ha_rows    cuted_fields,
              sent_row_count, examined_row_count;
@@ -896,7 +908,22 @@ public:
   bool	     locked, some_tables_deleted;
   bool       last_cuted_field;
   bool	     no_errors, password, is_fatal_error;
-  bool	     query_start_used,last_insert_id_used,insert_id_used,rand_used;
+  bool	     query_start_used, rand_used;
+
+  /*
+    last_insert_id_used is set when current statement calls
+    LAST_INSERT_ID() or reads @@LAST_INSERT_ID, so that binary log
+    LAST_INSERT_ID_EVENT be generated.
+  */
+  bool	     last_insert_id_used;
+
+  /*
+    insert_id_used is set when current statement updates
+    THD::last_insert_id, so that binary log INSERT_ID_EVENT be
+    generated.
+  */
+  bool       insert_id_used;
+
   /* for IS NULL => = last_insert_id() fix in remove_eq_conds() */
   bool       substitute_null_with_insert_id;
   bool	     time_zone_used;
@@ -995,15 +1022,6 @@ public:
     last_insert_id= id_arg;
     insert_id_used=1;
     substitute_null_with_insert_id= TRUE;
-  }
-  inline ulonglong insert_id(void)
-  {
-    if (!last_insert_id_used)
-    {      
-      last_insert_id_used=1;
-      current_insert_id=last_insert_id;
-    }
-    return last_insert_id;
   }
   inline ulonglong found_rows(void)
   {

--- 1.140/sql/sql_delete.cc	2006-11-02 01:08:51 +03:00
+++ 1.141/sql/sql_delete.cc	2006-11-02 01:08:51 +03:00
@@ -258,7 +258,8 @@ cleanup:
     mysql_unlock_tables(thd, thd->lock);
     thd->lock=0;
   }
-  if (error >= 0 || thd->net.report_error)
+  if ((error >= 0 || thd->net.report_error) &&
+      (!thd->lex->ignore || thd->is_fatal_error))
     send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN: 0);
   else
   {

--- 1.463/sql/sql_select.cc	2006-11-02 01:08:52 +03:00
+++ 1.464/sql/sql_select.cc	2006-11-02 01:08:52 +03:00
@@ -4838,7 +4838,7 @@ remove_eq_conds(THD *thd, COND *cond, It
       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);
@@ -4846,9 +4846,16 @@ remove_eq_conds(THD *thd, COND *cond, It
 	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 manually, as this statement
+            uses LAST_INSERT_ID() in a sense, and should issue
+            LAST_INSERT_ID_EVENT.
+          */
+          thd->last_insert_id_used= TRUE;
+
 	  cond=new_cond;
 	  cond->fix_fields(thd, 0, &cond);
 	}

--- 1.157/sql/sql_update.cc	2006-11-02 01:08:52 +03:00
+++ 1.158/sql/sql_update.cc	2006-11-02 01:08:52 +03:00
@@ -408,7 +408,7 @@ int mysql_update(THD *thd,
 	    (ulong) thd->cuted_fields);
     send_ok(thd,
 	    (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated,
-	    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 */
@@ -1324,6 +1324,6 @@ bool multi_update::send_eof()
 	  (ulong) thd->cuted_fields);
   ::send_ok(thd,
 	    (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated,
-	    thd->insert_id_used ? thd->insert_id() : 0L,buff);
+	    thd->insert_id_used ? thd->last_insert_id : 0L,buff);
   return 0;
 }

--- 1.187/sql/set_var.cc	2006-11-02 01:08:52 +03:00
+++ 1.188/sql/set_var.cc	2006-11-02 01:08:52 +03:00
@@ -2404,8 +2404,12 @@ bool sys_var_last_insert_id::update(THD 
 byte *sys_var_last_insert_id::value_ptr(THD *thd, enum_var_type type,
 					LEX_STRING *base)
 {
-  thd->sys_var_tmp.long_value= (long) thd->insert_id();
-  return (byte*) &thd->last_insert_id;
+  /*
+    As this statement reads @@LAST_INSERT_ID, set
+    THD::last_insert_id_used.
+  */
+  thd->last_insert_id_used= TRUE;
+  return (byte*) &thd->current_insert_id;
 }
 
 

--- 1.51/mysql-test/r/ps.result	2006-11-02 01:08:52 +03:00
+++ 1.52/mysql-test/r/ps.result	2006-11-02 01:08:52 +03:00
@@ -936,3 +936,100 @@ GROUP_CONCAT(Track SEPARATOR ', ')
 CAD
 DEALLOCATE PREPARE STMT;
 DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT, INDEX(i));
+INSERT INTO t1 VALUES (1);
+PREPARE stmt FROM "SELECT (COUNT(i) = 1), COUNT(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+(COUNT(i) = 1)	COUNT(i)
+0	0
+SET @a = 1;
+EXECUTE stmt USING @a;
+(COUNT(i) = 1)	COUNT(i)
+1	1
+SET @a = 0;
+EXECUTE stmt USING @a;
+(COUNT(i) = 1)	COUNT(i)
+0	0
+PREPARE stmt FROM "SELECT (AVG(i) = 1), AVG(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+(AVG(i) = 1)	AVG(i)
+NULL	NULL
+SET @a = 1;
+EXECUTE stmt USING @a;
+(AVG(i) = 1)	AVG(i)
+1	1.0000
+SET @a = 0;
+EXECUTE stmt USING @a;
+(AVG(i) = 1)	AVG(i)
+NULL	NULL
+PREPARE stmt FROM "SELECT (VARIANCE(i) = 1), VARIANCE(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+(VARIANCE(i) = 1)	VARIANCE(i)
+NULL	NULL
+SET @a = 1;
+EXECUTE stmt USING @a;
+(VARIANCE(i) = 1)	VARIANCE(i)
+0	0.0000
+SET @a = 0;
+EXECUTE stmt USING @a;
+(VARIANCE(i) = 1)	VARIANCE(i)
+NULL	NULL
+PREPARE stmt FROM "SELECT (STDDEV(i) = 1), STDDEV(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+(STDDEV(i) = 1)	STDDEV(i)
+NULL	NULL
+SET @a = 1;
+EXECUTE stmt USING @a;
+(STDDEV(i) = 1)	STDDEV(i)
+0	0.0000
+SET @a = 0;
+EXECUTE stmt USING @a;
+(STDDEV(i) = 1)	STDDEV(i)
+NULL	NULL
+PREPARE stmt FROM "SELECT (BIT_OR(i) = 1), BIT_OR(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+(BIT_OR(i) = 1)	BIT_OR(i)
+0	0
+SET @a = 1;
+EXECUTE stmt USING @a;
+(BIT_OR(i) = 1)	BIT_OR(i)
+1	1
+SET @a = 0;
+EXECUTE stmt USING @a;
+(BIT_OR(i) = 1)	BIT_OR(i)
+0	0
+PREPARE stmt FROM "SELECT (BIT_AND(i) = 1), BIT_AND(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+(BIT_AND(i) = 1)	BIT_AND(i)
+0	18446744073709551615
+SET @a = 1;
+EXECUTE stmt USING @a;
+(BIT_AND(i) = 1)	BIT_AND(i)
+1	1
+SET @a = 0;
+EXECUTE stmt USING @a;
+(BIT_AND(i) = 1)	BIT_AND(i)
+0	18446744073709551615
+PREPARE stmt FROM "SELECT (BIT_XOR(i) = 1), BIT_XOR(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+(BIT_XOR(i) = 1)	BIT_XOR(i)
+0	0
+SET @a = 1;
+EXECUTE stmt USING @a;
+(BIT_XOR(i) = 1)	BIT_XOR(i)
+1	1
+SET @a = 0;
+EXECUTE stmt USING @a;
+(BIT_XOR(i) = 1)	BIT_XOR(i)
+0	0
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
+End of 4.1 tests.

--- 1.38/mysql-test/t/func_gconcat.test	2006-11-02 01:08:52 +03:00
+++ 1.39/mysql-test/t/func_gconcat.test	2006-11-02 01:08:52 +03:00
@@ -32,7 +32,6 @@ select grp,group_concat(d order by a des
 select grp,group_concat(a order by a,d+c-ascii(c)-a) from t1 group by grp;
 select grp,group_concat(a order by d+c-ascii(c),a) from t1 group by grp;
 select grp,group_concat(c order by 1) from t1 group by grp;
-select grp,group_concat(c order by "c") from t1 group by grp;
 select grp,group_concat(distinct c order by c) from t1 group by grp;
 select grp,group_concat(distinct c order by c desc) from t1 group by grp;
 explain extended select grp,group_concat(distinct c order by c desc) from t1 group by grp;
Thread
bk commit into 4.1 tree (kostja:1.2539)konstantin1 Nov