MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Satya B Date:November 30 2009 9:41am
Subject:bzr commit into mysql-5.1-bugteam branch (satya.bn:3218) Bug#49032
View as plain text  
#At file:///home/satya/WORK/mysql/mysql-5.1-bugteam/ based on revid:satya.bn@stripped

 3218 Satya B	2009-11-30
      Applying InnoDB snapshot 5.1-ss6242, part 7. Fixes BUG#49032
      
      1. BUG#49032 - auto_increment field does not initialize to last value 
                     in InnoDB Storage Engine
      
      2. Fix whitespace issues and fix tests and make read float/double arg const
      
      Detailed revision comments:
      
      r6231 | sunny | 2009-11-25 10:26:27 +0200 (Wed, 25 Nov 2009) | 7 lines
      branches/5.1: Fix BUG#49032 - auto_increment field does not initialize to last value in InnoDB Storage Engine.
      
      We use the appropriate function to read the column value for non-integer
      autoinc column types, namely float and double.
      
      rb://208. Approved by Marko.
      
      r6232 | sunny | 2009-11-25 10:27:39 +0200 (Wed, 25 Nov 2009) | 2 lines
      branches/5.1: This is an interim fix, fix white space errors.
      
      r6233 | sunny | 2009-11-25 10:28:35 +0200 (Wed, 25 Nov 2009) | 2 lines
      branches/5.1: This is an interim fix, fix tests and make read float/double arg const.
      
      
      r6234 | sunny | 2009-11-25 10:29:03 +0200 (Wed, 25 Nov 2009) | 2 lines
      branches/5.1: This is an interim fix, fix whitepsace issues.

    modified:
      mysql-test/r/innodb-autoinc.result
      mysql-test/t/innodb-autoinc.test
      storage/innobase/include/mach0data.h
      storage/innobase/include/mach0data.ic
      storage/innobase/row/row0sel.c
=== modified file 'mysql-test/r/innodb-autoinc.result'
--- a/mysql-test/r/innodb-autoinc.result	2009-11-30 09:08:41 +0000
+++ b/mysql-test/r/innodb-autoinc.result	2009-11-30 09:41:38 +0000
@@ -1126,3 +1126,28 @@ SELECT * FROM T1;
 c1	c2
 10	0
 DROP TABLE T1;
+DROP TABLE IF EXISTS T1;
+Warnings:
+Note	1051	Unknown table 'T1'
+CREATE TABLE T1(C1 DOUBLE AUTO_INCREMENT KEY, C2 CHAR(10)) ENGINE=InnoDB;
+INSERT INTO T1(C1, C2) VALUES (1, 'innodb'), (3, 'innodb');
+INSERT INTO T1(C2) VALUES ('innodb');
+SHOW CREATE TABLE T1;
+Table	Create Table
+T1	CREATE TABLE `T1` (
+  `C1` double NOT NULL AUTO_INCREMENT,
+  `C2` char(10) DEFAULT NULL,
+  PRIMARY KEY (`C1`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
+DROP TABLE T1;
+CREATE TABLE T1(C1 FLOAT AUTO_INCREMENT KEY, C2 CHAR(10)) ENGINE=InnoDB;
+INSERT INTO T1(C1, C2) VALUES (1, 'innodb'), (3, 'innodb');
+INSERT INTO T1(C2) VALUES ('innodb');
+SHOW CREATE TABLE T1;
+Table	Create Table
+T1	CREATE TABLE `T1` (
+  `C1` float NOT NULL AUTO_INCREMENT,
+  `C2` char(10) DEFAULT NULL,
+  PRIMARY KEY (`C1`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
+DROP TABLE T1;

=== modified file 'mysql-test/t/innodb-autoinc.test'
--- a/mysql-test/t/innodb-autoinc.test	2009-11-02 15:06:58 +0000
+++ b/mysql-test/t/innodb-autoinc.test	2009-11-30 09:41:38 +0000
@@ -620,3 +620,22 @@ SHOW CREATE TABLE T1;
 INSERT INTO T1 (c2) values (0);
 SELECT * FROM T1;
 DROP TABLE T1;
+
+##
+# 49032: Use the correct function to read the AUTOINC column value
+#
+DROP TABLE IF EXISTS T1;
+CREATE TABLE T1(C1 DOUBLE AUTO_INCREMENT KEY, C2 CHAR(10)) ENGINE=InnoDB;
+INSERT INTO T1(C1, C2) VALUES (1, 'innodb'), (3, 'innodb');
+# Restart the server
+-- source include/restart_mysqld.inc
+INSERT INTO T1(C2) VALUES ('innodb');
+SHOW CREATE TABLE T1;
+DROP TABLE T1;
+CREATE TABLE T1(C1 FLOAT AUTO_INCREMENT KEY, C2 CHAR(10)) ENGINE=InnoDB;
+INSERT INTO T1(C1, C2) VALUES (1, 'innodb'), (3, 'innodb');
+# Restart the server
+-- source include/restart_mysqld.inc
+INSERT INTO T1(C2) VALUES ('innodb');
+SHOW CREATE TABLE T1;
+DROP TABLE T1;

=== modified file 'storage/innobase/include/mach0data.h'
--- a/storage/innobase/include/mach0data.h	2008-08-20 00:37:41 +0000
+++ b/storage/innobase/include/mach0data.h	2009-11-30 09:41:38 +0000
@@ -266,8 +266,8 @@ UNIV_INLINE
 double
 mach_double_read(
 /*=============*/
-			/* out: double read */
-	byte*	b);	 /* in: pointer to memory from where to read */
+				/* out: double read */
+	const byte*	b);	 /* in: pointer to memory from where to read */
 /*************************************************************
 Writes a double. It is stored in a little-endian format. */
 UNIV_INLINE
@@ -282,8 +282,8 @@ UNIV_INLINE
 float
 mach_float_read(
 /*============*/
-			/* out: float read */
-	byte*	b);	 /* in: pointer to memory from where to read */
+				/* out: float read */
+	const byte*	b);	 /* in: pointer to memory from where to read */
 /*************************************************************
 Writes a float. It is stored in a little-endian format. */
 UNIV_INLINE

=== modified file 'storage/innobase/include/mach0data.ic'
--- a/storage/innobase/include/mach0data.ic	2008-08-20 00:37:41 +0000
+++ b/storage/innobase/include/mach0data.ic	2009-11-30 09:41:38 +0000
@@ -504,8 +504,8 @@ UNIV_INLINE
 double
 mach_double_read(
 /*=============*/
-			/* out: double read */
-	byte*	b)	/* in: pointer to memory from where to read */
+				/* out: double read */
+	const byte*	b)	/* in: pointer to memory from where to read */
 {
 	double	d;
 	ulint	i;
@@ -553,8 +553,8 @@ UNIV_INLINE
 float
 mach_float_read(
 /*============*/
-			/* out: float read */
-	byte*	b)	/* in: pointer to memory from where to read */
+				/* out: float read */
+	const byte*	b)	/* in: pointer to memory from where to read */
 {
 	float	d;
 	ulint	i;

=== modified file 'storage/innobase/row/row0sel.c'
--- a/storage/innobase/row/row0sel.c	2009-07-10 23:12:13 +0000
+++ b/storage/innobase/row/row0sel.c	2009-11-30 09:41:38 +0000
@@ -4514,6 +4514,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;
@@ -4535,9 +4536,26 @@ row_search_autoinc_read_column(
 	data = rec_get_nth_field((rec_t*)rec, offsets, col_no, &len);
 
 	ut_a(len != UNIV_SQL_NULL);
-	ut_a(len <= sizeof value);
 
-	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);
@@ -4625,7 +4643,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);
 			}
 		}
 


Attachment: [text/bzr-bundle] bzr/satya.bn@sun.com-20091130094138-81lvmexqn6osk62d.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (satya.bn:3218) Bug#49032Satya B30 Nov