List:Internals« Previous MessageNext Message »
From:Osku Salerma Date:August 31 2005 12:43pm
Subject:bk commit into 5.1 tree (osku:1.1907)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 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.1907 05/08/31 13:43:35 osku@127.(none) +6 -0
  Merge 127.(none):/home/osku/upward-5.0
  into  127.(none):/home/osku/mysql-5.1

  sql/sql_delete.cc
    1.154 05/08/31 13:43:31 osku@127.(none) +0 -0
    Auto merged

  sql/handler.h
    1.155 05/08/31 13:43:31 osku@127.(none) +0 -0
    Auto merged

  sql/ha_innodb.h
    1.104 05/08/31 13:43:30 osku@127.(none) +0 -0
    Auto merged

  sql/ha_innodb.cc
    1.226 05/08/31 13:43:30 osku@127.(none) +0 -0
    Auto merged

  mysql-test/t/innodb.test
    1.101 05/08/31 13:43:30 osku@127.(none) +0 -0
    Auto merged

  mysql-test/r/innodb.result
    1.128 05/08/31 13:43:30 osku@127.(none) +0 -0
    Auto merged

# 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.1/RESYNC

--- 1.154/sql/handler.h	2005-08-25 19:49:40 +03:00
+++ 1.155/sql/handler.h	2005-08-31 13:43:31 +03:00
@@ -1129,6 +1129,15 @@
   { return (my_errno=HA_ERR_WRONG_COMMAND); }
   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()
+  { return HA_ERR_WRONG_COMMAND; }
+
   virtual void update_create_info(HA_CREATE_INFO *create_info) {}
 
   /* admin commands - called from mysql_admin_table */

--- 1.153/sql/sql_delete.cc	2005-08-25 19:49:42 +03:00
+++ 1.154/sql/sql_delete.cc	2005-08-31 13:43:31 +03:00
@@ -104,6 +104,13 @@
     free_underlaid_joins(thd, select_lex);
     thd->row_count_func= 0;
     send_ok(thd,0L);
+
+    /*
+      We don't need to call reset_auto_increment in this case, because
+      mysql_truncate always gives a NULL conds argument, hence we never
+      get here.
+    */
+
     DBUG_RETURN(0);				// Nothing to delete
   }
 
@@ -233,6 +240,21 @@
   free_io_cache(table);				// Will not do any harm
   if (options & OPTION_QUICK)
     (void) table->file->extra(HA_EXTRA_NORMAL);
+
+  if ((error < 0) && (thd->lex->sql_command == SQLCOM_TRUNCATE))
+  {
+    /*
+      We're really doing a truncate and need to reset the table's
+      auto-increment counter.
+    */
+    int error2 = table->file->reset_auto_increment();
+
+    if (error2 && (error2 != HA_ERR_WRONG_COMMAND))
+    {
+      table->file->print_error(error2, MYF(0));
+      error = 1;
+    }
+  }
 
 cleanup:
   /*

--- 1.127/mysql-test/r/innodb.result	2005-08-17 11:00:16 +03:00
+++ 1.128/mysql-test/r/innodb.result	2005-08-31 13:43:30 +03:00
@@ -750,6 +750,11 @@
 set @a:=now();
 CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=innodb;
 insert into t1 (a) values(1),(2),(3);
+select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
+a
+1
+2
+3
 select a from t1 natural join t1 as t2 where b >= @a order by a;
 a
 1
@@ -904,7 +909,7 @@
 commit;
 drop database mysqltest;
 show tables from mysqltest;
-Got one of the listed errors
+ERROR 42000: Unknown database 'mysqltest'
 set autocommit=0;
 create table t1 (a int not null) engine= innodb;
 insert into t1 values(1),(2);

--- 1.100/mysql-test/t/innodb.test	2005-08-17 11:00:16 +03:00
+++ 1.101/mysql-test/t/innodb.test	2005-08-31 13:43:30 +03:00
@@ -440,6 +440,7 @@
 set @a:=now();
 CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=innodb;
 insert into t1 (a) values(1),(2),(3);
+select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
 select a from t1 natural join t1 as t2 where b >= @a order by a;
 update t1 set a=5 where a=1;
 select a from t1;
@@ -586,7 +587,7 @@
 commit;
 drop database mysqltest;
 # Don't check error message
---error 12,12
+--error 1049
 show tables from mysqltest;
 
 #

--- 1.225/sql/ha_innodb.cc	2005-08-25 19:49:39 +03:00
+++ 1.226/sql/ha_innodb.cc	2005-08-31 13:43:30 +03:00
@@ -6890,6 +6890,28 @@
 	return((ulonglong) nr);
 }
 
+/* See comment in handler.h */
+int
+ha_innobase::reset_auto_increment()
+{
+	DBUG_ENTER("ha_innobase::reset_auto_increment");
+
+	row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
+  	int     	error;
+
+	error = row_lock_table_autoinc_for_mysql(prebuilt);
+
+	if (error != DB_SUCCESS) {
+		error = convert_error_code_to_mysql(error, user_thd);
+
+		DBUG_RETURN(error);
+	}	
+
+	dict_table_autoinc_initialize(prebuilt->table, 0);
+
+	DBUG_RETURN(0);
+}
+
 /***********************************************************************
 Compares two 'refs'. A 'ref' is the (internal) primary key value of the row.
 If there is no explicitly declared non-null unique key or a primary key, then

--- 1.103/sql/ha_innodb.h	2005-08-25 19:49:39 +03:00
+++ 1.104/sql/ha_innodb.h	2005-08-31 13:43:30 +03:00
@@ -183,6 +183,8 @@
 			     		enum thr_lock_type lock_type);
 	void init_table_handle_for_HANDLER(); 
 	ulonglong get_auto_increment();
+	int reset_auto_increment();
+	
         uint8 table_cache_type() { return HA_CACHE_TBL_ASKTRANSACT; }
         /*
           ask handler about permission to cache table during query registration
Thread
bk commit into 5.1 tree (osku:1.1907)Osku Salerma31 Aug