Commit 8a544f2a authored by Mattias Jonsson's avatar Mattias Jonsson

merge

parents 7c5d066b 620d955e
...@@ -43,8 +43,13 @@ SET INSERT_ID = 30; ...@@ -43,8 +43,13 @@ SET INSERT_ID = 30;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
if (!$skip_update) 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 = 50 WHERE c1 = 17;
UPDATE t1 SET c1 = 51 WHERE c1 = 19; 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 -- error 0, ER_BAD_NULL_ERROR
UPDATE t1 SET c1 = NULL WHERE c1 = 4; UPDATE t1 SET c1 = NULL WHERE c1 = 4;
if (!$mysql_errno) if (!$mysql_errno)
...@@ -83,6 +88,16 @@ TRUNCATE TABLE t1; ...@@ -83,6 +88,16 @@ TRUNCATE TABLE t1;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
SELECT * FROM t1 ORDER BY c1; 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; DROP TABLE t1;
-- echo # Simple test with NULL -- echo # Simple test with NULL
...@@ -184,6 +199,10 @@ if (!$skip_update) ...@@ -184,6 +199,10 @@ if (!$skip_update)
{ {
UPDATE t1 SET c1 = 150 WHERE c1 = 17; UPDATE t1 SET c1 = 150 WHERE c1 = 17;
UPDATE t1 SET c1 = 151 WHERE c1 = 19; 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 -- error 0, ER_BAD_NULL_ERROR
UPDATE t1 SET c1 = NULL WHERE c1 = 4; UPDATE t1 SET c1 = NULL WHERE c1 = 4;
if (!$mysql_errno) if (!$mysql_errno)
...@@ -295,6 +314,15 @@ TRUNCATE TABLE t1; ...@@ -295,6 +314,15 @@ TRUNCATE TABLE t1;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
SELECT * FROM t1 ORDER BY c1; 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; DROP TABLE t1;
-- echo # Test with two threads -- echo # Test with two threads
......
...@@ -105,6 +105,17 @@ c1 ...@@ -105,6 +105,17 @@ c1
5 5
6 6
7 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; DROP TABLE t1;
# Simple test with NULL # Simple test with NULL
CREATE TABLE t1 ( CREATE TABLE t1 (
...@@ -368,6 +379,19 @@ c1 ...@@ -368,6 +379,19 @@ c1
25 25
26 26
27 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; DROP TABLE t1;
# Test with two threads # Test with two threads
# con default # con default
......
...@@ -36,6 +36,12 @@ SET INSERT_ID = 30; ...@@ -36,6 +36,12 @@ SET INSERT_ID = 30;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 50 WHERE c1 = 17;
UPDATE t1 SET c1 = 51 WHERE c1 = 19; 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; UPDATE t1 SET c1 = NULL WHERE c1 = 4;
# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
...@@ -96,6 +102,18 @@ t1 CREATE TABLE `t1` ( ...@@ -96,6 +102,18 @@ t1 CREATE TABLE `t1` (
) ENGINE=BLACKHOLE DEFAULT CHARSET=latin1 ) ENGINE=BLACKHOLE DEFAULT CHARSET=latin1
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
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; DROP TABLE t1;
# Simple test with NULL # Simple test with NULL
CREATE TABLE t1 ( CREATE TABLE t1 (
...@@ -167,6 +185,12 @@ INSERT INTO t1 VALUES (NULL), (90); ...@@ -167,6 +185,12 @@ INSERT INTO t1 VALUES (NULL), (90);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
UPDATE t1 SET c1 = 150 WHERE c1 = 17; UPDATE t1 SET c1 = 150 WHERE c1 = 17;
UPDATE t1 SET c1 = 151 WHERE c1 = 19; 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; UPDATE t1 SET c1 = NULL WHERE c1 = 4;
# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
...@@ -278,6 +302,20 @@ t1 CREATE TABLE `t1` ( ...@@ -278,6 +302,20 @@ t1 CREATE TABLE `t1` (
PARTITIONS 2 */ PARTITIONS 2 */
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
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; DROP TABLE t1;
# Test with two threads # Test with two threads
# con default # con default
......
...@@ -35,6 +35,12 @@ SET INSERT_ID = 30; ...@@ -35,6 +35,12 @@ SET INSERT_ID = 30;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 50 WHERE c1 = 17;
UPDATE t1 SET c1 = 51 WHERE c1 = 19; 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; UPDATE t1 SET c1 = NULL WHERE c1 = 4;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
...@@ -52,7 +58,7 @@ c1 ...@@ -52,7 +58,7 @@ c1
30 30
31 31
32 32
50 40
51 51
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
...@@ -110,6 +116,19 @@ t1 CREATE TABLE `t1` ( ...@@ -110,6 +116,19 @@ t1 CREATE TABLE `t1` (
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
1 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; DROP TABLE t1;
# Simple test with NULL # Simple test with NULL
CREATE TABLE t1 ( CREATE TABLE t1 (
...@@ -189,6 +208,12 @@ INSERT INTO t1 VALUES (NULL), (90); ...@@ -189,6 +208,12 @@ INSERT INTO t1 VALUES (NULL), (90);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
UPDATE t1 SET c1 = 150 WHERE c1 = 17; UPDATE t1 SET c1 = 150 WHERE c1 = 17;
UPDATE t1 SET c1 = 151 WHERE c1 = 19; 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; UPDATE t1 SET c1 = NULL WHERE c1 = 4;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
...@@ -209,10 +234,10 @@ c1 ...@@ -209,10 +234,10 @@ c1
60 60
90 90
91 91
150 140
141
142
151 151
152
153
DROP TABLE t1; DROP TABLE t1;
# Test with auto_increment_increment and auto_increment_offset. # Test with auto_increment_increment and auto_increment_offset.
CREATE TABLE t1 ( CREATE TABLE t1 (
...@@ -359,6 +384,21 @@ PARTITIONS 2 */ ...@@ -359,6 +384,21 @@ PARTITIONS 2 */
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
1 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; DROP TABLE t1;
# Test with two threads # Test with two threads
# con default # con default
......
...@@ -35,6 +35,12 @@ SET INSERT_ID = 30; ...@@ -35,6 +35,12 @@ SET INSERT_ID = 30;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 50 WHERE c1 = 17;
UPDATE t1 SET c1 = 51 WHERE c1 = 19; 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; UPDATE t1 SET c1 = NULL WHERE c1 = 4;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
...@@ -50,7 +56,7 @@ c1 ...@@ -50,7 +56,7 @@ c1
22 22
23 23
30 30
50 40
51 51
52 52
53 53
...@@ -110,6 +116,18 @@ t1 CREATE TABLE `t1` ( ...@@ -110,6 +116,18 @@ t1 CREATE TABLE `t1` (
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
1 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; DROP TABLE t1;
# Simple test with NULL # Simple test with NULL
CREATE TABLE t1 ( CREATE TABLE t1 (
...@@ -189,6 +207,12 @@ INSERT INTO t1 VALUES (NULL), (90); ...@@ -189,6 +207,12 @@ INSERT INTO t1 VALUES (NULL), (90);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
UPDATE t1 SET c1 = 150 WHERE c1 = 17; UPDATE t1 SET c1 = 150 WHERE c1 = 17;
UPDATE t1 SET c1 = 151 WHERE c1 = 19; 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; UPDATE t1 SET c1 = NULL WHERE c1 = 4;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
...@@ -209,7 +233,7 @@ c1 ...@@ -209,7 +233,7 @@ c1
60 60
90 90
91 91
150 140
151 151
152 152
153 153
...@@ -359,6 +383,20 @@ PARTITIONS 2 */ ...@@ -359,6 +383,20 @@ PARTITIONS 2 */
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
27 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; DROP TABLE t1;
# Test with two threads # Test with two threads
# con default # con default
......
...@@ -35,6 +35,12 @@ SET INSERT_ID = 30; ...@@ -35,6 +35,12 @@ SET INSERT_ID = 30;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 50 WHERE c1 = 17;
UPDATE t1 SET c1 = 51 WHERE c1 = 19; 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; UPDATE t1 SET c1 = NULL WHERE c1 = 4;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
...@@ -50,7 +56,7 @@ c1 ...@@ -50,7 +56,7 @@ c1
22 22
23 23
30 30
50 40
51 51
52 52
53 53
...@@ -110,6 +116,18 @@ t1 CREATE TABLE `t1` ( ...@@ -110,6 +116,18 @@ t1 CREATE TABLE `t1` (
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
1 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; DROP TABLE t1;
# Simple test with NULL # Simple test with NULL
CREATE TABLE t1 ( CREATE TABLE t1 (
...@@ -189,6 +207,12 @@ INSERT INTO t1 VALUES (NULL), (90); ...@@ -189,6 +207,12 @@ INSERT INTO t1 VALUES (NULL), (90);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
UPDATE t1 SET c1 = 150 WHERE c1 = 17; UPDATE t1 SET c1 = 150 WHERE c1 = 17;
UPDATE t1 SET c1 = 151 WHERE c1 = 19; 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; UPDATE t1 SET c1 = NULL WHERE c1 = 4;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
...@@ -209,7 +233,7 @@ c1 ...@@ -209,7 +233,7 @@ c1
60 60
90 90
91 91
150 140
151 151
152 152
153 153
...@@ -359,6 +383,20 @@ PARTITIONS 2 */ ...@@ -359,6 +383,20 @@ PARTITIONS 2 */
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
27 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; DROP TABLE t1;
# Test with two threads # Test with two threads
# con default # con default
......
...@@ -36,6 +36,12 @@ SET INSERT_ID = 30; ...@@ -36,6 +36,12 @@ SET INSERT_ID = 30;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 50 WHERE c1 = 17;
UPDATE t1 SET c1 = 51 WHERE c1 = 19; 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; UPDATE t1 SET c1 = NULL WHERE c1 = 4;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
...@@ -51,7 +57,7 @@ c1 ...@@ -51,7 +57,7 @@ c1
22 22
23 23
30 30
50 40
51 51
52 52
53 53
...@@ -111,6 +117,18 @@ t1 CREATE TABLE `t1` ( ...@@ -111,6 +117,18 @@ t1 CREATE TABLE `t1` (
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
1 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; DROP TABLE t1;
# Simple test with NULL # Simple test with NULL
CREATE TABLE t1 ( CREATE TABLE t1 (
...@@ -190,6 +208,12 @@ INSERT INTO t1 VALUES (NULL), (90); ...@@ -190,6 +208,12 @@ INSERT INTO t1 VALUES (NULL), (90);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
UPDATE t1 SET c1 = 150 WHERE c1 = 17; UPDATE t1 SET c1 = 150 WHERE c1 = 17;
UPDATE t1 SET c1 = 151 WHERE c1 = 19; 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; UPDATE t1 SET c1 = NULL WHERE c1 = 4;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
...@@ -210,7 +234,7 @@ c1 ...@@ -210,7 +234,7 @@ c1
60 60
90 90
91 91
150 140
151 151
152 152
153 153
...@@ -360,6 +384,20 @@ PARTITIONS 2 */ ...@@ -360,6 +384,20 @@ PARTITIONS 2 */
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
1 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; DROP TABLE t1;
# Test with two threads # Test with two threads
# con default # con default
......
...@@ -2998,17 +2998,6 @@ int ha_partition::update_row(const uchar *old_data, uchar *new_data) ...@@ -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)); DBUG_PRINT("info", ("Update in partition %d", new_part_id));
tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */ tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */
error= m_file[new_part_id]->ha_update_row(old_data, new_data); 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); reenable_binlog(thd);
goto exit; goto exit;
} }
...@@ -3018,9 +3007,6 @@ int ha_partition::update_row(const uchar *old_data, uchar *new_data) ...@@ -3018,9 +3007,6 @@ int ha_partition::update_row(const uchar *old_data, uchar *new_data)
old_part_id, new_part_id)); old_part_id, new_part_id));
tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */ tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */
error= m_file[new_part_id]->ha_write_row(new_data); 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); reenable_binlog(thd);
if (error) if (error)
goto exit; goto exit;
...@@ -3038,6 +3024,22 @@ int ha_partition::update_row(const uchar *old_data, uchar *new_data) ...@@ -3038,6 +3024,22 @@ int ha_partition::update_row(const uchar *old_data, uchar *new_data)
} }
exit: 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; table->timestamp_field_type= orig_timestamp_type;
DBUG_RETURN(error); DBUG_RETURN(error);
} }
......
...@@ -932,10 +932,10 @@ private: ...@@ -932,10 +932,10 @@ private:
{ {
HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data; HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data;
lock_auto_increment(); lock_auto_increment();
DBUG_ASSERT(ha_data->auto_inc_initialized == TRUE);
/* must check when the mutex is taken */ /* must check when the mutex is taken */
if (nr >= ha_data->next_auto_inc_val) if (nr >= ha_data->next_auto_inc_val)
ha_data->next_auto_inc_val= nr + 1; ha_data->next_auto_inc_val= nr + 1;
ha_data->auto_inc_initialized= TRUE;
unlock_auto_increment(); unlock_auto_increment();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment