List:Commits« Previous MessageNext Message »
From:marko.makela Date:June 30 2011 10:56am
Subject:bzr push into mysql-5.1 branch (marko.makela:3661 to 3662) Bug#12637786
View as plain text  
 3662 Marko Mäkelä	2011-06-30
      Bug#12637786 Wrong secondary index entries on CHAR and VARCHAR columns
      
      row_build_index_entry(): In innodb_file_format=Barracuda
      (ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED), a secondary index on a
      full column can refer to a field that is stored off-page in the
      clustered index record. Take that into account.
      
      rb:692 approved by Jimmy Yang

    modified:
      mysql-test/suite/innodb_plugin/r/innodb-index.result
      mysql-test/suite/innodb_plugin/t/innodb-index.test
      storage/innodb_plugin/ChangeLog
      storage/innodb_plugin/row/row0row.c
 3661 Marko Mäkelä	2011-06-29
      Bug #12612184 BLOB debug code cleanup: Forgot an #if
      around the declaration of trx_assert_recovered().

    modified:
      storage/innodb_plugin/include/trx0sys.h
=== modified file 'mysql-test/suite/innodb_plugin/r/innodb-index.result'
--- a/mysql-test/suite/innodb_plugin/r/innodb-index.result	revid:marko.makela@stripped6w6ojc8n
+++ b/mysql-test/suite/innodb_plugin/r/innodb-index.result	revid:marko.makela@stripped3ayyxm9swpz9iqa
@@ -967,6 +967,19 @@ ERROR HY000: Too big row
 alter table t1 row_format=compact;
 create index t1u on t1 (u(1));
 drop table t1;
+SET @r=REPEAT('a',500);
+CREATE TABLE t1(a INT,
+v1 VARCHAR(500), v2 VARCHAR(500), v3 VARCHAR(500),
+v4 VARCHAR(500), v5 VARCHAR(500), v6 VARCHAR(500),
+v7 VARCHAR(500), v8 VARCHAR(500), v9 VARCHAR(500),
+v10 VARCHAR(500), v11 VARCHAR(500), v12 VARCHAR(500),
+v13 VARCHAR(500), v14 VARCHAR(500), v15 VARCHAR(500),
+v16 VARCHAR(500), v17 VARCHAR(500), v18 VARCHAR(500)
+) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+CREATE INDEX idx1 ON t1(a,v1);
+INSERT INTO t1 VALUES(9,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
+UPDATE t1 SET a=1000;
+DROP TABLE t1;
 set global innodb_file_per_table=0;
 set global innodb_file_format=Antelope;
 set global innodb_file_format_check=Antelope;

=== modified file 'mysql-test/suite/innodb_plugin/t/innodb-index.test'
--- a/mysql-test/suite/innodb_plugin/t/innodb-index.test	revid:marko.makela@stripped
+++ b/mysql-test/suite/innodb_plugin/t/innodb-index.test	revid:marko.makela@stripped
@@ -404,6 +404,22 @@ alter table t1 row_format=compact;
 create index t1u on t1 (u(1));
 
 drop table t1;
+
+# Bug#12637786
+SET @r=REPEAT('a',500);
+CREATE TABLE t1(a INT,
+ v1 VARCHAR(500), v2 VARCHAR(500), v3 VARCHAR(500),
+ v4 VARCHAR(500), v5 VARCHAR(500), v6 VARCHAR(500),
+ v7 VARCHAR(500), v8 VARCHAR(500), v9 VARCHAR(500),
+ v10 VARCHAR(500), v11 VARCHAR(500), v12 VARCHAR(500),
+ v13 VARCHAR(500), v14 VARCHAR(500), v15 VARCHAR(500),
+ v16 VARCHAR(500), v17 VARCHAR(500), v18 VARCHAR(500)
+) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+CREATE INDEX idx1 ON t1(a,v1);
+INSERT INTO t1 VALUES(9,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
+UPDATE t1 SET a=1000;
+DROP TABLE t1;
+
 eval set global innodb_file_per_table=$per_table;
 eval set global innodb_file_format=$format;
 eval set global innodb_file_format_check=$format;

=== modified file 'storage/innodb_plugin/ChangeLog'
--- a/storage/innodb_plugin/ChangeLog	revid:marko.makela@stripped41-5c73f0s16w6ojc8n
+++ b/storage/innodb_plugin/ChangeLog	revid:marko.makela@strippedz9iqa
@@ -1,3 +1,9 @@
+2011-06-30	The InnoDB Team
+
+	* row/row0row.c:
+	Fix Bug#12637786 Wrong secondary index entries on CHAR and VARCHAR
+	columns in ROW_FORMAT=DYNAMIC and ROW_FORMAT=COMPRESSED
+
 2011-06-16	The InnoDB Team
 
 	* btr/btr0cur.c, buf/buf0buddy.c, buf/buf0buf.c, buf/buf0lru.c,

=== modified file 'storage/innodb_plugin/row/row0row.c'
--- a/storage/innodb_plugin/row/row0row.c	revid:marko.makela@stripped
+++ b/storage/innodb_plugin/row/row0row.c	revid:marko.makela@stripped
@@ -101,12 +101,27 @@ row_build_index_entry(
 
 		dfield_copy(dfield, dfield2);
 
-		if (dfield_is_null(dfield) || ind_field->prefix_len == 0) {
+		if (dfield_is_null(dfield)) {
 			continue;
 		}
 
-		/* If a column prefix index, take only the prefix.
-		Prefix-indexed columns may be externally stored. */
+		if (ind_field->prefix_len == 0
+		    && (!dfield_is_ext(dfield)
+			|| dict_index_is_clust(index))) {
+			/* The dfield_copy() above suffices for
+			columns that are stored in-page, or for
+			clustered index record columns that are not
+			part of a column prefix in the PRIMARY KEY. */
+			continue;
+		}
+
+		/* If the column is stored externally (off-page) in
+		the clustered index, it must be an ordering field in
+		the secondary index.  In the Antelope format, only
+		prefix-indexed columns may be stored off-page in the
+		clustered index record. In the Barracuda format, also
+		fully indexed long CHAR or VARCHAR columns may be
+		stored off-page. */
 		ut_ad(col->ord_part);
 
 		if (UNIV_LIKELY_NULL(ext)) {
@@ -119,13 +134,34 @@ row_build_index_entry(
 				}
 				dfield_set_data(dfield, buf, len);
 			}
+
+			if (ind_field->prefix_len == 0) {
+				/* In the Barracuda format
+				(ROW_FORMAT=DYNAMIC or
+				ROW_FORMAT=COMPRESSED), we can have a
+				secondary index on an entire column
+				that is stored off-page in the
+				clustered index. As this is not a
+				prefix index (prefix_len == 0),
+				include the entire off-page column in
+				the secondary index record. */
+				continue;
+			}
 		} else if (dfield_is_ext(dfield)) {
+			/* This table should be in Antelope format
+			(ROW_FORMAT=REDUNDANT or ROW_FORMAT=COMPACT).
+			In that format, the maximum column prefix
+			index length is 767 bytes, and the clustered
+			index record contains a 768-byte prefix of
+			each off-page column. */
 			ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE);
 			len -= BTR_EXTERN_FIELD_REF_SIZE;
 			ut_a(ind_field->prefix_len <= len
 			     || dict_index_is_clust(index));
 		}
 
+		/* If a column prefix index, take only the prefix. */
+		ut_ad(ind_field->prefix_len);
 		len = dtype_get_at_most_n_mbchars(
 			col->prtype, col->mbminlen, col->mbmaxlen,
 			ind_field->prefix_len, len, dfield_get_data(dfield));

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1 branch (marko.makela:3661 to 3662) Bug#12637786marko.makela4 Jul