diff options
author | Georgi Kodinov <kgeorge@mysql.com> | 2008-10-07 18:19:32 +0300 |
---|---|---|
committer | Georgi Kodinov <kgeorge@mysql.com> | 2008-10-07 18:19:32 +0300 |
commit | 7831b221e0575e822422d6ba4c8472842386ec9c (patch) | |
tree | 89ad7298ca98cf76588844984f9c72516a2e891b /mysql-test | |
parent | 68fa4edc84c9beca00b5813621159561f9006b1d (diff) | |
parent | b4c5cafeb01adb9f8303520342ff0621d41cf8f8 (diff) | |
download | mariadb-git-7831b221e0575e822422d6ba4c8472842386ec9c.tar.gz |
merged 5.1-5.1.29-rc -> 5.1-bugteam
Diffstat (limited to 'mysql-test')
47 files changed, 5934 insertions, 48 deletions
diff --git a/mysql-test/extra/binlog_tests/binlog.test b/mysql-test/extra/binlog_tests/binlog.test index 48fc5a81c7b..98bd116ba29 100644 --- a/mysql-test/extra/binlog_tests/binlog.test +++ b/mysql-test/extra/binlog_tests/binlog.test @@ -125,6 +125,45 @@ drop table t1; --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /Server ver: [^,]*,/Server version,/ show binlog events from 0; + +# +# Bug #39182: Binary log producing incompatible character set query from +# stored procedure. +# +reset master; +CREATE DATABASE bug39182 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; +USE bug39182; +CREATE TABLE t1 (a VARCHAR(255) COLLATE utf8_unicode_ci) + DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +DELIMITER //; + +CREATE PROCEDURE p1() +BEGIN + DECLARE s1 VARCHAR(255); + SET s1= "test"; + CREATE TEMPORARY TABLE tmp1 + SELECT * FROM t1 WHERE a LIKE CONCAT("%", s1, "%"); + SELECT + COLLATION(NAME_CONST('s1', _utf8'test')) c1, + COLLATION(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) c2, + COLLATION(s1) c3, + COERCIBILITY(NAME_CONST('s1', _utf8'test')) d1, + COERCIBILITY(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) d2, + COERCIBILITY(s1) d3; + DROP TEMPORARY TABLE tmp1; +END// + +DELIMITER ;// + +CALL p1(); +source include/show_binlog_events.inc; + +DROP PROCEDURE p1; +DROP TABLE t1; +DROP DATABASE bug39182; +USE test; + --echo End of 5.0 tests # Test of a too big SET INSERT_ID: see if the truncated value goes diff --git a/mysql-test/extra/binlog_tests/blackhole.test b/mysql-test/extra/binlog_tests/blackhole.test index 2d63ae27aa3..e8671ed2da0 100644 --- a/mysql-test/extra/binlog_tests/blackhole.test +++ b/mysql-test/extra/binlog_tests/blackhole.test @@ -139,15 +139,6 @@ drop table t1,t2,t3; # table # CREATE TABLE t1(a INT) ENGINE=BLACKHOLE; -# NOTE: After exchanging open_ltable() by open_and_lock_tables() in -# handle_delayed_insert() to fix problems with MERGE tables (Bug#26379), -# problems with INSERT DELAYED and BLACKHOLE popped up. open_ltable() -# does not check if the binlogging capabilities of the statement and the -# table match. So the below used to succeed. But since INSERT DELAYED -# switches to row-based logging in mixed-mode and BLACKHOLE cannot do -# row-based logging, it could not really work. Until this problem is -# correctly fixed, we have that error here. ---error ER_BINLOG_LOGGING_IMPOSSIBLE INSERT DELAYED INTO t1 VALUES(1); DROP TABLE t1; diff --git a/mysql-test/extra/rpl_tests/rpl_blackhole.test b/mysql-test/extra/rpl_tests/rpl_blackhole.test new file mode 100644 index 00000000000..1a0eeb3cf15 --- /dev/null +++ b/mysql-test/extra/rpl_tests/rpl_blackhole.test @@ -0,0 +1,32 @@ +# Check replication of one statement assuming that the engine on the +# slave is a blackhole engine. + +# Input: +# $statement Statement to evaluate, it is assumed to change t1 + +# 1. Evaluate statement on master, it is assumed to change t1 +# 2. Wait for statement to be processed on slave +# 3. SELECT from table t1 to see what was written +# 4. Compare position on slave before executing statement and after +# executing statement. If difference is >0, then something was +# written to the binary log on the slave. + +connection slave; +let $before = query_get_value("SHOW MASTER STATUS", Position, 1); + +--echo [on master] +connection master; +eval $statement; + +--echo [on slave] +sync_slave_with_master; +--echo # Expect 0 +SELECT COUNT(*) FROM t1; +let $after = query_get_value("SHOW MASTER STATUS", Position, 1); +let $something_written = `select $after - $before != 0`; +if ($something_written) { + --echo >>> Something was written to binary log <<< +} +if (!$something_written) { + --echo >>> Nothing was written to binary log <<< +} diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index f4e9cf74b72..d2332edd5dc 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -1256,6 +1256,7 @@ connect (con1,localhost,root,,); connect (con2,localhost,root,,); SET SESSION AUTOCOMMIT = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +set binlog_format=mixed; --echo # Switch to connection con1 connection con1; diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index 3d593697ef6..3c78c3ca064 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -312,7 +312,7 @@ sub mtr_report_stats ($) { /Slave: According to the master's version/ or /Slave: Column [0-9]* type mismatch/ or /Slave: Error .* doesn't exist/ or - /Slave: Error .*Deadlock found/ or + /Slave: Deadlock found/ or /Slave: Error .*Unknown table/ or /Slave: Error in Write_rows event: / or /Slave: Field .* of table .* has no default value/ or diff --git a/mysql-test/r/ctype_cp932_binlog_stm.result b/mysql-test/r/ctype_cp932_binlog_stm.result index ff6957202d7..0cd2d395ebc 100644 --- a/mysql-test/r/ctype_cp932_binlog_stm.result +++ b/mysql-test/r/ctype_cp932_binlog_stm.result @@ -40,9 +40,9 @@ IN ind DECIMAL(10,2)) BEGIN INSERT INTO t4 VALUES (ins1, ins2, ind); END -master-bin.000001 784 Query 1 992 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93)) -master-bin.000001 992 Query 1 1081 use `test`; DROP PROCEDURE bug18293 -master-bin.000001 1081 Query 1 1160 use `test`; DROP TABLE t4 +master-bin.000001 784 Query 1 1048 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172 COLLATE 'latin1_swedish_ci'), NAME_CONST('ins2',_cp932 0xED40ED41ED42 COLLATE 'cp932_japanese_ci'), NAME_CONST('ind',47.93)) +master-bin.000001 1048 Query 1 1137 use `test`; DROP PROCEDURE bug18293 +master-bin.000001 1137 Query 1 1216 use `test`; DROP TABLE t4 End of 5.0 tests SHOW BINLOG EVENTS FROM 364; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index c198176532f..fd9cf69907c 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1416,4 +1416,41 @@ SELECT AVG(a), CAST(AVG(a) AS DECIMAL) FROM t1; AVG(a) CAST(AVG(a) AS DECIMAL) 15 15 DROP TABLE t1; +CREATE TABLE derived1 (a bigint(21)); +INSERT INTO derived1 VALUES (2); +CREATE TABLE D ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) DEFAULT NULL, +int_key int(11) DEFAULT NULL, +filler blob, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +INSERT INTO D VALUES +(39,40,4,repeat(' X', 42)), +(43,56,4,repeat(' X', 42)), +(47,12,4,repeat(' X', 42)), +(71,28,4,repeat(' X', 42)), +(76,54,4,repeat(' X', 42)), +(83,45,4,repeat(' X', 42)), +(105,53,12,NULL); +SELECT +(SELECT COUNT( int_nokey ) +FROM derived1 AS X +WHERE +X.int_nokey < 61 +GROUP BY pk +LIMIT 1) +FROM D AS X +WHERE X.int_key < 13 +GROUP BY int_nokey LIMIT 1; +(SELECT COUNT( int_nokey ) +FROM derived1 AS X +WHERE +X.int_nokey < 61 +GROUP BY pk +LIMIT 1) +1 +DROP TABLE derived1; +DROP TABLE D; End of 5.0 tests diff --git a/mysql-test/r/innodb-semi-consistent.result b/mysql-test/r/innodb-semi-consistent.result index f1139390f20..6173048c320 100644 --- a/mysql-test/r/innodb-semi-consistent.result +++ b/mysql-test/r/innodb-semi-consistent.result @@ -1,4 +1,5 @@ drop table if exists t1; +set binlog_format=mixed; set session transaction isolation level read committed; create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; insert into t1 values (1),(2),(3),(4),(5),(6),(7); @@ -6,6 +7,7 @@ set autocommit=0; select * from t1 where a=3 lock in share mode; a 3 +set binlog_format=mixed; set session transaction isolation level read committed; set autocommit=0; update t1 set a=10 where a=5; diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 84760e1720c..5f8c59b9a0c 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1024,6 +1024,7 @@ id code name 4 2 Erik 5 3 Sasha COMMIT; +SET binlog_format='MIXED'; BEGIN; SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt'); @@ -2961,9 +2962,11 @@ drop table t1,t2; create table t1(a int not null, b int, primary key(a)) engine=innodb; insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3); commit; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; update t1 set b = 5 where b = 1; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; select * from t1 where a = 7 and b = 3 for update; @@ -3002,6 +3005,7 @@ d e 3 1 8 6 12 1 +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; insert into t1 select * from t2; @@ -3032,30 +3036,39 @@ a b 3 1 8 6 12 1 +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; insert into t1 select * from t2; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; update t3 set b = (select b from t2 where a = d); +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; insert into t5 (select * from t2 lock in share mode); +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; update t6 set e = (select b from t2 where a = d lock in share mode); +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; insert into t8 (select * from t2 for update); +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; update t9 set e = (select b from t2 where a = d for update); +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update; @@ -3202,6 +3215,7 @@ id -10 1 DROP TABLE t1; +SET binlog_format='MIXED'; SET TX_ISOLATION='read-committed'; SET AUTOCOMMIT=0; DROP TABLE IF EXISTS t1, t2; @@ -3212,6 +3226,7 @@ CREATE TABLE t1 ( a int ) ENGINE=InnoDB; CREATE TABLE t2 LIKE t1; SELECT * FROM t2; a +SET binlog_format='MIXED'; SET TX_ISOLATION='read-committed'; SET AUTOCOMMIT=0; INSERT INTO t1 VALUES (1); @@ -3219,10 +3234,12 @@ COMMIT; SELECT * FROM t1 WHERE a=1; a 1 +SET binlog_format='MIXED'; SET TX_ISOLATION='read-committed'; SET AUTOCOMMIT=0; SELECT * FROM t2; a +SET binlog_format='MIXED'; SET TX_ISOLATION='read-committed'; SET AUTOCOMMIT=0; INSERT INTO t1 VALUES (2); diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 0b33e51ea35..985f4d2b464 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -1512,6 +1512,7 @@ ok drop table t1; SET SESSION AUTOCOMMIT = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +set binlog_format=mixed; # Switch to connection con1 CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256)) ENGINE = InnoDB; diff --git a/mysql-test/r/log_basic.result b/mysql-test/r/log_basic.result index 44d0ff48f1d..edda72fa91e 100644 --- a/mysql-test/r/log_basic.result +++ b/mysql-test/r/log_basic.result @@ -5,8 +5,8 @@ INIT_VALUE SELECT @@log AS INIT_VALUE; INIT_VALUE 1 -SET @@global.log = ON; -SET global log = 0; +SET @@global.general_log = ON; +SET global general_log = 0; 'Bug# 34832: log is a system but it is not accessible using SET @@global.log;' 'SET GLOBAL log; and SELECT @@global.log. SHOW VARIABLES shows the value of log.' '#--------------------FN_DYNVARS_062_02-------------------------#' diff --git a/mysql-test/r/log_bin_trust_routine_creators_basic.result b/mysql-test/r/log_bin_trust_routine_creators_basic.result index 2b7fb548f36..cfcbcddfca3 100644 --- a/mysql-test/r/log_bin_trust_routine_creators_basic.result +++ b/mysql-test/r/log_bin_trust_routine_creators_basic.result @@ -5,17 +5,17 @@ SELECT @start_global_value; '#--------------------FN_DYNVARS_064_01-------------------------#' SET @@global.log_bin_trust_routine_creators = TRUE; Warnings: -Warning 1287 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead +Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead SET @@global.log_bin_trust_routine_creators = DEFAULT; Warnings: -Warning 1287 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead +Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 0 '#--------------------FN_DYNVARS_064_02-------------------------#' SET @@global.log_bin_trust_routine_creators = DEFAULT; Warnings: -Warning 1287 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead +Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators = 'FALSE'; @@global.log_bin_trust_routine_creators = 'FALSE' 1 @@ -24,37 +24,37 @@ Warning 1292 Truncated incorrect DOUBLE value: 'FALSE' '#--------------------FN_DYNVARS_064_03-------------------------#' SET @@global.log_bin_trust_routine_creators = ON; Warnings: -Warning 1287 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead +Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 1 SET @@global.log_bin_trust_routine_creators = OFF; Warnings: -Warning 1287 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead +Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 0 SET @@global.log_bin_trust_routine_creators = 0; Warnings: -Warning 1287 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead +Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 0 SET @@global.log_bin_trust_routine_creators = 1; Warnings: -Warning 1287 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead +Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 1 SET @@global.log_bin_trust_routine_creators = TRUE; Warnings: -Warning 1287 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead +Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 1 SET @@global.log_bin_trust_routine_creators = FALSE; Warnings: -Warning 1287 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead +Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 0 @@ -70,7 +70,7 @@ SET @@global.log_bin_trust_routine_creators = "OFFF"; ERROR 42000: Variable 'log_bin_trust_routine_creators' can't be set to the value of 'OFFF' SET @@global.log_bin_trust_routine_creators = OF; Warnings: -Warning 1287 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead +Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 0 @@ -96,14 +96,14 @@ ERROR HY000: Variable 'log_bin_trust_routine_creators' is a GLOBAL variable '#---------------------FN_DYNVARS_064_07----------------------#' SET @@global.log_bin_trust_routine_creators = TRUE; Warnings: -Warning 1287 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead +Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead SELECT @@log_bin_trust_routine_creators = @@global.log_bin_trust_routine_creators; @@log_bin_trust_routine_creators = @@global.log_bin_trust_routine_creators 1 '#---------------------FN_DYNVARS_064_08----------------------#' SET @@global.log_bin_trust_routine_creators = TRUE; Warnings: -Warning 1287 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead +Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead SELECT @@log_bin_trust_routine_creators; @@log_bin_trust_routine_creators 1 @@ -115,7 +115,7 @@ SELECT log_bin_trust_routine_creators = @@session.log_bin_trust_routine_creators ERROR 42S22: Unknown column 'log_bin_trust_routine_creators' in 'field list' SET @@global.log_bin_trust_routine_creators = @start_global_value; Warnings: -Warning 1287 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead +Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 1 diff --git a/mysql-test/r/log_state.result b/mysql-test/r/log_state.result index c293956148f..63903a034d2 100644 --- a/mysql-test/r/log_state.result +++ b/mysql-test/r/log_state.result @@ -187,6 +187,8 @@ SELECT @@general_log, @@log; @@general_log @@log 1 1 SET GLOBAL log = 0; +Warnings: +Warning 1287 The syntax '@@log' is deprecated and will be removed in MySQL 7.0. Please use '@@general_log' instead SHOW VARIABLES LIKE 'general_log'; Variable_name Value general_log OFF @@ -216,6 +218,8 @@ SELECT @@slow_query_log, @@log_slow_queries; @@slow_query_log @@log_slow_queries 0 0 SET GLOBAL log_slow_queries = 0; +Warnings: +Warning 1287 The syntax '@@log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '@@slow_query_log' instead SHOW VARIABLES LIKE 'slow_query_log'; Variable_name Value slow_query_log OFF @@ -270,4 +274,28 @@ SET GLOBAL general_log_file = @general_log_file_saved; SET GLOBAL slow_query_log_file = @slow_query_log_file_saved; # -- End of Bug#32748. +deprecated: +SET GLOBAL log = 0; +Warnings: +Warning 1287 The syntax '@@log' is deprecated and will be removed in MySQL 7.0. Please use '@@general_log' instead +SET GLOBAL log_slow_queries = 0; +Warnings: +Warning 1287 The syntax '@@log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '@@slow_query_log' instead +SET GLOBAL log = DEFAULT; +Warnings: +Warning 1287 The syntax '@@log' is deprecated and will be removed in MySQL 7.0. Please use '@@general_log' instead +SET GLOBAL log_slow_queries = DEFAULT; +Warnings: +Warning 1287 The syntax '@@log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '@@slow_query_log' instead +not deprecated: +SELECT @@global.general_log_file INTO @my_glf; +SELECT @@global.slow_query_log_file INTO @my_sqlf; +SET GLOBAL general_log = 0; +SET GLOBAL slow_query_log = 0; +SET GLOBAL general_log_file = 'WL4403_G.log'; +SET GLOBAL slow_query_log_file = 'WL4403_SQ.log'; +SET GLOBAL general_log_file = @my_glf; +SET GLOBAL slow_query_log_file = @my_sqlf; +SET GLOBAL general_log = DEFAULT; +SET GLOBAL slow_query_log = DEFAULT; End of 5.1 tests diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 47b0d4f3504..e76c874324e 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1658,4 +1658,74 @@ c1 NULL DROP TABLE t1; SET SQL_MODE= @orig_sql_mode; +create table t1 (s1 int) partition by hash(s1) partitions 2; +create index i on t1 (s1); +insert into t1 values (1); +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1 order by s1 desc; +select * from t1; +s1 +1 +1 +1 +1 +1 +1 +1 +1 +drop table t1; +create table t1 (s1 int) partition by range(s1) +(partition pa1 values less than (10), +partition pa2 values less than MAXVALUE); +create index i on t1 (s1); +insert into t1 values (1); +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1 order by s1 desc; +select * from t1; +s1 +1 +1 +1 +1 +1 +1 +1 +1 +drop table t1; +create table t1 (s1 int) partition by range(s1) +(partition pa1 values less than (10), +partition pa2 values less than MAXVALUE); +create index i on t1 (s1); +insert into t1 values (20); +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1 order by s1 desc; +select * from t1; +s1 +20 +20 +20 +20 +20 +20 +20 +20 +drop table t1; +create table t1 (s1 int) partition by range(s1) +(partition pa1 values less than (10), +partition pa2 values less than MAXVALUE); +create index i on t1 (s1); +insert into t1 values (1), (2), (3), (4), (5), (6), (7), (8); +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1 order by s1 desc; +insert into t1 select s1 from t1 where s1=3; +select count(*) from t1; +count(*) +288 +drop table t1; End of 5.1 tests diff --git a/mysql-test/r/trigger-trans.result b/mysql-test/r/trigger-trans.result index 9e0f1e2c351..29df8cbe06d 100644 --- a/mysql-test/r/trigger-trans.result +++ b/mysql-test/r/trigger-trans.result @@ -161,3 +161,30 @@ SELECT @a, @b; 1 1 DROP TABLE t2, t1; End of 5.0 tests +BUG#31612 +Trigger fired multiple times leads to gaps in auto_increment sequence +create table t1 (a int, val char(1)) engine=InnoDB; +create table t2 (b int auto_increment primary key, +val char(1)) engine=InnoDB; +create trigger t1_after_insert after +insert on t1 for each row insert into t2 set val=NEW.val; +insert into t1 values ( 123, 'a'), ( 123, 'b'), ( 123, 'c'), +(123, 'd'), (123, 'e'), (123, 'f'), (123, 'g'); +insert into t1 values ( 654, 'a'), ( 654, 'b'), ( 654, 'c'), +(654, 'd'), (654, 'e'), (654, 'f'), (654, 'g'); +select * from t2 order by b; +b val +1 a +2 b +3 c +4 d +5 e +6 f +7 g +8 a +9 b +10 c +11 d +12 e +13 f +14 g diff --git a/mysql-test/r/tx_isolation_func.result b/mysql-test/r/tx_isolation_func.result index 8b763edd70c..2242525f14b 100644 --- a/mysql-test/r/tx_isolation_func.result +++ b/mysql-test/r/tx_isolation_func.result @@ -21,8 +21,10 @@ INSERT INTO t1 VALUES(24, 24); '#----------------------------FN_DYNVARS_184_01--------------------------------------#' ** Connection con0 ** SET SESSION tx_isolation = 'READ-UNCOMMITTED'; +set binlog_format=mixed; ** Connection con1 ** SET SESSION tx_isolation = 'READ-UNCOMMITTED'; +set binlog_format=mixed; ** Connection con0 ** START TRANSACTION; SELECT * FROM t1 WHERE a IN (2,4,6,8) FOR UPDATE; diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result index aad8a33ea61..090ac1340ea 100644 --- a/mysql-test/r/warnings.result +++ b/mysql-test/r/warnings.result @@ -167,7 +167,7 @@ max_error_count 10 drop table t1; set table_type=MYISAM; Warnings: -Warning 1287 The syntax 'table_type' is deprecated and will be removed in MySQL 5.2. Please use 'storage_engine' instead +Warning 1287 The syntax '@@table_type' is deprecated and will be removed in MySQL 5.2. Please use '@@storage_engine' instead create table t1 (a int); insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); update t1 set a='abc'; diff --git a/mysql-test/suite/binlog/r/binlog_multi_engine.result b/mysql-test/suite/binlog/r/binlog_multi_engine.result index ffe7915f1f8..a295657b8f8 100644 --- a/mysql-test/suite/binlog/r/binlog_multi_engine.result +++ b/mysql-test/suite/binlog/r/binlog_multi_engine.result @@ -43,8 +43,6 @@ INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2); UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c; UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f; ERROR HY000: Binary logging not possible. Message: Statement cannot be written atomically since more than one engine involved and at least one engine is self-logging -UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c; -ERROR HY000: Binary logging not possible. Message: Statement cannot be written atomically since more than one engine involved and at least one engine is self-logging TRUNCATE t1m; TRUNCATE t1b; TRUNCATE t1n; @@ -68,20 +66,21 @@ RESET MASTER; SET SESSION BINLOG_FORMAT=ROW; INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2); INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2); -ERROR HY000: Binary logging not possible. Message: Row-based format required for this statement, but not allowed by this combination of engines INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2); -UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c; -ERROR HY000: Binary logging not possible. Message: Row-based format required for this statement, but not allowed by this combination of engines UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f; ERROR HY000: Binary logging not possible. Message: Statement cannot be written atomically since more than one engine involved and at least one engine is self-logging UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c; -ERROR HY000: Binary logging not possible. Message: Row-based format required for this statement, but not allowed by this combination of engines +ERROR HY000: Binary logging not possible. Message: Statement cannot be written atomically since more than one engine involved and at least one engine is self-logging show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1m) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1b) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # use `test`; COMMIT master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1n) master-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) diff --git a/mysql-test/suite/binlog/r/binlog_row_binlog.result b/mysql-test/suite/binlog/r/binlog_row_binlog.result index 9668c7ce5ea..1a56e048b27 100644 --- a/mysql-test/suite/binlog/r/binlog_row_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result @@ -1090,6 +1090,53 @@ master-bin.000001 295 Table_map 1 337 table_id: # (test.t1) master-bin.000001 337 Write_rows 1 383 table_id: # flags: STMT_END_F master-bin.000001 383 Query 1 452 use `test`; COMMIT master-bin.000001 452 Query 1 528 use `test`; drop table t1 +reset master; +CREATE DATABASE bug39182 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; +USE bug39182; +CREATE TABLE t1 (a VARCHAR(255) COLLATE utf8_unicode_ci) +DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +CREATE PROCEDURE p1() +BEGIN +DECLARE s1 VARCHAR(255); +SET s1= "test"; +CREATE TEMPORARY TABLE tmp1 +SELECT * FROM t1 WHERE a LIKE CONCAT("%", s1, "%"); +SELECT +COLLATION(NAME_CONST('s1', _utf8'test')) c1, +COLLATION(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) c2, +COLLATION(s1) c3, +COERCIBILITY(NAME_CONST('s1', _utf8'test')) d1, +COERCIBILITY(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) d2, +COERCIBILITY(s1) d3; +DROP TEMPORARY TABLE tmp1; +END// +CALL p1(); +c1 c2 c3 d1 d2 d3 +utf8_general_ci utf8_unicode_ci utf8_unicode_ci 2 2 2 +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # CREATE DATABASE bug39182 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci +master-bin.000001 # Query # # use `bug39182`; CREATE TABLE t1 (a VARCHAR(255) COLLATE utf8_unicode_ci) +DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci +master-bin.000001 # Query # # use `bug39182`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() +BEGIN +DECLARE s1 VARCHAR(255); +SET s1= "test"; +CREATE TEMPORARY TABLE tmp1 +SELECT * FROM t1 WHERE a LIKE CONCAT("%", s1, "%"); +SELECT +COLLATION(NAME_CONST('s1', _utf8'test')) c1, +COLLATION(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) c2, +COLLATION(s1) c3, +COERCIBILITY(NAME_CONST('s1', _utf8'test')) d1, +COERCIBILITY(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) d2, +COERCIBILITY(s1) d3; +DROP TEMPORARY TABLE tmp1; +END +DROP PROCEDURE p1; +DROP TABLE t1; +DROP DATABASE bug39182; +USE test; End of 5.0 tests reset master; create table t1 (id tinyint auto_increment primary key); diff --git a/mysql-test/suite/binlog/r/binlog_stm_binlog.result b/mysql-test/suite/binlog/r/binlog_stm_binlog.result index ae8c1e11737..aadbf950b21 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result @@ -594,6 +594,56 @@ master-bin.000001 4 Format_desc 1 106 Server version, Binlog ver: 4 master-bin.000001 106 Query 1 227 use `test`; create table t1 (a bigint unsigned, b bigint(20) unsigned) master-bin.000001 227 Query 1 351 use `test`; insert into t1 values (9999999999999999,14632475938453979136) master-bin.000001 351 Query 1 427 use `test`; drop table t1 +reset master; +CREATE DATABASE bug39182 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; +USE bug39182; +CREATE TABLE t1 (a VARCHAR(255) COLLATE utf8_unicode_ci) +DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +CREATE PROCEDURE p1() +BEGIN +DECLARE s1 VARCHAR(255); +SET s1= "test"; +CREATE TEMPORARY TABLE tmp1 +SELECT * FROM t1 WHERE a LIKE CONCAT("%", s1, "%"); +SELECT +COLLATION(NAME_CONST('s1', _utf8'test')) c1, +COLLATION(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) c2, +COLLATION(s1) c3, +COERCIBILITY(NAME_CONST('s1', _utf8'test')) d1, +COERCIBILITY(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) d2, +COERCIBILITY(s1) d3; +DROP TEMPORARY TABLE tmp1; +END// +CALL p1(); +c1 c2 c3 d1 d2 d3 +utf8_general_ci utf8_unicode_ci utf8_unicode_ci 2 2 2 +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # CREATE DATABASE bug39182 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci +master-bin.000001 # Query # # use `bug39182`; CREATE TABLE t1 (a VARCHAR(255) COLLATE utf8_unicode_ci) +DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci +master-bin.000001 # Query # # use `bug39182`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() +BEGIN +DECLARE s1 VARCHAR(255); +SET s1= "test"; +CREATE TEMPORARY TABLE tmp1 +SELECT * FROM t1 WHERE a LIKE CONCAT("%", s1, "%"); +SELECT +COLLATION(NAME_CONST('s1', _utf8'test')) c1, +COLLATION(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) c2, +COLLATION(s1) c3, +COERCIBILITY(NAME_CONST('s1', _utf8'test')) d1, +COERCIBILITY(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) d2, +COERCIBILITY(s1) d3; +DROP TEMPORARY TABLE tmp1; +END +master-bin.000001 # Query # # use `bug39182`; CREATE TEMPORARY TABLE tmp1 +SELECT * FROM t1 WHERE a LIKE CONCAT("%", NAME_CONST('s1',_utf8'test' COLLATE 'utf8_unicode_ci'), "%") +master-bin.000001 # Query # # use `bug39182`; DROP TEMPORARY TABLE tmp1 +DROP PROCEDURE p1; +DROP TABLE t1; +DROP DATABASE bug39182; +USE test; End of 5.0 tests reset master; create table t1 (id tinyint auto_increment primary key); diff --git a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result index 619fd39a2a9..30f298488fc 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result +++ b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result @@ -141,7 +141,6 @@ master-bin.000001 # Query # # use `test`; COMMIT drop table t1,t2,t3; CREATE TABLE t1(a INT) ENGINE=BLACKHOLE; INSERT DELAYED INTO t1 VALUES(1); -ERROR HY000: Binary logging not possible. Message: Row-based format required for this statement, but not allowed by this combination of engines DROP TABLE t1; CREATE TABLE t1(a INT, b INT) ENGINE=BLACKHOLE; DELETE FROM t1 WHERE a=10; diff --git a/mysql-test/suite/binlog/t/binlog_multi_engine.test b/mysql-test/suite/binlog/t/binlog_multi_engine.test index bf84eed6ec1..c8136d669e4 100644 --- a/mysql-test/suite/binlog/t/binlog_multi_engine.test +++ b/mysql-test/suite/binlog/t/binlog_multi_engine.test @@ -69,9 +69,6 @@ UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f; #UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f; -error ER_BINLOG_LOGGING_IMPOSSIBLE; -UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c; - TRUNCATE t1m; TRUNCATE t1b; TRUNCATE t1n; @@ -83,13 +80,11 @@ RESET MASTER; SET SESSION BINLOG_FORMAT=ROW; INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2); -error ER_BINLOG_LOGGING_IMPOSSIBLE; + INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2); INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2); error ER_BINLOG_LOGGING_IMPOSSIBLE; -UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c; -error ER_BINLOG_LOGGING_IMPOSSIBLE; UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f; # Not possible to test this since NDB writes its own binlog, which diff --git a/mysql-test/suite/ndb/t/disabled.def b/mysql-test/suite/ndb/t/disabled.def index 6102d182684..c638c7b4774 100644 --- a/mysql-test/suite/ndb/t/disabled.def +++ b/mysql-test/suite/ndb/t/disabled.def @@ -12,6 +12,5 @@ partition_03ndb : BUG#16385 2006-03-24 mikael Partitions: crash when updating a range partitioned NDB table ndb_partition_error2 : HF is not sure if the test can work as internded on all the platforms -ndb_index_ordered : Bug#38370 The test ndb.ndb_index_ordered fails with the community features on # the below testcase have been reworked to avoid the bug, test contains comment, keep bug open diff --git a/mysql-test/suite/parts/inc/partition_auto_increment.inc b/mysql-test/suite/parts/inc/partition_auto_increment.inc new file mode 100644 index 00000000000..341bf7ab860 --- /dev/null +++ b/mysql-test/suite/parts/inc/partition_auto_increment.inc @@ -0,0 +1,600 @@ +# inc/partition_auto_increment.inc +# +# auto_increment test +# used variables: $engine +# + +-- disable_warnings +DROP TABLE IF EXISTS t1; +-- enable_warnings + +-- echo # test without partitioning for reference +eval CREATE TABLE t1 ( + c1 INT NOT NULL AUTO_INCREMENT, + PRIMARY KEY (c1)) +ENGINE=$engine; +SHOW CREATE TABLE t1; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +INSERT INTO t1 VALUES (0); +-- error 0, ER_DUP_KEY, ER_DUP_ENTRY +INSERT INTO t1 VALUES (5), (16); +if (!$mysql_errno) +{ + echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY; +} +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (19), (NULL); +-- error 0, ER_DUP_KEY +INSERT INTO t1 VALUES (NULL), (10), (NULL); +if ($mysql_errno) +{ + echo # ERROR (only OK if Archive) mysql_errno: $mysql_errno; +} +INSERT INTO t1 VALUES (NULL); +SET INSERT_ID = 30; +INSERT INTO t1 VALUES (NULL); +if (!$skip_update) +{ + UPDATE t1 SET c1 = 50 WHERE c1 = 17; + UPDATE t1 SET c1 = 51 WHERE c1 = 19; + -- error 0, ER_BAD_NULL_ERROR + UPDATE t1 SET c1 = NULL WHERE c1 = 4; +if (!$mysql_errno) +{ + echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY; +} + INSERT INTO t1 VALUES (NULL); + INSERT INTO t1 VALUES (NULL); +} +SELECT * FROM t1 ORDER BY c1; +DROP TABLE t1; +eval CREATE TABLE t1 ( + c1 INT NOT NULL AUTO_INCREMENT, + PRIMARY KEY (c1)) +ENGINE=$engine; +SHOW CREATE TABLE t1; +FLUSH TABLE; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES (4); +FLUSH TABLE; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES (NULL); +FLUSH TABLE; +SHOW CREATE TABLE t1; +if (!$skip_delete) +{ +DELETE FROM t1; +} +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +SELECT * FROM t1 ORDER BY c1; +if (!$skip_truncate) +{ +TRUNCATE TABLE t1; +} +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +SELECT * FROM t1 ORDER BY c1; +DROP TABLE t1; + +-- echo # Simple test with NULL +eval CREATE TABLE t1 ( + c1 INT NOT NULL AUTO_INCREMENT, + PRIMARY KEY (c1)) +ENGINE=$engine +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +SELECT * FROM t1; +DROP TABLE t1; + +-- echo # Test with sql_mode and first insert as 0 +eval CREATE TABLE t1 ( + c1 INT, + c2 INT NOT NULL AUTO_INCREMENT, + PRIMARY KEY (c2)) +ENGINE=$engine +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, NULL); +-- error 0, ER_DUP_KEY +INSERT INTO t1 VALUES (1, 1), (99, 99); +if (!$mysql_errno) +{ + echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY; +} +INSERT INTO t1 VALUES (1, NULL); +let $old_sql_mode = `select @@session.sql_mode`; +SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; +-- error 0, ER_DUP_KEY +INSERT INTO t1 VALUES (1, 0); +if ($mysql_errno) +{ + echo # ERROR (only OK if Archive) mysql_errno: $mysql_errno; +} +SELECT * FROM t1 ORDER BY c1, c2; +DROP TABLE t1; +eval CREATE TABLE t1 ( + c1 INT, + c2 INT NOT NULL AUTO_INCREMENT, + PRIMARY KEY (c2)) +ENGINE=$engine +PARTITION BY HASH(c2) +PARTITIONS 2; +-- error 0, ER_DUP_KEY +INSERT INTO t1 VALUES (1, 0); +if ($mysql_errno) +{ + echo # ERROR (only OK if Archive) mysql_errno: $mysql_errno; +} +INSERT INTO t1 VALUES (1, 1), (1, NULL); +INSERT INTO t1 VALUES (2, NULL), (4, 7); +INSERT INTO t1 VALUES (1, NULL); +SELECT * FROM t1 ORDER BY c1, c2; +eval SET @@session.sql_mode = '$old_sql_mode'; +DROP TABLE t1; + + +-- echo # Simple test with NULL, 0 and explicit values both incr. and desc. +eval CREATE TABLE t1 ( + c1 INT NOT NULL AUTO_INCREMENT, + PRIMARY KEY (c1)) +ENGINE=$engine +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 VALUES (2), (4), (NULL); +INSERT INTO t1 VALUES (0); +-- error 0, ER_DUP_KEY +INSERT INTO t1 VALUES (5), (16); +if (!$mysql_errno) +{ + echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY; +} +INSERT INTO t1 VALUES (17), (19), (NULL); +-- error 0, ER_DUP_KEY +INSERT INTO t1 VALUES (NULL), (10), (NULL); +if ($mysql_errno) +{ + echo # ERROR (only OK if Archive) mysql_errno: $mysql_errno; +} +-- error 0, ER_DUP_KEY +INSERT INTO t1 VALUES (NULL), (9); +if ($mysql_errno) +{ + echo # ERROR (only OK if Archive) mysql_errno: $mysql_errno; +} +-- error 0, ER_DUP_KEY +INSERT INTO t1 VALUES (59), (55); +if ($mysql_errno) +{ + echo # ERROR (only OK if Archive) mysql_errno: $mysql_errno; +} +INSERT INTO t1 VALUES (NULL), (90); +INSERT INTO t1 VALUES (NULL); +if (!$skip_update) +{ + UPDATE t1 SET c1 = 150 WHERE c1 = 17; + UPDATE t1 SET c1 = 151 WHERE c1 = 19; + -- error 0, ER_BAD_NULL_ERROR + UPDATE t1 SET c1 = NULL WHERE c1 = 4; +if (!$mysql_errno) +{ + echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY; +} + INSERT INTO t1 VALUES (NULL); + INSERT INTO t1 VALUES (NULL); +} +SELECT * FROM t1 ORDER BY c1; +DROP TABLE t1; + +-- echo # Test with auto_increment_increment and auto_increment_offset. +eval CREATE TABLE t1 ( + c1 INT NOT NULL AUTO_INCREMENT, + PRIMARY KEY (c1)) +ENGINE=$engine +PARTITION BY HASH(c1) +PARTITIONS 2; +let $old_increment = `SELECT @@session.auto_increment_increment`; +let $old_offset = `SELECT @@session.auto_increment_offset`; +SET @@session.auto_increment_increment = 10; +SET @@session.auto_increment_offset = 5; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (NULL), (NULL), (NULL); +SET @@session.auto_increment_increment = 5; +SET @@session.auto_increment_offset = 3; +INSERT INTO t1 VALUES (NULL); +let $new_val = `SELECT LAST_INSERT_ID()`; +eval INSERT INTO t1 VALUES ($new_val + 1); +INSERT INTO t1 VALUES (NULL); +let $new_val = `SELECT LAST_INSERT_ID()`; +eval INSERT INTO t1 VALUES ($new_val + 2); +INSERT INTO t1 VALUES (NULL); +let $new_val = `SELECT LAST_INSERT_ID()`; +eval INSERT INTO t1 VALUES ($new_val + 3); +INSERT INTO t1 VALUES (NULL); +let $new_val = `SELECT LAST_INSERT_ID()`; +eval INSERT INTO t1 VALUES ($new_val + 4); +INSERT INTO t1 VALUES (NULL); +let $new_val = `SELECT LAST_INSERT_ID()`; +eval INSERT INTO t1 VALUES ($new_val + 5); +INSERT INTO t1 VALUES (NULL); +let $new_val = `SELECT LAST_INSERT_ID()`; +eval INSERT INTO t1 VALUES ($new_val + 6); +INSERT INTO t1 VALUES (NULL); +eval SET @@session.auto_increment_increment = $old_increment; +eval SET @@session.auto_increment_offset = $old_offset; +SELECT * FROM t1 ORDER BY c1; +DROP TABLE t1; + + +-- echo # Test reported auto_increment value +eval CREATE TABLE t1 ( + c1 INT NOT NULL AUTO_INCREMENT, + PRIMARY KEY (c1)) +ENGINE=$engine +PARTITION BY HASH (c1) +PARTITIONS 2; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +INSERT INTO t1 VALUES (2); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (19); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +-- error 0, ER_DUP_KEY +INSERT INTO t1 VALUES (10); +if ($mysql_errno) +{ + echo # ERROR (only OK if Archive) mysql_errno: $mysql_errno; +} +SELECT * FROM t1 ORDER BY c1; +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +INSERT INTO t1 VALUES (NULL); +-- error 0, ER_DUP_KEY +INSERT INTO t1 VALUES (15); +if ($mysql_errno) +{ + echo # ERROR (only OK if Archive) mysql_errno: $mysql_errno; +} +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +INSERT INTO t1 VALUES (NULL); +if (!$skip_delete) +{ +DELETE FROM t1; +} +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +SELECT * FROM t1 ORDER BY c1; +if (!$skip_truncate) +{ +TRUNCATE TABLE t1; +} +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +SELECT * FROM t1 ORDER BY c1; +DROP TABLE t1; + +-- echo # Test with two threads +connection default; +-- echo # con default +eval CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) + ENGINE = $engine + PARTITION BY HASH(c1) + PARTITIONS 2; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +connect(con1, localhost, root,,); +connection con1; +-- echo # con1 +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (10); +connection default; +-- echo # con default +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (19); +INSERT INTO t1 (c1) VALUES (21); +-- echo # con1 +connection con1; +INSERT INTO t1 (c1) VALUES (NULL); +connection default; +-- echo # con default +-- error 0, ER_DUP_KEY +INSERT INTO t1 (c1) VALUES (16); +if ($mysql_errno) +{ + echo # ERROR (only OK if Archive) mysql_errno: $mysql_errno; +} +-- echo # con1 +connection con1; +INSERT INTO t1 (c1) VALUES (NULL); +disconnect con1; +connection default; +-- echo # con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +DROP TABLE t1; + +-- echo # Test with two threads + start transaction NO PARTITIONING +connect(con1, localhost, root,,); +connection default; +-- echo # con default +eval CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) + ENGINE = $engine; +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +connection con1; +-- echo # con1 +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (10); +connection default; +-- echo # con default +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (19); +INSERT INTO t1 (c1) VALUES (21); +-- echo # con1 +connection con1; +INSERT INTO t1 (c1) VALUES (NULL); +connection default; +-- echo # con default +-- error 0, ER_DUP_KEY +INSERT INTO t1 (c1) VALUES (16); +if ($mysql_errno) +{ + echo # ERROR (only OK if Archive) mysql_errno: $mysql_errno; +} +-- echo # con1 +connection con1; +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +COMMIT; +SELECT * FROM t1 ORDER BY c1; +disconnect con1; +connection default; +-- echo # con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +COMMIT; +SELECT * FROM t1 ORDER BY c1; +DROP TABLE t1; + +-- echo # Test with two threads + start transaction +connect(con1, localhost, root,,); +connection default; +-- echo # con default +eval CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) + ENGINE = $engine + PARTITION BY HASH(c1) + PARTITIONS 2; +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +connection con1; +-- echo # con1 +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (NULL), (10); +connection default; +-- echo # con default +INSERT INTO t1 (c1) VALUES (NULL), (NULL), (19); +INSERT INTO t1 (c1) VALUES (21); +-- echo # con1 +connection con1; +INSERT INTO t1 (c1) VALUES (NULL); +connection default; +-- echo # con default +-- error 0, ER_DUP_KEY +INSERT INTO t1 (c1) VALUES (16); +if ($mysql_errno) +{ + echo # ERROR (only OK if Archive) mysql_errno: $mysql_errno; +} +-- echo # con1 +connection con1; +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +COMMIT; +SELECT * FROM t1 ORDER BY c1; +disconnect con1; +connection default; +-- echo # con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +COMMIT; +SELECT * FROM t1 ORDER BY c1; +DROP TABLE t1; + +if (!$only_ai_pk) +{ +-- echo # Test with another column after +eval CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +c2 INT, +PRIMARY KEY (c1,c2)) +ENGINE = $engine +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 VALUES (NULL, 1), (NULL, 2), (NULL, 3); +INSERT INTO t1 VALUES (NULL, 3); +INSERT INTO t1 VALUES (2, 0), (NULL, 2); +INSERT INTO t1 VALUES (2, 2); +INSERT INTO t1 VALUES (2, 22); +INSERT INTO t1 VALUES (NULL, 2); +SELECT * FROM t1 ORDER BY c1,c2; +DROP TABLE t1; +} + +-- echo # Test with another column before +eval CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE = $engine +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +-- error 0, ER_DUP_KEY, ER_DUP_ENTRY +INSERT INTO t1 VALUES (1, 1); +if (!$mysql_errno) +{ + echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY; +} +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (2, NULL), (3, 11), (3, NULL), (2, 0); +INSERT INTO t1 VALUES (2, NULL); +-- error 0, ER_DUP_KEY, ER_DUP_ENTRY +INSERT INTO t1 VALUES (2, 2); +if (!$mysql_errno) +{ + echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY; +} +INSERT INTO t1 VALUES (2, 22); +INSERT INTO t1 VALUES (2, NULL); +SELECT * FROM t1 ORDER BY c1,c2; +DROP TABLE t1; + +-- echo # Test with auto_increment on secondary column in multi-column-index +-- disable_abort_on_error +eval CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1,c2)) +ENGINE = $engine +PARTITION BY HASH(c2) +PARTITIONS 2; +-- enable_abort_on_error +-- disable_query_log +eval SET @my_errno= $mysql_errno ; +let $run = `SELECT @my_errno = 0`; +# ER_WRONG_AUTO_KEY is 1075 +let $ER_WRONG_AUTO_KEY= 1075; +if (`SELECT @my_errno NOT IN (0,$ER_WRONG_AUTO_KEY)`) +{ + -- echo # Unknown error code, exits + exit; +} +-- enable_query_log +if ($run) +{ +INSERT INTO t1 VALUES (1, 0); +-- error 0, ER_DUP_KEY, ER_DUP_ENTRY +INSERT INTO t1 VALUES (1, 1); +if (!$mysql_errno) +{ + echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY; +} +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (2, NULL); +INSERT INTO t1 VALUES (3, NULL); +INSERT INTO t1 VALUES (3, NULL), (2, 0), (2, NULL); +-- error 0, ER_DUP_KEY +INSERT INTO t1 VALUES (2, 2); +if (!$mysql_errno) +{ +echo # ERROR (only OK if Blackhole/NDB) should give ER_DUP_KEY or ER_DUP_ENTRY; +} +INSERT INTO t1 VALUES (2, 22), (2, NULL); +SELECT * FROM t1 ORDER BY c1,c2; +DROP TABLE t1; +} + +-- echo # Test AUTO_INCREMENT in CREATE +eval CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) + ENGINE = $engine + AUTO_INCREMENT = 15 + PARTITION BY HASH(c1) + PARTITIONS 2; +SHOW CREATE TABLE t1; +-- error 0, ER_DUP_KEY +INSERT INTO t1 (c1) VALUES (4); +if ($mysql_errno) +{ + echo # ERROR (only OK if Archive) mysql_errno: $mysql_errno; +} +SHOW CREATE TABLE t1; +INSERT INTO t1 (c1) VALUES (0); +SHOW CREATE TABLE t1; +INSERT INTO t1 (c1) VALUES (NULL); +SHOW CREATE TABLE t1; +SELECT * FROM t1 ORDER BY c1; + +-- echo # Test sql_mode 'NO_AUTO_VALUE_ON_ZERO' +let $old_sql_mode = `select @@session.sql_mode`; +SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; +INSERT INTO t1 (c1) VALUES (300); +SHOW CREATE TABLE t1; +-- error 0, ER_DUP_KEY +INSERT INTO t1 (c1) VALUES (0); +if ($mysql_errno) +{ + echo # ERROR (only OK if Archive) mysql_errno: $mysql_errno; +} +SHOW CREATE TABLE t1; +INSERT INTO t1 (c1) VALUES (NULL); +SHOW CREATE TABLE t1; +SELECT * FROM t1 ORDER BY c1; +eval SET @@session.sql_mode = '$old_sql_mode'; +DROP TABLE t1; + +-- echo # Test SET INSERT_ID +eval CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) + ENGINE = $engine + PARTITION BY HASH(c1) + PARTITIONS 2; +SHOW CREATE TABLE t1; +INSERT INTO t1 (c1) VALUES (NULL); +SHOW CREATE TABLE t1; +SELECT * FROM t1; +SET INSERT_ID = 23; +SHOW CREATE TABLE t1; +INSERT INTO t1 (c1) VALUES (NULL); +SHOW CREATE TABLE t1; +SELECT * FROM t1 ORDER BY c1; +DROP TABLE t1; + +-- echo # Testing with FLUSH TABLE +eval CREATE TABLE t1 ( + c1 INT NOT NULL AUTO_INCREMENT, + PRIMARY KEY (c1)) + ENGINE=$engine + PARTITION BY HASH(c1) + PARTITIONS 2; +SHOW CREATE TABLE t1; +FLUSH TABLE; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES (4); +FLUSH TABLE; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES (NULL); +FLUSH TABLE; +SHOW CREATE TABLE t1; +SELECT * FROM t1 ORDER BY c1; +DROP TABLE t1; + diff --git a/mysql-test/suite/parts/r/partition_auto_increment_archive.result b/mysql-test/suite/parts/r/partition_auto_increment_archive.result new file mode 100644 index 00000000000..edfe408a072 --- /dev/null +++ b/mysql-test/suite/parts/r/partition_auto_increment_archive.result @@ -0,0 +1,747 @@ +DROP TABLE IF EXISTS t1; +# test without partitioning for reference +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Archive'; +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 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +INSERT INTO t1 VALUES (0); +INSERT INTO t1 VALUES (5), (16); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (19), (NULL); +INSERT INTO t1 VALUES (NULL), (10), (NULL); +# ERROR (only OK if Archive) mysql_errno: 1022 +INSERT INTO t1 VALUES (NULL); +SET INSERT_ID = 30; +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +17 +19 +20 +21 +22 +30 +DROP TABLE t1; +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Archive'; +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 +FLUSH TABLE; +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 +INSERT INTO t1 VALUES (4); +FLUSH TABLE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (NULL); +FLUSH TABLE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 +SELECT * FROM t1 ORDER BY c1; +c1 +4 +5 +6 +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=8 DEFAULT CHARSET=latin1 +SELECT * FROM t1 ORDER BY c1; +c1 +4 +5 +6 +7 +DROP TABLE t1; +# Simple test with NULL +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Archive' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1; +c1 +1 +DROP TABLE t1; +# Test with sql_mode and first insert as 0 +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE='Archive' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (1, 1), (99, 99); +INSERT INTO t1 VALUES (1, NULL); +SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; +INSERT INTO t1 VALUES (1, 0); +# ERROR (only OK if Archive) mysql_errno: 1022 +SELECT * FROM t1 ORDER BY c1, c2; +c1 c2 +1 1 +1 2 +DROP TABLE t1; +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE='Archive' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +# ERROR (only OK if Archive) mysql_errno: 1022 +INSERT INTO t1 VALUES (1, 1), (1, NULL); +INSERT INTO t1 VALUES (2, NULL), (4, 7); +INSERT INTO t1 VALUES (1, NULL); +SELECT * FROM t1 ORDER BY c1, c2; +c1 c2 +1 1 +1 2 +1 8 +2 3 +4 7 +SET @@session.sql_mode = ''; +DROP TABLE t1; +# Simple test with NULL, 0 and explicit values both incr. and desc. +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Archive' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 VALUES (2), (4), (NULL); +INSERT INTO t1 VALUES (0); +INSERT INTO t1 VALUES (5), (16); +INSERT INTO t1 VALUES (17), (19), (NULL); +INSERT INTO t1 VALUES (NULL), (10), (NULL); +# ERROR (only OK if Archive) mysql_errno: 1022 +INSERT INTO t1 VALUES (NULL), (9); +# ERROR (only OK if Archive) mysql_errno: 1022 +INSERT INTO t1 VALUES (59), (55); +# ERROR (only OK if Archive) mysql_errno: 1022 +INSERT INTO t1 VALUES (NULL), (90); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +17 +19 +20 +21 +22 +59 +60 +90 +91 +DROP TABLE t1; +# Test with auto_increment_increment and auto_increment_offset. +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Archive' +PARTITION BY HASH(c1) +PARTITIONS 2; +SET @@session.auto_increment_increment = 10; +SET @@session.auto_increment_offset = 5; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (NULL), (NULL), (NULL); +SET @@session.auto_increment_increment = 5; +SET @@session.auto_increment_offset = 3; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (33 + 1); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (38 + 2); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (43 + 3); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (48 + 4); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (53 + 5); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (63 + 6); +INSERT INTO t1 VALUES (NULL); +SET @@session.auto_increment_increment = 1; +SET @@session.auto_increment_offset = 1; +SELECT * FROM t1 ORDER BY c1; +c1 +1 +5 +15 +25 +33 +34 +38 +40 +43 +46 +48 +52 +53 +58 +63 +69 +73 +DROP TABLE t1; +# Test reported auto_increment value +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Archive' +PARTITION BY HASH (c1) +PARTITIONS 2; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 +INSERT INTO t1 VALUES (2); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +3 +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (19); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +22 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +22 +INSERT INTO t1 VALUES (10); +# ERROR (only OK if Archive) mysql_errno: 1022 +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +17 +19 +20 +21 +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +23 +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (15); +# ERROR (only OK if Archive) mysql_errno: 1022 +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +17 +19 +20 +21 +22 +23 +24 +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=27 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +17 +19 +20 +21 +22 +23 +24 +25 +26 +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=28 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +17 +19 +20 +21 +22 +23 +24 +25 +26 +27 +DROP TABLE t1; +# Test with two threads +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'Archive' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# ERROR (only OK if Archive) mysql_errno: 1022 +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +19 +21 +22 +23 +24 +DROP TABLE t1; +# Test with two threads + start transaction NO PARTITIONING +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'Archive'; +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# ERROR (only OK if Archive) mysql_errno: 1022 +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +19 +21 +22 +23 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +19 +21 +22 +23 +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +19 +21 +22 +23 +24 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +19 +21 +22 +23 +24 +DROP TABLE t1; +# Test with two threads + start transaction +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'Archive' +PARTITION BY HASH(c1) +PARTITIONS 2; +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (NULL), (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL), (NULL), (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# ERROR (only OK if Archive) mysql_errno: 1022 +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +19 +21 +22 +23 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +19 +21 +22 +23 +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +19 +21 +22 +23 +24 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +19 +21 +22 +23 +24 +DROP TABLE t1; +# Test with another column before +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE = 'Archive' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (2, NULL), (3, 11), (3, NULL), (2, 0); +INSERT INTO t1 VALUES (2, NULL); +INSERT INTO t1 VALUES (2, 2); +INSERT INTO t1 VALUES (2, 22); +INSERT INTO t1 VALUES (2, NULL); +SELECT * FROM t1 ORDER BY c1,c2; +c1 c2 +1 1 +1 2 +2 3 +2 13 +2 14 +2 22 +2 23 +3 11 +3 12 +DROP TABLE t1; +# Test with auto_increment on secondary column in multi-column-index +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1,c2)) +ENGINE = 'Archive' +PARTITION BY HASH(c2) +PARTITIONS 2; +ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key +# Test AUTO_INCREMENT in CREATE +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'Archive' +AUTO_INCREMENT = 15 +PARTITION BY HASH(c1) +PARTITIONS 2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=15 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (4); +# ERROR (only OK if Archive) mysql_errno: 1022 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=15 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (0); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=16 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=17 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +15 +16 +# Test sql_mode 'NO_AUTO_VALUE_ON_ZERO' +SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; +INSERT INTO t1 (c1) VALUES (300); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=301 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (0); +# ERROR (only OK if Archive) mysql_errno: 1022 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=301 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=302 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +15 +16 +300 +301 +SET @@session.sql_mode = ''; +DROP TABLE t1; +# Test SET INSERT_ID +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'Archive' +PARTITION BY HASH(c1) +PARTITIONS 2; +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 */ +INSERT INTO t1 (c1) VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1; +c1 +1 +SET INSERT_ID = 23; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=24 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +1 +23 +DROP TABLE t1; +# Testing with FLUSH TABLE +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Archive' +PARTITION BY HASH(c1) +PARTITIONS 2; +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 */ +FLUSH TABLE; +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 */ +INSERT INTO t1 VALUES (4); +FLUSH TABLE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 VALUES (NULL); +FLUSH TABLE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=ARCHIVE AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +4 +5 +DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result b/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result new file mode 100644 index 00000000000..73b228c1b72 --- /dev/null +++ b/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result @@ -0,0 +1,570 @@ +DROP TABLE IF EXISTS t1; +# test without partitioning for reference +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Blackhole'; +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 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 +INSERT INTO t1 VALUES (0); +INSERT INTO t1 VALUES (5), (16); +# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (19), (NULL); +INSERT INTO t1 VALUES (NULL), (10), (NULL); +INSERT INTO t1 VALUES (NULL); +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; +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); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +DROP TABLE t1; +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Blackhole'; +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 +FLUSH TABLE; +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 +INSERT INTO t1 VALUES (4); +FLUSH TABLE; +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 +INSERT INTO t1 VALUES (NULL); +FLUSH TABLE; +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 +DELETE FROM t1; +INSERT INTO t1 VALUES (NULL); +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 +SELECT * FROM t1 ORDER BY c1; +c1 +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES (NULL); +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 +SELECT * FROM t1 ORDER BY c1; +c1 +DROP TABLE t1; +# Simple test with NULL +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Blackhole' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=BLACKHOLE AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1; +c1 +DROP TABLE t1; +# Test with sql_mode and first insert as 0 +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE='Blackhole' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (1, 1), (99, 99); +# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY +INSERT INTO t1 VALUES (1, NULL); +SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; +INSERT INTO t1 VALUES (1, 0); +SELECT * FROM t1 ORDER BY c1, c2; +c1 c2 +DROP TABLE t1; +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE='Blackhole' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1), (1, NULL); +INSERT INTO t1 VALUES (2, NULL), (4, 7); +INSERT INTO t1 VALUES (1, NULL); +SELECT * FROM t1 ORDER BY c1, c2; +c1 c2 +SET @@session.sql_mode = ''; +DROP TABLE t1; +# Simple test with NULL, 0 and explicit values both incr. and desc. +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Blackhole' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 VALUES (2), (4), (NULL); +INSERT INTO t1 VALUES (0); +INSERT INTO t1 VALUES (5), (16); +# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY +INSERT INTO t1 VALUES (17), (19), (NULL); +INSERT INTO t1 VALUES (NULL), (10), (NULL); +INSERT INTO t1 VALUES (NULL), (9); +INSERT INTO t1 VALUES (59), (55); +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; +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); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +DROP TABLE t1; +# Test with auto_increment_increment and auto_increment_offset. +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Blackhole' +PARTITION BY HASH(c1) +PARTITIONS 2; +SET @@session.auto_increment_increment = 10; +SET @@session.auto_increment_offset = 5; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (NULL), (NULL), (NULL); +SET @@session.auto_increment_increment = 5; +SET @@session.auto_increment_offset = 3; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (33 + 1); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (38 + 2); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (43 + 3); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (48 + 4); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (53 + 5); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (63 + 6); +INSERT INTO t1 VALUES (NULL); +SET @@session.auto_increment_increment = 1; +SET @@session.auto_increment_offset = 1; +SELECT * FROM t1 ORDER BY c1; +c1 +DROP TABLE t1; +# Test reported auto_increment value +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Blackhole' +PARTITION BY HASH (c1) +PARTITIONS 2; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 +INSERT INTO t1 VALUES (2); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +3 +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (19); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +22 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +22 +INSERT INTO t1 VALUES (10); +SELECT * FROM t1 ORDER BY c1; +c1 +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +23 +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (15); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +INSERT INTO t1 VALUES (NULL); +DELETE FROM t1; +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=BLACKHOLE AUTO_INCREMENT=27 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=BLACKHOLE AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +DROP TABLE t1; +# Test with two threads +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'Blackhole' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +DROP TABLE t1; +# Test with two threads + start transaction NO PARTITIONING +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'Blackhole'; +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +DROP TABLE t1; +# Test with two threads + start transaction +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'Blackhole' +PARTITION BY HASH(c1) +PARTITIONS 2; +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (NULL), (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL), (NULL), (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +DROP TABLE t1; +# Test with another column after +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +c2 INT, +PRIMARY KEY (c1,c2)) +ENGINE = 'Blackhole' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 VALUES (NULL, 1), (NULL, 2), (NULL, 3); +INSERT INTO t1 VALUES (NULL, 3); +INSERT INTO t1 VALUES (2, 0), (NULL, 2); +INSERT INTO t1 VALUES (2, 2); +INSERT INTO t1 VALUES (2, 22); +INSERT INTO t1 VALUES (NULL, 2); +SELECT * FROM t1 ORDER BY c1,c2; +c1 c2 +DROP TABLE t1; +# Test with another column before +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE = 'Blackhole' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1); +# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (2, NULL), (3, 11), (3, NULL), (2, 0); +INSERT INTO t1 VALUES (2, NULL); +INSERT INTO t1 VALUES (2, 2); +# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY +INSERT INTO t1 VALUES (2, 22); +INSERT INTO t1 VALUES (2, NULL); +SELECT * FROM t1 ORDER BY c1,c2; +c1 c2 +DROP TABLE t1; +# Test with auto_increment on secondary column in multi-column-index +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1,c2)) +ENGINE = 'Blackhole' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1); +# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (2, NULL); +INSERT INTO t1 VALUES (3, NULL); +INSERT INTO t1 VALUES (3, NULL), (2, 0), (2, NULL); +INSERT INTO t1 VALUES (2, 2); +# ERROR (only OK if Blackhole/NDB) should give ER_DUP_KEY or ER_DUP_ENTRY +INSERT INTO t1 VALUES (2, 22), (2, NULL); +SELECT * FROM t1 ORDER BY c1,c2; +c1 c2 +DROP TABLE t1; +# Test AUTO_INCREMENT in CREATE +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'Blackhole' +AUTO_INCREMENT = 15 +PARTITION BY HASH(c1) +PARTITIONS 2; +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 */ +INSERT INTO t1 (c1) VALUES (4); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=BLACKHOLE AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (0); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=BLACKHOLE AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=BLACKHOLE AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +# Test sql_mode 'NO_AUTO_VALUE_ON_ZERO' +SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; +INSERT INTO t1 (c1) VALUES (300); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=BLACKHOLE AUTO_INCREMENT=301 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (0); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=BLACKHOLE AUTO_INCREMENT=301 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=BLACKHOLE AUTO_INCREMENT=302 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +SET @@session.sql_mode = ''; +DROP TABLE t1; +# Test SET INSERT_ID +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'Blackhole' +PARTITION BY HASH(c1) +PARTITIONS 2; +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 */ +INSERT INTO t1 (c1) VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=BLACKHOLE AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1; +c1 +SET INSERT_ID = 23; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=BLACKHOLE AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=BLACKHOLE AUTO_INCREMENT=24 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +DROP TABLE t1; +# Testing with FLUSH TABLE +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Blackhole' +PARTITION BY HASH(c1) +PARTITIONS 2; +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 */ +FLUSH TABLE; +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 */ +INSERT INTO t1 VALUES (4); +FLUSH TABLE; +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 */ +INSERT INTO t1 VALUES (NULL); +FLUSH TABLE; +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 */ +SELECT * FROM t1 ORDER BY c1; +c1 +DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_auto_increment_innodb.result b/mysql-test/suite/parts/r/partition_auto_increment_innodb.result new file mode 100644 index 00000000000..3cec527c2a6 --- /dev/null +++ b/mysql-test/suite/parts/r/partition_auto_increment_innodb.result @@ -0,0 +1,747 @@ +DROP TABLE IF EXISTS t1; +# test without partitioning for reference +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='InnoDB'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +INSERT INTO t1 VALUES (0); +INSERT INTO t1 VALUES (5), (16); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (19), (NULL); +INSERT INTO t1 VALUES (NULL), (10), (NULL); +INSERT INTO t1 VALUES (NULL); +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; +UPDATE t1 SET c1 = NULL WHERE c1 = 4; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +10 +20 +22 +23 +25 +30 +31 +32 +50 +51 +DROP TABLE t1; +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='InnoDB'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +FLUSH TABLE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (4); +FLUSH TABLE; +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=5 DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (NULL); +FLUSH TABLE; +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=6 DEFAULT CHARSET=latin1 +DELETE FROM t1; +INSERT INTO t1 VALUES (NULL); +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=7 DEFAULT CHARSET=latin1 +SELECT * FROM t1 ORDER BY c1; +c1 +6 +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES (NULL); +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 +SELECT * FROM t1 ORDER BY c1; +c1 +1 +DROP TABLE t1; +# Simple test with NULL +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='InnoDB' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 VALUES (NULL); +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 */ +SELECT * FROM t1; +c1 +1 +DROP TABLE t1; +# Test with sql_mode and first insert as 0 +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE='InnoDB' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (1, 1), (99, 99); +INSERT INTO t1 VALUES (1, NULL); +SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; +INSERT INTO t1 VALUES (1, 0); +SELECT * FROM t1 ORDER BY c1, c2; +c1 c2 +1 0 +1 1 +1 2 +DROP TABLE t1; +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE='InnoDB' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1), (1, NULL); +INSERT INTO t1 VALUES (2, NULL), (4, 7); +INSERT INTO t1 VALUES (1, NULL); +SELECT * FROM t1 ORDER BY c1, c2; +c1 c2 +1 0 +1 1 +1 2 +1 8 +2 3 +4 7 +SET @@session.sql_mode = ''; +DROP TABLE t1; +# Simple test with NULL, 0 and explicit values both incr. and desc. +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='InnoDB' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 VALUES (2), (4), (NULL); +INSERT INTO t1 VALUES (0); +INSERT INTO t1 VALUES (5), (16); +INSERT INTO t1 VALUES (17), (19), (NULL); +INSERT INTO t1 VALUES (NULL), (10), (NULL); +INSERT INTO t1 VALUES (NULL), (9); +INSERT INTO t1 VALUES (59), (55); +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; +UPDATE t1 SET c1 = NULL WHERE c1 = 4; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +9 +10 +20 +21 +22 +23 +55 +59 +60 +90 +91 +150 +151 +152 +153 +DROP TABLE t1; +# Test with auto_increment_increment and auto_increment_offset. +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='InnoDB' +PARTITION BY HASH(c1) +PARTITIONS 2; +SET @@session.auto_increment_increment = 10; +SET @@session.auto_increment_offset = 5; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (NULL), (NULL), (NULL); +SET @@session.auto_increment_increment = 5; +SET @@session.auto_increment_offset = 3; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (33 + 1); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (38 + 2); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (43 + 3); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (48 + 4); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (53 + 5); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (63 + 6); +INSERT INTO t1 VALUES (NULL); +SET @@session.auto_increment_increment = 1; +SET @@session.auto_increment_offset = 1; +SELECT * FROM t1 ORDER BY c1; +c1 +1 +5 +15 +25 +33 +34 +38 +40 +43 +46 +48 +52 +53 +58 +63 +69 +73 +DROP TABLE t1; +# Test reported auto_increment value +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='InnoDB' +PARTITION BY HASH (c1) +PARTITIONS 2; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 +INSERT INTO t1 VALUES (2); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +3 +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (19); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +22 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +22 +INSERT INTO t1 VALUES (10); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +10 +17 +19 +20 +21 +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +23 +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (15); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +10 +15 +17 +19 +20 +21 +22 +23 +24 +INSERT INTO t1 VALUES (NULL); +DELETE FROM t1; +INSERT INTO t1 VALUES (NULL); +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=27 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +26 +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES (NULL); +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 */ +SELECT * FROM t1 ORDER BY c1; +c1 +1 +DROP TABLE t1; +# Test with two threads +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'InnoDB' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +DROP TABLE t1; +# Test with two threads + start transaction NO PARTITIONING +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'InnoDB'; +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +5 +10 +22 +23 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +5 +10 +22 +23 +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +DROP TABLE t1; +# Test with two threads + start transaction +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'InnoDB' +PARTITION BY HASH(c1) +PARTITIONS 2; +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (NULL), (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL), (NULL), (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +5 +10 +22 +23 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +5 +10 +22 +23 +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +DROP TABLE t1; +# Test with another column after +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +c2 INT, +PRIMARY KEY (c1,c2)) +ENGINE = 'InnoDB' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 VALUES (NULL, 1), (NULL, 2), (NULL, 3); +INSERT INTO t1 VALUES (NULL, 3); +INSERT INTO t1 VALUES (2, 0), (NULL, 2); +INSERT INTO t1 VALUES (2, 2); +INSERT INTO t1 VALUES (2, 22); +INSERT INTO t1 VALUES (NULL, 2); +SELECT * FROM t1 ORDER BY c1,c2; +c1 c2 +1 0 +1 1 +2 0 +2 1 +2 2 +2 22 +3 2 +4 3 +5 3 +6 2 +7 2 +DROP TABLE t1; +# Test with another column before +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE = 'InnoDB' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (2, NULL), (3, 11), (3, NULL), (2, 0); +INSERT INTO t1 VALUES (2, NULL); +INSERT INTO t1 VALUES (2, 2); +INSERT INTO t1 VALUES (2, 22); +INSERT INTO t1 VALUES (2, NULL); +SELECT * FROM t1 ORDER BY c1,c2; +c1 c2 +1 1 +1 2 +2 3 +2 13 +2 14 +2 22 +2 23 +3 11 +3 12 +DROP TABLE t1; +# Test with auto_increment on secondary column in multi-column-index +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1,c2)) +ENGINE = 'InnoDB' +PARTITION BY HASH(c2) +PARTITIONS 2; +ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key +# Test AUTO_INCREMENT in CREATE +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'InnoDB' +AUTO_INCREMENT = 15 +PARTITION BY HASH(c1) +PARTITIONS 2; +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=15 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (4); +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=15 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (0); +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=16 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +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=17 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +4 +15 +16 +# Test sql_mode 'NO_AUTO_VALUE_ON_ZERO' +SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; +INSERT INTO t1 (c1) VALUES (300); +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=301 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (0); +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=301 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +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=302 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +0 +4 +15 +16 +300 +301 +SET @@session.sql_mode = ''; +DROP TABLE t1; +# Test SET INSERT_ID +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'InnoDB' +PARTITION BY HASH(c1) +PARTITIONS 2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +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 */ +SELECT * FROM t1; +c1 +1 +SET INSERT_ID = 23; +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 */ +INSERT INTO t1 (c1) VALUES (NULL); +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=24 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +1 +23 +DROP TABLE t1; +# Testing with FLUSH TABLE +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='InnoDB' +PARTITION BY HASH(c1) +PARTITIONS 2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +FLUSH TABLE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 VALUES (4); +FLUSH TABLE; +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=5 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 VALUES (NULL); +FLUSH TABLE; +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=6 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +4 +5 +DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_auto_increment_memory.result b/mysql-test/suite/parts/r/partition_auto_increment_memory.result new file mode 100644 index 00000000000..7a5d80c7758 --- /dev/null +++ b/mysql-test/suite/parts/r/partition_auto_increment_memory.result @@ -0,0 +1,775 @@ +DROP TABLE IF EXISTS t1; +# test without partitioning for reference +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Memory'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +INSERT INTO t1 VALUES (0); +INSERT INTO t1 VALUES (5), (16); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (19), (NULL); +INSERT INTO t1 VALUES (NULL), (10), (NULL); +INSERT INTO t1 VALUES (NULL); +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; +UPDATE t1 SET c1 = NULL WHERE c1 = 4; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +10 +20 +21 +22 +23 +30 +50 +51 +52 +53 +DROP TABLE t1; +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Memory'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +FLUSH TABLE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (4); +FLUSH TABLE; +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=5 DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (NULL); +FLUSH TABLE; +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=6 DEFAULT CHARSET=latin1 +DELETE FROM t1; +INSERT INTO t1 VALUES (NULL); +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=7 DEFAULT CHARSET=latin1 +SELECT * FROM t1 ORDER BY c1; +c1 +6 +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES (NULL); +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=2 DEFAULT CHARSET=latin1 +SELECT * FROM t1 ORDER BY c1; +c1 +1 +DROP TABLE t1; +# Simple test with NULL +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Memory' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 VALUES (NULL); +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=2 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1; +c1 +1 +DROP TABLE t1; +# Test with sql_mode and first insert as 0 +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE='Memory' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (1, 1), (99, 99); +INSERT INTO t1 VALUES (1, NULL); +SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; +INSERT INTO t1 VALUES (1, 0); +SELECT * FROM t1 ORDER BY c1, c2; +c1 c2 +1 0 +1 1 +1 2 +DROP TABLE t1; +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE='Memory' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1), (1, NULL); +INSERT INTO t1 VALUES (2, NULL), (4, 7); +INSERT INTO t1 VALUES (1, NULL); +SELECT * FROM t1 ORDER BY c1, c2; +c1 c2 +1 0 +1 1 +1 2 +1 8 +2 3 +4 7 +SET @@session.sql_mode = ''; +DROP TABLE t1; +# Simple test with NULL, 0 and explicit values both incr. and desc. +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Memory' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 VALUES (2), (4), (NULL); +INSERT INTO t1 VALUES (0); +INSERT INTO t1 VALUES (5), (16); +INSERT INTO t1 VALUES (17), (19), (NULL); +INSERT INTO t1 VALUES (NULL), (10), (NULL); +INSERT INTO t1 VALUES (NULL), (9); +INSERT INTO t1 VALUES (59), (55); +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; +UPDATE t1 SET c1 = NULL WHERE c1 = 4; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +9 +10 +20 +21 +22 +23 +55 +59 +60 +90 +91 +150 +151 +152 +153 +DROP TABLE t1; +# Test with auto_increment_increment and auto_increment_offset. +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Memory' +PARTITION BY HASH(c1) +PARTITIONS 2; +SET @@session.auto_increment_increment = 10; +SET @@session.auto_increment_offset = 5; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (NULL), (NULL), (NULL); +SET @@session.auto_increment_increment = 5; +SET @@session.auto_increment_offset = 3; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (33 + 1); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (38 + 2); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (43 + 3); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (48 + 4); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (53 + 5); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (63 + 6); +INSERT INTO t1 VALUES (NULL); +SET @@session.auto_increment_increment = 1; +SET @@session.auto_increment_offset = 1; +SELECT * FROM t1 ORDER BY c1; +c1 +1 +5 +15 +25 +33 +34 +38 +40 +43 +46 +48 +52 +53 +58 +63 +69 +73 +DROP TABLE t1; +# Test reported auto_increment value +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Memory' +PARTITION BY HASH (c1) +PARTITIONS 2; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 +INSERT INTO t1 VALUES (2); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +3 +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (19); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +22 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +22 +INSERT INTO t1 VALUES (10); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +10 +17 +19 +20 +21 +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +23 +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (15); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +10 +15 +17 +19 +20 +21 +22 +23 +24 +INSERT INTO t1 VALUES (NULL); +DELETE FROM t1; +INSERT INTO t1 VALUES (NULL); +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=27 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +26 +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES (NULL); +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=28 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +27 +DROP TABLE t1; +# Test with two threads +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'Memory' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +DROP TABLE t1; +# Test with two threads + start transaction NO PARTITIONING +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'Memory'; +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +DROP TABLE t1; +# Test with two threads + start transaction +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'Memory' +PARTITION BY HASH(c1) +PARTITIONS 2; +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (NULL), (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL), (NULL), (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +DROP TABLE t1; +# Test with another column after +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +c2 INT, +PRIMARY KEY (c1,c2)) +ENGINE = 'Memory' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 VALUES (NULL, 1), (NULL, 2), (NULL, 3); +INSERT INTO t1 VALUES (NULL, 3); +INSERT INTO t1 VALUES (2, 0), (NULL, 2); +INSERT INTO t1 VALUES (2, 2); +INSERT INTO t1 VALUES (2, 22); +INSERT INTO t1 VALUES (NULL, 2); +SELECT * FROM t1 ORDER BY c1,c2; +c1 c2 +1 0 +1 1 +2 0 +2 1 +2 2 +2 22 +3 2 +4 3 +5 3 +6 2 +7 2 +DROP TABLE t1; +# Test with another column before +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE = 'Memory' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (2, NULL), (3, 11), (3, NULL), (2, 0); +INSERT INTO t1 VALUES (2, NULL); +INSERT INTO t1 VALUES (2, 2); +INSERT INTO t1 VALUES (2, 22); +INSERT INTO t1 VALUES (2, NULL); +SELECT * FROM t1 ORDER BY c1,c2; +c1 c2 +1 1 +1 2 +2 3 +2 13 +2 14 +2 22 +2 23 +3 11 +3 12 +DROP TABLE t1; +# Test with auto_increment on secondary column in multi-column-index +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1,c2)) +ENGINE = 'Memory' +PARTITION BY HASH(c2) +PARTITIONS 2; +ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key +# Test AUTO_INCREMENT in CREATE +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'Memory' +AUTO_INCREMENT = 15 +PARTITION BY HASH(c1) +PARTITIONS 2; +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=15 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (4); +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=15 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (0); +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=16 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +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=17 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +4 +15 +16 +# Test sql_mode 'NO_AUTO_VALUE_ON_ZERO' +SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; +INSERT INTO t1 (c1) VALUES (300); +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=301 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (0); +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=301 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +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=302 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +0 +4 +15 +16 +300 +301 +SET @@session.sql_mode = ''; +DROP TABLE t1; +# Test SET INSERT_ID +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'Memory' +PARTITION BY HASH(c1) +PARTITIONS 2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +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=2 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1; +c1 +1 +SET INSERT_ID = 23; +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=2 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +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=24 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +1 +23 +DROP TABLE t1; +# Testing with FLUSH TABLE +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='Memory' +PARTITION BY HASH(c1) +PARTITIONS 2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +FLUSH TABLE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 VALUES (4); +FLUSH TABLE; +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=5 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 VALUES (NULL); +FLUSH TABLE; +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=6 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +4 +5 +DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_auto_increment_myisam.result b/mysql-test/suite/parts/r/partition_auto_increment_myisam.result new file mode 100644 index 00000000000..7ec76ee014c --- /dev/null +++ b/mysql-test/suite/parts/r/partition_auto_increment_myisam.result @@ -0,0 +1,794 @@ +DROP TABLE IF EXISTS t1; +# test without partitioning for reference +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='MyISAM'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +INSERT INTO t1 VALUES (0); +INSERT INTO t1 VALUES (5), (16); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (19), (NULL); +INSERT INTO t1 VALUES (NULL), (10), (NULL); +INSERT INTO t1 VALUES (NULL); +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; +UPDATE t1 SET c1 = NULL WHERE c1 = 4; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +10 +20 +21 +22 +23 +30 +50 +51 +52 +53 +DROP TABLE t1; +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='MyISAM'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +FLUSH TABLE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (4); +FLUSH TABLE; +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=5 DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (NULL); +FLUSH TABLE; +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=6 DEFAULT CHARSET=latin1 +DELETE FROM t1; +INSERT INTO t1 VALUES (NULL); +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=7 DEFAULT CHARSET=latin1 +SELECT * FROM t1 ORDER BY c1; +c1 +6 +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES (NULL); +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=2 DEFAULT CHARSET=latin1 +SELECT * FROM t1 ORDER BY c1; +c1 +1 +DROP TABLE t1; +# Simple test with NULL +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='MyISAM' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 VALUES (NULL); +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=2 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1; +c1 +1 +DROP TABLE t1; +# Test with sql_mode and first insert as 0 +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE='MyISAM' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (1, 1), (99, 99); +INSERT INTO t1 VALUES (1, NULL); +SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; +INSERT INTO t1 VALUES (1, 0); +SELECT * FROM t1 ORDER BY c1, c2; +c1 c2 +1 0 +1 1 +1 2 +DROP TABLE t1; +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE='MyISAM' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1), (1, NULL); +INSERT INTO t1 VALUES (2, NULL), (4, 7); +INSERT INTO t1 VALUES (1, NULL); +SELECT * FROM t1 ORDER BY c1, c2; +c1 c2 +1 0 +1 1 +1 2 +1 8 +2 3 +4 7 +SET @@session.sql_mode = ''; +DROP TABLE t1; +# Simple test with NULL, 0 and explicit values both incr. and desc. +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='MyISAM' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 VALUES (2), (4), (NULL); +INSERT INTO t1 VALUES (0); +INSERT INTO t1 VALUES (5), (16); +INSERT INTO t1 VALUES (17), (19), (NULL); +INSERT INTO t1 VALUES (NULL), (10), (NULL); +INSERT INTO t1 VALUES (NULL), (9); +INSERT INTO t1 VALUES (59), (55); +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; +UPDATE t1 SET c1 = NULL WHERE c1 = 4; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +9 +10 +20 +21 +22 +23 +55 +59 +60 +90 +91 +150 +151 +152 +153 +DROP TABLE t1; +# Test with auto_increment_increment and auto_increment_offset. +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='MyISAM' +PARTITION BY HASH(c1) +PARTITIONS 2; +SET @@session.auto_increment_increment = 10; +SET @@session.auto_increment_offset = 5; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (NULL), (NULL), (NULL); +SET @@session.auto_increment_increment = 5; +SET @@session.auto_increment_offset = 3; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (33 + 1); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (38 + 2); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (43 + 3); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (48 + 4); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (53 + 5); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (63 + 6); +INSERT INTO t1 VALUES (NULL); +SET @@session.auto_increment_increment = 1; +SET @@session.auto_increment_offset = 1; +SELECT * FROM t1 ORDER BY c1; +c1 +1 +5 +15 +25 +33 +34 +38 +40 +43 +46 +48 +52 +53 +58 +63 +69 +73 +DROP TABLE t1; +# Test reported auto_increment value +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='MyISAM' +PARTITION BY HASH (c1) +PARTITIONS 2; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 +INSERT INTO t1 VALUES (2); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +3 +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (19); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +22 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +22 +INSERT INTO t1 VALUES (10); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +10 +17 +19 +20 +21 +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +23 +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (15); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +10 +15 +17 +19 +20 +21 +22 +23 +24 +INSERT INTO t1 VALUES (NULL); +DELETE FROM t1; +INSERT INTO t1 VALUES (NULL); +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=27 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +26 +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES (NULL); +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=28 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +27 +DROP TABLE t1; +# Test with two threads +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'MyISAM' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +DROP TABLE t1; +# Test with two threads + start transaction NO PARTITIONING +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'MyISAM'; +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +DROP TABLE t1; +# Test with two threads + start transaction +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'MyISAM' +PARTITION BY HASH(c1) +PARTITIONS 2; +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (NULL), (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL), (NULL), (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +DROP TABLE t1; +# Test with another column after +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +c2 INT, +PRIMARY KEY (c1,c2)) +ENGINE = 'MyISAM' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 VALUES (NULL, 1), (NULL, 2), (NULL, 3); +INSERT INTO t1 VALUES (NULL, 3); +INSERT INTO t1 VALUES (2, 0), (NULL, 2); +INSERT INTO t1 VALUES (2, 2); +INSERT INTO t1 VALUES (2, 22); +INSERT INTO t1 VALUES (NULL, 2); +SELECT * FROM t1 ORDER BY c1,c2; +c1 c2 +1 0 +1 1 +2 0 +2 1 +2 2 +2 22 +3 2 +4 3 +5 3 +6 2 +7 2 +DROP TABLE t1; +# Test with another column before +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE = 'MyISAM' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (2, NULL), (3, 11), (3, NULL), (2, 0); +INSERT INTO t1 VALUES (2, NULL); +INSERT INTO t1 VALUES (2, 2); +INSERT INTO t1 VALUES (2, 22); +INSERT INTO t1 VALUES (2, NULL); +SELECT * FROM t1 ORDER BY c1,c2; +c1 c2 +1 1 +1 2 +2 3 +2 13 +2 14 +2 22 +2 23 +3 11 +3 12 +DROP TABLE t1; +# Test with auto_increment on secondary column in multi-column-index +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1,c2)) +ENGINE = 'MyISAM' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (2, NULL); +INSERT INTO t1 VALUES (3, NULL); +INSERT INTO t1 VALUES (3, NULL), (2, 0), (2, NULL); +INSERT INTO t1 VALUES (2, 2); +INSERT INTO t1 VALUES (2, 22), (2, NULL); +SELECT * FROM t1 ORDER BY c1,c2; +c1 c2 +1 1 +1 2 +2 1 +2 2 +2 3 +2 22 +2 23 +3 1 +3 2 +DROP TABLE t1; +# Test AUTO_INCREMENT in CREATE +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'MyISAM' +AUTO_INCREMENT = 15 +PARTITION BY HASH(c1) +PARTITIONS 2; +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=15 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (4); +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=15 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (0); +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=16 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +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=17 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +4 +15 +16 +# Test sql_mode 'NO_AUTO_VALUE_ON_ZERO' +SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; +INSERT INTO t1 (c1) VALUES (300); +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=301 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (0); +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=301 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +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=302 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +0 +4 +15 +16 +300 +301 +SET @@session.sql_mode = ''; +DROP TABLE t1; +# Test SET INSERT_ID +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'MyISAM' +PARTITION BY HASH(c1) +PARTITIONS 2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +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=2 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1; +c1 +1 +SET INSERT_ID = 23; +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=2 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 (c1) VALUES (NULL); +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=24 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +1 +23 +DROP TABLE t1; +# Testing with FLUSH TABLE +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='MyISAM' +PARTITION BY HASH(c1) +PARTITIONS 2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +FLUSH TABLE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 VALUES (4); +FLUSH TABLE; +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=5 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +INSERT INTO t1 VALUES (NULL); +FLUSH TABLE; +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=6 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ +SELECT * FROM t1 ORDER BY c1; +c1 +4 +5 +DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_auto_increment_ndb.result b/mysql-test/suite/parts/r/partition_auto_increment_ndb.result new file mode 100644 index 00000000000..37b46ef63ba --- /dev/null +++ b/mysql-test/suite/parts/r/partition_auto_increment_ndb.result @@ -0,0 +1,769 @@ +SET new=on; +DROP TABLE IF EXISTS t1; +# test without partitioning for reference +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='NDB'; +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 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +INSERT INTO t1 VALUES (0); +INSERT INTO t1 VALUES (5), (16); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (19), (NULL); +INSERT INTO t1 VALUES (NULL), (10), (NULL); +INSERT INTO t1 VALUES (NULL); +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; +UPDATE t1 SET c1 = NULL WHERE c1 = 4; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +10 +20 +21 +22 +23 +30 +50 +51 +52 +53 +DROP TABLE t1; +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='NDB'; +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 +FLUSH TABLE; +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 +INSERT INTO t1 VALUES (4); +FLUSH TABLE; +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 +INSERT INTO t1 VALUES (NULL); +FLUSH TABLE; +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 +DELETE FROM t1; +INSERT INTO t1 VALUES (NULL); +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 +SELECT * FROM t1 ORDER BY c1; +c1 +6 +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES (NULL); +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 +SELECT * FROM t1 ORDER BY c1; +c1 +1 +DROP TABLE t1; +# Simple test with NULL +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='NDB' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 VALUES (NULL); +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 */ +SELECT * FROM t1; +c1 +1 +DROP TABLE t1; +# Test with sql_mode and first insert as 0 +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE='NDB' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (1, 1), (99, 99); +INSERT INTO t1 VALUES (1, NULL); +SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; +INSERT INTO t1 VALUES (1, 0); +SELECT * FROM t1 ORDER BY c1, c2; +c1 c2 +1 0 +1 1 +1 100 +DROP TABLE t1; +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE='NDB' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1), (1, NULL); +INSERT INTO t1 VALUES (2, NULL), (4, 7); +INSERT INTO t1 VALUES (1, NULL); +SELECT * FROM t1 ORDER BY c1, c2; +c1 c2 +1 0 +1 1 +1 2 +1 8 +2 3 +4 7 +SET @@session.sql_mode = ''; +DROP TABLE t1; +# Simple test with NULL, 0 and explicit values both incr. and desc. +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='NDB' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 VALUES (2), (4), (NULL); +INSERT INTO t1 VALUES (0); +INSERT INTO t1 VALUES (5), (16); +INSERT INTO t1 VALUES (17), (19), (NULL); +INSERT INTO t1 VALUES (NULL), (10), (NULL); +INSERT INTO t1 VALUES (NULL), (9); +INSERT INTO t1 VALUES (59), (55); +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; +UPDATE t1 SET c1 = NULL WHERE c1 = 4; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +9 +10 +20 +21 +22 +23 +55 +59 +60 +90 +91 +150 +151 +152 +153 +DROP TABLE t1; +# Test with auto_increment_increment and auto_increment_offset. +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='NDB' +PARTITION BY HASH(c1) +PARTITIONS 2; +SET @@session.auto_increment_increment = 10; +SET @@session.auto_increment_offset = 5; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (NULL), (NULL), (NULL); +SET @@session.auto_increment_increment = 5; +SET @@session.auto_increment_offset = 3; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (33 + 1); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (38 + 2); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (43 + 3); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (48 + 4); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (53 + 5); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (63 + 6); +INSERT INTO t1 VALUES (NULL); +SET @@session.auto_increment_increment = 1; +SET @@session.auto_increment_offset = 1; +SELECT * FROM t1 ORDER BY c1; +c1 +1 +5 +15 +25 +33 +34 +38 +40 +43 +46 +48 +52 +53 +58 +63 +69 +73 +DROP TABLE t1; +# Test reported auto_increment value +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='NDB' +PARTITION BY HASH (c1) +PARTITIONS 2; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +1 +INSERT INTO t1 VALUES (2); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +3 +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +6 +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (19); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +22 +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +22 +INSERT INTO t1 VALUES (10); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +10 +17 +19 +20 +21 +INSERT INTO t1 VALUES (NULL); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' +AND TABLE_NAME='t1'; +AUTO_INCREMENT +23 +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (15); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +6 +10 +15 +17 +19 +20 +21 +22 +23 +24 +INSERT INTO t1 VALUES (NULL); +DELETE FROM t1; +INSERT INTO t1 VALUES (NULL); +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 */ +SELECT * FROM t1 ORDER BY c1; +c1 +26 +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES (NULL); +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 */ +SELECT * FROM t1 ORDER BY c1; +c1 +1 +DROP TABLE t1; +# Test with two threads +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'NDB' +PARTITION BY HASH(c1) +PARTITIONS 2; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +DROP TABLE t1; +# Test with two threads + start transaction NO PARTITIONING +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'NDB'; +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (NULL); +INSERT INTO t1 (c1) VALUES (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +5 +10 +22 +23 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +5 +10 +22 +23 +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +DROP TABLE t1; +# Test with two threads + start transaction +# con default +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'NDB' +PARTITION BY HASH(c1) +PARTITIONS 2; +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (2); +INSERT INTO t1 (c1) VALUES (4); +# con1 +START TRANSACTION; +INSERT INTO t1 (c1) VALUES (NULL), (10); +# con default +INSERT INTO t1 (c1) VALUES (NULL), (NULL), (19); +INSERT INTO t1 (c1) VALUES (21); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +# con default +INSERT INTO t1 (c1) VALUES (16); +# con1 +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +5 +10 +22 +23 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +5 +10 +22 +23 +# con default +INSERT INTO t1 (c1) VALUES (NULL); +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +COMMIT; +SELECT * FROM t1 ORDER BY c1; +c1 +2 +4 +5 +10 +11 +12 +16 +19 +21 +22 +23 +24 +DROP TABLE t1; +# Test with another column after +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +c2 INT, +PRIMARY KEY (c1,c2)) +ENGINE = 'NDB' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 VALUES (NULL, 1), (NULL, 2), (NULL, 3); +INSERT INTO t1 VALUES (NULL, 3); +INSERT INTO t1 VALUES (2, 0), (NULL, 2); +INSERT INTO t1 VALUES (2, 2); +INSERT INTO t1 VALUES (2, 22); +INSERT INTO t1 VALUES (NULL, 2); +SELECT * FROM t1 ORDER BY c1,c2; +c1 c2 +1 0 +1 1 +2 0 +2 1 +2 2 +2 22 +3 2 +4 3 +5 3 +6 2 +7 2 +DROP TABLE t1; +# Test with another column before +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c2)) +ENGINE = 'NDB' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (2, NULL), (3, 11), (3, NULL), (2, 0); +INSERT INTO t1 VALUES (2, NULL); +INSERT INTO t1 VALUES (2, 2); +INSERT INTO t1 VALUES (2, 22); +INSERT INTO t1 VALUES (2, NULL); +SELECT * FROM t1 ORDER BY c1,c2; +c1 c2 +1 1 +1 2 +2 3 +2 13 +2 14 +2 22 +2 23 +3 11 +3 12 +DROP TABLE t1; +# Test with auto_increment on secondary column in multi-column-index +CREATE TABLE t1 ( +c1 INT, +c2 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1,c2)) +ENGINE = 'NDB' +PARTITION BY HASH(c2) +PARTITIONS 2; +INSERT INTO t1 VALUES (1, 0); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (2, NULL); +INSERT INTO t1 VALUES (3, NULL); +INSERT INTO t1 VALUES (3, NULL), (2, 0), (2, NULL); +INSERT INTO t1 VALUES (2, 2); +# ERROR (only OK if Blackhole/NDB) should give ER_DUP_KEY or ER_DUP_ENTRY +INSERT INTO t1 VALUES (2, 22), (2, NULL); +SELECT * FROM t1 ORDER BY c1,c2; +c1 c2 +1 1 +1 2 +2 2 +2 3 +2 6 +2 7 +2 22 +2 23 +3 4 +3 5 +DROP TABLE t1; +# Test AUTO_INCREMENT in CREATE +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'NDB' +AUTO_INCREMENT = 15 +PARTITION BY HASH(c1) +PARTITIONS 2; +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 */ +INSERT INTO t1 (c1) VALUES (4); +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 */ +INSERT INTO t1 (c1) VALUES (0); +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 */ +INSERT INTO t1 (c1) VALUES (NULL); +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 */ +SELECT * FROM t1 ORDER BY c1; +c1 +4 +15 +16 +# Test sql_mode 'NO_AUTO_VALUE_ON_ZERO' +SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; +INSERT INTO t1 (c1) VALUES (300); +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 */ +INSERT INTO t1 (c1) VALUES (0); +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 */ +INSERT INTO t1 (c1) VALUES (NULL); +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 */ +SELECT * FROM t1 ORDER BY c1; +c1 +0 +4 +15 +16 +300 +301 +SET @@session.sql_mode = ''; +DROP TABLE t1; +# Test SET INSERT_ID +CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1)) +ENGINE = 'NDB' +PARTITION BY HASH(c1) +PARTITIONS 2; +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 */ +INSERT INTO t1 (c1) VALUES (NULL); +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 */ +SELECT * FROM t1; +c1 +1 +SET INSERT_ID = 23; +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 */ +INSERT INTO t1 (c1) VALUES (NULL); +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 */ +SELECT * FROM t1 ORDER BY c1; +c1 +1 +23 +DROP TABLE t1; +# Testing with FLUSH TABLE +CREATE TABLE t1 ( +c1 INT NOT NULL AUTO_INCREMENT, +PRIMARY KEY (c1)) +ENGINE='NDB' +PARTITION BY HASH(c1) +PARTITIONS 2; +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 */ +FLUSH TABLE; +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 */ +INSERT INTO t1 VALUES (4); +FLUSH TABLE; +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 */ +INSERT INTO t1 VALUES (NULL); +FLUSH TABLE; +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 */ +SELECT * FROM t1 ORDER BY c1; +c1 +4 +5 +DROP TABLE t1; diff --git a/mysql-test/suite/parts/t/partition_auto_increment_archive.test b/mysql-test/suite/parts/t/partition_auto_increment_archive.test new file mode 100644 index 00000000000..fb09557204f --- /dev/null +++ b/mysql-test/suite/parts/t/partition_auto_increment_archive.test @@ -0,0 +1,40 @@ +################################################################################ +# t/partition_auto_increment_archive.test # +# # +# Purpose: # +# Tests around auto increment column # +# Archive branch # +# # +#------------------------------------------------------------------------------# +# Original Author: MattiasJ # +# Original Date: 2008-09-02 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +# The server must support partitioning. +--source include/have_partition.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements +--source include/have_archive.inc +# Archve does not support delete +let $skip_delete= 1; +let $skip_truncate= 1; +let $skip_update= 1; +let $only_ai_pk= 1; + +##### Storage engine to be tested +let $engine= 'Archive'; + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/parts/inc/partition_auto_increment.inc + diff --git a/mysql-test/suite/parts/t/partition_auto_increment_blackhole.test b/mysql-test/suite/parts/t/partition_auto_increment_blackhole.test new file mode 100644 index 00000000000..64cd96c6173 --- /dev/null +++ b/mysql-test/suite/parts/t/partition_auto_increment_blackhole.test @@ -0,0 +1,35 @@ +################################################################################ +# t/partition_auto_increment_blackhole.test # +# # +# Purpose: # +# Tests around auto increment column # +# Blackhole branch # +# # +#------------------------------------------------------------------------------# +# Original Author: MattiasJ # +# Original Date: 2008-09-02 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +# The server must support partitioning. +--source include/have_partition.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements +--source include/have_blackhole.inc + +##### Storage engine to be tested +let $engine= 'Blackhole'; + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/parts/inc/partition_auto_increment.inc + diff --git a/mysql-test/suite/parts/t/partition_auto_increment_innodb.test b/mysql-test/suite/parts/t/partition_auto_increment_innodb.test new file mode 100644 index 00000000000..4e968d8758f --- /dev/null +++ b/mysql-test/suite/parts/t/partition_auto_increment_innodb.test @@ -0,0 +1,35 @@ +################################################################################ +# t/partition_auto_increment_innodb.test # +# # +# Purpose: # +# Tests around auto increment column # +# InnoDB branch # +# # +#------------------------------------------------------------------------------# +# Original Author: MattiasJ # +# Original Date: 2008-02-12 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +# The server must support partitioning. +--source include/have_partition.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +let $engine= 'InnoDB'; +--source include/have_innodb.inc + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/parts/inc/partition_auto_increment.inc + diff --git a/mysql-test/suite/parts/t/partition_auto_increment_memory.test b/mysql-test/suite/parts/t/partition_auto_increment_memory.test new file mode 100644 index 00000000000..585a75cc9b5 --- /dev/null +++ b/mysql-test/suite/parts/t/partition_auto_increment_memory.test @@ -0,0 +1,34 @@ +################################################################################ +# t/partition_auto_increment_memory.test # +# # +# Purpose: # +# Tests around auto increment column # +# Memory branch # +# # +#------------------------------------------------------------------------------# +# Original Author: MattiasJ # +# Original Date: 2008-02-12 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +# The server must support partitioning. +--source include/have_partition.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +let $engine= 'Memory'; + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/parts/inc/partition_auto_increment.inc + diff --git a/mysql-test/suite/parts/t/partition_auto_increment_myisam.test b/mysql-test/suite/parts/t/partition_auto_increment_myisam.test new file mode 100644 index 00000000000..2e3f49d5cb6 --- /dev/null +++ b/mysql-test/suite/parts/t/partition_auto_increment_myisam.test @@ -0,0 +1,34 @@ +################################################################################ +# t/partition_auto_increment_myisam.test # +# # +# Purpose: # +# Tests around auto increment column # +# MyISAM branch # +# # +#------------------------------------------------------------------------------# +# Original Author: MattiasJ # +# Original Date: 2008-02-12 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +# The server must support partitioning. +--source include/have_partition.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements + +##### Storage engine to be tested +let $engine= 'MyISAM'; + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/parts/inc/partition_auto_increment.inc + diff --git a/mysql-test/suite/parts/t/partition_auto_increment_ndb.test b/mysql-test/suite/parts/t/partition_auto_increment_ndb.test new file mode 100644 index 00000000000..7aa3839762d --- /dev/null +++ b/mysql-test/suite/parts/t/partition_auto_increment_ndb.test @@ -0,0 +1,41 @@ +################################################################################ +# t/partition_auto_increment_ndb.test # +# # +# Purpose: # +# Tests around auto increment column # +# NDB branch # +# # +# Note: NDB behavior for auto_increment on secondary column in # +# multi-column-index is NOT like MyISAM, instead it uses the same # +# behavior as if it was the primary column. # +#------------------------------------------------------------------------------# +# Original Author: MattiasJ # +# Original Date: 2008-09-02 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +# +# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE ! +# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN +# THE SOURCED FILES ONLY. +# + +# The server must support partitioning. +--source include/have_partition.inc + +#------------------------------------------------------------------------------# +# Engine specific settings and requirements +--source include/have_ndb.inc + +##### Storage engine to be tested +let $engine= 'NDB'; +connection default; +#enable hash partitioning +SET new=on; + +#------------------------------------------------------------------------------# +# Execute the tests to be applied to all storage engines +--source suite/parts/inc/partition_auto_increment.inc + diff --git a/mysql-test/suite/rpl/r/rpl_blackhole.result b/mysql-test/suite/rpl/r/rpl_blackhole.result new file mode 100644 index 00000000000..27094e761b0 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_blackhole.result @@ -0,0 +1,100 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +CREATE TABLE t1 (a INT, b INT, c INT); +CREATE TABLE t2 (a INT, b INT, c INT); +ALTER TABLE t1 ENGINE=BLACKHOLE; +INSERT INTO t2 VALUES (1,9,1), (2,9,2), (3,9,3), (4,9,4); +[on master] +INSERT INTO t1 VALUES (1,1,1),(2,1,2),(3,1,3),(4,1,4); +[on slave] +# Expect 0 +SELECT COUNT(*) FROM t1; +COUNT(*) +0 +>>> Something was written to binary log <<< +[on master] +UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 1; +[on slave] +# Expect 0 +SELECT COUNT(*) FROM t1; +COUNT(*) +0 +>>> Something was written to binary log <<< +[on master] +DELETE FROM t1 WHERE a % 2 = 0 AND b = 1; +[on slave] +# Expect 0 +SELECT COUNT(*) FROM t1; +COUNT(*) +0 +>>> Something was written to binary log <<< +[on master] +INSERT INTO t1 SELECT * FROM t2; +[on slave] +# Expect 0 +SELECT COUNT(*) FROM t1; +COUNT(*) +0 +>>> Something was written to binary log <<< +[on master] +INSERT INTO t2 SELECT * FROM t1; +[on slave] +# Expect 0 +SELECT COUNT(*) FROM t1; +COUNT(*) +0 +>>> Something was written to binary log <<< +ALTER TABLE t1 ADD PRIMARY KEY pk_t1 (a,b); +[on master] +INSERT INTO t1 VALUES (1,2,1),(2,2,2),(3,2,3),(4,2,4); +[on slave] +# Expect 0 +SELECT COUNT(*) FROM t1; +COUNT(*) +0 +>>> Something was written to binary log <<< +[on master] +UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 2; +[on slave] +# Expect 0 +SELECT COUNT(*) FROM t1; +COUNT(*) +0 +>>> Something was written to binary log <<< +[on master] +DELETE FROM t1 WHERE a % 2 = 0 AND b = 2; +[on slave] +# Expect 0 +SELECT COUNT(*) FROM t1; +COUNT(*) +0 +>>> Something was written to binary log <<< +ALTER TABLE t1 DROP PRIMARY KEY, ADD KEY key_t1 (a); +[on master] +INSERT INTO t1 VALUES (1,3,1),(2,3,2),(3,3,3),(4,3,4); +[on slave] +# Expect 0 +SELECT COUNT(*) FROM t1; +COUNT(*) +0 +>>> Something was written to binary log <<< +[on master] +UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 3; +[on slave] +# Expect 0 +SELECT COUNT(*) FROM t1; +COUNT(*) +0 +>>> Something was written to binary log <<< +[on master] +DELETE FROM t1 WHERE a % 2 = 0 AND b = 3; +[on slave] +# Expect 0 +SELECT COUNT(*) FROM t1; +COUNT(*) +0 +>>> Something was written to binary log <<< diff --git a/mysql-test/suite/rpl/r/rpl_sp.result b/mysql-test/suite/rpl/r/rpl_sp.result index 1255f9427b0..3ca4f86cf64 100644 --- a/mysql-test/suite/rpl/r/rpl_sp.result +++ b/mysql-test/suite/rpl/r/rpl_sp.result @@ -193,7 +193,7 @@ end| ERROR HY000: You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable) set global log_bin_trust_routine_creators=1; Warnings: -Warning 1287 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead +Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead set global log_bin_trust_function_creators=0; set global log_bin_trust_function_creators=1; set global log_bin_trust_function_creators=1; @@ -526,7 +526,7 @@ master-bin.000001 # Query 1 # use `test`; DROP TABLE IF EXISTS t1 master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1(col VARCHAR(10)) master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(arg VARCHAR(10)) INSERT INTO t1 VALUES(arg) -master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES( NAME_CONST('arg',_latin1'test')) +master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES( NAME_CONST('arg',_latin1'test' COLLATE 'latin1_swedish_ci')) master-bin.000001 # Query 1 # use `test`; DROP PROCEDURE p1 master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() SET @a = 1 @@ -869,7 +869,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(arg VARCHAR(10)) INSERT INTO t1 VALUES(arg) /*!*/; SET TIMESTAMP=t/*!*/; -INSERT INTO t1 VALUES( NAME_CONST('arg',_latin1'test')) +INSERT INTO t1 VALUES( NAME_CONST('arg',_latin1'test' COLLATE 'latin1_swedish_ci')) /*!*/; SET TIMESTAMP=t/*!*/; DROP PROCEDURE p1 diff --git a/mysql-test/suite/rpl/t/rpl_blackhole.test b/mysql-test/suite/rpl/t/rpl_blackhole.test new file mode 100644 index 00000000000..e8dfbd51552 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_blackhole.test @@ -0,0 +1,80 @@ +# PURPOSE. Test that blackhole works with replication in all three +# modes: STATEMENT, MIXED, and ROW. +# +# METHOD. We start by creating a table on the master and then change +# the engine to use blackhole on the slave. +# +# After insert/update/delete of one or more rows, the test the +# proceeds to check that replication is running after replicating an +# change, that the blackhole engine does not contain anything (which +# is just a check that the correct engine is used), and that something +# is written to the binary log. +# +# Whe check INSERT, UPDATE, and DELETE statement for tables with no +# key (forcing a range search on the slave), primary keys (using a +# primary key lookup), and index/key with multiple matches (forcing an +# index search). + +source include/master-slave.inc; +source include/have_blackhole.inc; + +# We start with no primary key +CREATE TABLE t1 (a INT, b INT, c INT); +CREATE TABLE t2 (a INT, b INT, c INT); + +sync_slave_with_master; +ALTER TABLE t1 ENGINE=BLACKHOLE; + +connection master; +INSERT INTO t2 VALUES (1,9,1), (2,9,2), (3,9,3), (4,9,4); +sync_slave_with_master; + +# Test insert, no primary key +let $statement = INSERT INTO t1 VALUES (1,1,1),(2,1,2),(3,1,3),(4,1,4); +source extra/rpl_tests/rpl_blackhole.test; + +# Test update, no primary key +let $statement = UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 1; +source extra/rpl_tests/rpl_blackhole.test; + +# Test delete, no primary key +let $statement = DELETE FROM t1 WHERE a % 2 = 0 AND b = 1; +source extra/rpl_tests/rpl_blackhole.test; + +# Test INSERT-SELECT into Blackhole, no primary key +let $statement = INSERT INTO t1 SELECT * FROM t2; +source extra/rpl_tests/rpl_blackhole.test; + +# Test INSERT-SELECT from Blackhole, no primary key +let $statement = INSERT INTO t2 SELECT * FROM t1; +source extra/rpl_tests/rpl_blackhole.test; + +connection master; +ALTER TABLE t1 ADD PRIMARY KEY pk_t1 (a,b); + +# Test insert, primary key +let $statement = INSERT INTO t1 VALUES (1,2,1),(2,2,2),(3,2,3),(4,2,4); +source extra/rpl_tests/rpl_blackhole.test; + +# Test update, primary key +let $statement = UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 2; +source extra/rpl_tests/rpl_blackhole.test; + +# Test delete, primary key +let $statement = DELETE FROM t1 WHERE a % 2 = 0 AND b = 2; +source extra/rpl_tests/rpl_blackhole.test; + +connection master; +ALTER TABLE t1 DROP PRIMARY KEY, ADD KEY key_t1 (a); + +# Test insert, key +let $statement = INSERT INTO t1 VALUES (1,3,1),(2,3,2),(3,3,3),(4,3,4); +source extra/rpl_tests/rpl_blackhole.test; + +# Test update, key +let $statement = UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 3; +source extra/rpl_tests/rpl_blackhole.test; + +# Test delete, key +let $statement = DELETE FROM t1 WHERE a % 2 = 0 AND b = 3; +source extra/rpl_tests/rpl_blackhole.test; diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index b6143bc0c78..4eedd433d34 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -933,5 +933,45 @@ SELECT AVG(a), CAST(AVG(a) AS DECIMAL) FROM t1; DROP TABLE t1; +# +# Bug #37348: Crash in or immediately after JOIN::make_sum_func_list +# + +CREATE TABLE derived1 (a bigint(21)); +INSERT INTO derived1 VALUES (2); + + +CREATE TABLE D ( + pk int(11) NOT NULL AUTO_INCREMENT, + int_nokey int(11) DEFAULT NULL, + int_key int(11) DEFAULT NULL, + filler blob, + PRIMARY KEY (pk), + KEY int_key (int_key) +); + +INSERT INTO D VALUES + (39,40,4,repeat(' X', 42)), + (43,56,4,repeat(' X', 42)), + (47,12,4,repeat(' X', 42)), + (71,28,4,repeat(' X', 42)), + (76,54,4,repeat(' X', 42)), + (83,45,4,repeat(' X', 42)), + (105,53,12,NULL); + +SELECT + (SELECT COUNT( int_nokey ) + FROM derived1 AS X + WHERE + X.int_nokey < 61 + GROUP BY pk + LIMIT 1) +FROM D AS X +WHERE X.int_key < 13 +GROUP BY int_nokey LIMIT 1; + +DROP TABLE derived1; +DROP TABLE D; + ### --echo End of 5.0 tests diff --git a/mysql-test/t/innodb-semi-consistent.test b/mysql-test/t/innodb-semi-consistent.test index c33126b93ff..a3496625e95 100644 --- a/mysql-test/t/innodb-semi-consistent.test +++ b/mysql-test/t/innodb-semi-consistent.test @@ -10,6 +10,7 @@ drop table if exists t1; connect (a,localhost,root,,); connect (b,localhost,root,,); connection a; +set binlog_format=mixed; set session transaction isolation level read committed; create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; insert into t1 values (1),(2),(3),(4),(5),(6),(7); @@ -17,6 +18,7 @@ set autocommit=0; # this should lock the entire table select * from t1 where a=3 lock in share mode; connection b; +set binlog_format=mixed; set session transaction isolation level read committed; set autocommit=0; -- error ER_LOCK_WAIT_TIMEOUT diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index 1073f5535df..339be87419a 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -701,6 +701,7 @@ insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha'); select id, code, name from t1 order by id; COMMIT; +SET binlog_format='MIXED'; BEGIN; SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt'); @@ -2000,10 +2001,12 @@ connection a; create table t1(a int not null, b int, primary key(a)) engine=innodb; insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3); commit; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; update t1 set b = 5 where b = 1; connection b; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; # @@ -2071,6 +2074,7 @@ commit; set autocommit = 0; select * from t2 for update; connection b; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; insert into t1 select * from t2; @@ -2127,46 +2131,55 @@ commit; set autocommit = 0; select * from t2 for update; connection b; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; --send insert into t1 select * from t2; connection c; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; --send update t3 set b = (select b from t2 where a = d); connection d; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; --send create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2; connection e; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; --send insert into t5 (select * from t2 lock in share mode); connection f; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; --send update t6 set e = (select b from t2 where a = d lock in share mode); connection g; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; --send create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode; connection h; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; --send insert into t8 (select * from t2 for update); connection i; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; --send update t9 set e = (select b from t2 where a = d for update); connection j; +SET binlog_format='MIXED'; set autocommit = 0; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; --send @@ -2380,6 +2393,7 @@ DROP TABLE t1; CONNECT (c1,localhost,root,,); CONNECT (c2,localhost,root,,); CONNECTION c1; +SET binlog_format='MIXED'; SET TX_ISOLATION='read-committed'; SET AUTOCOMMIT=0; DROP TABLE IF EXISTS t1, t2; @@ -2387,6 +2401,7 @@ CREATE TABLE t1 ( a int ) ENGINE=InnoDB; CREATE TABLE t2 LIKE t1; SELECT * FROM t2; CONNECTION c2; +SET binlog_format='MIXED'; SET TX_ISOLATION='read-committed'; SET AUTOCOMMIT=0; INSERT INTO t1 VALUES (1); @@ -2398,10 +2413,12 @@ DISCONNECT c2; CONNECT (c1,localhost,root,,); CONNECT (c2,localhost,root,,); CONNECTION c1; +SET binlog_format='MIXED'; SET TX_ISOLATION='read-committed'; SET AUTOCOMMIT=0; SELECT * FROM t2; CONNECTION c2; +SET binlog_format='MIXED'; SET TX_ISOLATION='read-committed'; SET AUTOCOMMIT=0; INSERT INTO t1 VALUES (2); diff --git a/mysql-test/t/log_basic.test b/mysql-test/t/log_basic.test index 16d7a4bfe7f..b9a64f8981b 100644 --- a/mysql-test/t/log_basic.test +++ b/mysql-test/t/log_basic.test @@ -38,9 +38,9 @@ SELECT @@global.log AS INIT_VALUE; SELECT @@log AS INIT_VALUE; -SET @@global.log = ON; +SET @@global.general_log = ON; -SET global log = 0; +SET global general_log = 0; --echo 'Bug# 34832: log is a system but it is not accessible using SET @@global.log;' --echo 'SET GLOBAL log; and SELECT @@global.log. SHOW VARIABLES shows the value of log.' diff --git a/mysql-test/t/log_state.test b/mysql-test/t/log_state.test index 2fd2cabc97c..977b74aa1e3 100644 --- a/mysql-test/t/log_state.test +++ b/mysql-test/t/log_state.test @@ -259,6 +259,32 @@ SET GLOBAL slow_query_log_file = @slow_query_log_file_saved; ########################################################################### + + +## WL#4403 - deprecate @log and @slow_log_queries variables + +## these are all deprecated -- show for command-line as well! +--echo deprecated: +SET GLOBAL log = 0; +SET GLOBAL log_slow_queries = 0; +SET GLOBAL log = DEFAULT; +SET GLOBAL log_slow_queries = DEFAULT; + +## these are NOT deprecated +--echo not deprecated: +SELECT @@global.general_log_file INTO @my_glf; +SELECT @@global.slow_query_log_file INTO @my_sqlf; +SET GLOBAL general_log = 0; +SET GLOBAL slow_query_log = 0; +SET GLOBAL general_log_file = 'WL4403_G.log'; +SET GLOBAL slow_query_log_file = 'WL4403_SQ.log'; +SET GLOBAL general_log_file = @my_glf; +SET GLOBAL slow_query_log_file = @my_sqlf; +SET GLOBAL general_log = DEFAULT; +SET GLOBAL slow_query_log = DEFAULT; + + + --echo End of 5.1 tests --enable_ps_protocol diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 3323e4f9bcd..83e0cde8991 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1816,4 +1816,53 @@ SET SQL_MODE= @orig_sql_mode; +# +# Bug #38005 Partitions: error with insert select +# + +create table t1 (s1 int) partition by hash(s1) partitions 2; +create index i on t1 (s1); +insert into t1 values (1); +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1 order by s1 desc; +select * from t1; +drop table t1; + +create table t1 (s1 int) partition by range(s1) + (partition pa1 values less than (10), + partition pa2 values less than MAXVALUE); +create index i on t1 (s1); +insert into t1 values (1); +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1 order by s1 desc; +select * from t1; +drop table t1; + +create table t1 (s1 int) partition by range(s1) + (partition pa1 values less than (10), + partition pa2 values less than MAXVALUE); +create index i on t1 (s1); +insert into t1 values (20); +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1 order by s1 desc; +select * from t1; +drop table t1; + +create table t1 (s1 int) partition by range(s1) + (partition pa1 values less than (10), + partition pa2 values less than MAXVALUE); +create index i on t1 (s1); +insert into t1 values (1), (2), (3), (4), (5), (6), (7), (8); +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1 order by s1 desc; +insert into t1 select s1 from t1 where s1=3; +select count(*) from t1; +drop table t1; + --echo End of 5.1 tests diff --git a/mysql-test/t/trigger-trans.test b/mysql-test/t/trigger-trans.test index 5db5b982773..ae223b2666e 100644 --- a/mysql-test/t/trigger-trans.test +++ b/mysql-test/t/trigger-trans.test @@ -162,3 +162,16 @@ DROP TABLE t2, t1; --echo End of 5.0 tests + +--echo BUG#31612 +--echo Trigger fired multiple times leads to gaps in auto_increment sequence +create table t1 (a int, val char(1)) engine=InnoDB; +create table t2 (b int auto_increment primary key, + val char(1)) engine=InnoDB; +create trigger t1_after_insert after + insert on t1 for each row insert into t2 set val=NEW.val; +insert into t1 values ( 123, 'a'), ( 123, 'b'), ( 123, 'c'), + (123, 'd'), (123, 'e'), (123, 'f'), (123, 'g'); +insert into t1 values ( 654, 'a'), ( 654, 'b'), ( 654, 'c'), + (654, 'd'), (654, 'e'), (654, 'f'), (654, 'g'); +select * from t2 order by b; diff --git a/mysql-test/t/tx_isolation_func.test b/mysql-test/t/tx_isolation_func.test index 3a4167dc368..1fd2e323db8 100644 --- a/mysql-test/t/tx_isolation_func.test +++ b/mysql-test/t/tx_isolation_func.test @@ -75,10 +75,12 @@ INSERT INTO t1 VALUES(24, 24); --echo ** Connection con0 ** connection con0; SET SESSION tx_isolation = 'READ-UNCOMMITTED'; +set binlog_format=mixed; --echo ** Connection con1 ** connection con1; SET SESSION tx_isolation = 'READ-UNCOMMITTED'; +set binlog_format=mixed; # # Testing WHERE on keys using IN clause |