MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:Osku Salerma Date:August 30 2005 9:39am
Subject:bk commit into 5.0 tree (osku:1.1910) BUG#11946
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of osku. When osku 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.1910 05/08/30 12:39:20 osku@127.(none) +6 -0
  Bug #11946: Review fixes.

  sql/sql_parse.cc
    1.477 05/08/30 12:39:17 osku@127.(none) +2 -1
    mysql_execute_command: Adapt to changes in mysql_delete.

  sql/sql_delete.cc
    1.159 05/08/30 12:39:17 osku@127.(none) +6 -5
    Add 'reset_auto_increment' parameter to mysql_delete, and use it instead
    of checking for SQLCOM_TRUNCATE.
    
    mysql_truncate: Adapt to changes in mysql_delete.

  sql/mysql_priv.h
    1.345 05/08/30 12:39:17 osku@127.(none) +3 -2
    Add 'reset_auto_increment' parameter to mysql_delete.

  sql/handler.h
    1.149 05/08/30 12:39:17 osku@127.(none) +7 -6
    Add 'value' parameter to reset_auto_increment.

  sql/ha_innodb.h
    1.102 05/08/30 12:39:17 osku@127.(none) +1 -1
    Add 'value' parameter to reset_auto_increment.

  sql/ha_innodb.cc
    1.249 05/08/30 12:39:17 osku@127.(none) +2 -2
    Add 'value' parameter to reset_auto_increment.

# 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:	osku
# Host:	127.(none)
# Root:	/home/osku/mysql-5.0

--- 1.148/sql/handler.h	2005-08-17 11:00:16 +03:00
+++ 1.149/sql/handler.h	2005-08-30 12:39:17 +03:00
@@ -651,12 +651,13 @@
   virtual ulonglong get_auto_increment();
   virtual void restore_auto_increment();
 
-  /* This is called after TRUNCATE is emulated by doing a 'DELETE FROM t',
-     in which case we need a separate operation for resetting the table's
-     auto-increment counter. HA_ERR_WRONG_COMMAND is returned by storage
-     engines that have no need for this, i.e. those that can always do a
-     fast TRUNCATE. */
-  virtual int reset_auto_increment()
+  /*
+    Reset the auto-increment counter to the given value, i.e. the next row
+    inserted will get the given value. This is called e.g. after TRUNCATE
+    is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is
+    returned by storage engines that don't support this operation.
+  */
+  virtual int reset_auto_increment(ulonglong value)
   { return HA_ERR_WRONG_COMMAND; }
 
   virtual void update_create_info(HA_CREATE_INFO *create_info) {}

--- 1.344/sql/mysql_priv.h	2005-08-25 16:39:01 +03:00
+++ 1.345/sql/mysql_priv.h	2005-08-30 12:39:17 +03:00
@@ -740,8 +740,9 @@
 int check_that_all_fields_are_given_values(THD *thd, TABLE *entry,
                                            TABLE_LIST *table_list);
 bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds);
-bool mysql_delete(THD *thd, TABLE_LIST *table, COND *conds, SQL_LIST *order,
-                  ha_rows rows, ulonglong options);
+bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
+                  SQL_LIST *order, ha_rows rows, ulonglong options,
+                  bool reset_auto_increment);
 bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok);
 bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create);
 TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update);

--- 1.158/sql/sql_delete.cc	2005-08-29 09:06:38 +03:00
+++ 1.159/sql/sql_delete.cc	2005-08-30 12:39:17 +03:00
@@ -27,7 +27,8 @@
 #include "sql_trigger.h"
 
 bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
-                  SQL_LIST *order, ha_rows limit, ulonglong options)
+                  SQL_LIST *order, ha_rows limit, ulonglong options,
+                  bool reset_auto_increment)
 {
   int		error;
   TABLE		*table;
@@ -230,18 +231,18 @@
   if (options & OPTION_QUICK)
     (void) table->file->extra(HA_EXTRA_NORMAL);
 
-  if ((error < 0) && (thd->lex->sql_command == SQLCOM_TRUNCATE))
+  if (reset_auto_increment && (error < 0))
   {
     /*
       We're really doing a truncate and need to reset the table's
       auto-increment counter.
     */
-    int error2 = table->file->reset_auto_increment();
+    int error2= table->file->reset_auto_increment(0);
 
     if (error2 && (error2 != HA_ERR_WRONG_COMMAND))
     {
       table->file->print_error(error2, MYF(0));
-      error = 1;
+      error= 1;
     }
   }
 
@@ -828,7 +829,7 @@
       ha_enable_transaction(thd, FALSE);
       mysql_init_select(thd->lex);
       error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0,
-			  HA_POS_ERROR, LL(0));
+                          HA_POS_ERROR, LL(0), TRUE);
       ha_enable_transaction(thd, TRUE);
       thd->options= save_options;
       DBUG_RETURN(error);

--- 1.476/sql/sql_parse.cc	2005-08-27 01:33:00 +03:00
+++ 1.477/sql/sql_parse.cc	2005-08-30 12:39:17 +03:00
@@ -3321,7 +3321,8 @@
     unit->set_limit(select_lex);
     res = mysql_delete(thd, all_tables, select_lex->where,
                        &select_lex->order_list,
-                       unit->select_limit_cnt, select_lex->options);
+                       unit->select_limit_cnt, select_lex->options,
+                       FALSE);
     break;
   }
   case SQLCOM_DELETE_MULTI:

--- 1.248/sql/ha_innodb.cc	2005-08-29 09:06:38 +03:00
+++ 1.249/sql/ha_innodb.cc	2005-08-30 12:39:17 +03:00
@@ -6890,7 +6890,7 @@
 
 /* See comment in handler.h */
 int
-ha_innobase::reset_auto_increment()
+ha_innobase::reset_auto_increment(ulonglong value)
 {
 	DBUG_ENTER("ha_innobase::reset_auto_increment");
 
@@ -6905,7 +6905,7 @@
 		DBUG_RETURN(error);
 	}	
 
-	dict_table_autoinc_initialize(prebuilt->table, 0);
+	dict_table_autoinc_initialize(prebuilt->table, value);
 
 	DBUG_RETURN(0);
 }

--- 1.101/sql/ha_innodb.h	2005-08-17 11:00:16 +03:00
+++ 1.102/sql/ha_innodb.h	2005-08-30 12:39:17 +03:00
@@ -173,7 +173,7 @@
 			     		enum thr_lock_type lock_type);
 	void init_table_handle_for_HANDLER(); 
 	ulonglong get_auto_increment();
-	int reset_auto_increment();
+	int reset_auto_increment(ulonglong value);
 	
         uint8 table_cache_type() { return HA_CACHE_TBL_ASKTRANSACT; }
         /*
Thread
bk commit into 5.0 tree (osku:1.1910) BUG#11946Osku Salerma30 Aug