diff options
9 files changed, 271 insertions, 25 deletions
diff --git a/mysql-test/suite/parts/inc/partition_auto_increment.inc b/mysql-test/suite/parts/inc/partition_auto_increment.inc index 341bf7ab860..5e9ad47aa2e 100644 --- a/mysql-test/suite/parts/inc/partition_auto_increment.inc +++ b/mysql-test/suite/parts/inc/partition_auto_increment.inc @@ -43,8 +43,13 @@ SET INSERT_ID = 30; INSERT INTO t1 VALUES (NULL); if (!$skip_update) { +# InnoDB Does not handle this correctly, see bug#14793, bug#21641 UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 51 WHERE c1 = 19; + FLUSH TABLES; + UPDATE t1 SET c1 = 40 WHERE c1 = 50; + SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' + AND TABLE_NAME='t1'; -- error 0, ER_BAD_NULL_ERROR UPDATE t1 SET c1 = NULL WHERE c1 = 4; if (!$mysql_errno) @@ -83,6 +88,16 @@ TRUNCATE TABLE t1; INSERT INTO t1 VALUES (NULL); SHOW CREATE TABLE t1; SELECT * FROM t1 ORDER BY c1; +INSERT INTO t1 VALUES (100); +INSERT INTO t1 VALUES (NULL); +if (!$skip_delete) +{ +DELETE FROM t1 WHERE c1 >= 100; +} +# InnoDB does reset auto_increment on OPTIMIZE, Bug#18274 +# Archive does reset auto_increment on OPTIMIZE, Bug#40216 +OPTIMIZE TABLE t1; +SHOW CREATE TABLE t1; DROP TABLE t1; -- echo # Simple test with NULL @@ -184,6 +199,10 @@ if (!$skip_update) { UPDATE t1 SET c1 = 150 WHERE c1 = 17; UPDATE t1 SET c1 = 151 WHERE c1 = 19; + FLUSH TABLES; + UPDATE t1 SET c1 = 140 WHERE c1 = 150; + SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' + AND TABLE_NAME='t1'; -- error 0, ER_BAD_NULL_ERROR UPDATE t1 SET c1 = NULL WHERE c1 = 4; if (!$mysql_errno) @@ -295,6 +314,15 @@ TRUNCATE TABLE t1; INSERT INTO t1 VALUES (NULL); SHOW CREATE TABLE t1; SELECT * FROM t1 ORDER BY c1; +INSERT INTO t1 VALUES (100); +INSERT INTO t1 VALUES (NULL); +if (!$skip_delete) +{ +DELETE FROM t1 WHERE c1 >= 100; +} +# InnoDB does reset auto_increment on OPTIMIZE, Bug#18274 +OPTIMIZE TABLE t1; +SHOW CREATE TABLE t1; DROP TABLE t1; -- echo # Test with two threads diff --git a/mysql-test/suite/parts/r/partition_auto_increment_archive.result b/mysql-test/suite/parts/r/partition_auto_increment_archive.result index 25b80f40e5a..beda861425c 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_archive.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_archive.result @@ -105,6 +105,17 @@ c1 5 6 7 +INSERT INTO t1 VALUES (100); +INSERT INTO t1 VALUES (NULL); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 DROP TABLE t1; # Simple test with NULL CREATE TABLE t1 ( @@ -368,6 +379,19 @@ c1 25 26 27 +INSERT INTO t1 VALUES (100); +INSERT INTO t1 VALUES (NULL); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (c1) +PARTITIONS 2 */ DROP TABLE t1; # Test with two threads # con default diff --git a/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result b/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result index e56e0e24017..1946ebbf978 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result @@ -36,6 +36,12 @@ SET INSERT_ID = 30; INSERT INTO t1 VALUES (NULL); UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 51 WHERE c1 = 19; +FLUSH TABLES; +UPDATE t1 SET c1 = 40 WHERE c1 = 50; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' + AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 UPDATE t1 SET c1 = NULL WHERE c1 = 4; # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY INSERT INTO t1 VALUES (NULL); @@ -96,6 +102,18 @@ t1 CREATE TABLE `t1` ( ) ENGINE=BLACKHOLE DEFAULT CHARSET=latin1 SELECT * FROM t1 ORDER BY c1; c1 +INSERT INTO t1 VALUES (100); +INSERT INTO t1 VALUES (NULL); +DELETE FROM t1 WHERE c1 >= 100; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note The storage engine for the table doesn't support optimize +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=BLACKHOLE DEFAULT CHARSET=latin1 DROP TABLE t1; # Simple test with NULL CREATE TABLE t1 ( @@ -167,6 +185,12 @@ INSERT INTO t1 VALUES (NULL), (90); INSERT INTO t1 VALUES (NULL); UPDATE t1 SET c1 = 150 WHERE c1 = 17; UPDATE t1 SET c1 = 151 WHERE c1 = 19; +FLUSH TABLES; +UPDATE t1 SET c1 = 140 WHERE c1 = 150; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' + AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 UPDATE t1 SET c1 = NULL WHERE c1 = 4; # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY INSERT INTO t1 VALUES (NULL); @@ -278,6 +302,20 @@ t1 CREATE TABLE `t1` ( PARTITIONS 2 */ SELECT * FROM t1 ORDER BY c1; c1 +INSERT INTO t1 VALUES (100); +INSERT INTO t1 VALUES (NULL); +DELETE FROM t1 WHERE c1 >= 100; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note The storage engine for the table doesn't support optimize +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=BLACKHOLE DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (c1) +PARTITIONS 2 */ DROP TABLE t1; # Test with two threads # con default diff --git a/mysql-test/suite/parts/r/partition_auto_increment_innodb.result b/mysql-test/suite/parts/r/partition_auto_increment_innodb.result index f42281d4cb6..a30dfbcbe72 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_innodb.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_innodb.result @@ -35,6 +35,12 @@ SET INSERT_ID = 30; INSERT INTO t1 VALUES (NULL); UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 51 WHERE c1 = 19; +FLUSH TABLES; +UPDATE t1 SET c1 = 40 WHERE c1 = 50; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' + AND TABLE_NAME='t1'; +AUTO_INCREMENT +31 UPDATE t1 SET c1 = NULL WHERE c1 = 4; INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL); @@ -52,7 +58,7 @@ c1 30 31 32 -50 +40 51 DROP TABLE t1; CREATE TABLE t1 ( @@ -110,6 +116,19 @@ t1 CREATE TABLE `t1` ( SELECT * FROM t1 ORDER BY c1; c1 1 +INSERT INTO t1 VALUES (100); +INSERT INTO t1 VALUES (NULL); +DELETE FROM t1 WHERE c1 >= 100; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 DROP TABLE t1; # Simple test with NULL CREATE TABLE t1 ( @@ -189,6 +208,12 @@ INSERT INTO t1 VALUES (NULL), (90); INSERT INTO t1 VALUES (NULL); UPDATE t1 SET c1 = 150 WHERE c1 = 17; UPDATE t1 SET c1 = 151 WHERE c1 = 19; +FLUSH TABLES; +UPDATE t1 SET c1 = 140 WHERE c1 = 150; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' + AND TABLE_NAME='t1'; +AUTO_INCREMENT +141 UPDATE t1 SET c1 = NULL WHERE c1 = 4; INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL); @@ -209,10 +234,10 @@ c1 60 90 91 -150 +140 +141 +142 151 -152 -153 DROP TABLE t1; # Test with auto_increment_increment and auto_increment_offset. CREATE TABLE t1 ( @@ -359,6 +384,21 @@ PARTITIONS 2 */ SELECT * FROM t1 ORDER BY c1; c1 1 +INSERT INTO t1 VALUES (100); +INSERT INTO t1 VALUES (NULL); +DELETE FROM t1 WHERE c1 >= 100; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (c1) +PARTITIONS 2 */ DROP TABLE t1; # Test with two threads # con default diff --git a/mysql-test/suite/parts/r/partition_auto_increment_memory.result b/mysql-test/suite/parts/r/partition_auto_increment_memory.result index 1b81199ad8d..96925d206f6 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_memory.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_memory.result @@ -35,6 +35,12 @@ SET INSERT_ID = 30; INSERT INTO t1 VALUES (NULL); UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 51 WHERE c1 = 19; +FLUSH TABLES; +UPDATE t1 SET c1 = 40 WHERE c1 = 50; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' + AND TABLE_NAME='t1'; +AUTO_INCREMENT +52 UPDATE t1 SET c1 = NULL WHERE c1 = 4; INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL); @@ -50,7 +56,7 @@ c1 22 23 30 -50 +40 51 52 53 @@ -110,6 +116,18 @@ t1 CREATE TABLE `t1` ( SELECT * FROM t1 ORDER BY c1; c1 1 +INSERT INTO t1 VALUES (100); +INSERT INTO t1 VALUES (NULL); +DELETE FROM t1 WHERE c1 >= 100; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note The storage engine for the table doesn't support optimize +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MEMORY AUTO_INCREMENT=102 DEFAULT CHARSET=latin1 DROP TABLE t1; # Simple test with NULL CREATE TABLE t1 ( @@ -189,6 +207,12 @@ INSERT INTO t1 VALUES (NULL), (90); INSERT INTO t1 VALUES (NULL); UPDATE t1 SET c1 = 150 WHERE c1 = 17; UPDATE t1 SET c1 = 151 WHERE c1 = 19; +FLUSH TABLES; +UPDATE t1 SET c1 = 140 WHERE c1 = 150; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' + AND TABLE_NAME='t1'; +AUTO_INCREMENT +152 UPDATE t1 SET c1 = NULL WHERE c1 = 4; INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL); @@ -209,7 +233,7 @@ c1 60 90 91 -150 +140 151 152 153 @@ -359,6 +383,20 @@ PARTITIONS 2 */ SELECT * FROM t1 ORDER BY c1; c1 27 +INSERT INTO t1 VALUES (100); +INSERT INTO t1 VALUES (NULL); +DELETE FROM t1 WHERE c1 >= 100; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note The storage engine for the table doesn't support optimize +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MEMORY AUTO_INCREMENT=102 DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (c1) +PARTITIONS 2 */ DROP TABLE t1; # Test with two threads # con default diff --git a/mysql-test/suite/parts/r/partition_auto_increment_myisam.result b/mysql-test/suite/parts/r/partition_auto_increment_myisam.result index 6a04304f8a7..204c241cfa8 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_myisam.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_myisam.result @@ -35,6 +35,12 @@ SET INSERT_ID = 30; INSERT INTO t1 VALUES (NULL); UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 51 WHERE c1 = 19; +FLUSH TABLES; +UPDATE t1 SET c1 = 40 WHERE c1 = 50; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' + AND TABLE_NAME='t1'; +AUTO_INCREMENT +52 UPDATE t1 SET c1 = NULL WHERE c1 = 4; INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL); @@ -50,7 +56,7 @@ c1 22 23 30 -50 +40 51 52 53 @@ -110,6 +116,18 @@ t1 CREATE TABLE `t1` ( SELECT * FROM t1 ORDER BY c1; c1 1 +INSERT INTO t1 VALUES (100); +INSERT INTO t1 VALUES (NULL); +DELETE FROM t1 WHERE c1 >= 100; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MyISAM AUTO_INCREMENT=102 DEFAULT CHARSET=latin1 DROP TABLE t1; # Simple test with NULL CREATE TABLE t1 ( @@ -189,6 +207,12 @@ INSERT INTO t1 VALUES (NULL), (90); INSERT INTO t1 VALUES (NULL); UPDATE t1 SET c1 = 150 WHERE c1 = 17; UPDATE t1 SET c1 = 151 WHERE c1 = 19; +FLUSH TABLES; +UPDATE t1 SET c1 = 140 WHERE c1 = 150; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' + AND TABLE_NAME='t1'; +AUTO_INCREMENT +152 UPDATE t1 SET c1 = NULL WHERE c1 = 4; INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL); @@ -209,7 +233,7 @@ c1 60 90 91 -150 +140 151 152 153 @@ -359,6 +383,20 @@ PARTITIONS 2 */ SELECT * FROM t1 ORDER BY c1; c1 27 +INSERT INTO t1 VALUES (100); +INSERT INTO t1 VALUES (NULL); +DELETE FROM t1 WHERE c1 >= 100; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MyISAM AUTO_INCREMENT=102 DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (c1) +PARTITIONS 2 */ DROP TABLE t1; # Test with two threads # con default diff --git a/mysql-test/suite/parts/r/partition_auto_increment_ndb.result b/mysql-test/suite/parts/r/partition_auto_increment_ndb.result index a1c16b6d7d5..85e226b749b 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_ndb.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_ndb.result @@ -36,6 +36,12 @@ SET INSERT_ID = 30; INSERT INTO t1 VALUES (NULL); UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 51 WHERE c1 = 19; +FLUSH TABLES; +UPDATE t1 SET c1 = 40 WHERE c1 = 50; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' + AND TABLE_NAME='t1'; +AUTO_INCREMENT +52 UPDATE t1 SET c1 = NULL WHERE c1 = 4; INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL); @@ -51,7 +57,7 @@ c1 22 23 30 -50 +40 51 52 53 @@ -111,6 +117,18 @@ t1 CREATE TABLE `t1` ( SELECT * FROM t1 ORDER BY c1; c1 1 +INSERT INTO t1 VALUES (100); +INSERT INTO t1 VALUES (NULL); +DELETE FROM t1 WHERE c1 >= 100; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note The storage engine for the table doesn't support optimize +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 DROP TABLE t1; # Simple test with NULL CREATE TABLE t1 ( @@ -190,6 +208,12 @@ INSERT INTO t1 VALUES (NULL), (90); INSERT INTO t1 VALUES (NULL); UPDATE t1 SET c1 = 150 WHERE c1 = 17; UPDATE t1 SET c1 = 151 WHERE c1 = 19; +FLUSH TABLES; +UPDATE t1 SET c1 = 140 WHERE c1 = 150; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' + AND TABLE_NAME='t1'; +AUTO_INCREMENT +152 UPDATE t1 SET c1 = NULL WHERE c1 = 4; INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL); @@ -210,7 +234,7 @@ c1 60 90 91 -150 +140 151 152 153 @@ -360,6 +384,20 @@ PARTITIONS 2 */ SELECT * FROM t1 ORDER BY c1; c1 1 +INSERT INTO t1 VALUES (100); +INSERT INTO t1 VALUES (NULL); +DELETE FROM t1 WHERE c1 >= 100; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note The storage engine for the table doesn't support optimize +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (c1) +PARTITIONS 2 */ DROP TABLE t1; # Test with two threads # con default diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index f2e63771467..49faed36de8 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2998,17 +2998,6 @@ int ha_partition::update_row(const uchar *old_data, uchar *new_data) DBUG_PRINT("info", ("Update in partition %d", new_part_id)); tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */ error= m_file[new_part_id]->ha_update_row(old_data, new_data); - /* - if updating an auto_increment column, update - table_share->ha_data->next_auto_inc_val if needed. - (not to be used if auto_increment on secondary field in a multi- - column index) - mysql_update does not set table->next_number_field, so we use - table->found_next_number_field instead. - */ - if (table->found_next_number_field && new_data == table->record[0] && - !table->s->next_number_keypart) - set_auto_increment_if_higher(table->found_next_number_field->val_int()); reenable_binlog(thd); goto exit; } @@ -3018,9 +3007,6 @@ int ha_partition::update_row(const uchar *old_data, uchar *new_data) old_part_id, new_part_id)); tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */ error= m_file[new_part_id]->ha_write_row(new_data); - if (table->found_next_number_field && new_data == table->record[0] && - !table->s->next_number_keypart) - set_auto_increment_if_higher(table->found_next_number_field->val_int()); reenable_binlog(thd); if (error) goto exit; @@ -3038,6 +3024,22 @@ int ha_partition::update_row(const uchar *old_data, uchar *new_data) } exit: + /* + if updating an auto_increment column, update + table_share->ha_data->next_auto_inc_val if needed. + (not to be used if auto_increment on secondary field in a multi-column + index) + mysql_update does not set table->next_number_field, so we use + table->found_next_number_field instead. + */ + if (table->found_next_number_field && new_data == table->record[0] && + !table->s->next_number_keypart) + { + HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data; + if (!ha_data->auto_inc_initialized) + info(HA_STATUS_AUTO); + set_auto_increment_if_higher(table->found_next_number_field->val_int()); + } table->timestamp_field_type= orig_timestamp_type; DBUG_RETURN(error); } diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 1f684b80f6c..78cf47dd1aa 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -932,10 +932,10 @@ private: { HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data; lock_auto_increment(); + DBUG_ASSERT(ha_data->auto_inc_initialized == TRUE); /* must check when the mutex is taken */ if (nr >= ha_data->next_auto_inc_val) ha_data->next_auto_inc_val= nr + 1; - ha_data->auto_inc_initialized= TRUE; unlock_auto_increment(); } |