List:Internals« Previous MessageNext Message »
From:Heikki Tuuri Date:September 4 2005 11:04am
Subject:bk commit into 5.0 tree (heikki:1.1952) BUG#12973
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of heikki. When heikki 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.1952 05/09/04 12:04:21 heikki@stripped +1 -0
  ha_innodb.cc:
    Fix bug #12973 : set the table handle field auto_increment_value if ::info() is called
with the flag HA_STATUS_AUTO

  sql/ha_innodb.cc
    1.252 05/09/04 12:03:30 heikki@stripped +34 -2
    Fix bug #12973 : set the table handle field auto_increment_value if ::info() is called
with the flag HA_STATUS_AUTO

# 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:	heikki
# Host:	hundin.mysql.fi
# Root:	/home/heikki/mysql-5.0

--- 1.251/sql/ha_innodb.cc	2005-09-01 01:24:03 +03:00
+++ 1.252/sql/ha_innodb.cc	2005-09-04 12:03:30 +03:00
@@ -5537,6 +5537,33 @@
 				       trx_get_error_info(prebuilt->trx));
   	}
 
+	if (flag & HA_STATUS_AUTO && table->found_next_number_field) {
+		longlong	auto_inc;
+		int		ret;
+
+		/* The following function call can the first time fail in
+		a lock wait timeout error because it reserves the auto-inc
+		lock on the table. If it fails, then someone has already inited
+		the auto-inc counter, and the second call is guaranteed to
+		succeed. */
+
+		ret = innobase_read_and_init_auto_inc(&auto_inc); 
+
+		if (ret != 0) {
+			ret = innobase_read_and_init_auto_inc(&auto_inc);
+
+			if (ret != 0) {
+				ut_print_timestamp(stderr);
+				sql_print_error("Cannot get table %s auto-inc"
+						"counter value in ::info\n",
+						ib_table->name);
+				auto_inc = 0;
+			}
+		}
+		
+		auto_increment_value = auto_inc;
+	}
+
 	prebuilt->trx->op_info = (char*)"";
 
   	DBUG_VOID_RETURN;
@@ -6845,8 +6872,13 @@
   			goto func_exit;
   		}
   	} else {
-		/* Initialize to max(col) + 1 */
-    		auto_inc = (longlong) table->next_number_field->
+		/* Initialize to max(col) + 1; we use
+		'found_next_number_field' below because MySQL in SHOW TABLE
+		STATUS does not seem to set 'next_number_field'. The comment
+		in table.h says that 'next_number_field' is set when it is
+		'active'. */
+
+    		auto_inc = (longlong) table->found_next_number_field->
                         	val_int_offset(table->s->rec_buff_length) + 1;
   	}
 
Thread
bk commit into 5.0 tree (heikki:1.1952) BUG#12973Heikki Tuuri4 Sep