← Back to team overview

maria-developers team mailing list archive

bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2804) Bug#47720 Bug#49032

 

#At lp:maria

 2804 knielsen@xxxxxxxxxxxxxxx	2010-01-15
      Apply to XtraDB MySQL/build-in innodb patches for Bug#49032 and Bug#47720.
      modified:
        mysql-test/t/innodb-autoinc.test
        storage/xtradb/handler/ha_innodb.cc
        storage/xtradb/row/row0sel.c

=== modified file 'mysql-test/t/innodb-autoinc.test'
--- a/mysql-test/t/innodb-autoinc.test	2010-01-15 17:02:57 +0000
+++ b/mysql-test/t/innodb-autoinc.test	2010-01-15 21:12:30 +0000
@@ -2,6 +2,8 @@
 # embedded server ignores 'delayed', so skip this
 -- source include/not_embedded.inc
 
+let $file_format_check=`select @@innodb_file_format_check`;
+
 --disable_warnings
 drop table if exists t1;
 --enable_warnings
@@ -655,3 +657,7 @@ REPLACE INTO t1 VALUES (-1);
 SELECT * FROM t1;
 SHOW CREATE TABLE t1;
 DROP TABLE t1;
+
+--disable_query_log
+EVAL SET GLOBAL innodb_file_format_check=$file_format_check;
+--enable_query_log

=== modified file 'storage/xtradb/handler/ha_innodb.cc'
--- a/storage/xtradb/handler/ha_innodb.cc	2010-01-15 18:44:11 +0000
+++ b/storage/xtradb/handler/ha_innodb.cc	2010-01-15 21:12:30 +0000
@@ -4742,24 +4742,29 @@ no_commit:
 			update the table upper limit. Note: last_value
 			will be 0 if get_auto_increment() was not called.*/
 
-			if (auto_inc <= col_max_value
-			    && auto_inc >= prebuilt->autoinc_last_value) {
+			if (auto_inc >= prebuilt->autoinc_last_value) {
 set_max_autoinc:
-				ut_a(prebuilt->autoinc_increment > 0);
-
-				ulonglong	need;
-				ulonglong	offset;
-
-				offset = prebuilt->autoinc_offset;
-				need = prebuilt->autoinc_increment;
-
-				auto_inc = innobase_next_autoinc(
-					auto_inc, need, offset, col_max_value);
-
-				err = innobase_set_max_autoinc(auto_inc);
-
-				if (err != DB_SUCCESS) {
-					error = err;
+				/* This should filter out the negative
+				values set explicitly by the user. */
+				if (auto_inc <= col_max_value) {
+					ut_a(prebuilt->autoinc_increment > 0);
+
+					ulonglong	need;
+					ulonglong	offset;
+
+					offset = prebuilt->autoinc_offset;
+					need = prebuilt->autoinc_increment;
+
+					auto_inc = innobase_next_autoinc(
+						auto_inc,
+						need, offset, col_max_value);
+
+					err = innobase_set_max_autoinc(
+						auto_inc);
+
+					if (err != DB_SUCCESS) {
+						error = err;
+					}
 				}
 			}
 			break;

=== modified file 'storage/xtradb/row/row0sel.c'
--- a/storage/xtradb/row/row0sel.c	2009-09-07 10:22:53 +0000
+++ b/storage/xtradb/row/row0sel.c	2010-01-15 21:12:30 +0000
@@ -4616,6 +4616,7 @@ row_search_autoinc_read_column(
 	dict_index_t*	index,		/*!< in: index to read from */
 	const rec_t*	rec,		/*!< in: current rec */
 	ulint		col_no,		/*!< in: column number */
+	ulint		mtype,		/*!< in: column main type */
 	ibool		unsigned_type)	/*!< in: signed or unsigned flag */
 {
 	ulint		len;
@@ -4632,10 +4633,27 @@ row_search_autoinc_read_column(
 	data = rec_get_nth_field(rec, offsets, col_no, &len);
 
 	ut_a(len != UNIV_SQL_NULL);
-	ut_a(len <= sizeof value);
 
 	/* we assume AUTOINC value cannot be negative */
-	value = mach_read_int_type(data, len, unsigned_type);
+	switch (mtype) {
+	case DATA_INT:
+		ut_a(len <= sizeof value);
+		value = mach_read_int_type(data, len, unsigned_type);
+		break;
+
+	case DATA_FLOAT:
+		ut_a(len == sizeof(float));
+		value = mach_float_read(data);
+		break;
+
+	case DATA_DOUBLE:
+		ut_a(len == sizeof(double));
+		value = mach_double_read(data);
+		break;
+
+	default:
+		ut_error;
+	}
 
 	if (UNIV_LIKELY_NULL(heap)) {
 		mem_heap_free(heap);
@@ -4721,7 +4739,8 @@ row_search_max_autoinc(
 					dfield->col->prtype & DATA_UNSIGNED);
 
 				*value = row_search_autoinc_read_column(
-					index, rec, i, unsigned_type);
+					index, rec, i,
+					dfield->col->mtype, unsigned_type);
 			}
 		}