From 0cf993c24f482663ba1685ecf97a23ab44f6912e Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Wed, 21 Jun 2017 21:07:20 +0300 Subject: [PATCH 01/15] MDEV-11002 large_tests.rpl_slave_net_timeout fails due to connection logging --- .../suite/large_tests/r/rpl_slave_net_timeout.result | 7 +++++++ 1 file changed, 7 insertions(+) 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 4dcc2e6295f78..ad704c0c68393 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 From a71c870ebfcb1ad43dd9eb118733480f64a2b3c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 20 Jun 2017 15:32:02 +0300 Subject: [PATCH 02/15] InnoDB: Reset unknown TRX_SYS page type to FIL_PAGE_TYPE_TRX_SYS buf_flush_init_for_writing(): Reset the FIL_PAGE_TYPE of the TRX_SYS page to the canonical value FIL_PAGE_TYPE_TRX_SYS instead of FIL_PAGE_TYPE_UNKNOWN. --- storage/innobase/buf/buf0flu.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 89fe74d59b8f9..50750364956b2 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: From 557e1bd472612848a42e772c1fb6f8ed32ab33b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 21 Jun 2017 16:37:48 +0300 Subject: [PATCH 03/15] dict_create_or_check_sys_tablespace(): Add some error handling These errors should only be possible when bootstrap is aborted and restarted. --- storage/innobase/dict/dict0crea.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index 128f661b61808..8db1878b4ef70 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -2506,6 +2506,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); @@ -2533,11 +2534,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); } From 064d1a480c6bb6825ecd00a765939a7715cd43c2 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Thu, 22 Jun 2017 09:52:02 +0200 Subject: [PATCH 04/15] MDEV-12579: Incorrect arguments to mysqld_stmt_execute when using LOBs Parameters can be MYSQL_TYPE_VARCHAR for long data load. --- sql/sql_prepare.cc | 6 ++++-- tests/mysql_client_test.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 11274fbbaa2a9..92137b30f7756 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -825,8 +825,10 @@ static void setup_one_conversion_function(THD *thd, Item_param *param, */ inline bool is_param_long_data_type(Item_param *param) { - return ((param->field_type() >= MYSQL_TYPE_TINY_BLOB) && - (param->field_type() <= MYSQL_TYPE_STRING)); + enum_field_types field_type= param->field_type(); + return (((field_type >= MYSQL_TYPE_TINY_BLOB) && + (field_type <= MYSQL_TYPE_STRING)) || + field_type == MYSQL_TYPE_VARCHAR); } diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index fc3e5470ddd2c..383036ff0927f 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -19531,6 +19531,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 }, @@ -19808,6 +19842,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 } }; From a133b05cd78be406dc79388b7b4d6c940bc21518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 21 Jun 2017 12:22:02 +0300 Subject: [PATCH 05/15] Disable more threads on innodb_force_recovery=3 or more The original intention of the setting innodb_force_recovery=3 was to disable background activity that could create trouble, most notably, the rollback of incomplete transactions, and the purge of transaction history. MySQL 5.6 introduced more background threads, it is creating dict_stats_thread and fts_optimize_thread even though these threads are at least as non-essential as the rollback and purge. These threads are in fact worse, because they can create new transactions on their own. innobase_start_or_create_for_mysql(): Do not create any internal undo log sources unless innodb_force_recovery<3. --- storage/innobase/srv/srv0start.cc | 8 +++----- storage/innobase/trx/trx0purge.cc | 4 ++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 2aea7b8ccb319..fbe29d5e75f32 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -2602,13 +2602,15 @@ innobase_start_or_create_for_mysql() 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; @@ -2617,10 +2619,6 @@ innobase_start_or_create_for_mysql() /* 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 e317a38815b28..5fea72b870c82 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -285,6 +285,8 @@ 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. + Also, DROP TABLE may be executed while innodb_force_recovery=2 + prevents the purge from running. 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 +294,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 */ From 953de413073040028b0445d567e872acd0d74837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 22 Jun 2017 13:40:10 +0300 Subject: [PATCH 06/15] trx_sys_read_wsrep_checkpoint(): Do not write If no checkpoint information is present, do not write to the data files. These writes would violate innodb_read_only=ON, among other things. --- storage/innobase/trx/trx0sys.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index 82bcfd5055a65..8d7c72319ed03 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -371,7 +371,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; } From bb857f02d52492b0f5386fc827fc88db4f5fee5a Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Thu, 22 Jun 2017 21:06:31 +0300 Subject: [PATCH 07/15] Test changes to improve stability of results --- mysql-test/suite/storage_engine/tbl_temporary.test | 3 ++- mysql-test/suite/storage_engine/type_binary_indexes.test | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/storage_engine/tbl_temporary.test b/mysql-test/suite/storage_engine/tbl_temporary.test index 963238c37a581..66b63fd2d8331 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 943593027f8ac..c17b0c53a6800 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%'; From a8131e71f9504a7399bc9a7f312b14ed6700d099 Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Thu, 22 Jun 2017 21:08:32 +0300 Subject: [PATCH 08/15] MDEV-12528 Run the engine-agnostic test suite on MyRocks --- .../storage_engine/cache_index.rdiff | 71 +++++++++ .../storage_engine/checksum_table_live.rdiff | 13 ++ .../storage_engine/cleanup_engine.inc | 25 +++ .../storage_engine/define_engine.inc | 45 ++++++ .../mysql-test/storage_engine/disabled.def | 25 +++ .../mysql-test/storage_engine/index.rdiff | 98 ++++++++++++ .../storage_engine/index_key_block_size.rdiff | 26 +++ .../storage_engine/index_type_btree.rdiff | 98 ++++++++++++ .../storage_engine/index_type_hash.rdiff | 98 ++++++++++++ .../storage_engine/insert_with_keys.rdiff | 148 ++++++++++++++++++ .../mysql-test/storage_engine/mask_engine.inc | 15 ++ .../mysql-test/storage_engine/misc.rdiff | 25 +++ .../storage_engine/parts/checksum_table.rdiff | 13 ++ .../storage_engine/parts/create_table.rdiff | 20 +++ .../storage_engine/parts/disabled.def | 3 + .../mysql-test/storage_engine/parts/suite.opt | 1 + .../mysql-test/storage_engine/replace.rdiff | 31 ++++ .../storage_engine/show_engine.rdiff | 14 ++ .../storage_engine/show_table_status.rdiff | 20 +++ .../mysql-test/storage_engine/suite.opt | 1 + .../tbl_opt_insert_method.rdiff | 11 ++ .../storage_engine/tbl_opt_union.rdiff | 16 ++ .../storage_engine/tbl_temporary.rdiff | 24 +++ .../storage_engine/truncate_table.rdiff | 24 +++ .../storage_engine/trx/delete.rdiff | 10 ++ .../storage_engine/trx/disabled.def | 4 + .../storage_engine/trx/insert.rdiff | 24 +++ .../trx/level_read_committed.rdiff | 10 ++ .../trx/level_repeatable_read.rdiff | 35 +++++ .../mysql-test/storage_engine/trx/suite.opt | 1 + .../storage_engine/trx/update.rdiff | 38 +++++ .../storage_engine/type_binary_indexes.rdiff | 61 ++++++++ .../storage_engine/type_bit_indexes.rdiff | 87 ++++++++++ .../storage_engine/type_blob_indexes.rdiff | 71 +++++++++ .../storage_engine/type_char_indexes.rdiff | 64 ++++++++ .../type_date_time_indexes.rdiff | 65 ++++++++ .../mysql-test/storage_engine/type_enum.rdiff | 20 +++ .../storage_engine/type_enum_indexes.rdiff | 47 ++++++ .../storage_engine/type_fixed_indexes.rdiff | 51 ++++++ .../storage_engine/type_float_indexes.rdiff | 97 ++++++++++++ .../storage_engine/type_int_indexes.rdiff | 57 +++++++ .../mysql-test/storage_engine/type_set.rdiff | 11 ++ .../storage_engine/type_set_indexes.rdiff | 47 ++++++ .../storage_engine/type_text_indexes.rdiff | 68 ++++++++ .../storage_engine/update_with_keys.rdiff | 77 +++++++++ 45 files changed, 1810 insertions(+) create mode 100644 storage/rocksdb/mysql-test/storage_engine/cache_index.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/checksum_table_live.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/cleanup_engine.inc create mode 100644 storage/rocksdb/mysql-test/storage_engine/define_engine.inc create mode 100644 storage/rocksdb/mysql-test/storage_engine/disabled.def create mode 100644 storage/rocksdb/mysql-test/storage_engine/index.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/index_key_block_size.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/index_type_btree.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/index_type_hash.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/insert_with_keys.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/mask_engine.inc create mode 100644 storage/rocksdb/mysql-test/storage_engine/misc.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/parts/checksum_table.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/parts/create_table.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/parts/disabled.def create mode 100644 storage/rocksdb/mysql-test/storage_engine/parts/suite.opt create mode 100644 storage/rocksdb/mysql-test/storage_engine/replace.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/show_engine.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/show_table_status.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/suite.opt create mode 100644 storage/rocksdb/mysql-test/storage_engine/tbl_opt_insert_method.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/tbl_opt_union.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/tbl_temporary.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/truncate_table.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/trx/delete.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/trx/disabled.def create mode 100644 storage/rocksdb/mysql-test/storage_engine/trx/insert.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/trx/level_read_committed.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/trx/level_repeatable_read.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/trx/suite.opt create mode 100644 storage/rocksdb/mysql-test/storage_engine/trx/update.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/type_binary_indexes.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/type_bit_indexes.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/type_blob_indexes.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/type_char_indexes.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/type_date_time_indexes.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/type_enum.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/type_enum_indexes.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/type_fixed_indexes.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/type_float_indexes.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/type_int_indexes.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/type_set.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/type_set_indexes.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/type_text_indexes.rdiff create mode 100644 storage/rocksdb/mysql-test/storage_engine/update_with_keys.rdiff 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 0000000000000..76e7705e377ee --- /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 .key_buffer_size=128*1024; + CACHE INDEX t1 INDEX (a), t2 IN ; + 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 .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 .key_cache_age_threshold = 100, .key_cache_block_size = 512, .key_cache_division_limit = 1, .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_.key_buffer_size=128*1024; + CACHE INDEX t1 IN new_; + 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= ; + CACHE INDEX t1 IN ; + 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 , + b , +@@ -59,11 +59,11 @@ + ) ENGINE= ; + CACHE INDEX t1 IN ; + 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 .key_buffer_size=0; + SET GLOBAL new_.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 0000000000000..094136ee926e3 --- /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 0000000000000..4f6c586172dcc --- /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//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 0000000000000..1c77a6b6bb611 --- /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//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 0000000000000..0643b2052e2b5 --- /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 0000000000000..ed22a30872618 --- /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= ; + 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 , + b , +@@ -12,8 +12,8 @@ + ) ENGINE= ; + 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 , + b , +@@ -22,46 +22,48 @@ + ) ENGINE= ; + 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 , + b , + UNIQUE INDEX (a) + ) ENGINE= ; +-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 , b ) ENGINE= ; + INSERT INTO t1 (a,b) VALUES (100,'z'); + ALTER TABLE t1 ADD (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 , + b , + UNIQUE INDEX (a) + ) ENGINE= ; +-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 0000000000000..5038a10b836ee --- /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 , + UNIQUE INDEX ind2(b(1) DESC) KEY_BLOCK_SIZE=32768 COMMENT 'big key_block_size value' + ) ENGINE= ; +-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 , + b , + 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 0000000000000..2f1ebe5553728 --- /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= ; + 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 , + b , +@@ -12,8 +12,8 @@ + ) ENGINE= ; + 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 , + b , +@@ -22,46 +22,48 @@ + ) ENGINE= ; + 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 , + b , + UNIQUE INDEX USING BTREE (a) + ) ENGINE= ; +-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 , b ) ENGINE= ; + INSERT INTO t1 (a,b) VALUES (100,'z'); + ALTER TABLE t1 ADD (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 , + b , + UNIQUE INDEX USING BTREE (a) + ) ENGINE= ; +-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 0000000000000..7dad7b11deb0b --- /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= ; + 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 , + b , +@@ -12,8 +12,8 @@ + ) ENGINE= ; + 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 , + b , +@@ -22,46 +22,48 @@ + ) ENGINE= ; + 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 , + b , + UNIQUE INDEX USING HASH (a) + ) ENGINE= ; +-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 , b ) ENGINE= ; + INSERT INTO t1 (a,b) VALUES (100,'z'); + ALTER TABLE t1 ADD (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 , + b , + UNIQUE INDEX USING HASH (a) + ) ENGINE= ; +-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 0000000000000..04313e11e7c11 --- /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 , b , UNIQUE INDEX(a)) ENGINE= ; +-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 , b , UNIQUE INDEX(a,b)) ENGINE= ; +-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 PRIMARY KEY, b ) ENGINE= ; + 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 UNIQUE KEY, b UNIQUE KEY, c ) ENGINE= ; +-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 0000000000000..fc6cd02e3ef48 --- /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 +# in the next statement. More masks can be added by defining $add_regex, e.g. +# let $add_regex = /$data_dir// /$index_dir// +# + +--let $regex = /$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 0000000000000..694f3f54815a9 --- /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 0000000000000..bf3347a434170 --- /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 0000000000000..b2cb47a09275d --- /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 0000000000000..ef8ad5b3c8247 --- /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 0000000000000..713e46dcddb02 --- /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 0000000000000..632c52f1504c5 --- /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 , b , UNIQUE INDEX (a)) ENGINE= ; +-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 , b , PRIMARY KEY (b)) ENGINE= ; + 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 0000000000000..77cc8b0b05e20 --- /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 STATUS; + Type Name Status +- ### Engine status, can be long and changeable ### ++DBSTATS ### 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 ### 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 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 0000000000000..d7252eb54eda4 --- /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 0000000000000..41beb675cc1a8 --- /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 0000000000000..20f594fbb403a --- /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= DEFAULT CHARSET=latin1 INSERT_METHOD=FIRST ++) 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 0000000000000..0d65ad0744aa9 --- /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= DEFAULT CHARSET=latin1 UNION=(`child1`) ++) 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= DEFAULT CHARSET=latin1 UNION=(`child1`,`child2`) ++) 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 0000000000000..d24806e7c9f5a --- /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 , b ) ENGINE= ; +-SHOW CREATE TABLE t1; +-Table Create Table +-t1 CREATE TEMPORARY TABLE `t1` ( +- `a` int(11) DEFAULT NULL, +- `b` char(8) DEFAULT NULL +-) 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 0000000000000..9ca7861d51eb3 --- /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 , b ) ENGINE= ; + 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 0000000000000..dac23b8357940 --- /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 0000000000000..4e227c10307fb --- /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 0000000000000..36a71076a2b75 --- /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 0000000000000..6b9e4a3f4e916 --- /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 ) ENGINE= ; + 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 0000000000000..cf770755243b9 --- /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 0000000000000..713e46dcddb02 --- /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 0000000000000..ab181947733e2 --- /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 0000000000000..9ba195c8823db --- /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) , + UNIQUE INDEX b_v (b,v128) + ) ENGINE= ; +-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 , + b20 BINARY(20) , + v16 VARBINARY(16) , +@@ -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 0000000000000..7ebba6f43a752 --- /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) , + UNIQUE INDEX b_c (b,c) + ) ENGINE= ; +-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 , + b BIT(20) , + c BIT(32) , +@@ -110,23 +101,18 @@ + d BIT(64) , + UNIQUE INDEX (d) + ) ENGINE= ; +-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 0000000000000..52c2587727fdc --- /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 , + UNIQUE INDEX l_t (l(256),t(64)) + ) ENGINE= ; +-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 , + t TINYBLOB , + m MEDIUMBLOB , 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 0000000000000..b18d6b85c4d93 --- /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) , + UNIQUE INDEX c_v (c,v128) + ) ENGINE= ; +-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 , + c20 CHAR(20) , + v16 VARCHAR(16) , 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 0000000000000..3aa333bb912ea --- /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 , + UNIQUE INDEX d_t (d,t) + ) ENGINE= ; +-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 , + dt DATETIME , + ts TIMESTAMP , 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 0000000000000..a402e0fb41803 --- /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') ; +-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 0000000000000..549b67b96edac --- /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') , + UNIQUE KEY a_b (a,b) + ) ENGINE= ; +-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') , + b ENUM('test1','test2','test3','test4','test5') , + c ENUM('1a','1b','1d','1j','4a','4z','5a','5b','6v','6z') 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 0000000000000..4c30b66f51f6b --- /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) , + UNIQUE INDEX n1_n2 (n1,n2) + ) ENGINE= ; +-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) , + d2 DECIMAL(60,10) , + n1 NUMERIC , 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 0000000000000..8674aa0f0bb51 --- /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) , + UNIQUE KEY r_dp (r,dp) + ) ENGINE= ; +-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 , + r REAL(20,3) , + d DOUBLE , + dp DOUBLE PRECISION (64,10) , + UNIQUE KEY(d) + ) ENGINE= ; +-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 , + r REAL(20,3) , + d DOUBLE , 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 0000000000000..f306212c0ea4f --- /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 , + UNIQUE KEY b_t (b,t) + ) ENGINE= ; +-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 0000000000000..c5cbeaedecf1b --- /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') ; +-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 0000000000000..6296fcadec0e5 --- /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') , + UNIQUE INDEX b_a (b,a) + ) ENGINE= ; +-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 0000000000000..6aba47d9bec90 --- /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 , + UNIQUE INDEX l_tt (l(256),tt(64)) + ) ENGINE= ; +-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 , + tt TINYTEXT , + m MEDIUMTEXT , 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 0000000000000..a59da32a10a89 --- /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 , b , UNIQUE INDEX(a)) ENGINE= ; +-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 , b , UNIQUE INDEX(a,b)) ENGINE= ; +-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 PRIMARY KEY, b ) ENGINE= ; + 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; From 9f3622191df074d9f4e512320effe86f06b250fb Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Thu, 22 Jun 2017 00:41:44 -0700 Subject: [PATCH 09/15] Fixed the bug mdev-12845. This patch fills in a serious flaw in the code that supports condition pushdown into materialized views / derived tables. If a predicate happened to contain a reference to a mergeable view / derived table and it does not depended directly on the target materialized view / derived table then the predicate was not considered as a subject to pusdown to this view / derived table. --- mysql-test/r/derived.result | 2 +- mysql-test/r/derived_cond_pushdown.result | 229 ++++++++++++++++- mysql-test/r/derived_view.result | 4 +- mysql-test/t/derived_cond_pushdown.test | 57 +++++ sql/item.cc | 299 +++++++++++++--------- sql/item.h | 66 ++++- sql/item_cmpfunc.h | 8 + sql/item_func.h | 13 + sql/item_row.h | 10 + sql/sql_derived.cc | 5 +- sql/sql_lex.cc | 17 +- sql/sql_lex.h | 2 +- sql/table.cc | 3 +- 13 files changed, 568 insertions(+), 147 deletions(-) diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 8a7422ba5ec07..722ff76e556d7 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 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 dbc25fb255cc3..db65d9cfec967 100644 --- a/mysql-test/r/derived_cond_pushdown.result +++ b/mysql-test/r/derived_cond_pushdown.result @@ -7234,6 +7234,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 5, + "having_condition": "s > 2", "filesort": { "sort_key": "t4.d", "temporary_table": { @@ -7605,6 +7606,7 @@ EXPLAIN "materialized": { "query_block": { "select_id": 3, + "having_condition": "s < 50", "filesort": { "sort_key": "t3.a", "temporary_table": { @@ -7755,9 +7757,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" } } } @@ -8447,3 +8454,221 @@ 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": "", + "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": "", + "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": "", + "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": "", + "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; diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result index 5e6bcd0db3757..f3964605b1a93 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 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/t/derived_cond_pushdown.test b/mysql-test/t/derived_cond_pushdown.test index bc448093e3378..6b5da541b7d4a 100644 --- a/mysql-test/t/derived_cond_pushdown.test +++ b/mysql-test/t/derived_cond_pushdown.test @@ -1452,3 +1452,60 @@ 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; diff --git a/sql/item.cc b/sql/item.cc index df615b5ace925..61a85f6d48729 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -7120,121 +7120,182 @@ 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)) + return this; + if (!item_equal && used_tables() != tab_map) + 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 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 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 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 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 && @@ -8702,6 +8763,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 && @@ -10613,46 +10700,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 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 5ed3e8acb82a1..02e4b2e346812 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1580,8 +1580,20 @@ class Item: public Value_source, 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; } /* @@ -2633,8 +2645,8 @@ class Item_field :public Item_ident 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) @@ -3853,6 +3865,28 @@ class Item_args } 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) @@ -4321,10 +4355,15 @@ class Item_ref :public Item_ident } Item *get_copy(THD *thd, MEM_ROOT *mem_root) { return get_item_copy(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(); @@ -4621,13 +4660,20 @@ class Item_direct_view_ref :public Item_direct_ref 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()) @@ -4709,6 +4755,8 @@ class Item_direct_view_ref :public Item_direct_ref item_equal= NULL; Item_direct_ref::cleanup(); } + Item *get_copy(THD *thd, MEM_ROOT *mem_root) + { return get_item_copy(thd, mem_root, this); } }; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 18ce611d30689..c81a1621f8afd 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -2395,6 +2395,14 @@ class Item_equal: public Item_bool_func 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; diff --git a/sql/item_func.h b/sql/item_func.h index 0919685bbf3cb..585b981ba05f4 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -316,6 +316,19 @@ class Item_func :public Item_func_or_sum 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 26468336dc815..cd58e15fe8b5e 100644 --- a/sql/item_row.h +++ b/sql/item_row.h @@ -126,6 +126,16 @@ class Item_row: public Item, 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(thd, mem_root, this); } diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 8f0410b4284eb..649f745fdc4c0 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -1246,7 +1246,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); @@ -1285,7 +1285,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 e3ead45447f6e..9584f2aba36c9 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -5006,8 +5006,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) @@ -5020,7 +5021,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++; @@ -5041,10 +5042,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 0c55ffc58920b..a1ef42861b44b 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1139,7 +1139,7 @@ class st_select_lex: public st_select_lex_node 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/table.cc b/sql/table.cc index a856799ddd54c..28fa34c5ad713 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -8128,8 +8128,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); } From 0288fa619f4cf95dd4725f16c11804cbd2b3bbab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 23 Jun 2017 09:46:51 +0300 Subject: [PATCH 10/15] Do allow writes for innodb_force_recovery=2 or 3 While the primary purpose of innodb_force_recovery is to allow data to be rescued from an InnoDB instance that would crash due to some data corruption, the settings 1, 2, or 3 are relatively safe to use and there is no need to prevent write transactions in these modes. The setting innodb_force_recovery=4 and above can cause database corruption. For those modes, we already set the flag high_level_read_only to disable modifications, except DROP TABLE. MODIFICATIONS_NOT_ALLOWED_MSG_FORCE_RECOVERY: Remove. There is no need to spam the error log for each refused DML operation. It suffices to return an error to the client. There will be messages at startup if innodb_read_only or innodb_force_recovery are preventing writes. --- .../innodb/r/innodb_force_recovery.result | 33 +++++++++++++++++- .../suite/innodb/t/innodb_force_recovery.test | 34 ++++++++++++++++++- storage/innobase/row/row0mysql.cc | 20 +++-------- storage/innobase/srv/srv0start.cc | 4 --- storage/innobase/trx/trx0purge.cc | 8 +++-- 5 files changed, 76 insertions(+), 23 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb_force_recovery.result b/mysql-test/suite/innodb/r/innodb_force_recovery.result index e405a79dd53a4..d71a6c4e8b051 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_force_recovery.test b/mysql-test/suite/innodb/t/innodb_force_recovery.test index 31b9660e87229..f9af16f660935 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/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 4751109292f72..e74fdc7a5d7ee 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -70,11 +70,6 @@ Created 9/17/2000 Heikki Tuuri #include #include -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"); @@ -4472,10 +4464,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 fbe29d5e75f32..a6b21e3893f6d 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; diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 5fea72b870c82..317087173c5bb 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -285,8 +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. - Also, DROP TABLE may be executed while innodb_force_recovery=2 - prevents the purge from running. + + 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(). */ From 0d69d313a11fb03f31d71282f622b25d0a4764b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 23 Jun 2017 22:54:42 +0300 Subject: [PATCH 11/15] Prevent interleaved error log output on InnoDB startup buf_flush_page_cleaner_coordinator(): Signal the thread creator that the error log output regarding setpriority() has been issued. innobase_start_or_create_for_mysql(): Wait for buf_flush_page_cleaner_coordinator() to completely start up. This prevents sporadic failures of tests that search the server error log for InnoDB redo log recovery messages. --- storage/innobase/buf/buf0flu.cc | 24 ++++++++++++------------ storage/innobase/srv/srv0start.cc | 4 ++++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 50750364956b2..541091d845f56 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -3133,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 */ @@ -3160,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 @@ -3203,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/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index a6b21e3893f6d..7fbf069257db2 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -1861,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); } From dd710e75523b2a8280617f0e1ef522a01767b318 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Thu, 22 Jun 2017 17:35:36 +0400 Subject: [PATCH 12/15] MDEV-12882 - Assertion failed in MDL_context::upgrade_shared_lock Relaxed assertion (in MySQL it was removed). For "LOCK TABLES t1 WRITE CONCURRENT, t1 READ" upgrade lock to weakest existing suitable lock, which is MDL_SHARED_NO_READ_WRITE. --- mysql-test/r/mdl.result | 22 ++++++++++++++++++++++ mysql-test/t/mdl.test | 19 +++++++++++++++++++ sql/mdl.cc | 5 +++-- sql/sql_parse.cc | 6 +++++- 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 mysql-test/r/mdl.result create mode 100644 mysql-test/t/mdl.test diff --git a/mysql-test/r/mdl.result b/mysql-test/r/mdl.result new file mode 100644 index 0000000000000..1a7291d922b57 --- /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/t/mdl.test b/mysql-test/t/mdl.test new file mode 100644 index 0000000000000..1770e53b61ac3 --- /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/sql/mdl.cc b/sql/mdl.cc index f1a505f3d84fc..25809c3d9ccaf 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -2320,11 +2320,12 @@ MDL_context::upgrade_shared_lock(MDL_ticket *mdl_ticket, if (mdl_ticket->has_stronger_or_equal_type(new_type)) DBUG_RETURN(FALSE); - /* Only allow upgrades from SHARED_UPGRADABLE/NO_WRITE/NO_READ_WRITE/READ */ + /* Only allow upgrades from UPGRADABLE/NO_WRITE/NO_READ_WRITE/READ/WRITE */ DBUG_ASSERT(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); + mdl_ticket->m_type == MDL_SHARED_READ || + mdl_ticket->m_type == MDL_SHARED_WRITE); mdl_xlock_request.init(&mdl_ticket->m_lock->key, new_type, MDL_TRANSACTION); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 412cd1dac70fc..7c910e87c7585 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2787,6 +2787,7 @@ static bool lock_tables_open_and_lock_tables(THD *thd, TABLE_LIST *tables) ! 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 @@ -2799,9 +2800,12 @@ static bool lock_tables_open_and_lock_tables(THD *thd, TABLE_LIST *tables) 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(); From 6d0aed42c5ea202eabf9f44d777a3e258d14ee60 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Thu, 22 Jun 2017 17:15:10 +0400 Subject: [PATCH 13/15] MDEV-12070 - Introduce thd_query_safe() from MySQL 5.7 Merged relevant part of MySQL revision: https://github.com/mysql/mysql-server/commit/565d20b44f24fcc855dc616164d87b03cfad10bc --- sql/sql_class.cc | 37 ++++++++++++++++++----- sql/sql_class.h | 3 +- storage/innobase/handler/ha_innodb.cc | 17 +---------- storage/innobase/handler/handler0alter.cc | 4 ++- 4 files changed, 34 insertions(+), 27 deletions(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index f8cf82958816c..3ad3b6adf89d4 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -4509,26 +4509,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 2d1bf8a988626..0a1be8c13c84c 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 @@ class CSET_STRING 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/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index a54176f84109a..d8a4d8d274268 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2462,22 +2462,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 107205e0375d1..2631f525dbac6 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -4471,11 +4471,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; } From 02655a91cf5c6f525ef702448dbb306a0a350bfb Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Mon, 26 Jun 2017 12:16:04 -0700 Subject: [PATCH 14/15] Fixed the bug mdev-13166. This patch corrects the fix for mdev-12845. --- mysql-test/r/derived_cond_pushdown.result | 37 +++++++++++++++++++++++ mysql-test/t/derived_cond_pushdown.test | 17 +++++++++++ sql/item.cc | 5 ++- 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/derived_cond_pushdown.result b/mysql-test/r/derived_cond_pushdown.result index db65d9cfec967..c009a08b4f793 100644 --- a/mysql-test/r/derived_cond_pushdown.result +++ b/mysql-test/r/derived_cond_pushdown.result @@ -8672,3 +8672,40 @@ EXPLAIN } 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": "", + "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/t/derived_cond_pushdown.test b/mysql-test/t/derived_cond_pushdown.test index 6b5da541b7d4a..beeaa7350f7dc 100644 --- a/mysql-test/t/derived_cond_pushdown.test +++ b/mysql-test/t/derived_cond_pushdown.test @@ -1509,3 +1509,20 @@ 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/sql/item.cc b/sql/item.cc index 61a85f6d48729..7ec50c2f47280 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -7173,9 +7173,8 @@ Item *Item_direct_view_ref::derived_field_transformer_for_having(THD *thd, { 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) + if ((item_equal && !(item_equal->used_tables() & tab_map)) || + !item_equal) return this; return get_field_item_for_having(thd, this, sel); } From 29624ea304b5893d3bc81670807285a89fce1a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 26 Jun 2017 16:39:00 +0300 Subject: [PATCH 15/15] =?UTF-8?q?MDEV-13176=20ALTER=20TABLE=E2=80=A6CHANGE?= =?UTF-8?q?=20col=20col=20TIMESTAMP=20NOT=20NULL=20DEFAULT=E2=80=A6=20fail?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When it comes to DEFAULT values of columns, InnoDB is imposing both unnecessary and insufficient conditions on whether ALGORITHM=INPLACE should be allowed for ALTER TABLE. When changing an existing column to NOT NULL, any NULL values in the columns only get a special treatment if the column is changed to an AUTO_INCREMENT column (which is not supported by ALGORITHM=INPLACE) or the column type is TIMESTAMP. In all other cases, an error must be reported for the failure to convert a NULL value to NOT NULL. InnoDB was unnecessarily interested in whether the DEFAULT value is not constant when altering other than TIMESTAMP columns. Also, when changing a TIMESTAMP column to NOT NULL, InnoDB was performing an insufficient check, and it was incorrectly allowing a constant DEFAULT value while not being able to replace NULL values with that constant value. Furthermore, in ADD COLUMN, InnoDB is unnecessarily rejecting certain nondeterministic DEFAULT expressions (depending on the session parameters or the current time). --- .../innodb/r/innodb-alter-timestamp.result | 81 +++++++++++++++-- .../innodb/t/innodb-alter-timestamp.test | 54 +++++++++-- storage/innobase/handler/handler0alter.cc | 91 ++++++++++++------- 3 files changed, 180 insertions(+), 46 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-alter-timestamp.result b/mysql-test/suite/innodb/r/innodb-alter-timestamp.result index 96ce33ac0972c..9659b03d6b282 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/t/innodb-alter-timestamp.test b/mysql-test/suite/innodb/t/innodb-alter-timestamp.test index 935320fb553ac..d8acc02cbdb78 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/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 2631f525dbac6..7c75711d2e3bc 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);