diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-06-27 08:14:45 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-06-27 08:14:45 +0300 |
commit | 176000a54ceb8dabe8f8b985aff565dfae6fb0df (patch) | |
tree | 533835ffe254189755e7bbb55e3522f06ed4a479 | |
parent | 2a3fe45dd2df047cc0d66e2bcdbadd5005c85a1a (diff) | |
parent | 43c77bb937cbd2fff10b980047b9926a5711a8b3 (diff) | |
download | mariadb-git-176000a54ceb8dabe8f8b985aff565dfae6fb0df.tar.gz |
Merge bb-10.2-ext into 10.3
82 files changed, 3030 insertions, 266 deletions
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index f763fd3a026..220fd5a8c74 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -554,7 +554,7 @@ EXPLAIN SELECT * FROM (SELECT * FROM t1) AS table1, id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY <derived3> ref key0 key0 5 const 0 -3 DERIVED t2 ALL NULL NULL NULL NULL 2 Using temporary +3 DERIVED t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary Warnings: Note 1249 Select 4 was reduced during optimization DROP TABLE t1, t2; diff --git a/mysql-test/r/derived_cond_pushdown.result b/mysql-test/r/derived_cond_pushdown.result index a662ebba8c5..8a90df3bc4d 100644 --- a/mysql-test/r/derived_cond_pushdown.result +++ b/mysql-test/r/derived_cond_pushdown.result @@ -7250,6 +7250,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 5, + "having_condition": "s > 2", "filesort": { "sort_key": "t4.d", "temporary_table": { @@ -7621,6 +7622,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 3, + "having_condition": "s < 50", "filesort": { "sort_key": "t3.a", "temporary_table": { @@ -7771,9 +7773,14 @@ EXPLAIN "select_id": 4, "table": { "table_name": "t", - "access_type": "ALL", + "access_type": "range", + "possible_keys": ["PRIMARY"], + "key": "PRIMARY", + "key_length": "4", + "used_key_parts": ["pk"], "rows": 2, - "filtered": 100 + "filtered": 100, + "index_condition": "t.pk > 2" } } } @@ -8463,3 +8470,258 @@ WHERE row <> order_number; row order_number 14 51 DROP TABLE sales_documents; +# +# MDEV-12845: pushdown from merged derived using equalities +# +create table t1 (a int); +insert into t1 values +(4), (8), (5), (3), (10), (2), (7); +create table t2 (b int, c int); +insert into t2 values +(2,1), (5,2), (2,2), (4,1), (4,3), +(5,3), (2,4), (4,6), (2,1); +create view v1 as +select b, sum(c) as s from t2 group by b; +create view v2 as +select distinct b, c from t2; +create view v3 as +select b, max(c) as m from t2 group by b; +select b +from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t +where b > 2; +b +4 +5 +explain format=json select b +from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t +where b > 2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t1.a > 2 and t1.a is not null" + }, + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t1.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 3, + "filesort": { + "sort_key": "t2.b", + "temporary_table": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.b > 2" + } + } + } + } + } + } + } +} +select a +from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t +where a > 2; +a +4 +5 +explain format=json select a +from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t +where a > 2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t1.a > 2 and t1.a is not null" + }, + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t1.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 3, + "filesort": { + "sort_key": "t2.b", + "temporary_table": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.b > 2" + } + } + } + } + } + } + } +} +select a +from ( select t1.a, v2.b, v2.c from t1, v2 where t1.a = v2.b ) as t +where a > 2; +a +4 +4 +4 +5 +5 +explain format=json select a +from ( select t1.a, v2.b, v2.c from t1, v2 where t1.a = v2.b ) as t +where a > 2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t1.a > 2 and t1.a is not null" + }, + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t1.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 3, + "temporary_table": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100, + "attached_condition": "t2.b > 2" + } + } + } + } + } + } +} +select a +from ( select t1.a, v3.b, v3.m from t1, v3 where t1.a = v3.m ) as t +where a > 2; +a +4 +3 +explain format=json select a +from ( select t1.a, v3.b, v3.m from t1, v3 where t1.a = v3.m ) as t +where a > 2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 7, + "filtered": 100, + "attached_condition": "t1.a > 2 and t1.a is not null" + }, + "table": { + "table_name": "<derived3>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["m"], + "ref": ["test.t1.a"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "m > 2", + "filesort": { + "sort_key": "t2.b", + "temporary_table": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } + } + } + } + } + } + } +} +drop view v1,v2,v3; +drop table t1,t2; +# +# MDEV-13166: pushdown from merged derived +# +CREATE TABLE t1 (i int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW v1 AS SELECT MAX(i) AS f FROM t1; +SELECT * FROM ( SELECT * FROM v1 ) AS sq WHERE f > 0; +f +2 +explain format=json SELECT * FROM ( SELECT * FROM v1 ) AS sq WHERE f > 0; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "<derived3>", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "v1.f > 0", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "f > 0", + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } + } + } + } + } +} +DROP VIEW v1; +DROP TABLE t1; diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result index deba9b1f09a..a8068006e0a 100644 --- a/mysql-test/r/derived_view.result +++ b/mysql-test/r/derived_view.result @@ -900,7 +900,7 @@ EXPLAIN "access_type": "ALL", "rows": 11, "filtered": 100, - "attached_condition": "t1.f1 in (2,3)" + "attached_condition": "t1.f1 < 7 and t1.f1 in (2,3)" } } } @@ -1107,7 +1107,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t2 ref a a 4 const 1 Using index 1 PRIMARY <derived2> ref key0 key0 8 const,const 1 -2 DERIVED t3 ALL NULL NULL NULL NULL 12 Using temporary; Using filesort +2 DERIVED t3 ALL NULL NULL NULL NULL 12 Using where; Using temporary; Using filesort SELECT * FROM t1, t2, v1 WHERE t2.a=t1.a AND t2.a=v1.a AND t2.a=v1.b; a a a b c c c c diff --git a/mysql-test/r/mdl.result b/mysql-test/r/mdl.result new file mode 100644 index 00000000000..1a7291d922b --- /dev/null +++ b/mysql-test/r/mdl.result @@ -0,0 +1,22 @@ +# +# MDEV-12882 - Assertion `mdl_ticket->m_type == MDL_SHARED_UPGRADABLE || +# mdl_ticket->m_type == MDL_SHARED_NO_WRITE || +# mdl_ticket->m_type == MDL_SHARED_NO_READ_WRITE || +# mdl_ticket->m_type == MDL_SHARED_READ' +# failed in MDL_context::upgrade_shared_lock +# +CREATE TABLE t1(a INT) ENGINE=InnoDB; +LOCK TABLES t1 WRITE CONCURRENT, t1 AS t2 READ; +SELECT * FROM information_schema.metadata_lock_info; +THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME +9 MDL_INTENTION_EXCLUSIVE NULL Global read lock +9 MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 +UNLOCK TABLES; +LOCK TABLES t1 AS t2 READ, t1 WRITE CONCURRENT; +SELECT * FROM information_schema.metadata_lock_info; +THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME +9 MDL_INTENTION_EXCLUSIVE NULL Global read lock +9 MDL_SHARED_WRITE NULL Table metadata lock test t1 +9 MDL_SHARED_READ_ONLY NULL Table metadata lock test t1 +UNLOCK TABLES; +DROP TABLE t1; diff --git a/mysql-test/r/win_insert_select.result b/mysql-test/r/win_insert_select.result new file mode 100644 index 00000000000..c86576df6ae --- /dev/null +++ b/mysql-test/r/win_insert_select.result @@ -0,0 +1,97 @@ +CREATE TABLE t1 (c1 INT, c2 VARCHAR(30)); +PREPARE populate_table FROM "INSERT into t1 values (1, 'manual_insert_1'), + (4, 'manual_insert_2')"; +INSERT INTO t1 SELECT row_number() over(), "should_have_0" FROM t1; +INSERT INTO t1 SELECT 1 + row_number() over(), "should_have_2" FROM t1; +EXECUTE populate_table; +INSERT INTO t1 SELECT 10 + row_number() over(), "should repeat 4 times [11-14]" FROM t1; +SELECT c1, c2 FROM t1 ORDER BY c2, c1; +c1 c2 +1 manual_insert_1 +4 manual_insert_2 +11 should repeat 4 times [11-14] +12 should repeat 4 times [11-14] +13 should repeat 4 times [11-14] +14 should repeat 4 times [11-14] +0 should_have_0 +2 should_have_2 +DELETE FROM t1; +EXECUTE populate_table; +INSERT INTO t1 +SELECT 10 + (dense_rank() over(order by c1)), "dense_rank_insert" from t1; +SELECT c1, c2 FROM t1 ORDER BY c2, c1; +c1 c2 +11 dense_rank_insert +12 dense_rank_insert +1 manual_insert_1 +4 manual_insert_2 +DELETE FROM t1; +EXECUTE populate_table; +INSERT INTO t1 +SELECT 100 + (rank() over(order by c1)), "rank_insert" from t1; +SELECT c1, c2 FROM t1 ORDER BY c2, c1; +c1 c2 +1 manual_insert_1 +4 manual_insert_2 +101 rank_insert +102 rank_insert +DELETE FROM t1; +EXECUTE populate_table; +INSERT INTO t1 +SELECT 100 + (ntile(10) over(order by c1)), "ntile_insert" from t1; +SELECT c1, c2 FROM t1 ORDER BY c2, c1; +c1 c2 +1 manual_insert_1 +4 manual_insert_2 +101 ntile_insert +102 ntile_insert +DELETE FROM t1; +EXECUTE populate_table; +INSERT INTO t1 +SELECT 1000 + (percent_rank() over(order by c1)), "percent_rank_insert" from t1; +SELECT c1, c2 FROM t1 ORDER BY c2, c1; +c1 c2 +1 manual_insert_1 +4 manual_insert_2 +1000 percent_rank_insert +1001 percent_rank_insert +DELETE FROM t1; +EXECUTE populate_table; +INSERT INTO t1 +SELECT 1000 + (count(*) over(order by c1)), "count_insert" from t1; +SELECT c1, c2 FROM t1 ORDER BY c2, c1; +c1 c2 +1001 count_insert +1002 count_insert +1 manual_insert_1 +4 manual_insert_2 +DELETE FROM t1; +EXECUTE populate_table; +# +# Test how avg interacts when the results need to be rounded. +# +SELECT 1000 + (avg(c1) over(order by c1)) as avg_expr, c1, "This will be inserted into t1" from t1; +avg_expr c1 This will be inserted into t1 +1001.0000 1 This will be inserted into t1 +1002.5000 4 This will be inserted into t1 +INSERT INTO t1 +SELECT 1000 + (avg(c1) over(order by c1)), "avg_insert" from t1; +SELECT c1, c2 FROM t1 ORDER BY c2, c1; +c1 c2 +1001 avg_insert +1003 avg_insert +1 manual_insert_1 +4 manual_insert_2 +DELETE FROM t1; +EXECUTE populate_table; +INSERT INTO t1 +SELECT 1000 + (sum(c1) over(order by c1)), "sum_insert" from t1; +SELECT c1, c2 +FROM t1 +ORDER BY c2, c1; +c1 c2 +1 manual_insert_1 +4 manual_insert_2 +1001 sum_insert +1005 sum_insert +DROP table t1; diff --git a/mysql-test/suite/innodb/r/innodb-alter-timestamp.result b/mysql-test/suite/innodb/r/innodb-alter-timestamp.result index 96ce33ac097..9659b03d6b2 100644 --- a/mysql-test/suite/innodb/r/innodb-alter-timestamp.result +++ b/mysql-test/suite/innodb/r/innodb-alter-timestamp.result @@ -1,7 +1,31 @@ -CREATE TABLE t1 ( -`i1` INT(10) UNSIGNED NOT NULL, -`d1` TIMESTAMP NULL DEFAULT NULL -) ENGINE=innodb; +CREATE TABLE t1 (i1 INT UNSIGNED NULL DEFAULT 42) ENGINE=innodb; +INSERT INTO t1 VALUES(NULL); +ALTER TABLE t1 CHANGE i1 i1 INT UNSIGNED NOT NULL DEFAULT rand(), +ALGORITHM=INPLACE; +ERROR 22004: Invalid use of NULL value +ALTER TABLE t1 CHANGE i1 i1 INT UNSIGNED NOT NULL DEFAULT rand(), +ALGORITHM=COPY; +ERROR 01000: Data truncated for column 'i1' at row 1 +ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT, +ADD PRIMARY KEY(id), ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY +ALTER TABLE t1 ADD PRIMARY KEY(i1), ALGORITHM=INPLACE; +ERROR 22004: Invalid use of NULL value +ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT, +ADD PRIMARY KEY(id); +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +SELECT * FROM t1; +id +1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (i1 INT UNSIGNED NOT NULL, d1 TIMESTAMP NULL) ENGINE=InnoDB; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -17,21 +41,56 @@ i1 d1 4 NULL 5 NULL set sql_mode = 'STRICT_ALL_TABLES,NO_ZERO_DATE'; -ALTER TABLE t1 CHANGE `d1` `d1` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL; +ALTER TABLE t1 CHANGE d1 d1 TIMESTAMP NULL DEFAULT '2017-05-08 16:23:45', +ALGORITHM=INPLACE; +SELECT DISTINCT d1 FROM t1; +d1 +NULL +ALTER TABLE t1 CHANGE d1 d1 TIMESTAMP NULL DEFAULT '2017-05-08 16:32:45', +ALGORITHM=COPY; +SELECT DISTINCT d1 FROM t1; +d1 +NULL +ALTER TABLE t1 CHANGE d1 d1 TIMESTAMP DEFAULT '2017-05-08 16:32:54'; +affected rows: 5 +info: Records: 5 Duplicates: 0 Warnings: 0 +# Note: NULL was changed to CURRENT_TIMESTAMP(), +# not the specified constant DEFAULT value! +SELECT COUNT(DISTINCT d1),COUNT(d1),COUNT(*) FROM t1; +COUNT(DISTINCT d1) COUNT(d1) COUNT(*) +1 5 5 +SELECT DISTINCT (CURRENT_TIMESTAMP()-d1) <= 60 FROM t1; +(CURRENT_TIMESTAMP()-d1) <= 60 +1 drop table t1; CREATE TABLE t1 ( `i1` INT(10) UNSIGNED NOT NULL, `d1` TIMESTAMP NULL DEFAULT NULL ) ENGINE=innodb; INSERT INTO t1 (i1) VALUES (1), (2), (3), (4), (5); -ALTER TABLE t1 CHANGE `d1` `d1` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE t1 CHANGE d1 d1 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP; +affected rows: 5 +info: Records: 5 Duplicates: 0 Warnings: 0 +ALTER TABLE t1 ADD COLUMN w1 varchar(20) NULL DEFAULT USER(); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ALTER TABLE t1 CHANGE w1 u1 varchar(30) NULL DEFAULT substr(USER(),1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT u1, COUNT(DISTINCT d1) FROM t1 GROUP BY u1; +u1 COUNT(DISTINCT d1) +root@localhost 1 ALTER TABLE t1 ADD COLUMN d2 TIMESTAMP DEFAULT '2017-05-08 16:23:45', LOCK=NONE; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 ALTER TABLE t1 ADD COLUMN d3 TIMESTAMP DEFAULT d1, LOCK=NONE; ERROR 0A000: LOCK=NONE is not supported for this operation. Try LOCK=SHARED ALTER TABLE t1 ADD COLUMN d3 TIMESTAMP DEFAULT d1, ALGORITHM=INPLACE; ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY ALTER TABLE t1 ADD COLUMN d3 TIMESTAMP DEFAULT d1; +affected rows: 5 +info: Records: 5 Duplicates: 0 Warnings: 0 SELECT d1-d3, d2 FROM t1; d1-d3 d2 0 2017-05-08 16:23:45 @@ -44,7 +103,17 @@ Table Create Table t1 CREATE TABLE `t1` ( `i1` int(10) unsigned NOT NULL, `d1` timestamp NOT NULL DEFAULT current_timestamp(), + `u1` varchar(30) DEFAULT substr(user(),1), `d2` timestamp NOT NULL DEFAULT '2017-05-08 16:23:45', `d3` timestamp NOT NULL DEFAULT `d1` ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1 ADD COLUMN d4 TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT COUNT(DISTINCT d4),COUNT(d4),COUNT(*) FROM t1; +COUNT(DISTINCT d4) COUNT(d4) COUNT(*) +1 5 5 +SELECT DISTINCT (CURRENT_TIMESTAMP()-d4) <= 60 FROM t1; +(CURRENT_TIMESTAMP()-d4) <= 60 +1 DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb_force_recovery.result b/mysql-test/suite/innodb/r/innodb_force_recovery.result index e405a79dd53..d71a6c4e8b0 100644 --- a/mysql-test/suite/innodb/r/innodb_force_recovery.result +++ b/mysql-test/suite/innodb/r/innodb_force_recovery.result @@ -1,5 +1,5 @@ create table t1(f1 int not null, f2 int not null, index idx(f2))engine=innodb; -create table t2(f1 int not null, f2 int not null, index idx(f2))engine=innodb; +create table t2(f1 int primary key, f2 int, index idx(f2))engine=innodb; insert into t1 values(1, 2); insert into t2 values(1, 2); SET GLOBAL innodb_fast_shutdown = 0; @@ -85,6 +85,37 @@ ERROR HY000: Table 't2' is read only show tables; Tables_in_test t2 +# Restart the server with innodb_force_recovery=2 +select * from t2; +f1 f2 +1 2 +begin; +update t2 set f2=3; +connect con1,localhost,root,,; +create table t3(a int)engine=innodb; +# Force a redo log flush of the above uncommitted UPDATE +SET GLOBAL innodb_flush_log_at_trx_commit=1; +drop table t3; +disconnect con1; +connection default; +# Kill the server +# Restart the server with innodb_force_recovery=3 +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select * from t2; +f1 f2 +1 3 +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +select * from t2; +f1 f2 +1 2 +SET GLOBAL innodb_lock_wait_timeout=1; +insert into t2 values(1,2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +insert into t2 values(9,10); +select * from t2; +f1 f2 +1 2 +9 10 drop table t2; show tables; Tables_in_test diff --git a/mysql-test/suite/innodb/t/innodb-alter-timestamp.test b/mysql-test/suite/innodb/t/innodb-alter-timestamp.test index 935320fb553..d8acc02cbdb 100644 --- a/mysql-test/suite/innodb/t/innodb-alter-timestamp.test +++ b/mysql-test/suite/innodb/t/innodb-alter-timestamp.test @@ -1,16 +1,46 @@ --source include/have_innodb.inc -CREATE TABLE t1 ( - `i1` INT(10) UNSIGNED NOT NULL, - `d1` TIMESTAMP NULL DEFAULT NULL -) ENGINE=innodb; +CREATE TABLE t1 (i1 INT UNSIGNED NULL DEFAULT 42) ENGINE=innodb; +INSERT INTO t1 VALUES(NULL); +--enable_info +--error ER_INVALID_USE_OF_NULL +ALTER TABLE t1 CHANGE i1 i1 INT UNSIGNED NOT NULL DEFAULT rand(), +ALGORITHM=INPLACE; +--error WARN_DATA_TRUNCATED +ALTER TABLE t1 CHANGE i1 i1 INT UNSIGNED NOT NULL DEFAULT rand(), +ALGORITHM=COPY; +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT, +ADD PRIMARY KEY(id), ALGORITHM=INPLACE; +--error ER_INVALID_USE_OF_NULL +ALTER TABLE t1 ADD PRIMARY KEY(i1), ALGORITHM=INPLACE; +ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT, +ADD PRIMARY KEY(id); +--disable_info +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 (i1 INT UNSIGNED NOT NULL, d1 TIMESTAMP NULL) ENGINE=InnoDB; SHOW CREATE TABLE t1; INSERT INTO t1 (i1) VALUES (1), (2), (3), (4), (5); select * from t1; set sql_mode = 'STRICT_ALL_TABLES,NO_ZERO_DATE'; -ALTER TABLE t1 CHANGE `d1` `d1` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL; +ALTER TABLE t1 CHANGE d1 d1 TIMESTAMP NULL DEFAULT '2017-05-08 16:23:45', +ALGORITHM=INPLACE; +SELECT DISTINCT d1 FROM t1; +ALTER TABLE t1 CHANGE d1 d1 TIMESTAMP NULL DEFAULT '2017-05-08 16:32:45', +ALGORITHM=COPY; +SELECT DISTINCT d1 FROM t1; +--enable_info +ALTER TABLE t1 CHANGE d1 d1 TIMESTAMP DEFAULT '2017-05-08 16:32:54'; +--disable_info +--echo # Note: NULL was changed to CURRENT_TIMESTAMP(), +--echo # not the specified constant DEFAULT value! +SELECT COUNT(DISTINCT d1),COUNT(d1),COUNT(*) FROM t1; +SELECT DISTINCT (CURRENT_TIMESTAMP()-d1) <= 60 FROM t1; drop table t1; CREATE TABLE t1 ( @@ -18,8 +48,14 @@ CREATE TABLE t1 ( `d1` TIMESTAMP NULL DEFAULT NULL ) ENGINE=innodb; INSERT INTO t1 (i1) VALUES (1), (2), (3), (4), (5); -ALTER TABLE t1 CHANGE `d1` `d1` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP; +--enable_info +ALTER TABLE t1 CHANGE d1 d1 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE t1 ADD COLUMN w1 varchar(20) NULL DEFAULT USER(); +ALTER TABLE t1 CHANGE w1 u1 varchar(30) NULL DEFAULT substr(USER(),1); +--disable_info +SELECT u1, COUNT(DISTINCT d1) FROM t1 GROUP BY u1; +--enable_info ALTER TABLE t1 ADD COLUMN d2 TIMESTAMP DEFAULT '2017-05-08 16:23:45', LOCK=NONE; --error ER_ALTER_OPERATION_NOT_SUPPORTED @@ -27,6 +63,12 @@ ALTER TABLE t1 ADD COLUMN d3 TIMESTAMP DEFAULT d1, LOCK=NONE; --error ER_ALTER_OPERATION_NOT_SUPPORTED ALTER TABLE t1 ADD COLUMN d3 TIMESTAMP DEFAULT d1, ALGORITHM=INPLACE; ALTER TABLE t1 ADD COLUMN d3 TIMESTAMP DEFAULT d1; +--disable_info SELECT d1-d3, d2 FROM t1; SHOW CREATE TABLE t1; +--enable_info +ALTER TABLE t1 ADD COLUMN d4 TIMESTAMP DEFAULT CURRENT_TIMESTAMP; +--disable_info +SELECT COUNT(DISTINCT d4),COUNT(d4),COUNT(*) FROM t1; +SELECT DISTINCT (CURRENT_TIMESTAMP()-d4) <= 60 FROM t1; DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb_force_recovery.test b/mysql-test/suite/innodb/t/innodb_force_recovery.test index 31b9660e872..f9af16f6609 100644 --- a/mysql-test/suite/innodb/t/innodb_force_recovery.test +++ b/mysql-test/suite/innodb/t/innodb_force_recovery.test @@ -10,7 +10,7 @@ call mtr.add_suppression("InnoDB: Allocated tablespace ID \\d+ for test.t[12], o --enable_query_log create table t1(f1 int not null, f2 int not null, index idx(f2))engine=innodb; -create table t2(f1 int not null, f2 int not null, index idx(f2))engine=innodb; +create table t2(f1 int primary key, f2 int, index idx(f2))engine=innodb; insert into t1 values(1, 2); insert into t2 values(1, 2); @@ -132,8 +132,40 @@ truncate table t2; drop table t2; show tables; +--echo # Restart the server with innodb_force_recovery=2 +--let $restart_parameters= --innodb-force-recovery=2 +--source include/restart_mysqld.inc + +select * from t2; +begin; +update t2 set f2=3; + +connect (con1,localhost,root,,); +create table t3(a int)engine=innodb; +--echo # Force a redo log flush of the above uncommitted UPDATE +SET GLOBAL innodb_flush_log_at_trx_commit=1; +drop table t3; +disconnect con1; + +connection default; +--source include/kill_mysqld.inc + +--echo # Restart the server with innodb_force_recovery=3 +--let $restart_parameters= --innodb-force-recovery=3 +--source include/start_mysqld.inc + +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select * from t2; +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +select * from t2; +SET GLOBAL innodb_lock_wait_timeout=1; +--error ER_LOCK_WAIT_TIMEOUT +insert into t2 values(1,2); +insert into t2 values(9,10); + --let $restart_parameters= --source include/restart_mysqld.inc +select * from t2; drop table t2; show tables; diff --git a/mysql-test/suite/large_tests/r/rpl_slave_net_timeout.result b/mysql-test/suite/large_tests/r/rpl_slave_net_timeout.result index 4dcc2e6295f..ad704c0c683 100644 --- a/mysql-test/suite/large_tests/r/rpl_slave_net_timeout.result +++ b/mysql-test/suite/large_tests/r/rpl_slave_net_timeout.result @@ -1,20 +1,27 @@ include/master-slave.inc [connection master] +connection master; set @save_general_log = @@global.general_log; set @save_log_output = @@global.log_output; +connection slave; set @save_slave_net_timeout = @@global.slave_net_timeout; +connection master; set @@global.general_log = ON; set @@global.log_output = 'table,file'; +connection slave; include/stop_slave.inc change master to master_host = '127.0.0.1',master_port = MASTER_PORT, master_user = 'root', master_heartbeat_period = 0; set @@global.slave_net_timeout = @@global.net_read_timeout * 2; include/start_slave.inc include/stop_slave.inc +connection master; select event_time from (select event_time from mysql.general_log as t_1 where command_type like 'Connect' order by event_time desc limit 2) as t_2 order by event_time desc limit 1 into @ts_last; select event_time from (select event_time from mysql.general_log as t_1 where command_type like 'Connect' order by event_time desc limit 2) as t_2 order by event_time asc limit 1 into @ts_prev; include/assert.inc [time between last reconnection and the reconnection before that should be >= slave_net_timeout] +connection master; set @@global.general_log = @save_general_log; set @@global.log_output = @save_log_output; +connection slave; set @@global.slave_net_timeout = @save_slave_net_timeout; include/rpl_end.inc diff --git a/mysql-test/suite/storage_engine/tbl_temporary.test b/mysql-test/suite/storage_engine/tbl_temporary.test index 963238c37a5..66b63fd2d83 100644 --- a/mysql-test/suite/storage_engine/tbl_temporary.test +++ b/mysql-test/suite/storage_engine/tbl_temporary.test @@ -26,7 +26,8 @@ if (!$mysql_errname) SHOW CREATE TABLE t1; DROP TEMPORARY TABLE t1; - DROP TABLE t1; } +DROP TABLE t1; + --source cleanup_engine.inc diff --git a/mysql-test/suite/storage_engine/type_binary_indexes.test b/mysql-test/suite/storage_engine/type_binary_indexes.test index 943593027f8..c17b0c53a68 100644 --- a/mysql-test/suite/storage_engine/type_binary_indexes.test +++ b/mysql-test/suite/storage_engine/type_binary_indexes.test @@ -131,6 +131,11 @@ if (!$mysql_errname) INSERT INTO t1 (b,b20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b'),('d','char5','varchar4a','varchar3b'),('e','char6','varchar2a','varchar3b'); INSERT INTO t1 (b,b20,v16,v128) SELECT b,b20,v16,v128 FROM t1; + --disable_result_log + --disable_query_log + ANALYZE TABLE t1; + --enable_query_log + --enable_result_log --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 # EXPLAIN SELECT HEX(SUBSTRING(v16,0,3)) FROM t1 WHERE v16 LIKE 'varchar%'; diff --git a/mysql-test/t/derived_cond_pushdown.test b/mysql-test/t/derived_cond_pushdown.test index bc448093e33..beeaa7350f7 100644 --- a/mysql-test/t/derived_cond_pushdown.test +++ b/mysql-test/t/derived_cond_pushdown.test @@ -1452,3 +1452,77 @@ SELECT * FROM WHERE row <> order_number; DROP TABLE sales_documents; + +--echo # +--echo # MDEV-12845: pushdown from merged derived using equalities +--echo # + +create table t1 (a int); +insert into t1 values + (4), (8), (5), (3), (10), (2), (7); + +create table t2 (b int, c int); +insert into t2 values + (2,1), (5,2), (2,2), (4,1), (4,3), + (5,3), (2,4), (4,6), (2,1); + +create view v1 as +select b, sum(c) as s from t2 group by b; + +create view v2 as +select distinct b, c from t2; + +create view v3 as +select b, max(c) as m from t2 group by b; + +let $q1= +select b +from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t +where b > 2; + +eval $q1; +eval explain format=json $q1; + +let $q2= +select a +from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t +where a > 2; + +eval $q2; +eval explain format=json $q2; + +let $q3= +select a +from ( select t1.a, v2.b, v2.c from t1, v2 where t1.a = v2.b ) as t +where a > 2; + +eval $q3; +eval explain format=json $q3; + +let $q4= +select a +from ( select t1.a, v3.b, v3.m from t1, v3 where t1.a = v3.m ) as t +where a > 2; + +eval $q4; +eval explain format=json $q4; + +drop view v1,v2,v3; +drop table t1,t2; + +--echo # +--echo # MDEV-13166: pushdown from merged derived +--echo # + +CREATE TABLE t1 (i int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW v1 AS SELECT MAX(i) AS f FROM t1; + +let $q= +SELECT * FROM ( SELECT * FROM v1 ) AS sq WHERE f > 0; + +eval $q; +eval explain format=json $q; + +DROP VIEW v1; +DROP TABLE t1; diff --git a/mysql-test/t/mdl.test b/mysql-test/t/mdl.test new file mode 100644 index 00000000000..1770e53b61a --- /dev/null +++ b/mysql-test/t/mdl.test @@ -0,0 +1,19 @@ +--source include/have_metadata_lock_info.inc +--source include/have_innodb.inc + +--echo # +--echo # MDEV-12882 - Assertion `mdl_ticket->m_type == MDL_SHARED_UPGRADABLE || +--echo # mdl_ticket->m_type == MDL_SHARED_NO_WRITE || +--echo # mdl_ticket->m_type == MDL_SHARED_NO_READ_WRITE || +--echo # mdl_ticket->m_type == MDL_SHARED_READ' +--echo # failed in MDL_context::upgrade_shared_lock +--echo # + +CREATE TABLE t1(a INT) ENGINE=InnoDB; +LOCK TABLES t1 WRITE CONCURRENT, t1 AS t2 READ; +SELECT * FROM information_schema.metadata_lock_info; +UNLOCK TABLES; +LOCK TABLES t1 AS t2 READ, t1 WRITE CONCURRENT; +SELECT * FROM information_schema.metadata_lock_info; +UNLOCK TABLES; +DROP TABLE t1; diff --git a/mysql-test/t/win_insert_select.test b/mysql-test/t/win_insert_select.test new file mode 100644 index 00000000000..66df7324c4f --- /dev/null +++ b/mysql-test/t/win_insert_select.test @@ -0,0 +1,79 @@ +CREATE TABLE t1 (c1 INT, c2 VARCHAR(30)); + +PREPARE populate_table FROM "INSERT into t1 values (1, 'manual_insert_1'), + (4, 'manual_insert_2')"; + +INSERT INTO t1 SELECT row_number() over(), "should_have_0" FROM t1; +INSERT INTO t1 SELECT 1 + row_number() over(), "should_have_2" FROM t1; + +EXECUTE populate_table; + +INSERT INTO t1 SELECT 10 + row_number() over(), "should repeat 4 times [11-14]" FROM t1; + +SELECT c1, c2 FROM t1 ORDER BY c2, c1; + +DELETE FROM t1; +EXECUTE populate_table; + + +INSERT INTO t1 + SELECT 10 + (dense_rank() over(order by c1)), "dense_rank_insert" from t1; + +SELECT c1, c2 FROM t1 ORDER BY c2, c1; + +DELETE FROM t1; +EXECUTE populate_table; + +INSERT INTO t1 + SELECT 100 + (rank() over(order by c1)), "rank_insert" from t1; + +SELECT c1, c2 FROM t1 ORDER BY c2, c1; + +DELETE FROM t1; +EXECUTE populate_table; + +INSERT INTO t1 + SELECT 100 + (ntile(10) over(order by c1)), "ntile_insert" from t1; + +SELECT c1, c2 FROM t1 ORDER BY c2, c1; + +DELETE FROM t1; +EXECUTE populate_table; + +INSERT INTO t1 + SELECT 1000 + (percent_rank() over(order by c1)), "percent_rank_insert" from t1; + +SELECT c1, c2 FROM t1 ORDER BY c2, c1; + +DELETE FROM t1; +EXECUTE populate_table; + +INSERT INTO t1 + SELECT 1000 + (count(*) over(order by c1)), "count_insert" from t1; + +SELECT c1, c2 FROM t1 ORDER BY c2, c1; + +DELETE FROM t1; +EXECUTE populate_table; + +--echo # +--echo # Test how avg interacts when the results need to be rounded. +--echo # +SELECT 1000 + (avg(c1) over(order by c1)) as avg_expr, c1, "This will be inserted into t1" from t1; + +INSERT INTO t1 + SELECT 1000 + (avg(c1) over(order by c1)), "avg_insert" from t1; + +SELECT c1, c2 FROM t1 ORDER BY c2, c1; + +DELETE FROM t1; +EXECUTE populate_table; + +INSERT INTO t1 + SELECT 1000 + (sum(c1) over(order by c1)), "sum_insert" from t1; + +SELECT c1, c2 +FROM t1 +ORDER BY c2, c1; + +DROP table t1; diff --git a/sql/item.cc b/sql/item.cc index 173444ad580..7279c79cef9 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -7117,122 +7117,181 @@ Item *Item_field::update_value_transformer(THD *thd, uchar *select_arg) } -Item *Item_field::derived_field_transformer_for_having(THD *thd, uchar *arg) -{ - st_select_lex *sl= (st_select_lex *)arg; - table_map map= sl->master_unit()->derived->table->map; - if (!((Item_field*)this)->item_equal) - { - if (used_tables() == map) - { - Item_ref *rf= - new (thd->mem_root) Item_ref(thd, &sl->context, - NullS, NullS, - &((Item_field*) this)->field_name); - if (!rf) - return 0; - return rf; - } - } +static +Item *get_field_item_for_having(THD *thd, Item *item, st_select_lex *sel) +{ + DBUG_ASSERT(item->type() == Item::FIELD_ITEM || + (item->type() == Item::REF_ITEM && + ((Item_ref *) item)->ref_type() == Item_ref::VIEW_REF)); + Item_field *field_item= NULL; + table_map map= sel->master_unit()->derived->table->map; + Item_equal *item_equal= item->get_item_equal(); + if (!item_equal) + field_item= (Item_field *)(item->real_item()); else { - Item_equal *cond= (Item_equal *) ((Item_field*)this)->item_equal; - Item_equal_fields_iterator li(*cond); - Item *item; - while ((item=li++)) + Item_equal_fields_iterator li(*item_equal); + Item *equal_item; + while ((equal_item= li++)) { - if (item->used_tables() == map && item->real_item()->type() == FIELD_ITEM) + if (equal_item->used_tables() == map) { - Item_ref *rf= - new (thd->mem_root) Item_ref(thd, &sl->context, - NullS, NullS, - &((Item_field*) (item->real_item()))-> - field_name); - if (!rf) - return 0; - return rf; + field_item= (Item_field *)(equal_item->real_item()); + break; } } } - return this; + if (field_item) + { + Item_ref *ref= new (thd->mem_root) Item_ref(thd, &sel->context, + NullS, NullS, + &field_item->field_name); + return ref; + } + DBUG_ASSERT(0); + return NULL; } -Item *Item_field::derived_field_transformer_for_where(THD *thd, uchar *arg) +Item *Item_field::derived_field_transformer_for_having(THD *thd, uchar *arg) +{ + st_select_lex *sel= (st_select_lex *)arg; + table_map tab_map= sel->master_unit()->derived->table->map; + if (item_equal && !(item_equal->used_tables() & tab_map)) + return this; + if (!item_equal && used_tables() != tab_map) + return this; + return get_field_item_for_having(thd, this, sel); +} + + +Item *Item_direct_view_ref::derived_field_transformer_for_having(THD *thd, + uchar *arg) { + st_select_lex *sel= (st_select_lex *)arg; + table_map tab_map= sel->master_unit()->derived->table->map; + if ((item_equal && !(item_equal->used_tables() & tab_map)) || + !item_equal) + return this; + return get_field_item_for_having(thd, this, sel); +} + + +static +Item *find_producing_item(Item *item, st_select_lex *sel) +{ + DBUG_ASSERT(item->type() == Item::FIELD_ITEM || + (item->type() == Item::REF_ITEM && + ((Item_ref *) item)->ref_type() == Item_ref::VIEW_REF)); Item *producing_item; - st_select_lex *sl= (st_select_lex *)arg; - List_iterator_fast<Item> li(sl->item_list); - table_map map= sl->master_unit()->derived->table->map; - if (used_tables() == map) - { - uint field_no= ((Item_field*) this)->field->field_index; - for (uint i= 0; i <= field_no; i++) - producing_item= li++; - return producing_item->build_clone(thd, thd->mem_root); - } - else if (((Item_field*)this)->item_equal) - { - Item_equal *cond= (Item_equal *) ((Item_field*)this)->item_equal; - Item_equal_fields_iterator it(*cond); - Item *item; - while ((item=it++)) + Item_field *field_item= NULL; + Item_equal *item_equal= item->get_item_equal(); + table_map tab_map= sel->master_unit()->derived->table->map; + if (item->used_tables() == tab_map) + field_item= (Item_field *) (item->real_item()); + if (!field_item && item_equal) + { + Item_equal_fields_iterator it(*item_equal); + Item *equal_item; + while ((equal_item= it++)) { - if (item->used_tables() == map && item->real_item()->type() == FIELD_ITEM) - { - Item_field *field_item= (Item_field *) (item->real_item()); - li.rewind(); - uint field_no= field_item->field->field_index; - for (uint i= 0; i <= field_no; i++) - producing_item= li++; - return producing_item->build_clone(thd, thd->mem_root); + if (equal_item->used_tables() == tab_map) + { + field_item= (Item_field *) (equal_item->real_item()); + break; } } } - return this; + List_iterator_fast<Item> li(sel->item_list); + if (field_item) + { + uint field_no= field_item->field->field_index; + for (uint i= 0; i <= field_no; i++) + producing_item= li++; + return producing_item; + } + return NULL; } +Item *Item_field::derived_field_transformer_for_where(THD *thd, uchar *arg) +{ + st_select_lex *sel= (st_select_lex *)arg; + Item *producing_item= find_producing_item(this, sel); + if (producing_item) + return producing_item->build_clone(thd, thd->mem_root); + return this; +} -Item *Item_field::derived_grouping_field_transformer_for_where(THD *thd, - uchar *arg) +Item *Item_direct_view_ref::derived_field_transformer_for_where(THD *thd, + uchar *arg) { - st_select_lex *sl= (st_select_lex *)arg; - List_iterator<Grouping_tmp_field> li(sl->grouping_tmp_fields); - Grouping_tmp_field *field; - table_map map= sl->master_unit()->derived->table->map; - if (used_tables() == map) + if (item_equal) { - while ((field=li++)) - { - if (((Item_field*) this)->field == field->tmp_field) - return field->producing_item->build_clone(thd, thd->mem_root); - } + st_select_lex *sel= (st_select_lex *)arg; + Item *producing_item= find_producing_item(this, sel); + DBUG_ASSERT (producing_item != NULL); + return producing_item->build_clone(thd, thd->mem_root); } - else if (((Item_field*)this)->item_equal) - { - Item_equal *cond= (Item_equal *) ((Item_field*)this)->item_equal; - Item_equal_fields_iterator it(*cond); - Item *item; - while ((item=it++)) + return this; +} + +static +Grouping_tmp_field *find_matching_grouping_field(Item *item, + st_select_lex *sel) +{ + DBUG_ASSERT(item->type() == Item::FIELD_ITEM || + (item->type() == Item::REF_ITEM && + ((Item_ref *) item)->ref_type() == Item_ref::VIEW_REF)); + List_iterator<Grouping_tmp_field> li(sel->grouping_tmp_fields); + Grouping_tmp_field *gr_field; + Item_field *field_item= (Item_field *) (item->real_item()); + while ((gr_field= li++)) + { + if (field_item->field == gr_field->tmp_field) + return gr_field; + } + Item_equal *item_equal= item->get_item_equal(); + if (item_equal) + { + Item_equal_fields_iterator it(*item_equal); + Item *equal_item; + while ((equal_item= it++)) { - if (item->used_tables() == map && item->real_item()->type() == FIELD_ITEM) - { - Item_field *field_item= (Item_field *) (item->real_item()); - li.rewind(); - while ((field=li++)) - { - if (field_item->field == field->tmp_field) - { - return field->producing_item->build_clone(thd, thd->mem_root); - } - } + field_item= (Item_field *) (equal_item->real_item()); + li.rewind(); + while ((gr_field= li++)) + { + if (field_item->field == gr_field->tmp_field) + return gr_field; } } } + return NULL; +} + + +Item *Item_field::derived_grouping_field_transformer_for_where(THD *thd, + uchar *arg) +{ + st_select_lex *sel= (st_select_lex *)arg; + Grouping_tmp_field *gr_field= find_matching_grouping_field(this, sel); + if (gr_field) + return gr_field->producing_item->build_clone(thd, thd->mem_root); return this; } +Item * +Item_direct_view_ref::derived_grouping_field_transformer_for_where(THD *thd, + uchar *arg) +{ + if (!item_equal) + return this; + st_select_lex *sel= (st_select_lex *)arg; + Grouping_tmp_field *gr_field= find_matching_grouping_field(this, sel); + return gr_field->producing_item->build_clone(thd, thd->mem_root); +} + void Item_field::print(String *str, enum_query_type query_type) { if (field && field->table->const_table && @@ -8720,6 +8779,32 @@ Item *Item_direct_view_ref::replace_equal_field(THD *thd, uchar *arg) } +bool Item_direct_view_ref::excl_dep_on_table(table_map tab_map) +{ + table_map used= used_tables(); + if (used & OUTER_REF_TABLE_BIT) + return false; + if (!(used & ~tab_map)) + return true; + if (item_equal) + { + DBUG_ASSERT(real_item()->type() == Item::FIELD_ITEM); + return item_equal->used_tables() & tab_map; + } + return (*ref)->excl_dep_on_table(tab_map); +} + +bool Item_direct_view_ref::excl_dep_on_grouping_fields(st_select_lex *sel) +{ + if (item_equal) + { + DBUG_ASSERT(real_item()->type() == Item::FIELD_ITEM); + return find_matching_grouping_field(this, sel) != NULL; + } + return (*ref)->excl_dep_on_grouping_fields(sel); +} + + bool Item_default_value::eq(const Item *item, bool binary_cmp) const { return item->type() == DEFAULT_VALUE_ITEM && @@ -10128,46 +10213,16 @@ const char *dbug_print_unit(SELECT_LEX_UNIT *un) #endif /*DBUG_OFF*/ -bool Item_field::exclusive_dependence_on_table_processor(void *map) +bool Item_field::excl_dep_on_table(table_map tab_map) { - table_map tab_map= *((table_map *) map); - return !((used_tables() == tab_map || - (item_equal && item_equal->used_tables() & tab_map))); + return used_tables() == tab_map || + (item_equal && (item_equal->used_tables() & tab_map)); } -bool Item_field::exclusive_dependence_on_grouping_fields_processor(void *arg) +bool +Item_field::excl_dep_on_grouping_fields(st_select_lex *sel) { - st_select_lex *sl= (st_select_lex *)arg; - List_iterator<Grouping_tmp_field> li(sl->grouping_tmp_fields); - Grouping_tmp_field *field; - table_map map= sl->master_unit()->derived->table->map; - if (used_tables() == map) - { - while ((field=li++)) - { - if (((Item_field*) this)->field == field->tmp_field) - return false; - } - } - else if (((Item_field*)this)->item_equal) - { - Item_equal *cond= (Item_equal *) ((Item_field*)this)->item_equal; - Item_equal_fields_iterator it(*cond); - Item *item; - while ((item=it++)) - { - if (item->used_tables() == map && item->real_item()->type() == FIELD_ITEM) - { - li.rewind(); - while ((field=li++)) - { - if (((Item_field *)(item->real_item()))->field == field->tmp_field) - return false; - } - } - } - } - return true; + return find_matching_grouping_field(this, sel) != NULL; } void Item::register_in(THD *thd) diff --git a/sql/item.h b/sql/item.h index bc349e8003a..0db81670ae7 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1497,8 +1497,20 @@ public: virtual bool limit_index_condition_pushdown_processor(void *arg) { return 0; } virtual bool exists2in_processor(void *arg) { return 0; } virtual bool find_selective_predicates_list_processor(void *arg) { return 0; } - virtual bool exclusive_dependence_on_table_processor(void *arg) { return 0; } - virtual bool exclusive_dependence_on_grouping_fields_processor(void *arg) { return 0; } + + /* + TRUE if the expression depends only on the table indicated by tab_map + or can be converted to such an exression using equalities. + Not to be used for AND/OR formulas. + */ + virtual bool excl_dep_on_table(table_map tab_map) { return false; } + /* + TRUE if the expression depends only on grouping fields of sel + or can be converted to such an exression using equalities. + Not to be used for AND/OR formulas. + */ + virtual bool excl_dep_on_grouping_fields(st_select_lex *sel) { return false; } + virtual bool switch_to_nullable_fields_processor(void *arg) { return 0; } virtual bool find_function_processor (void *arg) { return 0; } /* @@ -1934,6 +1946,28 @@ protected: } bool transform_args(THD *thd, Item_transformer transformer, uchar *arg); void propagate_equal_fields(THD *, const Item::Context &, COND_EQUAL *); + bool excl_dep_on_table(table_map tab_map) + { + for (uint i= 0; i < arg_count; i++) + { + if (args[i]->const_item()) + continue; + if (!args[i]->excl_dep_on_table(tab_map)) + return false; + } + return true; + } + bool excl_dep_on_grouping_fields(st_select_lex *sel) + { + for (uint i= 0; i < arg_count; i++) + { + if (args[i]->const_item()) + continue; + if (!args[i]->excl_dep_on_grouping_fields(sel)) + return false; + } + return true; + } public: Item_args(void) :args(NULL), arg_count(0) @@ -2795,8 +2829,8 @@ public: Item *derived_field_transformer_for_where(THD *thd, uchar *arg); Item *derived_grouping_field_transformer_for_where(THD *thd, uchar *arg); virtual void print(String *str, enum_query_type query_type); - bool exclusive_dependence_on_table_processor(void *map); - bool exclusive_dependence_on_grouping_fields_processor(void *arg); + bool excl_dep_on_table(table_map tab_map); + bool excl_dep_on_grouping_fields(st_select_lex *sel); bool cleanup_excluding_fields_processor(void *arg) { return field ? 0 : cleanup_processor(arg); } bool cleanup_excluding_const_fields_processor(void *arg) @@ -4426,10 +4460,15 @@ public: } Item *get_copy(THD *thd, MEM_ROOT *mem_root) { return get_item_copy<Item_ref>(thd, mem_root, this); } - bool exclusive_dependence_on_table_processor(void *map) - { return depended_from != NULL; } - bool exclusive_dependence_on_grouping_fields_processor(void *arg) - { return depended_from != NULL; } + bool excl_dep_on_table(table_map tab_map) + { + table_map used= used_tables(); + if (used & OUTER_REF_TABLE_BIT) + return false; + return (used == tab_map) || (*ref)->excl_dep_on_table(tab_map); + } + bool excl_dep_on_grouping_fields(st_select_lex *sel) + { return (*ref)->excl_dep_on_grouping_fields(sel); } bool cleanup_excluding_fields_processor(void *arg) { Item *item= real_item(); @@ -4725,13 +4764,20 @@ public: return (*ref)->walk(processor, walk_subquery, arg) || (this->*processor)(arg); } - bool view_used_tables_processor(void *arg) + bool view_used_tables_processor(void *arg) { TABLE_LIST *view_arg= (TABLE_LIST *) arg; if (view_arg == view) view_arg->view_used_tables|= (*ref)->used_tables(); return 0; } + bool excl_dep_on_table(table_map tab_map); + bool excl_dep_on_grouping_fields(st_select_lex *sel); + Item *derived_field_transformer_for_having(THD *thd, uchar *arg); + Item *derived_field_transformer_for_where(THD *thd, uchar *arg); + Item *derived_grouping_field_transformer_for_where(THD *thd, + uchar *arg); + void save_val(Field *to) { if (check_null_ref()) @@ -4813,6 +4859,8 @@ public: item_equal= NULL; Item_direct_ref::cleanup(); } + Item *get_copy(THD *thd, MEM_ROOT *mem_root) + { return get_item_copy<Item_direct_view_ref>(thd, mem_root, this); } }; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index f19cae72cb5..0afbd875ac2 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -2945,6 +2945,14 @@ public: void set_context_field(Item_field *ctx_field) { context_field= ctx_field; } void set_link_equal_fields(bool flag) { link_equal_fields= flag; } Item* get_copy(THD *thd, MEM_ROOT *mem_root) { return 0; } + /* + This does not comply with the specification of the virtual method, + but Item_equal items are processed distinguishly anyway + */ + bool excl_dep_on_table(table_map tab_map) + { + return used_tables() & tab_map; + } friend class Item_equal_fields_iterator; bool count_sargable_conds(void *arg); friend class Item_equal_iterator<List_iterator_fast,Item>; diff --git a/sql/item_func.h b/sql/item_func.h index 03eb01bbcc9..8616bdfefc2 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -310,6 +310,19 @@ public: return this; } + bool excl_dep_on_table(table_map tab_map) + { + if (used_tables() & OUTER_REF_TABLE_BIT) + return false; + return !(used_tables() & ~tab_map) || + Item_args::excl_dep_on_table(tab_map); + } + + bool excl_dep_on_grouping_fields(st_select_lex *sel) + { + return Item_args::excl_dep_on_grouping_fields(sel); + } + /* We assume the result of any function that has a TIMESTAMP argument to be timezone-dependent, since a TIMESTAMP value in both numeric and string diff --git a/sql/item_row.h b/sql/item_row.h index 83ceb80a359..9c92e19caab 100644 --- a/sql/item_row.h +++ b/sql/item_row.h @@ -120,6 +120,16 @@ public: return this; } + bool excl_dep_on_table(table_map tab_map) + { + return Item_args::excl_dep_on_table(tab_map); + } + + bool excl_dep_on_grouping_fields(st_select_lex *sel) + { + return Item_args::excl_dep_on_grouping_fields(sel); + } + bool check_vcol_func_processor(void *arg) {return FALSE; } Item *get_copy(THD *thd, MEM_ROOT *mem_root) { return get_item_copy<Item_row>(thd, mem_root, this); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 9fab6c5e252..e272a0e4a7f 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -7108,10 +7108,13 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, split_sum_func() must be called for Window Function items, see Item_window_func::split_sum_func. */ - if ((item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM && - sum_func_list) || item->with_window_func) + if (sum_func_list && + ((item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) || + item->with_window_func)) + { item->split_sum_func(thd, ref_pointer_array, *sum_func_list, SPLIT_SUM_SELECT); + } thd->lex->current_select->select_list_tables|= item->used_tables(); thd->lex->used_tables|= item->used_tables(); thd->lex->current_select->cur_pos_in_select_list++; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 4fb36dd9573..c8426c02407 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -4609,26 +4609,47 @@ extern "C" const struct charset_info_st *thd_charset(MYSQL_THD thd) return(thd->charset()); } -/** - OBSOLETE : there's no way to ensure the string is null terminated. - Use thd_query_string instead() -*/ -extern "C" char **thd_query(MYSQL_THD thd) -{ - return (&thd->query_string.string.str); -} /** Get the current query string for the thread. + This function is not thread safe and can be used only by thd owner thread. + @param The MySQL internal thread pointer @return query string and length. May be non-null-terminated. */ extern "C" LEX_STRING * thd_query_string (MYSQL_THD thd) { + DBUG_ASSERT(thd == current_thd); return(&thd->query_string.string); } + +/** + Get the current query string for the thread. + + @param thd The MySQL internal thread pointer + @param buf Buffer where the query string will be copied + @param buflen Length of the buffer + + @return Length of the query + + @note This function is thread safe as the query string is + accessed under mutex protection and the string is copied + into the provided buffer. @see thd_query_string(). +*/ + +extern "C" size_t thd_query_safe(MYSQL_THD thd, char *buf, size_t buflen) +{ + mysql_mutex_lock(&thd->LOCK_thd_data); + size_t len= MY_MIN(buflen - 1, thd->query_length()); + memcpy(buf, thd->query(), len); + mysql_mutex_unlock(&thd->LOCK_thd_data); + buf[len]= '\0'; + return len; +} + + extern "C" int thd_slave_thread(const MYSQL_THD thd) { return(thd->slave_thread); diff --git a/sql/sql_class.h b/sql/sql_class.h index 02bfb5f402d..4f2819375c7 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -153,7 +153,7 @@ extern MYSQL_PLUGIN_IMPORT const char **errmesg; extern bool volatile shutdown_in_progress; extern "C" LEX_STRING * thd_query_string (MYSQL_THD thd); -extern "C" char **thd_query(MYSQL_THD thd); +extern "C" size_t thd_query_safe(MYSQL_THD thd, char *buf, size_t buflen); /** @class CSET_STRING @@ -183,7 +183,6 @@ public: CHARSET_INFO *charset() const { return cs; } friend LEX_STRING * thd_query_string (MYSQL_THD thd); - friend char **thd_query(MYSQL_THD thd); }; diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index cd8540eb072..96683095336 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -1247,7 +1247,7 @@ bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived) Item *cond_over_grouping_fields; sl->collect_grouping_fields(thd); sl->check_cond_extraction_for_grouping_fields(extracted_cond_copy, - &Item::exclusive_dependence_on_grouping_fields_processor); + derived); cond_over_grouping_fields= sl->build_cond_for_grouping_fields(thd, extracted_cond_copy, true); @@ -1286,7 +1286,8 @@ bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived) if (!extracted_cond_copy) continue; - extracted_cond_copy->walk(&Item::cleanup_processor, 0, 0); + extracted_cond_copy->walk(&Item::cleanup_excluding_const_fields_processor, + 0, 0); sl->cond_pushed_into_having= extracted_cond_copy; } thd->lex->current_select= save_curr_select; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index ef7ca58fe93..c0a48e6c154 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -6901,8 +6901,9 @@ void st_select_lex::collect_grouping_fields(THD *thd) from cond. */ -void st_select_lex::check_cond_extraction_for_grouping_fields(Item *cond, - Item_processor check_processor) +void +st_select_lex::check_cond_extraction_for_grouping_fields(Item *cond, + TABLE_LIST *derived) { cond->clear_extraction_flag(); if (cond->type() == Item::COND_ITEM) @@ -6915,7 +6916,7 @@ void st_select_lex::check_cond_extraction_for_grouping_fields(Item *cond, Item *item; while ((item=li++)) { - check_cond_extraction_for_grouping_fields(item, check_processor); + check_cond_extraction_for_grouping_fields(item, derived); if (item->get_extraction_flag() != NO_EXTRACTION_FL) { count++; @@ -6936,10 +6937,12 @@ void st_select_lex::check_cond_extraction_for_grouping_fields(Item *cond, item->clear_extraction_flag(); } } - else - cond->set_extraction_flag(cond->walk(check_processor, - 0, (uchar *) this) ? - NO_EXTRACTION_FL : FULL_EXTRACTION_FL); + else + { + int fl= cond->excl_dep_on_grouping_fields(this) ? + FULL_EXTRACTION_FL : NO_EXTRACTION_FL; + cond->set_extraction_flag(fl); + } } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 08a6936db6e..92a90c26303 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1196,7 +1196,7 @@ public: bool check_subqueries_with_recursive_references(); void collect_grouping_fields(THD *thd); void check_cond_extraction_for_grouping_fields(Item *cond, - Item_processor processor); + TABLE_LIST *derived); Item *build_cond_for_grouping_fields(THD *thd, Item *cond, bool no_to_clones); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index fbfbe0f77fb..c696a2daa25 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2799,6 +2799,7 @@ retry: ! table->prelocking_placeholder && table->table->file->lock_count() == 0) { + enum enum_mdl_type lock_type; /* In case when LOCK TABLE ... READ LOCAL was issued for table with storage engine which doesn't support READ LOCAL option and doesn't @@ -2811,9 +2812,12 @@ retry: deadlock_handler.init(); thd->push_internal_handler(&deadlock_handler); + lock_type= table->table->mdl_ticket->get_type() == MDL_SHARED_WRITE ? + MDL_SHARED_NO_READ_WRITE : MDL_SHARED_READ_ONLY; + bool result= thd->mdl_context.upgrade_shared_lock( table->table->mdl_ticket, - MDL_SHARED_READ_ONLY, + lock_type, thd->variables.lock_wait_timeout); thd->pop_internal_handler(); diff --git a/sql/table.cc b/sql/table.cc index 0a23d2f1f41..dcfb3edff33 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -8140,8 +8140,7 @@ void TABLE_LIST::check_pushable_cond_for_table(Item *cond) item->clear_extraction_flag(); } } - else if (cond->walk(&Item::exclusive_dependence_on_table_processor, - 0, (void *) &tab_map)) + else if (!cond->excl_dep_on_table(tab_map)) cond->set_extraction_flag(NO_EXTRACTION_FL); } diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 791939f32dd..60c1255e208 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -917,6 +917,15 @@ buf_flush_init_for_writing( case 1: reset_type = FIL_PAGE_IBUF_BITMAP; break; + case FSP_TRX_SYS_PAGE_NO: + if (block->page.id.page_no() + == TRX_SYS_PAGE_NO + && block->page.id.space() + == TRX_SYS_SPACE) { + reset_type = FIL_PAGE_TYPE_TRX_SYS; + break; + } + /* fall through */ default: switch (page_type) { case FIL_PAGE_INDEX: @@ -3124,12 +3133,6 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)( os_thread_create */ { my_thread_init(); - ulint next_loop_time = ut_time_ms() + 1000; - ulint n_flushed = 0; - ulint last_activity = srv_get_activity_count(); - ulint last_pages = 0; - - my_thread_init(); #ifdef UNIV_PFS_THREAD pfs_register_thread(page_cleaner_thread_key); #endif /* UNIV_PFS_THREAD */ @@ -3151,6 +3154,8 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)( " page cleaner thread priority can be changed." " See the man page of setpriority()."; } + /* Signal that setpriority() has been attempted. */ + os_event_set(recv_sys->flush_end); #endif /* UNIV_LINUX */ while (!srv_read_only_mode @@ -3194,12 +3199,16 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)( os_event_wait(buf_flush_event); - ulint ret_sleep = 0; - ulint n_evicted = 0; - ulint n_flushed_last = 0; - ulint warn_interval = 1; - ulint warn_count = 0; - int64_t sig_count = os_event_reset(buf_flush_event); + ulint ret_sleep = 0; + ulint n_evicted = 0; + ulint n_flushed_last = 0; + ulint warn_interval = 1; + ulint warn_count = 0; + int64_t sig_count = os_event_reset(buf_flush_event); + ulint next_loop_time = ut_time_ms() + 1000; + ulint n_flushed = 0; + ulint last_activity = srv_get_activity_count(); + ulint last_pages = 0; while (srv_shutdown_state == SRV_SHUTDOWN_NONE) { diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index 7cc1c876589..c0821d667ef 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -2505,6 +2505,7 @@ dict_create_or_check_sys_tablespace(void) << ". Dropping incompletely created tables."; ut_a(err == DB_OUT_OF_FILE_SPACE + || err == DB_DUPLICATE_KEY || err == DB_TOO_MANY_CONCURRENT_TRXS); row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE, TRUE); @@ -2532,11 +2533,11 @@ dict_create_or_check_sys_tablespace(void) sys_tablespaces_err = dict_check_if_system_table_exists( "SYS_TABLESPACES", DICT_NUM_FIELDS__SYS_TABLESPACES + 1, 1); - ut_a(sys_tablespaces_err == DB_SUCCESS); + ut_a(sys_tablespaces_err == DB_SUCCESS || err != DB_SUCCESS); sys_datafiles_err = dict_check_if_system_table_exists( "SYS_DATAFILES", DICT_NUM_FIELDS__SYS_DATAFILES + 1, 1); - ut_a(sys_datafiles_err == DB_SUCCESS); + ut_a(sys_datafiles_err == DB_SUCCESS || err != DB_SUCCESS); return(err); } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 4d1b40052dc..ebf8f38368b 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2386,22 +2386,7 @@ innobase_get_stmt_safe( char* buf, size_t buflen) { - LEX_STRING* stmt; - size_t length=0; - - ut_ad(buflen > 1); - - stmt = thd ? thd_query_string(thd) : NULL; - - if (stmt && stmt->str) { - length = stmt->length >= buflen ? buflen - 1 : stmt->length; - memcpy(buf, stmt->str, length); - buf[length]='\0'; - } else { - buf[0]='\0'; - } - - return (length); + return thd_query_safe(thd, buf, buflen); } /**********************************************************************//** diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 1eec22874d1..24bfb31b1fb 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -1011,6 +1011,7 @@ ha_innobase::check_if_supported_inplace_alter( constant DEFAULT expression. */ cf_it.rewind(); Field **af = altered_table->field; + while (Create_field* cf = cf_it++) { DBUG_ASSERT(cf->field || (ha_alter_info->handler_flags @@ -1018,49 +1019,71 @@ ha_innobase::check_if_supported_inplace_alter( if (const Field* f = cf->field) { /* This could be changing an existing column - from NULL to NOT NULL. For now, ensure that - the DEFAULT is a constant. */ - if (~ha_alter_info->handler_flags - & (Alter_inplace_info::ALTER_COLUMN_NOT_NULLABLE - | Alter_inplace_info::ALTER_COLUMN_DEFAULT) - || (*af)->real_maybe_null()) { - /* This ALTER TABLE is not both changing - a column to NOT NULL and changing the - DEFAULT value of a column, or this column - does allow NULL after the ALTER TABLE. */ - goto next_column; - } - - /* Find the matching column in the old table. */ - Field** fp; - for (fp = table->field; *fp; fp++) { - if (f != *fp) { - continue; + from NULL to NOT NULL. */ + switch ((*af)->type()) { + case MYSQL_TYPE_TIMESTAMP: + case MYSQL_TYPE_TIMESTAMP2: + /* Inserting NULL into a TIMESTAMP column + would cause the DEFAULT value to be + replaced. Ensure that the DEFAULT + expression is not changing during + ALTER TABLE. */ + if (!f->real_maybe_null() + || (*af)->real_maybe_null()) { + /* The column was NOT NULL, or it + will allow NULL after ALTER TABLE. */ + goto next_column; } - if (!f->real_maybe_null()) { - /* The column already is NOT NULL. */ + + if (!(*af)->default_value + && (*af)->is_real_null()) { + /* No DEFAULT value is + specified. We can report + errors for any NULL values for + the TIMESTAMP. + + FIXME: Allow any DEFAULT + expression whose value does + not change during ALTER TABLE. + This would require a fix in + row_merge_read_clustered_index() + to try to replace the DEFAULT + value before reporting + DB_INVALID_NULL. */ goto next_column; } break; + default: + /* For any other data type, NULL + values are not converted. + (An AUTO_INCREMENT attribute cannot + be introduced to a column with + ALGORITHM=INPLACE.) */ + ut_ad((MTYP_TYPENR((*af)->unireg_check) + == Field::NEXT_NUMBER) + == (MTYP_TYPENR(f->unireg_check) + == Field::NEXT_NUMBER)); + goto next_column; } - /* The column must be found in the old table. */ - DBUG_ASSERT(fp < &table->field[table->s->fields]); - } - - if (!(*af)->default_value - || (*af)->default_value->flags == 0) { - /* The NOT NULL column is not - carrying a non-constant DEFAULT. */ - goto next_column; - } - - /* TODO: Allow NULL column values to - be replaced with a non-constant DEFAULT. */ - if (cf->field) { ha_alter_info->unsupported_reason = innobase_get_err_msg( ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOT_NULL); + } else if (!(*af)->default_value + || !((*af)->default_value->flags + & ~(VCOL_SESSION_FUNC | VCOL_TIME_FUNC))) { + /* The added NOT NULL column lacks a DEFAULT value, + or the DEFAULT is the same for all rows. + (Time functions, such as CURRENT_TIMESTAMP(), + are evaluated from a timestamp that is assigned + at the start of the statement. Session + functions, such as USER(), always evaluate the + same within a statement.) */ + + /* Compute the DEFAULT values of non-constant columns + (VCOL_SESSION_FUNC | VCOL_TIME_FUNC). */ + (*af)->set_default(); + goto next_column; } DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED); @@ -4471,11 +4494,13 @@ prepare_inplace_alter_table_dict( || !innobase_fulltext_exist(altered_table))) { /* InnoDB can perform an online operation (LOCK=NONE). */ } else { + size_t query_length; /* This should have been blocked in check_if_supported_inplace_alter(). */ ut_ad(0); my_error(ER_NOT_SUPPORTED_YET, MYF(0), - thd_query(ctx->prebuilt->trx->mysql_thd)); + innobase_get_stmt_unsafe(ctx->prebuilt->trx->mysql_thd, + &query_length)); goto error_handled; } diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 6d314f09bb0..061fc25a55e 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -70,11 +70,6 @@ Created 9/17/2000 Heikki Tuuri #include <deque> #include <vector> -static const char* MODIFICATIONS_NOT_ALLOWED_MSG_FORCE_RECOVERY = - "innodb_force_recovery is on. We do not allow database modifications" - " by the user. Shut down mysqld and edit my.cnf to set" - " innodb_force_recovery=0"; - /** Provide optional 4.x backwards compatibility for 5.0 and above */ ibool row_rollback_on_timeout = FALSE; @@ -1432,9 +1427,7 @@ row_insert_for_mysql( } else if (!prebuilt->table->is_readable()) { return(row_mysql_get_table_status(prebuilt->table, trx, true)); - } else if (srv_force_recovery) { - - ib::error() << MODIFICATIONS_NOT_ALLOWED_MSG_FORCE_RECOVERY; + } else if (high_level_read_only) { return(DB_READ_ONLY); } DBUG_EXECUTE_IF("mark_table_corrupted", { @@ -1850,9 +1843,8 @@ row_update_for_mysql_using_upd_graph( return(row_mysql_get_table_status(table, trx, true)); } - if(srv_force_recovery) { - ib::error() << MODIFICATIONS_NOT_ALLOWED_MSG_FORCE_RECOVERY; - DBUG_RETURN(DB_READ_ONLY); + if (high_level_read_only) { + return(DB_READ_ONLY); } DEBUG_SYNC_C("innodb_row_update_for_mysql_begin"); @@ -4474,10 +4466,8 @@ row_rename_table_for_mysql( ut_a(new_name != NULL); ut_ad(trx->state == TRX_STATE_ACTIVE); - if (srv_force_recovery) { - ib::info() << MODIFICATIONS_NOT_ALLOWED_MSG_FORCE_RECOVERY; - err = DB_READ_ONLY; - goto funct_exit; + if (high_level_read_only) { + return(DB_READ_ONLY); } else if (row_mysql_is_system_table(new_name)) { diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 3fb54c1280b..7150fd2343e 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -1471,10 +1471,6 @@ innobase_start_or_create_for_mysql() srv_read_only_mode = true; } - if (srv_force_recovery == SRV_FORCE_NO_LOG_REDO) { - srv_read_only_mode = 1; - } - high_level_read_only = srv_read_only_mode || srv_force_recovery > SRV_FORCE_NO_TRX_UNDO; @@ -1865,6 +1861,10 @@ innobase_start_or_create_for_mysql() NULL, NULL); } +#ifdef UNIV_LINUX + /* Wait for the setpriority() call to finish. */ + os_event_wait(recv_sys->flush_end); +#endif /* UNIV_LINUX */ srv_start_state_set(SRV_START_STATE_IO); } @@ -2573,13 +2573,15 @@ files_checked: operations */ if (!srv_read_only_mode) { - thread_handles[1 + SRV_MAX_N_IO_THREADS] = os_thread_create( srv_master_thread, NULL, thread_ids + (1 + SRV_MAX_N_IO_THREADS)); thread_started[1 + SRV_MAX_N_IO_THREADS] = true; srv_start_state_set(SRV_START_STATE_MASTER); + } + if (!srv_read_only_mode + && srv_force_recovery < SRV_FORCE_NO_BACKGROUND) { srv_undo_sources = true; /* Create the dict stats gathering thread */ srv_dict_stats_thread_active = true; @@ -2588,10 +2590,6 @@ files_checked: /* Create the thread that will optimize the FTS sub-system. */ fts_optimize_init(); - } - - if (!srv_read_only_mode - && srv_force_recovery < SRV_FORCE_NO_BACKGROUND) { thread_handles[5 + SRV_MAX_N_IO_THREADS] = os_thread_create( srv_purge_coordinator_thread, diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index e317a38815b..317087173c5 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -285,6 +285,12 @@ trx_purge_add_update_undo_to_history( purge have been started, recv_recovery_rollback_active() can start transactions in row_merge_drop_temp_indexes() and fts_drop_orphaned_tables(), and roll back recovered transactions. + + Arbitrary user transactions may be executed when all the undo log + related background processes (including purge) are disabled due to + innodb_force_recovery=2 or innodb_force_recovery=3. + DROP TABLE may be executed at any innodb_force_recovery level. + After the purge thread has been given permission to exit, in fast shutdown, we may roll back transactions (trx->undo_no==0) in THD::cleanup() invoked from unlink_thd(). */ @@ -292,6 +298,8 @@ trx_purge_add_update_undo_to_history( || ((srv_startup_is_before_trx_rollback_phase || trx_rollback_or_clean_is_active) && purge_sys->state == PURGE_STATE_INIT) + || (srv_force_recovery >= SRV_FORCE_NO_BACKGROUND + && purge_sys->state == PURGE_STATE_DISABLED) || (trx->undo_no == 0 && srv_fast_shutdown)); /* Add the log as the first in the history list */ diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index ff99900b5b9..e3f3ba81016 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -323,7 +323,6 @@ trx_sys_read_wsrep_checkpoint( long long seqno= -1; memcpy(xid->data + 24, &seqno, sizeof(long long)); xid->formatID = -1; - trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr); mtr_commit(&mtr); return; } diff --git a/storage/rocksdb/mysql-test/storage_engine/cache_index.rdiff b/storage/rocksdb/mysql-test/storage_engine/cache_index.rdiff new file mode 100644 index 00000000000..76e7705e377 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/cache_index.rdiff @@ -0,0 +1,71 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/cache_index.result 2017-06-22 00:33:46.419995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/cache_index.reject 2017-06-22 01:11:22.479981459 +0300 +@@ -12,31 +12,31 @@ + SET GLOBAL <CACHE_NAME>.key_buffer_size=128*1024; + CACHE INDEX t1 INDEX (a), t2 IN <CACHE_NAME>; + Table Op Msg_type Msg_text +-test.t1 assign_to_keycache status OK +-test.t2 assign_to_keycache status OK ++test.t1 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache ++test.t2 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache + LOAD INDEX INTO CACHE t1, t2; + Table Op Msg_type Msg_text +-test.t1 preload_keys status OK +-test.t2 preload_keys status OK ++test.t1 preload_keys note The storage engine for the table doesn't support preload_keys ++test.t2 preload_keys note The storage engine for the table doesn't support preload_keys + INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d'); + SET GLOBAL <CACHE_NAME>.key_buffer_size=8*1024; + LOAD INDEX INTO CACHE t1, t2 IGNORE LEAVES; + Table Op Msg_type Msg_text +-test.t1 preload_keys status OK +-test.t2 preload_keys status OK ++test.t1 preload_keys note The storage engine for the table doesn't support preload_keys ++test.t2 preload_keys note The storage engine for the table doesn't support preload_keys + SET GLOBAL <CACHE_NAME>.key_cache_age_threshold = 100, <CACHE_NAME>.key_cache_block_size = 512, <CACHE_NAME>.key_cache_division_limit = 1, <CACHE_NAME>.key_cache_segments=2; + INSERT INTO t1 (a,b) VALUES (5,'e'),(6,'f'); + LOAD INDEX INTO CACHE t1; + Table Op Msg_type Msg_text +-test.t1 preload_keys status OK ++test.t1 preload_keys note The storage engine for the table doesn't support preload_keys + SET GLOBAL new_<CACHE_NAME>.key_buffer_size=128*1024; + CACHE INDEX t1 IN new_<CACHE_NAME>; + Table Op Msg_type Msg_text +-test.t1 assign_to_keycache status OK ++test.t1 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache + INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h'); + LOAD INDEX INTO CACHE t1 IGNORE LEAVES; + Table Op Msg_type Msg_text +-test.t1 preload_keys status OK ++test.t1 preload_keys note The storage engine for the table doesn't support preload_keys + INSERT INTO t1 (a,b) VALUES (9,'i'); + DROP TABLE t2; + DROP TABLE t1; +@@ -47,11 +47,11 @@ + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + CACHE INDEX t1 IN <CACHE_NAME>; + Table Op Msg_type Msg_text +-test.t1 assign_to_keycache status OK ++test.t1 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache + INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'); + LOAD INDEX INTO CACHE t1; + Table Op Msg_type Msg_text +-test.t1 preload_keys status OK ++test.t1 preload_keys note The storage engine for the table doesn't support preload_keys + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, + b <CHAR_COLUMN>, +@@ -59,11 +59,11 @@ + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + CACHE INDEX t1 IN <CACHE_NAME>; + Table Op Msg_type Msg_text +-test.t1 assign_to_keycache status OK ++test.t1 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache + INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'); + LOAD INDEX INTO CACHE t1; + Table Op Msg_type Msg_text +-test.t1 preload_keys status OK ++test.t1 preload_keys note The storage engine for the table doesn't support preload_keys + DROP TABLE t1; + SET GLOBAL <CACHE_NAME>.key_buffer_size=0; + SET GLOBAL new_<CACHE_NAME>.key_buffer_size=0; diff --git a/storage/rocksdb/mysql-test/storage_engine/checksum_table_live.rdiff b/storage/rocksdb/mysql-test/storage_engine/checksum_table_live.rdiff new file mode 100644 index 00000000000..094136ee926 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/checksum_table_live.rdiff @@ -0,0 +1,13 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/checksum_table_live.result 2017-06-22 00:33:46.419995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/checksum_table_live.reject 2017-06-22 01:12:38.695980980 +0300 +@@ -11,8 +11,8 @@ + test.t1 4272806499 + CHECKSUM TABLE t1, t2 QUICK; + Table Checksum +-test.t1 4272806499 +-test.t2 0 ++test.t1 NULL ++test.t2 NULL + CHECKSUM TABLE t1, t2 EXTENDED; + Table Checksum + test.t1 4272806499 diff --git a/storage/rocksdb/mysql-test/storage_engine/cleanup_engine.inc b/storage/rocksdb/mysql-test/storage_engine/cleanup_engine.inc new file mode 100644 index 00000000000..4f6c586172d --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/cleanup_engine.inc @@ -0,0 +1,25 @@ +########################################### +# +# This is a stub of the include file cleanup_engine.inc which +# should be placed in storage/<engine>/mysql-test/storage_engine folder. +# +################################ +# +# Here you can add whatever is needed to cleanup +# in case your define_engine.inc created any artefacts, +# e.g. an additional schema and/or tables. + +--let $datadir= `SELECT @@datadir` + +--error 0,1 +--file_exists $datadir/.rocksdb/* +if (!$mysql_errno) +{ + --enable_reconnect + --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + --shutdown_server + --source include/wait_until_disconnected.inc + --rmdir $datadir/.rocksdb + --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + --source include/wait_until_connected_again.inc +} diff --git a/storage/rocksdb/mysql-test/storage_engine/define_engine.inc b/storage/rocksdb/mysql-test/storage_engine/define_engine.inc new file mode 100644 index 00000000000..1c77a6b6bb6 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/define_engine.inc @@ -0,0 +1,45 @@ +########################################### +# +# This is a template of the include file define_engine.inc which +# should be placed in storage/<engine>/mysql-test/storage_engine folder. +# +################################ +# +# The name of the engine under test must be defined in $ENGINE variable. +# You can set it either here (uncomment and edit) or in your environment. +# +let $ENGINE = RocksDB; +# +################################ +# +# The following three variables define specific options for columns and tables. +# Normally there should be none needed, but for some engines it can be different. +# If the engine requires specific column option for all or indexed columns, +# set them inside the comment, e.g. /*!NOT NULL*/. +# Do the same for table options if needed, e.g. /*!INSERT_METHOD=LAST*/ + +let $default_col_opts = /*!*/; +let $default_col_indexed_opts = /*!*/; +let $default_tbl_opts = /*!*/; + +# INDEX, UNIQUE INDEX, PRIMARY KEY, special index type - choose the fist that the engine allows, +# or set it to /*!*/ if none is supported + +let $default_index = /*!INDEX*/; + +# If the engine does not support the following types, replace them with the closest possible + +let $default_int_type = INT(11); +let $default_char_type = CHAR(8); + +################################ + +--disable_query_log +--disable_result_log + +# Here you can place your custom MTR code which needs to be executed before each test, +# e.g. creation of an additional schema or table, etc. +# The cleanup part should be defined in cleanup_engine.inc + +--enable_query_log +--enable_result_log diff --git a/storage/rocksdb/mysql-test/storage_engine/disabled.def b/storage/rocksdb/mysql-test/storage_engine/disabled.def new file mode 100644 index 00000000000..0643b2052e2 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/disabled.def @@ -0,0 +1,25 @@ +alter_tablespace : Not supported +autoinc_secondary : Not supported +create_table : MDEV-12914 - Engine for temporary tables which are implicitly created as RocksDB is substituted silently +delete_low_prio : Not supported +foreign_keys : Not supported +fulltext_search : Not supported +handler : Not supported +index_enable_disable : Not supported +insert_delayed : Not supported +insert_high_prio : Not supported +insert_low_prio : Not supported +lock : MDEV-13148 - LOCK TABLE on RocksDB table fails with a bogus error message +lock_concurrent : MDEV-13148 - LOCK TABLE on RocksDB table fails with a bogus error message +optimize_table : MDEV-13148 - LOCK TABLE on RocksDB table fails with a bogus error message +repair_table : MDEV-13148 - LOCK TABLE on RocksDB table fails with a bogus error message +select_high_prio : Not supported +show_table_status : MDEV-13152 - Indeterministic row number in SHOW TABLE STATUS on RocksDB table +tbl_opt_data_dir : Not supported +tbl_opt_index_dir : Not supported +type_spatial : Not supported +type_spatial_indexes : Not supported +update_low_prio : Not supported +update_ignore : MDEV-13151 - Indeterministic results of multi-table update on RocksDB tables +update_multi : MDEV-13151 - Indeterministic results of multi-table update on RocksDB tables +vcol : Not supported diff --git a/storage/rocksdb/mysql-test/storage_engine/index.rdiff b/storage/rocksdb/mysql-test/storage_engine/index.rdiff new file mode 100644 index 00000000000..ed22a308726 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/index.rdiff @@ -0,0 +1,98 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/index.result 2017-06-22 00:33:46.419995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/index.reject 2017-06-22 13:55:28.615693291 +0300 +@@ -4,7 +4,7 @@ + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + SHOW KEYS IN t1; + Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 1 a 1 a # # NULL NULL # BTREE ++t1 1 a 1 a # # NULL NULL # LSMTREE + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, + b <CHAR_COLUMN>, +@@ -12,8 +12,8 @@ + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + SHOW KEYS IN t1; + Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 1 a_b 1 a # # NULL NULL # BTREE a_b index +-t1 1 a_b 2 b # # NULL NULL # BTREE a_b index ++t1 1 a_b 1 a # # NULL NULL # LSMTREE a_b index ++t1 1 a_b 2 b # # NULL NULL # LSMTREE a_b index + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, + b <CHAR_COLUMN>, +@@ -22,46 +22,48 @@ + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + SHOW KEYS IN t1; + Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 1 a 1 a # # NULL NULL # BTREE +-t1 1 b 1 b # # NULL NULL # BTREE ++t1 1 a 1 a # # NULL NULL # LSMTREE ++t1 1 b 1 b # # NULL NULL # LSMTREE + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, + b <CHAR_COLUMN>, + UNIQUE INDEX (a) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW KEYS IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 a 1 a # # NULL NULL # BTREE +-INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'); +-INSERT INTO t1 (a,b) VALUES (1,'c'); +-ERROR 23000: Duplicate entry '1' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a INT(11) /*!*/ /*Custom indexed column options*/, ++b CHAR(8) /*!*/ /*Custom column options*/, ++UNIQUE INDEX (a) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Unique indexes or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + INSERT INTO t1 (a,b) VALUES (100,'z'); + ALTER TABLE t1 ADD <CUSTOM_INDEX> (a) COMMENT 'simple index on a'; + SHOW INDEX FROM t1; + Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 1 a 1 a # # NULL NULL # BTREE simple index on a ++t1 1 a 1 a # # NULL NULL # LSMTREE simple index on a + ALTER TABLE t1 DROP KEY a; + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, + b <CHAR_COLUMN>, + UNIQUE INDEX (a) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW KEYS IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 a 1 a # # NULL NULL # BTREE +-INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'); +-INSERT INTO t1 (a,b) VALUES (1,'c'); +-ERROR 23000: Duplicate entry '1' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-ALTER TABLE t1 DROP INDEX a; +-INSERT INTO t1 (a,b) VALUES (1,'c'); +-ALTER TABLE t1 ADD UNIQUE INDEX a(a) ; +-ERROR 23000: Duplicate entry '1' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a INT(11) /*!*/ /*Custom indexed column options*/, ++b CHAR(8) /*!*/ /*Custom column options*/, ++UNIQUE INDEX (a) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Unique indexes or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- diff --git a/storage/rocksdb/mysql-test/storage_engine/index_key_block_size.rdiff b/storage/rocksdb/mysql-test/storage_engine/index_key_block_size.rdiff new file mode 100644 index 00000000000..5038a10b836 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/index_key_block_size.rdiff @@ -0,0 +1,26 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/index_key_block_size.result 2017-06-22 00:33:46.419995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/index_key_block_size.reject 2017-06-22 13:56:59.503692719 +0300 +@@ -19,10 +19,19 @@ + b <CHAR_COLUMN>, + UNIQUE INDEX ind2(b(1) DESC) KEY_BLOCK_SIZE=32768 COMMENT 'big key_block_size value' + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW INDEX IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 ind2 1 b # # 1 NULL # # big key_block_size value +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a INT(11) /*!*/ /*Custom column options*/, ++b CHAR(8) /*!*/ /*Custom indexed column options*/, ++UNIQUE INDEX ind2(b(1) DESC) KEY_BLOCK_SIZE=32768 COMMENT 'big key_block_size value' ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Unique keys on char columns or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (a <INT_COLUMN>, + b <CHAR_COLUMN>, + <CUSTOM_INDEX> a_b(a,b) KEY_BLOCK_SIZE=8192 diff --git a/storage/rocksdb/mysql-test/storage_engine/index_type_btree.rdiff b/storage/rocksdb/mysql-test/storage_engine/index_type_btree.rdiff new file mode 100644 index 00000000000..2f1ebe55537 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/index_type_btree.rdiff @@ -0,0 +1,98 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/index_type_btree.result 2017-06-22 00:33:46.419995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/index_type_btree.reject 2017-06-22 13:58:02.359692324 +0300 +@@ -4,7 +4,7 @@ + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + SHOW KEYS IN t1; + Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 1 a 1 a # # NULL NULL # BTREE ++t1 1 a 1 a # # NULL NULL # LSMTREE + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, + b <CHAR_COLUMN>, +@@ -12,8 +12,8 @@ + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + SHOW KEYS IN t1; + Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 1 a_b 1 a # # NULL NULL # BTREE a_b index +-t1 1 a_b 2 b # # NULL NULL # BTREE a_b index ++t1 1 a_b 1 a # # NULL NULL # LSMTREE a_b index ++t1 1 a_b 2 b # # NULL NULL # LSMTREE a_b index + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, + b <CHAR_COLUMN>, +@@ -22,46 +22,48 @@ + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + SHOW KEYS IN t1; + Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 1 a 1 a # # NULL NULL # BTREE +-t1 1 b 1 b # # NULL NULL # BTREE ++t1 1 a 1 a # # NULL NULL # LSMTREE ++t1 1 b 1 b # # NULL NULL # LSMTREE + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, + b <CHAR_COLUMN>, + UNIQUE INDEX USING BTREE (a) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW KEYS IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 a 1 a # # NULL NULL # BTREE +-INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'); +-INSERT INTO t1 (a,b) VALUES (1,'c'); +-ERROR 23000: Duplicate entry '1' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a INT(11) /*!*/ /*Custom indexed column options*/, ++b CHAR(8) /*!*/ /*Custom column options*/, ++UNIQUE INDEX USING BTREE (a) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Unique indexes or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + INSERT INTO t1 (a,b) VALUES (100,'z'); + ALTER TABLE t1 ADD <CUSTOM_INDEX> (a) USING BTREE COMMENT 'simple index on a'; + SHOW INDEX FROM t1; + Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 1 a 1 a # # NULL NULL # BTREE simple index on a ++t1 1 a 1 a # # NULL NULL # LSMTREE simple index on a + ALTER TABLE t1 DROP KEY a; + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, + b <CHAR_COLUMN>, + UNIQUE INDEX USING BTREE (a) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW KEYS IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 a 1 a # # NULL NULL # BTREE +-INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'); +-INSERT INTO t1 (a,b) VALUES (1,'c'); +-ERROR 23000: Duplicate entry '1' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-ALTER TABLE t1 DROP INDEX a; +-INSERT INTO t1 (a,b) VALUES (1,'c'); +-ALTER TABLE t1 ADD UNIQUE INDEX a(a) USING BTREE; +-ERROR 23000: Duplicate entry '1' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a INT(11) /*!*/ /*Custom indexed column options*/, ++b CHAR(8) /*!*/ /*Custom column options*/, ++UNIQUE INDEX USING BTREE (a) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Unique indexes or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- diff --git a/storage/rocksdb/mysql-test/storage_engine/index_type_hash.rdiff b/storage/rocksdb/mysql-test/storage_engine/index_type_hash.rdiff new file mode 100644 index 00000000000..7dad7b11deb --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/index_type_hash.rdiff @@ -0,0 +1,98 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/index_type_hash.result 2017-06-22 00:33:46.419995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/index_type_hash.reject 2017-06-22 14:00:42.867691315 +0300 +@@ -4,7 +4,7 @@ + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + SHOW KEYS IN t1; + Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 1 a 1 a # # NULL NULL # HASH ++t1 1 a 1 a # # NULL NULL # LSMTREE + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, + b <CHAR_COLUMN>, +@@ -12,8 +12,8 @@ + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + SHOW KEYS IN t1; + Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 1 a_b 1 a # # NULL NULL # HASH a_b index +-t1 1 a_b 2 b # # NULL NULL # HASH a_b index ++t1 1 a_b 1 a # # NULL NULL # LSMTREE a_b index ++t1 1 a_b 2 b # # NULL NULL # LSMTREE a_b index + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, + b <CHAR_COLUMN>, +@@ -22,46 +22,48 @@ + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + SHOW KEYS IN t1; + Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 1 a 1 a # # NULL NULL # HASH +-t1 1 b 1 b # # NULL NULL # HASH ++t1 1 a 1 a # # NULL NULL # LSMTREE ++t1 1 b 1 b # # NULL NULL # LSMTREE + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, + b <CHAR_COLUMN>, + UNIQUE INDEX USING HASH (a) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW KEYS IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 a 1 a # # NULL NULL # HASH +-INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'); +-INSERT INTO t1 (a,b) VALUES (1,'c'); +-ERROR 23000: Duplicate entry '1' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a INT(11) /*!*/ /*Custom indexed column options*/, ++b CHAR(8) /*!*/ /*Custom column options*/, ++UNIQUE INDEX USING HASH (a) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Unique indexes or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + INSERT INTO t1 (a,b) VALUES (100,'z'); + ALTER TABLE t1 ADD <CUSTOM_INDEX> (a) USING HASH COMMENT 'simple index on a'; + SHOW INDEX FROM t1; + Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 1 a 1 a # # NULL NULL # HASH simple index on a ++t1 1 a 1 a # # NULL NULL # LSMTREE simple index on a + ALTER TABLE t1 DROP KEY a; + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, + b <CHAR_COLUMN>, + UNIQUE INDEX USING HASH (a) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW KEYS IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 a 1 a # # NULL NULL # HASH +-INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'); +-INSERT INTO t1 (a,b) VALUES (1,'c'); +-ERROR 23000: Duplicate entry '1' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-ALTER TABLE t1 DROP INDEX a; +-INSERT INTO t1 (a,b) VALUES (1,'c'); +-ALTER TABLE t1 ADD UNIQUE INDEX a(a) USING HASH; +-ERROR 23000: Duplicate entry '1' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a INT(11) /*!*/ /*Custom indexed column options*/, ++b CHAR(8) /*!*/ /*Custom column options*/, ++UNIQUE INDEX USING HASH (a) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Unique indexes or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- diff --git a/storage/rocksdb/mysql-test/storage_engine/insert_with_keys.rdiff b/storage/rocksdb/mysql-test/storage_engine/insert_with_keys.rdiff new file mode 100644 index 00000000000..04313e11e7c --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/insert_with_keys.rdiff @@ -0,0 +1,148 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/insert_with_keys.result 2017-06-22 00:33:46.419995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/insert_with_keys.reject 2017-06-22 14:01:57.539690846 +0300 +@@ -22,93 +22,27 @@ + 6 f + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, UNIQUE INDEX(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'); +-INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f'); +-INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n'); +-INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z'); +-ERROR 23000: Duplicate entry '1' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-INSERT INTO t1 (a,b) VALUES (3,'a'),(0,''); +-ERROR 23000: Duplicate entry '3' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-INSERT INTO t1 (a,b) VALUES (0,''); +-SELECT a,b FROM t1; +-a b +-0 +-1 a +-100 a +-2 b +-29 n +-3 c +-30 m +-4 d +-5 e +-6 f +-INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z'); +-Warnings: +-Warning 1062 Duplicate entry '1' for key 'a' +-INSERT INTO t1 (a,b) VALUES (3,'a'),(4,'d') ON DUPLICATE KEY UPDATE a = a+10; +-SELECT a,b FROM t1; +-a b +-0 +-1 a +-100 a +-12345 z +-13 c +-14 d +-2 b +-29 n +-30 m +-5 e +-6 f +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a INT(11) /*!*/ /*Custom indexed column options*/, b CHAR(8) /*!*/ /*Custom column options*/, UNIQUE INDEX(a)) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Unique indexes or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, UNIQUE INDEX(a,b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'); +-INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f'); +-INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n'); +-INSERT INTO t1 (a,b) VALUES (100,'b'), (2,'c'); +-INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z'); +-ERROR 23000: Duplicate entry '1-a' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-SELECT a,b FROM t1; +-a b +-1 a +-100 a +-100 b +-2 b +-2 c +-29 n +-3 c +-30 m +-4 d +-5 e +-6 f +-INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z'); +-Warnings: +-Warning 1062 Duplicate entry '1-a' for key 'a' +-INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z') ON DUPLICATE KEY UPDATE a = a+VALUES(a); +-SELECT a,b FROM t1; +-a b +-100 a +-100 b +-2 a +-2 b +-2 c +-24690 z +-29 n +-3 c +-30 m +-4 d +-5 e +-6 f +-INSERT INTO t1 (a,b) VALUES (101,'x'),(101,'x'); +-ERROR 23000: Duplicate entry '101-x' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a INT(11) /*!*/ /*Custom indexed column options*/, b CHAR(8) /*!*/ /*Custom indexed column options*/, UNIQUE INDEX(a,b)) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Multi-part indexes or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (a <INT_COLUMN> PRIMARY KEY, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'); + INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f'); +@@ -153,21 +87,13 @@ + 6 f + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN> UNIQUE KEY, b <INT_COLUMN> UNIQUE KEY, c <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-INSERT INTO t1 VALUES(1,1,0); +-INSERT INTO t1 VALUES(2,3,0); +-INSERT INTO t1 VALUES(3,2,0); +-INSERT INTO t1 VALUES(1,1,0) ON DUPLICATE KEY UPDATE c=c+1; +-INSERT INTO t1 VALUES(2,3,0) ON DUPLICATE KEY UPDATE c=c+1; +-INSERT INTO t1 VALUES(3,2,0) ON DUPLICATE KEY UPDATE c=c+1; +-INSERT INTO t1 VALUES(2,5,0) ON DUPLICATE KEY UPDATE c=c+1; +-INSERT INTO t1 VALUES(3,5,0) ON DUPLICATE KEY UPDATE c=c+1; +-INSERT INTO t1 VALUES(5,3,0) ON DUPLICATE KEY UPDATE c=c+1; +-INSERT INTO t1 VALUES(6,2,0) ON DUPLICATE KEY UPDATE c=c+1; +-INSERT INTO t1 VALUES(1,3,0) ON DUPLICATE KEY UPDATE c=c+1; +-INSERT INTO t1 VALUES(2,2,0) ON DUPLICATE KEY UPDATE c=c+1; +-SELECT * FROM t1; +-a b c +-1 1 2 +-2 3 4 +-3 2 3 +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a INT(11) /*!*/ /*Custom indexed column options*/ UNIQUE KEY, b INT(11) /*!*/ /*Custom indexed column options*/ UNIQUE KEY, c INT(11) /*!*/ /*Custom column options*/) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Multiple unique keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- diff --git a/storage/rocksdb/mysql-test/storage_engine/mask_engine.inc b/storage/rocksdb/mysql-test/storage_engine/mask_engine.inc new file mode 100644 index 00000000000..fc6cd02e3ef --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/mask_engine.inc @@ -0,0 +1,15 @@ +# +# This include file just replaces the storage engine under test by the generic string <STORAGE_ENGINE> +# in the next statement. More masks can be added by defining $add_regex, e.g. +# let $add_regex = /$data_dir/<DATA_DIR>/ /$index_dir/<INDEX_DIR>/ +# + +--let $regex = /$storage_engine/<STORAGE_ENGINE>/i / COLLATE[= ]latin1_bin// +if ($add_regex) +{ + --let $regex = $regex $add_regex +} + +--let $add_regex = +--replace_regex $regex + diff --git a/storage/rocksdb/mysql-test/storage_engine/misc.rdiff b/storage/rocksdb/mysql-test/storage_engine/misc.rdiff new file mode 100644 index 00000000000..694f3f54815 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/misc.rdiff @@ -0,0 +1,25 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/misc.result 2017-06-22 00:33:46.419995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/misc.reject 2017-06-22 02:34:23.647950149 +0300 +@@ -28,6 +28,9 @@ + SELECT TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME + FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE ORDER BY TABLE_NAME; + TABLE_NAME COLUMN_NAME REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME ++Warning 1286 Unknown storage engine 'InnoDB' ++Warning 1286 Unknown storage engine 'InnoDB' ++Warnings: + column_stats column_name NULL NULL + column_stats db_name NULL NULL + column_stats table_name NULL NULL +@@ -58,12 +61,6 @@ + index_stats index_name NULL NULL + index_stats prefix_arity NULL NULL + index_stats table_name NULL NULL +-innodb_index_stats database_name NULL NULL +-innodb_index_stats index_name NULL NULL +-innodb_index_stats stat_name NULL NULL +-innodb_index_stats table_name NULL NULL +-innodb_table_stats database_name NULL NULL +-innodb_table_stats table_name NULL NULL + plugin name NULL NULL + proc db NULL NULL + proc name NULL NULL diff --git a/storage/rocksdb/mysql-test/storage_engine/parts/checksum_table.rdiff b/storage/rocksdb/mysql-test/storage_engine/parts/checksum_table.rdiff new file mode 100644 index 00000000000..bf3347a4341 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/parts/checksum_table.rdiff @@ -0,0 +1,13 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/parts/checksum_table.result 2017-06-22 00:33:46.419995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/parts/checksum_table.reject 2017-06-22 19:25:02.935568998 +0300 +@@ -31,8 +31,8 @@ + test.t1 4272806499 + CHECKSUM TABLE t1, t2 QUICK; + Table Checksum +-test.t1 4272806499 +-test.t2 0 ++test.t1 NULL ++test.t2 NULL + CHECKSUM TABLE t1, t2 EXTENDED; + Table Checksum + test.t1 4272806499 diff --git a/storage/rocksdb/mysql-test/storage_engine/parts/create_table.rdiff b/storage/rocksdb/mysql-test/storage_engine/parts/create_table.rdiff new file mode 100644 index 00000000000..b2cb47a0927 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/parts/create_table.rdiff @@ -0,0 +1,20 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/parts/create_table.result 2017-06-22 00:33:46.419995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/parts/create_table.reject 2017-06-22 19:25:05.335568983 +0300 +@@ -65,7 +65,7 @@ + 1 SIMPLE t1 abc,def # # # # # # # + EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a = 100; + id select_type table partitions type possible_keys key key_len ref rows Extra +-1 SIMPLE NULL NULL # # # # # # # ++1 SIMPLE t1 def # # # # # # # + INSERT INTO t1 (a) VALUES (50); + ERROR HY000: Table has no partition for value 50 + DROP TABLE t1; +@@ -81,7 +81,7 @@ + 1 SIMPLE t1 abc_abcsp0,def_defsp0 # # # # # # # + EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a = 100; + id select_type table partitions type possible_keys key key_len ref rows Extra +-1 SIMPLE NULL NULL # # # # # # # ++1 SIMPLE t1 def_defsp0 # # # # # # # + SELECT TABLE_SCHEMA, TABLE_NAME, PARTITION_NAME, SUBPARTITION_NAME, PARTITION_METHOD, SUBPARTITION_METHOD + FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 't1'; + TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_METHOD SUBPARTITION_METHOD diff --git a/storage/rocksdb/mysql-test/storage_engine/parts/disabled.def b/storage/rocksdb/mysql-test/storage_engine/parts/disabled.def new file mode 100644 index 00000000000..ef8ad5b3c82 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/parts/disabled.def @@ -0,0 +1,3 @@ +alter_table : MDEV-13153 - Assertion `global_status_var.global_memory_used == 0' +optimize_table : MDEV-13148 - LOCK TABLE on RocksDB table fails with a bogus error message +repair_table : MDEV-13148 - LOCK TABLE on RocksDB table fails with a bogus error message diff --git a/storage/rocksdb/mysql-test/storage_engine/parts/suite.opt b/storage/rocksdb/mysql-test/storage_engine/parts/suite.opt new file mode 100644 index 00000000000..713e46dcddb --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/parts/suite.opt @@ -0,0 +1 @@ +--ignore-db-dirs=.rocksdb --plugin-load=$HA_ROCKSDB_SO --binlog_format=ROW diff --git a/storage/rocksdb/mysql-test/storage_engine/replace.rdiff b/storage/rocksdb/mysql-test/storage_engine/replace.rdiff new file mode 100644 index 00000000000..632c52f1504 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/replace.rdiff @@ -0,0 +1,31 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/replace.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/replace.reject 2017-06-22 14:03:14.971690359 +0300 +@@ -20,18 +20,16 @@ + 5 e + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, UNIQUE INDEX (a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'); +-INSERT INTO t1 (a,b) VALUES (2,'d'); +-ERROR 23000: Duplicate entry '2' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-REPLACE INTO t1 (a,b) VALUES (2,'d'); +-SELECT a,b FROM t1; +-a b +-1 a +-2 d +-3 c +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a INT(11) /*!*/ /*Custom indexed column options*/, b CHAR(8) /*!*/ /*Custom column options*/, UNIQUE INDEX (a)) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Unique keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, PRIMARY KEY (b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'); + INSERT INTO t1 (a,b) VALUES (4,'b'); diff --git a/storage/rocksdb/mysql-test/storage_engine/show_engine.rdiff b/storage/rocksdb/mysql-test/storage_engine/show_engine.rdiff new file mode 100644 index 00000000000..77cc8b0b05e --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/show_engine.rdiff @@ -0,0 +1,14 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/show_engine.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/show_engine.reject 2017-06-22 15:24:52.547659575 +0300 +@@ -4,7 +4,10 @@ + # volatile data (timestamps, memory info, etc.) + SHOW ENGINE <STORAGE_ENGINE> STATUS; + Type Name Status +-<STORAGE_ENGINE> ### Engine status, can be long and changeable ### ++DBSTATS <STORAGE_ENGINE> ### Engine status, can be long and changeable ### ++CF_COMPACTION __system__ ### Engine status, can be long and changeable ### ++CF_COMPACTION default ### Engine status, can be long and changeable ### ++Memory_Stats <STORAGE_ENGINE> ### Engine status, can be long and changeable ### + # For SHOW MUTEX even the number of lines is volatile, so the result logging is disabled, + # the test only checks that the command does not produce any errors + SHOW ENGINE <STORAGE_ENGINE> MUTEX; diff --git a/storage/rocksdb/mysql-test/storage_engine/show_table_status.rdiff b/storage/rocksdb/mysql-test/storage_engine/show_table_status.rdiff new file mode 100644 index 00000000000..d7252eb54ed --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/show_table_status.rdiff @@ -0,0 +1,20 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/show_table_status.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/show_table_status.reject 2017-06-22 14:04:10.723690009 +0300 +@@ -19,7 +19,7 @@ + Create_time ### + Update_time ### + Check_time NULL +-Collation latin1_swedish_ci ++Collation latin1_bin + Checksum NULL + Create_options + Comment +@@ -37,7 +37,7 @@ + Create_time ### + Update_time ### + Check_time NULL +-Collation latin1_swedish_ci ++Collation latin1_bin + Checksum NULL + Create_options + Comment diff --git a/storage/rocksdb/mysql-test/storage_engine/suite.opt b/storage/rocksdb/mysql-test/storage_engine/suite.opt new file mode 100644 index 00000000000..41beb675cc1 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/suite.opt @@ -0,0 +1 @@ +--ignore-db-dirs=.rocksdb --plugin-load=$HA_ROCKSDB_SO --binlog_format=ROW --collation-server=latin1_bin diff --git a/storage/rocksdb/mysql-test/storage_engine/tbl_opt_insert_method.rdiff b/storage/rocksdb/mysql-test/storage_engine/tbl_opt_insert_method.rdiff new file mode 100644 index 00000000000..20f594fbb40 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/tbl_opt_insert_method.rdiff @@ -0,0 +1,11 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/tbl_opt_insert_method.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/tbl_opt_insert_method.reject 2017-06-22 02:39:45.243948128 +0300 +@@ -5,7 +5,7 @@ + t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` char(8) DEFAULT NULL +-) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 INSERT_METHOD=FIRST ++) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 + ALTER TABLE t1 INSERT_METHOD=NO; + SHOW CREATE TABLE t1; + Table Create Table diff --git a/storage/rocksdb/mysql-test/storage_engine/tbl_opt_union.rdiff b/storage/rocksdb/mysql-test/storage_engine/tbl_opt_union.rdiff new file mode 100644 index 00000000000..0d65ad0744a --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/tbl_opt_union.rdiff @@ -0,0 +1,16 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/tbl_opt_union.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/tbl_opt_union.reject 2017-06-22 02:41:02.719947641 +0300 +@@ -4,11 +4,11 @@ + Table Create Table + t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +-) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 UNION=(`child1`) ++) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 + ALTER TABLE t1 UNION = (child1,child2); + SHOW CREATE TABLE t1; + Table Create Table + t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +-) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 UNION=(`child1`,`child2`) ++) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 + DROP TABLE t1, child1, child2; diff --git a/storage/rocksdb/mysql-test/storage_engine/tbl_temporary.rdiff b/storage/rocksdb/mysql-test/storage_engine/tbl_temporary.rdiff new file mode 100644 index 00000000000..d24806e7c9f --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/tbl_temporary.rdiff @@ -0,0 +1,24 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/tbl_temporary.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/tbl_temporary.reject 2017-06-22 15:27:50.643658456 +0300 +@@ -1,11 +1,14 @@ + DROP TABLE IF EXISTS t1; + CREATE TABLE t1 (c CHAR(1)) ENGINE=MyISAM; + CREATE TEMPORARY TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW CREATE TABLE t1; +-Table Create Table +-t1 CREATE TEMPORARY TABLE `t1` ( +- `a` int(11) DEFAULT NULL, +- `b` char(8) DEFAULT NULL +-) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 +-DROP TEMPORARY TABLE t1; ++ERROR HY000: Table storage engine 'ROCKSDB' does not support the create option 'TEMPORARY' ++# ERROR: Statement ended with errno 1478, errname ER_ILLEGAL_HA_CREATE_OPTION (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TEMPORARY TABLE t1 (a INT(11) /*!*/ /*Custom column options*/, b CHAR(8) /*!*/ /*Custom column options*/) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_ILLEGAL_HA_CREATE_OPTION. ++# Temporary tables or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + DROP TABLE t1; diff --git a/storage/rocksdb/mysql-test/storage_engine/truncate_table.rdiff b/storage/rocksdb/mysql-test/storage_engine/truncate_table.rdiff new file mode 100644 index 00000000000..9ca7861d51e --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/truncate_table.rdiff @@ -0,0 +1,24 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/truncate_table.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/truncate_table.reject 2017-06-22 02:43:27.183946733 +0300 +@@ -29,13 +29,12 @@ + CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'); + HANDLER t1 OPEN AS h1; +-HANDLER h1 READ FIRST; +-a b +-1 a +-TRUNCATE TABLE t1; +-HANDLER h1 READ NEXT; +-ERROR 42S02: Unknown table 'h1' in HANDLER +-HANDLER t1 OPEN AS h2; +-HANDLER h2 READ FIRST; +-a b ++ERROR HY000: Storage engine ROCKSDB of the table `test`.`t1` doesn't have this option ++# ------------ UNEXPECTED RESULT ------------ ++# The statement|command finished with ER_ILLEGAL_HA. ++# HANDLER or the syntax or the mix could be unsupported. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + DROP TABLE t1; diff --git a/storage/rocksdb/mysql-test/storage_engine/trx/delete.rdiff b/storage/rocksdb/mysql-test/storage_engine/trx/delete.rdiff new file mode 100644 index 00000000000..dac23b83579 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/trx/delete.rdiff @@ -0,0 +1,10 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/trx/delete.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/trx/delete.reject 2017-06-22 19:29:36.827567276 +0300 +@@ -68,5 +68,7 @@ + DELETE FROM t1; + INSERT INTO t1 (a,b) VALUES (1,'a'); + ROLLBACK TO SAVEPOINT spt1; ++ERROR HY000: MyRocks currently does not support ROLLBACK TO SAVEPOINT if modifying rows. + COMMIT; ++ERROR HY000: This transaction was rolled back and cannot be committed. Only supported operation is to roll it back, so all pending changes will be discarded. Please restart another transaction. + DROP TABLE t1; diff --git a/storage/rocksdb/mysql-test/storage_engine/trx/disabled.def b/storage/rocksdb/mysql-test/storage_engine/trx/disabled.def new file mode 100644 index 00000000000..4e227c10307 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/trx/disabled.def @@ -0,0 +1,4 @@ +cons_snapshot_serializable : Not supported +level_read_uncommitted : Not supported +level_serializable : Not supported +xa_recovery : MDEV-13155 - XA recovery not supported for RocksDB diff --git a/storage/rocksdb/mysql-test/storage_engine/trx/insert.rdiff b/storage/rocksdb/mysql-test/storage_engine/trx/insert.rdiff new file mode 100644 index 00000000000..36a71076a2b --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/trx/insert.rdiff @@ -0,0 +1,24 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/trx/insert.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/trx/insert.reject 2017-06-22 19:29:39.131567262 +0300 +@@ -37,18 +37,18 @@ + INSERT INTO t1 SET a = 11, b = 'f'; + INSERT t1 SET b = DEFAULT; + ROLLBACK TO SAVEPOINT spt1; ++ERROR HY000: MyRocks currently does not support ROLLBACK TO SAVEPOINT if modifying rows. + INSERT INTO t1 (b,a) VALUES ('test1',10); ++ERROR HY000: This transaction was rolled back and cannot be committed. Only supported operation is to roll it back, so all pending changes will be discarded. Please restart another transaction. + COMMIT; ++ERROR HY000: This transaction was rolled back and cannot be committed. Only supported operation is to roll it back, so all pending changes will be discarded. Please restart another transaction. + SELECT a,b FROM t1; + a b + 1 a +-10 NULL + 10 foo +-10 test1 + 100 foo + 11 abc + 2 b +-20 NULL + 3 c + 4 d + 5 e diff --git a/storage/rocksdb/mysql-test/storage_engine/trx/level_read_committed.rdiff b/storage/rocksdb/mysql-test/storage_engine/trx/level_read_committed.rdiff new file mode 100644 index 00000000000..6b9e4a3f4e9 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/trx/level_read_committed.rdiff @@ -0,0 +1,10 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/trx/level_read_committed.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/trx/level_read_committed.reject 2017-06-22 19:29:41.459567247 +0300 +@@ -77,6 +77,7 @@ + CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; + START TRANSACTION WITH CONSISTENT SNAPSHOT; ++ERROR HY000: Only REPEATABLE READ isolation level is supported for START TRANSACTION WITH CONSISTENT SNAPSHOT in RocksDB Storage Engine. + connection con2; + INSERT INTO t1 (a) VALUES (1); + connection con1; diff --git a/storage/rocksdb/mysql-test/storage_engine/trx/level_repeatable_read.rdiff b/storage/rocksdb/mysql-test/storage_engine/trx/level_repeatable_read.rdiff new file mode 100644 index 00000000000..cf770755243 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/trx/level_repeatable_read.rdiff @@ -0,0 +1,35 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/trx/level_repeatable_read.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/trx/level_repeatable_read.reject 2017-06-22 20:33:13.935543284 +0300 +@@ -24,8 +24,7 @@ + SELECT a FROM t1; + a + INSERT INTO t1 (a) SELECT a+100 FROM t1; +-ERROR HY000: Lock wait timeout exceeded; try restarting transaction +-# WARNING: Statement ended with errno 1205, errname 'ER_LOCK_WAIT_TIMEOUT'. ++# WARNING: Statement ended with errno 0, errname ''. + # If it differs from the result file, it might indicate a problem. + SELECT a FROM t1; + a +@@ -47,22 +46,16 @@ + # If it differs from the result file, it might indicate a problem. + SELECT a FROM t1; + a +-201 +-202 + COMMIT; + SELECT a FROM t1; + a + 1 + 2 +-201 +-202 + connection con2; + SELECT a FROM t1; + a + 1 + 2 +-201 +-202 + connection default; + disconnect con1; + disconnect con2; diff --git a/storage/rocksdb/mysql-test/storage_engine/trx/suite.opt b/storage/rocksdb/mysql-test/storage_engine/trx/suite.opt new file mode 100644 index 00000000000..713e46dcddb --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/trx/suite.opt @@ -0,0 +1 @@ +--ignore-db-dirs=.rocksdb --plugin-load=$HA_ROCKSDB_SO --binlog_format=ROW diff --git a/storage/rocksdb/mysql-test/storage_engine/trx/update.rdiff b/storage/rocksdb/mysql-test/storage_engine/trx/update.rdiff new file mode 100644 index 00000000000..ab181947733 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/trx/update.rdiff @@ -0,0 +1,38 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/trx/update.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/trx/update.reject 2017-06-22 19:29:57.267567148 +0300 +@@ -29,20 +29,23 @@ + SAVEPOINT spt1; + UPDATE t1 SET b = ''; + ROLLBACK TO SAVEPOINT spt1; ++ERROR HY000: MyRocks currently does not support ROLLBACK TO SAVEPOINT if modifying rows. + UPDATE t1 SET b = 'upd' WHERE a = 10050; ++ERROR HY000: This transaction was rolled back and cannot be committed. Only supported operation is to roll it back, so all pending changes will be discarded. Please restart another transaction. + COMMIT; ++ERROR HY000: This transaction was rolled back and cannot be committed. Only supported operation is to roll it back, so all pending changes will be discarded. Please restart another transaction. + SELECT a,b FROM t1; + a b +-10050 upd +-10050 upd +-51 update2 +-51 update2 +-52 update2 +-52 update2 +-53 update2 +-53 update2 +-54 update2 +-54 update2 +-55 update2 +-55 update2 ++10050 NULL ++10050 NULL ++51 NULL ++51 NULL ++52 NULL ++52 NULL ++53 NULL ++53 NULL ++54 NULL ++54 NULL ++55 NULL ++55 NULL + DROP TABLE t1; diff --git a/storage/rocksdb/mysql-test/storage_engine/type_binary_indexes.rdiff b/storage/rocksdb/mysql-test/storage_engine/type_binary_indexes.rdiff new file mode 100644 index 00000000000..9ba195c8823 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/type_binary_indexes.rdiff @@ -0,0 +1,61 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_binary_indexes.result 2017-06-22 15:31:43.719656991 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_binary_indexes.reject 2017-06-22 15:32:27.007656719 +0300 +@@ -50,34 +50,21 @@ + v128 VARBINARY(128) <CUSTOM_COL_OPTIONS>, + UNIQUE INDEX b_v (b,v128) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW INDEX IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 b_v 1 b # # NULL NULL # # +-t1 0 b_v 2 v128 # # NULL NULL # # +-INSERT INTO t1 (b,b20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b'); +-EXPLAIN SELECT HEX(b), HEX(v128) FROM t1 WHERE b != 'a' AND v128 > 'varchar'; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # b_v # # # # +-SELECT HEX(b), HEX(v128) FROM t1 WHERE b != 'a' AND v128 > 'varchar'; +-HEX(b) HEX(v128) +-62 766172636861723162 +-63 766172636861723362 +-EXPLAIN SELECT HEX(b), HEX(v128) FROM t1 USE INDEX (b_v) WHERE b != 'a' AND v128 > 'varchar'; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # b_v # # # # +-SELECT HEX(b), HEX(v128) FROM t1 USE INDEX (b_v) WHERE b != 'a' AND v128 > 'varchar'; +-HEX(b) HEX(v128) +-62 766172636861723162 +-63 766172636861723362 +-EXPLAIN SELECT HEX(v128), COUNT(*) FROM t1 GROUP BY HEX(v128); +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # b_v # # # # +-SELECT HEX(v128), COUNT(*) FROM t1 GROUP BY HEX(v128); +-HEX(v128) COUNT(*) +-766172636861723162 2 +-766172636861723262 1 +-766172636861723362 1 +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (b BINARY /*!*/ /*Custom indexed column options*/, ++b20 BINARY(20) /*!*/ /*Custom column options*/, ++v16 VARBINARY(16) /*!*/ /*Custom column options*/, ++v128 VARBINARY(128) /*!*/ /*Custom indexed column options*/, ++UNIQUE INDEX b_v (b,v128) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# BINARY or VARBINARY types or unique keys or multi-part keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (b BINARY <CUSTOM_COL_OPTIONS>, + b20 BINARY(20) <CUSTOM_COL_OPTIONS>, + v16 VARBINARY(16) <CUSTOM_COL_OPTIONS>, +@@ -92,7 +79,7 @@ + ANALYZE TABLE t1; + EXPLAIN SELECT HEX(SUBSTRING(v16,0,3)) FROM t1 WHERE v16 LIKE 'varchar%'; + id select_type table type possible_keys key key_len ref rows Extra +-# # # # # NULL # # # # ++# # # # # v16 # # # # + SELECT HEX(SUBSTRING(v16,7,3)) FROM t1 WHERE v16 LIKE 'varchar%'; + HEX(SUBSTRING(v16,7,3)) + 723161 diff --git a/storage/rocksdb/mysql-test/storage_engine/type_bit_indexes.rdiff b/storage/rocksdb/mysql-test/storage_engine/type_bit_indexes.rdiff new file mode 100644 index 00000000000..7ebba6f43a7 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/type_bit_indexes.rdiff @@ -0,0 +1,87 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_bit_indexes.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_bit_indexes.reject 2017-06-22 14:07:37.807688707 +0300 +@@ -59,30 +59,21 @@ + d BIT(64) <CUSTOM_COL_OPTIONS>, + UNIQUE INDEX b_c (b,c) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW INDEX IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 b_c 1 b # # NULL NULL # # +-t1 0 b_c 2 c # # NULL NULL # # +-INSERT INTO t1 (a,b,c,d) VALUES +-(0,0xFFFFF,0,1),(0,256,0xAAA,0x12345),(1,16,0,0xFFFFFFF),(0,11,12,13), +-(1,100,101,102),(0,12,13,14),(1,13,14,15),(0,101,201,202),(1,1000,1001,1002), +-(1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF); +-EXPLAIN SELECT HEX(b+c) FROM t1 WHERE c > 1 OR HEX(b) < 0xFFFFFF; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # b_c # # # # +-SELECT HEX(b+c) FROM t1 WHERE c > 1 OR HEX(b) < 0xFFFFFF; +-HEX(b+c) +-10 +-10000FFFE +-12E +-17 +-19 +-1B +-7D1 +-BAA +-C9 +-FFFFF +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a BIT /*!*/ /*Custom column options*/, ++b BIT(20) /*!*/ /*Custom indexed column options*/, ++c BIT(32) /*!*/ /*Custom indexed column options*/, ++d BIT(64) /*!*/ /*Custom column options*/, ++UNIQUE INDEX b_c (b,c) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# BIT types or unique keys or multi-part keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (a BIT <CUSTOM_COL_OPTIONS>, + b BIT(20) <CUSTOM_COL_OPTIONS>, + c BIT(32) <CUSTOM_COL_OPTIONS>, +@@ -110,23 +101,18 @@ + d BIT(64) <CUSTOM_COL_OPTIONS>, + UNIQUE INDEX (d) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW INDEX IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 d 1 d # # NULL NULL # # +-INSERT INTO t1 (a,b,c,d) VALUES +-(0,0xFFFFF,0,1),(0,256,0xAAA,0x12345),(1,16,0,0xFFFFFFF),(0,11,12,13), +-(1,100,101,102),(0,12,13,14),(1,13,14,15),(0,101,201,202),(1,1000,1001,1002), +-(1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF); +-EXPLAIN SELECT d FROM t1 WHERE d BETWEEN 1 AND 10000; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # d # # # # +-SELECT d+0 FROM t1 WHERE d BETWEEN 1 AND 10000; +-d+0 +-1 +-1002 +-102 +-13 +-14 +-15 +-202 +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a BIT /*!*/ /*Custom column options*/, ++b BIT(20) /*!*/ /*Custom column options*/, ++c BIT(32) /*!*/ /*Custom column options*/, ++d BIT(64) /*!*/ /*Custom indexed column options*/, ++UNIQUE INDEX (d) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# BIT types or unique keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- diff --git a/storage/rocksdb/mysql-test/storage_engine/type_blob_indexes.rdiff b/storage/rocksdb/mysql-test/storage_engine/type_blob_indexes.rdiff new file mode 100644 index 00000000000..52c2587727f --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/type_blob_indexes.rdiff @@ -0,0 +1,71 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_blob_indexes.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_blob_indexes.reject 2017-06-22 14:09:07.227688145 +0300 +@@ -71,53 +71,21 @@ + l LONGBLOB <CUSTOM_COL_OPTIONS>, + UNIQUE INDEX l_t (l(256),t(64)) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW INDEX IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 l_t 1 l # # 256 NULL # # +-t1 0 l_t 2 t # # 64 NULL # # +-INSERT INTO t1 (b,t,m,l) VALUES +-('','','',''), +-('a','b','c','d'), +-('b','d','c','b'), +-('test1','test2','test3','test4'), +-(REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)), +-(HEX('abcd'),HEX('def'),HEX('a'),HEX('abc')), +-('abc','def','ghi','jkl'), +-('test2','test3','test4','test5'), +-('test3','test4','test5','test6'), +-(REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)), +-(REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128)); +-EXPLAIN SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # l_t # # # # # +-SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC; +-SUBSTRING(t,64) SUBSTRING(l,256) +- +- +-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +- +- +-fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +- +- +- +-EXPLAIN SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 FORCE INDEX (l_t) WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # l_t # # # # # +-SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 FORCE INDEX (l_t) WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC; +-SUBSTRING(t,64) SUBSTRING(l,256) +- +- +-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +- +- +-fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +- +- +- +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (b BLOB /*!*/ /*Custom column options*/, ++t TINYBLOB /*!*/ /*Custom indexed column options*/, ++m MEDIUMBLOB /*!*/ /*Custom column options*/, ++l LONGBLOB /*!*/ /*Custom indexed column options*/, ++UNIQUE INDEX l_t (l(256),t(64)) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# BLOB types or unique indexes or multi-part indexes or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (b BLOB <CUSTOM_COL_OPTIONS>, + t TINYBLOB <CUSTOM_COL_OPTIONS>, + m MEDIUMBLOB <CUSTOM_COL_OPTIONS>, diff --git a/storage/rocksdb/mysql-test/storage_engine/type_char_indexes.rdiff b/storage/rocksdb/mysql-test/storage_engine/type_char_indexes.rdiff new file mode 100644 index 00000000000..b18d6b85c4d --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/type_char_indexes.rdiff @@ -0,0 +1,64 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_char_indexes.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_char_indexes.reject 2017-06-22 14:10:08.479687760 +0300 +@@ -67,46 +67,21 @@ + v128 VARCHAR(128) <CUSTOM_COL_OPTIONS>, + UNIQUE INDEX c_v (c,v128) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW INDEX IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 c_v 1 c # # NULL NULL # # +-t1 0 c_v 2 v128 # # NULL NULL # # +-INSERT INTO t1 (c,c20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b'); +-EXPLAIN SELECT c, v128 FROM t1 WHERE c != 'a' AND v128 > 'varchar'; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # c_v # # # # +-SELECT c, v128 FROM t1 WHERE c != 'a' AND v128 > 'varchar'; +-c v128 +-b varchar1b +-c varchar3b +-EXPLAIN SELECT v128, COUNT(*) FROM t1 GROUP BY v128; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # c_v # # # # +-SELECT v128, COUNT(*) FROM t1 GROUP BY v128; +-v128 COUNT(*) +-varchar1b 2 +-varchar2b 1 +-varchar3b 1 +-EXPLAIN SELECT v128, COUNT(*) FROM t1 USE INDEX FOR GROUP BY (c_v) GROUP BY v128; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # c_v # # # # +-SELECT v128, COUNT(*) FROM t1 USE INDEX FOR GROUP BY (c_v) GROUP BY v128; +-v128 COUNT(*) +-varchar1b 2 +-varchar2b 1 +-varchar3b 1 +-SET SESSION optimizer_switch = 'engine_condition_pushdown=on'; +-Warnings: +-Warning 1681 'engine_condition_pushdown=on' is deprecated and will be removed in a future release +-EXPLAIN SELECT c,c20,v16,v128 FROM t1 WHERE c > 'a'; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # range c_v c_v # # # Using index condition +-SELECT c,c20,v16,v128 FROM t1 WHERE c > 'a'; +-c c20 v16 v128 +-b char3 varchar1a varchar1b +-c char4 varchar3a varchar3b +-SET SESSION optimizer_switch = @@global.optimizer_switch; +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (c CHAR /*!*/ /*Custom indexed column options*/, ++c20 CHAR(20) /*!*/ /*Custom column options*/, ++v16 VARCHAR(16) /*!*/ /*Custom column options*/, ++v128 VARCHAR(128) /*!*/ /*Custom indexed column options*/, ++UNIQUE INDEX c_v (c,v128) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# CHAR or VARCHAR types or unique keys or multi-part keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS>, + c20 CHAR(20) <CUSTOM_COL_OPTIONS>, + v16 VARCHAR(16) <CUSTOM_COL_OPTIONS>, diff --git a/storage/rocksdb/mysql-test/storage_engine/type_date_time_indexes.rdiff b/storage/rocksdb/mysql-test/storage_engine/type_date_time_indexes.rdiff new file mode 100644 index 00000000000..3aa333bb912 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/type_date_time_indexes.rdiff @@ -0,0 +1,65 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_date_time_indexes.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_date_time_indexes.reject 2017-06-22 15:05:44.883666789 +0300 +@@ -194,46 +194,22 @@ + y YEAR <CUSTOM_COL_OPTIONS>, + UNIQUE INDEX d_t (d,t) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW INDEX IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 d_t 1 d # # NULL NULL # # +-t1 0 d_t 2 t # # NULL NULL # # +-SET @tm = '2012-04-09 05:27:00'; +-INSERT INTO t1 (d,dt,ts,t,y) VALUES +-('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000'), +-('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'), +-('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'), +-('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'), +-('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'), +-(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm)); +-EXPLAIN SELECT d, t FROM t1 WHERE CONCAT(d,' ',t) != CURRENT_DATE(); +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # d_t # # # # +-SELECT d, t FROM t1 WHERE CONCAT(d,' ',t) != CURRENT_DATE(); +-d t +-2011-03-31 22:04:10 +-2012-01-12 00:12:32 +-2012-01-12 00:12:33 +-2012-03-13 12:10:00 +-2012-03-31 12:00:00 +-2012-04-09 05:27:00 +-EXPLAIN SELECT d, t FROM t1 IGNORE INDEX (d_t) WHERE CONCAT(d,' ',t) != CURRENT_DATE(); +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # NULL # # # # +-SELECT d, t FROM t1 IGNORE INDEX (d_t) WHERE CONCAT(d,' ',t) != CURRENT_DATE(); +-d t +-2011-03-31 22:04:10 +-2012-01-12 00:12:32 +-2012-01-12 00:12:33 +-2012-03-13 12:10:00 +-2012-03-31 12:00:00 +-2012-04-09 05:27:00 +-INSERT INTO t1 (d,dt,ts,t,y) VALUES +-('2012-01-12', '2010-11-22 12:33:53', '2011-11-14 21:45:55', '00:12:33', '2000'); +-ERROR 23000: Duplicate entry '2012-01-12-00:12:33' for key 'd_t' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (d DATE /*!*/ /*Custom indexed column options*/, ++dt DATETIME /*!*/ /*Custom column options*/, ++ts TIMESTAMP /*!*/ /*Custom column options*/, ++t TIME /*!*/ /*Custom indexed column options*/, ++y YEAR /*!*/ /*Custom column options*/, ++UNIQUE INDEX d_t (d,t) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Date and time types or unique keys or multi-part keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (d DATE <CUSTOM_COL_OPTIONS>, + dt DATETIME <CUSTOM_COL_OPTIONS>, + ts TIMESTAMP <CUSTOM_COL_OPTIONS>, diff --git a/storage/rocksdb/mysql-test/storage_engine/type_enum.rdiff b/storage/rocksdb/mysql-test/storage_engine/type_enum.rdiff new file mode 100644 index 00000000000..a402e0fb418 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/type_enum.rdiff @@ -0,0 +1,20 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_enum.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_enum.reject 2017-06-22 02:55:49.599942066 +0300 +@@ -24,8 +24,6 @@ + test2 4 + test5 2 + ALTER TABLE t1 ADD COLUMN e ENUM('a','A') <CUSTOM_COL_OPTIONS>; +-Warnings: +-Note 1291 Column 'e' has duplicated value 'a' in ENUM + SHOW COLUMNS IN t1; + Field Type Null Key Default Extra + a enum('') # # # +@@ -37,7 +35,7 @@ + a b c e + NULL + test2 4 NULL +- test3 75 a ++ test3 75 A + test5 2 NULL + SELECT a,b,c,e FROM t1 WHERE b='test2' OR a != ''; + a b c e diff --git a/storage/rocksdb/mysql-test/storage_engine/type_enum_indexes.rdiff b/storage/rocksdb/mysql-test/storage_engine/type_enum_indexes.rdiff new file mode 100644 index 00000000000..549b67b96ed --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/type_enum_indexes.rdiff @@ -0,0 +1,47 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_enum_indexes.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_enum_indexes.reject 2017-06-22 15:08:42.299665674 +0300 +@@ -21,30 +21,20 @@ + c ENUM('1a','1b','1d','1j','4a','4z','5a','5b','6v','6z') <CUSTOM_COL_OPTIONS>, + UNIQUE KEY a_b (a,b) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-INSERT INTO t1 (a,b,c) VALUES +-('N.America','test1','5a'),('Europe','test1','5b'),('Europe','test2','6v'), +-('Africa','test3','4z'),('Africa','test4','1j'),('Antarctica','test4','1d'); +-SHOW INDEX IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 a_b 1 a # # NULL NULL # # +-t1 0 a_b 2 b # # NULL NULL # # +-EXPLAIN SELECT a FROM t1 WHERE b > 'test2' ORDER BY a; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # a_b # # # # +-SELECT a FROM t1 WHERE b > 'test2' ORDER BY a; +-a +-Africa +-Africa +-Antarctica +-EXPLAIN SELECT a FROM t1 FORCE INDEX (a_b) WHERE b > 'test2' ORDER BY a; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # a_b # # # # +-SELECT a FROM t1 FORCE INDEX (a_b) WHERE b > 'test2' ORDER BY a; +-a +-Africa +-Africa +-Antarctica +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a ENUM('N.America','S.America','Africa','Europe','Australia','Asia','Antarctica') /*!*/ /*Custom indexed column options*/, ++b ENUM('test1','test2','test3','test4','test5') /*!*/ /*Custom indexed column options*/, ++c ENUM('1a','1b','1d','1j','4a','4z','5a','5b','6v','6z') /*!*/ /*Custom column options*/, ++UNIQUE KEY a_b (a,b) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# ENUM types or unique keys or multi-part keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (a ENUM('N.America','S.America','Africa','Europe','Australia','Asia','Antarctica') <CUSTOM_COL_OPTIONS>, + b ENUM('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS>, + c ENUM('1a','1b','1d','1j','4a','4z','5a','5b','6v','6z') <CUSTOM_COL_OPTIONS> PRIMARY KEY diff --git a/storage/rocksdb/mysql-test/storage_engine/type_fixed_indexes.rdiff b/storage/rocksdb/mysql-test/storage_engine/type_fixed_indexes.rdiff new file mode 100644 index 00000000000..4c30b66f51f --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/type_fixed_indexes.rdiff @@ -0,0 +1,51 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_fixed_indexes.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_fixed_indexes.reject 2017-06-22 15:09:58.611665194 +0300 +@@ -77,33 +77,21 @@ + n2 NUMERIC(65,4) <CUSTOM_COL_OPTIONS>, + UNIQUE INDEX n1_n2 (n1,n2) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW INDEX IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 n1_n2 1 n1 # # NULL NULL # # +-t1 0 n1_n2 2 n2 # # NULL NULL # # +-INSERT INTO t1 (d1,d2,n1,n2) VALUES +-(10.22,60.12345,123456,14.3456), +-(10.0,60.12345,123456,14), +-(11.14,15,123456,13), +-(100,100,1,2), +-(0,0,0,0), +-(4540424564.23,3343303441.0,12,13), +-(15,17,23,100000); +-Warnings: +-Warning 1264 Out of range value for column 'd1' at row 6 +-EXPLAIN SELECT DISTINCT n1+n2 FROM t1; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # n1_n2 # # # # +-SELECT DISTINCT n1+n2 FROM t1; +-n1+n2 +-0.0000 +-100023.0000 +-123469.0000 +-123470.0000 +-123470.3456 +-25.0000 +-3.0000 +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (d1 DECIMAL(10,2) /*!*/ /*Custom column options*/, ++d2 DECIMAL(60,10) /*!*/ /*Custom column options*/, ++n1 NUMERIC /*!*/ /*Custom indexed column options*/, ++n2 NUMERIC(65,4) /*!*/ /*Custom indexed column options*/, ++UNIQUE INDEX n1_n2 (n1,n2) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Fixed point types or unique keys or multi-part keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (d1 DECIMAL(10,2) <CUSTOM_COL_OPTIONS>, + d2 DECIMAL(60,10) <CUSTOM_COL_OPTIONS>, + n1 NUMERIC <CUSTOM_COL_OPTIONS>, diff --git a/storage/rocksdb/mysql-test/storage_engine/type_float_indexes.rdiff b/storage/rocksdb/mysql-test/storage_engine/type_float_indexes.rdiff new file mode 100644 index 00000000000..8674aa0f0bb --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/type_float_indexes.rdiff @@ -0,0 +1,97 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_float_indexes.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_float_indexes.reject 2017-06-22 15:11:12.543664729 +0300 +@@ -58,9 +58,11 @@ + 4644 + ALTER TABLE t1 DROP PRIMARY KEY; + ALTER TABLE t1 ADD UNIQUE KEY(d); ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) + EXPLAIN SELECT d FROM t1 WHERE r > 0 and d > 0 ORDER BY d; + id select_type table type possible_keys key key_len ref rows Extra +-# # # # # d # # # # ++# # # # # NULL # # # # + SELECT d FROM t1 WHERE r > 0 and d > 0 ORDER BY d; + d + 1.2345 +@@ -73,51 +75,42 @@ + dp DOUBLE PRECISION (64,10) <CUSTOM_COL_OPTIONS>, + UNIQUE KEY r_dp (r,dp) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW INDEX IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 r_dp 1 r # # NULL NULL # # +-t1 0 r_dp 2 dp # # NULL NULL # # +-INSERT INTO t1 (f,r,d,dp) VALUES +-(1.2345,1422.22,1.2345,1234567.89), +-(0,0,0,0), +-(-1,-1,-1,-1), +-(17.5843,4953453454.44,29229114.0,1111111.23), +-(4644,1422.22,466664.999,0.5); +-EXPLAIN SELECT r, dp FROM t1 WHERE r > 0 or dp > 0; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # r_dp # # # # +-SELECT r, dp FROM t1 WHERE r > 0 or dp > 0; +-r dp +-1422.220 0.5000000000 +-1422.220 1234567.8900000000 +-4953453454.440 1111111.2300000000 +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (f FLOAT /*!*/ /*Custom column options*/, ++r REAL(20,3) /*!*/ /*Custom indexed column options*/, ++d DOUBLE /*!*/ /*Custom column options*/, ++dp DOUBLE PRECISION (64,10) /*!*/ /*Custom indexed column options*/, ++UNIQUE KEY r_dp (r,dp) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Float point types or unique keys or multi-part keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (f FLOAT <CUSTOM_COL_OPTIONS>, + r REAL(20,3) <CUSTOM_COL_OPTIONS>, + d DOUBLE <CUSTOM_COL_OPTIONS>, + dp DOUBLE PRECISION (64,10) <CUSTOM_COL_OPTIONS>, + UNIQUE KEY(d) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW INDEX IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 d 1 d # # NULL NULL # # +-INSERT INTO t1 (f,r,d,dp) VALUES +-(1.2345,1422.22,1.2345,1234567.89), +-(0,0,0,0), +-(-1,-1,-1,-1), +-(17.5843,4953453454.44,29229114.0,1111111.23), +-(4644,1422.22,466664.999,0.5); +-EXPLAIN SELECT DISTINCT d FROM t1 ORDER BY d; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # d # # # # +-SELECT DISTINCT d FROM t1 ORDER BY d; +-d +--1 +-0 +-1.2345 +-466664.999 +-29229114 +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (f FLOAT /*!*/ /*Custom column options*/, ++r REAL(20,3) /*!*/ /*Custom column options*/, ++d DOUBLE /*!*/ /*Custom indexed column options*/, ++dp DOUBLE PRECISION (64,10) /*!*/ /*Custom column options*/, ++UNIQUE KEY(d) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Float point types or unique keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (f FLOAT <CUSTOM_COL_OPTIONS>, + r REAL(20,3) <CUSTOM_COL_OPTIONS>, + d DOUBLE <CUSTOM_COL_OPTIONS>, diff --git a/storage/rocksdb/mysql-test/storage_engine/type_int_indexes.rdiff b/storage/rocksdb/mysql-test/storage_engine/type_int_indexes.rdiff new file mode 100644 index 00000000000..f306212c0ea --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/type_int_indexes.rdiff @@ -0,0 +1,57 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_int_indexes.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_int_indexes.reject 2017-06-22 15:12:14.199664342 +0300 +@@ -96,38 +96,19 @@ + b BIGINT <CUSTOM_COL_OPTIONS>, + UNIQUE KEY b_t (b,t) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-INSERT INTO t1 (i,t,s,m,b) VALUES (1,2,3,4,5),(1000,100,10000,1000000,1000000000000000000),(5,100,10000,1000000,100000000000000000),(2,3,4,5,6),(3,4,5,6,7),(101,102,103,104,105),(10001,103,10002,10003,10004),(10,11,12,13,14),(11,12,13,14,15),(12,13,14,15,16); +-SELECT b+t FROM t1 WHERE (b,t) IN ( SELECT b, t FROM t1 WHERE i>1 ) ORDER BY b+t; +-b+t +-9 +-11 +-25 +-27 +-29 +-207 +-10107 +-100000000000000100 +-1000000000000000100 +-SELECT b+t FROM t1 FORCE INDEX (b_t) WHERE (b,t) IN ( SELECT b, t FROM t1 WHERE i>1 ) ORDER BY b+t; +-b+t +-9 +-11 +-25 +-27 +-29 +-207 +-10107 +-100000000000000100 +-1000000000000000100 +-SELECT b+t FROM t1 IGNORE INDEX (b_t) WHERE (b,t) IN ( SELECT b, t FROM t1 WHERE i>1 ) ORDER BY b+t; +-b+t +-9 +-11 +-25 +-27 +-29 +-207 +-10107 +-100000000000000100 +-1000000000000000100 +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (i INT /*!*/ /*Custom column options*/, ++t TINYINT /*!*/ /*Custom indexed column options*/, ++s SMALLINT /*!*/ /*Custom column options*/, ++m MEDIUMINT /*!*/ /*Custom column options*/, ++b BIGINT /*!*/ /*Custom indexed column options*/, ++UNIQUE KEY b_t (b,t) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# INT types or unique keys or multi-part keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- diff --git a/storage/rocksdb/mysql-test/storage_engine/type_set.rdiff b/storage/rocksdb/mysql-test/storage_engine/type_set.rdiff new file mode 100644 index 00000000000..c5cbeaedecf --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/type_set.rdiff @@ -0,0 +1,11 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_set.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_set.reject 2017-06-22 03:02:58.695939369 +0300 +@@ -30,8 +30,6 @@ + test2,test3 01,23,34,44 + test2,test4 + ALTER TABLE t1 ADD COLUMN e SET('a','A') <CUSTOM_COL_OPTIONS>; +-Warnings: +-Note 1291 Column 'e' has duplicated value 'a' in SET + SHOW COLUMNS IN t1; + Field Type Null Key Default Extra + a set('') # # # diff --git a/storage/rocksdb/mysql-test/storage_engine/type_set_indexes.rdiff b/storage/rocksdb/mysql-test/storage_engine/type_set_indexes.rdiff new file mode 100644 index 00000000000..6296fcadec0 --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/type_set_indexes.rdiff @@ -0,0 +1,47 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_set_indexes.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_set_indexes.reject 2017-06-22 15:19:48.679661485 +0300 +@@ -108,30 +108,17 @@ + c SET('01','22','23','33','34','39','40','44','50','63','64') <CUSTOM_COL_OPTIONS>, + UNIQUE INDEX b_a (b,a) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW INDEX IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 b_a 1 b # # NULL NULL # # +-t1 0 b_a 2 a # # NULL NULL # # +-INSERT INTO t1 (a,b,c) VALUES +-('','test2,test3','01,34,44,23'), +-('',5,2), +-('N.America,Asia','test4,test2',''), +-('Africa,Europe,Asia','test2,test3','01'), +-('Antarctica','test3','34,44'), +-('Asia','test5','50'), +-('Europe,S.America','test1,','39'); +-Warnings: +-Warning 1265 Data truncated for column 'b' at row 7 +-EXPLAIN SELECT DISTINCT a, b FROM t1 ORDER BY b DESC, a; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # # b_a # # # # +-SELECT DISTINCT a, b FROM t1 ORDER BY b DESC, a; +-a b +- test1,test3 +- test2,test3 +-Africa,Europe,Asia test2,test3 +-Antarctica test3 +-Asia test5 +-N.America,Asia test2,test4 +-S.America,Europe test1 +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a SET('N.America','S.America','Africa','Antarctica','Australia','Europe','Asia') /*!*/ /*Custom indexed column options*/, ++b SET('test1','test2','test3','test4','test5') /*!*/ /*Custom indexed column options*/, ++c SET('01','22','23','33','34','39','40','44','50','63','64') /*!*/ /*Custom column options*/, ++UNIQUE INDEX b_a (b,a) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# SET types or unique keys or multi-part keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- diff --git a/storage/rocksdb/mysql-test/storage_engine/type_text_indexes.rdiff b/storage/rocksdb/mysql-test/storage_engine/type_text_indexes.rdiff new file mode 100644 index 00000000000..6aba47d9bec --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/type_text_indexes.rdiff @@ -0,0 +1,68 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_text_indexes.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/type_text_indexes.reject 2017-06-22 15:20:42.963661144 +0300 +@@ -65,50 +65,21 @@ + l LONGTEXT <CUSTOM_COL_OPTIONS>, + UNIQUE INDEX l_tt (l(256),tt(64)) + ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-SHOW INDEX IN t1; +-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +-t1 0 l_tt 1 l # # 256 NULL # # +-t1 0 l_tt 2 tt # # 64 NULL # # +-INSERT INTO t1 (t,tt,m,l) VALUES +-('','','',''), +-('a','b','c','d'), +-('b','d','c','b'), +-('test1','test2','test3','test4'), +-(REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)), +-('abc','def','ghi','jkl'), +-('test2','test3','test4','test5'), +-('test3','test4','test5','test6'), +-(REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)), +-(REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128)); +-EXPLAIN SELECT SUBSTRING(tt,64), SUBSTRING(l,256) FROM t1 WHERE tt!=l AND l NOT IN ('test1') ORDER BY tt, l DESC; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # l_tt # # # # # +-SELECT SUBSTRING(tt,64), SUBSTRING(l,256) FROM t1 WHERE tt!=l AND l NOT IN ('test1') ORDER BY tt, l DESC; +-SUBSTRING(tt,64) SUBSTRING(l,256) +- +-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +- +- +-fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +- +- +- +-EXPLAIN SELECT SUBSTRING(tt,64), SUBSTRING(l,256) FROM t1 FORCE INDEX (l_t) WHERE tt!=l AND l NOT IN ('test1') ORDER BY tt, l DESC; +-id select_type table type possible_keys key key_len ref rows Extra +-# # # # l_tt l_tt # # # # +-SELECT SUBSTRING(tt,64), SUBSTRING(l,256) FROM t1 FORCE INDEX (l_t) WHERE tt!=l AND l NOT IN ('test1') ORDER BY tt, l DESC; +-SUBSTRING(tt,64) SUBSTRING(l,256) +- +-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +- +- +-fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +- +- +- +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (t TEXT /*!*/ /*Custom column options*/, ++tt TINYTEXT /*!*/ /*Custom indexed column options*/, ++m MEDIUMTEXT /*!*/ /*Custom column options*/, ++l LONGTEXT /*!*/ /*Custom indexed column options*/, ++UNIQUE INDEX l_tt (l(256),tt(64)) ++) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# TEXT types or unique keys or multi-part keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (t TEXT <CUSTOM_COL_OPTIONS>, + tt TINYTEXT <CUSTOM_COL_OPTIONS>, + m MEDIUMTEXT <CUSTOM_COL_OPTIONS>, diff --git a/storage/rocksdb/mysql-test/storage_engine/update_with_keys.rdiff b/storage/rocksdb/mysql-test/storage_engine/update_with_keys.rdiff new file mode 100644 index 00000000000..a59da32a10a --- /dev/null +++ b/storage/rocksdb/mysql-test/storage_engine/update_with_keys.rdiff @@ -0,0 +1,77 @@ +--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/update_with_keys.result 2017-06-22 00:33:46.423995639 +0300 ++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/update_with_keys.reject 2017-06-22 15:21:52.275660708 +0300 +@@ -17,54 +17,27 @@ + 8 + DROP TABLE t1; + CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, UNIQUE INDEX(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(0,'f'),(100,'a'); +-UPDATE t1 SET a=a+200; +-UPDATE t1 SET a=0 WHERE a > 250; +-UPDATE t1 SET a=205 WHERE a=200; +-ERROR 23000: Duplicate entry '205' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-UPDATE t1 SET a=12345 ORDER BY a, b LIMIT 1; +-SELECT a,b FROM t1; +-a b +-12345 a +-200 f +-201 a +-202 b +-203 c +-204 d +-205 e +-UPDATE t1 SET a=80 WHERE a IN (202,203); +-ERROR 23000: Duplicate entry '80' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a INT(11) /*!*/ /*Custom column options*/, b CHAR(8) /*!*/ /*Custom column options*/, UNIQUE INDEX(a)) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Unique keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, UNIQUE INDEX(a,b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; +-INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(100,'a'),(6,'f'); +-UPDATE t1 SET a=6 WHERE a=3; +-UPDATE t1 SET a=100 WHERE a=1; +-ERROR 23000: Duplicate entry '100-a' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-UPDATE t1 SET a=4, b='d' WHERE b='f'; +-ERROR 23000: Duplicate entry '4-d' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-UPDATE t1 SET a=a+1; +-SELECT a,b FROM t1; +-a b +-101 a +-2 a +-3 b +-5 d +-6 e +-7 c +-7 f +-UPDATE t1 SET b='z'; +-ERROR 23000: Duplicate entry '7-z' for key 'a' +-# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY). +-# If you got a difference in error message, just add it to rdiff file +-DROP TABLE t1; ++ERROR HY000: Unique index support is disabled when the table has no primary key. ++# ERROR: Statement ended with errno 1105, errname ER_UNKNOWN_ERROR (expected to succeed) ++# ------------ UNEXPECTED RESULT ------------ ++# [ CREATE TABLE t1 (a INT(11) /*!*/ /*Custom column options*/, b CHAR(8) /*!*/ /*Custom column options*/, UNIQUE INDEX(a,b)) ENGINE=RocksDB /*!*/ /*Custom table options*/ ] ++# The statement|command finished with ER_UNKNOWN_ERROR. ++# Unique keys or multi-part keys or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors. ++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def. ++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped. ++# Also, this problem may cause a chain effect (more errors of different kinds in the test). ++# ------------------------------------------- + CREATE TABLE t1 (a <INT_COLUMN> PRIMARY KEY, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; + INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(0,'f'),(100,'a'); + UPDATE t1 SET a=a+200; diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index b37e0e8bc2c..734f7790025 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -19601,6 +19601,40 @@ static void test_prepare_analyze() check_execute(stmt, rc); } +static void test_mdev12579() +{ + MYSQL_STMT *stmt= mysql_stmt_init(mysql); + MYSQL_BIND bind[2]; + int rc; + long l=3; + const char *data = "123456"; + + rc= mysql_query(mysql, "CREATE TABLE mdev12579 (k integer,t LONGTEXT,b LONGBLOB,x integer)"); + myquery(rc); + + rc= mysql_stmt_prepare(stmt, "INSERT INTO mdev12579 VALUES (1,?,NULL,?)", -1); + myquery(rc); + + rc= mysql_stmt_send_long_data(stmt, 0, data, 6); + rc= mysql_stmt_send_long_data(stmt, 0, data, 6); + rc= mysql_stmt_send_long_data(stmt, 0, data, 6); + + memset(bind, 0, sizeof(MYSQL_BIND) * 2); + bind[0].buffer_type= MYSQL_TYPE_VAR_STRING; + bind[1].buffer_type= MYSQL_TYPE_LONG; + bind[1].buffer= &l; + mysql_stmt_bind_param(stmt, bind); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + mysql_stmt_close(stmt); + + rc= mysql_query(mysql, "DROP TABLE mdev12579"); + myquery(rc); +} + + static struct my_tests_st my_tests[]= { { "disable_query_logs", disable_query_logs }, { "test_view_sp_list_fields", test_view_sp_list_fields }, @@ -19879,6 +19913,7 @@ static struct my_tests_st my_tests[]= { { "test_compressed_protocol", test_compressed_protocol }, { "test_big_packet", test_big_packet }, { "test_prepare_analyze", test_prepare_analyze }, + { "test_mdev12579", test_mdev12579 }, { 0, 0 } }; |