From 5d5d1a814dbfe46a80ed36890d10442968f14086 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Wed, 20 Aug 2008 17:29:14 +0200 Subject: [PATCH] Backport of patch for Bug#34604 (from 6.0) post push fix for bug#20129, test failed due to non existing source files. mysql-test/Makefile.am: Bug#20129: ALTER TABLE ... REPAIR PARTITION ... complains that partition is corrupt Test parts.partition_repair_myisam failed because the corrupted pre fabricated files was not included in the dist-file. mysql-test/suite/parts/r/partition_special_innodb.result: Bug#34604: hander::ha_rnd_end(): Assertion inited==RND failed updated result file mysql-test/suite/parts/t/partition_special_innodb-master.opt: Bug#34604: hander::ha_rnd_end(): Assertion inited==RND failed Added parameter to speed up the test. Set to 2 seconds to be working on slow machines. mysql-test/suite/parts/t/partition_special_innodb.test: Bug#34604: hander::ha_rnd_end(): Assertion inited==RND failed Added test for verifying the bug (without the patch in ha_partition.cc, this crashes a debug compiled server) sql/ha_partition.cc: Bug#34604: hander::ha_rnd_end(): Assertion inited==RND failed In some cases error was not properly propagated through ha_partition::rnd_next. Will now return the error code from the partitions rnd_next and update m_part_spec.start_part and m_last_part properly. This makes the inited state to be correct. --- mysql-test/Makefile.am | 2 + .../parts/r/partition_special_innodb.result | 15 +++++++ .../t/partition_special_innodb-master.opt | 1 + .../parts/t/partition_special_innodb.test | 40 +++++++++++++++++-- sql/ha_partition.cc | 2 + 5 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 mysql-test/suite/parts/t/partition_special_innodb-master.opt diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index e7cdf2c3469..4d321f53ffa 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -77,6 +77,7 @@ dist-hook: $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_be/BACKUP* $(distdir)/std_data/ndb_backup51_data_be $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_le/BACKUP* $(distdir)/std_data/ndb_backup51_data_le $(INSTALL_DATA) $(srcdir)/std_data/parts/part_* $(distdir)/std_data/parts + $(INSTALL_DATA) $(srcdir)/std_data/parts/*.MY* $(distdir)/std_data/parts $(INSTALL_DATA) $(srcdir)/std_data/funcs_1/* $(distdir)/std_data/funcs_1 $(INSTALL_DATA) $(srcdir)/lib/*.pl $(distdir)/lib $(INSTALL_DATA) $(srcdir)/lib/My/*.pm $(distdir)/lib/My @@ -132,6 +133,7 @@ install-data-local: $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_be/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup51_data_be $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_le/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup51_data_le $(INSTALL_DATA) $(srcdir)/std_data/parts/part_* $(DESTDIR)$(testdir)/std_data/parts + $(INSTALL_DATA) $(srcdir)/std_data/parts/*.MY* $(DESTDIR)$(testdir)/std_data/parts $(INSTALL_DATA) $(srcdir)/std_data/funcs_1/* $(DESTDIR)$(testdir)/std_data/funcs_1 $(INSTALL_DATA) $(srcdir)/lib/*.pl $(DESTDIR)$(testdir)/lib $(INSTALL_DATA) $(srcdir)/lib/My/*.pm $(DESTDIR)$(testdir)/lib/My diff --git a/mysql-test/suite/parts/r/partition_special_innodb.result b/mysql-test/suite/parts/r/partition_special_innodb.result index fa1d2eb9994..35954c0f66a 100644 --- a/mysql-test/suite/parts/r/partition_special_innodb.result +++ b/mysql-test/suite/parts/r/partition_special_innodb.result @@ -180,3 +180,18 @@ a b c d e f g h a1 b1 c1 d1 e1 f1 g1 h1 a2 b2 c2 d2 e2 f2 g2 h2 a3 b3 c3 d3 e3 f 1983-12-31 cdef srtbvsr w 45634 13452.56 3452346456 127 1983-12-31 cdef srtbvsr w 45634 13452.56 3452346456 127 1983-12-31 cdef srtbvsr w 45634 13452.56 3452346456 127 1983-12-31 cdef srtbvsr w 45634 13452.56 3452346456 127 liuugbzvdmrlti b itiortudirtfgtibm dfi 1975-01-01 abcde abcde m 1234 123.45 32412341234 113 1975-01-01 abcde abcde m 1234 123.45 32412341234 113 1975-01-01 abcde abcde m 1234 123.45 32412341234 113 1975-01-01 abcde abcde m 1234 123.45 32412341234 113 tbhth nrzh ztfghgfh fzh ftzhj fztjh drop table t1; +# Bug#34604 - Assertion 'inited==RND' failed in handler::ha_rnd_end +CREATE TABLE t1 ( +a INT AUTO_INCREMENT, +b VARCHAR(255), +PRIMARY KEY (a)) +ENGINE = InnoDB +PARTITION BY HASH (a) +PARTITIONS 2; +SET autocommit=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (NULL, 'first row t2'); +SET autocommit=OFF; +ALTER TABLE t1 AUTO_INCREMENT = 10; +INSERT INTO t1 VALUES (NULL, 'second row t2'); +DROP TABLE t1; diff --git a/mysql-test/suite/parts/t/partition_special_innodb-master.opt b/mysql-test/suite/parts/t/partition_special_innodb-master.opt new file mode 100644 index 00000000000..e76299453d3 --- /dev/null +++ b/mysql-test/suite/parts/t/partition_special_innodb-master.opt @@ -0,0 +1 @@ +--innodb_lock_wait_timeout=2 diff --git a/mysql-test/suite/parts/t/partition_special_innodb.test b/mysql-test/suite/parts/t/partition_special_innodb.test index 598dfea1e27..b9fc8bdcd56 100644 --- a/mysql-test/suite/parts/t/partition_special_innodb.test +++ b/mysql-test/suite/parts/t/partition_special_innodb.test @@ -1,5 +1,5 @@ ################################################################################ -# t/partition_special_innodb.test # +# t/partition_special_innodb.test # # # # Purpose: # # different Tests # @@ -8,9 +8,9 @@ #------------------------------------------------------------------------------# # Original Author: HH # # Original Date: 2006-08-01 # -# Change Author: # -# Change Date: # -# Change: # +# Change Author: MattiasJ # +# Change Date: 2008-08-20 # +# Change: added test for bug#34604 # ################################################################################ # @@ -44,3 +44,35 @@ let $engine= 'InnoDB'; --source suite/parts/inc/partition_key_8col.inc --source suite/parts/inc/partition_key_16col.inc --source suite/parts/inc/partition_key_32col.inc + +#------------------------------------------------------------------------------# +# Execute storage engine specific tests + +--echo # Bug#34604 - Assertion 'inited==RND' failed in handler::ha_rnd_end + +CREATE TABLE t1 ( + a INT AUTO_INCREMENT, + b VARCHAR(255), + PRIMARY KEY (a)) +ENGINE = InnoDB +PARTITION BY HASH (a) +PARTITIONS 2; + +connect (con1,127.0.0.1,root,,test,$MASTER_MYPORT,); +connect (con2,127.0.0.1,root,,test,$MASTER_MYPORT,); + +--connection con1 +SET autocommit=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (NULL, 'first row t2'); + +--connection con2 +SET autocommit=OFF; +ALTER TABLE t1 AUTO_INCREMENT = 10; + +--connection con1 +INSERT INTO t1 VALUES (NULL, 'second row t2'); +--disconnect con2 +--disconnect con1 +--connection default +DROP TABLE t1; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index d2497081893..34cd160e7e4 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -3389,6 +3389,8 @@ int ha_partition::rnd_next(uchar *buf) result= HA_ERR_END_OF_FILE; break; } + m_last_part= part_id; + m_part_spec.start_part= part_id; file= m_file[part_id]; DBUG_PRINT("info", ("rnd_init on partition %d", part_id)); if ((result= file->ha_rnd_init(1)))