summaryrefslogtreecommitdiffstats
path: root/storage/rocksdb/mysql-test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/combinations5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/autoinc_crash_safe.inc150
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/bulk_load.inc165
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/bulk_load_unsorted.inc143
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/bypass_create_table.inc298
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/ddl_high_priority.inc174
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/ddl_high_priority_module.inc141
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/deadlock_stats.inc52
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/dup_key_update.inc69
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/group_min_max.inc1438
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/have_direct_io.inc23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb.inc10
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb.opt12
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb_default.inc10
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb_replication.inc11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/have_write_committed.inc3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/have_write_prepared.inc3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/index_merge1.inc910
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/index_merge2.inc520
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/index_merge_2sweeps.inc80
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/index_merge_ror.inc463
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/index_merge_ror_cpk.inc178
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case1_1.inc51
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case1_2.inc48
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case2.inc97
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case3.inc71
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case4.inc69
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case5.inc77
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case6.inc77
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case7.inc89
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/prefix_index_only_query_check.inc21
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_invalid_option.inc8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_option.inc31
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/rocksdb_icp.inc199
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/simple_deadlock.inc29
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/start_mysqld_with_option.inc14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/use_direct_io_option.inc24
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/my.cnf19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/1st.result22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/2pc_group_commit.result101
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace.result505
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_cardinality.result24
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_crash.result93
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_sstfilewriter.result79
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/add_unique_index_inplace.result111
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/allow_no_pk_concurrent_insert.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/allow_no_primary_key.result298
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/allow_no_primary_key_with_sk.result806
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/allow_to_start_after_corruption.result38
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/alter_table.result183
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/analyze_table.result61
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/apply_changes_iter.result64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/autoinc_crash_safe.result132
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/autoinc_crash_safe_partition.result132
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/autoinc_debug.result99
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/autoinc_secondary.result17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars.result199
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars_thread.result39
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars_thread_2.result98
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/binlog_rotate_crash.result19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/blind_delete_rc.result87
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/blind_delete_rr.result87
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bloomfilter.result2042
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bloomfilter2.result71
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bloomfilter3.result143
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bloomfilter4.result32
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bloomfilter5.result85
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bloomfilter_bulk_load.result15
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bloomfilter_skip.result2042
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bulk_load.result81
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bulk_load_drop_table.result11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bulk_load_errors.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf.result81
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf_and_data.result81
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_data.result81
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bulk_load_sk.result229
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted.result111
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted_errors.result4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted_rev.result111
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bypass_select_basic.result693
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bypass_select_basic_bloom.result693
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/bytes_written.result10
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/cardinality.result104
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/check_flags.result66
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/check_ignore_unknown_options.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/check_table.result68
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/checkpoint.result59
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/checksum_table.result92
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/checksum_table_live.result20
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/col_opt_default.result20
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/col_opt_not_null.result2613
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/col_opt_null.result2268
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/col_opt_unsigned.result749
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/col_opt_zerofill.result731
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/collation.result144
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/collation_exception.result25
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/com_rpc_tx.result21
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/commit_in_the_middle_ddl.result14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/compact_deletes.result78
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/compression_zstd.result3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/concurrent_alter.result12
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/cons_snapshot_read_committed.result151
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/cons_snapshot_repeatable_read.result144
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/cons_snapshot_serializable.result24
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/corrupted_data_reads_debug.result74
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/covered_unpack_info_format.result73
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/create_no_primary_key_table.result52
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/create_table.result165
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/ddl_high_priority.result1058
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/deadlock.result37
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/deadlock_stats.result14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/deadlock_tracking.result488
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/delete.result166
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/delete_ignore.result59
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/delete_quick.result24
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/delete_with_keys.result38
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/describe.result19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/drop_database.result6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/drop_index_inplace.result158
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/drop_table.result79
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/drop_table2.result66
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/drop_table3.result25
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/dup_key_update.result366
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/duplicate_table.result15
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/explicit_snapshot.result265
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/fail_system_cf.result4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/fast_prefix_index_fetch.result80
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/force_shutdown.result38
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/foreign_key.result25
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/gap_lock_issue254.result9
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/gap_lock_raise_error.result504
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/get_error_message.result8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result3526
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/ha_extra_keyread.result10
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/handler_basic.result128
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/hermitage.result648
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/i_s.result159
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/i_s_ddl.result22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/i_s_deadlock.result216
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/index.result89
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/index_file_map.result31
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/index_key_block_size.result53
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb.result49
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result1418
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/index_primary.result71
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/index_type_btree.result69
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/index_type_hash.result69
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/information_schema.result83
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result326
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/insert.result202
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/insert_optimized_config.result16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/insert_with_keys.result262
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/issue100.result23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/issue100_delete.result17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/issue111.result37
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/issue243_transactionStatus.result161
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/issue255.result68
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/issue290.result28
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/issue314.result12
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/issue495.result30
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/issue884.result80
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/issue896.result17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/issue900.result11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/iterator_bounds.result15
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/kill.result6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/level_read_committed.result111
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/level_read_uncommitted.result116
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/level_repeatable_read.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/level_serializable.result56
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/loaddata.result239
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/lock.result121
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/lock_info.result31
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/lock_rows_not_exist.result40
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/lock_wait_timeout_stats.result35
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues.result1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_1_rc.result30
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_1_rr.result30
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_2_rc.result30
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_2_rr.result30
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rc.result50
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rc_lsr.result37
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rr.result50
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rr_lsr.result37
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case3_rc.result25
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case3_rr.result23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case4_rc.result23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case4_rr.result23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case5_rc.result29
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case5_rr.result28
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case6_rc.result29
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case6_rr.result28
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rc.result41
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rc_lsr.result45
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rr.result41
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rr_lsr.result45
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/mariadb_ignore_dirs.result9
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/mariadb_misc_binlog.result33
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/mariadb_plugin.result35
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result119
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_rpl.result14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/max_open_files.result22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/misc.result94
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/multi_varchar_sk_lookup.result37
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/mysqlbinlog_blind_replace.result128
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/mysqlbinlog_gtid_skip_empty_trans_rocksdb.result143
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/mysqldump.result246
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/mysqldump2.result16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/native_procedure.result397
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/negative_stats.result9
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/no_merge_sort.result123
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/optimize_myrocks_replace_into_base.result98
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/optimize_myrocks_replace_into_lock.result46
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/optimize_table.result77
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/optimizer_loose_index_scans.result281
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/partition.result689
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/percona_nonflushing_analyze_debug.result19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/perf_context.result191
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/persistent_cache.result11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/prefix_extractor_override.result82
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/read_only_tx.result46
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result211
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/repair_table.result37
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/replace.result32
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result2643
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_cf_options.result64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_cf_per_partition.result425
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_cf_reverse.result120
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_checksums.result129
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_concurrent_delete.result671
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_datadir.result2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_detect_rc.result89
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_detect_rr.result89
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_stress_rc.result8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_stress_rr.result8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_debug.result11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp.result257
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp_rev.result223
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_locks.result64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_parts.result152
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_qcache.result45
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_range.result293
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_range2.result29
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_read_free_rpl.result335
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_read_free_rpl_stress.result35
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_row_stats.result66
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_table_stats_sampling_pct_change.result23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rocksdb_timeout_rollback.result84
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rollback_savepoint.result29
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rpl_row_not_found.result56
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rpl_row_not_found_rc.result56
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rpl_row_rocksdb.result45
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rpl_row_stats.result98
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rpl_row_triggers.result286
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rpl_savepoint.result110
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rpl_statement.result57
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rpl_statement_not_found.result70
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rqg_examples.result3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rqg_runtime.result30
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/rqg_transactions.result11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/secondary_key_update_lock.result18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/select.result380
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/select_for_update.result35
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/select_for_update_skip_locked_nowait.result28
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/select_lock_in_share_mode.result37
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/show_engine.result491
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/show_table_status.result136
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/shutdown.result9
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/singledelete.result86
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/skip_core_dump_on_error.result31
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/skip_validate_tmp_table.result22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/slow_query_log.result10
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/statistics.result73
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/table_stats.result12
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_ai.result38
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_avg_row_length.result18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_checksum.result18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_connection.result26
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_data_index_dir.result41
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_delay_key_write.result18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_insert_method.result18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_key_block_size.result18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_max_rows.result18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_min_rows.result18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_pack_keys.result18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_password.result18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_row_format.result18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_union.result16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tbl_standard_opts.result46
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/tmpdir.result32
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/transaction.result977
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/truncate_partition.result620
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/truncate_table.result33
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/truncate_table3.result23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/trx_info.result13
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/trx_info_rpl.result16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/ttl_primary.result489
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/ttl_primary_read_filtering.result283
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/ttl_primary_with_partitions.result256
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/ttl_rows_examined.result45
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary.result709
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_read_filtering.result511
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_read_filtering_multiple_index.result82
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_with_partitions.result389
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_binary.result48
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_binary_indexes.result80
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_bit.result53
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_bit_indexes.result58
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_blob.result57
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_blob_indexes.result198
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_bool.result73
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_char.result76
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes.result73
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes_collation.result91
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_date_time.result56
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_date_time_indexes.result119
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_decimal.result105
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_enum.result47
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_enum_indexes.result69
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_fixed.result131
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_fixed_indexes.result129
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_float.result314
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result189
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_int.result212
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_int_indexes.result99
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_set.result49
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_set_indexes.result115
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_text.result57
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_text_indexes.result181
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_varbinary.result93
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_varchar.result775
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/unique_check.result117
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/unique_sec.result221
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/unique_sec_rev_cf.result177
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/unsupported_tx_isolations.result18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/update.result121
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/update_ignore.result57
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/update_multi.result691
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/update_with_keys.result38
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/use_direct_io_for_flush_and_compaction.result18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/use_direct_reads.result18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/use_direct_reads_writes.result22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/validate_datadic.result9
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/varbinary_format.result260
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/write_sync.result30
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/xa.result70
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/slow_query_log.awk25
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/suite.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/suite.pm28
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/1st.test36
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/2pc_group_commit-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/2pc_group_commit.test168
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace.test417
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_cardinality-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_cardinality.test44
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_crash.test118
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_sstfilewriter.test113
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/add_unique_index_inplace.test101
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/allow_no_pk_concurrent_insert.test22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/allow_no_primary_key.test126
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/allow_no_primary_key_with_sk.test149
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/allow_to_start_after_corruption-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/allow_to_start_after_corruption.test77
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/alter_table.test94
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/analyze_table.test57
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/apply_changes_iter.test44
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe.cnf8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe.test9
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe_partition.cnf8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe_partition.test10
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/autoinc_debug-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/autoinc_debug.test121
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/autoinc_secondary.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars.test171
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars_thread.test65
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars_thread_2.test142
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/binlog_rotate_crash.test31
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rc.cnf11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rc.test3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rr.cnf11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rr.test3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/blind_delete_without_tx_api.inc132
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter-master.opt2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.inc78
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.test1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter2-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter2.test103
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter3-master.opt4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter3.test136
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter4-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter4.test52
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter5-master.opt3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter5.test86
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_bulk_load-master.opt2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_bulk_load.test35
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_load_select.inc190
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_skip-master.opt3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_skip.test1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_table_def.inc33
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bulk_load.test11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bulk_load_drop_table.test19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bulk_load_errors.test168
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bulk_load_rev_cf.test10
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bulk_load_rev_cf_and_data.test10
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bulk_load_rev_data.test10
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bulk_load_sk.test119
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bulk_load_unsorted.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bulk_load_unsorted_errors.test8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bulk_load_unsorted_rev.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic.inc213
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic.test3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic_bloom-master.opt3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic_bloom.test3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/bytes_written.test22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/cardinality-master.opt3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/cardinality.test119
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/check_flags.test117
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/check_ignore_unknown_options.test56
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/check_log_for_xa.py31
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/check_table.inc54
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/check_table.test12
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/checkpoint.test107
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/checksum_table.test84
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/checksum_table_live.test24
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/col_not_null.inc55
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/col_not_null_timestamp.inc70
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/col_null.inc34
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/col_opt_default.test27
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/col_opt_not_null.test229
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/col_opt_null.test220
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/col_opt_unsigned.test74
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/col_opt_zerofill.test67
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/collation-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/collation.test211
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/collation_exception-master.opt2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/collation_exception.test29
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/com_rpc_tx.cnf4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/com_rpc_tx.test90
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/commit_in_the_middle_ddl.test27
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/compact_deletes-master.opt3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/compact_deletes.test88
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/compact_deletes_test.inc72
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/compression_zstd.test14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/concurrent_alter.test39
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_read_committed.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_read_committed.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_repeatable_read.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_repeatable_read.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_serializable.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_serializable.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/consistent_snapshot.inc136
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/corrupted_data_reads_debug.test80
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/covered_unpack_info_format.test79
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/create_no_primary_key_table-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/create_no_primary_key_table.test63
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/create_table.test192
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ddl_high_priority.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/deadlock.test44
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/deadlock_stats.test3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/deadlock_tracking.test185
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/delete.test101
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/delete_ignore.test37
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/delete_quick.test32
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/delete_with_keys.test39
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/describe.test24
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/disabled.def98
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/drop_database.test11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/drop_index_inplace.test116
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/drop_stats_procedure.inc3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/drop_table-master.opt3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/drop_table.test145
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/drop_table2.test131
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/drop_table3-master.opt2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/drop_table3.inc52
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/drop_table3.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/drop_table3_repopulate_table.inc15
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/drop_table_repopulate_table.inc15
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/drop_table_sync.inc6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/dup_key_update.test45
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/duplicate_table.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/explicit_snapshot-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/explicit_snapshot.test263
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/fail_system_cf.test17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/fast_prefix_index_fetch.test120
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/force_shutdown.test97
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/foreign_key.test47
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/gap_lock_issue254-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/gap_lock_issue254.test14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/gap_lock_raise_error.test37
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/get_error_message.test27
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/group_min_max-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/group_min_max.test9
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ha_extra_keyread.test15
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test53
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/hermitage.inc257
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/hermitage.test10
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/hermitage_init.inc8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/i_s.test21
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/i_s_ddl.test29
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/i_s_deadlock.test158
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/index.inc155
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/index.test44
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/index_file_map-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/index_file_map.test54
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/index_key_block_size.test70
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb.test110
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb2-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb2.test72
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/index_primary.test96
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/index_type_btree.test12
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/index_type_hash.test12
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/information_schema-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/information_schema.test89
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/init_stats_procedure.inc40
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/innodb_i_s_tables_disabled-master.opt30
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/innodb_i_s_tables_disabled.test43
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/insert.test99
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/insert_optimized_config.test51
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/insert_with_keys.test169
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/issue100.test23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/issue100_delete-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/issue100_delete.test19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/issue111.test38
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/issue243_transactionStatus.test80
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/issue255.test52
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/issue290.test40
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/issue314.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/issue495.test34
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/issue884.test43
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/issue896.test17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/issue900.test13
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/iterator_bounds-master.opt2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/iterator_bounds.test29
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/kill.test9
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/level_read_committed.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/level_read_uncommitted.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/level_read_uncommitted.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/level_repeatable_read.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/level_serializable.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/loaddata.inc117
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/loaddata.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/lock.test224
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/lock_info.test31
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/lock_rows_not_exist.test110
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/lock_wait_timeout_stats.test38
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues.test3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_1_rc.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_1_rr.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_2_rc.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_2_rr.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rc.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rc_lsr.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rr.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rr_lsr.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case3_rc.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case3_rr.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case4_rc.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case4_rr.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case5_rc.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case5_rr.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case6_rc.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case6_rr.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rc.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rc_lsr.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rr.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rr_lsr.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mariadb_ignore_dirs.test17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mariadb_misc_binlog-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mariadb_misc_binlog.test40
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mariadb_plugin-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mariadb_plugin.test59
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test114
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_rpl.test14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/max_open_files.test53
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/misc.test45
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/multi_varchar_sk_lookup.test49
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mysqlbinlog_blind_replace.test62
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mysqlbinlog_gtid_skip_empty_trans_rocksdb-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mysqlbinlog_gtid_skip_empty_trans_rocksdb.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mysqldump-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mysqldump.test67
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mysqldump2-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mysqldump2.test43
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/native_procedure-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/native_procedure.test2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/negative_stats.test26
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/no_merge_sort.test32
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/no_primary_key_basic_ops.inc65
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/optimize_myrocks_replace_into_base.test96
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/optimize_myrocks_replace_into_lock.test88
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/optimize_table-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/optimize_table.inc20
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/optimize_table.test81
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/optimizer_loose_index_scans.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/partition.test762
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/percona_nonflushing_analyze_debug.test11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/perf_context.test96
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/persistent_cache.test41
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/prefix_extractor_override-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/prefix_extractor_override.test96
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/read_only_tx-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/read_only_tx.test70
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/records_in_range-master.opt3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/records_in_range.test146
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/repair_table.inc38
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/repair_table.test8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/replace.test54
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb.test1974
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_options-master.opt1
-rwxr-xr-xstorage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_options-master.sh5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_options.test75
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_per_partition.test513
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_reverse-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_reverse.test71
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_checksums-master.opt3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_checksums.test152
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete.inc109
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete.test38
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete_main.inc30
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete_range.inc85
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete_sk.inc82
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_insert.py95
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_datadir.test33
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect.inc123
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect_rc-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect_rc.test1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect_rr.test1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress.inc18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress.py94
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress_rc-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress_rc.test1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress_rr.test1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_debug.test14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp.test44
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp_rev-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp_rev.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_locks-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_locks.test94
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_parts-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_parts.test160
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_qcache-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_qcache.test43
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_range-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_range.test196
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_range2.test33
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl.cnf16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl.test414
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl_stress.cnf17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl_stress.inc69
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl_stress.test22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_row_stats.test57
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_table_stats_sampling_pct_change.test80
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_timeout_rollback-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_timeout_rollback.test78
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rollback_savepoint.test33
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found.cnf9
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found.inc98
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found_rc.cnf11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found_rc.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_row_rocksdb.cnf1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_row_rocksdb.test48
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_row_stats-slave.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_row_stats.cnf1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_row_stats.test47
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_row_triggers.cnf19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_row_triggers.test262
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_savepoint.cnf1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_savepoint.test91
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_statement.cnf7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_statement.test59
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_statement_not_found.cnf9
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rpl_statement_not_found.test3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rqg.inc44
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rqg_examples-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rqg_examples.test12
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rqg_runtime-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rqg_runtime.test58
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rqg_transactions-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rqg_transactions.test14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/se-innodb.out1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/secondary_key_update_lock.test26
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/select.test202
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/select_for_update.test55
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/select_for_update_skip_locked_nowait.test48
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/select_lock_in_share_mode.test54
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/set_checkpoint.inc30
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/show_engine.test103
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/show_table_status-master.opt3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/show_table_status.test175
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/shutdown-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/shutdown.test36
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/singledelete-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/singledelete.test105
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/skip_core_dump_on_error-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/skip_core_dump_on_error.test53
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/skip_validate_tmp_table.test39
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/slow_query_log-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/slow_query_log.test37
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/statistics-master.opt3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/statistics.test82
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/table_stats-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/table_stats.test29
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_ai.test29
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_avg_row_length.test23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_checksum.test19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_connection.test32
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_data_index_dir.test60
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_delay_key_write.test23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_insert_method.test23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_key_block_size.test23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_max_rows.test23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_min_rows.test23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_pack_keys.test23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_password.test27
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_row_format.test23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_union.test28
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tbl_standard_opts.test42
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/tmpdir.test35
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/transaction.test158
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/transaction_isolation.inc150
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/transaction_select.inc14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/truncate_partition.inc102
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/truncate_partition.test83
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/truncate_table.test74
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/truncate_table3-master.opt2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/truncate_table3.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/trx_info.test17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/trx_info_rpl.cnf11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/trx_info_rpl.test44
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ttl_primary-master.opt2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ttl_primary.test545
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_read_filtering-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_read_filtering.test388
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_with_partitions-master.opt2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_with_partitions.test254
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ttl_rows_examined.test57
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary-master.opt2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary.test780
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering.test503
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering_multiple_index.test87
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_with_partitions-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_with_partitions.test300
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_binary.inc45
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_binary.test8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_binary_indexes-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_binary_indexes.test99
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_bit.inc53
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_bit.test8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_bit_indexes-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_bit_indexes.test113
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_blob.inc49
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_blob.test8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_blob_indexes-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_blob_indexes.test176
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_bool.inc64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_bool.test8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_char.inc45
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_char.test19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes.test107
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation.test126
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_date_time.inc47
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_date_time.test9
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_date_time_indexes-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_date_time_indexes.test157
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_decimal-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_decimal.test88
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_enum.inc50
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_enum.test8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_enum_indexes-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_enum_indexes.test93
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_fixed.inc85
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_fixed.test8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_fixed_indexes-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_fixed_indexes.test107
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_float.inc121
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_float.test8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_float_indexes-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_float_indexes.test175
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_int.inc68
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_int.test8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_int_indexes-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_int_indexes.test75
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_set.inc49
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_set.test8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_set_indexes-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_set_indexes.test100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_text.inc49
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_text.test8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_text_indexes-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_text_indexes.test171
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_varbinary.inc75
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_varbinary.test8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_varchar-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_varchar.inc77
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_varchar.test82
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_varchar_endspace.inc85
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/unique_check.test173
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/unique_sec.inc198
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/unique_sec.test51
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/unique_sec_rev_cf.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/unsupported_tx_isolations.test25
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/update.test82
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/update_ignore-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/update_ignore.test35
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/update_multi.test15
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/update_multi_exec.inc27
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/update_with_keys.test78
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/use_direct_io_for_flush_and_compaction.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/use_direct_reads.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/use_direct_reads_writes.test62
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/validate_datadic.test108
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/varbinary_format.test131
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/write_sync.test41
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/xa-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/xa.test73
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/base.cnf25
-rwxr-xr-xstorage/rocksdb/mysql-test/rocksdb_hotbackup/include/clean_tmpfiles.sh8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/include/cleanup.inc3
-rwxr-xr-xstorage/rocksdb/mysql-test/rocksdb_hotbackup/include/create_slocket_socket.sh4
-rwxr-xr-xstorage/rocksdb/mysql-test/rocksdb_hotbackup/include/create_table.sh18
-rwxr-xr-xstorage/rocksdb/mysql-test/rocksdb_hotbackup/include/load_data.sh45
-rwxr-xr-xstorage/rocksdb/mysql-test/rocksdb_hotbackup/include/load_data_and_run.sh11
-rwxr-xr-xstorage/rocksdb/mysql-test/rocksdb_hotbackup/include/load_data_slocket.sh45
-rwxr-xr-xstorage/rocksdb/mysql-test/rocksdb_hotbackup/include/remove_slocket_socket.sh4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup.inc16
-rwxr-xr-xstorage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup_replication_gtid.sh22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup_replication_gtid_and_sync.inc4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup_slocket.inc10
-rwxr-xr-xstorage/rocksdb/mysql-test/rocksdb_hotbackup/include/stream_run.sh81
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/my.cnf2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/r/gtid.result23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/r/slocket.result41
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/r/stream.result20
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/r/wdt.result20
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/r/xbstream.result21
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/r/xbstream_direct.result21
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/r/xbstream_socket.result20
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/t/gtid-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/t/gtid-slave.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/t/gtid.test47
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/t/slocket.test46
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/t/stream.test22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/t/wdt.test22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream.inc25
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream_direct-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream_direct.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream_socket.test22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/combinations7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/include/have_rocksdb.inc10
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/include/have_rocksdb.opt12
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/include/rpl_gtid_crash_safe.inc37
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/include/rpl_no_unique_check_on_lag.inc72
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/my.cnf17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/consistent_snapshot_mixed_engines.result68
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/mdev12179.result283
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/multiclient_2pc.result26
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/optimize_myrocks_replace_into.result282
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rocksdb_slave_check_before_image_consistency.result165
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_binlog_xid_count.result204
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_crash_safe_wal_corrupt.result135
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_ddl_high_priority.result39
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_crash_safe.result361
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_crash_safe_optimized.result361
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_crash_safe_wal_corrupt.result140
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_rocksdb_sys_header.result16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_missing_columns_sk_update.result62
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_mts_dependency_unique_key_conflicts.result44
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_no_unique_check_on_lag.result34
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_no_unique_check_on_lag_mts.result31
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_2pc_crash_recover.result44
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_slave_gtid_info_optimized.result43
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_snapshot.result222
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_snapshot_without_gtid.result15
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_stress_crash.result28
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_skip_trx_api_binlog_format.result27
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_xa.result61
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/singledelete_idempotent_recovery.result25
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/r/singledelete_idempotent_table.result29
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/rpl_1slave_base.cnf51
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/suite.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/suite.pm25
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/consistent_snapshot_mixed_engines-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/consistent_snapshot_mixed_engines.test81
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def34
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/mdev12179.test317
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/multiclient_2pc-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/multiclient_2pc.test77
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/optimize_myrocks_replace_into.test149
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rocksdb_slave_check_before_image_consistency-slave.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rocksdb_slave_check_before_image_consistency.test22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count-master.opt3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count.test20
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_check_for_binlog_info.pl19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_crash_safe_wal_corrupt.cnf13
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_crash_safe_wal_corrupt.test12
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_ddl_high_priority.test2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe-slave.opt2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe.test11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_optimized-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_optimized-slave.opt2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_optimized.test11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_wal_corrupt.cnf18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_wal_corrupt.inc154
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_wal_corrupt.test12
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_rocksdb_sys_header-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_rocksdb_sys_header-slave.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_rocksdb_sys_header.test40
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_missing_columns_sk_update.cnf13
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_missing_columns_sk_update.test69
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_mts_dependency_unique_key_conflicts.test64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag-slave.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag_mts-slave.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag_mts.test3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_2pc_crash_recover-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_2pc_crash_recover-slave.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_2pc_crash_recover.test57
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_slave_gtid_info_optimized-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_slave_gtid_info_optimized-slave.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_slave_gtid_info_optimized.test51
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot-slave.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot.test374
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot_without_gtid.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_stress_crash-master.opt2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_stress_crash-slave.opt3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_stress_crash.test26
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_skip_trx_api_binlog_format-master.opt2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_skip_trx_api_binlog_format-slave.opt2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_skip_trx_api_binlog_format.test52
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_xa.inc84
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_xa.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_recovery.cnf15
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_recovery.test78
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.cnf11
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.test44
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_stress/combinations5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_stress/include/have_rocksdb.inc10
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_stress/include/have_rocksdb.opt12
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_stress/include/rocksdb_stress.inc57
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_stress/my.cnf9
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_stress/r/rocksdb_stress.result23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_stress/r/rocksdb_stress_crash.result23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_stress/suite.opt2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_stress/suite.pm28
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_stress/t/disabled.def2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_stress/t/load_generator.py1042
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_stress/t/rocksdb_stress.test33
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_stress/t/rocksdb_stress_crash.test34
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/include/correctboolvalue.inc25
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/include/have_rocksdb.inc10
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/include/have_rocksdb.opt12
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/include/rocksdb_sys_var.inc124
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/my.cnf10
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/all_vars.result13
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_access_hint_on_compaction_start_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_advise_random_on_open_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_concurrent_memtable_write_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_mmap_reads_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_mmap_writes_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_to_start_after_corruption_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_blind_delete_primary_key_basic.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_cache_size_basic.result85
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_restart_interval_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_size_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_size_deviation_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_allow_sk_basic.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_allow_unsorted_basic.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_basic.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_size_basic.result72
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bytes_per_sync_basic.result85
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_dump_basic.result19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_high_pri_pool_ratio_basic.result22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_index_and_filter_blocks_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_index_and_filter_with_high_priority_basic.result19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_checksums_pct_basic.result93
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_collect_sst_properties_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_commit_in_the_middle_basic.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_commit_time_batch_for_recovery_basic.result121
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compact_cf_basic.result40
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_readahead_size_basic.result70
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_basic.result64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_count_sd_basic.result64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_file_size_basic.result46
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_window_basic.result64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_create_checkpoint_basic.result15
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_create_if_missing_basic.result14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_create_missing_column_families_basic.result14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_datadir_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_db_write_buffer_size_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_deadlock_detect_basic.result121
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_deadlock_detect_depth_basic.result79
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_manual_compaction_delay_basic.result46
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_optimizer_no_zero_cardinality_basic.result64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_ignore_pk_basic.result64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_read_filter_ts_basic.result46
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_rec_ts_basic.result46
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_snapshot_ts_basic.result46
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_default_cf_options_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_delayed_write_rate_basic.result85
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_delete_cf_basic.result6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_delete_obsolete_files_period_micros_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_2pc_basic.result75
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_bulk_load_api_basic.result14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_insert_with_update_caching_basic.result75
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_thread_tracking_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_ttl_basic.result64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_ttl_read_filtering_basic.result64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_write_thread_adaptive_yield_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_error_if_exists_basic.result14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_error_on_suboptimal_collation_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_flush_log_at_trx_commit_basic.result57
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_compute_memtable_stats_basic.result15
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_compute_memtable_stats_cachetime_basic.result68
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_flush_memtable_and_lzero_now_basic.result50
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_flush_memtable_now_basic.result50
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_index_records_in_range_basic.result106
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_git_hash_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_hash_index_allow_collision_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_ignore_unknown_options_basic.result14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_index_type_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_info_log_level_basic.result93
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_io_write_timeout_basic.result86
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_is_fd_close_on_exec_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_keep_log_file_num_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_large_prefix_basic.result64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_lock_scanned_rows_basic.result170
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_lock_wait_timeout_basic.result72
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_log_file_time_to_roll_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_manifest_preallocation_size_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_manual_compaction_threads_basic.result93
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_manual_wal_flush_basic.result14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_master_skip_tx_api_basic.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_background_jobs_basic.result46
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_latest_deadlocks_basic.result53
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_log_file_size_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_manifest_file_size_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_manual_compactions_basic.result57
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_open_files_basic.result3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_row_locks_basic.result93
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_subcompactions_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_total_wal_size_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_merge_buf_size_basic.result43
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_merge_combine_read_size_basic.result29
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_merge_tmp_file_removal_delay_ms_basic.result93
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_new_table_reader_for_compaction_inputs_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_no_block_cache_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_override_cf_options_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_paranoid_checks_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_pause_background_work_basic.result75
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_perf_context_level_basic.result114
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_persistent_cache_path_basic.result13
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_persistent_cache_size_mb_basic.result14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_pin_l0_filter_and_index_blocks_in_cache_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_print_snapshot_conflict_queries_basic.result64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_rate_limiter_bytes_per_sec_basic.result101
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_read_free_rpl_basic.result58
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_read_free_rpl_tables_basic.result49
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_records_in_range_basic.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_remove_mariabackup_checkpoint_basic.result4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_reset_stats_basic.result97
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_rollback_on_timeout_basic.result97
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_seconds_between_stat_computes_basic.result64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_signal_drop_index_thread_basic.result64
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_sim_cache_size_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_skip_bloom_filter_on_read_basic.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_skip_fill_cache_basic.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_skip_unique_check_tables_basic.result67
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_sst_mgr_rate_bytes_per_sec_basic.result85
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_stats_dump_period_sec_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_stats_level_basic.result85
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_stats_recalc_rate_basic.result53
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_store_row_debug_checksums_basic.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_strict_collation_check_basic.result75
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_strict_collation_exceptions_basic.result36
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_supported_compression_types_basic.result4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_table_cache_numshardbits_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_table_stats_sampling_pct_basic.result85
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_tmpdir_basic.result29
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_trace_sst_api_basic.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_two_write_queues_basic.result14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_unsafe_for_binlog_basic.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_update_cf_options.result38
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_update_cf_options_basic.result126
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_adaptive_mutex_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_clock_cache_basic.result19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_direct_io_for_flush_and_compaction_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_direct_reads_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_fsync_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_validate_tables_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_verify_row_debug_checksums_basic.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_bytes_per_sync_basic.result85
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_dir_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_recovery_mode_basic.result46
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_size_limit_mb_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_ttl_seconds_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_whole_key_filtering_basic.result7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_batch_max_bytes_basic.result15
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_disable_wal_basic.result114
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_ignore_missing_column_families_basic.result100
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_policy_basic.result15
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/suite.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/suite.pm21
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/all_vars.test39
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/disabled.def5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_access_hint_on_compaction_start_basic.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_advise_random_on_open_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_concurrent_memtable_write_basic.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_mmap_reads_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_mmap_writes_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_to_start_after_corruption_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_blind_delete_primary_key_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_cache_size_basic.test21
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_restart_interval_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_size_basic.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_size_deviation_basic.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_allow_sk_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_allow_unsorted_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_size_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bytes_per_sync_basic.test22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_dump_basic.test21
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_high_pri_pool_ratio_basic.test24
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_index_and_filter_blocks_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_index_and_filter_with_high_priority_basic.test21
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_checksums_pct_basic.test17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_collect_sst_properties_basic.test8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_commit_in_the_middle_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_commit_time_batch_for_recovery_basic.test20
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compact_cf_basic.test19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_readahead_size_basic.test23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_count_sd_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_file_size_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_window_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_create_checkpoint_basic.test29
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_create_if_missing_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_create_missing_column_families_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_datadir_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_db_write_buffer_size_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_deadlock_detect_basic.test20
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_deadlock_detect_depth_basic.test17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_manual_compaction_delay_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_optimizer_no_zero_cardinality_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_ignore_pk_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_read_filter_ts_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_rec_ts_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_snapshot_ts_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_default_cf_options_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delayed_write_rate_basic.test22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delete_cf_basic-master.opt1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delete_cf_basic.test75
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delete_obsolete_files_period_micros_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_2pc_basic.test20
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_bulk_load_api_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_insert_with_update_caching_basic.test21
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_thread_tracking_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_ttl_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_ttl_read_filtering_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_write_thread_adaptive_yield_basic.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_error_if_exists_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_error_on_suboptimal_collation_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_flush_log_at_trx_commit_basic.test17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_compute_memtable_stats_basic.test23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_compute_memtable_stats_cachetime_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_flush_memtable_and_lzero_now_basic.test17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_flush_memtable_now_basic.test17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_index_records_in_range_basic.test23
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_git_hash_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_hash_index_allow_collision_basic.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_ignore_unknown_options_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_index_type_basic.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_info_log_level_basic.test21
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_io_write_timeout_basic.test20
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_is_fd_close_on_exec_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_keep_log_file_num_basic.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_large_prefix_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_lock_scanned_rows_basic.test22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_lock_wait_timeout_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_log_file_time_to_roll_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_manifest_preallocation_size_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_manual_compaction_threads_basic.test17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_manual_wal_flush_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_master_skip_tx_api_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_background_jobs_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_latest_deadlocks_basic.test17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_log_file_size_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_manifest_file_size_basic.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_manual_compactions_basic.test17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_open_files_basic.test8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_row_locks_basic.test17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_subcompactions_basic.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_total_wal_size_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_merge_buf_size_basic.test50
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_merge_combine_read_size_basic.test32
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_merge_tmp_file_removal_delay_ms_basic.test49
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_new_table_reader_for_compaction_inputs_basic.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_no_block_cache_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_override_cf_options_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_paranoid_checks_basic.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_pause_background_work_basic.test20
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_perf_context_level_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_persistent_cache_path_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_persistent_cache_size_mb_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_pin_l0_filter_and_index_blocks_in_cache_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_print_snapshot_conflict_queries_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rate_limiter_bytes_per_sec_basic.test63
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_read_free_rpl_basic.test19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_read_free_rpl_tables_basic.test20
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_records_in_range_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_remove_mariabackup_checkpoint_basic.test5
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_reset_stats_basic.test21
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rollback_on_timeout_basic.test21
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_seconds_between_stat_computes_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_signal_drop_index_thread_basic.test19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_sim_cache_size_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_skip_bloom_filter_on_read_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_skip_fill_cache_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_skip_unique_check_tables_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_sst_mgr_rate_bytes_per_sec_basic.test22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_stats_dump_period_sec_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_stats_level_basic.test21
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_stats_recalc_rate_basic.test17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_store_row_debug_checksums_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_strict_collation_check_basic.test19
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_strict_collation_exceptions_basic.test35
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_supported_compression_types_basic.test7
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_table_cache_numshardbits_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_table_stats_sampling_pct_basic.test22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_tmpdir_basic.test38
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_trace_sst_api_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_two_write_queues_basic.test16
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_unsafe_for_binlog_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_update_cf_options.test22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_update_cf_options_basic.test119
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_adaptive_mutex_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_clock_cache_basic.test21
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_direct_io_for_flush_and_compaction_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_direct_reads_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_fsync_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_validate_tables_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_verify_row_debug_checksums_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_bytes_per_sync_basic.test22
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_dir_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_recovery_mode_basic.test17
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_size_limit_mb_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_ttl_seconds_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_whole_key_filtering_basic.test6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_batch_max_bytes_basic.test26
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_disable_wal_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_ignore_missing_column_families_basic.test18
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_policy_basic.test17
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/cache_index.rdiff71
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/checksum_table_live.rdiff13
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/cleanup_engine.inc25
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/define_engine.inc45
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/disabled.def27
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/index.rdiff60
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/index_type_btree.rdiff60
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/index_type_hash.rdiff60
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/mask_engine.inc15
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/misc.rdiff34
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/parts/checksum_table.rdiff13
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/parts/create_table.rdiff20
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/parts/disabled.def3
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/parts/suite.opt1
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/show_engine.rdiff15
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/show_table_status.rdiff20
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/suite.opt1
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/tbl_opt_insert_method.rdiff11
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/tbl_opt_union.rdiff16
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/tbl_temporary.rdiff24
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/truncate_table.rdiff24
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/trx/delete.rdiff10
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/trx/disabled.def4
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/trx/insert.rdiff24
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/trx/level_read_committed.rdiff10
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/trx/level_repeatable_read.rdiff35
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/trx/suite.opt1
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/trx/update.rdiff38
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/type_binary_indexes.rdiff11
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/type_bit_indexes.rdiff20
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/type_enum_indexes.rdiff11
-rw-r--r--storage/rocksdb/mysql-test/storage_engine/type_set_indexes.rdiff20
1292 files changed, 103044 insertions, 0 deletions
diff --git a/storage/rocksdb/mysql-test/rocksdb/combinations b/storage/rocksdb/mysql-test/rocksdb/combinations
new file mode 100644
index 00000000..be8080d4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/combinations
@@ -0,0 +1,5 @@
+[write_committed]
+loose-rocksdb_write_policy=write_committed
+
+[write_prepared]
+loose-rocksdb_write_policy=write_prepared
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/autoinc_crash_safe.inc b/storage/rocksdb/mysql-test/rocksdb/include/autoinc_crash_safe.inc
new file mode 100644
index 00000000..ba2e7ace
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/autoinc_crash_safe.inc
@@ -0,0 +1,150 @@
+--echo #
+--echo # Testing concurrent transactions.
+--echo #
+
+--source include/count_sessions.inc
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+connect (con3,localhost,root,,);
+
+connection con1;
+begin;
+insert into t values (); # 1
+
+connection con2;
+begin;
+insert into t values (); # 2
+
+connection con3;
+begin;
+insert into t values (); # 3
+
+connection con1;
+insert into t values (); # 4
+
+connection con2;
+insert into t values (); # 5
+
+connection con3;
+insert into t values (); # 6
+
+connection con2;
+commit;
+
+connection con3;
+rollback;
+
+connection con1;
+commit;
+
+delete from t;
+
+--echo # Master value before restart
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+
+--echo # Slave value before restart
+sync_slave_with_master;
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+
+connection slave;
+--source include/stop_slave.inc
+--let $rpl_server_number = 1
+--source include/rpl_restart_server.inc
+
+connection default;
+--echo # Master value after restart
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+
+--let $rpl_server_number = 2
+--source include/rpl_restart_server.inc
+
+connection slave;
+--source include/start_slave.inc
+--echo # Slave value after restart
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+
+disconnect con1;
+disconnect con2;
+disconnect con3;
+--source include/wait_until_count_sessions.inc
+
+--echo #
+--echo # Testing interaction of merge markers with various DDL statements.
+--echo #
+connection slave;
+--source include/stop_slave.inc
+
+connection default;
+
+--echo # Drop and add primary key.
+alter table t modify i int;
+alter table t drop primary key;
+alter table t add primary key (i);
+alter table t modify i int auto_increment;
+
+--let $rpl_server_number = 1
+--source include/rpl_restart_server.inc
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+
+--echo # Remove auto_increment property.
+alter table t modify i int;
+--let $rpl_server_number = 1
+--source include/rpl_restart_server.inc
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+
+--echo # Add auto_increment property.
+insert into t values (123);
+alter table t modify i int auto_increment;
+--let $rpl_server_number = 1
+--source include/rpl_restart_server.inc
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+
+--echo # Add column j.
+alter table t add column j int;
+--let $rpl_server_number = 1
+--source include/rpl_restart_server.inc
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+
+--echo # Rename tables.
+rename table t to t2;
+rename table t2 to t;
+
+--let $rpl_server_number = 1
+--source include/rpl_restart_server.inc
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+
+--echo # Change auto_increment property
+alter table t auto_increment = 1000;
+--let $rpl_server_number = 1
+--source include/rpl_restart_server.inc
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+
+alter table t auto_increment = 1;
+--let $rpl_server_number = 1
+--source include/rpl_restart_server.inc
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+
+alter table t drop primary key, add key (i), auto_increment = 1;
+--let $rpl_server_number = 1
+--source include/rpl_restart_server.inc
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+
+alter table t add key (j), auto_increment = 1;
+--let $rpl_server_number = 1
+--source include/rpl_restart_server.inc
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+
+alter table t modify i int;
+alter table t add column (k int auto_increment), add key(k), auto_increment=15;
+--let $rpl_server_number = 1
+--source include/rpl_restart_server.inc
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+
+--echo # Drop table.
+drop table t;
+
+--let $rpl_server_number = 1
+--source include/rpl_restart_server.inc
+
+connection slave;
+--source include/start_slave.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/bulk_load.inc b/storage/rocksdb/mysql-test/rocksdb/include/bulk_load.inc
new file mode 100644
index 00000000..3bb766d5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/bulk_load.inc
@@ -0,0 +1,165 @@
+--source include/count_sessions.inc
+
+if ($data_order_desc)
+{
+ --echo Data will be ordered in descending order
+}
+
+if (!$data_order_desc)
+{
+ --echo Data will be ordered in ascending order
+}
+
+# Create a table with a primary key and one secondary key as well as one
+# more column
+eval CREATE TABLE t1(
+ pk CHAR(5),
+ a CHAR(30),
+ b CHAR(30),
+ PRIMARY KEY(pk) COMMENT "$pk_cf",
+ KEY(a)
+) ENGINE=ROCKSDB COLLATE 'latin1_bin';
+
+# Create a second identical table to validate that bulk loading different
+# tables in the same session works
+eval CREATE TABLE t2(
+ pk CHAR(5),
+ a CHAR(30),
+ b CHAR(30),
+ PRIMARY KEY(pk) COMMENT "$pk_cf",
+ KEY(a)
+) ENGINE=ROCKSDB COLLATE 'latin1_bin';
+
+# Create a third table using partitions to validate that bulk loading works
+# across a partitioned table
+eval CREATE TABLE t3(
+ pk CHAR(5),
+ a CHAR(30),
+ b CHAR(30),
+ PRIMARY KEY(pk) COMMENT "$pk_cf",
+ KEY(a)
+) ENGINE=ROCKSDB COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4;
+
+--let $file = `SELECT CONCAT(@@datadir, "test_loadfile.txt")`
+
+--let MTR_DATA_ORDER_DESC = $data_order_desc;
+
+# Create a text file with data to import into the table.
+# The primary key is in sorted order and the secondary keys are randomly generated
+--let ROCKSDB_INFILE = $file
+perl;
+my $fn = $ENV{'ROCKSDB_INFILE'};
+open(my $fh, '>', $fn) || die "perl open($fn): $!";
+my $max = 2500000;
+my $desc = $ENV{'MTR_DATA_ORDER_DESC'};
+my @chars = ("A".."Z", "a".."z", "0".."9");
+my @powers_of_26 = (26 * 26 * 26 * 26, 26 * 26 * 26, 26 * 26, 26, 1);
+for (my $ii = 0; $ii < $max; $ii++)
+{
+ my $pk;
+ my $tmp = $ii;
+ foreach (@powers_of_26)
+ {
+ if ($desc == 1)
+ {
+ $pk .= chr(ord('z') - int($tmp / $_));
+ }
+ else
+ {
+ $pk .= chr(ord('a') + int($tmp / $_));
+ }
+
+ $tmp = $tmp % $_;
+ }
+
+ my $num = int(rand(25)) + 6;
+ my $a;
+ $a .= $chars[rand(@chars)] for 1..$num;
+
+ $num = int(rand(25)) + 6;
+ my $b;
+ $b .= $chars[rand(@chars)] for 1..$num;
+ print $fh "$pk\t$a\t$b\n";
+}
+close($fh);
+EOF
+
+--file_exists $file
+
+# Make sure a snapshot held by another user doesn't block the bulk load
+connect (other,localhost,root,,);
+set session transaction isolation level repeatable read;
+start transaction with consistent snapshot;
+
+# Assert that there is a pending snapshot
+select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
+
+connection default;
+
+# Update CF to smaller value to create multiple SST in ingestion
+eval SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=
+ '$pk_cf_name={write_buffer_size=8m;target_file_size_base=1m};';
+
+set rocksdb_bulk_load=1;
+set rocksdb_bulk_load_size=100000;
+--disable_query_log
+--echo LOAD DATA INFILE <input_file> INTO TABLE t1;
+eval LOAD DATA INFILE '$file' INTO TABLE t1;
+# There should be no SST being ingested
+select * from t1;
+--echo LOAD DATA INFILE <input_file> INTO TABLE t2;
+eval LOAD DATA INFILE '$file' INTO TABLE t2;
+# There should be no SST being ingested
+select * from t2;
+--echo LOAD DATA INFILE <input_file> INTO TABLE t3;
+eval LOAD DATA INFILE '$file' INTO TABLE t3;
+# There should be no SST being ingested
+select * from t3;
+--enable_query_log
+set rocksdb_bulk_load=0;
+
+--remove_file $file
+
+# Make sure row count index stats are correct
+--replace_column 6 # 7 # 8 # 9 # 12 # 13 #
+SHOW TABLE STATUS WHERE name LIKE 't%';
+
+ANALYZE TABLE t1, t2, t3;
+
+--replace_column 6 # 7 # 8 # 9 # 12 # 13 #
+SHOW TABLE STATUS WHERE name LIKE 't%';
+
+# Make sure all the data is there.
+select count(pk),count(a) from t1;
+select count(b) from t1;
+select count(pk),count(a) from t2;
+select count(b) from t2;
+select count(pk),count(a) from t3;
+select count(b) from t3;
+
+# Create a dummy file with a bulk load extesion. It should be removed when
+# the server starts
+--let $tmpext = .bulk_load.tmp
+--let $MYSQLD_DATADIR= `SELECT @@datadir`
+--let $datadir = $MYSQLD_DATADIR/#rocksdb
+--write_file $datadir/test$tmpext
+dummy data
+EOF
+--write_file $datadir/longfilenamethatvalidatesthatthiswillgetdeleted$tmpext
+dummy data
+EOF
+
+# Show the files exists
+--list_files $datadir *$tmpext
+
+# Now restart the server and make sure it automatically removes this test file
+--source include/restart_mysqld.inc
+
+# Show the files do not exist
+--list_files $datadir *$tmpext
+
+# Cleanup
+disconnect other;
+DROP TABLE t1, t2, t3;
+
+--source include/wait_until_count_sessions.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/bulk_load_unsorted.inc b/storage/rocksdb/mysql-test/rocksdb/include/bulk_load_unsorted.inc
new file mode 100644
index 00000000..d6bee980
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/bulk_load_unsorted.inc
@@ -0,0 +1,143 @@
+--source include/have_partition.inc
+--source include/count_sessions.inc
+
+SET rocksdb_bulk_load_size=3;
+SET rocksdb_bulk_load_allow_unsorted=1;
+
+### Test individual INSERTs ###
+
+# A table with only a PK won't have rows until the bulk load is finished
+eval CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a) COMMENT "$pk_cf")
+ ENGINE=ROCKSDB;
+SET rocksdb_bulk_load=1;
+--disable_query_log
+let $sign = 1;
+let $max = 5;
+let $i = 1;
+while ($i <= $max) {
+ let $a = 1 + $sign * $i;
+ let $b = 1 - $sign * $i;
+ let $sign = -$sign;
+ let $insert = INSERT INTO t1 VALUES ($a, $b);
+ eval $insert;
+ inc $i;
+}
+--enable_query_log
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+DROP TABLE t1;
+
+# A table with a PK and a SK shows rows immediately
+eval CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a) COMMENT "$pk_cf", KEY(b))
+ ENGINE=ROCKSDB;
+SET rocksdb_bulk_load=1;
+--disable_query_log
+let $sign = 1;
+let $max = 5;
+let $i = 1;
+while ($i <= $max) {
+ let $a = 1 + $sign * $i;
+ let $b = 1 - $sign * $i;
+ let $sign = -$sign;
+ let $insert = INSERT INTO t1 VALUES ($a, $b);
+ eval $insert;
+ inc $i;
+}
+--enable_query_log
+
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+DROP TABLE t1;
+
+# Inserting into another table finishes bulk load to the previous table
+eval CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a) COMMENT "$pk_cf")
+ ENGINE=ROCKSDB;
+eval CREATE TABLE t2(a INT, b INT, PRIMARY KEY(a) COMMENT "$pk_cf")
+ ENGINE=ROCKSDB;
+
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t2 VALUES (1,1);
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+INSERT INTO t1 VALUES (2,2);
+SELECT * FROM t2 FORCE INDEX (PRIMARY);
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+DROP TABLE t1, t2;
+
+### Test bulk load from a file ###
+eval CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a) COMMENT "$pk_cf")
+ ENGINE=ROCKSDB;
+eval CREATE TABLE t2(a INT, b INT, PRIMARY KEY(b) COMMENT "$pk_cf")
+ ENGINE=ROCKSDB;
+eval CREATE TABLE t3(a INT, b INT, PRIMARY KEY(a) COMMENT "$pk_cf")
+ ENGINE=ROCKSDB PARTITION BY KEY() PARTITIONS 4;
+
+--let $file = `SELECT CONCAT(@@datadir, "test_loadfile.txt")`
+# Create a text file with data to import into the table.
+# PK and SK are not in any order
+--let ROCKSDB_INFILE = $file
+perl;
+my $fn = $ENV{'ROCKSDB_INFILE'};
+open(my $fh, '>', $fn) || die "perl open($fn): $!";
+binmode $fh;
+my $max = 2500000;
+my $sign = 1;
+for (my $ii = 0; $ii < $max; $ii++)
+{
+ my $a = 1 + $sign * $ii;
+ my $b = 1 - $sign * $ii;
+ $sign = -$sign;
+ print $fh "$a\t$b\n";
+}
+close($fh);
+EOF
+--file_exists $file
+
+# Make sure a snapshot held by another user doesn't block the bulk load
+connect (other,localhost,root,,);
+set session transaction isolation level repeatable read;
+start transaction with consistent snapshot;
+
+# Assert that there is a pending snapshot
+select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
+
+connection default;
+set rocksdb_bulk_load=1;
+set rocksdb_bulk_load_size=100000;
+--disable_query_log
+--echo LOAD DATA INFILE <input_file> INTO TABLE t1;
+eval LOAD DATA INFILE '$file' INTO TABLE t1;
+--echo LOAD DATA INFILE <input_file> INTO TABLE t2;
+eval LOAD DATA INFILE '$file' INTO TABLE t2;
+--echo LOAD DATA INFILE <input_file> INTO TABLE t3;
+eval LOAD DATA INFILE '$file' INTO TABLE t3;
+--enable_query_log
+set rocksdb_bulk_load=0;
+
+--remove_file $file
+
+# Make sure row count index stats are correct
+--replace_column 6 # 7 # 8 # 9 # 12 # 13 #
+SHOW TABLE STATUS WHERE name LIKE 't%';
+
+ANALYZE TABLE t1, t2, t3;
+
+--replace_column 6 # 7 # 8 # 9 # 12 # 13 #
+SHOW TABLE STATUS WHERE name LIKE 't%';
+
+# Make sure all the data is there.
+select count(a),count(b) from t1;
+select count(a),count(b) from t2;
+select count(a),count(b) from t3;
+
+SELECT * FROM t1 FORCE INDEX (PRIMARY) LIMIT 3;
+SELECT * FROM t2 FORCE INDEX (PRIMARY) LIMIT 3;
+
+disconnect other;
+DROP TABLE t1, t2, t3;
+
+--source include/wait_until_count_sessions.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/bypass_create_table.inc b/storage/rocksdb/mysql-test/rocksdb/include/bypass_create_table.inc
new file mode 100644
index 00000000..233635b3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/bypass_create_table.inc
@@ -0,0 +1,298 @@
+CREATE TABLE `link_table` (
+ `id1` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+ `id1_type` int(10) unsigned NOT NULL DEFAULT '0' ,
+ `id2` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+ `id2_type` int(10) unsigned NOT NULL DEFAULT '0' ,
+ `link_type` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+ `visibility` tinyint(3) NOT NULL DEFAULT '0' ,
+ `data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '' ,
+ `time` int(10) unsigned NOT NULL DEFAULT '0' ,
+ `version` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+ PRIMARY KEY (`link_type` , `id1` , `id2`) COMMENT 'cf_link' ,
+ KEY `id1_type` (`id1` , `link_type` , `visibility` , `time` , `id2` ,
+ `version` , `data`) COMMENT 'rev:cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+
+CREATE TABLE `link_table2` (
+ `id1` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+ `id1_type` int(10) unsigned NOT NULL DEFAULT '0' ,
+ `id2` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+ `id2_type` int(10) unsigned NOT NULL DEFAULT '0' ,
+ `link_type` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+ `visibility` tinyint(3) NOT NULL DEFAULT '0' ,
+ `data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '' ,
+ `time` int(10) unsigned NOT NULL DEFAULT '0' ,
+ `version` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+ PRIMARY KEY (`link_type` , `id1` , `id2`)
+ COMMENT 'cf_link' ,
+ KEY `id1_type` (`id1` , `link_type` , `visibility` , `time` , `id2` ,
+ `version` , `data`) COMMENT 'cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=9;
+
+insert into link_table values (1, 1, 1, 2, 3, 4, 'a10', 10, 125);
+insert into link_table values (1, 1, 2, 2, 3, 3, 'a10', 10, 125);
+insert into link_table values (1, 1, 3, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (1, 1, 4, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (1, 1, 5, 2, 3, 3, 'a12', 12, 125);
+insert into link_table values (1, 1, 6, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (1, 1, 7, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (1, 1, 8, 2, 3, 4, 'a13', 13, 125);
+insert into link_table values (1, 1, 9, 2, 3, 4, 'a14', 14, 125);
+insert into link_table values (1, 1, 10, 2, 3, 4, 'a15', 15, 125);
+insert into link_table values (2, 1, 1, 2, 3, 4, 'a10', 10, 125);
+insert into link_table values (2, 1, 2, 2, 3, 4, 'a10', 10, 125);
+insert into link_table values (2, 1, 3, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (2, 1, 4, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (2, 1, 5, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 6, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 7, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 8, 2, 3, 4, 'a13', 13, 125);
+insert into link_table values (2, 1, 9, 2, 3, 4, 'a14', 14, 125);
+insert into link_table values (2, 1, 10, 2, 3, 4, 'a15', 15, 125);
+insert into link_table values (2, 1, 1, 2, 4, 4, 'a10', 10, 125);
+insert into link_table values (2, 1, 2, 2, 4, 4, 'a10', 10, 125);
+insert into link_table values (2, 1, 3, 2, 4, 4, 'a11', 11, 125);
+insert into link_table values (2, 1, 4, 2, 4, 4, 'a11', 11, 125);
+insert into link_table values (2, 1, 5, 2, 4, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 6, 2, 4, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 7, 2, 4, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 8, 2, 4, 4, 'a13', 13, 125);
+insert into link_table values (2, 1, 9, 2, 4, 4, 'a14', 14, 125);
+insert into link_table values (2, 1, 10, 2, 4, 4, 'a15', 15, 125);
+insert into link_table values (3, 1, 10, 2, 3, 4, 'a10', 10, 125);
+insert into link_table values (3, 1, 9, 2, 3, 4, 'a10', 10, 125);
+insert into link_table values (3, 1, 8, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (3, 1, 7, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (3, 1, 6, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (3, 1, 5, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (3, 1, 4, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (3, 1, 3, 2, 3, 4, 'a13', 13, 125);
+insert into link_table values (3, 1, 2, 2, 3, 4, 'a14', 14, 125);
+insert into link_table values (3, 1, 1, 2, 3, 4, 'a15', 15, 125);
+insert into link_table values (9, 1, 9, 2, 5, 6, '0 ', 10, 125);
+insert into link_table values (9, 1, 8, 2, 5, 6, '01 ', 11, 125);
+insert into link_table values (9, 1, 7, 2, 5, 6, '012 ', 11, 125);
+insert into link_table values (9, 1, 6, 2, 5, 6, '0123 ', 12, 125);
+insert into link_table values (9, 1, 5, 2, 5, 6, '01234 ', 12, 125);
+insert into link_table values (9, 1, 4, 2, 5, 6, '012345 ', 12, 125);
+insert into link_table values (9, 1, 3, 2, 5, 6, '0123456 ', 13, 125);
+insert into link_table values (9, 1, 2, 2, 5, 6, '01234567 ', 14, 125);
+insert into link_table values (9, 1, 1, 2, 5, 6, '012345678 ', 15, 125);
+insert into link_table values (9, 1, 0, 2, 5, 6, '0123456789 ', 15, 125);
+
+insert into link_table2 select * from link_table;
+
+CREATE TABLE `id_table` (
+ `id` bigint(20) NOT NULL DEFAULT '0',
+ `type` int(11) NOT NULL DEFAULT '0',
+ `row_created_time` int(11) NOT NULL DEFAULT '0',
+ `hash_key` varchar(255) NOT NULL DEFAULT '',
+ `is_deleted` tinyint(4) DEFAULT '0',
+ PRIMARY KEY (`id`),
+ KEY `type_id` (`type`,`id`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED
+KEY_BLOCK_SIZE=8;
+
+insert into id_table values (1, 1, 10, '111', 0);
+insert into id_table values (2, 1, 10, '111', 1);
+insert into id_table values (3, 1, 10, '111', 0);
+insert into id_table values (4, 1, 10, '111', 1);
+insert into id_table values (5, 1, 10, '111', 0);
+insert into id_table values (6, 1, 10, '111', 1);
+insert into id_table values (7, 1, 10, '111', 0);
+insert into id_table values (8, 1, 10, '111', 1);
+insert into id_table values (9, 1, 10, '111', 0);
+insert into id_table values (10, 1, 10, '111', 1);
+
+CREATE TABLE `node_table` (
+ `id` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `type` int(10) unsigned NOT NULL DEFAULT '0',
+ `version` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `update_time` int(10) unsigned NOT NULL DEFAULT '0',
+ `data` mediumtext COLLATE latin1_bin NOT NULL,
+ PRIMARY KEY (`type`,`id`) COMMENT 'cf_node_type_id',
+ KEY `id` (`id`) COMMENT 'cf_node'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+
+insert into node_table values (1, 1, 1, 10, 'data');
+
+insert into node_table values (2, 1, 1, 10, 'data');
+
+insert into node_table values (3, 1, 1, 10, 'data');
+
+insert into node_table values (4, 1, 1, 10, 'data');
+
+insert into node_table values (5, 1, 1, 10, 'data');
+
+insert into node_table values (6, 1, 1, 10, 'data');
+
+insert into node_table values (7, 1, 1, 10, 'data');
+
+insert into node_table values (8, 1, 1, 10, 'data');
+
+insert into node_table values (9, 1, 1, 10, 'data');
+
+insert into node_table values (10, 1, 1, 10, 'data');
+
+CREATE TABLE `count_table` (
+ `id` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `type` int(10) unsigned NOT NULL DEFAULT '0',
+ `link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `count` int(10) unsigned NOT NULL DEFAULT '0',
+ `time` int(10) unsigned NOT NULL DEFAULT '0',
+ `version` bigint(20) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (`id`,`link_type`) COMMENT 'cf_count_table'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+
+
+insert into count_table values (2, 1, 1, 1, 10, 20);
+
+insert into count_table values (3, 1, 1, 1, 10, 20);
+
+insert into count_table values (4, 1, 1, 1, 10, 20);
+
+insert into count_table values (5, 1, 1, 1, 10, 20);
+
+insert into count_table values (6, 1, 1, 1, 10, 20);
+
+insert into count_table values (7, 1, 1, 1, 10, 20);
+
+insert into count_table values (8, 1, 1, 1, 10, 20);
+
+insert into count_table values (9, 1, 1, 1, 10, 20);
+
+insert into count_table values (10, 1, 1, 1, 10, 20);
+
+CREATE TABLE `link_table5` (
+ `id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+ `id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+ `link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `visibility` tinyint(3) NOT NULL DEFAULT '0',
+ `data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '',
+ `time` int(10) unsigned NOT NULL DEFAULT '0',
+ `version` bigint(20) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+
+insert into link_table5 values (1, 1, 2, 2, 1, 1, 'data12', 1, 1);
+insert into link_table5 values (1, 1, 3, 2, 1, 2, 'data13', 1, 1);
+insert into link_table5 values (1, 1, 4, 2, 1, 2, 'data14', 1, 1);
+insert into link_table5 values (1, 1, 5, 2, 1, 1, 'data15', 1, 1);
+insert into link_table5 values (2, 1, 1, 2, 1, 1, 'data21', 1, 1);
+insert into link_table5 values (2, 1, 2, 2, 1, 1, 'data22', 1, 1);
+insert into link_table5 values (2, 1, 3, 2, 1, 1, 'data32', 1, 1);
+
+
+CREATE TABLE `link_table3` (
+ `id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+ `id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+ `link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `visibility` tinyint(4) NOT NULL DEFAULT '0',
+ `data` text COLLATE latin1_bin NOT NULL,
+ `time` int(10) unsigned NOT NULL DEFAULT '0',
+ `version` bigint(20) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link',
+ KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`id2`,`version`)
+ COMMENT 'rev:cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+
+insert into link_table3 values (1, 1, 2, 2, 1, 1, 'data12', 1, 1);
+insert into link_table3 values (1, 1, 3, 2, 1, 2, 'data13', 1, 1);
+insert into link_table3 values (1, 1, 4, 2, 1, 2, 'data14', 1, 1);
+insert into link_table3 values (1, 1, 5, 2, 1, 1, 'data15', 1, 1);
+insert into link_table3 values (2, 1, 1, 2, 1, 1, 'data21', 1, 1);
+insert into link_table3 values (2, 1, 2, 2, 1, 1, 'data22', 1, 1);
+insert into link_table3 values (2, 1, 3, 2, 1, 1, 'data32', 1, 1);
+
+CREATE TABLE `link_table6` (
+ `id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+ `id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+ `link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `visibility` tinyint(4) NOT NULL DEFAULT '0',
+ `data` text COLLATE latin1_bin NOT NULL,
+ `time` int(10) unsigned NOT NULL DEFAULT '0',
+ `version` bigint(20) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link',
+ KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`id2`,`version`,
+ `data`(255)) COMMENT 'rev:cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+
+insert into link_table6 values (1, 1, 2, 2, 1, 1,
+ 'data12_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (1, 1, 3, 2, 1, 2,
+ 'data13_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (1, 1, 4, 2, 1, 2,
+ 'data14_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (1, 1, 5, 2, 1, 1,
+ 'data15_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (2, 1, 1, 2, 1, 1,
+ 'data21_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (2, 1, 2, 2, 1, 1,
+ 'data22_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (2, 1, 3, 2, 1, 1,
+ 'data32_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+
+CREATE TABLE `link_table4` (
+ `id1` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
+ `raw_key` text COLLATE latin1_bin,
+ `id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+ `link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `visibility` tinyint(3) NOT NULL DEFAULT '0',
+ `data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '',
+ `time` int(10) unsigned NOT NULL DEFAULT '0',
+ `version` bigint(20) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link',
+ KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`id2`,`version`,`data`)
+ COMMENT 'rev:cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+
+insert into link_table4 values ('a1', "rk1", 2, 2, 1, 1, 'data12', 1, 1);
+insert into link_table4 values ('a1', "rk2", 3, 2, 1, 2, 'data13', 1, 1);
+insert into link_table4 values ('a1', "rk3", 4, 2, 1, 2, 'data14', 1, 1);
+insert into link_table4 values ('a1', "rk4", 5, 2, 1, 1, 'data15', 1, 1);
+insert into link_table4 values ('b1', "rk5", 1, 2, 1, 1, 'data21', 1, 1);
+insert into link_table4 values ('b1', "rk6", 2, 2, 1, 1, 'data22', 1, 1);
+insert into link_table4 values ('b1', "rk7", 3, 2, 1, 1, 'data32', 1, 1);
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/ddl_high_priority.inc b/storage/rocksdb/mysql-test/rocksdb/include/ddl_high_priority.inc
new file mode 100644
index 00000000..7adca5d7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/ddl_high_priority.inc
@@ -0,0 +1,174 @@
+###############################################################################
+# Common test file for high priority DDL
+###############################################################################
+
+
+create user test_user1@localhost;
+grant all on test to test_user1@localhost;
+create user test_user2@localhost;
+grant all on test to test_user2@localhost;
+
+# Default values
+--let $con_block = con1
+--let $con_kill = default
+--let $should_kill = 1
+--let $recreate_table = 1
+--let $throw_error = 1
+
+##
+## killing conflicting shared locks by alter table
+##
+
+--let $blocking_sql = lock tables t1 read;
+--let $cmd = alter table t1 modify i bigint;
+--let $high_priority_cmd = alter high_priority table t1 modify i bigint;
+
+--source include/ddl_high_priority_module.inc
+
+##
+## killing conflicting shared lock in a transaction
+## transaction will rollback
+##
+
+--let $blocking_sql = begin; insert into t1 values (4); select i from t1;
+--let $cmd = alter table t1 rename t1_new;
+--let $high_priority_cmd = alter high_priority table t1 rename t1_new;
+
+--source include/ddl_high_priority_module.inc
+
+select * from t1_new;
+drop table t1_new;
+
+##
+## simulate conflicting DDL which will not be killed
+##
+
+# Simulate conflicting DDL
+# This will hold MDL_SHARED_NO_READ_WRITE, which may be upgraded to exclusive
+# locks to run DDLs like ALTER TABLE
+# the upgradable/exclusive lock should not be killed
+
+--let $should_kill = 0
+
+--let $blocking_sql = lock tables t1 write;
+--let $cmd = drop table t1;
+--let $high_priority_cmd = drop high_priority table t1;
+
+--source include/ddl_high_priority_module.inc
+
+# restore $should_kill
+--let $should_kill = 1
+
+##
+## killing conflicting transaction by drop table DDL
+##
+
+--let $blocking_sql = lock tables t1 read; begin; insert into t1 values (4);
+--let $cmd = drop table t1;
+--let $high_priority_cmd = drop high_priority table t1;
+
+--source include/ddl_high_priority_module.inc
+
+##
+## no effect for regular users
+##
+
+connect (con2,localhost,test_user2,,test,,);
+# $con_kill is regular user
+--let $con_kill = con2
+--let $should_kill = 0
+
+--let $blocking_sql = lock tables t1 read;
+--let $cmd = alter table t1 modify i bigint;
+--let $high_priority_cmd = alter high_priority table t1 modify i bigint;
+
+--source include/ddl_high_priority_module.inc
+
+disconnect con2;
+
+# restore $con_kill
+--let $con_kill = default
+# restore $should_kill
+--let $should_kill = 1
+
+##
+## create/drop index
+##
+
+# create index
+
+--let $blocking_sql = lock tables t1 read;
+--let $cmd = create index idx1 on t1 (i);
+--let $high_priority_cmd = create high_priority index idx1 on t1 (i);
+
+--source include/ddl_high_priority_module.inc
+
+# drop index (use the previously created table)
+--let $recreate_table = 0
+
+--let $cmd = drop index idx1 on t1;
+--let $high_priority_cmd = drop high_priority index idx1 on t1;
+
+--source include/ddl_high_priority_module.inc
+
+# restore $recreate_table
+--let $recreate_table = 1
+
+##
+## high_priority truncate table
+##
+
+--let $blocking_sql = lock tables t1 read;
+--let $cmd = truncate t1;
+--let $high_priority_cmd = truncate high_priority t1;
+
+--source include/ddl_high_priority_module.inc
+
+##
+## high_priority create/drop trigger
+##
+
+--let $blocking_sql = lock tables t1 read;
+--let $cmd = create trigger ins_sum before insert on t1 for each row set @sum = @sum + new.i;
+--let $high_priority_cmd = create high_priority trigger ins_sum before insert on t1 for each row set @sum = @sum + new.i;
+
+--source include/ddl_high_priority_module.inc
+
+# drop trigger (use the previously created table)
+--let $recreate_table = 0
+
+--let $cmd = drop trigger ins_sum;
+--let $high_priority_cmd = drop high_priority trigger ins_sum;
+
+--source include/ddl_high_priority_module.inc
+
+# restore $recreate_table
+--let $recreate_table = 1
+
+##
+## high_priority optimize table
+##
+## "optimize table" doesn't throw errors. It catches all errors, and
+## returns a result set in a table
+##
+
+--let $throw_error = 0
+
+--let $blocking_sql = lock tables t1 read;
+--let $cmd = optimize table t1;
+--let $high_priority_cmd = optimize high_priority table t1;
+
+--source include/ddl_high_priority_module.inc
+
+# restore throw_error
+--let $throw_error = 1
+
+##
+## clean up
+##
+
+drop user test_user1@localhost;
+drop user test_user2@localhost;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/ddl_high_priority_module.inc b/storage/rocksdb/mysql-test/rocksdb/include/ddl_high_priority_module.inc
new file mode 100644
index 00000000..ffbdc306
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/ddl_high_priority_module.inc
@@ -0,0 +1,141 @@
+###############################################################################
+# This file plays as a function/module for ddl_high_priority test
+#
+# Usage: set the following variables before including
+#
+# $use_sys_var: whether using sys_var or syntax to trigger high_priority
+# value: 0/1
+#
+# $con_block: a blocking connection
+# value: con1/con2/default
+#
+# $con_kill: a connection that will attempt to kill $con_blocking
+# value: con1/con2/default
+#
+# $cmd: a regular command to evaluate (to use with sys var)
+# value: sql command
+#
+# $high_priority_cmd: a high_priority command to evaluate
+# value: sql command
+#
+# $should_kill: Expect the con_block to be killed or not
+# value: 0/1
+#
+# $recreate_table: Should recreate the test table or not
+# value: 0/1
+#
+# $throw_error: whether a command will throw lock_wait_timeout error.
+# Note, optimize table catches all errors.
+# value: 0/1
+###############################################################################
+
+##
+## Print out the parameters of the test set
+## (useful for debugging)
+##
+--echo
+--echo ## Test parameters:
+--echo ## use_sys_var = $use_sys_var
+--echo ## con_block = $con_block
+--echo ## con_kill = $con_kill
+--echo ## cmd = $cmd
+--echo ## high_priority_cmd = $high_priority_cmd
+--echo ## should_kill = $should_kill
+--echo ## recreate_table = $recreate_table
+--echo ## throw_error = $throw_error
+--echo
+
+
+##
+## Setup
+##
+
+connection default;
+
+# create con1
+connect (con1,localhost,test_user1,,test,,);
+
+if ($recreate_table) {
+ # create t1
+ --disable_warnings
+ drop table if exists t1;
+ --enable_warnings
+ create table t1 (i int);
+ show create table t1;
+ insert into t1 values (1), (2), (3);
+}
+
+##
+## Testing
+##
+
+--echo connection: $con_block
+--connection $con_block
+--eval $blocking_sql
+
+--echo connection: $con_kill
+--connection $con_kill
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+
+describe t1;
+
+--echo connection: default (for show processlist)
+connection default;
+--echo # both $con_block and $con_kill exist
+--replace_column 1 <Id> 3 <Host> 5 <Command> 6 <Time> 7 <State> 8 <Info> 9 <RExam> 10 <RSent> 11 <TID>
+show processlist;
+
+--echo connection: $con_kill
+--connection $con_kill
+
+# command will fail without high_priority
+if ($throw_error) {
+ --error ER_LOCK_WAIT_TIMEOUT
+ --eval $cmd
+}
+
+if (!$throw_error) {
+ --eval $cmd
+}
+
+if ($use_sys_var) {
+ set high_priority_ddl = 1;
+ select @@high_priority_ddl;
+
+ # non-supported command will timeout
+ --error ER_LOCK_WAIT_TIMEOUT
+ lock tables t1 write;
+
+ if (!$should_kill) {
+ # regular user ddl will fail regardless of high_priority_ddl being on
+ --error ER_LOCK_WAIT_TIMEOUT
+ --eval $cmd
+ }
+
+ if ($should_kill) {
+ --eval $cmd
+ }
+
+ # reset high_priority_ddl
+ set high_priority_ddl = 0;
+}
+
+if (!$use_sys_var) {
+ if (!$should_kill) {
+ # regular user ddl will fail regardless of high_priority being on
+ --error ER_LOCK_WAIT_TIMEOUT
+ --eval $high_priority_cmd
+ }
+
+ if ($should_kill) {
+ --eval $high_priority_cmd
+ }
+}
+
+--echo connection: default (for show processlist)
+connection default;
+--replace_column 1 <Id> 3 <Host> 5 <Command> 6 <Time> 7 <State> 8 <Info> 9 <RExam> 10 <RSent> 11 <TID>
+show processlist;
+
+disconnect con1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/deadlock_stats.inc b/storage/rocksdb/mysql-test/rocksdb/include/deadlock_stats.inc
new file mode 100644
index 00000000..48ef6f81
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/deadlock_stats.inc
@@ -0,0 +1,52 @@
+let $prior_set_lwt = `select concat('set @prior_lock_wait_timeout = @@',
+ '$engine', '_lock_wait_timeout;')`;
+let $prior_set_dld = `select concat('set @prior_deadlock_detect = @@',
+ '$engine', '_deadlock_detect;')`;
+let $global_dld = `select concat('set global ', '$engine',
+ '_deadlock_detect = on;')`;
+let $global_lwt = `select concat('set global ', '$engine',
+ '_lock_wait_timeout = 100000;')`;
+eval $prior_set_lwt $prior_set_dld $global_dld $global_lwt;
+
+--source include/count_sessions.inc
+connect (con1,localhost,root,,);
+let $con1= `SELECT CONNECTION_ID()`;
+
+connect (con2,localhost,root,,);
+let $con2= `SELECT CONNECTION_ID()`;
+
+connection default;
+eval create table t (i int primary key) engine=$engine;
+insert into t values (1), (2), (3);
+
+--echo #
+--echo # The following is disabled due:
+--echo # MDEV-13404: MyRocks upstream uses I_S.table_statistics.row_lock_deadlocks, should we import?
+--echo #
+--disable_parsing
+--source include/simple_deadlock.inc
+connection default;
+select row_lock_deadlocks from information_schema.table_statistics where
+table_name = "t";
+
+select row_lock_deadlocks from information_schema.table_statistics where
+table_name = "t";
+--source include/simple_deadlock.inc
+connection default;
+select row_lock_deadlocks from information_schema.table_statistics where
+table_name = "t";
+
+select row_lock_deadlocks from information_schema.table_statistics where
+table_name = "t";
+--enable_parsing
+
+disconnect con1;
+disconnect con2;
+
+let $restore_lwt = `select concat('set global ', '$engine',
+ '_lock_wait_timeout = @prior_lock_wait_timeout;')`;
+let $restore_dld = `select concat('set global ', '$engine',
+ '_deadlock_detect = @prior_deadlock_detect;')`;
+eval $restore_lwt $restore_dld;
+drop table t;
+--source include/wait_until_count_sessions.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/dup_key_update.inc b/storage/rocksdb/mysql-test/rocksdb/include/dup_key_update.inc
new file mode 100644
index 00000000..82ceda19
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/dup_key_update.inc
@@ -0,0 +1,69 @@
+let $max_table = 2;
+
+--disable_query_log
+let $table = 1;
+while ($table <= $max_table) {
+ let $max = 9;
+ let $i = 2;
+ while ($i <= $max) {
+ let $insert = INSERT INTO t$table VALUES ($i, $i, $i);
+ eval $insert;
+ inc $i;
+ }
+ inc $table;
+}
+--enable_query_log
+
+let $table = 1;
+while ($table <= $max_table) {
+ let $i = 1;
+ let $j = 9;
+ while ($i <= $max) {
+
+ let $insert = INSERT INTO t$table VALUES ($i, $i, $i) ON DUPLICATE KEY UPDATE id2 = $j;
+ eval $insert;
+
+ let $select = SELECT * FROM t$table WHERE id1 = $i;
+ eval $select;
+
+ let $select = SELECT * FROM t$table FORCE INDEX (id3) WHERE id3 = $i;
+ eval $select;
+
+ inc $j;
+
+ let $insert = INSERT INTO t$table VALUES ($i, $i, $i) ON DUPLICATE KEY UPDATE id2 = $j;
+ eval $insert;
+
+ let $select = SELECT * FROM t$table WHERE id1 = $i;
+ eval $select;
+
+ let $select = SELECT * FROM t$table FORCE INDEX (id3) WHERE id3 = $i;
+ eval $select;
+
+ inc $j;
+
+ let $insert = INSERT INTO t$table VALUES ($i, $i, $i) ON DUPLICATE KEY UPDATE id2 = $j;
+ eval $insert;
+
+ let $select = SELECT * FROM t$table WHERE id1 = $i;
+ eval $select;
+
+ let $select = SELECT * FROM t$table FORCE INDEX (id3) WHERE id3 = $i;
+ eval $select;
+
+ inc $j;
+
+ inc $i;
+ inc $i;
+ inc $i;
+ inc $i;
+ }
+
+ let $select = SELECT * FROM t$table;
+ eval $select;
+
+ let $select = SELECT * FROM t$table FORCE INDEX (id3);
+ eval $select;
+
+ inc $table;
+}
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/group_min_max.inc b/storage/rocksdb/mysql-test/rocksdb/include/group_min_max.inc
new file mode 100644
index 00000000..40fabce0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/group_min_max.inc
@@ -0,0 +1,1438 @@
+#
+# Test file for WL#1724 (Min/Max Optimization for Queries with Group By Clause).
+# The queries in this file test query execution via QUICK_GROUP_MIN_MAX_SELECT.
+#
+
+#
+# TODO:
+# Add queries with:
+# - C != const
+# - C IS NOT NULL
+# - HAVING clause
+
+--source include/default_optimizer_switch.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+eval create table t1 (
+ a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(248) default ' '
+) engine=$engine;
+
+insert into t1 (a1, a2, b, c, d) values
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
+('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
+('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
+('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
+('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'),
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
+('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
+('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
+('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
+('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4');
+
+create index idx_t1_0 on t1 (a1);
+create index idx_t1_1 on t1 (a1,a2,b,c);
+create index idx_t1_2 on t1 (a1,a2,b);
+analyze table t1;
+
+# t2 is the same as t1, but with some NULLs in the MIN/MAX column, and
+# one more nullable attribute
+
+--disable_warnings
+drop table if exists t2;
+--enable_warnings
+
+eval create table t2 (
+ a1 char(64), a2 char(64) not null, b char(16), c char(16), d char(16), dummy char(248) default ' '
+) engine=$engine;
+insert into t2 select * from t1;
+# add few rows with NULL's in the MIN/MAX column
+insert into t2 (a1, a2, b, c, d) values
+('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'),
+('a','a','a',NULL,'xyz'),
+('a','a','b',NULL,'xyz'),
+('a','b','a',NULL,'xyz'),
+('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'),
+('d','b','b',NULL,'xyz'),
+('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),
+('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),
+('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'),
+('a','a','a',NULL,'xyz'),
+('a','a','b',NULL,'xyz'),
+('a','b','a',NULL,'xyz'),
+('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'),
+('d','b','b',NULL,'xyz'),
+('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),
+('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz');
+
+create index idx_t2_0 on t2 (a1);
+create index idx_t2_1 on t2 (a1,a2,b,c);
+create index idx_t2_2 on t2 (a1,a2,b);
+analyze table t2;
+
+# Table t3 is the same as t1, but with smaller column lenghts.
+# This allows to test different branches of the cost computation procedure
+# when the number of keys per block are less than the number of keys in the
+# sub-groups formed by predicates over non-group attributes.
+
+--disable_warnings
+drop table if exists t3;
+--enable_warnings
+
+eval create table t3 (
+ a1 char(1), a2 char(1), b char(1), c char(4) not null, d char(3), dummy char(1) default ' '
+) engine=$engine;
+
+insert into t3 (a1, a2, b, c, d) values
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
+insert into t3 (a1, a2, b, c, d) values
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
+insert into t3 (a1, a2, b, c, d) values
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
+insert into t3 (a1, a2, b, c, d) values
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
+
+create index idx_t3_0 on t3 (a1);
+create index idx_t3_1 on t3 (a1,a2,b,c);
+create index idx_t3_2 on t3 (a1,a2,b);
+analyze table t3;
+
+
+#
+# Queries without a WHERE clause. These queries do not use ranges.
+#
+
+# plans
+explain select a1, min(a2) from t1 group by a1;
+explain select a1, max(a2) from t1 group by a1;
+explain select a1, min(a2), max(a2) from t1 group by a1;
+explain select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b;
+explain select a1,a2,b,max(c),min(c) from t1 group by a1,a2,b;
+--replace_column 7 # 9 #
+explain select a1,a2,b,max(c),min(c) from t2 group by a1,a2,b;
+# Select fields in different order
+explain select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1;
+explain select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b;
+explain select min(a2) from t1 group by a1;
+explain select a2, min(c), max(c) from t1 group by a1,a2,b;
+
+# queries
+select a1, min(a2) from t1 group by a1;
+select a1, max(a2) from t1 group by a1;
+select a1, min(a2), max(a2) from t1 group by a1;
+select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b;
+select a1,a2,b,max(c),min(c) from t1 group by a1,a2,b;
+select a1,a2,b,max(c),min(c) from t2 group by a1,a2,b;
+# Select fields in different order
+select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1;
+select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b;
+select min(a2) from t1 group by a1;
+select a2, min(c), max(c) from t1 group by a1,a2,b;
+
+#
+# Queries with a where clause
+#
+
+# A) Preds only over the group 'A' attributes
+# plans
+explain select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
+explain select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+explain select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;
+explain select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+explain select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+explain select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
+explain select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b;
+
+--replace_column 9 #
+explain select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where a1 < 'd' group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+--replace_column 9 #
+explain select a1, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b, max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b, max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;
+--replace_column 9 #
+explain select a1, max(c) from t2 where a1 in ('a','b','d') group by a1,a2,b;
+
+# queries
+select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
+select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;
+select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
+select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b;
+
+select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where a1 < 'd' group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;
+select a1,a2,b, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+select a1, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;
+select a1,a2,b, max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+select a1,a2,b, max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+select a1,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;
+select a1, max(c) from t2 where a1 in ('a','b','d') group by a1,a2,b;
+
+# B) Equalities only over the non-group 'B' attributes
+# plans
+--echo #
+--echo # MariaDB: we dont have the following patch:
+--echo #
+--echo # commit 60a92a79a3b7fde3c6efe91799e344b977c8e5c3
+--echo # Author: Manuel Ung <mung@fb.com>
+--echo # Date: Thu Apr 19 23:06:27 2018 -0700
+--echo #
+--echo # Enhance group-by loose index scan
+--echo #
+--echo # So the following results are not very meaningful, but are still kept here
+
+explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;
+explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b' or b = 'a') group by a1;
+
+explain select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;
+explain select a1,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+explain select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+
+explain select a1,a2,b, max(c) from t1 where (b = 'b') group by a1,a2;
+explain select a1,a2,b, max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2;
+
+explain select a1,a2,b,min(c),max(c) from t1 where (b = 'b') group by a1,a2;
+explain select a1,a2,b,min(c),max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2;
+
+explain select a1,a2, max(c) from t1 where (b = 'b') group by a1,a2;
+explain select a1,a2, max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2;
+
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+
+explain select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;
+explain select a1,max(c),min(c) from t2 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+explain select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+
+explain select a1,a2,b, max(c) from t2 where (b = 'b') group by a1,a2;
+explain select a1,a2,b, max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2;
+
+explain select a1,a2,b,min(c),max(c) from t2 where (b = 'b') group by a1,a2;
+explain select a1,a2,b,min(c),max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2;
+
+explain select a1,a2, max(c) from t2 where (b = 'b') group by a1,a2;
+explain select a1,a2, max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2;
+
+# these queries test case 2) in TRP_GROUP_MIN_MAX::update_cost()
+explain select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;
+explain select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+explain select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+
+explain select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;
+explain select a1,max(c),min(c) from t3 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+explain select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+
+# queries
+select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;
+select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b' or b = 'a') group by a1;
+
+select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;
+select a1,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+
+select a1,a2,b, max(c) from t1 where (b = 'b') group by a1,a2;
+select a1,a2,b, max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2;
+
+select a1,a2,b,min(c),max(c) from t1 where (b = 'b') group by a1,a2;
+select a1,a2,b,min(c),max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2;
+
+select a1,a2, max(c) from t1 where (b = 'b') group by a1,a2;
+select a1,a2, max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2;
+
+select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;
+select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+
+select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;
+select a1,max(c),min(c) from t2 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+
+select a1,a2,b, max(c) from t2 where (b = 'b') group by a1,a2;
+select a1,a2,b, max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2;
+
+select a1,a2,b,min(c),max(c) from t2 where (b = 'b') group by a1,a2;
+select a1,a2,b,min(c),max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2;
+
+select a1,a2, max(c) from t2 where (b = 'b') group by a1,a2;
+select a1,a2, max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2;
+
+# these queries test case 2) in TRP_GROUP_MIN_MAX::update_cost()
+select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;
+select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+
+select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;
+select a1,max(c),min(c) from t3 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+
+
+# IS NULL (makes sense for t2 only)
+# plans
+explain select a1,a2,b,min(c) from t2 where (a2 = 'a') and b is NULL group by a1;
+explain select a1,a2,b,min(c) from t2 where (a2 = 'a' or a2 = 'b') and b is NULL group by a1;
+
+explain select a1,a2,b,max(c) from t2 where (a2 = 'a') and b is NULL group by a1;
+explain select a1,a2,b,max(c) from t2 where (a2 = 'a' or a2 = 'b') and b is NULL group by a1;
+
+explain select a1,a2,b,min(c) from t2 where b is NULL group by a1,a2;
+explain select a1,a2,b,max(c) from t2 where b is NULL group by a1,a2;
+explain select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2;
+
+# queries
+select a1,a2,b,min(c) from t2 where (a2 = 'a') and b is NULL group by a1;
+select a1,a2,b,min(c) from t2 where (a2 = 'a' or a2 = 'b') and b is NULL group by a1;
+select a1,a2,b,max(c) from t2 where (a2 = 'a') and b is NULL group by a1;
+select a1,a2,b,max(c) from t2 where (a2 = 'a' or a2 = 'b') and b is NULL group by a1;
+select a1,a2,b,min(c) from t2 where b is NULL group by a1,a2;
+select a1,a2,b,max(c) from t2 where b is NULL group by a1,a2;
+select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2;
+select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2;
+
+# C) Range predicates for the MIN/MAX attribute
+# plans
+--replace_column 9 #
+explain select a1,a2,b, max(c) from t1 where (c > 'b1') group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') group by a1,a2,b;
+explain select a1,a2,b, max(c) from t1 where (c > 'f123') group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where (c > 'f123') group by a1,a2,b;
+explain select a1,a2,b, max(c) from t1 where (c < 'a0') group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') group by a1,a2,b;
+explain select a1,a2,b, max(c) from t1 where (c < 'k321') group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where (c < 'k321') group by a1,a2,b;
+explain select a1,a2,b, max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+explain select a1,a2,b, max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where (c between 'b111' and 'g112') or (c between 'd000' and 'i110') group by a1,a2,b;
+
+--replace_column 9 #
+explain select a1,a2,b, max(c) from t2 where (c > 'b1') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b, max(c) from t2 where (c > 'f123') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where (c > 'f123') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b, max(c) from t2 where (c < 'a0') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b, max(c) from t2 where (c < 'k321') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where (c < 'k321') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b, max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b, max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b;
+
+# queries
+select a1,a2,b, max(c) from t1 where (c > 'b1') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') group by a1,a2,b;
+select a1,a2,b, max(c) from t1 where (c > 'f123') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where (c > 'f123') group by a1,a2,b;
+select a1,a2,b, max(c) from t1 where (c < 'a0') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') group by a1,a2,b;
+select a1,a2,b, max(c) from t1 where (c < 'k321') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where (c < 'k321') group by a1,a2,b;
+select a1,a2,b, max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+select a1,a2,b, max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where (c between 'b111' and 'g112') or (c between 'd000' and 'i110') group by a1,a2,b;
+
+select a1,a2,b, max(c) from t2 where (c > 'b1') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') group by a1,a2,b;
+select a1,a2,b, max(c) from t2 where (c > 'f123') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where (c > 'f123') group by a1,a2,b;
+select a1,a2,b, max(c) from t2 where (c < 'a0') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') group by a1,a2,b;
+select a1,a2,b, max(c) from t2 where (c < 'k321') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where (c < 'k321') group by a1,a2,b;
+select a1,a2,b, max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+select a1,a2,b, max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b;
+
+# analyze the sub-select
+explain select a1,a2,b,min(c),max(c) from t1
+where exists ( select * from t2 where t2.c = t1.c )
+group by a1,a2,b;
+
+# the sub-select is unrelated to MIN/MAX
+explain select a1,a2,b,min(c),max(c) from t1
+where exists ( select * from t2 where t2.c > 'b1' )
+group by a1,a2,b;
+
+
+# A,B,C) Predicates referencing mixed classes of attributes
+# plans
+explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;
+explain select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;
+explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
+explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
+explain select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+explain select a1,a2,b,min(c) from t1 where (ord(a1) > 97) and (ord(a2) + ord(a1) > 194) and (b = 'c') group by a1,a2,b;
+
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c),max(c) from t2 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+
+# queries
+select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;
+select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
+select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
+select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+select a1,a2,b,min(c) from t1 where (ord(a1) > 97) and (ord(a2) + ord(a1) > 194) and (b = 'c') group by a1,a2,b;
+
+select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t2 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;
+select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
+select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
+select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+
+
+#
+# GROUP BY queries without MIN/MAX
+#
+
+# plans
+explain select a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+explain select a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+explain select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+explain select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121' or c = 'i121') group by a1,a2,b;
+explain select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+
+--replace_column 9 #
+explain select a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121' or c = 'i121') group by a1,a2,b;
+--replace_column 9 #
+explain select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+
+# queries
+select a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+select a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121' or c = 'i121') group by a1,a2,b;
+select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+
+select a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+select a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121' or c = 'i121') group by a1,a2,b;
+select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+
+#
+# DISTINCT queries
+#
+
+# plans
+explain select distinct a1,a2,b from t1;
+explain select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a');
+explain extended select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
+explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
+explain select distinct b from t1 where (a2 >= 'b') and (b = 'a');
+explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b';
+explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e';
+
+--replace_column 9 #
+explain select distinct a1,a2,b from t2;
+--replace_column 9 #
+explain select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a');
+explain extended select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
+--replace_column 9 #
+explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
+explain select distinct b from t2 where (a2 >= 'b') and (b = 'a');
+explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'b';
+explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e';
+
+# queries
+select distinct a1,a2,b from t1;
+select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a');
+select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
+select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
+select distinct b from t1 where (a2 >= 'b') and (b = 'a');
+select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b';
+select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e';
+
+select distinct a1,a2,b from t2;
+select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a');
+select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
+select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
+select distinct b from t2 where (a2 >= 'b') and (b = 'a');
+select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'b';
+select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e';
+
+# BUG #6303
+select distinct t_00.a1
+from t1 t_00
+where exists ( select * from t2 where a1 = t_00.a1 );
+
+# BUG #8532 - SELECT DISTINCT a, a causes server to crash
+select distinct a1,a1 from t1;
+select distinct a2,a1,a2,a1 from t1;
+select distinct t1.a1,t2.a1 from t1,t2;
+
+
+#
+# DISTINCT queries with GROUP-BY
+#
+
+# plans
+explain select distinct a1,a2,b from t1;
+explain select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+explain select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+explain select distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b' group by a1;
+explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e' group by a1;
+
+--replace_column 9 #
+explain select distinct a1,a2,b from t2;
+--replace_column 9 #
+explain select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+--replace_column 9 #
+explain select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+--replace_column 9 #
+explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+--replace_column 9 #
+explain select distinct b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+--replace_column 9 #
+explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'b' group by a1;
+--replace_column 9 #
+explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e' group by a1;
+
+# queries
+select distinct a1,a2,b from t1;
+select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+select distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b' group by a1;
+select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e' group by a1;
+
+select distinct a1,a2,b from t2;
+select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+select distinct b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'b' group by a1;
+select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e' group by a1;
+
+
+#
+# COUNT (DISTINCT cols) queries
+#
+
+explain select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
+explain select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
+explain extended select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
+explain select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a');
+explain extended select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a');
+
+select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
+select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
+select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
+select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a');
+select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a');
+
+#
+# Queries with expressions in the select clause
+#
+
+explain select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b;
+explain select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b;
+explain select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b;
+explain select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
+explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2;
+
+select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b;
+select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b;
+select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b;
+select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
+select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2;
+
+
+#
+# Negative examples: queries that should NOT be treated as optimizable by
+# QUICK_GROUP_MIN_MAX_SELECT
+#
+
+# select a non-indexed attribute
+explain select a1,a2,b,d,min(c),max(c) from t1 group by a1,a2,b;
+
+explain select a1,a2,b,d from t1 group by a1,a2,b;
+
+# predicate that references an attribute that is after the MIN/MAX argument
+# in the index
+explain extended select a1,a2,min(b),max(b) from t1
+where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2;
+
+# predicate that references a non-indexed attribute
+explain extended select a1,a2,b,min(c),max(c) from t1
+where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b;
+
+explain extended select a1,a2,b,c from t1
+where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c;
+
+# non-equality predicate for a non-group select attribute
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1;
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b < 'b') group by a1;
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b <= 'b') group by a1;
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b <= 'b' and b >= 'a') group by a1;
+explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b;
+
+# non-group field with an equality predicate that references a keypart after the
+# MIN/MAX argument
+explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;
+select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;
+
+# disjunction for a non-group select attribute
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b = 'a') group by a1;
+
+# non-range predicate for the MIN/MAX attribute
+explain select a1,a2,b,min(c),max(c) from t2
+where (c > 'a000') and (c <= 'd999') and (c like '_8__') group by a1,a2,b;
+
+# not all attributes are indexed by one index
+explain select a1, a2, b, c, min(d), max(d) from t1 group by a1,a2,b,c;
+
+# other aggregate functions than MIN/MAX
+explain select a1,a2,count(a2) from t1 group by a1,a2,b;
+explain extended select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b;
+explain extended select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b;
+
+# test multi_range_groupby flag
+#MariaDB: no support: set optimizer_switch = 'multi_range_groupby=off';
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'a' or b = 'b') group by a1;
+#set optimizer_switch = 'default';
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'a' or b = 'b') group by a1;
+
+
+#
+# Bug #16710: select distinct doesn't return all it should
+#
+
+explain select distinct(a1) from t1 where ord(a2) = 98;
+select distinct(a1) from t1 where ord(a2) = 98;
+
+#
+# BUG#11044: DISTINCT or GROUP BY queries with equality predicates instead of MIN/MAX.
+#
+
+explain select a1 from t1 where a2 = 'b' group by a1;
+select a1 from t1 where a2 = 'b' group by a1;
+
+explain select distinct a1 from t1 where a2 = 'b';
+select distinct a1 from t1 where a2 = 'b';
+
+#
+# Bug #12672: primary key implcitly included in every innodb index
+#
+# Test case moved to group_min_max_innodb
+
+
+#
+# Bug #6142: a problem with the empty innodb table
+#
+# Test case moved to group_min_max_innodb
+
+
+#
+# Bug #9798: group by with rollup
+#
+# Test case moved to group_min_max_innodb
+
+
+#
+# Bug #13293 Wrongly used index results in endless loop.
+#
+# Test case moved to group_min_max_innodb
+
+
+drop table t1,t2,t3;
+
+#
+# Bug #14920 Ordering aggregated result sets with composite primary keys
+# corrupts resultset
+#
+eval create table t1 (c1 int not null,c2 int not null, primary key(c1,c2)) engine=$engine;
+insert into t1 (c1,c2) values
+(10,1),(10,2),(10,3),(20,4),(20,5),(20,6),(30,7),(30,8),(30,9);
+select distinct c1, c2 from t1 order by c2;
+select c1,min(c2) as c2 from t1 group by c1 order by c2;
+select c1,c2 from t1 group by c1,c2 order by c2;
+drop table t1;
+
+#
+# Bug #16203: Analysis for possible min/max optimization erroneously
+# returns impossible range
+#
+
+eval CREATE TABLE t1 (a varchar(5), b int(11), PRIMARY KEY (a,b)) engine=$engine;
+INSERT INTO t1 VALUES ('AA',1), ('AA',2), ('AA',3), ('BB',1), ('AA',4);
+OPTIMIZE TABLE t1;
+
+SELECT a FROM t1 WHERE a='AA' GROUP BY a;
+SELECT a FROM t1 WHERE a='BB' GROUP BY a;
+
+EXPLAIN SELECT a FROM t1 WHERE a='AA' GROUP BY a;
+EXPLAIN SELECT a FROM t1 WHERE a='BB' GROUP BY a;
+
+SELECT DISTINCT a FROM t1 WHERE a='BB';
+SELECT DISTINCT a FROM t1 WHERE a LIKE 'B%';
+SELECT a FROM t1 WHERE a LIKE 'B%' GROUP BY a;
+
+DROP TABLE t1;
+
+
+#
+# Bug #15102: select distinct returns empty result, select count
+# distinct > 0 (correct)
+#
+
+CREATE TABLE t1 (
+ a int(11) NOT NULL DEFAULT '0',
+ b varchar(16) COLLATE latin1_general_ci NOT NULL DEFAULT '',
+ PRIMARY KEY (a,b)
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+
+delimiter |;
+
+CREATE PROCEDURE a(x INT)
+BEGIN
+ DECLARE rnd INT;
+ DECLARE cnt INT;
+
+ WHILE x > 0 DO
+ SET rnd= x % 100;
+ SET cnt = (SELECT COUNT(*) FROM t1 WHERE a = rnd);
+ INSERT INTO t1(a,b) VALUES (rnd, CAST(cnt AS CHAR));
+ SET x= x - 1;
+ END WHILE;
+END|
+
+DELIMITER ;|
+
+CALL a(1000);
+
+SELECT a FROM t1 WHERE a=0;
+SELECT DISTINCT a FROM t1 WHERE a=0;
+SELECT COUNT(DISTINCT a) FROM t1 WHERE a=0;
+
+DROP TABLE t1;
+DROP PROCEDURE a;
+
+#
+# Bug #18068: SELECT DISTINCT
+#
+
+eval CREATE TABLE t1 (a varchar(64) NOT NULL default '', PRIMARY KEY(a)) engine=$engine;
+
+INSERT INTO t1 (a) VALUES
+ (''), ('CENTRAL'), ('EASTERN'), ('GREATER LONDON'),
+ ('NORTH CENTRAL'), ('NORTH EAST'), ('NORTH WEST'), ('SCOTLAND'),
+ ('SOUTH EAST'), ('SOUTH WEST'), ('WESTERN');
+
+EXPLAIN SELECT DISTINCT a,a FROM t1 ORDER BY a;
+SELECT DISTINCT a,a FROM t1 ORDER BY a;
+
+DROP TABLE t1;
+
+#
+# Bug #21007: NATURAL JOIN (any JOIN (2 x NATURAL JOIN)) crashes the server
+#
+
+eval CREATE TABLE t1 (id1 INT, id2 INT) engine=$engine;
+eval CREATE TABLE t2 (id2 INT, id3 INT, id5 INT) engine=$engine;
+eval CREATE TABLE t3 (id3 INT, id4 INT) engine=$engine;
+eval CREATE TABLE t4 (id4 INT) engine=$engine;
+eval CREATE TABLE t5 (id5 INT, id6 INT) engine=$engine;
+eval CREATE TABLE t6 (id6 INT) engine=$engine;
+
+INSERT INTO t1 VALUES(1,1);
+INSERT INTO t2 VALUES(1,1,1);
+INSERT INTO t3 VALUES(1,1);
+INSERT INTO t4 VALUES(1);
+INSERT INTO t5 VALUES(1,1);
+INSERT INTO t6 VALUES(1);
+
+# original bug query
+SELECT * FROM
+t1
+ NATURAL JOIN
+(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)
+ ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));
+
+# inner join swapped
+SELECT * FROM
+t1
+ NATURAL JOIN
+(((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6) on t3.id4 = t5.id5) JOIN t2
+ ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));
+
+# one join less, no ON cond
+SELECT * FROM t1 NATURAL JOIN ((t3 join (t5 NATURAL JOIN t6)) JOIN t2);
+
+# wrong error message: 'id2' - ambiguous column
+SELECT * FROM
+(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)
+ ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5))
+ NATURAL JOIN
+t1;
+SELECT * FROM
+(t2 JOIN ((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6)))
+ NATURAL JOIN
+t1;
+
+DROP TABLE t1,t2,t3,t4,t5,t6;
+
+#
+# Bug#22342: No results returned for query using max and group by
+#
+eval CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b), KEY b (b)) engine=$engine;
+INSERT INTO t1 VALUES (1,1),(1,2),(1,0),(1,3);
+ANALYZE TABLE t1;
+
+explain SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a;
+SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a;
+SELECT MIN(b), a FROM t1 WHERE b > 1 AND a = 1 GROUP BY a;
+eval CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c)) engine=$engine;
+INSERT INTO t2 SELECT a,b,b FROM t1;
+ANALYZE TABLE t2;
+explain SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a;
+SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a;
+
+DROP TABLE t1,t2;
+
+#
+# Bug#24156: Loose index scan not used with CREATE TABLE ...SELECT and similar statements
+#
+
+eval CREATE TABLE t1 (a INT, b INT, INDEX (a,b)) engine=$engine;
+INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5),
+ (2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
+ANALYZE TABLE t1;
+EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
+FLUSH STATUS;
+SELECT max(b), a FROM t1 GROUP BY a;
+SHOW STATUS LIKE 'handler_read__e%';
+EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
+FLUSH STATUS;
+eval CREATE TABLE t2 engine=$engine SELECT max(b), a FROM t1 GROUP BY a;
+SHOW STATUS LIKE 'handler_read__e%';
+FLUSH STATUS;
+SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b;
+SHOW STATUS LIKE 'handler_read__e%';
+FLUSH STATUS;
+(SELECT max(b), a FROM t1 GROUP BY a) UNION
+ (SELECT max(b), a FROM t1 GROUP BY a);
+SHOW STATUS LIKE 'handler_read__e%';
+EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION
+ (SELECT max(b), a FROM t1 GROUP BY a);
+
+EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
+ FROM t1 AS t1_outer;
+EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS
+ (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
+EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
+ (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
+EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
+ a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
+EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING
+ a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
+EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2
+ ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2)
+ AND t1_outer1.b = t1_outer2.b;
+EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
+ FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2;
+
+CREATE TABLE t3 LIKE t1;
+FLUSH STATUS;
+INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a;
+SHOW STATUS LIKE 'handler_read__e%';
+DELETE FROM t3;
+FLUSH STATUS;
+INSERT INTO t3 SELECT 1, (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2)
+ FROM t1 LIMIT 1;
+SHOW STATUS LIKE 'handler_read__e%';
+FLUSH STATUS;
+DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000;
+SHOW STATUS LIKE 'handler_read__e%';
+FLUSH STATUS;
+--error ER_SUBQUERY_NO_1_ROW
+DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x
+ FROM t1) > 10000;
+SHOW STATUS LIKE 'handler_read__e%';
+
+DROP TABLE t1,t2,t3;
+
+#
+# Bug#25602: queries with DISTINCT and SQL_BIG_RESULT hint
+# for which loose scan optimization is applied
+#
+
+eval CREATE TABLE t1 (a int, INDEX idx(a)) engine=$engine;
+INSERT INTO t1 VALUES
+ (4), (2), (1), (2), (4), (2), (1), (4),
+ (4), (2), (1), (2), (2), (4), (1), (4);
+ANALYZE TABLE t1;
+
+EXPLAIN SELECT DISTINCT(a) FROM t1;
+SELECT DISTINCT(a) FROM t1;
+EXPLAIN SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;
+SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;
+
+DROP TABLE t1;
+
+#
+# Bug #32268: Indexed queries give bogus MIN and MAX results
+#
+
+eval CREATE TABLE t1 (a INT, b INT) engine=$engine;
+INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3);
+INSERT INTO t1 SELECT a + 1, b FROM t1;
+INSERT INTO t1 SELECT a + 2, b FROM t1;
+ANALYZE TABLE t1;
+
+EXPLAIN
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+
+CREATE INDEX break_it ON t1 (a, b);
+
+EXPLAIN
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
+
+EXPLAIN
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+
+EXPLAIN
+SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
+SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
+
+DROP TABLE t1;
+
+#
+# Bug#38195: Incorrect handling of aggregate functions when loose index scan is
+# used causes server crash.
+#
+create table t1 (a int, b int, primary key (a,b), key `index` (a,b)) engine=MyISAM;
+insert into t1 (a,b) values
+(0,0),(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),
+ (0,7),(0,8),(0,9),(0,10),(0,11),(0,12),(0,13),
+(1,0),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),
+ (1,7),(1,8),(1,9),(1,10),(1,11),(1,12),(1,13),
+(2,0),(2,1),(2,2),(2,3),(2,4),(2,5),(2,6),
+ (2,7),(2,8),(2,9),(2,10),(2,11),(2,12),(2,13),
+(3,0),(3,1),(3,2),(3,3),(3,4),(3,5),(3,6),
+ (3,7),(3,8),(3,9),(3,10),(3,11),(3,12),(3,13);
+insert into t1 (a,b) select a, max(b)+1 from t1 where a = 0 group by a;
+ANALYZE TABLE t1;
+select * from t1;
+explain extended select sql_buffer_result a, max(b)+1 from t1 where a = 0 group by a;
+drop table t1;
+
+
+#
+# Bug #41610: key_infix_len can be overwritten causing some group by queries
+# to return no rows
+#
+
+eval CREATE TABLE t1 (a int, b int, c int, d int,
+ KEY foo (c,d,a,b), KEY bar (c,a,b,d)) engine=$engine;
+
+INSERT INTO t1 VALUES (1, 1, 1, 1), (1, 1, 1, 2), (1, 1, 1, 3), (1, 1, 1, 4);
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT a,b,c+1,d FROM t1;
+ANALYZE TABLE t1;
+
+#Should be non-empty
+EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4;
+SELECT DISTINCT c FROM t1 WHERE d=4;
+
+DROP TABLE t1;
+
+--echo #
+--echo # Bug #45386: Wrong query result with MIN function in field list,
+--echo # WHERE and GROUP BY clause
+--echo #
+
+eval CREATE TABLE t (a INT, b INT, INDEX (a,b)) engine=$engine;
+INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);
+INSERT INTO t SELECT * FROM t;
+INSERT INTO t SELECT * FROM t;
+ANALYZE TABLE t;
+
+--echo # test MIN
+--echo #should use range with index for group by
+EXPLAIN
+SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a;
+--echo #should return 1 row
+SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a;
+
+--echo # test MAX
+--echo #should use range with index for group by
+EXPLAIN
+SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a;
+--echo #should return 1 row
+SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a;
+
+--echo # test 3 ranges and use the middle one
+INSERT INTO t SELECT a, 2 FROM t;
+
+--echo #should use range with index for group by
+EXPLAIN
+SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a;
+--echo #should return 1 row
+SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a;
+
+DROP TABLE t;
+
+--echo #
+--echo # Bug #48472: Loose index scan inappropriately chosen for some WHERE
+--echo # conditions
+--echo #
+
+eval CREATE TABLE t (a INT, b INT, INDEX (a,b)) engine=$engine;
+INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);
+INSERT INTO t SELECT * FROM t;
+ANALYZE TABLE t;
+
+SELECT a, MAX(b) FROM t WHERE 0=b+0 GROUP BY a;
+
+DROP TABLE t;
+
+--echo End of 5.0 tests
+
+--echo #
+--echo # Bug #46607: Assertion failed: (cond_type == Item::FUNC_ITEM) results in
+--echo # server crash
+--echo #
+
+eval CREATE TABLE t (a INT, b INT, INDEX (a,b)) engine=$engine;
+INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);
+INSERT INTO t SELECT * FROM t;
+
+SELECT a, MAX(b) FROM t WHERE b GROUP BY a;
+
+DROP TABLE t;
+
+#
+# BUG#49902 - SELECT returns incorrect results
+#
+eval CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, KEY (b)) engine=$engine;
+INSERT INTO t1 VALUES(1,1),(2,1);
+ANALYZE TABLE t1;
+SELECT 1 AS c, b FROM t1 WHERE b IN (1,2) GROUP BY c, b;
+SELECT a FROM t1 WHERE b=1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#47762: Incorrect result from MIN() when WHERE tests NOT NULL column
+--echo # for NULL
+--echo #
+
+--echo ## Test for NULLs allowed
+eval CREATE TABLE t1 ( a INT, KEY (a) ) engine=$engine;
+INSERT INTO t1 VALUES (1), (2), (3);
+ANALYZE TABLE t1;
+--source include/min_null_cond.inc
+INSERT INTO t1 VALUES (NULL), (NULL);
+ANALYZE TABLE t1;
+--source include/min_null_cond.inc
+DROP TABLE t1;
+
+--echo ## Test for NOT NULLs
+eval CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY) engine=$engine;
+INSERT INTO t1 VALUES (1), (2), (3);
+ANALYZE TABLE t1;
+--echo #
+--echo # NULL-safe operator test disabled for non-NULL indexed columns.
+--echo #
+--echo # See bugs
+--echo #
+--echo # - Bug#52173: Reading NULL value from non-NULL index gives
+--echo # wrong result in embedded server
+--echo #
+--echo # - Bug#52174: Sometimes wrong plan when reading a MAX value from
+--echo # non-NULL index
+--echo #
+--let $skip_null_safe_test= 1
+--source include/min_null_cond.inc
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#53859: Valgrind: opt_sum_query(TABLE_LIST*, List<Item>&, Item*) at
+--echo # opt_sum.cc:305
+--echo #
+eval CREATE TABLE t1 ( a INT, KEY (a) ) engine=$engine;
+INSERT INTO t1 VALUES (1), (2), (3);
+
+SELECT MIN( a ) AS min_a
+FROM t1
+WHERE a > 1 AND a IS NULL
+ORDER BY min_a;
+
+DROP TABLE t1;
+
+
+--echo End of 5.1 tests
+
+
+--echo #
+--echo # WL#3220 (Loose index scan for COUNT DISTINCT)
+--echo #
+
+eval CREATE TABLE t1 (a INT, b INT, c INT, KEY (a,b)) engine=$engine;
+INSERT INTO t1 VALUES (1,1,1), (1,2,1), (1,3,1), (1,4,1);
+INSERT INTO t1 SELECT a, b + 4, 1 FROM t1;
+INSERT INTO t1 SELECT a + 1, b, 1 FROM t1;
+ANALYZE TABLE t1;
+eval CREATE TABLE t2 (a INT, b INT, c INT, d INT, e INT, f INT, KEY (a,b,c)) engine=$engine;
+INSERT INTO t2 VALUES (1,1,1,1,1,1), (1,2,1,1,1,1), (1,3,1,1,1,1),
+ (1,4,1,1,1,1);
+INSERT INTO t2 SELECT a, b + 4, c,d,e,f FROM t2;
+INSERT INTO t2 SELECT a + 1, b, c,d,e,f FROM t2;
+ANALYZE TABLE t2;
+
+EXPLAIN SELECT COUNT(DISTINCT a) FROM t1;
+SELECT COUNT(DISTINCT a) FROM t1;
+
+EXPLAIN SELECT COUNT(DISTINCT a,b) FROM t1;
+SELECT COUNT(DISTINCT a,b) FROM t1;
+
+EXPLAIN SELECT COUNT(DISTINCT b,a) FROM t1;
+SELECT COUNT(DISTINCT b,a) FROM t1;
+
+EXPLAIN SELECT COUNT(DISTINCT b) FROM t1;
+SELECT COUNT(DISTINCT b) FROM t1;
+
+EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a;
+SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a;
+
+EXPLAIN SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
+SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
+
+EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b;
+SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b;
+
+EXPLAIN SELECT DISTINCT COUNT(DISTINCT a) FROM t1;
+SELECT DISTINCT COUNT(DISTINCT a) FROM t1;
+
+EXPLAIN SELECT COUNT(DISTINCT a, b + 0) FROM t1;
+SELECT COUNT(DISTINCT a, b + 0) FROM t1;
+
+EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 10;
+SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 10;
+
+EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10;
+SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10;
+
+EXPLAIN SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10;
+SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10;
+
+EXPLAIN SELECT 1 FROM t1 GROUP BY a HAVING COUNT(DISTINCT b) > 1;
+SELECT 1 FROM t1 GROUP BY a HAVING COUNT(DISTINCT b) > 1;
+
+EXPLAIN SELECT COUNT(DISTINCT t1_1.a) FROM t1 t1_1, t1 t1_2 GROUP BY t1_1.a;
+SELECT COUNT(DISTINCT t1_1.a) FROM t1 t1_1, t1 t1_2 GROUP BY t1_1.a;
+
+EXPLAIN SELECT COUNT(DISTINCT a), 12 FROM t1;
+SELECT COUNT(DISTINCT a), 12 FROM t1;
+
+EXPLAIN SELECT COUNT(DISTINCT a, b, c) FROM t2;
+SELECT COUNT(DISTINCT a, b, c) FROM t2;
+
+EXPLAIN SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT a) FROM t2;
+SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT a) FROM t2;
+
+EXPLAIN SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT f) FROM t2;
+SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT f) FROM t2;
+
+EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2;
+SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2;
+
+EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, f) FROM t2;
+SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, f) FROM t2;
+
+EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, d) FROM t2;
+SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, d) FROM t2;
+
+EXPLAIN SELECT a, c, COUNT(DISTINCT c, a, b) FROM t2 GROUP BY a, b, c;
+SELECT a, c, COUNT(DISTINCT c, a, b) FROM t2 GROUP BY a, b, c;
+
+EXPLAIN SELECT COUNT(DISTINCT c, a, b) FROM t2
+ WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c;
+SELECT COUNT(DISTINCT c, a, b) FROM t2
+ WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c;
+
+EXPLAIN SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 WHERE a = 5
+ GROUP BY b;
+SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 WHERE a = 5
+ GROUP BY b;
+
+EXPLAIN SELECT a, COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
+SELECT a, COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
+
+EXPLAIN SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
+SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
+
+EXPLAIN SELECT COUNT(DISTINCT a, b) FROM t2 WHERE c = 13 AND d = 42;
+SELECT COUNT(DISTINCT a, b) FROM t2 WHERE c = 13 AND d = 42;
+
+EXPLAIN SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2
+ WHERE b = 13 AND c = 42 GROUP BY a;
+SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2
+ WHERE b = 13 AND c = 42 GROUP BY a;
+
+--echo # This query could have been resolved using loose index scan since
+--echo # the second part of count(..) is defined by a constant predicate
+EXPLAIN SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42;
+SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42;
+
+EXPLAIN SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a;
+SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a;
+
+EXPLAIN SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c;
+SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c;
+
+EXPLAIN SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a;
+SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a;
+
+DROP TABLE t1,t2;
+
+--echo # end of WL#3220 tests
+
+--echo #
+--echo # Bug#50539: Wrong result when loose index scan is used for an aggregate
+--echo # function with distinct
+--echo #
+eval CREATE TABLE t1 (
+ f1 int(11) NOT NULL DEFAULT '0',
+ f2 char(1) NOT NULL DEFAULT '',
+ PRIMARY KEY (f1,f2)
+) engine=$engine;
+insert into t1 values(1,'A'),(1 , 'B'), (1, 'C'), (2, 'A'),
+(3, 'A'), (3, 'B'), (3, 'C'), (3, 'D');
+ANALYZE TABLE t1;
+
+SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1;
+explain SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1;
+
+drop table t1;
+--echo # End of test#50539.
+
+--echo #
+--echo # Bug#17217128 - BAD INTERACTION BETWEEN MIN/MAX AND
+--echo # "HAVING SUM(DISTINCT)": WRONG RESULTS.
+--echo #
+
+eval CREATE TABLE t (a INT, b INT, KEY(a,b)) engine=$engine;
+INSERT INTO t VALUES (1,1), (2,2), (3,3), (4,4), (1,0), (3,2), (4,5);
+ANALYZE TABLE t;
+# MariaDB: 10.2 doesn't have trace, yet: let $DEFAULT_TRACE_MEM_SIZE=1048576; # 1MB
+# eval set optimizer_trace_max_mem_size=$DEFAULT_TRACE_MEM_SIZE;
+# set @@session.optimizer_trace='enabled=on';
+# set end_markers_in_json=on;
+
+ANALYZE TABLE t;
+
+SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a;
+EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a;
+#SELECT TRACE RLIKE 'have_both_agg_distinct_and_min_max' AS OK
+# FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+
+SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a;
+EXPLAIN SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a;
+#SELECT TRACE RLIKE 'have_both_agg_distinct_and_min_max' AS OK
+# FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+
+SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a);
+EXPLAIN SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a);
+#SELECT TRACE RLIKE 'have_both_agg_distinct_and_min_max' AS OK
+# FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+
+SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t;
+EXPLAIN SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t;
+#SELECT TRACE RLIKE 'have_both_agg_distinct_and_min_max' AS OK
+# FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+
+SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a;
+EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a;
+#SELECT TRACE RLIKE 'have_both_agg_distinct_and_min_max' AS OK
+# FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+
+#SET optimizer_trace_max_mem_size=DEFAULT;
+#SET optimizer_trace=DEFAULT;
+#SET end_markers_in_json=DEFAULT;
+
+DROP TABLE t;
+
+--echo #
+--echo # Bug#18109609: LOOSE INDEX SCAN IS NOT USED WHEN IT SHOULD
+--echo #
+
+eval CREATE TABLE t1 (
+id INT AUTO_INCREMENT PRIMARY KEY,
+c1 INT,
+c2 INT,
+KEY(c1,c2)) engine=$engine;
+
+INSERT INTO t1(c1,c2) VALUES
+(1, 1), (1,2), (2,1), (2,2), (3,1), (3,2), (3,3), (4,1), (4,2), (4,3),
+(4,4), (4,5), (4,6), (4,7), (4,8), (4,9), (4,10), (4,11), (4,12), (4,13),
+(4,14), (4,15), (4,16), (4,17), (4,18), (4,19), (4,20),(5,5);
+ANALYZE TABLE t1;
+
+EXPLAIN SELECT MAX(c2), c1 FROM t1 WHERE c1 = 4 GROUP BY c1;
+FLUSH STATUS;
+SELECT MAX(c2), c1 FROM t1 WHERE c1 = 4 GROUP BY c1;
+SHOW SESSION STATUS LIKE 'Handler_read%';
+
+DROP TABLE t1;
+
+--echo # End of test for Bug#18109609
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/have_direct_io.inc b/storage/rocksdb/mysql-test/rocksdb/include/have_direct_io.inc
new file mode 100644
index 00000000..d9b4b46b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/have_direct_io.inc
@@ -0,0 +1,23 @@
+# Common test pattern for options that control direct i/o
+#
+# Required input:
+# $io_option - name and assignment to enable on server command line
+
+--perl
+use Cwd 'abs_path';
+
+open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/data_in_shm.inc") or die;
+my $real_path= abs_path($ENV{'MYSQLTEST_VARDIR'});
+my $in_shm= (index($real_path, "/dev/shm") != -1) ||
+ (index($real_path, "/run/shm") != -1);
+print FILE "let \$DATA_IN_SHM= $in_shm;\n";
+close FILE;
+EOF
+
+--source $MYSQL_TMP_DIR/data_in_shm.inc
+--remove_file $MYSQL_TMP_DIR/data_in_shm.inc
+
+if ($DATA_IN_SHM)
+{
+ --skip DATADIR is in /{dev|run}/shm, possibly due to --mem
+}
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb.inc b/storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb.inc
new file mode 100644
index 00000000..1f762d38
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb.inc
@@ -0,0 +1,10 @@
+if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'rocksdb' AND support IN ('YES', 'DEFAULT', 'ENABLED')`)
+{
+ --skip Test requires engine RocksDB.
+}
+
+--disable_query_log
+# Table statistics can vary depending on when the memtables are flushed, so
+# flush them at the beginning of the test to ensure the test runs consistently.
+set global rocksdb_force_flush_memtable_now = true;
+--enable_query_log
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb.opt b/storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb.opt
new file mode 100644
index 00000000..36d7dda1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb.opt
@@ -0,0 +1,12 @@
+--loose-enable-rocksdb
+--loose-enable-rocksdb_global_info
+--loose-enable-rocksdb_ddl
+--loose-enable-rocksdb_cf_options
+--loose-enable_rocksdb_perf_context
+--loose-enable_rocksdb_perf_context_global
+--loose-enable-rocksdb_index_file_map
+--loose-enable-rocksdb_dbstats
+--loose-enable-rocksdb_cfstats
+--loose-enable-rocksdb_lock_info
+--loose-enable-rocksdb_trx
+--loose-enable-rocksdb_locks
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb_default.inc b/storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb_default.inc
new file mode 100644
index 00000000..2c50afd5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb_default.inc
@@ -0,0 +1,10 @@
+if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'rocksdb'` AND support in ('DEFAULT')`)
+{
+ --skip Test requires engine RocksDB as default.
+}
+
+--disable_query_log
+# Table statistics can vary depending on when the memtables are flushed, so
+# flush them at the beginning of the test to ensure the test runs consistently.
+set global rocksdb_force_flush_memtable_now = true;
+--enable_query_log
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb_replication.inc b/storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb_replication.inc
new file mode 100644
index 00000000..92261211
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/have_rocksdb_replication.inc
@@ -0,0 +1,11 @@
+# MARIAROCKS_NOT_YET: replication doesn't work yet:
+#if (`select count(*) = 0 from information_schema.tables where engine='rocksdb' and table_name='slave_gtid_info'`)
+#{
+# --skip Test requires default engine RocksDB
+#}
+
+--disable_query_log
+# Table statistics can vary depending on when the memtables are flushed, so
+# flush them at the beginning of the test to ensure the test runs consistently.
+set global rocksdb_force_flush_memtable_now = true;
+--enable_query_log
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/have_write_committed.inc b/storage/rocksdb/mysql-test/rocksdb/include/have_write_committed.inc
new file mode 100644
index 00000000..681b966f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/have_write_committed.inc
@@ -0,0 +1,3 @@
+if (`select count(*) = 0 from information_schema.session_variables where variable_name = 'rocksdb_write_policy' and variable_value = 'write_committed';`) {
+ --skip Test requires write_committed policy
+}
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/have_write_prepared.inc b/storage/rocksdb/mysql-test/rocksdb/include/have_write_prepared.inc
new file mode 100644
index 00000000..df088ea0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/have_write_prepared.inc
@@ -0,0 +1,3 @@
+if (`select count(*) = 0 from information_schema.session_variables where variable_name = 'rocksdb_write_policy' and variable_value = 'write_prepared';`) {
+ --skip Test requires write_prepared policy
+}
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/index_merge1.inc b/storage/rocksdb/mysql-test/rocksdb/include/index_merge1.inc
new file mode 100644
index 00000000..c1462e78
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/index_merge1.inc
@@ -0,0 +1,910 @@
+# include/index_merge1.inc
+#
+# Index merge tests
+#
+# The variables
+# $engine_type -- storage engine to be tested
+# $merge_table_support -- 1 storage engine supports merge tables
+# -- 0 storage engine does not support merge tables
+# have to be set before sourcing this script.
+#
+# Note: The comments/expectations refer to MyISAM.
+# They might be not valid for other storage engines.
+#
+# Last update:
+# 2006-08-02 ML test refactored
+# old name was t/index_merge.test
+# main code went into include/index_merge1.inc
+#
+
+--echo #---------------- Index merge test 1 -------------------------------------------
+
+eval SET SESSION DEFAULT_STORAGE_ENGINE = $engine_type;
+
+--disable_warnings
+drop table if exists t0, t1, t2, t3, t4;
+--enable_warnings
+
+# Create and fill a table with simple keys
+create table t0
+(
+ key1 int not null,
+ key2 int not null,
+ key3 int not null,
+ key4 int not null,
+ key5 int not null,
+ key6 int not null,
+ key7 int not null,
+ key8 int not null,
+ INDEX i1(key1),
+ INDEX i2(key2),
+ INDEX i3(key3),
+ INDEX i4(key4),
+ INDEX i5(key5),
+ INDEX i6(key6),
+ INDEX i7(key7),
+ INDEX i8(key8)
+);
+
+--disable_query_log
+insert into t0 values (1,1,1,1,1,1,1,1023),(2,2,2,2,2,2,2,1022);
+
+let $1=9;
+set @d=2;
+while ($1)
+{
+ eval insert into t0 select key1+@d, key2+@d, key3+@d, key4+@d, key5+@d,
+ key6+@d, key7+@d, key8-@d from t0;
+ eval set @d=@d*2;
+ dec $1;
+}
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+--enable_query_log
+
+analyze table t0;
+
+# 1. One index
+explain select * from t0 where key1 < 3 or key1 > 1020;
+
+# 2. Simple cases
+explain
+select * from t0 where key1 < 3 or key2 > 1020;
+select * from t0 where key1 < 3 or key2 > 1020;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where key1 < 2 or key2 <3;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain
+select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40);
+# Bug#21277: InnoDB, wrong result set, index_merge strategy, second index not evaluated
+select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40);
+
+# 3. Check that index_merge doesn't break "ignore/force/use index"
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 ignore index (i2) where key1 < 3 or key2 <4;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where (key1 < 3 or key2 <4) and key3 = 50;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 use index (i1,i2) where (key1 < 2 or key2 <3) and key3 = 50;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where (key1 > 1 or key2 > 2);
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 force index (i1,i2) where (key1 > 1 or key2 > 2);
+
+
+# 4. Check if conjuncts are grouped by keyuse
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain
+ select * from t0 where key1<2 or key2<3 or (key1>5 and key1<7) or
+ (key1>10 and key1<12) or (key2>100 and key2<102);
+
+# 5. Check index_merge with conjuncts that are always true/false
+# verify fallback to "range" if there is only one non-confluent condition
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where key2 = 45 or key1 <=> null;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where key2 = 45 or key1 is not null;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where key2 = 45 or key1 is null;
+
+# the last conj. is always false and will be discarded
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where key2=10 or key3=3 or key4 <=> null;
+
+# the last conj. is always true and will cause 'all' scan
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where key2=10 or key3=3 or key4 is null;
+
+# some more complicated cases
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select key1 from t0 where (key1 <=> null) or (key2 < 2) or
+ (key3=10) or (key4 <=> null);
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select key1 from t0 where (key1 <=> null) or (key1 < 5) or
+ (key3=10) or (key4 <=> null);
+
+# 6.Several ways to do index_merge, (ignored) index_merge vs. range
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where
+ (key1 < 2 or key2 < 2) and (key3 < 3 or key4 < 3) and (key5 < 5 or key6 < 5);
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain
+select * from t0 where (key1 < 2 or key2 < 4) and (key1 < 5 or key3 < 3);
+
+select * from t0 where (key1 < 2 or key2 < 4) and (key1 < 5 or key3 < 3);
+
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where
+ (key1 < 3 or key2 < 2) and (key3 < 3 or key4 < 3) and (key5 < 2 or key6 < 2);
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where
+ (key1 < 3 or key2 < 3) and (key3 < 70);
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where
+ (key1 < 3 or key2 < 3) and (key3 < 1000);
+
+
+# 7. Complex cases
+# tree_or(List<SEL_IMERGE>, range SEL_TREE).
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where
+ ((key1 < 3 or key2 < 3) and (key2 <4 or key3 < 3))
+ or
+ key2 > 4;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where
+ ((key1 < 4 or key2 < 4) and (key2 <4 or key3 < 3))
+ or
+ key1 < 5;
+
+select * from t0 where
+ ((key1 < 4 or key2 < 4) and (key2 <4 or key3 < 3))
+ or
+ key1 < 5;
+
+# tree_or(List<SEL_IMERGE>, List<SEL_IMERGE>).
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where
+ ((key1 < 2 or key2 < 2) and (key3 <4 or key5 < 3))
+ or
+ ((key5 < 3 or key6 < 3) and (key7 <3 or key8 < 3));
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where
+ ((key3 <3 or key5 < 4) and (key1 < 3 or key2 < 3))
+ or
+ ((key7 <5 or key8 < 3) and (key5 < 4 or key6 < 4));
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where
+ ((key3 <3 or key5 < 4) and (key1 < 3 or key2 < 4))
+ or
+ ((key3 <4 or key5 < 2) and (key5 < 5 or key6 < 3));
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where
+ ((key3 <4 or key5 < 3) and (key1 < 3 or key2 < 3))
+ or
+ (((key3 <5 and key7 < 5) or key5 < 2) and (key5 < 4 or key6 < 4));
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 where
+ ((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
+ or
+ ((key3 >5 or key5 < 2) and (key5 < 5 or key6 < 6));
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where
+ ((key3 <3 or key5 < 4) and (key1 < 3 or key2 < 3))
+ or
+ ((key3 >4 or key5 < 2) and (key5 < 5 or key6 < 4));
+
+# Can't merge any indexes here (predicate on key3 is always true)
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where
+ ((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
+ or
+ ((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6));
+
+# 8. Verify that "order by" after index merge uses filesort
+select * from t0 where key1 < 3 or key8 < 2 order by key1;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain
+select * from t0 where key1 < 3 or key8 < 2 order by key1;
+
+# 9. Check that index_merge cost is compared to 'index' where possible
+create table t2 like t0;
+insert into t2 select * from t0;
+
+alter table t2 add index i1_3(key1, key3);
+alter table t2 add index i2_3(key2, key3);
+alter table t2 drop index i1;
+alter table t2 drop index i2;
+alter table t2 add index i321(key3, key2, key1);
+
+-- disable_query_log
+-- disable_result_log
+analyze table t2;
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+-- enable_result_log
+-- enable_query_log
+
+# index_merge vs 'index', index_merge is better.
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select key3 from t2 where key1 = 100 or key2 = 100;
+
+# index_merge vs 'index', 'index' is better.
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select key3 from t2 where key1 <100 or key2 < 100;
+
+# index_merge vs 'all', index_merge is better.
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select key7 from t2 where key1 <100 or key2 < 100;
+
+# 10. Multipart keys.
+create table t4 (
+ key1a int not null,
+ key1b int not null,
+ key2 int not null,
+ key2_1 int not null,
+ key2_2 int not null,
+ key3 int not null,
+ index i1a (key1a, key1b),
+ index i1b (key1b, key1a),
+ index i2_1(key2, key2_1),
+ index i2_2(key2, key2_1)
+);
+
+insert into t4 select key1,key1,key1 div 10, key1 % 10, key1 % 10, key1 from t0;
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t4;
+-- enable_result_log
+-- enable_query_log
+
+# the following will be handled by index_merge:
+select * from t4 where key1a = 3 or key1b = 4;
+explain select * from t4 where key1a = 3 or key1b = 4;
+
+# and the following will not
+explain select * from t4 where key2 = 1 and (key2_1 = 1 or key3 = 5);
+
+explain select * from t4 where key2 = 1 and (key2_1 = 1 or key2_2 = 5);
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t4 where key2_1 = 1 or key2_2 = 5;
+
+
+# 11. Multitable selects
+create table t1 like t0;
+insert into t1 select * from t0;
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+# index_merge on first table in join
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0 left join t1 on (t0.key1=t1.key1)
+ where t0.key1=3 or t0.key2=4;
+
+select * from t0 left join t1 on (t0.key1=t1.key1)
+ where t0.key1=3 or t0.key2=4;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain
+select * from t0,t1 where (t0.key1=t1.key1) and ( t0.key1=3 or t0.key2=4);
+
+# index_merge vs. ref
+if (!$index_merge_random_rows_in_EXPLAIN)
+{
+#this plan varies too much for InnoDB
+explain
+select * from t0,t1 where (t0.key1=t1.key1) and
+ (t0.key1=3 or t0.key2=4) and t1.key1<200;
+}
+
+# index_merge vs. ref
+explain
+select * from t0,t1 where (t0.key1=t1.key1) and
+ (t0.key1=3 or t0.key2<4) and t1.key1=2;
+
+# index_merge on second table in join
+explain select * from t0,t1 where t0.key1 = 5 and
+ (t1.key1 = t0.key1 or t1.key8 = t0.key1);
+
+# Fix for bug#1974
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t0,t1 where t0.key1 < 3 and
+ (t1.key1 = t0.key1 or t1.key8 = t0.key1);
+
+# index_merge inside union
+explain select * from t1 where key1=3 or key2=4
+ union select * from t1 where key1<4 or key3=5;
+
+# index merge in subselect
+explain select * from (select * from t1 where key1 = 3 or key2 =3) as Z where key8 >5;
+
+# 12. check for long index_merges.
+create table t3 like t0;
+insert into t3 select * from t0;
+alter table t3 add key9 int not null, add index i9(key9);
+alter table t3 add keyA int not null, add index iA(keyA);
+alter table t3 add keyB int not null, add index iB(keyB);
+alter table t3 add keyC int not null, add index iC(keyC);
+update t3 set key9=key1,keyA=key1,keyB=key1,keyC=key1;
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t3;
+-- enable_result_log
+-- enable_query_log
+
+explain select * from t3 where
+ key1=1 or key2=2 or key3=3 or key4=4 or
+ key5=5 or key6=6 or key7=7 or key8=8 or
+ key9=9 or keyA=10 or keyB=11 or keyC=12;
+
+select * from t3 where
+ key1=1 or key2=2 or key3=3 or key4=4 or
+ key5=5 or key6=6 or key7=7 or key8=8 or
+ key9=9 or keyA=10 or keyB=11 or keyC=12;
+
+# Test for Bug#3183
+explain select * from t0 where key1 < 3 or key2 < 4;
+# Bug#21277: InnoDB, wrong result set, index_merge strategy, second index not evaluated
+select * from t0 where key1 < 3 or key2 < 4;
+
+update t0 set key8=123 where key1 < 3 or key2 < 4;
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t0;
+-- enable_result_log
+-- enable_query_log
+
+# Bug#21277: InnoDB, wrong result set, index_merge strategy, second index not evaluated
+select * from t0 where key1 < 3 or key2 < 4;
+
+delete from t0 where key1 < 3 or key2 < 4;
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t0;
+-- enable_result_log
+-- enable_query_log
+
+select * from t0 where key1 < 3 or key2 < 4;
+select count(*) from t0;
+
+# Test for BUG#4177
+drop table t4;
+create table t4 (a int);
+insert into t4 values (1),(4),(3);
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t4;
+-- enable_result_log
+-- enable_query_log
+
+set @save_join_buffer_size=@@join_buffer_size;
+set join_buffer_size= 4096;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
+ from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
+ where (A.key1 < 500000 or A.key2 < 3)
+ and (B.key1 < 500000 or B.key2 < 3);
+
+select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
+ from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
+ where (A.key1 < 500000 or A.key2 < 3)
+ and (B.key1 < 500000 or B.key2 < 3);
+
+update t0 set key1=1;
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t0;
+-- enable_result_log
+-- enable_query_log
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
+ from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
+ where (A.key1 = 1 or A.key2 = 1)
+ and (B.key1 = 1 or B.key2 = 1);
+
+select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
+ from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
+ where (A.key1 = 1 or A.key2 = 1)
+ and (B.key1 = 1 or B.key2 = 1);
+
+alter table t0 add filler1 char(200), add filler2 char(200), add filler3 char(200);
+update t0 set key2=1, key3=1, key4=1, key5=1,key6=1,key7=1 where key7 < 500;
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t0;
+-- enable_result_log
+-- enable_query_log
+
+# The next query will not use index i7 in intersection if the OS doesn't
+# support file sizes > 2GB. (ha_myisam::ref_length depends on this and index
+# scan cost estimates depend on ha_myisam::ref_length)
+if (!$index_merge_random_rows_in_EXPLAIN)
+{
+ # Too unstable for innodb
+ --replace_column 9 #
+ --replace_result "4,4,4,4,4,4,4" X "4,4,4,4,4,4" X "i6,i7" "i6,i7?" "i6" "i6,i7?"
+ explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
+ from t0 as A, t0 as B
+ where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)
+ and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7 = 1 or B.key8=1);
+}
+select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
+ from t0 as A, t0 as B
+ where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)
+ and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7 = 1 or B.key8=1);
+
+set join_buffer_size= @save_join_buffer_size;
+# Test for BUG#4177 ends
+
+drop table t0, t1, t2, t3, t4;
+
+# BUG#16166
+CREATE TABLE t1 (
+ cola char(3) not null, colb char(3) not null, filler char(200),
+ key(cola), key(colb)
+);
+INSERT INTO t1 VALUES ('foo','bar', 'ZZ'),('fuz','baz', 'ZZ');
+
+--disable_query_log
+let $1=9;
+while ($1)
+{
+ eval INSERT INTO t1 SELECT * from t1 WHERE cola = 'foo';
+ dec $1;
+}
+
+let $1=13;
+while ($1)
+{
+ eval INSERT INTO t1 SELECT * from t1 WHERE cola <> 'foo';
+ dec $1;
+}
+
+--enable_query_log
+
+OPTIMIZE TABLE t1;
+select count(*) from t1;
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t1 WHERE cola = 'foo' AND colb = 'bar';
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t1 force index(cola,colb) WHERE cola = 'foo' AND colb = 'bar';
+drop table t1;
+
+if ($merge_table_support)
+{
+#
+# BUG#17314: Index_merge/intersection not chosen by the optimizer for MERGE tables
+#
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (
+ a int, b int,
+ filler1 char(200), filler2 char(200),
+ key(a),key(b)
+);
+insert into t1 select @v:= A.a, @v, 't1', 'filler2' from t0 A, t0 B, t0 C;
+create table t2 like t1;
+
+create table t3 (
+ a int, b int,
+ filler1 char(200), filler2 char(200),
+ key(a),key(b)
+) engine=merge union=(t1,t2);
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t0;
+analyze table t1;
+analyze table t2;
+analyze table t3;
+-- enable_result_log
+-- enable_query_log
+
+--replace_column 9 #
+explain select * from t1 where a=1 and b=1;
+--replace_column 9 #
+explain select * from t3 where a=1 and b=1;
+
+drop table t3;
+drop table t0, t1, t2;
+}
+
+#
+# BUG#20256 - LOCK WRITE - MyISAM
+#
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES(1);
+CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b));
+INSERT INTO t2(a,b) VALUES
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(1,2);
+LOCK TABLES t1 WRITE, t2 WRITE;
+INSERT INTO t2(a,b) VALUES(1,2);
+SELECT t2.a FROM t1,t2 WHERE t2.b=2 AND t2.a=1;
+UNLOCK TABLES;
+DROP TABLE t1, t2;
+
+#
+# BUG#29740: HA_KEY_SCAN_NOT_ROR wasn't set for HEAP engine
+#
+CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `filler` char(200) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY `a` (`a`),
+ KEY `b` (`b`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1;
+
+insert into t1 values
+(0, 'filler', 0), (1, 'filler', 1), (2, 'filler', 2), (3, 'filler', 3),
+(4, 'filler', 4), (5, 'filler', 5), (6, 'filler', 6), (7, 'filler', 7),
+(8, 'filler', 8), (9, 'filler', 9), (0, 'filler', 0), (1, 'filler', 1),
+(2, 'filler', 2), (3, 'filler', 3), (4, 'filler', 4), (5, 'filler', 5),
+(6, 'filler', 6), (7, 'filler', 7), (8, 'filler', 8), (9, 'filler', 9),
+(10, 'filler', 10), (11, 'filler', 11), (12, 'filler', 12), (13, 'filler', 13),
+(14, 'filler', 14), (15, 'filler', 15), (16, 'filler', 16), (17, 'filler', 17),
+(18, 'filler', 18), (19, 'filler', 19), (4, '5 ', 0), (5, '4 ', 0),
+(4, '4 ', 0), (4, 'qq ', 5), (5, 'qq ', 4), (4, 'zz ', 4);
+
+create table t2(
+ `a` int(11) DEFAULT NULL,
+ `filler` char(200) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY USING BTREE (`a`),
+ KEY USING BTREE (`b`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1;
+insert into t2 select * from t1;
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+analyze table t2;
+-- enable_result_log
+-- enable_query_log
+
+--echo must use sort-union rather than union:
+--replace_column 9 #
+explain select * from t1 where a=4 or b=4;
+--sorted_result
+select * from t1 where a=4 or b=4;
+--sorted_result
+select * from t1 ignore index(a,b) where a=4 or b=4;
+
+--echo must use union, not sort-union:
+--replace_column 9 #
+explain select * from t2 where a=4 or b=4;
+--sorted_result
+select * from t2 where a=4 or b=4;
+
+drop table t1, t2;
+
+#
+# Bug #37943: Reproducible mysqld crash/sigsegv in sel_trees_can_be_ored
+#
+
+CREATE TABLE t1 (a varchar(8), b set('a','b','c','d','e','f','g','h'),
+ KEY b(b), KEY a(a));
+INSERT INTO t1 VALUES ('y',''), ('z','');
+
+#should not crash
+SELECT b,a from t1 WHERE (b!='c' AND b!='f' && b!='h') OR
+ (a='pure-S') OR (a='DE80337a') OR (a='DE80799');
+
+DROP TABLE t1;
+
+--echo #
+--echo # BUG#40974: Incorrect query results when using clause evaluated using range check
+--echo #
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t1 (a int);
+insert into t1 values (1),(2);
+create table t2(a int, b int);
+insert into t2 values (1,1), (2, 1000);
+create table t3 (a int, b int, filler char(100), key(a), key(b));
+
+insert into t3 select 1000, 1000,'filler' from t0 A, t0 B, t0 C;
+insert into t3 values (1,1,'data');
+insert into t3 values (1,1,'data');
+-- echo The plan should be ALL/ALL/ALL(Range checked for each record (index map: 0x3)
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t0;
+analyze table t1;
+analyze table t2;
+analyze table t3;
+-- enable_result_log
+-- enable_query_log
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t1
+where exists (select 1 from t2, t3
+ where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1));
+
+select * from t1
+where exists (select 1 from t2, t3
+ where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1));
+
+drop table t0, t1, t2, t3;
+
+--echo #
+--echo # BUG#44810: index merge and order by with low sort_buffer_size
+--echo # crashes server!
+--echo #
+CREATE TABLE t1(a VARCHAR(128),b VARCHAR(128),KEY(A),KEY(B));
+INSERT INTO t1 VALUES (REPEAT('a',128),REPEAT('b',128));
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+# Causes "out of sort memory" error in MariaDB:
+#SET SESSION sort_buffer_size=1;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+EXPLAIN
+SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%'
+ ORDER BY a,b;
+
+# we don't actually care about the result : we're checking if it crashes
+--disable_result_log
+SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%'
+ ORDER BY a,b;
+--enable_result_log
+
+SET SESSION sort_buffer_size=DEFAULT;
+DROP TABLE t1;
+
+
+--echo End of 5.0 tests
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/index_merge2.inc b/storage/rocksdb/mysql-test/rocksdb/include/index_merge2.inc
new file mode 100644
index 00000000..7e5cec40
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/index_merge2.inc
@@ -0,0 +1,520 @@
+# include/index_merge2.inc
+#
+# Index merge tests
+#
+# The variable
+# $engine_type -- storage engine to be tested
+# has to be set before sourcing this script.
+#
+# Note: The comments/expectations refer to InnoDB.
+# They might be not valid for other storage engines.
+#
+# Last update:
+# 2006-08-02 ML test refactored
+# old name was t/index_merge_innodb.test
+# main code went into include/index_merge2.inc
+#
+
+--echo #---------------- Index merge test 2 -------------------------------------------
+
+eval SET SESSION DEFAULT_STORAGE_ENGINE = $engine_type;
+
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+create table t1
+(
+ key1 int not null,
+ key2 int not null,
+
+ INDEX i1(key1),
+ INDEX i2(key2)
+);
+
+--disable_query_log
+let $1=200;
+while ($1)
+{
+ eval insert into t1 values (200-$1, $1);
+ dec $1;
+}
+--enable_query_log
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+# No primary key
+explain select * from t1 where key1 < 5 or key2 > 197;
+
+select * from t1 where key1 < 5 or key2 > 197;
+
+explain select * from t1 where key1 < 3 or key2 > 195;
+select * from t1 where key1 < 3 or key2 > 195;
+
+# Primary key as case-sensitive string with \0s.
+# also make primary key be longer then max. index length of MyISAM.
+alter table t1 add str1 char (255) not null,
+ add zeroval int not null default 0,
+ add str2 char (255) not null,
+ add str3 char (255) not null;
+
+update t1 set str1='aaa', str2='bbb', str3=concat(key2, '-', key1 div 2, '_' ,if(key1 mod 2 = 0, 'a', 'A'));
+
+alter table t1 add primary key (str1, zeroval, str2, str3);
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+explain select * from t1 where key1 < 5 or key2 > 197;
+
+select * from t1 where key1 < 5 or key2 > 197;
+
+explain select * from t1 where key1 < 3 or key2 > 195;
+select * from t1 where key1 < 3 or key2 > 195;
+
+# Test for BUG#5401
+drop table t1;
+create table t1 (
+ pk integer not null auto_increment primary key,
+ key1 integer,
+ key2 integer not null,
+ filler char (200),
+ index (key1),
+ index (key2)
+);
+show warnings;
+--disable_query_log
+let $1=30;
+while ($1)
+{
+ eval insert into t1 (key1, key2, filler) values ($1/4, $1/8, 'filler-data');
+ dec $1;
+}
+--enable_query_log
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+explain select pk from t1 where key1 = 1 and key2 = 1;
+select pk from t1 where key2 = 1 and key1 = 1;
+select pk from t1 ignore index(key1,key2) where key2 = 1 and key1 = 1;
+
+# More tests for BUG#5401.
+drop table t1;
+create table t1 (
+ pk int primary key auto_increment,
+ key1a int,
+ key2a int,
+ key1b int,
+ key2b int,
+ dummy1 int,
+ dummy2 int,
+ dummy3 int,
+ dummy4 int,
+ key3a int,
+ key3b int,
+ filler1 char (200),
+ index i1(key1a, key1b),
+ index i2(key2a, key2b),
+ index i3(key3a, key3b)
+);
+
+create table t2 (a int);
+insert into t2 values (0),(1),(2),(3),(4),(NULL);
+
+insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b)
+ select A.a, B.a, C.a, D.a, C.a, D.a from t2 A,t2 B,t2 C, t2 D;
+insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b)
+ select key1a, key1b, key2a, key2b, key3a, key3b from t1;
+insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b)
+ select key1a, key1b, key2a, key2b, key3a, key3b from t1;
+analyze table t1;
+select count(*) from t1;
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t2;
+-- enable_result_log
+-- enable_query_log
+
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select count(*) from t1 where
+ key1a = 2 and key1b is null and key2a = 2 and key2b is null;
+}
+
+select count(*) from t1 where
+ key1a = 2 and key1b is null and key2a = 2 and key2b is null;
+
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select count(*) from t1 where
+ key1a = 2 and key1b is null and key3a = 2 and key3b is null;
+}
+
+select count(*) from t1 where
+ key1a = 2 and key1b is null and key3a = 2 and key3b is null;
+
+drop table t1,t2;
+
+# Test for BUG#8441
+create table t1 (
+ id1 int,
+ id2 date ,
+ index idx2 (id1,id2),
+ index idx1 (id2)
+);
+insert into t1 values(1,'20040101'), (2,'20040102');
+select * from t1 where id1 = 1 and id2= '20040101';
+drop table t1;
+
+# Test for BUG#12720
+--disable_warnings
+drop view if exists v1;
+--enable_warnings
+CREATE TABLE t1 (
+ `oid` int(11) unsigned NOT NULL auto_increment,
+ `fk_bbk_niederlassung` int(11) unsigned NOT NULL,
+ `fk_wochentag` int(11) unsigned NOT NULL,
+ `uhrzeit_von` time NOT NULL COMMENT 'HH:MM',
+ `uhrzeit_bis` time NOT NULL COMMENT 'HH:MM',
+ `geloescht` tinyint(4) NOT NULL,
+ `version` int(5) NOT NULL,
+ PRIMARY KEY (`oid`),
+ KEY `fk_bbk_niederlassung` (`fk_bbk_niederlassung`),
+ KEY `fk_wochentag` (`fk_wochentag`),
+ KEY `ix_version` (`version`)
+) DEFAULT CHARSET=latin1;
+
+insert into t1 values
+(1, 38, 1, '08:00:00', '13:00:00', 0, 1),
+(2, 38, 2, '08:00:00', '13:00:00', 0, 1),
+(3, 38, 3, '08:00:00', '13:00:00', 0, 1),
+(4, 38, 4, '08:00:00', '13:00:00', 0, 1),
+(5, 38, 5, '08:00:00', '13:00:00', 0, 1),
+(6, 38, 5, '08:00:00', '13:00:00', 1, 2),
+(7, 38, 3, '08:00:00', '13:00:00', 1, 2),
+(8, 38, 1, '08:00:00', '13:00:00', 1, 2),
+(9, 38, 2, '08:00:00', '13:00:00', 1, 2),
+(10, 38, 4, '08:00:00', '13:00:00', 1, 2),
+(11, 38, 1, '08:00:00', '13:00:00', 0, 3),
+(12, 38, 2, '08:00:00', '13:00:00', 0, 3),
+(13, 38, 3, '08:00:00', '13:00:00', 0, 3),
+(14, 38, 4, '08:00:00', '13:00:00', 0, 3),
+(15, 38, 5, '08:00:00', '13:00:00', 0, 3),
+(16, 38, 4, '08:00:00', '13:00:00', 0, 4),
+(17, 38, 5, '08:00:00', '13:00:00', 0, 4),
+(18, 38, 1, '08:00:00', '13:00:00', 0, 4),
+(19, 38, 2, '08:00:00', '13:00:00', 0, 4),
+(20, 38, 3, '08:00:00', '13:00:00', 0, 4),
+(21, 7, 1, '08:00:00', '13:00:00', 0, 1),
+(22, 7, 2, '08:00:00', '13:00:00', 0, 1),
+(23, 7, 3, '08:00:00', '13:00:00', 0, 1),
+(24, 7, 4, '08:00:00', '13:00:00', 0, 1),
+(25, 7, 5, '08:00:00', '13:00:00', 0, 1);
+
+create view v1 as
+select
+ zeit1.oid AS oid,
+ zeit1.fk_bbk_niederlassung AS fk_bbk_niederlassung,
+ zeit1.fk_wochentag AS fk_wochentag,
+ zeit1.uhrzeit_von AS uhrzeit_von,
+ zeit1.uhrzeit_bis AS uhrzeit_bis,
+ zeit1.geloescht AS geloescht,
+ zeit1.version AS version
+from
+ t1 zeit1
+where
+(zeit1.version =
+ (select max(zeit2.version) AS `max(version)`
+ from t1 zeit2
+ where
+ ((zeit1.fk_bbk_niederlassung = zeit2.fk_bbk_niederlassung) and
+ (zeit1.fk_wochentag = zeit2.fk_wochentag) and
+ (zeit1.uhrzeit_von = zeit2.uhrzeit_von) and
+ (zeit1.uhrzeit_bis = zeit2.uhrzeit_bis)
+ )
+ )
+)
+and (zeit1.geloescht = 0);
+
+select * from v1 where oid = 21;
+drop view v1;
+drop table t1;
+##
+CREATE TABLE t1(
+ t_cpac varchar(2) NOT NULL,
+ t_vers varchar(4) NOT NULL,
+ t_rele varchar(2) NOT NULL,
+ t_cust varchar(4) NOT NULL,
+ filler1 char(250) default NULL,
+ filler2 char(250) default NULL,
+ PRIMARY KEY (t_cpac,t_vers,t_rele,t_cust),
+ UNIQUE KEY IX_4 (t_cust,t_cpac,t_vers,t_rele),
+ KEY IX_5 (t_vers,t_rele,t_cust)
+);
+
+insert into t1 values
+('tm','2.5 ','a ',' ','',''), ('tm','2.5U','a ','stnd','',''),
+('da','3.3 ','b ',' ','',''), ('da','3.3U','b ','stnd','',''),
+('tl','7.6 ','a ',' ','',''), ('tt','7.6 ','a ',' ','',''),
+('bc','B61 ','a ',' ','',''), ('bp','B61 ','a ',' ','',''),
+('ca','B61 ','a ',' ','',''), ('ci','B61 ','a ',' ','',''),
+('cp','B61 ','a ',' ','',''), ('dm','B61 ','a ',' ','',''),
+('ec','B61 ','a ',' ','',''), ('ed','B61 ','a ',' ','',''),
+('fm','B61 ','a ',' ','',''), ('nt','B61 ','a ',' ','',''),
+('qm','B61 ','a ',' ','',''), ('tc','B61 ','a ',' ','',''),
+('td','B61 ','a ',' ','',''), ('tf','B61 ','a ',' ','',''),
+('tg','B61 ','a ',' ','',''), ('ti','B61 ','a ',' ','',''),
+('tp','B61 ','a ',' ','',''), ('ts','B61 ','a ',' ','',''),
+('wh','B61 ','a ',' ','',''), ('bc','B61U','a ','stnd','',''),
+('bp','B61U','a ','stnd','',''), ('ca','B61U','a ','stnd','',''),
+('ci','B61U','a ','stnd','',''), ('cp','B61U','a ','stnd','',''),
+('dm','B61U','a ','stnd','',''), ('ec','B61U','a ','stnd','',''),
+('fm','B61U','a ','stnd','',''), ('nt','B61U','a ','stnd','',''),
+('qm','B61U','a ','stnd','',''), ('tc','B61U','a ','stnd','',''),
+('td','B61U','a ','stnd','',''), ('tf','B61U','a ','stnd','',''),
+('tg','B61U','a ','stnd','',''), ('ti','B61U','a ','stnd','',''),
+('tp','B61U','a ','stnd','',''), ('ts','B61U','a ','stnd','',''),
+('wh','B61U','a ','stnd','','');
+show create table t1;
+
+select t_vers,t_rele,t_cust,filler1 from t1 where t_vers = '7.6';
+select t_vers,t_rele,t_cust,filler1 from t1 where t_vers = '7.6'
+ and t_rele='a' and t_cust = ' ';
+
+drop table t1;
+
+# BUG#19021: Crash in index_merge/ROR-intersection optimizer under
+# specific circumstances.
+create table t1 (
+ pk int(11) not null auto_increment,
+ a int(11) not null default '0',
+ b int(11) not null default '0',
+ c int(11) not null default '0',
+
+ filler1 datetime, filler2 varchar(15),
+ filler3 longtext,
+
+ kp1 varchar(4), kp2 varchar(7),
+ kp3 varchar(2), kp4 varchar(4),
+ kp5 varchar(7),
+ filler4 char(1),
+
+ primary key (pk),
+ key idx1(a,b,c),
+ key idx2(c),
+ key idx3(kp1,kp2,kp3,kp4,kp5)
+) default charset=latin1;
+--disable_query_log
+set @fill= uncompress(unhex(concat(
+'F91D0000789CDD993D6FDB301086F7FE0A6D4E0105B8E3F1335D5BA028DA0EEDE28E1D320408',
+'52A0713BF4D7571FB62C51A475924839080307B603E77DEE787C8FA41F9E9EEF7F1F8A87A7C3',
+'AFE280C5DF9F8F7FEE9F8B1B2CB114D6902E918455245DB91300FA16E42D5201FA4EE29DA05D',
+'B9FB3718A33718A3FA8C30AEFAFDE1F317D016AA67BA7A60FDE45BF5F8BA7B5BDE8812AA9F1A',
+'069DB03C9804346644F3A3A6A1338DB572756A3C4D1BCC804CABF912C654AE9BB855A2B85962',
+'3A479259CAE6A86C0411D01AE5483581EDCBD9A39C45252D532E533979EB9F82E971D979BDB4',
+'8531105670740AFBFD1E34AAB0029E4AD0A1D46A6D0946A21A16038A5CD965CD2D524673F712',
+'20C304477315CE18405EAF9BD0AFFEAC74FDA14F1FBF5BD34C769D73FBBEDF4750ADD4E5A99C',
+'5C8DC04934AFA275D483D536D174C11B12AF27F8F888B41B6FC9DBA569E1FD7BD72D698130B7',
+'91B23A98803512B3D31881E8DCDA2AC1754E3644C4BB3A8466750B911681274A39E35E8624B7',
+'444A42AC1213F354758E3CF1A4CDD5A688C767CF1B11ABC5867CB15D8A18E0B91E9EC275BB94',
+'58F33C2936F64690D55BC29E4A293D95A798D84217736CEAAA538CE1354269EE2162053FBC66',
+'496D90CB53323CB279D3A6AF651B4B22B9E430743D83BE48E995A09D4FC9871C22D8D189B945',
+'706911BCB8C3C774B9C08D2FC6ED853ADACA37A14A4CB2E027630E5B80ECACD939431B1CDF62',
+'7D71487536EA2C678F59685E91F4B6C144BCCB94C1EBA9FA6F5552DDCA4E4539BE326A2720CB',
+'45ED028EB3616AC93C46E775FEA9FA6DA7CFCEC6DEBA5FCD1F915EED4D983BDDB881528AD9AB',
+'43C1576F29AAB35BDFBC21D422F52B307D350589D45225A887AC46C8EDD72D99EC3ED2E1BCEF',
+'7AF26FC4C74097B6768A5EDAFA660CC64278F7E63F99AC954B')));
+prepare x from @fill;
+execute x;
+deallocate prepare x;
+--enable_query_log
+set @fill=NULL;
+SELECT COUNT(*) FROM t1 WHERE b = 0 AND a = 0 AND c = 13286427 AND
+ kp1='279' AND kp2='ELM0678' AND kp3='6' AND kp4='10' AND kp5 = 'R ';
+
+drop table t1;
+
+# BUG#21277: Index Merge/sort_union: wrong query results
+create table t1
+(
+ key1 int not null,
+ key2 int not null default 0,
+ key3 int not null default 0
+);
+
+insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8);
+
+let $1=7;
+set @d=8;
+while ($1)
+{
+ eval insert into t1 (key1) select key1+@d from t1;
+ eval set @d=@d*2;
+ dec $1;
+}
+
+alter table t1 add index i2(key2);
+alter table t1 add index i3(key3);
+update t1 set key2=key1,key3=key1;
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+# to test the bug, the following must use "sort_union":
+explain select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
+}
+select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
+drop table t1;
+
+--echo #
+--echo # Bug#56423: Different count with SELECT and CREATE SELECT queries
+--echo #
+
+CREATE TABLE t1 (
+ a INT,
+ b INT,
+ c INT,
+ d INT,
+ PRIMARY KEY (a),
+ KEY (c),
+ KEY bd (b,d)
+);
+
+INSERT INTO t1 VALUES
+(1, 0, 1, 0),
+(2, 1, 1, 1),
+(3, 1, 1, 1),
+(4, 0, 1, 1);
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+EXPLAIN
+SELECT a
+FROM t1
+WHERE c = 1 AND b = 1 AND d = 1;
+
+CREATE TABLE t2 ( a INT )
+SELECT a
+FROM t1
+WHERE c = 1 AND b = 1 AND d = 1;
+
+SELECT * FROM t2;
+
+DROP TABLE t1, t2;
+
+CREATE TABLE t1( a INT, b INT, KEY(a), KEY(b) );
+INSERT INTO t1 VALUES (1, 2), (1, 2), (1, 2), (1, 2);
+SELECT * FROM t1 FORCE INDEX(a, b) WHERE a = 1 AND b = 2;
+
+DROP TABLE t1;
+
+--echo # Code coverage of fix.
+CREATE TABLE t1 ( a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT);
+INSERT INTO t1 (b) VALUES (1);
+UPDATE t1 SET b = 2 WHERE a = 1;
+SELECT * FROM t1;
+
+CREATE TABLE t2 ( a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b VARCHAR(1) );
+INSERT INTO t2 (b) VALUES ('a');
+UPDATE t2 SET b = 'b' WHERE a = 1;
+SELECT * FROM t2;
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # BUG#13970015: ASSERT `MIN_ENDP || MAX_ENDP' FAILED IN
+--echo # HANDLER::MULTI_RANGE_READ_INFO_CONST
+--echo #
+
+CREATE TABLE t1 (
+ pk INT NOT NULL,
+ col_int_key INT NOT NULL,
+ col_varchar_key VARCHAR(1) NOT NULL,
+ PRIMARY KEY (pk),
+ KEY col_int_key (col_int_key),
+ KEY col_varchar_key (col_varchar_key,col_int_key)
+);
+
+INSERT INTO t1 VALUES (1,1,'a'), (2,2,'b');
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+EXPLAIN
+SELECT col_int_key
+FROM t1
+WHERE col_varchar_key >= 'l' OR
+ (((pk BETWEEN 141 AND 141) OR col_varchar_key <> 'l')
+ AND ((pk BETWEEN 141 AND 141) OR (col_int_key > 141)));
+
+SELECT col_int_key
+FROM t1
+WHERE col_varchar_key >= 'l' OR
+ (((pk BETWEEN 141 AND 141) OR col_varchar_key <> 'l')
+ AND ((pk BETWEEN 141 AND 141) OR (col_int_key > 141)));
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/index_merge_2sweeps.inc b/storage/rocksdb/mysql-test/rocksdb/include/index_merge_2sweeps.inc
new file mode 100644
index 00000000..4f195051
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/index_merge_2sweeps.inc
@@ -0,0 +1,80 @@
+# include/index_merge_2sweeps.inc
+#
+# 2-sweeps read Index_merge test
+#
+# The variable
+# $engine_type -- storage engine to be tested
+# has to be set before sourcing this script.
+#
+# Last update:
+# 2006-08-02 ML test refactored
+# old name was index_merge_innodb2.test
+# main code went into include/index_merge_2sweeps.inc
+#
+
+--echo #---------------- 2-sweeps read Index merge test 2 -------------------------------
+
+eval SET SESSION DEFAULT_STORAGE_ENGINE = $engine_type;
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (
+ pk int primary key,
+ key1 int,
+ key2 int,
+ filler char(200),
+ filler2 char(200),
+ index(key1),
+ index(key2)
+);
+
+
+--disable_query_log
+let $1=1000;
+while ($1)
+{
+ eval insert into t1 values($1, $1, $1, 'filler-data','filler-data-2');
+ dec $1;
+}
+--enable_query_log
+
+if ($sorted_result) {
+ --sorted_result
+}
+select * from t1 where (key1 >= 2 and key1 <= 10) or (pk >= 4 and pk <=8 );
+
+set @maxv=1000;
+
+if ($sorted_result) {
+ --sorted_result
+}
+select * from t1 where
+ (pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10)
+ or key1=18 or key1=60;
+
+if ($sorted_result) {
+ --sorted_result
+}
+select * from t1 where
+ (pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10)
+ or key1 < 3 or key1 > @maxv-11;
+
+if ($sorted_result) {
+ --sorted_result
+}
+select * from t1 where
+ (pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10)
+ or
+ (key1 < 5) or (key1 > 10 and key1 < 15) or (key1 >= 50 and key1 < 55 ) or (key1 > @maxv-10);
+
+if ($sorted_result) {
+ --sorted_result
+}
+select * from t1 where
+ (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 )
+ or
+ (key1 < 5) or (key1 > @maxv-10);
+
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/index_merge_ror.inc b/storage/rocksdb/mysql-test/rocksdb/include/index_merge_ror.inc
new file mode 100644
index 00000000..21219d1a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/index_merge_ror.inc
@@ -0,0 +1,463 @@
+# include/index_merge_ror.inc
+#
+# ROR-index_merge tests.
+#
+# The variable
+# $engine_type -- storage engine to be tested
+# has to be set before sourcing this script.
+#
+# Note: The comments/expectations refer to MyISAM.
+# They might be not valid for other storage engines.
+#
+# Last update:
+# 2006-08-02 ML test refactored
+# old name was t/index_merge_ror.test
+# main code went into include/index_merge_ror.inc
+#
+
+--echo #---------------- ROR-index_merge tests -----------------------
+
+eval SET SESSION DEFAULT_STORAGE_ENGINE = $engine_type;
+
+--disable_warnings
+drop table if exists t0,t1,t2;
+--enable_warnings
+create table t1
+(
+ /* Field names reflect value(rowid) distribution, st=STairs, swt= SaWTooth */
+ st_a int not null default 0,
+ swt1a int not null default 0,
+ swt2a int not null default 0,
+
+ st_b int not null default 0,
+ swt1b int not null default 0,
+ swt2b int not null default 0,
+
+ /* fields/keys for row retrieval tests */
+ key1 int,
+ key2 int,
+ key3 int,
+ key4 int,
+
+ /* make rows much bigger then keys */
+ filler1 char (200),
+ filler2 char (200),
+ filler3 char (200),
+ filler4 char (200),
+ filler5 char (200),
+ filler6 char (200),
+
+ /* order of keys is important */
+ key sta_swt12a(st_a,swt1a,swt2a),
+ key sta_swt1a(st_a,swt1a),
+ key sta_swt2a(st_a,swt2a),
+ key sta_swt21a(st_a,swt2a,swt1a),
+
+ key st_a(st_a),
+ key stb_swt1a_2b(st_b,swt1b,swt2a),
+ key stb_swt1b(st_b,swt1b),
+ key st_b(st_b),
+
+ key(key1),
+ key(key2),
+ key(key3),
+ key(key4)
+) ;
+
+# Fill table
+create table t0 as select * from t1;
+--disable_query_log
+--echo # Printing of many insert into t0 values (....) disabled.
+let $cnt=1000;
+while ($cnt)
+{
+ eval insert into t0 values (1, 2, 3, 1, 2, 3, 0, 0, 0, 0, 'data1', 'data2', 'data3', 'data4', 'data5', 'data6');
+ dec $cnt;
+}
+--enable_query_log
+
+alter table t1 disable keys;
+--disable_query_log
+--echo # Printing of many insert into t1 select .... from t0 disabled.
+let $1=4;
+while ($1)
+{
+ let $2=4;
+ while ($2)
+ {
+ let $3=4;
+ while ($3)
+ {
+ eval insert into t1 select $1, $2, $3, $1 ,$2, $3, key1, key2, key3, key4, filler1, filler2, filler3, filler4, filler5, filler6 from t0;
+ dec $3;
+ }
+ dec $2;
+ }
+ dec $1;
+}
+
+--echo # Printing of many insert into t1 (...) values (....) disabled.
+# Row retrieval tests
+# -1 is used for values 'out of any range we are using'
+# insert enough rows for index intersection to be used for (key1,key2)
+insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 100, 100,'key1-key2-key3-key4');
+let $cnt=400;
+while ($cnt)
+{
+ eval insert into t1 (key1, key2, key3, key4, filler1) values (100, -1, 100, -1,'key1-key3');
+ dec $cnt;
+}
+let $cnt=400;
+while ($cnt)
+{
+ eval insert into t1 (key1, key2, key3, key4, filler1) values (-1, 100, -1, 100,'key2-key4');
+ dec $cnt;
+}
+--enable_query_log
+alter table t1 enable keys;
+select count(*) from t1;
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t0;
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+# One row results tests for cases where a single row matches all conditions
+--replace_column 9 #
+explain select key1,key2 from t1 where key1=100 and key2=100;
+select key1,key2 from t1 where key1=100 and key2=100;
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+ explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+ explain format=json select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+}
+select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+
+# Several-rows results
+insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, -1, -1, 'key1-key2');
+insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 100, 100, 'key4-key3');
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+# ROR-intersection, not covering
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+ explain select key1,key2,filler1 from t1 where key1=100 and key2=100;
+}
+select key1,key2,filler1 from t1 where key1=100 and key2=100;
+
+# ROR-intersection, covering
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+ explain select key1,key2 from t1 where key1=100 and key2=100;
+}
+select key1,key2 from t1 where key1=100 and key2=100;
+
+# ROR-union of ROR-intersections
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+ explain select key1,key2,key3,key4 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+}
+select key1,key2,key3,key4 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+ explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+}
+select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+
+# 3-way ROR-intersection
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+ explain select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100;
+}
+select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100;
+
+# ROR-union(ROR-intersection, ROR-range)
+insert into t1 (key1,key2,key3,key4,filler1) values (101,101,101,101, 'key1234-101');
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+ explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=101;
+}
+select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=101;
+
+# Run some ROR updates/deletes
+select key1,key2, filler1 from t1 where key1=100 and key2=100;
+update t1 set filler1='to be deleted' where key1=100 and key2=100;
+update t1 set key1=200,key2=200 where key1=100 and key2=100;
+delete from t1 where key1=200 and key2=200;
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+select key1,key2,filler1 from t1 where key2=100 and key2=200;
+
+# ROR-union(ROR-intersection) with one of ROR-intersection giving empty
+# results
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+ explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+}
+select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+
+delete from t1 where key3=100 and key4=100;
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+# ROR-union with all ROR-intersections giving empty results
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+ explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+}
+select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+
+# ROR-intersection with empty result
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+ explain select key1,key2 from t1 where key1=100 and key2=100;
+}
+select key1,key2 from t1 where key1=100 and key2=100;
+
+# ROR-union tests with various cases.
+# All scans returning duplicate rows:
+insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-1');
+insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-2');
+insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-3');
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+ explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
+}
+select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
+
+insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, -1, 200,'key4');
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+ explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
+}
+select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
+
+insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 200, -1,'key3');
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+ explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
+}
+select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
+
+##
+## Optimizer tests
+##
+
+# Check that the shortest key is used for ROR-intersection, covering and non-covering.
+if (!$index_merge_random_rows_in_EXPLAIN)
+{
+ # Too unstable on InnoDB
+ explain select * from t1 where st_a=1 and st_b=1;
+ explain select st_a,st_b from t1 where st_a=1 and st_b=1;
+ explain select st_a from t1 ignore index (st_a) where st_a=1 and st_b=1;
+}
+
+# Do many tests
+# Check that keys that don't improve selectivity are skipped.
+#
+if (!$skip_ror_EXPLAIN_for_MyRocks)
+{
+# Different value on 32 and 64 bit
+if ($random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+--replace_result sta_swt12a sta_swt21a sta_swt12a, sta_swt12a,
+explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1;
+
+if ($random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t1 where st_b=1 and swt1b=1 and swt2b=1;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t1 ignore index (sta_swt21a, stb_swt1a_2b)
+ where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t1 ignore index (sta_swt21a, sta_swt12a, stb_swt1a_2b)
+ where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t1 ignore index (sta_swt21a, sta_swt12a, stb_swt1a_2b, stb_swt1b)
+ where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t1
+ where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select * from t1
+ where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select st_a from t1
+ where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
+
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+ --replace_column 9 #
+}
+explain select st_a from t1
+ where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
+}
+
+drop table t0,t1;
+
+# 'Partially' covered fields test
+
+create table t2 (
+ a char(10),
+ b char(10),
+ filler1 char(255),
+ filler2 char(255),
+ key(a(5)),
+ key(b(5))
+);
+
+--disable_query_log
+let $1=8;
+while ($1)
+{
+ eval insert into t2 values (repeat(char($1+64), 8),repeat(char($1+64), 8),'filler1', 'filler2');
+ dec $1;
+}
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+--enable_query_log
+
+# The table row buffer is reused. Fill it with rows that don't match.
+select count(a) from t2 where a='BBBBBBBB';
+select count(a) from t2 where b='BBBBBBBB';
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t2;
+-- enable_result_log
+-- enable_query_log
+
+# BUG#1:
+--replace_result a a_or_b b a_or_b
+explain select count(a) from t2 where a='AAAAAAAA' and b='AAAAAAAA';
+select count(a) from t2 where a='AAAAAAAA' and b='AAAAAAAA';
+select count(a) from t2 ignore index(a,b) where a='AAAAAAAA' and b='AAAAAAAA';
+
+insert into t2 values ('ab', 'ab', 'uh', 'oh');
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t2;
+-- enable_result_log
+-- enable_query_log
+explain select a from t2 where a='ab';
+drop table t2;
+
+#
+# BUG#25048 - ERROR 126 : Incorrect key file for table '.XXXX.MYI'; try to
+# repair it
+#
+CREATE TABLE t1(c1 INT, c2 INT DEFAULT 0, c3 CHAR(255) DEFAULT '',
+KEY(c1), KEY(c2), KEY(c3));
+INSERT INTO t1(c1) VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),
+(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0);
+INSERT INTO t1 VALUES(0,0,0);
+CREATE TABLE t2(c1 int);
+INSERT INTO t2 VALUES(1);
+DELETE t1 FROM t1,t2 WHERE t1.c1=0 AND t1.c2=0;
+SELECT * FROM t1;
+DROP TABLE t1,t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/index_merge_ror_cpk.inc b/storage/rocksdb/mysql-test/rocksdb/include/index_merge_ror_cpk.inc
new file mode 100644
index 00000000..f0d18a50
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/index_merge_ror_cpk.inc
@@ -0,0 +1,178 @@
+# include/index_merge_ror_cpk.inc
+#
+# Clustered PK ROR-index_merge tests
+#
+# The variable
+# $engine_type -- storage engine to be tested
+# has to be set before sourcing this script.
+#
+# Note: The comments/expectations refer to InnoDB.
+# They might be not valid for other storage engines.
+#
+# Last update:
+# 2006-08-02 ML test refactored
+# old name was t/index_merge_ror_cpk.test
+# main code went into include/index_merge_ror_cpk.inc
+#
+
+--echo #---------------- Clustered PK ROR-index_merge tests -----------------------------
+
+eval SET SESSION DEFAULT_STORAGE_ENGINE = $engine_type;
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1
+(
+ pk1 int not null,
+ pk2 int not null,
+
+ key1 int not null,
+ key2 int not null,
+
+ pktail1ok int not null,
+ pktail2ok int not null,
+ pktail3bad int not null,
+ pktail4bad int not null,
+ pktail5bad int not null,
+
+ pk2copy int not null,
+ badkey int not null,
+
+ filler1 char (200),
+ filler2 char (200),
+ key (key1),
+ key (key2),
+
+ /* keys with tails from CPK members */
+ key (pktail1ok, pk1),
+ key (pktail2ok, pk1, pk2),
+ key (pktail3bad, pk2, pk1),
+ key (pktail4bad, pk1, pk2copy),
+ key (pktail5bad, pk1, pk2, pk2copy),
+
+ primary key (pk1, pk2)
+);
+
+--disable_query_log
+set autocommit=0;
+let $1=10000;
+while ($1)
+{
+ eval insert into t1 values ($1 div 10,$1 mod 100, $1/100,$1/100, $1/100,$1/100,$1/100,$1/100,$1/100, $1 mod 100, $1/1000,'filler-data-$1','filler2');
+ dec $1;
+}
+set autocommit=1;
+--enable_query_log
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+# Verify that range scan on CPK is ROR
+# (use index_intersection because it is impossible to check that for index union)
+# Column 9, rows, can change depending on innodb-page-size.
+--replace_column 9 ROWS
+explain select * from t1 where pk1 = 1 and pk2 < 80 and key1=0;
+# CPK scan + 1 ROR range scan is a special case
+--sorted_result
+select * from t1 where pk1 = 1 and pk2 < 80 and key1=0;
+
+# Verify that CPK fields are considered to be covered by index scans
+explain select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1;
+select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1;
+
+# Verify that CPK is always used for index intersection scans
+# (this is because it is used as a filter, not for retrieval)
+# The expected number of rows can vary depending on page size
+--replace_column 9 ROWS
+explain select * from t1 where badkey=1 and key1=10;
+# The expected number of rows can vary depending on page size
+--replace_column 9 ROWS
+explain select * from t1 where pk1 < 7500 and key1 = 10;
+
+# Verify that keys with 'tails' of PK members are ok.
+explain select * from t1 where pktail1ok=1 and key1=10;
+explain select * from t1 where pktail2ok=1 and key1=10;
+
+# Note: The following is actually a deficiency, it uses sort_union currently.
+# This comment refers to InnoDB and is probably not valid for other engines.
+# The expected number of rows can vary depending on page size
+--replace_column 9 ROWS
+explain select * from t1 where (pktail2ok=1 and pk1< 50000) or key1=10;
+
+# The expected column used for KEY vary depending on page size
+# The expected number of rows can vary depending on page size and platform
+--replace_column 6 EITHER_KEY 9 ROWS
+explain select * from t1 where pktail3bad=1 and key1=10;
+# The expected column used for KEY vary depending on page size
+--replace_column 9 ROWS
+explain select * from t1 where pktail4bad=1 and key1=10;
+# The expected column used for KEY vary depending on page size
+--replace_column 9 ROWS
+explain select * from t1 where pktail5bad=1 and key1=10;
+
+# Test for problem with innodb key values prefetch buffer:
+explain select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
+select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
+
+drop table t1;
+# Testcase for BUG#4984
+create table t1
+(
+ RUNID varchar(22),
+ SUBMITNR varchar(5),
+ ORDERNR char(1),
+ PROGRAMM varchar(8),
+ TESTID varchar(4),
+ UCCHECK char(1),
+ ETEXT varchar(80),
+ ETEXT_TYPE char(1),
+ INFO char(1),
+ SEVERITY tinyint(3),
+ TADIRFLAG char(1),
+ PRIMARY KEY (RUNID,SUBMITNR,ORDERNR,PROGRAMM,TESTID,UCCHECK),
+ KEY `TVERM~KEY` (PROGRAMM,TESTID,UCCHECK)
+) DEFAULT CHARSET=latin1;
+
+update t1 set `ETEXT` = '', `ETEXT_TYPE`='', `INFO`='', `SEVERITY`='', `TADIRFLAG`=''
+WHERE
+ `RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND
+ `TESTID`='' AND `UCCHECK`='';
+
+drop table t1;
+
+--echo #
+--echo # Bug#50402 Optimizer producing wrong results when using Index Merge on InnoDB
+--echo #
+CREATE TABLE t1 (f1 INT, PRIMARY KEY (f1));
+INSERT INTO t1 VALUES (2);
+CREATE TABLE t2 (f1 INT, f2 INT, f3 char(1),
+ PRIMARY KEY (f1), KEY (f2), KEY (f3) );
+INSERT INTO t2 VALUES (1, 1, 'h'), (2, 3, 'h'), (3, 2, ''), (4, 2, '');
+
+SELECT t1.f1 FROM t1
+WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
+
+-- disable_query_log
+-- disable_result_log
+if ($engine_type == RocksDB)
+{
+ set global rocksdb_force_flush_memtable_now=1;
+}
+analyze table t1;
+analyze table t2;
+-- enable_result_log
+-- enable_query_log
+
+EXPLAIN SELECT t1.f1 FROM t1
+WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
+
+DROP TABLE t1,t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case1_1.inc b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case1_1.inc
new file mode 100644
index 00000000..6dc5a78e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case1_1.inc
@@ -0,0 +1,51 @@
+#
+# Check concurrent locking issues:
+# Locking rows that do not exist when using all primary key columns in a
+# WHERE clause
+#
+# To call this, set $isolation_level and call this file
+#
+# let $isolation_level = REPEATABLE READ;
+# --source suite/rocksdb/include/locking_issues_case1_1.inc
+#
+
+--echo
+--echo -----------------------------------------------------------------------
+--echo - Locking issues case 1.1:
+--echo - Locking rows that do not exist when using all primary key columns in
+--echo - a WHERE clause
+--echo - using $isolation_level transaction isolation level
+--echo -----------------------------------------------------------------------
+
+--disable_warnings
+DROP TABLE IF EXISTS t0;
+--enable_warnings
+
+CREATE TABLE t0(id1 INT, id2 INT, value INT, PRIMARY KEY(id1, id2));
+INSERT INTO t0 VALUES (1,1,0), (3,3,0), (4,4,0), (6,6,0);
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+BEGIN;
+SELECT * FROM t0 WHERE id1=1 AND id2=5 FOR UPDATE;
+
+connection con2;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+BEGIN;
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t0 VALUES (1,5,0);
+
+--error ER_LOCK_WAIT_TIMEOUT
+SELECT * FROM t0 WHERE id1=1 AND id2=5 FOR UPDATE;
+
+connection con1;
+COMMIT;
+
+connection default;
+disconnect con1;
+disconnect con2;
+
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case1_2.inc b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case1_2.inc
new file mode 100644
index 00000000..13083bf8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case1_2.inc
@@ -0,0 +1,48 @@
+#
+# Check concurrent locking issues:
+# Locking rows that do not exist without using all primary key columns in a
+# WHERE clause
+#
+# To call this, set $isolation_level and call this file
+#
+# let $isolation_level = REPEATABLE READ;
+# --source suite/rocksdb/include/locking_issues_case1_2.inc
+#
+
+--echo
+--echo -----------------------------------------------------------------------
+--echo - Locking issues case 1.2:
+--echo - Locking rows that do not exist without using all primary key
+--echo - columns in a WHERE clause
+--echo - using $isolation_level transaction isolation level
+--echo -----------------------------------------------------------------------
+
+--disable_warnings
+DROP TABLE IF EXISTS t0;
+--enable_warnings
+
+CREATE TABLE t0(id1 INT, id2 INT, value INT, PRIMARY KEY(id1, id2));
+INSERT INTO t0 VALUES (1,1,0), (3,3,0), (4,4,0), (6,6,0);
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+BEGIN;
+SELECT * FROM t0 WHERE id1=1 FOR UPDATE;
+
+connection con2;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+BEGIN;
+SELECT * FROM t0 WHERE id1=1 AND id2=4 FOR UPDATE;
+INSERT INTO t0 VALUES (1,5,0);
+
+connection con1;
+COMMIT;
+
+connection default;
+disconnect con1;
+disconnect con2;
+
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case2.inc b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case2.inc
new file mode 100644
index 00000000..61c604dd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case2.inc
@@ -0,0 +1,97 @@
+#
+# Check concurrent locking issues:
+# Rows that are scanned but do not match the WHERE clause are not locked.
+#
+# To call this, set $isolation_level and call this file
+# If you want to enable rocksdb_lock_scanned_rows set $lock_scanned_rows=1
+#
+# let $isolation_level = REPEATABLE READ;
+# let $lock_scanned_rows = 1 (optional)
+# --source suite/rocksdb/include/locking_issues_case2.inc
+#
+
+--echo
+--echo -----------------------------------------------------------------------
+--echo - Locking issues case 2:
+--echo - Rows that are scanned but do not match the WHERE are not locked
+--echo - using $isolation_level transaction isolation level unless
+--echo - rocksdb_lock_scanned_rows is on
+--echo -----------------------------------------------------------------------
+
+--disable_warnings
+DROP TABLE IF EXISTS t0;
+--enable_warnings
+
+SELECT @@global.rocksdb_lock_scanned_rows;
+
+if ($lock_scanned_rows)
+{
+ let $original_val=query_get_value(
+ select @@global.rocksdb_lock_scanned_rows as val, val, 1);
+ SET GLOBAL rocksdb_lock_scanned_rows=ON;
+}
+
+CREATE TABLE t0(id INT PRIMARY KEY, value INT);
+INSERT INTO t0 VALUES (1,0), (2,1), (3,0), (4,0), (5,1);
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+BEGIN;
+
+connection con2;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+BEGIN;
+
+if ($lock_scanned_rows == 1)
+{
+ connection con1;
+ # This is expected to leave locks on all the rows in t0
+ SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+
+ connection con2;
+ --error ER_LOCK_WAIT_TIMEOUT
+ UPDATE t0 SET VALUE=10 WHERE id=1;
+}
+
+if ($lock_scanned_rows == 0)
+{
+ connection con1;
+ # This is expected to release locks on rows with value=0
+ SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+
+ connection con2;
+ # This should succeed as con1 should have released the lock on row (1,0)
+ UPDATE t0 SET VALUE=10 WHERE id=1;
+
+ # This should fail because lock on row (5,1) is still held.
+ --error ER_LOCK_WAIT_TIMEOUT
+ UPDATE t0 SET VALUE=10 WHERE id=5;
+
+ connection con1;
+ # Do another operation
+ UPDATE t0 SET value=100 WHERE id in (4,5) and value>0;
+
+ connection con2;
+ # Check that row (4,0) is still not locked
+ SELECT * FROM t0 WHERE id=4 FOR UPDATE;
+
+ COMMIT;
+ SELECT * FROM t0;
+}
+
+connection con1;
+COMMIT;
+
+connection default;
+disconnect con1;
+disconnect con2;
+
+DROP TABLE t0;
+
+if ($lock_scanned_rows == 1)
+{
+ eval SET GLOBAL rocksdb_lock_scanned_rows=$original_val;
+}
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case3.inc b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case3.inc
new file mode 100644
index 00000000..34947cb0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case3.inc
@@ -0,0 +1,71 @@
+#
+# Check concurrent locking issues:
+# After creating a snapshot, other clients updating rows
+#
+# To call this, set $isolation_level and call this file
+#
+# let $isolation_level = REPEATABLE READ;
+# --source suite/rocksdb/include/locking_issues_case3.inc
+#
+
+--echo
+--echo -----------------------------------------------------------------------
+--echo - Locking issues case 3:
+--echo - After creating a snapshot, other clients updating rows
+--echo - using $isolation_level transaction isolation level
+--echo -----------------------------------------------------------------------
+
+--disable_warnings
+DROP TABLE IF EXISTS t0;
+--enable_warnings
+
+CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT);
+
+# Insert 200,000 rows, breaking it up into inserts of 1000 rows at a time
+--echo Inserting 200,000 rows
+--disable_query_log
+SET @save_rocksdb_bulk_load=@@rocksdb_bulk_load;
+SET rocksdb_bulk_load=1;
+SET @save_rocksdb_write_disable_wal=@@rocksdb_write_disable_wal;
+SET GLOBAL rocksdb_write_disable_wal=1;
+let $i = 1;
+while ($i <= 200) {
+ eval BEGIN;
+ let $j = 1;
+ while ($j <= 100) {
+ eval INSERT INTO t0(value) VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0);
+ inc $j;
+ }
+ eval COMMIT;
+ inc $i;
+}
+SET rocksdb_bulk_load=@save_rocksdb_bulk_load;
+SET GLOBAL rocksdb_write_disable_wal=@save_rocksdb_write_disable_wal;
+--enable_query_log
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+let $ID = `SELECT connection_id()`;
+send SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+
+connection con2;
+let $wait_condition =
+ SELECT 1 FROM information_schema.processlist
+ WHERE (id = $ID/* OR srv_id = $ID*/) AND state = "Sending data";
+--source include/wait_condition.inc
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+UPDATE t0 SET VALUE=VALUE+1 WHERE id=190000;
+
+connection con1;
+--error 0,ER_LOCK_DEADLOCK
+reap;
+--echo ERROR: $mysql_errno
+
+connection default;
+disconnect con1;
+disconnect con2;
+
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case4.inc b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case4.inc
new file mode 100644
index 00000000..8140b81a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case4.inc
@@ -0,0 +1,69 @@
+#
+# Check concurrent locking issues:
+# Phantom rows
+#
+# To call this, set $isolation_level and call this file
+#
+# let $isolation_level = REPEATABLE READ;
+# --source suite/rocksdb/include/locking_issues_case4.inc
+#
+
+--echo
+--echo -----------------------------------------------------------------------
+--echo - Locking issues case 4:
+--echo - Phantom rows
+--echo - using $isolation_level transaction isolation level
+--echo -----------------------------------------------------------------------
+
+--disable_warnings
+DROP TABLE IF EXISTS t0;
+--enable_warnings
+
+CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT);
+
+# Insert 200,000 rows, breaking it up into inserts of 1000 rows at a time
+--echo Inserting 200,000 rows
+--disable_query_log
+SET @save_rocksdb_bulk_load=@@rocksdb_bulk_load;
+SET rocksdb_bulk_load=1;
+SET @save_rocksdb_write_disable_wal=@@rocksdb_write_disable_wal;
+SET GLOBAL rocksdb_write_disable_wal=1;
+let $i = 1;
+while ($i <= 200) {
+ eval BEGIN;
+ let $j = 1;
+ while ($j <= 100) {
+ eval INSERT INTO t0(value) VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0);
+ inc $j;
+ }
+ eval COMMIT;
+ inc $i;
+}
+SET rocksdb_bulk_load=@save_rocksdb_bulk_load;
+SET GLOBAL rocksdb_write_disable_wal=@save_rocksdb_write_disable_wal;
+--enable_query_log
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+let $ID = `SELECT connection_id()`;
+send SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+
+connection con2;
+let $wait_condition =
+ SELECT 1 FROM information_schema.processlist
+ WHERE (id = $ID/* OR srv_id = $ID*/) AND state = "Sending data";
+--source include/wait_condition.inc
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+INSERT INTO t0 VALUES(200001,1), (-1,1);
+
+connection con1;
+reap;
+
+connection default;
+disconnect con1;
+disconnect con2;
+
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case5.inc b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case5.inc
new file mode 100644
index 00000000..e28f1c90
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case5.inc
@@ -0,0 +1,77 @@
+#
+# Check concurrent locking issues:
+# Deleting primary key
+#
+# To call this, set $isolation_level and call this file
+#
+# let $isolation_level = REPEATABLE READ;
+# --source suite/rocksdb/include/locking_issues_case5.inc
+#
+
+--echo
+--echo -----------------------------------------------------------------------
+--echo - Locking issues case 5:
+--echo - Deleting primary key
+--echo - using $isolation_level transaction isolation level
+--echo -----------------------------------------------------------------------
+
+--disable_warnings
+DROP TABLE IF EXISTS t0;
+--enable_warnings
+
+CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT);
+
+# Insert 200,000 rows, breaking it up into inserts of 1000 rows at a time
+--echo Inserting 200,000 rows
+--disable_query_log
+SET @save_rocksdb_bulk_load=@@rocksdb_bulk_load;
+SET rocksdb_bulk_load=1;
+SET @save_rocksdb_write_disable_wal=@@rocksdb_write_disable_wal;
+SET GLOBAL rocksdb_write_disable_wal=1;
+let $i = 1;
+while ($i <= 200) {
+ eval BEGIN;
+ let $j = 1;
+ while ($j <= 100) {
+ eval INSERT INTO t0(value) VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0);
+ inc $j;
+ }
+ eval COMMIT;
+ inc $i;
+}
+SET rocksdb_bulk_load=@save_rocksdb_bulk_load;
+SET GLOBAL rocksdb_write_disable_wal=@save_rocksdb_write_disable_wal;
+--enable_query_log
+
+UPDATE t0 SET value=100 WHERE id=190000;
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+BEGIN;
+let $ID = `SELECT connection_id()`;
+send SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+
+connection con2;
+let $wait_condition =
+ SELECT 1 FROM information_schema.processlist
+ WHERE (id = $ID /* OR srv_id = $ID*/) AND state = "Sending data";
+--source include/wait_condition.inc
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+BEGIN;
+DELETE FROM t0 WHERE id=190000;
+COMMIT;
+
+connection con1;
+--error 0,ER_LOCK_DEADLOCK
+reap;
+--echo ERROR: $mysql_errno
+COMMIT;
+
+connection default;
+disconnect con1;
+disconnect con2;
+
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case6.inc b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case6.inc
new file mode 100644
index 00000000..13ceca07
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case6.inc
@@ -0,0 +1,77 @@
+#
+# Check concurrent locking issues:
+# Changing primary key
+#
+# To call this, set $isolation_level and call this file
+#
+# let $isolation_level = REPEATABLE READ;
+# --source suite/rocksdb/include/locking_issues_case6.inc
+#
+
+--echo
+--echo -----------------------------------------------------------------------
+--echo - Locking issues case 6:
+--echo - Changing primary key
+--echo - using $isolation_level transaction isolation level
+--echo -----------------------------------------------------------------------
+
+--disable_warnings
+DROP TABLE IF EXISTS t0;
+--enable_warnings
+
+CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT);
+
+# Insert 200,000 rows, breaking it up into inserts of 1000 rows at a time
+--echo Inserting 200,000 rows
+--disable_query_log
+SET @save_rocksdb_bulk_load=@@rocksdb_bulk_load;
+SET rocksdb_bulk_load=1;
+SET @save_rocksdb_write_disable_wal=@@rocksdb_write_disable_wal;
+SET GLOBAL rocksdb_write_disable_wal=1;
+let $i = 1;
+while ($i <= 200) {
+ eval BEGIN;
+ let $j = 1;
+ while ($j <= 100) {
+ eval INSERT INTO t0(value) VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0);
+ inc $j;
+ }
+ eval COMMIT;
+ inc $i;
+}
+SET rocksdb_bulk_load=@save_rocksdb_bulk_load;
+SET GLOBAL rocksdb_write_disable_wal=@save_rocksdb_write_disable_wal;
+--enable_query_log
+
+UPDATE t0 SET value=100 WHERE id=190000;
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+BEGIN;
+let $ID = `SELECT connection_id()`;
+send SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+
+connection con2;
+let $wait_condition =
+ SELECT 1 FROM information_schema.processlist
+ WHERE (id = $ID/* OR srv_id = $ID*/) AND state = "Sending data";
+--source include/wait_condition.inc
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+BEGIN;
+UPDATE t0 SET id=200001 WHERE id=190000;
+COMMIT;
+
+connection con1;
+--error 0,ER_LOCK_DEADLOCK
+reap;
+--echo ERROR: $mysql_errno
+COMMIT;
+
+connection default;
+disconnect con1;
+disconnect con2;
+
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case7.inc b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case7.inc
new file mode 100644
index 00000000..d71d3989
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/locking_issues_case7.inc
@@ -0,0 +1,89 @@
+#
+# Check concurrent locking issues:
+# Rows scanned but are not in the updated table should be locked when
+# rocksdb_lock_scanned_rows is on but not locked otherwise.
+#
+# To call this, set $isolation_level and $lock_scanned_rows and call this file
+#
+# let $isolation_level = REPEATABLE READ;
+# let $lock_scanned_rows = 0 (or 1)
+# --source suite/rocksdb/include/locking_issues_case7.inc
+#
+
+--echo
+--echo -----------------------------------------------------------------------
+--echo - Locking issues case 7:
+--echo - Rows that are scanned as part of a query but not in the table being
+--echo - updated should not be locked unless rocksdb_lock_scanned_rows is on
+--echo -----------------------------------------------------------------------
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+SELECT @@global.rocksdb_lock_scanned_rows;
+
+if ($lock_scanned_rows)
+{
+ let $original_val=query_get_value(
+ select @@global.rocksdb_lock_scanned_rows as val, val, 1);
+ SET GLOBAL rocksdb_lock_scanned_rows=ON;
+}
+
+CREATE TABLE t1(id INT PRIMARY KEY, value INT);
+CREATE TABLE t2(id INT PRIMARY KEY, value INT);
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
+INSERT INTO t2 VALUES (1,1), (2,2), (3,3), (4,4), (5,5);
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+BEGIN;
+
+connection con2;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+BEGIN;
+
+--echo lock_scanned_rows is $lock_scanned_rows
+if ($lock_scanned_rows == 1)
+{
+ connection con1;
+ # This is expected to leave a lock id=3 in t2;
+ UPDATE t1 JOIN t2 ON t1.id = t2.id SET t1.value=t1.value+100 WHERE t2.id=3;
+
+ connection con2;
+ --error ER_LOCK_WAIT_TIMEOUT
+ UPDATE t2 SET value=value+100 WHERE id=3;
+
+ # No other row in t2 should be locked;
+ UPDATE t2 SET value=value+100 WHERE id IN (1,2,4,5);
+ SELECT * FROM t2;
+}
+
+if ($lock_scanned_rows == 0)
+{
+ connection con1;
+ # This should leave no locks on any row in t2;
+ UPDATE t1 JOIN t2 ON t1.id = t2.id SET t1.value=t1.value+100 WHERE t2.id=3;
+
+ connection con2;
+ UPDATE t2 SET value=value+100;
+ SELECT * FROM t2;
+}
+
+connection con1;
+COMMIT;
+
+connection default;
+disconnect con1;
+disconnect con2;
+
+DROP TABLE t1;
+DROP TABLE t2;
+
+if ($lock_scanned_rows == 1)
+{
+ eval SET GLOBAL rocksdb_lock_scanned_rows=$original_val;
+}
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/prefix_index_only_query_check.inc b/storage/rocksdb/mysql-test/rocksdb/include/prefix_index_only_query_check.inc
new file mode 100644
index 00000000..e96eb573
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/prefix_index_only_query_check.inc
@@ -0,0 +1,21 @@
+#
+# A helper include file for prefix index index-only query tests
+#
+# Parameters:
+# $prefix_index_check_title - title of the test
+# $prefix_index_check_query - test query
+# $prefix_index_check_read_avoided_delta - expected change of
+# 'rocksdb_covered_secondary_key_lookups' status variable
+# value after running the query
+
+--let $show_count_statement = show status like 'rocksdb_covered_secondary_key_lookups'
+
+--echo # $prefix_index_check_title
+--let $base_count = query_get_value($show_count_statement, Value, 1)
+
+--eval $prefix_index_check_query
+
+--let $count = query_get_value($show_count_statement, Value, 1)
+--let $assert_text= $prefix_index_check_title: $prefix_index_check_read_avoided_delta rocksdb_covered_secondary_key_lookups
+--let $assert_cond= $count - $base_count = $prefix_index_check_read_avoided_delta
+--source include/assert.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_invalid_option.inc b/storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_invalid_option.inc
new file mode 100644
index 00000000..8eef7ed2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_invalid_option.inc
@@ -0,0 +1,8 @@
+--source include/shutdown_mysqld.inc
+
+# Expect the server to fail to come up with these options
+--error 1
+--exec $MYSQLD_CMD --plugin_load=$HA_ROCKSDB_SO $_mysqld_option
+
+# Restart the server with the default options
+--source include/start_mysqld.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_option.inc b/storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_option.inc
new file mode 100644
index 00000000..81cd2200
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_option.inc
@@ -0,0 +1,31 @@
+
+if ($rpl_inited)
+{
+ if (!$allow_rpl_inited)
+ {
+ --die ERROR IN TEST: This script does not support replication
+ }
+}
+
+# Write file to make mysql-test-run.pl expect the "crash", but don't start
+# it until it's told to
+--let $_server_id= `SELECT @@server_id`
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
+--exec echo "wait" > $_expect_file_name
+
+# Send shutdown to the connected server and give
+# it 10 seconds to die before zapping it
+shutdown_server;
+
+# Write file to make mysql-test-run.pl start up the server again
+--exec echo "restart:$_mysqld_option" > $_expect_file_name
+
+# Turn on reconnect
+--enable_reconnect
+
+# Call script that will poll the server waiting for it to be back online again
+--source include/wait_until_connected_again.inc
+
+# Turn off reconnect again
+--disable_reconnect
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/rocksdb_icp.inc b/storage/rocksdb/mysql-test/rocksdb/include/rocksdb_icp.inc
new file mode 100644
index 00000000..c76b52d4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/rocksdb_icp.inc
@@ -0,0 +1,199 @@
+#
+# Testing Index Condition Pushdown for MyRocks
+# Test file parameter: $cf_name specifies the CF to store test data in
+# It can be forward or reverse-ordered CF
+#
+select * from information_schema.engines where engine = 'rocksdb';
+
+--disable_warnings
+drop table if exists t0,t1,t2,t3;
+--enable_warnings
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t1(a int) engine=myisam;
+insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
+
+eval
+create table t2 (
+ pk int primary key,
+ kp1 int,
+ kp2 int,
+ col1 int,
+ key (kp1,kp2) comment '$cf_name'
+) engine=rocksdb;
+
+insert into t2 select a,a,a,a from t1;
+
+--echo # Try a basic case:
+--replace_column 9 #
+explain
+select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0;
+select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0;
+
+--echo # Check that ICP doesnt work for columns where column value
+--echo # cant be restored from mem-comparable form:
+
+eval
+create table t3 (
+ pk int primary key,
+ kp1 int,
+ kp2 varchar(10) collate utf8_general_ci,
+ col1 int,
+ key (kp1,kp2) comment '$cf_name'
+) engine=rocksdb;
+
+insert into t3 select a,a/10,a,a from t1;
+--echo # This must not use ICP:
+--replace_column 9 #
+explain
+select * from t3 where kp1=3 and kp2 like '%foo%';
+
+--replace_column 9 #
+explain format=json
+select * from t3 where kp1 between 2 and 4 and mod(kp1,3)=0 and kp2 like '%foo%';
+
+--echo # Check that we handle the case where out-of-range is encountered sooner
+--echo # than matched index condition
+--replace_column 9 #
+explain
+select * from t2 where kp1< 3 and kp2+1>50000;
+select * from t2 where kp1< 3 and kp2+1>50000;
+
+--replace_column 9 #
+explain
+select * from t2 where kp1< 3 and kp2+1>50000;
+select * from t2 where kp1< 3 and kp2+1>50000;
+
+--echo # Try doing backwards scans
+--echo # MariaDB: ICP is not supported for reverse scans.
+
+--replace_column 9 #
+explain
+select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc;
+select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc;
+
+--replace_column 9 #
+explain
+select * from t2 where kp1 >990 and mod(kp2,2)=0 order by kp1 desc;
+select * from t2 where kp1 >990 and mod(kp2,2)=0 order by kp1 desc;
+
+--replace_column 9 #
+explain
+select * from t2 where kp1< 3 and kp2+1>50000 order by kp1 desc;
+select * from t2 where kp1< 3 and kp2+1>50000 order by kp1 desc;
+
+drop table t0,t1,t2,t3;
+
+--echo #
+--echo # Check how ICP affects counters
+--echo #
+--echo # First, some preparations
+--echo #
+--echo # in facebook/mysql-5.6, it was:
+--echo # select ROWS_READ, ROWS_REQUESTED, ROWS_INDEX_FIRST, ROWS_INDEX_NEXT
+--echo #
+--echo # In MariaDB, we do:
+delimiter |;
+create procedure save_read_stats()
+begin
+ set @rr=(select ROWS_READ
+ from information_schema.table_statistics
+ where table_name='t4' and table_schema=database());
+
+ set @rif= (select VARIABLE_VALUE
+ from information_schema.session_status
+ where VARIABLE_NAME='Handler_read_first');
+
+ set @rin=(select VARIABLE_VALUE
+ from information_schema.session_status
+ where VARIABLE_NAME='Handler_read_next');
+
+ set @icp_attempts=(select VARIABLE_VALUE
+ from information_schema.session_status
+ where VARIABLE_NAME='Handler_icp_attempts');
+
+ set @icp_matches=(select VARIABLE_VALUE
+ from information_schema.session_status
+ where VARIABLE_NAME='Handler_icp_match');
+end|
+
+create procedure get_read_stats()
+begin
+ select
+ (select ROWS_READ
+ from information_schema.table_statistics
+ where table_name='t4' and table_schema=database()
+ ) - @rr as ROWS_READ_DIFF,
+
+ (select VARIABLE_VALUE - @rif
+ from information_schema.session_status
+ where VARIABLE_NAME='Handler_read_first') as ROWS_INDEX_FIRST,
+
+ (select VARIABLE_VALUE - @rin
+ from information_schema.session_status
+ where VARIABLE_NAME='Handler_read_next') as ROWS_INDEX_NEXT,
+
+ (select VARIABLE_VALUE - @icp_attempts
+ from information_schema.session_status
+ where VARIABLE_NAME='Handler_icp_attempts') as ICP_ATTEMPTS,
+
+ (select VARIABLE_VALUE - @icp_matches
+ from information_schema.session_status
+ where VARIABLE_NAME='Handler_icp_match') as ICP_MATCHES;
+end|
+
+delimiter ;|
+
+eval
+create table t4 (
+ id int,
+ id1 int,
+ id2 int,
+ value int,
+ value2 varchar(100),
+ primary key (id),
+ key id1_id2 (id1, id2) comment '$cf_name'
+) engine=rocksdb charset=latin1 collate latin1_bin;
+
+insert into t4 values
+(1,1,1,1,1), (2,1,2,2,2), (3,1,3,3,3),(4,1,4,4,4),(5,1,5,5,5),
+(6,1,6,6,6), (7,1,7,7,7), (8,1,8,8,8),(9,1,9,9,9),(10,1,10,10,10);
+
+--echo #
+--echo # Now, the test itself
+--echo #
+call save_read_stats();
+call get_read_stats();
+
+
+--echo # ============== index-only query ==============
+--replace_column 9 #
+explain
+select id1,id2 from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+call save_read_stats();
+select id1,id2 from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+query_vertical call get_read_stats();
+
+--echo # ============== Query without ICP ==============
+set optimizer_switch='index_condition_pushdown=off';
+--replace_column 9 #
+explain
+select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+call save_read_stats();
+select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+query_vertical call get_read_stats();
+
+--echo # ============== Query with ICP ==============
+set optimizer_switch='index_condition_pushdown=on';
+--replace_column 9 #
+explain
+select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+call save_read_stats();
+select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+query_vertical call get_read_stats();
+
+drop table t4;
+drop procedure save_read_stats;
+drop procedure get_read_stats;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/simple_deadlock.inc b/storage/rocksdb/mysql-test/rocksdb/include/simple_deadlock.inc
new file mode 100644
index 00000000..0afdfea7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/simple_deadlock.inc
@@ -0,0 +1,29 @@
+connection con1;
+begin;
+select * from t where i=1 for update;
+
+connection con2;
+begin;
+select * from t where i=2 for update;
+
+connection con1;
+--send select * from t where i=2 for update
+
+connection con2;
+if ($engine == "rocksdb"){
+ let $wait_condition = select count(*) = 1 from information_schema.rocksdb_trx
+ where thread_id = $con1 and waiting_key != "";
+}
+if ($engine == "innodb"){
+ let $wait_condition = select count(*) = 1 from information_schema.innodb_trx
+ where trx_mysql_thread_id = $con1 and trx_state="LOCK WAIT";
+}
+--source include/wait_condition.inc
+
+--error ER_LOCK_DEADLOCK
+select * from t where i=1 for update;
+rollback;
+
+connection con1;
+--reap
+rollback;
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/start_mysqld_with_option.inc b/storage/rocksdb/mysql-test/rocksdb/include/start_mysqld_with_option.inc
new file mode 100644
index 00000000..73e30b3e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/start_mysqld_with_option.inc
@@ -0,0 +1,14 @@
+# Include this script only after using shutdown_mysqld.inc
+# where $_expect_file_name was initialized.
+# Write file to make mysql-test-run.pl start up the server again
+--exec echo "restart:$_mysqld_option" > $_expect_file_name
+
+# Turn on reconnect
+--enable_reconnect
+
+# Call script that will poll the server waiting for it to be back online again
+--source include/wait_until_connected_again.inc
+
+# Turn off reconnect again
+--disable_reconnect
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/use_direct_io_option.inc b/storage/rocksdb/mysql-test/rocksdb/include/use_direct_io_option.inc
new file mode 100644
index 00000000..6e427f26
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/include/use_direct_io_option.inc
@@ -0,0 +1,24 @@
+# Common test pattern for options that control direct i/o
+#
+# Required input:
+# $io_option - name and assignment to enable on server command line
+
+--source include/have_direct_io.inc
+
+--echo Checking direct reads
+--let $restart_noprint=2
+--let $_mysqld_option=$io_option
+--source include/restart_mysqld_with_option.inc
+
+CREATE TABLE t1 (pk INT PRIMARY KEY DEFAULT '0', a INT(11), b CHAR(8)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (1, 1,'a');
+INSERT INTO t1 (a,b) VALUES (2,'b');
+set global rocksdb_force_flush_memtable_now=1;
+--sorted_result
+SELECT a,b FROM t1;
+DROP TABLE t1;
+
+# cleanup
+--let _$mysqld_option=
+--source include/restart_mysqld.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/my.cnf b/storage/rocksdb/mysql-test/rocksdb/my.cnf
new file mode 100644
index 00000000..ab89713c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/my.cnf
@@ -0,0 +1,19 @@
+!include include/default_my.cnf
+
+[server]
+skip-innodb
+default-storage-engine=rocksdb
+
+sql-mode=NO_ENGINE_SUBSTITUTION
+explicit-defaults-for-timestamp=1
+loose-rocksdb_lock_wait_timeout=1
+loose-rocksdb_strict_collation_check=0
+
+# MariaDB: speed up the tests:
+loose-rocksdb-flush-log-at-trx-commit=0
+
+loose-rocksdb_force_compute_memtable_stats_cachetime=0
+
+# The following is to get rid of the harmless
+# "Deadlock found when trying to get lock" errors, see MDEV-12285.
+log-warnings=1
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/1st.result b/storage/rocksdb/mysql-test/rocksdb/r/1st.result
new file mode 100644
index 00000000..323b614e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/1st.result
@@ -0,0 +1,22 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (pk INT PRIMARY KEY DEFAULT '0', a INT(11), b CHAR(8)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL DEFAULT 0,
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI 0
+a int(11) YES NULL
+b char(8) YES NULL
+INSERT INTO t1 VALUES (1, 1,'a');
+INSERT INTO t1 (a,b) VALUES (2,'b');
+SELECT a,b FROM t1;
+a b
+1 a
+2 b
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/2pc_group_commit.result b/storage/rocksdb/mysql-test/rocksdb/r/2pc_group_commit.result
new file mode 100644
index 00000000..a6bb9eb6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/2pc_group_commit.result
@@ -0,0 +1,101 @@
+# Disable for valgrind because this takes too long
+DROP DATABASE IF EXISTS mysqlslap;
+CREATE DATABASE mysqlslap;
+USE mysqlslap;
+CREATE TABLE t1(id BIGINT AUTO_INCREMENT, value BIGINT, PRIMARY KEY(id)) ENGINE=rocksdb;
+SET @save_rocksdb_enable_2pc= @@rocksdb_enable_2pc;
+SET @save_rocksdb_flush_log_at_trx_commit= @@rocksdb_flush_log_at_trx_commit;
+# 2PC enabled, MyRocks durability enabled
+SET GLOBAL rocksdb_enable_2pc=1;
+SET GLOBAL rocksdb_flush_log_at_trx_commit=1;
+##
+## 2PC + durability + single thread
+##
+select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
+select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
+select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+select IF(variable_value - @b1 = 1000, 'OK', variable_value - @b1) as Binlog_commits
+from information_schema.global_status where variable_name='Binlog_commits';
+Binlog_commits
+OK
+select IF(variable_value - @b2 = 1000, 'OK', variable_value - @b2) as Binlog_group_commits
+from information_schema.global_status where variable_name='Binlog_group_commits';
+Binlog_group_commits
+OK
+# Prepare operations sync, commits don't. We expect slightly more than 1K syncs:
+select IF(variable_value - @b3 between 1000 and 1500, 'OK', variable_value - @b3) as Rocksdb_wal_synced
+from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+Rocksdb_wal_synced
+OK
+set debug_dbug='+d,rocksdb_enable_delay_commits';
+create table dummy10(a int) engine=rocksdb;
+Warnings:
+Warning 1210 enable_delay_commits_mode ON
+drop table dummy10;
+set debug_dbug='-d,rocksdb_enable_delay_commits';
+##
+## 2PC + durability + group commit
+##
+select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
+select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
+select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+select IF(variable_value - @b1 = 10000, 'OK', variable_value - @b1) as Binlog_commits
+from information_schema.global_status where variable_name='Binlog_commits';
+Binlog_commits
+OK
+select IF(variable_value - @b2 between 100 and 5000, 'OK', variable_value - @b2) as Binlog_group_commits
+from information_schema.global_status where variable_name='Binlog_group_commits';
+Binlog_group_commits
+OK
+select IF(variable_value - @b3 between 1 and 9000, 'OK', variable_value - @b3)
+from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+IF(variable_value - @b3 between 1 and 9000, 'OK', variable_value - @b3)
+OK
+set debug_dbug='+d,rocksdb_disable_delay_commits';
+create table dummy10(a int) engine=rocksdb;
+Warnings:
+Warning 1210 enable_delay_commits_mode OFF
+drop table dummy10;
+set debug_dbug='-d,rocksdb_disable_delay_commits';
+##
+# 2PC enabled, MyRocks durability disabled, single thread
+##
+SET GLOBAL rocksdb_enable_2pc=1;
+SET GLOBAL rocksdb_flush_log_at_trx_commit=0;
+select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
+select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
+select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+select IF(variable_value - @b1 = 1000, 'OK', variable_value - @b1) as Binlog_commits
+from information_schema.global_status where variable_name='Binlog_commits';
+Binlog_commits
+OK
+select IF(variable_value - @b2 = 1000, 'OK', variable_value - @b2) as Binlog_group_commits
+from information_schema.global_status where variable_name='Binlog_group_commits';
+Binlog_group_commits
+OK
+select IF(variable_value - @b3 < 10, 'OK', variable_value - @b3)
+from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+IF(variable_value - @b3 < 10, 'OK', variable_value - @b3)
+OK
+##
+# 2PC enabled, MyRocks durability disabled, concurrent workload
+##
+select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
+select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
+select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+select IF(variable_value - @b1 = 10000, 'OK', variable_value - @b1) as Binlog_commits
+from information_schema.global_status where variable_name='Binlog_commits';
+Binlog_commits
+OK
+select IF(variable_value - @b2 < 8000, 'OK', variable_value - @b2) as Binlog_group_commits
+from information_schema.global_status where variable_name='Binlog_group_commits';
+Binlog_group_commits
+OK
+select IF(variable_value - @b3 < 10, 'OK', variable_value - @b3)
+from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+IF(variable_value - @b3 < 10, 'OK', variable_value - @b3)
+OK
+SET GLOBAL rocksdb_enable_2pc= @save_rocksdb_enable_2pc;
+SET GLOBAL rocksdb_flush_log_at_trx_commit= @save_rocksdb_flush_log_at_trx_commit;
+DROP TABLE t1;
+DROP DATABASE mysqlslap;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace.result b/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace.result
new file mode 100644
index 00000000..20f84dd5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace.result
@@ -0,0 +1,505 @@
+drop table if exists t1;
+CREATE TABLE t1 (a INT, b INT, KEY ka(a), KEY kab(a,b)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY `ka` (`a`),
+ KEY `kab` (`a`,`b`),
+ KEY `kb` (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 FORCE INDEX(kb) WHERE b > 5;
+a b
+2 6
+3 7
+SELECT * FROM t1 FORCE INDEX(kab) WHERE a > 2;
+a b
+3 7
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT, KEY ka(a), KEY kab(a,b)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+ALTER TABLE t1 ADD INDEX kb(b), DROP INDEX ka, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY `kab` (`a`,`b`),
+ KEY `kb` (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 FORCE INDEX(kb) WHERE b > 5;
+a b
+2 6
+3 7
+SELECT * FROM t1 FORCE INDEX(kab) WHERE a > 2;
+a b
+3 7
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT, KEY ka(a), KEY kab(a,b)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+ALTER TABLE t1 DROP INDEX ka, DROP INDEX kab, ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD INDEX kb(b), ADD INDEX kab(a,b), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY `kb` (`b`),
+ KEY `kab` (`a`,`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 FORCE INDEX(kb) WHERE b > 5;
+a b
+2 6
+3 7
+SELECT * FROM t1 FORCE INDEX(kab) WHERE a > 2;
+a b
+3 7
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT, KEY ka(a), KEY kab(a,b)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+ALTER TABLE t1 ADD INDEX kb(b), DROP INDEX ka, ADD INDEX kba(b,a), DROP INDEX kab, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY `kb` (`b`),
+ KEY `kba` (`b`,`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 FORCE INDEX(kb) WHERE b > 5;
+a b
+2 6
+3 7
+SELECT * FROM t1 FORCE INDEX(kba) WHERE a > 2;
+a b
+3 7
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT, KEY ka(a), KEY kab(a,b)) ENGINE=RocksDB;
+ALTER TABLE t1 DROP INDEX ka, ADD INDEX ka(b), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY `kab` (`a`,`b`),
+ KEY `ka` (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 FORCE INDEX(ka) WHERE b > 5;
+a b
+SELECT * FROM t1 FORCE INDEX(kab) WHERE a > 2;
+a b
+DROP TABLE t1;
+CREATE TABLE t1 (pk CHAR(8) PRIMARY KEY, a VARCHAR(11), b INT UNSIGNED) ENGINE=rocksdb charset utf8 collate utf8_bin;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` char(8) COLLATE utf8_bin NOT NULL,
+ `a` varchar(11) COLLATE utf8_bin DEFAULT NULL,
+ `b` int(10) unsigned DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk char(8) NO PRI NULL
+a varchar(11) YES NULL
+b int(10) unsigned YES NULL
+INSERT INTO t1 VALUES ('aaa', '1111', 1);
+INSERT INTO t1 VALUES ('bbb', '2222', 2);
+INSERT INTO t1 VALUES ('ccc', '3333', 3);
+ALTER TABLE t1 ADD INDEX kab(a,b), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` char(8) COLLATE utf8_bin NOT NULL,
+ `a` varchar(11) COLLATE utf8_bin DEFAULT NULL,
+ `b` int(10) unsigned DEFAULT NULL,
+ PRIMARY KEY (`pk`),
+ KEY `kab` (`a`,`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 FORCE INDEX(kab) WHERE a > '2' AND b < 3;
+pk a b
+bbb 2222 2
+DROP TABLE t1;
+CREATE TABLE t1 (pk CHAR(8) PRIMARY KEY, a VARCHAR(11), b INT UNSIGNED) ENGINE=rocksdb charset utf8 collate utf8_bin;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` char(8) COLLATE utf8_bin NOT NULL,
+ `a` varchar(11) COLLATE utf8_bin DEFAULT NULL,
+ `b` int(10) unsigned DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk char(8) NO PRI NULL
+a varchar(11) YES NULL
+b int(10) unsigned YES NULL
+INSERT INTO t1 VALUES ('aaa', '1111', 1);
+INSERT INTO t1 VALUES ('bbb', '2222', 2);
+INSERT INTO t1 VALUES ('ccc', '3333', 3);
+ALTER TABLE t1 ADD INDEX kab(a,b), ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD INDEX ka(a), DROP INDEX kab, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` char(8) COLLATE utf8_bin NOT NULL,
+ `a` varchar(11) COLLATE utf8_bin DEFAULT NULL,
+ `b` int(10) unsigned DEFAULT NULL,
+ PRIMARY KEY (`pk`),
+ KEY `ka` (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 FORCE INDEX(ka) WHERE a > '2' AND b < 3;
+pk a b
+bbb 2222 2
+DROP TABLE t1;
+CREATE TABLE t1 (pk CHAR(8) PRIMARY KEY, a VARCHAR(11), b INT UNSIGNED) ENGINE=rocksdb charset utf8 collate utf8_bin;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` char(8) COLLATE utf8_bin NOT NULL,
+ `a` varchar(11) COLLATE utf8_bin DEFAULT NULL,
+ `b` int(10) unsigned DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk char(8) NO PRI NULL
+a varchar(11) YES NULL
+b int(10) unsigned YES NULL
+INSERT INTO t1 VALUES ('aaa', '1111', 1);
+INSERT INTO t1 VALUES ('bbb', '2222', 2);
+INSERT INTO t1 VALUES ('ccc', '3333', 3);
+ALTER TABLE t1 ADD INDEX kab(a,b), ADD INDEX ka(a), ADD INDEX kb(b), ALGORITHM=INPLACE;
+ALTER TABLE t1 DROP INDEX ka, DROP INDEX kb, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` char(8) COLLATE utf8_bin NOT NULL,
+ `a` varchar(11) COLLATE utf8_bin DEFAULT NULL,
+ `b` int(10) unsigned DEFAULT NULL,
+ PRIMARY KEY (`pk`),
+ KEY `kab` (`a`,`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 FORCE INDEX(kab) WHERE a > '2' AND b < 3;
+pk a b
+bbb 2222 2
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT, KEY ka(a), KEY kab(a,b)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+CREATE INDEX kb on t1 (b);
+CREATE INDEX kba on t1 (b,a);
+DROP INDEX ka on t1;
+DROP INDEX kab on t1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY `kb` (`b`),
+ KEY `kba` (`b`,`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 FORCE INDEX(kb) WHERE b > 5;
+a b
+2 6
+3 7
+SELECT * FROM t1 FORCE INDEX(kba) WHERE a > 2;
+a b
+3 7
+DROP TABLE t1;
+CREATE TABLE t1 (i INT, j INT, k INT, PRIMARY KEY (i), KEY(j)) ENGINE = ROCKSDB PARTITION BY KEY(i) PARTITIONS 4;
+ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
+DROP INDEX kij ON t1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) NOT NULL,
+ `j` int(11) DEFAULT NULL,
+ `k` int(11) DEFAULT NULL,
+ PRIMARY KEY (`i`),
+ KEY `j` (`j`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ PARTITION BY KEY (`i`)
+PARTITIONS 4
+SELECT * FROM t1 ORDER BY i LIMIT 10;
+i j k
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+8 8 8
+9 9 9
+10 10 10
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+100
+DROP TABLE t1;
+set @tmp_rocksdb_strict_collation_check= @@rocksdb_strict_collation_check;
+set global rocksdb_strict_collation_check=1;
+CREATE TABLE t1 (a INT, b TEXT);
+# MariaDB no longer gives ER_UNSUPPORTED_COLLATION
+ALTER TABLE t1 ADD KEY kb(b(10));
+ALTER TABLE t1 ADD PRIMARY KEY(a);
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b TEXT collate utf8_general_ci);
+# MariaDB no longer gives ER_UNSUPPORTED_COLLATION
+ALTER TABLE t1 ADD KEY kb(b(10));
+Warnings:
+Warning 1815 Internal error: Indexed column test.t1.b uses a collation that does not allow index-only access in secondary key and has reduced disk space efficiency in primary key.
+ALTER TABLE t1 ADD PRIMARY KEY(a);
+DROP TABLE t1;
+set global rocksdb_strict_collation_check= @tmp_rocksdb_strict_collation_check;
+set global rocksdb_bulk_load=1;
+# Establish connection con1 (user=root)
+connect con1,localhost,root,,;
+# Switch to connection con1
+connection con1;
+show global variables like 'rocksdb_bulk_load%';
+Variable_name Value
+rocksdb_bulk_load ON
+rocksdb_bulk_load_allow_sk OFF
+rocksdb_bulk_load_allow_unsorted OFF
+rocksdb_bulk_load_size 1000
+show session variables like 'rocksdb_bulk_load%';
+Variable_name Value
+rocksdb_bulk_load ON
+rocksdb_bulk_load_allow_sk OFF
+rocksdb_bulk_load_allow_unsorted OFF
+rocksdb_bulk_load_size 1000
+CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i)) ENGINE = ROCKSDB;
+INSERT INTO t1 VALUES (1,1);
+# Disconnecting on con1
+disconnect con1;
+# Establish connection con2 (user=root)
+connect con2,localhost,root,,;
+# Switch to connection con2
+connection con2;
+ALTER TABLE t1 ADD INDEX kj(j), ALGORITHM=INPLACE;
+SELECT COUNT(*) FROM t1 FORCE INDEX(PRIMARY);
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 FORCE INDEX(kj);
+COUNT(*)
+1
+DROP TABLE t1;
+disconnect con2;
+# Establish connection con1 (user=root)
+connect con1,localhost,root,,;
+# Establish connection con2 (user=root)
+connect con2,localhost,root,,;
+# Switch to connection con1
+connection con1;
+CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i)) ENGINE = ROCKSDB;
+set rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES (1,1);
+# Switch to connection con2
+connection con2;
+SELECT COUNT(*) FROM t1 FORCE INDEX(PRIMARY);
+COUNT(*)
+0
+ALTER TABLE t1 ADD INDEX kj(j), ALGORITHM=INPLACE;
+SELECT COUNT(*) FROM t1 FORCE INDEX(PRIMARY);
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 FORCE INDEX(kj);
+COUNT(*)
+1
+set global rocksdb_bulk_load=0;
+DROP TABLE t1;
+connection default;
+SET @prior_rocksdb_merge_combine_read_size= @@rocksdb_merge_combine_read_size;
+SET @prior_rocksdb_strict_collation_check= @@rocksdb_strict_collation_check;
+SET @prior_rocksdb_merge_buf_size = @@rocksdb_merge_buf_size;
+SET global rocksdb_strict_collation_check = off;
+SET session rocksdb_merge_combine_read_size = 566;
+SET session rocksdb_merge_buf_size = 340;
+show variables like 'rocksdb_bulk_load%';
+Variable_name Value
+rocksdb_bulk_load OFF
+rocksdb_bulk_load_allow_sk OFF
+rocksdb_bulk_load_allow_unsorted OFF
+rocksdb_bulk_load_size 1000
+CREATE TABLE t1 (a VARCHAR(80)) ENGINE=RocksDB;
+INSERT INTO t1 (a) VALUES (REPEAT("a", 80));
+INSERT INTO t1 (a) VALUES (REPEAT("a", 80));
+INSERT INTO t1 (a) VALUES (REPEAT("a", 80));
+INSERT INTO t1 (a) VALUES (REPEAT("a", 80));
+ALTER TABLE t1 ADD INDEX ka(a), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(80) DEFAULT NULL,
+ KEY `ka` (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT * FROM t1 FORCE INDEX(ka) WHERE a > "";
+a
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+DROP TABLE t1;
+SET session rocksdb_merge_buf_size = @prior_rocksdb_merge_buf_size;
+SET session rocksdb_merge_combine_read_size = @prior_rocksdb_merge_combine_read_size;
+SET global rocksdb_strict_collation_check = @prior_rocksdb_strict_collation_check;
+CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i)) ENGINE = ROCKSDB;
+set global rocksdb_force_flush_memtable_now=1;
+ALTER TABLE t1 ADD INDEX kj(j), ALGORITHM=INPLACE;
+larger
+1
+# restart
+larger
+1
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+larger
+1
+# restart
+larger
+1
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+select 1300 < 1300 * 1.5 as "same";
+same
+1
+DROP TABLE t1;
+CREATE TABLE t1 (
+a INT PRIMARY KEY,
+b INT,
+c INT,
+KEY kbc(b,c)) ENGINE = ROCKSDB;
+INSERT INTO t1 (a,b,c) VALUES (1,1,1);
+INSERT INTO t1 (a,b,c) VALUES (2,2,2);
+INSERT INTO t1 (a,b,c) VALUES (3,3,3);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ KEY `kbc` (`b`,`c`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 DROP INDEX kbc, ADD INDEX kbc(b,c), ALGORITHM=INPLACE;
+ALTER TABLE t1 DROP INDEX kbc;
+DROP TABLE t1;
+CREATE TABLE t1 (
+a INT PRIMARY KEY,
+b varchar(10),
+index kb(b(5))
+) ENGINE = ROCKSDB charset utf8 collate utf8_bin;
+INSERT INTO t1 (a,b) VALUES (1,'1111122222');
+INSERT INTO t1 (a,b) VALUES (2,'2222233333');
+INSERT INTO t1 (a,b) VALUES (3,'3333344444');
+ALTER TABLE t1 DROP INDEX kb, ADD INDEX kb(b(8)), ALGORITHM=INPLACE;
+SELECT * FROM t1 FORCE INDEX(kb);
+a b
+1 1111122222
+2 2222233333
+3 3333344444
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` varchar(10) COLLATE utf8_bin DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ KEY `kb` (`b`(8))
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
+DROP TABLE t1;
+SET @prior_rocksdb_table_stats_sampling_pct = @@rocksdb_table_stats_sampling_pct;
+set global rocksdb_table_stats_sampling_pct = 100;
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
+Warnings:
+Warning 1280 Name 'ka' ignored for PRIMARY key.
+INSERT INTO t1 (a, b) VALUES (1, 10);
+INSERT INTO t1 (a, b) VALUES (2, 10);
+INSERT INTO t1 (a, b) VALUES (3, 20);
+INSERT INTO t1 (a, b) VALUES (4, 20);
+set global rocksdb_force_flush_memtable_now=1;
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+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 PRIMARY 1 a A 4 NULL NULL LSMTREE
+ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE;
+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 PRIMARY 1 a A 4 NULL NULL LSMTREE
+t1 1 kb 1 b A 2 NULL NULL YES LSMTREE
+DROP TABLE t1;
+SET global rocksdb_table_stats_sampling_pct = @prior_rocksdb_table_stats_sampling_pct;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_cardinality.result b/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_cardinality.result
new file mode 100644
index 00000000..61105fa1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_cardinality.result
@@ -0,0 +1,24 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT PRIMARY KEY, j INT) ENGINE = ROCKSDB;
+INSERT INTO t1 VALUES (1,2), (2,4), (3,6), (4,8), (5,10);
+SET debug_sync= 'rocksdb.commit_in_place_alter_table WAIT_FOR flushed';
+ALTER TABLE t1 ADD INDEX kj(j), ALGORITHM=INPLACE;
+connect con1,localhost,root,,;
+SET GLOBAL rocksdb_force_flush_memtable_now = 1;
+SET debug_sync= 'now SIGNAL flushed';
+connection default;
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP
+WHERE INDEX_NUMBER =
+(SELECT INDEX_NUMBER FROM INFORMATION_SCHEMA.ROCKSDB_DDL
+WHERE TABLE_NAME = 't1' AND INDEX_NAME = "PRIMARY");
+COLUMN_FAMILY INDEX_NUMBER SST_NAME NUM_ROWS DATA_SIZE ENTRY_DELETES ENTRY_SINGLEDELETES ENTRY_MERGES ENTRY_OTHERS DISTINCT_KEYS_PREFIX
+# # SSTNAME 5 # # # # # 5
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP
+WHERE INDEX_NUMBER =
+(SELECT INDEX_NUMBER FROM INFORMATION_SCHEMA.ROCKSDB_DDL
+WHERE TABLE_NAME = 't1' AND INDEX_NAME = "kj");
+COLUMN_FAMILY INDEX_NUMBER SST_NAME NUM_ROWS DATA_SIZE ENTRY_DELETES ENTRY_SINGLEDELETES ENTRY_MERGES ENTRY_OTHERS DISTINCT_KEYS_PREFIX
+# # SSTNAME 5 # # # # # 5,5
+disconnect con1;
+SET debug_sync='RESET';
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_crash.result b/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_crash.result
new file mode 100644
index 00000000..d3801258
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_crash.result
@@ -0,0 +1,93 @@
+drop table if exists t1;
+CREATE TABLE t1 (a INT, b INT, KEY ka(a), KEY kab(a,b)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+# crash_during_online_index_creation
+flush logs;
+SET SESSION debug_dbug="+d,crash_during_online_index_creation";
+ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE;
+ERROR HY000: Lost connection to MySQL server during query
+SET SESSION debug_dbug="-d,crash_during_online_index_creation";
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY `ka` (`a`),
+ KEY `kab` (`a`,`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE t1;
+CREATE TABLE t1 (i INT, j INT, k INT, PRIMARY KEY (i), KEY(j)) ENGINE = ROCKSDB PARTITION BY KEY(i) PARTITIONS 4;
+# crash_during_index_creation_partition
+flush logs;
+SET SESSION debug_dbug="+d,crash_during_index_creation_partition";
+ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
+ERROR HY000: Lost connection to MySQL server during query
+SET SESSION debug_dbug="-d,crash_during_index_creation_partition";
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) NOT NULL,
+ `j` int(11) DEFAULT NULL,
+ `k` int(11) DEFAULT NULL,
+ PRIMARY KEY (`i`),
+ KEY `j` (`j`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ PARTITION BY KEY (`i`)
+PARTITIONS 4
+ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
+SELECT * FROM t1 ORDER BY i LIMIT 10;
+i j k
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+8 8 8
+9 9 9
+10 10 10
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+100
+DROP TABLE t1;
+CREATE TABLE t1 (i INT, j INT, k INT, PRIMARY KEY (i), KEY(j)) ENGINE = ROCKSDB PARTITION BY KEY(i) PARTITIONS 4;
+# crash_during_index_creation_partition
+flush logs;
+SET SESSION debug_dbug="+d,myrocks_simulate_index_create_rollback";
+ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
+ERROR HY000: Intentional failure in inplace alter occurred.
+SET SESSION debug_dbug="-d,myrocks_simulate_index_create_rollback";
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) NOT NULL,
+ `j` int(11) DEFAULT NULL,
+ `k` int(11) DEFAULT NULL,
+ PRIMARY KEY (`i`),
+ KEY `j` (`j`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ PARTITION BY KEY (`i`)
+PARTITIONS 4
+ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) NOT NULL,
+ `j` int(11) DEFAULT NULL,
+ `k` int(11) DEFAULT NULL,
+ PRIMARY KEY (`i`),
+ KEY `j` (`j`),
+ KEY `kij` (`i`,`j`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ PARTITION BY KEY (`i`)
+PARTITIONS 4
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+100
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_sstfilewriter.result b/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_sstfilewriter.result
new file mode 100644
index 00000000..e7883f7e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_sstfilewriter.result
@@ -0,0 +1,79 @@
+drop table if exists t1;
+CREATE TABLE t1(pk CHAR(5) PRIMARY KEY, a char(30), b char(30)) COLLATE 'latin1_bin';
+set rocksdb_bulk_load=1;
+set rocksdb_bulk_load_size=10000;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+set rocksdb_bulk_load=0;
+select count(pk) from t1;
+count(pk)
+300000
+select count(a) from t1;
+count(a)
+300000
+select count(b) from t1;
+count(b)
+300000
+ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE;
+set @tmp= @@rocksdb_max_row_locks;
+set session rocksdb_max_row_locks=1000;
+ALTER TABLE t1 ADD INDEX kb_copy(b), ALGORITHM=COPY;
+ERROR HY000: Got error 10 'Operation aborted: Failed to acquire lock due to rocksdb_max_row_locks limit' from ROCKSDB
+set session rocksdb_bulk_load=1;
+ALTER TABLE t1 ADD INDEX kb_copy(b), ALGORITHM=COPY;
+set session rocksdb_bulk_load=0;
+set session rocksdb_max_row_locks=@tmp;
+SELECT COUNT(*) as c FROM
+(SELECT COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `b`, CONCAT(ISNULL(`b`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `t1` FORCE INDEX(`kb`)
+UNION DISTINCT
+SELECT COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#',
+`b`, CONCAT(ISNULL(`b`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `t1` FORCE
+INDEX(`kb_copy`)) as temp;
+c
+1
+select count(*) from t1 FORCE INDEX(kb);
+count(*)
+300000
+select count(*) from t1 FORCE INDEX(kb_copy);
+count(*)
+300000
+select count(*) from t1 FORCE INDEX(PRIMARY);
+count(*)
+300000
+ALTER TABLE t1 DROP INDEX kb, ALGORITHM=INPLACE;
+ALTER TABLE t1 DROP INDEX kb_copy, ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD INDEX kb(b), ADD INDEX kab(a,b), ALGORITHM=INPLACE;
+SELECT COUNT(*) FROM t1 FORCE INDEX(kab);
+COUNT(*)
+300000
+SELECT COUNT(*) FROM t1 FORCE INDEX(kb);
+COUNT(*)
+300000
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` char(5) COLLATE latin1_bin NOT NULL,
+ `a` char(30) COLLATE latin1_bin DEFAULT NULL,
+ `b` char(30) COLLATE latin1_bin DEFAULT NULL,
+ PRIMARY KEY (`pk`),
+ KEY `kb` (`b`),
+ KEY `kab` (`a`,`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+DROP TABLE t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT, KEY kab(a,b)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+ALTER TABLE t1 DROP INDEX kab, ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD INDEX kb(b) comment 'rev:cf1', ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ KEY `kb` (`b`) COMMENT 'rev:cf1'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SELECT COUNT(*) FROM t1 FORCE INDEX(kb);
+COUNT(*)
+3
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/add_unique_index_inplace.result b/storage/rocksdb/mysql-test/rocksdb/r/add_unique_index_inplace.result
new file mode 100644
index 00000000..e998cfb4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/add_unique_index_inplace.result
@@ -0,0 +1,111 @@
+drop table if exists t1;
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
+Warnings:
+Warning 1280 Name 'ka' ignored for PRIMARY key.
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+INSERT INTO t1 (a,b) VALUES (4,5);
+ALTER TABLE t1 ADD UNIQUE INDEX kb(b), ALGORITHM=INPLACE;
+ERROR 23000: Duplicate entry '5' for key 'kb'
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
+Warnings:
+Warning 1280 Name 'ka' ignored for PRIMARY key.
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+ALTER TABLE t1 ADD UNIQUE INDEX kb(b), ALGORITHM=INPLACE;
+INSERT INTO t1 (a,b) VALUES (4,5);
+ERROR 23000: Duplicate entry '5' for key 'kb'
+INSERT INTO t1 (a,b) VALUES (5,8);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `kb` (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SELECT * FROM t1 FORCE INDEX(kb);
+a b
+1 5
+2 6
+3 7
+5 8
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
+Warnings:
+Warning 1280 Name 'ka' ignored for PRIMARY key.
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, NULL);
+INSERT INTO t1 (a, b) VALUES (3, NULL);
+ALTER TABLE t1 ADD UNIQUE INDEX kb(b), ALGORITHM=INPLACE;
+INSERT INTO t1 (a, b) VALUES (4, NULL);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `kb` (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SELECT COUNT(*) FROM t1 FORCE INDEX(kb);
+COUNT(*)
+4
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT, c INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
+Warnings:
+Warning 1280 Name 'ka' ignored for PRIMARY key.
+INSERT INTO t1 (a,b,c) VALUES (1,1,NULL);
+INSERT INTO t1 (a,b,c) VALUES (2,1,NULL);
+INSERT INTO t1 (a,b,c) VALUES (3,1,NULL);
+INSERT INTO t1 (a,b,c) VALUES (4,1,5);
+ALTER TABLE t1 ADD UNIQUE INDEX kbc(b,c), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `kbc` (`b`,`c`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SELECT COUNT(*) FROM t1 FORCE INDEX(kbc);
+COUNT(*)
+4
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+ALTER TABLE t1 ADD UNIQUE INDEX kb(b);
+INSERT INTO t1 (a, b) VALUES (4, 8);
+INSERT INTO t1 (a, b) VALUES (5, 5);
+ERROR 23000: Duplicate entry '5' for key 'kb'
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ UNIQUE KEY `kb` (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (
+a INT PRIMARY KEY,
+b INT,
+c INT,
+KEY kbc(b,c)) ENGINE = ROCKSDB;
+INSERT INTO t1 (a,b,c) VALUES (1,1,1);
+INSERT INTO t1 (a,b,c) VALUES (2,2,2);
+INSERT INTO t1 (a,b,c) VALUES (3,2,2);
+ALTER TABLE t1 DROP INDEX kbc, ADD UNIQUE INDEX kbc(b,c), ALGORITHM=INPLACE;
+ERROR 23000: Duplicate entry '2-2' for key 'kbc'
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/allow_no_pk_concurrent_insert.result b/storage/rocksdb/mysql-test/rocksdb/r/allow_no_pk_concurrent_insert.result
new file mode 100644
index 00000000..4fef9bce
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/allow_no_pk_concurrent_insert.result
@@ -0,0 +1,7 @@
+drop table if exists t1;
+# Binary must be compiled with debug for this test
+CREATE TABLE t1 (a INT) ENGINE=rocksdb;
+SELECT COUNT(*) from t1;
+COUNT(*)
+400
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/allow_no_primary_key.result b/storage/rocksdb/mysql-test/rocksdb/r/allow_no_primary_key.result
new file mode 100644
index 00000000..96d25b2e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/allow_no_primary_key.result
@@ -0,0 +1,298 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT, b CHAR(8)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) YES NULL
+b char(8) YES NULL
+INSERT INTO t1 (a,b) VALUES (76,'bar');
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (77,'baz');
+SELECT * FROM t1 WHERE a = 35;
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 35 AND b = 'foo';
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 77 OR b = 'bar';
+a b
+76 bar
+77 baz
+SELECT * FROM t1 WHERE a > 35;
+a b
+76 bar
+77 baz
+SELECT * FROM t1;
+a b
+35 foo
+76 bar
+77 baz
+UPDATE t1 SET a=a+100;
+SELECT * FROM t1;
+a b
+135 foo
+176 bar
+177 baz
+UPDATE t1 SET a=a-100, b='bbb' WHERE a>100;
+SELECT * FROM t1;
+a b
+35 bbb
+76 bbb
+77 bbb
+UPDATE t1 SET a=300, b='ccc' WHERE a>70;
+SELECT * FROM t1;
+a b
+300 ccc
+300 ccc
+35 bbb
+UPDATE t1 SET a=123 WHERE a=35;
+SELECT * FROM t1;
+a b
+123 bbb
+300 ccc
+300 ccc
+UPDATE t1 SET a=321 WHERE b='ccc';
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+# restart
+INSERT INTO t1 (a,b) VALUES (45,'bob');
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE a=123;
+SELECT * FROM t1;
+a b
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE b > 'bbb' AND a > 100;
+SELECT * FROM t1;
+a b
+45 bob
+TRUNCATE TABLE t1;
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, c CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (1,'a'),(5,'z');
+ALTER TABLE t1 ADD COLUMN b INT;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `c` char(8) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SELECT * FROM t1;
+a c b
+1 a NULL
+5 z NULL
+ALTER TABLE t1 DROP COLUMN b;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `c` char(8) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SELECT * FROM t1;
+a c
+1 a
+5 z
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+ALTER TABLE t1 DROP COLUMN pk;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) YES NULL
+b char(8) YES NULL
+INSERT INTO t1 (a,b) VALUES (76,'bar');
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (77,'baz');
+SELECT * FROM t1 WHERE a = 35;
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 35 AND b = 'foo';
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 77 OR b = 'bar';
+a b
+76 bar
+77 baz
+SELECT * FROM t1 WHERE a > 35;
+a b
+76 bar
+77 baz
+SELECT * FROM t1;
+a b
+35 foo
+76 bar
+77 baz
+UPDATE t1 SET a=a+100;
+SELECT * FROM t1;
+a b
+135 foo
+176 bar
+177 baz
+UPDATE t1 SET a=a-100, b='bbb' WHERE a>100;
+SELECT * FROM t1;
+a b
+35 bbb
+76 bbb
+77 bbb
+UPDATE t1 SET a=300, b='ccc' WHERE a>70;
+SELECT * FROM t1;
+a b
+300 ccc
+300 ccc
+35 bbb
+UPDATE t1 SET a=123 WHERE a=35;
+SELECT * FROM t1;
+a b
+123 bbb
+300 ccc
+300 ccc
+UPDATE t1 SET a=321 WHERE b='ccc';
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+# restart
+INSERT INTO t1 (a,b) VALUES (45,'bob');
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE a=123;
+SELECT * FROM t1;
+a b
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE b > 'bbb' AND a > 100;
+SELECT * FROM t1;
+a b
+45 bob
+TRUNCATE TABLE t1;
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a INT, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a INT, b CHAR(8)) ENGINE=rocksdb;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a,b) VALUES (3,'c');
+INSERT INTO t2 (a,b) VALUES (4,'d');
+CHECK TABLE t1, t2 FOR UPGRADE;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+test.t2 check status OK
+INSERT INTO t2 (a,b) VALUES (5,'e');
+CHECK TABLE t2 QUICK;
+Table Op Msg_type Msg_text
+test.t2 check status OK
+INSERT INTO t1 (a,b) VALUES (6,'f');
+CHECK TABLE t1 FAST;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a,b) VALUES (7,'g');
+INSERT INTO t2 (a,b) VALUES (8,'h');
+CHECK TABLE t2, t1 MEDIUM;
+Table Op Msg_type Msg_text
+test.t2 check status OK
+test.t1 check status OK
+INSERT INTO t1 (a,b) VALUES (9,'i');
+INSERT INTO t2 (a,b) VALUES (10,'j');
+CHECK TABLE t1, t2 EXTENDED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+test.t2 check status OK
+INSERT INTO t1 (a,b) VALUES (11,'k');
+CHECK TABLE t1 CHANGED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), UNIQUE INDEX(a)) ENGINE=rocksdb;
+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'
+SELECT * FROM t1;
+a b
+1 a
+2 b
+SELECT * FROM t1 WHERE a = 2;
+a b
+2 b
+EXPLAIN SELECT * FROM t1 WHERE a = 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const a a 5 const 1
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) YES NULL
+b char(8) YES NULL
+# restart
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (36,'foo');
+DELETE FROM t1 WHERE a = 35 AND b = 'foo';
+SELECT * FROM t1;
+a b
+36 foo
+DROP TABLE t1;
+#
+# Issue #834/MDEV-15304 ALTER TABLE table_with_hidden_pk causes Can't
+# write; duplicate key in table error and/or crash
+#
+CREATE TABLE t1 (a INT, KEY(a)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1),(1+1);
+create table t2 (a int);
+insert into t2 values (10),(20),(30);
+BEGIN;
+select * from t2;
+a
+10
+20
+30
+connect con1,localhost,root,,;
+connection con1;
+alter table t1 force;
+connection default;
+select * from t1;
+a
+connection con1;
+insert into t1 values (100);
+select * from t1;
+a
+1
+2
+100
+disconnect con1;
+connection default;
+rollback;
+drop table t1,t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/allow_no_primary_key_with_sk.result b/storage/rocksdb/mysql-test/rocksdb/r/allow_no_primary_key_with_sk.result
new file mode 100644
index 00000000..27722b23
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/allow_no_primary_key_with_sk.result
@@ -0,0 +1,806 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT, b CHAR(8), KEY(a)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL,
+ KEY `a` (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) YES MUL NULL
+b char(8) YES NULL
+INSERT INTO t1 (a,b) VALUES (76,'bar');
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (77,'baz');
+SELECT * FROM t1 WHERE a = 35;
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 35 AND b = 'foo';
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 77 OR b = 'bar';
+a b
+76 bar
+77 baz
+SELECT * FROM t1 WHERE a > 35;
+a b
+76 bar
+77 baz
+SELECT * FROM t1;
+a b
+35 foo
+76 bar
+77 baz
+UPDATE t1 SET a=a+100;
+SELECT * FROM t1;
+a b
+135 foo
+176 bar
+177 baz
+UPDATE t1 SET a=a-100, b='bbb' WHERE a>100;
+SELECT * FROM t1;
+a b
+35 bbb
+76 bbb
+77 bbb
+UPDATE t1 SET a=300, b='ccc' WHERE a>70;
+SELECT * FROM t1;
+a b
+300 ccc
+300 ccc
+35 bbb
+UPDATE t1 SET a=123 WHERE a=35;
+SELECT * FROM t1;
+a b
+123 bbb
+300 ccc
+300 ccc
+UPDATE t1 SET a=321 WHERE b='ccc';
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+# restart
+INSERT INTO t1 (a,b) VALUES (45,'bob');
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE a=123;
+SELECT * FROM t1;
+a b
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE b > 'bbb' AND a > 100;
+SELECT * FROM t1;
+a b
+45 bob
+TRUNCATE TABLE t1;
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8)) ENGINE=rocksdb;
+ALTER TABLE t1 ADD INDEX (b);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL,
+ KEY `b` (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) YES NULL
+b char(8) YES MUL NULL
+INSERT INTO t1 (a,b) VALUES (76,'bar');
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (77,'baz');
+SELECT * FROM t1 WHERE a = 35;
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 35 AND b = 'foo';
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 77 OR b = 'bar';
+a b
+76 bar
+77 baz
+SELECT * FROM t1 WHERE a > 35;
+a b
+76 bar
+77 baz
+SELECT * FROM t1;
+a b
+35 foo
+76 bar
+77 baz
+UPDATE t1 SET a=a+100;
+SELECT * FROM t1;
+a b
+135 foo
+176 bar
+177 baz
+UPDATE t1 SET a=a-100, b='bbb' WHERE a>100;
+SELECT * FROM t1;
+a b
+35 bbb
+76 bbb
+77 bbb
+UPDATE t1 SET a=300, b='ccc' WHERE a>70;
+SELECT * FROM t1;
+a b
+300 ccc
+300 ccc
+35 bbb
+UPDATE t1 SET a=123 WHERE a=35;
+SELECT * FROM t1;
+a b
+123 bbb
+300 ccc
+300 ccc
+UPDATE t1 SET a=321 WHERE b='ccc';
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+# restart
+INSERT INTO t1 (a,b) VALUES (45,'bob');
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE a=123;
+SELECT * FROM t1;
+a b
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE b > 'bbb' AND a > 100;
+SELECT * FROM t1;
+a b
+45 bob
+TRUNCATE TABLE t1;
+ALTER TABLE t1 DROP INDEX b;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) YES NULL
+b char(8) YES NULL
+INSERT INTO t1 (a,b) VALUES (76,'bar');
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (77,'baz');
+SELECT * FROM t1 WHERE a = 35;
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 35 AND b = 'foo';
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 77 OR b = 'bar';
+a b
+76 bar
+77 baz
+SELECT * FROM t1 WHERE a > 35;
+a b
+76 bar
+77 baz
+SELECT * FROM t1;
+a b
+35 foo
+76 bar
+77 baz
+UPDATE t1 SET a=a+100;
+SELECT * FROM t1;
+a b
+135 foo
+176 bar
+177 baz
+UPDATE t1 SET a=a-100, b='bbb' WHERE a>100;
+SELECT * FROM t1;
+a b
+35 bbb
+76 bbb
+77 bbb
+UPDATE t1 SET a=300, b='ccc' WHERE a>70;
+SELECT * FROM t1;
+a b
+300 ccc
+300 ccc
+35 bbb
+UPDATE t1 SET a=123 WHERE a=35;
+SELECT * FROM t1;
+a b
+123 bbb
+300 ccc
+300 ccc
+UPDATE t1 SET a=321 WHERE b='ccc';
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+# restart
+INSERT INTO t1 (a,b) VALUES (45,'bob');
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE a=123;
+SELECT * FROM t1;
+a b
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE b > 'bbb' AND a > 100;
+SELECT * FROM t1;
+a b
+45 bob
+TRUNCATE TABLE t1;
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+ALTER TABLE t1 DROP COLUMN pk;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) YES NULL
+b char(8) YES NULL
+INSERT INTO t1 (a,b) VALUES (76,'bar');
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (77,'baz');
+SELECT * FROM t1 WHERE a = 35;
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 35 AND b = 'foo';
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 77 OR b = 'bar';
+a b
+76 bar
+77 baz
+SELECT * FROM t1 WHERE a > 35;
+a b
+76 bar
+77 baz
+SELECT * FROM t1;
+a b
+35 foo
+76 bar
+77 baz
+UPDATE t1 SET a=a+100;
+SELECT * FROM t1;
+a b
+135 foo
+176 bar
+177 baz
+UPDATE t1 SET a=a-100, b='bbb' WHERE a>100;
+SELECT * FROM t1;
+a b
+35 bbb
+76 bbb
+77 bbb
+UPDATE t1 SET a=300, b='ccc' WHERE a>70;
+SELECT * FROM t1;
+a b
+300 ccc
+300 ccc
+35 bbb
+UPDATE t1 SET a=123 WHERE a=35;
+SELECT * FROM t1;
+a b
+123 bbb
+300 ccc
+300 ccc
+UPDATE t1 SET a=321 WHERE b='ccc';
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+# restart
+INSERT INTO t1 (a,b) VALUES (45,'bob');
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE a=123;
+SELECT * FROM t1;
+a b
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE b > 'bbb' AND a > 100;
+SELECT * FROM t1;
+a b
+45 bob
+TRUNCATE TABLE t1;
+DROP TABLE t1;
+#
+# MDEV-4313: RocksDB: Server crashes in Rdb_key_def::setup on dropping the primary key column
+#
+CREATE TABLE t1 (pk INT PRIMARY KEY, i INT NOT NULL, KEY(i)) ENGINE=RocksDB;
+ALTER TABLE t1 DROP COLUMN `pk`;
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8), KEY(a), KEY(b)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL,
+ KEY `a` (`a`),
+ KEY `b` (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) YES MUL NULL
+b char(8) YES MUL NULL
+INSERT INTO t1 (a,b) VALUES (76,'bar');
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (77,'baz');
+SELECT * FROM t1 WHERE a = 35;
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 35 AND b = 'foo';
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 77 OR b = 'bar';
+a b
+76 bar
+77 baz
+SELECT * FROM t1 WHERE a > 35;
+a b
+76 bar
+77 baz
+SELECT * FROM t1;
+a b
+35 foo
+76 bar
+77 baz
+UPDATE t1 SET a=a+100;
+SELECT * FROM t1;
+a b
+135 foo
+176 bar
+177 baz
+UPDATE t1 SET a=a-100, b='bbb' WHERE a>100;
+SELECT * FROM t1;
+a b
+35 bbb
+76 bbb
+77 bbb
+UPDATE t1 SET a=300, b='ccc' WHERE a>70;
+SELECT * FROM t1;
+a b
+300 ccc
+300 ccc
+35 bbb
+UPDATE t1 SET a=123 WHERE a=35;
+SELECT * FROM t1;
+a b
+123 bbb
+300 ccc
+300 ccc
+UPDATE t1 SET a=321 WHERE b='ccc';
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+# restart
+INSERT INTO t1 (a,b) VALUES (45,'bob');
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE a=123;
+SELECT * FROM t1;
+a b
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE b > 'bbb' AND a > 100;
+SELECT * FROM t1;
+a b
+45 bob
+TRUNCATE TABLE t1;
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8), KEY(a, b)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL,
+ KEY `a` (`a`,`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) YES MUL NULL
+b char(8) YES NULL
+INSERT INTO t1 (a,b) VALUES (76,'bar');
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (77,'baz');
+SELECT * FROM t1 WHERE a = 35;
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 35 AND b = 'foo';
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 77 OR b = 'bar';
+a b
+76 bar
+77 baz
+SELECT * FROM t1 WHERE a > 35;
+a b
+76 bar
+77 baz
+SELECT * FROM t1;
+a b
+35 foo
+76 bar
+77 baz
+UPDATE t1 SET a=a+100;
+SELECT * FROM t1;
+a b
+135 foo
+176 bar
+177 baz
+UPDATE t1 SET a=a-100, b='bbb' WHERE a>100;
+SELECT * FROM t1;
+a b
+35 bbb
+76 bbb
+77 bbb
+UPDATE t1 SET a=300, b='ccc' WHERE a>70;
+SELECT * FROM t1;
+a b
+300 ccc
+300 ccc
+35 bbb
+UPDATE t1 SET a=123 WHERE a=35;
+SELECT * FROM t1;
+a b
+123 bbb
+300 ccc
+300 ccc
+UPDATE t1 SET a=321 WHERE b='ccc';
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+# restart
+INSERT INTO t1 (a,b) VALUES (45,'bob');
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE a=123;
+SELECT * FROM t1;
+a b
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE b > 'bbb' AND a > 100;
+SELECT * FROM t1;
+a b
+45 bob
+TRUNCATE TABLE t1;
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8), KEY(a), KEY(b)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL,
+ KEY `a` (`a`),
+ KEY `b` (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) YES MUL NULL
+b char(8) YES MUL NULL
+INSERT INTO t1 (a,b) VALUES (76,'bar');
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (77,'baz');
+SELECT * FROM t1 WHERE a = 35;
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 35 AND b = 'foo';
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 77 OR b = 'bar';
+a b
+76 bar
+77 baz
+SELECT * FROM t1 WHERE a > 35;
+a b
+76 bar
+77 baz
+SELECT * FROM t1;
+a b
+35 foo
+76 bar
+77 baz
+UPDATE t1 SET a=a+100;
+SELECT * FROM t1;
+a b
+135 foo
+176 bar
+177 baz
+UPDATE t1 SET a=a-100, b='bbb' WHERE a>100;
+SELECT * FROM t1;
+a b
+35 bbb
+76 bbb
+77 bbb
+UPDATE t1 SET a=300, b='ccc' WHERE a>70;
+SELECT * FROM t1;
+a b
+300 ccc
+300 ccc
+35 bbb
+UPDATE t1 SET a=123 WHERE a=35;
+SELECT * FROM t1;
+a b
+123 bbb
+300 ccc
+300 ccc
+UPDATE t1 SET a=321 WHERE b='ccc';
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+# restart
+INSERT INTO t1 (a,b) VALUES (45,'bob');
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE a=123;
+SELECT * FROM t1;
+a b
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE b > 'bbb' AND a > 100;
+SELECT * FROM t1;
+a b
+45 bob
+TRUNCATE TABLE t1;
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8), KEY(a)) ENGINE=rocksdb;
+INSERT INTO t1 (a) VALUES (1),(2),(5);
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (6),(8),(12);
+CHECK TABLE t1 FOR UPGRADE;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (13),(15),(16);
+CHECK TABLE t1 QUICK;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (17),(120),(132);
+CHECK TABLE t1 FAST;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (801),(900),(7714);
+CHECK TABLE t1 MEDIUM;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (8760),(10023),(12000);
+CHECK TABLE t1 EXTENDED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (13345),(24456),(78302),(143028);
+CHECK TABLE t1 CHANGED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT, c INT, d INT, KEY kab(a, b), KEY kbc(b, c), KEY kabc(a,b,c)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ `d` int(11) DEFAULT NULL,
+ KEY `kab` (`a`,`b`),
+ KEY `kbc` (`b`,`c`),
+ KEY `kabc` (`a`,`b`,`c`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) YES MUL NULL
+b int(11) YES MUL NULL
+c int(11) YES NULL
+d int(11) YES NULL
+INSERT INTO t1 (a,b,c,d) VALUES (1,2,3,4);
+INSERT INTO t1 (a,b,c,d) VALUES (5,6,7,8);
+INSERT INTO t1 (a,b,c,d) VALUES (10,11,12,13);
+INSERT INTO t1 (a,b,c,d) VALUES (14,15,16,17);
+SELECT * FROM t1;
+a b c d
+1 2 3 4
+10 11 12 13
+14 15 16 17
+5 6 7 8
+SELECT * FROM t1 WHERE a = 1 OR a = 10;
+a b c d
+1 2 3 4
+10 11 12 13
+SELECT * FROM t1 WHERE c = 3 OR d = 17;
+a b c d
+1 2 3 4
+14 15 16 17
+SELECT * FROM t1 WHERE a > 5 OR d > 5;
+a b c d
+10 11 12 13
+14 15 16 17
+5 6 7 8
+SELECT a, b, c FROM t1 FORCE INDEX (kabc) WHERE a=1 OR b=11;
+a b c
+1 2 3
+10 11 12
+SELECT d FROM t1 FORCE INDEX (kbc) WHERE b > 6 AND c > 12;
+d
+17
+UPDATE t1 SET a=a+100;
+UPDATE t1 SET a=a-100, b=99 WHERE a>100;
+SELECT * FROM t1;
+a b c d
+1 99 3 4
+10 99 12 13
+14 99 16 17
+5 99 7 8
+DELETE FROM t1 WHERE a>5;
+DELETE FROM t1 WHERE b=99 AND d>4;
+SELECT * FROM t1;
+a b c d
+1 99 3 4
+TRUNCATE TABLE t1;
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8), KEY ka(a) comment 'rev:cf1', KEY kb(b)
+comment 'rev:cf1', KEY kab(a,b) comment 'rev:cf2') ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL,
+ KEY `ka` (`a`) COMMENT 'rev:cf1',
+ KEY `kb` (`b`) COMMENT 'rev:cf1',
+ KEY `kab` (`a`,`b`) COMMENT 'rev:cf2'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) YES MUL NULL
+b char(8) YES MUL NULL
+INSERT INTO t1 (a,b) VALUES (76,'bar');
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (77,'baz');
+SELECT * FROM t1 WHERE a = 35;
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 35 AND b = 'foo';
+a b
+35 foo
+SELECT * FROM t1 WHERE a = 77 OR b = 'bar';
+a b
+76 bar
+77 baz
+SELECT * FROM t1 WHERE a > 35;
+a b
+76 bar
+77 baz
+SELECT * FROM t1;
+a b
+35 foo
+76 bar
+77 baz
+UPDATE t1 SET a=a+100;
+SELECT * FROM t1;
+a b
+135 foo
+176 bar
+177 baz
+UPDATE t1 SET a=a-100, b='bbb' WHERE a>100;
+SELECT * FROM t1;
+a b
+35 bbb
+76 bbb
+77 bbb
+UPDATE t1 SET a=300, b='ccc' WHERE a>70;
+SELECT * FROM t1;
+a b
+300 ccc
+300 ccc
+35 bbb
+UPDATE t1 SET a=123 WHERE a=35;
+SELECT * FROM t1;
+a b
+123 bbb
+300 ccc
+300 ccc
+UPDATE t1 SET a=321 WHERE b='ccc';
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+# restart
+INSERT INTO t1 (a,b) VALUES (45,'bob');
+SELECT * FROM t1;
+a b
+123 bbb
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE a=123;
+SELECT * FROM t1;
+a b
+321 ccc
+321 ccc
+45 bob
+DELETE FROM t1 WHERE b > 'bbb' AND a > 100;
+SELECT * FROM t1;
+a b
+45 bob
+TRUNCATE TABLE t1;
+DROP TABLE t1;
+CREATE TABLE t1 (col1 int, col2 int, KEY kcol1(col1)) ENGINE=ROCKSDB;
+INSERT INTO t1 (col1, col2) values (2,2);
+ALTER TABLE t1 ADD COLUMN extra INT;
+UPDATE t1 SET col2 = 1;
+select * from t1;
+col1 col2 extra
+2 1 NULL
+DELETE FROM t1 WHERE col1 = 2;
+set global rocksdb_force_flush_memtable_now = true;
+select * from t1;
+col1 col2 extra
+DROP TABLE t1;
+create table t1 (i int auto_increment, key(i)) engine=rocksdb;
+insert into t1 values();
+insert into t1 values();
+insert into t1 values();
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) NOT NULL AUTO_INCREMENT,
+ KEY `i` (`i`)
+) ENGINE=ROCKSDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
+# restart
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) NOT NULL AUTO_INCREMENT,
+ KEY `i` (`i`)
+) ENGINE=ROCKSDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/allow_to_start_after_corruption.result b/storage/rocksdb/mysql-test/rocksdb/r/allow_to_start_after_corruption.result
new file mode 100644
index 00000000..9b5a335b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/allow_to_start_after_corruption.result
@@ -0,0 +1,38 @@
+#
+# Test how MyRocks behaves when RocksDB reports corrupted data.
+#
+#
+# Test server crashes on corrupted data and restarts
+#
+create table t1 (
+pk int not null primary key,
+col1 varchar(10)
+) engine=rocksdb;
+insert into t1 values (1,1),(2,2),(3,3);
+select * from t1 where pk=1;
+pk col1
+1 1
+set session debug_dbug= "+d,rocksdb_return_status_corrupted";
+select * from t1 where pk=1;
+ERROR HY000: Lost connection to MySQL server during query
+FOUND 1 /data corruption detected/ in allow_to_start_after_corruption_debug.err
+#
+# The same for scan queries
+#
+select * from t1;
+pk col1
+1 1
+2 2
+3 3
+set session debug_dbug= "+d,rocksdb_return_status_corrupted";
+select * from t1;
+ERROR HY000: Lost connection to MySQL server during query
+FOUND 1 /data corruption detected/ in allow_to_start_after_corruption_debug.err
+#
+# Test restart failure. The server is shutdown at this point.
+#
+FOUND 1 /The server will exit normally and stop restart attempts/ in allow_to_start_after_corruption_debug.err
+#
+# Remove corruption file and restart cleanly
+#
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/alter_table.result b/storage/rocksdb/mysql-test/rocksdb/r/alter_table.result
new file mode 100644
index 00000000..a4e00626
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/alter_table.result
@@ -0,0 +1,183 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT, c CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (1,1,'a'),(2,5,'z');
+ALTER TABLE t1 ADD COLUMN b INT;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL,
+ `a` int(11) DEFAULT NULL,
+ `c` char(8) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 ALTER COLUMN a SET DEFAULT '0';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL,
+ `a` int(11) DEFAULT 0,
+ `c` char(8) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 ALTER a DROP DEFAULT;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL,
+ `a` int(11),
+ `c` char(8) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 CHANGE COLUMN b b1 CHAR(8) FIRST;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `b1` char(8) DEFAULT NULL,
+ `pk` int(11) NOT NULL,
+ `a` int(11),
+ `c` char(8) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 CHANGE b1 b INT AFTER c;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL,
+ `a` int(11),
+ `c` char(8) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 CHANGE b b CHAR(8);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL,
+ `a` int(11),
+ `c` char(8) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 MODIFY COLUMN b INT;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL,
+ `a` int(11),
+ `c` char(8) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 MODIFY COLUMN b CHAR(8) FIRST;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `b` char(8) DEFAULT NULL,
+ `pk` int(11) NOT NULL,
+ `a` int(11),
+ `c` char(8) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 MODIFY COLUMN b INT AFTER a;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL,
+ `a` int(11),
+ `b` int(11) DEFAULT NULL,
+ `c` char(8) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 DROP COLUMN b;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL,
+ `a` int(11),
+ `c` char(8) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 RENAME TO t2;
+SHOW CREATE TABLE t1;
+ERROR 42S02: Table 'test.t1' doesn't exist
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `pk` int(11) NOT NULL,
+ `a` int(11),
+ `c` char(8) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+DROP TABLE t2;
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT, b INT) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (1,1,5),(2,2,2),(3,4,3);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL,
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 ORDER BY b ASC, a DESC, pk DESC;
+Warnings:
+Warning 1105 ORDER BY ignored as there is a user-defined clustered index in the table 't1'
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL,
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SELECT * FROM t1;
+pk a b
+1 1 5
+2 2 2
+3 4 3
+DROP TABLE t1;
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT, b CHAR(8), c CHAR(8)) ENGINE=rocksdb CHARACTER SET latin1 COLLATE latin1_general_cs;
+INSERT INTO t1 VALUES (1,5,'z','t');
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL,
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) COLLATE latin1_general_cs DEFAULT NULL,
+ `c` char(8) COLLATE latin1_general_cs DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs
+ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL,
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL,
+ `c` char(8) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8
+ALTER TABLE t1 DEFAULT CHARACTER SET = latin1 COLLATE latin1_general_ci;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL,
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) CHARACTER SET utf8 DEFAULT NULL,
+ `c` char(8) CHARACTER SET utf8 DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
+ALTER TABLE t1 FORCE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL,
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) CHARACTER SET utf8 DEFAULT NULL,
+ `c` char(8) CHARACTER SET utf8 DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/analyze_table.result b/storage/rocksdb/mysql-test/rocksdb/r/analyze_table.result
new file mode 100644
index 00000000..3459b6f1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/analyze_table.result
@@ -0,0 +1,61 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT(11), b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (1,1,'a'),(2,2,'b');
+CREATE TABLE t2 (pk INT PRIMARY KEY, a INT(11), b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (3,3,'c');
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+INSERT INTO t2 VALUES (1,4,'d');
+ANALYZE NO_WRITE_TO_BINLOG TABLE t2;
+Table Op Msg_type Msg_text
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+INSERT INTO t1 VALUES (4,5,'e');
+INSERT INTO t2 VALUES (2,6,'f');
+ANALYZE LOCAL TABLE t1, t2;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+DROP TABLE t1, t2;
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT(11), KEY(a)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (1,1),(2,2),(3,4),(4,7);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+INSERT INTO t1 VALUES (5,8),(6,10),(7,11),(8,12);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+DROP TABLE t1;
+#
+# MDEV-12465: Server crashes in my_scan_weight_utf8_bin upon
+# collecting stats for RocksDB table
+#
+CREATE TABLE t1 (
+pk INT,
+f1 CHAR(255),
+f2 TEXT,
+f3 VARCHAR(255),
+f4 TEXT,
+PRIMARY KEY (pk),
+KEY (f4(255))
+) ENGINE=RocksDB
+CHARSET utf8
+COLLATE utf8_bin
+PARTITION BY KEY (pk) PARTITIONS 2;
+INSERT INTO t1 VALUES
+(1,'foo','bar','foo','bar'), (2,'bar','foo','bar','foo');
+ANALYZE TABLE t1 PERSISTENT FOR ALL;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze Warning Engine-independent statistics are not collected for column 'f2'
+test.t1 analyze Warning Engine-independent statistics are not collected for column 'f4'
+test.t1 analyze status OK
+drop table t1;
+# End of 10.2 tests
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/apply_changes_iter.result b/storage/rocksdb/mysql-test/rocksdb/r/apply_changes_iter.result
new file mode 100644
index 00000000..a5d81031
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/apply_changes_iter.result
@@ -0,0 +1,64 @@
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1 (
+pk INT NOT NULL PRIMARY KEY,
+key1 INT NOT NULL,
+KEY (key1)
+) ENGINE=ROCKSDB;
+INSERT INTO t1 VALUES (12,12);
+INSERT INTO t1 VALUES (6,6);
+BEGIN;
+INSERT INTO t1 VALUES (8,8), (10,10);
+SELECT * FROM t1 WHERE key1 BETWEEN 4 and 11 ORDER BY KEY1 DESC;
+pk key1
+10 10
+8 8
+6 6
+SELECT * FROM t1 WHERE key1 BETWEEN 4 and 11 ORDER BY KEY1 ASC;
+pk key1
+6 6
+8 8
+10 10
+SELECT * FROM t1 IGNORE INDEX(key1) WHERE key1 BETWEEN 4 and 11 ORDER BY key1 DESC;
+pk key1
+10 10
+8 8
+6 6
+SELECT * FROM t1 IGNORE INDEX(key1) WHERE key1 BETWEEN 4 and 11 ORDER BY key1 ASC;
+pk key1
+6 6
+8 8
+10 10
+ROLLBACK;
+CREATE TABLE t2 (
+pk INT NOT NULL PRIMARY KEY,
+key1 INT NOT NULL,
+KEY (key1) COMMENT 'rev:cf'
+) ENGINE=ROCKSDB;
+INSERT INTO t2 VALUES (12,12);
+INSERT INTO t2 VALUES (6,6);
+BEGIN;
+INSERT INTO t2 VALUES (8,8), (10,10);
+SELECT * FROM t2 WHERE key1 BETWEEN 4 and 11 ORDER BY KEY1 DESC;
+pk key1
+10 10
+8 8
+6 6
+SELECT * FROM t2 WHERE key1 BETWEEN 4 and 11 ORDER BY KEY1 ASC;
+pk key1
+6 6
+8 8
+10 10
+SELECT * FROM t2 IGNORE INDEX(key1) WHERE key1 BETWEEN 4 and 11 ORDER BY key1 DESC;
+pk key1
+10 10
+8 8
+6 6
+SELECT * FROM t2 IGNORE INDEX(key1) WHERE key1 BETWEEN 4 and 11 ORDER BY key1 ASC;
+pk key1
+6 6
+8 8
+10 10
+ROLLBACK;
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/autoinc_crash_safe.result b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_crash_safe.result
new file mode 100644
index 00000000..60395ece
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_crash_safe.result
@@ -0,0 +1,132 @@
+include/master-slave.inc
+[connection master]
+create table t (i int primary key auto_increment) engine=rocksdb;
+#
+# Testing concurrent transactions.
+#
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connect con3,localhost,root,,;
+connection con1;
+begin;
+insert into t values ();
+connection con2;
+begin;
+insert into t values ();
+connection con3;
+begin;
+insert into t values ();
+connection con1;
+insert into t values ();
+connection con2;
+insert into t values ();
+connection con3;
+insert into t values ();
+connection con2;
+commit;
+connection con3;
+rollback;
+connection con1;
+commit;
+delete from t;
+# Master value before restart
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 7
+# Slave value before restart
+connection slave;
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 6
+connection slave;
+include/stop_slave.inc
+include/rpl_restart_server.inc [server_number=1]
+connection default;
+# Master value after restart
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 6
+include/rpl_restart_server.inc [server_number=2]
+connection slave;
+include/start_slave.inc
+# Slave value after restart
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 6
+disconnect con1;
+disconnect con2;
+disconnect con3;
+#
+# Testing interaction of merge markers with various DDL statements.
+#
+connection slave;
+include/stop_slave.inc
+connection default;
+# Drop and add primary key.
+alter table t modify i int;
+alter table t drop primary key;
+alter table t add primary key (i);
+alter table t modify i int auto_increment;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 6
+# Remove auto_increment property.
+alter table t modify i int;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t NULL
+# Add auto_increment property.
+insert into t values (123);
+alter table t modify i int auto_increment;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 124
+# Add column j.
+alter table t add column j int;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 124
+# Rename tables.
+rename table t to t2;
+rename table t2 to t;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 124
+# Change auto_increment property
+alter table t auto_increment = 1000;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 1000
+alter table t auto_increment = 1;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 124
+alter table t drop primary key, add key (i), auto_increment = 1;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 124
+alter table t add key (j), auto_increment = 1;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 124
+alter table t modify i int;
+alter table t add column (k int auto_increment), add key(k), auto_increment=15;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 16
+# Drop table.
+drop table t;
+include/rpl_restart_server.inc [server_number=1]
+connection slave;
+include/start_slave.inc
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/autoinc_crash_safe_partition.result b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_crash_safe_partition.result
new file mode 100644
index 00000000..c837fb7c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_crash_safe_partition.result
@@ -0,0 +1,132 @@
+include/master-slave.inc
+[connection master]
+create table t (i int primary key auto_increment) engine=rocksdb partition by key (i) partitions 3;
+#
+# Testing concurrent transactions.
+#
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connect con3,localhost,root,,;
+connection con1;
+begin;
+insert into t values ();
+connection con2;
+begin;
+insert into t values ();
+connection con3;
+begin;
+insert into t values ();
+connection con1;
+insert into t values ();
+connection con2;
+insert into t values ();
+connection con3;
+insert into t values ();
+connection con2;
+commit;
+connection con3;
+rollback;
+connection con1;
+commit;
+delete from t;
+# Master value before restart
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 7
+# Slave value before restart
+connection slave;
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 6
+connection slave;
+include/stop_slave.inc
+include/rpl_restart_server.inc [server_number=1]
+connection default;
+# Master value after restart
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 6
+include/rpl_restart_server.inc [server_number=2]
+connection slave;
+include/start_slave.inc
+# Slave value after restart
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 6
+disconnect con1;
+disconnect con2;
+disconnect con3;
+#
+# Testing interaction of merge markers with various DDL statements.
+#
+connection slave;
+include/stop_slave.inc
+connection default;
+# Drop and add primary key.
+alter table t modify i int;
+alter table t drop primary key;
+alter table t add primary key (i);
+alter table t modify i int auto_increment;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 1
+# Remove auto_increment property.
+alter table t modify i int;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t NULL
+# Add auto_increment property.
+insert into t values (123);
+alter table t modify i int auto_increment;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 124
+# Add column j.
+alter table t add column j int;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 124
+# Rename tables.
+rename table t to t2;
+rename table t2 to t;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 124
+# Change auto_increment property
+alter table t auto_increment = 1000;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 1000
+alter table t auto_increment = 1;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 124
+alter table t drop primary key, add key (i), auto_increment = 1;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 124
+alter table t add key (j), auto_increment = 1;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 124
+alter table t modify i int;
+alter table t add column (k int auto_increment), add key(k), auto_increment=15;
+include/rpl_restart_server.inc [server_number=1]
+select table_schema, table_name, auto_increment from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment
+test t 16
+# Drop table.
+drop table t;
+include/rpl_restart_server.inc [server_number=1]
+connection slave;
+include/start_slave.inc
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/autoinc_debug.result b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_debug.result
new file mode 100644
index 00000000..604e5572
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_debug.result
@@ -0,0 +1,99 @@
+#
+# Testing upgrading from server without merges for auto_increment
+# to new server with such support.
+#
+set debug_dbug='+d,myrocks_autoinc_upgrade';
+create table t (i int primary key auto_increment);
+insert into t values ();
+insert into t values ();
+insert into t values ();
+select * from t;
+i
+1
+2
+3
+delete from t where i > 1;
+select * from t;
+i
+1
+select table_name, index_name, auto_increment
+from information_schema.rocksdb_ddl where table_name = 't';
+table_name index_name auto_increment
+t PRIMARY NULL
+set debug_dbug='-d,myrocks_autoinc_upgrade';
+insert into t values ();
+insert into t values ();
+insert into t values ();
+select * from t;
+i
+1
+2
+3
+4
+select table_name, index_name, auto_increment
+from information_schema.rocksdb_ddl where table_name = 't';
+table_name index_name auto_increment
+t PRIMARY 5
+delete from t where i > 1;
+insert into t values ();
+insert into t values ();
+insert into t values ();
+select * from t;
+i
+1
+5
+6
+7
+drop table t;
+#
+# Testing crash safety of transactions.
+#
+create table t (i int primary key auto_increment);
+insert into t values ();
+insert into t values ();
+insert into t values ();
+# Before anything
+begin;
+insert into t values ();
+insert into t values ();
+set debug_dbug="+d,crash_commit_before";
+commit;
+ERROR HY000: Lost connection to MySQL server during query
+select max(i) into @row_max from t;
+select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment > @row_max
+test t 1
+# After engine prepare
+begin;
+insert into t values ();
+insert into t values ();
+set debug_dbug="+d,crash_commit_after_prepare";
+commit;
+ERROR HY000: Lost connection to MySQL server during query
+select max(i) into @row_max from t;
+select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment > @row_max
+test t 1
+# After binlog
+begin;
+insert into t values ();
+insert into t values ();
+set debug_dbug="+d,crash_commit_after_log";
+commit;
+ERROR HY000: Lost connection to MySQL server during query
+select max(i) into @row_max from t;
+select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment > @row_max
+test t 1
+# After everything
+begin;
+insert into t values ();
+insert into t values ();
+set debug_dbug="+d,crash_commit_after";
+commit;
+ERROR HY000: Lost connection to MySQL server during query
+select max(i) into @row_max from t;
+select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
+table_schema table_name auto_increment > @row_max
+test t 1
+drop table t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/autoinc_secondary.result b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_secondary.result
new file mode 100644
index 00000000..c6dcb023
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_secondary.result
@@ -0,0 +1,17 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT AUTO_INCREMENT, KEY(a)) ENGINE=rocksdb;
+INSERT INTO t1 (pk) VALUES (3), (2), (1);
+SELECT * FROM t1;
+pk a
+3 1
+2 2
+1 3
+# restart
+INSERT INTO t1 (pk) VALUES (4);
+SELECT * FROM t1;
+pk a
+3 1
+2 2
+1 3
+4 4
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars.result b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars.result
new file mode 100644
index 00000000..cc47ceff
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars.result
@@ -0,0 +1,199 @@
+DROP TABLE IF EXISTS t1;
+#---------------------------
+# auto_increment_offset
+#---------------------------
+SET auto_increment_offset = 200;
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (NULL,'a'),(NULL,'b'),(NULL,'c');
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+1
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 a
+2 b
+3 c
+#---------------------------
+# auto_increment_increment
+#---------------------------
+SET auto_increment_increment = 300;
+INSERT INTO t1 (a,b) VALUES (NULL,'d'),(NULL,'e'),(NULL,'f');
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+200
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 a
+2 b
+3 c
+200 d
+500 e
+800 f
+SET auto_increment_increment = 50;
+INSERT INTO t1 (a,b) VALUES (NULL,'g'),(NULL,'h'),(NULL,'i');
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+850
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 a
+2 b
+3 c
+200 d
+500 e
+800 f
+850 g
+900 h
+950 i
+DROP TABLE t1;
+#---------------------------
+# offset is greater than the max value
+#---------------------------
+SET auto_increment_increment = 500;
+SET auto_increment_offset = 300;
+CREATE TABLE t1 (a TINYINT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+# In MariaDB, this is an error:
+INSERT INTO t1 (a) VALUES (NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+850
+SELECT a FROM t1 ORDER BY a;
+a
+DROP TABLE t1;
+#---------------------------
+# test large autoincrement values
+#---------------------------
+SET auto_increment_increment = 1;
+SET auto_increment_offset = 1;
+CREATE TABLE t1 (a BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (18446744073709551613, 'a');
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB AUTO_INCREMENT=18446744073709551614 DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (NULL, 'b');
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB AUTO_INCREMENT=18446744073709551615 DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (NULL, 'c');
+ERROR HY000: Failed to read auto-increment value from storage engine
+SELECT * FROM t1;
+a b
+18446744073709551613 a
+18446744073709551614 b
+DROP TABLE t1;
+SET auto_increment_increment = 300;
+CREATE TABLE t1 (a BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (18446744073709551613, 'a');
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB AUTO_INCREMENT=18446744073709551614 DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (NULL, 'b');
+ERROR HY000: Failed to read auto-increment value from storage engine
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB AUTO_INCREMENT=18446744073709551615 DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (NULL, 'c');
+ERROR HY000: Failed to read auto-increment value from storage engine
+SELECT * FROM t1;
+a b
+18446744073709551613 a
+DROP TABLE t1;
+SET auto_increment_offset = 200;
+CREATE TABLE t1 (a BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (18446744073709551613, 'a');
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB AUTO_INCREMENT=18446744073709551614 DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (NULL, 'b');
+ERROR HY000: Failed to read auto-increment value from storage engine
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB AUTO_INCREMENT=18446744073709551615 DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (NULL, 'c');
+ERROR HY000: Failed to read auto-increment value from storage engine
+SELECT * FROM t1;
+a b
+18446744073709551613 a
+DROP TABLE t1;
+#----------------------------------
+# Issue #792 Crash in autoincrement
+#----------------------------------
+CREATE TABLE t1(C1 DOUBLE AUTO_INCREMENT KEY,C2 CHAR) ENGINE=ROCKSDB;
+INSERT INTO t1 VALUES(2177,0);
+DROP TABLE t1;
+CREATE TABLE t0(c0 BLOB) ENGINE=ROCKSDB;
+INSERT INTO t0 VALUES(0);
+ALTER TABLE t0 AUTO_INCREMENT=0;
+DROP TABLE t0;
+#---------------------------------------------------------------
+# MDEV-16703 Assertion failed in load_auto_incr_value_from_index
+#---------------------------------------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT, a INT, PRIMARY KEY(pk)) ENGINE=RocksDB;
+INSERT INTO t1 (a) VALUES (1);
+UPDATE t1 SET pk = 3;
+ALTER TABLE t1 AUTO_INCREMENT 2;
+DROP TABLE t1;
+#----------------------------------
+# Issue #792 Crash in autoincrement
+#----------------------------------
+CREATE TABLE t1(C1 DOUBLE AUTO_INCREMENT KEY,C2 CHAR) ENGINE=ROCKSDB;
+INSERT INTO t1 VALUES(2177,0);
+DROP TABLE t1;
+CREATE TABLE t0(c0 BLOB) ENGINE=ROCKSDB;
+INSERT INTO t0 VALUES(0);
+ALTER TABLE t0 AUTO_INCREMENT=0;
+DROP TABLE t0;
+#----------------------------------
+# Issue #869 Crash in autoincrement
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT, a INT, PRIMARY KEY(pk)) ENGINE=RocksDB;
+INSERT INTO t1 (a) VALUES (1);
+UPDATE t1 SET pk = 3;
+ALTER TABLE t1 AUTO_INCREMENT 2;
+DROP TABLE t1;
+#----------------------------------
+# Issue #902 Debug assert in autoincrement with small field type
+#----------------------------------
+SET auto_increment_increment=100, auto_increment_offset=10;
+CREATE TABLE t1(i INT AUTO_INCREMENT PRIMARY KEY) ENGINE=ROCKSDB AUTO_INCREMENT=18446744073709551615;
+INSERT INTO t1 VALUES (NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
+SELECT * FROM t1;
+i
+ALTER TABLE t1 AUTO_INCREMENT=1;
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+i
+10
+ALTER TABLE t1 AUTO_INCREMENT=18446744073709551615;
+INSERT INTO t1 VALUES (NULL);
+ERROR HY000: Failed to read auto-increment value from storage engine
+SELECT * FROM t1;
+i
+10
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars_thread.result b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars_thread.result
new file mode 100644
index 00000000..9331b4e2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars_thread.result
@@ -0,0 +1,39 @@
+#---------------------------
+# two threads inserting simultaneously with increment > 1
+# Issue #390
+#---------------------------
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+connect con1, localhost, root,,;
+SET auto_increment_increment = 2;
+SET auto_increment_offset = 1;
+INSERT INTO t1 VALUES(NULL);
+connect con2, localhost, root,,;
+SET auto_increment_increment = 2;
+SET auto_increment_offset = 1;
+connect con3, localhost, root,,;
+connection con1;
+SET debug_sync='rocksdb.autoinc_vars2 SIGNAL go2';
+SET debug_sync='rocksdb.autoinc_vars SIGNAL parked1 WAIT_FOR go1';
+INSERT INTO t1 VALUES(NULL);
+connection default;
+SET debug_sync='now WAIT_FOR parked1';
+connection con2;
+SET debug_sync='rocksdb.autoinc_vars SIGNAL parked2 WAIT_FOR go2';
+INSERT INTO t1 VALUES(NULL);
+connection default;
+SET debug_sync='now WAIT_FOR parked2';
+SET debug_sync='now SIGNAL go1';
+connection con3;
+connection default;
+connection con1;
+connection con2;
+connection default;
+SET debug_sync='RESET';
+disconnect con1;
+disconnect con2;
+SELECT * FROM t1;
+a
+1
+3
+5
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars_thread_2.result b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars_thread_2.result
new file mode 100644
index 00000000..6bd6cea9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars_thread_2.result
@@ -0,0 +1,98 @@
+#---------------------------
+# ten threads inserting simultaneously with increment > 1
+# Issue #390
+#---------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, thr INT) ENGINE=rocksdb;
+connect con$i, localhost, root,,;
+SET auto_increment_increment = 100;
+SET auto_increment_offset = 9 + 1;
+connect con$i, localhost, root,,;
+SET auto_increment_increment = 100;
+SET auto_increment_offset = 8 + 1;
+connect con$i, localhost, root,,;
+SET auto_increment_increment = 100;
+SET auto_increment_offset = 7 + 1;
+connect con$i, localhost, root,,;
+SET auto_increment_increment = 100;
+SET auto_increment_offset = 6 + 1;
+connect con$i, localhost, root,,;
+SET auto_increment_increment = 100;
+SET auto_increment_offset = 5 + 1;
+connect con$i, localhost, root,,;
+SET auto_increment_increment = 100;
+SET auto_increment_offset = 4 + 1;
+connect con$i, localhost, root,,;
+SET auto_increment_increment = 100;
+SET auto_increment_offset = 3 + 1;
+connect con$i, localhost, root,,;
+SET auto_increment_increment = 100;
+SET auto_increment_offset = 2 + 1;
+connect con$i, localhost, root,,;
+SET auto_increment_increment = 100;
+SET auto_increment_offset = 1 + 1;
+connect con$i, localhost, root,,;
+SET auto_increment_increment = 100;
+SET auto_increment_offset = 0 + 1;
+connection default;
+connection con9;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+connection con8;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+connection con7;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+connection con6;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+connection con5;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+connection con4;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+connection con3;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+connection con2;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+connection con1;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+connection con0;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+connection default;
+connection con9;
+connection con8;
+connection con7;
+connection con6;
+connection con5;
+connection con4;
+connection con3;
+connection con2;
+connection con1;
+connection con0;
+connection default;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1000000
+SELECT thr, COUNT(pk) FROM t1 GROUP BY thr;
+thr COUNT(pk)
+0 100000
+1 100000
+2 100000
+3 100000
+4 100000
+5 100000
+6 100000
+7 100000
+8 100000
+9 100000
+disconnect con9;
+disconnect con8;
+disconnect con7;
+disconnect con6;
+disconnect con5;
+disconnect con4;
+disconnect con3;
+disconnect con2;
+disconnect con1;
+disconnect con0;
+SELECT * FROM t1 ORDER BY pk INTO OUTFILE <output_file>;
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+All pk values matched their expected values
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/binlog_rotate_crash.result b/storage/rocksdb/mysql-test/rocksdb/r/binlog_rotate_crash.result
new file mode 100644
index 00000000..1b221418
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/binlog_rotate_crash.result
@@ -0,0 +1,19 @@
+#
+# MDEV-25305: MyRocks: Killing server during RESET MASTER can lose last transactions
+#
+set global rocksdb_flush_log_at_trx_commit=1;
+create table t1 (a int, b int, key(a)) engine=rocksdb;
+insert into t1 values (1,1),(2,2);
+select * from t1;
+a b
+1 1
+2 2
+flush tables;
+set @@debug_dbug="+d,crash_after_reset_master";
+RESET MASTER;
+# Must show the inserted rows:
+select * from t1;
+a b
+1 1
+2 2
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/blind_delete_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/blind_delete_rc.result
new file mode 100644
index 00000000..973d1876
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/blind_delete_rc.result
@@ -0,0 +1,87 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+set @save_rocksdb_blind_delete_primary_key=@@session.rocksdb_blind_delete_primary_key;
+set @save_rocksdb_master_skip_tx_api=@@session.rocksdb_master_skip_tx_api;
+DROP TABLE IF EXISTS t1,t2;
+create table t1 (id int primary key, value int, value2 varchar(200)) engine=rocksdb;
+create table t2 (id int primary key, value int, value2 varchar(200), index(value)) engine=rocksdb;
+SET session rocksdb_blind_delete_primary_key=1;
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+variable_value-@c
+1000
+SELECT count(*) FROM t1;
+count(*)
+9000
+include/sync_slave_sql_with_master.inc
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SELECT count(*) FROM t1;
+count(*)
+9000
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+variable_value-@c
+0
+SELECT count(*) FROM t2;
+count(*)
+9000
+SET session rocksdb_master_skip_tx_api=1;
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+variable_value-@c
+1000
+SELECT count(*) FROM t1;
+count(*)
+8000
+SELECT count(*) FROM t2;
+count(*)
+8000
+include/sync_slave_sql_with_master.inc
+SELECT count(*) FROM t1;
+count(*)
+8000
+SELECT count(*) FROM t2;
+count(*)
+8000
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+DELETE FROM t1 WHERE id BETWEEN 3001 AND 4000;
+DELETE FROM t2 WHERE id BETWEEN 3001 AND 4000;
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+variable_value-@c
+0
+SELECT count(*) FROM t1;
+count(*)
+7000
+SELECT count(*) FROM t2;
+count(*)
+7000
+include/sync_slave_sql_with_master.inc
+SELECT count(*) FROM t1;
+count(*)
+7000
+SELECT count(*) FROM t2;
+count(*)
+7000
+DELETE FROM t1 WHERE id = 10;
+SELECT count(*) FROM t1;
+count(*)
+7000
+call mtr.add_suppression("Slave SQL.*Could not execute Delete_rows event on table test.t1.*Error_code.*");
+call mtr.add_suppression("Slave: Can't find record in 't1'.*");
+include/wait_for_slave_sql_error.inc [errno=1032]
+set @save_rocksdb_read_free_rpl=@@global.rocksdb_read_free_rpl;
+set global rocksdb_read_free_rpl=PK_SK;
+START SLAVE;
+include/sync_slave_sql_with_master.inc
+SELECT count(*) FROM t1;
+count(*)
+7000
+set global rocksdb_read_free_rpl=@save_rocksdb_read_free_rpl;
+SET session rocksdb_blind_delete_primary_key=@save_rocksdb_blind_delete_primary_key;
+SET session rocksdb_master_skip_tx_api=@save_rocksdb_master_skip_tx_api;
+DROP TABLE t1, t2;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/blind_delete_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/blind_delete_rr.result
new file mode 100644
index 00000000..683b672e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/blind_delete_rr.result
@@ -0,0 +1,87 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+set @save_rocksdb_blind_delete_primary_key=@@session.rocksdb_blind_delete_primary_key;
+set @save_rocksdb_master_skip_tx_api=@@session.rocksdb_master_skip_tx_api;
+DROP TABLE IF EXISTS t1,t2;
+create table t1 (id int primary key, value int, value2 varchar(200)) engine=rocksdb;
+create table t2 (id int primary key, value int, value2 varchar(200), index(value)) engine=rocksdb;
+SET session rocksdb_blind_delete_primary_key=1;
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+variable_value-@c
+1000
+SELECT count(*) FROM t1;
+count(*)
+9000
+include/sync_slave_sql_with_master.inc
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+SELECT count(*) FROM t1;
+count(*)
+9000
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+variable_value-@c
+0
+SELECT count(*) FROM t2;
+count(*)
+9000
+SET session rocksdb_master_skip_tx_api=1;
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+variable_value-@c
+1000
+SELECT count(*) FROM t1;
+count(*)
+8000
+SELECT count(*) FROM t2;
+count(*)
+8000
+include/sync_slave_sql_with_master.inc
+SELECT count(*) FROM t1;
+count(*)
+8000
+SELECT count(*) FROM t2;
+count(*)
+8000
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+DELETE FROM t1 WHERE id BETWEEN 3001 AND 4000;
+DELETE FROM t2 WHERE id BETWEEN 3001 AND 4000;
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+variable_value-@c
+0
+SELECT count(*) FROM t1;
+count(*)
+7000
+SELECT count(*) FROM t2;
+count(*)
+7000
+include/sync_slave_sql_with_master.inc
+SELECT count(*) FROM t1;
+count(*)
+7000
+SELECT count(*) FROM t2;
+count(*)
+7000
+DELETE FROM t1 WHERE id = 10;
+SELECT count(*) FROM t1;
+count(*)
+7000
+call mtr.add_suppression("Slave SQL.*Could not execute Delete_rows event on table test.t1.*Error_code.*");
+call mtr.add_suppression("Slave: Can't find record in 't1'.*");
+include/wait_for_slave_sql_error.inc [errno=1032]
+set @save_rocksdb_read_free_rpl=@@global.rocksdb_read_free_rpl;
+set global rocksdb_read_free_rpl=PK_SK;
+START SLAVE;
+include/sync_slave_sql_with_master.inc
+SELECT count(*) FROM t1;
+count(*)
+7000
+set global rocksdb_read_free_rpl=@save_rocksdb_read_free_rpl;
+SET session rocksdb_blind_delete_primary_key=@save_rocksdb_blind_delete_primary_key;
+SET session rocksdb_master_skip_tx_api=@save_rocksdb_master_skip_tx_api;
+DROP TABLE t1, t2;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter.result b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter.result
new file mode 100644
index 00000000..bc5d685f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter.result
@@ -0,0 +1,2042 @@
+CREATE PROCEDURE bloom_start()
+BEGIN
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+END//
+CREATE PROCEDURE bloom_end()
+BEGIN
+select case when variable_value-@c > 0 then 'true' else 'false' end as checked from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+END//
+create or replace table t1 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id1, id2, id3, id4) ,
+index id2 (id2) ,
+index id2_id1 (id2, id1) ,
+index id2_id3 (id2, id3) ,
+index id2_id4 (id2, id4) ,
+index id2_id3_id1_id4 (id2, id3, id1, id4) ,
+index id3_id2 (id3, id2)
+) engine=ROCKSDB;
+create or replace table t2 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id4) ,
+index id2 (id2) ,
+index id2_id3 (id2, id3) ,
+index id2_id4 (id2, id4) ,
+index id2_id4_id5 (id2, id4, id5) ,
+index id3_id4 (id3, id4) ,
+index id3_id5 (id3, id5)
+) engine=ROCKSDB;
+insert t1
+select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc"
+ from seq_1_to_10000;
+insert t2 select * from t1;
+set global rocksdb_force_flush_memtable_now=1;
+call bloom_start();
+select count(*) from t1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(PRIMARY) where id1 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index(id3_id4) where id3 >= '1';
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=2 and id1=1;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=24 and id1=12;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=88 and id1=44;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=100 and id1=50;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=428 and id1=214;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=1 and id4=1 and id5=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=23 and id4=115 and id5=115;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=500 and id4=2500 and id5=2500;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=601 and id4=3005 and id5=3005;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=1 and id3='1' and id1=1 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36 and id3='36' and id1=18 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124' and id1=62 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=888 and id3='888' and id1=444 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124';
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1 and id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=12 and id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=1;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=12;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=23;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=100;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=234;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=234;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=1 and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=23 and id4=115;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=500 and id4=2500;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=601 and id4=3005;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='100' and id5=500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='240' and id5=1200;
+count(*)
+1
+call bloom_end();
+checked
+false
+create or replace table t1 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id1, id2, id3, id4) COMMENT 'cf_short_prefix',
+index id2 (id2) COMMENT 'cf_short_prefix',
+index id2_id1 (id2, id1) COMMENT 'cf_short_prefix',
+index id2_id3 (id2, id3) COMMENT 'cf_short_prefix',
+index id2_id4 (id2, id4) COMMENT 'cf_short_prefix',
+index id2_id3_id1_id4 (id2, id3, id1, id4) COMMENT 'cf_short_prefix',
+index id3_id2 (id3, id2) COMMENT 'cf_short_prefix'
+) engine=ROCKSDB;
+create or replace table t2 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id4) COMMENT 'cf_short_prefix',
+index id2 (id2) COMMENT 'cf_short_prefix',
+index id2_id3 (id2, id3) COMMENT 'cf_short_prefix',
+index id2_id4 (id2, id4) COMMENT 'cf_short_prefix',
+index id2_id4_id5 (id2, id4, id5) COMMENT 'cf_short_prefix',
+index id3_id4 (id3, id4) COMMENT 'cf_short_prefix',
+index id3_id5 (id3, id5) COMMENT 'cf_short_prefix'
+) engine=ROCKSDB;
+insert t1
+select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc"
+ from seq_1_to_10000;
+insert t2 select * from t1;
+set global rocksdb_force_flush_memtable_now=1;
+call bloom_start();
+select count(*) from t1;
+count(*)
+10000
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2;
+count(*)
+10000
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(PRIMARY) where id1 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index(id3_id4) where id3 >= '1';
+count(*)
+10000
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=2 and id1=1;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=24 and id1=12;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=88 and id1=44;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=100 and id1=50;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=428 and id1=214;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=1 and id4=1 and id5=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=23 and id4=115 and id5=115;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=500 and id4=2500 and id5=2500;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=601 and id4=3005 and id5=3005;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=1 and id3='1' and id1=1 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36 and id3='36' and id1=18 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124' and id1=62 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=888 and id3='888' and id1=444 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124';
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1 and id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=12 and id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=1;
+count(*)
+10
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=12;
+count(*)
+10
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=23;
+count(*)
+10
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=100;
+count(*)
+10
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=234;
+count(*)
+10
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=234;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=1 and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=23 and id4=115;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=500 and id4=2500;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=601 and id4=3005;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='100' and id5=500;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='240' and id5=1200;
+count(*)
+1
+call bloom_end();
+checked
+true
+create or replace table t1 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id1, id2, id3, id4) COMMENT 'rev:cf_short_prefix',
+index id2 (id2) COMMENT 'rev:cf_short_prefix',
+index id2_id1 (id2, id1) COMMENT 'rev:cf_short_prefix',
+index id2_id3 (id2, id3) COMMENT 'rev:cf_short_prefix',
+index id2_id4 (id2, id4) COMMENT 'rev:cf_short_prefix',
+index id2_id3_id1_id4 (id2, id3, id1, id4) COMMENT 'rev:cf_short_prefix',
+index id3_id2 (id3, id2) COMMENT 'rev:cf_short_prefix'
+) engine=ROCKSDB;
+create or replace table t2 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id4) COMMENT 'rev:cf_short_prefix',
+index id2 (id2) COMMENT 'rev:cf_short_prefix',
+index id2_id3 (id2, id3) COMMENT 'rev:cf_short_prefix',
+index id2_id4 (id2, id4) COMMENT 'rev:cf_short_prefix',
+index id2_id4_id5 (id2, id4, id5) COMMENT 'rev:cf_short_prefix',
+index id3_id4 (id3, id4) COMMENT 'rev:cf_short_prefix',
+index id3_id5 (id3, id5) COMMENT 'rev:cf_short_prefix'
+) engine=ROCKSDB;
+insert t1
+select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc"
+ from seq_1_to_10000;
+insert t2 select * from t1;
+set global rocksdb_force_flush_memtable_now=1;
+call bloom_start();
+select count(*) from t1;
+count(*)
+10000
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2;
+count(*)
+10000
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(PRIMARY) where id1 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index(id3_id4) where id3 >= '1';
+count(*)
+10000
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=2 and id1=1;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=24 and id1=12;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=88 and id1=44;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=100 and id1=50;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=428 and id1=214;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=1 and id4=1 and id5=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=23 and id4=115 and id5=115;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=500 and id4=2500 and id5=2500;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=601 and id4=3005 and id5=3005;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=1 and id3='1' and id1=1 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36 and id3='36' and id1=18 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124' and id1=62 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=888 and id3='888' and id1=444 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124';
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1 and id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=12 and id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=1;
+count(*)
+10
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=12;
+count(*)
+10
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=23;
+count(*)
+10
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=100;
+count(*)
+10
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=234;
+count(*)
+10
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=234;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=1 and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=23 and id4=115;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=500 and id4=2500;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=601 and id4=3005;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='100' and id5=500;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='240' and id5=1200;
+count(*)
+1
+call bloom_end();
+checked
+true
+create or replace table t1 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id1, id2, id3, id4) COMMENT 'cf_long_prefix',
+index id2 (id2) COMMENT 'cf_long_prefix',
+index id2_id1 (id2, id1) COMMENT 'cf_long_prefix',
+index id2_id3 (id2, id3) COMMENT 'cf_long_prefix',
+index id2_id4 (id2, id4) COMMENT 'cf_long_prefix',
+index id2_id3_id1_id4 (id2, id3, id1, id4) COMMENT 'cf_long_prefix',
+index id3_id2 (id3, id2) COMMENT 'cf_long_prefix'
+) engine=ROCKSDB;
+create or replace table t2 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id4) COMMENT 'cf_long_prefix',
+index id2 (id2) COMMENT 'cf_long_prefix',
+index id2_id3 (id2, id3) COMMENT 'cf_long_prefix',
+index id2_id4 (id2, id4) COMMENT 'cf_long_prefix',
+index id2_id4_id5 (id2, id4, id5) COMMENT 'cf_long_prefix',
+index id3_id4 (id3, id4) COMMENT 'cf_long_prefix',
+index id3_id5 (id3, id5) COMMENT 'cf_long_prefix'
+) engine=ROCKSDB;
+insert t1
+select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc"
+ from seq_1_to_10000;
+insert t2 select * from t1;
+set global rocksdb_force_flush_memtable_now=1;
+call bloom_start();
+select count(*) from t1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(PRIMARY) where id1 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index(id3_id4) where id3 >= '1';
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=2 and id1=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=24 and id1=12;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=88 and id1=44;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=100 and id1=50;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=428 and id1=214;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=1 and id4=1 and id5=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=23 and id4=115 and id5=115;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=500 and id4=2500 and id5=2500;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=601 and id4=3005 and id5=3005;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=1 and id3='1' and id1=1 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36 and id3='36' and id1=18 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124' and id1=62 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=888 and id3='888' and id1=444 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1 and id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=12 and id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=1;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=12;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=23;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=100;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=234;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=234;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=1 and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=23 and id4=115;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=500 and id4=2500;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=601 and id4=3005;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='100' and id5=500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='240' and id5=1200;
+count(*)
+1
+call bloom_end();
+checked
+false
+create or replace table t1 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id1, id2, id3, id4) COMMENT 'rev:cf_long_prefix',
+index id2 (id2) COMMENT 'rev:cf_long_prefix',
+index id2_id1 (id2, id1) COMMENT 'rev:cf_long_prefix',
+index id2_id3 (id2, id3) COMMENT 'rev:cf_long_prefix',
+index id2_id4 (id2, id4) COMMENT 'rev:cf_long_prefix',
+index id2_id3_id1_id4 (id2, id3, id1, id4) COMMENT 'rev:cf_long_prefix',
+index id3_id2 (id3, id2) COMMENT 'rev:cf_long_prefix'
+) engine=ROCKSDB;
+create or replace table t2 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id4) COMMENT 'rev:cf_long_prefix',
+index id2 (id2) COMMENT 'rev:cf_long_prefix',
+index id2_id3 (id2, id3) COMMENT 'rev:cf_long_prefix',
+index id2_id4 (id2, id4) COMMENT 'rev:cf_long_prefix',
+index id2_id4_id5 (id2, id4, id5) COMMENT 'rev:cf_long_prefix',
+index id3_id4 (id3, id4) COMMENT 'rev:cf_long_prefix',
+index id3_id5 (id3, id5) COMMENT 'rev:cf_long_prefix'
+) engine=ROCKSDB;
+insert t1
+select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc"
+ from seq_1_to_10000;
+insert t2 select * from t1;
+set global rocksdb_force_flush_memtable_now=1;
+call bloom_start();
+select count(*) from t1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(PRIMARY) where id1 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index(id3_id4) where id3 >= '1';
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=2 and id1=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=24 and id1=12;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=88 and id1=44;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=100 and id1=50;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=428 and id1=214;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=1 and id4=1 and id5=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=23 and id4=115 and id5=115;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=500 and id4=2500 and id5=2500;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=601 and id4=3005 and id5=3005;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=1 and id3='1' and id1=1 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36 and id3='36' and id1=18 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124' and id1=62 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=888 and id3='888' and id1=444 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1 and id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=12 and id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=1;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=12;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=23;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=100;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=234;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=234;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=1 and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=23 and id4=115;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=500 and id4=2500;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=601 and id4=3005;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+true
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='100' and id5=500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='240' and id5=1200;
+count(*)
+1
+call bloom_end();
+checked
+false
+create table r1 (id1 bigint, id2 bigint, id3 bigint, v1 int, v2 text, primary key (id1, id2, id3)) engine=rocksdb DEFAULT CHARSET=latin1 collate latin1_bin;
+call bloom_start();
+select * from r1 where id1=1 and id2 in (1) order by id3 asc;
+id1 id2 id3 v1 v2
+1 1 1 1 1
+call bloom_end();
+checked
+true
+call bloom_start();
+select * from r1 where id1=1 and id2 in (1) order by id3 desc;
+id1 id2 id3 v1 v2
+1 1 1 1 1
+call bloom_end();
+checked
+false
+DROP PROCEDURE bloom_start;
+DROP PROCEDURE bloom_end;
+truncate table t1;
+optimize table t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+truncate table t2;
+optimize table t2;
+Table Op Msg_type Msg_text
+test.t2 optimize status OK
+drop table if exists t1;
+drop table if exists t2;
+drop table if exists r1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter2.result b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter2.result
new file mode 100644
index 00000000..d5369e2d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter2.result
@@ -0,0 +1,71 @@
+CREATE TABLE t0 (id1 VARCHAR(30), id2 INT, value INT, PRIMARY KEY (id1, id2)) ENGINE=rocksdb collate latin1_bin;
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+SELECT COUNT(*) FROM t0 WHERE id1='X' AND id2>=1;
+COUNT(*)
+10000
+select case when variable_value-@u = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+case when variable_value-@u = 0 then 'true' else 'false' end
+true
+DROP TABLE t0;
+CREATE TABLE t1 (id1 BIGINT, id2 INT, id3 BIGINT, value INT, PRIMARY KEY (id1, id2, id3)) ENGINE=rocksdb;
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3>=2;
+COUNT(*)
+9999
+select case when variable_value-@u = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+case when variable_value-@u = 0 then 'true' else 'false' end
+true
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2>=1 AND id3>=2;
+COUNT(*)
+9999
+select case when variable_value-@u = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+case when variable_value-@u = 0 then 'true' else 'false' end
+true
+DROP TABLE t1;
+CREATE TABLE t2 (id1 INT, id2 VARCHAR(100), id3 BIGINT, value INT, PRIMARY KEY (id1, id2, id3)) ENGINE=rocksdb collate latin1_bin;
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+select count(*) from t2 WHERE id1=100 and id2 IN ('00000000000000000000', '100');
+count(*)
+1
+select case when variable_value-@u > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+case when variable_value-@u > 0 then 'true' else 'false' end
+true
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+select count(*) from t2 WHERE id1=200 and id2 IN ('00000000000000000000', '200');
+count(*)
+1
+select case when variable_value-@u > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+case when variable_value-@u > 0 then 'true' else 'false' end
+true
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+select count(*) from t2 WHERE id1=200 and id2 IN ('3', '200');
+count(*)
+1
+select case when variable_value-@u = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+case when variable_value-@u = 0 then 'true' else 'false' end
+true
+DROP TABLE t2;
+CREATE TABLE t3 (id1 BIGINT, id2 BIGINT, id3 BIGINT, id4 BIGINT, PRIMARY KEY (id1, id2, id3, id4)) ENGINE=rocksdb collate latin1_bin;
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_useful';
+SELECT COUNT(*) FROM t3 WHERE id1=1 AND id2=5000 AND id3=1 AND id4=1;
+COUNT(*)
+0
+select case when variable_value-@u > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_useful';
+case when variable_value-@u > 0 then 'true' else 'false' end
+true
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+SELECT COUNT(*) FROM t3 WHERE id1=1 AND id2=1 AND id3=1;
+COUNT(*)
+1
+select case when variable_value-@u > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+case when variable_value-@u > 0 then 'true' else 'false' end
+true
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+SELECT COUNT(*) FROM t3 WHERE id1=1 AND id2=1 AND id3=1 AND id4 <= 500;
+COUNT(*)
+1
+select case when variable_value-@u > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+case when variable_value-@u > 0 then 'true' else 'false' end
+true
+DROP TABLE t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter3.result b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter3.result
new file mode 100644
index 00000000..d447b480
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter3.result
@@ -0,0 +1,143 @@
+# restart
+CREATE TABLE `linktable` (
+`id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+`visibility` tinyint(3) NOT NULL DEFAULT '0',
+`data` varchar(255) NOT NULL DEFAULT '',
+`time` bigint(20) unsigned NOT NULL DEFAULT '0',
+`version` int(11) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (link_type, `id1`,`id2`) COMMENT 'cf_link_pk',
+KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`version`,`data`) COMMENT 'rev:cf_link_id1_type',
+KEY `id1_type2` (`id1`,`link_type`,`time`,`version`,`data`,`visibility`) COMMENT 'rev:cf_link_id1_type2',
+KEY `id1_type3` (`id1`,`visibility`,`time`,`version`,`data`,`link_type`) COMMENT 'rev:cf_link_id1_type3'
+) ENGINE=RocksDB DEFAULT COLLATE=latin1_bin;
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type`) where id1 = 100 and link_type = 1 and time >= 0 and time <= 9223372036854775807 and visibility = 1 order by time desc;
+id1 id2 link_type visibility data time version
+100 100 1 1 100 100 100
+select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+case when variable_value-@c > 0 then 'true' else 'false' end
+true
+# MariaDB: we don't have optimizer_force_index_for_range, but we can use EITS
+# to get the query plan we want.
+set @tmp_use_stat_tables= @@use_stat_tables;
+set use_stat_tables='preferably';
+analyze table linktable persistent for all;
+Table Op Msg_type Msg_text
+test.linktable analyze status Engine-independent statistics collected
+test.linktable analyze status OK
+flush tables;
+explain select * from linktable;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE linktable ALL NULL NULL NULL NULL 10000
+# This must use range(id1_type2), key_len=24
+explain
+select id1, id2, link_type, visibility, data, time, version from linktable
+FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 and time >= 0 and time <= 9223372036854775807 order by time desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE linktable range id1_type2 id1_type2 24 NULL 1000 Using where; Using index
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 and time >= 0 and time <= 9223372036854775807 order by time desc;
+id1 id2 link_type visibility data time version
+100 100 1 1 100 100 100
+select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+case when variable_value-@c > 0 then 'true' else 'false' end
+true
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type3`) where id1 = 100 and time >= 0 and time <= 9223372036854775807 and visibility = 1 order by time desc;
+id1 id2 link_type visibility data time version
+100 100 1 1 100 100 100
+select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+case when variable_value-@c = 0 then 'true' else 'false' end
+true
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type`) where id1 = 100 and link_type = 1 and visibility = 1 and time >= 0 order by time desc;
+id1 id2 link_type visibility data time version
+100 100 1 1 100 100 100
+select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+case when variable_value-@c > 0 then 'true' else 'false' end
+true
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 and time >= 0 order by time desc;
+id1 id2 link_type visibility data time version
+100 100 1 1 100 100 100
+select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+case when variable_value-@c = 0 then 'true' else 'false' end
+true
+## HA_READ_PREFIX_LAST
+# BF len 20
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type`) where id1 = 100 and link_type = 1 and visibility = 1 order by time desc;
+id1 id2 link_type visibility data time version
+100 100 1 1 100 100 100
+select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+case when variable_value-@c > 0 then 'true' else 'false' end
+true
+# BF len 19
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 order by time desc;
+id1 id2 link_type visibility data time version
+100 100 1 1 100 100 100
+select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+case when variable_value-@c = 0 then 'true' else 'false' end
+true
+# BF len 12
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type3`) where id1 = 100 and visibility = 1 order by time desc;
+id1 id2 link_type visibility data time version
+100 100 1 1 100 100 100
+select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+case when variable_value-@c = 0 then 'true' else 'false' end
+true
+DROP TABLE linktable;
+# restart
+#
+# bloom filter prefix is 20 byte
+# Create a key which is longer than that, so that we see that
+# eq_cond_len= slice.size() - 1;
+# doesnt work.
+#
+# indexnr 4
+# kp0 + 4 = 8
+# kp1 + 8 = 16
+# kp2 + 8 = 24 24>20 byte length prefix
+# kp3 + 8 = 28
+create table t1 (
+pk int primary key,
+kp0 int not null,
+kp1 bigint not null,
+kp2 bigint not null,
+kp3 bigint not null,
+key kp12(kp0, kp1, kp2, kp3) comment 'rev:x1'
+) engine=rocksdb;
+insert into t1 values (1, 1,1, 1,1);
+insert into t1 values (10,1,1,0x12FFFFFFFFFF,1);
+insert into t1 values (11,1,1,0x12FFFFFFFFFF,1);
+insert into t1 values (20,2,2,0x12FFFFFFFFFF,1);
+insert into t1 values (21,2,2,0x12FFFFFFFFFF,1);
+# restart
+explain
+select * from t1 where kp0=1 and kp1=1 and kp2=0x12FFFFFFFFFF order by kp3 desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref kp12 kp12 20 const,const,const # Using where; Using index
+show status like '%rocksdb_bloom_filter_prefix%';
+Variable_name Value
+Rocksdb_bloom_filter_prefix_checked 0
+Rocksdb_bloom_filter_prefix_useful 0
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select * from t1 where kp0=1 and kp1=1 and kp2=0x12FFFFFFFFFF order by kp3 desc;
+pk kp0 kp1 kp2 kp3
+11 1 1 20890720927743 1
+10 1 1 20890720927743 1
+show status like '%rocksdb_bloom_filter_prefix%';
+Variable_name Value
+Rocksdb_bloom_filter_prefix_checked 0
+Rocksdb_bloom_filter_prefix_useful 0
+# The following MUST show TRUE:
+select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+case when variable_value-@c = 0 then 'true' else 'false' end
+true
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter4.result b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter4.result
new file mode 100644
index 00000000..c4a1c5f4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter4.result
@@ -0,0 +1,32 @@
+CREATE TABLE t1 (
+`id1` int unsigned NOT NULL DEFAULT '0',
+`id2` int unsigned NOT NULL DEFAULT '0',
+`link_type` int unsigned NOT NULL DEFAULT '0',
+`visibility` tinyint NOT NULL DEFAULT '0',
+`data` varchar(255) NOT NULL DEFAULT '',
+`time` int unsigned NOT NULL DEFAULT '0',
+`version` int unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (id1, link_type, visibility, id2) COMMENT 'rev:cf_link_pk'
+) ENGINE=RocksDB DEFAULT COLLATE=latin1_bin;
+CREATE PROCEDURE select_test()
+BEGIN
+DECLARE id1_cond INT;
+SET id1_cond = 1;
+WHILE id1_cond <= 20000 DO
+SELECT count(*) AS cnt FROM (SELECT id1 FROM t1 FORCE INDEX (PRIMARY) WHERE id1 = id1_cond AND link_type = 1 AND visibility = 1 ORDER BY id2 DESC) AS t INTO @cnt;
+IF @cnt < 1 THEN
+SELECT id1_cond, @cnt;
+END IF;
+SET id1_cond = id1_cond + 1;
+END WHILE;
+END//
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+"Skipping bloom filter"
+SET session rocksdb_skip_bloom_filter_on_read=1;
+CALL select_test();
+"Using bloom filter"
+SET session rocksdb_skip_bloom_filter_on_read=0;
+CALL select_test();
+DROP PROCEDURE select_test;
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter5.result b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter5.result
new file mode 100644
index 00000000..daf4f5e3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter5.result
@@ -0,0 +1,85 @@
+#
+# Issue #809: Wrong query result with bloom filters
+#
+create table t1 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id1, id2, id3, id4) COMMENT 'rev:bf5_1'
+) engine=ROCKSDB;
+create table t2(a int);
+insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t3(seq int);
+insert into t3
+select
+1+ A.a + B.a* 10 + C.a * 100 + D.a * 1000
+from t2 A, t2 B, t2 C, t2 D;
+insert t1
+select
+(seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc"
+from t3;
+set global rocksdb_force_flush_memtable_now=1;
+# Full table scan
+explain
+select * from t1 limit 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 10000
+select * from t1 limit 10;
+id1 id2 id3 id4 id5 value value2
+1000 2000 2000 10000 10000 1000 aaabbbccc
+1000 2000 2000 9999 9999 1000 aaabbbccc
+1000 2000 2000 9998 9998 1000 aaabbbccc
+1000 2000 2000 9997 9997 1000 aaabbbccc
+1000 2000 2000 9996 9996 1000 aaabbbccc
+1000 1999 1999 9995 9995 1000 aaabbbccc
+1000 1999 1999 9994 9994 1000 aaabbbccc
+1000 1999 1999 9993 9993 1000 aaabbbccc
+1000 1999 1999 9992 9992 1000 aaabbbccc
+1000 1999 1999 9991 9991 1000 aaabbbccc
+# An index scan starting from the end of the table:
+explain
+select * from t1 order by id1 desc,id2 desc, id3 desc, id4 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 122 NULL 1
+select * from t1 order by id1 desc,id2 desc, id3 desc, id4 desc limit 1;
+id1 id2 id3 id4 id5 value value2
+1000 2000 2000 10000 10000 1000 aaabbbccc
+create table t4 (
+pk int unsigned not null primary key,
+kp1 int unsigned not null,
+kp2 int unsigned not null,
+col1 int unsigned,
+key(kp1, kp2) comment 'rev:bf5_2'
+) engine=rocksdb;
+insert into t4 values (1, 0xFFFF, 0xFFF, 12345);
+# This must not fail an assert:
+select * from t4 force index(kp1) where kp1=0xFFFFFFFF and kp2<=0xFFFFFFFF order by kp2 desc;
+pk kp1 kp2 col1
+#
+# Issue #881: Issue #809 still occurs for reverse scans on forward cfs
+#
+create table t5 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id1, id2, id3, id4) COMMENT 'bf5_1'
+) engine=ROCKSDB;
+insert into t5 select * from t1;
+set global rocksdb_force_flush_memtable_now=1;
+# An index scan starting from the end of the table:
+explain
+select * from t5 order by id1 desc,id2 desc, id3 desc, id4 desc limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t5 index NULL PRIMARY 122 NULL 1
+select * from t5 order by id1 desc,id2 desc, id3 desc, id4 desc limit 1;
+id1 id2 id3 id4 id5 value value2
+1000 2000 2000 10000 10000 1000 aaabbbccc
+drop table t1,t2,t3,t4,t5;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter_bulk_load.result b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter_bulk_load.result
new file mode 100644
index 00000000..4b02d110
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter_bulk_load.result
@@ -0,0 +1,15 @@
+create table r1 (id bigint primary key, value bigint) engine=rocksdb;
+create table r2 (id bigint, value bigint, primary key (id) comment 'cf2') engine=rocksdb;
+set session rocksdb_bulk_load=1;
+set session rocksdb_bulk_load=0;
+select variable_value into @h from information_schema.global_status where variable_name='rocksdb_block_cache_filter_hit';
+insert into r1 values (100, 100);
+select variable_value-@h from information_schema.global_status where variable_name='rocksdb_block_cache_filter_hit';
+variable_value-@h
+1
+select variable_value into @h from information_schema.global_status where variable_name='rocksdb_block_cache_filter_hit';
+insert into r2 values (100, 100);
+select variable_value-@h from information_schema.global_status where variable_name='rocksdb_block_cache_filter_hit';
+variable_value-@h
+0
+DROP TABLE r1, r2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter_skip.result b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter_skip.result
new file mode 100644
index 00000000..28475630
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter_skip.result
@@ -0,0 +1,2042 @@
+CREATE PROCEDURE bloom_start()
+BEGIN
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+END//
+CREATE PROCEDURE bloom_end()
+BEGIN
+select case when variable_value-@c > 0 then 'true' else 'false' end as checked from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+END//
+create or replace table t1 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id1, id2, id3, id4) ,
+index id2 (id2) ,
+index id2_id1 (id2, id1) ,
+index id2_id3 (id2, id3) ,
+index id2_id4 (id2, id4) ,
+index id2_id3_id1_id4 (id2, id3, id1, id4) ,
+index id3_id2 (id3, id2)
+) engine=ROCKSDB;
+create or replace table t2 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id4) ,
+index id2 (id2) ,
+index id2_id3 (id2, id3) ,
+index id2_id4 (id2, id4) ,
+index id2_id4_id5 (id2, id4, id5) ,
+index id3_id4 (id3, id4) ,
+index id3_id5 (id3, id5)
+) engine=ROCKSDB;
+insert t1
+select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc"
+ from seq_1_to_10000;
+insert t2 select * from t1;
+set global rocksdb_force_flush_memtable_now=1;
+call bloom_start();
+select count(*) from t1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(PRIMARY) where id1 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index(id3_id4) where id3 >= '1';
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=2 and id1=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=24 and id1=12;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=88 and id1=44;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=100 and id1=50;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=428 and id1=214;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=1 and id4=1 and id5=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=23 and id4=115 and id5=115;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=500 and id4=2500 and id5=2500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=601 and id4=3005 and id5=3005;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=1 and id3='1' and id1=1 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36 and id3='36' and id1=18 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124' and id1=62 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=888 and id3='888' and id1=444 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1 and id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=12 and id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=1;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=12;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=23;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=100;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=234;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=234;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=1 and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=23 and id4=115;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=500 and id4=2500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=601 and id4=3005;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='100' and id5=500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='240' and id5=1200;
+count(*)
+1
+call bloom_end();
+checked
+false
+create or replace table t1 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id1, id2, id3, id4) COMMENT 'cf_short_prefix',
+index id2 (id2) COMMENT 'cf_short_prefix',
+index id2_id1 (id2, id1) COMMENT 'cf_short_prefix',
+index id2_id3 (id2, id3) COMMENT 'cf_short_prefix',
+index id2_id4 (id2, id4) COMMENT 'cf_short_prefix',
+index id2_id3_id1_id4 (id2, id3, id1, id4) COMMENT 'cf_short_prefix',
+index id3_id2 (id3, id2) COMMENT 'cf_short_prefix'
+) engine=ROCKSDB;
+create or replace table t2 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id4) COMMENT 'cf_short_prefix',
+index id2 (id2) COMMENT 'cf_short_prefix',
+index id2_id3 (id2, id3) COMMENT 'cf_short_prefix',
+index id2_id4 (id2, id4) COMMENT 'cf_short_prefix',
+index id2_id4_id5 (id2, id4, id5) COMMENT 'cf_short_prefix',
+index id3_id4 (id3, id4) COMMENT 'cf_short_prefix',
+index id3_id5 (id3, id5) COMMENT 'cf_short_prefix'
+) engine=ROCKSDB;
+insert t1
+select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc"
+ from seq_1_to_10000;
+insert t2 select * from t1;
+set global rocksdb_force_flush_memtable_now=1;
+call bloom_start();
+select count(*) from t1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(PRIMARY) where id1 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index(id3_id4) where id3 >= '1';
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=2 and id1=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=24 and id1=12;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=88 and id1=44;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=100 and id1=50;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=428 and id1=214;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=1 and id4=1 and id5=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=23 and id4=115 and id5=115;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=500 and id4=2500 and id5=2500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=601 and id4=3005 and id5=3005;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=1 and id3='1' and id1=1 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36 and id3='36' and id1=18 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124' and id1=62 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=888 and id3='888' and id1=444 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1 and id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=12 and id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=1;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=12;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=23;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=100;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=234;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=234;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=1 and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=23 and id4=115;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=500 and id4=2500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=601 and id4=3005;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='100' and id5=500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='240' and id5=1200;
+count(*)
+1
+call bloom_end();
+checked
+false
+create or replace table t1 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id1, id2, id3, id4) COMMENT 'rev:cf_short_prefix',
+index id2 (id2) COMMENT 'rev:cf_short_prefix',
+index id2_id1 (id2, id1) COMMENT 'rev:cf_short_prefix',
+index id2_id3 (id2, id3) COMMENT 'rev:cf_short_prefix',
+index id2_id4 (id2, id4) COMMENT 'rev:cf_short_prefix',
+index id2_id3_id1_id4 (id2, id3, id1, id4) COMMENT 'rev:cf_short_prefix',
+index id3_id2 (id3, id2) COMMENT 'rev:cf_short_prefix'
+) engine=ROCKSDB;
+create or replace table t2 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id4) COMMENT 'rev:cf_short_prefix',
+index id2 (id2) COMMENT 'rev:cf_short_prefix',
+index id2_id3 (id2, id3) COMMENT 'rev:cf_short_prefix',
+index id2_id4 (id2, id4) COMMENT 'rev:cf_short_prefix',
+index id2_id4_id5 (id2, id4, id5) COMMENT 'rev:cf_short_prefix',
+index id3_id4 (id3, id4) COMMENT 'rev:cf_short_prefix',
+index id3_id5 (id3, id5) COMMENT 'rev:cf_short_prefix'
+) engine=ROCKSDB;
+insert t1
+select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc"
+ from seq_1_to_10000;
+insert t2 select * from t1;
+set global rocksdb_force_flush_memtable_now=1;
+call bloom_start();
+select count(*) from t1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(PRIMARY) where id1 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index(id3_id4) where id3 >= '1';
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=2 and id1=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=24 and id1=12;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=88 and id1=44;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=100 and id1=50;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=428 and id1=214;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=1 and id4=1 and id5=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=23 and id4=115 and id5=115;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=500 and id4=2500 and id5=2500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=601 and id4=3005 and id5=3005;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=1 and id3='1' and id1=1 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36 and id3='36' and id1=18 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124' and id1=62 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=888 and id3='888' and id1=444 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1 and id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=12 and id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=1;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=12;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=23;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=100;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=234;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=234;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=1 and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=23 and id4=115;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=500 and id4=2500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=601 and id4=3005;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='100' and id5=500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='240' and id5=1200;
+count(*)
+1
+call bloom_end();
+checked
+false
+create or replace table t1 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id1, id2, id3, id4) COMMENT 'cf_long_prefix',
+index id2 (id2) COMMENT 'cf_long_prefix',
+index id2_id1 (id2, id1) COMMENT 'cf_long_prefix',
+index id2_id3 (id2, id3) COMMENT 'cf_long_prefix',
+index id2_id4 (id2, id4) COMMENT 'cf_long_prefix',
+index id2_id3_id1_id4 (id2, id3, id1, id4) COMMENT 'cf_long_prefix',
+index id3_id2 (id3, id2) COMMENT 'cf_long_prefix'
+) engine=ROCKSDB;
+create or replace table t2 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id4) COMMENT 'cf_long_prefix',
+index id2 (id2) COMMENT 'cf_long_prefix',
+index id2_id3 (id2, id3) COMMENT 'cf_long_prefix',
+index id2_id4 (id2, id4) COMMENT 'cf_long_prefix',
+index id2_id4_id5 (id2, id4, id5) COMMENT 'cf_long_prefix',
+index id3_id4 (id3, id4) COMMENT 'cf_long_prefix',
+index id3_id5 (id3, id5) COMMENT 'cf_long_prefix'
+) engine=ROCKSDB;
+insert t1
+select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc"
+ from seq_1_to_10000;
+insert t2 select * from t1;
+set global rocksdb_force_flush_memtable_now=1;
+call bloom_start();
+select count(*) from t1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(PRIMARY) where id1 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index(id3_id4) where id3 >= '1';
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=2 and id1=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=24 and id1=12;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=88 and id1=44;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=100 and id1=50;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=428 and id1=214;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=1 and id4=1 and id5=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=23 and id4=115 and id5=115;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=500 and id4=2500 and id5=2500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=601 and id4=3005 and id5=3005;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=1 and id3='1' and id1=1 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36 and id3='36' and id1=18 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124' and id1=62 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=888 and id3='888' and id1=444 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1 and id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=12 and id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=1;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=12;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=23;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=100;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=234;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=234;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=1 and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=23 and id4=115;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=500 and id4=2500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=601 and id4=3005;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='100' and id5=500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='240' and id5=1200;
+count(*)
+1
+call bloom_end();
+checked
+false
+create or replace table t1 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id1, id2, id3, id4) COMMENT 'rev:cf_long_prefix',
+index id2 (id2) COMMENT 'rev:cf_long_prefix',
+index id2_id1 (id2, id1) COMMENT 'rev:cf_long_prefix',
+index id2_id3 (id2, id3) COMMENT 'rev:cf_long_prefix',
+index id2_id4 (id2, id4) COMMENT 'rev:cf_long_prefix',
+index id2_id3_id1_id4 (id2, id3, id1, id4) COMMENT 'rev:cf_long_prefix',
+index id3_id2 (id3, id2) COMMENT 'rev:cf_long_prefix'
+) engine=ROCKSDB;
+create or replace table t2 (
+id1 bigint not null,
+id2 bigint not null,
+id3 varchar(100) not null,
+id4 int not null,
+id5 int not null,
+value bigint,
+value2 varchar(100),
+primary key (id4) COMMENT 'rev:cf_long_prefix',
+index id2 (id2) COMMENT 'rev:cf_long_prefix',
+index id2_id3 (id2, id3) COMMENT 'rev:cf_long_prefix',
+index id2_id4 (id2, id4) COMMENT 'rev:cf_long_prefix',
+index id2_id4_id5 (id2, id4, id5) COMMENT 'rev:cf_long_prefix',
+index id3_id4 (id3, id4) COMMENT 'rev:cf_long_prefix',
+index id3_id5 (id3, id5) COMMENT 'rev:cf_long_prefix'
+) engine=ROCKSDB;
+insert t1
+select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc"
+ from seq_1_to_10000;
+insert t2 select * from t1;
+set global rocksdb_force_flush_memtable_now=1;
+call bloom_start();
+select count(*) from t1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(PRIMARY) where id1 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2 >= 1;
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index(id3_id4) where id3 >= '1';
+count(*)
+10000
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=2 and id1=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=24 and id1=12;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=88 and id1=44;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=100 and id1=50;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=428 and id1=214;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=1 and id4=1 and id5=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=23 and id4=115 and id5=115;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=500 and id4=2500 and id5=2500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=601 and id4=3005 and id5=3005;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=1 and id3='1' and id1=1 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36 and id3='36' and id1=18 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124' and id1=62 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=888 and id3='888' and id1=444 order by id4;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1 and id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=12 and id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=1 and id3='1';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=23 and id3='23';
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=1;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=12;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=23;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=100;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=234;
+count(*)
+10
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=234;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=1 and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=23 and id4=115;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=500 and id4=2500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=601 and id4=3005;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='1' and id4=1;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='12' and id4=60;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=1;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=23;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=345;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=456;
+count(*)
+5
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='100' and id5=500;
+count(*)
+1
+call bloom_end();
+checked
+false
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='240' and id5=1200;
+count(*)
+1
+call bloom_end();
+checked
+false
+create table r1 (id1 bigint, id2 bigint, id3 bigint, v1 int, v2 text, primary key (id1, id2, id3)) engine=rocksdb DEFAULT CHARSET=latin1 collate latin1_bin;
+call bloom_start();
+select * from r1 where id1=1 and id2 in (1) order by id3 asc;
+id1 id2 id3 v1 v2
+1 1 1 1 1
+call bloom_end();
+checked
+false
+call bloom_start();
+select * from r1 where id1=1 and id2 in (1) order by id3 desc;
+id1 id2 id3 v1 v2
+1 1 1 1 1
+call bloom_end();
+checked
+false
+DROP PROCEDURE bloom_start;
+DROP PROCEDURE bloom_end;
+truncate table t1;
+optimize table t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+truncate table t2;
+optimize table t2;
+Table Op Msg_type Msg_text
+test.t2 optimize status OK
+drop table if exists t1;
+drop table if exists t2;
+drop table if exists r1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load.result
new file mode 100644
index 00000000..b8a98efa
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load.result
@@ -0,0 +1,81 @@
+Data will be ordered in ascending order
+CREATE TABLE t1(
+pk CHAR(5),
+a CHAR(30),
+b CHAR(30),
+PRIMARY KEY(pk) COMMENT "cf1",
+KEY(a)
+) ENGINE=ROCKSDB COLLATE 'latin1_bin';
+CREATE TABLE t2(
+pk CHAR(5),
+a CHAR(30),
+b CHAR(30),
+PRIMARY KEY(pk) COMMENT "cf1",
+KEY(a)
+) ENGINE=ROCKSDB COLLATE 'latin1_bin';
+CREATE TABLE t3(
+pk CHAR(5),
+a CHAR(30),
+b CHAR(30),
+PRIMARY KEY(pk) COMMENT "cf1",
+KEY(a)
+) ENGINE=ROCKSDB COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4;
+connect other,localhost,root,,;
+set session transaction isolation level repeatable read;
+start transaction with consistent snapshot;
+select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
+Has opened snapshots
+1
+connection default;
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=
+'cf1={write_buffer_size=8m;target_file_size_base=1m};';
+set rocksdb_bulk_load=1;
+set rocksdb_bulk_load_size=100000;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+pk a b
+LOAD DATA INFILE <input_file> INTO TABLE t2;
+pk a b
+LOAD DATA INFILE <input_file> INTO TABLE t3;
+pk a b
+set rocksdb_bulk_load=0;
+SHOW TABLE STATUS WHERE name LIKE 't%';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
+ANALYZE TABLE t1, t2, t3;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+test.t3 analyze status Engine-independent statistics collected
+test.t3 analyze status OK
+SHOW TABLE STATUS WHERE name LIKE 't%';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
+select count(pk),count(a) from t1;
+count(pk) count(a)
+2500000 2500000
+select count(b) from t1;
+count(b)
+2500000
+select count(pk),count(a) from t2;
+count(pk) count(a)
+2500000 2500000
+select count(b) from t2;
+count(b)
+2500000
+select count(pk),count(a) from t3;
+count(pk) count(a)
+2500000 2500000
+select count(b) from t3;
+count(b)
+2500000
+longfilenamethatvalidatesthatthiswillgetdeleted.bulk_load.tmp
+test.bulk_load.tmp
+# restart
+disconnect other;
+DROP TABLE t1, t2, t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_drop_table.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_drop_table.result
new file mode 100644
index 00000000..4e79d828
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_drop_table.result
@@ -0,0 +1,11 @@
+CREATE TABLE t1 (pk INT, PRIMARY KEY (pk)) ENGINE=ROCKSDB;
+SET rocksdb_bulk_load_allow_unsorted=1;
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES (1);
+connect con1,localhost,root,,;
+DROP TABLE t1;
+connection default;
+disconnect con1;
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1;
+ERROR 42S02: Table 'test.t1' doesn't exist
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_errors.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_errors.result
new file mode 100644
index 00000000..995da9e8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_errors.result
@@ -0,0 +1,100 @@
+CREATE TABLE t1(pk INT, PRIMARY KEY(pk)) ENGINE=ROCKSDB;
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES(10);
+INSERT INTO t1 VALUES(11);
+INSERT INTO t1 VALUES(9);
+ERROR HY000: Rows must be inserted in primary key order during bulk load operation
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1;
+pk
+10
+11
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t1 VALUES(2);
+INSERT INTO t1 VALUES(20);
+INSERT INTO t1 VALUES(21);
+SET rocksdb_bulk_load=0;
+ERROR HY000: Rows inserted during bulk load must not overlap existing rows
+SHOW VARIABLES LIKE 'rocksdb_bulk_load';
+Variable_name Value
+rocksdb_bulk_load OFF
+call mtr.add_suppression('finalizing last SST file while setting bulk loading variable');
+SELECT * FROM t1;
+pk
+10
+11
+FOUND 1 /RocksDB: Error [0-9]+ finalizing last SST file while setting bulk loading variable/ in rocksdb.bulk_load_errors.1.err
+connect con1,localhost,root,,;
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t1 VALUES(2);
+INSERT INTO t1 VALUES(20);
+INSERT INTO t1 VALUES(21);
+connection default;
+disconnect con1;
+SELECT * FROM t1;
+pk
+10
+11
+FOUND 1 /RocksDB: Error [0-9]+ finalizing last SST file while disconnecting/ in rocksdb.bulk_load_errors.2.err
+TRUNCATE TABLE t1;
+SET rocksdb_bulk_load_allow_unsorted=1;
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES(100);
+INSERT INTO t1 VALUES(101);
+INSERT INTO t1 VALUES(99);
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1;
+pk
+99
+100
+101
+TRUNCATE TABLE t1;
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES(201);
+INSERT INTO t1 VALUES(200);
+INSERT INTO t1 VALUES(202);
+INSERT INTO t1 VALUES(201);
+ERROR 23000: Failed to insert the record: the key already exists
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1;
+pk
+200
+201
+202
+SET rocksdb_bulk_load_allow_unsorted=DEFAULT;
+DROP TABLE t1;
+CREATE TABLE t1(c1 INT KEY) ENGINE=ROCKSDB;
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES (),(),();
+ERROR HY000: Rows must be inserted in primary key order during bulk load operation
+SET rocksdb_bulk_load=0;
+DROP TABLE t1;
+SET @orig_table_open_cache=@@global.table_open_cache;
+CREATE TABLE t1(a INT AUTO_INCREMENT, b INT, PRIMARY KEY (a)) ENGINE=ROCKSDB DEFAULT CHARSET=latin1;
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES(13, 0);
+INSERT INTO t1 VALUES(2, 'test 2');
+Warnings:
+Warning 1366 Incorrect integer value: 'test 2' for column `test`.`t1`.`b` at row 1
+INSERT INTO t1 VALUES(@id, @arg04);
+SET @@global.table_open_cache=FALSE;
+Warnings:
+Warning 1292 Truncated incorrect table_open_cache value: '0'
+INSERT INTO t1 VALUES(51479+0.333333333,1);
+DROP TABLE t1;
+SET @@global.table_open_cache=@orig_table_open_cache;
+FOUND 1 /RocksDB: Error [0-9]+ finalizing bulk load while closing handler/ in rocksdb.bulk_load_errors.3.err
+# restart
+CREATE TABLE t1 (pk INT, PRIMARY KEY (pk)) ENGINE=ROCKSDB;
+CREATE TABLE t2 (pk INT, PRIMARY KEY (pk)) ENGINE=ROCKSDB;
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES (1), (2);
+INSERT INTO t2 VALUES (1), (2);
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (3);
+ERROR HY000: Rows inserted during bulk load must not overlap existing rows
+SET rocksdb_bulk_load=0;
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf.result
new file mode 100644
index 00000000..56b1a832
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf.result
@@ -0,0 +1,81 @@
+Data will be ordered in ascending order
+CREATE TABLE t1(
+pk CHAR(5),
+a CHAR(30),
+b CHAR(30),
+PRIMARY KEY(pk) COMMENT "rev:cf1",
+KEY(a)
+) ENGINE=ROCKSDB COLLATE 'latin1_bin';
+CREATE TABLE t2(
+pk CHAR(5),
+a CHAR(30),
+b CHAR(30),
+PRIMARY KEY(pk) COMMENT "rev:cf1",
+KEY(a)
+) ENGINE=ROCKSDB COLLATE 'latin1_bin';
+CREATE TABLE t3(
+pk CHAR(5),
+a CHAR(30),
+b CHAR(30),
+PRIMARY KEY(pk) COMMENT "rev:cf1",
+KEY(a)
+) ENGINE=ROCKSDB COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4;
+connect other,localhost,root,,;
+set session transaction isolation level repeatable read;
+start transaction with consistent snapshot;
+select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
+Has opened snapshots
+1
+connection default;
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=
+'cf1={write_buffer_size=8m;target_file_size_base=1m};';
+set rocksdb_bulk_load=1;
+set rocksdb_bulk_load_size=100000;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+pk a b
+LOAD DATA INFILE <input_file> INTO TABLE t2;
+pk a b
+LOAD DATA INFILE <input_file> INTO TABLE t3;
+pk a b
+set rocksdb_bulk_load=0;
+SHOW TABLE STATUS WHERE name LIKE 't%';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
+ANALYZE TABLE t1, t2, t3;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+test.t3 analyze status Engine-independent statistics collected
+test.t3 analyze status OK
+SHOW TABLE STATUS WHERE name LIKE 't%';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
+select count(pk),count(a) from t1;
+count(pk) count(a)
+2500000 2500000
+select count(b) from t1;
+count(b)
+2500000
+select count(pk),count(a) from t2;
+count(pk) count(a)
+2500000 2500000
+select count(b) from t2;
+count(b)
+2500000
+select count(pk),count(a) from t3;
+count(pk) count(a)
+2500000 2500000
+select count(b) from t3;
+count(b)
+2500000
+longfilenamethatvalidatesthatthiswillgetdeleted.bulk_load.tmp
+test.bulk_load.tmp
+# restart
+disconnect other;
+DROP TABLE t1, t2, t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf_and_data.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf_and_data.result
new file mode 100644
index 00000000..1a260c69
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf_and_data.result
@@ -0,0 +1,81 @@
+Data will be ordered in descending order
+CREATE TABLE t1(
+pk CHAR(5),
+a CHAR(30),
+b CHAR(30),
+PRIMARY KEY(pk) COMMENT "rev:cf1",
+KEY(a)
+) ENGINE=ROCKSDB COLLATE 'latin1_bin';
+CREATE TABLE t2(
+pk CHAR(5),
+a CHAR(30),
+b CHAR(30),
+PRIMARY KEY(pk) COMMENT "rev:cf1",
+KEY(a)
+) ENGINE=ROCKSDB COLLATE 'latin1_bin';
+CREATE TABLE t3(
+pk CHAR(5),
+a CHAR(30),
+b CHAR(30),
+PRIMARY KEY(pk) COMMENT "rev:cf1",
+KEY(a)
+) ENGINE=ROCKSDB COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4;
+connect other,localhost,root,,;
+set session transaction isolation level repeatable read;
+start transaction with consistent snapshot;
+select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
+Has opened snapshots
+1
+connection default;
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=
+'cf1={write_buffer_size=8m;target_file_size_base=1m};';
+set rocksdb_bulk_load=1;
+set rocksdb_bulk_load_size=100000;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+pk a b
+LOAD DATA INFILE <input_file> INTO TABLE t2;
+pk a b
+LOAD DATA INFILE <input_file> INTO TABLE t3;
+pk a b
+set rocksdb_bulk_load=0;
+SHOW TABLE STATUS WHERE name LIKE 't%';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
+ANALYZE TABLE t1, t2, t3;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+test.t3 analyze status Engine-independent statistics collected
+test.t3 analyze status OK
+SHOW TABLE STATUS WHERE name LIKE 't%';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
+select count(pk),count(a) from t1;
+count(pk) count(a)
+2500000 2500000
+select count(b) from t1;
+count(b)
+2500000
+select count(pk),count(a) from t2;
+count(pk) count(a)
+2500000 2500000
+select count(b) from t2;
+count(b)
+2500000
+select count(pk),count(a) from t3;
+count(pk) count(a)
+2500000 2500000
+select count(b) from t3;
+count(b)
+2500000
+longfilenamethatvalidatesthatthiswillgetdeleted.bulk_load.tmp
+test.bulk_load.tmp
+# restart
+disconnect other;
+DROP TABLE t1, t2, t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_data.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_data.result
new file mode 100644
index 00000000..e216fb1c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_data.result
@@ -0,0 +1,81 @@
+Data will be ordered in descending order
+CREATE TABLE t1(
+pk CHAR(5),
+a CHAR(30),
+b CHAR(30),
+PRIMARY KEY(pk) COMMENT "cf1",
+KEY(a)
+) ENGINE=ROCKSDB COLLATE 'latin1_bin';
+CREATE TABLE t2(
+pk CHAR(5),
+a CHAR(30),
+b CHAR(30),
+PRIMARY KEY(pk) COMMENT "cf1",
+KEY(a)
+) ENGINE=ROCKSDB COLLATE 'latin1_bin';
+CREATE TABLE t3(
+pk CHAR(5),
+a CHAR(30),
+b CHAR(30),
+PRIMARY KEY(pk) COMMENT "cf1",
+KEY(a)
+) ENGINE=ROCKSDB COLLATE 'latin1_bin' PARTITION BY KEY() PARTITIONS 4;
+connect other,localhost,root,,;
+set session transaction isolation level repeatable read;
+start transaction with consistent snapshot;
+select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
+Has opened snapshots
+1
+connection default;
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=
+'cf1={write_buffer_size=8m;target_file_size_base=1m};';
+set rocksdb_bulk_load=1;
+set rocksdb_bulk_load_size=100000;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+pk a b
+LOAD DATA INFILE <input_file> INTO TABLE t2;
+pk a b
+LOAD DATA INFILE <input_file> INTO TABLE t3;
+pk a b
+set rocksdb_bulk_load=0;
+SHOW TABLE STATUS WHERE name LIKE 't%';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
+ANALYZE TABLE t1, t2, t3;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+test.t3 analyze status Engine-independent statistics collected
+test.t3 analyze status OK
+SHOW TABLE STATUS WHERE name LIKE 't%';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
+t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
+select count(pk),count(a) from t1;
+count(pk) count(a)
+2500000 2500000
+select count(b) from t1;
+count(b)
+2500000
+select count(pk),count(a) from t2;
+count(pk) count(a)
+2500000 2500000
+select count(b) from t2;
+count(b)
+2500000
+select count(pk),count(a) from t3;
+count(pk) count(a)
+2500000 2500000
+select count(b) from t3;
+count(b)
+2500000
+longfilenamethatvalidatesthatthiswillgetdeleted.bulk_load.tmp
+test.bulk_load.tmp
+# restart
+disconnect other;
+DROP TABLE t1, t2, t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_sk.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_sk.result
new file mode 100644
index 00000000..42f820a2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_sk.result
@@ -0,0 +1,229 @@
+SET rocksdb_bulk_load_size=15;
+CREATE TABLE t4 (a INT, b INT, c INT,
+PRIMARY KEY (a),
+KEY (b),
+KEY (c) COMMENT "rev:cf") ENGINE=ROCKSDB;
+CREATE TABLE t3 (a INT, b INT, c INT,
+PRIMARY KEY (a),
+KEY (b),
+KEY (c) COMMENT "rev:cf") ENGINE=ROCKSDB;
+CREATE TABLE t2 (a INT, b INT, c INT,
+PRIMARY KEY (a),
+KEY (b),
+KEY (c) COMMENT "rev:cf") ENGINE=ROCKSDB;
+CREATE TABLE t1 (a INT, b INT, c INT,
+PRIMARY KEY (a),
+KEY (b),
+KEY (c) COMMENT "rev:cf") ENGINE=ROCKSDB;
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 SELECT * FROM t3 FORCE INDEX (PRIMARY) ORDER BY a;
+SELECT count(*) FROM t1 FORCE INDEX (PRIMARY);
+count(*)
+0
+SELECT count(*) FROM t1 FORCE INDEX (b);
+count(*)
+10
+SELECT count(*) FROM t1 FORCE INDEX (c);
+count(*)
+10
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b c
+-9 11 11
+-7 9 9
+-5 7 7
+-3 5 5
+-1 3 3
+2 0 0
+4 -2 -2
+6 -4 -4
+8 -6 -6
+10 -8 -8
+SELECT b FROM t1 FORCE INDEX (b);
+b
+-8
+-6
+-4
+-2
+0
+3
+5
+7
+9
+11
+SELECT c FROM t1 FORCE INDEX (c);
+c
+-8
+-6
+-4
+-2
+0
+3
+5
+7
+9
+11
+Checksums should match
+CHECKSUM TABLE t3;
+Table Checksum
+test.t3 3862424802
+CHECKSUM TABLE t1;
+Table Checksum
+test.t1 3862424802
+SET rocksdb_bulk_load_allow_sk=1;
+SET rocksdb_bulk_load=1;
+INSERT INTO t4 SELECT * FROM t3 FORCE INDEX (PRIMARY) ORDER BY a;
+SELECT count(*) FROM t4 FORCE INDEX (PRIMARY);
+count(*)
+0
+SELECT count(*) FROM t4 FORCE INDEX (b);
+count(*)
+0
+SELECT count(*) FROM t4 FORCE INDEX (c);
+count(*)
+0
+SET rocksdb_bulk_load=0;
+SELECT * FROM t4 FORCE INDEX (PRIMARY);
+a b c
+-9 11 11
+-7 9 9
+-5 7 7
+-3 5 5
+-1 3 3
+2 0 0
+4 -2 -2
+6 -4 -4
+8 -6 -6
+10 -8 -8
+SELECT b FROM t4 FORCE INDEX (b);
+b
+-8
+-6
+-4
+-2
+0
+3
+5
+7
+9
+11
+SELECT c FROM t4 FORCE INDEX (c);
+c
+-8
+-6
+-4
+-2
+0
+3
+5
+7
+9
+11
+Checksums should match
+CHECKSUM TABLE t3;
+Table Checksum
+test.t3 3862424802
+CHECKSUM TABLE t4;
+Table Checksum
+test.t4 3862424802
+SET rocksdb_bulk_load_allow_unsorted=1;
+SET rocksdb_bulk_load_allow_sk=1;
+SET rocksdb_bulk_load=1;
+INSERT INTO t2 SELECT * FROM t3 WHERE b >= 0 ORDER BY b;
+INSERT INTO t2 SELECT * FROM t3 WHERE b < 0 ORDER BY b;
+SELECT count(*) FROM t2 FORCE INDEX (PRIMARY);
+count(*)
+0
+SELECT count(*) FROM t2 FORCE INDEX (b);
+count(*)
+0
+SELECT count(*) FROM t2 FORCE INDEX (c);
+count(*)
+0
+SELECT count(*) FROM t2 FORCE INDEX (PRIMARY);
+count(*)
+0
+SELECT count(*) FROM t2 FORCE INDEX (b);
+count(*)
+0
+SELECT count(*) FROM t2 FORCE INDEX (c);
+count(*)
+0
+SET rocksdb_bulk_load=0;
+SELECT * FROM t2 FORCE INDEX (PRIMARY);
+a b c
+-19 21 21
+-17 19 19
+-15 17 17
+-13 15 15
+-11 13 13
+-9 11 11
+-7 9 9
+-5 7 7
+-3 5 5
+-1 3 3
+2 0 0
+4 -2 -2
+6 -4 -4
+8 -6 -6
+10 -8 -8
+12 -10 -10
+14 -12 -12
+16 -14 -14
+18 -16 -16
+20 -18 -18
+SELECT b FROM t2 FORCE INDEX (b);
+b
+-18
+-16
+-14
+-12
+-10
+-8
+-6
+-4
+-2
+0
+3
+5
+7
+9
+11
+13
+15
+17
+19
+21
+SELECT c FROM t2 FORCE INDEX (c);
+c
+-18
+-16
+-14
+-12
+-10
+-8
+-6
+-4
+-2
+0
+3
+5
+7
+9
+11
+13
+15
+17
+19
+21
+Checksums should match
+CHECKSUM TABLE t3;
+Table Checksum
+test.t3 1495594118
+CHECKSUM TABLE t2;
+Table Checksum
+test.t2 1495594118
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted.result
new file mode 100644
index 00000000..63d07a25
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted.result
@@ -0,0 +1,111 @@
+SET rocksdb_bulk_load_size=3;
+SET rocksdb_bulk_load_allow_unsorted=1;
+CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a) COMMENT "cf1")
+ENGINE=ROCKSDB;
+SET rocksdb_bulk_load=1;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+-3 5
+-1 3
+2 0
+4 -2
+6 -4
+DROP TABLE t1;
+CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a) COMMENT "cf1", KEY(b))
+ENGINE=ROCKSDB;
+SET rocksdb_bulk_load=1;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+-3 5
+-1 3
+2 0
+4 -2
+6 -4
+DROP TABLE t1;
+CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a) COMMENT "cf1")
+ENGINE=ROCKSDB;
+CREATE TABLE t2(a INT, b INT, PRIMARY KEY(a) COMMENT "cf1")
+ENGINE=ROCKSDB;
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t2 VALUES (1,1);
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+1 1
+INSERT INTO t1 VALUES (2,2);
+SELECT * FROM t2 FORCE INDEX (PRIMARY);
+a b
+1 1
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+1 1
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+1 1
+2 2
+DROP TABLE t1, t2;
+CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a) COMMENT "cf1")
+ENGINE=ROCKSDB;
+CREATE TABLE t2(a INT, b INT, PRIMARY KEY(b) COMMENT "cf1")
+ENGINE=ROCKSDB;
+CREATE TABLE t3(a INT, b INT, PRIMARY KEY(a) COMMENT "cf1")
+ENGINE=ROCKSDB PARTITION BY KEY() PARTITIONS 4;
+connect other,localhost,root,,;
+set session transaction isolation level repeatable read;
+start transaction with consistent snapshot;
+select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
+Has opened snapshots
+1
+connection default;
+set rocksdb_bulk_load=1;
+set rocksdb_bulk_load_size=100000;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+LOAD DATA INFILE <input_file> INTO TABLE t2;
+LOAD DATA INFILE <input_file> INTO TABLE t3;
+set rocksdb_bulk_load=0;
+SHOW TABLE STATUS WHERE name LIKE 't%';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
+t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
+t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned 0 N
+ANALYZE TABLE t1, t2, t3;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+test.t3 analyze status Engine-independent statistics collected
+test.t3 analyze status OK
+SHOW TABLE STATUS WHERE name LIKE 't%';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
+t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
+t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned 0 N
+select count(a),count(b) from t1;
+count(a) count(b)
+2500000 2500000
+select count(a),count(b) from t2;
+count(a) count(b)
+2500000 2500000
+select count(a),count(b) from t3;
+count(a) count(b)
+2500000 2500000
+SELECT * FROM t1 FORCE INDEX (PRIMARY) LIMIT 3;
+a b
+-2499998 2500000
+-2499996 2499998
+-2499994 2499996
+SELECT * FROM t2 FORCE INDEX (PRIMARY) LIMIT 3;
+a b
+2499999 -2499997
+2499997 -2499995
+2499995 -2499993
+disconnect other;
+DROP TABLE t1, t2, t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted_errors.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted_errors.result
new file mode 100644
index 00000000..d8e5b92e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted_errors.result
@@ -0,0 +1,4 @@
+SET rocksdb_bulk_load=1;
+SET rocksdb_bulk_load_allow_unsorted=1;
+ERROR HY000: Error when executing command SET: Cannot change this setting while bulk load is enabled
+SET rocksdb_bulk_load=0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted_rev.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted_rev.result
new file mode 100644
index 00000000..a6e0793f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted_rev.result
@@ -0,0 +1,111 @@
+SET rocksdb_bulk_load_size=3;
+SET rocksdb_bulk_load_allow_unsorted=1;
+CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a) COMMENT "rev:cf1")
+ENGINE=ROCKSDB;
+SET rocksdb_bulk_load=1;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+6 -4
+4 -2
+2 0
+-1 3
+-3 5
+DROP TABLE t1;
+CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a) COMMENT "rev:cf1", KEY(b))
+ENGINE=ROCKSDB;
+SET rocksdb_bulk_load=1;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+6 -4
+4 -2
+2 0
+-1 3
+-3 5
+DROP TABLE t1;
+CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a) COMMENT "rev:cf1")
+ENGINE=ROCKSDB;
+CREATE TABLE t2(a INT, b INT, PRIMARY KEY(a) COMMENT "rev:cf1")
+ENGINE=ROCKSDB;
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t2 VALUES (1,1);
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+1 1
+INSERT INTO t1 VALUES (2,2);
+SELECT * FROM t2 FORCE INDEX (PRIMARY);
+a b
+1 1
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+1 1
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+2 2
+1 1
+DROP TABLE t1, t2;
+CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a) COMMENT "rev:cf1")
+ENGINE=ROCKSDB;
+CREATE TABLE t2(a INT, b INT, PRIMARY KEY(b) COMMENT "rev:cf1")
+ENGINE=ROCKSDB;
+CREATE TABLE t3(a INT, b INT, PRIMARY KEY(a) COMMENT "rev:cf1")
+ENGINE=ROCKSDB PARTITION BY KEY() PARTITIONS 4;
+connect other,localhost,root,,;
+set session transaction isolation level repeatable read;
+start transaction with consistent snapshot;
+select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
+Has opened snapshots
+1
+connection default;
+set rocksdb_bulk_load=1;
+set rocksdb_bulk_load_size=100000;
+LOAD DATA INFILE <input_file> INTO TABLE t1;
+LOAD DATA INFILE <input_file> INTO TABLE t2;
+LOAD DATA INFILE <input_file> INTO TABLE t3;
+set rocksdb_bulk_load=0;
+SHOW TABLE STATUS WHERE name LIKE 't%';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
+t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
+t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned 0 N
+ANALYZE TABLE t1, t2, t3;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+test.t3 analyze status Engine-independent statistics collected
+test.t3 analyze status OK
+SHOW TABLE STATUS WHERE name LIKE 't%';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
+t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
+t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned 0 N
+select count(a),count(b) from t1;
+count(a) count(b)
+2500000 2500000
+select count(a),count(b) from t2;
+count(a) count(b)
+2500000 2500000
+select count(a),count(b) from t3;
+count(a) count(b)
+2500000 2500000
+SELECT * FROM t1 FORCE INDEX (PRIMARY) LIMIT 3;
+a b
+2499999 -2499997
+2499997 -2499995
+2499995 -2499993
+SELECT * FROM t2 FORCE INDEX (PRIMARY) LIMIT 3;
+a b
+-2499998 2500000
+-2499996 2499998
+-2499994 2499996
+disconnect other;
+DROP TABLE t1, t2, t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bypass_select_basic.result b/storage/rocksdb/mysql-test/rocksdb/r/bypass_select_basic.result
new file mode 100644
index 00000000..1f687dfe
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bypass_select_basic.result
@@ -0,0 +1,693 @@
+CREATE TABLE `link_table` (
+`id1` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+`id1_type` int(10) unsigned NOT NULL DEFAULT '0' ,
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0' ,
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+`visibility` tinyint(3) NOT NULL DEFAULT '0' ,
+`data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '' ,
+`time` int(10) unsigned NOT NULL DEFAULT '0' ,
+`version` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+PRIMARY KEY (`link_type` , `id1` , `id2`) COMMENT 'cf_link' ,
+KEY `id1_type` (`id1` , `link_type` , `visibility` , `time` , `id2` ,
+`version` , `data`) COMMENT 'rev:cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+CREATE TABLE `link_table2` (
+`id1` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+`id1_type` int(10) unsigned NOT NULL DEFAULT '0' ,
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0' ,
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+`visibility` tinyint(3) NOT NULL DEFAULT '0' ,
+`data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '' ,
+`time` int(10) unsigned NOT NULL DEFAULT '0' ,
+`version` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+PRIMARY KEY (`link_type` , `id1` , `id2`)
+COMMENT 'cf_link' ,
+KEY `id1_type` (`id1` , `link_type` , `visibility` , `time` , `id2` ,
+`version` , `data`) COMMENT 'cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=9;
+insert into link_table values (1, 1, 1, 2, 3, 4, 'a10', 10, 125);
+insert into link_table values (1, 1, 2, 2, 3, 3, 'a10', 10, 125);
+insert into link_table values (1, 1, 3, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (1, 1, 4, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (1, 1, 5, 2, 3, 3, 'a12', 12, 125);
+insert into link_table values (1, 1, 6, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (1, 1, 7, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (1, 1, 8, 2, 3, 4, 'a13', 13, 125);
+insert into link_table values (1, 1, 9, 2, 3, 4, 'a14', 14, 125);
+insert into link_table values (1, 1, 10, 2, 3, 4, 'a15', 15, 125);
+insert into link_table values (2, 1, 1, 2, 3, 4, 'a10', 10, 125);
+insert into link_table values (2, 1, 2, 2, 3, 4, 'a10', 10, 125);
+insert into link_table values (2, 1, 3, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (2, 1, 4, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (2, 1, 5, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 6, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 7, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 8, 2, 3, 4, 'a13', 13, 125);
+insert into link_table values (2, 1, 9, 2, 3, 4, 'a14', 14, 125);
+insert into link_table values (2, 1, 10, 2, 3, 4, 'a15', 15, 125);
+insert into link_table values (2, 1, 1, 2, 4, 4, 'a10', 10, 125);
+insert into link_table values (2, 1, 2, 2, 4, 4, 'a10', 10, 125);
+insert into link_table values (2, 1, 3, 2, 4, 4, 'a11', 11, 125);
+insert into link_table values (2, 1, 4, 2, 4, 4, 'a11', 11, 125);
+insert into link_table values (2, 1, 5, 2, 4, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 6, 2, 4, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 7, 2, 4, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 8, 2, 4, 4, 'a13', 13, 125);
+insert into link_table values (2, 1, 9, 2, 4, 4, 'a14', 14, 125);
+insert into link_table values (2, 1, 10, 2, 4, 4, 'a15', 15, 125);
+insert into link_table values (3, 1, 10, 2, 3, 4, 'a10', 10, 125);
+insert into link_table values (3, 1, 9, 2, 3, 4, 'a10', 10, 125);
+insert into link_table values (3, 1, 8, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (3, 1, 7, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (3, 1, 6, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (3, 1, 5, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (3, 1, 4, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (3, 1, 3, 2, 3, 4, 'a13', 13, 125);
+insert into link_table values (3, 1, 2, 2, 3, 4, 'a14', 14, 125);
+insert into link_table values (3, 1, 1, 2, 3, 4, 'a15', 15, 125);
+insert into link_table values (9, 1, 9, 2, 5, 6, '0 ', 10, 125);
+insert into link_table values (9, 1, 8, 2, 5, 6, '01 ', 11, 125);
+insert into link_table values (9, 1, 7, 2, 5, 6, '012 ', 11, 125);
+insert into link_table values (9, 1, 6, 2, 5, 6, '0123 ', 12, 125);
+insert into link_table values (9, 1, 5, 2, 5, 6, '01234 ', 12, 125);
+insert into link_table values (9, 1, 4, 2, 5, 6, '012345 ', 12, 125);
+insert into link_table values (9, 1, 3, 2, 5, 6, '0123456 ', 13, 125);
+insert into link_table values (9, 1, 2, 2, 5, 6, '01234567 ', 14, 125);
+insert into link_table values (9, 1, 1, 2, 5, 6, '012345678 ', 15, 125);
+insert into link_table values (9, 1, 0, 2, 5, 6, '0123456789 ', 15, 125);
+insert into link_table2 select * from link_table;
+CREATE TABLE `id_table` (
+`id` bigint(20) NOT NULL DEFAULT '0',
+`type` int(11) NOT NULL DEFAULT '0',
+`row_created_time` int(11) NOT NULL DEFAULT '0',
+`hash_key` varchar(255) NOT NULL DEFAULT '',
+`is_deleted` tinyint(4) DEFAULT '0',
+PRIMARY KEY (`id`),
+KEY `type_id` (`type`,`id`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED
+KEY_BLOCK_SIZE=8;
+insert into id_table values (1, 1, 10, '111', 0);
+insert into id_table values (2, 1, 10, '111', 1);
+insert into id_table values (3, 1, 10, '111', 0);
+insert into id_table values (4, 1, 10, '111', 1);
+insert into id_table values (5, 1, 10, '111', 0);
+insert into id_table values (6, 1, 10, '111', 1);
+insert into id_table values (7, 1, 10, '111', 0);
+insert into id_table values (8, 1, 10, '111', 1);
+insert into id_table values (9, 1, 10, '111', 0);
+insert into id_table values (10, 1, 10, '111', 1);
+CREATE TABLE `node_table` (
+`id` bigint(20) unsigned NOT NULL DEFAULT '0',
+`type` int(10) unsigned NOT NULL DEFAULT '0',
+`version` bigint(20) unsigned NOT NULL DEFAULT '0',
+`update_time` int(10) unsigned NOT NULL DEFAULT '0',
+`data` mediumtext COLLATE latin1_bin NOT NULL,
+PRIMARY KEY (`type`,`id`) COMMENT 'cf_node_type_id',
+KEY `id` (`id`) COMMENT 'cf_node'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+insert into node_table values (1, 1, 1, 10, 'data');
+insert into node_table values (2, 1, 1, 10, 'data');
+insert into node_table values (3, 1, 1, 10, 'data');
+insert into node_table values (4, 1, 1, 10, 'data');
+insert into node_table values (5, 1, 1, 10, 'data');
+insert into node_table values (6, 1, 1, 10, 'data');
+insert into node_table values (7, 1, 1, 10, 'data');
+insert into node_table values (8, 1, 1, 10, 'data');
+insert into node_table values (9, 1, 1, 10, 'data');
+insert into node_table values (10, 1, 1, 10, 'data');
+CREATE TABLE `count_table` (
+`id` bigint(20) unsigned NOT NULL DEFAULT '0',
+`type` int(10) unsigned NOT NULL DEFAULT '0',
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+`count` int(10) unsigned NOT NULL DEFAULT '0',
+`time` int(10) unsigned NOT NULL DEFAULT '0',
+`version` bigint(20) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`id`,`link_type`) COMMENT 'cf_count_table'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+insert into count_table values (2, 1, 1, 1, 10, 20);
+insert into count_table values (3, 1, 1, 1, 10, 20);
+insert into count_table values (4, 1, 1, 1, 10, 20);
+insert into count_table values (5, 1, 1, 1, 10, 20);
+insert into count_table values (6, 1, 1, 1, 10, 20);
+insert into count_table values (7, 1, 1, 1, 10, 20);
+insert into count_table values (8, 1, 1, 1, 10, 20);
+insert into count_table values (9, 1, 1, 1, 10, 20);
+insert into count_table values (10, 1, 1, 1, 10, 20);
+CREATE TABLE `link_table5` (
+`id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+`visibility` tinyint(3) NOT NULL DEFAULT '0',
+`data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '',
+`time` int(10) unsigned NOT NULL DEFAULT '0',
+`version` bigint(20) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+insert into link_table5 values (1, 1, 2, 2, 1, 1, 'data12', 1, 1);
+insert into link_table5 values (1, 1, 3, 2, 1, 2, 'data13', 1, 1);
+insert into link_table5 values (1, 1, 4, 2, 1, 2, 'data14', 1, 1);
+insert into link_table5 values (1, 1, 5, 2, 1, 1, 'data15', 1, 1);
+insert into link_table5 values (2, 1, 1, 2, 1, 1, 'data21', 1, 1);
+insert into link_table5 values (2, 1, 2, 2, 1, 1, 'data22', 1, 1);
+insert into link_table5 values (2, 1, 3, 2, 1, 1, 'data32', 1, 1);
+CREATE TABLE `link_table3` (
+`id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+`visibility` tinyint(4) NOT NULL DEFAULT '0',
+`data` text COLLATE latin1_bin NOT NULL,
+`time` int(10) unsigned NOT NULL DEFAULT '0',
+`version` bigint(20) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link',
+KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`id2`,`version`)
+COMMENT 'rev:cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+insert into link_table3 values (1, 1, 2, 2, 1, 1, 'data12', 1, 1);
+insert into link_table3 values (1, 1, 3, 2, 1, 2, 'data13', 1, 1);
+insert into link_table3 values (1, 1, 4, 2, 1, 2, 'data14', 1, 1);
+insert into link_table3 values (1, 1, 5, 2, 1, 1, 'data15', 1, 1);
+insert into link_table3 values (2, 1, 1, 2, 1, 1, 'data21', 1, 1);
+insert into link_table3 values (2, 1, 2, 2, 1, 1, 'data22', 1, 1);
+insert into link_table3 values (2, 1, 3, 2, 1, 1, 'data32', 1, 1);
+CREATE TABLE `link_table6` (
+`id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+`visibility` tinyint(4) NOT NULL DEFAULT '0',
+`data` text COLLATE latin1_bin NOT NULL,
+`time` int(10) unsigned NOT NULL DEFAULT '0',
+`version` bigint(20) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link',
+KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`id2`,`version`,
+`data`(255)) COMMENT 'rev:cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+insert into link_table6 values (1, 1, 2, 2, 1, 1,
+'data12_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (1, 1, 3, 2, 1, 2,
+'data13_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (1, 1, 4, 2, 1, 2,
+'data14_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (1, 1, 5, 2, 1, 1,
+'data15_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (2, 1, 1, 2, 1, 1,
+'data21_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (2, 1, 2, 2, 1, 1,
+'data22_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (2, 1, 3, 2, 1, 1,
+'data32_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+CREATE TABLE `link_table4` (
+`id1` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
+`raw_key` text COLLATE latin1_bin,
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+`visibility` tinyint(3) NOT NULL DEFAULT '0',
+`data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '',
+`time` int(10) unsigned NOT NULL DEFAULT '0',
+`version` bigint(20) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link',
+KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`id2`,`version`,`data`)
+COMMENT 'rev:cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+insert into link_table4 values ('a1', "rk1", 2, 2, 1, 1, 'data12', 1, 1);
+insert into link_table4 values ('a1', "rk2", 3, 2, 1, 2, 'data13', 1, 1);
+insert into link_table4 values ('a1', "rk3", 4, 2, 1, 2, 'data14', 1, 1);
+insert into link_table4 values ('a1', "rk4", 5, 2, 1, 1, 'data15', 1, 1);
+insert into link_table4 values ('b1', "rk5", 1, 2, 1, 1, 'data21', 1, 1);
+insert into link_table4 values ('b1', "rk6", 2, 2, 1, 1, 'data22', 1, 1);
+insert into link_table4 values ('b1', "rk7", 3, 2, 1, 1, 'data32', 1, 1);
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+ no_bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+bypassabc*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /* +bypassabc*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*aaaaaaaaabbbbbbbbb*/ id1,id2,id1_type,id2_type,data,version
+from link_table WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+b*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+byp*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+bypw*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*-b*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /**/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+# Point query
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2 IN (2, 3, 4) and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+1 3 1 2 a11 125
+1 4 1 2 a11 125
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2 IN (2) and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1 IN (1) and id2 IN (2) and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1 IN (1, 2) and id2 IN (2, 3, 4) and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+1 3 1 2 a11 125
+1 4 1 2 a11 125
+2 2 1 2 a10 125
+2 3 1 2 a11 125
+2 4 1 2 a11 125
+# Prefix range query
+# Prefix range query with SK
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 3 AND time = 10
+ORDER BY TIME DESC LIMIT 10;
+id1 id2 link_type visibility data time version
+1 2 3 3 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 3 AND time = 10
+ORDER BY TIME ASC LIMIT 10;
+id1 id2 link_type visibility data time version
+1 2 3 3 a10 10 125
+# Prefix range query with SK with limits
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+1 4 3 4 a11 11 125
+1 3 3 4 a11 11 125
+1 1 3 4 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 10;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+1 4 3 4 a11 11 125
+1 3 3 4 a11 11 125
+1 1 3 4 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 5;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 0;
+id1 id2 link_type visibility data time version
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 0,10;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+1 4 3 4 a11 11 125
+1 3 3 4 a11 11 125
+1 1 3 4 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 0,5;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 0,1;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1,0;
+id1 id2 link_type visibility data time version
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1,10;
+id1 id2 link_type visibility data time version
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+1 4 3 4 a11 11 125
+1 3 3 4 a11 11 125
+1 1 3 4 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1,5;
+id1 id2 link_type visibility data time version
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+1 4 3 4 a11 11 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1,1;
+id1 id2 link_type visibility data time version
+1 9 3 4 a14 14 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1,0;
+id1 id2 link_type visibility data time version
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 5,10;
+id1 id2 link_type visibility data time version
+1 4 3 4 a11 11 125
+1 3 3 4 a11 11 125
+1 1 3 4 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 5,5;
+id1 id2 link_type visibility data time version
+1 4 3 4 a11 11 125
+1 3 3 4 a11 11 125
+1 1 3 4 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 5,1;
+id1 id2 link_type visibility data time version
+1 4 3 4 a11 11 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 5,0;
+id1 id2 link_type visibility data time version
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 10,10;
+id1 id2 link_type visibility data time version
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 10,5;
+id1 id2 link_type visibility data time version
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 10,1;
+id1 id2 link_type visibility data time version
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 10,0;
+id1 id2 link_type visibility data time version
+# Prefix range query with PK
+SELECT /*+ bypass */ id1, id2, link_type FROM link_table FORCE INDEX (PRIMARY)
+WHERE link_type=3 and id1=1 ORDER BY id2 DESC;
+id1 id2 link_type
+1 10 3
+1 9 3
+1 8 3
+1 7 3
+1 6 3
+1 5 3
+1 4 3
+1 3 3
+1 2 3
+1 1 3
+SELECT /*+ bypass */ id1, id2, link_type FROM link_table FORCE INDEX (PRIMARY)
+WHERE link_type=3 and id1=1 ORDER BY id2 ASC;
+id1 id2 link_type
+1 1 3
+1 2 3
+1 3 3
+1 4 3
+1 5 3
+1 6 3
+1 7 3
+1 8 3
+1 9 3
+1 10 3
+# Prefix range query with PK + value
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (PRIMARY)
+WHERE link_type=3 and id1=1 ORDER BY id2 DESC;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+1 5 3 3 a12 12 125
+1 4 3 4 a11 11 125
+1 3 3 4 a11 11 125
+1 2 3 3 a10 10 125
+1 1 3 4 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (PRIMARY)
+WHERE link_type=3 and id1=1 ORDER BY id2 ASC;
+id1 id2 link_type visibility data time version
+1 1 3 4 a10 10 125
+1 2 3 3 a10 10 125
+1 3 3 4 a11 11 125
+1 4 3 4 a11 11 125
+1 5 3 3 a12 12 125
+1 6 3 4 a12 12 125
+1 7 3 4 a12 12 125
+1 8 3 4 a13 13 125
+1 9 3 4 a14 14 125
+1 10 3 4 a15 15 125
+# Transaction
+BEGIN;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+UPDATE link_table set data="bcd" WHERE id1=1 and id2=2 and link_type = 3;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 bcd 125
+COMMIT;
+BEGIN;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 bcd 125
+UPDATE link_table set data="cde" WHERE id1=1 and id2=2 and link_type = 3;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 cde 125
+ROLLBACK;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 bcd 125
+# Data types
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3";
+id1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3" AND id1="1";
+id1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3" AND id1=True;
+id1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3" AND id1=b'1';
+id1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3" AND id1=x'01';
+id1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3" AND id1=NULL;
+id1
+DROP TABLE count_table;
+DROP TABLE link_table;
+DROP TABLE link_table3;
+DROP TABLE link_table2;
+DROP TABLE id_table;
+DROP TABLE node_table;
+DROP TABLE link_table5;
+DROP TABLE link_table6;
+DROP TABLE link_table4;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bypass_select_basic_bloom.result b/storage/rocksdb/mysql-test/rocksdb/r/bypass_select_basic_bloom.result
new file mode 100644
index 00000000..1f687dfe
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bypass_select_basic_bloom.result
@@ -0,0 +1,693 @@
+CREATE TABLE `link_table` (
+`id1` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+`id1_type` int(10) unsigned NOT NULL DEFAULT '0' ,
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0' ,
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+`visibility` tinyint(3) NOT NULL DEFAULT '0' ,
+`data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '' ,
+`time` int(10) unsigned NOT NULL DEFAULT '0' ,
+`version` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+PRIMARY KEY (`link_type` , `id1` , `id2`) COMMENT 'cf_link' ,
+KEY `id1_type` (`id1` , `link_type` , `visibility` , `time` , `id2` ,
+`version` , `data`) COMMENT 'rev:cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+CREATE TABLE `link_table2` (
+`id1` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+`id1_type` int(10) unsigned NOT NULL DEFAULT '0' ,
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0' ,
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+`visibility` tinyint(3) NOT NULL DEFAULT '0' ,
+`data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '' ,
+`time` int(10) unsigned NOT NULL DEFAULT '0' ,
+`version` bigint(20) unsigned NOT NULL DEFAULT '0' ,
+PRIMARY KEY (`link_type` , `id1` , `id2`)
+COMMENT 'cf_link' ,
+KEY `id1_type` (`id1` , `link_type` , `visibility` , `time` , `id2` ,
+`version` , `data`) COMMENT 'cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=9;
+insert into link_table values (1, 1, 1, 2, 3, 4, 'a10', 10, 125);
+insert into link_table values (1, 1, 2, 2, 3, 3, 'a10', 10, 125);
+insert into link_table values (1, 1, 3, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (1, 1, 4, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (1, 1, 5, 2, 3, 3, 'a12', 12, 125);
+insert into link_table values (1, 1, 6, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (1, 1, 7, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (1, 1, 8, 2, 3, 4, 'a13', 13, 125);
+insert into link_table values (1, 1, 9, 2, 3, 4, 'a14', 14, 125);
+insert into link_table values (1, 1, 10, 2, 3, 4, 'a15', 15, 125);
+insert into link_table values (2, 1, 1, 2, 3, 4, 'a10', 10, 125);
+insert into link_table values (2, 1, 2, 2, 3, 4, 'a10', 10, 125);
+insert into link_table values (2, 1, 3, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (2, 1, 4, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (2, 1, 5, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 6, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 7, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 8, 2, 3, 4, 'a13', 13, 125);
+insert into link_table values (2, 1, 9, 2, 3, 4, 'a14', 14, 125);
+insert into link_table values (2, 1, 10, 2, 3, 4, 'a15', 15, 125);
+insert into link_table values (2, 1, 1, 2, 4, 4, 'a10', 10, 125);
+insert into link_table values (2, 1, 2, 2, 4, 4, 'a10', 10, 125);
+insert into link_table values (2, 1, 3, 2, 4, 4, 'a11', 11, 125);
+insert into link_table values (2, 1, 4, 2, 4, 4, 'a11', 11, 125);
+insert into link_table values (2, 1, 5, 2, 4, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 6, 2, 4, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 7, 2, 4, 4, 'a12', 12, 125);
+insert into link_table values (2, 1, 8, 2, 4, 4, 'a13', 13, 125);
+insert into link_table values (2, 1, 9, 2, 4, 4, 'a14', 14, 125);
+insert into link_table values (2, 1, 10, 2, 4, 4, 'a15', 15, 125);
+insert into link_table values (3, 1, 10, 2, 3, 4, 'a10', 10, 125);
+insert into link_table values (3, 1, 9, 2, 3, 4, 'a10', 10, 125);
+insert into link_table values (3, 1, 8, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (3, 1, 7, 2, 3, 4, 'a11', 11, 125);
+insert into link_table values (3, 1, 6, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (3, 1, 5, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (3, 1, 4, 2, 3, 4, 'a12', 12, 125);
+insert into link_table values (3, 1, 3, 2, 3, 4, 'a13', 13, 125);
+insert into link_table values (3, 1, 2, 2, 3, 4, 'a14', 14, 125);
+insert into link_table values (3, 1, 1, 2, 3, 4, 'a15', 15, 125);
+insert into link_table values (9, 1, 9, 2, 5, 6, '0 ', 10, 125);
+insert into link_table values (9, 1, 8, 2, 5, 6, '01 ', 11, 125);
+insert into link_table values (9, 1, 7, 2, 5, 6, '012 ', 11, 125);
+insert into link_table values (9, 1, 6, 2, 5, 6, '0123 ', 12, 125);
+insert into link_table values (9, 1, 5, 2, 5, 6, '01234 ', 12, 125);
+insert into link_table values (9, 1, 4, 2, 5, 6, '012345 ', 12, 125);
+insert into link_table values (9, 1, 3, 2, 5, 6, '0123456 ', 13, 125);
+insert into link_table values (9, 1, 2, 2, 5, 6, '01234567 ', 14, 125);
+insert into link_table values (9, 1, 1, 2, 5, 6, '012345678 ', 15, 125);
+insert into link_table values (9, 1, 0, 2, 5, 6, '0123456789 ', 15, 125);
+insert into link_table2 select * from link_table;
+CREATE TABLE `id_table` (
+`id` bigint(20) NOT NULL DEFAULT '0',
+`type` int(11) NOT NULL DEFAULT '0',
+`row_created_time` int(11) NOT NULL DEFAULT '0',
+`hash_key` varchar(255) NOT NULL DEFAULT '',
+`is_deleted` tinyint(4) DEFAULT '0',
+PRIMARY KEY (`id`),
+KEY `type_id` (`type`,`id`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED
+KEY_BLOCK_SIZE=8;
+insert into id_table values (1, 1, 10, '111', 0);
+insert into id_table values (2, 1, 10, '111', 1);
+insert into id_table values (3, 1, 10, '111', 0);
+insert into id_table values (4, 1, 10, '111', 1);
+insert into id_table values (5, 1, 10, '111', 0);
+insert into id_table values (6, 1, 10, '111', 1);
+insert into id_table values (7, 1, 10, '111', 0);
+insert into id_table values (8, 1, 10, '111', 1);
+insert into id_table values (9, 1, 10, '111', 0);
+insert into id_table values (10, 1, 10, '111', 1);
+CREATE TABLE `node_table` (
+`id` bigint(20) unsigned NOT NULL DEFAULT '0',
+`type` int(10) unsigned NOT NULL DEFAULT '0',
+`version` bigint(20) unsigned NOT NULL DEFAULT '0',
+`update_time` int(10) unsigned NOT NULL DEFAULT '0',
+`data` mediumtext COLLATE latin1_bin NOT NULL,
+PRIMARY KEY (`type`,`id`) COMMENT 'cf_node_type_id',
+KEY `id` (`id`) COMMENT 'cf_node'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+insert into node_table values (1, 1, 1, 10, 'data');
+insert into node_table values (2, 1, 1, 10, 'data');
+insert into node_table values (3, 1, 1, 10, 'data');
+insert into node_table values (4, 1, 1, 10, 'data');
+insert into node_table values (5, 1, 1, 10, 'data');
+insert into node_table values (6, 1, 1, 10, 'data');
+insert into node_table values (7, 1, 1, 10, 'data');
+insert into node_table values (8, 1, 1, 10, 'data');
+insert into node_table values (9, 1, 1, 10, 'data');
+insert into node_table values (10, 1, 1, 10, 'data');
+CREATE TABLE `count_table` (
+`id` bigint(20) unsigned NOT NULL DEFAULT '0',
+`type` int(10) unsigned NOT NULL DEFAULT '0',
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+`count` int(10) unsigned NOT NULL DEFAULT '0',
+`time` int(10) unsigned NOT NULL DEFAULT '0',
+`version` bigint(20) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`id`,`link_type`) COMMENT 'cf_count_table'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+insert into count_table values (2, 1, 1, 1, 10, 20);
+insert into count_table values (3, 1, 1, 1, 10, 20);
+insert into count_table values (4, 1, 1, 1, 10, 20);
+insert into count_table values (5, 1, 1, 1, 10, 20);
+insert into count_table values (6, 1, 1, 1, 10, 20);
+insert into count_table values (7, 1, 1, 1, 10, 20);
+insert into count_table values (8, 1, 1, 1, 10, 20);
+insert into count_table values (9, 1, 1, 1, 10, 20);
+insert into count_table values (10, 1, 1, 1, 10, 20);
+CREATE TABLE `link_table5` (
+`id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+`visibility` tinyint(3) NOT NULL DEFAULT '0',
+`data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '',
+`time` int(10) unsigned NOT NULL DEFAULT '0',
+`version` bigint(20) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+insert into link_table5 values (1, 1, 2, 2, 1, 1, 'data12', 1, 1);
+insert into link_table5 values (1, 1, 3, 2, 1, 2, 'data13', 1, 1);
+insert into link_table5 values (1, 1, 4, 2, 1, 2, 'data14', 1, 1);
+insert into link_table5 values (1, 1, 5, 2, 1, 1, 'data15', 1, 1);
+insert into link_table5 values (2, 1, 1, 2, 1, 1, 'data21', 1, 1);
+insert into link_table5 values (2, 1, 2, 2, 1, 1, 'data22', 1, 1);
+insert into link_table5 values (2, 1, 3, 2, 1, 1, 'data32', 1, 1);
+CREATE TABLE `link_table3` (
+`id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+`visibility` tinyint(4) NOT NULL DEFAULT '0',
+`data` text COLLATE latin1_bin NOT NULL,
+`time` int(10) unsigned NOT NULL DEFAULT '0',
+`version` bigint(20) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link',
+KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`id2`,`version`)
+COMMENT 'rev:cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+insert into link_table3 values (1, 1, 2, 2, 1, 1, 'data12', 1, 1);
+insert into link_table3 values (1, 1, 3, 2, 1, 2, 'data13', 1, 1);
+insert into link_table3 values (1, 1, 4, 2, 1, 2, 'data14', 1, 1);
+insert into link_table3 values (1, 1, 5, 2, 1, 1, 'data15', 1, 1);
+insert into link_table3 values (2, 1, 1, 2, 1, 1, 'data21', 1, 1);
+insert into link_table3 values (2, 1, 2, 2, 1, 1, 'data22', 1, 1);
+insert into link_table3 values (2, 1, 3, 2, 1, 1, 'data32', 1, 1);
+CREATE TABLE `link_table6` (
+`id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+`visibility` tinyint(4) NOT NULL DEFAULT '0',
+`data` text COLLATE latin1_bin NOT NULL,
+`time` int(10) unsigned NOT NULL DEFAULT '0',
+`version` bigint(20) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link',
+KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`id2`,`version`,
+`data`(255)) COMMENT 'rev:cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
+insert into link_table6 values (1, 1, 2, 2, 1, 1,
+'data12_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (1, 1, 3, 2, 1, 2,
+'data13_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (1, 1, 4, 2, 1, 2,
+'data14_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (1, 1, 5, 2, 1, 1,
+'data15_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (2, 1, 1, 2, 1, 1,
+'data21_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (2, 1, 2, 2, 1, 1,
+'data22_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+insert into link_table6 values (2, 1, 3, 2, 1, 1,
+'data32_12345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890123456789012345678901234567890123456789'
+ '0123456789012345678901234567890', 1, 1);
+CREATE TABLE `link_table4` (
+`id1` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
+`raw_key` text COLLATE latin1_bin,
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+`visibility` tinyint(3) NOT NULL DEFAULT '0',
+`data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '',
+`time` int(10) unsigned NOT NULL DEFAULT '0',
+`version` bigint(20) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link',
+KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`id2`,`version`,`data`)
+COMMENT 'rev:cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
+ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+insert into link_table4 values ('a1', "rk1", 2, 2, 1, 1, 'data12', 1, 1);
+insert into link_table4 values ('a1', "rk2", 3, 2, 1, 2, 'data13', 1, 1);
+insert into link_table4 values ('a1', "rk3", 4, 2, 1, 2, 'data14', 1, 1);
+insert into link_table4 values ('a1', "rk4", 5, 2, 1, 1, 'data15', 1, 1);
+insert into link_table4 values ('b1', "rk5", 1, 2, 1, 1, 'data21', 1, 1);
+insert into link_table4 values ('b1', "rk6", 2, 2, 1, 1, 'data22', 1, 1);
+insert into link_table4 values ('b1', "rk7", 3, 2, 1, 1, 'data32', 1, 1);
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+ no_bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+bypassabc*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /* +bypassabc*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*aaaaaaaaabbbbbbbbb*/ id1,id2,id1_type,id2_type,data,version
+from link_table WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+b*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+byp*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+bypw*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*-b*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /**/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+# Point query
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2 IN (2, 3, 4) and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+1 3 1 2 a11 125
+1 4 1 2 a11 125
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2 IN (2) and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1 IN (1) and id2 IN (2) and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1 IN (1, 2) and id2 IN (2, 3, 4) and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+1 3 1 2 a11 125
+1 4 1 2 a11 125
+2 2 1 2 a10 125
+2 3 1 2 a11 125
+2 4 1 2 a11 125
+# Prefix range query
+# Prefix range query with SK
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 3 AND time = 10
+ORDER BY TIME DESC LIMIT 10;
+id1 id2 link_type visibility data time version
+1 2 3 3 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 3 AND time = 10
+ORDER BY TIME ASC LIMIT 10;
+id1 id2 link_type visibility data time version
+1 2 3 3 a10 10 125
+# Prefix range query with SK with limits
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+1 4 3 4 a11 11 125
+1 3 3 4 a11 11 125
+1 1 3 4 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 10;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+1 4 3 4 a11 11 125
+1 3 3 4 a11 11 125
+1 1 3 4 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 5;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 0;
+id1 id2 link_type visibility data time version
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 0,10;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+1 4 3 4 a11 11 125
+1 3 3 4 a11 11 125
+1 1 3 4 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 0,5;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 0,1;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1,0;
+id1 id2 link_type visibility data time version
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1,10;
+id1 id2 link_type visibility data time version
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+1 4 3 4 a11 11 125
+1 3 3 4 a11 11 125
+1 1 3 4 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1,5;
+id1 id2 link_type visibility data time version
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+1 4 3 4 a11 11 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1,1;
+id1 id2 link_type visibility data time version
+1 9 3 4 a14 14 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1,0;
+id1 id2 link_type visibility data time version
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 5,10;
+id1 id2 link_type visibility data time version
+1 4 3 4 a11 11 125
+1 3 3 4 a11 11 125
+1 1 3 4 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 5,5;
+id1 id2 link_type visibility data time version
+1 4 3 4 a11 11 125
+1 3 3 4 a11 11 125
+1 1 3 4 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 5,1;
+id1 id2 link_type visibility data time version
+1 4 3 4 a11 11 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 5,0;
+id1 id2 link_type visibility data time version
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 10,10;
+id1 id2 link_type visibility data time version
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 10,5;
+id1 id2 link_type visibility data time version
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 10,1;
+id1 id2 link_type visibility data time version
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 10,0;
+id1 id2 link_type visibility data time version
+# Prefix range query with PK
+SELECT /*+ bypass */ id1, id2, link_type FROM link_table FORCE INDEX (PRIMARY)
+WHERE link_type=3 and id1=1 ORDER BY id2 DESC;
+id1 id2 link_type
+1 10 3
+1 9 3
+1 8 3
+1 7 3
+1 6 3
+1 5 3
+1 4 3
+1 3 3
+1 2 3
+1 1 3
+SELECT /*+ bypass */ id1, id2, link_type FROM link_table FORCE INDEX (PRIMARY)
+WHERE link_type=3 and id1=1 ORDER BY id2 ASC;
+id1 id2 link_type
+1 1 3
+1 2 3
+1 3 3
+1 4 3
+1 5 3
+1 6 3
+1 7 3
+1 8 3
+1 9 3
+1 10 3
+# Prefix range query with PK + value
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (PRIMARY)
+WHERE link_type=3 and id1=1 ORDER BY id2 DESC;
+id1 id2 link_type visibility data time version
+1 10 3 4 a15 15 125
+1 9 3 4 a14 14 125
+1 8 3 4 a13 13 125
+1 7 3 4 a12 12 125
+1 6 3 4 a12 12 125
+1 5 3 3 a12 12 125
+1 4 3 4 a11 11 125
+1 3 3 4 a11 11 125
+1 2 3 3 a10 10 125
+1 1 3 4 a10 10 125
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (PRIMARY)
+WHERE link_type=3 and id1=1 ORDER BY id2 ASC;
+id1 id2 link_type visibility data time version
+1 1 3 4 a10 10 125
+1 2 3 3 a10 10 125
+1 3 3 4 a11 11 125
+1 4 3 4 a11 11 125
+1 5 3 3 a12 12 125
+1 6 3 4 a12 12 125
+1 7 3 4 a12 12 125
+1 8 3 4 a13 13 125
+1 9 3 4 a14 14 125
+1 10 3 4 a15 15 125
+# Transaction
+BEGIN;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 a10 125
+UPDATE link_table set data="bcd" WHERE id1=1 and id2=2 and link_type = 3;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 bcd 125
+COMMIT;
+BEGIN;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 bcd 125
+UPDATE link_table set data="cde" WHERE id1=1 and id2=2 and link_type = 3;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 cde 125
+ROLLBACK;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+id1 id2 id1_type id2_type data version
+1 2 1 2 bcd 125
+# Data types
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3";
+id1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3" AND id1="1";
+id1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3" AND id1=True;
+id1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3" AND id1=b'1';
+id1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3" AND id1=x'01';
+id1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3" AND id1=NULL;
+id1
+DROP TABLE count_table;
+DROP TABLE link_table;
+DROP TABLE link_table3;
+DROP TABLE link_table2;
+DROP TABLE id_table;
+DROP TABLE node_table;
+DROP TABLE link_table5;
+DROP TABLE link_table6;
+DROP TABLE link_table4;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bytes_written.result b/storage/rocksdb/mysql-test/rocksdb/r/bytes_written.result
new file mode 100644
index 00000000..d9d29e6a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/bytes_written.result
@@ -0,0 +1,10 @@
+DROP TABLE IF EXISTS stats_test_table;
+CREATE TABLE stats_test_table (a INT, b INT, PRIMARY KEY (a)) ENGINE=ROCKSDB;
+SET GLOBAL rocksdb_perf_context_level=3;
+INSERT INTO stats_test_table VALUES (7,1);
+INSERT INTO stats_test_table VALUES (2,2);
+SELECT io_write_bytes > 0 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME = "stats_test_table";
+io_write_bytes > 0
+1
+DROP TABLE stats_test_table;
+SET GLOBAL rocksdb_perf_context_level=DEFAULT;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/cardinality.result b/storage/rocksdb/mysql-test/rocksdb/r/cardinality.result
new file mode 100644
index 00000000..dcaca8b7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/cardinality.result
@@ -0,0 +1,104 @@
+# restart
+set use_stat_tables= 'COMPLEMENTARY';
+CREATE TABLE t0 (id int PRIMARY KEY, a int, INDEX ix_a (a)) engine=rocksdb;
+insert into t0 values (0, 0),(1, 1),(2, 2),(3, 3),(4, 4),
+(5, 4),(6, 4),(7, 4),(8, 4),(9, 4);
+SELECT cardinality FROM information_schema.statistics where table_name="t0" and
+column_name="id";
+cardinality
+NULL
+SELECT cardinality FROM information_schema.statistics where table_name="t0" and
+column_name="a";
+cardinality
+NULL
+ANALYZE TABLE t0;
+SELECT table_rows into @N FROM information_schema.tables
+WHERE table_name = "t0";
+SELECT FLOOR(@N/cardinality) FROM
+information_schema.statistics where table_name="t0" and column_name="id";
+FLOOR(@N/cardinality)
+1
+SELECT FLOOR(@N/cardinality) FROM
+information_schema.statistics where table_name="t0" and column_name="a";
+FLOOR(@N/cardinality)
+2
+SET GLOBAL rocksdb_force_flush_memtable_now = 1;
+ANALYZE TABLE t0;
+SELECT table_rows into @N FROM information_schema.tables
+WHERE table_name = "t0";
+SELECT FLOOR(@N/cardinality) FROM
+information_schema.statistics where table_name="t0" and column_name="id";
+FLOOR(@N/cardinality)
+1
+SELECT FLOOR(@N/cardinality) FROM
+information_schema.statistics where table_name="t0" and column_name="a";
+FLOOR(@N/cardinality)
+2
+drop table t0;
+DROP TABLE IF EXISTS t1,t10,t11;
+create table t1(
+id bigint not null primary key,
+i1 bigint, #unique
+i2 bigint, #repeating
+c1 varchar(20), #unique
+c2 varchar(20), #repeating
+index t1_1(id, i1),
+index t1_2(i1, i2),
+index t1_3(i2, i1),
+index t1_4(c1, c2),
+index t1_5(c2, c1)
+) engine=rocksdb;
+optimize table t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+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 PRIMARY 1 id A 100000 NULL NULL LSMTREE
+t1 1 t1_1 1 id A 100000 NULL NULL LSMTREE
+t1 1 t1_1 2 i1 A 100000 NULL NULL YES LSMTREE
+t1 1 t1_2 1 i1 A 100000 NULL NULL YES LSMTREE
+t1 1 t1_2 2 i2 A 100000 NULL NULL YES LSMTREE
+t1 1 t1_3 1 i2 A 11111 NULL NULL YES LSMTREE
+t1 1 t1_3 2 i1 A 100000 NULL NULL YES LSMTREE
+t1 1 t1_4 1 c1 A 100000 NULL NULL YES LSMTREE
+t1 1 t1_4 2 c2 A 100000 NULL NULL YES LSMTREE
+t1 1 t1_5 1 c2 A 11111 NULL NULL YES LSMTREE
+t1 1 t1_5 2 c1 A 100000 NULL NULL YES LSMTREE
+SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE();
+table_name table_rows
+t1 100000
+restarting...
+# restart
+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 PRIMARY 1 id A 100000 NULL NULL LSMTREE
+t1 1 t1_1 1 id A 100000 NULL NULL LSMTREE
+t1 1 t1_1 2 i1 A 100000 NULL NULL YES LSMTREE
+t1 1 t1_2 1 i1 A 100000 NULL NULL YES LSMTREE
+t1 1 t1_2 2 i2 A 100000 NULL NULL YES LSMTREE
+t1 1 t1_3 1 i2 A 11111 NULL NULL YES LSMTREE
+t1 1 t1_3 2 i1 A 100000 NULL NULL YES LSMTREE
+t1 1 t1_4 1 c1 A 100000 NULL NULL YES LSMTREE
+t1 1 t1_4 2 c2 A 100000 NULL NULL YES LSMTREE
+t1 1 t1_5 1 c2 A 11111 NULL NULL YES LSMTREE
+t1 1 t1_5 2 c1 A 100000 NULL NULL YES LSMTREE
+SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE();
+table_name table_rows
+t1 100000
+CREATE TABLE t2 (a INT, b INT, c INT, d INT, e INT, f INT, g INT,
+PRIMARY KEY (a), KEY (c, b, a, d, e, f, g))
+ENGINE=ROCKSDB;
+SET GLOBAL rocksdb_force_flush_memtable_now = 1;
+ANALYZE TABLE t2;
+Table Op Msg_type Msg_text
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+cardinality of the columns after 'a' must be equal to the cardinality of column 'a'
+SELECT CARDINALITY INTO @c FROM information_schema.statistics WHERE TABLE_NAME='t2' AND INDEX_NAME='c' AND COLUMN_NAME='a';
+SELECT COLUMN_NAME, CARDINALITY = @c FROM information_schema.statistics WHERE TABLE_NAME='t2' AND INDEX_NAME='c' AND SEQ_IN_INDEX > 3;
+COLUMN_NAME CARDINALITY = @c
+d 1
+e 1
+f 1
+g 1
+drop table t1, t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/check_flags.result b/storage/rocksdb/mysql-test/rocksdb/r/check_flags.result
new file mode 100644
index 00000000..12c5bc4f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/check_flags.result
@@ -0,0 +1,66 @@
+set debug_sync='RESET';
+set global rocksdb_debug_ttl_read_filter_ts = -10;
+connect conn1, localhost, root,,;
+connection default;
+CREATE TABLE t1 (id INT, value INT, KEY (id), KEY (value)) ENGINE=ROCKSDB;
+CREATE TABLE t2 (id INT, value INT) ENGINE=ROCKSDB;
+CREATE TABLE t3 (id INT, kp1 INT, PRIMARY KEY (id), KEY(kp1)) ENGINE=ROCKSDB COMMENT='ttl_duration=1';
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4), (5,5);
+INSERT INTO t2 SELECT * FROM t1;
+INSERT INTO t3 SELECT * FROM t1;
+connection conn1;
+set debug_sync='rocksdb.check_flags_rmi SIGNAL parked WAIT_FOR go';
+SELECT value FROM t1 WHERE value = 3;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+KILL QUERY $conn1_id;
+set debug_sync='now SIGNAL go';
+connection conn1;
+ERROR 70100: Query execution was interrupted
+set debug_sync='RESET';
+connection conn1;
+set debug_sync='rocksdb.check_flags_rmi_scan SIGNAL parked WAIT_FOR go';
+SELECT DISTINCT(id) FROM t1 WHERE value = 5 AND id IN (1, 3, 5);
+connection default;
+set debug_sync='now WAIT_FOR parked';
+KILL QUERY $conn1_id;
+set debug_sync='now SIGNAL go';
+connection conn1;
+ERROR 70100: Query execution was interrupted
+set debug_sync='RESET';
+connection conn1;
+set debug_sync='rocksdb.check_flags_inwd SIGNAL parked WAIT_FOR go';
+SELECT value FROM t1 WHERE value > 3;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+KILL QUERY $conn1_id;
+set debug_sync='now SIGNAL go';
+connection conn1;
+ERROR 70100: Query execution was interrupted
+set debug_sync='RESET';
+connection conn1;
+set debug_sync='rocksdb.check_flags_rnwd SIGNAL parked WAIT_FOR go';
+SELECT id FROM t2;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+KILL QUERY $conn1_id;
+set debug_sync='now SIGNAL go';
+connection conn1;
+ERROR 70100: Query execution was interrupted
+set debug_sync='RESET';
+connection conn1;
+set debug_sync='rocksdb.check_flags_ser SIGNAL parked WAIT_FOR go';
+SELECT kp1 FROM t3 ORDER BY kp1;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+KILL QUERY $conn1_id;
+set debug_sync='now SIGNAL go';
+connection conn1;
+ERROR 70100: Query execution was interrupted
+connection default;
+disconnect conn1;
+set debug_sync='RESET';
+set global rocksdb_debug_ttl_read_filter_ts = DEFAULT;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/check_ignore_unknown_options.result b/storage/rocksdb/mysql-test/rocksdb/r/check_ignore_unknown_options.result
new file mode 100644
index 00000000..6ff49908
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/check_ignore_unknown_options.result
@@ -0,0 +1,7 @@
+select variable_name, variable_value from information_schema.global_variables where variable_name="rocksdb_ignore_unknown_options";
+variable_name variable_value
+ROCKSDB_IGNORE_UNKNOWN_OPTIONS ON
+FOUND 1 /RocksDB: Compatibility check against existing database options failed/ in my_restart.err
+select variable_name, variable_value from information_schema.global_variables where variable_name="rocksdb_ignore_unknown_options";
+variable_name variable_value
+ROCKSDB_IGNORE_UNKNOWN_OPTIONS ON
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/check_table.result b/storage/rocksdb/mysql-test/rocksdb/r/check_table.result
new file mode 100644
index 00000000..116c168c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/check_table.result
@@ -0,0 +1,68 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a,b) VALUES (3,'c');
+INSERT INTO t2 (a,b) VALUES (4,'d');
+CHECK TABLE t1, t2 FOR UPGRADE;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+test.t2 check status OK
+INSERT INTO t2 (a,b) VALUES (5,'e');
+CHECK TABLE t2 QUICK;
+Table Op Msg_type Msg_text
+test.t2 check status OK
+INSERT INTO t1 (a,b) VALUES (6,'f');
+CHECK TABLE t1 FAST;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a,b) VALUES (7,'g');
+INSERT INTO t2 (a,b) VALUES (8,'h');
+CHECK TABLE t2, t1 MEDIUM;
+Table Op Msg_type Msg_text
+test.t2 check status OK
+test.t1 check status OK
+INSERT INTO t1 (a,b) VALUES (9,'i');
+INSERT INTO t2 (a,b) VALUES (10,'j');
+CHECK TABLE t1, t2 EXTENDED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+test.t2 check status OK
+INSERT INTO t1 (a,b) VALUES (11,'k');
+CHECK TABLE t1 CHANGED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, KEY(a)) ENGINE=rocksdb;
+INSERT INTO t1 (a) VALUES (1),(2),(5);
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (6),(8),(12);
+CHECK TABLE t1 FOR UPGRADE;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (13),(15),(16);
+CHECK TABLE t1 QUICK;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (17),(120),(132);
+CHECK TABLE t1 FAST;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (801),(900),(7714);
+CHECK TABLE t1 MEDIUM;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (8760),(10023),(12000);
+CHECK TABLE t1 EXTENDED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (13345),(24456),(78302),(143028);
+CHECK TABLE t1 CHANGED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/checkpoint.result b/storage/rocksdb/mysql-test/rocksdb/r/checkpoint.result
new file mode 100644
index 00000000..fd1ac636
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/checkpoint.result
@@ -0,0 +1,59 @@
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+CREATE TABLE t2 (
+a int not null,
+b int not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+CREATE TABLE t3 (
+a int not null,
+b int not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+CREATE TABLE t4 (
+a int not null,
+b int not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+DELETE FROM t1;
+DELETE FROM t2;
+DELETE FROM t3;
+DELETE FROM t4;
+CREATE TABLE t5 (
+a int not null,
+b int not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+DELETE FROM t5;
+SET GLOBAL ROCKSDB_CREATE_CHECKPOINT = '[CHECKPOINT]';
+CURRENT
+SET GLOBAL ROCKSDB_CREATE_CHECKPOINT = '[CHECKPOINT]';
+CURRENT
+truncate table t1;
+optimize table t1;
+truncate table t2;
+optimize table t2;
+truncate table t3;
+optimize table t3;
+truncate table t4;
+optimize table t4;
+truncate table t5;
+optimize table t5;
+drop table if exists t1;
+drop table if exists t2;
+drop table if exists t3;
+drop table if exists t4;
+drop table if exists t5;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/checksum_table.result b/storage/rocksdb/mysql-test/rocksdb/r/checksum_table.result
new file mode 100644
index 00000000..bb209856
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/checksum_table.result
@@ -0,0 +1,92 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb CHECKSUM=0;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb CHECKSUM=0;
+CHECKSUM TABLE t1;
+Table Checksum
+test.t1 4259194219
+CHECKSUM TABLE t2, t1;
+Table Checksum
+test.t2 0
+test.t1 4259194219
+CHECKSUM TABLE t1, t2 QUICK;
+Table Checksum
+test.t1 NULL
+test.t2 NULL
+CHECKSUM TABLE t1, t2 EXTENDED;
+Table Checksum
+test.t1 4259194219
+test.t2 0
+DROP TABLE t1, t2;
+#
+# Issue #110: SQL command checksum returns inconsistent result
+#
+create table t1 (pk int primary key, col1 varchar(10)) engine=rocksdb;
+insert into t1 values (2,'fooo');
+insert into t1 values (1,NULL);
+checksum table t1;
+Table Checksum
+test.t1 1303411884
+checksum table t1;
+Table Checksum
+test.t1 1303411884
+select * from t1 where pk=2;
+pk col1
+2 fooo
+checksum table t1;
+Table Checksum
+test.t1 1303411884
+checksum table t1;
+Table Checksum
+test.t1 1303411884
+flush tables;
+checksum table t1;
+Table Checksum
+test.t1 1303411884
+checksum table t1;
+Table Checksum
+test.t1 1303411884
+drop table t1;
+#
+# The following test is about making sure MyRocks CHECKSUM TABLE
+# values are the same as with InnoDB.
+# If you see checksum values changed, make sure their counterparts
+# in suite/innodb/r/checksum-matches-myrocks.result match.
+#
+create table t1 (pk int primary key, col1 varchar(10)) engine=rocksdb;
+insert into t1 values (2,'fooo');
+insert into t1 values (1,NULL);
+checksum table t1;
+Table Checksum
+test.t1 1303411884
+drop table t1;
+create table t1 (
+pk bigint unsigned primary key,
+col1 varchar(10),
+col2 tinyint,
+col3 double
+) engine=rocksdb;
+# MariaDB has changed the checksumming algorithm
+# Enable the old algorithm:
+set @tmp_old=@@old;
+set old=1;
+checksum table t1;
+Table Checksum
+test.t1 0
+insert into t1 values (1, NULL, NULL, NULL);
+insert into t1 values (2, 'foo', NULL, NULL);
+checksum table t1;
+Table Checksum
+test.t1 3633741545
+insert into t1 values (3, NULL, 123, NULL);
+insert into t1 values (4, NULL, NULL, 2.78);
+checksum table t1;
+Table Checksum
+test.t1 390004011
+insert into t1 values (5, 'xxxYYYzzzT', NULL, 2.78);
+insert into t1 values (6, '', NULL, 2.78);
+checksum table t1;
+Table Checksum
+test.t1 3183101003
+set old=@tmp_old;
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/checksum_table_live.result b/storage/rocksdb/mysql-test/rocksdb/r/checksum_table_live.result
new file mode 100644
index 00000000..fb86c0af
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/checksum_table_live.result
@@ -0,0 +1,20 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb CHECKSUM=1;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb CHECKSUM=1;
+CHECKSUM TABLE t1;
+Table Checksum
+test.t1 4259194219
+CHECKSUM TABLE t2, t1;
+Table Checksum
+test.t2 0
+test.t1 4259194219
+CHECKSUM TABLE t1, t2 QUICK;
+Table Checksum
+test.t1 NULL
+test.t2 NULL
+CHECKSUM TABLE t1, t2 EXTENDED;
+Table Checksum
+test.t1 4259194219
+test.t2 0
+DROP TABLE t1, t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/col_opt_default.result b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_default.result
new file mode 100644
index 00000000..af53f061
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_default.result
@@ -0,0 +1,20 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT PRIMARY KEY DEFAULT '0') ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) NO PRI 0
+INSERT INTO t1 (a) VALUES (1);
+SELECT a FROM t1;
+a
+1
+ALTER TABLE t1 ADD COLUMN b CHAR(8) DEFAULT '';
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) NO PRI 0
+b char(8) YES
+INSERT INTO t1 (b) VALUES ('a');
+SELECT a,b FROM t1 ORDER BY a,b;
+a b
+0 a
+1
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/col_opt_not_null.result b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_not_null.result
new file mode 100644
index 00000000..e5a8d2dd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_not_null.result
@@ -0,0 +1,2613 @@
+########################
+# BINARY columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+b BINARY NOT NULL,
+b0 BINARY(0) NOT NULL,
+b1 BINARY(1) NOT NULL,
+b20 BINARY(20) NOT NULL,
+b255 BINARY(255) NOT NULL,
+pk BINARY PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b binary(1) NO NULL
+b0 binary(0) NO NULL
+b1 binary(1) NO NULL
+b20 binary(20) NO NULL
+b255 binary(255) NO NULL
+pk binary(1) NO PRI NULL
+INSERT INTO t1 VALUES ('','','','','','');
+INSERT INTO t1 VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.','a');
+SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255), HEX(pk) FROM t1 ORDER BY pk;
+HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255) HEX(pk)
+00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00
+61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000 61
+INSERT INTO t1 VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256),'b');
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b0' at row 1
+Warning 1265 Data truncated for column 'b1' at row 1
+Warning 1265 Data truncated for column 'b20' at row 1
+Warning 1265 Data truncated for column 'b255' at row 1
+INSERT INTO t1 SELECT b255, b255, b255, b255, CONCAT('a',b255,b255), 'c' FROM t1;
+ERROR 23000: Duplicate entry 'c' for key 'PRIMARY'
+SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255), HEX(pk) FROM t1 ORDER BY pk;
+HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255) HEX(pk)
+00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00
+61 61 6161616161616161616161616161616161616161 787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 62
+61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000 61
+ALTER TABLE t1 ADD COLUMN b257 BINARY(257) NOT NULL;
+ERROR 42000: Column length too big for column 'b257' (max = 255); use BLOB or TEXT instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b binary(1) NO NULL
+b0 binary(0) NO NULL
+b1 binary(1) NO NULL
+b20 binary(20) NO NULL
+b255 binary(255) NO NULL
+pk binary(1) NO PRI NULL
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# BINARY NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c BINARY NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c binary(1) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (0);
+SELECT HEX(c) FROM t1;
+HEX(c)
+30
+DROP TABLE t1;
+#----------------------------------
+# BINARY NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c BINARY NOT NULL DEFAULT 0
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c binary(1) NO 0
+ALTER TABLE t1 ADD COLUMN err BINARY NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (0);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 30
+2 30
+DROP TABLE t1;
+########################
+# VARBINARY columns
+########################
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (
+v0 VARBINARY(0) NOT NULL,
+v1 VARBINARY(1) NOT NULL,
+v64 VARBINARY(64) NOT NULL,
+v65000 VARBINARY(65000) NOT NULL,
+PRIMARY KEY (v64)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varbinary(0) NO NULL
+v1 varbinary(1) NO NULL
+v64 varbinary(64) NO PRI NULL
+v65000 varbinary(65000) NO NULL
+CREATE TABLE t2 (v VARBINARY(65532) NOT NULL, PRIMARY KEY(v(255))) ENGINE=rocksdb;
+SHOW COLUMNS IN t2;
+Field Type Null Key Default Extra
+v varbinary(65532) NO PRI NULL
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+SELECT HEX(v0), HEX(v1), HEX(v64), HEX(v65000) FROM t1;
+HEX(v0) HEX(v1) HEX(v64) HEX(v65000)
+
+ 79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E2057652776652070726F7669646564206C696E6B7320746F20416D617A6F6E2E636F6D206865726520666F7220636F6E76656E69656E63652C2062757420746865792063616E20626520666F756E64206174206D616E79206F7468657220626F6F6B73746F7265732C20626F7468206F6E6C696E6520616E64206F66662E0A0A2020496620796F752077616E7420746F206861766520796F7572206661766F72697465204D7953514C202F204D61726961444220626F6F6B206C697374656420686572652C20706C65617365206C65617665206120636F6D6D656E742E0A2020466F7220646576656C6F706572732077686F2077616E7420746F20636F6465206F6E204D617269614442206F72204D7953514C0A0A2020202020202A20556E6465727374616E64696E67204D7953514C20496E7465726E616C73206279205361736861205061636865762C20666F726D6572204D7953514C20646576656C6F706572206174204D7953514C2041422E0A2020202020202020202020206F205468697320697320746865206F6E6C7920626F6F6B207765206B6E6F772061626F75742074686174206465736372696265732074686520696E7465726E616C73206F66204D617269614442202F204D7953514C2E2041206D757374206861766520666F7220616E796F6E652077686F2077616E747320746F20756E6465727374616E6420616E6420646576656C6F70206F6E204D617269614442210A2020202020202020202020206F204E6F7420616C6C20746F706963732061726520636F766572656420616E6420736F6D652070617274732061726520736C696768746C79206F757464617465642C20627574207374696C6C20746865206265737420626F6F6B206F6E207468697320746F7069632E200A2020202020202A204D7953514C20352E3120506C7567696E20446576656C6F706D656E742062792053657267656920476F6C75626368696B20616E6420416E64726577204875746368696E67730A2020202020202020202020206F2041206D757374207265616420666F7220616E796F6E652077616E74696E6720746F207772697465206120706C7567696E20666F72204D6172696144422C207772697474656E20627920746865205365726765692077686F2064657369676E65642074686520706C7567696E20696E7465726661636520666F72204D7953514C20616E64204D61726961444221200A0A2020466F72204D617269614442202F204D7953514C20656E642075736572730A0A2020202020202A204D61726961444220437261736820436F757273652062792042656E20466F7274610A2020202020202020202020206F204669727374204D61726961444220626F6F6B210A2020202020202020202020206F20466F722070656F706C652077686F2077616E7420746F206C6561726E2053514C20616E642074686520626173696373206F66204D6172696144422E0A2020202020202020202020206F204E6F77207368697070696E672E20507572636861736520617420416D617A6F6E2E636F6D206F7220796F7572206661766F7269746520626F6F6B73656C6C65722E200A0A2020202020202A2053514C2D393920436F6D706C6574652C205265616C6C792062792050657465722047756C75747A616E20262054727564792050656C7A65722E0A2020202020202020202020206F2045766572797468696E6720796F752077616E74656420746F206B6E6F772061626F7574207468652053514C203939207374616E646172642E20457863656C6C656E74207265666572656E636520626F6F6B210A2020202020202020202020206F204672656520746F207265616420696E20746865204B6E6F776C656467656261736521200A0A2020202020202A204D7953514C20283474682045646974696F6E29206279205061756C204475426F69730A2020202020202020202020206F20546865202764656661756C742720626F6F6B20746F207265616420696620796F7520776F6E7420746F206C6561726E20746F20757365204D7953514C202F204D6172696144422E200A0A2020202020202A204D7953514C20436F6F6B626F6F6B206279205061756C204475426F69730A2020202020202020202020206F2041206C6F74206F66206578616D706C6573206F6620686F7720746F20757365204D7953514C2E204173207769746820616C6C206F66205061756C277320626F6F6B732C206974277320776F727468206974732077656967687420696E20676F6C6420616E64206576656E20656E6A6F7961626C652072656164696E6720666F7220737563682061202764727927207375626A6563742E200A0A2020202020202A204869676820506572666F726D616E6365204D7953514C2C205365636F6E642045646974696F6E2C204279204261726F6E20536368776172747A2C205065746572205A6169747365762C20566164696D20546B616368656E6B6F2C204A6572656D7920442E205A61776F646E792C2041726A656E204C656E747A2C20446572656B204A2E2042616C6C696E672C20657420616C2E0A2020202020202020202020206F20224869676820506572666F726D616E6365204D7953514C2069732074686520646566696E697469766520677569646520746F206275696C64696E6720666173742C2072656C6961626C652073797374656D732077697468204D7953514C2E205772697474656E206279206E6F74656420657870657274732077697468207965617273206F66207265616C2D776F726C6420657870657269656E6365206275696C64696E672076657279206C617267652073797374656D732C207468697320626F6F6B20636F7665727320657665727920617370656374206F66204D7953514C20706572666F726D616E636520696E2064657461696C2C20616E6420666F6375736573206F6E20726F627573746E6573732C2073656375726974792C20616E64206461746120696E746567726974792E204C6561726E20616476616E63656420746563686E697175657320696E20646570746820736F20796F752063616E206272696E67206F7574204D7953514C27732066756C6C20706F7765722E22202846726F6D2074686520626F6F6B206465736372697074696F6E206174204F275265696C6C7929200A0A2020202020202A204D7953514C2041646D696E20436F6F6B626F6F6B0A2020202020202020202020206F204120717569636B20737465702D62792D7374657020677569646520666F72204D7953514C20757365727320616E642064617461626173652061646D696E6973747261746F727320746F207461636B6C65207265616C2D776F726C64206368616C6C656E6765732077697468204D7953514C20636F6E66696775726174696F6E20616E642061646D696E697374726174696F6E200A0A2020202020202A204D7953514C20352E302043657274696669636174696F6E2053747564792047756964652C204279205061756C204475426F69732C2053746566616E2048696E7A2C204361727374656E20506564657273656E0A2020202020202020202020206F205468697320697320746865206F6666696369616C20677569646520746F20636F766572207468652070617373696E67206F66207468652074776F204D7953514C2043657274696669636174696F6E206578616D696E6174696F6E732E2049742069732076616C69642074696C6C2076657273696F6E20352E30206F6620746865207365727665722C20736F207768696C65206974206D697373657320616C6C2074686520666561747572657320617661696C61626C6520696E204D7953514C20352E3120616E6420677265617465722028696E636C7564696E67204D61726961444220352E3120616E642067726561746572292C2069742070726F7669646573206120676F6F6420626173696320756E6465727374616E64696E67206F66204D7953514C20666F722074686520656E642D757365722E20
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 1
+Warning 1265 Data truncated for column 'v1' at row 1
+Warning 1265 Data truncated for column 'v64' at row 1
+Warning 1265 Data truncated for column 'v65000' at row 1
+INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, CONCAT('a',v65000), CONCAT(v65000,v1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 5
+Warning 1265 Data truncated for column 'v1' at row 5
+Warning 1265 Data truncated for column 'v64' at row 5
+Warning 1265 Data truncated for column 'v0' at row 6
+Warning 1265 Data truncated for column 'v1' at row 6
+Warning 1265 Data truncated for column 'v64' at row 6
+Warning 1265 Data truncated for column 'v65000' at row 6
+SELECT HEX(v0), HEX(v1), HEX(v64), LENGTH(HEX(v65000)) FROM t1;
+HEX(v0) HEX(v1) HEX(v64) LENGTH(HEX(v65000))
+ 0
+ 61 0
+ 48 61486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E205765277665 5932
+ 61 61616263646566676869206162636465666768692061626364656667686920616263646566676869206162636465666768692061626364656667686920616263 130000
+ 79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 5930
+ 79 63636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363 130000
+ALTER TABLE t1 ADD COLUMN v65536 VARBINARY(65536) NOT NULL;
+Warnings:
+Note 1246 Converting column 'v65536' from VARBINARY to BLOB
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varbinary(0) NO NULL
+v1 varbinary(1) NO NULL
+v64 varbinary(64) NO PRI NULL
+v65000 varbinary(65000) NO NULL
+v65536 mediumblob NO NULL
+DROP TABLE t1, t2;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# VARBINARY(64) NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c VARBINARY(64) NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c varbinary(64) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('test');
+SELECT HEX(c) FROM t1;
+HEX(c)
+74657374
+DROP TABLE t1;
+#----------------------------------
+# VARBINARY(64) NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c VARBINARY(64) NOT NULL DEFAULT 'test'
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c varbinary(64) NO test
+ALTER TABLE t1 ADD COLUMN err VARBINARY(64) NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('test');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 74657374
+2 74657374
+DROP TABLE t1;
+########################
+# BIT columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+a BIT NOT NULL,
+b BIT(20) NOT NULL,
+c BIT(64) NOT NULL,
+d BIT(1) NOT NULL,
+PRIMARY KEY (c)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a bit(1) NO NULL
+b bit(20) NO NULL
+c bit(64) NO PRI NULL
+d bit(1) NO NULL
+ALTER TABLE t1 DROP COLUMN d;
+ALTER TABLE t1 ADD COLUMN d BIT(0) NOT NULL;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a bit(1) NO NULL
+b bit(20) NO NULL
+c bit(64) NO PRI NULL
+d bit(1) NO NULL
+INSERT INTO t1 (a,b,c,d) VALUES (0,POW(2,20)-1,b'1111111111111111111111111111111111111111111111111111111111111111',1);
+SELECT BIN(a), HEX(b), c+0 FROM t1 WHERE d>0;
+BIN(a) HEX(b) c+0
+0 FFFFF 18446744073709551615
+INSERT INTO t1 (a,b,c,d) VALUES (1,0,-2,0);
+SELECT a+0, b+0, c+0 FROM t1 WHERE d<100;
+a+0 b+0 c+0
+0 1048575 18446744073709551615
+1 0 18446744073709551614
+INSERT INTO t1 (a,b,c,d) VALUES (b'1', 'f', 0xFF, 0x0);
+SELECT a+0, b+0, c+0 FROM t1 WHERE d IN (0, 2);
+a+0 b+0 c+0
+1 0 18446744073709551614
+1 102 255
+DELETE FROM t1;
+INSERT INTO t1 (a,b,c,d) VALUES (0x10,0,0,1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+SELECT a+0,b+0,c+0,d+0 FROM t1;
+a+0 b+0 c+0 d+0
+1 0 0 1
+INSERT INTO t1 (a,b,c,d) VALUES (0x01,0,0x10000000000000000,0);
+Warnings:
+Warning 1264 Out of range value for column 'c' at row 1
+SELECT a+0,b+0,c+0,d+0 FROM t1;
+a+0 b+0 c+0 d+0
+1 0 0 1
+1 0 18446744073709551615 0
+DROP TABLE t1;
+CREATE TABLE t1 (pk INT PRIMARY KEY, a BIT(65) NOT NULL) ENGINE=rocksdb;
+ERROR 42000: Display width out of range for 'a' (max = 64)
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# BIT NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c BIT NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c bit(1) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (1);
+SELECT HEX(c) FROM t1;
+HEX(c)
+1
+DROP TABLE t1;
+#----------------------------------
+# BIT NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c BIT NOT NULL DEFAULT 1
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c bit(1) NO b'1'
+ALTER TABLE t1 ADD COLUMN err BIT NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (1);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 1
+2 1
+DROP TABLE t1;
+########################
+# BLOB columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+b BLOB NOT NULL,
+b0 BLOB(0) NOT NULL,
+b1 BLOB(1) NOT NULL,
+b300 BLOB(300) NOT NULL,
+bm BLOB(65535) NOT NULL,
+b70k BLOB(70000) NOT NULL,
+b17m BLOB(17000000) NOT NULL,
+t TINYBLOB NOT NULL,
+m MEDIUMBLOB NOT NULL,
+l LONGBLOB NOT NULL
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+b blob NO NULL
+b0 blob NO NULL
+b1 tinyblob NO NULL
+b300 blob NO NULL
+bm blob NO NULL
+b70k mediumblob NO NULL
+b17m longblob NO NULL
+t tinyblob NO NULL
+m mediumblob NO NULL
+l longblob NO NULL
+INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+('','','','','','','','','',''),
+('a','b','c','d','e','f','g','h','i','j'),
+('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), HEX(REPEAT('g',1048576)), REPEAT('h',255), REPEAT('i',1048576), HEX(REPEAT('j',1048576)) );
+SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(b) LENGTH(b0) LENGTH(b1) LENGTH(b300) LENGTH(bm) LENGTH(b70k) LENGTH(b17m) LENGTH(t) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 2097152 255 1048576 2097152
+INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b0' at row 1
+Warning 1265 Data truncated for column 'b1' at row 1
+Warning 1265 Data truncated for column 'b300' at row 1
+Warning 1265 Data truncated for column 'bm' at row 1
+Warning 1265 Data truncated for column 't' at row 1
+SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(b) LENGTH(b0) LENGTH(b1) LENGTH(b300) LENGTH(bm) LENGTH(b70k) LENGTH(b17m) LENGTH(t) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+65535 65535 255 65535 65535 1048576 2097152 255 1048576 2097152
+ALTER TABLE t1 ADD COLUMN bbb BLOB(4294967296);
+ERROR 42000: Display width out of range for 'bbb' (max = 4294967295)
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# BLOB NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c BLOB NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c blob NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+SELECT HEX(c) FROM t1;
+HEX(c)
+
+DROP TABLE t1;
+#----------------------------------
+# BLOB NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c BLOB NOT NULL DEFAULT ''
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c blob NO ''
+ALTER TABLE t1 ADD COLUMN err BLOB NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1
+2
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# TINYBLOB NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TINYBLOB NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c tinyblob NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+SELECT HEX(c) FROM t1;
+HEX(c)
+
+DROP TABLE t1;
+#----------------------------------
+# TINYBLOB NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c TINYBLOB NOT NULL DEFAULT ''
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c tinyblob NO ''
+ALTER TABLE t1 ADD COLUMN err TINYBLOB NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1
+2
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# MEDIUMBLOB NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c MEDIUMBLOB NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c mediumblob NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+SELECT HEX(c) FROM t1;
+HEX(c)
+
+DROP TABLE t1;
+#----------------------------------
+# MEDIUMBLOB NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c MEDIUMBLOB NOT NULL DEFAULT ''
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c mediumblob NO ''
+ALTER TABLE t1 ADD COLUMN err MEDIUMBLOB NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1
+2
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# LONGBLOB NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c LONGBLOB NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c longblob NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+SELECT HEX(c) FROM t1;
+HEX(c)
+
+DROP TABLE t1;
+#----------------------------------
+# LONGBLOB NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c LONGBLOB NOT NULL DEFAULT ''
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c longblob NO ''
+ALTER TABLE t1 ADD COLUMN err LONGBLOB NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1
+2
+DROP TABLE t1;
+########################
+# BOOL columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+b1 BOOL NOT NULL,
+b2 BOOLEAN NOT NULL
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+b1 tinyint(1) NO NULL
+b2 tinyint(1) NO NULL
+INSERT INTO t1 (b1,b2) VALUES (1,TRUE);
+SELECT b1,b2 FROM t1;
+b1 b2
+1 1
+INSERT INTO t1 (b1,b2) VALUES (FALSE,0);
+SELECT b1,b2 FROM t1;
+b1 b2
+0 0
+1 1
+INSERT INTO t1 (b1,b2) VALUES (2,3);
+SELECT b1,b2 FROM t1;
+b1 b2
+0 0
+1 1
+2 3
+INSERT INTO t1 (b1,b2) VALUES (-1,-2);
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+1 1
+2 3
+SELECT IF(b1,'true','false') AS a, IF(b2,'true','false') AS b FROM t1;
+a b
+false false
+true true
+true true
+true true
+SELECT b1,b2 FROM t1 WHERE b1 = TRUE;
+b1 b2
+1 1
+SELECT b1,b2 FROM t1 WHERE b2 = FALSE;
+b1 b2
+0 0
+INSERT INTO t1 (b1,b2) VALUES ('a','b');
+Warnings:
+Warning 1366 Incorrect integer value: 'a' for column `test`.`t1`.`b1` at row 1
+Warning 1366 Incorrect integer value: 'b' for column `test`.`t1`.`b2` at row 1
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+0 0
+1 1
+2 3
+INSERT INTO t1 (b1,b2) VALUES (128,-129);
+Warnings:
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b2' at row 1
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+0 0
+1 1
+127 -128
+2 3
+ALTER TABLE t1 ADD COLUMN b3 BOOLEAN UNSIGNED NOT NULL;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNSIGNED NOT NULL' at line 1
+ALTER TABLE ADD COLUMN b3 BOOL ZEROFILL NOT NULL;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ADD COLUMN b3 BOOL ZEROFILL NOT NULL' at line 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# BOOL NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c BOOL NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c tinyint(1) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('0');
+SELECT HEX(c) FROM t1;
+HEX(c)
+0
+DROP TABLE t1;
+#----------------------------------
+# BOOL NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c BOOL NOT NULL DEFAULT '0'
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c tinyint(1) NO 0
+ALTER TABLE t1 ADD COLUMN err BOOL NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('0');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 0
+2 0
+DROP TABLE t1;
+########################
+# CHAR columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c CHAR NOT NULL,
+c0 CHAR(0) NOT NULL,
+c1 CHAR(1) NOT NULL,
+c20 CHAR(20) NOT NULL,
+c255 CHAR(255) NOT NULL,
+PRIMARY KEY (c255)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c char(1) NO NULL
+c0 char(0) NO NULL
+c1 char(1) NO NULL
+c20 char(20) NO NULL
+c255 char(255) NO PRI NULL
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('','','','','');
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.');
+SELECT c,c0,c1,c20,c255 FROM t1;
+c c0 c1 c20 c255
+
+a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+Warning 1265 Data truncated for column 'c0' at row 1
+Warning 1265 Data truncated for column 'c1' at row 1
+Warning 1265 Data truncated for column 'c20' at row 1
+Warning 1265 Data truncated for column 'c255' at row 1
+INSERT INTO t1 (c,c0,c1,c20,c255) SELECT c255, c255, c255, c255, CONCAT('a',c255,c1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 5
+Warning 1265 Data truncated for column 'c0' at row 5
+Warning 1265 Data truncated for column 'c1' at row 5
+Warning 1265 Data truncated for column 'c20' at row 5
+Warning 1265 Data truncated for column 'c' at row 6
+Warning 1265 Data truncated for column 'c0' at row 6
+Warning 1265 Data truncated for column 'c1' at row 6
+Warning 1265 Data truncated for column 'c20' at row 6
+Warning 1265 Data truncated for column 'c255' at row 6
+SELECT c,c0,c1,c20,c255 FROM t1;
+c c0 c1 c20 c255
+
+ a
+C C Creating an article aCreating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.b
+a a aaaaaaaaaaaaaaaaaaaa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
+x x xxxxxxxxxxxxxxxxxxxx axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+SELECT DISTINCT c20, REPEAT('a',LENGTH(c20)), COUNT(*) FROM t1 GROUP BY c1, c20;
+c20 REPEAT('a',LENGTH(c20)) COUNT(*)
+ 2
+Creating an article aaaaaaaaaaaaaaaaaaa 1
+aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa 1
+abcdefghi klmnopqrst aaaaaaaaaaaaaaaaaaaa 1
+xxxxxxxxxxxxxxxxxxxx aaaaaaaaaaaaaaaaaaaa 1
+ALTER TABLE t1 ADD COLUMN c257 CHAR(257) NOT NULL;
+ERROR 42000: Column length too big for column 'c257' (max = 255); use BLOB or TEXT instead
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# CHAR NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c CHAR NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c char(1) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('_');
+SELECT HEX(c) FROM t1;
+HEX(c)
+5F
+DROP TABLE t1;
+#----------------------------------
+# CHAR NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c CHAR NOT NULL DEFAULT '_'
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c char(1) NO _
+ALTER TABLE t1 ADD COLUMN err CHAR NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('_');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 5F
+2 5F
+DROP TABLE t1;
+########################
+# VARCHAR columns
+########################
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (
+v0 VARCHAR(0) NOT NULL,
+v1 VARCHAR(1) NOT NULL,
+v64 VARCHAR(64) NOT NULL,
+v65000 VARCHAR(65000) NOT NULL,
+PRIMARY KEY (v64)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varchar(0) NO NULL
+v1 varchar(1) NO NULL
+v64 varchar(64) NO PRI NULL
+v65000 varchar(65000) NO NULL
+CREATE TABLE t2 (v VARCHAR(65532), PRIMARY KEY (v(255))) ENGINE=rocksdb;
+SHOW COLUMNS IN t2;
+Field Type Null Key Default Extra
+v varchar(65532) NO PRI NULL
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+SELECT v0,v1,v64,v65000 FROM t1;
+v0 v1 v64 v65000
+
+
+
+
+
+
+
+
+
+
+
+ y Once there, double check that an article doesn't already exist Here is a list of recommended books on MariaDB and MySQL. We've provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+ o "High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL's full power." (From the book description at O'Reilly)
+ o A lot of examples of how to use MySQL. As with all of Paul's books, it's worth its weight in gold and even enjoyable reading for such a 'dry' subject.
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Free to read in the Knowledgebase!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+ o The 'default' book to read if you wont to learn to use MySQL / MariaDB.
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ * MariaDB Crash Course by Ben Forta
+ * MySQL (4th Edition) by Paul DuBois
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ * MySQL Admin Cookbook
+ * MySQL Cookbook by Paul DuBois
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ For MariaDB / MySQL end users
+ For developers who want to code on MariaDB or MySQL
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 1
+Warning 1265 Data truncated for column 'v1' at row 1
+Warning 1265 Data truncated for column 'v64' at row 1
+Warning 1265 Data truncated for column 'v65000' at row 1
+INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, CONCAT('a',v65000), CONCAT(v65000,v1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 5
+Warning 1265 Data truncated for column 'v1' at row 5
+Warning 1265 Data truncated for column 'v64' at row 5
+Warning 1265 Data truncated for column 'v65000' at row 5
+Warning 1265 Data truncated for column 'v0' at row 6
+Warning 1265 Data truncated for column 'v1' at row 6
+Warning 1265 Data truncated for column 'v64' at row 6
+SELECT v0, v1, v64, LENGTH(v65000) FROM t1;
+v0 v1 v64 LENGTH(v65000)
+ 0
+ a 0
+ H aHere is a list of recommended books on MariaDB and MySQL. We've 2966
+ a aabcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abc 65000
+ y Once there, double check that an article doesn't already exist 2965
+ y cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 65000
+ALTER TABLE t1 ADD COLUMN v65536 VARCHAR(65536) NOT NULL;
+Warnings:
+Note 1246 Converting column 'v65536' from VARCHAR to TEXT
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varchar(0) NO NULL
+v1 varchar(1) NO NULL
+v64 varchar(64) NO PRI NULL
+v65000 varchar(65000) NO NULL
+v65536 mediumtext NO NULL
+DROP TABLE t1, t2;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# VARCHAR(64) NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c VARCHAR(64) NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c varchar(64) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('test default');
+SELECT HEX(c) FROM t1;
+HEX(c)
+746573742064656661756C74
+DROP TABLE t1;
+#----------------------------------
+# VARCHAR(64) NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c VARCHAR(64) NOT NULL DEFAULT 'test default'
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c varchar(64) NO test default
+ALTER TABLE t1 ADD COLUMN err VARCHAR(64) NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('test default');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 746573742064656661756C74
+2 746573742064656661756C74
+DROP TABLE t1;
+########################
+# date and time columns
+########################
+set @col_opt_not_nullsave_time_zone=@@time_zone;
+set time_zone='UTC';
+DROP TABLE IF EXISTS t1;
+set @save_time_zone=@@time_zone;
+set time_zone='UTC';
+CREATE TABLE t1 (
+d DATE NOT NULL,
+dt DATETIME NOT NULL,
+ts TIMESTAMP NOT NULL,
+t TIME NOT NULL,
+y YEAR NOT NULL,
+y4 YEAR(4) NOT NULL,
+y2 YEAR(2) NOT NULL,
+pk DATETIME PRIMARY KEY
+) ENGINE=rocksdb;
+Warnings:
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d date NO NULL
+dt datetime NO NULL
+ts timestamp NO NULL
+t time NO NULL
+y year(4) NO NULL
+y4 year(4) NO NULL
+y2 year(2) NO NULL
+pk datetime NO PRI NULL
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y,y4,y2,pk) VALUES
+('1000-01-01', '1000-01-01 00:00:00', FROM_UNIXTIME(1), '-838:59:59', '1901', '1901', '00','2012-12-12 12:12:12'),
+('9999-12-31', '9999-12-31 23:59:59', FROM_UNIXTIME(2147483647), '838:59:59', '2155', '2155', '99','2012-12-12 12:12:13'),
+('0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '00:00:00', '0', '0', '0','2012-12-12 12:12:14'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),YEAR(@tm),YEAR(@tm),'2012-12-12 12:12:15');
+SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+d dt ts t y y4 y2
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 00
+1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
+2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
+9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
+INSERT INTO t1 (d,dt,ts,t,y,y4,y2,pk) VALUES
+('999-13-32', '999-11-31 00:00:00', '0', '-839:00:00', '1900', '1900', '-1','2012-12-12 12:12:16');
+Warnings:
+Warning 1265 Data truncated for column 'd' at row 1
+Warning 1265 Data truncated for column 'dt' at row 1
+Warning 1265 Data truncated for column 'ts' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 'y' at row 1
+Warning 1264 Out of range value for column 'y4' at row 1
+Warning 1264 Out of range value for column 'y2' at row 1
+SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+d dt ts t y y4 y2
+1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
+9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 00
+2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 -838:59:59 0000 0000 00
+set time_zone=@save_time_zone;
+DROP TABLE t1;
+SET TIMESTAMP=UNIX_TIMESTAMP('2013-12-12 12:12:12');
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# DATE NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c DATE NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c date NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('2012-12-21');
+SELECT HEX(c) FROM t1;
+HEX(c)
+323031322D31322D3231
+DROP TABLE t1;
+#----------------------------------
+# DATE NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c DATE NOT NULL DEFAULT '2012-12-21'
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c date NO 2012-12-21
+ALTER TABLE t1 ADD COLUMN err DATE NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('2012-12-21');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 323031322D31322D3231
+2 323031322D31322D3231
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# DATETIME NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c DATETIME NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c datetime NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('2012-12-21 12:21:12');
+SELECT HEX(c) FROM t1;
+HEX(c)
+323031322D31322D32312031323A32313A3132
+DROP TABLE t1;
+#----------------------------------
+# DATETIME NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c DATETIME NOT NULL DEFAULT '2012-12-21 12:21:12'
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c datetime NO 2012-12-21 12:21:12
+ALTER TABLE t1 ADD COLUMN err DATETIME NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('2012-12-21 12:21:12');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 323031322D31322D32312031323A32313A3132
+2 323031322D31322D32312031323A32313A3132
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# TIMESTAMP NOT NULL column without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TIMESTAMP NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c timestamp NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+INSERT INTO t1 (c) VALUES ('2012-12-21 12:21:12');
+SELECT HEX(c) FROM t1;
+HEX(c)
+323031332D31322D31322031323A31323A3132
+323031322D31322D32312031323A32313A3132
+DROP TABLE t1;
+#----------------------------------
+# TIMESTAMP NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c TIMESTAMP NOT NULL DEFAULT '2012-12-21 12:21:12'
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c timestamp NO 2012-12-21 12:21:12
+ALTER TABLE t1 ADD COLUMN err TIMESTAMP NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+set @save_ts=@@timestamp;
+set timestamp=1478923914;
+INSERT INTO t1 (c) VALUES (NULL);
+set timestamp=@save_ts;
+INSERT INTO t1 (c) VALUES ('2012-12-21 12:21:12');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 323031362D31312D31322030343A31313A3534
+2 323031322D31322D32312031323A32313A3132
+3 323031322D31322D32312031323A32313A3132
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# TIME NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TIME NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c time NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('12:21:12');
+SELECT HEX(c) FROM t1;
+HEX(c)
+31323A32313A3132
+DROP TABLE t1;
+#----------------------------------
+# TIME NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c TIME NOT NULL DEFAULT '12:21:12'
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c time NO 12:21:12
+ALTER TABLE t1 ADD COLUMN err TIME NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('12:21:12');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 31323A32313A3132
+2 31323A32313A3132
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# YEAR NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c YEAR NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c year(4) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('2012');
+SELECT HEX(c) FROM t1;
+HEX(c)
+7DC
+DROP TABLE t1;
+#----------------------------------
+# YEAR NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c YEAR NOT NULL DEFAULT '2012'
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c year(4) NO 2012
+ALTER TABLE t1 ADD COLUMN err YEAR NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('2012');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 7DC
+2 7DC
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# YEAR(2) NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c YEAR(2) NOT NULL) ENGINE=rocksdb;
+Warnings:
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c year(2) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('12');
+SELECT HEX(c) FROM t1;
+HEX(c)
+C
+DROP TABLE t1;
+#----------------------------------
+# YEAR(2) NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c YEAR(2) NOT NULL DEFAULT '12'
+) ENGINE=rocksdb;
+Warnings:
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c year(2) NO 12
+ALTER TABLE t1 ADD COLUMN err YEAR(2) NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('12');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 C
+2 C
+DROP TABLE t1;
+set time_zone= @col_opt_not_nullsave_time_zone;
+########################
+# ENUM columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+a ENUM('') NOT NULL,
+b ENUM('test1','test2','test3','test4','test5') NOT NULL,
+c ENUM('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') NOT NULL,
+PRIMARY KEY (b)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a enum('') NO NULL
+b enum('test1','test2','test3','test4','test5') NO PRI NULL
+c enum('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') NO NULL
+INSERT INTO t1 (a,b,c) VALUES ('','test2','4'),('',5,2);
+SELECT a,b,c FROM t1;
+a b c
+ test2 4
+ test5 2
+INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+
+ test2 4
+ test5 2
+ALTER TABLE t1 ADD COLUMN e ENUM('a','A') NOT NULL;
+Warnings:
+Note 1291 Column 'e' has duplicated value 'a' in ENUM
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a enum('') NO NULL
+b enum('test1','test2','test3','test4','test5') NO PRI NULL
+c enum('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') NO NULL
+e enum('a','A') NO NULL
+INSERT INTO t1 (a,b,c,e) VALUES ('','test3','75','A');
+SELECT a,b,c,e FROM t1;
+a b c e
+ a
+ test2 4 a
+ test3 75 a
+ test5 2 a
+SELECT a,b,c,e FROM t1 WHERE b='test2' OR a != '';
+a b c e
+ test2 4 a
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# ENUM('test1','test2','test3') NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c ENUM('test1','test2','test3') NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c enum('test1','test2','test3') NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('test2');
+SELECT HEX(c) FROM t1;
+HEX(c)
+7465737432
+DROP TABLE t1;
+#----------------------------------
+# ENUM('test1','test2','test3') NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c ENUM('test1','test2','test3') NOT NULL DEFAULT 'test2'
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c enum('test1','test2','test3') NO test2
+ALTER TABLE t1 ADD COLUMN err ENUM('test1','test2','test3') NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('test2');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 7465737432
+2 7465737432
+DROP TABLE t1;
+########################
+# Fixed point columns (NUMERIC, DECIMAL)
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+d DECIMAL NOT NULL,
+d0 DECIMAL(0) NOT NULL,
+d1_1 DECIMAL(1,1) NOT NULL,
+d10_2 DECIMAL(10,2) NOT NULL,
+d60_10 DECIMAL(60,10) NOT NULL,
+n NUMERIC NOT NULL,
+n0_0 NUMERIC(0,0) NOT NULL,
+n1 NUMERIC(1) NOT NULL,
+n20_4 NUMERIC(20,4) NOT NULL,
+n65_4 NUMERIC(65,4) NOT NULL,
+pk NUMERIC NOT NULL PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d decimal(10,0) NO NULL
+d0 decimal(10,0) NO NULL
+d1_1 decimal(1,1) NO NULL
+d10_2 decimal(10,2) NO NULL
+d60_10 decimal(60,10) NO NULL
+n decimal(10,0) NO NULL
+n0_0 decimal(10,0) NO NULL
+n1 decimal(1,0) NO NULL
+n20_4 decimal(20,4) NO NULL
+n65_4 decimal(65,4) NO NULL
+pk decimal(10,0) NO PRI NULL
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807,1);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999,3);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807,4);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999,5);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+6
+);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999,7);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111,8);
+Warnings:
+Note 1265 Data truncated for column 'd' at row 1
+Note 1265 Data truncated for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Note 1265 Data truncated for column 'd10_2' at row 1
+Note 1265 Data truncated for column 'd60_10' at row 1
+Note 1265 Data truncated for column 'n' at row 1
+Note 1265 Data truncated for column 'n0_0' at row 1
+Note 1265 Data truncated for column 'n1' at row 1
+Note 1265 Data truncated for column 'n20_4' at row 1
+Note 1265 Data truncated for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.00 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.0000 9999999999999999999999999999999999999999999999999999999999999.1111
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66) NOT NULL;
+ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6) NOT NULL;
+ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66) NOT NULL;
+ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 38
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# DECIMAL NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c DECIMAL NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c decimal(10,0) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (1.1);
+Warnings:
+Note 1265 Data truncated for column 'c' at row 1
+SELECT HEX(c) FROM t1;
+HEX(c)
+1
+DROP TABLE t1;
+#----------------------------------
+# DECIMAL NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c DECIMAL NOT NULL DEFAULT 1.1
+) ENGINE=rocksdb;
+Warnings:
+Note 1265 Data truncated for column 'c' at row 1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c decimal(10,0) NO 1
+ALTER TABLE t1 ADD COLUMN err DECIMAL NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (1.1);
+Warnings:
+Note 1265 Data truncated for column 'c' at row 1
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 1
+2 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# NUMERIC NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c NUMERIC NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c decimal(10,0) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (0);
+SELECT HEX(c) FROM t1;
+HEX(c)
+0
+DROP TABLE t1;
+#----------------------------------
+# NUMERIC NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c NUMERIC NOT NULL DEFAULT 0
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c decimal(10,0) NO 0
+ALTER TABLE t1 ADD COLUMN err NUMERIC NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (0);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 0
+2 0
+DROP TABLE t1;
+########################
+# Floating point columns (FLOAT, DOUBLE)
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+f FLOAT NOT NULL,
+f0 FLOAT(0) NOT NULL,
+r1_1 REAL(1,1) NOT NULL,
+f23_0 FLOAT(23) NOT NULL,
+f20_3 FLOAT(20,3) NOT NULL,
+d DOUBLE NOT NULL,
+d1_0 DOUBLE(1,0) NOT NULL,
+d10_10 DOUBLE PRECISION (10,10) NOT NULL,
+d53 DOUBLE(53,0) NOT NULL,
+d53_10 DOUBLE(53,10) NOT NULL,
+pk DOUBLE NOT NULL PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+f float NO NULL
+f0 float NO NULL
+r1_1 double(1,1) NO NULL
+f23_0 float NO NULL
+f20_3 float(20,3) NO NULL
+d double NO NULL
+d1_0 double(1,0) NO NULL
+d10_10 double(10,10) NO NULL
+d53 double(53,0) NO NULL
+d53_10 double(53,10) NO NULL
+pk double NO PRI NULL
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999,1);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 11111111.111
+d10_10 0.0123456789
+d1_0 8
+d53 1234566789123456800
+d53_10 100000000000000000.0000000000
+f0 12345.1
+f20_3 56789.988
+f23_0 123457000
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+99999999999999999999999999999999999999,
+99999999999999999999999999999999999999.9999999999999999,
+0.9,
+99999999999999999999999999999999999999.9,
+99999999999999999.999,
+999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+9,
+0.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999,
+3
+);
+Warnings:
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 0
+d 11111111.111
+d 1e81
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 0
+d1_0 8
+d1_0 9
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 0
+f 1e38
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999,4);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+SELECT
+CONCAT('', MAX(f)),
+CONCAT('', MAX(f0)),
+CONCAT('', MAX(r1_1)),
+CONCAT('', MAX(f23_0)),
+CONCAT('', MAX(f20_3)),
+CONCAT('', MAX(d)),
+CONCAT('', MAX(d1_0)),
+CONCAT('', MAX(d10_10)),
+CONCAT('', MAX(d53)),
+CONCAT('', MAX(d53_10)) FROM t1;
+CONCAT('', MAX(f)) 1e38
+CONCAT('', MAX(d)) 1e81
+CONCAT('', MAX(d10_10)) 0.9999999999
+CONCAT('', MAX(d1_0)) 9
+CONCAT('', MAX(d53)) 100000000000000000000000000000000000000000000000000000
+CONCAT('', MAX(d53_10)) 10000000000000000000000000000000000000000000.0000000000
+CONCAT('', MAX(f0)) 1e38
+CONCAT('', MAX(f20_3)) 99999998430674940.000
+CONCAT('', MAX(f23_0)) 1e38
+CONCAT('', MAX(r1_1)) 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+5
+);
+Warnings:
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e61
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 0.9999999999
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f 3.40282e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+999999999999999999999999999999999999999,
+999999999999999999999999999999999999999.9999999999999999,
+1.9,
+999999999999999999999999999999999999999.9,
+999999999999999999.999,
+9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+99,
+1.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999,
+6
+);
+Warnings:
+Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e61
+d 1e65
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 0.9999999999
+d10_10 0.9999999999
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f 3.40282e38
+f 3.40282e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f0 3.40282e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+f23_0 3.40282e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) NOT NULL;
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1) NOT NULL;
+ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35) NOT NULL;
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# FLOAT NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c FLOAT NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c float NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (1.1);
+SELECT HEX(c) FROM t1;
+HEX(c)
+1
+DROP TABLE t1;
+#----------------------------------
+# FLOAT NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c FLOAT NOT NULL DEFAULT 1.1
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c float NO 1.1
+ALTER TABLE t1 ADD COLUMN err FLOAT NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (1.1);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 1
+2 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# DOUBLE NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c DOUBLE NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c double NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (0);
+SELECT HEX(c) FROM t1;
+HEX(c)
+0
+DROP TABLE t1;
+#----------------------------------
+# DOUBLE NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c DOUBLE NOT NULL DEFAULT 0
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c double NO 0
+ALTER TABLE t1 ADD COLUMN err DOUBLE NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (0);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 0
+2 0
+DROP TABLE t1;
+########################
+# INT columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+i INT NOT NULL,
+i0 INT(0) NOT NULL,
+i1 INT(1) NOT NULL,
+i20 INT(20) NOT NULL,
+t TINYINT NOT NULL,
+t0 TINYINT(0) NOT NULL,
+t1 TINYINT(1) NOT NULL,
+t20 TINYINT(20) NOT NULL,
+s SMALLINT NOT NULL,
+s0 SMALLINT(0) NOT NULL,
+s1 SMALLINT(1) NOT NULL,
+s20 SMALLINT(20) NOT NULL,
+m MEDIUMINT NOT NULL,
+m0 MEDIUMINT(0) NOT NULL,
+m1 MEDIUMINT(1) NOT NULL,
+m20 MEDIUMINT(20) NOT NULL,
+b BIGINT NOT NULL,
+b0 BIGINT(0) NOT NULL,
+b1 BIGINT(1) NOT NULL,
+b20 BIGINT(20) NOT NULL,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+i int(11) NO NULL
+i0 int(11) NO NULL
+i1 int(1) NO NULL
+i20 int(20) NO NULL
+t tinyint(4) NO NULL
+t0 tinyint(4) NO NULL
+t1 tinyint(1) NO NULL
+t20 tinyint(20) NO NULL
+s smallint(6) NO NULL
+s0 smallint(6) NO NULL
+s1 smallint(1) NO NULL
+s20 smallint(20) NO NULL
+m mediumint(9) NO NULL
+m0 mediumint(9) NO NULL
+m1 mediumint(1) NO NULL
+m20 mediumint(20) NO NULL
+b bigint(20) NO NULL
+b0 bigint(20) NO NULL
+b1 bigint(1) NO NULL
+b20 bigint(20) NO NULL
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 8
+Warning 1264 Out of range value for column 'i0' at row 8
+Warning 1264 Out of range value for column 'i1' at row 8
+Warning 1264 Out of range value for column 'i20' at row 8
+Warning 1264 Out of range value for column 't' at row 8
+Warning 1264 Out of range value for column 't0' at row 8
+Warning 1264 Out of range value for column 't1' at row 8
+Warning 1264 Out of range value for column 't20' at row 8
+Warning 1264 Out of range value for column 's' at row 8
+Warning 1264 Out of range value for column 's0' at row 8
+Warning 1264 Out of range value for column 's1' at row 8
+Warning 1264 Out of range value for column 's20' at row 8
+Warning 1264 Out of range value for column 'm' at row 8
+Warning 1264 Out of range value for column 'm0' at row 8
+Warning 1264 Out of range value for column 'm1' at row 8
+Warning 1264 Out of range value for column 'm20' at row 8
+Warning 1264 Out of range value for column 'i' at row 9
+Warning 1264 Out of range value for column 'i0' at row 9
+Warning 1264 Out of range value for column 'i1' at row 9
+Warning 1264 Out of range value for column 'i20' at row 9
+Warning 1264 Out of range value for column 't' at row 9
+Warning 1264 Out of range value for column 't0' at row 9
+Warning 1264 Out of range value for column 't1' at row 9
+Warning 1264 Out of range value for column 't20' at row 9
+Warning 1264 Out of range value for column 's' at row 9
+Warning 1264 Out of range value for column 's0' at row 9
+Warning 1264 Out of range value for column 's1' at row 9
+Warning 1264 Out of range value for column 's20' at row 9
+Warning 1264 Out of range value for column 'm' at row 9
+Warning 1264 Out of range value for column 'm0' at row 9
+Warning 1264 Out of range value for column 'm1' at row 9
+Warning 1264 Out of range value for column 'm20' at row 9
+Warning 1264 Out of range value for column 'i' at row 10
+Warning 1264 Out of range value for column 'i0' at row 10
+Warning 1264 Out of range value for column 'i1' at row 10
+Warning 1264 Out of range value for column 'i20' at row 10
+Warning 1264 Out of range value for column 't' at row 10
+Warning 1264 Out of range value for column 't0' at row 10
+Warning 1264 Out of range value for column 't1' at row 10
+Warning 1264 Out of range value for column 't20' at row 10
+Warning 1264 Out of range value for column 's' at row 10
+Warning 1264 Out of range value for column 's0' at row 10
+Warning 1264 Out of range value for column 's1' at row 10
+Warning 1264 Out of range value for column 's20' at row 10
+Warning 1264 Out of range value for column 'm' at row 10
+Warning 1264 Out of range value for column 'm0' at row 10
+Warning 1264 Out of range value for column 'm1' at row 10
+Warning 1264 Out of range value for column 'm20' at row 10
+Warning 1264 Out of range value for column 'i' at row 11
+Warning 1264 Out of range value for column 'i0' at row 11
+Warning 1264 Out of range value for column 'i1' at row 11
+Warning 1264 Out of range value for column 'i20' at row 11
+Warning 1264 Out of range value for column 't' at row 11
+Warning 1264 Out of range value for column 't0' at row 11
+Warning 1264 Out of range value for column 't1' at row 11
+Warning 1264 Out of range value for column 't20' at row 11
+Warning 1264 Out of range value for column 's' at row 11
+Warning 1264 Out of range value for column 's0' at row 11
+Warning 1264 Out of range value for column 's1' at row 11
+Warning 1264 Out of range value for column 's20' at row 11
+Warning 1264 Out of range value for column 'm' at row 11
+Warning 1264 Out of range value for column 'm0' at row 11
+Warning 1264 Out of range value for column 'm1' at row 11
+Warning 1264 Out of range value for column 'm20' at row 11
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+ALTER TABLE t1 ADD COLUMN i257 INT(257) NOT NULL;
+ERROR 42000: Display width out of range for 'i257' (max = 255)
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# INT NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c INT NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c int(11) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (2147483647);
+SELECT HEX(c) FROM t1;
+HEX(c)
+7FFFFFFF
+DROP TABLE t1;
+#----------------------------------
+# INT NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c INT NOT NULL DEFAULT 2147483647
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c int(11) NO 2147483647
+ALTER TABLE t1 ADD COLUMN err INT NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (2147483647);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 7FFFFFFF
+2 7FFFFFFF
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# TINYINT NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TINYINT NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c tinyint(4) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (127);
+SELECT HEX(c) FROM t1;
+HEX(c)
+7F
+DROP TABLE t1;
+#----------------------------------
+# TINYINT NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c TINYINT NOT NULL DEFAULT 127
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c tinyint(4) NO 127
+ALTER TABLE t1 ADD COLUMN err TINYINT NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (127);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 7F
+2 7F
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# SMALLINT NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c SMALLINT NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c smallint(6) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (0);
+SELECT HEX(c) FROM t1;
+HEX(c)
+0
+DROP TABLE t1;
+#----------------------------------
+# SMALLINT NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c SMALLINT NOT NULL DEFAULT 0
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c smallint(6) NO 0
+ALTER TABLE t1 ADD COLUMN err SMALLINT NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (0);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 0
+2 0
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# MEDIUMINT NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c MEDIUMINT NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c mediumint(9) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (1);
+SELECT HEX(c) FROM t1;
+HEX(c)
+1
+DROP TABLE t1;
+#----------------------------------
+# MEDIUMINT NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c MEDIUMINT NOT NULL DEFAULT 1
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c mediumint(9) NO 1
+ALTER TABLE t1 ADD COLUMN err MEDIUMINT NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (1);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 1
+2 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# BIGINT NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c BIGINT NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c bigint(20) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (9223372036854775807);
+SELECT HEX(c) FROM t1;
+HEX(c)
+7FFFFFFFFFFFFFFF
+DROP TABLE t1;
+#----------------------------------
+# BIGINT NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c BIGINT NOT NULL DEFAULT 9223372036854775807
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c bigint(20) NO 9223372036854775807
+ALTER TABLE t1 ADD COLUMN err BIGINT NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES (9223372036854775807);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 7FFFFFFFFFFFFFFF
+2 7FFFFFFFFFFFFFFF
+DROP TABLE t1;
+########################
+# SET columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+a SET('') NOT NULL,
+b SET('test1','test2','test3','test4','test5') NOT NULL,
+c SET('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') NOT NULL,
+PRIMARY KEY (c)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a set('') NO NULL
+b set('test1','test2','test3','test4','test5') NO NULL
+c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') NO PRI NULL
+INSERT INTO t1 (a,b,c) VALUES
+('','test2,test3','01,34,44,,23'),
+('',5,2),
+(',','test4,test2','');
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+ test1,test3 02
+ test2,test3 01,23,34,44
+ test2,test4
+INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+ 01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50'51,52,53,54,55,56,57,58,59,60,61,62,63,64
+ test1,test3 02
+ test2,test3 01,23,34,44
+ test2,test4
+ALTER TABLE t1 ADD COLUMN e SET('a','A') NOT NULL;
+Warnings:
+Note 1291 Column 'e' has duplicated value 'a' in SET
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a set('') NO NULL
+b set('test1','test2','test3','test4','test5') NO NULL
+c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') NO PRI NULL
+e set('a','A') NO NULL
+ALTER TABLE t1 ADD COLUMN f SET('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i') NOT NULL;
+ERROR HY000: Too many strings for column f and SET
+SELECT a,b,c,e FROM t1 WHERE FIND_IN_SET('test2',b)>0 OR a != '';
+a b c e
+ test2,test3 01,23,34,44
+ test2,test4
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# SET('test1','test2','test3') NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c SET('test1','test2','test3') NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c set('test1','test2','test3') NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('test2,test3');
+SELECT HEX(c) FROM t1;
+HEX(c)
+74657374322C7465737433
+DROP TABLE t1;
+#----------------------------------
+# SET('test1','test2','test3') NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c SET('test1','test2','test3') NOT NULL DEFAULT 'test2,test3'
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c set('test1','test2','test3') NO test2,test3
+ALTER TABLE t1 ADD COLUMN err SET('test1','test2','test3') NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('test2,test3');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1 74657374322C7465737433
+2 74657374322C7465737433
+DROP TABLE t1;
+########################
+# TEXT columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+t TEXT NOT NULL,
+t0 TEXT(0) NOT NULL,
+t1 TEXT(1) NOT NULL,
+t300 TEXT(300) NOT NULL,
+tm TEXT(65535) NOT NULL,
+t70k TEXT(70000) NOT NULL,
+t17m TEXT(17000000) NOT NULL,
+tt TINYTEXT NOT NULL,
+m MEDIUMTEXT NOT NULL,
+l LONGTEXT NOT NULL
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+t text NO NULL
+t0 text NO NULL
+t1 tinytext NO NULL
+t300 text NO NULL
+tm text NO NULL
+t70k mediumtext NO NULL
+t17m longtext NO NULL
+tt tinytext NO NULL
+m mediumtext NO NULL
+l longtext NO NULL
+INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+('','','','','','','','','',''),
+('a','b','c','d','e','f','g','h','i','j'),
+('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',255), REPEAT('i',1048576), REPEAT('j',1048576) );
+SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(t) LENGTH(t0) LENGTH(t1) LENGTH(t300) LENGTH(tm) LENGTH(t70k) LENGTH(t17m) LENGTH(tt) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+Warnings:
+Warning 1265 Data truncated for column 't' at row 1
+Warning 1265 Data truncated for column 't0' at row 1
+Warning 1265 Data truncated for column 't1' at row 1
+Warning 1265 Data truncated for column 't300' at row 1
+Warning 1265 Data truncated for column 'tm' at row 1
+Warning 1265 Data truncated for column 'tt' at row 1
+SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(t) LENGTH(t0) LENGTH(t1) LENGTH(t300) LENGTH(tm) LENGTH(t70k) LENGTH(t17m) LENGTH(tt) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+ALTER TABLE t1 ADD COLUMN ttt TEXT(4294967296) NOT NULL;
+ERROR 42000: Display width out of range for 'ttt' (max = 4294967295)
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# TEXT NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TEXT NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c text NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+SELECT HEX(c) FROM t1;
+HEX(c)
+
+DROP TABLE t1;
+#----------------------------------
+# TEXT NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c TEXT NOT NULL DEFAULT ''
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c text NO ''
+ALTER TABLE t1 ADD COLUMN err TEXT NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1
+2
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# TINYTEXT NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TINYTEXT NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c tinytext NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+SELECT HEX(c) FROM t1;
+HEX(c)
+
+DROP TABLE t1;
+#----------------------------------
+# TINYTEXT NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c TINYTEXT NOT NULL DEFAULT ''
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c tinytext NO ''
+ALTER TABLE t1 ADD COLUMN err TINYTEXT NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1
+2
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# MEDIUMTEXT NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c MEDIUMTEXT NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c mediumtext NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+SELECT HEX(c) FROM t1;
+HEX(c)
+
+DROP TABLE t1;
+#----------------------------------
+# MEDIUMTEXT NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c MEDIUMTEXT NOT NULL DEFAULT ''
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c mediumtext NO ''
+ALTER TABLE t1 ADD COLUMN err MEDIUMTEXT NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1
+2
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+#----------------------------------
+# LONGTEXT NOT NULL columns without a default
+#----------------------------------
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c LONGTEXT NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c longtext NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+SELECT HEX(c) FROM t1;
+HEX(c)
+
+DROP TABLE t1;
+#----------------------------------
+# LONGTEXT NOT NULL columns with a default
+#----------------------------------
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+c LONGTEXT NOT NULL DEFAULT ''
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+c longtext NO ''
+ALTER TABLE t1 ADD COLUMN err LONGTEXT NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+INSERT INTO t1 (c) VALUES ('');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+pk HEX(c)
+1
+2
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/col_opt_null.result b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_null.result
new file mode 100644
index 00000000..ac87cb02
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_null.result
@@ -0,0 +1,2268 @@
+########################
+# BINARY columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+b BINARY NULL,
+b0 BINARY(0) NULL,
+b1 BINARY(1) NULL,
+b20 BINARY(20) NULL,
+b255 BINARY(255) NULL,
+pk BINARY PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b binary(1) YES NULL
+b0 binary(0) YES NULL
+b1 binary(1) YES NULL
+b20 binary(20) YES NULL
+b255 binary(255) YES NULL
+pk binary(1) NO PRI NULL
+INSERT INTO t1 VALUES ('','','','','','');
+INSERT INTO t1 VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.','a');
+SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255), HEX(pk) FROM t1 ORDER BY pk;
+HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255) HEX(pk)
+00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00
+61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000 61
+INSERT INTO t1 VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256),'b');
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b0' at row 1
+Warning 1265 Data truncated for column 'b1' at row 1
+Warning 1265 Data truncated for column 'b20' at row 1
+Warning 1265 Data truncated for column 'b255' at row 1
+INSERT INTO t1 SELECT b255, b255, b255, b255, CONCAT('a',b255,b255), 'c' FROM t1;
+ERROR 23000: Duplicate entry 'c' for key 'PRIMARY'
+SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255), HEX(pk) FROM t1 ORDER BY pk;
+HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255) HEX(pk)
+00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00
+61 61 6161616161616161616161616161616161616161 787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 62
+61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000 61
+ALTER TABLE t1 ADD COLUMN b257 BINARY(257) NULL;
+ERROR 42000: Column length too big for column 'b257' (max = 255); use BLOB or TEXT instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b binary(1) YES NULL
+b0 binary(0) YES NULL
+b1 binary(1) YES NULL
+b20 binary(20) YES NULL
+b255 binary(255) YES NULL
+pk binary(1) NO PRI NULL
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c BINARY NULL,
+c1 BINARY NULL DEFAULT NULL,
+c2 BINARY NULL DEFAULT 0,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c binary(1) YES NULL
+c1 binary(1) YES NULL
+c2 binary(1) YES 0
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES (0,0,0);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 30 30 30
+3 NULL NULL 30
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 30
+3 30
+DROP TABLE t1;
+########################
+# VARBINARY columns
+########################
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (
+v0 VARBINARY(0) NULL,
+v1 VARBINARY(1) NULL,
+v64 VARBINARY(64) NULL,
+v65000 VARBINARY(65000) NULL,
+PRIMARY KEY (v64)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varbinary(0) YES NULL
+v1 varbinary(1) YES NULL
+v64 varbinary(64) NO PRI NULL
+v65000 varbinary(65000) YES NULL
+CREATE TABLE t2 (v VARBINARY(65532) NULL, PRIMARY KEY(v(255))) ENGINE=rocksdb;
+SHOW COLUMNS IN t2;
+Field Type Null Key Default Extra
+v varbinary(65532) NO PRI NULL
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+SELECT HEX(v0), HEX(v1), HEX(v64), HEX(v65000) FROM t1;
+HEX(v0) HEX(v1) HEX(v64) HEX(v65000)
+
+ 79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E2057652776652070726F7669646564206C696E6B7320746F20416D617A6F6E2E636F6D206865726520666F7220636F6E76656E69656E63652C2062757420746865792063616E20626520666F756E64206174206D616E79206F7468657220626F6F6B73746F7265732C20626F7468206F6E6C696E6520616E64206F66662E0A0A2020496620796F752077616E7420746F206861766520796F7572206661766F72697465204D7953514C202F204D61726961444220626F6F6B206C697374656420686572652C20706C65617365206C65617665206120636F6D6D656E742E0A2020466F7220646576656C6F706572732077686F2077616E7420746F20636F6465206F6E204D617269614442206F72204D7953514C0A0A2020202020202A20556E6465727374616E64696E67204D7953514C20496E7465726E616C73206279205361736861205061636865762C20666F726D6572204D7953514C20646576656C6F706572206174204D7953514C2041422E0A2020202020202020202020206F205468697320697320746865206F6E6C7920626F6F6B207765206B6E6F772061626F75742074686174206465736372696265732074686520696E7465726E616C73206F66204D617269614442202F204D7953514C2E2041206D757374206861766520666F7220616E796F6E652077686F2077616E747320746F20756E6465727374616E6420616E6420646576656C6F70206F6E204D617269614442210A2020202020202020202020206F204E6F7420616C6C20746F706963732061726520636F766572656420616E6420736F6D652070617274732061726520736C696768746C79206F757464617465642C20627574207374696C6C20746865206265737420626F6F6B206F6E207468697320746F7069632E200A2020202020202A204D7953514C20352E3120506C7567696E20446576656C6F706D656E742062792053657267656920476F6C75626368696B20616E6420416E64726577204875746368696E67730A2020202020202020202020206F2041206D757374207265616420666F7220616E796F6E652077616E74696E6720746F207772697465206120706C7567696E20666F72204D6172696144422C207772697474656E20627920746865205365726765692077686F2064657369676E65642074686520706C7567696E20696E7465726661636520666F72204D7953514C20616E64204D61726961444221200A0A2020466F72204D617269614442202F204D7953514C20656E642075736572730A0A2020202020202A204D61726961444220437261736820436F757273652062792042656E20466F7274610A2020202020202020202020206F204669727374204D61726961444220626F6F6B210A2020202020202020202020206F20466F722070656F706C652077686F2077616E7420746F206C6561726E2053514C20616E642074686520626173696373206F66204D6172696144422E0A2020202020202020202020206F204E6F77207368697070696E672E20507572636861736520617420416D617A6F6E2E636F6D206F7220796F7572206661766F7269746520626F6F6B73656C6C65722E200A0A2020202020202A2053514C2D393920436F6D706C6574652C205265616C6C792062792050657465722047756C75747A616E20262054727564792050656C7A65722E0A2020202020202020202020206F2045766572797468696E6720796F752077616E74656420746F206B6E6F772061626F7574207468652053514C203939207374616E646172642E20457863656C6C656E74207265666572656E636520626F6F6B210A2020202020202020202020206F204672656520746F207265616420696E20746865204B6E6F776C656467656261736521200A0A2020202020202A204D7953514C20283474682045646974696F6E29206279205061756C204475426F69730A2020202020202020202020206F20546865202764656661756C742720626F6F6B20746F207265616420696620796F7520776F6E7420746F206C6561726E20746F20757365204D7953514C202F204D6172696144422E200A0A2020202020202A204D7953514C20436F6F6B626F6F6B206279205061756C204475426F69730A2020202020202020202020206F2041206C6F74206F66206578616D706C6573206F6620686F7720746F20757365204D7953514C2E204173207769746820616C6C206F66205061756C277320626F6F6B732C206974277320776F727468206974732077656967687420696E20676F6C6420616E64206576656E20656E6A6F7961626C652072656164696E6720666F7220737563682061202764727927207375626A6563742E200A0A2020202020202A204869676820506572666F726D616E6365204D7953514C2C205365636F6E642045646974696F6E2C204279204261726F6E20536368776172747A2C205065746572205A6169747365762C20566164696D20546B616368656E6B6F2C204A6572656D7920442E205A61776F646E792C2041726A656E204C656E747A2C20446572656B204A2E2042616C6C696E672C20657420616C2E0A2020202020202020202020206F20224869676820506572666F726D616E6365204D7953514C2069732074686520646566696E697469766520677569646520746F206275696C64696E6720666173742C2072656C6961626C652073797374656D732077697468204D7953514C2E205772697474656E206279206E6F74656420657870657274732077697468207965617273206F66207265616C2D776F726C6420657870657269656E6365206275696C64696E672076657279206C617267652073797374656D732C207468697320626F6F6B20636F7665727320657665727920617370656374206F66204D7953514C20706572666F726D616E636520696E2064657461696C2C20616E6420666F6375736573206F6E20726F627573746E6573732C2073656375726974792C20616E64206461746120696E746567726974792E204C6561726E20616476616E63656420746563686E697175657320696E20646570746820736F20796F752063616E206272696E67206F7574204D7953514C27732066756C6C20706F7765722E22202846726F6D2074686520626F6F6B206465736372697074696F6E206174204F275265696C6C7929200A0A2020202020202A204D7953514C2041646D696E20436F6F6B626F6F6B0A2020202020202020202020206F204120717569636B20737465702D62792D7374657020677569646520666F72204D7953514C20757365727320616E642064617461626173652061646D696E6973747261746F727320746F207461636B6C65207265616C2D776F726C64206368616C6C656E6765732077697468204D7953514C20636F6E66696775726174696F6E20616E642061646D696E697374726174696F6E200A0A2020202020202A204D7953514C20352E302043657274696669636174696F6E2053747564792047756964652C204279205061756C204475426F69732C2053746566616E2048696E7A2C204361727374656E20506564657273656E0A2020202020202020202020206F205468697320697320746865206F6666696369616C20677569646520746F20636F766572207468652070617373696E67206F66207468652074776F204D7953514C2043657274696669636174696F6E206578616D696E6174696F6E732E2049742069732076616C69642074696C6C2076657273696F6E20352E30206F6620746865207365727665722C20736F207768696C65206974206D697373657320616C6C2074686520666561747572657320617661696C61626C6520696E204D7953514C20352E3120616E6420677265617465722028696E636C7564696E67204D61726961444220352E3120616E642067726561746572292C2069742070726F7669646573206120676F6F6420626173696320756E6465727374616E64696E67206F66204D7953514C20666F722074686520656E642D757365722E20
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 1
+Warning 1265 Data truncated for column 'v1' at row 1
+Warning 1265 Data truncated for column 'v64' at row 1
+Warning 1265 Data truncated for column 'v65000' at row 1
+INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, CONCAT('a',v65000), CONCAT(v65000,v1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 5
+Warning 1265 Data truncated for column 'v1' at row 5
+Warning 1265 Data truncated for column 'v64' at row 5
+Warning 1265 Data truncated for column 'v0' at row 6
+Warning 1265 Data truncated for column 'v1' at row 6
+Warning 1265 Data truncated for column 'v64' at row 6
+Warning 1265 Data truncated for column 'v65000' at row 6
+SELECT HEX(v0), HEX(v1), HEX(v64), LENGTH(HEX(v65000)) FROM t1;
+HEX(v0) HEX(v1) HEX(v64) LENGTH(HEX(v65000))
+ 0
+ 61 0
+ 48 61486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E205765277665 5932
+ 61 61616263646566676869206162636465666768692061626364656667686920616263646566676869206162636465666768692061626364656667686920616263 130000
+ 79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 5930
+ 79 63636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363 130000
+ALTER TABLE t1 ADD COLUMN v65536 VARBINARY(65536) NULL;
+Warnings:
+Note 1246 Converting column 'v65536' from VARBINARY to BLOB
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varbinary(0) YES NULL
+v1 varbinary(1) YES NULL
+v64 varbinary(64) NO PRI NULL
+v65000 varbinary(65000) YES NULL
+v65536 mediumblob YES NULL
+DROP TABLE t1, t2;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c VARBINARY(64) NULL,
+c1 VARBINARY(64) NULL DEFAULT NULL,
+c2 VARBINARY(64) NULL DEFAULT 'test',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c varbinary(64) YES NULL
+c1 varbinary(64) YES NULL
+c2 varbinary(64) YES test
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('test','test','test');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 74657374 74657374 74657374
+3 NULL NULL 74657374
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 74657374
+3 74657374
+DROP TABLE t1;
+########################
+# BIT columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+a BIT NULL,
+b BIT(20) NULL,
+c BIT(64) NULL,
+d BIT(1) NULL,
+PRIMARY KEY (c)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a bit(1) YES NULL
+b bit(20) YES NULL
+c bit(64) NO PRI NULL
+d bit(1) YES NULL
+ALTER TABLE t1 DROP COLUMN d;
+ALTER TABLE t1 ADD COLUMN d BIT(0) NULL;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a bit(1) YES NULL
+b bit(20) YES NULL
+c bit(64) NO PRI NULL
+d bit(1) YES NULL
+INSERT INTO t1 (a,b,c,d) VALUES (0,POW(2,20)-1,b'1111111111111111111111111111111111111111111111111111111111111111',1);
+SELECT BIN(a), HEX(b), c+0 FROM t1 WHERE d>0;
+BIN(a) HEX(b) c+0
+0 FFFFF 18446744073709551615
+INSERT INTO t1 (a,b,c,d) VALUES (1,0,-2,0);
+SELECT a+0, b+0, c+0 FROM t1 WHERE d<100;
+a+0 b+0 c+0
+0 1048575 18446744073709551615
+1 0 18446744073709551614
+INSERT INTO t1 (a,b,c,d) VALUES (b'1', 'f', 0xFF, 0x0);
+SELECT a+0, b+0, c+0 FROM t1 WHERE d IN (0, 2);
+a+0 b+0 c+0
+1 0 18446744073709551614
+1 102 255
+DELETE FROM t1;
+INSERT INTO t1 (a,b,c,d) VALUES (0x10,0,0,1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+SELECT a+0,b+0,c+0,d+0 FROM t1;
+a+0 b+0 c+0 d+0
+1 0 0 1
+INSERT INTO t1 (a,b,c,d) VALUES (0x01,0,0x10000000000000000,0);
+Warnings:
+Warning 1264 Out of range value for column 'c' at row 1
+SELECT a+0,b+0,c+0,d+0 FROM t1;
+a+0 b+0 c+0 d+0
+1 0 0 1
+1 0 18446744073709551615 0
+DROP TABLE t1;
+CREATE TABLE t1 (pk INT PRIMARY KEY, a BIT(65) NULL) ENGINE=rocksdb;
+ERROR 42000: Display width out of range for 'a' (max = 64)
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c BIT NULL,
+c1 BIT NULL DEFAULT NULL,
+c2 BIT NULL DEFAULT 1,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c bit(1) YES NULL
+c1 bit(1) YES NULL
+c2 bit(1) YES b'1'
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES (1,1,1);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 1 1 1
+3 NULL NULL 1
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 1
+3 1
+DROP TABLE t1;
+########################
+# BLOB columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+b BLOB NULL,
+b0 BLOB(0) NULL,
+b1 BLOB(1) NULL,
+b300 BLOB(300) NULL,
+bm BLOB(65535) NULL,
+b70k BLOB(70000) NULL,
+b17m BLOB(17000000) NULL,
+t TINYBLOB NULL,
+m MEDIUMBLOB NULL,
+l LONGBLOB NULL
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+b blob YES NULL
+b0 blob YES NULL
+b1 tinyblob YES NULL
+b300 blob YES NULL
+bm blob YES NULL
+b70k mediumblob YES NULL
+b17m longblob YES NULL
+t tinyblob YES NULL
+m mediumblob YES NULL
+l longblob YES NULL
+INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+('','','','','','','','','',''),
+('a','b','c','d','e','f','g','h','i','j'),
+('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), HEX(REPEAT('g',1048576)), REPEAT('h',255), REPEAT('i',1048576), HEX(REPEAT('j',1048576)) );
+SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(b) LENGTH(b0) LENGTH(b1) LENGTH(b300) LENGTH(bm) LENGTH(b70k) LENGTH(b17m) LENGTH(t) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 2097152 255 1048576 2097152
+INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b0' at row 1
+Warning 1265 Data truncated for column 'b1' at row 1
+Warning 1265 Data truncated for column 'b300' at row 1
+Warning 1265 Data truncated for column 'bm' at row 1
+Warning 1265 Data truncated for column 't' at row 1
+SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(b) LENGTH(b0) LENGTH(b1) LENGTH(b300) LENGTH(bm) LENGTH(b70k) LENGTH(b17m) LENGTH(t) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+65535 65535 255 65535 65535 1048576 2097152 255 1048576 2097152
+ALTER TABLE t1 ADD COLUMN bbb BLOB(4294967296);
+ERROR 42000: Display width out of range for 'bbb' (max = 4294967295)
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c BLOB NULL,
+c1 BLOB NULL DEFAULT NULL,
+c2 BLOB NULL DEFAULT '',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c blob YES NULL
+c1 blob YES NULL
+c2 blob YES ''
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('','','');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2
+3 NULL NULL
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2
+3
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c TINYBLOB NULL,
+c1 TINYBLOB NULL DEFAULT NULL,
+c2 TINYBLOB NULL DEFAULT '',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinyblob YES NULL
+c1 tinyblob YES NULL
+c2 tinyblob YES ''
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('','','');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2
+3 NULL NULL
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2
+3
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c MEDIUMBLOB NULL,
+c1 MEDIUMBLOB NULL DEFAULT NULL,
+c2 MEDIUMBLOB NULL DEFAULT '',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c mediumblob YES NULL
+c1 mediumblob YES NULL
+c2 mediumblob YES ''
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('','','');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2
+3 NULL NULL
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2
+3
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c LONGBLOB NULL,
+c1 LONGBLOB NULL DEFAULT NULL,
+c2 LONGBLOB NULL DEFAULT '',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c longblob YES NULL
+c1 longblob YES NULL
+c2 longblob YES ''
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('','','');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2
+3 NULL NULL
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2
+3
+DROP TABLE t1;
+########################
+# BOOL columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+b1 BOOL NULL,
+b2 BOOLEAN NULL
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+b1 tinyint(1) YES NULL
+b2 tinyint(1) YES NULL
+INSERT INTO t1 (b1,b2) VALUES (1,TRUE);
+SELECT b1,b2 FROM t1;
+b1 b2
+1 1
+INSERT INTO t1 (b1,b2) VALUES (FALSE,0);
+SELECT b1,b2 FROM t1;
+b1 b2
+0 0
+1 1
+INSERT INTO t1 (b1,b2) VALUES (2,3);
+SELECT b1,b2 FROM t1;
+b1 b2
+0 0
+1 1
+2 3
+INSERT INTO t1 (b1,b2) VALUES (-1,-2);
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+1 1
+2 3
+SELECT IF(b1,'true','false') AS a, IF(b2,'true','false') AS b FROM t1;
+a b
+false false
+true true
+true true
+true true
+SELECT b1,b2 FROM t1 WHERE b1 = TRUE;
+b1 b2
+1 1
+SELECT b1,b2 FROM t1 WHERE b2 = FALSE;
+b1 b2
+0 0
+INSERT INTO t1 (b1,b2) VALUES ('a','b');
+Warnings:
+Warning 1366 Incorrect integer value: 'a' for column `test`.`t1`.`b1` at row 1
+Warning 1366 Incorrect integer value: 'b' for column `test`.`t1`.`b2` at row 1
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+0 0
+1 1
+2 3
+INSERT INTO t1 (b1,b2) VALUES (128,-129);
+Warnings:
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b2' at row 1
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+0 0
+1 1
+127 -128
+2 3
+ALTER TABLE t1 ADD COLUMN b3 BOOLEAN UNSIGNED NULL;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNSIGNED NULL' at line 1
+ALTER TABLE ADD COLUMN b3 BOOL ZEROFILL NULL;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ADD COLUMN b3 BOOL ZEROFILL NULL' at line 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c BOOL NULL,
+c1 BOOL NULL DEFAULT NULL,
+c2 BOOL NULL DEFAULT '0',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinyint(1) YES NULL
+c1 tinyint(1) YES NULL
+c2 tinyint(1) YES 0
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('0','0','0');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 0 0 0
+3 NULL NULL 0
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 0
+3 0
+DROP TABLE t1;
+########################
+# CHAR columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c CHAR NULL,
+c0 CHAR(0) NULL,
+c1 CHAR(1) NULL,
+c20 CHAR(20) NULL,
+c255 CHAR(255) NULL,
+PRIMARY KEY (c255)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c char(1) YES NULL
+c0 char(0) YES NULL
+c1 char(1) YES NULL
+c20 char(20) YES NULL
+c255 char(255) NO PRI NULL
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('','','','','');
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.');
+SELECT c,c0,c1,c20,c255 FROM t1;
+c c0 c1 c20 c255
+
+a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+Warning 1265 Data truncated for column 'c0' at row 1
+Warning 1265 Data truncated for column 'c1' at row 1
+Warning 1265 Data truncated for column 'c20' at row 1
+Warning 1265 Data truncated for column 'c255' at row 1
+INSERT INTO t1 (c,c0,c1,c20,c255) SELECT c255, c255, c255, c255, CONCAT('a',c255,c1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 5
+Warning 1265 Data truncated for column 'c0' at row 5
+Warning 1265 Data truncated for column 'c1' at row 5
+Warning 1265 Data truncated for column 'c20' at row 5
+Warning 1265 Data truncated for column 'c' at row 6
+Warning 1265 Data truncated for column 'c0' at row 6
+Warning 1265 Data truncated for column 'c1' at row 6
+Warning 1265 Data truncated for column 'c20' at row 6
+Warning 1265 Data truncated for column 'c255' at row 6
+SELECT c,c0,c1,c20,c255 FROM t1;
+c c0 c1 c20 c255
+
+ a
+C C Creating an article aCreating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.b
+a a aaaaaaaaaaaaaaaaaaaa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
+x x xxxxxxxxxxxxxxxxxxxx axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+SELECT DISTINCT c20, REPEAT('a',LENGTH(c20)), COUNT(*) FROM t1 GROUP BY c1, c20;
+c20 REPEAT('a',LENGTH(c20)) COUNT(*)
+ 2
+Creating an article aaaaaaaaaaaaaaaaaaa 1
+aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa 1
+abcdefghi klmnopqrst aaaaaaaaaaaaaaaaaaaa 1
+xxxxxxxxxxxxxxxxxxxx aaaaaaaaaaaaaaaaaaaa 1
+ALTER TABLE t1 ADD COLUMN c257 CHAR(257) NULL;
+ERROR 42000: Column length too big for column 'c257' (max = 255); use BLOB or TEXT instead
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c CHAR NULL,
+c1 CHAR NULL DEFAULT NULL,
+c2 CHAR NULL DEFAULT '_',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c char(1) YES NULL
+c1 char(1) YES NULL
+c2 char(1) YES _
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('_','_','_');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 5F 5F 5F
+3 NULL NULL 5F
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 5F
+3 5F
+DROP TABLE t1;
+########################
+# VARCHAR columns
+########################
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (
+v0 VARCHAR(0) NULL,
+v1 VARCHAR(1) NULL,
+v64 VARCHAR(64) NULL,
+v65000 VARCHAR(65000) NULL,
+PRIMARY KEY (v64)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varchar(0) YES NULL
+v1 varchar(1) YES NULL
+v64 varchar(64) NO PRI NULL
+v65000 varchar(65000) YES NULL
+CREATE TABLE t2 (v VARCHAR(65532), PRIMARY KEY (v(255))) ENGINE=rocksdb;
+SHOW COLUMNS IN t2;
+Field Type Null Key Default Extra
+v varchar(65532) NO PRI NULL
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+SELECT v0,v1,v64,v65000 FROM t1;
+v0 v1 v64 v65000
+
+
+
+
+
+
+
+
+
+
+
+ y Once there, double check that an article doesn't already exist Here is a list of recommended books on MariaDB and MySQL. We've provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+ o "High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL's full power." (From the book description at O'Reilly)
+ o A lot of examples of how to use MySQL. As with all of Paul's books, it's worth its weight in gold and even enjoyable reading for such a 'dry' subject.
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Free to read in the Knowledgebase!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+ o The 'default' book to read if you wont to learn to use MySQL / MariaDB.
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ * MariaDB Crash Course by Ben Forta
+ * MySQL (4th Edition) by Paul DuBois
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ * MySQL Admin Cookbook
+ * MySQL Cookbook by Paul DuBois
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ For MariaDB / MySQL end users
+ For developers who want to code on MariaDB or MySQL
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 1
+Warning 1265 Data truncated for column 'v1' at row 1
+Warning 1265 Data truncated for column 'v64' at row 1
+Warning 1265 Data truncated for column 'v65000' at row 1
+INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, CONCAT('a',v65000), CONCAT(v65000,v1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 5
+Warning 1265 Data truncated for column 'v1' at row 5
+Warning 1265 Data truncated for column 'v64' at row 5
+Warning 1265 Data truncated for column 'v65000' at row 5
+Warning 1265 Data truncated for column 'v0' at row 6
+Warning 1265 Data truncated for column 'v1' at row 6
+Warning 1265 Data truncated for column 'v64' at row 6
+SELECT v0, v1, v64, LENGTH(v65000) FROM t1;
+v0 v1 v64 LENGTH(v65000)
+ 0
+ a 0
+ H aHere is a list of recommended books on MariaDB and MySQL. We've 2966
+ a aabcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abc 65000
+ y Once there, double check that an article doesn't already exist 2965
+ y cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 65000
+ALTER TABLE t1 ADD COLUMN v65536 VARCHAR(65536) NULL;
+Warnings:
+Note 1246 Converting column 'v65536' from VARCHAR to TEXT
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varchar(0) YES NULL
+v1 varchar(1) YES NULL
+v64 varchar(64) NO PRI NULL
+v65000 varchar(65000) YES NULL
+v65536 mediumtext YES NULL
+DROP TABLE t1, t2;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c VARCHAR(64) NULL,
+c1 VARCHAR(64) NULL DEFAULT NULL,
+c2 VARCHAR(64) NULL DEFAULT 'test default',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c varchar(64) YES NULL
+c1 varchar(64) YES NULL
+c2 varchar(64) YES test default
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('test default','test default','test default');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 746573742064656661756C74 746573742064656661756C74 746573742064656661756C74
+3 NULL NULL 746573742064656661756C74
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 746573742064656661756C74
+3 746573742064656661756C74
+DROP TABLE t1;
+########################
+# date and time columns
+########################
+set @col_opt_nullsave_time_zone=@@time_zone;
+set time_zone='UTC';
+DROP TABLE IF EXISTS t1;
+set @save_time_zone=@@time_zone;
+set time_zone='UTC';
+CREATE TABLE t1 (
+d DATE NULL,
+dt DATETIME NULL,
+ts TIMESTAMP NULL,
+t TIME NULL,
+y YEAR NULL,
+y4 YEAR(4) NULL,
+y2 YEAR(2) NULL,
+pk DATETIME PRIMARY KEY
+) ENGINE=rocksdb;
+Warnings:
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d date YES NULL
+dt datetime YES NULL
+ts timestamp YES NULL
+t time YES NULL
+y year(4) YES NULL
+y4 year(4) YES NULL
+y2 year(2) YES NULL
+pk datetime NO PRI NULL
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y,y4,y2,pk) VALUES
+('1000-01-01', '1000-01-01 00:00:00', FROM_UNIXTIME(1), '-838:59:59', '1901', '1901', '00','2012-12-12 12:12:12'),
+('9999-12-31', '9999-12-31 23:59:59', FROM_UNIXTIME(2147483647), '838:59:59', '2155', '2155', '99','2012-12-12 12:12:13'),
+('0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '00:00:00', '0', '0', '0','2012-12-12 12:12:14'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),YEAR(@tm),YEAR(@tm),'2012-12-12 12:12:15');
+SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+d dt ts t y y4 y2
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 00
+1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
+2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
+9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
+INSERT INTO t1 (d,dt,ts,t,y,y4,y2,pk) VALUES
+('999-13-32', '999-11-31 00:00:00', '0', '-839:00:00', '1900', '1900', '-1','2012-12-12 12:12:16');
+Warnings:
+Warning 1265 Data truncated for column 'd' at row 1
+Warning 1265 Data truncated for column 'dt' at row 1
+Warning 1265 Data truncated for column 'ts' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 'y' at row 1
+Warning 1264 Out of range value for column 'y4' at row 1
+Warning 1264 Out of range value for column 'y2' at row 1
+SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+d dt ts t y y4 y2
+1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
+9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 00
+2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 -838:59:59 0000 0000 00
+set time_zone=@save_time_zone;
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c DATE NULL,
+c1 DATE NULL DEFAULT NULL,
+c2 DATE NULL DEFAULT '2012-12-21',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c date YES NULL
+c1 date YES NULL
+c2 date YES 2012-12-21
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('2012-12-21','2012-12-21','2012-12-21');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 323031322D31322D3231 323031322D31322D3231 323031322D31322D3231
+3 NULL NULL 323031322D31322D3231
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 323031322D31322D3231
+3 323031322D31322D3231
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c DATETIME NULL,
+c1 DATETIME NULL DEFAULT NULL,
+c2 DATETIME NULL DEFAULT '2012-12-21 12:21:12',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c datetime YES NULL
+c1 datetime YES NULL
+c2 datetime YES 2012-12-21 12:21:12
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('2012-12-21 12:21:12','2012-12-21 12:21:12','2012-12-21 12:21:12');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 323031322D31322D32312031323A32313A3132 323031322D31322D32312031323A32313A3132 323031322D31322D32312031323A32313A3132
+3 NULL NULL 323031322D31322D32312031323A32313A3132
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 323031322D31322D32312031323A32313A3132
+3 323031322D31322D32312031323A32313A3132
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c TIMESTAMP NULL,
+c1 TIMESTAMP NULL DEFAULT NULL,
+c2 TIMESTAMP NULL DEFAULT '2012-12-21 12:21:12',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c timestamp YES NULL
+c1 timestamp YES NULL
+c2 timestamp YES 2012-12-21 12:21:12
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('2012-12-21 12:21:12','2012-12-21 12:21:12','2012-12-21 12:21:12');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 323031322D31322D32312031323A32313A3132 323031322D31322D32312031323A32313A3132 323031322D31322D32312031323A32313A3132
+3 NULL NULL 323031322D31322D32312031323A32313A3132
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 323031322D31322D32312031323A32313A3132
+3 323031322D31322D32312031323A32313A3132
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c TIME NULL,
+c1 TIME NULL DEFAULT NULL,
+c2 TIME NULL DEFAULT '12:21:12',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c time YES NULL
+c1 time YES NULL
+c2 time YES 12:21:12
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('12:21:12','12:21:12','12:21:12');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 31323A32313A3132 31323A32313A3132 31323A32313A3132
+3 NULL NULL 31323A32313A3132
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 31323A32313A3132
+3 31323A32313A3132
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c YEAR NULL,
+c1 YEAR NULL DEFAULT NULL,
+c2 YEAR NULL DEFAULT '2012',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c year(4) YES NULL
+c1 year(4) YES NULL
+c2 year(4) YES 2012
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('2012','2012','2012');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 7DC 7DC 7DC
+3 NULL NULL 7DC
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 7DC
+3 7DC
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c YEAR(2) NULL,
+c1 YEAR(2) NULL DEFAULT NULL,
+c2 YEAR(2) NULL DEFAULT '12',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+Warnings:
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c year(2) YES NULL
+c1 year(2) YES NULL
+c2 year(2) YES 12
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('12','12','12');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 C C C
+3 NULL NULL C
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 C
+3 C
+DROP TABLE t1;
+set time_zone=@col_opt_nullsave_time_zone;
+########################
+# ENUM columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+a ENUM('') NULL,
+b ENUM('test1','test2','test3','test4','test5') NULL,
+c ENUM('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') NULL,
+PRIMARY KEY (b)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a enum('') YES NULL
+b enum('test1','test2','test3','test4','test5') NO PRI NULL
+c enum('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') YES NULL
+INSERT INTO t1 (a,b,c) VALUES ('','test2','4'),('',5,2);
+SELECT a,b,c FROM t1;
+a b c
+ test2 4
+ test5 2
+INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+
+ test2 4
+ test5 2
+ALTER TABLE t1 ADD COLUMN e ENUM('a','A') NULL;
+Warnings:
+Note 1291 Column 'e' has duplicated value 'a' in ENUM
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a enum('') YES NULL
+b enum('test1','test2','test3','test4','test5') NO PRI NULL
+c enum('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') YES NULL
+e enum('a','A') YES NULL
+INSERT INTO t1 (a,b,c,e) VALUES ('','test3','75','A');
+SELECT a,b,c,e FROM t1;
+a b c e
+ NULL
+ test2 4 NULL
+ test3 75 a
+ test5 2 NULL
+SELECT a,b,c,e FROM t1 WHERE b='test2' OR a != '';
+a b c e
+ test2 4 NULL
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c ENUM('test1','test2','test3') NULL,
+c1 ENUM('test1','test2','test3') NULL DEFAULT NULL,
+c2 ENUM('test1','test2','test3') NULL DEFAULT 'test2',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c enum('test1','test2','test3') YES NULL
+c1 enum('test1','test2','test3') YES NULL
+c2 enum('test1','test2','test3') YES test2
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('test2','test2','test2');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 7465737432 7465737432 7465737432
+3 NULL NULL 7465737432
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 7465737432
+3 7465737432
+DROP TABLE t1;
+########################
+# Fixed point columns (NUMERIC, DECIMAL)
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+d DECIMAL NULL,
+d0 DECIMAL(0) NULL,
+d1_1 DECIMAL(1,1) NULL,
+d10_2 DECIMAL(10,2) NULL,
+d60_10 DECIMAL(60,10) NULL,
+n NUMERIC NULL,
+n0_0 NUMERIC(0,0) NULL,
+n1 NUMERIC(1) NULL,
+n20_4 NUMERIC(20,4) NULL,
+n65_4 NUMERIC(65,4) NULL,
+pk NUMERIC NULL PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d decimal(10,0) YES NULL
+d0 decimal(10,0) YES NULL
+d1_1 decimal(1,1) YES NULL
+d10_2 decimal(10,2) YES NULL
+d60_10 decimal(60,10) YES NULL
+n decimal(10,0) YES NULL
+n0_0 decimal(10,0) YES NULL
+n1 decimal(1,0) YES NULL
+n20_4 decimal(20,4) YES NULL
+n65_4 decimal(65,4) YES NULL
+pk decimal(10,0) NO PRI NULL
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807,1);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999,3);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807,4);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999,5);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+6
+);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999,7);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111,8);
+Warnings:
+Note 1265 Data truncated for column 'd' at row 1
+Note 1265 Data truncated for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Note 1265 Data truncated for column 'd10_2' at row 1
+Note 1265 Data truncated for column 'd60_10' at row 1
+Note 1265 Data truncated for column 'n' at row 1
+Note 1265 Data truncated for column 'n0_0' at row 1
+Note 1265 Data truncated for column 'n1' at row 1
+Note 1265 Data truncated for column 'n20_4' at row 1
+Note 1265 Data truncated for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.00 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.0000 9999999999999999999999999999999999999999999999999999999999999.1111
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66) NULL;
+ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6) NULL;
+ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66) NULL;
+ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 38
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c DECIMAL NULL,
+c1 DECIMAL NULL DEFAULT NULL,
+c2 DECIMAL NULL DEFAULT 1.1,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+Warnings:
+Note 1265 Data truncated for column 'c2' at row 1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c decimal(10,0) YES NULL
+c1 decimal(10,0) YES NULL
+c2 decimal(10,0) YES 1
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES (1.1,1.1,1.1);
+Warnings:
+Note 1265 Data truncated for column 'c' at row 1
+Note 1265 Data truncated for column 'c1' at row 1
+Note 1265 Data truncated for column 'c2' at row 1
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 1 1 1
+3 NULL NULL 1
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 1
+3 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c NUMERIC NULL,
+c1 NUMERIC NULL DEFAULT NULL,
+c2 NUMERIC NULL DEFAULT 0 ,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c decimal(10,0) YES NULL
+c1 decimal(10,0) YES NULL
+c2 decimal(10,0) YES 0
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES (0 ,0 ,0 );
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 0 0 0
+3 NULL NULL 0
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 0
+3 0
+DROP TABLE t1;
+########################
+# Floating point columns (FLOAT, DOUBLE)
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+f FLOAT NULL,
+f0 FLOAT(0) NULL,
+r1_1 REAL(1,1) NULL,
+f23_0 FLOAT(23) NULL,
+f20_3 FLOAT(20,3) NULL,
+d DOUBLE NULL,
+d1_0 DOUBLE(1,0) NULL,
+d10_10 DOUBLE PRECISION (10,10) NULL,
+d53 DOUBLE(53,0) NULL,
+d53_10 DOUBLE(53,10) NULL,
+pk DOUBLE NULL PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+f float YES NULL
+f0 float YES NULL
+r1_1 double(1,1) YES NULL
+f23_0 float YES NULL
+f20_3 float(20,3) YES NULL
+d double YES NULL
+d1_0 double(1,0) YES NULL
+d10_10 double(10,10) YES NULL
+d53 double(53,0) YES NULL
+d53_10 double(53,10) YES NULL
+pk double NO PRI NULL
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999,1);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 11111111.111
+d10_10 0.0123456789
+d1_0 8
+d53 1234566789123456800
+d53_10 100000000000000000.0000000000
+f0 12345.1
+f20_3 56789.988
+f23_0 123457000
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+99999999999999999999999999999999999999,
+99999999999999999999999999999999999999.9999999999999999,
+0.9,
+99999999999999999999999999999999999999.9,
+99999999999999999.999,
+999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+9,
+0.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999,
+3
+);
+Warnings:
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 0
+d 11111111.111
+d 1e81
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 0
+d1_0 8
+d1_0 9
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 0
+f 1e38
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999,4);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+SELECT
+CONCAT('', MAX(f)),
+CONCAT('', MAX(f0)),
+CONCAT('', MAX(r1_1)),
+CONCAT('', MAX(f23_0)),
+CONCAT('', MAX(f20_3)),
+CONCAT('', MAX(d)),
+CONCAT('', MAX(d1_0)),
+CONCAT('', MAX(d10_10)),
+CONCAT('', MAX(d53)),
+CONCAT('', MAX(d53_10)) FROM t1;
+CONCAT('', MAX(f)) 1e38
+CONCAT('', MAX(d)) 1e81
+CONCAT('', MAX(d10_10)) 0.9999999999
+CONCAT('', MAX(d1_0)) 9
+CONCAT('', MAX(d53)) 100000000000000000000000000000000000000000000000000000
+CONCAT('', MAX(d53_10)) 10000000000000000000000000000000000000000000.0000000000
+CONCAT('', MAX(f0)) 1e38
+CONCAT('', MAX(f20_3)) 99999998430674940.000
+CONCAT('', MAX(f23_0)) 1e38
+CONCAT('', MAX(r1_1)) 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+5
+);
+Warnings:
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e61
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 0.9999999999
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f 3.40282e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+999999999999999999999999999999999999999,
+999999999999999999999999999999999999999.9999999999999999,
+1.9,
+999999999999999999999999999999999999999.9,
+999999999999999999.999,
+9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+99,
+1.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999,
+6
+);
+Warnings:
+Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e61
+d 1e65
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 0.9999999999
+d10_10 0.9999999999
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f 3.40282e38
+f 3.40282e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f0 3.40282e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+f23_0 3.40282e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) NULL;
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1) NULL;
+ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35) NULL;
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c FLOAT NULL,
+c1 FLOAT NULL DEFAULT NULL,
+c2 FLOAT NULL DEFAULT 1.1 ,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c float YES NULL
+c1 float YES NULL
+c2 float YES 1.1
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES (1.1 ,1.1 ,1.1 );
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 1 1 1
+3 NULL NULL 1
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 1
+3 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c DOUBLE NULL,
+c1 DOUBLE NULL DEFAULT NULL,
+c2 DOUBLE NULL DEFAULT 0 ,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c double YES NULL
+c1 double YES NULL
+c2 double YES 0
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES (0 ,0 ,0 );
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 0 0 0
+3 NULL NULL 0
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 0
+3 0
+DROP TABLE t1;
+########################
+# INT columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+i INT NULL,
+i0 INT(0) NULL,
+i1 INT(1) NULL,
+i20 INT(20) NULL,
+t TINYINT NULL,
+t0 TINYINT(0) NULL,
+t1 TINYINT(1) NULL,
+t20 TINYINT(20) NULL,
+s SMALLINT NULL,
+s0 SMALLINT(0) NULL,
+s1 SMALLINT(1) NULL,
+s20 SMALLINT(20) NULL,
+m MEDIUMINT NULL,
+m0 MEDIUMINT(0) NULL,
+m1 MEDIUMINT(1) NULL,
+m20 MEDIUMINT(20) NULL,
+b BIGINT NULL,
+b0 BIGINT(0) NULL,
+b1 BIGINT(1) NULL,
+b20 BIGINT(20) NULL,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+i0 int(11) YES NULL
+i1 int(1) YES NULL
+i20 int(20) YES NULL
+t tinyint(4) YES NULL
+t0 tinyint(4) YES NULL
+t1 tinyint(1) YES NULL
+t20 tinyint(20) YES NULL
+s smallint(6) YES NULL
+s0 smallint(6) YES NULL
+s1 smallint(1) YES NULL
+s20 smallint(20) YES NULL
+m mediumint(9) YES NULL
+m0 mediumint(9) YES NULL
+m1 mediumint(1) YES NULL
+m20 mediumint(20) YES NULL
+b bigint(20) YES NULL
+b0 bigint(20) YES NULL
+b1 bigint(1) YES NULL
+b20 bigint(20) YES NULL
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 8
+Warning 1264 Out of range value for column 'i0' at row 8
+Warning 1264 Out of range value for column 'i1' at row 8
+Warning 1264 Out of range value for column 'i20' at row 8
+Warning 1264 Out of range value for column 't' at row 8
+Warning 1264 Out of range value for column 't0' at row 8
+Warning 1264 Out of range value for column 't1' at row 8
+Warning 1264 Out of range value for column 't20' at row 8
+Warning 1264 Out of range value for column 's' at row 8
+Warning 1264 Out of range value for column 's0' at row 8
+Warning 1264 Out of range value for column 's1' at row 8
+Warning 1264 Out of range value for column 's20' at row 8
+Warning 1264 Out of range value for column 'm' at row 8
+Warning 1264 Out of range value for column 'm0' at row 8
+Warning 1264 Out of range value for column 'm1' at row 8
+Warning 1264 Out of range value for column 'm20' at row 8
+Warning 1264 Out of range value for column 'i' at row 9
+Warning 1264 Out of range value for column 'i0' at row 9
+Warning 1264 Out of range value for column 'i1' at row 9
+Warning 1264 Out of range value for column 'i20' at row 9
+Warning 1264 Out of range value for column 't' at row 9
+Warning 1264 Out of range value for column 't0' at row 9
+Warning 1264 Out of range value for column 't1' at row 9
+Warning 1264 Out of range value for column 't20' at row 9
+Warning 1264 Out of range value for column 's' at row 9
+Warning 1264 Out of range value for column 's0' at row 9
+Warning 1264 Out of range value for column 's1' at row 9
+Warning 1264 Out of range value for column 's20' at row 9
+Warning 1264 Out of range value for column 'm' at row 9
+Warning 1264 Out of range value for column 'm0' at row 9
+Warning 1264 Out of range value for column 'm1' at row 9
+Warning 1264 Out of range value for column 'm20' at row 9
+Warning 1264 Out of range value for column 'i' at row 10
+Warning 1264 Out of range value for column 'i0' at row 10
+Warning 1264 Out of range value for column 'i1' at row 10
+Warning 1264 Out of range value for column 'i20' at row 10
+Warning 1264 Out of range value for column 't' at row 10
+Warning 1264 Out of range value for column 't0' at row 10
+Warning 1264 Out of range value for column 't1' at row 10
+Warning 1264 Out of range value for column 't20' at row 10
+Warning 1264 Out of range value for column 's' at row 10
+Warning 1264 Out of range value for column 's0' at row 10
+Warning 1264 Out of range value for column 's1' at row 10
+Warning 1264 Out of range value for column 's20' at row 10
+Warning 1264 Out of range value for column 'm' at row 10
+Warning 1264 Out of range value for column 'm0' at row 10
+Warning 1264 Out of range value for column 'm1' at row 10
+Warning 1264 Out of range value for column 'm20' at row 10
+Warning 1264 Out of range value for column 'i' at row 11
+Warning 1264 Out of range value for column 'i0' at row 11
+Warning 1264 Out of range value for column 'i1' at row 11
+Warning 1264 Out of range value for column 'i20' at row 11
+Warning 1264 Out of range value for column 't' at row 11
+Warning 1264 Out of range value for column 't0' at row 11
+Warning 1264 Out of range value for column 't1' at row 11
+Warning 1264 Out of range value for column 't20' at row 11
+Warning 1264 Out of range value for column 's' at row 11
+Warning 1264 Out of range value for column 's0' at row 11
+Warning 1264 Out of range value for column 's1' at row 11
+Warning 1264 Out of range value for column 's20' at row 11
+Warning 1264 Out of range value for column 'm' at row 11
+Warning 1264 Out of range value for column 'm0' at row 11
+Warning 1264 Out of range value for column 'm1' at row 11
+Warning 1264 Out of range value for column 'm20' at row 11
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+ALTER TABLE t1 ADD COLUMN i257 INT(257) NULL;
+ERROR 42000: Display width out of range for 'i257' (max = 255)
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c INT NULL,
+c1 INT NULL DEFAULT NULL,
+c2 INT NULL DEFAULT 2147483647,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c int(11) YES NULL
+c1 int(11) YES NULL
+c2 int(11) YES 2147483647
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES (2147483647,2147483647,2147483647);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 7FFFFFFF 7FFFFFFF 7FFFFFFF
+3 NULL NULL 7FFFFFFF
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 7FFFFFFF
+3 7FFFFFFF
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c TINYINT NULL,
+c1 TINYINT NULL DEFAULT NULL,
+c2 TINYINT NULL DEFAULT 127 ,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinyint(4) YES NULL
+c1 tinyint(4) YES NULL
+c2 tinyint(4) YES 127
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES (127 ,127 ,127 );
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 7F 7F 7F
+3 NULL NULL 7F
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 7F
+3 7F
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c SMALLINT NULL,
+c1 SMALLINT NULL DEFAULT NULL,
+c2 SMALLINT NULL DEFAULT 0,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c smallint(6) YES NULL
+c1 smallint(6) YES NULL
+c2 smallint(6) YES 0
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES (0,0,0);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 0 0 0
+3 NULL NULL 0
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 0
+3 0
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c MEDIUMINT NULL,
+c1 MEDIUMINT NULL DEFAULT NULL,
+c2 MEDIUMINT NULL DEFAULT 1,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c mediumint(9) YES NULL
+c1 mediumint(9) YES NULL
+c2 mediumint(9) YES 1
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES (1,1,1);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 1 1 1
+3 NULL NULL 1
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 1
+3 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c BIGINT NULL,
+c1 BIGINT NULL DEFAULT NULL,
+c2 BIGINT NULL DEFAULT 9223372036854775807,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c bigint(20) YES NULL
+c1 bigint(20) YES NULL
+c2 bigint(20) YES 9223372036854775807
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES (9223372036854775807,9223372036854775807,9223372036854775807);
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 7FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF
+3 NULL NULL 7FFFFFFFFFFFFFFF
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 7FFFFFFFFFFFFFFF
+3 7FFFFFFFFFFFFFFF
+DROP TABLE t1;
+########################
+# SET columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+a SET('') NULL,
+b SET('test1','test2','test3','test4','test5') NULL,
+c SET('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') NULL,
+PRIMARY KEY (c)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a set('') YES NULL
+b set('test1','test2','test3','test4','test5') YES NULL
+c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') NO PRI NULL
+INSERT INTO t1 (a,b,c) VALUES
+('','test2,test3','01,34,44,,23'),
+('',5,2),
+(',','test4,test2','');
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+ test1,test3 02
+ test2,test3 01,23,34,44
+ test2,test4
+INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+ 01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50'51,52,53,54,55,56,57,58,59,60,61,62,63,64
+ test1,test3 02
+ test2,test3 01,23,34,44
+ test2,test4
+ALTER TABLE t1 ADD COLUMN e SET('a','A') NULL;
+Warnings:
+Note 1291 Column 'e' has duplicated value 'a' in SET
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a set('') YES NULL
+b set('test1','test2','test3','test4','test5') YES NULL
+c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') NO PRI NULL
+e set('a','A') YES NULL
+ALTER TABLE t1 ADD COLUMN f SET('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i') NULL;
+ERROR HY000: Too many strings for column f and SET
+SELECT a,b,c,e FROM t1 WHERE FIND_IN_SET('test2',b)>0 OR a != '';
+a b c e
+ test2,test3 01,23,34,44 NULL
+ test2,test4 NULL
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c SET('test1','test2','test3') NULL,
+c1 SET('test1','test2','test3') NULL DEFAULT NULL,
+c2 SET('test1','test2','test3') NULL DEFAULT 'test2,test3',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c set('test1','test2','test3') YES NULL
+c1 set('test1','test2','test3') YES NULL
+c2 set('test1','test2','test3') YES test2,test3
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('test2,test3','test2,test3','test2,test3');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2 74657374322C7465737433 74657374322C7465737433 74657374322C7465737433
+3 NULL NULL 74657374322C7465737433
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2 74657374322C7465737433
+3 74657374322C7465737433
+DROP TABLE t1;
+########################
+# TEXT columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+t TEXT NULL,
+t0 TEXT(0) NULL,
+t1 TEXT(1) NULL,
+t300 TEXT(300) NULL,
+tm TEXT(65535) NULL,
+t70k TEXT(70000) NULL,
+t17m TEXT(17000000) NULL,
+tt TINYTEXT NULL,
+m MEDIUMTEXT NULL,
+l LONGTEXT NULL
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+t text YES NULL
+t0 text YES NULL
+t1 tinytext YES NULL
+t300 text YES NULL
+tm text YES NULL
+t70k mediumtext YES NULL
+t17m longtext YES NULL
+tt tinytext YES NULL
+m mediumtext YES NULL
+l longtext YES NULL
+INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+('','','','','','','','','',''),
+('a','b','c','d','e','f','g','h','i','j'),
+('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',255), REPEAT('i',1048576), REPEAT('j',1048576) );
+SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(t) LENGTH(t0) LENGTH(t1) LENGTH(t300) LENGTH(tm) LENGTH(t70k) LENGTH(t17m) LENGTH(tt) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+Warnings:
+Warning 1265 Data truncated for column 't' at row 1
+Warning 1265 Data truncated for column 't0' at row 1
+Warning 1265 Data truncated for column 't1' at row 1
+Warning 1265 Data truncated for column 't300' at row 1
+Warning 1265 Data truncated for column 'tm' at row 1
+Warning 1265 Data truncated for column 'tt' at row 1
+SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(t) LENGTH(t0) LENGTH(t1) LENGTH(t300) LENGTH(tm) LENGTH(t70k) LENGTH(t17m) LENGTH(tt) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+ALTER TABLE t1 ADD COLUMN ttt TEXT(4294967296) NULL;
+ERROR 42000: Display width out of range for 'ttt' (max = 4294967295)
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c TEXT NULL,
+c1 TEXT NULL DEFAULT NULL,
+c2 TEXT NULL DEFAULT '',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c text YES NULL
+c1 text YES NULL
+c2 text YES ''
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('','','');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2
+3 NULL NULL
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2
+3
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c TINYTEXT NULL,
+c1 TINYTEXT NULL DEFAULT NULL,
+c2 TINYTEXT NULL DEFAULT '',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinytext YES NULL
+c1 tinytext YES NULL
+c2 tinytext YES ''
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('','','');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2
+3 NULL NULL
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2
+3
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c MEDIUMTEXT NULL,
+c1 MEDIUMTEXT NULL DEFAULT NULL,
+c2 MEDIUMTEXT NULL DEFAULT '',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c mediumtext YES NULL
+c1 mediumtext YES NULL
+c2 mediumtext YES ''
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('','','');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2
+3 NULL NULL
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2
+3
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c LONGTEXT NULL,
+c1 LONGTEXT NULL DEFAULT NULL,
+c2 LONGTEXT NULL DEFAULT '',
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c longtext YES NULL
+c1 longtext YES NULL
+c2 longtext YES ''
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+INSERT INTO t1 (c,c1,c2) VALUES ('','','');
+INSERT INTO t1 () VALUES ();
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c) HEX(c1) HEX(c2)
+1 NULL NULL NULL
+2
+3 NULL NULL
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+pk HEX(c2)
+1 NULL
+2
+3
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/col_opt_unsigned.result b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_unsigned.result
new file mode 100644
index 00000000..439f9be9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_unsigned.result
@@ -0,0 +1,749 @@
+########################
+# Fixed point columns (NUMERIC, DECIMAL)
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+d DECIMAL UNSIGNED,
+d0 DECIMAL(0) UNSIGNED,
+d1_1 DECIMAL(1,1) UNSIGNED,
+d10_2 DECIMAL(10,2) UNSIGNED,
+d60_10 DECIMAL(60,10) UNSIGNED,
+n NUMERIC UNSIGNED,
+n0_0 NUMERIC(0,0) UNSIGNED,
+n1 NUMERIC(1) UNSIGNED,
+n20_4 NUMERIC(20,4) UNSIGNED,
+n65_4 NUMERIC(65,4) UNSIGNED,
+pk NUMERIC UNSIGNED PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d decimal(10,0) unsigned YES NULL
+d0 decimal(10,0) unsigned YES NULL
+d1_1 decimal(1,1) unsigned YES NULL
+d10_2 decimal(10,2) unsigned YES NULL
+d60_10 decimal(60,10) unsigned YES NULL
+n decimal(10,0) unsigned YES NULL
+n0_0 decimal(10,0) unsigned YES NULL
+n1 decimal(1,0) unsigned YES NULL
+n20_4 decimal(20,4) unsigned YES NULL
+n65_4 decimal(65,4) unsigned YES NULL
+pk decimal(10,0) unsigned NO PRI NULL
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807,1);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999,3);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807,4);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999,5);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+6
+);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999,7);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111,8);
+Warnings:
+Note 1265 Data truncated for column 'd' at row 1
+Note 1265 Data truncated for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Note 1265 Data truncated for column 'd10_2' at row 1
+Note 1265 Data truncated for column 'd60_10' at row 1
+Note 1265 Data truncated for column 'n' at row 1
+Note 1265 Data truncated for column 'n0_0' at row 1
+Note 1265 Data truncated for column 'n1' at row 1
+Note 1265 Data truncated for column 'n20_4' at row 1
+Note 1265 Data truncated for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.00 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.0000 9999999999999999999999999999999999999999999999999999999999999.1111
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66) UNSIGNED;
+ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6) UNSIGNED;
+ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66) UNSIGNED;
+ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 38
+DROP TABLE t1;
+CREATE TABLE t1 (
+a DECIMAL UNSIGNED,
+b NUMERIC UNSIGNED,
+PRIMARY KEY (a)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a decimal(10,0) unsigned NO PRI NULL
+b decimal(10,0) unsigned YES NULL
+INSERT INTO t1 (a,b) VALUES (1.0,-1.0);
+Warnings:
+Warning 1264 Out of range value for column 'b' at row 1
+INSERT INTO t1 (a,b) VALUES (-100,100);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+SELECT a,b FROM t1;
+a b
+0 100
+1 0
+DROP TABLE t1;
+########################
+# Floating point columns (FLOAT, DOUBLE)
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+f FLOAT UNSIGNED,
+f0 FLOAT(0) UNSIGNED,
+r1_1 REAL(1,1) UNSIGNED,
+f23_0 FLOAT(23) UNSIGNED,
+f20_3 FLOAT(20,3) UNSIGNED,
+d DOUBLE UNSIGNED,
+d1_0 DOUBLE(1,0) UNSIGNED,
+d10_10 DOUBLE PRECISION (10,10) UNSIGNED,
+d53 DOUBLE(53,0) UNSIGNED,
+d53_10 DOUBLE(53,10) UNSIGNED,
+pk DOUBLE UNSIGNED PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+f float unsigned YES NULL
+f0 float unsigned YES NULL
+r1_1 double(1,1) unsigned YES NULL
+f23_0 float unsigned YES NULL
+f20_3 float(20,3) unsigned YES NULL
+d double unsigned YES NULL
+d1_0 double(1,0) unsigned YES NULL
+d10_10 double(10,10) unsigned YES NULL
+d53 double(53,0) unsigned YES NULL
+d53_10 double(53,10) unsigned YES NULL
+pk double unsigned NO PRI NULL
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999,1);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 11111111.111
+d10_10 0.0123456789
+d1_0 8
+d53 1234566789123456800
+d53_10 100000000000000000.0000000000
+f0 12345.1
+f20_3 56789.988
+f23_0 123457000
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+99999999999999999999999999999999999999,
+99999999999999999999999999999999999999.9999999999999999,
+0.9,
+99999999999999999999999999999999999999.9,
+99999999999999999.999,
+999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+9,
+0.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999,
+3
+);
+Warnings:
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 0
+d 11111111.111
+d 1e81
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 0
+d1_0 8
+d1_0 9
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 0
+f 1e38
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999,4);
+Warnings:
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 0
+d 0
+d 11111111.111
+d 1e81
+d10_10 0.0000000000
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 0
+d1_0 0
+d1_0 8
+d1_0 9
+d53 0
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 0.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 0
+f 0
+f 1e38
+f0 0
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 0.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 0
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 0.0
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+SELECT
+CONCAT('', MAX(f)),
+CONCAT('', MAX(f0)),
+CONCAT('', MAX(r1_1)),
+CONCAT('', MAX(f23_0)),
+CONCAT('', MAX(f20_3)),
+CONCAT('', MAX(d)),
+CONCAT('', MAX(d1_0)),
+CONCAT('', MAX(d10_10)),
+CONCAT('', MAX(d53)),
+CONCAT('', MAX(d53_10)) FROM t1;
+CONCAT('', MAX(f)) 1e38
+CONCAT('', MAX(d)) 1e81
+CONCAT('', MAX(d10_10)) 0.9999999999
+CONCAT('', MAX(d1_0)) 9
+CONCAT('', MAX(d53)) 100000000000000000000000000000000000000000000000000000
+CONCAT('', MAX(d53_10)) 10000000000000000000000000000000000000000000.0000000000
+CONCAT('', MAX(f0)) 1e38
+CONCAT('', MAX(f20_3)) 99999998430674940.000
+CONCAT('', MAX(f23_0)) 1e38
+CONCAT('', MAX(r1_1)) 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+5
+);
+Warnings:
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 0
+d 0
+d 11111111.111
+d 1e61
+d 1e81
+d10_10 0.0000000000
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 0.9999999999
+d1_0 0
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d53 0
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 0.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 0
+f 0
+f 1e38
+f 3.40282e38
+f0 0
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f20_3 0.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 0
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+r1_1 0.0
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+999999999999999999999999999999999999999,
+999999999999999999999999999999999999999.9999999999999999,
+1.9,
+999999999999999999999999999999999999999.9,
+999999999999999999.999,
+9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+99,
+1.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999,
+6
+);
+Warnings:
+Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 0
+d 0
+d 11111111.111
+d 1e61
+d 1e65
+d 1e81
+d10_10 0.0000000000
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 0.9999999999
+d10_10 0.9999999999
+d1_0 0
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d1_0 9
+d53 0
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 0.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 0
+f 0
+f 1e38
+f 3.40282e38
+f 3.40282e38
+f0 0
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f0 3.40282e38
+f20_3 0.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 0
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+f23_0 3.40282e38
+r1_1 0.0
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) UNSIGNED;
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1) UNSIGNED;
+ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35) UNSIGNED;
+DROP TABLE t1;
+CREATE TABLE t1 (
+a DOUBLE UNSIGNED,
+b FLOAT UNSIGNED,
+PRIMARY KEY (b)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a double unsigned YES NULL
+b float unsigned NO PRI NULL
+INSERT INTO t1 (a,b) VALUES (1.0,-1.0);
+Warnings:
+Warning 1264 Out of range value for column 'b' at row 1
+INSERT INTO t1 (a,b) VALUES (-100,100);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+SELECT a,b FROM t1;
+a b
+0 100
+1 0
+DROP TABLE t1;
+########################
+# INT columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+i INT UNSIGNED,
+i0 INT(0) UNSIGNED,
+i1 INT(1) UNSIGNED,
+i20 INT(20) UNSIGNED,
+t TINYINT UNSIGNED,
+t0 TINYINT(0) UNSIGNED,
+t1 TINYINT(1) UNSIGNED,
+t20 TINYINT(20) UNSIGNED,
+s SMALLINT UNSIGNED,
+s0 SMALLINT(0) UNSIGNED,
+s1 SMALLINT(1) UNSIGNED,
+s20 SMALLINT(20) UNSIGNED,
+m MEDIUMINT UNSIGNED,
+m0 MEDIUMINT(0) UNSIGNED,
+m1 MEDIUMINT(1) UNSIGNED,
+m20 MEDIUMINT(20) UNSIGNED,
+b BIGINT UNSIGNED,
+b0 BIGINT(0) UNSIGNED,
+b1 BIGINT(1) UNSIGNED,
+b20 BIGINT(20) UNSIGNED,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+i int(10) unsigned YES NULL
+i0 int(10) unsigned YES NULL
+i1 int(1) unsigned YES NULL
+i20 int(20) unsigned YES NULL
+t tinyint(3) unsigned YES NULL
+t0 tinyint(3) unsigned YES NULL
+t1 tinyint(1) unsigned YES NULL
+t20 tinyint(20) unsigned YES NULL
+s smallint(5) unsigned YES NULL
+s0 smallint(5) unsigned YES NULL
+s1 smallint(1) unsigned YES NULL
+s20 smallint(20) unsigned YES NULL
+m mediumint(8) unsigned YES NULL
+m0 mediumint(8) unsigned YES NULL
+m1 mediumint(1) unsigned YES NULL
+m20 mediumint(20) unsigned YES NULL
+b bigint(20) unsigned YES NULL
+b0 bigint(20) unsigned YES NULL
+b1 bigint(1) unsigned YES NULL
+b20 bigint(20) unsigned YES NULL
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 8
+Warning 1264 Out of range value for column 'i0' at row 8
+Warning 1264 Out of range value for column 'i1' at row 8
+Warning 1264 Out of range value for column 'i20' at row 8
+Warning 1264 Out of range value for column 't' at row 8
+Warning 1264 Out of range value for column 't0' at row 8
+Warning 1264 Out of range value for column 't1' at row 8
+Warning 1264 Out of range value for column 't20' at row 8
+Warning 1264 Out of range value for column 's' at row 8
+Warning 1264 Out of range value for column 's0' at row 8
+Warning 1264 Out of range value for column 's1' at row 8
+Warning 1264 Out of range value for column 's20' at row 8
+Warning 1264 Out of range value for column 'm' at row 8
+Warning 1264 Out of range value for column 'm0' at row 8
+Warning 1264 Out of range value for column 'm1' at row 8
+Warning 1264 Out of range value for column 'm20' at row 8
+Warning 1264 Out of range value for column 'i' at row 9
+Warning 1264 Out of range value for column 'i0' at row 9
+Warning 1264 Out of range value for column 'i1' at row 9
+Warning 1264 Out of range value for column 'i20' at row 9
+Warning 1264 Out of range value for column 't' at row 9
+Warning 1264 Out of range value for column 't0' at row 9
+Warning 1264 Out of range value for column 't1' at row 9
+Warning 1264 Out of range value for column 't20' at row 9
+Warning 1264 Out of range value for column 's' at row 9
+Warning 1264 Out of range value for column 's0' at row 9
+Warning 1264 Out of range value for column 's1' at row 9
+Warning 1264 Out of range value for column 's20' at row 9
+Warning 1264 Out of range value for column 'm' at row 9
+Warning 1264 Out of range value for column 'm0' at row 9
+Warning 1264 Out of range value for column 'm1' at row 9
+Warning 1264 Out of range value for column 'm20' at row 9
+Warning 1264 Out of range value for column 'i' at row 10
+Warning 1264 Out of range value for column 'i0' at row 10
+Warning 1264 Out of range value for column 'i1' at row 10
+Warning 1264 Out of range value for column 'i20' at row 10
+Warning 1264 Out of range value for column 't' at row 10
+Warning 1264 Out of range value for column 't0' at row 10
+Warning 1264 Out of range value for column 't1' at row 10
+Warning 1264 Out of range value for column 't20' at row 10
+Warning 1264 Out of range value for column 's' at row 10
+Warning 1264 Out of range value for column 's0' at row 10
+Warning 1264 Out of range value for column 's1' at row 10
+Warning 1264 Out of range value for column 's20' at row 10
+Warning 1264 Out of range value for column 'm' at row 10
+Warning 1264 Out of range value for column 'm0' at row 10
+Warning 1264 Out of range value for column 'm1' at row 10
+Warning 1264 Out of range value for column 'm20' at row 10
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+ALTER TABLE t1 ADD COLUMN i257 INT(257) UNSIGNED;
+ERROR 42000: Display width out of range for 'i257' (max = 255)
+DROP TABLE t1;
+CREATE TABLE t1 (
+t TINYINT UNSIGNED,
+s SMALLINT UNSIGNED,
+m MEDIUMINT UNSIGNED,
+i INT UNSIGNED,
+b BIGINT UNSIGNED,
+PRIMARY KEY (b)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+t tinyint(3) unsigned YES NULL
+s smallint(5) unsigned YES NULL
+m mediumint(8) unsigned YES NULL
+i int(10) unsigned YES NULL
+b bigint(20) unsigned NO PRI NULL
+INSERT INTO t1 (t,s,m,i,b) VALUES (255,65535,16777215,4294967295,18446744073709551615);
+INSERT INTO t1 (t,s,m,i,b) VALUES (-1,-1,-1,-1,-1);
+Warnings:
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+SELECT t,s,m,i,b FROM t1;
+t s m i b
+0 0 0 0 0
+255 65535 16777215 4294967295 18446744073709551615
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/col_opt_zerofill.result b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_zerofill.result
new file mode 100644
index 00000000..f8fdfed8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_zerofill.result
@@ -0,0 +1,731 @@
+########################
+# Fixed point columns (NUMERIC, DECIMAL)
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+d DECIMAL ZEROFILL,
+d0 DECIMAL(0) ZEROFILL,
+d1_1 DECIMAL(1,1) ZEROFILL,
+d10_2 DECIMAL(10,2) ZEROFILL,
+d60_10 DECIMAL(60,10) ZEROFILL,
+n NUMERIC ZEROFILL,
+n0_0 NUMERIC(0,0) ZEROFILL,
+n1 NUMERIC(1) ZEROFILL,
+n20_4 NUMERIC(20,4) ZEROFILL,
+n65_4 NUMERIC(65,4) ZEROFILL,
+pk NUMERIC ZEROFILL PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d decimal(10,0) unsigned zerofill YES NULL
+d0 decimal(10,0) unsigned zerofill YES NULL
+d1_1 decimal(1,1) unsigned zerofill YES NULL
+d10_2 decimal(10,2) unsigned zerofill YES NULL
+d60_10 decimal(60,10) unsigned zerofill YES NULL
+n decimal(10,0) unsigned zerofill YES NULL
+n0_0 decimal(10,0) unsigned zerofill YES NULL
+n1 decimal(1,0) unsigned zerofill YES NULL
+n20_4 decimal(20,4) unsigned zerofill YES NULL
+n65_4 decimal(65,4) unsigned zerofill YES NULL
+pk decimal(10,0) unsigned zerofill NO PRI NULL
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807,1);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999,3);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000100 0000123456 0.3 00040000.25 00000000000000000000000000000000123456789123456789.1000100000 0000001024 0000007000 8 0000000000999999.9000 0000000000000000000000000000000000000000009223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807,4);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999,5);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000100 0000123456 0.3 00040000.25 00000000000000000000000000000000123456789123456789.1000100000 0000001024 0000007000 8 0000000000999999.9000 0000000000000000000000000000000000000000009223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+6
+);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000100 0000123456 0.3 00040000.25 00000000000000000000000000000000123456789123456789.1000100000 0000001024 0000007000 8 0000000000999999.9000 0000000000000000000000000000000000000000009223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999,7);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000100 0000123456 0.3 00040000.25 00000000000000000000000000000000123456789123456789.1000100000 0000001024 0000007000 8 0000000000999999.9000 0000000000000000000000000000000000000000009223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111,8);
+Warnings:
+Note 1265 Data truncated for column 'd' at row 1
+Note 1265 Data truncated for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Note 1265 Data truncated for column 'd10_2' at row 1
+Note 1265 Data truncated for column 'd60_10' at row 1
+Note 1265 Data truncated for column 'n' at row 1
+Note 1265 Data truncated for column 'n0_0' at row 1
+Note 1265 Data truncated for column 'n1' at row 1
+Note 1265 Data truncated for column 'n20_4' at row 1
+Note 1265 Data truncated for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000100 0000123456 0.3 00040000.25 00000000000000000000000000000000123456789123456789.1000100000 0000001024 0000007000 8 0000000000999999.9000 0000000000000000000000000000000000000000009223372036854775807.0000
+9999999999 9999999999 0.9 99999999.00 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.0000 9999999999999999999999999999999999999999999999999999999999999.1111
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66) ZEROFILL;
+ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6) ZEROFILL;
+ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66) ZEROFILL;
+ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 38
+DROP TABLE t1;
+CREATE TABLE t1 (
+a DECIMAL ZEROFILL,
+b NUMERIC ZEROFILL,
+PRIMARY KEY (a)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a decimal(10,0) unsigned zerofill NO PRI NULL
+b decimal(10,0) unsigned zerofill YES NULL
+INSERT INTO t1 (a,b) VALUES (1.1,1234);
+Warnings:
+Note 1265 Data truncated for column 'a' at row 1
+SELECT a,b FROM t1;
+a b
+0000000001 0000001234
+DROP TABLE t1;
+########################
+# Floating point columns (FLOAT, DOUBLE)
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+f FLOAT ZEROFILL,
+f0 FLOAT(0) ZEROFILL,
+r1_1 REAL(1,1) ZEROFILL,
+f23_0 FLOAT(23) ZEROFILL,
+f20_3 FLOAT(20,3) ZEROFILL,
+d DOUBLE ZEROFILL,
+d1_0 DOUBLE(1,0) ZEROFILL,
+d10_10 DOUBLE PRECISION (10,10) ZEROFILL,
+d53 DOUBLE(53,0) ZEROFILL,
+d53_10 DOUBLE(53,10) ZEROFILL,
+pk DOUBLE ZEROFILL PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+f float unsigned zerofill YES NULL
+f0 float unsigned zerofill YES NULL
+r1_1 double(1,1) unsigned zerofill YES NULL
+f23_0 float unsigned zerofill YES NULL
+f20_3 float(20,3) unsigned zerofill YES NULL
+d double unsigned zerofill YES NULL
+d1_0 double(1,0) unsigned zerofill YES NULL
+d10_10 double(10,10) unsigned zerofill YES NULL
+d53 double(53,0) unsigned zerofill YES NULL
+d53_10 double(53,10) unsigned zerofill YES NULL
+pk double unsigned zerofill NO PRI NULL
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999,1);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 0000012345.1
+d 000000000011111111.111
+d10_10 0.0123456789
+d1_0 8
+d53 00000000000000000000000000000000001234566789123456800
+d53_10 000000000000000000000000100000000000000000.0000000000
+f0 0000012345.1
+f20_3 0000000000056789.988
+f23_0 000123457000
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+99999999999999999999999999999999999999,
+99999999999999999999999999999999999999.9999999999999999,
+0.9,
+99999999999999999999999999999999999999.9,
+99999999999999999.999,
+999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+9,
+0.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999,
+3
+);
+Warnings:
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 0000012345.1
+d 0000000000000000000000
+d 0000000000000000001e81
+d 000000000011111111.111
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 0
+d1_0 8
+d1_0 9
+d53 00000000000000000000000000000000000000000000000000000
+d53 00000000000000000000000000000000001234566789123456800
+d53 100000000000000000000000000000000000000000000000000000
+d53_10 000000000000000000000000000000000000000000.0000000000
+d53_10 000000000000000000000000100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 000000000000
+f 000000001e38
+f0 000000000000
+f0 000000001e38
+f0 0000012345.1
+f20_3 0000000000000000.000
+f20_3 0000000000056789.988
+f20_3 99999998430674940.000
+f23_0 000000000000
+f23_0 000000001e38
+f23_0 000123457000
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999,4);
+Warnings:
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 0000012345.1
+d 0000000000000000000000
+d 0000000000000000000000
+d 0000000000000000001e81
+d 000000000011111111.111
+d10_10 0.0000000000
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 0
+d1_0 0
+d1_0 8
+d1_0 9
+d53 00000000000000000000000000000000000000000000000000000
+d53 00000000000000000000000000000000000000000000000000000
+d53 00000000000000000000000000000000001234566789123456800
+d53 100000000000000000000000000000000000000000000000000000
+d53_10 000000000000000000000000000000000000000000.0000000000
+d53_10 000000000000000000000000000000000000000000.0000000000
+d53_10 000000000000000000000000100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 000000000000
+f 000000000000
+f 000000001e38
+f0 000000000000
+f0 000000000000
+f0 000000001e38
+f0 0000012345.1
+f20_3 0000000000000000.000
+f20_3 0000000000000000.000
+f20_3 0000000000056789.988
+f20_3 99999998430674940.000
+f23_0 000000000000
+f23_0 000000000000
+f23_0 000000001e38
+f23_0 000123457000
+r1_1 0.0
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+SELECT
+CONCAT('', MAX(f)),
+CONCAT('', MAX(f0)),
+CONCAT('', MAX(r1_1)),
+CONCAT('', MAX(f23_0)),
+CONCAT('', MAX(f20_3)),
+CONCAT('', MAX(d)),
+CONCAT('', MAX(d1_0)),
+CONCAT('', MAX(d10_10)),
+CONCAT('', MAX(d53)),
+CONCAT('', MAX(d53_10)) FROM t1;
+CONCAT('', MAX(f)) 9.999999680285692e37
+CONCAT('', MAX(d)) 1e81
+CONCAT('', MAX(d10_10)) 0.9999999999
+CONCAT('', MAX(d1_0)) 9
+CONCAT('', MAX(d53)) 100000000000000000000000000000000000000000000000000000
+CONCAT('', MAX(d53_10)) 10000000000000000000000000000000000000000000.0000000000
+CONCAT('', MAX(f0)) 9.999999680285692e37
+CONCAT('', MAX(f20_3)) 99999998430674940.000
+CONCAT('', MAX(f23_0)) 9.999999680285692e37
+CONCAT('', MAX(r1_1)) 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+5
+);
+Warnings:
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 0000012345.1
+d 0000000000000000000000
+d 0000000000000000000000
+d 0000000000000000001e61
+d 0000000000000000001e81
+d 000000000011111111.111
+d10_10 0.0000000000
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 0.9999999999
+d1_0 0
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d53 00000000000000000000000000000000000000000000000000000
+d53 00000000000000000000000000000000000000000000000000000
+d53 00000000000000000000000000000000001234566789123456800
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53_10 000000000000000000000000000000000000000000.0000000000
+d53_10 000000000000000000000000000000000000000000.0000000000
+d53_10 000000000000000000000000100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 000000000000
+f 000000000000
+f 000000001e38
+f 003.40282e38
+f0 000000000000
+f0 000000000000
+f0 000000001e38
+f0 0000012345.1
+f0 003.40282e38
+f20_3 0000000000000000.000
+f20_3 0000000000000000.000
+f20_3 0000000000056789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 000000000000
+f23_0 000000000000
+f23_0 000000001e38
+f23_0 000123457000
+f23_0 003.40282e38
+r1_1 0.0
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+999999999999999999999999999999999999999,
+999999999999999999999999999999999999999.9999999999999999,
+1.9,
+999999999999999999999999999999999999999.9,
+999999999999999999.999,
+9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+99,
+1.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999,
+6
+);
+Warnings:
+Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 0000012345.1
+d 0000000000000000000000
+d 0000000000000000000000
+d 0000000000000000001e61
+d 0000000000000000001e65
+d 0000000000000000001e81
+d 000000000011111111.111
+d10_10 0.0000000000
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 0.9999999999
+d10_10 0.9999999999
+d1_0 0
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d1_0 9
+d53 00000000000000000000000000000000000000000000000000000
+d53 00000000000000000000000000000000000000000000000000000
+d53 00000000000000000000000000000000001234566789123456800
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53_10 000000000000000000000000000000000000000000.0000000000
+d53_10 000000000000000000000000000000000000000000.0000000000
+d53_10 000000000000000000000000100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 000000000000
+f 000000000000
+f 000000001e38
+f 003.40282e38
+f 003.40282e38
+f0 000000000000
+f0 000000000000
+f0 000000001e38
+f0 0000012345.1
+f0 003.40282e38
+f0 003.40282e38
+f20_3 0000000000000000.000
+f20_3 0000000000000000.000
+f20_3 0000000000056789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 000000000000
+f23_0 000000000000
+f23_0 000000001e38
+f23_0 000123457000
+f23_0 003.40282e38
+f23_0 003.40282e38
+r1_1 0.0
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) ZEROFILL;
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1) ZEROFILL;
+ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35) ZEROFILL;
+DROP TABLE t1;
+CREATE TABLE t1 (
+a DOUBLE ZEROFILL,
+b FLOAT ZEROFILL,
+PRIMARY KEY (b)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a double unsigned zerofill YES NULL
+b float unsigned zerofill NO PRI NULL
+INSERT INTO t1 (a,b) VALUES (1,1234.5);
+SELECT a,b FROM t1;
+a b
+0000000000000000000001 0000001234.5
+DROP TABLE t1;
+########################
+# INT columns
+########################
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+i INT ZEROFILL,
+i0 INT(0) ZEROFILL,
+i1 INT(1) ZEROFILL,
+i20 INT(20) ZEROFILL,
+t TINYINT ZEROFILL,
+t0 TINYINT(0) ZEROFILL,
+t1 TINYINT(1) ZEROFILL,
+t20 TINYINT(20) ZEROFILL,
+s SMALLINT ZEROFILL,
+s0 SMALLINT(0) ZEROFILL,
+s1 SMALLINT(1) ZEROFILL,
+s20 SMALLINT(20) ZEROFILL,
+m MEDIUMINT ZEROFILL,
+m0 MEDIUMINT(0) ZEROFILL,
+m1 MEDIUMINT(1) ZEROFILL,
+m20 MEDIUMINT(20) ZEROFILL,
+b BIGINT ZEROFILL,
+b0 BIGINT(0) ZEROFILL,
+b1 BIGINT(1) ZEROFILL,
+b20 BIGINT(20) ZEROFILL,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+i int(10) unsigned zerofill YES NULL
+i0 int(10) unsigned zerofill YES NULL
+i1 int(1) unsigned zerofill YES NULL
+i20 int(20) unsigned zerofill YES NULL
+t tinyint(3) unsigned zerofill YES NULL
+t0 tinyint(3) unsigned zerofill YES NULL
+t1 tinyint(1) unsigned zerofill YES NULL
+t20 tinyint(20) unsigned zerofill YES NULL
+s smallint(5) unsigned zerofill YES NULL
+s0 smallint(5) unsigned zerofill YES NULL
+s1 smallint(1) unsigned zerofill YES NULL
+s20 smallint(20) unsigned zerofill YES NULL
+m mediumint(8) unsigned zerofill YES NULL
+m0 mediumint(8) unsigned zerofill YES NULL
+m1 mediumint(1) unsigned zerofill YES NULL
+m20 mediumint(20) unsigned zerofill YES NULL
+b bigint(20) unsigned zerofill YES NULL
+b0 bigint(20) unsigned zerofill YES NULL
+b1 bigint(1) unsigned zerofill YES NULL
+b20 bigint(20) unsigned zerofill YES NULL
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
+0000000001 0000000002 3 00000000000000000004 005 006 7 00000000000000000008 00009 00010 11 00000000000000000012 00000013 00000014 15 00000000000000000016 00000000000000000017 00000000000000000018 19 00000000000000000020
+2147483647 2147483647 2147483647 00000000002147483647 127 127 127 00000000000000000127 32767 32767 32767 00000000000000032767 08388607 08388607 8388607 00000000000008388607 09223372036854775807 09223372036854775807 9223372036854775807 09223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
+0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
+0000000001 0000000002 3 00000000000000000004 005 006 7 00000000000000000008 00009 00010 11 00000000000000000012 00000013 00000014 15 00000000000000000016 00000000000000000017 00000000000000000018 19 00000000000000000020
+2147483647 2147483647 2147483647 00000000002147483647 127 127 127 00000000000000000127 32767 32767 32767 00000000000000032767 08388607 08388607 8388607 00000000000008388607 09223372036854775807 09223372036854775807 9223372036854775807 09223372036854775807
+4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 8
+Warning 1264 Out of range value for column 'i0' at row 8
+Warning 1264 Out of range value for column 'i1' at row 8
+Warning 1264 Out of range value for column 'i20' at row 8
+Warning 1264 Out of range value for column 't' at row 8
+Warning 1264 Out of range value for column 't0' at row 8
+Warning 1264 Out of range value for column 't1' at row 8
+Warning 1264 Out of range value for column 't20' at row 8
+Warning 1264 Out of range value for column 's' at row 8
+Warning 1264 Out of range value for column 's0' at row 8
+Warning 1264 Out of range value for column 's1' at row 8
+Warning 1264 Out of range value for column 's20' at row 8
+Warning 1264 Out of range value for column 'm' at row 8
+Warning 1264 Out of range value for column 'm0' at row 8
+Warning 1264 Out of range value for column 'm1' at row 8
+Warning 1264 Out of range value for column 'm20' at row 8
+Warning 1264 Out of range value for column 'i' at row 9
+Warning 1264 Out of range value for column 'i0' at row 9
+Warning 1264 Out of range value for column 'i1' at row 9
+Warning 1264 Out of range value for column 'i20' at row 9
+Warning 1264 Out of range value for column 't' at row 9
+Warning 1264 Out of range value for column 't0' at row 9
+Warning 1264 Out of range value for column 't1' at row 9
+Warning 1264 Out of range value for column 't20' at row 9
+Warning 1264 Out of range value for column 's' at row 9
+Warning 1264 Out of range value for column 's0' at row 9
+Warning 1264 Out of range value for column 's1' at row 9
+Warning 1264 Out of range value for column 's20' at row 9
+Warning 1264 Out of range value for column 'm' at row 9
+Warning 1264 Out of range value for column 'm0' at row 9
+Warning 1264 Out of range value for column 'm1' at row 9
+Warning 1264 Out of range value for column 'm20' at row 9
+Warning 1264 Out of range value for column 'i' at row 10
+Warning 1264 Out of range value for column 'i0' at row 10
+Warning 1264 Out of range value for column 'i1' at row 10
+Warning 1264 Out of range value for column 'i20' at row 10
+Warning 1264 Out of range value for column 't' at row 10
+Warning 1264 Out of range value for column 't0' at row 10
+Warning 1264 Out of range value for column 't1' at row 10
+Warning 1264 Out of range value for column 't20' at row 10
+Warning 1264 Out of range value for column 's' at row 10
+Warning 1264 Out of range value for column 's0' at row 10
+Warning 1264 Out of range value for column 's1' at row 10
+Warning 1264 Out of range value for column 's20' at row 10
+Warning 1264 Out of range value for column 'm' at row 10
+Warning 1264 Out of range value for column 'm0' at row 10
+Warning 1264 Out of range value for column 'm1' at row 10
+Warning 1264 Out of range value for column 'm20' at row 10
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
+0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
+0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
+0000000001 0000000002 3 00000000000000000004 005 006 7 00000000000000000008 00009 00010 11 00000000000000000012 00000013 00000014 15 00000000000000000016 00000000000000000017 00000000000000000018 19 00000000000000000020
+2147483647 2147483647 2147483647 00000000002147483647 127 127 127 00000000000000000127 32767 32767 32767 00000000000000032767 08388607 08388607 8388607 00000000000008388607 09223372036854775807 09223372036854775807 9223372036854775807 09223372036854775807
+4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 09223372036854775807 09223372036854775807 9223372036854775807 09223372036854775807
+4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+ALTER TABLE t1 ADD COLUMN i257 INT(257) ZEROFILL;
+ERROR 42000: Display width out of range for 'i257' (max = 255)
+DROP TABLE t1;
+CREATE TABLE t1 (
+t TINYINT ZEROFILL,
+s SMALLINT ZEROFILL,
+m MEDIUMINT ZEROFILL,
+i INT ZEROFILL,
+b BIGINT ZEROFILL,
+PRIMARY KEY (b)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+t tinyint(3) unsigned zerofill YES NULL
+s smallint(5) unsigned zerofill YES NULL
+m mediumint(8) unsigned zerofill YES NULL
+i int(10) unsigned zerofill YES NULL
+b bigint(20) unsigned zerofill NO PRI NULL
+INSERT INTO t1 (t,s,m,i,b) VALUES (1,10,100,1000,0);
+SELECT t,s,m,i,b FROM t1;
+t s m i b
+001 00010 00000100 0000001000 00000000000000000000
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/collation.result b/storage/rocksdb/mysql-test/rocksdb/r/collation.result
new file mode 100644
index 00000000..10e0d9b0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/collation.result
@@ -0,0 +1,144 @@
+call mtr.add_suppression("Invalid pattern");
+CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text) engine=rocksdb charset utf8;
+ALTER TABLE t1 ADD INDEX (value);
+ERROR HY000: Unsupported collation on string indexed column test.t1.value Use binary collation (binary, latin1_bin, utf8_bin).
+DROP TABLE t1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.t1.value Use binary collation (latin1_bin, binary, utf8_bin).
+CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value3(50))) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.t1.value3 Use binary collation (latin1_bin, binary, utf8_bin).
+SET GLOBAL rocksdb_strict_collation_check=0;
+CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value3(50))) engine=rocksdb charset utf8;
+DROP TABLE t1;
+SET GLOBAL rocksdb_strict_collation_check=1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value2)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+CREATE TABLE t1 (id varchar(20), value varchar(50), value2 varchar(50), value3 text, primary key (id), index(value, value2)) engine=rocksdb charset latin1 collate latin1_bin;
+ALTER TABLE t1 collate=latin1_general_ci;
+DROP TABLE t1;
+CREATE TABLE t1 (id varchar(20), value varchar(50), value2 varchar(50), value3 text, primary key (id), index(value, value2)) engine=rocksdb charset utf8 collate utf8_bin;
+DROP TABLE t1;
+CREATE TABLE t1 (id varchar(20) collate latin1_bin, value varchar(50) collate utf8_bin, value2 varchar(50) collate latin1_bin, value3 text, primary key (id), index(value, value2)) engine=rocksdb;
+DROP TABLE t1;
+SET GLOBAL rocksdb_strict_collation_exceptions=t1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+CREATE TABLE t2 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.t2.value Use binary collation (latin1_bin, binary, utf8_bin).
+SET GLOBAL rocksdb_strict_collation_exceptions="t.*";
+CREATE TABLE t123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t123;
+CREATE TABLE s123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.s123.value Use binary collation (latin1_bin, binary, utf8_bin).
+SET GLOBAL rocksdb_strict_collation_exceptions=".t.*";
+CREATE TABLE xt123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE xt123;
+CREATE TABLE t123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.t123.value Use binary collation (latin1_bin, binary, utf8_bin).
+SET GLOBAL rocksdb_strict_collation_exceptions="s.*,t.*";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin).
+SET GLOBAL rocksdb_strict_collation_exceptions="s.*|t.*";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin).
+SET GLOBAL rocksdb_strict_collation_exceptions=",s.*,t.*";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin).
+SET GLOBAL rocksdb_strict_collation_exceptions="|s.*|t.*";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin).
+SET GLOBAL rocksdb_strict_collation_exceptions="s.*,,t.*";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin).
+SET GLOBAL rocksdb_strict_collation_exceptions="s.*||t.*";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin).
+SET GLOBAL rocksdb_strict_collation_exceptions="s.*,t.*,";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin).
+SET GLOBAL rocksdb_strict_collation_exceptions="s.*|t.*|";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin).
+SET GLOBAL rocksdb_strict_collation_exceptions="||||,,,,s.*,,|,,||,t.*,,|||,,,";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin).
+SET GLOBAL rocksdb_strict_collation_exceptions='t1';
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb;
+ALTER TABLE t1 AUTO_INCREMENT=1;
+DROP TABLE t1;
+CREATE TABLE t2 (id INT primary key, value varchar(50), index(value)) engine=rocksdb;
+ERROR HY000: Unsupported collation on string indexed column test.t2.value Use binary collation (latin1_bin, binary, utf8_bin).
+CREATE TABLE t2 (id INT primary key, value varchar(50)) engine=rocksdb;
+ALTER TABLE t2 ADD INDEX(value);
+ERROR HY000: Unsupported collation on string indexed column test.t2.value Use binary collation (latin1_bin, binary, utf8_bin).
+DROP TABLE t2;
+SET GLOBAL rocksdb_strict_collation_exceptions="[a-b";
+FOUND 1 /Invalid pattern in strict_collation_exceptions: \[a-b/ in mysqld.1.err
+CREATE TABLE a (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.a.value Use binary collation (latin1_bin, binary, utf8_bin).
+SET GLOBAL rocksdb_strict_collation_exceptions="[a-b]";
+CREATE TABLE a (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8;
+CREATE TABLE b (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8;
+CREATE TABLE c (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.c.value Use binary collation (latin1_bin, binary, utf8_bin).
+DROP TABLE a, b;
+call mtr.add_suppression("Invalid pattern in strict_collation_exceptions:");
+SET GLOBAL rocksdb_strict_collation_exceptions="abc\\";
+FOUND 1 /Invalid pattern in strict_collation_exceptions: abc/ in mysqld.1.err
+CREATE TABLE abc (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.abc.value Use binary collation (latin1_bin, binary, utf8_bin).
+SET GLOBAL rocksdb_strict_collation_exceptions="abc";
+CREATE TABLE abc (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8;
+CREATE TABLE abcd (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8;
+ERROR HY000: Unsupported collation on string indexed column test.abcd.value Use binary collation (latin1_bin, binary, utf8_bin).
+DROP TABLE abc;
+SET GLOBAL rocksdb_strict_collation_exceptions=null;
+SET GLOBAL rocksdb_strict_collation_check=1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value)) engine=rocksdb charset utf8;
+Warnings:
+Warning 1210 Unsupported collation on string indexed column test.t1.value Use binary collation (binary, latin1_bin, utf8_bin).
+DROP TABLE t1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text) engine=rocksdb charset utf8;
+ALTER TABLE t1 ADD INDEX (value);
+Warnings:
+Warning 1210 Unsupported collation on string indexed column test.t1.value Use binary collation (binary, latin1_bin, utf8_bin).
+DROP TABLE t1;
+CREATE TABLE t1 (id varchar(20), value varchar(50), value2 varchar(50), value3 text, primary key (id), index(value, value2)) engine=rocksdb charset latin1 collate latin1_bin;
+ALTER TABLE t1 collate=latin1_general_ci;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/collation_exception.result b/storage/rocksdb/mysql-test/rocksdb/r/collation_exception.result
new file mode 100644
index 00000000..83d72d6c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/collation_exception.result
@@ -0,0 +1,25 @@
+CREATE TABLE `r1.lol` (
+`c1` int(10) NOT NULL DEFAULT '0',
+`c2` int(11) NOT NULL DEFAULT '0',
+`c3` int(1) NOT NULL DEFAULT '0',
+`c4` int(11) NOT NULL DEFAULT '0',
+`c5` int(11) NOT NULL DEFAULT '0',
+`c6` varchar(100) NOT NULL DEFAULT '',
+`c7` varchar(100) NOT NULL DEFAULT '',
+`c8` varchar(255) NOT NULL DEFAULT '',
+`c9` int(10) NOT NULL DEFAULT '125',
+`c10` int(10) NOT NULL DEFAULT '125',
+`c11` text NOT NULL,
+`c12` int(11) NOT NULL DEFAULT '0',
+`c13` int(10) NOT NULL DEFAULT '0',
+`c14` text NOT NULL,
+`c15` blob NOT NULL,
+`c16` int(11) NOT NULL DEFAULT '0',
+`c17` int(11) NOT NULL DEFAULT '0',
+`c18` int(11) NOT NULL DEFAULT '0',
+PRIMARY KEY (`c1`),
+KEY i1 (`c4`),
+KEY i2 (`c7`),
+KEY i3 (`c2`)) ENGINE=RocksDB DEFAULT CHARSET=latin1;
+DROP INDEX i1 ON `r1.lol`;
+DROP TABLE `r1.lol`;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/com_rpc_tx.result b/storage/rocksdb/mysql-test/rocksdb/r/com_rpc_tx.result
new file mode 100644
index 00000000..789ce12e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/com_rpc_tx.result
@@ -0,0 +1,21 @@
+CREATE DATABASE db_rpc;
+USE db_rpc;
+CREATE TABLE t1(pk INT PRIMARY KEY) ENGINE=rocksdb;
+SET GLOBAL rocksdb_enable_2pc=1;
+SET autocommit = 0;
+SET autocommit = 0;
+BEGIN;
+BEGIN;
+SELECT * from t1;
+pk
+SELECT * from t1;
+pk
+INSERT INTO t1 VALUES(1);
+INSERT INTO t1 VALUES(2);
+COMMIT;
+COMMIT;
+SELECT * from db_rpc.t1;
+pk
+1
+2
+DROP DATABASE db_rpc;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/commit_in_the_middle_ddl.result b/storage/rocksdb/mysql-test/rocksdb/r/commit_in_the_middle_ddl.result
new file mode 100644
index 00000000..4d64d128
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/commit_in_the_middle_ddl.result
@@ -0,0 +1,14 @@
+DROP TABLE IF EXISTS a;
+create table a (id int, value int, primary key (id) comment 'cf_a') engine=rocksdb;
+set rocksdb_bulk_load=1;
+set rocksdb_commit_in_the_middle=1;
+alter table a add index v (value) COMMENT 'cf_a';
+set rocksdb_bulk_load=0;
+set rocksdb_commit_in_the_middle=0;
+select count(*) from a force index(primary);
+count(*)
+100000
+select count(*) from a force index(v);
+count(*)
+100000
+DROP TABLE a;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/compact_deletes.result b/storage/rocksdb/mysql-test/rocksdb/r/compact_deletes.result
new file mode 100644
index 00000000..5b3cfaf7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/compact_deletes.result
@@ -0,0 +1,78 @@
+DROP TABLE IF EXISTS r1;
+create table r1 (
+id1 int,
+id2 int,
+type int,
+value varchar(100),
+value2 int,
+value3 int,
+primary key (type, id1, id2),
+index id1_type (id1, type, value2, value, id2)
+) engine=rocksdb collate latin1_bin;
+select 'loading data';
+loading data
+loading data
+set global rocksdb_force_flush_memtable_now=1;
+optimize table r1;
+Table Op Msg_type Msg_text
+test.r1 optimize status OK
+Test 1: Do a bunch of updates without setting the compaction sysvar
+Expect: no compaction
+set global rocksdb_compaction_sequential_deletes_window=0;
+set global rocksdb_compaction_sequential_deletes= 0;
+set global rocksdb_compaction_sequential_deletes_file_size=0;
+set global rocksdb_force_flush_memtable_now=1;
+wait_for_delete: 0
+There are deletes left
+SET GLOBAL rocksdb_compaction_sequential_deletes= 0;
+SET GLOBAL rocksdb_compaction_sequential_deletes_file_size= 0;
+SET GLOBAL rocksdb_compaction_sequential_deletes_window= 0;
+Test 2: Do a bunch of updates and set the compaction sysvar
+Expect: compaction
+set global rocksdb_compaction_sequential_deletes_window=1000;
+set global rocksdb_compaction_sequential_deletes= 990;
+set global rocksdb_compaction_sequential_deletes_file_size=0;
+set global rocksdb_force_flush_memtable_now=1;
+wait_for_delete: 1
+No more deletes left
+SET GLOBAL rocksdb_compaction_sequential_deletes= 0;
+SET GLOBAL rocksdb_compaction_sequential_deletes_file_size= 0;
+SET GLOBAL rocksdb_compaction_sequential_deletes_window= 0;
+Test 3: Do a bunch of updates and set the compaction sysvar and a file size to something large
+Expect: no compaction
+set global rocksdb_compaction_sequential_deletes_window=1000;
+set global rocksdb_compaction_sequential_deletes= 1000;
+set global rocksdb_compaction_sequential_deletes_file_size=1000000;
+set global rocksdb_force_flush_memtable_now=1;
+wait_for_delete: 0
+There are deletes left
+SET GLOBAL rocksdb_compaction_sequential_deletes= 0;
+SET GLOBAL rocksdb_compaction_sequential_deletes_file_size= 0;
+SET GLOBAL rocksdb_compaction_sequential_deletes_window= 0;
+Test 4: Do a bunch of secondary key updates and set the compaction sysvar
+Expect: compaction
+set global rocksdb_compaction_sequential_deletes_window=1000;
+set global rocksdb_compaction_sequential_deletes= 50;
+set global rocksdb_compaction_sequential_deletes_file_size=0;
+set global rocksdb_force_flush_memtable_now=1;
+wait_for_delete: 1
+No more deletes left
+SET GLOBAL rocksdb_compaction_sequential_deletes= 0;
+SET GLOBAL rocksdb_compaction_sequential_deletes_file_size= 0;
+SET GLOBAL rocksdb_compaction_sequential_deletes_window= 0;
+Test 5: Do a bunch of secondary key updates and set the compaction sysvar,
+and rocksdb_compaction_sequential_deletes_count_sd turned on
+Expect: compaction
+SET @save_rocksdb_compaction_sequential_deletes_count_sd = @@global.rocksdb_compaction_sequential_deletes_count_sd;
+SET GLOBAL rocksdb_compaction_sequential_deletes_count_sd= ON;
+set global rocksdb_compaction_sequential_deletes_window=1000;
+set global rocksdb_compaction_sequential_deletes= 50;
+set global rocksdb_compaction_sequential_deletes_file_size=0;
+set global rocksdb_force_flush_memtable_now=1;
+wait_for_delete: 1
+No more deletes left
+SET GLOBAL rocksdb_compaction_sequential_deletes= 0;
+SET GLOBAL rocksdb_compaction_sequential_deletes_file_size= 0;
+SET GLOBAL rocksdb_compaction_sequential_deletes_window= 0;
+SET GLOBAL rocksdb_compaction_sequential_deletes_count_sd= @save_rocksdb_compaction_sequential_deletes_count_sd;
+drop table r1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/compression_zstd.result b/storage/rocksdb/mysql-test/rocksdb/r/compression_zstd.result
new file mode 100644
index 00000000..2c1cab7f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/compression_zstd.result
@@ -0,0 +1,3 @@
+# restart: --rocksdb_default_cf_options=compression_per_level=kZSTDNotFinalCompression;compression_opts=-14:4:0;
+create table t (id int primary key) engine=rocksdb;
+drop table t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/concurrent_alter.result b/storage/rocksdb/mysql-test/rocksdb/r/concurrent_alter.result
new file mode 100644
index 00000000..b8c73b24
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/concurrent_alter.result
@@ -0,0 +1,12 @@
+DROP DATABASE IF EXISTS mysqlslap;
+CREATE DATABASE mysqlslap;
+use mysqlslap;
+CREATE TABLE a1 (a int, b int) ENGINE=ROCKSDB;
+INSERT INTO a1 VALUES (1, 1);
+SHOW CREATE TABLE a1;
+Table Create Table
+a1 CREATE TABLE `a1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=DEFAULT_CHARSET
+DROP DATABASE mysqlslap;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/cons_snapshot_read_committed.result b/storage/rocksdb/mysql-test/rocksdb/r/cons_snapshot_read_committed.result
new file mode 100644
index 00000000..637354e0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/cons_snapshot_read_committed.result
@@ -0,0 +1,151 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE t1 (a INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=ROCKSDB;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+ERROR: 4062
+connection con2;
+select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
+STAT_TYPE VALUE
+DB_NUM_SNAPSHOTS 0
+connection con1;
+COMMIT;
+connection con2;
+select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
+STAT_TYPE VALUE
+DB_NUM_SNAPSHOTS 0
+connection con1;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+ERROR: 4062
+connection con2;
+INSERT INTO t1 (a) VALUES (1);
+connection con1;
+# If consistent read works on this isolation level (READ COMMITTED), the following SELECT should not return the value we inserted (1)
+SELECT a FROM t1;
+a
+1
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE r1 (id int primary key, value int, value2 int) engine=ROCKSDB;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+insert into r1 values (1,1,1),(2,2,2),(3,3,3),(4,4,4);
+BEGIN;
+connection con2;
+INSERT INTO r1 values (5,5,5);
+connection con1;
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+connection con2;
+INSERT INTO r1 values (6,6,6);
+connection con1;
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+COMMIT;
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+ERROR: 4062
+connection con2;
+INSERT INTO r1 values (7,7,7);
+connection con1;
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+connection con2;
+INSERT INTO r1 values (8,8,8);
+connection con1;
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+8 8 8
+COMMIT;
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+8 8 8
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+ERROR: 4062
+connection con2;
+INSERT INTO r1 values (9,9,9);
+connection con1;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+ERROR: 4062
+connection con2;
+INSERT INTO r1 values (10,10,10);
+connection con1;
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+8 8 8
+9 9 9
+10 10 10
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+ERROR: 4062
+INSERT INTO r1 values (11,11,11);
+ERROR: 0
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+8 8 8
+9 9 9
+10 10 10
+11 11 11
+drop table r1;
+connection default;
+disconnect con1;
+disconnect con2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/cons_snapshot_repeatable_read.result b/storage/rocksdb/mysql-test/rocksdb/r/cons_snapshot_repeatable_read.result
new file mode 100644
index 00000000..d9be37ee
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/cons_snapshot_repeatable_read.result
@@ -0,0 +1,144 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE t1 (a INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=ROCKSDB;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+ERROR: 0
+connection con2;
+select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
+STAT_TYPE VALUE
+DB_NUM_SNAPSHOTS 1
+connection con1;
+COMMIT;
+connection con2;
+select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
+STAT_TYPE VALUE
+DB_NUM_SNAPSHOTS 0
+connection con1;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+ERROR: 0
+connection con2;
+INSERT INTO t1 (a) VALUES (1);
+connection con1;
+# If consistent read works on this isolation level (REPEATABLE READ), the following SELECT should not return the value we inserted (1)
+SELECT a FROM t1;
+a
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE r1 (id int primary key, value int, value2 int) engine=ROCKSDB;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+insert into r1 values (1,1,1),(2,2,2),(3,3,3),(4,4,4);
+BEGIN;
+connection con2;
+INSERT INTO r1 values (5,5,5);
+connection con1;
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+connection con2;
+INSERT INTO r1 values (6,6,6);
+connection con1;
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+COMMIT;
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+ERROR: 0
+connection con2;
+INSERT INTO r1 values (7,7,7);
+connection con1;
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+connection con2;
+INSERT INTO r1 values (8,8,8);
+connection con1;
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+COMMIT;
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+8 8 8
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+ERROR: 0
+connection con2;
+INSERT INTO r1 values (9,9,9);
+connection con1;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+ERROR: 0
+connection con2;
+INSERT INTO r1 values (10,10,10);
+connection con1;
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+8 8 8
+9 9 9
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+ERROR: 0
+INSERT INTO r1 values (11,11,11);
+ERROR: 4059
+SELECT * FROM r1;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+8 8 8
+9 9 9
+10 10 10
+drop table r1;
+connection default;
+disconnect con1;
+disconnect con2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/cons_snapshot_serializable.result b/storage/rocksdb/mysql-test/rocksdb/r/cons_snapshot_serializable.result
new file mode 100644
index 00000000..9c55b0dd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/cons_snapshot_serializable.result
@@ -0,0 +1,24 @@
+# -- WARNING ----------------------------------------------------------------
+# According to I_S.ENGINES, does not support transactions.
+# If it is true, the test will most likely fail; you can
+# either create an rdiff file, or add the test to disabled.def.
+# If transactions should be supported, check the data in Information Schema.
+# ---------------------------------------------------------------------------
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE t1 (a INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=ROCKSDB;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connection con2;
+INSERT INTO t1 (a) VALUES (1);
+connection con1;
+# If consistent read works on this isolation level (SERIALIZABLE), the following SELECT should not return the value we inserted (1)
+SELECT a FROM t1;
+a
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/corrupted_data_reads_debug.result b/storage/rocksdb/mysql-test/rocksdb/r/corrupted_data_reads_debug.result
new file mode 100644
index 00000000..47f7bb92
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/corrupted_data_reads_debug.result
@@ -0,0 +1,74 @@
+#
+# Test how MyRocks handles reading corrupted data from disk.
+# Data corruption is simulated at source-code level.
+#
+#
+# A test for case when data in the table *record* is longer
+# than table DDL expects it to be
+#
+create table t1 (
+pk int not null primary key,
+col1 varchar(10)
+) engine=rocksdb;
+insert into t1 values (1,1),(2,2),(3,3);
+select * from t1;
+pk col1
+1 1
+2 2
+3 3
+set @tmp1=@@rocksdb_verify_row_debug_checksums;
+set rocksdb_verify_row_debug_checksums=1;
+set session debug_dbug= "+d,myrocks_simulate_bad_row_read1";
+select * from t1 where pk=1;
+ERROR HY000: Got error 202 'Found data corruption.' from ROCKSDB
+set session debug_dbug= "-d,myrocks_simulate_bad_row_read1";
+set rocksdb_verify_row_debug_checksums=@tmp1;
+select * from t1 where pk=1;
+pk col1
+1 1
+set session debug_dbug= "+d,myrocks_simulate_bad_row_read2";
+select * from t1 where pk=1;
+ERROR HY000: Got error 202 'Found data corruption.' from ROCKSDB
+set session debug_dbug= "-d,myrocks_simulate_bad_row_read2";
+set session debug_dbug= "+d,myrocks_simulate_bad_row_read3";
+select * from t1 where pk=1;
+ERROR HY000: Got error 202 'Found data corruption.' from ROCKSDB
+set session debug_dbug= "-d,myrocks_simulate_bad_row_read3";
+insert into t1 values(4,'0123456789');
+select * from t1;
+pk col1
+1 1
+2 2
+3 3
+4 0123456789
+drop table t1;
+#
+# A test for case when index data is longer than table DDL
+# expects it to be
+#
+create table t2 (
+pk varchar(4) not null primary key,
+col1 int not null
+) engine=rocksdb collate latin1_bin;
+insert into t2 values ('ABCD',1);
+select * from t2;
+pk col1
+ABCD 1
+set session debug_dbug= "+d,myrocks_simulate_bad_pk_read1";
+select * from t2;
+ERROR HY000: Got error 202 'Found data corruption.' from ROCKSDB
+set session debug_dbug= "-d,myrocks_simulate_bad_pk_read1";
+drop table t2;
+create table t2 (
+pk varchar(4) not null primary key,
+col1 int not null
+) engine=rocksdb;
+insert into t2 values ('ABCD',1);
+select * from t2;
+pk col1
+ABCD 1
+set session debug_dbug= "+d,myrocks_simulate_bad_pk_read1";
+select * from t2;
+ERROR HY000: Got error 202 'Found data corruption.' from ROCKSDB
+set session debug_dbug= "-d,myrocks_simulate_bad_pk_read1";
+drop table t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/covered_unpack_info_format.result b/storage/rocksdb/mysql-test/rocksdb/r/covered_unpack_info_format.result
new file mode 100644
index 00000000..19521533
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/covered_unpack_info_format.result
@@ -0,0 +1,73 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+id INT,
+fake_id INT,
+bigfield VARCHAR(4096),
+PRIMARY KEY (id),
+KEY bf (bigfield(32)),
+KEY fid (fake_id, bigfield(32))
+) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (1, 1001, REPEAT('a', 1)),
+(8, 1008, REPEAT('b', 8)),
+(24, 1024, REPEAT('c', 24)),
+(31, 1031, REPEAT('d', 31)),
+(32, 1032, REPEAT('x', 32)),
+(33, 1033, REPEAT('y', 33)),
+(128, 1128, REPEAT('z', 128));
+SELECT * FROM t1;
+id fake_id bigfield
+1 1001 a
+8 1008 bbbbbbbb
+24 1024 cccccccccccccccccccccccc
+31 1031 ddddddddddddddddddddddddddddddd
+32 1032 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+33 1033 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
+128 1128 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
+# Eligible for optimization, access via fake_id only
+SELECT id, bigfield FROM t1 FORCE INDEX(fid) WHERE fake_id = 1031;
+id bigfield
+31 ddddddddddddddddddddddddddddddd
+include/assert.inc [Eligible for optimization, access via fake_id only: 2 rocksdb_covered_secondary_key_lookups]
+# Not eligible for optimization, access via fake_id of big row.
+SELECT id, bigfield FROM t1 FORCE INDEX(fid) WHERE fake_id = 1033;
+id bigfield
+33 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
+include/assert.inc [Not eligible for optimization, access via fake_id of big row.: 0 rocksdb_covered_secondary_key_lookups]
+DROP TABLE t1;
+set session debug= '+d,MYROCKS_NO_COVERED_BITMAP_FORMAT';
+CREATE TABLE t1 (
+id INT,
+fake_id INT,
+bigfield VARCHAR(4096),
+PRIMARY KEY (id),
+KEY bf (bigfield(32)),
+KEY fid (fake_id, bigfield(32))
+) ENGINE=rocksdb;
+set session debug= '-d,MYROCKS_NO_COVERED_BITMAP_FORMAT';
+INSERT INTO t1 VALUES (1, 1001, REPEAT('a', 1)),
+(8, 1008, REPEAT('b', 8)),
+(24, 1024, REPEAT('c', 24)),
+(31, 1031, REPEAT('d', 31)),
+(32, 1032, REPEAT('x', 32)),
+(33, 1033, REPEAT('y', 33)),
+(128, 1128, REPEAT('z', 128));
+SELECT * FROM t1;
+id fake_id bigfield
+1 1001 a
+8 1008 bbbbbbbb
+24 1024 cccccccccccccccccccccccc
+31 1031 ddddddddddddddddddddddddddddddd
+32 1032 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+33 1033 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
+128 1128 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
+# No longer eligible for optimization since no covered bitmap was stored.
+SELECT id, bigfield FROM t1 FORCE INDEX(fid) WHERE fake_id = 1031;
+id bigfield
+31 ddddddddddddddddddddddddddddddd
+include/assert.inc [No longer eligible for optimization since no covered bitmap was stored.: 0 rocksdb_covered_secondary_key_lookups]
+# Not eligible for optimization.
+SELECT id, bigfield FROM t1 FORCE INDEX(fid) WHERE fake_id = 1033;
+id bigfield
+33 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
+include/assert.inc [Not eligible for optimization.: 0 rocksdb_covered_secondary_key_lookups]
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/create_no_primary_key_table.result b/storage/rocksdb/mysql-test/rocksdb/r/create_no_primary_key_table.result
new file mode 100644
index 00000000..1c45cfd0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/create_no_primary_key_table.result
@@ -0,0 +1,52 @@
+USE mysql;
+CREATE TABLE mysql_table (a INT) ENGINE=ROCKSDB;
+CREATE TABLE test.mysql_table (a INT) ENGINE=ROCKSDB;
+ERROR HY000: Table without primary key cannot be created outside mysql schema.
+USE test;
+CREATE TABLE mysql_table (a INT) ENGINE=ROCKSDB;
+ERROR HY000: Table without primary key cannot be created outside mysql schema.
+CREATE TABLE IF NOT EXISTS mysql_table_2 (a INT) ENGINE=ROCKSDB;
+ERROR HY000: Table without primary key cannot be created outside mysql schema.
+CREATE TABLE mysql_table_no_cols ENGINE=ROCKSDB;
+ERROR 42000: A table must have at least 1 column
+CREATE TABLE mysql.mysql_table_2 (a INT) ENGINE=ROCKSDB;
+CREATE TABLE mysql_primkey (a INT PRIMARY KEY, b INT, c INT, d INT, INDEX (c)) ENGINE=ROCKSDB;
+ALTER TABLE mysql_primkey DROP b, DROP a, ADD (f INT PRIMARY KEY);
+ALTER TABLE mysql_primkey DROP PRIMARY KEY;
+ERROR HY000: Table without primary key cannot be created outside mysql schema.
+CREATE TABLE mysql_primkey2 (a INT PRIMARY KEY, b INT, c INT) ENGINE=ROCKSDB;
+ALTER TABLE mysql_primkey2 DROP b;
+ALTER TABLE mysql_primkey2 ADD (b INT);
+ALTER TABLE mysql_primkey2 DROP c, DROP A;
+ERROR HY000: Table without primary key cannot be created outside mysql schema.
+CREATE TABLE mysql_primkey3 (a INT PRIMARY KEY, b INT, c INT, INDEX indexonb (b), INDEX indexonc (c)) ENGINE=ROCKSDB;
+ALTER TABLE mysql_primkey3 DROP INDEX indexonb;
+ALTER TABLE mysql_primkey3 DROP c;
+ALTER TABLE mysql_primkey3 DROP PRIMARY KEY, ADD PRIMARY KEY(b);
+CREATE TABLE mysql_primkey4(a INT, b INT, PRIMARY KEY(a), INDEX si (a, b)) ENGINE=ROCKSDB;
+DROP INDEX si ON mysql_primkey4;
+DROP INDEX `PRIMARY` ON mysql_primkey4;
+ERROR HY000: Table without primary key cannot be created outside mysql schema.
+ALTER TABLE mysql.mysql_table ADD PRIMARY KEY (a);
+ALTER TABLE mysql.mysql_table DROP PRIMARY KEY;
+SET default_storage_engine=ROCKSDB;
+CREATE TABLE mysql_noeng(a INT, b INT);
+ERROR HY000: Table without primary key cannot be created outside mysql schema.
+SET sql_mode="";
+CREATE TABLE mysql_noeng_sub(a INT, b INT) ENGINE=BOGUS_ENGINE;
+ERROR HY000: Table without primary key cannot be created outside mysql schema.
+CREATE TABLE mysql_primkey5 LIKE mysql_primkey;
+SET @@global.block_create_no_primary_key = false;
+CREATE TABLE mysql_no_primkey (a INT) ENGINE=ROCKSDB;
+SET @@global.block_create_no_primary_key = true;
+CREATE TABLE mysql_block_no_primkey LIKE mysql_no_primkey;
+ERROR HY000: Table without primary key cannot be created outside mysql schema.
+DROP TABLE mysql_primkey;
+DROP TABLE mysql_primkey2;
+DROP TABLE mysql_primkey3;
+DROP TABLE mysql_primkey4;
+DROP TABLE mysql_primkey5;
+DROP TABLE mysql_no_primkey;
+USE mysql;
+DROP TABLE mysql_table;
+DROP TABLE mysql_table_2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/create_table.result b/storage/rocksdb/mysql-test/rocksdb/r/create_table.result
new file mode 100644
index 00000000..8c879d82
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/create_table.result
@@ -0,0 +1,165 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+CREATE TABLE IF NOT EXISTS t1 (a INT PRIMARY KEY) ENGINE=rocksdb;
+Warnings:
+Note 1050 Table 't1' already exists
+CREATE TABLE t2 LIKE t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(11) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+CREATE TEMPORARY TABLE t2 (a INT PRIMARY KEY) ENGINE=rocksdb;
+ERROR HY000: Table storage engine 'ROCKSDB' does not support the create option 'TEMPORARY'
+DROP TABLE t2;
+DROP TABLE IF EXISTS t1;
+SET default_storage_engine = rocksdb;
+CREATE TABLE t1 (a INT PRIMARY KEY);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (a INT PRIMARY KEY) AS SELECT 1 AS a UNION SELECT 2 AS a;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SELECT * FROM t1;
+a
+1
+2
+FLUSH LOGS;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(c1 INT,c2 INT,c3 INT,c4 INT,c5 INT,c6 INT,c7 INT,c8 INT,c9 INT,
+c10 INT,c11 INT,c12 INT,c13 INT,c14 INT,c15 INT,c16 INT,c17 INT,
+c18 INT,c19 INT,c20 INT,c21 INT,c22 INT,c23 INT,c24 INT,c25 INT,
+c26 INT,c27 INT,c28 INT,c29 INT,c30 INT,c31 INT,c32 INT,c33 INT,
+c34 INT,c35 INT,c36 INT,c37 INT,c38 INT,c39 INT,c40 INT,c41 INT,
+c42 INT,c43 INT,c44 INT,c45 INT,c46 INT,c47 INT,c48 INT,c49 INT,
+c50 INT,c51 INT,c52 INT,c53 INT,c54 INT,c55 INT,c56 INT,c57 INT,
+c58 INT,c59 INT,c60 INT,c61 INT,c62 INT,c63 INT,c64 INT,c65 INT,
+c66 INT,c67 INT,c68 INT,c69 INT,c70 INT,c71 INT,c72 INT,c73 INT,
+c74 INT,c75 INT,c76 INT,c77 INT,c78 INT,c79 INT,c80 INT,c81 INT,
+c82 INT,c83 INT,c84 INT,c85 INT,c86 INT,c87 INT,c88 INT,c89 INT,
+c90 INT,c91 INT,c92 INT,c93 INT,c94 INT,c95 INT,c96 INT,c97 INT,
+c98 INT,c99 INT,c100 INT,c101 INT,c102 INT,c103 INT,c104 INT,
+c105 INT,c106 INT,c107 INT,c108 INT,c109 INT,c110 INT,c111 INT,
+c112 INT,c113 INT,c114 INT,c115 INT,c116 INT,c117 INT,c118 INT,
+c119 INT,c120 INT,c121 INT,c122 INT,c123 INT,c124 INT,c125 INT,
+c126 INT,c127 INT,c128 INT,c129 INT,c130 INT,c131 INT,c132 INT,
+c133 INT,c134 INT,c135 INT,c136 INT,c137 INT,c138 INT,c139 INT,
+c140 INT,c141 INT,c142 INT,c143 INT,c144 INT,c145 INT,c146 INT,
+c147 INT,c148 INT,c149 INT,c150 INT,c151 INT,c152 INT,c153 INT,
+c154 INT,c155 INT,c156 INT,c157 INT,c158 INT,c159 INT,c160 INT,
+c161 INT,c162 INT,c163 INT,c164 INT,c165 INT,c166 INT,c167 INT,
+c168 INT,c169 INT,c170 INT,c171 INT,c172 INT,c173 INT,c174 INT,
+c175 INT,c176 INT,c177 INT,c178 INT,c179 INT,c180 INT,c181 INT,
+c182 INT,c183 INT,c184 INT,c185 INT,c186 INT,c187 INT,c188 INT,
+c189 INT,c190 INT,c191 INT,c192 INT,c193 INT,c194 INT,c195 INT,
+c196 INT,c197 INT,c198 INT,c199 INT,c200 INT,c201 INT,c202 INT,
+c203 INT,c204 INT,c205 INT,c206 INT,c207 INT,c208 INT,c209 INT,
+c210 INT,c211 INT,c212 INT,c213 INT,c214 INT,c215 INT,c216 INT,
+c217 INT,c218 INT,c219 INT,c220 INT,c221 INT,c222 INT,c223 INT,
+c224 INT,c225 INT,c226 INT,c227 INT,c228 INT,c229 INT,c230 INT,
+c231 INT,c232 INT,c233 INT,c234 INT,c235 INT,c236 INT,c237 INT,
+c238 INT,c239 INT,c240 INT,c241 INT,c242 INT,c243 INT,c244 INT,
+c245 INT,c246 INT,c247 INT,c248 INT,c249 INT,c250 INT,c251 INT,
+c252 INT,c253 INT,c254 INT,c255 INT,c256 INT,c257 INT,c258 INT,
+c259 INT,c260 INT,c261 INT,c262 INT,c263 INT,c264 INT,c265 INT,
+c266 INT,c267 INT,c268 INT,c269 INT,c270 INT,c271 INT,c272 INT,
+c273 INT,c274 INT,c275 INT,c276 INT,c277 INT,c278 INT,c279 INT,
+c280 INT,c281 INT,c282 INT,c283 INT,c284 INT,c285 INT,c286 INT,
+c287 INT,c288 INT,c289 INT,c290 INT,c291 INT,c292 INT,c293 INT,
+c294 INT,c295 INT,c296 INT,c297 INT,c298 INT,c299 INT,c300 INT,
+c301 INT,c302 INT,c303 INT,c304 INT,c305 INT,c306 INT,c307 INT,
+c308 INT,c309 INT,c310 INT,c311 INT,c312 INT,c313 INT,c314 INT,
+c315 INT,c316 INT,c317 INT,c318 INT,c319 INT,c320 INT,c321 INT,
+c322 INT,c323 INT,c324 INT,c325 INT,c326 INT,c327 INT,c328 INT,
+c329 INT,c330 INT,c331 INT,c332 INT,c333 INT,c334 INT,c335 INT,
+c336 INT,c337 INT,c338 INT,c339 INT,c340 INT,c341 INT,c342 INT,
+c343 INT,c344 INT,c345 INT,c346 INT,c347 INT,c348 INT,c349 INT,
+c350 INT,c351 INT,c352 INT,c353 INT,c354 INT,c355 INT,c356 INT,
+c357 INT,c358 INT,c359 INT,c360 INT,c361 INT,c362 INT,c363 INT,
+c364 INT,c365 INT,c366 INT,c367 INT,c368 INT,c369 INT,c370 INT,
+c371 INT,c372 INT,c373 INT,c374 INT,c375 INT,c376 INT,c377 INT,
+c378 INT,c379 INT,c380 INT,c381 INT,c382 INT,c383 INT,c384 INT,
+c385 INT,c386 INT,c387 INT,c388 INT,c389 INT,c390 INT,c391 INT,
+c392 INT,c393 INT,c394 INT,c395 INT,c396 INT,c397 INT,c398 INT,
+c399 INT,c400 INT,c401 INT,c402 INT,c403 INT,c404 INT,c405 INT,
+c406 INT,c407 INT,c408 INT,c409 INT,c410 INT,c411 INT,c412 INT,
+c413 INT,c414 INT,c415 INT,c416 INT,c417 INT,c418 INT,c419 INT,
+c420 INT,c421 INT,c422 INT,c423 INT,c424 INT,c425 INT,c426 INT,
+c427 INT,c428 INT,c429 INT,c430 INT,c431 INT,c432 INT,c433 INT,
+c434 INT,c435 INT,c436 INT,c437 INT,c438 INT,c439 INT,c440 INT,
+c441 INT,c442 INT,c443 INT,c444 INT,c445 INT,c446 INT,c447 INT,
+c448 INT,
+KEY (c1,c2,c3,c4,c5,c6,c7),KEY (c8,c9,c10,c11,c12,c13,c14),
+KEY (c15,c16,c17,c18,c19,c20,c21),KEY (c22,c23,c24,c25,c26,c27,c28),
+KEY (c29,c30,c31,c32,c33,c34,c35),KEY (c36,c37,c38,c39,c40,c41,c42),
+KEY (c43,c44,c45,c46,c47,c48,c49),KEY (c50,c51,c52,c53,c54,c55,c56),
+KEY (c57,c58,c59,c60,c61,c62,c63),KEY (c64,c65,c66,c67,c68,c69,c70),
+KEY (c71,c72,c73,c74,c75,c76,c77),KEY (c78,c79,c80,c81,c82,c83,c84),
+KEY (c85,c86,c87,c88,c89,c90,c91),KEY (c92,c93,c94,c95,c96,c97,c98),
+KEY (c99,c100,c101,c102,c103,c104,c105),
+KEY (c106,c107,c108,c109,c110,c111,c112),
+KEY (c113,c114,c115,c116,c117,c118,c119),
+KEY (c120,c121,c122,c123,c124,c125,c126),
+KEY (c127,c128,c129,c130,c131,c132,c133),
+KEY (c134,c135,c136,c137,c138,c139,c140),
+KEY (c141,c142,c143,c144,c145,c146,c147),
+KEY (c148,c149,c150,c151,c152,c153,c154),
+KEY (c155,c156,c157,c158,c159,c160,c161),
+KEY (c162,c163,c164,c165,c166,c167,c168),
+KEY (c169,c170,c171,c172,c173,c174,c175),
+KEY (c176,c177,c178,c179,c180,c181,c182),
+KEY (c183,c184,c185,c186,c187,c188,c189),
+KEY (c190,c191,c192,c193,c194,c195,c196),
+KEY (c197,c198,c199,c200,c201,c202,c203),
+KEY (c204,c205,c206,c207,c208,c209,c210),
+KEY (c211,c212,c213,c214,c215,c216,c217),
+KEY (c218,c219,c220,c221,c222,c223,c224),
+KEY (c225,c226,c227,c228,c229,c230,c231),
+KEY (c232,c233,c234,c235,c236,c237,c238),
+KEY (c239,c240,c241,c242,c243,c244,c245),
+KEY (c246,c247,c248,c249,c250,c251,c252),
+KEY (c253,c254,c255,c256,c257,c258,c259),
+KEY (c260,c261,c262,c263,c264,c265,c266),
+KEY (c267,c268,c269,c270,c271,c272,c273),
+KEY (c274,c275,c276,c277,c278,c279,c280),
+KEY (c281,c282,c283,c284,c285,c286,c287),
+KEY (c288,c289,c290,c291,c292,c293,c294),
+KEY (c295,c296,c297,c298,c299,c300,c301),
+KEY (c302,c303,c304,c305,c306,c307,c308),
+KEY (c309,c310,c311,c312,c313,c314,c315),
+KEY (c316,c317,c318,c319,c320,c321,c322),
+KEY (c323,c324,c325,c326,c327,c328,c329),
+KEY (c330,c331,c332,c333,c334,c335,c336),
+KEY (c337,c338,c339,c340,c341,c342,c343),
+KEY (c344,c345,c346,c347,c348,c349,c350),
+KEY (c351,c352,c353,c354,c355,c356,c357),
+KEY (c358,c359,c360,c361,c362,c363,c364),
+KEY (c365,c366,c367,c368,c369,c370,c371),
+KEY (c372,c373,c374,c375,c376,c377,c378),
+KEY (c379,c380,c381,c382,c383,c384,c385),
+KEY (c386,c387,c388,c389,c390,c391,c392),
+KEY (c393,c394,c395,c396,c397,c398,c399),
+KEY (c400,c401,c402,c403,c404,c405,c406),
+KEY (c407,c408,c409,c410,c411,c412,c413),
+KEY (c414,c415,c416,c417,c418,c419,c420),
+KEY (c421,c422,c423,c424,c425,c426,c427),
+KEY (c428,c429,c430,c431,c432,c433,c434),
+KEY (c435,c436,c437,c438,c439,c440,c441),
+KEY (c442,c443,c444,c445,c446,c447,c448));
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/ddl_high_priority.result b/storage/rocksdb/mysql-test/rocksdb/r/ddl_high_priority.result
new file mode 100644
index 00000000..1e2636c8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/ddl_high_priority.result
@@ -0,0 +1,1058 @@
+##
+## Using the system variable high_priority_ddl"
+##
+create user test_user1@localhost;
+grant all on test to test_user1@localhost;
+create user test_user2@localhost;
+grant all on test to test_user2@localhost;
+
+## Test parameters:
+## use_sys_var = 1;
+## con_block = con1
+## con_kill = default
+## cmd = alter table t1 modify i bigint;
+## high_priority_cmd = alter high_priority table t1 modify i bigint;
+## should_kill = 1
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 read;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+alter table t1 modify i bigint;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+set high_priority_ddl = 1;
+select @@high_priority_ddl;
+@@high_priority_ddl
+1
+rename table t1 to t2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+alter table t1 modify i bigint;;
+set high_priority_ddl = 0;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 1;
+## con_block = con1
+## con_kill = default
+## cmd = alter table t1 rename t1_new;
+## high_priority_cmd = alter high_priority table t1 rename t1_new;
+## should_kill = 1
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+begin; insert into t1 values (4); select i from t1;;
+i
+1
+2
+3
+4
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+alter table t1 rename t1_new;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+set high_priority_ddl = 1;
+select @@high_priority_ddl;
+@@high_priority_ddl
+1
+rename table t1 to t2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+alter table t1 rename t1_new;;
+set high_priority_ddl = 0;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+select * from t1_new;
+i
+1
+2
+3
+drop table t1_new;
+
+## Test parameters:
+## use_sys_var = 1;
+## con_block = con1
+## con_kill = default
+## cmd = drop table t1;
+## high_priority_cmd = drop high_priority table t1;
+## should_kill = 0
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 write;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+drop table t1;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+set high_priority_ddl = 1;
+select @@high_priority_ddl;
+@@high_priority_ddl
+1
+rename table t1 to t2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+drop table t1;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+set high_priority_ddl = 0;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 1;
+## con_block = con1
+## con_kill = default
+## cmd = drop table t1;
+## high_priority_cmd = drop high_priority table t1;
+## should_kill = 1
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 read; begin; insert into t1 values (4);;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+drop table t1;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+set high_priority_ddl = 1;
+select @@high_priority_ddl;
+@@high_priority_ddl
+1
+rename table t1 to t2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+drop table t1;;
+set high_priority_ddl = 0;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 1;
+## con_block = con1
+## con_kill = con2
+## cmd = alter table t1 modify i bigint;
+## high_priority_cmd = alter high_priority table t1 modify i bigint;
+## should_kill = 0
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 read;;
+connection: con2
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and con2 exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user2 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: con2
+alter table t1 modify i bigint;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+set high_priority_ddl = 1;
+select @@high_priority_ddl;
+@@high_priority_ddl
+1
+rename table t1 to t2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+alter table t1 modify i bigint;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+set high_priority_ddl = 0;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user2 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 1;
+## con_block = con1
+## con_kill = default
+## cmd = create index idx1 on t1 (i);
+## high_priority_cmd = create high_priority index idx1 on t1 (i);
+## should_kill = 1
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 read;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+create index idx1 on t1 (i);;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+set high_priority_ddl = 1;
+select @@high_priority_ddl;
+@@high_priority_ddl
+1
+rename table t1 to t2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+create index idx1 on t1 (i);;
+set high_priority_ddl = 0;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 1;
+## con_block = con1
+## con_kill = default
+## cmd = drop index idx1 on t1;
+## high_priority_cmd = drop high_priority index idx1 on t1;
+## should_kill = 1
+## recreate_table = 0
+## throw_error = 1
+
+connection: con1
+lock tables t1 read;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES MUL NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+drop index idx1 on t1;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+set high_priority_ddl = 1;
+select @@high_priority_ddl;
+@@high_priority_ddl
+1
+rename table t1 to t2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+drop index idx1 on t1;;
+set high_priority_ddl = 0;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 1;
+## con_block = con1
+## con_kill = default
+## cmd = truncate t1;
+## high_priority_cmd = truncate high_priority t1;
+## should_kill = 1
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 read;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+truncate t1;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+set high_priority_ddl = 1;
+select @@high_priority_ddl;
+@@high_priority_ddl
+1
+rename table t1 to t2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+truncate t1;;
+set high_priority_ddl = 0;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 1;
+## con_block = con1
+## con_kill = default
+## cmd = create trigger ins_sum before insert on t1 for each row set @sum = @sum + new.i;
+## high_priority_cmd = create high_priority trigger ins_sum before insert on t1 for each row set @sum = @sum + new.i;
+## should_kill = 1
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 read;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+create trigger ins_sum before insert on t1 for each row set @sum = @sum + new.i;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+set high_priority_ddl = 1;
+select @@high_priority_ddl;
+@@high_priority_ddl
+1
+rename table t1 to t2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+create trigger ins_sum before insert on t1 for each row set @sum = @sum + new.i;;
+set high_priority_ddl = 0;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 1;
+## con_block = con1
+## con_kill = default
+## cmd = drop trigger ins_sum;
+## high_priority_cmd = drop high_priority trigger ins_sum;
+## should_kill = 1
+## recreate_table = 0
+## throw_error = 1
+
+connection: con1
+lock tables t1 read;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+drop trigger ins_sum;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+set high_priority_ddl = 1;
+select @@high_priority_ddl;
+@@high_priority_ddl
+1
+rename table t1 to t2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+drop trigger ins_sum;;
+set high_priority_ddl = 0;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 1;
+## con_block = con1
+## con_kill = default
+## cmd = optimize table t1;
+## high_priority_cmd = optimize high_priority table t1;
+## should_kill = 1
+## recreate_table = 1
+## throw_error = 0
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 read;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+optimize table t1;;
+Table Op Msg_type Msg_text
+test.t1 optimize Error Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+test.t1 optimize status Operation failed
+set high_priority_ddl = 1;
+select @@high_priority_ddl;
+@@high_priority_ddl
+1
+rename table t1 to t2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+optimize table t1;;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+set high_priority_ddl = 0;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 1;
+## con_block = con1
+## con_kill = default
+## cmd = lock tables t1 write;
+## high_priority_cmd = optimize high_priority table t1;
+## should_kill = 1
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 read;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+lock tables t1 write;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+set high_priority_ddl = 1;
+select @@high_priority_ddl;
+@@high_priority_ddl
+1
+rename table t1 to t2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+lock tables t1 write;;
+set high_priority_ddl = 0;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+unlock tables;
+drop user test_user1@localhost;
+drop user test_user2@localhost;
+drop table if exists t1;
+##
+## Using HIGH_PRIORITY syntax
+##
+create user test_user1@localhost;
+grant all on test to test_user1@localhost;
+create user test_user2@localhost;
+grant all on test to test_user2@localhost;
+
+## Test parameters:
+## use_sys_var = 0;
+## con_block = con1
+## con_kill = default
+## cmd = alter table t1 modify i bigint;
+## high_priority_cmd = alter high_priority table t1 modify i bigint;
+## should_kill = 1
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 read;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+alter table t1 modify i bigint;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+alter high_priority table t1 modify i bigint;;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 0;
+## con_block = con1
+## con_kill = default
+## cmd = alter table t1 rename t1_new;
+## high_priority_cmd = alter high_priority table t1 rename t1_new;
+## should_kill = 1
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+begin; insert into t1 values (4); select i from t1;;
+i
+1
+2
+3
+4
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+alter table t1 rename t1_new;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+alter high_priority table t1 rename t1_new;;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+select * from t1_new;
+i
+1
+2
+3
+drop table t1_new;
+
+## Test parameters:
+## use_sys_var = 0;
+## con_block = con1
+## con_kill = default
+## cmd = drop table t1;
+## high_priority_cmd = drop high_priority table t1;
+## should_kill = 0
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 write;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+drop table t1;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+drop high_priority table t1;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 0;
+## con_block = con1
+## con_kill = default
+## cmd = drop table t1;
+## high_priority_cmd = drop high_priority table t1;
+## should_kill = 1
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 read; begin; insert into t1 values (4);;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+drop table t1;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+drop high_priority table t1;;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 0;
+## con_block = con1
+## con_kill = con2
+## cmd = alter table t1 modify i bigint;
+## high_priority_cmd = alter high_priority table t1 modify i bigint;
+## should_kill = 0
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 read;;
+connection: con2
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and con2 exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user2 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: con2
+alter table t1 modify i bigint;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+alter high_priority table t1 modify i bigint;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user2 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 0;
+## con_block = con1
+## con_kill = default
+## cmd = create index idx1 on t1 (i);
+## high_priority_cmd = create high_priority index idx1 on t1 (i);
+## should_kill = 1
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 read;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+create index idx1 on t1 (i);;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+create high_priority index idx1 on t1 (i);;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 0;
+## con_block = con1
+## con_kill = default
+## cmd = drop index idx1 on t1;
+## high_priority_cmd = drop high_priority index idx1 on t1;
+## should_kill = 1
+## recreate_table = 0
+## throw_error = 1
+
+connection: con1
+lock tables t1 read;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES MUL NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+drop index idx1 on t1;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+drop high_priority index idx1 on t1;;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 0;
+## con_block = con1
+## con_kill = default
+## cmd = truncate t1;
+## high_priority_cmd = truncate high_priority t1;
+## should_kill = 1
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 read;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+truncate t1;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+truncate high_priority t1;;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 0;
+## con_block = con1
+## con_kill = default
+## cmd = create trigger ins_sum before insert on t1 for each row set @sum = @sum + new.i;
+## high_priority_cmd = create high_priority trigger ins_sum before insert on t1 for each row set @sum = @sum + new.i;
+## should_kill = 1
+## recreate_table = 1
+## throw_error = 1
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 read;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+create trigger ins_sum before insert on t1 for each row set @sum = @sum + new.i;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+create high_priority trigger ins_sum before insert on t1 for each row set @sum = @sum + new.i;;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 0;
+## con_block = con1
+## con_kill = default
+## cmd = drop trigger ins_sum;
+## high_priority_cmd = drop high_priority trigger ins_sum;
+## should_kill = 1
+## recreate_table = 0
+## throw_error = 1
+
+connection: con1
+lock tables t1 read;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+drop trigger ins_sum;;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+drop high_priority trigger ins_sum;;
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+
+## Test parameters:
+## use_sys_var = 0;
+## con_block = con1
+## con_kill = default
+## cmd = optimize table t1;
+## high_priority_cmd = optimize high_priority table t1;
+## should_kill = 1
+## recreate_table = 1
+## throw_error = 0
+
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection: con1
+lock tables t1 read;;
+connection: default
+set lock_wait_timeout = 0.02;
+set high_priority_lock_wait_timeout = 0.02;
+describe t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+connection: default (for show processlist)
+# both con1 and default exist
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+<Id> test_user1 <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+connection: default
+optimize table t1;;
+Table Op Msg_type Msg_text
+test.t1 optimize Error Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
+test.t1 optimize status Operation failed
+optimize high_priority table t1;;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+connection: default (for show processlist)
+show processlist;
+Id User Host db Command Time State Info Rows examined Rows sent Tid Srv_Id
+<Id> root <Host> test <Command> <Time> <State> <Info> <RExam> <RSent> <TID> <SrvID>
+drop user test_user1@localhost;
+drop user test_user2@localhost;
+drop table if exists t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/deadlock.result b/storage/rocksdb/mysql-test/rocksdb/r/deadlock.result
new file mode 100644
index 00000000..3e2f5709
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/deadlock.result
@@ -0,0 +1,37 @@
+#
+# Validate that deadlock errors don't occur with a high level of concurrency
+#
+# Disable for valgrind because this takes too long
+DROP DATABASE IF EXISTS mysqlslap;
+CREATE DATABASE mysqlslap;
+USE mysqlslap;
+CREATE TABLE t1(id1 BIGINT, id2 BIGINT, count INT, PRIMARY KEY(id1, id2), KEY(id2)) ENGINE=rocksdb;
+CREATE TABLE t1rev(id1 BIGINT, id2 BIGINT, count INT, PRIMARY KEY(id1, id2) COMMENT "rev:cf2", KEY(id2) COMMENT "rev:cf2") ENGINE=rocksdb;
+SET @save = @@global.rocksdb_lock_wait_timeout;
+SET GLOBAL rocksdb_lock_wait_timeout = 60;
+SELECT count from t1;
+count
+50000
+SELECT count from t1;
+count
+100000
+SELECT count from t1;
+count
+150000
+SELECT count from t1;
+count
+200000
+SELECT count from t1rev;
+count
+50000
+SELECT count from t1rev;
+count
+100000
+SELECT count from t1rev;
+count
+150000
+SELECT count from t1rev;
+count
+200000
+SET GLOBAL rocksdb_lock_wait_timeout = @save;
+DROP DATABASE mysqlslap;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/deadlock_stats.result b/storage/rocksdb/mysql-test/rocksdb/r/deadlock_stats.result
new file mode 100644
index 00000000..79cb6bb0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/deadlock_stats.result
@@ -0,0 +1,14 @@
+set @prior_lock_wait_timeout = @@rocksdb_lock_wait_timeout; set @prior_deadlock_detect = @@rocksdb_deadlock_detect; set global rocksdb_deadlock_detect = on; set global rocksdb_lock_wait_timeout = 100000;;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection default;
+create table t (i int primary key) engine=rocksdb;
+insert into t values (1), (2), (3);
+#
+# The following is disabled due:
+# MDEV-13404: MyRocks upstream uses I_S.table_statistics.row_lock_deadlocks, should we import?
+#
+disconnect con1;
+disconnect con2;
+set global rocksdb_lock_wait_timeout = @prior_lock_wait_timeout; set global rocksdb_deadlock_detect = @prior_deadlock_detect;;
+drop table t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/deadlock_tracking.result b/storage/rocksdb/mysql-test/rocksdb/r/deadlock_tracking.result
new file mode 100644
index 00000000..fffae916
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/deadlock_tracking.result
@@ -0,0 +1,488 @@
+set @prior_lock_wait_timeout = @@rocksdb_lock_wait_timeout;
+set @prior_deadlock_detect = @@rocksdb_deadlock_detect;
+set @prior_max_latest_deadlocks = @@rocksdb_max_latest_deadlocks;
+set global rocksdb_deadlock_detect = on;
+set global rocksdb_lock_wait_timeout = 10000;
+# Clears deadlock buffer of any prior deadlocks.
+set global rocksdb_max_latest_deadlocks = 0;
+set global rocksdb_max_latest_deadlocks = @prior_max_latest_deadlocks;
+create table t (i int primary key) engine=rocksdb;
+insert into t values (1), (2), (3);
+show engine rocksdb transaction status;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+----------LATEST DETECTED DEADLOCKS----------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+Deadlock #1
+begin;
+select * from t where i=1 for update;
+i
+1
+begin;
+select * from t where i=2 for update;
+i
+2
+select * from t where i=2 for update;
+select * from t where i=1 for update;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+rollback;
+i
+2
+rollback;
+show engine rocksdb transaction status;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+----------LATEST DETECTED DEADLOCKS----------
+
+*** DEADLOCK PATH
+=========================================
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+---------------WAITING FOR---------------
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+
+--------TXN_ID GOT DEADLOCK---------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+Deadlock #2
+begin;
+select * from t where i=1 for update;
+i
+1
+begin;
+select * from t where i=2 for update;
+i
+2
+select * from t where i=2 for update;
+select * from t where i=1 for update;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+rollback;
+i
+2
+rollback;
+show engine rocksdb transaction status;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+----------LATEST DETECTED DEADLOCKS----------
+
+*** DEADLOCK PATH
+=========================================
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+---------------WAITING FOR---------------
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+
+--------TXN_ID GOT DEADLOCK---------
+
+*** DEADLOCK PATH
+=========================================
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+---------------WAITING FOR---------------
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+
+--------TXN_ID GOT DEADLOCK---------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+set global rocksdb_max_latest_deadlocks = 10;
+Deadlock #3
+begin;
+select * from t where i=1 for update;
+i
+1
+begin;
+select * from t where i=2 for update;
+i
+2
+select * from t where i=2 for update;
+select * from t where i=1 for update;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+rollback;
+i
+2
+rollback;
+show engine rocksdb transaction status;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+----------LATEST DETECTED DEADLOCKS----------
+
+*** DEADLOCK PATH
+=========================================
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+---------------WAITING FOR---------------
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+
+--------TXN_ID GOT DEADLOCK---------
+
+*** DEADLOCK PATH
+=========================================
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+---------------WAITING FOR---------------
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+
+--------TXN_ID GOT DEADLOCK---------
+
+*** DEADLOCK PATH
+=========================================
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+---------------WAITING FOR---------------
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+
+--------TXN_ID GOT DEADLOCK---------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+set global rocksdb_max_latest_deadlocks = 1;
+show engine rocksdb transaction status;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+----------LATEST DETECTED DEADLOCKS----------
+
+*** DEADLOCK PATH
+=========================================
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+---------------WAITING FOR---------------
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+
+--------TXN_ID GOT DEADLOCK---------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+set rocksdb_deadlock_detect_depth = 2;
+Deadlock #4
+begin;
+select * from t where i=1 for update;
+i
+1
+begin;
+select * from t where i=2 for update;
+i
+2
+begin;
+select * from t where i=3 for update;
+i
+3
+select * from t where i=2 for update;
+select * from t where i=3 for update;
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_row_lock_deadlocks';
+select * from t where i=1 for update;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+select case when variable_value-@a = 1 then 'true' else 'false' end as deadlocks from information_schema.global_status where variable_name='rocksdb_row_lock_deadlocks';
+deadlocks
+true
+rollback;
+i
+3
+rollback;
+i
+2
+rollback;
+set global rocksdb_max_latest_deadlocks = 5;
+show engine rocksdb transaction status;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+----------LATEST DETECTED DEADLOCKS----------
+
+-------DEADLOCK EXCEEDED MAX DEPTH-------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+Deadlock #5
+begin;
+select * from t where i=1 for update;
+i
+1
+begin;
+select * from t where i=2 for update;
+i
+2
+begin;
+select * from t where i=3 lock in share mode;
+i
+3
+select * from t where i=100 for update;
+i
+select * from t where i=101 for update;
+i
+select * from t where i=2 for update;
+select * from t where i=3 lock in share mode;
+i
+3
+select * from t where i=200 for update;
+i
+select * from t where i=201 for update;
+i
+select * from t where i=1 lock in share mode;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+rollback;
+i
+2
+rollback;
+rollback;
+show engine rocksdb transaction status;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+----------LATEST DETECTED DEADLOCKS----------
+
+*** DEADLOCK PATH
+=========================================
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+---------------WAITING FOR---------------
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: SHARED
+INDEX NAME: PRIMARY
+TABLE NAME: test.t
+
+--------TXN_ID GOT DEADLOCK---------
+
+-------DEADLOCK EXCEEDED MAX DEPTH-------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+Deadlock #6
+create table t1 (id int primary key, value int) engine=rocksdb;
+insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5);
+begin;
+update t1 set value=value+100 where id=1;
+update t1 set value=value+100 where id=2;
+begin;
+update t1 set value=value+200 where id=3;
+update t1 set value=value+100 where id=3;
+update t1 set value=value+200 where id=1;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+select * from t1;
+id value
+1 101
+2 102
+3 103
+4 4
+5 5
+drop table t1;
+set global rocksdb_lock_wait_timeout = @prior_lock_wait_timeout;
+set global rocksdb_deadlock_detect = @prior_deadlock_detect;
+drop table t;
+show engine rocksdb transaction status;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+----------LATEST DETECTED DEADLOCKS----------
+
+*** DEADLOCK PATH
+=========================================
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: NOT FOUND; IDX_ID
+TABLE NAME: NOT FOUND; IDX_ID
+---------------WAITING FOR---------------
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: NOT FOUND; IDX_ID
+TABLE NAME: NOT FOUND; IDX_ID
+
+--------TXN_ID GOT DEADLOCK---------
+
+*** DEADLOCK PATH
+=========================================
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: EXCLUSIVE
+INDEX NAME: NOT FOUND; IDX_ID
+TABLE NAME: NOT FOUND; IDX_ID
+---------------WAITING FOR---------------
+TSTAMP
+TXN_ID
+COLUMN FAMILY NAME: default
+KEY
+LOCK TYPE: SHARED
+INDEX NAME: NOT FOUND; IDX_ID
+TABLE NAME: NOT FOUND; IDX_ID
+
+--------TXN_ID GOT DEADLOCK---------
+
+-------DEADLOCK EXCEEDED MAX DEPTH-------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+set global rocksdb_max_latest_deadlocks = 0;
+# Clears deadlock buffer of any existent deadlocks.
+set global rocksdb_max_latest_deadlocks = @prior_max_latest_deadlocks;
+show engine rocksdb transaction status;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+----------LATEST DETECTED DEADLOCKS----------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/delete.result b/storage/rocksdb/mysql-test/rocksdb/r/delete.result
new file mode 100644
index 00000000..8ec3c50f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/delete.result
@@ -0,0 +1,166 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (10000,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+DELETE FROM t1 WHERE b IN ('c');
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+10000 foobar
+10000 foobar
+2 b
+2 b
+4 d
+4 d
+5 e
+5 e
+DELETE FROM t1 WHERE a < 0 OR b = 'a';
+SELECT a,b FROM t1;
+a b
+10000 foobar
+10000 foobar
+2 b
+2 b
+4 d
+4 d
+5 e
+5 e
+DELETE FROM t1 WHERE a <= 4 ORDER BY b DESC LIMIT 1;
+SELECT a,b FROM t1;
+a b
+10000 foobar
+10000 foobar
+2 b
+2 b
+4 d
+5 e
+5 e
+CREATE TABLE t2 (c CHAR(8), d INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+SELECT c,d FROM t2;
+c d
+b 2
+b 2
+d 4
+e 5
+e 5
+foobar 10000
+foobar 10000
+DELETE t2.* FROM t1, t2 WHERE c < b AND a + d != 1;
+SELECT a,b FROM t1;
+a b
+10000 foobar
+10000 foobar
+2 b
+2 b
+4 d
+5 e
+5 e
+SELECT c,d FROM t2;
+c d
+foobar 10000
+foobar 10000
+DELETE FROM t2, t1.* USING t2, t1 WHERE c = 'foobar' and b = c;
+SELECT a,b FROM t1;
+a b
+2 b
+2 b
+4 d
+5 e
+5 e
+SELECT c,d FROM t2;
+c d
+DELETE FROM t1;
+SELECT a,b FROM t1;
+a b
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'f'),(7,'g'),(8,'h'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+BEGIN;
+DELETE FROM t1 WHERE b IN ('c');
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+10000 foobar
+10000 foobar
+2 b
+2 b
+4 d
+4 d
+5 e
+5 e
+6 f
+6 f
+7 g
+7 g
+8 h
+8 h
+DELETE FROM t1 WHERE a < 0 OR b = 'a';
+COMMIT;
+SELECT a,b FROM t1;
+a b
+10000 foobar
+10000 foobar
+2 b
+2 b
+4 d
+4 d
+5 e
+5 e
+6 f
+6 f
+7 g
+7 g
+8 h
+8 h
+BEGIN;
+DELETE FROM t1 WHERE a <= 4 ORDER BY b DESC LIMIT 1;
+SAVEPOINT spt1;
+DELETE FROM t1;
+RELEASE SAVEPOINT spt1;
+ROLLBACK;
+SELECT a,b FROM t1;
+a b
+10000 foobar
+10000 foobar
+2 b
+2 b
+4 d
+4 d
+5 e
+5 e
+6 f
+6 f
+7 g
+7 g
+8 h
+8 h
+BEGIN;
+DELETE FROM t1 WHERE a <= 4 ORDER BY b DESC LIMIT 1;
+SAVEPOINT spt1;
+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.
+SELECT a,b FROM t1;
+a b
+10000 foobar
+10000 foobar
+2 b
+2 b
+4 d
+4 d
+5 e
+5 e
+6 f
+6 f
+7 g
+7 g
+8 h
+8 h
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/delete_ignore.result b/storage/rocksdb/mysql-test/rocksdb/r/delete_ignore.result
new file mode 100644
index 00000000..f8ac42c4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/delete_ignore.result
@@ -0,0 +1,59 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (10000,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY, c CHAR(8), d INT) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+10000 foobar
+10000 foobar
+2 b
+2 b
+3 c
+3 c
+4 d
+4 d
+5 e
+5 e
+SELECT c,d FROM t2;
+c d
+a 1
+a 1
+b 2
+b 2
+c 3
+c 3
+d 4
+d 4
+e 5
+e 5
+foobar 10000
+foobar 10000
+DELETE IGNORE FROM t1 WHERE b IS NOT NULL ORDER BY a LIMIT 1;
+SELECT a,b FROM t1;
+a b
+1 a
+10000 foobar
+10000 foobar
+2 b
+2 b
+3 c
+3 c
+4 d
+4 d
+5 e
+5 e
+DELETE IGNORE t1.*, t2.* FROM t1, t2 WHERE c < b OR a != ( SELECT 1 UNION SELECT 2 );
+Warnings:
+Warning 1242 Subquery returns more than 1 row
+SELECT a,b FROM t1;
+a b
+1 a
+SELECT c,d FROM t2;
+c d
+foobar 10000
+foobar 10000
+DROP TABLE t1, t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/delete_quick.result b/storage/rocksdb/mysql-test/rocksdb/r/delete_quick.result
new file mode 100644
index 00000000..4173d875
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/delete_quick.result
@@ -0,0 +1,24 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a INT, b CHAR(8), PRIMARY KEY (a)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+DELETE QUICK FROM t1 WHERE a = 1 OR b > 'foo';
+SELECT a,b FROM t1;
+a b
+2 b
+3 c
+4 d
+5 e
+CREATE TABLE t2 (c CHAR(8), d INT, PRIMARY KEY (c)) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+SELECT c,d FROM t2;
+c d
+b 2
+c 3
+d 4
+e 5
+DELETE QUICK FROM t2, t1.* USING t2, t1 WHERE c IS NULL OR a = d;
+SELECT a,b FROM t1;
+a b
+SELECT c,d FROM t2;
+c d
+DROP TABLE t1, t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/delete_with_keys.result b/storage/rocksdb/mysql-test/rocksdb/r/delete_with_keys.result
new file mode 100644
index 00000000..c94708b8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/delete_with_keys.result
@@ -0,0 +1,38 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, KEY(b)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
+DELETE FROM t1 WHERE b > 'y';
+DELETE FROM t1 WHERE a=2;
+SELECT a,b FROM t1;
+a b
+1 a
+3 c
+4 d
+5 e
+6 x
+7 y
+DELETE FROM t1;
+DROP TABLE t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
+DELETE FROM t1 WHERE b > 'y';
+DELETE FROM t1 WHERE a=2;
+SELECT a,b FROM t1;
+a b
+1 a
+3 c
+4 d
+5 e
+6 x
+7 y
+DELETE FROM t1;
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT, c INT, pk INT AUTO_INCREMENT PRIMARY KEY, KEY(a), KEY (b)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6),(7,8,9);
+DELETE FROM t1 WHERE a = 10 OR b = 20 ORDER BY c LIMIT 1;
+SELECT a,b,c FROM t1;
+a b c
+1 2 3
+4 5 6
+7 8 9
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/describe.result b/storage/rocksdb/mysql-test/rocksdb/r/describe.result
new file mode 100644
index 00000000..6d43f89c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/describe.result
@@ -0,0 +1,19 @@
+DROP TABLE IF EXISTS t1, t2, t3;
+CREATE TABLE t1 (a INT, b CHAR(8), PRIMARY KEY (a)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (100,'foo'),(2, 'b');
+CREATE TABLE t2 (a INT, b CHAR(8), PRIMARY KEY (b)) ENGINE=rocksdb CHARACTER SET utf8;
+INSERT INTO t2 (a,b) VALUES (1, 'bar');
+CREATE TABLE t3 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb CHARACTER SET utf8;
+DESCRIBE t1;
+Field Type Null Key Default Extra
+a int(11) NO PRI NULL
+b char(8) YES NULL
+DESC t2 a;
+Field Type Null Key Default Extra
+a int(11) YES NULL
+DESCRIBE t3 '%';
+Field Type Null Key Default Extra
+a int(11) YES NULL
+b char(8) YES NULL
+pk int(11) NO PRI NULL auto_increment
+DROP TABLE t1, t2, t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/drop_database.result b/storage/rocksdb/mysql-test/rocksdb/r/drop_database.result
new file mode 100644
index 00000000..f220efe9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/drop_database.result
@@ -0,0 +1,6 @@
+DROP DATABASE IF EXISTS test_drop_database;
+CREATE DATABASE test_drop_database;
+CREATE TABLE t1 (a int, b int, c int, primary key (a), unique key (b)) ENGINE=ROCKSDB;
+ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (a);
+DROP TABLE t1;
+DROP DATABASE test_drop_database;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/drop_index_inplace.result b/storage/rocksdb/mysql-test/rocksdb/r/drop_index_inplace.result
new file mode 100644
index 00000000..668f7e8f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/drop_index_inplace.result
@@ -0,0 +1,158 @@
+drop table if exists t1;
+CREATE TABLE t1 (a INT, b INT AUTO_INCREMENT, KEY ka(a), KEY kb(a,b), PRIMARY KEY(b)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`b`),
+ KEY `ka` (`a`),
+ KEY `kb` (`a`,`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+INSERT INTO t1 (a) VALUES (1);
+INSERT INTO t1 (a) VALUES (3);
+INSERT INTO t1 (a) VALUES (5);
+ALTER TABLE t1 DROP INDEX ka, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`b`),
+ KEY `kb` (`a`,`b`)
+) ENGINE=ROCKSDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
+SELECT * FROM t1 FORCE INDEX(ka) where a > 1;
+ERROR 42000: Key 'ka' doesn't exist in table 't1'
+SELECT * FROM t1 FORCE INDEX(kb) where a > 1;
+a b
+3 2
+5 3
+SELECT * FROM t1 where b > 1;
+a b
+3 2
+5 3
+DROP TABLE t1;
+CREATE TABLE t1 (a INT AUTO_INCREMENT, b INT, c INT, KEY kb(b), KEY kbc(b,c), KEY kc(c), PRIMARY KEY(a)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ KEY `kb` (`b`),
+ KEY `kbc` (`b`,`c`),
+ KEY `kc` (`c`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) VALUES (1,2);
+INSERT INTO t1 (b,c) VALUES (3,4);
+INSERT INTO t1 (b,c) VALUES (5,6);
+ALTER TABLE t1 DROP INDEX kb, DROP INDEX kbc, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ KEY `kc` (`c`)
+) ENGINE=ROCKSDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
+# restart
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ KEY `kc` (`c`)
+) ENGINE=ROCKSDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) VALUES (1,2);
+INSERT INTO t1 (b,c) VALUES (3,4);
+INSERT INTO t1 (b,c) VALUES (5,6);
+SELECT * FROM t1 FORCE INDEX(kc) where c > 3;
+a b c
+2 3 4
+3 5 6
+5 3 4
+6 5 6
+SELECT * FROM t1 where b > 3;
+a b c
+3 5 6
+6 5 6
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT, c INT, KEY kb(b), KEY kbc(b,c), KEY kc(c), PRIMARY KEY(a)) ENGINE=rocksdb;
+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 PRIMARY 1 a A 0 NULL NULL LSMTREE
+t1 1 kb 1 b A 0 NULL NULL YES LSMTREE
+t1 1 kbc 1 b A 0 NULL NULL YES LSMTREE
+t1 1 kbc 2 c A 0 NULL NULL YES LSMTREE
+t1 1 kc 1 c A 0 NULL NULL YES LSMTREE
+ALTER TABLE t1 DROP INDEX kb, DROP INDEX kbc, ALGORITHM=INPLACE;
+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 PRIMARY 1 a A 0 NULL NULL LSMTREE
+t1 1 kc 1 c A 0 NULL NULL YES LSMTREE
+ALTER TABLE t1 DROP PRIMARY KEY;
+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 1 kc 1 c A 0 NULL NULL YES LSMTREE
+ALTER TABLE t1 DROP INDEX kc, ALGORITHM=INPLACE;
+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
+DROP TABLE t1;
+CREATE TABLE t1 (a INT AUTO_INCREMENT, b INT, c INT, PRIMARY KEY(a)) ENGINE=rocksdb;
+ALTER TABLE t1 ADD UNIQUE INDEX kb(b);
+ALTER TABLE t1 ADD UNIQUE INDEX kbc(b,c);
+ALTER TABLE t1 ADD UNIQUE INDEX kc(c);
+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 PRIMARY 1 a A 0 NULL NULL LSMTREE
+t1 0 kb 1 b A 0 NULL NULL YES LSMTREE
+t1 0 kbc 1 b A 0 NULL NULL YES LSMTREE
+t1 0 kbc 2 c A 0 NULL NULL YES LSMTREE
+t1 0 kc 1 c A 0 NULL NULL YES LSMTREE
+ALTER TABLE t1 DROP INDEX kb, DROP INDEX kbc;
+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 PRIMARY 1 a A 0 NULL NULL LSMTREE
+t1 0 kc 1 c A 0 NULL NULL YES LSMTREE
+# restart
+INSERT INTO t1 (b,c) VALUES (1,2);
+INSERT INTO t1 (b,c) VALUES (3,4);
+INSERT INTO t1 (b,c) VALUES (5,6);
+SELECT * FROM t1 FORCE INDEX(kc) where c > 3;
+a b c
+2 3 4
+3 5 6
+ALTER TABLE t1 DROP INDEX kc, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE IF NOT EXISTS t1 (col1 INT, col2 INT, col3 INT);
+INSERT INTO t1 (col1,col2,col3) VALUES (1,2,3);
+ALTER TABLE t1 ADD KEY idx ( col1, col2 );
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+ALTER TABLE t1 DROP COLUMN col2;
+ALTER TABLE t1 DROP COLUMN col3;
+DROP TABLE t1;
+CREATE TABLE IF NOT EXISTS t1 (col1 INT, col2 INT, col3 INT);
+INSERT INTO t1 (col1,col2,col3) VALUES (1,2,3);
+ALTER TABLE t1 ADD KEY idx ( col1, col2 );
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+ALTER TABLE t1 DROP COLUMN col2;
+ALTER TABLE t1 DROP COLUMN col3;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/drop_table.result b/storage/rocksdb/mysql-test/rocksdb/r/drop_table.result
new file mode 100644
index 00000000..4d20242f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/drop_table.result
@@ -0,0 +1,79 @@
+call mtr.add_suppression("Column family 'cf1' not found");
+call mtr.add_suppression("Column family 'rev:cf2' not found");
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+call mtr.add_suppression("Column family 'cf1' not found");
+call mtr.add_suppression("Column family 'rev:cf2' not found");
+call mtr.add_suppression("LibRocksDB");
+set global rocksdb_compact_cf = 'cf1';
+set global rocksdb_compact_cf = 'rev:cf2';
+set global rocksdb_signal_drop_index_thread = 1;
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+CREATE TABLE t2 (
+a int not null,
+b int not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+CREATE TABLE t3 (
+a int not null,
+b int not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+CREATE TABLE t4 (
+a int not null,
+b int not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+DELETE FROM t1;
+DELETE FROM t2;
+DELETE FROM t3;
+DELETE FROM t4;
+drop table t2;
+DELETE FROM t1;
+DELETE FROM t4;
+drop table t3;
+DELETE FROM t1;
+DELETE FROM t4;
+SET GLOBAL rocksdb_max_manual_compactions = 2;
+SET GLOBAL rocksdb_debug_manual_compaction_delay = 3600;
+connect con1, localhost, root,,;
+connect con2, localhost, root,,;
+connect con3, localhost, root,,;
+connection con1;
+SET GLOBAL rocksdb_compact_cf='cf1';
+connection con2;
+SET GLOBAL rocksdb_compact_cf='rev:cf2';
+connection default;
+select * from information_schema.global_status where variable_name='rocksdb_manual_compactions_running';
+VARIABLE_NAME VARIABLE_VALUE
+ROCKSDB_MANUAL_COMPACTIONS_RUNNING 1
+connection con3;
+SET GLOBAL rocksdb_compact_cf='cf1';
+ERROR HY000: Internal error: Can't schedule more manual compactions. Increase rocksdb_max_manual_compactions or stop issuing more manual compactions.
+SET GLOBAL rocksdb_compact_cf='rev:cf2';
+ERROR HY000: Internal error: Can't schedule more manual compactions. Increase rocksdb_max_manual_compactions or stop issuing more manual compactions.
+connection default;
+drop table t4;
+CREATE TABLE t5 (
+a int not null,
+b int not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+DELETE FROM t5;
+drop table t5;
+set global rocksdb_compact_cf = 'cf1';
+set global rocksdb_compact_cf = 'rev:cf2';
+set global rocksdb_signal_drop_index_thread = 1;
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/drop_table2.result b/storage/rocksdb/mysql-test/rocksdb/r/drop_table2.result
new file mode 100644
index 00000000..aec4138c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/drop_table2.result
@@ -0,0 +1,66 @@
+call mtr.add_suppression("Column family 'cf1' not found");
+call mtr.add_suppression("Column family 'rev:cf2' not found");
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+call mtr.add_suppression("Column family 'cf1' not found");
+call mtr.add_suppression("Column family 'rev:cf2' not found");
+set global rocksdb_compact_cf = 'cf1';
+set global rocksdb_compact_cf = 'rev:cf2';
+set global rocksdb_signal_drop_index_thread = 1;
+# restart
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+CREATE TABLE t2 (
+a int not null,
+b int not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+CREATE TABLE t3 (
+a int not null,
+b int not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+CREATE TABLE t4 (
+a int not null,
+b int not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+DELETE FROM t1;
+DELETE FROM t2;
+DELETE FROM t3;
+DELETE FROM t4;
+# restart
+DELETE FROM t1;
+DELETE FROM t4;
+DELETE FROM t1;
+DELETE FROM t4;
+# restart
+CREATE TABLE t5 (
+a int not null,
+b int not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+DELETE FROM t5;
+set @@global.rocksdb_compact_cf = 'cf1';
+set @@global.rocksdb_compact_cf = 'rev:cf2';
+set @@global.rocksdb_compact_cf = 'default';
+drop table t1;
+drop table t2;
+drop table t3;
+drop table t4;
+drop table t5;
+set @@global.rocksdb_compact_cf = 'cf1';
+set @@global.rocksdb_compact_cf = 'rev:cf2';
+set @@global.rocksdb_compact_cf = 'default';
+Compacted
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/drop_table3.result b/storage/rocksdb/mysql-test/rocksdb/r/drop_table3.result
new file mode 100644
index 00000000..954e6079
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/drop_table3.result
@@ -0,0 +1,25 @@
+call mtr.add_suppression("Column family 'cf1' not found");
+call mtr.add_suppression("Column family 'rev:cf2' not found");
+DROP TABLE IF EXISTS t1;
+call mtr.add_suppression("Column family 'cf1' not found");
+call mtr.add_suppression("Column family 'rev:cf2' not found");
+set global rocksdb_compact_cf = 'cf1';
+set global rocksdb_compact_cf = 'rev:cf2';
+set global rocksdb_signal_drop_index_thread = 1;
+# restart
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c varchar(500) not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+DELETE FROM t1;
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_compact_read_bytes';
+drop table t1;
+select case when variable_value-@a < 500000 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_compact_read_bytes';
+case when variable_value-@a < 500000 then 'true' else 'false' end
+true
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note 1051 Unknown table 'test.t1'
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/dup_key_update.result b/storage/rocksdb/mysql-test/rocksdb/r/dup_key_update.result
new file mode 100644
index 00000000..b4cebb08
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/dup_key_update.result
@@ -0,0 +1,366 @@
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1 (id1 INT, id2 INT, id3 INT,
+PRIMARY KEY (id1, id2, id3),
+UNIQUE KEY (id3, id1)) ENGINE=ROCKSDB;
+CREATE TABLE t2 (id1 INT, id2 INT, id3 INT,
+PRIMARY KEY (id1, id2, id3),
+UNIQUE KEY (id3, id1) COMMENT 'rev:cf') ENGINE=ROCKSDB;
+INSERT INTO t1 VALUES (1, 1, 1) ON DUPLICATE KEY UPDATE id2 = 9;
+SELECT * FROM t1 WHERE id1 = 1;
+id1 id2 id3
+1 1 1
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 1;
+id1 id2 id3
+1 1 1
+INSERT INTO t1 VALUES (1, 1, 1) ON DUPLICATE KEY UPDATE id2 = 10;
+SELECT * FROM t1 WHERE id1 = 1;
+id1 id2 id3
+1 10 1
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 1;
+id1 id2 id3
+1 10 1
+INSERT INTO t1 VALUES (1, 1, 1) ON DUPLICATE KEY UPDATE id2 = 11;
+SELECT * FROM t1 WHERE id1 = 1;
+id1 id2 id3
+1 11 1
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 1;
+id1 id2 id3
+1 11 1
+INSERT INTO t1 VALUES (5, 5, 5) ON DUPLICATE KEY UPDATE id2 = 12;
+SELECT * FROM t1 WHERE id1 = 5;
+id1 id2 id3
+5 12 5
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 5;
+id1 id2 id3
+5 12 5
+INSERT INTO t1 VALUES (5, 5, 5) ON DUPLICATE KEY UPDATE id2 = 13;
+SELECT * FROM t1 WHERE id1 = 5;
+id1 id2 id3
+5 13 5
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 5;
+id1 id2 id3
+5 13 5
+INSERT INTO t1 VALUES (5, 5, 5) ON DUPLICATE KEY UPDATE id2 = 14;
+SELECT * FROM t1 WHERE id1 = 5;
+id1 id2 id3
+5 14 5
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 5;
+id1 id2 id3
+5 14 5
+INSERT INTO t1 VALUES (9, 9, 9) ON DUPLICATE KEY UPDATE id2 = 15;
+SELECT * FROM t1 WHERE id1 = 9;
+id1 id2 id3
+9 15 9
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 9;
+id1 id2 id3
+9 15 9
+INSERT INTO t1 VALUES (9, 9, 9) ON DUPLICATE KEY UPDATE id2 = 16;
+SELECT * FROM t1 WHERE id1 = 9;
+id1 id2 id3
+9 16 9
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 9;
+id1 id2 id3
+9 16 9
+INSERT INTO t1 VALUES (9, 9, 9) ON DUPLICATE KEY UPDATE id2 = 17;
+SELECT * FROM t1 WHERE id1 = 9;
+id1 id2 id3
+9 17 9
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 9;
+id1 id2 id3
+9 17 9
+SELECT * FROM t1;
+id1 id2 id3
+1 11 1
+2 2 2
+3 3 3
+4 4 4
+5 14 5
+6 6 6
+7 7 7
+8 8 8
+9 17 9
+SELECT * FROM t1 FORCE INDEX (id3);
+id1 id2 id3
+1 11 1
+2 2 2
+3 3 3
+4 4 4
+5 14 5
+6 6 6
+7 7 7
+8 8 8
+9 17 9
+INSERT INTO t2 VALUES (1, 1, 1) ON DUPLICATE KEY UPDATE id2 = 9;
+SELECT * FROM t2 WHERE id1 = 1;
+id1 id2 id3
+1 1 1
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 1;
+id1 id2 id3
+1 1 1
+INSERT INTO t2 VALUES (1, 1, 1) ON DUPLICATE KEY UPDATE id2 = 10;
+SELECT * FROM t2 WHERE id1 = 1;
+id1 id2 id3
+1 10 1
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 1;
+id1 id2 id3
+1 10 1
+INSERT INTO t2 VALUES (1, 1, 1) ON DUPLICATE KEY UPDATE id2 = 11;
+SELECT * FROM t2 WHERE id1 = 1;
+id1 id2 id3
+1 11 1
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 1;
+id1 id2 id3
+1 11 1
+INSERT INTO t2 VALUES (5, 5, 5) ON DUPLICATE KEY UPDATE id2 = 12;
+SELECT * FROM t2 WHERE id1 = 5;
+id1 id2 id3
+5 12 5
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 5;
+id1 id2 id3
+5 12 5
+INSERT INTO t2 VALUES (5, 5, 5) ON DUPLICATE KEY UPDATE id2 = 13;
+SELECT * FROM t2 WHERE id1 = 5;
+id1 id2 id3
+5 13 5
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 5;
+id1 id2 id3
+5 13 5
+INSERT INTO t2 VALUES (5, 5, 5) ON DUPLICATE KEY UPDATE id2 = 14;
+SELECT * FROM t2 WHERE id1 = 5;
+id1 id2 id3
+5 14 5
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 5;
+id1 id2 id3
+5 14 5
+INSERT INTO t2 VALUES (9, 9, 9) ON DUPLICATE KEY UPDATE id2 = 15;
+SELECT * FROM t2 WHERE id1 = 9;
+id1 id2 id3
+9 15 9
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 9;
+id1 id2 id3
+9 15 9
+INSERT INTO t2 VALUES (9, 9, 9) ON DUPLICATE KEY UPDATE id2 = 16;
+SELECT * FROM t2 WHERE id1 = 9;
+id1 id2 id3
+9 16 9
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 9;
+id1 id2 id3
+9 16 9
+INSERT INTO t2 VALUES (9, 9, 9) ON DUPLICATE KEY UPDATE id2 = 17;
+SELECT * FROM t2 WHERE id1 = 9;
+id1 id2 id3
+9 17 9
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 9;
+id1 id2 id3
+9 17 9
+SELECT * FROM t2;
+id1 id2 id3
+1 11 1
+2 2 2
+3 3 3
+4 4 4
+5 14 5
+6 6 6
+7 7 7
+8 8 8
+9 17 9
+SELECT * FROM t2 FORCE INDEX (id3);
+id1 id2 id3
+1 11 1
+2 2 2
+3 3 3
+4 4 4
+5 14 5
+6 6 6
+7 7 7
+8 8 8
+9 17 9
+DROP TABLE t1;
+DROP TABLE t2;
+set global rocksdb_large_prefix=1;
+CREATE TABLE t1 (id1 varchar(128) CHARACTER SET latin1 COLLATE latin1_bin,
+id2 varchar(256) CHARACTER SET utf8 COLLATE utf8_bin,
+id3 varchar(200) CHARACTER SET latin1 COLLATE latin1_swedish_ci,
+PRIMARY KEY (id1, id2, id3),
+UNIQUE KEY (id3, id1)) ENGINE=ROCKSDB;
+set global rocksdb_large_prefix=DEFAULT;
+set global rocksdb_large_prefix=1;
+CREATE TABLE t2 (id1 varchar(128) CHARACTER SET latin1 COLLATE latin1_bin,
+id2 varchar(256) CHARACTER SET utf8 COLLATE utf8_bin,
+id3 varchar(200) CHARACTER SET latin1 COLLATE latin1_swedish_ci,
+PRIMARY KEY (id1, id2, id3),
+UNIQUE KEY (id3, id1) COMMENT 'rev:cf') ENGINE=ROCKSDB;
+set global rocksdb_large_prefix=DEFAULT;
+INSERT INTO t1 VALUES (1, 1, 1) ON DUPLICATE KEY UPDATE id2 = 9;
+SELECT * FROM t1 WHERE id1 = 1;
+id1 id2 id3
+1 1 1
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 1;
+id1 id2 id3
+1 1 1
+INSERT INTO t1 VALUES (1, 1, 1) ON DUPLICATE KEY UPDATE id2 = 10;
+SELECT * FROM t1 WHERE id1 = 1;
+id1 id2 id3
+1 10 1
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 1;
+id1 id2 id3
+1 10 1
+INSERT INTO t1 VALUES (1, 1, 1) ON DUPLICATE KEY UPDATE id2 = 11;
+SELECT * FROM t1 WHERE id1 = 1;
+id1 id2 id3
+1 11 1
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 1;
+id1 id2 id3
+1 11 1
+INSERT INTO t1 VALUES (5, 5, 5) ON DUPLICATE KEY UPDATE id2 = 12;
+SELECT * FROM t1 WHERE id1 = 5;
+id1 id2 id3
+5 12 5
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 5;
+id1 id2 id3
+5 12 5
+INSERT INTO t1 VALUES (5, 5, 5) ON DUPLICATE KEY UPDATE id2 = 13;
+SELECT * FROM t1 WHERE id1 = 5;
+id1 id2 id3
+5 13 5
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 5;
+id1 id2 id3
+5 13 5
+INSERT INTO t1 VALUES (5, 5, 5) ON DUPLICATE KEY UPDATE id2 = 14;
+SELECT * FROM t1 WHERE id1 = 5;
+id1 id2 id3
+5 14 5
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 5;
+id1 id2 id3
+5 14 5
+INSERT INTO t1 VALUES (9, 9, 9) ON DUPLICATE KEY UPDATE id2 = 15;
+SELECT * FROM t1 WHERE id1 = 9;
+id1 id2 id3
+9 15 9
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 9;
+id1 id2 id3
+9 15 9
+INSERT INTO t1 VALUES (9, 9, 9) ON DUPLICATE KEY UPDATE id2 = 16;
+SELECT * FROM t1 WHERE id1 = 9;
+id1 id2 id3
+9 16 9
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 9;
+id1 id2 id3
+9 16 9
+INSERT INTO t1 VALUES (9, 9, 9) ON DUPLICATE KEY UPDATE id2 = 17;
+SELECT * FROM t1 WHERE id1 = 9;
+id1 id2 id3
+9 17 9
+SELECT * FROM t1 FORCE INDEX (id3) WHERE id3 = 9;
+id1 id2 id3
+9 17 9
+SELECT * FROM t1;
+id1 id2 id3
+1 11 1
+2 2 2
+3 3 3
+4 4 4
+5 14 5
+6 6 6
+7 7 7
+8 8 8
+9 17 9
+SELECT * FROM t1 FORCE INDEX (id3);
+id1 id2 id3
+1 11 1
+2 2 2
+3 3 3
+4 4 4
+5 14 5
+6 6 6
+7 7 7
+8 8 8
+9 17 9
+INSERT INTO t2 VALUES (1, 1, 1) ON DUPLICATE KEY UPDATE id2 = 9;
+SELECT * FROM t2 WHERE id1 = 1;
+id1 id2 id3
+1 1 1
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 1;
+id1 id2 id3
+1 1 1
+INSERT INTO t2 VALUES (1, 1, 1) ON DUPLICATE KEY UPDATE id2 = 10;
+SELECT * FROM t2 WHERE id1 = 1;
+id1 id2 id3
+1 10 1
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 1;
+id1 id2 id3
+1 10 1
+INSERT INTO t2 VALUES (1, 1, 1) ON DUPLICATE KEY UPDATE id2 = 11;
+SELECT * FROM t2 WHERE id1 = 1;
+id1 id2 id3
+1 11 1
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 1;
+id1 id2 id3
+1 11 1
+INSERT INTO t2 VALUES (5, 5, 5) ON DUPLICATE KEY UPDATE id2 = 12;
+SELECT * FROM t2 WHERE id1 = 5;
+id1 id2 id3
+5 12 5
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 5;
+id1 id2 id3
+5 12 5
+INSERT INTO t2 VALUES (5, 5, 5) ON DUPLICATE KEY UPDATE id2 = 13;
+SELECT * FROM t2 WHERE id1 = 5;
+id1 id2 id3
+5 13 5
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 5;
+id1 id2 id3
+5 13 5
+INSERT INTO t2 VALUES (5, 5, 5) ON DUPLICATE KEY UPDATE id2 = 14;
+SELECT * FROM t2 WHERE id1 = 5;
+id1 id2 id3
+5 14 5
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 5;
+id1 id2 id3
+5 14 5
+INSERT INTO t2 VALUES (9, 9, 9) ON DUPLICATE KEY UPDATE id2 = 15;
+SELECT * FROM t2 WHERE id1 = 9;
+id1 id2 id3
+9 15 9
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 9;
+id1 id2 id3
+9 15 9
+INSERT INTO t2 VALUES (9, 9, 9) ON DUPLICATE KEY UPDATE id2 = 16;
+SELECT * FROM t2 WHERE id1 = 9;
+id1 id2 id3
+9 16 9
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 9;
+id1 id2 id3
+9 16 9
+INSERT INTO t2 VALUES (9, 9, 9) ON DUPLICATE KEY UPDATE id2 = 17;
+SELECT * FROM t2 WHERE id1 = 9;
+id1 id2 id3
+9 17 9
+SELECT * FROM t2 FORCE INDEX (id3) WHERE id3 = 9;
+id1 id2 id3
+9 17 9
+SELECT * FROM t2;
+id1 id2 id3
+1 11 1
+2 2 2
+3 3 3
+4 4 4
+5 14 5
+6 6 6
+7 7 7
+8 8 8
+9 17 9
+SELECT * FROM t2 FORCE INDEX (id3);
+id1 id2 id3
+1 11 1
+2 2 2
+3 3 3
+4 4 4
+5 14 5
+6 6 6
+7 7 7
+8 8 8
+9 17 9
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/duplicate_table.result b/storage/rocksdb/mysql-test/rocksdb/r/duplicate_table.result
new file mode 100644
index 00000000..ba16aaa6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/duplicate_table.result
@@ -0,0 +1,15 @@
+DROP TABLE IF EXISTS t;
+CREATE TABLE t(id int primary key) engine=rocksdb;
+INSERT INTO t values (1), (2), (3);
+CREATE TABLE t(id int primary key) engine=rocksdb;
+ERROR 42S01: Table 't' already exists
+FLUSH TABLES;
+CREATE TABLE t(id int primary key) engine=rocksdb;
+ERROR HY000: Table 'test.t' does not exist, but metadata information exists inside MyRocks. This is a sign of data inconsistency. Please check if './test/t.frm' exists, and try to restore it if it does not exist.
+FLUSH TABLES;
+SELECT * FROM t;
+id
+1
+2
+3
+DROP TABLE t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/explicit_snapshot.result b/storage/rocksdb/mysql-test/rocksdb/r/explicit_snapshot.result
new file mode 100644
index 00000000..14f5ef65
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/explicit_snapshot.result
@@ -0,0 +1,265 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE T1 (a INT PRIMARY KEY AUTO_INCREMENT) ENGINE=ROCKSDB;
+INSERT INTO T1 VALUES();
+"con1: Creating explict snapshot"
+SELECT * FROM T1;
+a
+1
+"con2: Inserting a row"
+INSERT INTO T1 VALUES();
+SELECT * FROM T1;
+a
+1
+2
+"con2: Attaching snapshot id 1"
+ATTACH EXPLICIT ROCKSDB SNAPSHOT 1;
+"con2: New row should not be visible"
+SELECT * FROM T1;
+a
+1
+"con2: Releasing snapshot"
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+"con2: New row should be visible"
+SELECT * FROM T1;
+a
+1
+2
+"con1: New row should not be visible"
+SELECT * FROM T1;
+a
+1
+"con1: Releasing snapshot"
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+"con1: New row should be visible"
+SELECT * FROM T1;
+a
+1
+2
+"con1: Starting shared snapshot"
+SELECT * FROM T1;
+a
+1
+2
+"con2: Inserting a row"
+INSERT INTO T1 VALUES();
+SELECT * FROM T1;
+a
+1
+2
+3
+"con2: Starting existing snapshot"
+START TRANSACTION WITH EXISTING ROCKSDB SNAPSHOT 2;
+"con2: New row should not be visible"
+SELECT * FROM T1;
+a
+1
+2
+COMMIT;
+"con2: New row should be visible"
+SELECT * FROM T1;
+a
+1
+2
+3
+COMMIT;
+"con1: New row should be visible"
+SELECT * FROM T1;
+a
+1
+2
+3
+"con1: Creating explict snapshot"
+"con2: Trying to insert row"
+INSERT INTO T1 VALUES();
+ERROR HY000: Can't execute updates when an explicit snapshot is associated with the connection using CREATE|ATTACH EXPLICIT [ENGINE] SNAPSHOT
+"con2: Attaching existing snapshot"
+ATTACH EXPLICIT ROCKSDB SNAPSHOT 3;
+"con2: Trying to insert row"
+INSERT INTO T1 VALUES();
+ERROR HY000: Can't execute updates when an explicit snapshot is associated with the connection using CREATE|ATTACH EXPLICIT [ENGINE] SNAPSHOT
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+"con1: Starting shared snapshot"
+"con1: Trying to insert row"
+INSERT INTO T1 VALUES();
+ERROR HY000: Can't execute updates when you started a transaction with START TRANSACTION WITH CONSISTENT|SHARED|EXISTING [ROCKSDB] SNAPSHOT.
+"con2: Starting existing snapshot"
+START TRANSACTION WITH EXISTING ROCKSDB SNAPSHOT 4;
+"con2: Trying to insert row"
+INSERT INTO T1 VALUES();
+ERROR HY000: Can't execute updates when you started a transaction with START TRANSACTION WITH CONSISTENT|SHARED|EXISTING [ROCKSDB] SNAPSHOT.
+COMMIT;
+COMMIT;
+"con1: Creating explicit snapshot"
+CREATE EXPLICIT ROCKSDB SNAPSHOT;
+SELECT * FROM T1;
+a
+1
+2
+3
+"con2: Inserting a row"
+INSERT INTO T1 VALUES();
+SELECT * FROM T1;
+a
+1
+2
+3
+4
+"con1: New row should not be seen"
+SELECT * FROM T1;
+a
+1
+2
+3
+"con1: Creating another explicit snapshot"
+CREATE EXPLICIT ROCKSDB SNAPSHOT;
+"con1: Now the new row should be seen"
+SELECT * FROM T1;
+a
+1
+2
+3
+4
+"con1: Starting transaction with consistent snapshot"
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+SELECT * FROM T1;
+a
+1
+2
+3
+4
+"con2: Inserting a row"
+INSERT INTO T1 VALUES();
+SELECT * FROM T1;
+a
+1
+2
+3
+4
+5
+"con1: The new row should not be seen"
+SELECT * FROM T1;
+a
+1
+2
+3
+4
+"con1: Creating another explicit snapshot"
+CREATE EXPLICIT ROCKSDB SNAPSHOT;
+"con1: The new row should still not be seen"
+SELECT * FROM T1;
+a
+1
+2
+3
+4
+"con1: Committing trx"
+COMMIT;
+"con1: The new row should now be seen because of the new explicit snapshot created above"
+SELECT * FROM T1;
+a
+1
+2
+3
+4
+5
+"con1: Releasing explicit snapshot"
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+"con1: Starting transaction with shared snapshot"
+START TRANSACTION WITH SHARED ROCKSDB SNAPSHOT;
+SELECT * FROM T1;
+a
+1
+2
+3
+4
+5
+"con2: Inserting a row"
+INSERT INTO T1 VALUES();
+SELECT * FROM T1;
+a
+1
+2
+3
+4
+5
+6
+"con1: The new row should not be seen"
+SELECT * FROM T1;
+a
+1
+2
+3
+4
+5
+"con1: Starting another transaction with shared snapshot"
+START TRANSACTION WITH SHARED ROCKSDB SNAPSHOT;
+"con1: The new row should now be seen"
+SELECT * FROM T1;
+a
+1
+2
+3
+4
+5
+6
+COMMIT;
+"con1: Creating explicit snapshot"
+CREATE EXPLICIT ROCKSDB SNAPSHOT;
+SELECT * FROM T1;
+a
+1
+2
+3
+4
+5
+6
+"con1: Releasing explicit snapshot"
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+"con1: Releasing explicit snapshot again"
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+ERROR HY000: Cannot process explicit snapshot
+"con1: Starting transaction with shared snapshot"
+START TRANSACTION WITH SHARED ROCKSDB SNAPSHOT;
+SELECT * FROM T1;
+a
+1
+2
+3
+4
+5
+6
+"con2: Inserting a row"
+INSERT INTO T1 VALUES();
+SELECT * FROM T1;
+a
+1
+2
+3
+4
+5
+6
+7
+"con1: Creating explicit snapshot"
+CREATE EXPLICIT ROCKSDB SNAPSHOT;
+SELECT * FROM T1;
+a
+1
+2
+3
+4
+5
+6
+"con1: Releasing explicit snapshot"
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+"con1: The new row should not be seen"
+SELECT* FROM T1;
+a
+1
+2
+3
+4
+5
+6
+COMMIT;
+DROP TABLE T1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/fail_system_cf.result b/storage/rocksdb/mysql-test/rocksdb/r/fail_system_cf.result
new file mode 100644
index 00000000..df90f2b3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/fail_system_cf.result
@@ -0,0 +1,4 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT, PRIMARY KEY (i) COMMENT '__system__') ENGINE = ROCKSDB;
+ERROR HY000: Incorrect arguments to column family not valid for storing index data.
+DROP TABLE IF EXISTS t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/fast_prefix_index_fetch.result b/storage/rocksdb/mysql-test/rocksdb/r/fast_prefix_index_fetch.result
new file mode 100644
index 00000000..963f9706
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/fast_prefix_index_fetch.result
@@ -0,0 +1,80 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+id INT,
+fake_id INT,
+bigfield VARCHAR(4096),
+PRIMARY KEY (id),
+KEY bf (bigfield(32)),
+KEY fid (fake_id, bigfield(32))
+) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (1, 1001, REPEAT('a', 1)),
+(8, 1008, REPEAT('b', 8)),
+(24, 1024, REPEAT('c', 24)),
+(31, 1031, REPEAT('d', 31)),
+(32, 1032, REPEAT('x', 32)),
+(33, 1033, REPEAT('y', 33)),
+(128, 1128, REPEAT('z', 128));
+SELECT * FROM t1;
+id fake_id bigfield
+1 1001 a
+8 1008 bbbbbbbb
+24 1024 cccccccccccccccccccccccc
+31 1031 ddddddddddddddddddddddddddddddd
+32 1032 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+33 1033 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
+128 1128 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
+# Baseline sanity check
+no-op query
+no-op query
+include/assert.inc [Baseline sanity check: 0 rocksdb_covered_secondary_key_lookups]
+# Eligible for optimization.
+id bigfield
+31 ddddddddddddddddddddddddddddddd
+include/assert.inc [Eligible for optimization.: 2 rocksdb_covered_secondary_key_lookups]
+# Eligible for optimization, access via fake_id only
+id bigfield
+31 ddddddddddddddddddddddddddddddd
+include/assert.inc [Eligible for optimization, access via fake_id only: 2 rocksdb_covered_secondary_key_lookups]
+# Not eligible for optimization, access via fake_id of big row.
+id bigfield
+33 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
+include/assert.inc [Not eligible for optimization, access via fake_id of big row.: 0 rocksdb_covered_secondary_key_lookups]
+# Eligible for optimization.
+id bigfield
+32 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+include/assert.inc [Eligible for optimization.: 1 rocksdb_covered_secondary_key_lookups]
+# Not eligible for optimization.
+id bigfield
+33 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
+include/assert.inc [Not eligible for optimization.: 0 rocksdb_covered_secondary_key_lookups]
+# Eligible for optimization.
+id bigfield
+8 bbbbbbbb
+include/assert.inc [Eligible for optimization.: 2 rocksdb_covered_secondary_key_lookups]
+# Eligible for optimization.
+id bigfield
+24 cccccccccccccccccccccccc
+include/assert.inc [Eligible for optimization.: 2 rocksdb_covered_secondary_key_lookups]
+# Not eligible for optimization.
+id bigfield
+128 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
+include/assert.inc [Not eligible for optimization.: 0 rocksdb_covered_secondary_key_lookups]
+#
+# Test that multi-byte charsets are handled correctly
+#
+# Charset record obviously shorter than the prefix
+a b
+1 a
+include/assert.inc [Charset record obviously shorter than the prefix: 2 rocksdb_covered_secondary_key_lookups]
+# Charset record shorter than prefix
+a b
+2 cc
+include/assert.inc [Charset record shorter than prefix: 2 rocksdb_covered_secondary_key_lookups]
+# Charset record with glyphs shorter than prefix
+a b
+3 ŽŽ
+include/assert.inc [Charset record with glyphs shorter than prefix: 1 rocksdb_covered_secondary_key_lookups]
+# Charset record longer than prefix
+a b
+4 žžžž
+include/assert.inc [Charset record longer than prefix: 0 rocksdb_covered_secondary_key_lookups]
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/force_shutdown.result b/storage/rocksdb/mysql-test/rocksdb/r/force_shutdown.result
new file mode 100644
index 00000000..4386ad59
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/force_shutdown.result
@@ -0,0 +1,38 @@
+create table t1 (
+pk int not null primary key,
+col1 varchar(10)
+) engine=rocksdb;
+insert into t1 values (1,1),(2,2),(3,3);
+set session debug= "+d,myrocks_busy_loop_on_row_read";
+select * from t1 where pk=1;
+# testing unclean shutdown on stuck instance
+# Run shutdown sql command with forcing kill (exit code 127)
+shutdown 1;
+Got one of the listed errors
+# verifying exit code is printed
+# restart the server
+shutdown 230;
+Got one of the listed errors
+# restart the server
+# verifying SHUTDOWN is refused if exit code > 255
+SHUTDOWN 256;
+ERROR HY000: exit code must be 0..255
+SHUTDOWN 10000;
+ERROR HY000: exit code must be 0..255
+# verifying SHUTDOWN is refused if instances are not read only
+SHUTDOWN 0 read_only;
+ERROR HY000: Only read_only instance can be killed.
+SHUTDOWN 127 read_only;
+ERROR HY000: Only read_only instance can be killed.
+SHUTDOWN 127;
+Got one of the listed errors
+# restart the server
+set session debug= "+d,myrocks_busy_loop_on_row_read";
+select * from t1 where pk=1;
+SET GLOBAL read_only=1;
+# verifying SHUTDOWN read_only works with read_only instance
+# Run shutdown sql command with forcing kill (exit code 127)
+shutdown 255 read_only;
+Got one of the listed errors
+# restart the server
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/foreign_key.result b/storage/rocksdb/mysql-test/rocksdb/r/foreign_key.result
new file mode 100644
index 00000000..fa3809e9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/foreign_key.result
@@ -0,0 +1,25 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (b INT PRIMARY KEY);
+CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, FOREIGN KEY (b) REFERENCES t1(b));
+ERROR 42000: This version of MariaDB doesn't yet support 'FOREIGN KEY for the RocksDB storage engine'
+CREATE TABLE t2 (a INT NOT NULL, bforeign INT NOT NULL);
+DROP TABLE t2;
+CREATE TABLE t2 (a INT NOT NULL, foreignkey INT NOT NULL);
+DROP TABLE t2;
+CREATE TABLE t2 (a INT NOT NULL, bforeign INT not null, FOREIGN KEY (bforeign) REFERENCES t1(b));
+ERROR 42000: This version of MariaDB doesn't yet support 'FOREIGN KEY for the RocksDB storage engine'
+CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL);
+ALTER TABLE t2 ADD FOREIGN KEY (b) REFERENCES t1(b);
+ERROR 42000: This version of MariaDB doesn't yet support 'FOREIGN KEY for the RocksDB storage engine'
+DROP TABLE t2;
+CREATE TABLE t2 (a INT NOT NULL);
+ALTER TABLE t2 ADD bforeign INT NOT NULL;
+DROP TABLE t2;
+CREATE TABLE t2 (a INT NOT NULL);
+ALTER TABLE t2 ADD foreignkey INT NOT NULL;
+DROP TABLE t2;
+CREATE TABLE t2 (a INT NOT NULL);
+ALTER TABLE t2 ADD bforeign INT NOT NULL, ADD FOREIGN KEY (bforeign) REFERENCES t1(b);
+ERROR 42000: This version of MariaDB doesn't yet support 'FOREIGN KEY for the RocksDB storage engine'
+DROP TABLE t2;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/gap_lock_issue254.result b/storage/rocksdb/mysql-test/rocksdb/r/gap_lock_issue254.result
new file mode 100644
index 00000000..d4204118
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/gap_lock_issue254.result
@@ -0,0 +1,9 @@
+create table t (id int primary key, value int);
+begin;
+update t set value=100 where id in (1, 2);
+commit;
+begin;
+select * from t for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from t for update
+commit;
+drop table t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/gap_lock_raise_error.result b/storage/rocksdb/mysql-test/rocksdb/r/gap_lock_raise_error.result
new file mode 100644
index 00000000..c1cf1e77
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/gap_lock_raise_error.result
@@ -0,0 +1,504 @@
+drop table if exists gap1,gap2,gap3;
+CREATE DATABASE mysqlslap;
+CREATE TABLE gap1 (id1 INT, id2 INT, id3 INT, c1 INT, value INT,
+PRIMARY KEY (id1, id2, id3),
+INDEX i (c1)) ENGINE=rocksdb;
+CREATE TABLE gap2 like gap1;
+CREATE TABLE gap3 (id INT, value INT,
+PRIMARY KEY (id),
+UNIQUE KEY ui(value)) ENGINE=rocksdb;
+insert into gap3 values (1,1), (2,2),(3,3),(4,4),(5,5);
+create table gap4 (
+pk int primary key,
+a int,
+b int,
+key(a)
+) ENGINE=rocksdb;
+insert into gap4 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
+create table gap5 like gap4;
+insert into gap5 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
+set session gap_lock_raise_error=1;
+set session gap_lock_write_log=1;
+set @save_gap_lock_write_log = @@gap_lock_write_log;
+set @save_gap_lock_raise_error = @@gap_lock_raise_error;
+set gap_lock_write_log = 1;
+set gap_lock_raise_error = 0;
+begin;
+update gap4 set a= (select 1+max(a) from gap5 where gap5.pk between 1 and 3 and gap5.b=gap4.b);
+1
+update gap4 set a= (select 2+max(a) from gap5 where gap5.pk between 1 and 3 and gap5.b=gap4.b);
+update gap4 set a= (select 3+max(a) from gap5 where gap5.pk between 1 and 3 and gap5.b=gap4.b);
+1
+1
+0
+flush logs;
+0
+rollback;
+set gap_lock_write_log = @save_gap_lock_write_log;
+set gap_lock_raise_error = @save_gap_lock_raise_error;
+set global gap_lock_write_log = 1;
+set global gap_lock_write_log = 0;
+1000
+set session autocommit=0;
+select * from gap1 limit 1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 limit 1 for update
+select * from gap1 where value != 100 limit 1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 where value != 100 limit 1 for update
+select * from gap1 where id1=1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 where id1=1 for update
+select * from gap1 where id1=1 and id2= 1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 where id1=1 and id2= 1 for update
+select * from gap1 where id1=1 and id2= 1 and id3 != 1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 where id1=1 and id2= 1 and id3 != 1 for update
+select * from gap1 where id1=1 and id2= 1 and id3
+between 1 and 3 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 where id1=1 and id2= 1 and id3
+between 1 and 3 for update
+select * from gap1 where id1=1 and id2= 1 order by id3 asc
+limit 1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 where id1=1 and id2= 1 order by id3 asc
+limit 1 for update
+select * from gap1 where id1=1 and id2= 1 order by id3 desc
+limit 1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 where id1=1 and id2= 1 order by id3 desc
+limit 1 for update
+select * from gap1 order by id1 asc limit 1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 order by id1 asc limit 1 for update
+select * from gap1 order by id1 asc, id2 asc, id3 asc limit 1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 order by id1 asc, id2 asc, id3 asc limit 1 for update
+select * from gap1 order by id1 desc limit 1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 order by id1 desc limit 1 for update
+select * from gap1 order by id1 desc, id2 desc, id3 desc
+limit 1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 order by id1 desc, id2 desc, id3 desc
+limit 1 for update
+select * from gap1 force index(i) where c1=1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 force index(i) where c1=1 for update
+select * from gap3 force index(ui) where value=1 for update;
+id value
+1 1
+select * from gap1 where id1=1 and id2=1 and id3=1 for update;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2=1 and id3 in (1, 2, 3) for update;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2=1 and id3=1 and value=1
+order by c1 for update;
+id1 id2 id3 c1 value
+select * from gap3 where id=1 for update;
+id value
+1 1
+set session autocommit=1;
+select * from gap1 limit 1 for update;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 where value != 100 limit 1 for update;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 where id1=1 for update;
+id1 id2 id3 c1 value
+1 0 2 2 2
+1 0 3 3 3
+select * from gap1 where id1=1 and id2= 1 for update;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 and id3 != 1 for update;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 and id3
+between 1 and 3 for update;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 order by id3 asc
+limit 1 for update;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 order by id3 desc
+limit 1 for update;
+id1 id2 id3 c1 value
+select * from gap1 order by id1 asc limit 1 for update;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 order by id1 asc, id2 asc, id3 asc limit 1 for update;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 order by id1 desc limit 1 for update;
+id1 id2 id3 c1 value
+500 100 1000 1000 1000
+select * from gap1 order by id1 desc, id2 desc, id3 desc
+limit 1 for update;
+id1 id2 id3 c1 value
+500 100 1000 1000 1000
+select * from gap1 force index(i) where c1=1 for update;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap3 force index(ui) where value=1 for update;
+id value
+1 1
+select * from gap1 where id1=1 and id2=1 and id3=1 for update;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2=1 and id3 in (1, 2, 3) for update;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2=1 and id3=1 and value=1
+order by c1 for update;
+id1 id2 id3 c1 value
+select * from gap3 where id=1 for update;
+id value
+1 1
+set session autocommit=0;
+select * from gap1 limit 1 lock in share mode;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 limit 1 lock in share mode
+select * from gap1 where value != 100 limit 1 lock in share mode;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 where value != 100 limit 1 lock in share mode
+select * from gap1 where id1=1 lock in share mode;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 where id1=1 lock in share mode
+select * from gap1 where id1=1 and id2= 1 lock in share mode;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 where id1=1 and id2= 1 lock in share mode
+select * from gap1 where id1=1 and id2= 1 and id3 != 1 lock in share mode;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 where id1=1 and id2= 1 and id3 != 1 lock in share mode
+select * from gap1 where id1=1 and id2= 1 and id3
+between 1 and 3 lock in share mode;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 where id1=1 and id2= 1 and id3
+between 1 and 3 lock in share mode
+select * from gap1 where id1=1 and id2= 1 order by id3 asc
+limit 1 lock in share mode;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 where id1=1 and id2= 1 order by id3 asc
+limit 1 lock in share mode
+select * from gap1 where id1=1 and id2= 1 order by id3 desc
+limit 1 lock in share mode;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 where id1=1 and id2= 1 order by id3 desc
+limit 1 lock in share mode
+select * from gap1 order by id1 asc limit 1 lock in share mode;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 order by id1 asc limit 1 lock in share mode
+select * from gap1 order by id1 asc, id2 asc, id3 asc limit 1 lock in share mode;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 order by id1 asc, id2 asc, id3 asc limit 1 lock in share mode
+select * from gap1 order by id1 desc limit 1 lock in share mode;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 order by id1 desc limit 1 lock in share mode
+select * from gap1 order by id1 desc, id2 desc, id3 desc
+limit 1 lock in share mode;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 order by id1 desc, id2 desc, id3 desc
+limit 1 lock in share mode
+select * from gap1 force index(i) where c1=1 lock in share mode;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 force index(i) where c1=1 lock in share mode
+select * from gap3 force index(ui) where value=1 lock in share mode;
+id value
+1 1
+select * from gap1 where id1=1 and id2=1 and id3=1 lock in share mode;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2=1 and id3 in (1, 2, 3) lock in share mode;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2=1 and id3=1 and value=1
+order by c1 lock in share mode;
+id1 id2 id3 c1 value
+select * from gap3 where id=1 lock in share mode;
+id value
+1 1
+set session autocommit=1;
+select * from gap1 limit 1 lock in share mode;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 where value != 100 limit 1 lock in share mode;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 where id1=1 lock in share mode;
+id1 id2 id3 c1 value
+1 0 2 2 2
+1 0 3 3 3
+select * from gap1 where id1=1 and id2= 1 lock in share mode;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 and id3 != 1 lock in share mode;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 and id3
+between 1 and 3 lock in share mode;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 order by id3 asc
+limit 1 lock in share mode;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 order by id3 desc
+limit 1 lock in share mode;
+id1 id2 id3 c1 value
+select * from gap1 order by id1 asc limit 1 lock in share mode;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 order by id1 asc, id2 asc, id3 asc limit 1 lock in share mode;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 order by id1 desc limit 1 lock in share mode;
+id1 id2 id3 c1 value
+500 100 1000 1000 1000
+select * from gap1 order by id1 desc, id2 desc, id3 desc
+limit 1 lock in share mode;
+id1 id2 id3 c1 value
+500 100 1000 1000 1000
+select * from gap1 force index(i) where c1=1 lock in share mode;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap3 force index(ui) where value=1 lock in share mode;
+id value
+1 1
+select * from gap1 where id1=1 and id2=1 and id3=1 lock in share mode;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2=1 and id3 in (1, 2, 3) lock in share mode;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2=1 and id3=1 and value=1
+order by c1 lock in share mode;
+id1 id2 id3 c1 value
+select * from gap3 where id=1 lock in share mode;
+id value
+1 1
+set session autocommit=0;
+select * from gap1 limit 1 ;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 where value != 100 limit 1 ;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 where id1=1 ;
+id1 id2 id3 c1 value
+1 0 2 2 2
+1 0 3 3 3
+select * from gap1 where id1=1 and id2= 1 ;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 and id3 != 1 ;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 and id3
+between 1 and 3 ;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 order by id3 asc
+limit 1 ;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 order by id3 desc
+limit 1 ;
+id1 id2 id3 c1 value
+select * from gap1 order by id1 asc limit 1 ;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 order by id1 asc, id2 asc, id3 asc limit 1 ;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 order by id1 desc limit 1 ;
+id1 id2 id3 c1 value
+500 100 1000 1000 1000
+select * from gap1 order by id1 desc, id2 desc, id3 desc
+limit 1 ;
+id1 id2 id3 c1 value
+500 100 1000 1000 1000
+select * from gap1 force index(i) where c1=1 ;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap3 force index(ui) where value=1 ;
+id value
+1 1
+select * from gap1 where id1=1 and id2=1 and id3=1 ;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2=1 and id3 in (1, 2, 3) ;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2=1 and id3=1 and value=1
+order by c1 ;
+id1 id2 id3 c1 value
+select * from gap3 where id=1 ;
+id value
+1 1
+set session autocommit=1;
+select * from gap1 limit 1 ;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 where value != 100 limit 1 ;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 where id1=1 ;
+id1 id2 id3 c1 value
+1 0 2 2 2
+1 0 3 3 3
+select * from gap1 where id1=1 and id2= 1 ;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 and id3 != 1 ;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 and id3
+between 1 and 3 ;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 order by id3 asc
+limit 1 ;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2= 1 order by id3 desc
+limit 1 ;
+id1 id2 id3 c1 value
+select * from gap1 order by id1 asc limit 1 ;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 order by id1 asc, id2 asc, id3 asc limit 1 ;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 order by id1 desc limit 1 ;
+id1 id2 id3 c1 value
+500 100 1000 1000 1000
+select * from gap1 order by id1 desc, id2 desc, id3 desc
+limit 1 ;
+id1 id2 id3 c1 value
+500 100 1000 1000 1000
+select * from gap1 force index(i) where c1=1 ;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap3 force index(ui) where value=1 ;
+id value
+1 1
+select * from gap1 where id1=1 and id2=1 and id3=1 ;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2=1 and id3 in (1, 2, 3) ;
+id1 id2 id3 c1 value
+select * from gap1 where id1=1 and id2=1 and id3=1 and value=1
+order by c1 ;
+id1 id2 id3 c1 value
+select * from gap3 where id=1 ;
+id value
+1 1
+set session autocommit=0;
+insert into gap1 (id1, id2, id3) values (-1,-1,-1);
+insert into gap1 (id1, id2, id3) values (-1,-1,-1)
+on duplicate key update value=100;
+update gap1 set value=100 where id1=1;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: update gap1 set value=100 where id1=1
+update gap1 set value=100 where id1=1 and id2=1 and id3=1;
+delete from gap1 where id1=2;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: delete from gap1 where id1=2
+delete from gap1 where id1=-1 and id2=-1 and id3=-1;
+commit;
+set session autocommit=1;
+insert into gap1 (id1, id2, id3) values (-1,-1,-1);
+insert into gap1 (id1, id2, id3) values (-1,-1,-1)
+on duplicate key update value=100;
+update gap1 set value=100 where id1=1;
+update gap1 set value=100 where id1=1 and id2=1 and id3=1;
+delete from gap1 where id1=2;
+delete from gap1 where id1=-1 and id2=-1 and id3=-1;
+commit;
+set session autocommit=1;
+insert into gap2 select * from gap1;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: insert into gap2 select * from gap1
+insert into gap2 select * from gap1 where id1=1;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: insert into gap2 select * from gap1 where id1=1
+insert into gap2 select * from gap1 where id1=1 and id2=1 and id3=1;
+create table t4 select * from gap1 where id1=1 and id2=1 and id3=1;
+drop table t4;
+create table t4 select * from gap1;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: create table t4 select * from gap1
+create table t4 select * from gap1 where id1=1;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: create table t4 select * from gap1 where id1=1
+update gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 set gap1.value=100 where gap2.id1=3
+and gap2.id2=3 and gap2.id3=3;
+update gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 set gap1.value=100 where gap2.id1=3;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: update gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 set gap1.value=100 where gap2.id1=3
+update gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 join gap3 on gap1.id1=gap3.id
+set gap1.value=100 where gap2.id1=3;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: update gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 join gap3 on gap1.id1=gap3.id
+set gap1.value=100 where gap2.id1=3
+update gap1 set gap1.value= (select count(*) from gap2);
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: update gap1 set gap1.value= (select count(*) from gap2)
+delete gap1 from gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 where gap2.id1=3
+and gap2.id2=3 and gap2.id3=3;
+delete gap1 from gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 where gap2.id1=3;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: delete gap1 from gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 where gap2.id1=3
+select * from gap1, gap2 limit 1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1, gap2 limit 1 for update
+select * from gap1 a, gap1 b limit 1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 a, gap1 b limit 1 for update
+create table u1(
+c1 int,
+c2 int,
+c3 int,
+c4 int,
+primary key (c1, c2, c3),
+unique key (c3, c1)
+);
+set session gap_lock_raise_error=1;
+begin;
+insert into u1 values (1,1,1,1);
+commit;
+begin;
+insert into u1 values (1,2,1,1) on duplicate key update c4=10;
+commit;
+begin;
+select * from u1 where c3=1 and c1 = 1 for update;
+c1 c2 c3 c4
+1 1 1 10
+select * from u1 where c3=1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from u1 where c3=1 for update
+commit;
+drop table u1;
+set global gap_lock_write_log= 0;
+set global gap_lock_raise_error= 0;
+drop table if exists gap1, gap2, gap3, gap4, gap5;
+DROP DATABASE mysqlslap;
+0
+SET GLOBAL gap_lock_log_file='<GAP_LOCK_ORIG>';
+SET GLOBAL gap_lock_log_file='<GAP_LOCK>';
+flush general logs;
+SET @save_gap_lock_exceptions = @@global.gap_lock_exceptions;
+SET GLOBAL gap_lock_exceptions="t.*";
+drop table if exists gap1,gap2,gap3;
+CREATE DATABASE mysqlslap;
+CREATE TABLE gap1 (id1 INT, id2 INT, id3 INT, c1 INT, value INT,
+PRIMARY KEY (id1, id2, id3),
+INDEX i (c1)) ENGINE=rocksdb;
+CREATE TABLE gap2 like gap1;
+CREATE TABLE gap3 (id INT, value INT,
+PRIMARY KEY (id),
+UNIQUE KEY ui(value)) ENGINE=rocksdb;
+insert into gap3 values (1,1), (2,2),(3,3),(4,4),(5,5);
+create table gap4 (
+pk int primary key,
+a int,
+b int,
+key(a)
+) ENGINE=rocksdb;
+insert into gap4 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
+create table gap5 like gap4;
+insert into gap5 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
+set session gap_lock_raise_error=1;
+set session gap_lock_write_log=1;
+set session autocommit=0;
+select * from gap1 limit 1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 limit 1 for update
+select * from gap1 where value != 100 limit 1 for update;
+ERROR HY000: Using Gap Lock without full unique key in multi-table or multi-statement transactions is not allowed. You need either 1: Execute 'SET SESSION gap_lock_raise_error=0' if you are sure that your application does not rely on Gap Lock. 2: Rewrite queries to use all unique key columns in WHERE equal conditions. 3: Rewrite to single-table, single-statement transaction. Query: select * from gap1 where value != 100 limit 1 for update
+set global gap_lock_write_log= 0;
+set global gap_lock_raise_error= 0;
+drop table if exists gap1, gap2, gap3, gap4, gap5;
+DROP DATABASE mysqlslap;
+0
+SET GLOBAL gap_lock_log_file='<GAP_LOCK_ORIG>';
+SET GLOBAL gap_lock_log_file='<GAP_LOCK>';
+flush general logs;
+SET GLOBAL gap_lock_exceptions="gap.*";
+drop table if exists gap1,gap2,gap3;
+CREATE DATABASE mysqlslap;
+CREATE TABLE gap1 (id1 INT, id2 INT, id3 INT, c1 INT, value INT,
+PRIMARY KEY (id1, id2, id3),
+INDEX i (c1)) ENGINE=rocksdb;
+CREATE TABLE gap2 like gap1;
+CREATE TABLE gap3 (id INT, value INT,
+PRIMARY KEY (id),
+UNIQUE KEY ui(value)) ENGINE=rocksdb;
+insert into gap3 values (1,1), (2,2),(3,3),(4,4),(5,5);
+create table gap4 (
+pk int primary key,
+a int,
+b int,
+key(a)
+) ENGINE=rocksdb;
+insert into gap4 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
+create table gap5 like gap4;
+insert into gap5 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
+set session gap_lock_raise_error=1;
+set session gap_lock_write_log=1;
+set session autocommit=0;
+select * from gap1 limit 1 for update;
+id1 id2 id3 c1 value
+0 0 1 1 1
+select * from gap1 where value != 100 limit 1 for update;
+id1 id2 id3 c1 value
+0 0 1 1 1
+set global gap_lock_write_log= 0;
+set global gap_lock_raise_error= 0;
+drop table if exists gap1, gap2, gap3, gap4, gap5;
+DROP DATABASE mysqlslap;
+0
+SET GLOBAL gap_lock_log_file='<GAP_LOCK_ORIG>';
+SET GLOBAL gap_lock_log_file='<GAP_LOCK>';
+flush general logs;
+SET GLOBAL gap_lock_exceptions=@save_gap_lock_exceptions;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/get_error_message.result b/storage/rocksdb/mysql-test/rocksdb/r/get_error_message.result
new file mode 100644
index 00000000..04dcac1f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/get_error_message.result
@@ -0,0 +1,8 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(a INT,b INT,KEY (a)) PARTITION BY HASH (a) PARTITIONS 3;
+SHOW TABLES;
+Tables_in_test
+t1
+ALTER TABLE t1 ADD PARTITION(PARTITION p3 DATA DIRECTORY='G:/mysqltest/p3Data' INDEX DIRECTORY='H:/mysqltest/p3Index');
+ERROR 42000: Incorrect table name 'H:/mysqltest/p3Index'
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result b/storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result
new file mode 100644
index 00000000..b8cb4157
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result
@@ -0,0 +1,3526 @@
+set @debug_tmp= @@debug_dbug;
+set global debug_dbug="+d,force_group_by";
+drop table if exists t1;
+create table t1 (
+a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(248) default ' '
+) engine=RocksDB;
+insert into t1 (a1, a2, b, c, d) values
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
+('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
+('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
+('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
+('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'),
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
+('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
+('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
+('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
+('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4');
+create index idx_t1_0 on t1 (a1);
+create index idx_t1_1 on t1 (a1,a2,b,c);
+create index idx_t1_2 on t1 (a1,a2,b);
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+drop table if exists t2;
+create table t2 (
+a1 char(64), a2 char(64) not null, b char(16), c char(16), d char(16), dummy char(248) default ' '
+) engine=RocksDB;
+insert into t2 select * from t1;
+insert into t2 (a1, a2, b, c, d) values
+('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'),
+('a','a','a',NULL,'xyz'),
+('a','a','b',NULL,'xyz'),
+('a','b','a',NULL,'xyz'),
+('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'),
+('d','b','b',NULL,'xyz'),
+('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),
+('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),
+('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'),
+('a','a','a',NULL,'xyz'),
+('a','a','b',NULL,'xyz'),
+('a','b','a',NULL,'xyz'),
+('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'),
+('d','b','b',NULL,'xyz'),
+('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),
+('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz');
+create index idx_t2_0 on t2 (a1);
+create index idx_t2_1 on t2 (a1,a2,b,c);
+create index idx_t2_2 on t2 (a1,a2,b);
+analyze table t2;
+Table Op Msg_type Msg_text
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+drop table if exists t3;
+create table t3 (
+a1 char(1), a2 char(1), b char(1), c char(4) not null, d char(3), dummy char(1) default ' '
+) engine=RocksDB;
+insert into t3 (a1, a2, b, c, d) values
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
+insert into t3 (a1, a2, b, c, d) values
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
+insert into t3 (a1, a2, b, c, d) values
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
+insert into t3 (a1, a2, b, c, d) values
+('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
+('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
+('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
+('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
+('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
+('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
+('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
+('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
+('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
+('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
+('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
+('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4');
+create index idx_t3_0 on t3 (a1);
+create index idx_t3_1 on t3 (a1,a2,b,c);
+create index idx_t3_2 on t3 (a1,a2,b);
+analyze table t3;
+Table Op Msg_type Msg_text
+test.t3 analyze status Engine-independent statistics collected
+test.t3 analyze status OK
+explain select a1, min(a2) from t1 group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
+explain select a1, max(a2) from t1 group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by
+explain select a1, min(a2), max(a2) from t1 group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
+explain select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
+explain select a1,a2,b,max(c),min(c) from t1 group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
+explain select a1,a2,b,max(c),min(c) from t2 group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 # NULL # Using index for group-by
+explain select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
+explain select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
+explain select min(a2) from t1 group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
+explain select a2, min(c), max(c) from t1 group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
+select a1, min(a2) from t1 group by a1;
+a1 min(a2)
+a a
+b a
+c a
+d a
+select a1, max(a2) from t1 group by a1;
+a1 max(a2)
+a b
+b b
+c b
+d b
+select a1, min(a2), max(a2) from t1 group by a1;
+a1 min(a2) max(a2)
+a a b
+b a b
+c a b
+d a b
+select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a a111 d111
+a a b e112 h112
+a b a i121 l121
+a b b m122 p122
+b a a a211 d211
+b a b e212 h212
+b b a i221 l221
+b b b m222 p222
+c a a a311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+d a a a411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+select a1,a2,b,max(c),min(c) from t1 group by a1,a2,b;
+a1 a2 b max(c) min(c)
+a a a d111 a111
+a a b h112 e112
+a b a l121 i121
+a b b p122 m122
+b a a d211 a211
+b a b h212 e212
+b b a l221 i221
+b b b p222 m222
+c a a d311 a311
+c a b h312 e312
+c b a l321 i321
+c b b p322 m322
+d a a d411 a411
+d a b h412 e412
+d b a l421 i421
+d b b p422 m422
+select a1,a2,b,max(c),min(c) from t2 group by a1,a2,b;
+a1 a2 b max(c) min(c)
+a a NULL a999 a777
+a a a d111 a111
+a a b h112 e112
+a b a l121 i121
+a b b p122 m122
+b a a d211 a211
+b a b h212 e212
+b b a l221 i221
+b b b p222 m222
+c a NULL c999 c777
+c a a d311 a311
+c a b h312 e312
+c b a l321 i321
+c b b p322 m322
+d a a d411 a411
+d a b h412 e412
+d b a l421 i421
+d b b p422 m422
+e a a NULL NULL
+e a b NULL NULL
+select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1;
+min(a2) a1 max(a2) min(a2) a1
+a a b a a
+a b b a b
+a c b a c
+a d b a d
+select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b;
+a1 b min(c) a1 max(c) b a2 max(c) max(c)
+a a a111 a d111 a a d111 d111
+a b e112 a h112 b a h112 h112
+a a i121 a l121 a b l121 l121
+a b m122 a p122 b b p122 p122
+b a a211 b d211 a a d211 d211
+b b e212 b h212 b a h212 h212
+b a i221 b l221 a b l221 l221
+b b m222 b p222 b b p222 p222
+c a a311 c d311 a a d311 d311
+c b e312 c h312 b a h312 h312
+c a i321 c l321 a b l321 l321
+c b m322 c p322 b b p322 p322
+d a a411 d d411 a a d411 d411
+d b e412 d h412 b a h412 h412
+d a i421 d l421 a b l421 l421
+d b m422 d p422 b b p422 p422
+select min(a2) from t1 group by a1;
+min(a2)
+a
+a
+a
+a
+select a2, min(c), max(c) from t1 group by a1,a2,b;
+a2 min(c) max(c)
+a a111 d111
+a e112 h112
+b i121 l121
+b m122 p122
+a a211 d211
+a e212 h212
+b i221 l221
+b m222 p222
+a a311 d311
+a e312 h312
+b i321 l321
+b m322 p322
+a a411 d411
+a e412 h412
+b i421 l421
+b m422 p422
+explain select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where a1 < 'd' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
+explain select a1, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1, max(c) from t2 where a1 in ('a','b','d') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
+select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a a111 d111
+a a b e112 h112
+a b a i121 l121
+a b b m122 p122
+b a a a211 d211
+b a b e212 h212
+b b a i221 l221
+b b b m222 p222
+c a a a311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
+a1 a2 b min(c) max(c)
+b a a a211 d211
+b a b e212 h212
+b b a i221 l221
+b b b m222 p222
+c a a a311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+d a a a411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+a1 a2 b max(c)
+a a a d111
+a a b h112
+a b a l121
+a b b p122
+c a a d311
+c a b h312
+c b a l321
+c b b p322
+d a a d411
+d a b h412
+d b a l421
+d b b p422
+select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+a1 max(c)
+a d111
+a h112
+a l121
+a p122
+c d311
+c h312
+c l321
+c p322
+d d411
+d h412
+d l421
+d p422
+select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a a111 d111
+a a b e112 h112
+b a a a211 d211
+b a b e212 h212
+c a a a311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+d a a a411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+a1 a2 b max(c)
+b a a d211
+b a b h212
+b b a l221
+b b b p222
+d a a d411
+d a b h412
+d b a l421
+d b b p422
+select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+a1 a2 b min(c) max(c)
+b a a a211 d211
+b a b e212 h212
+b b a i221 l221
+b b b m222 p222
+d a a a411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+a1 a2 b max(c)
+a b a l121
+a b b p122
+b b a l221
+b b b p222
+c b a l321
+c b b p322
+d b a l421
+d b b p422
+select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a b a i121 l121
+a b b m122 p122
+b b a i221 l221
+b b b m222 p222
+c b a i321 l321
+c b b m322 p322
+d b a i421 l421
+d b b m422 p422
+select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
+a1 min(c) max(c)
+b a211 d211
+b e212 h212
+b i221 l221
+b m222 p222
+c a311 d311
+c e312 h312
+c i321 l321
+c m322 p322
+d a411 d411
+d e412 h412
+d i421 l421
+d m422 p422
+select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b;
+a1 max(c)
+a d111
+a h112
+a l121
+a p122
+b d211
+b h212
+b l221
+b p222
+d d411
+d h412
+d l421
+d p422
+select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b;
+a1 a2 b max(c)
+a a NULL a999
+a a a d111
+a a b h112
+a b a l121
+a b b p122
+b a a d211
+b a b h212
+b b a l221
+b b b p222
+c a NULL c999
+c a a d311
+c a b h312
+c b a l321
+c b b p322
+select a1,a2,b,min(c),max(c) from t2 where a1 < 'd' group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a NULL a777 a999
+a a a a111 d111
+a a b e112 h112
+a b a i121 l121
+a b b m122 p122
+b a a a211 d211
+b a b e212 h212
+b b a i221 l221
+b b b m222 p222
+c a NULL c777 c999
+c a a a311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+select a1,a2,b,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;
+a1 a2 b min(c) max(c)
+b a a a211 d211
+b a b e212 h212
+b b a i221 l221
+b b b m222 p222
+c a NULL c777 c999
+c a a a311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+d a a a411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+e a a NULL NULL
+e a b NULL NULL
+select a1,a2,b, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+a1 a2 b max(c)
+a a NULL a999
+a a a d111
+a a b h112
+a b a l121
+a b b p122
+c a NULL c999
+c a a d311
+c a b h312
+c b a l321
+c b b p322
+d a a d411
+d a b h412
+d b a l421
+d b b p422
+e a a NULL
+e a b NULL
+select a1, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
+a1 max(c)
+a a999
+a d111
+a h112
+a l121
+a p122
+c c999
+c d311
+c h312
+c l321
+c p322
+d d411
+d h412
+d l421
+d p422
+e NULL
+e NULL
+select a1,a2,b,min(c),max(c) from t2 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a NULL a777 a999
+a a a a111 d111
+a a b e112 h112
+b a a a211 d211
+b a b e212 h212
+c a NULL c777 c999
+c a a a311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+d a a a411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+e a a NULL NULL
+e a b NULL NULL
+select a1,a2,b, max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+a1 a2 b max(c)
+b a a d211
+b a b h212
+b b a l221
+b b b p222
+d a a d411
+d a b h412
+d b a l421
+d b b p422
+select a1,a2,b,min(c),max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
+a1 a2 b min(c) max(c)
+b a a a211 d211
+b a b e212 h212
+b b a i221 l221
+b b b m222 p222
+d a a a411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+select a1,a2,b, max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+a1 a2 b max(c)
+a b a l121
+a b b p122
+b b a l221
+b b b p222
+c b a l321
+c b b p322
+d b a l421
+d b b p422
+select a1,a2,b,min(c),max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a b a i121 l121
+a b b m122 p122
+b b a i221 l221
+b b b m222 p222
+c b a i321 l321
+c b b m322 p322
+d b a i421 l421
+d b b m422 p422
+select a1,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b;
+a1 min(c) max(c)
+b a211 d211
+b e212 h212
+b i221 l221
+b m222 p222
+c c777 c999
+c a311 d311
+c e312 h312
+c i321 l321
+c m322 p322
+d a411 d411
+d e412 h412
+d i421 l421
+d m422 p422
+e NULL NULL
+e NULL NULL
+select a1, max(c) from t2 where a1 in ('a','b','d') group by a1,a2,b;
+a1 max(c)
+a a999
+a d111
+a h112
+a l121
+a p122
+b d211
+b h212
+b l221
+b p222
+d d411
+d h412
+d l421
+d p422
+#
+# MariaDB: we dont have the following patch:
+#
+# commit 60a92a79a3b7fde3c6efe91799e344b977c8e5c3
+# Author: Manuel Ung <mung@fb.com>
+# Date: Thu Apr 19 23:06:27 2018 -0700
+#
+# Enhance group-by loose index scan
+#
+# So the following results are not very meaningful, but are still kept here
+explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 147 NULL 5 Using where; Using index for group-by
+explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
+explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
+explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b' or b = 'a') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
+explain select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 147 NULL 5 Using where; Using index for group-by
+explain select a1,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
+explain select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
+explain select a1,a2,b, max(c) from t1 where (b = 'b') group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
+explain select a1,a2,b,min(c),max(c) from t1 where (b = 'b') group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
+explain select a1,a2, max(c) from t1 where (b = 'b') group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using where; Using index for group-by
+explain select a1,a2, max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL 6 Using where; Using index for group-by
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL 6 Using where; Using index for group-by
+explain select a1,max(c),min(c) from t2 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1,a2,b, max(c) from t2 where (b = 'b') group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 146 NULL 10 Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1,a2,b,min(c),max(c) from t2 where (b = 'b') group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL 10 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1,a2, max(c) from t2 where (b = 'b') group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 146 NULL 10 Using where; Using index for group-by
+explain select a1,a2, max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 range NULL idx_t3_1 6 NULL 4 Using where; Using index for group-by
+explain select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index
+explain select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index
+explain select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 range NULL idx_t3_1 6 NULL 4 Using where; Using index for group-by
+explain select a1,max(c),min(c) from t3 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index
+explain select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index
+select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;
+a1 a2 b max(c) min(c)
+a a b h112 e112
+b a b h212 e212
+c a b h312 e312
+d a b h412 e412
+select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+a1 a2 b max(c) min(c)
+a a b p122 e112
+b a b p222 e212
+c a b p322 e312
+d a b p422 e412
+select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+a1 a2 b max(c) min(c)
+a a a h112 a111
+b a a h212 a211
+c a a h312 a311
+d a a h412 a411
+select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b' or b = 'a') group by a1;
+a1 a2 b max(c) min(c)
+a a a p122 a111
+b a a p222 a211
+c a a p322 a311
+d a a p422 a411
+select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1;
+a1 max(c) min(c)
+a h112 e112
+b h212 e212
+c h312 e312
+d h412 e412
+select a1,max(c),min(c) from t1 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+a1 max(c) min(c)
+a p122 e112
+b p222 e212
+c p322 e312
+d p422 e412
+select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+a1 max(c) min(c)
+a h112 a111
+b h212 a211
+c h312 a311
+d h412 a411
+select a1,a2,b, max(c) from t1 where (b = 'b') group by a1,a2;
+a1 a2 b max(c)
+a a b h112
+a b b p122
+b a b h212
+b b b p222
+c a b h312
+c b b p322
+d a b h412
+d b b p422
+select a1,a2,b, max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2;
+a1 a2 b max(c)
+a a a h112
+a b a p122
+b a a h212
+b b a p222
+c a a h312
+c b a p322
+d a a h412
+d b a p422
+select a1,a2,b,min(c),max(c) from t1 where (b = 'b') group by a1,a2;
+a1 a2 b min(c) max(c)
+a a b e112 h112
+a b b m122 p122
+b a b e212 h212
+b b b m222 p222
+c a b e312 h312
+c b b m322 p322
+d a b e412 h412
+d b b m422 p422
+select a1,a2,b,min(c),max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2;
+a1 a2 b min(c) max(c)
+a a a a111 h112
+a b a i121 p122
+b a a a211 h212
+b b a i221 p222
+c a a a311 h312
+c b a i321 p322
+d a a a411 h412
+d b a i421 p422
+select a1,a2, max(c) from t1 where (b = 'b') group by a1,a2;
+a1 a2 max(c)
+a a h112
+a b p122
+b a h212
+b b p222
+c a h312
+c b p322
+d a h412
+d b p422
+select a1,a2, max(c) from t1 where (b = 'b' or b = 'a') group by a1,a2;
+a1 a2 max(c)
+a a h112
+a b p122
+b a h212
+b b p222
+c a h312
+c b p322
+d a h412
+d b p422
+select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;
+a1 a2 b max(c) min(c)
+a a b h112 e112
+b a b h212 e212
+c a b h312 e312
+d a b h412 e412
+e a b NULL NULL
+select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+a1 a2 b max(c) min(c)
+a a b p122 e112
+b a b p222 e212
+c a b p322 e312
+d a b p422 e412
+e a b NULL NULL
+select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+a1 a2 b max(c) min(c)
+a a a h112 a111
+b a a h212 a211
+c a a h312 a311
+d a a h412 a411
+e a a NULL NULL
+select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1;
+a1 max(c) min(c)
+a h112 e112
+b h212 e212
+c h312 e312
+d h412 e412
+e NULL NULL
+select a1,max(c),min(c) from t2 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+a1 max(c) min(c)
+a p122 e112
+b p222 e212
+c p322 e312
+d p422 e412
+e NULL NULL
+select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+a1 max(c) min(c)
+a h112 a111
+b h212 a211
+c h312 a311
+d h412 a411
+e NULL NULL
+select a1,a2,b, max(c) from t2 where (b = 'b') group by a1,a2;
+a1 a2 b max(c)
+a a b h112
+a b b p122
+b a b h212
+b b b p222
+c a b h312
+c b b p322
+d a b h412
+d b b p422
+e a b NULL
+select a1,a2,b, max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2;
+a1 a2 b max(c)
+a a a h112
+a b a p122
+b a a h212
+b b a p222
+c a a h312
+c b a p322
+d a a h412
+d b a p422
+e a a NULL
+select a1,a2,b,min(c),max(c) from t2 where (b = 'b') group by a1,a2;
+a1 a2 b min(c) max(c)
+a a b e112 h112
+a b b m122 p122
+b a b e212 h212
+b b b m222 p222
+c a b e312 h312
+c b b m322 p322
+d a b e412 h412
+d b b m422 p422
+e a b NULL NULL
+select a1,a2,b,min(c),max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2;
+a1 a2 b min(c) max(c)
+a a a a111 h112
+a b a i121 p122
+b a a a211 h212
+b b a i221 p222
+c a a a311 h312
+c b a i321 p322
+d a a a411 h412
+d b a i421 p422
+e a a NULL NULL
+select a1,a2, max(c) from t2 where (b = 'b') group by a1,a2;
+a1 a2 max(c)
+a a h112
+a b p122
+b a h212
+b b p222
+c a h312
+c b p322
+d a h412
+d b p422
+e a NULL
+select a1,a2, max(c) from t2 where (b = 'b' or b = 'a') group by a1,a2;
+a1 a2 max(c)
+a a h112
+a b p122
+b a h212
+b b p222
+c a h312
+c b p322
+d a h412
+d b p422
+e a NULL
+select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;
+a1 a2 b max(c) min(c)
+a a b h112 e112
+b a b h212 e212
+c a b h312 e312
+select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+a1 a2 b max(c) min(c)
+a a b p122 e112
+b a b p222 e212
+c a b p322 e312
+select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+a1 a2 b max(c) min(c)
+a a a h112 a111
+b a a h212 a211
+c a a h312 a311
+select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1;
+a1 max(c) min(c)
+a h112 e112
+b h212 e212
+c h312 e312
+select a1,max(c),min(c) from t3 where (a2 = 'a' or a2 = 'b') and (b = 'b') group by a1;
+a1 max(c) min(c)
+a p122 e112
+b p222 e212
+c p322 e312
+select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b' or b = 'a') group by a1;
+a1 max(c) min(c)
+a h112 a111
+b h212 a211
+c h312 a311
+explain select a1,a2,b,min(c) from t2 where (a2 = 'a') and b is NULL group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL 6 Using where; Using index for group-by
+explain select a1,a2,b,min(c) from t2 where (a2 = 'a' or a2 = 'b') and b is NULL group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1,a2,b,max(c) from t2 where (a2 = 'a') and b is NULL group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 146 NULL 6 Using where; Using index for group-by
+explain select a1,a2,b,max(c) from t2 where (a2 = 'a' or a2 = 'b') and b is NULL group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1,a2,b,min(c) from t2 where b is NULL group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL 10 Using where; Using index for group-by
+explain select a1,a2,b,max(c) from t2 where b is NULL group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 146 NULL 10 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL 10 Using where; Using index for group-by
+select a1,a2,b,min(c) from t2 where (a2 = 'a') and b is NULL group by a1;
+a1 a2 b min(c)
+a a NULL a777
+c a NULL c777
+select a1,a2,b,min(c) from t2 where (a2 = 'a' or a2 = 'b') and b is NULL group by a1;
+a1 a2 b min(c)
+a a NULL a777
+c a NULL c777
+select a1,a2,b,max(c) from t2 where (a2 = 'a') and b is NULL group by a1;
+a1 a2 b max(c)
+a a NULL a999
+c a NULL c999
+select a1,a2,b,max(c) from t2 where (a2 = 'a' or a2 = 'b') and b is NULL group by a1;
+a1 a2 b max(c)
+a a NULL a999
+c a NULL c999
+select a1,a2,b,min(c) from t2 where b is NULL group by a1,a2;
+a1 a2 b min(c)
+a a NULL a777
+c a NULL c777
+select a1,a2,b,max(c) from t2 where b is NULL group by a1,a2;
+a1 a2 b max(c)
+a a NULL a999
+c a NULL c999
+select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2;
+a1 a2 b min(c) max(c)
+a a NULL a777 a999
+c a NULL c777 c999
+select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2;
+a1 a2 b min(c) max(c)
+a a NULL a777 a999
+c a NULL c777 c999
+explain select a1,a2,b, max(c) from t1 where (c > 'b1') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 147 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t1 where (c > 'f123') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where (c > 'f123') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t1 where (c < 'a0') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t1 where (c < 'k321') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where (c < 'k321') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where (c between 'b111' and 'g112') or (c between 'd000' and 'i110') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t2 where (c > 'b1') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t2 where (c > 'f123') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where (c > 'f123') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t2 where (c < 'a0') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t2 where (c < 'k321') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where (c < 'k321') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b, max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+select a1,a2,b, max(c) from t1 where (c > 'b1') group by a1,a2,b;
+a1 a2 b max(c)
+a a a d111
+a a b h112
+a b a l121
+a b b p122
+b a a d211
+b a b h212
+b b a l221
+b b b p222
+c a a d311
+c a b h312
+c b a l321
+c b b p322
+d a a d411
+d a b h412
+d b a l421
+d b b p422
+select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a b111 d111
+a a b e112 h112
+a b a i121 l121
+a b b m122 p122
+b a a b211 d211
+b a b e212 h212
+b b a i221 l221
+b b b m222 p222
+c a a b311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+d a a b411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+select a1,a2,b, max(c) from t1 where (c > 'f123') group by a1,a2,b;
+a1 a2 b max(c)
+a a b h112
+a b a l121
+a b b p122
+b a b h212
+b b a l221
+b b b p222
+c a b h312
+c b a l321
+c b b p322
+d a b h412
+d b a l421
+d b b p422
+select a1,a2,b,min(c),max(c) from t1 where (c > 'f123') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a b g112 h112
+a b a i121 l121
+a b b m122 p122
+b a b f212 h212
+b b a i221 l221
+b b b m222 p222
+c a b f312 h312
+c b a i321 l321
+c b b m322 p322
+d a b f412 h412
+d b a i421 l421
+d b b m422 p422
+select a1,a2,b, max(c) from t1 where (c < 'a0') group by a1,a2,b;
+a1 a2 b max(c)
+select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+select a1,a2,b, max(c) from t1 where (c < 'k321') group by a1,a2,b;
+a1 a2 b max(c)
+a a a d111
+a a b h112
+a b a k121
+b a a d211
+b a b h212
+b b a k221
+c a a d311
+c a b h312
+c b a j321
+d a a d411
+d a b h412
+d b a j421
+select a1,a2,b,min(c),max(c) from t1 where (c < 'k321') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a a111 d111
+a a b e112 h112
+a b a i121 k121
+b a a a211 d211
+b a b e212 h212
+b b a i221 k221
+c a a a311 d311
+c a b e312 h312
+c b a i321 j321
+d a a a411 d411
+d a b e412 h412
+d b a i421 j421
+select a1,a2,b, max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+a1 a2 b max(c)
+a a a d111
+a a b h112
+a b a l121
+a b b p122
+b a a d211
+b a b h212
+b b a l221
+b b b p222
+c a a d311
+c a b h312
+c b a l321
+c b b p322
+d a a d411
+d a b h412
+d b a l421
+d b b p422
+select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a b111 d111
+a a b e112 h112
+a b a i121 l121
+a b b m122 p122
+b a a b211 d211
+b a b e212 h212
+b b a i221 l221
+b b b m222 p222
+c a a b311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+d a a b411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+select a1,a2,b, max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+a1 a2 b max(c)
+a a a d111
+a a b h112
+a b a l121
+a b b p122
+b a a d211
+b a b h212
+b b a l221
+b b b p222
+c a a d311
+c a b h312
+c b a l321
+c b b p322
+d a a d411
+d a b h412
+d b a l421
+d b b p422
+select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a a111 d111
+a a b e112 h112
+a b a i121 l121
+a b b m122 p122
+b a a a211 d211
+b a b e212 h212
+b b a i221 l221
+b b b m222 p222
+c a a a311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+d a a a411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+select a1,a2,b,min(c),max(c) from t1 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a c111 d111
+a a b e112 g112
+b a a b211 d211
+b a b e212 f212
+c a a b311 d311
+c a b e312 f312
+d a a b411 d411
+d a b e412 f412
+select a1,a2,b,min(c),max(c) from t1 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a a111 c111
+b a a a211 c211
+c a a a311 c311
+d a a a411 c411
+d a b g412 g412
+d b a k421 k421
+select a1,a2,b,min(c),max(c) from t1 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a c111 d111
+a a b e112 h112
+b a a b211 d211
+b a b e212 h212
+c a a b311 d311
+c a b e312 h312
+d a a b411 d411
+d a b e412 h412
+select a1,a2,b,min(c),max(c) from t1 where (c between 'b111' and 'g112') or (c between 'd000' and 'i110') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a b111 d111
+a a b e112 h112
+b a a b211 d211
+b a b e212 h212
+c a a b311 d311
+c a b e312 h312
+d a a b411 d411
+d a b e412 h412
+select a1,a2,b, max(c) from t2 where (c > 'b1') group by a1,a2,b;
+a1 a2 b max(c)
+a a a d111
+a a b h112
+a b a l121
+a b b p122
+b a a d211
+b a b h212
+b b a l221
+b b b p222
+c a NULL c999
+c a a d311
+c a b h312
+c b a l321
+c b b p322
+d a a d411
+d a b h412
+d b a l421
+d b b p422
+select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a b111 d111
+a a b e112 h112
+a b a i121 l121
+a b b m122 p122
+b a a b211 d211
+b a b e212 h212
+b b a i221 l221
+b b b m222 p222
+c a NULL c777 c999
+c a a b311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+d a a b411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+select a1,a2,b, max(c) from t2 where (c > 'f123') group by a1,a2,b;
+a1 a2 b max(c)
+a a b h112
+a b a l121
+a b b p122
+b a b h212
+b b a l221
+b b b p222
+c a b h312
+c b a l321
+c b b p322
+d a b h412
+d b a l421
+d b b p422
+select a1,a2,b,min(c),max(c) from t2 where (c > 'f123') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a b g112 h112
+a b a i121 l121
+a b b m122 p122
+b a b f212 h212
+b b a i221 l221
+b b b m222 p222
+c a b f312 h312
+c b a i321 l321
+c b b m322 p322
+d a b f412 h412
+d b a i421 l421
+d b b m422 p422
+select a1,a2,b, max(c) from t2 where (c < 'a0') group by a1,a2,b;
+a1 a2 b max(c)
+select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+select a1,a2,b, max(c) from t2 where (c < 'k321') group by a1,a2,b;
+a1 a2 b max(c)
+a a NULL a999
+a a a d111
+a a b h112
+a b a k121
+b a a d211
+b a b h212
+b b a k221
+c a NULL c999
+c a a d311
+c a b h312
+c b a j321
+d a a d411
+d a b h412
+d b a j421
+select a1,a2,b,min(c),max(c) from t2 where (c < 'k321') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a NULL a777 a999
+a a a a111 d111
+a a b e112 h112
+a b a i121 k121
+b a a a211 d211
+b a b e212 h212
+b b a i221 k221
+c a NULL c777 c999
+c a a a311 d311
+c a b e312 h312
+c b a i321 j321
+d a a a411 d411
+d a b e412 h412
+d b a i421 j421
+select a1,a2,b, max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+a1 a2 b max(c)
+a a a d111
+a a b h112
+a b a l121
+a b b p122
+b a a d211
+b a b h212
+b b a l221
+b b b p222
+c a NULL c999
+c a a d311
+c a b h312
+c b a l321
+c b b p322
+d a a d411
+d a b h412
+d b a l421
+d b b p422
+select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a b111 d111
+a a b e112 h112
+a b a i121 l121
+a b b m122 p122
+b a a b211 d211
+b a b e212 h212
+b b a i221 l221
+b b b m222 p222
+c a NULL c777 c999
+c a a b311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+d a a b411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+select a1,a2,b, max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+a1 a2 b max(c)
+a a NULL a999
+a a a d111
+a a b h112
+a b a l121
+a b b p122
+b a a d211
+b a b h212
+b b a l221
+b b b p222
+c a NULL c999
+c a a d311
+c a b h312
+c b a l321
+c b b p322
+d a a d411
+d a b h412
+d b a l421
+d b b p422
+select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a NULL a777 a999
+a a a a111 d111
+a a b e112 h112
+a b a i121 l121
+a b b m122 p122
+b a a a211 d211
+b a b e212 h212
+b b a i221 l221
+b b b m222 p222
+c a NULL c777 c999
+c a a a311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+d a a a411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+select a1,a2,b,min(c),max(c) from t2 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a c111 d111
+a a b e112 g112
+b a a b211 d211
+b a b e212 f212
+c a NULL c777 c999
+c a a b311 d311
+c a b e312 f312
+d a a b411 d411
+d a b e412 f412
+select a1,a2,b,min(c),max(c) from t2 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a NULL a777 a999
+a a a a111 c111
+b a a a211 c211
+c a a a311 c311
+d a a a411 c411
+d a b g412 g412
+d b a k421 k421
+select a1,a2,b,min(c),max(c) from t2 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a c111 d111
+a a b e112 h112
+b a a b211 d211
+b a b e212 h212
+c a NULL c777 c999
+c a a b311 d311
+c a b e312 h312
+d a a b411 d411
+d a b e412 h412
+explain select a1,a2,b,min(c),max(c) from t1
+where exists ( select * from t2 where t2.c = t1.c )
+group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using index
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 16 func 1
+2 MATERIALIZED t2 index NULL idx_t2_1 163 NULL 164 Using index
+explain select a1,a2,b,min(c),max(c) from t1
+where exists ( select * from t2 where t2.c > 'b1' )
+group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using index
+2 SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c) from t1 where (ord(a1) > 97) and (ord(a2) + ord(a1) > 194) and (b = 'c') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c),max(c) from t2 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
+select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a b e112 h112
+b a b e212 h212
+c a b e312 h312
+c b b m322 p322
+d a b e412 h412
+d b b m422 p422
+select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a c111 d111
+a a b e112 h112
+b a a b211 d211
+b a b e212 h212
+c a a b311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+d a a b411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a b a i121 l121
+b b a i221 l221
+c b a i321 l321
+d b a i421 l421
+select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
+a1 a2 b min(c)
+b b a k221
+c b a k321
+d b a k421
+select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
+a1 a2 b min(c)
+b b a k221
+c b a k321
+d b a k421
+select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+a1 a2 b min(c)
+select a1,a2,b,min(c) from t1 where (ord(a1) > 97) and (ord(a2) + ord(a1) > 194) and (b = 'c') group by a1,a2,b;
+a1 a2 b min(c)
+select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a b e112 h112
+b a b e212 h212
+c a b e312 h312
+c b b m322 p322
+d a b e412 h412
+d b b m422 p422
+e a b NULL NULL
+select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a c111 d111
+a a b e112 h112
+b a a b211 d211
+b a b e212 h212
+c a NULL c777 c999
+c a a b311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+d a a b411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+select a1,a2,b,min(c),max(c) from t2 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a b a i121 l121
+b b a i221 l221
+c b a i321 l321
+d b a i421 l421
+select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
+a1 a2 b min(c)
+b b a k221
+c b a k321
+d b a k421
+select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
+a1 a2 b min(c)
+b b a k221
+c b a k321
+d b a k421
+select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+a1 a2 b min(c)
+explain select a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121' or c = 'i121') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 17 Using where; Using index for group-by
+explain select a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 146 NULL # Using where; Using index for group-by
+explain select a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using where; Using index for group-by
+explain select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121' or c = 'i121') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 146 NULL # Using where; Using index for group-by
+select a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+a1 a2 b
+a a b
+b a b
+c a b
+c b b
+d a b
+d b b
+select a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+a1 a2 b
+a b a
+b b a
+c b a
+d b a
+select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+a1 a2 b c
+a b a i121
+select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121' or c = 'i121') group by a1,a2,b;
+a1 a2 b c
+a b a i121
+select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+a1 a2 b
+select a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
+a1 a2 b
+a a b
+b a b
+c a b
+c b b
+d a b
+d b b
+e a b
+select a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+a1 a2 b
+a b a
+b b a
+c b a
+d b a
+select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+a1 a2 b c
+a b a i121
+select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121' or c = 'i121') group by a1,a2,b;
+a1 a2 b c
+a b a i121
+select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+a1 a2 b
+explain select distinct a1,a2,b from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using index for group-by
+explain select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using where; Using index for group-by
+explain extended select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 100.00 Using where; Using index for group-by
+Warnings:
+Note 1003 select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where `test`.`t1`.`b` = 'a' and `test`.`t1`.`c` = 'i121' and `test`.`t1`.`a2` >= 'b'
+explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 17 Using where; Using index for group-by
+explain select distinct b from t1 where (a2 >= 'b') and (b = 'a');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
+explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 5 Using where; Using index for group-by
+explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 5 Using where; Using index for group-by
+explain select distinct a1,a2,b from t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using index for group-by
+explain select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using where; Using index for group-by
+explain extended select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL 83 100.00 Using where; Using index for group-by
+Warnings:
+Note 1003 select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where `test`.`t2`.`b` = 'a' and `test`.`t2`.`c` = 'i121' and `test`.`t2`.`a2` >= 'b'
+explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 146 NULL # Using where; Using index for group-by
+explain select distinct b from t2 where (a2 >= 'b') and (b = 'a');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_2 146 NULL 164 Using where; Using index
+explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'b';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 129 NULL 6 Using where; Using index for group-by
+explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 129 NULL 6 Using where; Using index for group-by
+select distinct a1,a2,b from t1;
+a1 a2 b
+a a a
+a a b
+a b a
+a b b
+b a a
+b a b
+b b a
+b b b
+c a a
+c a b
+c b a
+c b b
+d a a
+d a b
+d b a
+d b b
+select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a');
+a1 a2 b
+a b a
+b b a
+c b a
+d b a
+select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
+a1 a2 b c
+a b a i121
+select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
+a1 a2 b
+select distinct b from t1 where (a2 >= 'b') and (b = 'a');
+b
+a
+select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b';
+a1
+a
+d
+select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e';
+a1
+select distinct a1,a2,b from t2;
+a1 a2 b
+a a NULL
+a a a
+a a b
+a b a
+a b b
+b a a
+b a b
+b b a
+b b b
+c a NULL
+c a a
+c a b
+c b a
+c b b
+d a a
+d a b
+d b a
+d b b
+e a a
+e a b
+select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a');
+a1 a2 b
+a b a
+b b a
+c b a
+d b a
+select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
+a1 a2 b c
+a b a i121
+select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
+a1 a2 b
+select distinct b from t2 where (a2 >= 'b') and (b = 'a');
+b
+a
+select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'b';
+a1
+a
+d
+select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e';
+a1
+select distinct t_00.a1
+from t1 t_00
+where exists ( select * from t2 where a1 = t_00.a1 );
+a1
+a
+b
+c
+d
+select distinct a1,a1 from t1;
+a1 a1
+a a
+b b
+c c
+d d
+select distinct a2,a1,a2,a1 from t1;
+a2 a1 a2 a1
+a a a a
+b a b a
+a b a b
+b b b b
+a c a c
+b c b c
+a d a d
+b d b d
+select distinct t1.a1,t2.a1 from t1,t2;
+a1 a1
+a a
+b a
+c a
+d a
+a b
+b b
+c b
+d b
+a c
+b c
+c c
+d c
+a d
+b d
+c d
+d d
+a e
+b e
+c e
+d e
+explain select distinct a1,a2,b from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using index for group-by
+explain select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using where; Using index for group-by
+explain select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
+explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 17 Using where; Using index for group-by
+explain select distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using where; Using index for group-by; Using temporary; Using filesort
+explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b' group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 5 Using where; Using index for group-by
+explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e' group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 5 Using where; Using index for group-by
+explain select distinct a1,a2,b from t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using index for group-by
+explain select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using where; Using index for group-by
+explain select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
+explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 146 NULL # Using where; Using index for group-by
+explain select distinct b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using where; Using index for group-by; Using temporary; Using filesort
+explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'b' group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 129 NULL # Using where; Using index for group-by
+explain select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e' group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_2 129 NULL # Using where; Using index for group-by
+select distinct a1,a2,b from t1;
+a1 a2 b
+a a a
+a a b
+a b a
+a b b
+b a a
+b a b
+b b a
+b b b
+c a a
+c a b
+c b a
+c b b
+d a a
+d a b
+d b a
+d b b
+select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+a1 a2 b
+a b a
+b b a
+c b a
+d b a
+select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+a1 a2 b c
+a b a i121
+select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+a1 a2 b
+select distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+b
+a
+select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b' group by a1;
+a1
+a
+d
+select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e' group by a1;
+a1
+select distinct a1,a2,b from t2;
+a1 a2 b
+a a NULL
+a a a
+a a b
+a b a
+a b b
+b a a
+b a b
+b b a
+b b b
+c a NULL
+c a a
+c a b
+c b a
+c b b
+d a a
+d a b
+d b a
+d b b
+e a a
+e a b
+select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+a1 a2 b
+a b a
+b b a
+c b a
+d b a
+select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b;
+a1 a2 b c
+a b a i121
+select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
+a1 a2 b
+select distinct b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
+b
+a
+select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'b' group by a1;
+a1
+a
+d
+select distinct a1 from t2 where a1 in ('a', 'd') and a2 = 'e' group by a1;
+a1
+explain select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using where; Using index for group-by
+explain select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 Using where; Using index for group-by
+explain extended select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 17 100.00 Using where; Using index for group-by
+Warnings:
+Note 1003 select count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `count(distinct a1,a2,b)` from `test`.`t1` where `test`.`t1`.`b` = 'c' and `test`.`t1`.`a1` > 'a' and `test`.`t1`.`a2` > 'a'
+explain select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
+explain extended select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 17 100.00 Using where; Using index for group-by
+Warnings:
+Note 1003 select 98 + count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `98 + count(distinct a1,a2,b)` from `test`.`t1` where `test`.`t1`.`a1` > 'a' and `test`.`t1`.`a2` > 'a'
+select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
+count(distinct a1,a2,b)
+4
+select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
+count(distinct a1,a2,b,c)
+1
+select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
+count(distinct a1,a2,b)
+0
+select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a');
+count(distinct b)
+1
+select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a');
+98 + count(distinct a1,a2,b)
+104
+explain select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
+explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_2 147 NULL 9 Using index for group-by
+select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b;
+a1 a2 b concat(min(c), max(c))
+a a a a111d111
+a a b e112h112
+a b a i121l121
+a b b m122p122
+b a a a211d211
+b a b e212h212
+b b a i221l221
+b b b m222p222
+c a a a311d311
+c a b e312h312
+c b a i321l321
+c b b m322p322
+select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b;
+concat(a1,min(c)) b
+aa111 a
+ae112 b
+ai121 a
+am122 b
+ba211 a
+be212 b
+bi221 a
+bm222 b
+ca311 a
+ce312 b
+ci321 a
+cm322 b
+select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b;
+concat(a1,min(c)) b max(c)
+aa111 a d111
+ae112 b h112
+ai121 a l121
+am122 b p122
+ba211 a d211
+be212 b h212
+bi221 a l221
+bm222 b p222
+ca311 a d311
+ce312 b h312
+ci321 a l321
+cm322 b p322
+select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
+concat(a1,a2) b min(c) max(c)
+aa a a111 d111
+aa b e112 h112
+ab a i121 l121
+ab b m122 p122
+ba a a211 d211
+ba b e212 h212
+bb a i221 l221
+bb b m222 p222
+ca a a311 d311
+ca b e312 h312
+cb a i321 l321
+cb b m322 p322
+select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2;
+concat(ord(min(b)),ord(max(b))) min(b) max(b)
+9798 a b
+9798 a b
+9798 a b
+9798 a b
+9798 a b
+9798 a b
+9798 a b
+9798 a b
+explain select a1,a2,b,d,min(c),max(c) from t1 group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128
+explain select a1,a2,b,d from t1 group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128
+explain extended select a1,a2,min(b),max(b) from t1
+where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 128 99.22 Using where; Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`
+explain extended select a1,a2,b,min(c),max(c) from t1
+where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 128 75.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
+explain extended select a1,a2,b,c from t1
+where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 128 75.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c`
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b < 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b <= 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b <= 'b' and b >= 'a') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 128 99.22 Using where; Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
+explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;
+a1 a2 min(b) c
+a a a a111
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b = 'a') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1,a2,b,min(c),max(c) from t2
+where (c > 'a000') and (c <= 'd999') and (c like '_8__') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1, a2, b, c, min(d), max(d) from t1 group by a1,a2,b,c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128
+explain select a1,a2,count(a2) from t1 group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using index
+explain extended select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 128 100.00 Using where; Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
+explain extended select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 128 100.00 Using where; Using index
+Warnings:
+Note 1003 select sum(ord(`test`.`t1`.`a1`)) AS `sum(ord(a1))` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'a' or b = 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'a' or b = 'b') group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+explain select distinct(a1) from t1 where ord(a2) = 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
+select distinct(a1) from t1 where ord(a2) = 98;
+a1
+a
+b
+c
+d
+explain select a1 from t1 where a2 = 'b' group by a1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_2 130 NULL 5 Using where; Using index for group-by
+select a1 from t1 where a2 = 'b' group by a1;
+a1
+a
+b
+c
+d
+explain select distinct a1 from t1 where a2 = 'b';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx_t1_2 130 NULL 5 Using where; Using index for group-by
+select distinct a1 from t1 where a2 = 'b';
+a1
+a
+b
+c
+d
+drop table t1,t2,t3;
+create table t1 (c1 int not null,c2 int not null, primary key(c1,c2)) engine=RocksDB;
+insert into t1 (c1,c2) values
+(10,1),(10,2),(10,3),(20,4),(20,5),(20,6),(30,7),(30,8),(30,9);
+select distinct c1, c2 from t1 order by c2;
+c1 c2
+10 1
+10 2
+10 3
+20 4
+20 5
+20 6
+30 7
+30 8
+30 9
+select c1,min(c2) as c2 from t1 group by c1 order by c2;
+c1 c2
+10 1
+20 4
+30 7
+select c1,c2 from t1 group by c1,c2 order by c2;
+c1 c2
+10 1
+10 2
+10 3
+20 4
+20 5
+20 6
+30 7
+30 8
+30 9
+drop table t1;
+CREATE TABLE t1 (a varchar(5), b int(11), PRIMARY KEY (a,b)) engine=RocksDB;
+INSERT INTO t1 VALUES ('AA',1), ('AA',2), ('AA',3), ('BB',1), ('AA',4);
+OPTIMIZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+SELECT a FROM t1 WHERE a='AA' GROUP BY a;
+a
+AA
+SELECT a FROM t1 WHERE a='BB' GROUP BY a;
+a
+BB
+EXPLAIN SELECT a FROM t1 WHERE a='AA' GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref PRIMARY PRIMARY 7 const 1000 Using where; Using index
+EXPLAIN SELECT a FROM t1 WHERE a='BB' GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref PRIMARY PRIMARY 7 const 1000 Using where; Using index
+SELECT DISTINCT a FROM t1 WHERE a='BB';
+a
+BB
+SELECT DISTINCT a FROM t1 WHERE a LIKE 'B%';
+a
+BB
+SELECT a FROM t1 WHERE a LIKE 'B%' GROUP BY a;
+a
+BB
+DROP TABLE t1;
+CREATE TABLE t1 (
+a int(11) NOT NULL DEFAULT '0',
+b varchar(16) COLLATE latin1_general_ci NOT NULL DEFAULT '',
+PRIMARY KEY (a,b)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+CREATE PROCEDURE a(x INT)
+BEGIN
+DECLARE rnd INT;
+DECLARE cnt INT;
+WHILE x > 0 DO
+SET rnd= x % 100;
+SET cnt = (SELECT COUNT(*) FROM t1 WHERE a = rnd);
+INSERT INTO t1(a,b) VALUES (rnd, CAST(cnt AS CHAR));
+SET x= x - 1;
+END WHILE;
+END|
+CALL a(1000);
+SELECT a FROM t1 WHERE a=0;
+a
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+SELECT DISTINCT a FROM t1 WHERE a=0;
+a
+0
+SELECT COUNT(DISTINCT a) FROM t1 WHERE a=0;
+COUNT(DISTINCT a)
+1
+DROP TABLE t1;
+DROP PROCEDURE a;
+CREATE TABLE t1 (a varchar(64) NOT NULL default '', PRIMARY KEY(a)) engine=RocksDB;
+INSERT INTO t1 (a) VALUES
+(''), ('CENTRAL'), ('EASTERN'), ('GREATER LONDON'),
+('NORTH CENTRAL'), ('NORTH EAST'), ('NORTH WEST'), ('SCOTLAND'),
+('SOUTH EAST'), ('SOUTH WEST'), ('WESTERN');
+EXPLAIN SELECT DISTINCT a,a FROM t1 ORDER BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 66 NULL 1000 Using index
+SELECT DISTINCT a,a FROM t1 ORDER BY a;
+a a
+
+CENTRAL CENTRAL
+EASTERN EASTERN
+GREATER LONDON GREATER LONDON
+NORTH CENTRAL NORTH CENTRAL
+NORTH EAST NORTH EAST
+NORTH WEST NORTH WEST
+SCOTLAND SCOTLAND
+SOUTH EAST SOUTH EAST
+SOUTH WEST SOUTH WEST
+WESTERN WESTERN
+DROP TABLE t1;
+CREATE TABLE t1 (id1 INT, id2 INT) engine=RocksDB;
+CREATE TABLE t2 (id2 INT, id3 INT, id5 INT) engine=RocksDB;
+CREATE TABLE t3 (id3 INT, id4 INT) engine=RocksDB;
+CREATE TABLE t4 (id4 INT) engine=RocksDB;
+CREATE TABLE t5 (id5 INT, id6 INT) engine=RocksDB;
+CREATE TABLE t6 (id6 INT) engine=RocksDB;
+INSERT INTO t1 VALUES(1,1);
+INSERT INTO t2 VALUES(1,1,1);
+INSERT INTO t3 VALUES(1,1);
+INSERT INTO t4 VALUES(1);
+INSERT INTO t5 VALUES(1,1);
+INSERT INTO t6 VALUES(1);
+SELECT * FROM
+t1
+NATURAL JOIN
+(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)
+ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));
+id2 id1 id3 id5 id4 id3 id6 id5
+1 1 1 1 1 1 1 1
+SELECT * FROM
+t1
+NATURAL JOIN
+(((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6) on t3.id4 = t5.id5) JOIN t2
+ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));
+id2 id1 id4 id3 id6 id5 id3 id5
+1 1 1 1 1 1 1 1
+SELECT * FROM t1 NATURAL JOIN ((t3 join (t5 NATURAL JOIN t6)) JOIN t2);
+id2 id1 id3 id4 id6 id5 id3 id5
+1 1 1 1 1 1 1 1
+SELECT * FROM
+(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)
+ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5))
+NATURAL JOIN
+t1;
+id2 id3 id5 id4 id3 id6 id5 id1
+1 1 1 1 1 1 1 1
+SELECT * FROM
+(t2 JOIN ((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6)))
+NATURAL JOIN
+t1;
+id2 id3 id5 id4 id3 id6 id5 id1
+1 1 1 1 1 1 1 1
+DROP TABLE t1,t2,t3,t4,t5,t6;
+CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b), KEY b (b)) engine=RocksDB;
+INSERT INTO t1 VALUES (1,1),(1,2),(1,0),(1,3);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY,b PRIMARY 8 NULL 2 Using where; Using index for group-by
+SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a;
+MAX(b) a
+1 1
+SELECT MIN(b), a FROM t1 WHERE b > 1 AND a = 1 GROUP BY a;
+MIN(b) a
+2 1
+CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c)) engine=RocksDB;
+INSERT INTO t2 SELECT a,b,b FROM t1;
+ANALYZE TABLE t2;
+Table Op Msg_type Msg_text
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+explain SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range PRIMARY PRIMARY 12 NULL 2 Using where; Using index for group-by
+SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a;
+MIN(c)
+2
+DROP TABLE t1,t2;
+CREATE TABLE t1 (a INT, b INT, INDEX (a,b)) engine=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5),
+(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 5 NULL 6 Using index for group-by
+FLUSH STATUS;
+SELECT max(b), a FROM t1 GROUP BY a;
+max(b) a
+5 1
+3 2
+1 3
+6 4
+SHOW STATUS LIKE 'handler_read__e%';
+Variable_name Value
+Handler_read_key 8
+Handler_read_next 0
+Handler_read_retry 0
+EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 5 NULL 6 Using index for group-by
+FLUSH STATUS;
+CREATE TABLE t2 engine=RocksDB SELECT max(b), a FROM t1 GROUP BY a;
+SHOW STATUS LIKE 'handler_read__e%';
+Variable_name Value
+Handler_read_key 8
+Handler_read_next 0
+Handler_read_retry 0
+FLUSH STATUS;
+SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b;
+max(b) a
+5 1
+3 2
+1 3
+6 4
+SHOW STATUS LIKE 'handler_read__e%';
+Variable_name Value
+Handler_read_key 8
+Handler_read_next 0
+Handler_read_retry 0
+FLUSH STATUS;
+(SELECT max(b), a FROM t1 GROUP BY a) UNION
+(SELECT max(b), a FROM t1 GROUP BY a);
+max(b) a
+5 1
+3 2
+1 3
+6 4
+SHOW STATUS LIKE 'handler_read__e%';
+Variable_name Value
+Handler_read_key 16
+Handler_read_next 0
+Handler_read_retry 0
+EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION
+(SELECT max(b), a FROM t1 GROUP BY a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range NULL a 5 NULL 6 Using index for group-by
+2 UNION t1 range NULL a 5 NULL 6 Using index for group-by
+NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
+EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
+FROM t1 AS t1_outer;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
+2 SUBQUERY t1 range a a 5 NULL 6 Using where; Using index for group-by
+EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS
+(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
+2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
+EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
+(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY t1 range a a 5 NULL 6 Using where; Using index for group-by
+EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
+a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 6
+1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 3 Using index
+2 MATERIALIZED t1 range a a 5 NULL 6 Using where; Using index for group-by
+EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING
+a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_outer range NULL a 5 NULL 6 Using index for group-by
+2 SUBQUERY t1 range a a 5 NULL 6 Using where; Using index for group-by
+EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2
+ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2)
+AND t1_outer1.b = t1_outer2.b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index
+1 PRIMARY t1_outer1 ref a a 10 const,test.t1_outer2.b 1 Using where; Using index
+2 SUBQUERY t1 range a a 5 NULL 6 Using where; Using index for group-by
+EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
+FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using index
+2 SUBQUERY t1_outer index NULL a 10 NULL 15 Using index
+3 SUBQUERY t1 range a a 5 NULL 6 Using where; Using index for group-by
+CREATE TABLE t3 LIKE t1;
+FLUSH STATUS;
+INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a;
+SHOW STATUS LIKE 'handler_read__e%';
+Variable_name Value
+Handler_read_key 13
+Handler_read_next 0
+Handler_read_retry 0
+DELETE FROM t3;
+FLUSH STATUS;
+INSERT INTO t3 SELECT 1, (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2)
+FROM t1 LIMIT 1;
+SHOW STATUS LIKE 'handler_read__e%';
+Variable_name Value
+Handler_read_key 8
+Handler_read_next 0
+Handler_read_retry 0
+FLUSH STATUS;
+DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000;
+SHOW STATUS LIKE 'handler_read__e%';
+Variable_name Value
+Handler_read_key 8
+Handler_read_next 0
+Handler_read_retry 0
+FLUSH STATUS;
+DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x
+FROM t1) > 10000;
+ERROR 21000: Subquery returns more than 1 row
+SHOW STATUS LIKE 'handler_read__e%';
+Variable_name Value
+Handler_read_key 8
+Handler_read_next 1
+Handler_read_retry 0
+DROP TABLE t1,t2,t3;
+CREATE TABLE t1 (a int, INDEX idx(a)) engine=RocksDB;
+INSERT INTO t1 VALUES
+(4), (2), (1), (2), (4), (2), (1), (4),
+(4), (2), (1), (2), (2), (4), (1), (4);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+EXPLAIN SELECT DISTINCT(a) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx 5 NULL 4 Using index for group-by
+SELECT DISTINCT(a) FROM t1;
+a
+1
+2
+4
+EXPLAIN SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL idx 5 NULL 4 Using index for group-by
+SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;
+a
+1
+2
+4
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT) engine=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3);
+INSERT INTO t1 SELECT a + 1, b FROM t1;
+INSERT INTO t1 SELECT a + 2, b FROM t1;
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+EXPLAIN
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 12 Using temporary; Using filesort
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+a MIN(b) MAX(b)
+4 1 3
+3 1 3
+2 1 3
+1 1 3
+CREATE INDEX break_it ON t1 (a, b);
+EXPLAIN
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL break_it 10 NULL 4 Using index for group-by
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
+a MIN(b) MAX(b)
+1 1 3
+2 1 3
+3 1 3
+4 1 3
+EXPLAIN
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL break_it 10 NULL 4 Using index for group-by; Using temporary; Using filesort
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+a MIN(b) MAX(b)
+4 1 3
+3 1 3
+2 1 3
+1 1 3
+EXPLAIN
+SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL break_it 10 NULL 12 Using index
+SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
+a MIN(b) MAX(b) AVG(b)
+4 1 3 2.0000
+3 1 3 2.0000
+2 1 3 2.0000
+1 1 3 2.0000
+DROP TABLE t1;
+create table t1 (a int, b int, primary key (a,b), key `index` (a,b)) engine=MyISAM;
+insert into t1 (a,b) values
+(0,0),(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),
+(0,7),(0,8),(0,9),(0,10),(0,11),(0,12),(0,13),
+(1,0),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),
+(1,7),(1,8),(1,9),(1,10),(1,11),(1,12),(1,13),
+(2,0),(2,1),(2,2),(2,3),(2,4),(2,5),(2,6),
+(2,7),(2,8),(2,9),(2,10),(2,11),(2,12),(2,13),
+(3,0),(3,1),(3,2),(3,3),(3,4),(3,5),(3,6),
+(3,7),(3,8),(3,9),(3,10),(3,11),(3,12),(3,13);
+insert into t1 (a,b) select a, max(b)+1 from t1 where a = 0 group by a;
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+select * from t1;
+a b
+0 0
+0 1
+0 2
+0 3
+0 4
+0 5
+0 6
+0 7
+0 8
+0 9
+0 10
+0 11
+0 12
+0 13
+0 14
+1 0
+1 1
+1 2
+1 3
+1 4
+1 5
+1 6
+1 7
+1 8
+1 9
+1 10
+1 11
+1 12
+1 13
+2 0
+2 1
+2 2
+2 3
+2 4
+2 5
+2 6
+2 7
+2 8
+2 9
+2 10
+2 11
+2 12
+2 13
+3 0
+3 1
+3 2
+3 3
+3 4
+3 5
+3 6
+3 7
+3 8
+3 9
+3 10
+3 11
+3 12
+3 13
+explain extended select sql_buffer_result a, max(b)+1 from t1 where a = 0 group by a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ref PRIMARY,index PRIMARY 4 const 15 6.67 Using index; Using temporary
+Warnings:
+Note 1003 select sql_buffer_result `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) + 1 AS `max(b)+1` from `test`.`t1` where `test`.`t1`.`a` = 0 group by `test`.`t1`.`a`
+drop table t1;
+CREATE TABLE t1 (a int, b int, c int, d int,
+KEY foo (c,d,a,b), KEY bar (c,a,b,d)) engine=RocksDB;
+INSERT INTO t1 VALUES (1, 1, 1, 1), (1, 1, 1, 2), (1, 1, 1, 3), (1, 1, 1, 4);
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT a,b,c+1,d FROM t1;
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL foo 10 NULL 3 Using where; Using index for group-by
+SELECT DISTINCT c FROM t1 WHERE d=4;
+c
+1
+2
+DROP TABLE t1;
+#
+# Bug #45386: Wrong query result with MIN function in field list,
+# WHERE and GROUP BY clause
+#
+CREATE TABLE t (a INT, b INT, INDEX (a,b)) engine=RocksDB;
+INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);
+INSERT INTO t SELECT * FROM t;
+INSERT INTO t SELECT * FROM t;
+ANALYZE TABLE t;
+Table Op Msg_type Msg_text
+test.t analyze status Engine-independent statistics collected
+test.t analyze status OK
+# test MIN
+#should use range with index for group by
+EXPLAIN
+SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range NULL a 10 NULL 2 Using where; Using index for group-by
+#should return 1 row
+SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a;
+a MIN(b)
+2 1
+# test MAX
+#should use range with index for group by
+EXPLAIN
+SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range NULL a 10 NULL 2 Using where; Using index for group-by
+#should return 1 row
+SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a;
+a MAX(b)
+2 0
+# test 3 ranges and use the middle one
+INSERT INTO t SELECT a, 2 FROM t;
+#should use range with index for group by
+EXPLAIN
+SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range NULL a 10 NULL 2 Using where; Using index for group-by
+#should return 1 row
+SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a;
+a MAX(b)
+2 1
+DROP TABLE t;
+#
+# Bug #48472: Loose index scan inappropriately chosen for some WHERE
+# conditions
+#
+CREATE TABLE t (a INT, b INT, INDEX (a,b)) engine=RocksDB;
+INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);
+INSERT INTO t SELECT * FROM t;
+ANALYZE TABLE t;
+Table Op Msg_type Msg_text
+test.t analyze status Engine-independent statistics collected
+test.t analyze status OK
+SELECT a, MAX(b) FROM t WHERE 0=b+0 GROUP BY a;
+a MAX(b)
+2 0
+DROP TABLE t;
+End of 5.0 tests
+#
+# Bug #46607: Assertion failed: (cond_type == Item::FUNC_ITEM) results in
+# server crash
+#
+CREATE TABLE t (a INT, b INT, INDEX (a,b)) engine=RocksDB;
+INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);
+INSERT INTO t SELECT * FROM t;
+SELECT a, MAX(b) FROM t WHERE b GROUP BY a;
+a MAX(b)
+2 1
+DROP TABLE t;
+CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, KEY (b)) engine=RocksDB;
+INSERT INTO t1 VALUES(1,1),(2,1);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+SELECT 1 AS c, b FROM t1 WHERE b IN (1,2) GROUP BY c, b;
+c b
+1 1
+SELECT a FROM t1 WHERE b=1;
+a
+1
+2
+DROP TABLE t1;
+#
+# Bug#47762: Incorrect result from MIN() when WHERE tests NOT NULL column
+# for NULL
+#
+## Test for NULLs allowed
+CREATE TABLE t1 ( a INT, KEY (a) ) engine=RocksDB;
+INSERT INTO t1 VALUES (1), (2), (3);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a = NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a = NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a <> NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a <> NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a > NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a > NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a < NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a < NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a <=> NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x No matching min/max row
+SELECT MIN( a ) FROM t1 WHERE a <=> NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+x x x x x x x x x Using where; Using index
+SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a IS NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x No matching min/max row
+SELECT MIN( a ) FROM t1 WHERE a IS NULL;
+MIN( a )
+NULL
+INSERT INTO t1 VALUES (NULL), (NULL);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a = NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a = NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a <> NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a <> NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a > NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a > NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a < NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a < NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a <=> NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Select tables optimized away
+SELECT MIN( a ) FROM t1 WHERE a <=> NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+x x x x x x x x x Using where; Using index
+SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a IS NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Select tables optimized away
+SELECT MIN( a ) FROM t1 WHERE a IS NULL;
+MIN( a )
+NULL
+DROP TABLE t1;
+## Test for NOT NULLs
+CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY) engine=RocksDB;
+INSERT INTO t1 VALUES (1), (2), (3);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+#
+# NULL-safe operator test disabled for non-NULL indexed columns.
+#
+# See bugs
+#
+# - Bug#52173: Reading NULL value from non-NULL index gives
+# wrong result in embedded server
+#
+# - Bug#52174: Sometimes wrong plan when reading a MAX value from
+# non-NULL index
+#
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a = NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a = NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a <> NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a <> NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a > NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a > NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a < NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a < NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL;
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE noticed after reading const tables
+x x x x x x x x x Using where; Using index
+SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
+MIN( a )
+NULL
+EXPLAIN
+SELECT MIN( a ) FROM t1 WHERE a IS NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+x x x x x x x x x Impossible WHERE
+SELECT MIN( a ) FROM t1 WHERE a IS NULL;
+MIN( a )
+NULL
+DROP TABLE t1;
+#
+# Bug#53859: Valgrind: opt_sum_query(TABLE_LIST*, List<Item>&, Item*) at
+# opt_sum.cc:305
+#
+CREATE TABLE t1 ( a INT, KEY (a) ) engine=RocksDB;
+INSERT INTO t1 VALUES (1), (2), (3);
+SELECT MIN( a ) AS min_a
+FROM t1
+WHERE a > 1 AND a IS NULL
+ORDER BY min_a;
+min_a
+NULL
+DROP TABLE t1;
+End of 5.1 tests
+#
+# WL#3220 (Loose index scan for COUNT DISTINCT)
+#
+CREATE TABLE t1 (a INT, b INT, c INT, KEY (a,b)) engine=RocksDB;
+INSERT INTO t1 VALUES (1,1,1), (1,2,1), (1,3,1), (1,4,1);
+INSERT INTO t1 SELECT a, b + 4, 1 FROM t1;
+INSERT INTO t1 SELECT a + 1, b, 1 FROM t1;
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+CREATE TABLE t2 (a INT, b INT, c INT, d INT, e INT, f INT, KEY (a,b,c)) engine=RocksDB;
+INSERT INTO t2 VALUES (1,1,1,1,1,1), (1,2,1,1,1,1), (1,3,1,1,1,1),
+(1,4,1,1,1,1);
+INSERT INTO t2 SELECT a, b + 4, c,d,e,f FROM t2;
+INSERT INTO t2 SELECT a + 1, b, c,d,e,f FROM t2;
+ANALYZE TABLE t2;
+Table Op Msg_type Msg_text
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+EXPLAIN SELECT COUNT(DISTINCT a) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 5 NULL 3 Using index for group-by
+SELECT COUNT(DISTINCT a) FROM t1;
+COUNT(DISTINCT a)
+2
+EXPLAIN SELECT COUNT(DISTINCT a,b) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 10 NULL 17 Using index for group-by
+SELECT COUNT(DISTINCT a,b) FROM t1;
+COUNT(DISTINCT a,b)
+16
+EXPLAIN SELECT COUNT(DISTINCT b,a) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 10 NULL 17 Using index for group-by
+SELECT COUNT(DISTINCT b,a) FROM t1;
+COUNT(DISTINCT b,a)
+16
+EXPLAIN SELECT COUNT(DISTINCT b) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 10 NULL 16 Using index
+SELECT COUNT(DISTINCT b) FROM t1;
+COUNT(DISTINCT b)
+8
+EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 5 NULL 3 Using index for group-by
+SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a;
+COUNT(DISTINCT a)
+1
+1
+EXPLAIN SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 10 NULL 17 Using index for group-by
+SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
+COUNT(DISTINCT b)
+8
+8
+EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 10 NULL 16 Using index; Using filesort
+SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b;
+COUNT(DISTINCT a)
+2
+2
+2
+2
+2
+2
+2
+2
+EXPLAIN SELECT DISTINCT COUNT(DISTINCT a) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 10 NULL 16 Using index
+SELECT DISTINCT COUNT(DISTINCT a) FROM t1;
+COUNT(DISTINCT a)
+2
+EXPLAIN SELECT COUNT(DISTINCT a, b + 0) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 10 NULL 16 Using index
+SELECT COUNT(DISTINCT a, b + 0) FROM t1;
+COUNT(DISTINCT a, b + 0)
+16
+EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 10 NULL 16 Using index
+SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 10;
+COUNT(DISTINCT a)
+2
+EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 16
+SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10;
+COUNT(DISTINCT a)
+2
+EXPLAIN SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 5 NULL 3 Using index for group-by
+SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10;
+1
+1
+EXPLAIN SELECT 1 FROM t1 GROUP BY a HAVING COUNT(DISTINCT b) > 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 10 NULL 17 Using index for group-by
+SELECT 1 FROM t1 GROUP BY a HAVING COUNT(DISTINCT b) > 1;
+1
+1
+1
+EXPLAIN SELECT COUNT(DISTINCT t1_1.a) FROM t1 t1_1, t1 t1_2 GROUP BY t1_1.a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1_1 index NULL a 10 NULL 16 Using index; Using temporary; Using filesort
+1 SIMPLE t1_2 index NULL a 10 NULL 16 Using index; Using join buffer (flat, BNL join)
+SELECT COUNT(DISTINCT t1_1.a) FROM t1 t1_1, t1 t1_2 GROUP BY t1_1.a;
+COUNT(DISTINCT t1_1.a)
+1
+1
+EXPLAIN SELECT COUNT(DISTINCT a), 12 FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 5 NULL 3 Using index for group-by
+SELECT COUNT(DISTINCT a), 12 FROM t1;
+COUNT(DISTINCT a) 12
+2 12
+EXPLAIN SELECT COUNT(DISTINCT a, b, c) FROM t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL a 15 NULL 17 Using index for group-by
+SELECT COUNT(DISTINCT a, b, c) FROM t2;
+COUNT(DISTINCT a, b, c)
+16
+EXPLAIN SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT a) FROM t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL a 5 NULL 3 Using index for group-by
+SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT a) FROM t2;
+COUNT(DISTINCT a) SUM(DISTINCT a) AVG(DISTINCT a)
+2 3 1.5000
+EXPLAIN SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT f) FROM t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 16
+SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT f) FROM t2;
+COUNT(DISTINCT a) SUM(DISTINCT a) AVG(DISTINCT f)
+2 3 1.0000
+EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL a 10 NULL 17 Using index for group-by
+SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2;
+COUNT(DISTINCT a, b) COUNT(DISTINCT b, a)
+16 16
+EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, f) FROM t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 16
+SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, f) FROM t2;
+COUNT(DISTINCT a, b) COUNT(DISTINCT b, f)
+16 8
+EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, d) FROM t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 16
+SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, d) FROM t2;
+COUNT(DISTINCT a, b) COUNT(DISTINCT b, d)
+16 8
+EXPLAIN SELECT a, c, COUNT(DISTINCT c, a, b) FROM t2 GROUP BY a, b, c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL a 15 NULL 17 Using index for group-by
+SELECT a, c, COUNT(DISTINCT c, a, b) FROM t2 GROUP BY a, b, c;
+a c COUNT(DISTINCT c, a, b)
+1 1 1
+1 1 1
+1 1 1
+1 1 1
+1 1 1
+1 1 1
+1 1 1
+1 1 1
+2 1 1
+2 1 1
+2 1 1
+2 1 1
+2 1 1
+2 1 1
+2 1 1
+2 1 1
+EXPLAIN SELECT COUNT(DISTINCT c, a, b) FROM t2
+WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range a a 15 NULL 17 Using where; Using index for group-by
+SELECT COUNT(DISTINCT c, a, b) FROM t2
+WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c;
+COUNT(DISTINCT c, a, b)
+EXPLAIN SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 WHERE a = 5
+GROUP BY b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref a a 5 const 16 Using where; Using index
+SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 WHERE a = 5
+GROUP BY b;
+COUNT(DISTINCT b) SUM(DISTINCT b)
+EXPLAIN SELECT a, COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL a 10 NULL 17 Using index for group-by
+SELECT a, COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
+a COUNT(DISTINCT b) SUM(DISTINCT b)
+1 8 36
+2 8 36
+EXPLAIN SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL a 10 NULL 17 Using index for group-by
+SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
+COUNT(DISTINCT b) SUM(DISTINCT b)
+8 36
+8 36
+EXPLAIN SELECT COUNT(DISTINCT a, b) FROM t2 WHERE c = 13 AND d = 42;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 16 Using where
+SELECT COUNT(DISTINCT a, b) FROM t2 WHERE c = 13 AND d = 42;
+COUNT(DISTINCT a, b)
+0
+EXPLAIN SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2
+WHERE b = 13 AND c = 42 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL a 15 NULL 3 Using where; Using index for group-by
+SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2
+WHERE b = 13 AND c = 42 GROUP BY a;
+a COUNT(DISTINCT a) SUM(DISTINCT a)
+# This query could have been resolved using loose index scan since
+# the second part of count(..) is defined by a constant predicate
+EXPLAIN SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL a 15 NULL 16 Using where; Using index
+SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42;
+COUNT(DISTINCT a, b) SUM(DISTINCT a)
+0 NULL
+EXPLAIN SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL a 15 NULL 16 Using index
+SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a;
+SUM(DISTINCT a) MAX(b)
+1 8
+2 8
+EXPLAIN SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range NULL a 15 NULL 17 Using index for group-by
+SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c;
+42 * (a + c + COUNT(DISTINCT c, a, b))
+126
+126
+126
+126
+126
+126
+126
+126
+168
+168
+168
+168
+168
+168
+168
+168
+EXPLAIN SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL a 15 NULL 16 Using index
+SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a;
+(SUM(DISTINCT a) + MAX(b))
+9
+10
+DROP TABLE t1,t2;
+# end of WL#3220 tests
+#
+# Bug#50539: Wrong result when loose index scan is used for an aggregate
+# function with distinct
+#
+CREATE TABLE t1 (
+f1 int(11) NOT NULL DEFAULT '0',
+f2 char(1) NOT NULL DEFAULT '',
+PRIMARY KEY (f1,f2)
+) engine=RocksDB;
+insert into t1 values(1,'A'),(1 , 'B'), (1, 'C'), (2, 'A'),
+(3, 'A'), (3, 'B'), (3, 'C'), (3, 'D');
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1;
+f1 COUNT(DISTINCT f2)
+1 3
+2 1
+3 4
+explain SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 5 NULL 8 Using index
+drop table t1;
+# End of test#50539.
+#
+# Bug#17217128 - BAD INTERACTION BETWEEN MIN/MAX AND
+# "HAVING SUM(DISTINCT)": WRONG RESULTS.
+#
+CREATE TABLE t (a INT, b INT, KEY(a,b)) engine=RocksDB;
+INSERT INTO t VALUES (1,1), (2,2), (3,3), (4,4), (1,0), (3,2), (4,5);
+ANALYZE TABLE t;
+Table Op Msg_type Msg_text
+test.t analyze status Engine-independent statistics collected
+test.t analyze status OK
+ANALYZE TABLE t;
+Table Op Msg_type Msg_text
+test.t analyze status Engine-independent statistics collected
+test.t analyze status OK
+SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a;
+a SUM(DISTINCT a) MIN(b)
+1 1 0
+2 2 2
+3 3 2
+4 4 4
+EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL a 10 NULL 7 Using index
+SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a;
+a SUM(DISTINCT a) MAX(b)
+1 1 1
+2 2 2
+3 3 3
+4 4 5
+EXPLAIN SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL a 10 NULL 7 Using index
+SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a);
+a MAX(b)
+1 1
+2 2
+3 3
+4 5
+EXPLAIN SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL a 10 NULL 7 Using index
+SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t;
+SUM(DISTINCT a) MIN(b) MAX(b)
+10 0 5
+EXPLAIN SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL a 10 NULL 7 Using index
+SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a;
+a SUM(DISTINCT a) MIN(b) MAX(b)
+1 1 0 1
+2 2 2 2
+3 3 2 3
+4 4 4 5
+EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL a 10 NULL 7 Using index
+DROP TABLE t;
+#
+# Bug#18109609: LOOSE INDEX SCAN IS NOT USED WHEN IT SHOULD
+#
+CREATE TABLE t1 (
+id INT AUTO_INCREMENT PRIMARY KEY,
+c1 INT,
+c2 INT,
+KEY(c1,c2)) engine=RocksDB;
+INSERT INTO t1(c1,c2) VALUES
+(1, 1), (1,2), (2,1), (2,2), (3,1), (3,2), (3,3), (4,1), (4,2), (4,3),
+(4,4), (4,5), (4,6), (4,7), (4,8), (4,9), (4,10), (4,11), (4,12), (4,13),
+(4,14), (4,15), (4,16), (4,17), (4,18), (4,19), (4,20),(5,5);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+EXPLAIN SELECT MAX(c2), c1 FROM t1 WHERE c1 = 4 GROUP BY c1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref c1 c1 5 const 28 Using index
+FLUSH STATUS;
+SELECT MAX(c2), c1 FROM t1 WHERE c1 = 4 GROUP BY c1;
+MAX(c2) c1
+20 4
+SHOW SESSION STATUS LIKE 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 1
+Handler_read_last 0
+Handler_read_next 20
+Handler_read_prev 0
+Handler_read_retry 0
+Handler_read_rnd 0
+Handler_read_rnd_deleted 0
+Handler_read_rnd_next 0
+DROP TABLE t1;
+# End of test for Bug#18109609
+set global debug_dbug=@debug_tmp;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/ha_extra_keyread.result b/storage/rocksdb/mysql-test/rocksdb/r/ha_extra_keyread.result
new file mode 100644
index 00000000..93c8a464
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/ha_extra_keyread.result
@@ -0,0 +1,10 @@
+CREATE TABLE t1 (a INT, b CHAR(8), KEY ab(a, b)) ENGINE=rocksdb DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_bin;
+INSERT INTO t1 (a,b) VALUES (76,'bar');
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (77,'baz');
+SET debug_dbug="+d,dbug.rocksdb.HA_EXTRA_KEYREAD";
+SELECT b FROM t1 FORCE INDEX(ab) WHERE a=35;
+b
+foo
+SET debug_dbug="-d,dbug.rocksdb.HA_EXTRA_KEYREAD";
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/handler_basic.result b/storage/rocksdb/mysql-test/rocksdb/r/handler_basic.result
new file mode 100644
index 00000000..4f285134
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/handler_basic.result
@@ -0,0 +1,128 @@
+DROP TABLE IF EXISTS t1;
+FLUSH STATUS;
+CREATE TABLE t1 (id INT PRIMARY KEY, a VARCHAR(100), b INT,
+INDEX b(b)) ENGINE=rocksdb;
+INSERT INTO t1 (id,a,b) VALUES (1,'foobar',100),(2,'z',0),(3,'bar',50);
+SHOW SESSION STATUS LIKE 'Handler_write%';
+Variable_name Value
+Handler_write 3
+UPDATE t1 SET b=1000 WHERE id=1;
+SHOW SESSION STATUS LIKE 'Handler_update%';
+Variable_name Value
+Handler_update 1
+DELETE FROM t1 WHERE id=2;
+SHOW SESSION STATUS LIKE 'Handler_delete%';
+Variable_name Value
+Handler_delete 1
+INSERT INTO t1 (id,b) VALUES(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10);
+SHOW SESSION STATUS LIKE 'Handler_write%';
+Variable_name Value
+Handler_write 10
+FLUSH STATUS;
+SELECT * FROM t1 WHERE id=8;
+id a b
+8 NULL 8
+SHOW SESSION STATUS LIKE 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 1
+Handler_read_last 0
+Handler_read_next 0
+Handler_read_prev 0
+Handler_read_retry 0
+Handler_read_rnd 0
+Handler_read_rnd_deleted 0
+Handler_read_rnd_next 0
+FLUSH STATUS;
+SET GLOBAL rocksdb_force_flush_memtable_and_lzero_now=1;
+SELECT * FROM t1 WHERE b=6;
+id a b
+6 NULL 6
+SHOW SESSION STATUS LIKE 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 1
+Handler_read_last 0
+Handler_read_next 1
+Handler_read_prev 0
+Handler_read_retry 0
+Handler_read_rnd 0
+Handler_read_rnd_deleted 0
+Handler_read_rnd_next 0
+FLUSH STATUS;
+SELECT * FROM t1;
+id a b
+1 foobar 1000
+10 NULL 10
+3 bar 50
+4 NULL 4
+5 NULL 5
+6 NULL 6
+7 NULL 7
+8 NULL 8
+9 NULL 9
+SHOW SESSION STATUS LIKE 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 0
+Handler_read_last 0
+Handler_read_next 0
+Handler_read_prev 0
+Handler_read_retry 0
+Handler_read_rnd 0
+Handler_read_rnd_deleted 0
+Handler_read_rnd_next 10
+FLUSH STATUS;
+SELECT * FROM t1 FORCE INDEX(b) WHERE b <=5 ORDER BY b;
+id a b
+4 NULL 4
+5 NULL 5
+SHOW SESSION STATUS LIKE 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 1
+Handler_read_last 0
+Handler_read_next 2
+Handler_read_prev 0
+Handler_read_retry 0
+Handler_read_rnd 0
+Handler_read_rnd_deleted 0
+Handler_read_rnd_next 0
+FLUSH STATUS;
+SELECT * FROM t1 WHERE id >=8 ORDER BY id;
+id a b
+8 NULL 8
+9 NULL 9
+10 NULL 10
+SHOW SESSION STATUS LIKE 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 1
+Handler_read_last 0
+Handler_read_next 3
+Handler_read_prev 0
+Handler_read_retry 0
+Handler_read_rnd 0
+Handler_read_rnd_deleted 0
+Handler_read_rnd_next 0
+FLUSH STATUS;
+SELECT * FROM t1 WHERE id < 8 ORDER BY id;
+id a b
+1 foobar 1000
+3 bar 50
+4 NULL 4
+5 NULL 5
+6 NULL 6
+7 NULL 7
+SHOW SESSION STATUS LIKE 'Handler_read%';
+Variable_name Value
+Handler_read_first 1
+Handler_read_key 0
+Handler_read_last 0
+Handler_read_next 6
+Handler_read_prev 0
+Handler_read_retry 0
+Handler_read_rnd 0
+Handler_read_rnd_deleted 0
+Handler_read_rnd_next 0
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/hermitage.result b/storage/rocksdb/mysql-test/rocksdb/r/hermitage.result
new file mode 100644
index 00000000..8bf2416a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/hermitage.result
@@ -0,0 +1,648 @@
+DROP TABLE IF EXISTS test;
+connect con1,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+connect con2,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+connect con3,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+connection con1;
+create table test (id int primary key, value int) engine=rocksdb;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test;
+id value
+1 10
+2 20
+update test set value = 101 where id = 1;
+connection con2;
+select * from test;
+id value
+1 10
+2 20
+connection con1;
+rollback;
+connection con2;
+select * from test;
+id value
+1 10
+2 20
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+update test set value = 101 where id = 1;
+connection con2;
+select * from test;
+id value
+1 10
+2 20
+connection con1;
+update test set value = 11 where id = 1;
+commit;
+connection con2;
+select * from test;
+id value
+1 11
+2 20
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+update test set value = 11 where id = 1;
+connection con2;
+update test set value = 22 where id = 2;
+connection con1;
+select * from test where id = 2;
+id value
+2 20
+connection con2;
+select * from test where id = 1;
+id value
+1 10
+connection con1;
+commit;
+connection con2;
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+update test set value = 11 where id = 1;
+update test set value = 19 where id = 2;
+connection con2;
+update test set value = 12 where id = 1;
+connection con1;
+commit;
+connection con2;
+connection con3;
+select * from test;
+id value
+1 11
+2 19
+connection con2;
+update test set value = 18 where id = 2;
+connection con3;
+select * from test;
+id value
+1 11
+2 19
+connection con2;
+commit;
+connection con3;
+select * from test;
+id value
+1 12
+2 18
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test where value = 30;
+id value
+connection con2;
+insert into test (id, value) values(3, 30);
+commit;
+connection con1;
+select * from test where value % 3 = 0;
+id value
+3 30
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+update test set value = value + 10;
+connection con2;
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_snapshot_conflict_errors';
+select * from test;
+id value
+1 10
+2 20
+delete from test where value = 20;
+connection con1;
+commit;
+connection con2;
+select * from test;
+id value
+2 30
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test where id = 1;
+id value
+1 10
+connection con2;
+select * from test where id = 1;
+id value
+1 10
+connection con1;
+update test set value = 11 where id = 1;
+connection con2;
+update test set value = 12 where id = 1;
+connection con1;
+commit;
+connection con2;
+select * from test;
+id value
+1 12
+2 20
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test where id = 1;
+id value
+1 10
+connection con2;
+select * from test where id = 1;
+id value
+1 10
+select * from test where id = 2;
+id value
+2 20
+update test set value = 12 where id = 1;
+update test set value = 18 where id = 2;
+commit;
+connection con1;
+select * from test where id = 2;
+id value
+2 18
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test where value % 5 = 0;
+id value
+1 10
+2 20
+connection con2;
+update test set value = 12 where value = 10;
+commit;
+connection con1;
+select * from test where value % 3 = 0;
+id value
+1 12
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test where id = 1;
+id value
+1 10
+connection con2;
+select * from test;
+id value
+1 10
+2 20
+update test set value = 12 where id = 1;
+update test set value = 18 where id = 2;
+commit;
+connection con1;
+delete from test where value = 20;
+select * from test where id = 2;
+id value
+2 18
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test where id in (1,2);
+id value
+1 10
+2 20
+connection con2;
+select * from test where id in (1,2);
+id value
+1 10
+2 20
+connection con1;
+update test set value = 11 where id = 1;
+connection con2;
+update test set value = 21 where id = 2;
+connection con1;
+commit;
+connection con2;
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test where value % 3 = 0;
+id value
+connection con2;
+select * from test where value % 3 = 0;
+id value
+connection con1;
+insert into test (id, value) values(3, 30);
+connection con2;
+insert into test (id, value) values(4, 42);
+connection con1;
+commit;
+connection con2;
+commit;
+select * from test where value % 3 = 0;
+id value
+3 30
+4 42
+connection con1;
+select * from test where value % 3 = 0;
+id value
+3 30
+4 42
+connection default;
+drop table test;
+disconnect con1;
+disconnect con2;
+disconnect con3;
+DROP TABLE IF EXISTS test;
+connect con1,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+connect con2,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+connect con3,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+connection con1;
+create table test (id int primary key, value int) engine=rocksdb;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test;
+id value
+1 10
+2 20
+update test set value = 101 where id = 1;
+connection con2;
+select * from test;
+id value
+1 10
+2 20
+connection con1;
+rollback;
+connection con2;
+select * from test;
+id value
+1 10
+2 20
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+update test set value = 101 where id = 1;
+connection con2;
+select * from test;
+id value
+1 10
+2 20
+connection con1;
+update test set value = 11 where id = 1;
+commit;
+connection con2;
+select * from test;
+id value
+1 10
+2 20
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+update test set value = 11 where id = 1;
+connection con2;
+update test set value = 22 where id = 2;
+connection con1;
+select * from test where id = 2;
+id value
+2 20
+connection con2;
+select * from test where id = 1;
+id value
+1 10
+connection con1;
+commit;
+connection con2;
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+update test set value = 11 where id = 1;
+update test set value = 19 where id = 2;
+connection con2;
+update test set value = 12 where id = 1;
+connection con1;
+commit;
+connection con2;
+connection con3;
+select * from test;
+id value
+1 11
+2 19
+connection con2;
+update test set value = 18 where id = 2;
+connection con3;
+select * from test;
+id value
+1 11
+2 19
+connection con2;
+commit;
+connection con3;
+select * from test;
+id value
+1 11
+2 19
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test where value = 30;
+id value
+connection con2;
+insert into test (id, value) values(3, 30);
+commit;
+connection con1;
+select * from test where value % 3 = 0;
+id value
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+update test set value = value + 10;
+connection con2;
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_snapshot_conflict_errors';
+select * from test;
+id value
+1 10
+2 20
+delete from test where value = 20;
+connection con1;
+commit;
+connection con2;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_snapshot_conflict_errors';
+variable_value-@a
+1
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test where id = 1;
+id value
+1 10
+connection con2;
+select * from test where id = 1;
+id value
+1 10
+connection con1;
+update test set value = 11 where id = 1;
+connection con2;
+update test set value = 12 where id = 1;
+connection con1;
+commit;
+connection con2;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test where id = 1;
+id value
+1 10
+connection con2;
+select * from test where id = 1;
+id value
+1 10
+select * from test where id = 2;
+id value
+2 20
+update test set value = 12 where id = 1;
+update test set value = 18 where id = 2;
+commit;
+connection con1;
+select * from test where id = 2;
+id value
+2 20
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test where value % 5 = 0;
+id value
+1 10
+2 20
+connection con2;
+update test set value = 12 where value = 10;
+commit;
+connection con1;
+select * from test where value % 3 = 0;
+id value
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test where id = 1;
+id value
+1 10
+connection con2;
+select * from test;
+id value
+1 10
+2 20
+update test set value = 12 where id = 1;
+update test set value = 18 where id = 2;
+commit;
+connection con1;
+delete from test where value = 20;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test where id in (1,2);
+id value
+1 10
+2 20
+connection con2;
+select * from test where id in (1,2);
+id value
+1 10
+2 20
+connection con1;
+update test set value = 11 where id = 1;
+connection con2;
+update test set value = 21 where id = 2;
+connection con1;
+commit;
+connection con2;
+commit;
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
+connection con1;
+select * from test where value % 3 = 0;
+id value
+connection con2;
+select * from test where value % 3 = 0;
+id value
+connection con1;
+insert into test (id, value) values(3, 30);
+connection con2;
+insert into test (id, value) values(4, 42);
+connection con1;
+commit;
+connection con2;
+commit;
+select * from test where value % 3 = 0;
+id value
+3 30
+4 42
+connection con1;
+select * from test where value % 3 = 0;
+id value
+3 30
+4 42
+connection default;
+drop table test;
+disconnect con1;
+disconnect con2;
+disconnect con3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/i_s.result b/storage/rocksdb/mysql-test/rocksdb/r/i_s.result
new file mode 100644
index 00000000..84671b76
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/i_s.result
@@ -0,0 +1,159 @@
+SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA='INFORMATION_SCHEMA'
+ AND TABLE_NAME LIKE 'ROCKSDB%'
+ ORDER BY TABLE_NAME;
+TABLE_NAME
+ROCKSDB_CFSTATS
+ROCKSDB_CF_OPTIONS
+ROCKSDB_COMPACTION_STATS
+ROCKSDB_DBSTATS
+ROCKSDB_DDL
+ROCKSDB_DEADLOCK
+ROCKSDB_GLOBAL_INFO
+ROCKSDB_INDEX_FILE_MAP
+ROCKSDB_LOCKS
+ROCKSDB_PERF_CONTEXT
+ROCKSDB_PERF_CONTEXT_GLOBAL
+ROCKSDB_SST_PROPS
+ROCKSDB_TRX
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_CF_OPTIONS;
+Table Create Table
+ROCKSDB_CF_OPTIONS CREATE TEMPORARY TABLE `ROCKSDB_CF_OPTIONS` (
+ `CF_NAME` varchar(193) NOT NULL DEFAULT '',
+ `OPTION_TYPE` varchar(193) NOT NULL DEFAULT '',
+ `VALUE` varchar(193) NOT NULL DEFAULT ''
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_CFSTATS;
+Table Create Table
+ROCKSDB_CFSTATS CREATE TEMPORARY TABLE `ROCKSDB_CFSTATS` (
+ `CF_NAME` varchar(193) NOT NULL DEFAULT '',
+ `STAT_TYPE` varchar(193) NOT NULL DEFAULT '',
+ `VALUE` bigint(21) NOT NULL DEFAULT 0
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_COMPACTION_STATS;
+Table Create Table
+ROCKSDB_COMPACTION_STATS CREATE TEMPORARY TABLE `ROCKSDB_COMPACTION_STATS` (
+ `CF_NAME` varchar(193) NOT NULL DEFAULT '',
+ `LEVEL` varchar(513) NOT NULL DEFAULT '',
+ `TYPE` varchar(513) NOT NULL DEFAULT '',
+ `VALUE` double NOT NULL DEFAULT 0
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_DBSTATS;
+Table Create Table
+ROCKSDB_DBSTATS CREATE TEMPORARY TABLE `ROCKSDB_DBSTATS` (
+ `STAT_TYPE` varchar(193) NOT NULL DEFAULT '',
+ `VALUE` bigint(21) NOT NULL DEFAULT 0
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_DDL;
+Table Create Table
+ROCKSDB_DDL CREATE TEMPORARY TABLE `ROCKSDB_DDL` (
+ `TABLE_SCHEMA` varchar(193) NOT NULL DEFAULT '',
+ `TABLE_NAME` varchar(193) NOT NULL DEFAULT '',
+ `PARTITION_NAME` varchar(193) DEFAULT NULL,
+ `INDEX_NAME` varchar(193) NOT NULL DEFAULT '',
+ `COLUMN_FAMILY` int(11) NOT NULL DEFAULT 0,
+ `INDEX_NUMBER` int(11) NOT NULL DEFAULT 0,
+ `INDEX_TYPE` smallint(6) NOT NULL DEFAULT 0,
+ `KV_FORMAT_VERSION` smallint(6) NOT NULL DEFAULT 0,
+ `TTL_DURATION` bigint(21) NOT NULL DEFAULT 0,
+ `INDEX_FLAGS` bigint(21) NOT NULL DEFAULT 0,
+ `CF` varchar(193) NOT NULL DEFAULT '',
+ `AUTO_INCREMENT` bigint(21) unsigned DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_DEADLOCK;
+Table Create Table
+ROCKSDB_DEADLOCK CREATE TEMPORARY TABLE `ROCKSDB_DEADLOCK` (
+ `DEADLOCK_ID` bigint(21) NOT NULL DEFAULT 0,
+ `TIMESTAMP` bigint(21) NOT NULL DEFAULT 0,
+ `TRANSACTION_ID` bigint(21) NOT NULL DEFAULT 0,
+ `CF_NAME` varchar(193) NOT NULL DEFAULT '',
+ `WAITING_KEY` varchar(513) NOT NULL DEFAULT '',
+ `LOCK_TYPE` varchar(193) NOT NULL DEFAULT '',
+ `INDEX_NAME` varchar(193) NOT NULL DEFAULT '',
+ `TABLE_NAME` varchar(193) NOT NULL DEFAULT '',
+ `ROLLED_BACK` bigint(21) NOT NULL DEFAULT 0
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO;
+Table Create Table
+ROCKSDB_GLOBAL_INFO CREATE TEMPORARY TABLE `ROCKSDB_GLOBAL_INFO` (
+ `TYPE` varchar(513) NOT NULL DEFAULT '',
+ `NAME` varchar(513) NOT NULL DEFAULT '',
+ `VALUE` varchar(513) NOT NULL DEFAULT ''
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP;
+Table Create Table
+ROCKSDB_INDEX_FILE_MAP CREATE TEMPORARY TABLE `ROCKSDB_INDEX_FILE_MAP` (
+ `COLUMN_FAMILY` int(11) NOT NULL DEFAULT 0,
+ `INDEX_NUMBER` int(11) NOT NULL DEFAULT 0,
+ `SST_NAME` varchar(193) NOT NULL DEFAULT '',
+ `NUM_ROWS` bigint(21) NOT NULL DEFAULT 0,
+ `DATA_SIZE` bigint(21) NOT NULL DEFAULT 0,
+ `ENTRY_DELETES` bigint(21) NOT NULL DEFAULT 0,
+ `ENTRY_SINGLEDELETES` bigint(21) NOT NULL DEFAULT 0,
+ `ENTRY_MERGES` bigint(21) NOT NULL DEFAULT 0,
+ `ENTRY_OTHERS` bigint(21) NOT NULL DEFAULT 0,
+ `DISTINCT_KEYS_PREFIX` varchar(800) NOT NULL DEFAULT ''
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_LOCKS;
+Table Create Table
+ROCKSDB_LOCKS CREATE TEMPORARY TABLE `ROCKSDB_LOCKS` (
+ `COLUMN_FAMILY_ID` int(11) NOT NULL DEFAULT 0,
+ `TRANSACTION_ID` int(11) NOT NULL DEFAULT 0,
+ `KEY` varchar(513) NOT NULL DEFAULT '',
+ `MODE` varchar(32) NOT NULL DEFAULT ''
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT;
+Table Create Table
+ROCKSDB_PERF_CONTEXT CREATE TEMPORARY TABLE `ROCKSDB_PERF_CONTEXT` (
+ `TABLE_SCHEMA` varchar(193) NOT NULL DEFAULT '',
+ `TABLE_NAME` varchar(193) NOT NULL DEFAULT '',
+ `PARTITION_NAME` varchar(193) DEFAULT NULL,
+ `STAT_TYPE` varchar(193) NOT NULL DEFAULT '',
+ `VALUE` bigint(21) NOT NULL DEFAULT 0
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT_GLOBAL;
+Table Create Table
+ROCKSDB_PERF_CONTEXT_GLOBAL CREATE TEMPORARY TABLE `ROCKSDB_PERF_CONTEXT_GLOBAL` (
+ `STAT_TYPE` varchar(193) NOT NULL DEFAULT '',
+ `VALUE` bigint(21) NOT NULL DEFAULT 0
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_SST_PROPS;
+Table Create Table
+ROCKSDB_SST_PROPS CREATE TEMPORARY TABLE `ROCKSDB_SST_PROPS` (
+ `SST_NAME` varchar(193) NOT NULL DEFAULT '',
+ `COLUMN_FAMILY` int(11) NOT NULL DEFAULT 0,
+ `DATA_BLOCKS` bigint(21) NOT NULL DEFAULT 0,
+ `ENTRIES` bigint(21) NOT NULL DEFAULT 0,
+ `RAW_KEY_SIZE` bigint(21) NOT NULL DEFAULT 0,
+ `RAW_VALUE_SIZE` bigint(21) NOT NULL DEFAULT 0,
+ `DATA_BLOCK_SIZE` bigint(21) NOT NULL DEFAULT 0,
+ `INDEX_BLOCK_SIZE` bigint(21) NOT NULL DEFAULT 0,
+ `INDEX_PARTITIONS` int(11) NOT NULL DEFAULT 0,
+ `TOP_LEVEL_INDEX_SIZE` bigint(21) NOT NULL DEFAULT 0,
+ `FILTER_BLOCK_SIZE` bigint(21) NOT NULL DEFAULT 0,
+ `COMPRESSION_ALGO` varchar(193) NOT NULL DEFAULT '',
+ `CREATION_TIME` bigint(21) NOT NULL DEFAULT 0,
+ `FILE_CREATION_TIME` bigint(21) NOT NULL DEFAULT 0,
+ `OLDEST_KEY_TIME` bigint(21) NOT NULL DEFAULT 0,
+ `FILTER_POLICY` varchar(193) NOT NULL DEFAULT '',
+ `COMPRESSION_OPTIONS` varchar(193) NOT NULL DEFAULT ''
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_TRX;
+Table Create Table
+ROCKSDB_TRX CREATE TEMPORARY TABLE `ROCKSDB_TRX` (
+ `TRANSACTION_ID` bigint(21) NOT NULL DEFAULT 0,
+ `STATE` varchar(193) NOT NULL DEFAULT '',
+ `NAME` varchar(193) NOT NULL DEFAULT '',
+ `WRITE_COUNT` bigint(21) NOT NULL DEFAULT 0,
+ `LOCK_COUNT` bigint(21) NOT NULL DEFAULT 0,
+ `TIMEOUT_SEC` int(11) NOT NULL DEFAULT 0,
+ `WAITING_KEY` varchar(513) NOT NULL DEFAULT '',
+ `WAITING_COLUMN_FAMILY_ID` int(11) NOT NULL DEFAULT 0,
+ `IS_REPLICATION` int(11) NOT NULL DEFAULT 0,
+ `SKIP_TRX_API` int(11) NOT NULL DEFAULT 0,
+ `READ_ONLY` int(11) NOT NULL DEFAULT 0,
+ `HAS_DEADLOCK_DETECTION` int(11) NOT NULL DEFAULT 0,
+ `NUM_ONGOING_BULKLOAD` int(11) NOT NULL DEFAULT 0,
+ `THREAD_ID` int(11) NOT NULL DEFAULT 0,
+ `QUERY` varchar(193) NOT NULL DEFAULT ''
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/i_s_ddl.result b/storage/rocksdb/mysql-test/rocksdb/r/i_s_ddl.result
new file mode 100644
index 00000000..6bca2cba
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/i_s_ddl.result
@@ -0,0 +1,22 @@
+DROP TABLE IF EXISTS is_ddl_t1;
+DROP TABLE IF EXISTS is_ddl_t2;
+DROP TABLE IF EXISTS is_ddl_t3;
+CREATE TABLE is_ddl_t1 (i INT, j INT, k INT, l INT,
+PRIMARY KEY (i), KEY (j), KEY (k, l) COMMENT 'kl_cf')
+ENGINE = ROCKSDB;
+CREATE TABLE is_ddl_t2 (x INT, y INT, z INT,
+PRIMARY KEY (z, y) COMMENT 'zy_cf',
+KEY (x)) ENGINE = ROCKSDB;
+CREATE TABLE is_ddl_t3 (a INT, b INT, c INT, PRIMARY KEY (a)) ENGINE = ROCKSDB
+COMMENT "ttl_duration=3600;";
+SELECT TABLE_SCHEMA,TABLE_NAME,PARTITION_NAME,INDEX_NAME,INDEX_TYPE,KV_FORMAT_VERSION,CF,TTL_DURATION,INDEX_FLAGS FROM INFORMATION_SCHEMA.ROCKSDB_DDL WHERE TABLE_NAME like 'is_ddl_t%';
+TABLE_SCHEMA TABLE_NAME PARTITION_NAME INDEX_NAME INDEX_TYPE KV_FORMAT_VERSION CF TTL_DURATION INDEX_FLAGS
+test is_ddl_t1 NULL PRIMARY 1 13 default 0 0
+test is_ddl_t1 NULL j 2 13 default 0 0
+test is_ddl_t1 NULL k 2 13 kl_cf 0 0
+test is_ddl_t2 NULL PRIMARY 1 13 zy_cf 0 0
+test is_ddl_t2 NULL x 2 13 default 0 0
+test is_ddl_t3 NULL PRIMARY 1 13 default 3600 1
+DROP TABLE is_ddl_t1;
+DROP TABLE is_ddl_t2;
+DROP TABLE is_ddl_t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/i_s_deadlock.result b/storage/rocksdb/mysql-test/rocksdb/r/i_s_deadlock.result
new file mode 100644
index 00000000..0419c0f3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/i_s_deadlock.result
@@ -0,0 +1,216 @@
+set @prior_lock_wait_timeout = @@rocksdb_lock_wait_timeout;
+set @prior_deadlock_detect = @@rocksdb_deadlock_detect;
+set @prior_max_latest_deadlocks = @@rocksdb_max_latest_deadlocks;
+set global rocksdb_deadlock_detect = on;
+set global rocksdb_lock_wait_timeout = 10000;
+# Clears deadlock buffer of any prior deadlocks.
+set global rocksdb_max_latest_deadlocks = 0;
+set global rocksdb_max_latest_deadlocks = @prior_max_latest_deadlocks;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connect con3,localhost,root,,;
+connection default;
+show create table information_schema.rocksdb_deadlock;
+Table Create Table
+ROCKSDB_DEADLOCK CREATE TEMPORARY TABLE `ROCKSDB_DEADLOCK` (
+ `DEADLOCK_ID` bigint(21) NOT NULL DEFAULT 0,
+ `TIMESTAMP` bigint(21) NOT NULL DEFAULT 0,
+ `TRANSACTION_ID` bigint(21) NOT NULL DEFAULT 0,
+ `CF_NAME` varchar(193) NOT NULL DEFAULT '',
+ `WAITING_KEY` varchar(513) NOT NULL DEFAULT '',
+ `LOCK_TYPE` varchar(193) NOT NULL DEFAULT '',
+ `INDEX_NAME` varchar(193) NOT NULL DEFAULT '',
+ `TABLE_NAME` varchar(193) NOT NULL DEFAULT '',
+ `ROLLED_BACK` bigint(21) NOT NULL DEFAULT 0
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+create table t (i int primary key) engine=rocksdb;
+insert into t values (1), (2), (3);
+select * from information_schema.rocksdb_deadlock;
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID CF_NAME WAITING_KEY LOCK_TYPE INDEX_NAME TABLE_NAME ROLLED_BACK
+Deadlock #1
+connection con1;
+begin;
+select * from t where i=1 for update;
+i
+1
+connection con2;
+begin;
+select * from t where i=2 for update;
+i
+2
+connection con1;
+select * from t where i=2 for update;
+connection con2;
+select * from t where i=1 for update;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+rollback;
+connection con1;
+i
+2
+rollback;
+connection default;
+select * from information_schema.rocksdb_deadlock;
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID CF_NAME WAITING_KEY LOCK_TYPE INDEX_NAME TABLE_NAME ROLLED_BACK
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE PRIMARY test.t 0
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE PRIMARY test.t 1
+Deadlock #2
+connection con1;
+begin;
+select * from t where i=1 for update;
+i
+1
+connection con2;
+begin;
+select * from t where i=2 for update;
+i
+2
+connection con1;
+select * from t where i=2 for update;
+connection con2;
+select * from t where i=1 for update;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+rollback;
+connection con1;
+i
+2
+rollback;
+connection default;
+select * from information_schema.rocksdb_deadlock;
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID CF_NAME WAITING_KEY LOCK_TYPE INDEX_NAME TABLE_NAME ROLLED_BACK
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE PRIMARY test.t 0
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE PRIMARY test.t 1
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE PRIMARY test.t 0
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE PRIMARY test.t 1
+set global rocksdb_max_latest_deadlocks = 10;
+Deadlock #3
+connection con1;
+begin;
+select * from t where i=1 for update;
+i
+1
+connection con2;
+begin;
+select * from t where i=2 for update;
+i
+2
+connection con1;
+select * from t where i=2 for update;
+connection con2;
+select * from t where i=1 for update;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+rollback;
+connection con1;
+i
+2
+rollback;
+connection default;
+select * from information_schema.rocksdb_deadlock;
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID CF_NAME WAITING_KEY LOCK_TYPE INDEX_NAME TABLE_NAME ROLLED_BACK
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE PRIMARY test.t 0
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE PRIMARY test.t 1
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE PRIMARY test.t 0
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE PRIMARY test.t 1
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE PRIMARY test.t 0
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE PRIMARY test.t 1
+set global rocksdb_max_latest_deadlocks = 1;
+select * from information_schema.rocksdb_deadlock;
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID CF_NAME WAITING_KEY LOCK_TYPE INDEX_NAME TABLE_NAME ROLLED_BACK
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE PRIMARY test.t 0
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE PRIMARY test.t 1
+connection con3;
+set rocksdb_deadlock_detect_depth = 2;
+Deadlock #4
+connection con1;
+begin;
+select * from t where i=1 for update;
+i
+1
+connection con2;
+begin;
+select * from t where i=2 for update;
+i
+2
+connection con3;
+begin;
+select * from t where i=3 for update;
+i
+3
+connection con1;
+select * from t where i=2 for update;
+connection con2;
+select * from t where i=3 for update;
+connection con3;
+select * from t where i=1 for update;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+rollback;
+connection con2;
+i
+3
+rollback;
+connection con1;
+i
+2
+rollback;
+connection default;
+set global rocksdb_max_latest_deadlocks = 5;
+select * from information_schema.rocksdb_deadlock;
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID CF_NAME WAITING_KEY LOCK_TYPE INDEX_NAME TABLE_NAME ROLLED_BACK
+Deadlock #5
+connection con1;
+begin;
+select * from t where i=1 for update;
+i
+1
+connection con2;
+begin;
+select * from t where i=2 for update;
+i
+2
+connection con3;
+begin;
+select * from t where i=3 lock in share mode;
+i
+3
+connection con1;
+select * from t where i=100 for update;
+i
+select * from t where i=101 for update;
+i
+select * from t where i=2 for update;
+connection con2;
+select * from t where i=3 lock in share mode;
+i
+3
+select * from t where i=200 for update;
+i
+select * from t where i=201 for update;
+i
+select * from t where i=1 lock in share mode;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+rollback;
+connection con1;
+i
+2
+rollback;
+connection con3;
+rollback;
+connection default;
+select * from information_schema.rocksdb_deadlock;
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID CF_NAME WAITING_KEY LOCK_TYPE INDEX_NAME TABLE_NAME ROLLED_BACK
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE PRIMARY test.t 0
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY SHARED PRIMARY test.t 1
+disconnect con1;
+disconnect con2;
+disconnect con3;
+set global rocksdb_lock_wait_timeout = @prior_lock_wait_timeout;
+set global rocksdb_deadlock_detect = @prior_deadlock_detect;
+drop table t;
+select * from information_schema.rocksdb_deadlock;
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID CF_NAME WAITING_KEY LOCK_TYPE INDEX_NAME TABLE_NAME ROLLED_BACK
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY EXCLUSIVE INDEX_NAME TABLE_NAME 0
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID default WAITING_KEY SHARED INDEX_NAME TABLE_NAME 1
+set global rocksdb_max_latest_deadlocks = 0;
+# Clears deadlock buffer of any existent deadlocks.
+set global rocksdb_max_latest_deadlocks = @prior_max_latest_deadlocks;
+select * from information_schema.rocksdb_deadlock;
+DEADLOCK_ID TIMESTAMP TRANSACTION_ID CF_NAME WAITING_KEY LOCK_TYPE INDEX_NAME TABLE_NAME ROLLED_BACK
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/index.result b/storage/rocksdb/mysql-test/rocksdb/r/index.result
new file mode 100644
index 00000000..0920d0e0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/index.result
@@ -0,0 +1,89 @@
+CREATE TABLE t1 (a INT,
+b CHAR(8),
+pk INT PRIMARY KEY,
+KEY (a)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A # NULL NULL LSMTREE
+t1 1 a 1 a A # NULL NULL YES LSMTREE
+DROP TABLE t1;
+CREATE TABLE t1 (a INT,
+b CHAR(8),
+pk INT PRIMARY KEY,
+KEY a_b (a,b) COMMENT 'a_b index'
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A # NULL NULL LSMTREE
+t1 1 a_b 1 a A # NULL NULL YES LSMTREE a_b index
+t1 1 a_b 2 b A # NULL NULL YES LSMTREE a_b index
+DROP TABLE t1;
+CREATE TABLE t1 (a INT,
+b CHAR(8),
+pk INT PRIMARY KEY,
+KEY (a),
+KEY (b)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A # NULL NULL LSMTREE
+t1 1 a 1 a A # NULL NULL YES LSMTREE
+t1 1 b 1 b A # NULL NULL YES LSMTREE
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (100,'z');
+ALTER TABLE t1 ADD KEY (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 0 PRIMARY 1 pk A # NULL NULL LSMTREE
+t1 1 a 1 a A # NULL NULL YES LSMTREE simple index on a
+ALTER TABLE t1 DROP KEY a;
+DROP TABLE t1;
+set global rocksdb_large_prefix=0;
+CREATE TABLE t1 (
+a BLOB(1024),
+KEY (a(767))
+) ENGINE=rocksdb;
+DROP TABLE t1;
+CREATE TABLE t1 (
+a BLOB(1024),
+KEY (a(768))
+) ENGINE=rocksdb;
+Warnings:
+Note 1071 Specified key was too long; max key length is 767 bytes
+DROP TABLE t1;
+set global rocksdb_large_prefix=1;
+CREATE TABLE t1 (
+a BLOB(4096),
+KEY (a(3072))
+) ENGINE=rocksdb;
+DROP TABLE t1;
+CREATE TABLE t1 (
+a BLOB(4096),
+KEY (a(3073))
+) ENGINE=rocksdb;
+Warnings:
+Note 1071 Specified key was too long; max key length is 3072 bytes
+DROP TABLE t1;
+set global rocksdb_large_prefix=DEFAULT;
+#
+# Issue #376: MyRocks: ORDER BY optimizer is unable to use the index extension
+#
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1(a int);
+insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
+create table t2 (
+pk int not null,
+a int not null,
+b int not null,
+primary key(pk),
+key(a)
+) engine=rocksdb;
+insert into t2 select A.a, FLOOR(A.a/10), A.a from t1 A;
+# This must have type=range, index=a, and must not have 'Using filesort':
+explain select * from t2 force index (a) where a=0 and pk>=3 order by pk;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range a a 8 NULL # Using index condition
+drop table t0,t1,t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/index_file_map.result b/storage/rocksdb/mysql-test/rocksdb/r/index_file_map.result
new file mode 100644
index 00000000..ad007d71
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/index_file_map.result
@@ -0,0 +1,31 @@
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1 (i INT PRIMARY KEY, j INT, INDEX(j)) ENGINE = ROCKSDB;
+CREATE TABLE t2 (k INT PRIMARY KEY, l INT REFERENCES t1.i) ENGINE = ROCKSDB;
+INSERT INTO t1 VALUES (1,2), (2,4), (3,6), (4,8), (5,10);
+INSERT INTO t2 VALUES (100,1), (200,2), (300,3), (400,4);
+COMMIT;
+SET GLOBAL rocksdb_force_flush_memtable_now = 1;
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP
+WHERE INDEX_NUMBER =
+(SELECT INDEX_NUMBER FROM INFORMATION_SCHEMA.ROCKSDB_DDL
+WHERE TABLE_NAME = 't1' AND INDEX_NAME = "PRIMARY");
+COLUMN_FAMILY INDEX_NUMBER SST_NAME NUM_ROWS DATA_SIZE ENTRY_DELETES ENTRY_SINGLEDELETES ENTRY_MERGES ENTRY_OTHERS DISTINCT_KEYS_PREFIX
+# # SSTNAME 5 # # # # # 5
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP
+WHERE INDEX_NUMBER =
+(SELECT INDEX_NUMBER FROM INFORMATION_SCHEMA.ROCKSDB_DDL
+WHERE TABLE_NAME = 't1' AND INDEX_NAME = "j");
+COLUMN_FAMILY INDEX_NUMBER SST_NAME NUM_ROWS DATA_SIZE ENTRY_DELETES ENTRY_SINGLEDELETES ENTRY_MERGES ENTRY_OTHERS DISTINCT_KEYS_PREFIX
+# # SSTNAME 5 # # # # # 5,5
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP
+WHERE INDEX_NUMBER =
+(SELECT INDEX_NUMBER FROM INFORMATION_SCHEMA.ROCKSDB_DDL
+WHERE TABLE_NAME = 't2' AND INDEX_NAME = "PRIMARY");
+COLUMN_FAMILY INDEX_NUMBER SST_NAME NUM_ROWS DATA_SIZE ENTRY_DELETES ENTRY_SINGLEDELETES ENTRY_MERGES ENTRY_OTHERS DISTINCT_KEYS_PREFIX
+# # SSTNAME 4 # # # # # 4
+select count(*) > 0 from information_schema.rocksdb_sst_props;
+count(*) > 0
+1
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/index_key_block_size.result b/storage/rocksdb/mysql-test/rocksdb/r/index_key_block_size.result
new file mode 100644
index 00000000..5b804828
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/index_key_block_size.result
@@ -0,0 +1,53 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT,
+b CHAR(8),
+pk INT PRIMARY KEY,
+KEY (a) KEY_BLOCK_SIZE=8
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A # NULL NULL LSMTREE
+t1 1 a 1 a A # NULL NULL YES LSMTREE
+DROP TABLE t1;
+CREATE TABLE t1 (a INT,
+b CHAR(8),
+pk INT PRIMARY KEY,
+KEY ind1(b ASC) KEY_BLOCK_SIZE=0
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A # NULL NULL LSMTREE
+t1 1 ind1 1 b A # NULL NULL YES LSMTREE
+DROP TABLE t1;
+CREATE TABLE t1 (a INT,
+b CHAR(8),
+PRIMARY KEY ind2(b(1) DESC) KEY_BLOCK_SIZE=32768 COMMENT 'big key_block_size value'
+) ENGINE=rocksdb;
+Warnings:
+Warning 1280 Name 'ind2' ignored for PRIMARY key.
+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 PRIMARY 1 b A # 1 NULL LSMTREE big key_block_size value
+DROP TABLE t1;
+CREATE TABLE t1 (a INT,
+b CHAR(8),
+pk INT AUTO_INCREMENT PRIMARY KEY,
+KEY a_b(a,b) KEY_BLOCK_SIZE=8192
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A # NULL NULL LSMTREE
+t1 1 a_b 1 a A # NULL NULL YES LSMTREE
+t1 1 a_b 2 b A # NULL NULL YES LSMTREE
+DROP TABLE t1;
+CREATE TABLE t1 (a INT,
+b CHAR(8),
+PRIMARY KEY (b)
+) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (100,'z');
+ALTER TABLE t1 ADD KEY(a) KEY_BLOCK_SIZE 8192;
+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 0 PRIMARY 1 b A # NULL NULL LSMTREE
+t1 1 a 1 a A # NULL NULL YES LSMTREE
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb.result b/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb.result
new file mode 100644
index 00000000..7c4f57b6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb.result
@@ -0,0 +1,49 @@
+CREATE TABLE t1
+(
+/* fields/keys for row retrieval tests */
+key1 INT,
+key2 INT,
+key3 INT,
+key4 INT,
+/* make rows much bigger then keys */
+filler1 CHAR(200),
+KEY(key1),
+KEY(key2)
+) ENGINE=ROCKSDB;
+CREATE TABLE t0 AS SELECT * FROM t1;
+# Printing of many insert into t0 values (....) disabled.
+# Printing of many insert into t1 select .... from t0 disabled.
+# Printing of many insert into t1 (...) values (....) disabled.
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+7201
+SET GLOBAL rocksdb_force_flush_memtable_now = 1;
+EXPLAIN UPDATE t1 SET filler1='to be deleted' WHERE key1=100 AND key2=100;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL # Using intersect(key1,key2); Using where
+UPDATE t1 SET filler1='to be deleted' WHERE key1=100 and key2=100;
+DROP TABLE t0, t1;
+create table t1 (key1 int, key2 int, key3 int, key (key1), key (key2), key(key3)) engine=rocksdb;
+insert into t1 values (1, 100, 100), (1, 200, 200), (1, 300, 300);
+set global rocksdb_force_flush_memtable_now=1;
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select * from t1 where key1 = 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref key1 key1 5 const #
+explain select key1,key2 from t1 where key1 = 1 or key2 = 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL # Using union(key1,key2); Using where
+select * from t1 where key1 = 1;
+key1 key2 key3
+1 100 100
+1 200 200
+1 300 300
+select key1,key2 from t1 where key1 = 1 or key2 = 1;
+key1 key2
+1 100
+1 200
+1 300
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result b/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result
new file mode 100644
index 00000000..d96c4012
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result
@@ -0,0 +1,1418 @@
+set global rocksdb_force_flush_memtable_now=1;
+#---------------- Index merge test 1 -------------------------------------------
+SET SESSION DEFAULT_STORAGE_ENGINE = RocksDB;
+drop table if exists t0, t1, t2, t3, t4;
+create table t0
+(
+key1 int not null,
+key2 int not null,
+key3 int not null,
+key4 int not null,
+key5 int not null,
+key6 int not null,
+key7 int not null,
+key8 int not null,
+INDEX i1(key1),
+INDEX i2(key2),
+INDEX i3(key3),
+INDEX i4(key4),
+INDEX i5(key5),
+INDEX i6(key6),
+INDEX i7(key7),
+INDEX i8(key8)
+);
+analyze table t0;
+Table Op Msg_type Msg_text
+test.t0 analyze status Engine-independent statistics collected
+test.t0 analyze status OK
+explain select * from t0 where key1 < 3 or key1 > 1020;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 range i1 i1 4 NULL 4 Using index condition
+explain
+select * from t0 where key1 < 3 or key2 > 1020;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 4 Using sort_union(i1,i2); Using where
+select * from t0 where key1 < 3 or key2 > 1020;
+key1 key2 key3 key4 key5 key6 key7 key8
+1 1 1 1 1 1 1 1023
+2 2 2 2 2 2 2 1022
+1021 1021 1021 1021 1021 1021 1021 3
+1022 1022 1022 1022 1022 1022 1022 2
+1023 1023 1023 1023 1023 1023 1023 1
+1024 1024 1024 1024 1024 1024 1024 0
+explain select * from t0 where key1 < 2 or key2 <3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
+explain
+select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
+select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40);
+key1 key2 key3 key4 key5 key6 key7 key8
+31 31 31 31 31 31 31 993
+32 32 32 32 32 32 32 992
+33 33 33 33 33 33 33 991
+34 34 34 34 34 34 34 990
+35 35 35 35 35 35 35 989
+36 36 36 36 36 36 36 988
+37 37 37 37 37 37 37 987
+38 38 38 38 38 38 38 986
+39 39 39 39 39 39 39 985
+explain select * from t0 ignore index (i2) where key1 < 3 or key2 <4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 ALL i1 NULL NULL NULL # Using where
+explain select * from t0 where (key1 < 3 or key2 <4) and key3 = 50;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
+explain select * from t0 use index (i1,i2) where (key1 < 2 or key2 <3) and key3 = 50;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
+explain select * from t0 where (key1 > 1 or key2 > 2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
+explain select * from t0 force index (i1,i2) where (key1 > 1 or key2 > 2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
+explain
+select * from t0 where key1<2 or key2<3 or (key1>5 and key1<7) or
+(key1>10 and key1<12) or (key2>100 and key2<102);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
+explain select * from t0 where key2 = 45 or key1 <=> null;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 range i1,i2 i2 4 NULL # Using index condition
+explain select * from t0 where key2 = 45 or key1 is not null;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 ALL i1,i2 NULL NULL NULL # Using where
+explain select * from t0 where key2 = 45 or key1 is null;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 ref i2 i2 4 const #
+explain select * from t0 where key2=10 or key3=3 or key4 <=> null;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i2,i3,i4 i2,i3 4,4 NULL # Using union(i2,i3); Using where
+explain select * from t0 where key2=10 or key3=3 or key4 is null;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i2,i3 i2,i3 4,4 NULL # Using union(i2,i3); Using where
+explain select key1 from t0 where (key1 <=> null) or (key2 < 2) or
+(key3=10) or (key4 <=> null);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3,i4 i2,i3 4,4 NULL # Using sort_union(i2,i3); Using where
+explain select key1 from t0 where (key1 <=> null) or (key1 < 5) or
+(key3=10) or (key4 <=> null);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i3,i4 i1,i3 4,4 NULL # Using sort_union(i1,i3); Using where
+explain select * from t0 where
+(key1 < 2 or key2 < 2) and (key3 < 3 or key4 < 3) and (key5 < 5 or key6 < 5);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3,i4,i5,i6 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
+explain
+select * from t0 where (key1 < 2 or key2 < 4) and (key1 < 5 or key3 < 3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
+select * from t0 where (key1 < 2 or key2 < 4) and (key1 < 5 or key3 < 3);
+key1 key2 key3 key4 key5 key6 key7 key8
+1 1 1 1 1 1 1 1023
+2 2 2 2 2 2 2 1022
+3 3 3 3 3 3 3 1021
+explain select * from t0 where
+(key1 < 3 or key2 < 2) and (key3 < 3 or key4 < 3) and (key5 < 2 or key6 < 2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3,i4,i5,i6 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
+explain select * from t0 where
+(key1 < 3 or key2 < 3) and (key3 < 70);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
+explain select * from t0 where
+(key1 < 3 or key2 < 3) and (key3 < 1000);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
+explain select * from t0 where
+((key1 < 3 or key2 < 3) and (key2 <4 or key3 < 3))
+or
+key2 > 4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
+explain select * from t0 where
+((key1 < 4 or key2 < 4) and (key2 <4 or key3 < 3))
+or
+key1 < 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
+select * from t0 where
+((key1 < 4 or key2 < 4) and (key2 <4 or key3 < 3))
+or
+key1 < 5;
+key1 key2 key3 key4 key5 key6 key7 key8
+1 1 1 1 1 1 1 1023
+2 2 2 2 2 2 2 1022
+3 3 3 3 3 3 3 1021
+4 4 4 4 4 4 4 1020
+explain select * from t0 where
+((key1 < 2 or key2 < 2) and (key3 <4 or key5 < 3))
+or
+((key5 < 3 or key6 < 3) and (key7 <3 or key8 < 3));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7,i8 i1,i2,i5,i6 4,4,4,4 NULL # Using sort_union(i1,i2,i5,i6); Using where
+explain select * from t0 where
+((key3 <3 or key5 < 4) and (key1 < 3 or key2 < 3))
+or
+((key7 <5 or key8 < 3) and (key5 < 4 or key6 < 4));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7,i8 i3,i5,i7,i8 4,4,4,4 NULL # Using sort_union(i3,i5,i7,i8); Using where
+explain select * from t0 where
+((key3 <3 or key5 < 4) and (key1 < 3 or key2 < 4))
+or
+((key3 <4 or key5 < 2) and (key5 < 5 or key6 < 3));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3,i5,i6 i3,i5 4,4 NULL # Using sort_union(i3,i5); Using where
+explain select * from t0 where
+((key3 <4 or key5 < 3) and (key1 < 3 or key2 < 3))
+or
+(((key3 <5 and key7 < 5) or key5 < 2) and (key5 < 4 or key6 < 4));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7 i3,i5 4,4 NULL # Using sort_union(i3,i5); Using where
+explain select * from t0 where
+((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
+or
+((key3 >5 or key5 < 2) and (key5 < 5 or key6 < 6));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3,i5,i6 i3,i5 4,4 NULL # Using sort_union(i3,i5); Using where
+explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where
+((key3 <3 or key5 < 4) and (key1 < 3 or key2 < 3))
+or
+((key3 >4 or key5 < 2) and (key5 < 5 or key6 < 4));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3,i5,i6 i3,i5 4,4 NULL # Using sort_union(i3,i5); Using where
+explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where
+((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
+or
+((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2,i3,i5,i6 i3,i5 0,4 NULL # Using sort_union(i3,i5); Using where
+select * from t0 where key1 < 3 or key8 < 2 order by key1;
+key1 key2 key3 key4 key5 key6 key7 key8
+1 1 1 1 1 1 1 1023
+2 2 2 2 2 2 2 1022
+1023 1023 1023 1023 1023 1023 1023 1
+1024 1024 1024 1024 1024 1024 1024 0
+explain
+select * from t0 where key1 < 3 or key8 < 2 order by key1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i8 i1,i8 4,4 NULL # Using sort_union(i1,i8); Using where; Using filesort
+create table t2 like t0;
+insert into t2 select * from t0;
+alter table t2 add index i1_3(key1, key3);
+alter table t2 add index i2_3(key2, key3);
+alter table t2 drop index i1;
+alter table t2 drop index i2;
+alter table t2 add index i321(key3, key2, key1);
+explain select key3 from t2 where key1 = 100 or key2 = 100;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index_merge i1_3,i2_3 i1_3,i2_3 4,4 NULL # Using sort_union(i1_3,i2_3); Using where
+explain select key3 from t2 where key1 <100 or key2 < 100;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index_merge i1_3,i2_3 i1_3,i2_3 4,4 NULL # Using sort_union(i1_3,i2_3); Using where
+explain select key7 from t2 where key1 <100 or key2 < 100;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index_merge i1_3,i2_3 i1_3,i2_3 4,4 NULL # Using sort_union(i1_3,i2_3); Using where
+create table t4 (
+key1a int not null,
+key1b int not null,
+key2 int not null,
+key2_1 int not null,
+key2_2 int not null,
+key3 int not null,
+index i1a (key1a, key1b),
+index i1b (key1b, key1a),
+index i2_1(key2, key2_1),
+index i2_2(key2, key2_1)
+);
+Warnings:
+Note 1831 Duplicate index `i2_2`. This is deprecated and will be disallowed in a future release
+insert into t4 select key1,key1,key1 div 10, key1 % 10, key1 % 10, key1 from t0;
+select * from t4 where key1a = 3 or key1b = 4;
+key1a key1b key2 key2_1 key2_2 key3
+3 3 0 3 3 3
+4 4 0 4 4 4
+explain select * from t4 where key1a = 3 or key1b = 4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 index_merge i1a,i1b i1a,i1b 4,4 NULL 4 Using sort_union(i1a,i1b); Using where
+explain select * from t4 where key2 = 1 and (key2_1 = 1 or key3 = 5);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ref i2_1,i2_2 i2_1 4 const 2 Using where
+explain select * from t4 where key2 = 1 and (key2_1 = 1 or key2_2 = 5);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ref i2_1,i2_2 i2_1 4 const 2 Using where
+explain select * from t4 where key2_1 = 1 or key2_2 = 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ALL NULL NULL NULL NULL # Using where
+create table t1 like t0;
+insert into t1 select * from t0;
+explain select * from t0 left join t1 on (t0.key1=t1.key1)
+where t0.key1=3 or t0.key2=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL # Using union(i1,i2); Using where
+1 SIMPLE t1 ref i1 i1 4 test.t0.key1 #
+select * from t0 left join t1 on (t0.key1=t1.key1)
+where t0.key1=3 or t0.key2=4;
+key1 key2 key3 key4 key5 key6 key7 key8 key1 key2 key3 key4 key5 key6 key7 key8
+3 3 3 3 3 3 3 1021 3 3 3 3 3 3 3 1021
+4 4 4 4 4 4 4 1020 4 4 4 4 4 4 4 1020
+explain
+select * from t0,t1 where (t0.key1=t1.key1) and ( t0.key1=3 or t0.key2=4);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL # Using union(i1,i2); Using where
+1 SIMPLE t1 ref i1 i1 4 test.t0.key1 #
+explain
+select * from t0,t1 where (t0.key1=t1.key1) and
+(t0.key1=3 or t0.key2<4) and t1.key1=2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 ref i1,i2 i1 4 const 2 Using where
+1 SIMPLE t1 ref i1 i1 4 const 2
+explain select * from t0,t1 where t0.key1 = 5 and
+(t1.key1 = t0.key1 or t1.key8 = t0.key1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 ref i1 i1 4 const 2
+1 SIMPLE t1 index_merge i1,i8 i1,i8 4,4 NULL 4 Using union(i1,i8); Using where; Using join buffer (flat, BNL join)
+explain select * from t0,t1 where t0.key1 < 3 and
+(t1.key1 = t0.key1 or t1.key8 = t0.key1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 range i1 i1 4 NULL # Using index condition
+1 SIMPLE t1 ALL i1,i8 NULL NULL NULL # Range checked for each record (index map: 0x81)
+explain select * from t1 where key1=3 or key2=4
+union select * from t1 where key1<4 or key3=5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index_merge i1,i2 i1,i2 4,4 NULL 4 Using union(i1,i2); Using where
+2 UNION t1 index_merge i1,i3 i1,i3 4,4 NULL 4 Using sort_union(i1,i3); Using where
+NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
+explain select * from (select * from t1 where key1 = 3 or key2 =3) as Z where key8 >5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge i1,i2,i8 i1,i2 4,4 NULL 4 Using union(i1,i2); Using where
+create table t3 like t0;
+insert into t3 select * from t0;
+alter table t3 add key9 int not null, add index i9(key9);
+alter table t3 add keyA int not null, add index iA(keyA);
+alter table t3 add keyB int not null, add index iB(keyB);
+alter table t3 add keyC int not null, add index iC(keyC);
+update t3 set key9=key1,keyA=key1,keyB=key1,keyC=key1;
+explain select * from t3 where
+key1=1 or key2=2 or key3=3 or key4=4 or
+key5=5 or key6=6 or key7=7 or key8=8 or
+key9=9 or keyA=10 or keyB=11 or keyC=12;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 index_merge i1,i2,i3,i4,i5,i6,i7,i8,i9,iA,iB,iC i1,i2,i3,i4,i5,i6,i7,i8,i9,iA,iB,iC 4,4,4,4,4,4,4,4,4,4,4,4 NULL 24 Using union(i1,i2,i3,i4,i5,i6,i7,i8,i9,iA,iB,iC); Using where
+select * from t3 where
+key1=1 or key2=2 or key3=3 or key4=4 or
+key5=5 or key6=6 or key7=7 or key8=8 or
+key9=9 or keyA=10 or keyB=11 or keyC=12;
+key1 key2 key3 key4 key5 key6 key7 key8 key9 keyA keyB keyC
+1 1 1 1 1 1 1 1023 1 1 1 1
+2 2 2 2 2 2 2 1022 2 2 2 2
+3 3 3 3 3 3 3 1021 3 3 3 3
+4 4 4 4 4 4 4 1020 4 4 4 4
+5 5 5 5 5 5 5 1019 5 5 5 5
+6 6 6 6 6 6 6 1018 6 6 6 6
+7 7 7 7 7 7 7 1017 7 7 7 7
+9 9 9 9 9 9 9 1015 9 9 9 9
+10 10 10 10 10 10 10 1014 10 10 10 10
+11 11 11 11 11 11 11 1013 11 11 11 11
+12 12 12 12 12 12 12 1012 12 12 12 12
+1016 1016 1016 1016 1016 1016 1016 8 1016 1016 1016 1016
+explain select * from t0 where key1 < 3 or key2 < 4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 4 Using sort_union(i1,i2); Using where
+select * from t0 where key1 < 3 or key2 < 4;
+key1 key2 key3 key4 key5 key6 key7 key8
+1 1 1 1 1 1 1 1023
+2 2 2 2 2 2 2 1022
+3 3 3 3 3 3 3 1021
+update t0 set key8=123 where key1 < 3 or key2 < 4;
+select * from t0 where key1 < 3 or key2 < 4;
+key1 key2 key3 key4 key5 key6 key7 key8
+1 1 1 1 1 1 1 123
+2 2 2 2 2 2 2 123
+3 3 3 3 3 3 3 123
+delete from t0 where key1 < 3 or key2 < 4;
+select * from t0 where key1 < 3 or key2 < 4;
+key1 key2 key3 key4 key5 key6 key7 key8
+select count(*) from t0;
+count(*)
+1021
+drop table t4;
+create table t4 (a int);
+insert into t4 values (1),(4),(3);
+set @save_join_buffer_size=@@join_buffer_size;
+set join_buffer_size= 4096;
+explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
+from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
+where (A.key1 < 500000 or A.key2 < 3)
+and (B.key1 < 500000 or B.key2 < 3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE A index_merge i1,i2 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
+1 SIMPLE B index_merge i1,i2 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where; Using join buffer (flat, BNL join)
+select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
+from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
+where (A.key1 < 500000 or A.key2 < 3)
+and (B.key1 < 500000 or B.key2 < 3);
+max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
+10240
+update t0 set key1=1;
+explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
+from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
+where (A.key1 = 1 or A.key2 = 1)
+and (B.key1 = 1 or B.key2 = 1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE A index_merge i1,i2 i1,i2 4,4 NULL # Using union(i1,i2); Using where
+1 SIMPLE B index_merge i1,i2 i1,i2 4,4 NULL # Using union(i1,i2); Using where; Using join buffer (flat, BNL join)
+select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
+from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
+where (A.key1 = 1 or A.key2 = 1)
+and (B.key1 = 1 or B.key2 = 1);
+max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
+8194
+alter table t0 add filler1 char(200), add filler2 char(200), add filler3 char(200);
+update t0 set key2=1, key3=1, key4=1, key5=1,key6=1,key7=1 where key7 < 500;
+select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
+from t0 as A, t0 as B
+where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)
+and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7 = 1 or B.key8=1);
+max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
+8186
+set join_buffer_size= @save_join_buffer_size;
+drop table t0, t1, t2, t3, t4;
+CREATE TABLE t1 (
+cola char(3) not null, colb char(3) not null, filler char(200),
+key(cola), key(colb)
+);
+INSERT INTO t1 VALUES ('foo','bar', 'ZZ'),('fuz','baz', 'ZZ');
+OPTIMIZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+select count(*) from t1;
+count(*)
+8704
+explain select * from t1 WHERE cola = 'foo' AND colb = 'bar';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref cola,colb cola 3 const # Using index condition; Using where
+explain select * from t1 force index(cola,colb) WHERE cola = 'foo' AND colb = 'bar';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref cola,colb cola 3 const # Using index condition; Using where
+drop table t1;
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES(1);
+CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b));
+INSERT INTO t2(a,b) VALUES
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(1,2);
+LOCK TABLES t1 WRITE, t2 WRITE;
+INSERT INTO t2(a,b) VALUES(1,2);
+SELECT t2.a FROM t1,t2 WHERE t2.b=2 AND t2.a=1;
+a
+1
+1
+UNLOCK TABLES;
+DROP TABLE t1, t2;
+CREATE TABLE `t1` (
+`a` int(11) DEFAULT NULL,
+`filler` char(200) DEFAULT NULL,
+`b` int(11) DEFAULT NULL,
+KEY `a` (`a`),
+KEY `b` (`b`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1;
+insert into t1 values
+(0, 'filler', 0), (1, 'filler', 1), (2, 'filler', 2), (3, 'filler', 3),
+(4, 'filler', 4), (5, 'filler', 5), (6, 'filler', 6), (7, 'filler', 7),
+(8, 'filler', 8), (9, 'filler', 9), (0, 'filler', 0), (1, 'filler', 1),
+(2, 'filler', 2), (3, 'filler', 3), (4, 'filler', 4), (5, 'filler', 5),
+(6, 'filler', 6), (7, 'filler', 7), (8, 'filler', 8), (9, 'filler', 9),
+(10, 'filler', 10), (11, 'filler', 11), (12, 'filler', 12), (13, 'filler', 13),
+(14, 'filler', 14), (15, 'filler', 15), (16, 'filler', 16), (17, 'filler', 17),
+(18, 'filler', 18), (19, 'filler', 19), (4, '5 ', 0), (5, '4 ', 0),
+(4, '4 ', 0), (4, 'qq ', 5), (5, 'qq ', 4), (4, 'zz ', 4);
+create table t2(
+`a` int(11) DEFAULT NULL,
+`filler` char(200) DEFAULT NULL,
+`b` int(11) DEFAULT NULL,
+KEY USING BTREE (`a`),
+KEY USING BTREE (`b`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1;
+insert into t2 select * from t1;
+must use sort-union rather than union:
+explain select * from t1 where a=4 or b=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b a,b 5,5 NULL # Using sort_union(a,b); Using where
+select * from t1 where a=4 or b=4;
+a filler b
+4 4 0
+4 5 0
+4 filler 4
+4 filler 4
+4 qq 5
+4 zz 4
+5 qq 4
+select * from t1 ignore index(a,b) where a=4 or b=4;
+a filler b
+4 4 0
+4 5 0
+4 filler 4
+4 filler 4
+4 qq 5
+4 zz 4
+5 qq 4
+must use union, not sort-union:
+explain select * from t2 where a=4 or b=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index_merge a,b a,b 5,5 NULL # Using union(a,b); Using where
+select * from t2 where a=4 or b=4;
+a filler b
+4 4 0
+4 5 0
+4 filler 4
+4 filler 4
+4 qq 5
+4 zz 4
+5 qq 4
+drop table t1, t2;
+CREATE TABLE t1 (a varchar(8), b set('a','b','c','d','e','f','g','h'),
+KEY b(b), KEY a(a));
+INSERT INTO t1 VALUES ('y',''), ('z','');
+SELECT b,a from t1 WHERE (b!='c' AND b!='f' && b!='h') OR
+(a='pure-S') OR (a='DE80337a') OR (a='DE80799');
+b a
+ y
+ z
+DROP TABLE t1;
+#
+# BUG#40974: Incorrect query results when using clause evaluated using range check
+#
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (a int);
+insert into t1 values (1),(2);
+create table t2(a int, b int);
+insert into t2 values (1,1), (2, 1000);
+create table t3 (a int, b int, filler char(100), key(a), key(b));
+insert into t3 select 1000, 1000,'filler' from t0 A, t0 B, t0 C;
+insert into t3 values (1,1,'data');
+insert into t3 values (1,1,'data');
+The plan should be ALL/ALL/ALL(Range checked for each record (index map: 0x3)
+explain select * from t1
+where exists (select 1 from t2, t3
+where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL #
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func #
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL #
+2 MATERIALIZED t3 ALL a,b NULL NULL NULL # Range checked for each record (index map: 0x3)
+select * from t1
+where exists (select 1 from t2, t3
+where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1));
+a
+1
+2
+drop table t0, t1, t2, t3;
+#
+# BUG#44810: index merge and order by with low sort_buffer_size
+# crashes server!
+#
+CREATE TABLE t1(a VARCHAR(128),b VARCHAR(128),KEY(A),KEY(B));
+INSERT INTO t1 VALUES (REPEAT('a',128),REPEAT('b',128));
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+EXPLAIN
+SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%'
+ORDER BY a,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b a,b 131,131 NULL # Using sort_union(a,b); Using where; Using filesort
+SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%'
+ORDER BY a,b;
+SET SESSION sort_buffer_size=DEFAULT;
+DROP TABLE t1;
+End of 5.0 tests
+set global rocksdb_force_flush_memtable_now=1;
+#---------------- ROR-index_merge tests -----------------------
+SET SESSION DEFAULT_STORAGE_ENGINE = RocksDB;
+drop table if exists t0,t1,t2;
+create table t1
+(
+/* Field names reflect value(rowid) distribution, st=STairs, swt= SaWTooth */
+st_a int not null default 0,
+swt1a int not null default 0,
+swt2a int not null default 0,
+st_b int not null default 0,
+swt1b int not null default 0,
+swt2b int not null default 0,
+/* fields/keys for row retrieval tests */
+key1 int,
+key2 int,
+key3 int,
+key4 int,
+/* make rows much bigger then keys */
+filler1 char (200),
+filler2 char (200),
+filler3 char (200),
+filler4 char (200),
+filler5 char (200),
+filler6 char (200),
+/* order of keys is important */
+key sta_swt12a(st_a,swt1a,swt2a),
+key sta_swt1a(st_a,swt1a),
+key sta_swt2a(st_a,swt2a),
+key sta_swt21a(st_a,swt2a,swt1a),
+key st_a(st_a),
+key stb_swt1a_2b(st_b,swt1b,swt2a),
+key stb_swt1b(st_b,swt1b),
+key st_b(st_b),
+key(key1),
+key(key2),
+key(key3),
+key(key4)
+) ;
+create table t0 as select * from t1;
+# Printing of many insert into t0 values (....) disabled.
+alter table t1 disable keys;
+Warnings:
+Note 1031 Storage engine ROCKSDB of the table `test`.`t1` doesn't have this option
+# Printing of many insert into t1 select .... from t0 disabled.
+# Printing of many insert into t1 (...) values (....) disabled.
+alter table t1 enable keys;
+Warnings:
+Note 1031 Storage engine ROCKSDB of the table `test`.`t1` doesn't have this option
+select count(*) from t1;
+count(*)
+64801
+explain select key1,key2 from t1 where key1=100 and key2=100;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL # Using intersect(key1,key2); Using where; Using index
+select key1,key2 from t1 where key1=100 and key2=100;
+key1 key2
+100 100
+select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+key1 key2 key3 key4 filler1
+100 100 100 100 key1-key2-key3-key4
+insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, -1, -1, 'key1-key2');
+insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 100, 100, 'key4-key3');
+select key1,key2,filler1 from t1 where key1=100 and key2=100;
+key1 key2 filler1
+100 100 key1-key2-key3-key4
+100 100 key1-key2
+select key1,key2 from t1 where key1=100 and key2=100;
+key1 key2
+100 100
+100 100
+select key1,key2,key3,key4 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+key1 key2 key3 key4
+100 100 100 100
+100 100 -1 -1
+-1 -1 100 100
+select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+key1 key2 key3 key4 filler1
+100 100 100 100 key1-key2-key3-key4
+100 100 -1 -1 key1-key2
+-1 -1 100 100 key4-key3
+select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100;
+key1 key2 key3
+100 100 100
+insert into t1 (key1,key2,key3,key4,filler1) values (101,101,101,101, 'key1234-101');
+select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=101;
+key1 key2 key3 key4 filler1
+100 100 100 100 key1-key2-key3-key4
+100 100 -1 -1 key1-key2
+101 101 101 101 key1234-101
+select key1,key2, filler1 from t1 where key1=100 and key2=100;
+key1 key2 filler1
+100 100 key1-key2-key3-key4
+100 100 key1-key2
+update t1 set filler1='to be deleted' where key1=100 and key2=100;
+update t1 set key1=200,key2=200 where key1=100 and key2=100;
+delete from t1 where key1=200 and key2=200;
+select key1,key2,filler1 from t1 where key2=100 and key2=200;
+key1 key2 filler1
+select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+key1 key2 key3 key4 filler1
+-1 -1 100 100 key4-key3
+delete from t1 where key3=100 and key4=100;
+select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
+key1 key2 key3 key4 filler1
+select key1,key2 from t1 where key1=100 and key2=100;
+key1 key2
+insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-1');
+insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-2');
+insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-3');
+select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
+key1 key2 key3 key4 filler1
+100 100 200 200 key1-key2-key3-key4-1
+100 100 200 200 key1-key2-key3-key4-2
+100 100 200 200 key1-key2-key3-key4-3
+insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, -1, 200,'key4');
+select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
+key1 key2 key3 key4 filler1
+100 100 200 200 key1-key2-key3-key4-1
+100 100 200 200 key1-key2-key3-key4-2
+100 100 200 200 key1-key2-key3-key4-3
+-1 -1 -1 200 key4
+insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 200, -1,'key3');
+select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
+key1 key2 key3 key4 filler1
+100 100 200 200 key1-key2-key3-key4-1
+100 100 200 200 key1-key2-key3-key4-2
+100 100 200 200 key1-key2-key3-key4-3
+-1 -1 -1 200 key4
+-1 -1 200 -1 key3
+drop table t0,t1;
+create table t2 (
+a char(10),
+b char(10),
+filler1 char(255),
+filler2 char(255),
+key(a(5)),
+key(b(5))
+);
+select count(a) from t2 where a='BBBBBBBB';
+count(a)
+4
+select count(a) from t2 where b='BBBBBBBB';
+count(a)
+4
+expla_or_bin select count(a_or_b) from t2 where a_or_b='AAAAAAAA' a_or_bnd a_or_b='AAAAAAAA';
+id select_type ta_or_ba_or_ble type possia_or_ble_keys key key_len ref rows Extra_or_b
+1 SIMPLE t2 ref a_or_b,a_or_b a_or_b 6 const 2 Using where
+select count(a) from t2 where a='AAAAAAAA' and b='AAAAAAAA';
+count(a)
+4
+select count(a) from t2 ignore index(a,b) where a='AAAAAAAA' and b='AAAAAAAA';
+count(a)
+4
+insert into t2 values ('ab', 'ab', 'uh', 'oh');
+explain select a from t2 where a='ab';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref a a 6 const 2 Using where
+drop table t2;
+CREATE TABLE t1(c1 INT, c2 INT DEFAULT 0, c3 CHAR(255) DEFAULT '',
+KEY(c1), KEY(c2), KEY(c3));
+INSERT INTO t1(c1) VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),
+(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0);
+INSERT INTO t1 VALUES(0,0,0);
+CREATE TABLE t2(c1 int);
+INSERT INTO t2 VALUES(1);
+DELETE t1 FROM t1,t2 WHERE t1.c1=0 AND t1.c2=0;
+SELECT * FROM t1;
+c1 c2 c3
+DROP TABLE t1,t2;
+set global rocksdb_force_flush_memtable_now=1;
+#---------------- Index merge test 2 -------------------------------------------
+SET SESSION DEFAULT_STORAGE_ENGINE = RocksDB;
+drop table if exists t1,t2;
+create table t1
+(
+key1 int not null,
+key2 int not null,
+INDEX i1(key1),
+INDEX i2(key2)
+);
+explain select * from t1 where key1 < 5 or key2 > 197;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 4 Using sort_union(i1,i2); Using where
+select * from t1 where key1 < 5 or key2 > 197;
+key1 key2
+0 200
+1 199
+2 198
+3 197
+4 196
+explain select * from t1 where key1 < 3 or key2 > 195;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 4 Using sort_union(i1,i2); Using where
+select * from t1 where key1 < 3 or key2 > 195;
+key1 key2
+0 200
+1 199
+2 198
+3 197
+4 196
+alter table t1 add str1 char (255) not null,
+add zeroval int not null default 0,
+add str2 char (255) not null,
+add str3 char (255) not null;
+update t1 set str1='aaa', str2='bbb', str3=concat(key2, '-', key1 div 2, '_' ,if(key1 mod 2 = 0, 'a', 'A'));
+alter table t1 add primary key (str1, zeroval, str2, str3);
+explain select * from t1 where key1 < 5 or key2 > 197;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 4 Using sort_union(i1,i2); Using where
+select * from t1 where key1 < 5 or key2 > 197;
+key1 key2 str1 zeroval str2 str3
+4 196 aaa 0 bbb 196-2_a
+3 197 aaa 0 bbb 197-1_A
+2 198 aaa 0 bbb 198-1_a
+1 199 aaa 0 bbb 199-0_A
+0 200 aaa 0 bbb 200-0_a
+explain select * from t1 where key1 < 3 or key2 > 195;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 4 Using sort_union(i1,i2); Using where
+select * from t1 where key1 < 3 or key2 > 195;
+key1 key2 str1 zeroval str2 str3
+4 196 aaa 0 bbb 196-2_a
+3 197 aaa 0 bbb 197-1_A
+2 198 aaa 0 bbb 198-1_a
+1 199 aaa 0 bbb 199-0_A
+0 200 aaa 0 bbb 200-0_a
+drop table t1;
+create table t1 (
+pk integer not null auto_increment primary key,
+key1 integer,
+key2 integer not null,
+filler char (200),
+index (key1),
+index (key2)
+);
+show warnings;
+Level Code Message
+explain select pk from t1 where key1 = 1 and key2 = 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge key1,key2 key2,key1 4,5 NULL 1 Using intersect(key2,key1); Using where; Using index
+select pk from t1 where key2 = 1 and key1 = 1;
+pk
+26
+27
+select pk from t1 ignore index(key1,key2) where key2 = 1 and key1 = 1;
+pk
+26
+27
+drop table t1;
+create table t1 (
+pk int primary key auto_increment,
+key1a int,
+key2a int,
+key1b int,
+key2b int,
+dummy1 int,
+dummy2 int,
+dummy3 int,
+dummy4 int,
+key3a int,
+key3b int,
+filler1 char (200),
+index i1(key1a, key1b),
+index i2(key2a, key2b),
+index i3(key3a, key3b)
+);
+create table t2 (a int);
+insert into t2 values (0),(1),(2),(3),(4),(NULL);
+insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b)
+select A.a, B.a, C.a, D.a, C.a, D.a from t2 A,t2 B,t2 C, t2 D;
+insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b)
+select key1a, key1b, key2a, key2b, key3a, key3b from t1;
+insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b)
+select key1a, key1b, key2a, key2b, key3a, key3b from t1;
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+select count(*) from t1;
+count(*)
+5184
+select count(*) from t1 where
+key1a = 2 and key1b is null and key2a = 2 and key2b is null;
+count(*)
+4
+select count(*) from t1 where
+key1a = 2 and key1b is null and key3a = 2 and key3b is null;
+count(*)
+4
+drop table t1,t2;
+create table t1 (
+id1 int,
+id2 date ,
+index idx2 (id1,id2),
+index idx1 (id2)
+);
+insert into t1 values(1,'20040101'), (2,'20040102');
+select * from t1 where id1 = 1 and id2= '20040101';
+id1 id2
+1 2004-01-01
+drop table t1;
+drop view if exists v1;
+CREATE TABLE t1 (
+`oid` int(11) unsigned NOT NULL auto_increment,
+`fk_bbk_niederlassung` int(11) unsigned NOT NULL,
+`fk_wochentag` int(11) unsigned NOT NULL,
+`uhrzeit_von` time NOT NULL COMMENT 'HH:MM',
+`uhrzeit_bis` time NOT NULL COMMENT 'HH:MM',
+`geloescht` tinyint(4) NOT NULL,
+`version` int(5) NOT NULL,
+PRIMARY KEY (`oid`),
+KEY `fk_bbk_niederlassung` (`fk_bbk_niederlassung`),
+KEY `fk_wochentag` (`fk_wochentag`),
+KEY `ix_version` (`version`)
+) DEFAULT CHARSET=latin1;
+insert into t1 values
+(1, 38, 1, '08:00:00', '13:00:00', 0, 1),
+(2, 38, 2, '08:00:00', '13:00:00', 0, 1),
+(3, 38, 3, '08:00:00', '13:00:00', 0, 1),
+(4, 38, 4, '08:00:00', '13:00:00', 0, 1),
+(5, 38, 5, '08:00:00', '13:00:00', 0, 1),
+(6, 38, 5, '08:00:00', '13:00:00', 1, 2),
+(7, 38, 3, '08:00:00', '13:00:00', 1, 2),
+(8, 38, 1, '08:00:00', '13:00:00', 1, 2),
+(9, 38, 2, '08:00:00', '13:00:00', 1, 2),
+(10, 38, 4, '08:00:00', '13:00:00', 1, 2),
+(11, 38, 1, '08:00:00', '13:00:00', 0, 3),
+(12, 38, 2, '08:00:00', '13:00:00', 0, 3),
+(13, 38, 3, '08:00:00', '13:00:00', 0, 3),
+(14, 38, 4, '08:00:00', '13:00:00', 0, 3),
+(15, 38, 5, '08:00:00', '13:00:00', 0, 3),
+(16, 38, 4, '08:00:00', '13:00:00', 0, 4),
+(17, 38, 5, '08:00:00', '13:00:00', 0, 4),
+(18, 38, 1, '08:00:00', '13:00:00', 0, 4),
+(19, 38, 2, '08:00:00', '13:00:00', 0, 4),
+(20, 38, 3, '08:00:00', '13:00:00', 0, 4),
+(21, 7, 1, '08:00:00', '13:00:00', 0, 1),
+(22, 7, 2, '08:00:00', '13:00:00', 0, 1),
+(23, 7, 3, '08:00:00', '13:00:00', 0, 1),
+(24, 7, 4, '08:00:00', '13:00:00', 0, 1),
+(25, 7, 5, '08:00:00', '13:00:00', 0, 1);
+create view v1 as
+select
+zeit1.oid AS oid,
+zeit1.fk_bbk_niederlassung AS fk_bbk_niederlassung,
+zeit1.fk_wochentag AS fk_wochentag,
+zeit1.uhrzeit_von AS uhrzeit_von,
+zeit1.uhrzeit_bis AS uhrzeit_bis,
+zeit1.geloescht AS geloescht,
+zeit1.version AS version
+from
+t1 zeit1
+where
+(zeit1.version =
+(select max(zeit2.version) AS `max(version)`
+ from t1 zeit2
+where
+((zeit1.fk_bbk_niederlassung = zeit2.fk_bbk_niederlassung) and
+(zeit1.fk_wochentag = zeit2.fk_wochentag) and
+(zeit1.uhrzeit_von = zeit2.uhrzeit_von) and
+(zeit1.uhrzeit_bis = zeit2.uhrzeit_bis)
+)
+)
+)
+and (zeit1.geloescht = 0);
+select * from v1 where oid = 21;
+oid fk_bbk_niederlassung fk_wochentag uhrzeit_von uhrzeit_bis geloescht version
+21 7 1 08:00:00 13:00:00 0 1
+drop view v1;
+drop table t1;
+CREATE TABLE t1(
+t_cpac varchar(2) NOT NULL,
+t_vers varchar(4) NOT NULL,
+t_rele varchar(2) NOT NULL,
+t_cust varchar(4) NOT NULL,
+filler1 char(250) default NULL,
+filler2 char(250) default NULL,
+PRIMARY KEY (t_cpac,t_vers,t_rele,t_cust),
+UNIQUE KEY IX_4 (t_cust,t_cpac,t_vers,t_rele),
+KEY IX_5 (t_vers,t_rele,t_cust)
+);
+insert into t1 values
+('tm','2.5 ','a ',' ','',''), ('tm','2.5U','a ','stnd','',''),
+('da','3.3 ','b ',' ','',''), ('da','3.3U','b ','stnd','',''),
+('tl','7.6 ','a ',' ','',''), ('tt','7.6 ','a ',' ','',''),
+('bc','B61 ','a ',' ','',''), ('bp','B61 ','a ',' ','',''),
+('ca','B61 ','a ',' ','',''), ('ci','B61 ','a ',' ','',''),
+('cp','B61 ','a ',' ','',''), ('dm','B61 ','a ',' ','',''),
+('ec','B61 ','a ',' ','',''), ('ed','B61 ','a ',' ','',''),
+('fm','B61 ','a ',' ','',''), ('nt','B61 ','a ',' ','',''),
+('qm','B61 ','a ',' ','',''), ('tc','B61 ','a ',' ','',''),
+('td','B61 ','a ',' ','',''), ('tf','B61 ','a ',' ','',''),
+('tg','B61 ','a ',' ','',''), ('ti','B61 ','a ',' ','',''),
+('tp','B61 ','a ',' ','',''), ('ts','B61 ','a ',' ','',''),
+('wh','B61 ','a ',' ','',''), ('bc','B61U','a ','stnd','',''),
+('bp','B61U','a ','stnd','',''), ('ca','B61U','a ','stnd','',''),
+('ci','B61U','a ','stnd','',''), ('cp','B61U','a ','stnd','',''),
+('dm','B61U','a ','stnd','',''), ('ec','B61U','a ','stnd','',''),
+('fm','B61U','a ','stnd','',''), ('nt','B61U','a ','stnd','',''),
+('qm','B61U','a ','stnd','',''), ('tc','B61U','a ','stnd','',''),
+('td','B61U','a ','stnd','',''), ('tf','B61U','a ','stnd','',''),
+('tg','B61U','a ','stnd','',''), ('ti','B61U','a ','stnd','',''),
+('tp','B61U','a ','stnd','',''), ('ts','B61U','a ','stnd','',''),
+('wh','B61U','a ','stnd','','');
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `t_cpac` varchar(2) NOT NULL,
+ `t_vers` varchar(4) NOT NULL,
+ `t_rele` varchar(2) NOT NULL,
+ `t_cust` varchar(4) NOT NULL,
+ `filler1` char(250) DEFAULT NULL,
+ `filler2` char(250) DEFAULT NULL,
+ PRIMARY KEY (`t_cpac`,`t_vers`,`t_rele`,`t_cust`),
+ UNIQUE KEY `IX_4` (`t_cust`,`t_cpac`,`t_vers`,`t_rele`),
+ KEY `IX_5` (`t_vers`,`t_rele`,`t_cust`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+select t_vers,t_rele,t_cust,filler1 from t1 where t_vers = '7.6';
+t_vers t_rele t_cust filler1
+7.6 a
+7.6 a
+select t_vers,t_rele,t_cust,filler1 from t1 where t_vers = '7.6'
+ and t_rele='a' and t_cust = ' ';
+t_vers t_rele t_cust filler1
+7.6 a
+7.6 a
+drop table t1;
+create table t1 (
+pk int(11) not null auto_increment,
+a int(11) not null default '0',
+b int(11) not null default '0',
+c int(11) not null default '0',
+filler1 datetime, filler2 varchar(15),
+filler3 longtext,
+kp1 varchar(4), kp2 varchar(7),
+kp3 varchar(2), kp4 varchar(4),
+kp5 varchar(7),
+filler4 char(1),
+primary key (pk),
+key idx1(a,b,c),
+key idx2(c),
+key idx3(kp1,kp2,kp3,kp4,kp5)
+) default charset=latin1;
+set @fill=NULL;
+SELECT COUNT(*) FROM t1 WHERE b = 0 AND a = 0 AND c = 13286427 AND
+kp1='279' AND kp2='ELM0678' AND kp3='6' AND kp4='10' AND kp5 = 'R ';
+COUNT(*)
+1
+drop table t1;
+create table t1
+(
+key1 int not null,
+key2 int not null default 0,
+key3 int not null default 0
+);
+insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8);
+set @d=8;
+insert into t1 (key1) select key1+@d from t1;
+set @d=@d*2;
+insert into t1 (key1) select key1+@d from t1;
+set @d=@d*2;
+insert into t1 (key1) select key1+@d from t1;
+set @d=@d*2;
+insert into t1 (key1) select key1+@d from t1;
+set @d=@d*2;
+insert into t1 (key1) select key1+@d from t1;
+set @d=@d*2;
+insert into t1 (key1) select key1+@d from t1;
+set @d=@d*2;
+insert into t1 (key1) select key1+@d from t1;
+set @d=@d*2;
+alter table t1 add index i2(key2);
+alter table t1 add index i3(key3);
+update t1 set key2=key1,key3=key1;
+select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
+key1 key2 key3
+31 31 31
+32 32 32
+33 33 33
+34 34 34
+35 35 35
+36 36 36
+37 37 37
+38 38 38
+39 39 39
+drop table t1;
+#
+# Bug#56423: Different count with SELECT and CREATE SELECT queries
+#
+CREATE TABLE t1 (
+a INT,
+b INT,
+c INT,
+d INT,
+PRIMARY KEY (a),
+KEY (c),
+KEY bd (b,d)
+);
+INSERT INTO t1 VALUES
+(1, 0, 1, 0),
+(2, 1, 1, 1),
+(3, 1, 1, 1),
+(4, 0, 1, 1);
+EXPLAIN
+SELECT a
+FROM t1
+WHERE c = 1 AND b = 1 AND d = 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge c,bd c,bd 5,10 NULL 1 Using intersect(c,bd); Using where; Using index
+CREATE TABLE t2 ( a INT )
+SELECT a
+FROM t1
+WHERE c = 1 AND b = 1 AND d = 1;
+SELECT * FROM t2;
+a
+2
+3
+DROP TABLE t1, t2;
+CREATE TABLE t1( a INT, b INT, KEY(a), KEY(b) );
+INSERT INTO t1 VALUES (1, 2), (1, 2), (1, 2), (1, 2);
+SELECT * FROM t1 FORCE INDEX(a, b) WHERE a = 1 AND b = 2;
+a b
+1 2
+1 2
+1 2
+1 2
+DROP TABLE t1;
+# Code coverage of fix.
+CREATE TABLE t1 ( a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT);
+INSERT INTO t1 (b) VALUES (1);
+UPDATE t1 SET b = 2 WHERE a = 1;
+SELECT * FROM t1;
+a b
+1 2
+CREATE TABLE t2 ( a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b VARCHAR(1) );
+INSERT INTO t2 (b) VALUES ('a');
+UPDATE t2 SET b = 'b' WHERE a = 1;
+SELECT * FROM t2;
+a b
+1 b
+DROP TABLE t1, t2;
+#
+# BUG#13970015: ASSERT `MIN_ENDP || MAX_ENDP' FAILED IN
+# HANDLER::MULTI_RANGE_READ_INFO_CONST
+#
+CREATE TABLE t1 (
+pk INT NOT NULL,
+col_int_key INT NOT NULL,
+col_varchar_key VARCHAR(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY col_int_key (col_int_key),
+KEY col_varchar_key (col_varchar_key,col_int_key)
+);
+INSERT INTO t1 VALUES (1,1,'a'), (2,2,'b');
+EXPLAIN
+SELECT col_int_key
+FROM t1
+WHERE col_varchar_key >= 'l' OR
+(((pk BETWEEN 141 AND 141) OR col_varchar_key <> 'l')
+AND ((pk BETWEEN 141 AND 141) OR (col_int_key > 141)));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY,col_int_key,col_varchar_key col_varchar_key 7 NULL 2 Using where; Using index
+SELECT col_int_key
+FROM t1
+WHERE col_varchar_key >= 'l' OR
+(((pk BETWEEN 141 AND 141) OR col_varchar_key <> 'l')
+AND ((pk BETWEEN 141 AND 141) OR (col_int_key > 141)));
+col_int_key
+DROP TABLE t1;
+set global rocksdb_force_flush_memtable_now=1;
+#---------------- 2-sweeps read Index merge test 2 -------------------------------
+SET SESSION DEFAULT_STORAGE_ENGINE = RocksDB;
+drop table if exists t1;
+create table t1 (
+pk int primary key,
+key1 int,
+key2 int,
+filler char(200),
+filler2 char(200),
+index(key1),
+index(key2)
+);
+select * from t1 where (key1 >= 2 and key1 <= 10) or (pk >= 4 and pk <=8 );
+pk key1 key2 filler filler2
+10 10 10 filler-data filler-data-2
+2 2 2 filler-data filler-data-2
+3 3 3 filler-data filler-data-2
+4 4 4 filler-data filler-data-2
+5 5 5 filler-data filler-data-2
+6 6 6 filler-data filler-data-2
+7 7 7 filler-data filler-data-2
+8 8 8 filler-data filler-data-2
+9 9 9 filler-data filler-data-2
+set @maxv=1000;
+select * from t1 where
+(pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10)
+or key1=18 or key1=60;
+pk key1 key2 filler filler2
+1 1 1 filler-data filler-data-2
+1000 1000 1000 filler-data filler-data-2
+11 11 11 filler-data filler-data-2
+12 12 12 filler-data filler-data-2
+13 13 13 filler-data filler-data-2
+14 14 14 filler-data filler-data-2
+18 18 18 filler-data filler-data-2
+2 2 2 filler-data filler-data-2
+3 3 3 filler-data filler-data-2
+4 4 4 filler-data filler-data-2
+50 50 50 filler-data filler-data-2
+51 51 51 filler-data filler-data-2
+52 52 52 filler-data filler-data-2
+53 53 53 filler-data filler-data-2
+54 54 54 filler-data filler-data-2
+60 60 60 filler-data filler-data-2
+991 991 991 filler-data filler-data-2
+992 992 992 filler-data filler-data-2
+993 993 993 filler-data filler-data-2
+994 994 994 filler-data filler-data-2
+995 995 995 filler-data filler-data-2
+996 996 996 filler-data filler-data-2
+997 997 997 filler-data filler-data-2
+998 998 998 filler-data filler-data-2
+999 999 999 filler-data filler-data-2
+select * from t1 where
+(pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10)
+or key1 < 3 or key1 > @maxv-11;
+pk key1 key2 filler filler2
+1 1 1 filler-data filler-data-2
+1000 1000 1000 filler-data filler-data-2
+11 11 11 filler-data filler-data-2
+12 12 12 filler-data filler-data-2
+13 13 13 filler-data filler-data-2
+14 14 14 filler-data filler-data-2
+2 2 2 filler-data filler-data-2
+3 3 3 filler-data filler-data-2
+4 4 4 filler-data filler-data-2
+50 50 50 filler-data filler-data-2
+51 51 51 filler-data filler-data-2
+52 52 52 filler-data filler-data-2
+53 53 53 filler-data filler-data-2
+54 54 54 filler-data filler-data-2
+990 990 990 filler-data filler-data-2
+991 991 991 filler-data filler-data-2
+992 992 992 filler-data filler-data-2
+993 993 993 filler-data filler-data-2
+994 994 994 filler-data filler-data-2
+995 995 995 filler-data filler-data-2
+996 996 996 filler-data filler-data-2
+997 997 997 filler-data filler-data-2
+998 998 998 filler-data filler-data-2
+999 999 999 filler-data filler-data-2
+select * from t1 where
+(pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10)
+or
+(key1 < 5) or (key1 > 10 and key1 < 15) or (key1 >= 50 and key1 < 55 ) or (key1 > @maxv-10);
+pk key1 key2 filler filler2
+1 1 1 filler-data filler-data-2
+1000 1000 1000 filler-data filler-data-2
+11 11 11 filler-data filler-data-2
+12 12 12 filler-data filler-data-2
+13 13 13 filler-data filler-data-2
+14 14 14 filler-data filler-data-2
+2 2 2 filler-data filler-data-2
+3 3 3 filler-data filler-data-2
+4 4 4 filler-data filler-data-2
+50 50 50 filler-data filler-data-2
+51 51 51 filler-data filler-data-2
+52 52 52 filler-data filler-data-2
+53 53 53 filler-data filler-data-2
+54 54 54 filler-data filler-data-2
+991 991 991 filler-data filler-data-2
+992 992 992 filler-data filler-data-2
+993 993 993 filler-data filler-data-2
+994 994 994 filler-data filler-data-2
+995 995 995 filler-data filler-data-2
+996 996 996 filler-data filler-data-2
+997 997 997 filler-data filler-data-2
+998 998 998 filler-data filler-data-2
+999 999 999 filler-data filler-data-2
+select * from t1 where
+(pk > 10 and pk < 15) or (pk >= 50 and pk < 55 )
+or
+(key1 < 5) or (key1 > @maxv-10);
+pk key1 key2 filler filler2
+1 1 1 filler-data filler-data-2
+1000 1000 1000 filler-data filler-data-2
+11 11 11 filler-data filler-data-2
+12 12 12 filler-data filler-data-2
+13 13 13 filler-data filler-data-2
+14 14 14 filler-data filler-data-2
+2 2 2 filler-data filler-data-2
+3 3 3 filler-data filler-data-2
+4 4 4 filler-data filler-data-2
+50 50 50 filler-data filler-data-2
+51 51 51 filler-data filler-data-2
+52 52 52 filler-data filler-data-2
+53 53 53 filler-data filler-data-2
+54 54 54 filler-data filler-data-2
+991 991 991 filler-data filler-data-2
+992 992 992 filler-data filler-data-2
+993 993 993 filler-data filler-data-2
+994 994 994 filler-data filler-data-2
+995 995 995 filler-data filler-data-2
+996 996 996 filler-data filler-data-2
+997 997 997 filler-data filler-data-2
+998 998 998 filler-data filler-data-2
+999 999 999 filler-data filler-data-2
+drop table t1;
+set global rocksdb_force_flush_memtable_now=1;
+#---------------- Clustered PK ROR-index_merge tests -----------------------------
+SET SESSION DEFAULT_STORAGE_ENGINE = RocksDB;
+drop table if exists t1;
+create table t1
+(
+pk1 int not null,
+pk2 int not null,
+key1 int not null,
+key2 int not null,
+pktail1ok int not null,
+pktail2ok int not null,
+pktail3bad int not null,
+pktail4bad int not null,
+pktail5bad int not null,
+pk2copy int not null,
+badkey int not null,
+filler1 char (200),
+filler2 char (200),
+key (key1),
+key (key2),
+/* keys with tails from CPK members */
+key (pktail1ok, pk1),
+key (pktail2ok, pk1, pk2),
+key (pktail3bad, pk2, pk1),
+key (pktail4bad, pk1, pk2copy),
+key (pktail5bad, pk1, pk2, pk2copy),
+primary key (pk1, pk2)
+);
+explain select * from t1 where pk1 = 1 and pk2 < 80 and key1=0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY,key1 PRIMARY 8 NULL ROWS Using where
+select * from t1 where pk1 = 1 and pk2 < 80 and key1=0;
+pk1 pk2 key1 key2 pktail1ok pktail2ok pktail3bad pktail4bad pktail5bad pk2copy badkey filler1 filler2
+1 10 0 0 0 0 0 0 0 10 0 filler-data-10 filler2
+1 11 0 0 0 0 0 0 0 11 0 filler-data-11 filler2
+1 12 0 0 0 0 0 0 0 12 0 filler-data-12 filler2
+1 13 0 0 0 0 0 0 0 13 0 filler-data-13 filler2
+1 14 0 0 0 0 0 0 0 14 0 filler-data-14 filler2
+1 15 0 0 0 0 0 0 0 15 0 filler-data-15 filler2
+1 16 0 0 0 0 0 0 0 16 0 filler-data-16 filler2
+1 17 0 0 0 0 0 0 0 17 0 filler-data-17 filler2
+1 18 0 0 0 0 0 0 0 18 0 filler-data-18 filler2
+1 19 0 0 0 0 0 0 0 19 0 filler-data-19 filler2
+explain select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge key1,key2 key1,key2 4,4 NULL 1 Using intersect(key1,key2); Using where; Using index
+select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1;
+pk1 pk2
+95 50
+95 51
+95 52
+95 53
+95 54
+95 55
+95 56
+95 57
+95 58
+95 59
+explain select * from t1 where badkey=1 and key1=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref key1 key1 4 const ROWS Using where
+explain select * from t1 where pk1 < 7500 and key1 = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY,key1 PRIMARY 4 NULL ROWS Using where
+explain select * from t1 where pktail1ok=1 and key1=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref key1,pktail1ok key1 4 const 2 Using where
+explain select * from t1 where pktail2ok=1 and key1=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref key1,pktail2ok key1 4 const 2 Using where
+explain select * from t1 where (pktail2ok=1 and pk1< 50000) or key1=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge PRIMARY,key1,pktail2ok pktail2ok,key1 8,4 NULL ROWS Using sort_union(pktail2ok,key1); Using where
+explain select * from t1 where pktail3bad=1 and key1=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref key1,pktail3bad EITHER_KEY 4 const ROWS Using where
+explain select * from t1 where pktail4bad=1 and key1=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref key1,pktail4bad key1 4 const ROWS Using where
+explain select * from t1 where pktail5bad=1 and key1=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref key1,pktail5bad key1 4 const ROWS Using where
+explain select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge key1,key2 key1,key2 4,4 NULL 1 Using intersect(key1,key2); Using where; Using index
+select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
+pk1 pk2 key1 key2
+95 50 10 10
+95 51 10 10
+95 52 10 10
+95 53 10 10
+95 54 10 10
+95 55 10 10
+95 56 10 10
+95 57 10 10
+95 58 10 10
+95 59 10 10
+drop table t1;
+create table t1
+(
+RUNID varchar(22),
+SUBMITNR varchar(5),
+ORDERNR char(1),
+PROGRAMM varchar(8),
+TESTID varchar(4),
+UCCHECK char(1),
+ETEXT varchar(80),
+ETEXT_TYPE char(1),
+INFO char(1),
+SEVERITY tinyint(3),
+TADIRFLAG char(1),
+PRIMARY KEY (RUNID,SUBMITNR,ORDERNR,PROGRAMM,TESTID,UCCHECK),
+KEY `TVERM~KEY` (PROGRAMM,TESTID,UCCHECK)
+) DEFAULT CHARSET=latin1;
+update t1 set `ETEXT` = '', `ETEXT_TYPE`='', `INFO`='', `SEVERITY`='', `TADIRFLAG`=''
+WHERE
+`RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND
+`TESTID`='' AND `UCCHECK`='';
+drop table t1;
+#
+# Bug#50402 Optimizer producing wrong results when using Index Merge on InnoDB
+#
+CREATE TABLE t1 (f1 INT, PRIMARY KEY (f1));
+INSERT INTO t1 VALUES (2);
+CREATE TABLE t2 (f1 INT, f2 INT, f3 char(1),
+PRIMARY KEY (f1), KEY (f2), KEY (f3) );
+INSERT INTO t2 VALUES (1, 1, 'h'), (2, 3, 'h'), (3, 2, ''), (4, 2, '');
+SELECT t1.f1 FROM t1
+WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
+f1
+2
+EXPLAIN SELECT t1.f1 FROM t1
+WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1 Using index
+2 SUBQUERY t2 index_merge f2,f3 f3,f2 2,5 NULL 1 Using intersect(f3,f2); Using where; Using index
+DROP TABLE t1,t2;
+set global rocksdb_force_flush_memtable_now=1;
+#
+# Bug#11747423 32254: INDEX MERGE USED UNNECESSARILY
+#
+CREATE TABLE t1 (
+id INT NOT NULL PRIMARY KEY,
+id2 INT NOT NULL,
+id3 INT NOT NULL,
+KEY (id2),
+KEY (id3),
+KEY covering_index (id2,id3)
+) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (0, 0, 0), (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5), (6, 6, 6), (7, 7, 7);
+INSERT INTO t1 SELECT id + 8, id2 + 8, id3 +8 FROM t1;
+INSERT INTO t1 SELECT id + 16, 7, 0 FROM t1;
+EXPLAIN SELECT SQL_NO_CACHE count(*) FROM t1 WHERE id2=7 AND id3=0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref id2,id3,covering_index covering_index 8 const,const 2 Using index
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/index_primary.result b/storage/rocksdb/mysql-test/rocksdb/r/index_primary.result
new file mode 100644
index 00000000..1f4c88e5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/index_primary.result
@@ -0,0 +1,71 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT PRIMARY KEY,
+b CHAR(8)
+) ENGINE=rocksdb;
+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 PRIMARY 1 a A # NULL NULL LSMTREE
+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 'PRIMARY'
+DROP TABLE t1;
+CREATE TABLE t1 (a INT PRIMARY KEY,
+b CHAR(8) PRIMARY KEY
+) ENGINE=rocksdb;
+ERROR 42000: Multiple primary key defined
+CREATE TABLE t1 (a INT,
+b CHAR(8),
+PRIMARY KEY (a,b)
+) ENGINE=rocksdb;
+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 PRIMARY 1 a A # NULL NULL LSMTREE
+t1 0 PRIMARY 2 b A # NULL NULL LSMTREE
+INSERT INTO t1 (a,b) VALUES (1,'a'),(1,'b'),(2,'a'),(2,'b');
+INSERT INTO t1 (a,b) VALUES (1,'b');
+ERROR 23000: Duplicate entry '1-b' for key 'PRIMARY'
+DROP TABLE t1;
+CREATE TABLE t1 (a INT KEY,
+b CHAR(8),
+KEY (b)
+) ENGINE=rocksdb;
+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 PRIMARY 1 a A # NULL NULL LSMTREE
+t1 1 b 1 b A # NULL NULL YES LSMTREE
+DROP TABLE t1;
+CREATE TABLE t1 (a INT,
+b CHAR(8) PRIMARY KEY
+) ENGINE=rocksdb;
+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 PRIMARY 1 b A # NULL NULL LSMTREE
+ALTER TABLE t1 ADD CONSTRAINT PRIMARY KEY pk (a);
+ERROR 42000: Multiple primary key defined
+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 PRIMARY 1 b A # NULL NULL LSMTREE
+DROP TABLE t1;
+set global rocksdb_large_prefix=0;
+CREATE TABLE t1 (
+a BLOB(1024),
+PRIMARY KEY (a(767))
+) ENGINE=rocksdb;
+DROP TABLE t1;
+CREATE TABLE t1 (
+a BLOB(1024),
+PRIMARY KEY (a(768))
+) ENGINE=rocksdb;
+ERROR 42000: Specified key was too long; max key length is 767 bytes
+set global rocksdb_large_prefix=1;
+CREATE TABLE t1 (
+a BLOB(4096),
+PRIMARY KEY (a(3072))
+) ENGINE=rocksdb;
+DROP TABLE t1;
+CREATE TABLE t1 (
+a BLOB(4096),
+PRIMARY KEY (a(3073))
+) ENGINE=rocksdb;
+ERROR 42000: Specified key was too long; max key length is 3072 bytes
+set global rocksdb_large_prefix=DEFAULT;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/index_type_btree.result b/storage/rocksdb/mysql-test/rocksdb/r/index_type_btree.result
new file mode 100644
index 00000000..9eaab9f5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/index_type_btree.result
@@ -0,0 +1,69 @@
+CREATE TABLE t1 (a INT,
+b CHAR(8),
+pk INT PRIMARY KEY,
+KEY USING BTREE (a)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A # NULL NULL LSMTREE
+t1 1 a 1 a A # NULL NULL YES LSMTREE
+DROP TABLE t1;
+CREATE TABLE t1 (a INT,
+b CHAR(8),
+pk INT PRIMARY KEY,
+KEY a_b USING BTREE (a,b) COMMENT 'a_b index'
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A # NULL NULL LSMTREE
+t1 1 a_b 1 a A # NULL NULL YES LSMTREE a_b index
+t1 1 a_b 2 b A # NULL NULL YES LSMTREE a_b index
+DROP TABLE t1;
+CREATE TABLE t1 (a INT,
+b CHAR(8),
+pk INT PRIMARY KEY,
+KEY USING BTREE (a),
+KEY USING BTREE (b)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A # NULL NULL LSMTREE
+t1 1 a 1 a A # NULL NULL YES LSMTREE
+t1 1 b 1 b A # NULL NULL YES LSMTREE
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (100,'z');
+ALTER TABLE t1 ADD KEY (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 0 PRIMARY 1 pk A # NULL NULL LSMTREE
+t1 1 a 1 a A # NULL NULL YES LSMTREE simple index on a
+ALTER TABLE t1 DROP KEY a;
+DROP TABLE t1;
+set global rocksdb_large_prefix=0;
+CREATE TABLE t1 (
+a BLOB(1024),
+KEY (a(767))
+) ENGINE=rocksdb;
+DROP TABLE t1;
+CREATE TABLE t1 (
+a BLOB(1024),
+KEY (a(768))
+) ENGINE=rocksdb;
+Warnings:
+Note 1071 Specified key was too long; max key length is 767 bytes
+DROP TABLE t1;
+set global rocksdb_large_prefix=1;
+CREATE TABLE t1 (
+a BLOB(4096),
+KEY (a(3072))
+) ENGINE=rocksdb;
+DROP TABLE t1;
+CREATE TABLE t1 (
+a BLOB(4096),
+KEY (a(3073))
+) ENGINE=rocksdb;
+Warnings:
+Note 1071 Specified key was too long; max key length is 3072 bytes
+DROP TABLE t1;
+set global rocksdb_large_prefix=DEFAULT;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/index_type_hash.result b/storage/rocksdb/mysql-test/rocksdb/r/index_type_hash.result
new file mode 100644
index 00000000..bc1a96fa
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/index_type_hash.result
@@ -0,0 +1,69 @@
+CREATE TABLE t1 (a INT,
+b CHAR(8),
+pk INT PRIMARY KEY,
+KEY USING HASH (a)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A # NULL NULL LSMTREE
+t1 1 a 1 a A # NULL NULL YES LSMTREE
+DROP TABLE t1;
+CREATE TABLE t1 (a INT,
+b CHAR(8),
+pk INT PRIMARY KEY,
+KEY a_b USING HASH (a,b) COMMENT 'a_b index'
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A # NULL NULL LSMTREE
+t1 1 a_b 1 a A # NULL NULL YES LSMTREE a_b index
+t1 1 a_b 2 b A # NULL NULL YES LSMTREE a_b index
+DROP TABLE t1;
+CREATE TABLE t1 (a INT,
+b CHAR(8),
+pk INT PRIMARY KEY,
+KEY USING HASH (a),
+KEY USING HASH (b)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A # NULL NULL LSMTREE
+t1 1 a 1 a A # NULL NULL YES LSMTREE
+t1 1 b 1 b A # NULL NULL YES LSMTREE
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (100,'z');
+ALTER TABLE t1 ADD KEY (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 0 PRIMARY 1 pk A # NULL NULL LSMTREE
+t1 1 a 1 a A # NULL NULL YES LSMTREE simple index on a
+ALTER TABLE t1 DROP KEY a;
+DROP TABLE t1;
+set global rocksdb_large_prefix=0;
+CREATE TABLE t1 (
+a BLOB(1024),
+KEY (a(767))
+) ENGINE=rocksdb;
+DROP TABLE t1;
+CREATE TABLE t1 (
+a BLOB(1024),
+KEY (a(768))
+) ENGINE=rocksdb;
+Warnings:
+Note 1071 Specified key was too long; max key length is 767 bytes
+DROP TABLE t1;
+set global rocksdb_large_prefix=1;
+CREATE TABLE t1 (
+a BLOB(4096),
+KEY (a(3072))
+) ENGINE=rocksdb;
+DROP TABLE t1;
+CREATE TABLE t1 (
+a BLOB(4096),
+KEY (a(3073))
+) ENGINE=rocksdb;
+Warnings:
+Note 1071 Specified key was too long; max key length is 3072 bytes
+DROP TABLE t1;
+set global rocksdb_large_prefix=DEFAULT;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/information_schema.result b/storage/rocksdb/mysql-test/rocksdb/r/information_schema.result
new file mode 100644
index 00000000..e22a85fd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/information_schema.result
@@ -0,0 +1,83 @@
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK=1;
+create table t1 (a int) engine=rocksdb;
+drop table t1;
+select * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where type<>'DDL_DROP_INDEX_ONGOING';
+TYPE NAME VALUE
+MAX_INDEX_ID MAX_INDEX_ID max_index_id
+CF_FLAGS 0 default [0]
+CF_FLAGS 1 __system__ [0]
+select count(*) from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where type<>'DDL_DROP_INDEX_ONGOING';
+count(*)
+3
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK=0;
+select VALUE into @keysIn from INFORMATION_SCHEMA.ROCKSDB_COMPACTION_STATS where CF_NAME = 'default' and LEVEL = 'Sum' and TYPE = 'KeyIn';
+CREATE TABLE t1 (i1 INT, i2 INT, PRIMARY KEY (i1)) ENGINE = ROCKSDB;
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+set global rocksdb_force_flush_memtable_now = true;
+select * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO;
+TYPE NAME VALUE
+MAX_INDEX_ID MAX_INDEX_ID max_index_id
+CF_FLAGS 0 default [0]
+CF_FLAGS 1 __system__ [0]
+select count(*) from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO;
+count(*)
+3
+set global rocksdb_force_flush_memtable_now = true;
+set global rocksdb_compact_cf='default';
+select case when VALUE-@keysIn >= 3 then 'true' else 'false' end from INFORMATION_SCHEMA.ROCKSDB_COMPACTION_STATS where CF_NAME = 'default' and LEVEL = 'Sum' and TYPE = 'KeyIn';
+case when VALUE-@keysIn >= 3 then 'true' else 'false' end
+true
+CREATE INDEX tindex1 on t1 (i1);
+CREATE INDEX tindex2 on t1 (i2);
+select * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where TYPE = 'CF_FLAGS';
+TYPE NAME VALUE
+CF_FLAGS 0 default [0]
+CF_FLAGS 1 __system__ [0]
+CREATE TABLE t2 (
+a int,
+b int,
+c int,
+d int,
+PRIMARY KEY (a) COMMENT "cf_a",
+KEY (b) COMMENT "cf_b",
+KEY (c) COMMENT "cf_c",
+KEY (d) COMMENT "rev:cf_d") ENGINE=ROCKSDB;
+select * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where TYPE = 'CF_FLAGS';
+TYPE NAME VALUE
+CF_FLAGS 0 default [0]
+CF_FLAGS 1 __system__ [0]
+CF_FLAGS 2 cf_a [0]
+CF_FLAGS 3 cf_b [0]
+CF_FLAGS 4 cf_c [0]
+CF_FLAGS 5 rev:cf_d [1]
+CREATE TABLE t3 (a INT, PRIMARY KEY (a)) ENGINE=ROCKSDB;
+insert into t3 (a) values (1), (2), (3);
+SET @ORIG_ROCKSDB_PAUSE_BACKGROUND_WORK = @@GLOBAL.ROCKSDB_PAUSE_BACKGROUND_WORK;
+SHOW GLOBAL VARIABLES LIKE 'ROCKSDB_PAUSE_BACKGROUND_WORK';
+Variable_name Value
+rocksdb_pause_background_work OFF
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK=1;
+SHOW GLOBAL VARIABLES LIKE 'ROCKSDB_PAUSE_BACKGROUND_WORK';
+Variable_name Value
+rocksdb_pause_background_work ON
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK=1;
+SHOW GLOBAL VARIABLES LIKE 'ROCKSDB_PAUSE_BACKGROUND_WORK';
+Variable_name Value
+rocksdb_pause_background_work ON
+DROP TABLE t3;
+cf_id:0,index_id:264
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK=0;
+SHOW GLOBAL VARIABLES LIKE 'ROCKSDB_PAUSE_BACKGROUND_WORK';
+Variable_name Value
+rocksdb_pause_background_work OFF
+next line shouldn't cause assertion to fail
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK=0;
+SHOW GLOBAL VARIABLES LIKE 'ROCKSDB_PAUSE_BACKGROUND_WORK';
+Variable_name Value
+rocksdb_pause_background_work OFF
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_ROCKSDB_PAUSE_BACKGROUND_WORK;
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result b/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result
new file mode 100644
index 00000000..ac6e2bcc
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result
@@ -0,0 +1,326 @@
+SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX;
+trx_id trx_state trx_started trx_requested_lock_id trx_wait_started trx_weight trx_mysql_thread_id trx_query trx_operation_state trx_tables_in_use trx_tables_locked trx_lock_structs trx_lock_memory_bytes trx_rows_locked trx_rows_modified trx_concurrency_tickets trx_isolation_level trx_unique_checks trx_foreign_key_checks trx_last_foreign_key_error trx_is_read_only trx_autocommit_non_locking
+SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS;
+lock_id lock_trx_id lock_mode lock_type lock_table lock_index lock_space lock_page lock_rec lock_data
+SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS;
+requesting_trx_id requested_lock_id blocking_trx_id blocking_lock_id
+SELECT * FROM INFORMATION_SCHEMA.INNODB_CMP;
+page_size compress_ops compress_ops_ok compress_time uncompress_ops uncompress_time
+SELECT * FROM INFORMATION_SCHEMA.INNODB_CMP_RESET;
+page_size compress_ops compress_ops_ok compress_time uncompress_ops uncompress_time
+SELECT * FROM INFORMATION_SCHEMA.INNODB_CMP_PER_INDEX;
+database_name table_name index_name compress_ops compress_ops_ok compress_time uncompress_ops uncompress_time
+SELECT * FROM INFORMATION_SCHEMA.INNODB_CMP_PER_INDEX_RESET;
+database_name table_name index_name compress_ops compress_ops_ok compress_time uncompress_ops uncompress_time
+SELECT * FROM INFORMATION_SCHEMA.INNODB_CMPMEM;
+page_size buffer_pool_instance pages_used pages_free relocation_ops relocation_time
+SELECT * FROM INFORMATION_SCHEMA.INNODB_CMPMEM_RESET;
+page_size buffer_pool_instance pages_used pages_free relocation_ops relocation_time
+SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS;
+NAME SUBSYSTEM COUNT MAX_COUNT MIN_COUNT AVG_COUNT COUNT_RESET MAX_COUNT_RESET MIN_COUNT_RESET AVG_COUNT_RESET TIME_ENABLED TIME_DISABLED TIME_ELAPSED TIME_RESET ENABLED TYPE COMMENT
+metadata_table_handles_opened metadata 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of table handles opened
+metadata_table_handles_closed metadata 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of table handles closed
+metadata_table_reference_count metadata 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Table reference counter
+lock_deadlocks lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of deadlocks
+lock_timeouts lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of lock timeouts
+lock_rec_lock_waits lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times enqueued into record lock wait queue
+lock_table_lock_waits lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times enqueued into table lock wait queue
+lock_rec_lock_requests lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of record locks requested
+lock_rec_lock_created lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of record locks created
+lock_rec_lock_removed lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of record locks removed from the lock queue
+lock_rec_locks lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Current number of record locks on tables
+lock_table_lock_created lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of table locks created
+lock_table_lock_removed lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of table locks removed from the lock queue
+lock_table_locks lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Current number of table locks on tables
+lock_row_lock_current_waits lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of row locks currently being waited for (innodb_row_lock_current_waits)
+lock_row_lock_time lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Time spent in acquiring row locks, in milliseconds (innodb_row_lock_time)
+lock_row_lock_time_max lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value The maximum time to acquire a row lock, in milliseconds (innodb_row_lock_time_max)
+lock_row_lock_waits lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of times a row lock had to be waited for (innodb_row_lock_waits)
+lock_row_lock_time_avg lock 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value The average time to acquire a row lock, in milliseconds (innodb_row_lock_time_avg)
+buffer_pool_size server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Server buffer pool size (all buffer pools) in bytes
+buffer_pool_reads buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of reads directly from disk (innodb_buffer_pool_reads)
+buffer_pool_read_requests buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of logical read requests (innodb_buffer_pool_read_requests)
+buffer_pool_write_requests buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of write requests (innodb_buffer_pool_write_requests)
+buffer_pool_wait_free buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of times waited for free buffer (innodb_buffer_pool_wait_free)
+buffer_pool_read_ahead buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of pages read as read ahead (innodb_buffer_pool_read_ahead)
+buffer_pool_read_ahead_evicted buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Read-ahead pages evicted without being accessed (innodb_buffer_pool_read_ahead_evicted)
+buffer_pool_pages_total buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Total buffer pool size in pages (innodb_buffer_pool_pages_total)
+buffer_pool_pages_misc buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Buffer pages for misc use such as row locks or the adaptive hash index (innodb_buffer_pool_pages_misc)
+buffer_pool_pages_data buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Buffer pages containing data (innodb_buffer_pool_pages_data)
+buffer_pool_bytes_data buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Buffer bytes containing data (innodb_buffer_pool_bytes_data)
+buffer_pool_pages_dirty buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Buffer pages currently dirty (innodb_buffer_pool_pages_dirty)
+buffer_pool_bytes_dirty buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Buffer bytes currently dirty (innodb_buffer_pool_bytes_dirty)
+buffer_pool_pages_free buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Buffer pages currently free (innodb_buffer_pool_pages_free)
+buffer_pages_created buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of pages created (innodb_pages_created)
+buffer_pages_written buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of pages written (innodb_pages_written)
+buffer_index_pages_written buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of index pages written (innodb_index_pages_written)
+buffer_non_index_pages_written buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of non index pages written (innodb_non_index_pages_written)
+buffer_pages_read buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of pages read (innodb_pages_read)
+buffer_index_sec_rec_cluster_reads buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of secondary record reads triggered cluster read
+buffer_index_sec_rec_cluster_reads_avoided buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of secondary record reads avoided triggering cluster read
+buffer_data_reads buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Amount of data read in bytes (innodb_data_reads)
+buffer_data_written buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Amount of data written in bytes (innodb_data_written)
+buffer_flush_batch_scanned buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_owner Total pages scanned as part of flush batch
+buffer_flush_batch_num_scan buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Number of times buffer flush list flush is called
+buffer_flush_batch_scanned_per_call buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Pages scanned per flush batch scan
+buffer_flush_batch_total_pages buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_owner Total pages flushed as part of flush batch
+buffer_flush_batches buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Number of flush batches
+buffer_flush_batch_pages buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Pages queued as a flush batch
+buffer_flush_neighbor_total_pages buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_owner Total neighbors flushed as part of neighbor flush
+buffer_flush_neighbor buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Number of times neighbors flushing is invoked
+buffer_flush_neighbor_pages buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Pages queued as a neighbor batch
+buffer_flush_n_to_flush_requested buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of pages requested for flushing.
+buffer_flush_n_to_flush_by_age buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of pages target by LSN Age for flushing.
+buffer_flush_adaptive_avg_time buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Avg time (ms) spent for adaptive flushing recently.
+buffer_flush_adaptive_avg_pass buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of adaptive flushes passed during the recent Avg period.
+buffer_LRU_get_free_loops buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Total loops in LRU get free.
+buffer_LRU_get_free_waits buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Total sleep waits in LRU get free.
+buffer_flush_avg_page_rate buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Average number of pages at which flushing is happening
+buffer_flush_lsn_avg_rate buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Average redo generation rate
+buffer_flush_pct_for_dirty buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Percent of IO capacity used to avoid max dirty page limit
+buffer_flush_pct_for_lsn buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Percent of IO capacity used to avoid reusable redo space limit
+buffer_flush_sync_waits buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times a wait happens due to sync flushing
+buffer_flush_adaptive_total_pages buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_owner Total pages flushed as part of adaptive flushing
+buffer_flush_adaptive buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Number of adaptive batches
+buffer_flush_adaptive_pages buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Pages queued as an adaptive batch
+buffer_flush_sync_total_pages buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_owner Total pages flushed as part of sync batches
+buffer_flush_sync buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Number of sync batches
+buffer_flush_sync_pages buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Pages queued as a sync batch
+buffer_flush_background_total_pages buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_owner Total pages flushed as part of background batches
+buffer_flush_background buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Number of background batches
+buffer_flush_background_pages buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Pages queued as a background batch
+buffer_LRU_batch_scanned buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_owner Total pages scanned as part of LRU batch
+buffer_LRU_batch_num_scan buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Number of times LRU batch is called
+buffer_LRU_batch_scanned_per_call buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Pages scanned per LRU batch call
+buffer_LRU_batch_flush_total_pages buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_owner Total pages flushed as part of LRU batches
+buffer_LRU_batches_flush buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Number of LRU batches
+buffer_LRU_batch_flush_pages buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Pages queued as an LRU batch
+buffer_LRU_batch_evict_total_pages buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_owner Total pages evicted as part of LRU batches
+buffer_LRU_batches_evict buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Number of LRU batches
+buffer_LRU_batch_evict_pages buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Pages queued as an LRU batch
+buffer_LRU_single_flush_failure_count Buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times attempt to flush a single page from LRU failed
+buffer_LRU_get_free_search Buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of searches performed for a clean page
+buffer_LRU_search_scanned buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_owner Total pages scanned as part of LRU search
+buffer_LRU_search_num_scan buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Number of times LRU search is performed
+buffer_LRU_search_scanned_per_call buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Page scanned per single LRU search
+buffer_LRU_unzip_search_scanned buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_owner Total pages scanned as part of LRU unzip search
+buffer_LRU_unzip_search_num_scan buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Number of times LRU unzip search is performed
+buffer_LRU_unzip_search_scanned_per_call buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 set_member Page scanned per single LRU unzip search
+buffer_page_read_index_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Leaf Pages read
+buffer_page_read_index_non_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Non-leaf Pages read
+buffer_page_read_index_ibuf_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Index Leaf Pages read
+buffer_page_read_index_ibuf_non_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Index Non-Leaf Pages read
+buffer_page_read_undo_log buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Undo Log Pages read
+buffer_page_read_index_inode buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Inode Pages read
+buffer_page_read_ibuf_free_list buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Free List Pages read
+buffer_page_read_ibuf_bitmap buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Bitmap Pages read
+buffer_page_read_system_page buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of System Pages read
+buffer_page_read_trx_system buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Transaction System Pages read
+buffer_page_read_fsp_hdr buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of File Space Header Pages read
+buffer_page_read_xdes buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Extent Descriptor Pages read
+buffer_page_read_blob buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Uncompressed BLOB Pages read
+buffer_page_read_zblob buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of First Compressed BLOB Pages read
+buffer_page_read_zblob2 buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Subsequent Compressed BLOB Pages read
+buffer_page_read_other buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of other/unknown (old version of InnoDB) Pages read
+buffer_page_written_index_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Leaf Pages written
+buffer_page_written_index_non_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Non-leaf Pages written
+buffer_page_written_index_ibuf_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Index Leaf Pages written
+buffer_page_written_index_ibuf_non_leaf buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Index Non-Leaf Pages written
+buffer_page_written_undo_log buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Undo Log Pages written
+buffer_page_written_index_inode buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Index Inode Pages written
+buffer_page_written_ibuf_free_list buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Free List Pages written
+buffer_page_written_ibuf_bitmap buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Insert Buffer Bitmap Pages written
+buffer_page_written_system_page buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of System Pages written
+buffer_page_written_trx_system buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Transaction System Pages written
+buffer_page_written_fsp_hdr buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of File Space Header Pages written
+buffer_page_written_xdes buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Extent Descriptor Pages written
+buffer_page_written_blob buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Uncompressed BLOB Pages written
+buffer_page_written_zblob buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of First Compressed BLOB Pages written
+buffer_page_written_zblob2 buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Subsequent Compressed BLOB Pages written
+buffer_page_written_other buffer_page_io 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of other/unknown (old version InnoDB) Pages written
+os_data_reads os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of reads initiated (innodb_data_reads)
+os_data_writes os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of writes initiated (innodb_data_writes)
+os_data_fsyncs os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of fsync() calls (innodb_data_fsyncs)
+os_pending_reads os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of reads pending
+os_pending_writes os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of writes pending
+os_log_bytes_written os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Bytes of log written (innodb_os_log_written)
+os_log_fsyncs os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of fsync log writes (innodb_os_log_fsyncs)
+os_log_pending_fsyncs os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of pending fsync write (innodb_os_log_pending_fsyncs)
+os_log_pending_writes os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of pending log file writes (innodb_os_log_pending_writes)
+trx_rw_commits transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of read-write transactions committed
+trx_ro_commits transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of read-only transactions committed
+trx_nl_ro_commits transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of non-locking auto-commit read-only transactions committed
+trx_commits_insert_update transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions committed with inserts and updates
+trx_rollbacks transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back
+trx_rollbacks_savepoint transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back to savepoint
+trx_active_transactions transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of active transactions
+trx_rseg_history_len transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Length of the TRX_RSEG_HISTORY list
+trx_undo_slots_used transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of undo slots used
+trx_undo_slots_cached transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of undo slots cached
+trx_rseg_current_size transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Current rollback segment size in pages
+purge_del_mark_records purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of delete-marked rows purged
+purge_upd_exist_or_extern_records purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of purges on updates of existing records and updates on delete marked record with externally stored field
+purge_invoked purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times purge was invoked
+purge_undo_log_pages purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of undo log pages handled by the purge
+purge_dml_delay_usec purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Microseconds DML to be delayed due to purge lagging
+purge_stop_count purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of times purge was stopped
+purge_resume_count purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of times purge was resumed
+log_checkpoints recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of checkpoints
+log_lsn_last_flush recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value LSN of Last flush
+log_lsn_last_checkpoint recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value LSN at last checkpoint
+log_lsn_current recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Current LSN value
+log_lsn_checkpoint_age recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Current LSN value minus LSN at last checkpoint
+log_lsn_buf_pool_oldest recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value The oldest modified block LSN in the buffer pool
+log_max_modified_age_async recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Maximum LSN difference; when exceeded, start asynchronous preflush
+log_pending_log_flushes recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Pending log flushes
+log_pending_checkpoint_writes recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Pending checkpoints
+log_num_log_io recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of log I/Os
+log_waits recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of log waits due to small log buffer (innodb_log_waits)
+log_write_requests recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of log write requests (innodb_log_write_requests)
+log_writes recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of log writes (innodb_log_writes)
+log_padded recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Bytes of log padded for log write ahead
+compress_pages_compressed compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of pages compressed
+compress_pages_decompressed compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of pages decompressed
+compression_pad_increments compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times padding is incremented to avoid compression failures
+compression_pad_decrements compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times padding is decremented due to good compressibility
+compress_saved compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of bytes saved by page compression
+compress_pages_page_compressed compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of pages compressed by page compression
+compress_page_compressed_trim_op compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of TRIM operation performed by page compression
+compress_pages_page_decompressed compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of pages decompressed by page compression
+compress_pages_page_compression_error compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of page compression errors
+compress_pages_encrypted compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of pages encrypted
+compress_pages_decrypted compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of pages decrypted
+index_page_splits index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of index page splits
+index_page_merge_attempts index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of index page merge attempts
+index_page_merge_successful index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of successful index page merges
+index_page_reorg_attempts index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of index page reorganization attempts
+index_page_reorg_successful index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of successful index page reorganizations
+index_page_discards index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of index pages discarded
+adaptive_hash_searches adaptive_hash_index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of successful searches using Adaptive Hash Index
+adaptive_hash_searches_btree adaptive_hash_index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of searches using B-tree on an index search
+adaptive_hash_pages_added adaptive_hash_index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of index pages on which the Adaptive Hash Index is built
+adaptive_hash_pages_removed adaptive_hash_index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of index pages whose corresponding Adaptive Hash Index entries were removed
+adaptive_hash_rows_added adaptive_hash_index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Adaptive Hash Index rows added
+adaptive_hash_rows_removed adaptive_hash_index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Adaptive Hash Index rows removed
+adaptive_hash_rows_deleted_no_hash_entry adaptive_hash_index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of rows deleted that did not have corresponding Adaptive Hash Index entries
+adaptive_hash_rows_updated adaptive_hash_index 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of Adaptive Hash Index rows updated
+file_num_open_files file_system 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of files currently open (innodb_num_open_files)
+ibuf_merges_insert change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of inserted records merged by change buffering
+ibuf_merges_delete_mark change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of deleted records merged by change buffering
+ibuf_merges_delete change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of purge records merged by change buffering
+ibuf_merges_discard_insert change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of insert merged operations discarded
+ibuf_merges_discard_delete_mark change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of deleted merged operations discarded
+ibuf_merges_discard_delete change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of purge merged operations discarded
+ibuf_merges change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of change buffer merges
+ibuf_size change_buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Change buffer size in pages
+innodb_master_thread_sleeps server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times (seconds) master thread sleeps
+innodb_activity_count server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Current server activity count
+innodb_master_active_loops server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times master thread performs its tasks when server is active
+innodb_master_idle_loops server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times master thread performs its tasks when server is idle
+innodb_background_drop_table_usec server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Time (in microseconds) spent to process drop table list
+innodb_log_flush_usec server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Time (in microseconds) spent to flush log records
+innodb_dict_lru_usec server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Time (in microseconds) spent to process DICT LRU list
+innodb_dict_lru_count_active server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of tables evicted from DICT LRU list in the active loop
+innodb_dict_lru_count_idle server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of tables evicted from DICT LRU list in the idle loop
+innodb_dblwr_writes server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of doublewrite operations that have been performed (innodb_dblwr_writes)
+innodb_dblwr_pages_written server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of pages that have been written for doublewrite operations (innodb_dblwr_pages_written)
+innodb_page_size server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value InnoDB page size in bytes (innodb_page_size)
+innodb_rwlock_s_spin_waits server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of rwlock spin waits due to shared latch request
+innodb_rwlock_x_spin_waits server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of rwlock spin waits due to exclusive latch request
+innodb_rwlock_sx_spin_waits server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of rwlock spin waits due to sx latch request
+innodb_rwlock_s_spin_rounds server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of rwlock spin loop rounds due to shared latch request
+innodb_rwlock_x_spin_rounds server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of rwlock spin loop rounds due to exclusive latch request
+innodb_rwlock_sx_spin_rounds server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of rwlock spin loop rounds due to sx latch request
+innodb_rwlock_s_os_waits server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of OS waits due to shared latch request
+innodb_rwlock_x_os_waits server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of OS waits due to exclusive latch request
+innodb_rwlock_sx_os_waits server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of OS waits due to sx latch request
+dml_reads dml 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of rows read
+dml_inserts dml 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of rows inserted
+dml_deletes dml 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of rows deleted
+dml_updates dml 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of rows updated
+dml_system_reads dml 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of system rows read
+dml_system_inserts dml 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of system rows inserted
+dml_system_deletes dml 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of system rows deleted
+dml_system_updates dml 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of system rows updated
+ddl_background_drop_indexes ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of indexes waiting to be dropped after failed index creation
+ddl_background_drop_tables ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of tables in background drop table list
+ddl_online_create_index ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of indexes being created online
+ddl_pending_alter_table ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of ALTER TABLE, CREATE INDEX, DROP INDEX in progress
+ddl_sort_file_alter_table ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of sort files created during alter table
+ddl_log_file_alter_table ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of log files created during alter table
+icp_attempts icp 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of attempts for index push-down condition checks
+icp_no_match icp 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Index push-down condition does not match
+icp_out_of_range icp 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Index push-down condition out of range
+icp_match icp 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Index push-down condition matches
+SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DEFAULT_STOPWORD;
+value
+a
+about
+an
+are
+as
+at
+be
+by
+com
+de
+en
+for
+from
+how
+i
+in
+is
+it
+la
+of
+on
+or
+that
+the
+this
+to
+was
+what
+when
+where
+who
+will
+with
+und
+the
+www
+SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DELETED;
+DOC_ID
+SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED;
+DOC_ID
+SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE;
+WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION
+SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE;
+WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION
+SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_CONFIG;
+KEY VALUE
+SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS;
+POOL_ID POOL_SIZE FREE_BUFFERS DATABASE_PAGES OLD_DATABASE_PAGES MODIFIED_DATABASE_PAGES PENDING_DECOMPRESS PENDING_READS PENDING_FLUSH_LRU PENDING_FLUSH_LIST PAGES_MADE_YOUNG PAGES_NOT_MADE_YOUNG PAGES_MADE_YOUNG_RATE PAGES_MADE_NOT_YOUNG_RATE NUMBER_PAGES_READ NUMBER_PAGES_CREATED NUMBER_PAGES_WRITTEN PAGES_READ_RATE PAGES_CREATE_RATE PAGES_WRITTEN_RATE NUMBER_PAGES_GET HIT_RATE YOUNG_MAKE_PER_THOUSAND_GETS NOT_YOUNG_MAKE_PER_THOUSAND_GETS NUMBER_PAGES_READ_AHEAD NUMBER_READ_AHEAD_EVICTED READ_AHEAD_RATE READ_AHEAD_EVICTED_RATE LRU_IO_TOTAL LRU_IO_CURRENT UNCOMPRESS_TOTAL UNCOMPRESS_CURRENT
+SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE;
+POOL_ID BLOCK_ID SPACE PAGE_NUMBER PAGE_TYPE FLUSH_TYPE FIX_COUNT IS_HASHED NEWEST_MODIFICATION OLDEST_MODIFICATION ACCESS_TIME TABLE_NAME INDEX_NAME NUMBER_RECORDS DATA_SIZE COMPRESSED_SIZE PAGE_STATE IO_FIX IS_OLD FREE_PAGE_CLOCK
+SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE_LRU;
+POOL_ID LRU_POSITION SPACE PAGE_NUMBER PAGE_TYPE FLUSH_TYPE FIX_COUNT IS_HASHED NEWEST_MODIFICATION OLDEST_MODIFICATION ACCESS_TIME TABLE_NAME INDEX_NAME NUMBER_RECORDS DATA_SIZE COMPRESSED_SIZE COMPRESSED IO_FIX IS_OLD FREE_PAGE_CLOCK
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES;
+TABLE_ID NAME FLAG N_COLS SPACE ROW_FORMAT ZIP_PAGE_SIZE SPACE_TYPE
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS;
+TABLE_ID NAME STATS_INITIALIZED NUM_ROWS CLUST_INDEX_SIZE OTHER_INDEX_SIZE MODIFIED_COUNTER AUTOINC REF_COUNT
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES;
+INDEX_ID NAME TABLE_ID TYPE N_FIELDS PAGE_NO SPACE MERGE_THRESHOLD
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS;
+TABLE_ID NAME POS MTYPE PRTYPE LEN
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS;
+INDEX_ID NAME POS
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
+ID FOR_NAME REF_NAME N_COLS TYPE
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
+ID FOR_COL_NAME REF_COL_NAME POS
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES;
+SPACE NAME FLAG ROW_FORMAT PAGE_SIZE ZIP_PAGE_SIZE FS_BLOCK_SIZE FILE_SIZE ALLOCATED_SIZE
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_DATAFILES;
+SPACE PATH
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/insert.result b/storage/rocksdb/mysql-test/rocksdb/r/insert.result
new file mode 100644
index 00000000..a1fb3ae9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/insert.result
@@ -0,0 +1,202 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (100,'foobar',100),(1,'a',101),(2,'b',103),(3,'c',104),(4,'d',105),(5,'e',106);
+SELECT a,b FROM t1;
+a b
+1 a
+100 foobar
+2 b
+3 c
+4 d
+5 e
+INSERT t1 VALUE (10,'foo',107),(11,'abc',108);
+SELECT a,b FROM t1;
+a b
+1 a
+10 foo
+100 foobar
+11 abc
+2 b
+3 c
+4 d
+5 e
+INSERT INTO t1 (b,a) VALUES ('test',0);
+SELECT a,b FROM t1;
+a b
+0 test
+1 a
+10 foo
+100 foobar
+11 abc
+2 b
+3 c
+4 d
+5 e
+INSERT INTO t1 VALUES (DEFAULT,DEFAULT,NULL);
+SELECT a,b FROM t1;
+a b
+0 test
+1 a
+10 foo
+100 foobar
+11 abc
+2 b
+3 c
+4 d
+5 e
+NULL NULL
+INSERT t1 (a) VALUE (10),(20);
+SELECT a,b FROM t1;
+a b
+0 test
+1 a
+10 NULL
+10 foo
+100 foobar
+11 abc
+2 b
+20 NULL
+3 c
+4 d
+5 e
+NULL NULL
+INSERT INTO t1 SET a = 11, b = 'f';
+SELECT a,b FROM t1;
+a b
+0 test
+1 a
+10 NULL
+10 foo
+100 foobar
+11 abc
+11 f
+2 b
+20 NULL
+3 c
+4 d
+5 e
+NULL NULL
+INSERT t1 SET b = DEFAULT;
+SELECT a,b FROM t1;
+a b
+0 test
+1 a
+10 NULL
+10 foo
+100 foobar
+11 abc
+11 f
+2 b
+20 NULL
+3 c
+4 d
+5 e
+NULL NULL
+NULL NULL
+CREATE TABLE t2 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 SELECT a,b,pk FROM t1;
+INSERT INTO t1 (a) SELECT a FROM t2 WHERE b = 'foo';
+SELECT a,b FROM t1;
+a b
+0 test
+1 a
+10 NULL
+10 NULL
+10 foo
+100 foobar
+11 abc
+11 f
+2 b
+20 NULL
+3 c
+4 d
+5 e
+NULL NULL
+NULL NULL
+INSERT t1 (a,b) SELECT a,b FROM t1;
+SELECT a,b FROM t1;
+a b
+0 test
+0 test
+1 a
+1 a
+10 NULL
+10 NULL
+10 NULL
+10 NULL
+10 foo
+10 foo
+100 foobar
+100 foobar
+11 abc
+11 abc
+11 f
+11 f
+2 b
+2 b
+20 NULL
+20 NULL
+3 c
+3 c
+4 d
+4 d
+5 e
+5 e
+NULL NULL
+NULL NULL
+NULL NULL
+NULL NULL
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+BEGIN;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(100,'foo');
+INSERT t1 (a,b) VALUE (10,'foo'),(11,'abc');
+COMMIT;
+SELECT a,b FROM t1;
+a b
+1 a
+10 foo
+100 foo
+11 abc
+2 b
+3 c
+4 d
+5 e
+BEGIN;
+INSERT INTO t1 (b,a) VALUES ('test',0);
+SAVEPOINT spt1;
+INSERT INTO t1 (a,b) VALUES (DEFAULT,DEFAULT);
+RELEASE SAVEPOINT spt1;
+INSERT INTO t1 (a,b) VALUES (DEFAULT,DEFAULT);
+ROLLBACK;
+SELECT a,b FROM t1;
+a b
+1 a
+10 foo
+100 foo
+11 abc
+2 b
+3 c
+4 d
+5 e
+BEGIN;
+INSERT t1 (a) VALUE (10),(20);
+SAVEPOINT spt1;
+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);
+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 foo
+100 foo
+11 abc
+2 b
+3 c
+4 d
+5 e
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/insert_optimized_config.result b/storage/rocksdb/mysql-test/rocksdb/r/insert_optimized_config.result
new file mode 100644
index 00000000..ded48057
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/insert_optimized_config.result
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS t1;
+create table t1(
+id bigint not null primary key,
+i1 bigint, #unique
+i2 bigint, #repeating
+c1 varchar(20), #unique
+c2 varchar(20), #repeating
+index t1_2(i1)
+) engine=rocksdb;
+select count(*), sum(id), sum(i1), sum(i2) from t1;
+count(*) sum(id) sum(i1) sum(i2)
+50000 1250025000 1250025000 124980000
+select count(*), sum(id), sum(i1), sum(i2) from t1;
+count(*) sum(id) sum(i1) sum(i2)
+50000 1250025000 1250025000 124980000
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/insert_with_keys.result b/storage/rocksdb/mysql-test/rocksdb/r/insert_with_keys.result
new file mode 100644
index 00000000..6d4139ca
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/insert_with_keys.result
@@ -0,0 +1,262 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, KEY(b)) ENGINE=rocksdb;
+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');
+INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
+SELECT a,b FROM t1;
+a b
+0
+1 a
+1 a
+100 a
+12345 z
+2 b
+29 n
+3 a
+3 c
+30 m
+4 d
+5 e
+6 f
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, UNIQUE INDEX(a)) ENGINE=rocksdb;
+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'
+INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
+ERROR 23000: Duplicate entry '3' for key 'a'
+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;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, UNIQUE INDEX(a,b)) ENGINE=rocksdb;
+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'
+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'
+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
+DROP TABLE t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+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 'PRIMARY'
+INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
+ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
+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 'PRIMARY'
+INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z') ON DUPLICATE KEY UPDATE b = CONCAT(b,b);
+SELECT a,b FROM t1;
+a b
+0
+1 aa
+100 a
+12345 zz
+2 b
+29 n
+3 c
+30 m
+4 d
+5 e
+6 f
+DROP TABLE t1;
+
+INSERT on DUPLICATE KEY UPDATE with multiple keys
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(255)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (3,'a'), (4,'a'), (5,'a'), (6,'a'), (7,'a'), (8,'a'), (9,'a'), (10,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (3,'a'), (4,'a'), (5,'a'), (6,'a'), (7,'a'), (8,'a'), (9,'a'), (10,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+SELECT a,b FROM t1;
+a b
+1 aaaaaaaaaaaaaaaaaa
+10 aa
+2 aaaaaaa
+3 aa
+4 aa
+5 aa
+6 aa
+7 aa
+8 aa
+9 aa
+DROP TABLE t1;
+
+INSERT on DUPLICATE KEY UPDATE with secondary key
+
+CREATE TABLE t1 (a INT, b CHAR(8), c INT DEFAULT 0, pk INT AUTO_INCREMENT PRIMARY KEY, UNIQUE INDEX(a,b)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d'), (5,'e'), (6,'f'), (7,'g'), (8,'h'), (9,'i'), (10,'j') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d'), (5,'e'), (6,'f'), (7,'g'), (8,'h'), (9,'i'), (10,'j') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c') ON DUPLICATE KEY UPDATE c = c + 1;
+SELECT a,b,c,pk FROM t1;
+a b c pk
+1 a 22 1
+10 j 1 11
+2 b 6 3
+2 c 4 14
+3 c 1 4
+4 d 1 5
+5 e 1 6
+6 f 1 7
+7 g 1 8
+8 h 1 9
+9 i 1 10
+DROP TABLE t1;
+
+Disable caching and see if it still functions properly
+
+SELECT @@rocksdb_enable_insert_with_update_caching;
+@@rocksdb_enable_insert_with_update_caching
+1
+SET GLOBAL rocksdb_enable_insert_with_update_caching=0;
+SELECT @@rocksdb_enable_insert_with_update_caching;
+@@rocksdb_enable_insert_with_update_caching
+0
+
+INSERT on DUPLICATE KEY UPDATE with multiple keys
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(255)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (3,'a'), (4,'a'), (5,'a'), (6,'a'), (7,'a'), (8,'a'), (9,'a'), (10,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (3,'a'), (4,'a'), (5,'a'), (6,'a'), (7,'a'), (8,'a'), (9,'a'), (10,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+SELECT a,b FROM t1;
+a b
+1 aaaaaaaaaaaaaaaaaa
+10 aa
+2 aaaaaaa
+3 aa
+4 aa
+5 aa
+6 aa
+7 aa
+8 aa
+9 aa
+DROP TABLE t1;
+
+INSERT on DUPLICATE KEY UPDATE with secondary key
+
+CREATE TABLE t1 (a INT, b CHAR(8), c INT DEFAULT 0, pk INT AUTO_INCREMENT PRIMARY KEY, UNIQUE INDEX(a,b)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d'), (5,'e'), (6,'f'), (7,'g'), (8,'h'), (9,'i'), (10,'j') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d'), (5,'e'), (6,'f'), (7,'g'), (8,'h'), (9,'i'), (10,'j') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c') ON DUPLICATE KEY UPDATE c = c + 1;
+SELECT a,b,c,pk FROM t1;
+a b c pk
+1 a 22 1
+10 j 1 11
+2 b 6 3
+2 c 4 14
+3 c 1 4
+4 d 1 5
+5 e 1 6
+6 f 1 7
+7 g 1 8
+8 h 1 9
+9 i 1 10
+DROP TABLE t1;
+
+Cleanup
+
+SET GLOBAL rocksdb_enable_insert_with_update_caching=1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/issue100.result b/storage/rocksdb/mysql-test/rocksdb/r/issue100.result
new file mode 100644
index 00000000..ee73ac3e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/issue100.result
@@ -0,0 +1,23 @@
+create table t1 (
+id int,
+value int,
+primary key (id)
+) engine=rocksdb;
+insert into t1 values(1,1),(2,2);
+set autocommit=0;
+begin;
+insert into t1 values (50,50);
+select * from t1;
+id value
+1 1
+2 2
+50 50
+update t1 set id=id+100;
+select * from t1;
+id value
+101 1
+102 2
+150 50
+rollback;
+set autocommit=1;
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/issue100_delete.result b/storage/rocksdb/mysql-test/rocksdb/r/issue100_delete.result
new file mode 100644
index 00000000..9e55ebd0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/issue100_delete.result
@@ -0,0 +1,17 @@
+create table ten(a int primary key);
+insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table one_k(a int primary key);
+insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;
+create table t100(pk int primary key, a int, b int, key(a));
+insert into t100 select a,a,a from test.one_k;
+set global rocksdb_force_flush_memtable_now=1;
+select num_rows, entry_deletes, entry_singledeletes from information_schema.rocksdb_index_file_map where index_number = (select max(index_number) from information_schema.rocksdb_index_file_map) order by entry_deletes, entry_singledeletes;
+num_rows entry_deletes entry_singledeletes
+1000 0 0
+update t100 set a=a+1;
+set global rocksdb_force_flush_memtable_now=1;
+select num_rows, entry_deletes, entry_singledeletes from information_schema.rocksdb_index_file_map where index_number = (select max(index_number) from information_schema.rocksdb_index_file_map) order by entry_deletes, entry_singledeletes;
+num_rows entry_deletes entry_singledeletes
+1000 0 0
+1000 0 1000
+drop table ten, t100, one_k;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/issue111.result b/storage/rocksdb/mysql-test/rocksdb/r/issue111.result
new file mode 100644
index 00000000..796a637e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/issue111.result
@@ -0,0 +1,37 @@
+connect con2,localhost,root,,;
+connection default;
+create table t1 (
+pk int not null primary key,
+col1 int not null,
+col2 int not null,
+key(col1)
+) engine=rocksdb;
+create table ten(a int primary key);
+insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table one_k(a int primary key);
+insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;
+insert into t1 select a,a,a from one_k;
+# Start the transaction, get the snapshot
+begin;
+select * from t1 where col1<10;
+pk col1 col2
+0 0 0
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+8 8 8
+9 9 9
+# Connect with another connection and make a conflicting change
+connection con2;
+begin;
+update t1 set col2=123456 where pk=0;
+commit;
+connection default;
+update t1 set col2=col2+1 where col1 < 10 limit 5;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+disconnect con2;
+drop table t1, ten, one_k;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/issue243_transactionStatus.result b/storage/rocksdb/mysql-test/rocksdb/r/issue243_transactionStatus.result
new file mode 100644
index 00000000..d4d211b9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/issue243_transactionStatus.result
@@ -0,0 +1,161 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+id INT,
+val1 INT,
+val2 INT,
+PRIMARY KEY (id)
+) ENGINE=rocksdb;
+INSERT INTO t1 VALUES(1,1,1),(2,1,2);
+SELECT * FROM t1;
+id val1 val2
+1 1 1
+2 1 2
+UPDATE t1 SET val1=2 WHERE id=2;
+SELECT * FROM t1;
+id val1 val2
+1 1 1
+2 2 2
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+----------LATEST DETECTED DEADLOCKS----------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+SET AUTOCOMMIT=0;
+START TRANSACTION;
+INSERT INTO t1 VALUES(20,1,1),(30,30,30);
+SELECT * FROM t1;
+id val1 val2
+1 1 1
+2 2 2
+20 1 1
+30 30 30
+UPDATE t1 SET val1=20, val2=20 WHERE id=20;
+SELECT * FROM t1;
+id val1 val2
+1 1 1
+2 2 2
+20 20 20
+30 30 30
+DELETE FROM t1 WHERE id=30;
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+---SNAPSHOT, ACTIVE NUM sec
+MySQL thread id TID, OS thread handle PTR, query id QID localhost root ACTION
+SHOW ENGINE rocksdb TRANSACTION STATUS
+lock count 8, write count 4
+insert count 2, update count 1, delete count 1
+----------LATEST DETECTED DEADLOCKS----------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+ROLLBACK;
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+----------LATEST DETECTED DEADLOCKS----------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+START TRANSACTION;
+INSERT INTO t1 VALUES(40,40,40);
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+---SNAPSHOT, ACTIVE NUM sec
+MySQL thread id TID, OS thread handle PTR, query id QID localhost root ACTION
+SHOW ENGINE rocksdb TRANSACTION STATUS
+lock count 2, write count 1
+insert count 1, update count 0, delete count 0
+----------LATEST DETECTED DEADLOCKS----------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+COMMIT;
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+----------LATEST DETECTED DEADLOCKS----------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+SET AUTOCOMMIT=1;
+DROP TABLE t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t2 (
+id1 INT,
+id2 INT,
+value INT,
+PRIMARY KEY (id1),
+KEY (id2)
+) ENGINE=rocksdb;
+SET AUTOCOMMIT=0;
+START TRANSACTION;
+INSERT INTO t2 VALUES(1,2,0),(10,20,30);
+UPDATE t2 SET value=3 WHERE id2=2;
+DELETE FROM t2 WHERE id1=10;
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+---SNAPSHOT, ACTIVE NUM sec
+MySQL thread id TID, OS thread handle PTR, query id QID localhost root ACTION
+SHOW ENGINE rocksdb TRANSACTION STATUS
+lock count 9, write count 7
+insert count 2, update count 1, delete count 1
+----------LATEST DETECTED DEADLOCKS----------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+ROLLBACK;
+SET AUTOCOMMIT=1;
+DROP TABLE t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/issue255.result b/storage/rocksdb/mysql-test/rocksdb/r/issue255.result
new file mode 100644
index 00000000..840699dd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/issue255.result
@@ -0,0 +1,68 @@
+CREATE TABLE t1 (pk BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT);
+INSERT INTO t1 VALUES (5);
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB # Fixed # # # # # # 6 # # NULL latin1_swedish_ci NULL 0 N
+INSERT INTO t1 VALUES ('538647864786478647864');
+Warnings:
+Warning 1264 Out of range value for column 'pk' at row 1
+SELECT * FROM t1;
+pk
+5
+9223372036854775807
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 2 22 44 0 0 0 9223372036854775807 # # NULL latin1_swedish_ci NULL 0 N
+INSERT INTO t1 VALUES ();
+ERROR 23000: Duplicate entry '9223372036854775807' for key 'PRIMARY'
+SELECT * FROM t1;
+pk
+5
+9223372036854775807
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 # # NULL latin1_swedish_ci NULL 0 N
+INSERT INTO t1 VALUES ();
+ERROR 23000: Duplicate entry '9223372036854775807' for key 'PRIMARY'
+SELECT * FROM t1;
+pk
+5
+9223372036854775807
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 # # NULL latin1_swedish_ci NULL 0 N
+DROP TABLE t1;
+CREATE TABLE t1 (pk TINYINT NOT NULL PRIMARY KEY AUTO_INCREMENT);
+INSERT INTO t1 VALUES (5);
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB # Fixed # # # # # # 6 # # NULL latin1_swedish_ci NULL 0 N
+INSERT INTO t1 VALUES (1000);
+Warnings:
+Warning 1264 Out of range value for column 'pk' at row 1
+SELECT * FROM t1;
+pk
+5
+127
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB # Fixed # # # # # # 127 # # NULL latin1_swedish_ci NULL 0 N
+INSERT INTO t1 VALUES ();
+ERROR 23000: Duplicate entry '127' for key 'PRIMARY'
+SELECT * FROM t1;
+pk
+5
+127
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB # Fixed # # # # # # 127 # # NULL latin1_swedish_ci NULL 0 N
+INSERT INTO t1 VALUES ();
+ERROR 23000: Duplicate entry '127' for key 'PRIMARY'
+SELECT * FROM t1;
+pk
+5
+127
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB # Fixed # # # # # # 127 # # NULL latin1_swedish_ci NULL 0 N
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/issue290.result b/storage/rocksdb/mysql-test/rocksdb/r/issue290.result
new file mode 100644
index 00000000..1a83a93b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/issue290.result
@@ -0,0 +1,28 @@
+CREATE TABLE `linktable` (
+`id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+`visibility` tinyint(3) NOT NULL DEFAULT '0',
+`data` varchar(255) NOT NULL DEFAULT '',
+`time` bigint(20) unsigned NOT NULL DEFAULT '0',
+`version` int(11) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (link_type, `id1`,`id2`) COMMENT 'cf_link_pk',
+KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`id2`,`version`,`data`) COMMENT 'rev:cf_link_id1_type'
+) ENGINE=RocksDB DEFAULT COLLATE=latin1_bin;
+set global rocksdb_force_flush_memtable_now=1;
+insert into linktable (id1, link_type, id2) values (2, 1, 1);
+insert into linktable (id1, link_type, id2) values (2, 1, 2);
+insert into linktable (id1, link_type, id2) values (2, 1, 3);
+insert into linktable (id1, link_type, id2) values (2, 1, 4);
+insert into linktable (id1, link_type, id2) values (2, 1, 5);
+insert into linktable (id1, link_type, id2) values (2, 1, 6);
+insert into linktable (id1, link_type, id2) values (2, 1, 7);
+insert into linktable (id1, link_type, id2) values (2, 1, 8);
+insert into linktable (id1, link_type, id2) values (2, 1, 9);
+insert into linktable (id1, link_type, id2) values (2, 1, 10);
+explain select id1, id2, link_type, data from linktable force index(primary) where id1=2 and link_type=1 and (id2=1 or id2=2 or id2=3 or id2=4 or id2=5);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE linktable range PRIMARY PRIMARY 24 NULL # Using where
+drop table linktable;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/issue314.result b/storage/rocksdb/mysql-test/rocksdb/r/issue314.result
new file mode 100644
index 00000000..eee90800
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/issue314.result
@@ -0,0 +1,12 @@
+drop table if exists t1;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+CREATE TABLE t1(a int);
+SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
+INSERT INTO t1 VALUES(1);
+select * from t1;
+ERROR HY000: MyRocks supports only READ COMMITTED and REPEATABLE READ isolation levels. Please change from current isolation level SERIALIZABLE
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+select * from t1;
+a
+1
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/issue495.result b/storage/rocksdb/mysql-test/rocksdb/r/issue495.result
new file mode 100644
index 00000000..c7ac34c6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/issue495.result
@@ -0,0 +1,30 @@
+drop table if exists t;
+create table t (
+a int,
+b int,
+c varchar(12249) collate latin1_bin,
+d datetime,
+e int,
+f int,
+g blob,
+h int,
+i int,
+key (b,e),
+key (h,b)
+) engine=rocksdb
+partition by linear hash (i) partitions 8 ;
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+select i from t group by h;
+i
+1
+select i from t group by h;
+i
+1
+drop table t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/issue884.result b/storage/rocksdb/mysql-test/rocksdb/r/issue884.result
new file mode 100644
index 00000000..60c96745
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/issue884.result
@@ -0,0 +1,80 @@
+create table test (
+a bigint(20) not null,
+b bigint(20) not null,
+c varchar(500) not null,
+d bigint(20) not null,
+e bigint(20) not null,
+f varchar(500) not null,
+g varchar(500) not null,
+h varchar(500) not null,
+i varchar(1000) not null,
+j varchar(16384) not null,
+k varchar(200) not null,
+l varchar(500) not null,
+m varchar(100) not null,
+n bigint(20) not null,
+primary key (a, b, m, c(100), l(100), d, e, f(100), g(100), h(100), n),
+key n (n),
+key d (d, a)
+) engine = rocksdb default charset = latin1;
+Table Op Msg_type Msg_text
+test.test analyze status Engine-independent statistics collected
+test.test analyze status OK
+explain
+select * from test where d = 10 and a = 10 and b = 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE test index_merge PRIMARY,d d,PRIMARY 24,16 NULL # Using intersect(d,PRIMARY); Using where
+select * from test where d = 10 and a = 10 and b = 2;
+a b c d e f g h i j k l m n
+10 2 i 10 950 f g h i j k l m 950
+10 2 i 10 951 f g h i j k l m 951
+10 2 i 10 952 f g h i j k l m 952
+10 2 i 10 953 f g h i j k l m 953
+10 2 i 10 954 f g h i j k l m 954
+10 2 i 10 955 f g h i j k l m 955
+10 2 i 10 956 f g h i j k l m 956
+10 2 i 10 957 f g h i j k l m 957
+10 2 i 10 958 f g h i j k l m 958
+10 2 i 10 959 f g h i j k l m 959
+10 2 i 10 960 f g h i j k l m 960
+10 2 i 10 961 f g h i j k l m 961
+10 2 i 10 962 f g h i j k l m 962
+10 2 i 10 963 f g h i j k l m 963
+10 2 i 10 964 f g h i j k l m 964
+10 2 i 10 965 f g h i j k l m 965
+10 2 i 10 966 f g h i j k l m 966
+10 2 i 10 967 f g h i j k l m 967
+10 2 i 10 968 f g h i j k l m 968
+10 2 i 10 969 f g h i j k l m 969
+10 2 i 10 970 f g h i j k l m 970
+10 2 i 10 971 f g h i j k l m 971
+10 2 i 10 972 f g h i j k l m 972
+10 2 i 10 973 f g h i j k l m 973
+10 2 i 10 974 f g h i j k l m 974
+10 2 i 10 975 f g h i j k l m 975
+10 2 i 10 976 f g h i j k l m 976
+10 2 i 10 977 f g h i j k l m 977
+10 2 i 10 978 f g h i j k l m 978
+10 2 i 10 979 f g h i j k l m 979
+10 2 i 10 980 f g h i j k l m 980
+10 2 i 10 981 f g h i j k l m 981
+10 2 i 10 982 f g h i j k l m 982
+10 2 i 10 983 f g h i j k l m 983
+10 2 i 10 984 f g h i j k l m 984
+10 2 i 10 985 f g h i j k l m 985
+10 2 i 10 986 f g h i j k l m 986
+10 2 i 10 987 f g h i j k l m 987
+10 2 i 10 988 f g h i j k l m 988
+10 2 i 10 989 f g h i j k l m 989
+10 2 i 10 990 f g h i j k l m 990
+10 2 i 10 991 f g h i j k l m 991
+10 2 i 10 992 f g h i j k l m 992
+10 2 i 10 993 f g h i j k l m 993
+10 2 i 10 994 f g h i j k l m 994
+10 2 i 10 995 f g h i j k l m 995
+10 2 i 10 996 f g h i j k l m 996
+10 2 i 10 997 f g h i j k l m 997
+10 2 i 10 998 f g h i j k l m 998
+10 2 i 10 999 f g h i j k l m 999
+10 2 i 10 1000 f g h i j k l m 1000
+drop table test;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/issue896.result b/storage/rocksdb/mysql-test/rocksdb/r/issue896.result
new file mode 100644
index 00000000..6b742eba
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/issue896.result
@@ -0,0 +1,17 @@
+CREATE TABLE `t1` (
+`a` bigint(20) NOT NULL,
+`b` varchar(10) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+`u` bigint(20) unsigned NOT NULL,
+`d` bigint(20) DEFAULT NULL,
+PRIMARY KEY (`a`,`b`),
+KEY `d` (`d`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='ttl_duration=1000;ttl_col=u';
+INSERT INTO t1 VALUES (100, 'aaabbb', UNIX_TIMESTAMP(), 200);
+EXPLAIN SELECT COUNT(*) FROM t1 FORCE INDEX(d);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL d 9 NULL # Using index
+# segfault here without the fix
+SELECT COUNT(*) FROM t1 FORCE INDEX(d);
+COUNT(*)
+1
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/issue900.result b/storage/rocksdb/mysql-test/rocksdb/r/issue900.result
new file mode 100644
index 00000000..062d0da0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/issue900.result
@@ -0,0 +1,11 @@
+CREATE TABLE t1(c1 VARCHAR(1) CHARACTER SET 'utf8' COLLATE 'utf8_bin', c2 YEAR, c3 REAL(1,0) UNSIGNED, PRIMARY KEY(c1)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES(0,'0','0');
+INSERT INTO t1 VALUES('{0}','0','0');
+Warnings:
+Warning 1265 Data truncated for column 'c1' at row 1
+INSERT INTO t1 VALUES('1','0','1');
+ALTER TABLE t1 ADD INDEX(c3), ADD UNIQUE (c3);
+ERROR 23000: Duplicate entry '0' for key 'c3_2'
+SELECT c3 FROM t1 FORCE INDEX(c3) ORDER BY c3;
+ERROR 42000: Key 'c3' doesn't exist in table 't1'
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/iterator_bounds.result b/storage/rocksdb/mysql-test/rocksdb/r/iterator_bounds.result
new file mode 100644
index 00000000..600f19e0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/iterator_bounds.result
@@ -0,0 +1,15 @@
+create table t (i int primary key) engine=rocksdb;
+drop table t;
+create table t (i int primary key, j int, key(j) comment 'rev:bf5_2') engine=rocksdb;
+select RIGHT(HEX(index_number), 2) from information_schema.rocksdb_ddl where table_name = 't';
+RIGHT(HEX(index_number), 2)
+FE
+FF
+insert into t values (1, 1);
+select j from t order by j asc;
+j
+1
+select j from t order by j desc;
+j
+1
+drop table t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/kill.result b/storage/rocksdb/mysql-test/rocksdb/r/kill.result
new file mode 100644
index 00000000..19614e1f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/kill.result
@@ -0,0 +1,6 @@
+CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=RocksDB;
+LOCK TABLE t1 WRITE;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+FLUSH TABLES;
+ERROR HY000: MyRocks supports only READ COMMITTED and REPEATABLE READ isolation levels. Please change from current isolation level SERIALIZABLE
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/level_read_committed.result b/storage/rocksdb/mysql-test/rocksdb/r/level_read_committed.result
new file mode 100644
index 00000000..b68b37cf
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/level_read_committed.result
@@ -0,0 +1,111 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+connect con2,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+connection con1;
+CREATE TABLE t1 (a INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+START TRANSACTION;
+SELECT a FROM t1;
+a
+connection con2;
+BEGIN;
+INSERT INTO t1 (a) VALUES(1);
+connection con1;
+SELECT a FROM t1;
+a
+connection con2;
+INSERT INTO t1 (a) VALUES (2);
+connection con1;
+SELECT a FROM t1;
+a
+INSERT INTO t1 (a) SELECT a+100 FROM t1;
+SELECT a FROM t1;
+a
+connection con2;
+SELECT a FROM t1;
+a
+1
+2
+COMMIT;
+SELECT a FROM t1;
+a
+1
+2
+connection con1;
+SELECT a FROM t1;
+a
+1
+2
+INSERT INTO t1 (a) SELECT a+200 FROM t1;
+SELECT a FROM t1;
+a
+1
+2
+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;
+CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (a) VALUES (1);
+COMMIT;
+connection con1;
+BEGIN;
+SELECT a from t2;
+a
+1
+INSERT INTO t2 (a) VALUES (1), (3);
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+connection con2;
+INSERT INTO t2 (a) VALUES (2);
+COMMIT;
+connection con1;
+SELECT a from t2;
+a
+1
+2
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+DROP TABLE t2;
+CREATE TABLE t3 (
+pk int unsigned PRIMARY KEY,
+count int unsigned DEFAULT '0'
+) ENGINE=ROCKSDB;
+connect con1,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+connect con2,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+connection con1;
+BEGIN;
+SELECT * FROM t3;
+pk count
+connection con2;
+BEGIN;
+INSERT INTO t3 (pk) VALUES(1) ON DUPLICATE KEY UPDATE count=count+1;
+COMMIT;
+connection con1;
+INSERT INTO t3 (pk) VALUES(1) ON DUPLICATE KEY UPDATE count=count+1;
+COMMIT;
+SELECT count FROM t3;
+count
+1
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/level_read_uncommitted.result b/storage/rocksdb/mysql-test/rocksdb/r/level_read_uncommitted.result
new file mode 100644
index 00000000..68fbe563
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/level_read_uncommitted.result
@@ -0,0 +1,116 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+connect con2,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+connection con1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+START TRANSACTION;
+SELECT a FROM t1;
+a
+connection con2;
+BEGIN;
+INSERT INTO t1 (a) VALUES(1);
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+connection con1;
+SELECT a FROM t1;
+a
+1
+connection con2;
+INSERT INTO t1 (a) VALUES (2);
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+connection con1;
+SELECT a FROM t1;
+a
+1
+2
+INSERT INTO t1 (a) SELECT a+100 FROM t1;
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+SELECT a FROM t1;
+a
+1
+101
+102
+2
+connection con2;
+SELECT a FROM t1;
+a
+1
+101
+102
+2
+COMMIT;
+SELECT a FROM t1;
+a
+1
+101
+102
+2
+connection con1;
+SELECT a FROM t1;
+a
+1
+101
+102
+2
+INSERT INTO t1 (a) SELECT a+200 FROM t1;
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+SELECT a FROM t1;
+a
+1
+101
+102
+2
+201
+202
+301
+302
+COMMIT;
+SELECT a FROM t1;
+a
+1
+101
+102
+2
+201
+202
+301
+302
+connection con2;
+SELECT a FROM t1;
+a
+1
+101
+102
+2
+201
+202
+301
+302
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connection con2;
+INSERT INTO t1 (a) VALUES (1);
+connection con1;
+# If consistent read works on this isolation level (READ UNCOMMITTED), the following SELECT should not return the value we inserted (1)
+SELECT a FROM t1;
+a
+1
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/level_repeatable_read.result b/storage/rocksdb/mysql-test/rocksdb/r/level_repeatable_read.result
new file mode 100644
index 00000000..13da8a0f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/level_repeatable_read.result
@@ -0,0 +1,100 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+connect con2,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+connection con1;
+CREATE TABLE t1 (a INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+START TRANSACTION;
+SELECT a FROM t1;
+a
+connection con2;
+BEGIN;
+INSERT INTO t1 (a) VALUES(1);
+connection con1;
+SELECT a FROM t1;
+a
+connection con2;
+INSERT INTO t1 (a) VALUES (2);
+connection con1;
+SELECT a FROM t1;
+a
+INSERT INTO t1 (a) SELECT a+100 FROM t1;
+SELECT a FROM t1;
+a
+connection con2;
+SELECT a FROM t1;
+a
+1
+2
+COMMIT;
+SELECT a FROM t1;
+a
+1
+2
+connection con1;
+SELECT a FROM t1;
+a
+INSERT INTO t1 (a) SELECT a+200 FROM t1;
+SELECT a FROM t1;
+a
+COMMIT;
+SELECT a FROM t1;
+a
+1
+2
+connection con2;
+SELECT a FROM t1;
+a
+1
+2
+connection default;
+CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (a) VALUES (1);
+COMMIT;
+connection con1;
+BEGIN;
+SELECT a from t2;
+a
+1
+INSERT INTO t2 (a) VALUES (1), (3);
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+connection con2;
+INSERT INTO t2 (a) VALUES (2);
+COMMIT;
+connection con1;
+SELECT a from t2;
+a
+1
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+DROP TABLE t2;
+CREATE TABLE t3 (
+pk int unsigned PRIMARY KEY,
+count int unsigned DEFAULT '0'
+) ENGINE=ROCKSDB;
+connect con1,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+connect con2,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+connection con1;
+BEGIN;
+SELECT * FROM t3;
+pk count
+connection con2;
+BEGIN;
+INSERT INTO t3 (pk) VALUES(1) ON DUPLICATE KEY UPDATE count=count+1;
+COMMIT;
+connection con1;
+INSERT INTO t3 (pk) VALUES(1) ON DUPLICATE KEY UPDATE count=count+1;
+COMMIT;
+SELECT count FROM t3;
+count
+0
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/level_serializable.result b/storage/rocksdb/mysql-test/rocksdb/r/level_serializable.result
new file mode 100644
index 00000000..3f57395f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/level_serializable.result
@@ -0,0 +1,56 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+connect con2,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+connection con1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+START TRANSACTION;
+SELECT a FROM t1;
+a
+connection con2;
+BEGIN;
+INSERT INTO t1 (a) VALUES(1);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# WARNING: Statement ended with errno 1205, errname 'ER_LOCK_WAIT_TIMEOUT'.
+# If it differs from the result file, it might indicate a problem.
+connection con1;
+SELECT a FROM t1;
+a
+connection con2;
+INSERT INTO t1 (a) VALUES (2);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# WARNING: Statement ended with errno 1205, errname 'ER_LOCK_WAIT_TIMEOUT'.
+# If it differs from the result file, it might indicate a problem.
+connection con1;
+SELECT a FROM t1;
+a
+INSERT INTO t1 (a) SELECT a+100 FROM t1;
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+SELECT a FROM t1;
+a
+connection con2;
+SELECT a FROM t1;
+a
+COMMIT;
+SELECT a FROM t1;
+a
+connection con1;
+SELECT a FROM t1;
+a
+INSERT INTO t1 (a) SELECT a+200 FROM t1;
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+SELECT a FROM t1;
+a
+COMMIT;
+SELECT a FROM t1;
+a
+connection con2;
+SELECT a FROM t1;
+a
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/loaddata.result b/storage/rocksdb/mysql-test/rocksdb/r/loaddata.result
new file mode 100644
index 00000000..a9f9c0b4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/loaddata.result
@@ -0,0 +1,239 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+LOAD DATA INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
+FIELDS TERMINATED BY ',' (a,b);
+SELECT a,b FROM t1;
+a b
+1 foo
+2 bar
+3
+4 abc
+LOAD DATA LOCAL INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
+CHARACTER SET utf8 COLUMNS TERMINATED BY ','
+ ESCAPED BY '/' (a,b);
+SELECT a,b FROM t1;
+a b
+1 foo
+1 foo
+2 bar
+2 bar
+3
+3
+4 abc
+4 abc
+LOAD DATA LOCAL INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
+FIELDS TERMINATED BY ';'
+ (a) SET b='loaded';
+Warnings:
+Warning 1262 Row 1 was truncated; it contained more data than there were input columns
+Warning 1262 Row 2 was truncated; it contained more data than there were input columns
+Warning 1262 Row 3 was truncated; it contained more data than there were input columns
+SELECT a,b FROM t1;
+a b
+0 loaded
+1 foo
+1 foo
+102 loaded
+2 bar
+2 bar
+3
+3
+4 abc
+4 abc
+5 loaded
+LOAD DATA INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
+FIELDS TERMINATED BY ';'
+ OPTIONALLY ENCLOSED BY ''''
+ LINES STARTING BY 'prefix:'
+IGNORE 2 LINES (a,b);
+Warnings:
+Warning 1262 Row 2 was truncated; it contained more data than there were input columns
+SELECT a,b FROM t1;
+a b
+0
+0 loaded
+1 foo
+1 foo
+100 foo
+102 loaded
+2 bar
+2 bar
+3
+3
+4 abc
+4 abc
+5 loaded
+7 test
+LOAD DATA INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1;
+Warnings:
+Warning 1261 Row 1 doesn't contain data for all columns
+Warning 1261 Row 2 doesn't contain data for all columns
+Warning 1261 Row 3 doesn't contain data for all columns
+Warning 1261 Row 4 doesn't contain data for all columns
+SELECT a,b FROM t1;
+a b
+0
+0 loaded
+1 foo
+1 foo
+1 foo
+100 foo
+102 loaded
+2 bar
+2 bar
+2 bar
+3
+3
+3
+4 abc
+4 abc
+4 abc
+5 loaded
+7 test
+LOAD DATA INFILE '<DATADIR>/se_replacedata.dat' REPLACE INTO TABLE t1;
+Warnings:
+Warning 1261 Row 1 doesn't contain data for all columns
+Warning 1261 Row 2 doesn't contain data for all columns
+Warning 1261 Row 3 doesn't contain data for all columns
+Warning 1261 Row 4 doesn't contain data for all columns
+SELECT a,b FROM t1;
+a b
+0
+0 loaded
+1 aaa
+1 foo
+1 foo
+1 foo
+100 foo
+102 loaded
+2 bar
+2 bar
+2 bar
+2 bbb
+3
+3
+3
+3 ccc
+4 abc
+4 abc
+4 abc
+4 ddd
+5 loaded
+7 test
+DROP TABLE t1;
+set session unique_checks=0;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+LOAD DATA INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
+FIELDS TERMINATED BY ',' (a,b);
+SELECT a,b FROM t1;
+a b
+1 foo
+2 bar
+3
+4 abc
+LOAD DATA LOCAL INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
+CHARACTER SET utf8 COLUMNS TERMINATED BY ','
+ ESCAPED BY '/' (a,b);
+SELECT a,b FROM t1;
+a b
+1 foo
+1 foo
+2 bar
+2 bar
+3
+3
+4 abc
+4 abc
+LOAD DATA LOCAL INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
+FIELDS TERMINATED BY ';'
+ (a) SET b='loaded';
+Warnings:
+Warning 1262 Row 1 was truncated; it contained more data than there were input columns
+Warning 1262 Row 2 was truncated; it contained more data than there were input columns
+Warning 1262 Row 3 was truncated; it contained more data than there were input columns
+SELECT a,b FROM t1;
+a b
+0 loaded
+1 foo
+1 foo
+102 loaded
+2 bar
+2 bar
+3
+3
+4 abc
+4 abc
+5 loaded
+LOAD DATA INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
+FIELDS TERMINATED BY ';'
+ OPTIONALLY ENCLOSED BY ''''
+ LINES STARTING BY 'prefix:'
+IGNORE 2 LINES (a,b);
+Warnings:
+Warning 1262 Row 2 was truncated; it contained more data than there were input columns
+SELECT a,b FROM t1;
+a b
+0
+0 loaded
+1 foo
+1 foo
+100 foo
+102 loaded
+2 bar
+2 bar
+3
+3
+4 abc
+4 abc
+5 loaded
+7 test
+LOAD DATA INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1;
+Warnings:
+Warning 1261 Row 1 doesn't contain data for all columns
+Warning 1261 Row 2 doesn't contain data for all columns
+Warning 1261 Row 3 doesn't contain data for all columns
+Warning 1261 Row 4 doesn't contain data for all columns
+SELECT a,b FROM t1;
+a b
+0
+0 loaded
+1 foo
+1 foo
+1 foo
+100 foo
+102 loaded
+2 bar
+2 bar
+2 bar
+3
+3
+3
+4 abc
+4 abc
+4 abc
+5 loaded
+7 test
+LOAD DATA INFILE '<DATADIR>/se_replacedata.dat' REPLACE INTO TABLE t1;
+ERROR HY000: When unique checking is disabled in MyRocks, INSERT,UPDATE,LOAD statements with clauses that update or replace the key (i.e. INSERT ON DUPLICATE KEY UPDATE, REPLACE) are not allowed. Query: LOAD DATA INFILE '<DATADIR>/se_replacedata.dat' REPLACE INTO TABLE t1
+SELECT a,b FROM t1;
+a b
+0
+0 loaded
+1 foo
+1 foo
+1 foo
+100 foo
+102 loaded
+2 bar
+2 bar
+2 bar
+3
+3
+3
+4 abc
+4 abc
+4 abc
+5 loaded
+7 test
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/lock.result b/storage/rocksdb/mysql-test/rocksdb/r/lock.result
new file mode 100644
index 00000000..7c4f5477
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/lock.result
@@ -0,0 +1,121 @@
+connect con1,localhost,root,,;
+SET lock_wait_timeout=1;
+connection default;
+DROP TABLE IF EXISTS t1, t2, t3;
+CREATE TABLE t1 (id INT, id2 INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (id,id2) VALUES (1,1),(1,2),(1,3);
+LOCK TABLE t1 LOW_PRIORITY WRITE;
+SELECT id2,COUNT(DISTINCT id) FROM t1 GROUP BY id2;
+id2 COUNT(DISTINCT id)
+1 1
+2 1
+3 1
+UPDATE t1 SET id=-1 WHERE id=1;
+connection con1;
+SELECT id,id2 FROM t1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+LOCK TABLE t1 READ;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection default;
+LOCK TABLE t1 READ;
+UPDATE t1 SET id=1 WHERE id=1;
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
+connection con1;
+SELECT COUNT(DISTINCT id) FROM t1;
+COUNT(DISTINCT id)
+1
+UPDATE t1 SET id=2 WHERE id=2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+LOCK TABLE t1 WRITE;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+LOCK TABLE t1 READ;
+UNLOCK TABLES;
+connection default;
+CREATE TABLE t2 (a INT, b CHAR(8), PRIMARY KEY(a)) ENGINE=rocksdb;
+ERROR HY000: Table 't2' was not locked with LOCK TABLES
+UNLOCK TABLES;
+CREATE TABLE t2 (id INT, id2 INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+LOCK TABLE t1 WRITE, t2 WRITE;
+INSERT INTO t2 (id,id2) SELECT id,id2 FROM t1;
+UPDATE t1 SET id=1 WHERE id=-1;
+DROP TABLE t1,t2;
+CREATE TABLE t1 (i1 INT, nr INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+CREATE TABLE t2 (nr INT, nm INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (nr,nm) VALUES (1,3);
+INSERT INTO t2 (nr,nm) VALUES (2,4);
+LOCK TABLES t1 WRITE, t2 READ;
+INSERT INTO t1 (i1,nr) SELECT 1, nr FROM t2 WHERE nm=3;
+INSERT INTO t1 (i1,nr) SELECT 2, nr FROM t2 WHERE nm=4;
+UNLOCK TABLES;
+LOCK TABLES t1 WRITE;
+INSERT INTO t1 (i1,nr) SELECT i1, nr FROM t1;
+ERROR HY000: Table 't1' was not locked with LOCK TABLES
+UNLOCK TABLES;
+LOCK TABLES t1 WRITE, t1 AS t1_alias READ;
+INSERT INTO t1 (i1,nr) SELECT i1, nr FROM t1 AS t1_alias;
+DROP TABLE t1,t2;
+ERROR HY000: Table 't2' was not locked with LOCK TABLES
+UNLOCK TABLES;
+DROP TABLE t1,t2;
+CREATE TABLE t1 (a INT, b CHAR(8), PRIMARY KEY(a)) ENGINE=rocksdb;
+CREATE TABLE t2 (a INT, b CHAR(8), PRIMARY KEY(b)) ENGINE=rocksdb;
+CREATE TABLE t3 (a INT, b CHAR(8), pk INT PRIMARY KEY) ENGINE=rocksdb;
+LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE;
+DROP TABLE t2, t3, t1;
+CREATE TABLE t1 (a INT, b CHAR(8), PRIMARY KEY(a)) ENGINE=rocksdb;
+CREATE TABLE t2 (a INT, b CHAR(8), PRIMARY KEY(b)) ENGINE=rocksdb;
+CREATE TABLE t3 (a INT, b CHAR(8), pk INT PRIMARY KEY) ENGINE=rocksdb;
+LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t1 AS t4 READ;
+ALTER TABLE t2 ADD COLUMN c2 INT;
+DROP TABLE t1, t2, t3;
+CREATE TABLE t1 (a INT, b CHAR(8), PRIMARY KEY(a)) ENGINE=rocksdb;
+CREATE TABLE t2 (a INT, b CHAR(8), PRIMARY KEY(b)) ENGINE=rocksdb;
+LOCK TABLE t1 READ, t2 READ;
+FLUSH TABLE t1;
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
+FLUSH TABLES;
+ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
+FLUSH TABLES t1, t2 WITH READ LOCK;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+UNLOCK TABLES;
+FLUSH TABLES t1, t2 WITH READ LOCK;
+connection con1;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection default;
+UNLOCK TABLES;
+FLUSH TABLES WITH READ LOCK;
+connection con1;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection default;
+UNLOCK TABLES;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+FLUSH TABLES WITH READ LOCK;
+DROP TABLE t1, t2;
+ERROR HY000: Can't execute the query because you have a conflicting read lock
+UNLOCK TABLES;
+DROP TABLE t1, t2;
+disconnect con1;
+CREATE TABLE t1 (a INT, b CHAR(8), PRIMARY KEY(a)) ENGINE=rocksdb;
+CREATE TABLE t2 (a INT, b CHAR(8), PRIMARY KEY(b)) ENGINE=rocksdb;
+LOCK TABLE t1 WRITE, t2 WRITE;
+SELECT a,b FROM t1;
+a b
+UNLOCK TABLES;
+DROP TABLE t1, t2;
+CREATE TABLE t1 (i INT) ENGINE=MyISAM;
+HANDLER t1 OPEN h;
+CREATE TABLE t2 (i INT) ENGINE=RocksDB;
+LOCK TABLES t2 WRITE;
+connect con1,localhost,root,,test;
+connection con1;
+FLUSH TABLES WITH READ LOCK;
+connection default;
+INSERT INTO t2 VALUES (1);
+UNLOCK TABLES;
+HANDLER h CLOSE;
+connection con1;
+disconnect con1;
+connection default;
+DROP TABLE t1, t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/lock_info.result b/storage/rocksdb/mysql-test/rocksdb/r/lock_info.result
new file mode 100644
index 00000000..d0f1221e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/lock_info.result
@@ -0,0 +1,31 @@
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+create table t1 (a int, primary key(a) comment 'lock_into_cf1') engine=rocksdb;
+insert into t1 values (1);
+insert into t1 values (2);
+create table t2 (a int, primary key(a) comment 'lock_info_cf2') engine=rocksdb;
+insert into t2 values (1);
+insert into t2 values (2);
+set autocommit=0;
+select * from t1 for update;
+a
+1
+2
+select * from t2 for update;
+a
+1
+2
+use information_schema;
+select rocksdb_ddl.cf, rocksdb_locks.transaction_id, rocksdb_locks.key
+from rocksdb_locks
+left join rocksdb_ddl
+on rocksdb_locks.column_family_id=rocksdb_ddl.column_family
+order by rocksdb_ddl.cf;
+cf transaction_id key
+lock_info_cf2 _txn_id_ _key_
+lock_info_cf2 _txn_id_ _key_
+lock_into_cf1 _txn_id_ _key_
+lock_into_cf1 _txn_id_ _key_
+use test;
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/lock_rows_not_exist.result b/storage/rocksdb/mysql-test/rocksdb/r/lock_rows_not_exist.result
new file mode 100644
index 00000000..7898489d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/lock_rows_not_exist.result
@@ -0,0 +1,40 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE t (id1 int, id2 int, id3 int, value int, PRIMARY KEY (id1, id2, id3)) ENGINE=RocksDB;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+SELECT * FROM t WHERE id1=1 AND id2=1 AND id3=1 FOR UPDATE;
+id1 id2 id3 value
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+SELECT * FROM t WHERE id1=1 AND id2=1 AND id3=1 FOR UPDATE;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT * FROM t WHERE id1=1 AND id2=1 AND id3=2 FOR UPDATE;
+id1 id2 id3 value
+connection con1;
+ROLLBACK;
+BEGIN;
+UPDATE t SET value=value+100 WHERE id1=1 AND id2=1 AND id3=1;
+connection con2;
+ROLLBACK;
+BEGIN;
+UPDATE t SET value=value+100 WHERE id1=1 AND id2=1 AND id3=1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t SET value=value+100 WHERE id1=1 AND id2=0 AND id3=1;
+connection con1;
+ROLLBACK;
+BEGIN;
+DELETE FROM t WHERE id1=1 AND id2=1 AND id3=1;
+connection con2;
+ROLLBACK;
+BEGIN;
+DELETE FROM t WHERE id1=1 AND id2=1 AND id3=1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+DELETE FROM t WHERE id1=1 AND id2=1 AND id3=0;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/lock_wait_timeout_stats.result b/storage/rocksdb/mysql-test/rocksdb/r/lock_wait_timeout_stats.result
new file mode 100644
index 00000000..96efca6e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/lock_wait_timeout_stats.result
@@ -0,0 +1,35 @@
+create table t (a int primary key) engine=rocksdb;
+begin;
+insert into t values (0);
+set @@rocksdb_lock_wait_timeout=1;
+select ROW_LOCK_WAIT_TIMEOUTS from information_schema.table_statistics where table_name="t";
+ROW_LOCK_WAIT_TIMEOUTS
+0
+begin;
+set @@rocksdb_lock_wait_timeout=1;
+begin;
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_row_lock_wait_timeouts';
+insert into t values(0);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on index: test.t.PRIMARY
+select ROW_LOCK_WAIT_TIMEOUTS from information_schema.table_statistics where table_name="t";
+ROW_LOCK_WAIT_TIMEOUTS
+1
+select ROW_LOCK_WAIT_TIMEOUTS from information_schema.table_statistics where table_name="t";
+ROW_LOCK_WAIT_TIMEOUTS
+1
+select case when variable_value-@a = 1 then 'true' else 'false' end as waits from information_schema.global_status where variable_name='rocksdb_row_lock_wait_timeouts';
+waits
+true
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_row_lock_wait_timeouts';
+insert into t values(0);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on index: test.t.PRIMARY
+select ROW_LOCK_WAIT_TIMEOUTS from information_schema.table_statistics where table_name="t";
+ROW_LOCK_WAIT_TIMEOUTS
+2
+select ROW_LOCK_WAIT_TIMEOUTS from information_schema.table_statistics where table_name="t";
+ROW_LOCK_WAIT_TIMEOUTS
+2
+select case when variable_value-@a = 1 then 'true' else 'false' end as waits from information_schema.global_status where variable_name='rocksdb_row_lock_wait_timeouts';
+waits
+true
+drop table t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues.result
new file mode 100644
index 00000000..84c93481
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues.result
@@ -0,0 +1 @@
+tests moved to rocksdb.locking_issues_case*
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_1_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_1_rc.result
new file mode 100644
index 00000000..a47aa3c7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_1_rc.result
@@ -0,0 +1,30 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 1.1:
+- Locking rows that do not exist when using all primary key columns in
+- a WHERE clause
+- using READ COMMITTED transaction isolation level
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+CREATE TABLE t0(id1 INT, id2 INT, value INT, PRIMARY KEY(id1, id2));
+INSERT INTO t0 VALUES (1,1,0), (3,3,0), (4,4,0), (6,6,0);
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+SELECT * FROM t0 WHERE id1=1 AND id2=5 FOR UPDATE;
+id1 id2 value
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+INSERT INTO t0 VALUES (1,5,0);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT * FROM t0 WHERE id1=1 AND id2=5 FOR UPDATE;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection con1;
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_1_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_1_rr.result
new file mode 100644
index 00000000..c923c34c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_1_rr.result
@@ -0,0 +1,30 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 1.1:
+- Locking rows that do not exist when using all primary key columns in
+- a WHERE clause
+- using REPEATABLE READ transaction isolation level
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+CREATE TABLE t0(id1 INT, id2 INT, value INT, PRIMARY KEY(id1, id2));
+INSERT INTO t0 VALUES (1,1,0), (3,3,0), (4,4,0), (6,6,0);
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+SELECT * FROM t0 WHERE id1=1 AND id2=5 FOR UPDATE;
+id1 id2 value
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+INSERT INTO t0 VALUES (1,5,0);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT * FROM t0 WHERE id1=1 AND id2=5 FOR UPDATE;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection con1;
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_2_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_2_rc.result
new file mode 100644
index 00000000..01c4e7e3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_2_rc.result
@@ -0,0 +1,30 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 1.2:
+- Locking rows that do not exist without using all primary key
+- columns in a WHERE clause
+- using READ COMMITTED transaction isolation level
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+CREATE TABLE t0(id1 INT, id2 INT, value INT, PRIMARY KEY(id1, id2));
+INSERT INTO t0 VALUES (1,1,0), (3,3,0), (4,4,0), (6,6,0);
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+SELECT * FROM t0 WHERE id1=1 FOR UPDATE;
+id1 id2 value
+1 1 0
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+SELECT * FROM t0 WHERE id1=1 AND id2=4 FOR UPDATE;
+id1 id2 value
+INSERT INTO t0 VALUES (1,5,0);
+connection con1;
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_2_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_2_rr.result
new file mode 100644
index 00000000..798fd15b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_2_rr.result
@@ -0,0 +1,30 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 1.2:
+- Locking rows that do not exist without using all primary key
+- columns in a WHERE clause
+- using REPEATABLE READ transaction isolation level
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+CREATE TABLE t0(id1 INT, id2 INT, value INT, PRIMARY KEY(id1, id2));
+INSERT INTO t0 VALUES (1,1,0), (3,3,0), (4,4,0), (6,6,0);
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+SELECT * FROM t0 WHERE id1=1 FOR UPDATE;
+id1 id2 value
+1 1 0
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+SELECT * FROM t0 WHERE id1=1 AND id2=4 FOR UPDATE;
+id1 id2 value
+INSERT INTO t0 VALUES (1,5,0);
+connection con1;
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rc.result
new file mode 100644
index 00000000..16480da8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rc.result
@@ -0,0 +1,50 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 2:
+- Rows that are scanned but do not match the WHERE are not locked
+- using READ COMMITTED transaction isolation level unless
+- rocksdb_lock_scanned_rows is on
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+SELECT @@global.rocksdb_lock_scanned_rows;
+@@global.rocksdb_lock_scanned_rows
+0
+CREATE TABLE t0(id INT PRIMARY KEY, value INT);
+INSERT INTO t0 VALUES (1,0), (2,1), (3,0), (4,0), (5,1);
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+connection con1;
+SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+id value
+2 1
+5 1
+connection con2;
+UPDATE t0 SET VALUE=10 WHERE id=1;
+UPDATE t0 SET VALUE=10 WHERE id=5;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection con1;
+UPDATE t0 SET value=100 WHERE id in (4,5) and value>0;
+connection con2;
+SELECT * FROM t0 WHERE id=4 FOR UPDATE;
+id value
+4 0
+COMMIT;
+SELECT * FROM t0;
+id value
+1 10
+2 1
+3 0
+4 0
+5 1
+connection con1;
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rc_lsr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rc_lsr.result
new file mode 100644
index 00000000..330cd09d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rc_lsr.result
@@ -0,0 +1,37 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 2:
+- Rows that are scanned but do not match the WHERE are not locked
+- using READ COMMITTED transaction isolation level unless
+- rocksdb_lock_scanned_rows is on
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+SELECT @@global.rocksdb_lock_scanned_rows;
+@@global.rocksdb_lock_scanned_rows
+0
+SET GLOBAL rocksdb_lock_scanned_rows=ON;
+CREATE TABLE t0(id INT PRIMARY KEY, value INT);
+INSERT INTO t0 VALUES (1,0), (2,1), (3,0), (4,0), (5,1);
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+connection con1;
+SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+id value
+2 1
+5 1
+connection con2;
+UPDATE t0 SET VALUE=10 WHERE id=1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection con1;
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
+SET GLOBAL rocksdb_lock_scanned_rows=0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rr.result
new file mode 100644
index 00000000..3e6b63af
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rr.result
@@ -0,0 +1,50 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 2:
+- Rows that are scanned but do not match the WHERE are not locked
+- using REPEATABLE READ transaction isolation level unless
+- rocksdb_lock_scanned_rows is on
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+SELECT @@global.rocksdb_lock_scanned_rows;
+@@global.rocksdb_lock_scanned_rows
+0
+CREATE TABLE t0(id INT PRIMARY KEY, value INT);
+INSERT INTO t0 VALUES (1,0), (2,1), (3,0), (4,0), (5,1);
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+connection con1;
+SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+id value
+2 1
+5 1
+connection con2;
+UPDATE t0 SET VALUE=10 WHERE id=1;
+UPDATE t0 SET VALUE=10 WHERE id=5;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection con1;
+UPDATE t0 SET value=100 WHERE id in (4,5) and value>0;
+connection con2;
+SELECT * FROM t0 WHERE id=4 FOR UPDATE;
+id value
+4 0
+COMMIT;
+SELECT * FROM t0;
+id value
+1 10
+2 1
+3 0
+4 0
+5 1
+connection con1;
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rr_lsr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rr_lsr.result
new file mode 100644
index 00000000..088e975e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rr_lsr.result
@@ -0,0 +1,37 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 2:
+- Rows that are scanned but do not match the WHERE are not locked
+- using REPEATABLE READ transaction isolation level unless
+- rocksdb_lock_scanned_rows is on
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+SELECT @@global.rocksdb_lock_scanned_rows;
+@@global.rocksdb_lock_scanned_rows
+0
+SET GLOBAL rocksdb_lock_scanned_rows=ON;
+CREATE TABLE t0(id INT PRIMARY KEY, value INT);
+INSERT INTO t0 VALUES (1,0), (2,1), (3,0), (4,0), (5,1);
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+connection con1;
+SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+id value
+2 1
+5 1
+connection con2;
+UPDATE t0 SET VALUE=10 WHERE id=1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection con1;
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
+SET GLOBAL rocksdb_lock_scanned_rows=0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case3_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case3_rc.result
new file mode 100644
index 00000000..9a6f02cd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case3_rc.result
@@ -0,0 +1,25 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 3:
+- After creating a snapshot, other clients updating rows
+- using READ COMMITTED transaction isolation level
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT);
+Inserting 200,000 rows
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+UPDATE t0 SET VALUE=VALUE+1 WHERE id=190000;
+connection con1;
+id value
+190000 1
+ERROR: 0
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case3_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case3_rr.result
new file mode 100644
index 00000000..fdd4d8fc
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case3_rr.result
@@ -0,0 +1,23 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 3:
+- After creating a snapshot, other clients updating rows
+- using REPEATABLE READ transaction isolation level
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT);
+Inserting 200,000 rows
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+UPDATE t0 SET VALUE=VALUE+1 WHERE id=190000;
+connection con1;
+ERROR: 1213
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case4_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case4_rc.result
new file mode 100644
index 00000000..1a35d276
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case4_rc.result
@@ -0,0 +1,23 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 4:
+- Phantom rows
+- using READ COMMITTED transaction isolation level
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT);
+Inserting 200,000 rows
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+INSERT INTO t0 VALUES(200001,1), (-1,1);
+connection con1;
+id value
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case4_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case4_rr.result
new file mode 100644
index 00000000..7ecb1ac5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case4_rr.result
@@ -0,0 +1,23 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 4:
+- Phantom rows
+- using REPEATABLE READ transaction isolation level
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT);
+Inserting 200,000 rows
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+INSERT INTO t0 VALUES(200001,1), (-1,1);
+connection con1;
+id value
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case5_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case5_rc.result
new file mode 100644
index 00000000..4d707e83
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case5_rc.result
@@ -0,0 +1,29 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 5:
+- Deleting primary key
+- using READ COMMITTED transaction isolation level
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT);
+Inserting 200,000 rows
+UPDATE t0 SET value=100 WHERE id=190000;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+DELETE FROM t0 WHERE id=190000;
+COMMIT;
+connection con1;
+id value
+ERROR: 0
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case5_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case5_rr.result
new file mode 100644
index 00000000..0ebfe8e6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case5_rr.result
@@ -0,0 +1,28 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 5:
+- Deleting primary key
+- using REPEATABLE READ transaction isolation level
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT);
+Inserting 200,000 rows
+UPDATE t0 SET value=100 WHERE id=190000;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+DELETE FROM t0 WHERE id=190000;
+COMMIT;
+connection con1;
+ERROR: 1213
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case6_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case6_rc.result
new file mode 100644
index 00000000..f16ffbea
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case6_rc.result
@@ -0,0 +1,29 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 6:
+- Changing primary key
+- using READ COMMITTED transaction isolation level
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT);
+Inserting 200,000 rows
+UPDATE t0 SET value=100 WHERE id=190000;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+UPDATE t0 SET id=200001 WHERE id=190000;
+COMMIT;
+connection con1;
+id value
+ERROR: 0
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case6_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case6_rr.result
new file mode 100644
index 00000000..c2323937
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case6_rr.result
@@ -0,0 +1,28 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 6:
+- Changing primary key
+- using REPEATABLE READ transaction isolation level
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t0;
+CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT);
+Inserting 200,000 rows
+UPDATE t0 SET value=100 WHERE id=190000;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+SELECT * FROM t0 WHERE value > 0 FOR UPDATE;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+UPDATE t0 SET id=200001 WHERE id=190000;
+COMMIT;
+connection con1;
+ERROR: 1213
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rc.result
new file mode 100644
index 00000000..f30dbab0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rc.result
@@ -0,0 +1,41 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 7:
+- Rows that are scanned as part of a query but not in the table being
+- updated should not be locked unless rocksdb_lock_scanned_rows is on
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t1, t2;
+SELECT @@global.rocksdb_lock_scanned_rows;
+@@global.rocksdb_lock_scanned_rows
+0
+CREATE TABLE t1(id INT PRIMARY KEY, value INT);
+CREATE TABLE t2(id INT PRIMARY KEY, value INT);
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
+INSERT INTO t2 VALUES (1,1), (2,2), (3,3), (4,4), (5,5);
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+lock_scanned_rows is 0
+connection con1;
+UPDATE t1 JOIN t2 ON t1.id = t2.id SET t1.value=t1.value+100 WHERE t2.id=3;
+connection con2;
+UPDATE t2 SET value=value+100;
+SELECT * FROM t2;
+id value
+1 101
+2 102
+3 103
+4 104
+5 105
+connection con1;
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rc_lsr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rc_lsr.result
new file mode 100644
index 00000000..d43e3efb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rc_lsr.result
@@ -0,0 +1,45 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 7:
+- Rows that are scanned as part of a query but not in the table being
+- updated should not be locked unless rocksdb_lock_scanned_rows is on
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t1, t2;
+SELECT @@global.rocksdb_lock_scanned_rows;
+@@global.rocksdb_lock_scanned_rows
+0
+SET GLOBAL rocksdb_lock_scanned_rows=ON;
+CREATE TABLE t1(id INT PRIMARY KEY, value INT);
+CREATE TABLE t2(id INT PRIMARY KEY, value INT);
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
+INSERT INTO t2 VALUES (1,1), (2,2), (3,3), (4,4), (5,5);
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+lock_scanned_rows is 1
+connection con1;
+UPDATE t1 JOIN t2 ON t1.id = t2.id SET t1.value=t1.value+100 WHERE t2.id=3;
+connection con2;
+UPDATE t2 SET value=value+100 WHERE id=3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t2 SET value=value+100 WHERE id IN (1,2,4,5);
+SELECT * FROM t2;
+id value
+1 101
+2 102
+3 3
+4 104
+5 105
+connection con1;
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+DROP TABLE t2;
+SET GLOBAL rocksdb_lock_scanned_rows=0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rr.result
new file mode 100644
index 00000000..dbcb0a03
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rr.result
@@ -0,0 +1,41 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 7:
+- Rows that are scanned as part of a query but not in the table being
+- updated should not be locked unless rocksdb_lock_scanned_rows is on
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t1, t2;
+SELECT @@global.rocksdb_lock_scanned_rows;
+@@global.rocksdb_lock_scanned_rows
+0
+CREATE TABLE t1(id INT PRIMARY KEY, value INT);
+CREATE TABLE t2(id INT PRIMARY KEY, value INT);
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
+INSERT INTO t2 VALUES (1,1), (2,2), (3,3), (4,4), (5,5);
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+lock_scanned_rows is 0
+connection con1;
+UPDATE t1 JOIN t2 ON t1.id = t2.id SET t1.value=t1.value+100 WHERE t2.id=3;
+connection con2;
+UPDATE t2 SET value=value+100;
+SELECT * FROM t2;
+id value
+1 101
+2 102
+3 103
+4 104
+5 105
+connection con1;
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rr_lsr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rr_lsr.result
new file mode 100644
index 00000000..d9f7e333
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rr_lsr.result
@@ -0,0 +1,45 @@
+
+-----------------------------------------------------------------------
+- Locking issues case 7:
+- Rows that are scanned as part of a query but not in the table being
+- updated should not be locked unless rocksdb_lock_scanned_rows is on
+-----------------------------------------------------------------------
+DROP TABLE IF EXISTS t1, t2;
+SELECT @@global.rocksdb_lock_scanned_rows;
+@@global.rocksdb_lock_scanned_rows
+0
+SET GLOBAL rocksdb_lock_scanned_rows=ON;
+CREATE TABLE t1(id INT PRIMARY KEY, value INT);
+CREATE TABLE t2(id INT PRIMARY KEY, value INT);
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
+INSERT INTO t2 VALUES (1,1), (2,2), (3,3), (4,4), (5,5);
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+lock_scanned_rows is 1
+connection con1;
+UPDATE t1 JOIN t2 ON t1.id = t2.id SET t1.value=t1.value+100 WHERE t2.id=3;
+connection con2;
+UPDATE t2 SET value=value+100 WHERE id=3;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t2 SET value=value+100 WHERE id IN (1,2,4,5);
+SELECT * FROM t2;
+id value
+1 101
+2 102
+3 3
+4 104
+5 105
+connection con1;
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+DROP TABLE t2;
+SET GLOBAL rocksdb_lock_scanned_rows=0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_ignore_dirs.result b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_ignore_dirs.result
new file mode 100644
index 00000000..9b91cdb5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_ignore_dirs.result
@@ -0,0 +1,9 @@
+#
+# RocksDB plugin adds #rocksdb to ignore_db_dirs
+#
+select @@ignore_db_dirs;
+@@ignore_db_dirs
+#rocksdb
+select @@ignore_db_dirs;
+@@ignore_db_dirs
+aa,bbb,#rocksdb
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_misc_binlog.result b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_misc_binlog.result
new file mode 100644
index 00000000..c37ab946
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_misc_binlog.result
@@ -0,0 +1,33 @@
+create table t1 (a int) engine=rocksdb;
+# Should have binlog ON
+select @@log_bin;
+@@log_bin
+1
+set binlog_format='row';
+# Should succeed
+optimize table t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+#
+# MDEV-13602: rocksdb.index_merge_rocksdb2 failed in buildbot
+#
+lock tables t1 write;
+insert into t1 values(1);
+unlock tables;
+set @tmp_bf= @@binlog_format;
+set binlog_format='STATEMENT';
+lock tables t1 write;
+insert into t1 values(1);
+ERROR HY000: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging.
+unlock tables;
+set @@binlog_format=@tmp_bf;
+drop table t1;
+#
+# MDEV-17045: MyRocks tables cannot be updated when binlog_format=MIXED.
+#
+set @tmp_bf= @@binlog_format;
+set binlog_format='MIXED';
+create table t1 (pk int primary key) engine=rocksdb;
+insert into t1 values (1);
+drop table t1;
+set @@binlog_format=@tmp_bf;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_plugin.result b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_plugin.result
new file mode 100644
index 00000000..6d6cb1db
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_plugin.result
@@ -0,0 +1,35 @@
+#
+# MDEV-14843: Assertion `s_tx_list.size() == 0' failed in myrocks::Rdb_transaction::term_mutex
+#
+INSTALL SONAME 'ha_rocksdb';
+connect con1,localhost,root,,test;
+CREATE TABLE t1 (i INT) ENGINE=RocksDB;
+insert into t1 values (1);
+DROP TABLE t1;
+connection default;
+UNINSTALL SONAME 'ha_rocksdb';
+Warnings:
+Warning 1620 Plugin is busy and will be uninstalled on shutdown
+SELECT ENGINE, SUPPORT FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE='ROCKSDB';
+ENGINE SUPPORT
+ROCKSDB NO
+disconnect con1;
+#
+# MDEV-15686: Loading MyRocks plugin back after it has been unloaded causes a crash
+#
+call mtr.add_suppression("Plugin 'ROCKSDB.*' init function returned error.");
+call mtr.add_suppression("Plugin 'ROCKSDB.*' registration as a INFORMATION SCHEMA failed.");
+call mtr.add_suppression("Plugin 'ROCKSDB' registration as a STORAGE ENGINE failed");
+#
+# There are two possible scenarios:
+# ha_rocksdb.{dll,so} is still loaded into mysqld's address space. Its
+# global variables are in the state that doesn't allow it to be
+# initialized back (this is what MDEV-15686 is about). This is handled
+# by intentionally returning an error from rocksdb_init_func.
+#
+# The second case is when ha_rocksdb.{ddl,so} has been fully unloaded
+# and so it will be now loaded as if it happens for the first time.
+INSTALL SONAME 'ha_rocksdb';
+# Whatever happened on the previous step, restore things to the way they
+# were at testcase start.
+UNINSTALL SONAME 'ha_rocksdb';
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result
new file mode 100644
index 00000000..730e12d0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result
@@ -0,0 +1,119 @@
+#
+# MDEV-14433: RocksDB may show empty or incorrect output with rocksdb_strict_collation_check=off
+#
+set global rocksdb_strict_collation_check=off;
+set @tmp_rscc=@@rocksdb_strict_collation_check;
+CREATE TABLE t1(
+a varchar(10) NOT NULL,
+b char(1) DEFAULT 'X',
+c char(2) NOT NULL DEFAULT '??',
+d varchar(10) NOT NULL,
+e int(11) DEFAULT 0,
+PRIMARY KEY (a,d),
+KEY (e)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8;
+insert into t1 select 1,1,1,1,0;
+insert into t1 select 2,1,1,1,0;
+insert into t1 select 3,1,1,1,0;
+explain
+select a from t1 force index(e) where e<10000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range e e 5 NULL # Using index condition
+select a from t1;
+a
+1
+2
+3
+select * from t1;
+a b c d e
+1 1 1 1 0
+2 1 1 1 0
+3 1 1 1 0
+DROP TABLE t1;
+#
+# MDEV-14563: Wrong query plan for query with no PK
+#
+CREATE TABLE t1(
+pk int primary key,
+a varchar(10) NOT NULL,
+e int(11) DEFAULT 0,
+KEY (a)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8;
+insert into t1 values (1,1,1),(2,2,2);
+explain select a from t1 where a <'zzz';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 32 NULL # Using where
+CREATE TABLE t2(
+pk int,
+a varchar(10) NOT NULL,
+e int(11) DEFAULT 0,
+KEY (a)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8;
+insert into t2 values (1,1,1),(2,2,2);
+explain select a from t2 where a <'zzz';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range a a 32 NULL # Using where
+drop table t1,t2;
+set global rocksdb_strict_collation_check=@tmp_rscc;
+#
+# MDEV-14389: MyRocks and NOPAD collations
+#
+create table t1 (pk varchar(10) collate latin1_nopad_bin, primary key(pk)) engine=rocksdb;
+ERROR HY000: MyRocks doesn't currently support collations with "No pad" attribute.
+set global rocksdb_strict_collation_check=off;
+create table t1 (pk varchar(10) collate latin1_nopad_bin, primary key(pk)) engine=rocksdb;
+ERROR HY000: MyRocks doesn't currently support collations with "No pad" attribute.
+set global rocksdb_strict_collation_check=@tmp_rscc;
+#
+# MDEV-14679: RocksdB plugin fails to load with "Loading of unknown plugin ROCKSDB_CFSTATS
+#
+select plugin_name, plugin_maturity from information_schema.plugins where plugin_name like '%rocksdb%';
+plugin_name plugin_maturity
+ROCKSDB Stable
+ROCKSDB_CFSTATS Stable
+ROCKSDB_DBSTATS Stable
+ROCKSDB_PERF_CONTEXT Stable
+ROCKSDB_PERF_CONTEXT_GLOBAL Stable
+ROCKSDB_CF_OPTIONS Stable
+ROCKSDB_COMPACTION_STATS Stable
+ROCKSDB_GLOBAL_INFO Stable
+ROCKSDB_DDL Stable
+ROCKSDB_SST_PROPS Stable
+ROCKSDB_INDEX_FILE_MAP Stable
+ROCKSDB_LOCKS Stable
+ROCKSDB_TRX Stable
+ROCKSDB_DEADLOCK Stable
+#
+# MDEV-12466 : Assertion `thd->transaction.stmt.is_empty() || thd->in_sub_stmt || ...
+#
+CREATE TABLE t1 (i INT) ENGINE=RocksDB;
+FLUSH TABLE t1 FOR EXPORT;
+ERROR HY000: Storage engine ROCKSDB of the table `test`.`t1` doesn't have this option
+DROP TABLE t1;
+#
+# MDEV-16154 Server crashes in in myrocks::ha_rocksdb::load_auto_incr_value_from_inde
+#
+CREATE TABLE t1 (a INT) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1);
+ALTER TABLE t1 AUTO_INCREMENT 10;
+DROP TABLE t1;
+#
+# MDEV-16155: UPDATE on RocksDB table with unique constraint does not work
+#
+CREATE TABLE t1 (a INT, b CHAR(8), UNIQUE INDEX(a)) ENGINE=RocksDB;
+INSERT INTO t1 (a,b) VALUES (1,'foo'),(2,'bar');
+UPDATE t1 SET a=a+100;
+SELECT * FROM t1;
+a b
+101 foo
+102 bar
+DROP TABLE t1;
+#
+# MDEV-15319: [SQL Layer] Server crashes in Field::set_null / myrocks::ha_rocksdb::convert_record_from_storage_format
+# (just a testcase)
+#
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 ENGINE=RocksDB AS SELECT VALUE(i) AS a FROM t1;
+DELETE FROM t2;
+DROP TABLE t1,t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_rpl.result b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_rpl.result
new file mode 100644
index 00000000..98408c78
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_rpl.result
@@ -0,0 +1,14 @@
+#
+# MDEV-15472: Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failure ...
+#
+select @@log_bin;
+@@log_bin
+1
+select @@binlog_format;
+@@binlog_format
+ROW
+CREATE OR REPLACE TABLE t1 (i INT) ENGINE=RocksDB;
+LOCK TABLE t1 WRITE;
+FLUSH TABLES;
+UNLOCK TABLES;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/max_open_files.result b/storage/rocksdb/mysql-test/rocksdb/r/max_open_files.result
new file mode 100644
index 00000000..d3aac194
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/max_open_files.result
@@ -0,0 +1,22 @@
+CALL mtr.add_suppression("RocksDB: rocksdb_max_open_files should not be greater than the open_files_limit*");
+FOUND 1 /RocksDB: rocksdb_max_open_files should not be greater than the open_files_limit/ in rocksdb.max_open_files.err
+SELECT FLOOR(@@global.open_files_limit / 2) = @@global.rocksdb_max_open_files;
+FLOOR(@@global.open_files_limit / 2) = @@global.rocksdb_max_open_files
+1
+SELECT @@global.open_files_limit - 1 = @@global.rocksdb_max_open_files;
+@@global.open_files_limit - 1 = @@global.rocksdb_max_open_files
+1
+SELECT @@global.rocksdb_max_open_files;
+@@global.rocksdb_max_open_files
+0
+CREATE TABLE t1(a INT) ENGINE=ROCKSDB;
+INSERT INTO t1 VALUES(0),(1),(2),(3),(4);
+SET GLOBAL rocksdb_force_flush_memtable_and_lzero_now=1;
+DROP TABLE t1;
+SELECT @@global.rocksdb_max_open_files;
+@@global.rocksdb_max_open_files
+-1
+SELECT FLOOR(@@global.open_files_limit / 2) = @@global.rocksdb_max_open_files;
+FLOOR(@@global.open_files_limit / 2) = @@global.rocksdb_max_open_files
+1
+# restart
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/misc.result b/storage/rocksdb/mysql-test/rocksdb/r/misc.result
new file mode 100644
index 00000000..b2e5d04f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/misc.result
@@ -0,0 +1,94 @@
+INSERT INTO mysql.event (
+db,
+name,
+body,
+definer,
+interval_value,
+interval_field,
+originator,
+character_set_client,
+collation_connection,
+db_collation,
+body_utf8)
+values (
+database(),
+"ev1",
+"select 1",
+user(),
+100,
+"SECOND_MICROSECOND",
+1,
+'utf8',
+'utf8_general_ci',
+'utf8_general_ci',
+'select 1');
+SHOW EVENTS;
+ERROR 42000: This version of MariaDB doesn't yet support 'MICROSECOND'
+DROP EVENT ev1;
+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'
+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
+columns_priv Column_name NULL NULL
+columns_priv Db NULL NULL
+columns_priv Host NULL NULL
+columns_priv Table_name NULL NULL
+columns_priv User NULL NULL
+db Db NULL NULL
+db Host NULL NULL
+db User NULL NULL
+event db NULL NULL
+event name NULL NULL
+func name NULL NULL
+global_priv Host NULL NULL
+global_priv User NULL NULL
+gtid_slave_pos domain_id NULL NULL
+gtid_slave_pos sub_id NULL NULL
+help_category help_category_id NULL NULL
+help_category name NULL NULL
+help_keyword help_keyword_id NULL NULL
+help_keyword name NULL NULL
+help_relation help_keyword_id NULL NULL
+help_relation help_topic_id NULL NULL
+help_topic help_topic_id NULL NULL
+help_topic name NULL NULL
+index_stats db_name NULL NULL
+index_stats index_name NULL NULL
+index_stats prefix_arity NULL NULL
+index_stats table_name NULL NULL
+plugin name NULL NULL
+proc db NULL NULL
+proc name NULL NULL
+proc type NULL NULL
+procs_priv Db NULL NULL
+procs_priv Host NULL NULL
+procs_priv Routine_name NULL NULL
+procs_priv Routine_type NULL NULL
+procs_priv User NULL NULL
+proxies_priv Host NULL NULL
+proxies_priv Proxied_host NULL NULL
+proxies_priv Proxied_user NULL NULL
+proxies_priv User NULL NULL
+roles_mapping Host NULL NULL
+roles_mapping Role NULL NULL
+roles_mapping User NULL NULL
+servers Server_name NULL NULL
+table_stats db_name NULL NULL
+table_stats table_name NULL NULL
+tables_priv Db NULL NULL
+tables_priv Host NULL NULL
+tables_priv Table_name NULL NULL
+tables_priv User NULL NULL
+time_zone Time_zone_id NULL NULL
+time_zone_leap_second Transition_time NULL NULL
+time_zone_name Name NULL NULL
+time_zone_transition Time_zone_id NULL NULL
+time_zone_transition Transition_time NULL NULL
+time_zone_transition_type Time_zone_id NULL NULL
+time_zone_transition_type Transition_type_id NULL NULL
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/multi_varchar_sk_lookup.result b/storage/rocksdb/mysql-test/rocksdb/r/multi_varchar_sk_lookup.result
new file mode 100644
index 00000000..86ba6d92
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/multi_varchar_sk_lookup.result
@@ -0,0 +1,37 @@
+DROP TABLE IF EXISTS T1;
+CREATE TABLE T1 (
+P1 VARCHAR(64), P2 VARCHAR(64), P3 VARCHAR(64), P4 VARCHAR(64),
+S1 VARCHAR(64), S2 VARCHAR(64), S3 VARCHAR(64), S4 VARCHAR(64),
+S5 VARCHAR(64), S6 VARCHAR(64), S7 VARCHAR(64), S8 VARCHAR(64),
+S9 VARCHAR(64), S10 VARCHAR(64), S11 VARCHAR(64), S12 VARCHAR(64),
+S13 VARCHAR(64), S14 VARCHAR(64), S15 VARCHAR(64), S16 VARCHAR(64),
+PRIMARY KEY (P1(8), P2(8), P3(8), P4(8)),
+KEY SK (S1(8), S2(8), S3(8), S4(8),
+S5(8), S6(8), S7(8), S8(8),
+S9(8), S10(8), S11(8), S12(8),
+S13(8), S14(8), S15(8), S16(8))
+) ENGINE=rocksdb;
+INSERT INTO T1 VALUES ('1', '2', '3', '4',
+'5', '6', '7', '8',
+'9', '10', '11', '12',
+'13', '14', '15', '16',
+'17', '18', '19', '20');
+SELECT * FROM T1;
+P1 P2 P3 P4 S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 S11 S12 S13 S14 S15 S16
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+# Not eligible for optimization, shorter than prefix length.
+SELECT P4, S2 FROM T1 FORCE INDEX(SK) WHERE S1='5';
+P4 S2
+4 6
+include/assert.inc [Not eligible for optimization, shorter than prefix length.: 0 rocksdb_covered_secondary_key_lookups]
+DELETE FROM T1;
+INSERT INTO T1 VALUES ('100000000', '200000000', '300000000', '400000000',
+'500000000', '600000000', '700000000', '800000000',
+'900000000', '100000000', '110000000', '120000000',
+'130000000', '140000000', '150000000', '160000000',
+'170000000', '180000000', '190000000', '200000000');
+# Not eligible for optimization, longer than prefix length.
+SELECT P4, S2 FROM T1 FORCE INDEX(SK) WHERE S1='5';
+P4 S2
+include/assert.inc [Not eligible for optimization, longer than prefix length.: 0 rocksdb_covered_secondary_key_lookups]
+DROP TABLE T1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mysqlbinlog_blind_replace.result b/storage/rocksdb/mysql-test/rocksdb/r/mysqlbinlog_blind_replace.result
new file mode 100644
index 00000000..ff462569
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/mysqlbinlog_blind_replace.result
@@ -0,0 +1,128 @@
+reset master;
+set GLOBAL binlog_format= 'ROW';
+SET GLOBAL enable_blind_replace=ON;
+set binlog_format=row;
+create table t5 (c1 int primary key, c2 int);
+insert into t5 values (1, 1);
+insert into t5 values (2, 2);
+insert into t5 values (3, 3);
+select * from t5;
+c1 c2
+1 1
+2 2
+3 3
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t5 values (1, 11);
+replace into t5 values (2, 22);
+replace into t5 values (3, 33);
+select case when variable_value-@c = 3 then 'true' else 'false' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+select * from t5;
+c1 c2
+1 11
+2 22
+3 33
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; create table t5 (c1 int primary key, c2 int)
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+flush logs;
+drop table t5;
+reset master;
+Replaying binlog events containing blind replace statements should work
+select * from t5;
+c1 c2
+1 11
+2 22
+3 33
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; create table t5 (c1 int primary key, c2 int)
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+drop table t5;
+reset master;
+Replaying the same binlog events with blind replace disabled should work
+The server should internally convert such events into updates
+SET GLOBAL enable_blind_replace=OFF;
+select * from t5;
+c1 c2
+1 11
+2 22
+3 33
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; create table t5 (c1 int primary key, c2 int)
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t5)
+master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+set GLOBAL binlog_format=DEFAULT;
+SET GLOBAL enable_blind_replace=DEFAULT;
+drop table t5;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mysqlbinlog_gtid_skip_empty_trans_rocksdb.result b/storage/rocksdb/mysql-test/rocksdb/r/mysqlbinlog_gtid_skip_empty_trans_rocksdb.result
new file mode 100644
index 00000000..835361ee
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/mysqlbinlog_gtid_skip_empty_trans_rocksdb.result
@@ -0,0 +1,143 @@
+reset master;
+set timestamp=1000000000;
+set SESSION binlog_format = 'ROW';
+create database test2;
+create database test3;
+use test;
+create table t1 (a int primary key, b char(8)) ENGINE=rocksdb;
+insert into t1 values(1, 'a');
+insert into t1 values(2, 'b');
+create table t2 (a int primary key, b char(8)) ENGINE=rocksdb;
+start transaction;
+insert into t2 values(1, 'a');
+insert into t2 values(2, 'b');
+insert into t2 values(3, 'c');
+insert into t2 values(4, 'd');
+commit;
+use test2;
+create table t1 (a int primary key, b char(8)) ENGINE=rocksdb;
+insert into t1 values(1, 'a');
+insert into t1 values(2, 'b');
+create table t2 (a int primary key, b char(8)) ENGINE=rocksdb;
+start transaction;
+insert into t2 values(1, 'a');
+insert into t2 values(2, 'b');
+insert into t2 values(3, 'c');
+insert into t2 values(4, 'd');
+commit;
+use test3;
+create table t1 (a int primary key, b char(8)) ENGINE=rocksdb;
+insert into t1 values(1, 'a');
+insert into t1 values(2, 'b');
+create table t2 (a int primary key, b char(8)) ENGINE=rocksdb;
+start transaction;
+insert into t2 values(1, 'a');
+insert into t2 values(2, 'b');
+insert into t2 values(3, 'c');
+insert into t2 values(4, 'd');
+commit;
+FLUSH LOGS;
+==== Output of mysqlbinlog with --short-form --skip-empty-trans, --database and --skip-gtids options ====
+/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+ROLLBACK/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.pseudo_thread_id=999999999/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.sql_mode=1073741824/*!*/;
+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+SET @@session.lc_time_names=0/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+create database test2
+/*!*/;
+use `test2`/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+create table t1 (a int primary key, b char(8)) ENGINE=rocksdb
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+BEGIN
+/*!*/;
+COMMIT/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+BEGIN
+/*!*/;
+COMMIT/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+create table t2 (a int primary key, b char(8)) ENGINE=rocksdb
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+BEGIN
+/*!*/;
+COMMIT/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
+use test2;
+start transaction;
+insert into t2 values(5, 'e');
+insert into t2 values(6, 'f');
+use test;
+insert into t2 values(7, 'g');
+insert into t2 values(8, 'h');
+commit;
+FLUSH LOGS;
+==== Output of mysqlbinlog with --short-form --skip-empty-trans, --database and --skip-gtids options ====
+==== DB changed in the middle of the transaction, which belongs to the selected database
+/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.pseudo_thread_id=999999999/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.sql_mode=1073741824/*!*/;
+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+SET @@session.lc_time_names=0/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+BEGIN
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
+use test;
+start transaction;
+insert into t2 values(9, 'i');
+insert into t2 values(10, 'j');
+use test2;
+insert into t2 values(11, 'k');
+insert into t2 values(12, 'l');
+commit;
+FLUSH LOGS;
+==== Output of mysqlbinlog with --short-form --skip-empty-trans, --database and --skip-gtids options ====
+==== DB changed in the middle of the transaction, which belongs to the non-selected database
+/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
+use test;
+drop table t1;
+drop table if exists t2;
+use test2;
+drop table t1;
+drop table if exists t2;
+use test3;
+drop table t1;
+drop table if exists t2;
+drop database test2;
+drop database test3;
+FLUSH LOGS;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mysqldump.result b/storage/rocksdb/mysql-test/rocksdb/r/mysqldump.result
new file mode 100644
index 00000000..ac6615be
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/mysqldump.result
@@ -0,0 +1,246 @@
+drop table if exists r1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+create table r1 (id1 int, id2 int, id3 varchar(100), id4 int, value1 int, value2 int, value3 int, value4 int, primary key (id1, id2, id3, id4), KEY (value1, value2, value3)) engine=rocksdb;
+insert into r1 values (1,1,1,1,1,1,1,1);
+insert into r1 values (1,1,1,2,2,2,2,2);
+insert into r1 values (1,1,2,1,3,3,3,3);
+insert into r1 values (1,1,2,2,4,4,4,4);
+insert into r1 values (1,2,1,1,5,5,5,5);
+insert into r1 values (1,2,1,2,6,6,6,6);
+insert into r1 values (1,2,2,1,7,7,7,7);
+insert into r1 values (1,2,2,2,8,8,8,8);
+insert into r1 values (2,1,1,1,9,9,9,9);
+insert into r1 values (2,1,1,2,10,10,10,10);
+insert into r1 values (2,1,2,1,11,11,11,11);
+insert into r1 values (2,1,2,2,12,12,12,12);
+insert into r1 values (2,2,1,1,13,13,13,13);
+insert into r1 values (2,2,1,2,14,14,14,14);
+insert into r1 values (2,2,2,1,15,15,15,15);
+insert into r1 values (2,2,2,2,16,16,16,16);
+connection con2;
+BEGIN;
+insert into r1 values (5,5,5,5,5,5,5,5);
+update r1 set value1=value1+100 where id1=1 and id2=1 and id3='1';
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+/*!50601 SELECT count(*) INTO @is_mysql8 FROM information_schema.TABLES WHERE table_schema='performance_schema' AND table_name='session_variables' */;
+/*!50601 SET @check_rocksdb = CONCAT( 'SELECT count(*) INTO @is_rocksdb_supported FROM ', IF (@is_mysql8, 'performance', 'information'), '_schema.session_variables WHERE variable_name=\'rocksdb_bulk_load\'') */;
+/*!50601 PREPARE s FROM @check_rocksdb */;
+/*!50601 EXECUTE s */;
+/*!50601 SET @enable_bulk_load = IF (@is_rocksdb_supported, 'SET SESSION rocksdb_bulk_load=1', 'SET @dummy = 0') */;
+/*!50601 PREPARE s FROM @enable_bulk_load */;
+/*!50601 EXECUTE s */;
+-- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
+-- SET GLOBAL gtid_slave_pos='0-1-18';
+DROP TABLE IF EXISTS `r1`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `r1` (
+ `id1` int(11) NOT NULL,
+ `id2` int(11) NOT NULL,
+ `id3` varchar(100) NOT NULL,
+ `id4` int(11) NOT NULL,
+ `value1` int(11) DEFAULT NULL,
+ `value2` int(11) DEFAULT NULL,
+ `value3` int(11) DEFAULT NULL,
+ `value4` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id1`,`id2`,`id3`,`id4`),
+ KEY `value1` (`value1`,`value2`,`value3`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+/* ORDERING KEY (DESC) : PRIMARY */;
+
+LOCK TABLES `r1` WRITE;
+/*!40000 ALTER TABLE `r1` DISABLE KEYS */;
+INSERT INTO `r1` VALUES (2,2,'2',2,16,16,16,16),(2,2,'2',1,15,15,15,15),(2,2,'1',2,14,14,14,14),(2,2,'1',1,13,13,13,13),(2,1,'2',2,12,12,12,12),(2,1,'2',1,11,11,11,11),(2,1,'1',2,10,10,10,10),(2,1,'1',1,9,9,9,9),(1,2,'2',2,8,8,8,8),(1,2,'2',1,7,7,7,7),(1,2,'1',2,6,6,6,6),(1,2,'1',1,5,5,5,5),(1,1,'2',2,4,4,4,4),(1,1,'2',1,3,3,3,3),(1,1,'1',2,2,2,2,2),(1,1,'1',1,1,1,1,1);
+/*!40000 ALTER TABLE `r1` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!50601 SET @disable_bulk_load = IF (@is_rocksdb_supported, 'SET SESSION rocksdb_bulk_load=0', 'SET @dummy = 0') */;
+/*!50601 PREPARE s FROM @disable_bulk_load */;
+/*!50601 EXECUTE s */;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+/*!50601 SELECT count(*) INTO @is_mysql8 FROM information_schema.TABLES WHERE table_schema='performance_schema' AND table_name='session_variables' */;
+/*!50601 SET @check_rocksdb = CONCAT( 'SELECT count(*) INTO @is_rocksdb_supported FROM ', IF (@is_mysql8, 'performance', 'information'), '_schema.session_variables WHERE variable_name=\'rocksdb_bulk_load\'') */;
+/*!50601 PREPARE s FROM @check_rocksdb */;
+/*!50601 EXECUTE s */;
+/*!50601 SET @bulk_load_allow_sk = IF (@is_rocksdb_supported, 'SET SESSION rocksdb_bulk_load_allow_sk=1', 'SET @dummy = 0') */;
+/*!50601 PREPARE s FROM @bulk_load_allow_sk */;
+/*!50601 EXECUTE s */;
+/*!50601 SET @enable_bulk_load = IF (@is_rocksdb_supported, 'SET SESSION rocksdb_bulk_load=1', 'SET @dummy = 0') */;
+/*!50601 PREPARE s FROM @enable_bulk_load */;
+/*!50601 EXECUTE s */;
+-- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
+DROP TABLE IF EXISTS `r1`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `r1` (
+ `id1` int(11) NOT NULL DEFAULT '0',
+ `id2` int(11) NOT NULL DEFAULT '0',
+ `id3` varchar(100) NOT NULL DEFAULT '',
+ `id4` int(11) NOT NULL DEFAULT '0',
+ `value1` int(11) DEFAULT NULL,
+ `value2` int(11) DEFAULT NULL,
+ `value3` int(11) DEFAULT NULL,
+ `value4` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id1`,`id2`,`id3`,`id4`),
+ KEY `value1` (`value1`,`value2`,`value3`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+/* ORDERING KEY (DESC) : PRIMARY */;
+
+LOCK TABLES `r1` WRITE;
+/*!40000 ALTER TABLE `r1` DISABLE KEYS */;
+INSERT INTO `r1` VALUES (2,2,'2',2,16,16,16,16),(2,2,'2',1,15,15,15,15),(2,2,'1',2,14,14,14,14),(2,2,'1',1,13,13,13,13),(2,1,'2',2,12,12,12,12),(2,1,'2',1,11,11,11,11),(2,1,'1',2,10,10,10,10),(2,1,'1',1,9,9,9,9),(1,2,'2',2,8,8,8,8),(1,2,'2',1,7,7,7,7),(1,2,'1',2,6,6,6,6),(1,2,'1',1,5,5,5,5),(1,1,'2',2,4,4,4,4),(1,1,'2',1,3,3,3,3),(1,1,'1',2,2,2,2,2),(1,1,'1',1,1,1,1,1);
+/*!40000 ALTER TABLE `r1` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!50601 SET @disable_bulk_load = IF (@is_rocksdb_supported, 'SET SESSION rocksdb_bulk_load=0', 'SET @dummy = 0') */;
+/*!50601 PREPARE s FROM @disable_bulk_load */;
+/*!50601 EXECUTE s */;
+/*!50601 SET @disable_bulk_load_allow_sk = IF (@is_rocksdb_supported, 'SET SESSION rocksdb_bulk_load_allow_sk=0', 'SET @dummy = 0') */;
+/*!50601 PREPARE s FROM @disable_bulk_load_allow_sk */;
+/*!50601 EXECUTE s */;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+rollback;
+connection con1;
+2
+set @save_default_storage_engine=@@global.default_storage_engine;
+SET GLOBAL default_storage_engine=rocksdb;
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+-- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
+-- SET GLOBAL gtid_slave_pos='0-1-18';
+DROP TABLE IF EXISTS `r1`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `r1` (
+ `id1` int(11) NOT NULL,
+ `id2` int(11) NOT NULL,
+ `id3` varchar(100) NOT NULL,
+ `id4` int(11) NOT NULL,
+ `value1` int(11) DEFAULT NULL,
+ `value2` int(11) DEFAULT NULL,
+ `value3` int(11) DEFAULT NULL,
+ `value4` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id1`,`id2`,`id3`,`id4`),
+ KEY `value1` (`value1`,`value2`,`value3`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+/* ORDERING KEY : (null) */;
+
+LOCK TABLES `r1` WRITE;
+/*!40000 ALTER TABLE `r1` DISABLE KEYS */;
+INSERT INTO `r1` VALUES (1,1,'1',1,1,1,1,1),(1,1,'1',2,2,2,2,2),(1,1,'2',1,3,3,3,3),(1,1,'2',2,4,4,4,4),(1,2,'1',1,5,5,5,5),(1,2,'1',2,6,6,6,6),(1,2,'2',1,7,7,7,7),(1,2,'2',2,8,8,8,8),(2,1,'1',1,9,9,9,9),(2,1,'1',2,10,10,10,10),(2,1,'2',1,11,11,11,11),(2,1,'2',2,12,12,12,12),(2,2,'1',1,13,13,13,13),(2,2,'1',2,14,14,14,14),(2,2,'2',1,15,15,15,15),(2,2,'2',2,16,16,16,16);
+/*!40000 ALTER TABLE `r1` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+3
+==== mysqldump with --innodb-stats-on-metadata ====
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+-- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
+-- SET GLOBAL gtid_slave_pos='0-1-18';
+DROP TABLE IF EXISTS `r1`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `r1` (
+ `id1` int(11) NOT NULL,
+ `id2` int(11) NOT NULL,
+ `id3` varchar(100) NOT NULL,
+ `id4` int(11) NOT NULL,
+ `value1` int(11) DEFAULT NULL,
+ `value2` int(11) DEFAULT NULL,
+ `value3` int(11) DEFAULT NULL,
+ `value4` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id1`,`id2`,`id3`,`id4`),
+ KEY `value1` (`value1`,`value2`,`value3`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+/* ORDERING KEY : (null) */;
+
+LOCK TABLES `r1` WRITE;
+/*!40000 ALTER TABLE `r1` DISABLE KEYS */;
+INSERT INTO `r1` VALUES (1,1,'1',1,1,1,1,1),(1,1,'1',2,2,2,2,2),(1,1,'2',1,3,3,3,3),(1,1,'2',2,4,4,4,4),(1,2,'1',1,5,5,5,5),(1,2,'1',2,6,6,6,6),(1,2,'2',1,7,7,7,7),(1,2,'2',2,8,8,8,8),(2,1,'1',1,9,9,9,9),(2,1,'1',2,10,10,10,10),(2,1,'2',1,11,11,11,11),(2,1,'2',2,12,12,12,12),(2,2,'1',1,13,13,13,13),(2,2,'1',2,14,14,14,14),(2,2,'2',1,15,15,15,15),(2,2,'2',2,16,16,16,16);
+/*!40000 ALTER TABLE `r1` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+SET GLOBAL binlog_format=statement;
+SET GLOBAL binlog_format=row;
+drop table r1;
+reset master;
+set @@global.default_storage_engine=@save_default_storage_engine;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mysqldump2.result b/storage/rocksdb/mysql-test/rocksdb/r/mysqldump2.result
new file mode 100644
index 00000000..11c1f370
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/mysqldump2.result
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS t1;
+create table t1 (id int primary key, value int, value2 varchar(200), index(value)) engine=rocksdb;
+optimize table t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_block_cache_add';
+select case when variable_value - @a > 20 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_block_cache_add';
+case when variable_value - @a > 20 then 'true' else 'false' end
+false
+select count(*) from t1;
+count(*)
+50000
+select case when variable_value - @a > 100 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_block_cache_add';
+case when variable_value - @a > 100 then 'true' else 'false' end
+true
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/native_procedure.result b/storage/rocksdb/mysql-test/rocksdb/r/native_procedure.result
new file mode 100644
index 00000000..725b74e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/native_procedure.result
@@ -0,0 +1,397 @@
+create database linkdb;
+use linkdb;
+create table linktable (
+id1 bigint(20) unsigned NOT NULL DEFAULT '0',
+id2 bigint(20) unsigned NOT NULL DEFAULT '0',
+link_type bigint(20) unsigned NOT NULL DEFAULT '0',
+visibility tinyint(3) NOT NULL DEFAULT '0',
+data varchar(255) NOT NULL DEFAULT '',
+time bigint(20) unsigned NOT NULL DEFAULT '0',
+version int(11) unsigned NOT NULL DEFAULT '0',
+primary key (id1,id2,link_type) COMMENT 'cf_link_pk',
+KEY id1_type (id1,link_type,visibility,time,version,data)
+COMMENT 'rev:cf_link_id1_type') ENGINE=rocksdb DEFAULT COLLATE=latin1_bin;
+create table counttable (
+id bigint(20) unsigned NOT NULL DEFAULT '0',
+link_type bigint(20) unsigned NOT NULL DEFAULT '0',
+count int(10) unsigned NOT NULL DEFAULT '0',
+time bigint(20) unsigned NOT NULL DEFAULT '0',
+version bigint(20) unsigned NOT NULL DEFAULT '0',
+primary key (id,link_type) COMMENT 'cf_count_pk')
+ENGINE=rocksdb DEFAULT COLLATE=latin1_bin;
+create table nodetable (
+id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+type int(10) unsigned NOT NULL,
+version bigint(20) unsigned NOT NULL,
+time int(10) unsigned NOT NULL,
+data mediumtext NOT NULL,
+primary key(id) COMMENT 'cf_node_pk')
+ENGINE=rocksdb DEFAULT COLLATE=latin1_bin;
+#
+# Test nodeGet function
+#
+create native procedure nodeGet soname "NP_EXAMPLE_LIB";
+%nodeGet 1;
+id type version time data
+1 1 1 1000 data
+%nodeGet 50 anything can go here;
+id type version time data
+50 1 1 50000 data
+%nodeGet 39;
+id type version time data
+39 1 1 39000 data
+%nodeGet 98;
+id type version time data
+98 1 1 98000 data
+%nodeGet 1000;
+id type version time data
+%nodeGet -1;
+ERROR HY000: Native procedure failed. (code: 7, msg: 'Invalid arguments: Conversion failed for field id.', query 'nodeGet -1')
+%nodeGet asdf;
+ERROR HY000: Native procedure failed. (code: 7, msg: 'Invalid arguments: Conversion failed for field id.', query 'nodeGet asdf')
+#
+# Test linkGetRange/linkGetId2s function
+#
+create native procedure linkGetRange soname "NP_EXAMPLE_LIB";
+create native procedure linkGetId2s soname "NP_EXAMPLE_LIB";
+%linkGetRange 1 1 1000 2000 0 1000;
+id1 id2 link_type visibility data time version
+1 5 1 1 data 1005 1
+1 4 1 1 data 1004 1
+1 3 1 1 data 1003 1
+1 2 1 1 data 1002 1
+1 1 1 1 data 1001 1
+%linkGetRange 1 2 1000 2000 0 1000;
+id1 id2 link_type visibility data time version
+%linkGetRange 1 1 5000 2000 0 1000;
+id1 id2 link_type visibility data time version
+%linkGetRange 1 2 1000 6000 0 5;
+id1 id2 link_type visibility data time version
+1 5 2 1 data 2005 1
+1 4 2 1 data 2004 1
+1 3 2 1 data 2003 1
+1 2 2 1 data 2002 1
+1 1 2 1 data 2001 1
+%linkGetRange 1 2 1000 6000 0 2;
+id1 id2 link_type visibility data time version
+1 5 2 1 data 2005 1
+1 4 2 1 data 2004 1
+%linkGetRange 1 2 1000 6000 2 2;
+id1 id2 link_type visibility data time version
+1 3 2 1 data 2003 1
+1 2 2 1 data 2002 1
+%linkGetId2s 1 3 3 1 2 3;
+id1 id2 link_type visibility data time version
+1 1 3 1 data 3001 1
+1 2 3 1 data 3002 1
+1 3 3 1 data 3003 1
+%linkGetId2s 1 3 3 3 2 1;
+id1 id2 link_type visibility data time version
+1 3 3 1 data 3003 1
+1 2 3 1 data 3002 1
+1 1 3 1 data 3001 1
+%linkGetId2s 1 3 3 3 2 10;
+id1 id2 link_type visibility data time version
+1 3 3 1 data 3003 1
+1 2 3 1 data 3002 1
+%linkGetId2s 1 3 3 3 2 1 asdf;
+id1 id2 link_type visibility data time version
+1 3 3 1 data 3003 1
+1 2 3 1 data 3002 1
+1 1 3 1 data 3001 1
+%linkGetId2s 1 3 0;
+id1 id2 link_type visibility data time version
+%linkGetId2s 1 3 4 2;
+ERROR HY000: Incorrect arguments to native procedure. (query 'linkGetId2s 1 3 4 2')
+#
+# Test rangeQuery function
+#
+create native procedure rangeQuery soname "NP_EXAMPLE_LIB";
+%rangeQuery 1 0 0 4 id1 1 link_type 1 visibility 1 time 1001 4 id1 1 link_type 1 visibility 1 time 1005;
+id1 id2 link_type visibility data time version
+1 1 1 1 data 1001 1
+1 2 1 1 data 1002 1
+1 3 1 1 data 1003 1
+1 4 1 1 data 1004 1
+1 5 1 1 data 1005 1
+%rangeQuery 1 0 1 4 id1 1 link_type 1 visibility 1 time 1001 4 id1 1 link_type 1 visibility 1 time 1005;
+id1 id2 link_type visibility data time version
+1 1 1 1 data 1001 1
+1 2 1 1 data 1002 1
+1 3 1 1 data 1003 1
+1 4 1 1 data 1004 1
+%rangeQuery 1 1 0 4 id1 1 link_type 1 visibility 1 time 1001 4 id1 1 link_type 1 visibility 1 time 1005;
+id1 id2 link_type visibility data time version
+1 2 1 1 data 1002 1
+1 3 1 1 data 1003 1
+1 4 1 1 data 1004 1
+1 5 1 1 data 1005 1
+%rangeQuery 1 1 1 4 id1 1 link_type 1 visibility 1 time 1001 4 id1 1 link_type 1 visibility 1 time 1005;
+id1 id2 link_type visibility data time version
+1 2 1 1 data 1002 1
+1 3 1 1 data 1003 1
+1 4 1 1 data 1004 1
+%rangeQuery 0 0 0 4 id1 1 link_type 1 visibility 1 time 1001 4 id1 1 link_type 1 visibility 1 time 1005;
+id1 id2 link_type visibility data time version
+1 5 1 1 data 1005 1
+1 4 1 1 data 1004 1
+1 3 1 1 data 1003 1
+1 2 1 1 data 1002 1
+1 1 1 1 data 1001 1
+%rangeQuery 0 0 1 4 id1 1 link_type 1 visibility 1 time 1001 4 id1 1 link_type 1 visibility 1 time 1005;
+id1 id2 link_type visibility data time version
+1 4 1 1 data 1004 1
+1 3 1 1 data 1003 1
+1 2 1 1 data 1002 1
+1 1 1 1 data 1001 1
+%rangeQuery 0 1 0 4 id1 1 link_type 1 visibility 1 time 1001 4 id1 1 link_type 1 visibility 1 time 1005;
+id1 id2 link_type visibility data time version
+1 5 1 1 data 1005 1
+1 4 1 1 data 1004 1
+1 3 1 1 data 1003 1
+1 2 1 1 data 1002 1
+%rangeQuery 0 1 1 4 id1 1 link_type 1 visibility 1 time 1001 4 id1 1 link_type 1 visibility 1 time 1005;
+id1 id2 link_type visibility data time version
+1 4 1 1 data 1004 1
+1 3 1 1 data 1003 1
+1 2 1 1 data 1002 1
+%rangeQuery 1 0 0 2 id1 1 link_type 1 2 id1 1 link_type 2;
+id1 id2 link_type visibility data time version
+1 1 1 1 data 1001 1
+1 2 1 1 data 1002 1
+1 3 1 1 data 1003 1
+1 4 1 1 data 1004 1
+1 5 1 1 data 1005 1
+1 1 2 1 data 2001 1
+1 2 2 1 data 2002 1
+1 3 2 1 data 2003 1
+1 4 2 1 data 2004 1
+1 5 2 1 data 2005 1
+%rangeQuery 1 0 1 2 id1 1 link_type 1 2 id1 1 link_type 2;
+id1 id2 link_type visibility data time version
+1 1 1 1 data 1001 1
+1 2 1 1 data 1002 1
+1 3 1 1 data 1003 1
+1 4 1 1 data 1004 1
+1 5 1 1 data 1005 1
+%rangeQuery 1 1 0 2 id1 1 link_type 1 2 id1 1 link_type 2;
+id1 id2 link_type visibility data time version
+1 1 2 1 data 2001 1
+1 2 2 1 data 2002 1
+1 3 2 1 data 2003 1
+1 4 2 1 data 2004 1
+1 5 2 1 data 2005 1
+%rangeQuery 1 1 1 2 id1 1 link_type 1 2 id1 1 link_type 2;
+id1 id2 link_type visibility data time version
+%rangeQuery 0 0 0 2 id1 1 link_type 1 2 id1 1 link_type 2;
+id1 id2 link_type visibility data time version
+1 5 2 1 data 2005 1
+1 4 2 1 data 2004 1
+1 3 2 1 data 2003 1
+1 2 2 1 data 2002 1
+1 1 2 1 data 2001 1
+1 5 1 1 data 1005 1
+1 4 1 1 data 1004 1
+1 3 1 1 data 1003 1
+1 2 1 1 data 1002 1
+1 1 1 1 data 1001 1
+%rangeQuery 0 0 1 2 id1 1 link_type 1 2 id1 1 link_type 2;
+id1 id2 link_type visibility data time version
+1 5 1 1 data 1005 1
+1 4 1 1 data 1004 1
+1 3 1 1 data 1003 1
+1 2 1 1 data 1002 1
+1 1 1 1 data 1001 1
+%rangeQuery 0 1 0 2 id1 1 link_type 1 2 id1 1 link_type 2;
+id1 id2 link_type visibility data time version
+1 5 2 1 data 2005 1
+1 4 2 1 data 2004 1
+1 3 2 1 data 2003 1
+1 2 2 1 data 2002 1
+1 1 2 1 data 2001 1
+%rangeQuery 0 1 1 2 id1 1 link_type 1 2 id1 1 link_type 2;
+id1 id2 link_type visibility data time version
+%rangeQuery 0 0 0 2 id1 1 link_type 1 4 id1 1 link_type 2 visibility 1 time 2004;
+id1 id2 link_type visibility data time version
+1 4 2 1 data 2004 1
+1 3 2 1 data 2003 1
+1 2 2 1 data 2002 1
+1 1 2 1 data 2001 1
+1 5 1 1 data 1005 1
+1 4 1 1 data 1004 1
+1 3 1 1 data 1003 1
+1 2 1 1 data 1002 1
+1 1 1 1 data 1001 1
+%rangeQuery 0 0 1 2 id1 1 link_type 1 4 id1 1 link_type 2 visibility 1 time 2004;
+id1 id2 link_type visibility data time version
+1 3 2 1 data 2003 1
+1 2 2 1 data 2002 1
+1 1 2 1 data 2001 1
+1 5 1 1 data 1005 1
+1 4 1 1 data 1004 1
+1 3 1 1 data 1003 1
+1 2 1 1 data 1002 1
+1 1 1 1 data 1001 1
+%rangeQuery 0 1 0 2 id1 1 link_type 1 4 id1 1 link_type 2 visibility 1 time 2004;
+id1 id2 link_type visibility data time version
+1 4 2 1 data 2004 1
+1 3 2 1 data 2003 1
+1 2 2 1 data 2002 1
+1 1 2 1 data 2001 1
+%rangeQuery 0 1 1 2 id1 1 link_type 1 4 id1 1 link_type 2 visibility 1 time 2004;
+id1 id2 link_type visibility data time version
+1 3 2 1 data 2003 1
+1 2 2 1 data 2002 1
+1 1 2 1 data 2001 1
+#
+# Test countGet function
+#
+create native procedure countGet soname "NP_EXAMPLE_LIB";
+%countGet 1 1;
+count
+2
+%countGet 10 1;
+count
+20
+%countGet 111 1;
+count
+%countGet 1 111;
+count
+%countGet -1 1 1;
+ERROR HY000: Native procedure failed. (code: 7, msg: 'Invalid arguments: Conversion failed for field id.', query 'countGet -1 1 1')
+%countGet -1 1 2;
+ERROR HY000: Native procedure failed. (code: 7, msg: 'Invalid arguments: Conversion failed for field id.', query 'countGet -1 1 2')
+%countGet;
+ERROR HY000: Incorrect arguments to native procedure. (query 'countGet')
+#
+# Check that DDL locks are respected.
+#
+create native procedure sleepRange soname "NP_EXAMPLE_LIB";
+%sleepRange 1;
+set @start_lock_wait_timeout = @@session.lock_wait_timeout;
+set lock_wait_timeout = 1;
+drop table counttable;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: linkdb.counttable
+set lock_wait_timeout = @start_lock_wait_timeout;
+count
+2
+4
+6
+8
+10
+12
+14
+16
+18
+20
+#
+# Check that queries can be killed.
+#
+%sleepRange 0;
+kill query ID;
+ERROR 70100: Query execution was interrupted
+#
+# Check that native procedures work properly with transactions.
+#
+use linkdb;
+set session transaction isolation level repeatable read;
+%countGet 1 1;
+count
+2
+begin;
+select count from counttable where id = 1 and link_type = 1;
+count
+2
+%countGet 1 1;
+count
+2
+# Before update
+%countGet 1 1;
+count
+2
+update counttable set count = count + 1 where id = 1 and link_type = 1;
+# After update
+%countGet 1 1;
+count
+3
+# Unchanged due to consistent reads
+%countGet 1 1;
+count
+2
+#
+# Check index reads on prefixed data.
+#
+alter table linktable drop index id1_type;
+alter table linktable
+add index id1_type (id1,link_type,visibility,time,version,data(1))
+COMMENT 'rev:cf_link_id1_type';
+%linkGetRange 1 1 1000 2000 0 1000;
+id1 id2 link_type visibility data time version
+1 5 1 1 data 1005 1
+1 4 1 1 data 1004 1
+1 3 1 1 data 1003 1
+1 2 1 1 data 1002 1
+1 1 1 1 data 1001 1
+#
+# Check correct error handling for various scenarios.
+#
+create native procedure invalidKey1 soname "NP_EXAMPLE_LIB";
+%invalidKey1;
+ERROR HY000: Native procedure failed. (code: 6, msg: 'Not found: ', query 'invalidKey1')
+create native procedure invalidOpen1 soname "NP_EXAMPLE_LIB";
+%invalidOpen1;
+ERROR HY000: Native procedure failed. (code: 5, msg: 'Cannot reinitialize: ', query 'invalidOpen1')
+create native procedure invalidOpen2 soname "NP_EXAMPLE_LIB";
+%invalidOpen2;
+ERROR HY000: Native procedure failed. (code: 5, msg: 'Cannot reinitialize: ', query 'invalidOpen2')
+create native procedure invalidOpen3 soname "NP_EXAMPLE_LIB";
+%invalidOpen3;
+ERROR HY000: Native procedure failed. (code: 5, msg: 'Cannot reinitialize: ', query 'invalidOpen3')
+create native procedure invalidOpen4 soname "NP_EXAMPLE_LIB";
+%invalidOpen4;
+ERROR HY000: Native procedure failed. (code: 5, msg: 'Cannot reinitialize: ', query 'invalidOpen4')
+%invalidProcedure;
+ERROR HY000: Unknown native procedure. 'invalidProcedure'
+create native procedure invalidProcedure soname "invalid.so";
+ERROR HY000: Can't open shared library
+create native procedure invalidProcedure soname "NP_EXAMPLE_LIB";
+ERROR HY000: Can't find symbol 'invalidProcedure' in library
+#
+# Check that our functions are reloaded after restart.
+#
+select * from mysql.native_proc order by name;
+name type dl lua
+countGet native np_example.so
+invalidKey1 native np_example.so
+invalidOpen1 native np_example.so
+invalidOpen2 native np_example.so
+invalidOpen3 native np_example.so
+invalidOpen4 native np_example.so
+linkGetId2s native np_example.so
+linkGetRange native np_example.so
+nodeGet native np_example.so
+rangeQuery native np_example.so
+sleepRange native np_example.so
+drop native procedure nodeGet;
+create native procedure nodeGet soname "NP_EXAMPLE_LIB";
+ERROR HY000: Native procedure 'nodeGet' exists.
+drop native procedure linkGetRange;
+drop native procedure linkGetId2s;
+drop native procedure countGet;
+drop native procedure sleepRange;
+drop native procedure rangeQuery;
+drop native procedure invalidKey1;
+drop native procedure invalidOpen1;
+drop native procedure invalidOpen2;
+drop native procedure invalidOpen3;
+drop native procedure invalidOpen4;
+%nodeGet 1;
+ERROR HY000: Unknown native procedure. 'nodeGet'
+#
+# Check that our functions are unloaded after restart.
+#
+select * from mysql.native_proc order by name;
+name type dl lua
+%nodeGet 1;
+ERROR HY000: Unknown native procedure. 'nodeGet'
+drop database linkdb;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/negative_stats.result b/storage/rocksdb/mysql-test/rocksdb/r/negative_stats.result
new file mode 100644
index 00000000..61c1d7e9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/negative_stats.result
@@ -0,0 +1,9 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i1 INT, PRIMARY KEY (i1)) ENGINE = ROCKSDB;
+SET GLOBAL ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW=1;
+set session debug_dbug= "+d,myrocks_simulate_negative_stats";
+SELECT CASE WHEN DATA_LENGTH < 1024 * 1024 THEN 'true' ELSE 'false' END FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
+CASE WHEN DATA_LENGTH < 1024 * 1024 THEN 'true' ELSE 'false' END
+true
+set session debug_dbug= "-d,myrocks_simulate_negative_stats";
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/no_merge_sort.result b/storage/rocksdb/mysql-test/rocksdb/r/no_merge_sort.result
new file mode 100644
index 00000000..6ea13872
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/no_merge_sort.result
@@ -0,0 +1,123 @@
+Warnings:
+Note 1051 Unknown table 'test.ti_nk'
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+skip_merge_sort
+true
+DROP TABLE ti_nk;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/optimize_myrocks_replace_into_base.result b/storage/rocksdb/mysql-test/rocksdb/r/optimize_myrocks_replace_into_base.result
new file mode 100644
index 00000000..12223ebf
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/optimize_myrocks_replace_into_base.result
@@ -0,0 +1,98 @@
+SET @prior_rocksdb_perf_context_level = @@rocksdb_perf_context_level;
+SET GLOBAL rocksdb_perf_context_level=3;
+SET GLOBAL enable_blind_replace=ON;
+create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+c1 c2
+1 1
+2 2
+3 3
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(1,11);
+select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+drop table t1;
+create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
+create trigger trg before insert on t1 for each row set @a:=1;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+c1 c2
+1 1
+2 2
+3 3
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(1,11);
+select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+false
+drop table t1;
+create table t1(c1 int,c2 int) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+c1 c2
+1 1
+2 2
+3 3
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(1,11);
+select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+drop table t1;
+create table t1(c1 int,c2 int unique) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+c1 c2
+1 1
+2 2
+3 3
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(1,11);
+select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+false
+drop table t1;
+create table t1(c1 int primary key,c2 int unique) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+c1 c2
+1 1
+2 2
+3 3
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(1,11);
+select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+false
+drop table t1;
+create table t1(c1 int primary key,c2 int, key idx1(c2)) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+c1 c2
+1 1
+2 2
+3 3
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(1,11);
+select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+false
+drop table t1;
+SET GLOBAL enable_blind_replace=OFF;
+create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+c1 c2
+1 1
+2 2
+3 3
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(1,11);
+select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+false
+drop table t1;
+SET GLOBAL enable_blind_replace=DEFAULT;
+SET GLOBAL rocksdb_perf_context_level = @prior_rocksdb_perf_context_level;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/optimize_myrocks_replace_into_lock.result b/storage/rocksdb/mysql-test/rocksdb/r/optimize_myrocks_replace_into_lock.result
new file mode 100644
index 00000000..65ee9768
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/optimize_myrocks_replace_into_lock.result
@@ -0,0 +1,46 @@
+SET GLOBAL enable_blind_replace=ON;
+create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+c1 c2
+1 1
+2 2
+3 3
+SELECT @@global.enable_blind_replace;
+@@global.enable_blind_replace
+1
+begin;
+replace into t1 values(1,11);
+SELECT @@global.enable_blind_replace;
+@@global.enable_blind_replace
+1
+begin;
+update t1 set c2=22 where c1=1;
+commit;
+# Reap update.
+commit;
+select * from t1;
+c1 c2
+1 22
+2 2
+3 3
+SELECT @@global.enable_blind_replace;
+@@global.enable_blind_replace
+1
+begin;
+update t1 set c2=55 where c1=1;
+SELECT @@global.enable_blind_replace;
+@@global.enable_blind_replace
+1
+begin;
+replace into t1 values(1,66);
+commit;
+# Reap replace into.
+commit;
+select * from t1;
+c1 c2
+1 66
+2 2
+3 3
+drop table t1;
+SET GLOBAL enable_blind_replace=DEFAULT;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/optimize_table.result b/storage/rocksdb/mysql-test/rocksdb/r/optimize_table.result
new file mode 100644
index 00000000..8273fdba
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/optimize_table.result
@@ -0,0 +1,77 @@
+DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6;
+create table t1 (id int primary key, value int, value2 varchar(200), index(value)) engine=rocksdb;
+create table t2 (id int primary key, value int, value2 varchar(200), index(value)) engine=rocksdb;
+create table t3 (id int primary key, value int, value2 varchar(200), index(value)) engine=rocksdb;
+create table t4 (id int, value int, value2 varchar(200), primary key (id) comment 'rev:cf_i', index(value) comment 'rev:cf_i') engine=rocksdb;
+create table t5 (id int, value int, value2 varchar(200), primary key (id) comment 'rev:cf_i', index(value) comment 'rev:cf_i') engine=rocksdb;
+create table t6 (id int, value int, value2 varchar(200), primary key (id) comment 'rev:cf_i', index(value) comment 'rev:cf_i') engine=rocksdb;
+select count(*) from t1;
+count(*)
+10000
+select count(*) from t2;
+count(*)
+10000
+select count(*) from t3;
+count(*)
+10000
+select count(*) from t4;
+count(*)
+10000
+select count(*) from t5;
+count(*)
+10000
+select count(*) from t6;
+count(*)
+10000
+delete from t1 where id <= 9900;
+delete from t2 where id <= 9900;
+delete from t3 where id <= 9900;
+delete from t4 where id <= 9900;
+delete from t5 where id <= 9900;
+delete from t6 where id <= 9900;
+optimize table t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+sst file reduction ok
+optimize table t3;
+Table Op Msg_type Msg_text
+test.t3 optimize status OK
+sst file reduction ok
+optimize table t4;
+Table Op Msg_type Msg_text
+test.t4 optimize status OK
+sst file reduction ok
+optimize table t6;
+Table Op Msg_type Msg_text
+test.t6 optimize status OK
+sst file reduction ok
+select count(*) from t1;
+count(*)
+100
+select count(*) from t2;
+count(*)
+100
+select count(*) from t3;
+count(*)
+100
+select count(*) from t4;
+count(*)
+100
+select count(*) from t5;
+count(*)
+100
+select count(*) from t6;
+count(*)
+100
+optimize table t2;
+Table Op Msg_type Msg_text
+test.t2 optimize status OK
+optimize table t5;
+Table Op Msg_type Msg_text
+test.t5 optimize status OK
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
+DROP TABLE t5;
+DROP TABLE t6;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/optimizer_loose_index_scans.result b/storage/rocksdb/mysql-test/rocksdb/r/optimizer_loose_index_scans.result
new file mode 100644
index 00000000..1fe61fe9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/optimizer_loose_index_scans.result
@@ -0,0 +1,281 @@
+set optimizer_switch='index_merge_sort_union=off';
+create table t (a int, b int, c int, d int, e int, primary key(a, b, c, d), key(b, d)) engine=rocksdb;
+analyze table t;
+Table Op Msg_type Msg_text
+test.t analyze status OK
+show indexes from t;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t 0 PRIMARY 1 a A 100 NULL NULL LSMTREE
+t 0 PRIMARY 2 b A 500 NULL NULL LSMTREE
+t 0 PRIMARY 3 c A 2500 NULL NULL LSMTREE
+t 0 PRIMARY 4 d A 2500 NULL NULL LSMTREE
+t 1 b 1 b A 50 NULL NULL LSMTREE
+t 1 b 2 d A 500 NULL NULL LSMTREE
+set optimizer_switch = 'skip_scan=off';
+explain select b, d from t where d < 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL b 8 NULL # Using where; Using index
+rows_read
+2500
+set optimizer_switch = 'skip_scan=on,skip_scan_cost_based=off';
+explain select b, d from t where d < 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b b 8 NULL # Using where; Using index for skip scan
+rows_read
+260
+include/diff_tables.inc [temp_orig, temp_skip]
+set optimizer_switch = 'skip_scan=off,skip_scan_cost_based=on';
+set optimizer_switch = 'skip_scan=off';
+explain select b, d from t where d > 4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL b 8 NULL # Using where; Using index
+rows_read
+2500
+set optimizer_switch = 'skip_scan=on,skip_scan_cost_based=off';
+explain select b, d from t where d > 4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b b 8 NULL # Using where; Using index for skip scan
+rows_read
+1505
+include/diff_tables.inc [temp_orig, temp_skip]
+set optimizer_switch = 'skip_scan=off,skip_scan_cost_based=on';
+set optimizer_switch = 'skip_scan=off';
+explain select a, b, c, d from t where a = 5 and d <= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ref PRIMARY PRIMARY 4 const # Using where; Using index
+rows_read
+250
+set optimizer_switch = 'skip_scan=on,skip_scan_cost_based=off';
+explain select a, b, c, d from t where a = 5 and d <= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b PRIMARY 16 NULL # Using where; Using index for skip scan
+rows_read
+126
+include/diff_tables.inc [temp_orig, temp_skip]
+set optimizer_switch = 'skip_scan=off,skip_scan_cost_based=on';
+set optimizer_switch = 'skip_scan=off';
+explain select e from t where a = 5 and d <= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ref PRIMARY PRIMARY 4 const # Using where
+rows_read
+250
+set optimizer_switch = 'skip_scan=on,skip_scan_cost_based=off';
+explain select e from t where a = 5 and d <= 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ref PRIMARY,b PRIMARY 4 const # Using where
+rows_read
+250
+include/diff_tables.inc [temp_orig, temp_skip]
+set optimizer_switch = 'skip_scan=off,skip_scan_cost_based=on';
+set optimizer_switch = 'skip_scan=off';
+explain select a, b, c, d from t where a = 5 and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ref PRIMARY PRIMARY 4 const # Using where; Using index
+rows_read
+250
+set optimizer_switch = 'skip_scan=on,skip_scan_cost_based=off';
+explain select a, b, c, d from t where a = 5 and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b PRIMARY 16 NULL # Using where; Using index for skip scan
+rows_read
+26
+include/diff_tables.inc [temp_orig, temp_skip]
+set optimizer_switch = 'skip_scan=off,skip_scan_cost_based=on';
+set optimizer_switch = 'skip_scan=off';
+explain select e from t where a = 5 and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ref PRIMARY PRIMARY 4 const # Using where
+rows_read
+250
+set optimizer_switch = 'skip_scan=on,skip_scan_cost_based=off';
+explain select e from t where a = 5 and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ref PRIMARY,b PRIMARY 4 const # Using where
+rows_read
+250
+include/diff_tables.inc [temp_orig, temp_skip]
+set optimizer_switch = 'skip_scan=off,skip_scan_cost_based=on';
+set optimizer_switch = 'skip_scan=off';
+explain select a, b, c, d from t where a in (1, 5) and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY PRIMARY 4 NULL # Using where; Using index
+rows_read
+500
+set optimizer_switch = 'skip_scan=on,skip_scan_cost_based=off';
+explain select a, b, c, d from t where a in (1, 5) and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b PRIMARY 16 NULL # Using where; Using index for skip scan
+rows_read
+52
+include/diff_tables.inc [temp_orig, temp_skip]
+set optimizer_switch = 'skip_scan=off,skip_scan_cost_based=on';
+set optimizer_switch = 'skip_scan=off';
+explain select a, b, c, d from t where a in (1, 3, 5) and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY PRIMARY 4 NULL # Using where; Using index
+rows_read
+750
+set optimizer_switch = 'skip_scan=on,skip_scan_cost_based=off';
+explain select a, b, c, d from t where a in (1, 3, 5) and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b PRIMARY 16 NULL # Using where; Using index for skip scan
+rows_read
+78
+include/diff_tables.inc [temp_orig, temp_skip]
+set optimizer_switch = 'skip_scan=off,skip_scan_cost_based=on';
+set optimizer_switch = 'skip_scan=off';
+explain select a, b, c, d from t where a in (1, 5) and b in (1, 2) and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b PRIMARY 8 NULL # Using where; Using index
+rows_read
+200
+set optimizer_switch = 'skip_scan=on,skip_scan_cost_based=off';
+explain select a, b, c, d from t where a in (1, 5) and b in (1, 2) and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b PRIMARY 16 NULL # Using where; Using index for skip scan
+rows_read
+24
+include/diff_tables.inc [temp_orig, temp_skip]
+set optimizer_switch = 'skip_scan=off,skip_scan_cost_based=on';
+set optimizer_switch = 'skip_scan=off';
+explain select a, b, c, d from t where a in (1, 2, 3, 4, 5) and b in (1, 2, 3) and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b PRIMARY 8 NULL # Using where; Using index
+rows_read
+750
+set optimizer_switch = 'skip_scan=on,skip_scan_cost_based=off';
+explain select a, b, c, d from t where a in (1, 2, 3, 4, 5) and b in (1, 2, 3) and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b PRIMARY 16 NULL # Using where; Using index for skip scan
+rows_read
+90
+include/diff_tables.inc [temp_orig, temp_skip]
+set optimizer_switch = 'skip_scan=off,skip_scan_cost_based=on';
+set optimizer_switch = 'skip_scan=off';
+explain select a, b, c, d from t where a = 5 and b = 2 and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ref PRIMARY,b PRIMARY 8 const,const # Using where; Using index
+rows_read
+50
+set optimizer_switch = 'skip_scan=on,skip_scan_cost_based=off';
+explain select a, b, c, d from t where a = 5 and b = 2 and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b PRIMARY 16 NULL # Using where; Using index for skip scan
+rows_read
+6
+include/diff_tables.inc [temp_orig, temp_skip]
+set optimizer_switch = 'skip_scan=off,skip_scan_cost_based=on';
+set optimizer_switch = 'skip_scan=off';
+explain select a+1, b, c, d from t where a = 5 and d < 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ref PRIMARY PRIMARY 4 const # Using where; Using index
+rows_read
+250
+set optimizer_switch = 'skip_scan=on,skip_scan_cost_based=off';
+explain select a+1, b, c, d from t where a = 5 and d < 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b PRIMARY 16 NULL # Using where; Using index for skip scan
+rows_read
+101
+include/diff_tables.inc [temp_orig, temp_skip]
+set optimizer_switch = 'skip_scan=off,skip_scan_cost_based=on';
+set optimizer_switch = 'skip_scan=off';
+explain select b, c, d from t where a = 5 and d < 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ref PRIMARY PRIMARY 4 const # Using where; Using index
+rows_read
+250
+set optimizer_switch = 'skip_scan=on,skip_scan_cost_based=off';
+explain select b, c, d from t where a = 5 and d < 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b PRIMARY 16 NULL # Using where; Using index for skip scan
+rows_read
+101
+include/diff_tables.inc [temp_orig, temp_skip]
+set optimizer_switch = 'skip_scan=off,skip_scan_cost_based=on';
+set optimizer_switch = 'skip_scan=off';
+explain select a, b, c, d from t where a = b and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL b 8 NULL # Using where; Using index
+rows_read
+2500
+set optimizer_switch = 'skip_scan=on,skip_scan_cost_based=off';
+explain select a, b, c, d from t where a = b and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b b 8 NULL # Using where; Using index for skip scan
+rows_read
+5
+include/diff_tables.inc [temp_orig, temp_skip]
+set optimizer_switch = 'skip_scan=off,skip_scan_cost_based=on';
+set optimizer_switch = 'skip_scan=on';
+set optimizer_trace = 'enabled=on';
+explain select a, b, c, d from t where a = 5 and d < 3 order by b, c, d;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ref PRIMARY,b PRIMARY 4 const # Using where; Using index
+select count(*) from information_schema.optimizer_trace where trace like '%order_attribute_not_prefix_in_index%';
+count(*)
+1
+explain select a, b, c, d from t where a = 2 and d >= 98 and e = 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ref PRIMARY PRIMARY 4 const # Using where
+select count(*) from information_schema.optimizer_trace where trace like '%query_references_nonkey_column%';
+count(*)
+1
+explain select a, b, c, d from t where a = 5 or b = 2 and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index PRIMARY,b b 8 NULL # Using where; Using index
+select count(*) from information_schema.optimizer_trace where trace like '%no_range_tree%';
+count(*)
+1
+explain select a, b, c, d from t where a = 5 or b = 2 or d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index PRIMARY,b b 8 NULL # Using where; Using index
+select count(*) from information_schema.optimizer_trace where trace like '%no_range_tree%';
+count(*)
+1
+explain select a, b, c, d from t where a = 5 or d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index PRIMARY,b b 8 NULL # Using where; Using index
+select count(*) from information_schema.optimizer_trace where trace like '%no_range_tree%';
+count(*)
+1
+explain select a, b, c, d from t where ((a = 5 and b = 2) or a = 2) and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b b 8 NULL # Using where; Using index for skip scan
+select count(*) from information_schema.optimizer_trace where trace like '%keypart_in_disjunctive_query%';
+count(*)
+1
+explain select a, b, c, d from t where a > 2 and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b PRIMARY 4 NULL # Using where; Using index
+select count(*) from information_schema.optimizer_trace where trace like '%prefix_not_const_equality%';
+count(*)
+1
+explain select a, b, c, d from t where a = 2 and (d >= 98 or d < 2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ref PRIMARY,b PRIMARY 4 const # Using where; Using index
+select count(*) from information_schema.optimizer_trace where trace like '%range_predicate_too_complex%';
+count(*)
+1
+explain select a, b, c, d from t where a = 2 and b = 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ref PRIMARY,b PRIMARY 8 const,const # Using index
+select count(*) from information_schema.optimizer_trace where trace like '%no_range_predicate%';
+count(*)
+1
+explain select a, b, c, d from t where a = 2 and c > 2 and d < 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ref PRIMARY,b PRIMARY 4 const # Using where; Using index
+select count(*) from information_schema.optimizer_trace where trace like '%too_many_range_predicates%';
+count(*)
+1
+explain select a, b, c, d from t where (a < 1 or a = 4 or a = 5) and b in (1, 2, 3) and d >= 98;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range PRIMARY,b PRIMARY 8 NULL # Using where; Using index
+select count(*) from information_schema.optimizer_trace where trace like '%prefix_not_const_equality%';
+count(*)
+1
+set optimizer_trace = 'enabled=off';
+set optimizer_switch= 'skip_scan=off';
+drop table t;
+set optimizer_switch='index_merge_sort_union=on';
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/partition.result b/storage/rocksdb/mysql-test/rocksdb/r/partition.result
new file mode 100644
index 00000000..a7f2a611
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/partition.result
@@ -0,0 +1,689 @@
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS VAR_POP;
+DROP TABLE IF EXISTS TEMP0;
+DROP TABLE IF EXISTS VAR_SAMP;
+DROP TABLE IF EXISTS ti;
+DROP TABLE IF EXISTS members;
+DROP TABLE IF EXISTS members_2;
+DROP TABLE IF EXISTS employees;
+DROP TABLE IF EXISTS employees_2;
+DROP TABLE IF EXISTS employees_3;
+DROP TABLE IF EXISTS quarterly_report_status;
+DROP TABLE IF EXISTS employees_4;
+DROP TABLE IF EXISTS h2;
+DROP TABLE IF EXISTS rcx;
+DROP TABLE IF EXISTS r1;
+DROP TABLE IF EXISTS rc1;
+DROP TABLE IF EXISTS rx;
+DROP TABLE IF EXISTS rc2;
+DROP TABLE IF EXISTS rc3;
+DROP TABLE IF EXISTS rc4;
+DROP TABLE IF EXISTS employees_by_lname;
+DROP TABLE IF EXISTS customers_1;
+DROP TABLE IF EXISTS customers_2;
+DROP TABLE IF EXISTS customers_3;
+DROP TABLE IF EXISTS employees_hash;
+DROP TABLE IF EXISTS employees_hash_1;
+DROP TABLE IF EXISTS t1_hash;
+DROP TABLE IF EXISTS employees_linear_hash;
+DROP TABLE IF EXISTS t1_linear_hash;
+DROP TABLE IF EXISTS k1;
+DROP TABLE IF EXISTS k2;
+DROP TABLE IF EXISTS tm1;
+DROP TABLE IF EXISTS tk;
+DROP TABLE IF EXISTS ts;
+DROP TABLE IF EXISTS ts_1;
+DROP TABLE IF EXISTS ts_3;
+DROP TABLE IF EXISTS ts_4;
+DROP TABLE IF EXISTS ts_5;
+DROP TABLE IF EXISTS trb3;
+DROP TABLE IF EXISTS tr;
+DROP TABLE IF EXISTS members_3;
+DROP TABLE IF EXISTS clients;
+DROP TABLE IF EXISTS clients_lk;
+DROP TABLE IF EXISTS trb1;
+CREATE TABLE t1 (i INT, j INT, k INT, PRIMARY KEY (i)) ENGINE = ROCKSDB PARTITION BY KEY(i) PARTITIONS 4;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+Table Op Msg_type Msg_text
+test.t1 check status OK
+select lower(table_name) as tname
+from information_schema.tables
+where table_schema=database()
+order by tname;
+tname
+t1
+temp0
+var_pop
+var_samp
+SELECT * FROM t1 ORDER BY i LIMIT 10;
+i j k
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+8 8 8
+9 9 9
+10 10 10
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1000
+CREATE TABLE ti(
+id INT,
+amount DECIMAL(7,2),
+tr_date DATE
+) ENGINE=ROCKSDB
+PARTITION BY HASH(MONTH(tr_date))
+PARTITIONS 6;
+CREATE TABLE members (
+firstname VARCHAR(25) NOT NULL,
+lastname VARCHAR(25) NOT NULL,
+username VARCHAR(16) NOT NULL,
+email VARCHAR(35),
+joined DATE NOT NULL
+) ENGINE=ROCKSDB
+PARTITION BY KEY(joined)
+PARTITIONS 6;
+CREATE TABLE members_2 (
+firstname VARCHAR(25) NOT NULL,
+lastname VARCHAR(25) NOT NULL,
+username VARCHAR(16) NOT NULL,
+email VARCHAR(35),
+joined DATE NOT NULL
+) ENGINE=ROCKSDB
+PARTITION BY RANGE(YEAR(joined)) (
+PARTITION p0 VALUES LESS THAN (1960),
+PARTITION p1 VALUES LESS THAN (1970),
+PARTITION p2 VALUES LESS THAN (1980),
+PARTITION p3 VALUES LESS THAN (1990),
+PARTITION p4 VALUES LESS THAN MAXVALUE
+);
+CREATE TABLE t2 (val INT)
+ENGINE=ROCKSDB
+PARTITION BY LIST(val)(
+PARTITION mypart VALUES IN (1,3,5),
+PARTITION MyPart VALUES IN (2,4,6)
+);
+ERROR HY000: Duplicate partition name MyPart
+CREATE TABLE employees (
+id INT NOT NULL,
+fname VARCHAR(30),
+lname VARCHAR(30),
+hired DATE NOT NULL DEFAULT '1970-01-01',
+separated DATE NOT NULL DEFAULT '9999-12-31',
+job_code INT NOT NULL,
+store_id INT NOT NULL
+) ENGINE=ROCKSDB
+PARTITION BY RANGE (store_id) (
+PARTITION p0 VALUES LESS THAN (6),
+PARTITION p1 VALUES LESS THAN (11),
+PARTITION p2 VALUES LESS THAN (16),
+PARTITION p3 VALUES LESS THAN MAXVALUE
+);
+CREATE TABLE employees_2 (
+id INT NOT NULL,
+fname VARCHAR(30),
+lname VARCHAR(30),
+hired DATE NOT NULL DEFAULT '1970-01-01',
+separated DATE NOT NULL DEFAULT '9999-12-31',
+job_code INT NOT NULL,
+store_id INT NOT NULL
+) ENGINE=ROCKSDB
+PARTITION BY RANGE (job_code) (
+PARTITION p0 VALUES LESS THAN (100),
+PARTITION p1 VALUES LESS THAN (1000),
+PARTITION p2 VALUES LESS THAN (10000)
+);
+CREATE TABLE employees_3 (
+id INT NOT NULL,
+fname VARCHAR(30),
+lname VARCHAR(30),
+hired DATE NOT NULL DEFAULT '1970-01-01',
+separated DATE NOT NULL DEFAULT '9999-12-31',
+job_code INT,
+store_id INT
+) ENGINE=ROCKSDB
+PARTITION BY RANGE (YEAR(separated)) (
+PARTITION p0 VALUES LESS THAN (1991),
+PARTITION p1 VALUES LESS THAN (1996),
+PARTITION p2 VALUES LESS THAN (2001),
+PARTITION p3 VALUES LESS THAN MAXVALUE
+);
+CREATE TABLE quarterly_report_status (
+report_id INT NOT NULL,
+report_status VARCHAR(20) NOT NULL,
+report_updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
+) ENGINE=ROCKSDB
+PARTITION BY RANGE (UNIX_TIMESTAMP(report_updated)) (
+PARTITION p0 VALUES LESS THAN ( UNIX_TIMESTAMP('2008-01-01 00:00:00') ),
+PARTITION p1 VALUES LESS THAN ( UNIX_TIMESTAMP('2008-04-01 00:00:00') ),
+PARTITION p2 VALUES LESS THAN ( UNIX_TIMESTAMP('2008-07-01 00:00:00') ),
+PARTITION p3 VALUES LESS THAN ( UNIX_TIMESTAMP('2008-10-01 00:00:00') ),
+PARTITION p4 VALUES LESS THAN ( UNIX_TIMESTAMP('2009-01-01 00:00:00') ),
+PARTITION p5 VALUES LESS THAN ( UNIX_TIMESTAMP('2009-04-01 00:00:00') ),
+PARTITION p6 VALUES LESS THAN ( UNIX_TIMESTAMP('2009-07-01 00:00:00') ),
+PARTITION p7 VALUES LESS THAN ( UNIX_TIMESTAMP('2009-10-01 00:00:00') ),
+PARTITION p8 VALUES LESS THAN ( UNIX_TIMESTAMP('2010-01-01 00:00:00') ),
+PARTITION p9 VALUES LESS THAN (MAXVALUE)
+);
+CREATE TABLE employees_4 (
+id INT NOT NULL,
+fname VARCHAR(30),
+lname VARCHAR(30),
+hired DATE NOT NULL DEFAULT '1970-01-01',
+separated DATE NOT NULL DEFAULT '9999-12-31',
+job_code INT,
+store_id INT
+) ENGINE=ROCKSDB
+PARTITION BY LIST(store_id) (
+PARTITION pNorth VALUES IN (3,5,6,9,17),
+PARTITION pEast VALUES IN (1,2,10,11,19,20),
+PARTITION pWest VALUES IN (4,12,13,14,18),
+PARTITION pCentral VALUES IN (7,8,15,16)
+);
+CREATE TABLE h2 (
+c1 INT,
+c2 INT
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+PARTITION p0 VALUES IN (1, 4, 7),
+PARTITION p1 VALUES IN (2, 5, 8)
+);
+INSERT INTO h2 VALUES (3, 5);
+ERROR HY000: Table has no partition for value 3
+CREATE TABLE rcx (
+a INT,
+b INT,
+c CHAR(3),
+d INT
+) ENGINE=ROCKSDB
+PARTITION BY RANGE COLUMNS(a,d,c) (
+PARTITION p0 VALUES LESS THAN (5,10,'ggg'),
+PARTITION p1 VALUES LESS THAN (10,20,'mmm'),
+PARTITION p2 VALUES LESS THAN (15,30,'sss'),
+PARTITION p3 VALUES LESS THAN (MAXVALUE,MAXVALUE,MAXVALUE)
+);
+CREATE TABLE r1 (
+a INT,
+b INT
+) ENGINE=ROCKSDB
+PARTITION BY RANGE (a) (
+PARTITION p0 VALUES LESS THAN (5),
+PARTITION p1 VALUES LESS THAN (MAXVALUE)
+);
+INSERT INTO r1 VALUES (5,10), (5,11), (5,12);
+CREATE TABLE rc1 (
+a INT,
+b INT
+) ENGINE=ROCKSDB
+PARTITION BY RANGE COLUMNS(a, b) (
+PARTITION p0 VALUES LESS THAN (5, 12),
+PARTITION p3 VALUES LESS THAN (MAXVALUE, MAXVALUE)
+);
+INSERT INTO rc1 VALUES (5,10), (5,11), (5,12);
+SELECT (5,10) < (5,12), (5,11) < (5,12), (5,12) < (5,12);
+(5,10) < (5,12) (5,11) < (5,12) (5,12) < (5,12)
+1 1 0
+CREATE TABLE rx (
+a INT,
+b INT
+) ENGINE=ROCKSDB
+PARTITION BY RANGE COLUMNS (a) (
+PARTITION p0 VALUES LESS THAN (5),
+PARTITION p1 VALUES LESS THAN (MAXVALUE)
+);
+INSERT INTO rx VALUES (5,10), (5,11), (5,12);
+CREATE TABLE rc2 (
+a INT,
+b INT
+) ENGINE=ROCKSDB
+PARTITION BY RANGE COLUMNS(a,b) (
+PARTITION p0 VALUES LESS THAN (0,10),
+PARTITION p1 VALUES LESS THAN (10,20),
+PARTITION p2 VALUES LESS THAN (10,30),
+PARTITION p3 VALUES LESS THAN (MAXVALUE,MAXVALUE)
+);
+CREATE TABLE rc3 (
+a INT,
+b INT
+) ENGINE=ROCKSDB
+PARTITION BY RANGE COLUMNS(a,b) (
+PARTITION p0 VALUES LESS THAN (0,10),
+PARTITION p1 VALUES LESS THAN (10,20),
+PARTITION p2 VALUES LESS THAN (10,30),
+PARTITION p3 VALUES LESS THAN (10,35),
+PARTITION p4 VALUES LESS THAN (20,40),
+PARTITION p5 VALUES LESS THAN (MAXVALUE,MAXVALUE)
+);
+CREATE TABLE rc4 (
+a INT,
+b INT,
+c INT
+) ENGINE=ROCKSDB
+PARTITION BY RANGE COLUMNS(a,b,c) (
+PARTITION p0 VALUES LESS THAN (0,25,50),
+PARTITION p1 VALUES LESS THAN (10,20,100),
+PARTITION p2 VALUES LESS THAN (10,30,50),
+PARTITION p3 VALUES LESS THAN (MAXVALUE,MAXVALUE,MAXVALUE)
+);
+SELECT (0,25,50) < (10,20,100), (10,20,100) < (10,30,50);
+(0,25,50) < (10,20,100) (10,20,100) < (10,30,50)
+1 1
+CREATE TABLE rcf (
+a INT,
+b INT,
+c INT
+) ENGINE=ROCKSDB
+PARTITION BY RANGE COLUMNS(a,b,c) (
+PARTITION p0 VALUES LESS THAN (0,25,50),
+PARTITION p1 VALUES LESS THAN (20,20,100),
+PARTITION p2 VALUES LESS THAN (10,30,50),
+PARTITION p3 VALUES LESS THAN (MAXVALUE,MAXVALUE,MAXVALUE)
+);
+ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition
+CREATE TABLE employees_by_lname (
+id INT NOT NULL,
+fname VARCHAR(30),
+lname VARCHAR(30),
+hired DATE NOT NULL DEFAULT '1970-01-01',
+separated DATE NOT NULL DEFAULT '9999-12-31',
+job_code INT NOT NULL,
+store_id INT NOT NULL
+) ENGINE=ROCKSDB
+PARTITION BY RANGE COLUMNS (lname) (
+PARTITION p0 VALUES LESS THAN ('g'),
+PARTITION p1 VALUES LESS THAN ('m'),
+PARTITION p2 VALUES LESS THAN ('t'),
+PARTITION p3 VALUES LESS THAN (MAXVALUE)
+);
+ALTER TABLE employees_by_lname PARTITION BY RANGE COLUMNS (lname) (
+PARTITION p0 VALUES LESS THAN ('g'),
+PARTITION p1 VALUES LESS THAN ('m'),
+PARTITION p2 VALUES LESS THAN ('t'),
+PARTITION p3 VALUES LESS THAN (MAXVALUE)
+);
+ALTER TABLE employees_by_lname PARTITION BY RANGE COLUMNS (hired) (
+PARTITION p0 VALUES LESS THAN ('1970-01-01'),
+PARTITION p1 VALUES LESS THAN ('1980-01-01'),
+PARTITION p2 VALUES LESS THAN ('1990-01-01'),
+PARTITION p3 VALUES LESS THAN ('2000-01-01'),
+PARTITION p4 VALUES LESS THAN ('2010-01-01'),
+PARTITION p5 VALUES LESS THAN (MAXVALUE)
+);
+CREATE TABLE customers_1 (
+first_name VARCHAR(25),
+last_name VARCHAR(25),
+street_1 VARCHAR(30),
+street_2 VARCHAR(30),
+city VARCHAR(15),
+renewal DATE
+) ENGINE=ROCKSDB
+PARTITION BY LIST COLUMNS(city) (
+PARTITION pRegion_1 VALUES IN('Oskarshamn', 'Högsby', 'Mönsterås'),
+PARTITION pRegion_2 VALUES IN('Vimmerby', 'Hultsfred', 'Västervik'),
+PARTITION pRegion_3 VALUES IN('Nässjö', 'Eksjö', 'Vetlanda'),
+PARTITION pRegion_4 VALUES IN('Uppvidinge', 'Alvesta', 'Växjo')
+);
+CREATE TABLE customers_2 (
+first_name VARCHAR(25),
+last_name VARCHAR(25),
+street_1 VARCHAR(30),
+street_2 VARCHAR(30),
+city VARCHAR(15),
+renewal DATE
+) ENGINE=ROCKSDB
+PARTITION BY LIST COLUMNS(renewal) (
+PARTITION pWeek_1 VALUES IN('2010-02-01', '2010-02-02', '2010-02-03',
+'2010-02-04', '2010-02-05', '2010-02-06', '2010-02-07'),
+PARTITION pWeek_2 VALUES IN('2010-02-08', '2010-02-09', '2010-02-10',
+'2010-02-11', '2010-02-12', '2010-02-13', '2010-02-14'),
+PARTITION pWeek_3 VALUES IN('2010-02-15', '2010-02-16', '2010-02-17',
+'2010-02-18', '2010-02-19', '2010-02-20', '2010-02-21'),
+PARTITION pWeek_4 VALUES IN('2010-02-22', '2010-02-23', '2010-02-24',
+'2010-02-25', '2010-02-26', '2010-02-27', '2010-02-28')
+);
+CREATE TABLE customers_3 (
+first_name VARCHAR(25),
+last_name VARCHAR(25),
+street_1 VARCHAR(30),
+street_2 VARCHAR(30),
+city VARCHAR(15),
+renewal DATE
+) ENGINE=ROCKSDB
+PARTITION BY RANGE COLUMNS(renewal) (
+PARTITION pWeek_1 VALUES LESS THAN('2010-02-09'),
+PARTITION pWeek_2 VALUES LESS THAN('2010-02-15'),
+PARTITION pWeek_3 VALUES LESS THAN('2010-02-22'),
+PARTITION pWeek_4 VALUES LESS THAN('2010-03-01')
+);
+CREATE TABLE employees_hash (
+id INT NOT NULL,
+fname VARCHAR(30),
+lname VARCHAR(30),
+hired DATE NOT NULL DEFAULT '1970-01-01',
+separated DATE NOT NULL DEFAULT '9999-12-31',
+job_code INT,
+store_id INT
+) ENGINE=ROCKSDB
+PARTITION BY HASH(store_id)
+PARTITIONS 4;
+CREATE TABLE employees_hash_1 (
+id INT NOT NULL,
+fname VARCHAR(30),
+lname VARCHAR(30),
+hired DATE NOT NULL DEFAULT '1970-01-01',
+separated DATE NOT NULL DEFAULT '9999-12-31',
+job_code INT,
+store_id INT
+) ENGINE=ROCKSDB
+PARTITION BY HASH( YEAR(hired) )
+PARTITIONS 4;
+CREATE TABLE t1_hash (
+col1 INT,
+col2 CHAR(5),
+col3 DATE
+) ENGINE=ROCKSDB
+PARTITION BY HASH( YEAR(col3) )
+PARTITIONS 4;
+CREATE TABLE employees_linear_hash (
+id INT NOT NULL,
+fname VARCHAR(30),
+lname VARCHAR(30),
+hired DATE NOT NULL DEFAULT '1970-01-01',
+separated DATE NOT NULL DEFAULT '9999-12-31',
+job_code INT,
+store_id INT
+) ENGINE=ROCKSDB
+PARTITION BY LINEAR HASH( YEAR(hired) )
+PARTITIONS 4;
+CREATE TABLE t1_linear_hash (
+col1 INT,
+col2 CHAR(5),
+col3 DATE
+) ENGINE=ROCKSDB
+PARTITION BY LINEAR HASH( YEAR(col3) )
+PARTITIONS 6;
+CREATE TABLE k1 (
+id INT NOT NULL PRIMARY KEY,
+name VARCHAR(20)
+) ENGINE=ROCKSDB
+PARTITION BY KEY()
+PARTITIONS 2;
+CREATE TABLE k2 (
+id INT NOT NULL,
+name VARCHAR(20),
+UNIQUE KEY (id)
+) ENGINE=ROCKSDB
+PARTITION BY KEY()
+PARTITIONS 2;
+CREATE TABLE tm1 (
+s1 CHAR(32) PRIMARY KEY
+) ENGINE=ROCKSDB
+PARTITION BY KEY(s1)
+PARTITIONS 10;
+CREATE TABLE tk (
+col1 INT NOT NULL,
+col2 CHAR(5),
+col3 DATE
+) ENGINE=ROCKSDB
+PARTITION BY LINEAR KEY (col1)
+PARTITIONS 3;
+CREATE TABLE ts (
+id INT,
+purchased DATE
+) ENGINE=ROCKSDB
+PARTITION BY RANGE( YEAR(purchased) )
+SUBPARTITION BY HASH( TO_DAYS(purchased) )
+SUBPARTITIONS 2 (
+PARTITION p0 VALUES LESS THAN (1990),
+PARTITION p1 VALUES LESS THAN (2000),
+PARTITION p2 VALUES LESS THAN MAXVALUE
+);
+CREATE TABLE ts_1 (
+id INT,
+purchased DATE
+) ENGINE=ROCKSDB
+PARTITION BY RANGE( YEAR(purchased) )
+SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
+PARTITION p0 VALUES LESS THAN (1990) (
+SUBPARTITION s0,
+SUBPARTITION s1
+),
+PARTITION p1 VALUES LESS THAN (2000) (
+SUBPARTITION s2,
+SUBPARTITION s3
+),
+PARTITION p2 VALUES LESS THAN MAXVALUE (
+SUBPARTITION s4,
+SUBPARTITION s5
+)
+);
+CREATE TABLE ts_2 (
+id INT,
+purchased DATE
+) ENGINE=ROCKSDB
+PARTITION BY RANGE( YEAR(purchased) )
+SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
+PARTITION p0 VALUES LESS THAN (1990) (
+SUBPARTITION s0,
+SUBPARTITION s1
+),
+PARTITION p1 VALUES LESS THAN (2000),
+PARTITION p2 VALUES LESS THAN MAXVALUE (
+SUBPARTITION s2,
+SUBPARTITION s3
+)
+);
+ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near '
+PARTITION p2 VALUES LESS THAN MAXVALUE (
+SUBPARTITION s2,
+SUBPARTITION s3
+)
+)' at line 11
+CREATE TABLE ts_3 (
+id INT,
+purchased DATE
+) ENGINE=ROCKSDB
+PARTITION BY RANGE( YEAR(purchased) )
+SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
+PARTITION p0 VALUES LESS THAN (1990) (
+SUBPARTITION s0,
+SUBPARTITION s1
+),
+PARTITION p1 VALUES LESS THAN (2000) (
+SUBPARTITION s2,
+SUBPARTITION s3
+),
+PARTITION p2 VALUES LESS THAN MAXVALUE (
+SUBPARTITION s4,
+SUBPARTITION s5
+)
+);
+CREATE TABLE ts_4 (
+id INT,
+purchased DATE
+) ENGINE=ROCKSDB
+PARTITION BY RANGE( YEAR(purchased) )
+SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
+PARTITION p0 VALUES LESS THAN (1990) (
+SUBPARTITION s0,
+SUBPARTITION s1
+),
+PARTITION p1 VALUES LESS THAN (2000) (
+SUBPARTITION s2,
+SUBPARTITION s3
+),
+PARTITION p2 VALUES LESS THAN MAXVALUE (
+SUBPARTITION s4,
+SUBPARTITION s5
+)
+);
+CREATE TABLE ts_5 (
+id INT,
+purchased DATE
+) ENGINE=ROCKSDB
+PARTITION BY RANGE(YEAR(purchased))
+SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
+PARTITION p0 VALUES LESS THAN (1990) (
+SUBPARTITION s0a,
+SUBPARTITION s0b
+),
+PARTITION p1 VALUES LESS THAN (2000) (
+SUBPARTITION s1a,
+SUBPARTITION s1b
+),
+PARTITION p2 VALUES LESS THAN MAXVALUE (
+SUBPARTITION s2a,
+SUBPARTITION s2b
+)
+);
+CREATE TABLE trb3 (
+id INT,
+name VARCHAR(50),
+purchased DATE
+) ENGINE=ROCKSDB
+PARTITION BY RANGE( YEAR(purchased) ) (
+PARTITION p0 VALUES LESS THAN (1990),
+PARTITION p1 VALUES LESS THAN (1995),
+PARTITION p2 VALUES LESS THAN (2000),
+PARTITION p3 VALUES LESS THAN (2005)
+);
+ALTER TABLE trb3 PARTITION BY KEY(id) PARTITIONS 2;
+CREATE TABLE tr (
+id INT,
+name VARCHAR(50),
+purchased DATE
+) ENGINE=ROCKSDB
+PARTITION BY RANGE( YEAR(purchased) ) (
+PARTITION p0 VALUES LESS THAN (1990),
+PARTITION p1 VALUES LESS THAN (1995),
+PARTITION p2 VALUES LESS THAN (2000),
+PARTITION p3 VALUES LESS THAN (2005)
+);
+INSERT INTO tr VALUES
+(1, 'desk organiser', '2003-10-15'),
+(2, 'CD player', '1993-11-05'),
+(3, 'TV set', '1996-03-10'),
+(4, 'bookcase', '1982-01-10'),
+(5, 'exercise bike', '2004-05-09'),
+(6, 'sofa', '1987-06-05'),
+(7, 'popcorn maker', '2001-11-22'),
+(8, 'aquarium', '1992-08-04'),
+(9, 'study desk', '1984-09-16'),
+(10, 'lava lamp', '1998-12-25');
+SELECT * FROM tr WHERE purchased BETWEEN '1995-01-01' AND '1999-12-31';
+id name purchased
+3 TV set 1996-03-10
+10 lava lamp 1998-12-25
+ALTER TABLE tr DROP PARTITION p2;
+SELECT * FROM tr WHERE purchased BETWEEN '1995-01-01' AND '1999-12-31';
+id name purchased
+CREATE TABLE members_3 (
+id INT,
+fname VARCHAR(25),
+lname VARCHAR(25),
+dob DATE
+) ENGINE=ROCKSDB
+PARTITION BY RANGE( YEAR(dob) ) (
+PARTITION p0 VALUES LESS THAN (1970),
+PARTITION p1 VALUES LESS THAN (1980),
+PARTITION p2 VALUES LESS THAN (1990)
+);
+ALTER TABLE members_3 ADD PARTITION (PARTITION p3 VALUES LESS THAN (2000));
+ALTER TABLE members_3 ADD PARTITION (PARTITION n VALUES LESS THAN (1960));
+ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition
+CREATE TABLE clients (
+id INT,
+fname VARCHAR(30),
+lname VARCHAR(30),
+signed DATE
+) ENGINE=ROCKSDB
+PARTITION BY HASH( MONTH(signed) )
+PARTITIONS 12;
+ALTER TABLE clients COALESCE PARTITION 4;
+CREATE TABLE clients_lk (
+id INT,
+fname VARCHAR(30),
+lname VARCHAR(30),
+signed DATE
+) ENGINE=ROCKSDB
+PARTITION BY LINEAR KEY(signed)
+PARTITIONS 12;
+ALTER TABLE clients COALESCE PARTITION 18;
+ERROR HY000: Cannot remove all partitions, use DROP TABLE instead
+ALTER TABLE clients ADD PARTITION PARTITIONS 6;
+CREATE TABLE trb1 (
+id INT,
+name VARCHAR(50),
+purchased DATE
+) ENGINE=ROCKSDB
+PARTITION BY RANGE(id) (
+PARTITION p0 VALUES LESS THAN (3),
+PARTITION p1 VALUES LESS THAN (7),
+PARTITION p2 VALUES LESS THAN (9),
+PARTITION p3 VALUES LESS THAN (11)
+);
+INSERT INTO trb1 VALUES
+(1, 'desk organiser', '2003-10-15'),
+(2, 'CD player', '1993-11-05'),
+(3, 'TV set', '1996-03-10'),
+(4, 'bookcase', '1982-01-10'),
+(5, 'exercise bike', '2004-05-09'),
+(6, 'sofa', '1987-06-05'),
+(7, 'popcorn maker', '2001-11-22'),
+(8, 'aquarium', '1992-08-04'),
+(9, 'study desk', '1984-09-16'),
+(10, 'lava lamp', '1998-12-25');
+ALTER TABLE trb1 ADD PRIMARY KEY (id);
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS VAR_POP;
+DROP TABLE IF EXISTS TEMP0;
+DROP TABLE IF EXISTS VAR_SAMP;
+DROP TABLE IF EXISTS ti;
+DROP TABLE IF EXISTS members;
+DROP TABLE IF EXISTS members_2;
+DROP TABLE IF EXISTS employees;
+DROP TABLE IF EXISTS employees_2;
+DROP TABLE IF EXISTS employees_3;
+DROP TABLE IF EXISTS quarterly_report_status;
+DROP TABLE IF EXISTS employees_4;
+DROP TABLE IF EXISTS h2;
+DROP TABLE IF EXISTS rcx;
+DROP TABLE IF EXISTS r1;
+DROP TABLE IF EXISTS rc1;
+DROP TABLE IF EXISTS rx;
+DROP TABLE IF EXISTS rc2;
+DROP TABLE IF EXISTS rc3;
+DROP TABLE IF EXISTS rc4;
+DROP TABLE IF EXISTS employees_by_lname;
+DROP TABLE IF EXISTS customers_1;
+DROP TABLE IF EXISTS customers_2;
+DROP TABLE IF EXISTS customers_3;
+DROP TABLE IF EXISTS employees_hash;
+DROP TABLE IF EXISTS employees_hash_1;
+DROP TABLE IF EXISTS t1_hash;
+DROP TABLE IF EXISTS employees_linear_hash;
+DROP TABLE IF EXISTS t1_linear_hash;
+DROP TABLE IF EXISTS k1;
+DROP TABLE IF EXISTS k2;
+DROP TABLE IF EXISTS tm1;
+DROP TABLE IF EXISTS tk;
+DROP TABLE IF EXISTS ts;
+DROP TABLE IF EXISTS ts_1;
+DROP TABLE IF EXISTS ts_3;
+DROP TABLE IF EXISTS ts_4;
+DROP TABLE IF EXISTS ts_5;
+DROP TABLE IF EXISTS trb3;
+DROP TABLE IF EXISTS tr;
+DROP TABLE IF EXISTS members_3;
+DROP TABLE IF EXISTS clients;
+DROP TABLE IF EXISTS clients_lk;
+DROP TABLE IF EXISTS trb1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/percona_nonflushing_analyze_debug.result b/storage/rocksdb/mysql-test/rocksdb/r/percona_nonflushing_analyze_debug.result
new file mode 100644
index 00000000..84176da3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/percona_nonflushing_analyze_debug.result
@@ -0,0 +1,19 @@
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1), (2), (3);
+SET DEBUG_SYNC="handler_ha_index_next_end SIGNAL idx_scan_in_progress WAIT_FOR finish_scan";
+SELECT * FROM t1;
+SET DEBUG_SYNC="now WAIT_FOR idx_scan_in_progress";
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+SELECT * FROM t1;
+a
+1
+2
+3
+SET DEBUG_SYNC="now SIGNAL finish_scan";
+a
+1
+2
+3
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/perf_context.result b/storage/rocksdb/mysql-test/rocksdb/r/perf_context.result
new file mode 100644
index 00000000..28f96584
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/perf_context.result
@@ -0,0 +1,191 @@
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+SET @prior_rocksdb_perf_context_level = @@rocksdb_perf_context_level;
+SET GLOBAL rocksdb_perf_context_level=3;
+CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i)) ENGINE = ROCKSDB;
+CREATE TABLE t2 (k INT, PRIMARY KEY (k)) ENGINE = ROCKSDB;
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4), (5,5);
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT WHERE TABLE_NAME = 't1';
+TABLE_SCHEMA TABLE_NAME PARTITION_NAME STAT_TYPE VALUE
+test t1 NULL USER_KEY_COMPARISON_COUNT #
+test t1 NULL BLOCK_CACHE_HIT_COUNT #
+test t1 NULL BLOCK_READ_COUNT #
+test t1 NULL BLOCK_READ_BYTE #
+test t1 NULL BLOCK_READ_TIME #
+test t1 NULL BLOCK_CHECKSUM_TIME #
+test t1 NULL BLOCK_DECOMPRESS_TIME #
+test t1 NULL GET_READ_BYTES #
+test t1 NULL MULTIGET_READ_BYTES #
+test t1 NULL ITER_READ_BYTES #
+test t1 NULL INTERNAL_KEY_SKIPPED_COUNT #
+test t1 NULL INTERNAL_DELETE_SKIPPED_COUNT #
+test t1 NULL INTERNAL_RECENT_SKIPPED_COUNT #
+test t1 NULL INTERNAL_MERGE_COUNT #
+test t1 NULL GET_SNAPSHOT_TIME #
+test t1 NULL GET_FROM_MEMTABLE_TIME #
+test t1 NULL GET_FROM_MEMTABLE_COUNT #
+test t1 NULL GET_POST_PROCESS_TIME #
+test t1 NULL GET_FROM_OUTPUT_FILES_TIME #
+test t1 NULL SEEK_ON_MEMTABLE_TIME #
+test t1 NULL SEEK_ON_MEMTABLE_COUNT #
+test t1 NULL NEXT_ON_MEMTABLE_COUNT #
+test t1 NULL PREV_ON_MEMTABLE_COUNT #
+test t1 NULL SEEK_CHILD_SEEK_TIME #
+test t1 NULL SEEK_CHILD_SEEK_COUNT #
+test t1 NULL SEEK_MIN_HEAP_TIME #
+test t1 NULL SEEK_MAX_HEAP_TIME #
+test t1 NULL SEEK_INTERNAL_SEEK_TIME #
+test t1 NULL FIND_NEXT_USER_ENTRY_TIME #
+test t1 NULL WRITE_WAL_TIME #
+test t1 NULL WRITE_MEMTABLE_TIME #
+test t1 NULL WRITE_DELAY_TIME #
+test t1 NULL WRITE_PRE_AND_POST_PROCESS_TIME #
+test t1 NULL DB_MUTEX_LOCK_NANOS #
+test t1 NULL DB_CONDITION_WAIT_NANOS #
+test t1 NULL MERGE_OPERATOR_TIME_NANOS #
+test t1 NULL READ_INDEX_BLOCK_NANOS #
+test t1 NULL READ_FILTER_BLOCK_NANOS #
+test t1 NULL NEW_TABLE_BLOCK_ITER_NANOS #
+test t1 NULL NEW_TABLE_ITERATOR_NANOS #
+test t1 NULL BLOCK_SEEK_NANOS #
+test t1 NULL FIND_TABLE_NANOS #
+test t1 NULL BLOOM_MEMTABLE_HIT_COUNT #
+test t1 NULL BLOOM_MEMTABLE_MISS_COUNT #
+test t1 NULL BLOOM_SST_HIT_COUNT #
+test t1 NULL BLOOM_SST_MISS_COUNT #
+test t1 NULL KEY_LOCK_WAIT_TIME #
+test t1 NULL KEY_LOCK_WAIT_COUNT #
+test t1 NULL IO_THREAD_POOL_ID #
+test t1 NULL IO_BYTES_WRITTEN #
+test t1 NULL IO_BYTES_READ #
+test t1 NULL IO_OPEN_NANOS #
+test t1 NULL IO_ALLOCATE_NANOS #
+test t1 NULL IO_WRITE_NANOS #
+test t1 NULL IO_READ_NANOS #
+test t1 NULL IO_RANGE_SYNC_NANOS #
+test t1 NULL IO_LOGGER_NANOS #
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT_GLOBAL;
+STAT_TYPE VALUE
+USER_KEY_COMPARISON_COUNT #
+BLOCK_CACHE_HIT_COUNT #
+BLOCK_READ_COUNT #
+BLOCK_READ_BYTE #
+BLOCK_READ_TIME #
+BLOCK_CHECKSUM_TIME #
+BLOCK_DECOMPRESS_TIME #
+GET_READ_BYTES #
+MULTIGET_READ_BYTES #
+ITER_READ_BYTES #
+INTERNAL_KEY_SKIPPED_COUNT #
+INTERNAL_DELETE_SKIPPED_COUNT #
+INTERNAL_RECENT_SKIPPED_COUNT #
+INTERNAL_MERGE_COUNT #
+GET_SNAPSHOT_TIME #
+GET_FROM_MEMTABLE_TIME #
+GET_FROM_MEMTABLE_COUNT #
+GET_POST_PROCESS_TIME #
+GET_FROM_OUTPUT_FILES_TIME #
+SEEK_ON_MEMTABLE_TIME #
+SEEK_ON_MEMTABLE_COUNT #
+NEXT_ON_MEMTABLE_COUNT #
+PREV_ON_MEMTABLE_COUNT #
+SEEK_CHILD_SEEK_TIME #
+SEEK_CHILD_SEEK_COUNT #
+SEEK_MIN_HEAP_TIME #
+SEEK_MAX_HEAP_TIME #
+SEEK_INTERNAL_SEEK_TIME #
+FIND_NEXT_USER_ENTRY_TIME #
+WRITE_WAL_TIME #
+WRITE_MEMTABLE_TIME #
+WRITE_DELAY_TIME #
+WRITE_PRE_AND_POST_PROCESS_TIME #
+DB_MUTEX_LOCK_NANOS #
+DB_CONDITION_WAIT_NANOS #
+MERGE_OPERATOR_TIME_NANOS #
+READ_INDEX_BLOCK_NANOS #
+READ_FILTER_BLOCK_NANOS #
+NEW_TABLE_BLOCK_ITER_NANOS #
+NEW_TABLE_ITERATOR_NANOS #
+BLOCK_SEEK_NANOS #
+FIND_TABLE_NANOS #
+BLOOM_MEMTABLE_HIT_COUNT #
+BLOOM_MEMTABLE_MISS_COUNT #
+BLOOM_SST_HIT_COUNT #
+BLOOM_SST_MISS_COUNT #
+KEY_LOCK_WAIT_TIME #
+KEY_LOCK_WAIT_COUNT #
+IO_THREAD_POOL_ID #
+IO_BYTES_WRITTEN #
+IO_BYTES_READ #
+IO_OPEN_NANOS #
+IO_ALLOCATE_NANOS #
+IO_WRITE_NANOS #
+IO_READ_NANOS #
+IO_RANGE_SYNC_NANOS #
+IO_LOGGER_NANOS #
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT
+WHERE TABLE_NAME = 't1'
+AND STAT_TYPE in ('INTERNAL_KEY_SKIPPED_COUNT', 'INTERNAL_DELETE_SKIPPED_COUNT');
+TABLE_SCHEMA TABLE_NAME PARTITION_NAME STAT_TYPE VALUE
+test t1 NULL INTERNAL_KEY_SKIPPED_COUNT 0
+test t1 NULL INTERNAL_DELETE_SKIPPED_COUNT 0
+SELECT * FROM t1;
+i j
+1 1
+2 2
+3 3
+4 4
+5 5
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT
+WHERE TABLE_NAME = 't1'
+AND STAT_TYPE in ('INTERNAL_KEY_SKIPPED_COUNT', 'INTERNAL_DELETE_SKIPPED_COUNT');
+TABLE_SCHEMA TABLE_NAME PARTITION_NAME STAT_TYPE VALUE
+test t1 NULL INTERNAL_KEY_SKIPPED_COUNT 5
+test t1 NULL INTERNAL_DELETE_SKIPPED_COUNT 0
+SELECT * FROM t1 WHERE j BETWEEN 1 AND 5;
+i j
+1 1
+2 2
+3 3
+4 4
+5 5
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT
+WHERE TABLE_NAME = 't1'
+AND STAT_TYPE in ('INTERNAL_KEY_SKIPPED_COUNT', 'INTERNAL_DELETE_SKIPPED_COUNT');
+TABLE_SCHEMA TABLE_NAME PARTITION_NAME STAT_TYPE VALUE
+test t1 NULL INTERNAL_KEY_SKIPPED_COUNT 10
+test t1 NULL INTERNAL_DELETE_SKIPPED_COUNT 0
+set @tmp_flush_log= @@rocksdb_flush_log_at_trx_commit;
+set global rocksdb_flush_log_at_trx_commit=1;
+BEGIN;
+INSERT INTO t2 VALUES (1), (2);
+INSERT INTO t2 VALUES (3), (4);
+COMMIT;
+SELECT COUNT(*) from INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT
+WHERE TABLE_NAME = 't2'
+AND STAT_TYPE = 'IO_WRITE_NANOS'
+AND VALUE > 0;
+COUNT(*)
+0
+SELECT COUNT(*) from INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT_GLOBAL
+WHERE STAT_TYPE = 'IO_WRITE_NANOS' AND VALUE > 0;
+COUNT(*)
+1
+SELECT VALUE INTO @a from INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT_GLOBAL
+WHERE STAT_TYPE = 'IO_WRITE_NANOS';
+INSERT INTO t2 VALUES (5), (6), (7), (8);
+SELECT COUNT(*) from INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT
+WHERE TABLE_NAME = 't2'
+AND STAT_TYPE = 'IO_WRITE_NANOS'
+AND VALUE > 0;
+COUNT(*)
+1
+SELECT VALUE INTO @b from INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT_GLOBAL
+WHERE STAT_TYPE = 'IO_WRITE_NANOS';
+SELECT CASE WHEN @b - @a > 0 THEN 'true' ELSE 'false' END;
+CASE WHEN @b - @a > 0 THEN 'true' ELSE 'false' END
+true
+DROP TABLE t1;
+DROP TABLE t2;
+SET GLOBAL rocksdb_perf_context_level = @prior_rocksdb_perf_context_level;
+set global rocksdb_flush_log_at_trx_commit= @tmp_flush_log;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/persistent_cache.result b/storage/rocksdb/mysql-test/rocksdb/r/persistent_cache.result
new file mode 100644
index 00000000..bc5739c2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/persistent_cache.result
@@ -0,0 +1,11 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a int primary key) ENGINE=ROCKSDB;
+insert into t1 values (1);
+set global rocksdb_force_flush_memtable_now=1;
+select * from t1 where a = 1;
+a
+1
+select * from t1 where a = 1;
+a
+1
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/prefix_extractor_override.result b/storage/rocksdb/mysql-test/rocksdb/r/prefix_extractor_override.result
new file mode 100644
index 00000000..070169fd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/prefix_extractor_override.result
@@ -0,0 +1,82 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (id1 BIGINT, id2 BIGINT, id3 BIGINT, id4 BIGINT, PRIMARY KEY (id1, id2, id3, id4) comment 'cf1') ENGINE=rocksdb collate latin1_bin;
+set global rocksdb_force_flush_memtable_now = 1;
+
+Original Prefix Extractor:
+
+SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%';
+CF_NAME OPTION_TYPE VALUE
+__system__ PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
+cf1 PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
+default PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
+COUNT(*)
+1
+select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+variable_value-@u
+1
+
+Prefix Extractor (after override_cf_options set, should not be changed):
+
+SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%';
+CF_NAME OPTION_TYPE VALUE
+__system__ PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
+cf1 PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
+default PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
+SET @@global.rocksdb_update_cf_options = 'cf1={prefix_extractor=capped:26};';
+
+Changed Prefix Extractor (after update_cf_options set, without restart):
+
+SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%';
+CF_NAME OPTION_TYPE VALUE
+__system__ PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
+cf1 PREFIX_EXTRACTOR rocksdb.CappedPrefix.26
+default PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
+SET @@global.rocksdb_update_cf_options = 'cf2={prefix_extractor=capped:28};';
+SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%';
+CF_NAME OPTION_TYPE VALUE
+__system__ PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
+cf1 PREFIX_EXTRACTOR rocksdb.CappedPrefix.26
+cf2 PREFIX_EXTRACTOR rocksdb.CappedPrefix.28
+default PREFIX_EXTRACTOR rocksdb.CappedPrefix.24
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
+COUNT(*)
+1
+select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+variable_value-@u
+0
+set global rocksdb_force_flush_memtable_now = 1;
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
+COUNT(*)
+1
+select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+variable_value-@u
+1
+SELECT COUNT(*) FROM information_schema.rocksdb_index_file_map WHERE COLUMN_FAMILY != 1;
+COUNT(*)
+2
+UPDATE t1 SET id1=1,id2 = 30,id3 = 30 WHERE id4 >= 0 AND id4 <=10;
+set global rocksdb_force_flush_memtable_now = 1;
+SELECT COUNT(*) FROM information_schema.rocksdb_index_file_map WHERE COLUMN_FAMILY != 1;
+COUNT(*)
+3
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
+COUNT(*)
+0
+select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+variable_value-@u
+2
+SET @@global.rocksdb_update_cf_options = '';
+set global rocksdb_compact_cf='cf1';
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=30 AND id3=30;
+COUNT(*)
+11
+select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+variable_value-@u
+1
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/read_only_tx.result b/storage/rocksdb/mysql-test/rocksdb/r/read_only_tx.result
new file mode 100644
index 00000000..db21c3c0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/read_only_tx.result
@@ -0,0 +1,46 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE t1 (id INT, value int, PRIMARY KEY (id), INDEX (value)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1,1);
+select variable_value into @p from information_schema.global_status where variable_name='rocksdb_number_sst_entry_put';
+select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connection con2;
+connection con1;
+select case when variable_value-@p < 1000 then 'true' else variable_value-@p end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_put';
+case when variable_value-@p < 1000 then 'true' else variable_value-@p end
+true
+select case when variable_value-@s < 100 then 'true' else variable_value-@s end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+case when variable_value-@s < 100 then 'true' else variable_value-@s end
+true
+SELECT * FROM t1;
+id value
+1 1
+INSERT INTO t1 values (2, 2);
+ERROR HY000: Can't execute updates when you started a transaction with START TRANSACTION WITH CONSISTENT [ROCKSDB] SNAPSHOT.
+ROLLBACK;
+SELECT * FROM t1;
+id value
+1 10001
+INSERT INTO t1 values (2, 2);
+SELECT * FROM t1 ORDER BY id;
+id value
+1 10001
+2 2
+BEGIN;
+connection con2;
+connection con1;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+9998
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+OPTIMIZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+DROP TABLE t1;
+reset master;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result b/storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result
new file mode 100644
index 00000000..feeabd7e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result
@@ -0,0 +1,211 @@
+# restart
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+i INT,
+a INT,
+b INT,
+PRIMARY KEY (i),
+KEY ka(a),
+KEY kb(b) comment 'rev:cf1'
+) ENGINE = rocksdb;
+explain extended select * from t1 where a> 500 and a< 750;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range ka ka 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` > 500 and `test`.`t1`.`a` < 750
+explain extended select * from t1 where a< 750;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range ka ka 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` < 750
+explain extended select * from t1 where a> 500;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range ka ka 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` > 500
+explain extended select * from t1 where a>=0 and a<=1000;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range ka ka 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` >= 0 and `test`.`t1`.`a` <= 1000
+explain extended select * from t1 where b> 500 and b< 750;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range kb kb 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` > 500 and `test`.`t1`.`b` < 750
+explain extended select * from t1 where b< 750;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range kb kb 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` < 750
+explain extended select * from t1 where b> 500;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range kb kb 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` > 500
+explain extended select * from t1 where b>=0 and b<=1000;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range kb kb 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` >= 0 and `test`.`t1`.`b` <= 1000
+set @save_rocksdb_records_in_range = @@session.rocksdb_records_in_range;
+set rocksdb_records_in_range = 15000;
+explain extended select a from t1 where a < 750;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range ka ka 5 NULL 15000 100.00 Using where; Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` < 750
+explain extended select a, b from t1 where a < 750;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL ka NULL NULL NULL 20000 75.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` < 750
+explain extended select a from t1 where a = 700;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ref ka ka 5 const 15000 100.00 Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 700
+explain extended select a,b from t1 where a = 700;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL ka NULL NULL NULL 20000 75.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` = 700
+explain extended select a from t1 where a in (700, 800);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 index ka ka 5 NULL 20000 100.00 Using where; Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` in (700,800)
+explain extended select a,b from t1 where a in (700, 800);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL ka NULL NULL NULL 20000 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` in (700,800)
+set rocksdb_records_in_range=8000;
+explain extended select a from t1 where a in (700, 800);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range ka ka 5 NULL 16000 100.00 Using where; Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` in (700,800)
+explain extended select a,b from t1 where a in (700, 800);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL ka NULL NULL NULL 20000 80.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` in (700,800)
+set rocksdb_records_in_range = @save_rocksdb_records_in_range;
+set global rocksdb_force_flush_memtable_now = true;
+explain extended select * from t1 where a> 500 and a< 750;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range ka ka 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` > 500 and `test`.`t1`.`a` < 750
+explain extended select * from t1 where a< 750;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range ka ka 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` < 750
+explain extended select * from t1 where a> 500;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range ka ka 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` > 500
+explain extended select * from t1 where a>=0 and a<=1000;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range ka ka 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` >= 0 and `test`.`t1`.`a` <= 1000
+explain extended select * from t1 where b> 500 and b< 750;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range kb kb 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` > 500 and `test`.`t1`.`b` < 750
+explain extended select * from t1 where b< 750;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range kb kb 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` < 750
+explain extended select * from t1 where b> 500;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range kb kb 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` > 500
+explain extended select * from t1 where b>=0 and b<=1000;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range kb kb 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` >= 0 and `test`.`t1`.`b` <= 1000
+explain extended select * from t1 where a>= 500 and a<= 500;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range ka ka 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` >= 500 and `test`.`t1`.`a` <= 500
+explain extended select * from t1 where b>= 500 and b<= 500;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range kb kb 5 NULL 1000 100.00 Using index condition
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` >= 500 and `test`.`t1`.`b` <= 500
+explain extended select * from t1 where a< 750 and b> 500 and b< 750;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range ka,kb ka 5 NULL 1000 5.00 Using index condition; Using where
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` < 750 and `test`.`t1`.`b` > 500 and `test`.`t1`.`b` < 750
+drop index ka on t1;
+drop index kb on t1;
+create index kab on t1(a,b);
+set global rocksdb_force_flush_memtable_now = true;
+explain extended select * from t1 where a< 750 and b> 500 and b< 750;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range kab kab 5 NULL 1000 100.00 Using where; Using index
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` < 750 and `test`.`t1`.`b` > 500 and `test`.`t1`.`b` < 750
+set rocksdb_records_in_range=444;
+explain extended select * from t1 where a< 750 and b> 500 and b< 750;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range kab kab 5 NULL 444 100.00 Using where; Using index
+Warnings:
+Note 1003 select `test`.`t1`.`i` AS `i`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` < 750 and `test`.`t1`.`b` > 500 and `test`.`t1`.`b` < 750
+set rocksdb_records_in_range=0;
+CREATE TABLE `linktable` (
+`id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+`visibility` tinyint(3) NOT NULL DEFAULT '0',
+`data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '',
+`time` bigint(20) unsigned NOT NULL DEFAULT '0',
+`version` int(11) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link_pk',
+KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`version`,`data`) COMMENT 'cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
+insert into linktable values (1,1,1,1,1,1,1,1,1);
+insert into linktable values (1,1,2,1,1,1,1,1,1);
+insert into linktable values (1,1,3,1,1,1,1,1,1);
+insert into linktable values (1,1,4,1,1,1,1,1,1);
+set global rocksdb_force_flush_memtable_now = true;
+explain select id1, id2, link_type, visibility, data, time, version from linktable where id1 = 1 and link_type = 1 and id2 in (1, 2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE linktable range PRIMARY,id1_type PRIMARY 24 NULL 2 Using where
+drop table linktable;
+CREATE TABLE `linktable` (
+`id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+`id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+`id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+`visibility` tinyint(3) NOT NULL DEFAULT '0',
+`data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '',
+`time` bigint(20) unsigned NOT NULL DEFAULT '0',
+`version` int(11) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link_pk',
+KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`version`,`data`) COMMENT 'rev:cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
+insert into linktable values (1,1,1,1,1,1,1,1,1);
+insert into linktable values (1,1,2,1,1,1,1,1,1);
+insert into linktable values (1,1,3,1,1,1,1,1,1);
+insert into linktable values (1,1,4,1,1,1,1,1,1);
+set global rocksdb_force_flush_memtable_now = true;
+explain select id1, id2, link_type, visibility, data, time, version from linktable where id1 = 1 and link_type = 1 and id2 in (1, 2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE linktable range PRIMARY,id1_type PRIMARY 24 NULL 2 Using where
+drop table linktable;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/repair_table.result b/storage/rocksdb/mysql-test/rocksdb/r/repair_table.result
new file mode 100644
index 00000000..f227d200
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/repair_table.result
@@ -0,0 +1,37 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a INT, b CHAR(8) PRIMARY KEY) ENGINE=rocksdb;
+REPAIR TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 repair note The storage engine for the table doesn't support repair
+INSERT INTO t1 (a,b) VALUES (3,'c');
+INSERT INTO t2 (a,b) VALUES (4,'d');
+REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2;
+Table Op Msg_type Msg_text
+test.t1 repair note The storage engine for the table doesn't support repair
+test.t2 repair note The storage engine for the table doesn't support repair
+INSERT INTO t2 (a,b) VALUES (5,'e'),(6,'f');
+REPAIR LOCAL TABLE t2;
+Table Op Msg_type Msg_text
+test.t2 repair note The storage engine for the table doesn't support repair
+INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
+INSERT INTO t2 (a,b) VALUES (9,'i');
+REPAIR LOCAL TABLE t2, t1 EXTENDED;
+Table Op Msg_type Msg_text
+test.t2 repair note The storage engine for the table doesn't support repair
+test.t1 repair note The storage engine for the table doesn't support repair
+INSERT INTO t1 (a,b) VALUES (10,'j');
+INSERT INTO t2 (a,b) VALUES (11,'k');
+REPAIR TABLE t1, t2 QUICK USE_FRM;
+Table Op Msg_type Msg_text
+test.t1 repair note The storage engine for the table doesn't support repair
+test.t2 repair note The storage engine for the table doesn't support repair
+INSERT INTO t1 (a,b) VALUES (12,'l');
+INSERT INTO t2 (a,b) VALUES (13,'m');
+REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2 QUICK EXTENDED USE_FRM;
+Table Op Msg_type Msg_text
+test.t1 repair note The storage engine for the table doesn't support repair
+test.t2 repair note The storage engine for the table doesn't support repair
+FLUSH TABLE t1;
+DROP TABLE t1, t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/replace.result b/storage/rocksdb/mysql-test/rocksdb/r/replace.result
new file mode 100644
index 00000000..f8f61a3f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/replace.result
@@ -0,0 +1,32 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+SELECT a,b FROM t1;
+a b
+1 a
+2 b
+3 c
+4 d
+5 e
+REPLACE t1 (a,b) VALUE (10,'foo'),(10,'foo');
+SELECT a,b FROM t1;
+a b
+1 a
+10 foo
+10 foo
+2 b
+3 c
+4 d
+5 e
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8), PRIMARY KEY (b)) ENGINE=rocksdb;
+REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
+INSERT INTO t1 (a,b) VALUES (4,'b');
+ERROR 23000: Duplicate entry 'b' for key 'PRIMARY'
+REPLACE INTO t1 (a,b) VALUES (4,'b');
+SELECT a,b FROM t1;
+a b
+1 a
+3 c
+4 b
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result
new file mode 100644
index 00000000..95cbc3e7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result
@@ -0,0 +1,2643 @@
+select ENGINE,COMMENT,TRANSACTIONS,XA,SAVEPOINTS from information_schema.engines where engine = 'rocksdb';
+ENGINE COMMENT TRANSACTIONS XA SAVEPOINTS
+ROCKSDB RocksDB storage engine YES YES YES
+drop table if exists t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
+drop table if exists t11,t12,t13,t14,t15,t16,t17,t18,t19,t20;
+drop table if exists t21,t22,t23,t24,t25,t26,t27,t28,t29;
+drop table if exists t30,t31,t32,t33,t34,t35,t36,t37,t38,t39;
+drop table if exists t40,t41,t42,t43,t44,t45,t46,t47,t48,t49;
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+#
+# Issue #1: Don't update indexes if index values have not changed
+#
+create table t1 (
+pk int primary key,
+a int,
+b int,
+key(a)
+) engine=rocksdb;
+insert into t1 values
+(1,1,1), (2,2,2), (3,3,3), (4,4,4);
+set @var1=(select variable_value
+from information_schema.global_status
+where variable_name='rocksdb_number_keys_written');
+# Do an update that doesn't change the key 'a'.
+update t1 set b=3334341 where a=2;
+set @var2=(select variable_value
+from information_schema.global_status
+where variable_name='rocksdb_number_keys_written');
+# The following should produce 1
+select @var2 - @var1;
+@var2 - @var1
+1
+# Do an update that sets the key to the same value
+update t1 set a=pk where a=3;
+set @var3=(select variable_value
+from information_schema.global_status
+where variable_name='rocksdb_number_keys_written');
+# We have 'updated' column to the same value, so the following must return 0:
+select @var3 - @var2;
+@var3 - @var2
+0
+drop table t1;
+create table t0 (a int primary key) engine=rocksdb;
+show create table t0;
+Table Create Table
+t0 CREATE TABLE `t0` (
+ `a` int(11) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+drop table t0;
+create table t1 (a int primary key, b int) engine=rocksdb;
+insert into t1 values (1,1);
+insert into t1 values (2,2);
+select * from t1;
+a b
+1 1
+2 2
+# Check that we can create another table and insert there
+create table t2 (a varchar(10) primary key, b varchar(10)) engine=rocksdb;
+insert into t2 value ('abc','def');
+insert into t2 value ('hijkl','mnopq');
+select * from t2;
+a b
+abc def
+hijkl mnopq
+# Select again from t1 to see that records from different tables dont mix
+select * from t1;
+a b
+1 1
+2 2
+explain select * from t2 where a='no-such-key';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+explain select * from t2 where a='abc';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 const PRIMARY PRIMARY 12 const #
+select * from t2 where a='abc';
+a b
+abc def
+# Try a composite PK
+create table t3 (
+pk1 int,
+pk2 varchar(10),
+col1 varchar(10),
+primary key(pk1, pk2)
+) engine=rocksdb;
+insert into t3 values (2,'two', 'row#2');
+insert into t3 values (3,'three', 'row#3');
+insert into t3 values (1,'one', 'row#1');
+select * from t3;
+pk1 pk2 col1
+1 one row#1
+2 two row#2
+3 three row#3
+select * from t3 where pk1=3 and pk2='three';
+pk1 pk2 col1
+3 three row#3
+drop table t1, t2, t3;
+#
+# Test blob values
+#
+create table t4 (a int primary key, b blob) engine=rocksdb;
+insert into t4 values (1, repeat('quux-quux', 60));
+insert into t4 values (10, repeat('foo-bar', 43));
+insert into t4 values (5, repeat('foo-bar', 200));
+insert into t4 values (2, NULL);
+select
+a,
+(case a
+when 1 then b=repeat('quux-quux', 60)
+when 10 then b=repeat('foo-bar', 43)
+when 5 then b=repeat('foo-bar', 200)
+when 2 then b is null
+else 'IMPOSSIBLE!' end) as CMP
+from t4;
+a CMP
+1 1
+2 1
+5 1
+10 1
+drop table t4;
+#
+# Test blobs of various sizes
+#
+# TINYBLOB
+create table t5 (a int primary key, b tinyblob) engine=rocksdb;
+insert into t5 values (1, repeat('quux-quux', 6));
+insert into t5 values (10, repeat('foo-bar', 4));
+insert into t5 values (5, repeat('foo-bar', 2));
+select
+a,
+(case a
+when 1 then b=repeat('quux-quux', 6)
+when 10 then b=repeat('foo-bar', 4)
+when 5 then b=repeat('foo-bar', 2)
+else 'IMPOSSIBLE!' end) as CMP
+from t5;
+a CMP
+1 1
+5 1
+10 1
+drop table t5;
+# MEDIUMBLOB
+create table t6 (a int primary key, b mediumblob) engine=rocksdb;
+insert into t6 values (1, repeat('AB', 65000));
+insert into t6 values (10, repeat('bbb', 40000));
+insert into t6 values (5, repeat('foo-bar', 2));
+select
+a,
+(case a
+when 1 then b=repeat('AB', 65000)
+when 10 then b=repeat('bbb', 40000)
+when 5 then b=repeat('foo-bar', 2)
+else 'IMPOSSIBLE!' end) as CMP
+from t6;
+a CMP
+1 1
+5 1
+10 1
+drop table t6;
+# LONGBLOB
+create table t7 (a int primary key, b longblob) engine=rocksdb;
+insert into t7 values (1, repeat('AB', 65000));
+insert into t7 values (10, repeat('bbb', 40000));
+insert into t7 values (5, repeat('foo-bar', 2));
+select
+a,
+(case a
+when 1 then b=repeat('AB', 65000)
+when 10 then b=repeat('bbb', 40000)
+when 5 then b=repeat('foo-bar', 2)
+else 'IMPOSSIBLE!' end) as CMP
+from t7;
+a CMP
+1 1
+5 1
+10 1
+drop table t7;
+#
+# Check if DELETEs work
+#
+create table t8 (a varchar(10) primary key, col1 varchar(12)) engine=rocksdb;
+insert into t8 values
+('one', 'eins'),
+('two', 'zwei'),
+('three', 'drei'),
+('four', 'vier'),
+('five', 'funf');
+# Delete by PK
+explain delete from t8 where a='three';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t8 range PRIMARY PRIMARY 12 NULL # Using where
+delete from t8 where a='three';
+select * from t8;
+a col1
+five funf
+four vier
+one eins
+two zwei
+# Delete while doing a full table scan
+delete from t8 where col1='eins' or col1='vier';
+select * from t8;
+a col1
+five funf
+two zwei
+# delete w/o WHERE:
+delete from t8;
+select * from t8;
+a col1
+#
+# Test UPDATEs
+#
+insert into t8 values
+('one', 'eins'),
+('two', 'zwei'),
+('three', 'drei'),
+('four', 'vier'),
+('five', 'funf');
+update t8 set col1='dva' where a='two';
+update t8 set a='fourAAA' where col1='vier';
+select * from t8;
+a col1
+five funf
+fourAAA vier
+one eins
+three drei
+two dva
+delete from t8;
+#
+# Basic transactions tests
+#
+begin;
+insert into t8 values ('trx1-val1', 'data');
+insert into t8 values ('trx1-val2', 'data');
+rollback;
+select * from t8;
+a col1
+begin;
+insert into t8 values ('trx1-val1', 'data');
+insert into t8 values ('trx1-val2', 'data');
+commit;
+select * from t8;
+a col1
+trx1-val1 data
+trx1-val2 data
+drop table t8;
+#
+# Check if DROP TABLE works
+#
+create table t8 (a varchar(10) primary key, col1 varchar(12)) engine=rocksdb;
+select * from t8;
+a col1
+insert into t8 values ('foo','foo');
+drop table t8;
+create table t8 (a varchar(10) primary key, col1 varchar(12)) engine=rocksdb;
+select * from t8;
+a col1
+drop table t8;
+#
+# MDEV-3961: Assertion ... on creating a TEMPORARY RocksDB table
+#
+CREATE TEMPORARY TABLE t10 (pk INT PRIMARY KEY) ENGINE=RocksDB;
+ERROR HY000: Table storage engine 'ROCKSDB' does not support the create option 'TEMPORARY'
+#
+# MDEV-3963: JOIN or WHERE conditions involving keys on RocksDB tables don't work
+#
+CREATE TABLE t10 (i INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t10 VALUES (1),(3);
+CREATE TABLE t11 (j INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t11 VALUES (1),(4);
+select * from t10;
+i
+1
+3
+select * from t11;
+j
+1
+4
+EXPLAIN
+SELECT * FROM t10, t11 WHERE i=j;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t10 index PRIMARY PRIMARY 4 NULL # Using index
+1 SIMPLE t11 eq_ref PRIMARY PRIMARY 4 test.t10.i # Using index
+SELECT * FROM t10, t11 WHERE i=j;
+i j
+1 1
+DROP TABLE t10,t11;
+#
+# MDEV-3962: SELECT with ORDER BY causes "ERROR 1030 (HY000): Got error 122
+#
+CREATE TABLE t12 (pk INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t12 VALUES (2),(1);
+SELECT * FROM t12 ORDER BY pk;
+pk
+1
+2
+DROP TABLE t12;
+#
+# MDEV-3964: Assertion `!pk_descr' fails in ha_rocksdb::open on adding partitions ...
+#
+create table t14 (pk int primary key) engine=RocksDB partition by hash(pk) partitions 2;
+drop table t14;
+#
+# MDEV-3960: Server crashes on running DISCARD TABLESPACE on a RocksDB table
+#
+create table t9 (i int primary key) engine=rocksdb;
+alter table t9 discard tablespace;
+ERROR HY000: Storage engine ROCKSDB of the table `test`.`t9` doesn't have this option
+drop table t9;
+#
+# MDEV-3959: Assertion `slice->size() == table->s->reclength' fails ...
+# on accessing a table after ALTER
+#
+CREATE TABLE t15 (a INT, rocksdb_pk INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t15 VALUES (1,1),(5,2);
+ALTER TABLE t15 DROP COLUMN a;
+DROP TABLE t15;
+#
+# MDEV-3968: UPDATE produces a wrong result while modifying a PK on a RocksDB table
+#
+create table t16 (pk int primary key, a char(8)) engine=RocksDB;
+insert into t16 values (1,'a'),(2,'b'),(3,'c'),(4,'d');
+update t16 set pk=100, a = 'updated' where a in ('b','c');
+ERROR 23000: Duplicate entry '100' for key 'PRIMARY'
+select * from t16;
+pk a
+1 a
+2 b
+3 c
+4 d
+drop table t16;
+#
+# MDEV-3970: A set of assorted crashes on inserting a row into a RocksDB table
+#
+drop table if exists t_very_long_table_name;
+CREATE TABLE `t_very_long_table_name` (
+`c` char(1) NOT NULL,
+`c0` char(0) NOT NULL,
+`c1` char(1) NOT NULL,
+`c20` char(20) NOT NULL,
+`c255` char(255) NOT NULL,
+PRIMARY KEY (`c255`)
+) ENGINE=RocksDB DEFAULT CHARSET=latin1;
+INSERT INTO t_very_long_table_name VALUES ('a', '', 'c', REPEAT('a',20), REPEAT('x',255));
+drop table t_very_long_table_name;
+#
+# Test table locking and read-before-write checks.
+#
+create table t17 (pk varchar(12) primary key, col1 varchar(12)) engine=rocksdb;
+insert into t17 values ('row1', 'val1');
+insert into t17 values ('row1', 'val1-try2');
+ERROR 23000: Duplicate entry 'row1' for key 'PRIMARY'
+insert into t17 values ('ROW1', 'val1-try2');
+ERROR 23000: Duplicate entry 'ROW1' for key 'PRIMARY'
+insert into t17 values ('row2', 'val2');
+insert into t17 values ('row3', 'val3');
+# This is ok
+update t17 set pk='row4' where pk='row1';
+# This will try to overwrite another row:
+update t17 set pk='row3' where pk='row2';
+ERROR 23000: Duplicate entry 'row3' for key 'PRIMARY'
+select * from t17;
+pk col1
+row2 val2
+row3 val3
+row4 val1
+#
+# Locking tests
+#
+connect con1,localhost,root,,;
+# First, make sure there's no locking when transactions update different rows
+connection con1;
+set autocommit=0;
+update t17 set col1='UPD1' where pk='row2';
+connection default;
+update t17 set col1='UPD2' where pk='row3';
+connection con1;
+commit;
+connection default;
+select * from t17;
+pk col1
+row2 UPD1
+row3 UPD2
+row4 val1
+# Check the variable
+show variables like 'rocksdb_lock_wait_timeout';
+Variable_name Value
+rocksdb_lock_wait_timeout 1
+set rocksdb_lock_wait_timeout=2;
+show variables like 'rocksdb_lock_wait_timeout';
+Variable_name Value
+rocksdb_lock_wait_timeout 2
+# Try updating the same row from two transactions
+connection con1;
+begin;
+update t17 set col1='UPD2-AA' where pk='row2';
+connection default;
+update t17 set col1='UPD2-BB' where pk='row2';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+set rocksdb_lock_wait_timeout=1000;
+update t17 set col1='UPD2-CC' where pk='row2';
+connection con1;
+rollback;
+connection default;
+select * from t17 where pk='row2';
+pk col1
+row2 UPD2-CC
+drop table t17;
+disconnect con1;
+#
+# MDEV-4035: RocksDB: SELECT produces different results inside a transaction (read is not repeatable)
+#
+create table t18 (pk int primary key, i int) engine=RocksDB;
+begin;
+select * from t18;
+pk i
+select * from t18 where pk = 1;
+pk i
+connect con1,localhost,root,,;
+insert into t18 values (1,100);
+connection default;
+select * from t18;
+pk i
+select * from t18 where pk = 1;
+pk i
+commit;
+drop table t18;
+#
+# MDEV-4036: RocksDB: INSERT .. ON DUPLICATE KEY UPDATE does not work, produces ER_DUP_KEY
+#
+create table t19 (pk int primary key, i int) engine=RocksDB;
+insert into t19 values (1,1);
+insert into t19 values (1,100) on duplicate key update i = 102;
+select * from t19;
+pk i
+1 102
+drop table t19;
+# MDEV-4037: RocksDB: REPLACE doesn't work, produces ER_DUP_KEY
+create table t20 (pk int primary key, i int) engine=RocksDB;
+insert into t20 values (1,1);
+replace into t20 values (1,100);
+select * from t20;
+pk i
+1 100
+drop table t20;
+#
+# MDEV-4041: Server crashes in Primary_key_comparator::get_hashnr on INSERT
+#
+create table t21 (v varbinary(16) primary key, i int) engine=RocksDB;
+insert into t21 values ('a',1);
+select * from t21;
+v i
+a 1
+drop table t21;
+#
+# MDEV-4047: RocksDB: Assertion `0' fails in Protocol::end_statement() on multi-table INSERT IGNORE
+#
+CREATE TABLE t22 (a int primary key) ENGINE=RocksDB;
+INSERT INTO t22 VALUES (1),(2);
+CREATE TABLE t23 (b int primary key) ENGINE=RocksDB;
+INSERT INTO t23 SELECT * FROM t22;
+DELETE IGNORE t22.*, t23.* FROM t22, t23 WHERE b < a;
+DROP TABLE t22,t23;
+#
+# MDEV-4046: RocksDB: Multi-table DELETE locks itself and ends with ER_LOCK_WAIT_TIMEOUT
+#
+CREATE TABLE t24 (pk int primary key) ENGINE=RocksDB;
+INSERT INTO t24 VALUES (1),(2);
+CREATE TABLE t25 LIKE t24;
+INSERT INTO t25 SELECT * FROM t24;
+DELETE t25.* FROM t24, t25;
+DROP TABLE t24,t25;
+#
+# MDEV-4044: RocksDB: UPDATE or DELETE with ORDER BY locks itself
+#
+create table t26 (pk int primary key, c char(1)) engine=RocksDB;
+insert into t26 values (1,'a'),(2,'b');
+update t26 set c = 'x' order by pk limit 1;
+delete from t26 order by pk limit 1;
+select * from t26;
+pk c
+2 b
+drop table t26;
+#
+# Test whether SELECT ... FOR UPDATE puts locks
+#
+create table t27(pk varchar(10) primary key, col1 varchar(20)) engine=RocksDB;
+insert into t27 values
+('row1', 'row1data'),
+('row2', 'row2data'),
+('row3', 'row3data');
+connection con1;
+begin;
+select * from t27 where pk='row3' for update;
+pk col1
+row3 row3data
+connection default;
+set rocksdb_lock_wait_timeout=1;
+update t27 set col1='row2-modified' where pk='row3';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection con1;
+rollback;
+connection default;
+disconnect con1;
+drop table t27;
+#
+# MDEV-4060: RocksDB: Assertion `! trx->batch' fails in
+#
+create table t28 (pk int primary key, a int) engine=RocksDB;
+insert into t28 values (1,10),(2,20);
+begin;
+update t28 set a = 100 where pk = 3;
+rollback;
+select * from t28;
+pk a
+1 10
+2 20
+drop table t28;
+#
+# Secondary indexes
+#
+create table t30 (
+pk varchar(16) not null primary key,
+key1 varchar(16) not null,
+col1 varchar(16) not null,
+key(key1)
+) engine=rocksdb;
+insert into t30 values ('row1', 'row1-key', 'row1-data');
+insert into t30 values ('row2', 'row2-key', 'row2-data');
+insert into t30 values ('row3', 'row3-key', 'row3-data');
+explain
+select * from t30 where key1='row2-key';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t30 ref key1 key1 18 const # Using index condition
+select * from t30 where key1='row2-key';
+pk key1 col1
+row2 row2-key row2-data
+explain
+select * from t30 where key1='row1';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t30 ref key1 key1 18 const # Using index condition
+# This will produce nothing:
+select * from t30 where key1='row1';
+pk key1 col1
+explain
+select key1 from t30;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t30 index NULL key1 18 NULL # Using index
+select key1 from t30;
+key1
+row1-key
+row2-key
+row3-key
+# Create a duplicate record
+insert into t30 values ('row2a', 'row2-key', 'row2a-data');
+# Can we see it?
+select * from t30 where key1='row2-key';
+pk key1 col1
+row2 row2-key row2-data
+row2a row2-key row2a-data
+delete from t30 where pk='row2';
+select * from t30 where key1='row2-key';
+pk key1 col1
+row2a row2-key row2a-data
+#
+# Range scans on secondary index
+#
+delete from t30;
+insert into t30 values
+('row1', 'row1-key', 'row1-data'),
+('row2', 'row2-key', 'row2-data'),
+('row3', 'row3-key', 'row3-data'),
+('row4', 'row4-key', 'row4-data'),
+('row5', 'row5-key', 'row5-data');
+explain
+select * from t30 where key1 <='row3-key';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t30 range key1 key1 18 NULL # Using index condition
+select * from t30 where key1 <='row3-key';
+pk key1 col1
+row1 row1-key row1-data
+row2 row2-key row2-data
+row3 row3-key row3-data
+explain
+select * from t30 where key1 between 'row2-key' and 'row4-key';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t30 range key1 key1 18 NULL # Using index condition
+select * from t30 where key1 between 'row2-key' and 'row4-key';
+pk key1 col1
+row2 row2-key row2-data
+row3 row3-key row3-data
+row4 row4-key row4-data
+explain
+select * from t30 where key1 in ('row2-key','row4-key');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t30 range key1 key1 18 NULL # Using index condition
+select * from t30 where key1 in ('row2-key','row4-key');
+pk key1 col1
+row2 row2-key row2-data
+row4 row4-key row4-data
+explain
+select key1 from t30 where key1 in ('row2-key','row4-key');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t30 range key1 key1 18 NULL # Using where; Using index
+select key1 from t30 where key1 in ('row2-key','row4-key');
+key1
+row2-key
+row4-key
+explain
+select * from t30 where key1 > 'row1-key' and key1 < 'row4-key';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t30 range key1 key1 18 NULL # Using index condition
+select * from t30 where key1 > 'row1-key' and key1 < 'row4-key';
+pk key1 col1
+row2 row2-key row2-data
+row3 row3-key row3-data
+explain
+select * from t30 order by key1 limit 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t30 index NULL key1 18 NULL #
+select * from t30 order by key1 limit 3;
+pk key1 col1
+row1 row1-key row1-data
+row2 row2-key row2-data
+row3 row3-key row3-data
+explain
+select * from t30 order by key1 desc limit 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t30 index NULL key1 18 NULL #
+select * from t30 order by key1 desc limit 3;
+pk key1 col1
+row5 row5-key row5-data
+row4 row4-key row4-data
+row3 row3-key row3-data
+#
+# Range scans on primary key
+#
+explain
+select * from t30 where pk <='row3';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t30 range PRIMARY PRIMARY 18 NULL # Using where
+select * from t30 where pk <='row3';
+pk key1 col1
+row1 row1-key row1-data
+row2 row2-key row2-data
+row3 row3-key row3-data
+explain
+select * from t30 where pk between 'row2' and 'row4';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t30 range PRIMARY PRIMARY 18 NULL # Using where
+select * from t30 where pk between 'row2' and 'row4';
+pk key1 col1
+row2 row2-key row2-data
+row3 row3-key row3-data
+row4 row4-key row4-data
+explain
+select * from t30 where pk in ('row2','row4');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t30 range PRIMARY PRIMARY 18 NULL # Using where
+select * from t30 where pk in ('row2','row4');
+pk key1 col1
+row2 row2-key row2-data
+row4 row4-key row4-data
+explain
+select * from t30 order by pk limit 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t30 index NULL PRIMARY 18 NULL #
+select * from t30 order by pk limit 3;
+pk key1 col1
+row1 row1-key row1-data
+row2 row2-key row2-data
+row3 row3-key row3-data
+drop table t30;
+#
+# MDEV-3841: RocksDB: Reading by PK prefix does not work
+#
+create table t31 (i int, j int, k int, primary key(i,j,k)) engine=RocksDB;
+insert into t31 values (1,10,100),(2,20,200);
+select * from t31 where i = 1;
+i j k
+1 10 100
+select * from t31 where j = 10;
+i j k
+1 10 100
+select * from t31 where k = 100;
+i j k
+1 10 100
+select * from t31 where i = 1 and j = 10;
+i j k
+1 10 100
+select * from t31 where i = 1 and k = 100;
+i j k
+1 10 100
+select * from t31 where j = 10 and k = 100;
+i j k
+1 10 100
+select * from t31 where i = 1 and j = 10 and k = 100;
+i j k
+1 10 100
+drop table t31;
+#
+# MDEV-4055: RocksDB: UPDATE/DELETE by a multi-part PK does not work
+#
+create table t32 (i int, j int, k int, primary key(i,j,k), a varchar(8)) engine=RocksDB;
+insert into t32 values
+(1,10,100,''),
+(2,20,200,'');
+select * from t32 where i = 1 and j = 10 and k = 100;
+i j k a
+1 10 100
+update t32 set a = 'updated' where i = 1 and j = 10 and k = 100;
+select * from t32;
+i j k a
+1 10 100 updated
+2 20 200
+drop table t32;
+#
+# MDEV-3841: RocksDB: Assertion `0' fails in ha_rocksdb::index_read_map on range select with ORDER BY .. DESC
+#
+CREATE TABLE t33 (pk INT PRIMARY KEY, a CHAR(1)) ENGINE=RocksDB;
+INSERT INTO t33 VALUES (1,'a'),(2,'b');
+SELECT * FROM t33 WHERE pk <= 10 ORDER BY pk DESC;
+pk a
+2 b
+1 a
+DROP TABLE t33;
+#
+# MDEV-4081: RocksDB throws error 122 on an attempt to create a table with unique index
+#
+# Unique indexes can be created, but uniqueness won't be enforced
+create table t33 (pk int primary key, u int, unique index(u)) engine=RocksDB;
+drop table t33;
+#
+# MDEV-4077: RocksDB: Wrong result (duplicate row) on select with range
+#
+CREATE TABLE t34 (pk INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t34 VALUES (10),(11);
+SELECT pk FROM t34 WHERE pk > 5 AND pk < 15;
+pk
+10
+11
+SELECT pk FROM t34 WHERE pk BETWEEN 5 AND 15;
+pk
+10
+11
+SELECT pk FROM t34 WHERE pk > 5;
+pk
+10
+11
+SELECT pk FROM t34 WHERE pk < 15;
+pk
+10
+11
+drop table t34;
+#
+# MDEV-4086: RocksDB does not allow a query with multi-part pk and index and ORDER BY .. DEC
+#
+create table t35 (a int, b int, c int, d int, e int, primary key (a,b,c), key (a,c,d,e)) engine=RocksDB;
+insert into t35 values (1,1,1,1,1),(2,2,2,2,2);
+select * from t35 where a = 1 and c = 1 and d = 1 order by e desc;
+a b c d e
+1 1 1 1 1
+drop table t35;
+#
+# MDEV-4084: RocksDB: Wrong result on IN subquery with index
+#
+CREATE TABLE t36 (pk INT PRIMARY KEY, a INT, KEY(a)) ENGINE=RocksDB;
+INSERT INTO t36 VALUES (1,10),(2,20);
+SELECT 3 IN ( SELECT a FROM t36 );
+3 IN ( SELECT a FROM t36 )
+0
+drop table t36;
+#
+# MDEV-4084: RocksDB: Wrong result on IN subquery with index
+#
+CREATE TABLE t37 (pk INT PRIMARY KEY, a INT, b CHAR(1), KEY(a), KEY(a,b))
+ENGINE=RocksDB;
+INSERT INTO t37 VALUES (1,10,'x'), (2,20,'y');
+SELECT MAX(a) FROM t37 WHERE a < 100;
+MAX(a)
+20
+DROP TABLE t37;
+#
+# MDEV-4090: RocksDB: Wrong result (duplicate rows) on range access with secondary key and ORDER BY DESC
+#
+CREATE TABLE t38 (pk INT PRIMARY KEY, i INT, KEY(i)) ENGINE=RocksDB;
+INSERT INTO t38 VALUES (1,10), (2,20);
+SELECT i FROM t38 WHERE i NOT IN (8) ORDER BY i DESC;
+i
+20
+10
+drop table t38;
+#
+# MDEV-4092: RocksDB: Assertion `in_table(pa, a_len)' fails in Rdb_key_def::cmp_full_keys
+# with a multi-part key and ORDER BY .. DESC
+#
+CREATE TABLE t40 (pk1 INT PRIMARY KEY, a INT, b VARCHAR(1), KEY(b,a)) ENGINE=RocksDB;
+INSERT INTO t40 VALUES (1, 7,'x'),(2,8,'y');
+CREATE TABLE t41 (pk2 INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t41 VALUES (1),(2);
+SELECT * FROM t40, t41 WHERE pk1 = pk2 AND b = 'o' ORDER BY a DESC;
+pk1 a b pk2
+DROP TABLE t40,t41;
+#
+# MDEV-4093: RocksDB: IN subquery by secondary key with NULL among values returns true instead of NULL
+#
+CREATE TABLE t42 (pk INT PRIMARY KEY, a INT, KEY(a)) ENGINE=RocksDB;
+INSERT INTO t42 VALUES (1, NULL),(2, 8);
+SELECT ( 3 ) NOT IN ( SELECT a FROM t42 );
+( 3 ) NOT IN ( SELECT a FROM t42 )
+NULL
+DROP TABLE t42;
+#
+# MDEV-4094: RocksDB: Wrong result on SELECT and ER_KEY_NOT_FOUND on
+# DELETE with search by NULL-able secondary key ...
+#
+CREATE TABLE t43 (pk INT PRIMARY KEY, a INT, b CHAR(1), KEY(a)) ENGINE=RocksDB;
+INSERT INTO t43 VALUES (1,8,'g'),(2,9,'x');
+UPDATE t43 SET pk = 10 WHERE a = 8;
+REPLACE INTO t43 ( a ) VALUES ( 8 );
+Warnings:
+Warning 1364 Field 'pk' doesn't have a default value
+REPLACE INTO t43 ( b ) VALUES ( 'y' );
+Warnings:
+Warning 1364 Field 'pk' doesn't have a default value
+SELECT * FROM t43 WHERE a = 8;
+pk a b
+10 8 g
+DELETE FROM t43 WHERE a = 8;
+DROP TABLE t43;
+#
+# Basic AUTO_INCREMENT tests
+#
+create table t44(pk int primary key auto_increment, col1 varchar(12)) engine=rocksdb;
+insert into t44 (col1) values ('row1');
+insert into t44 (col1) values ('row2');
+insert into t44 (col1) values ('row3');
+select * from t44;
+pk col1
+1 row1
+2 row2
+3 row3
+drop table t44;
+#
+# ALTER TABLE tests
+#
+create table t45 (pk int primary key, col1 varchar(12)) engine=rocksdb;
+insert into t45 values (1, 'row1');
+insert into t45 values (2, 'row2');
+alter table t45 rename t46;
+select * from t46;
+pk col1
+1 row1
+2 row2
+drop table t46;
+drop table t45;
+ERROR 42S02: Unknown table 'test.t45'
+#
+# Check Bulk loading
+# Bulk loading used to overwrite existing data
+# Now it fails if there is data overlap with what
+# already exists
+#
+show variables
+where
+variable_name like 'rocksdb%' and
+variable_name not like 'rocksdb_max_open_files' and
+variable_name not like 'rocksdb_supported_compression_types';
+Variable_name Value
+rocksdb_access_hint_on_compaction_start 1
+rocksdb_advise_random_on_open ON
+rocksdb_allow_concurrent_memtable_write OFF
+rocksdb_allow_mmap_reads OFF
+rocksdb_allow_mmap_writes OFF
+rocksdb_allow_to_start_after_corruption OFF
+rocksdb_blind_delete_primary_key OFF
+rocksdb_block_cache_size 536870912
+rocksdb_block_restart_interval 16
+rocksdb_block_size 4096
+rocksdb_block_size_deviation 10
+rocksdb_bulk_load OFF
+rocksdb_bulk_load_allow_sk OFF
+rocksdb_bulk_load_allow_unsorted OFF
+rocksdb_bulk_load_size 1000
+rocksdb_bytes_per_sync 0
+rocksdb_cache_dump ON
+rocksdb_cache_high_pri_pool_ratio 0.000000
+rocksdb_cache_index_and_filter_blocks ON
+rocksdb_cache_index_and_filter_with_high_priority ON
+rocksdb_checksums_pct 100
+rocksdb_collect_sst_properties ON
+rocksdb_commit_in_the_middle OFF
+rocksdb_commit_time_batch_for_recovery ON
+rocksdb_compact_cf
+rocksdb_compaction_readahead_size 0
+rocksdb_compaction_sequential_deletes 0
+rocksdb_compaction_sequential_deletes_count_sd OFF
+rocksdb_compaction_sequential_deletes_file_size 0
+rocksdb_compaction_sequential_deletes_window 0
+rocksdb_create_checkpoint
+rocksdb_create_if_missing ON
+rocksdb_create_missing_column_families OFF
+rocksdb_datadir ./#rocksdb
+rocksdb_db_write_buffer_size 0
+rocksdb_deadlock_detect OFF
+rocksdb_deadlock_detect_depth 50
+rocksdb_debug_manual_compaction_delay 0
+rocksdb_debug_optimizer_no_zero_cardinality ON
+rocksdb_debug_ttl_ignore_pk OFF
+rocksdb_debug_ttl_read_filter_ts 0
+rocksdb_debug_ttl_rec_ts 0
+rocksdb_debug_ttl_snapshot_ts 0
+rocksdb_default_cf_options
+rocksdb_delayed_write_rate 0
+rocksdb_delete_cf
+rocksdb_delete_obsolete_files_period_micros 21600000000
+rocksdb_enable_2pc ON
+rocksdb_enable_bulk_load_api ON
+rocksdb_enable_insert_with_update_caching ON
+rocksdb_enable_thread_tracking ON
+rocksdb_enable_ttl ON
+rocksdb_enable_ttl_read_filtering ON
+rocksdb_enable_write_thread_adaptive_yield OFF
+rocksdb_error_if_exists OFF
+rocksdb_error_on_suboptimal_collation ON
+rocksdb_flush_log_at_trx_commit 0
+rocksdb_force_compute_memtable_stats ON
+rocksdb_force_compute_memtable_stats_cachetime 0
+rocksdb_force_flush_memtable_and_lzero_now OFF
+rocksdb_force_flush_memtable_now OFF
+rocksdb_force_index_records_in_range 0
+rocksdb_git_hash #
+rocksdb_hash_index_allow_collision ON
+rocksdb_ignore_unknown_options ON
+rocksdb_index_type kBinarySearch
+rocksdb_info_log_level error_level
+rocksdb_io_write_timeout 0
+rocksdb_is_fd_close_on_exec ON
+rocksdb_keep_log_file_num 1000
+rocksdb_large_prefix OFF
+rocksdb_lock_scanned_rows OFF
+rocksdb_lock_wait_timeout 1
+rocksdb_log_file_time_to_roll 0
+rocksdb_manifest_preallocation_size 4194304
+rocksdb_manual_compaction_threads 0
+rocksdb_manual_wal_flush ON
+rocksdb_master_skip_tx_api OFF
+rocksdb_max_background_jobs 2
+rocksdb_max_latest_deadlocks 5
+rocksdb_max_log_file_size 0
+rocksdb_max_manifest_file_size 1073741824
+rocksdb_max_manual_compactions 10
+rocksdb_max_row_locks 1048576
+rocksdb_max_subcompactions 1
+rocksdb_max_total_wal_size 0
+rocksdb_merge_buf_size 67108864
+rocksdb_merge_combine_read_size 1073741824
+rocksdb_merge_tmp_file_removal_delay_ms 0
+rocksdb_new_table_reader_for_compaction_inputs OFF
+rocksdb_no_block_cache OFF
+rocksdb_override_cf_options
+rocksdb_paranoid_checks ON
+rocksdb_pause_background_work ON
+rocksdb_perf_context_level 0
+rocksdb_persistent_cache_path
+rocksdb_persistent_cache_size_mb 0
+rocksdb_pin_l0_filter_and_index_blocks_in_cache ON
+rocksdb_print_snapshot_conflict_queries OFF
+rocksdb_rate_limiter_bytes_per_sec 0
+rocksdb_records_in_range 50
+rocksdb_remove_mariabackup_checkpoint OFF
+rocksdb_reset_stats OFF
+rocksdb_rollback_on_timeout OFF
+rocksdb_seconds_between_stat_computes 3600
+rocksdb_signal_drop_index_thread OFF
+rocksdb_sim_cache_size 0
+rocksdb_skip_bloom_filter_on_read OFF
+rocksdb_skip_fill_cache OFF
+rocksdb_skip_unique_check_tables .*
+rocksdb_sst_mgr_rate_bytes_per_sec 0
+rocksdb_stats_dump_period_sec 600
+rocksdb_stats_level 0
+rocksdb_stats_recalc_rate 0
+rocksdb_store_row_debug_checksums OFF
+rocksdb_strict_collation_check OFF
+rocksdb_strict_collation_exceptions
+rocksdb_table_cache_numshardbits 6
+rocksdb_table_stats_sampling_pct 10
+rocksdb_tmpdir
+rocksdb_trace_sst_api OFF
+rocksdb_two_write_queues ON
+rocksdb_unsafe_for_binlog OFF
+rocksdb_update_cf_options
+rocksdb_use_adaptive_mutex OFF
+rocksdb_use_clock_cache OFF
+rocksdb_use_direct_io_for_flush_and_compaction OFF
+rocksdb_use_direct_reads OFF
+rocksdb_use_fsync OFF
+rocksdb_validate_tables 1
+rocksdb_verify_row_debug_checksums OFF
+rocksdb_wal_bytes_per_sync 0
+rocksdb_wal_dir
+rocksdb_wal_recovery_mode 1
+rocksdb_wal_size_limit_mb 0
+rocksdb_wal_ttl_seconds 0
+rocksdb_whole_key_filtering ON
+rocksdb_write_batch_max_bytes 0
+rocksdb_write_disable_wal OFF
+rocksdb_write_ignore_missing_column_families OFF
+rocksdb_write_policy write_committed
+create table t47 (pk int primary key, col1 varchar(12)) engine=rocksdb;
+insert into t47 values (1, 'row1');
+insert into t47 values (2, 'row2');
+set rocksdb_bulk_load=1;
+insert into t47 values (3, 'row3'),(4, 'row4');
+set rocksdb_bulk_load=0;
+connect con1,localhost,root,,;
+set rocksdb_bulk_load=1;
+insert into t47 values (10, 'row10'),(11, 'row11');
+connection default;
+set rocksdb_bulk_load=1;
+insert into t47 values (100, 'row100'),(101, 'row101');
+disconnect con1;
+connection default;
+set rocksdb_bulk_load=0;
+select * from t47;
+pk col1
+1 row1
+2 row2
+3 row3
+4 row4
+10 row10
+11 row11
+100 row100
+101 row101
+drop table t47;
+#
+# Fix TRUNCATE over empty table (transaction is committed when it wasn't
+# started)
+#
+create table t48(pk int primary key auto_increment, col1 varchar(12)) engine=rocksdb;
+set autocommit=0;
+truncate table t48;
+set autocommit=1;
+drop table t48;
+#
+# MDEV-4059: RocksDB: query waiting for a lock cannot be killed until query timeout exceeded
+#
+create table t49 (pk int primary key, a int) engine=RocksDB;
+insert into t49 values (1,10),(2,20);
+begin;
+update t49 set a = 100 where pk = 1;
+connect con1,localhost,root,,;
+set rocksdb_lock_wait_timeout=60;
+set @var1= to_seconds(now());
+update t49 set a = 1000 where pk = 1;
+connect con2,localhost,root,,;
+kill query $con1_id;
+connection con1;
+ERROR 70100: Query execution was interrupted
+set @var2= to_seconds(now());
+select if ((@var2 - @var1) < 60, "passed", (@var2 - @var1)) as 'result';
+result
+passed
+connection default;
+disconnect con1;
+commit;
+drop table t49;
+#
+# Index-only tests for INT-based columns
+#
+create table t1 (pk int primary key, key1 int, col1 int, key(key1)) engine=rocksdb;
+insert into t1 values (1,1,1);
+insert into t1 values (2,2,2);
+insert into t1 values (-5,-5,-5);
+# INT column uses index-only:
+explain
+select key1 from t1 where key1=2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref key1 key1 5 const # Using index
+select key1 from t1 where key1=2;
+key1
+2
+select key1 from t1 where key1=-5;
+key1
+-5
+drop table t1;
+create table t2 (pk int primary key, key1 int unsigned, col1 int, key(key1)) engine=rocksdb;
+insert into t2 values (1,1,1), (2,2,2);
+# INT UNSIGNED column uses index-only:
+explain
+select key1 from t2 where key1=2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref key1 key1 5 const # Using index
+select key1 from t2 where key1=2;
+key1
+2
+drop table t2;
+create table t3 (pk bigint primary key, key1 bigint, col1 int, key(key1)) engine=rocksdb;
+insert into t3 values (1,1,1), (2,2,2);
+# BIGINT uses index-only:
+explain
+select key1 from t3 where key1=2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 ref key1 key1 9 const # Using index
+select key1 from t3 where key1=2;
+key1
+2
+drop table t3;
+#
+# Index-only reads for string columns
+#
+create table t1 (
+pk int primary key,
+key1 char(10) character set binary,
+col1 int,
+key (key1)
+) engine=rocksdb;
+insert into t1 values(1, 'one',11), (2,'two',22);
+explain
+select key1 from t1 where key1='one';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref key1 key1 11 const # Using where; Using index
+# The following will produce no rows. This looks like a bug,
+# but it is actually correct behavior. Binary strings are end-padded
+# with \0 character (and not space). Comparison does not ignore
+# the tail of \0.
+select key1 from t1 where key1='one';
+key1
+explain
+select hex(key1) from t1 where key1='one\0\0\0\0\0\0\0';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref key1 key1 11 const # Using where; Using index
+select hex(key1) from t1 where key1='one\0\0\0\0\0\0\0';
+hex(key1)
+6F6E6500000000000000
+drop table t1;
+create table t2 (
+pk int primary key,
+key1 char(10) collate latin1_bin,
+col1 int,
+key (key1)
+) engine=rocksdb;
+insert into t2 values(1, 'one',11), (2,'two',22);
+explain
+select key1 from t2 where key1='one';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref key1 key1 11 const # Using where; Using index
+select key1 from t2 where key1='one';
+key1
+one
+drop table t2;
+create table t3 (
+pk int primary key,
+key1 char(10) collate utf8_bin,
+col1 int,
+key (key1)
+) engine=rocksdb;
+insert into t3 values(1, 'one',11), (2,'two',22);
+explain
+select key1 from t3 where key1='one';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 ref key1 key1 31 const # Using where; Using index
+select key1 from t3 where key1='one';
+key1
+one
+drop table t3;
+# a VARCHAR column
+create table t4 (
+pk int primary key,
+key1 varchar(10) collate latin1_bin,
+key(key1)
+) engine=rocksdb;
+insert into t4 values(1, 'one'), (2,'two'),(3,'threee'),(55,'fifty-five');
+explain
+select key1 from t4 where key1='two';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ref key1 key1 13 const # Using where; Using index
+select key1 from t4 where key1='two';
+key1
+two
+select key1 from t4 where key1='fifty-five';
+key1
+fifty-five
+explain
+select key1 from t4 where key1 between 's' and 'u';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 range key1 key1 13 NULL # Using where; Using index
+select key1 from t4 where key1 between 's' and 'u';
+key1
+threee
+two
+drop table t4;
+#
+# MDEV-4305: RocksDB: Assertion `((keypart_map + 1) & keypart_map) == 0' fails in calculate_key_len
+#
+CREATE TABLE t1 (pk1 INT, pk2 CHAR(32), i INT, PRIMARY KEY(pk1,pk2), KEY(i)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1,'test1',6),(2,'test2',8);
+SELECT * FROM t1 WHERE i != 3 OR pk1 > 9;
+pk1 pk2 i
+1 test1 6
+2 test2 8
+DROP TABLE t1;
+#
+# MDEV-4298: RocksDB: Assertion `thd->is_error() || kill_errno' fails in ha_rows filesort
+#
+call mtr.add_suppression("Sort aborted");
+CREATE TABLE t1 (pk INT PRIMARY KEY, i INT, KEY(i)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1,1),(2,2);
+BEGIN;
+UPDATE t1 SET i = 100;
+connect con1,localhost,root,,test;
+DELETE IGNORE FROM t1 ORDER BY i;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+disconnect con1;
+connection default;
+COMMIT;
+DROP TABLE t1;
+#
+# MDEV-4324: RocksDB: Valgrind "Use of uninitialised value" warnings on inserting value into varchar field
+# (testcase only)
+#
+CREATE TABLE t1 (pk INT PRIMARY KEY, c VARCHAR(4)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1,'foo'), (2,'bar');
+DROP TABLE t1;
+#
+# MDEV-4304: RocksDB: Index-only scan by a field with utf8_bin collation returns garbage symbols
+#
+CREATE TABLE t1 (pk INT PRIMARY KEY, c1 CHAR(1), c2 CHAR(1), KEY(c1)) ENGINE=RocksDB CHARSET utf8 COLLATE utf8_bin;
+INSERT INTO t1 VALUES (1,'h','h');
+SELECT * FROM t1;
+pk c1 c2
+1 h h
+SELECT c1 FROM t1;
+c1
+h
+DROP TABLE t1;
+#
+# MDEV-4300: RocksDB: Server crashes in inline_mysql_mutex_lock on SELECT .. FOR UPDATE
+#
+CREATE TABLE t2 (pk INT PRIMARY KEY, i INT, KEY (i)) ENGINE=RocksDB;
+INSERT INTO t2 VALUES (1,4),(2,5);
+SELECT 1 FROM t2 WHERE i < 0 FOR UPDATE;
+1
+DROP TABLE t2;
+#
+# MDEV-4301: RocksDB: Assertion `pack_info != __null' fails in Rdb_key_def::unpack_record
+#
+CREATE TABLE t1 (pk INT PRIMARY KEY, i INT, c CHAR(1), KEY(c,i)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1,4,'d'),(2,8,'e');
+SELECT MAX( pk ) FROM t1 WHERE i = 105 AND c = 'h';
+MAX( pk )
+NULL
+DROP TABLE t1;
+#
+# MDEV-4337: RocksDB: Inconsistent results comparing a char field with an int field
+#
+create table t1 (c char(1), i int, primary key(c), key(i)) engine=RocksDB;
+insert into t1 values ('2',2),('6',6);
+select * from t1 where c = i;
+c i
+2 2
+6 6
+select * from t1 ignore index (i) where c = i;
+c i
+2 2
+6 6
+drop table t1;
+#
+# Test statement rollback inside a transaction
+#
+create table t1 (pk varchar(12) primary key) engine=rocksdb;
+insert into t1 values ('old-val1'),('old-val2');
+create table t2 (pk varchar(12) primary key) engine=rocksdb;
+insert into t2 values ('new-val2'),('old-val1');
+begin;
+insert into t1 values ('new-val1');
+insert into t1 select * from t2;
+ERROR 23000: Duplicate entry 'old-val1' for key 'PRIMARY'
+commit;
+select * from t1;
+pk
+new-val1
+old-val1
+old-val2
+drop table t1, t2;
+#
+# MDEV-4383: RocksDB: Wrong result of DELETE .. ORDER BY .. LIMIT:
+# rows that should be deleted remain in the table
+#
+CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=RocksDB;
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t1 (pk) VALUES (NULL),(NULL);
+BEGIN;
+INSERT INTO t2 (pk) VALUES (NULL),(NULL);
+INSERT INTO t1 (pk) VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+SELECT * FROM t1 ORDER BY pk LIMIT 9;
+pk
+1
+2
+3
+4
+5
+6
+7
+8
+affected rows: 8
+DELETE FROM t1 ORDER BY pk LIMIT 9;
+affected rows: 8
+SELECT * FROM t1 ORDER BY pk LIMIT 9;
+pk
+affected rows: 0
+DROP TABLE t1,t2;
+#
+# MDEV-4374: RocksDB: Valgrind warnings 'Use of uninitialised value' on
+# inserting into a varchar column
+#
+CREATE TABLE t1 (pk INT PRIMARY KEY, a VARCHAR(32)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
+DROP TABLE t1;
+#
+# MDEV-4061: RocksDB: Changes from an interrupted query are still applied
+#
+create table t1 (pk int primary key, a int) engine=RocksDB;
+insert into t1 values (1,10),(2,20);
+set autocommit = 1;
+update t1 set a = sleep(100) where pk = 1;
+connect con1,localhost,root,,;
+kill query $con_id;
+connection default;
+ERROR 70100: Query execution was interrupted
+select * from t1;
+pk a
+1 10
+2 20
+disconnect con1;
+drop table t1;
+#
+# MDEV-4099: RocksDB: Wrong results with index and range access after INSERT IGNORE or REPLACE
+#
+CREATE TABLE t1 (pk INT PRIMARY KEY, a SMALLINT, b INT, KEY (a)) ENGINE=RocksDB;
+INSERT IGNORE INTO t1 VALUES (1, 157, 0), (2, 1898, -504403), (1, -14659, 0);
+Warnings:
+Warning 1062 Duplicate entry '1' for key 'PRIMARY'
+SELECT * FROM t1;
+pk a b
+1 157 0
+2 1898 -504403
+SELECT pk FROM t1;
+pk
+1
+2
+SELECT * FROM t1 WHERE a != 97;
+pk a b
+1 157 0
+2 1898 -504403
+DROP TABLE t1;
+#
+# Test @@rocksdb_max_row_locks
+#
+CREATE TABLE t1 (pk INT PRIMARY KEY, a int) ENGINE=RocksDB;
+set @a=-1;
+insert into t1 select (@a:=@a+1), 1234 from information_schema.session_variables limit 100;
+set @tmp1= @@rocksdb_max_row_locks;
+set rocksdb_max_row_locks= 20;
+update t1 set a=a+10;
+ERROR HY000: Got error 10 'Operation aborted: Failed to acquire lock due to rocksdb_max_row_locks limit' from ROCKSDB
+DROP TABLE t1;
+#
+# Test AUTO_INCREMENT behavior problem,
+# "explicit insert into an auto-inc column is not noticed by RocksDB"
+#
+create table t1 (i int primary key auto_increment) engine=RocksDB;
+insert into t1 values (null);
+insert into t1 values (null);
+select * from t1;
+i
+1
+2
+drop table t1;
+create table t2 (i int primary key auto_increment) engine=RocksDB;
+insert into t2 values (1);
+select * from t2;
+i
+1
+# this fails (ie. used to fail), RocksDB engine did not notice use of '1' above
+insert into t2 values (null);
+select * from t2;
+i
+1
+2
+# but then this succeeds, so previous statement must have incremented next number counter
+insert into t2 values (null);
+select * from t2;
+i
+1
+2
+3
+drop table t2;
+#
+# Fix Issue#2: AUTO_INCREMENT value doesn't survive server shutdown
+#
+create table t1 (i int primary key auto_increment) engine=RocksDB;
+insert into t1 values (null);
+insert into t1 values (null);
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
+# restart
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+insert into t1 values (null);
+select * from t1;
+i
+1
+2
+3
+drop table t1;
+#
+# Fix Issue #3: SHOW TABLE STATUS shows Auto_increment=0
+#
+create table t1 (i int primary key auto_increment) engine=RocksDB;
+insert into t1 values (null),(null);
+show table status like 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 1000 0 # 0 0 0 3 # # NULL latin1_swedish_ci NULL 0 N
+drop table t1;
+#
+# Fix Issue #4: Crash when using pseudo-unique keys
+#
+CREATE TABLE t1 (
+i INT,
+t TINYINT,
+s SMALLINT,
+m MEDIUMINT,
+b BIGINT,
+pk MEDIUMINT AUTO_INCREMENT PRIMARY KEY,
+UNIQUE KEY b_t (b,t)
+) ENGINE=rocksdb;
+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
+DROP TABLE t1;
+#
+# Fix issue #5: Transaction rollback doesn't undo all changes.
+#
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (id int auto_increment primary key, value int) engine=rocksdb;
+set autocommit=0;
+begin;
+set @a:=0;
+insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4;
+insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4;
+insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4;
+rollback;
+select count(*) from t1;
+count(*)
+0
+set autocommit=1;
+drop table t0, t1;
+#
+# Check status variables
+# NOTE: We exclude rocksdb_num_get_for_update_calls because it's a debug only status var
+#
+show status where variable_name like 'rocksdb%' and variable_name not like '%num_get_for_update%';
+Variable_name Value
+Rocksdb_rows_deleted #
+Rocksdb_rows_inserted #
+Rocksdb_rows_read #
+Rocksdb_rows_updated #
+Rocksdb_rows_deleted_blind #
+Rocksdb_rows_expired #
+Rocksdb_rows_filtered #
+Rocksdb_system_rows_deleted #
+Rocksdb_system_rows_inserted #
+Rocksdb_system_rows_read #
+Rocksdb_system_rows_updated #
+Rocksdb_memtable_total #
+Rocksdb_memtable_unflushed #
+Rocksdb_queries_point #
+Rocksdb_queries_range #
+Rocksdb_covered_secondary_key_lookups #
+Rocksdb_block_cache_add #
+Rocksdb_block_cache_add_failures #
+Rocksdb_block_cache_bytes_read #
+Rocksdb_block_cache_bytes_write #
+Rocksdb_block_cache_data_add #
+Rocksdb_block_cache_data_bytes_insert #
+Rocksdb_block_cache_data_hit #
+Rocksdb_block_cache_data_miss #
+Rocksdb_block_cache_filter_add #
+Rocksdb_block_cache_filter_bytes_evict #
+Rocksdb_block_cache_filter_bytes_insert #
+Rocksdb_block_cache_filter_hit #
+Rocksdb_block_cache_filter_miss #
+Rocksdb_block_cache_hit #
+Rocksdb_block_cache_index_add #
+Rocksdb_block_cache_index_bytes_evict #
+Rocksdb_block_cache_index_bytes_insert #
+Rocksdb_block_cache_index_hit #
+Rocksdb_block_cache_index_miss #
+Rocksdb_block_cache_miss #
+Rocksdb_block_cachecompressed_hit #
+Rocksdb_block_cachecompressed_miss #
+Rocksdb_bloom_filter_full_positive #
+Rocksdb_bloom_filter_full_true_positive #
+Rocksdb_bloom_filter_prefix_checked #
+Rocksdb_bloom_filter_prefix_useful #
+Rocksdb_bloom_filter_useful #
+Rocksdb_bytes_read #
+Rocksdb_bytes_written #
+Rocksdb_compact_read_bytes #
+Rocksdb_compact_write_bytes #
+Rocksdb_compaction_key_drop_new #
+Rocksdb_compaction_key_drop_obsolete #
+Rocksdb_compaction_key_drop_user #
+Rocksdb_flush_write_bytes #
+Rocksdb_get_hit_l0 #
+Rocksdb_get_hit_l1 #
+Rocksdb_get_hit_l2_and_up #
+Rocksdb_getupdatessince_calls #
+Rocksdb_iter_bytes_read #
+Rocksdb_manual_compactions_processed #
+Rocksdb_manual_compactions_running #
+Rocksdb_memtable_hit #
+Rocksdb_memtable_miss #
+Rocksdb_no_file_closes #
+Rocksdb_no_file_errors #
+Rocksdb_no_file_opens #
+Rocksdb_num_iterators #
+Rocksdb_number_block_not_compressed #
+Rocksdb_number_db_next #
+Rocksdb_number_db_next_found #
+Rocksdb_number_db_prev #
+Rocksdb_number_db_prev_found #
+Rocksdb_number_db_seek #
+Rocksdb_number_db_seek_found #
+Rocksdb_number_deletes_filtered #
+Rocksdb_number_keys_read #
+Rocksdb_number_keys_updated #
+Rocksdb_number_keys_written #
+Rocksdb_number_merge_failures #
+Rocksdb_number_multiget_bytes_read #
+Rocksdb_number_multiget_get #
+Rocksdb_number_multiget_keys_read #
+Rocksdb_number_reseeks_iteration #
+Rocksdb_number_sst_entry_delete #
+Rocksdb_number_sst_entry_merge #
+Rocksdb_number_sst_entry_other #
+Rocksdb_number_sst_entry_put #
+Rocksdb_number_sst_entry_singledelete #
+Rocksdb_number_superversion_acquires #
+Rocksdb_number_superversion_cleanups #
+Rocksdb_number_superversion_releases #
+Rocksdb_row_lock_deadlocks #
+Rocksdb_row_lock_wait_timeouts #
+Rocksdb_snapshot_conflict_errors #
+Rocksdb_stall_l0_file_count_limit_slowdowns #
+Rocksdb_stall_locked_l0_file_count_limit_slowdowns #
+Rocksdb_stall_l0_file_count_limit_stops #
+Rocksdb_stall_locked_l0_file_count_limit_stops #
+Rocksdb_stall_pending_compaction_limit_stops #
+Rocksdb_stall_pending_compaction_limit_slowdowns #
+Rocksdb_stall_memtable_limit_stops #
+Rocksdb_stall_memtable_limit_slowdowns #
+Rocksdb_stall_total_stops #
+Rocksdb_stall_total_slowdowns #
+Rocksdb_stall_micros #
+Rocksdb_wal_bytes #
+Rocksdb_wal_group_syncs #
+Rocksdb_wal_synced #
+Rocksdb_write_other #
+Rocksdb_write_self #
+Rocksdb_write_timedout #
+Rocksdb_write_wal #
+select VARIABLE_NAME from INFORMATION_SCHEMA.global_status where VARIABLE_NAME LIKE 'rocksdb%' and VARIABLE_NAME NOT LIKE '%num_get_for_update%';
+VARIABLE_NAME
+ROCKSDB_ROWS_DELETED
+ROCKSDB_ROWS_INSERTED
+ROCKSDB_ROWS_READ
+ROCKSDB_ROWS_UPDATED
+ROCKSDB_ROWS_DELETED_BLIND
+ROCKSDB_ROWS_EXPIRED
+ROCKSDB_ROWS_FILTERED
+ROCKSDB_SYSTEM_ROWS_DELETED
+ROCKSDB_SYSTEM_ROWS_INSERTED
+ROCKSDB_SYSTEM_ROWS_READ
+ROCKSDB_SYSTEM_ROWS_UPDATED
+ROCKSDB_MEMTABLE_TOTAL
+ROCKSDB_MEMTABLE_UNFLUSHED
+ROCKSDB_QUERIES_POINT
+ROCKSDB_QUERIES_RANGE
+ROCKSDB_COVERED_SECONDARY_KEY_LOOKUPS
+ROCKSDB_BLOCK_CACHE_ADD
+ROCKSDB_BLOCK_CACHE_ADD_FAILURES
+ROCKSDB_BLOCK_CACHE_BYTES_READ
+ROCKSDB_BLOCK_CACHE_BYTES_WRITE
+ROCKSDB_BLOCK_CACHE_DATA_ADD
+ROCKSDB_BLOCK_CACHE_DATA_BYTES_INSERT
+ROCKSDB_BLOCK_CACHE_DATA_HIT
+ROCKSDB_BLOCK_CACHE_DATA_MISS
+ROCKSDB_BLOCK_CACHE_FILTER_ADD
+ROCKSDB_BLOCK_CACHE_FILTER_BYTES_EVICT
+ROCKSDB_BLOCK_CACHE_FILTER_BYTES_INSERT
+ROCKSDB_BLOCK_CACHE_FILTER_HIT
+ROCKSDB_BLOCK_CACHE_FILTER_MISS
+ROCKSDB_BLOCK_CACHE_HIT
+ROCKSDB_BLOCK_CACHE_INDEX_ADD
+ROCKSDB_BLOCK_CACHE_INDEX_BYTES_EVICT
+ROCKSDB_BLOCK_CACHE_INDEX_BYTES_INSERT
+ROCKSDB_BLOCK_CACHE_INDEX_HIT
+ROCKSDB_BLOCK_CACHE_INDEX_MISS
+ROCKSDB_BLOCK_CACHE_MISS
+ROCKSDB_BLOCK_CACHECOMPRESSED_HIT
+ROCKSDB_BLOCK_CACHECOMPRESSED_MISS
+ROCKSDB_BLOOM_FILTER_FULL_POSITIVE
+ROCKSDB_BLOOM_FILTER_FULL_TRUE_POSITIVE
+ROCKSDB_BLOOM_FILTER_PREFIX_CHECKED
+ROCKSDB_BLOOM_FILTER_PREFIX_USEFUL
+ROCKSDB_BLOOM_FILTER_USEFUL
+ROCKSDB_BYTES_READ
+ROCKSDB_BYTES_WRITTEN
+ROCKSDB_COMPACT_READ_BYTES
+ROCKSDB_COMPACT_WRITE_BYTES
+ROCKSDB_COMPACTION_KEY_DROP_NEW
+ROCKSDB_COMPACTION_KEY_DROP_OBSOLETE
+ROCKSDB_COMPACTION_KEY_DROP_USER
+ROCKSDB_FLUSH_WRITE_BYTES
+ROCKSDB_GET_HIT_L0
+ROCKSDB_GET_HIT_L1
+ROCKSDB_GET_HIT_L2_AND_UP
+ROCKSDB_GETUPDATESSINCE_CALLS
+ROCKSDB_ITER_BYTES_READ
+ROCKSDB_MANUAL_COMPACTIONS_PROCESSED
+ROCKSDB_MANUAL_COMPACTIONS_RUNNING
+ROCKSDB_MEMTABLE_HIT
+ROCKSDB_MEMTABLE_MISS
+ROCKSDB_NO_FILE_CLOSES
+ROCKSDB_NO_FILE_ERRORS
+ROCKSDB_NO_FILE_OPENS
+ROCKSDB_NUM_ITERATORS
+ROCKSDB_NUMBER_BLOCK_NOT_COMPRESSED
+ROCKSDB_NUMBER_DB_NEXT
+ROCKSDB_NUMBER_DB_NEXT_FOUND
+ROCKSDB_NUMBER_DB_PREV
+ROCKSDB_NUMBER_DB_PREV_FOUND
+ROCKSDB_NUMBER_DB_SEEK
+ROCKSDB_NUMBER_DB_SEEK_FOUND
+ROCKSDB_NUMBER_DELETES_FILTERED
+ROCKSDB_NUMBER_KEYS_READ
+ROCKSDB_NUMBER_KEYS_UPDATED
+ROCKSDB_NUMBER_KEYS_WRITTEN
+ROCKSDB_NUMBER_MERGE_FAILURES
+ROCKSDB_NUMBER_MULTIGET_BYTES_READ
+ROCKSDB_NUMBER_MULTIGET_GET
+ROCKSDB_NUMBER_MULTIGET_KEYS_READ
+ROCKSDB_NUMBER_RESEEKS_ITERATION
+ROCKSDB_NUMBER_SST_ENTRY_DELETE
+ROCKSDB_NUMBER_SST_ENTRY_MERGE
+ROCKSDB_NUMBER_SST_ENTRY_OTHER
+ROCKSDB_NUMBER_SST_ENTRY_PUT
+ROCKSDB_NUMBER_SST_ENTRY_SINGLEDELETE
+ROCKSDB_NUMBER_SUPERVERSION_ACQUIRES
+ROCKSDB_NUMBER_SUPERVERSION_CLEANUPS
+ROCKSDB_NUMBER_SUPERVERSION_RELEASES
+ROCKSDB_ROW_LOCK_DEADLOCKS
+ROCKSDB_ROW_LOCK_WAIT_TIMEOUTS
+ROCKSDB_SNAPSHOT_CONFLICT_ERRORS
+ROCKSDB_STALL_L0_FILE_COUNT_LIMIT_SLOWDOWNS
+ROCKSDB_STALL_LOCKED_L0_FILE_COUNT_LIMIT_SLOWDOWNS
+ROCKSDB_STALL_L0_FILE_COUNT_LIMIT_STOPS
+ROCKSDB_STALL_LOCKED_L0_FILE_COUNT_LIMIT_STOPS
+ROCKSDB_STALL_PENDING_COMPACTION_LIMIT_STOPS
+ROCKSDB_STALL_PENDING_COMPACTION_LIMIT_SLOWDOWNS
+ROCKSDB_STALL_MEMTABLE_LIMIT_STOPS
+ROCKSDB_STALL_MEMTABLE_LIMIT_SLOWDOWNS
+ROCKSDB_STALL_TOTAL_STOPS
+ROCKSDB_STALL_TOTAL_SLOWDOWNS
+ROCKSDB_STALL_MICROS
+ROCKSDB_WAL_BYTES
+ROCKSDB_WAL_GROUP_SYNCS
+ROCKSDB_WAL_SYNCED
+ROCKSDB_WRITE_OTHER
+ROCKSDB_WRITE_SELF
+ROCKSDB_WRITE_TIMEDOUT
+ROCKSDB_WRITE_WAL
+# RocksDB-SE's status variables are global internally
+# but they are shown as both session and global, like InnoDB's status vars.
+select VARIABLE_NAME from INFORMATION_SCHEMA.session_status where VARIABLE_NAME LIKE 'rocksdb%' and VARIABLE_NAME NOT LIKE '%num_get_for_update%';
+VARIABLE_NAME
+ROCKSDB_ROWS_DELETED
+ROCKSDB_ROWS_INSERTED
+ROCKSDB_ROWS_READ
+ROCKSDB_ROWS_UPDATED
+ROCKSDB_ROWS_DELETED_BLIND
+ROCKSDB_ROWS_EXPIRED
+ROCKSDB_ROWS_FILTERED
+ROCKSDB_SYSTEM_ROWS_DELETED
+ROCKSDB_SYSTEM_ROWS_INSERTED
+ROCKSDB_SYSTEM_ROWS_READ
+ROCKSDB_SYSTEM_ROWS_UPDATED
+ROCKSDB_MEMTABLE_TOTAL
+ROCKSDB_MEMTABLE_UNFLUSHED
+ROCKSDB_QUERIES_POINT
+ROCKSDB_QUERIES_RANGE
+ROCKSDB_COVERED_SECONDARY_KEY_LOOKUPS
+ROCKSDB_BLOCK_CACHE_ADD
+ROCKSDB_BLOCK_CACHE_ADD_FAILURES
+ROCKSDB_BLOCK_CACHE_BYTES_READ
+ROCKSDB_BLOCK_CACHE_BYTES_WRITE
+ROCKSDB_BLOCK_CACHE_DATA_ADD
+ROCKSDB_BLOCK_CACHE_DATA_BYTES_INSERT
+ROCKSDB_BLOCK_CACHE_DATA_HIT
+ROCKSDB_BLOCK_CACHE_DATA_MISS
+ROCKSDB_BLOCK_CACHE_FILTER_ADD
+ROCKSDB_BLOCK_CACHE_FILTER_BYTES_EVICT
+ROCKSDB_BLOCK_CACHE_FILTER_BYTES_INSERT
+ROCKSDB_BLOCK_CACHE_FILTER_HIT
+ROCKSDB_BLOCK_CACHE_FILTER_MISS
+ROCKSDB_BLOCK_CACHE_HIT
+ROCKSDB_BLOCK_CACHE_INDEX_ADD
+ROCKSDB_BLOCK_CACHE_INDEX_BYTES_EVICT
+ROCKSDB_BLOCK_CACHE_INDEX_BYTES_INSERT
+ROCKSDB_BLOCK_CACHE_INDEX_HIT
+ROCKSDB_BLOCK_CACHE_INDEX_MISS
+ROCKSDB_BLOCK_CACHE_MISS
+ROCKSDB_BLOCK_CACHECOMPRESSED_HIT
+ROCKSDB_BLOCK_CACHECOMPRESSED_MISS
+ROCKSDB_BLOOM_FILTER_FULL_POSITIVE
+ROCKSDB_BLOOM_FILTER_FULL_TRUE_POSITIVE
+ROCKSDB_BLOOM_FILTER_PREFIX_CHECKED
+ROCKSDB_BLOOM_FILTER_PREFIX_USEFUL
+ROCKSDB_BLOOM_FILTER_USEFUL
+ROCKSDB_BYTES_READ
+ROCKSDB_BYTES_WRITTEN
+ROCKSDB_COMPACT_READ_BYTES
+ROCKSDB_COMPACT_WRITE_BYTES
+ROCKSDB_COMPACTION_KEY_DROP_NEW
+ROCKSDB_COMPACTION_KEY_DROP_OBSOLETE
+ROCKSDB_COMPACTION_KEY_DROP_USER
+ROCKSDB_FLUSH_WRITE_BYTES
+ROCKSDB_GET_HIT_L0
+ROCKSDB_GET_HIT_L1
+ROCKSDB_GET_HIT_L2_AND_UP
+ROCKSDB_GETUPDATESSINCE_CALLS
+ROCKSDB_ITER_BYTES_READ
+ROCKSDB_MANUAL_COMPACTIONS_PROCESSED
+ROCKSDB_MANUAL_COMPACTIONS_RUNNING
+ROCKSDB_MEMTABLE_HIT
+ROCKSDB_MEMTABLE_MISS
+ROCKSDB_NO_FILE_CLOSES
+ROCKSDB_NO_FILE_ERRORS
+ROCKSDB_NO_FILE_OPENS
+ROCKSDB_NUM_ITERATORS
+ROCKSDB_NUMBER_BLOCK_NOT_COMPRESSED
+ROCKSDB_NUMBER_DB_NEXT
+ROCKSDB_NUMBER_DB_NEXT_FOUND
+ROCKSDB_NUMBER_DB_PREV
+ROCKSDB_NUMBER_DB_PREV_FOUND
+ROCKSDB_NUMBER_DB_SEEK
+ROCKSDB_NUMBER_DB_SEEK_FOUND
+ROCKSDB_NUMBER_DELETES_FILTERED
+ROCKSDB_NUMBER_KEYS_READ
+ROCKSDB_NUMBER_KEYS_UPDATED
+ROCKSDB_NUMBER_KEYS_WRITTEN
+ROCKSDB_NUMBER_MERGE_FAILURES
+ROCKSDB_NUMBER_MULTIGET_BYTES_READ
+ROCKSDB_NUMBER_MULTIGET_GET
+ROCKSDB_NUMBER_MULTIGET_KEYS_READ
+ROCKSDB_NUMBER_RESEEKS_ITERATION
+ROCKSDB_NUMBER_SST_ENTRY_DELETE
+ROCKSDB_NUMBER_SST_ENTRY_MERGE
+ROCKSDB_NUMBER_SST_ENTRY_OTHER
+ROCKSDB_NUMBER_SST_ENTRY_PUT
+ROCKSDB_NUMBER_SST_ENTRY_SINGLEDELETE
+ROCKSDB_NUMBER_SUPERVERSION_ACQUIRES
+ROCKSDB_NUMBER_SUPERVERSION_CLEANUPS
+ROCKSDB_NUMBER_SUPERVERSION_RELEASES
+ROCKSDB_ROW_LOCK_DEADLOCKS
+ROCKSDB_ROW_LOCK_WAIT_TIMEOUTS
+ROCKSDB_SNAPSHOT_CONFLICT_ERRORS
+ROCKSDB_STALL_L0_FILE_COUNT_LIMIT_SLOWDOWNS
+ROCKSDB_STALL_LOCKED_L0_FILE_COUNT_LIMIT_SLOWDOWNS
+ROCKSDB_STALL_L0_FILE_COUNT_LIMIT_STOPS
+ROCKSDB_STALL_LOCKED_L0_FILE_COUNT_LIMIT_STOPS
+ROCKSDB_STALL_PENDING_COMPACTION_LIMIT_STOPS
+ROCKSDB_STALL_PENDING_COMPACTION_LIMIT_SLOWDOWNS
+ROCKSDB_STALL_MEMTABLE_LIMIT_STOPS
+ROCKSDB_STALL_MEMTABLE_LIMIT_SLOWDOWNS
+ROCKSDB_STALL_TOTAL_STOPS
+ROCKSDB_STALL_TOTAL_SLOWDOWNS
+ROCKSDB_STALL_MICROS
+ROCKSDB_WAL_BYTES
+ROCKSDB_WAL_GROUP_SYNCS
+ROCKSDB_WAL_SYNCED
+ROCKSDB_WRITE_OTHER
+ROCKSDB_WRITE_SELF
+ROCKSDB_WRITE_TIMEDOUT
+ROCKSDB_WRITE_WAL
+#
+# Fix issue #9: HA_ERR_INTERNAL_ERROR when running linkbench
+#
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (
+pk int primary key,
+col1 varchar(255),
+key(col1)
+) engine=rocksdb;
+insert into t1 select a, repeat('123456789ABCDEF-', 15) from t0;
+select * from t1 where pk=3;
+pk col1
+3 123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-
+drop table t0, t1;
+#
+# Fix issue #10: Segfault in Rdb_key_def::get_primary_key_tuple
+#
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+CREATE TABLE t1 (
+id1 bigint(20) unsigned NOT NULL DEFAULT '0',
+id2 bigint(20) unsigned NOT NULL DEFAULT '0',
+link_type bigint(20) unsigned NOT NULL DEFAULT '0',
+visibility tinyint(3) NOT NULL DEFAULT '0',
+data varchar(255) NOT NULL DEFAULT '',
+time bigint(20) unsigned NOT NULL DEFAULT '0',
+version int(11) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (link_type,id1,id2)
+) engine=rocksdb;
+insert into t1 select a,a,a,1,a,a,a from t0;
+alter table t1 add index id1_type (id1,link_type,visibility,time,version,data);
+select * from t1 where id1 = 3;
+id1 id2 link_type visibility data time version
+3 3 3 1 3 3 3
+drop table t0,t1;
+#
+# Test column families
+#
+create table t1 (
+pk int primary key,
+col1 int,
+col2 int,
+key(col1) comment 'cf3',
+key(col2) comment 'cf4'
+) engine=rocksdb;
+insert into t1 values (1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5);
+explain
+select * from t1 where col1=2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref col1 col1 5 const #
+select * from t1 where col1=2;
+pk col1 col2
+2 2 2
+explain
+select * from t1 where col2=3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref col2 col2 5 const #
+select * from t1 where col2=3;
+pk col1 col2
+3 3 3
+select * from t1 where pk=4;
+pk col1 col2
+4 4 4
+drop table t1;
+#
+# Try primary key in a non-default CF:
+#
+create table t1 (
+pk int,
+col1 int,
+col2 int,
+key(col1) comment 'cf3',
+key(col2) comment 'cf4',
+primary key (pk) comment 'cf5'
+) engine=rocksdb;
+insert into t1 values (1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5);
+explain
+select * from t1 where col1=2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref col1 col1 5 const #
+select * from t1 where col1=2;
+pk col1 col2
+2 2 2
+select * from t1 where pk=4;
+pk col1 col2
+4 4 4
+drop table t1;
+#
+# Issue #15: SIGSEGV from reading in blob data
+#
+CREATE TABLE t1 (
+id int not null,
+blob_col text,
+PRIMARY KEY (id)
+) ENGINE=ROCKSDB CHARSET=latin1;
+INSERT INTO t1 SET id=123, blob_col=repeat('z',64000) ON DUPLICATE KEY UPDATE blob_col=VALUES(blob_col);
+INSERT INTO t1 SET id=123, blob_col='' ON DUPLICATE KEY UPDATE blob_col=VALUES(blob_col);
+DROP TABLE t1;
+#
+# Issue #17: Automatic per-index column families
+# (Now deprecated)
+#
+create table t1 (
+id int not null,
+key1 int,
+PRIMARY KEY (id),
+index (key1) comment '$per_index_cf'
+) engine=rocksdb;
+ERROR HY000: The per-index column family option has been deprecated
+#
+# Issue #22: SELECT ... FOR UPDATE takes a long time
+#
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (
+id1 int,
+id2 int,
+value1 int,
+value2 int,
+primary key(id1, id2) COMMENT 'new_column_family',
+key(id2)
+) engine=rocksdb default charset=latin1 collate=latin1_bin;
+insert into t1 select A.a, B.a, 31, 1234 from t0 A, t0 B;
+explain
+select * from t1 where id1=30 and value1=30 for update;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref PRIMARY PRIMARY 4 const # Using where
+set @var1=(select variable_value
+from information_schema.global_status
+where variable_name='rocksdb_number_keys_read');
+select * from t1 where id1=3 and value1=3 for update;
+id1 id2 value1 value2
+set @var2=(select variable_value
+from information_schema.global_status
+where variable_name='rocksdb_number_keys_read');
+# The following must return true (before the fix, the difference was 70):
+select if((@var2 - @var1) < 30, 1, @var2-@var1);
+if((@var2 - @var1) < 30, 1, @var2-@var1)
+1
+drop table t0,t1;
+#
+# Issue #33: SELECT ... FROM rocksdb_table ORDER BY primary_key uses sorting
+#
+create table t1 (id int primary key, value int) engine=rocksdb;
+insert into t1 values (1,1),(2,2),(3,3);
+# The following must not use 'Using filesort':
+explain select * from t1 ORDER BY id;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 4 NULL #
+drop table t1;
+#
+# Issue #26: Index-only scans for DATETIME and TIMESTAMP
+#
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+# Try a DATETIME column:
+create table t1 (
+pk int auto_increment primary key,
+kp1 datetime,
+kp2 int,
+col1 int,
+key(kp1, kp2)
+) engine=rocksdb;
+insert into t1 (kp1,kp2)
+select date_add('2015-01-01 12:34:56', interval a day), a from t0;
+select * from t1;
+pk kp1 kp2 col1
+1 2015-01-01 12:34:56 0 NULL
+2 2015-01-02 12:34:56 1 NULL
+3 2015-01-03 12:34:56 2 NULL
+4 2015-01-04 12:34:56 3 NULL
+5 2015-01-05 12:34:56 4 NULL
+6 2015-01-06 12:34:56 5 NULL
+7 2015-01-07 12:34:56 6 NULL
+8 2015-01-08 12:34:56 7 NULL
+9 2015-01-09 12:34:56 8 NULL
+10 2015-01-10 12:34:56 9 NULL
+# This must show 'Using index'
+explain
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range kp1 kp1 6 NULL # Using where; Using index
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+kp1 kp2
+2015-01-01 12:34:56 0
+2015-01-02 12:34:56 1
+2015-01-03 12:34:56 2
+2015-01-04 12:34:56 3
+2015-01-05 12:34:56 4
+# Now, the same with NOT NULL column
+create table t2 (
+pk int auto_increment primary key,
+kp1 datetime not null,
+kp2 int,
+col1 int,
+key(kp1, kp2)
+) engine=rocksdb;
+insert into t2 select * from t1;
+# This must show 'Using index'
+explain
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 5 NULL # Using where; Using index
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+kp1 kp2
+2015-01-01 12:34:56 0
+2015-01-02 12:34:56 1
+2015-01-03 12:34:56 2
+2015-01-04 12:34:56 3
+2015-01-05 12:34:56 4
+drop table t1,t2;
+# Try a DATE column:
+create table t1 (
+pk int auto_increment primary key,
+kp1 date,
+kp2 int,
+col1 int,
+key(kp1, kp2)
+) engine=rocksdb;
+insert into t1 (kp1,kp2)
+select date_add('2015-01-01', interval a day), a from t0;
+select * from t1;
+pk kp1 kp2 col1
+1 2015-01-01 0 NULL
+2 2015-01-02 1 NULL
+3 2015-01-03 2 NULL
+4 2015-01-04 3 NULL
+5 2015-01-05 4 NULL
+6 2015-01-06 5 NULL
+7 2015-01-07 6 NULL
+8 2015-01-08 7 NULL
+9 2015-01-09 8 NULL
+10 2015-01-10 9 NULL
+# This must show 'Using index'
+explain
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2015-01-01' and '2015-01-05';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range kp1 kp1 4 NULL # Using where; Using index
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2015-01-01' and '2015-01-05';
+kp1 kp2
+2015-01-01 0
+2015-01-02 1
+2015-01-03 2
+2015-01-04 3
+2015-01-05 4
+# Now, the same with NOT NULL column
+create table t2 (
+pk int auto_increment primary key,
+kp1 date not null,
+kp2 int,
+col1 int,
+key(kp1, kp2)
+) engine=rocksdb;
+insert into t2 select * from t1;
+# This must show 'Using index'
+explain
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 3 NULL # Using where; Using index
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+kp1 kp2
+2015-01-01 0
+2015-01-02 1
+2015-01-03 2
+2015-01-04 3
+2015-01-05 4
+drop table t1,t2;
+#
+# Try a TIMESTAMP column:
+#
+create table t1 (
+pk int auto_increment primary key,
+kp1 timestamp,
+kp2 int,
+col1 int,
+key(kp1, kp2)
+) engine=rocksdb;
+insert into t1 (kp1,kp2)
+select date_add('2015-01-01 12:34:56', interval a day), a from t0;
+select * from t1;
+pk kp1 kp2 col1
+1 2015-01-01 12:34:56 0 NULL
+2 2015-01-02 12:34:56 1 NULL
+3 2015-01-03 12:34:56 2 NULL
+4 2015-01-04 12:34:56 3 NULL
+5 2015-01-05 12:34:56 4 NULL
+6 2015-01-06 12:34:56 5 NULL
+7 2015-01-07 12:34:56 6 NULL
+8 2015-01-08 12:34:56 7 NULL
+9 2015-01-09 12:34:56 8 NULL
+10 2015-01-10 12:34:56 9 NULL
+# This must show 'Using index'
+explain
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range kp1 kp1 5 NULL # Using where; Using index
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+kp1 kp2
+2015-01-01 12:34:56 0
+2015-01-02 12:34:56 1
+2015-01-03 12:34:56 2
+2015-01-04 12:34:56 3
+2015-01-05 12:34:56 4
+# Now, the same with NOT NULL column
+create table t2 (
+pk int auto_increment primary key,
+kp1 timestamp not null,
+kp2 int,
+col1 int,
+key(kp1, kp2)
+) engine=rocksdb;
+insert into t2 select * from t1;
+# This must show 'Using index'
+explain
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 4 NULL # Using where; Using index
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+kp1 kp2
+2015-01-01 12:34:56 0
+2015-01-02 12:34:56 1
+2015-01-03 12:34:56 2
+2015-01-04 12:34:56 3
+2015-01-05 12:34:56 4
+drop table t1,t2;
+#
+# Try a TIME column:
+#
+create table t1 (
+pk int auto_increment primary key,
+kp1 time,
+kp2 int,
+col1 int,
+key(kp1, kp2)
+) engine=rocksdb;
+insert into t1 (kp1,kp2)
+select date_add('2015-01-01 09:00:00', interval a minute), a from t0;
+select * from t1;
+pk kp1 kp2 col1
+1 09:00:00 0 NULL
+2 09:01:00 1 NULL
+3 09:02:00 2 NULL
+4 09:03:00 3 NULL
+5 09:04:00 4 NULL
+6 09:05:00 5 NULL
+7 09:06:00 6 NULL
+8 09:07:00 7 NULL
+9 09:08:00 8 NULL
+10 09:09:00 9 NULL
+# This must show 'Using index'
+explain
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '09:01:00' and '09:05:00';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range kp1 kp1 4 NULL # Using where; Using index
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '09:01:00' and '09:05:00';
+kp1 kp2
+09:01:00 1
+09:02:00 2
+09:03:00 3
+09:04:00 4
+09:05:00 5
+# Now, the same with NOT NULL column
+create table t2 (
+pk int auto_increment primary key,
+kp1 time not null,
+kp2 int,
+col1 int,
+key(kp1, kp2)
+) engine=rocksdb;
+insert into t2 select * from t1;
+# This must show 'Using index'
+explain
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '09:01:00' and '09:05:00';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 3 NULL # Using where; Using index
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '09:01:00' and '09:05:00';
+kp1 kp2
+09:01:00 1
+09:02:00 2
+09:03:00 3
+09:04:00 4
+09:05:00 5
+drop table t1,t2;
+#
+# Try a YEAR column:
+#
+create table t1 (
+pk int auto_increment primary key,
+kp1 year,
+kp2 int,
+col1 int,
+key(kp1, kp2)
+) engine=rocksdb;
+insert into t1 (kp1,kp2) select 2015+a, a from t0;
+select * from t1;
+pk kp1 kp2 col1
+1 2015 0 NULL
+2 2016 1 NULL
+3 2017 2 NULL
+4 2018 3 NULL
+5 2019 4 NULL
+6 2020 5 NULL
+7 2021 6 NULL
+8 2022 7 NULL
+9 2023 8 NULL
+10 2024 9 NULL
+# This must show 'Using index'
+explain
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2016' and '2020';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range kp1 kp1 2 NULL # Using where; Using index
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2016' and '2020';
+kp1 kp2
+2016 1
+2017 2
+2018 3
+2019 4
+2020 5
+# Now, the same with NOT NULL column
+create table t2 (
+pk int auto_increment primary key,
+kp1 year not null,
+kp2 int,
+col1 int,
+key(kp1, kp2)
+) engine=rocksdb;
+insert into t2 select * from t1;
+# This must show 'Using index'
+explain
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2016' and '2020';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 1 NULL # Using where; Using index
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2016' and '2020';
+kp1 kp2
+2016 1
+2017 2
+2018 3
+2019 4
+2020 5
+drop table t1,t2;
+#
+# Issue #57: Release row locks on statement errors
+#
+create table t1 (id int primary key) engine=rocksdb;
+insert into t1 values (1), (2), (3);
+begin;
+insert into t1 values (4), (5), (6);
+insert into t1 values (7), (8), (2), (9);
+ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
+select * from t1;
+id
+1
+2
+3
+4
+5
+6
+begin;
+select * from t1 where id=4 for update;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+select * from t1 where id=7 for update;
+id
+select * from t1 where id=9 for update;
+id
+drop table t1;
+#Index on blob column
+SET @old_mode = @@sql_mode;
+SET sql_mode = 'strict_all_tables';
+create table t1 (a int, b text, c varchar(400), Primary Key(a), Key(c, b(255))) engine=rocksdb;
+drop table t1;
+set global rocksdb_large_prefix=1;
+create table t1 (a int, b text, c varchar(400), Primary Key(a), Key(b(1255))) engine=rocksdb;
+set global rocksdb_large_prefix=0;
+insert into t1 values (1, '1abcde', '1abcde'), (2, '2abcde', '2abcde'), (3, '3abcde', '3abcde');
+select * from t1;
+a b c
+1 1abcde 1abcde
+2 2abcde 2abcde
+3 3abcde 3abcde
+explain select * from t1 where b like '1%';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range b b 1258 NULL # Using where
+explain select b, a from t1 where b like '1%';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range b b 1258 NULL # Using where
+update t1 set b= '12345' where b = '2abcde';
+select * from t1;
+a b c
+1 1abcde 1abcde
+2 12345 2abcde
+3 3abcde 3abcde
+drop table t1;
+create table t1 (a int, b text, c varchar(400), Primary Key(a), Key(b(2255))) engine=rocksdb;
+Warnings:
+Note 1071 Specified key was too long; max key length is 767 bytes
+drop table t1;
+SET sql_mode = @old_mode;
+drop table t0;
+#
+# Fix assertion failure (attempt to overrun the key buffer) for prefix indexes
+#
+create table t1 (
+pk int primary key,
+col1 varchar(100),
+key (col1(10))
+) engine=rocksdb;
+insert into t1 values (1, repeat('0123456789', 9));
+drop table t1;
+#
+# Issue #76: Assertion `buf == table->record[0]' fails in virtual int ha_rocksdb::delete_row(const uchar*)
+#
+CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT) ENGINE=RocksDB;
+CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT) ENGINE=RocksDB;
+CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW DELETE FROM t2 WHERE pk = old.pk;
+INSERT INTO t1 VALUES (1,1);
+REPLACE INTO t1 VALUES (1,2);
+SELECT * FROM t1;
+pk f1
+1 2
+DROP TABLE t1, t2;
+#
+# Issue #99: UPDATE for table with VARCHAR pk gives "Can't find record" error
+#
+create table t1(a int primary key);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2 (
+a varchar(32) primary key,
+col1 int
+) engine=rocksdb;
+insert into t2
+select concat('v-', 100 + A.a*100 + B.a), 12345 from t1 A, t1 B;
+update t2 set a=concat('x-', a) where a between 'v-1002' and 'v-1004';
+drop table t1,t2;
+#
+# Issue #131: Assertion `v->cfd_->internal_comparator().Compare(start, end) <= 0' failed
+#
+CREATE TABLE t2(c1 INTEGER UNSIGNED NOT NULL, c2 INTEGER NULL, c3 TINYINT, c4 SMALLINT , c5 MEDIUMINT, c6 INT, c7 BIGINT, PRIMARY KEY(c1,c6)) ENGINE=RocksDB;
+INSERT INTO t2 VALUES (1,1,1,1,1,1,1);
+SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6;
+c1 c2 c3 c4 c5 c6 c7
+EXPLAIN SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 50 Using where
+drop table t2;
+#
+# Issue #135: register transaction was not being called for statement
+#
+DROP DATABASE IF EXISTS test_db;
+CREATE DATABASE test_db;
+CREATE TABLE test_db.t1(c1 INT PRIMARY KEY);
+LOCK TABLES test_db.t1 READ;
+SET AUTOCOMMIT=0;
+SELECT c1 FROM test_db.t1;
+c1
+START TRANSACTION WITH CONSISTENT SNAPSHOT, READ ONLY;
+DROP DATABASE test_db;
+#
+# Issue #143: Split rocksdb_bulk_load option into two
+#
+CREATE TABLE t1 (id int primary key, value int) engine=RocksDB;
+SET unique_checks=0;
+INSERT INTO t1 VALUES(1, 1);
+INSERT INTO t1 VALUES(1, 2);
+INSERT INTO t1 VALUES(1, 3);
+SELECT * FROM t1;
+id value
+1 3
+REPLACE INTO t1 VALUES(4, 4);
+ERROR HY000: When unique checking is disabled in MyRocks, INSERT,UPDATE,LOAD statements with clauses that update or replace the key (i.e. INSERT ON DUPLICATE KEY UPDATE, REPLACE) are not allowed. Query: REPLACE INTO t1 VALUES(4, 4)
+INSERT INTO t1 VALUES(5, 5) ON DUPLICATE KEY UPDATE value=value+1;
+ERROR HY000: When unique checking is disabled in MyRocks, INSERT,UPDATE,LOAD statements with clauses that update or replace the key (i.e. INSERT ON DUPLICATE KEY UPDATE, REPLACE) are not allowed. Query: INSERT INTO t1 VALUES(5, 5) ON DUPLICATE KEY UPDATE value=value+1
+TRUNCATE TABLE t1;
+SET @save_rocksdb_bulk_load_size= @@rocksdb_bulk_load_size;
+SET unique_checks=1;
+SET rocksdb_commit_in_the_middle=1;
+SET rocksdb_bulk_load_size=10;
+BEGIN;
+INSERT INTO t1 (id) VALUES(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
+(11),(12),(13),(14),(15),(16),(17),(18),(19);
+ROLLBACK;
+SELECT * FROM t1;
+id value
+1 NULL
+2 NULL
+3 NULL
+4 NULL
+5 NULL
+6 NULL
+7 NULL
+8 NULL
+9 NULL
+10 NULL
+INSERT INTO t1 (id) VALUES (11),(12),(13),(14),(15);
+BEGIN;
+UPDATE t1 SET value=100;
+ROLLBACK;
+SELECT * FROM t1;
+id value
+1 100
+2 100
+3 100
+4 100
+5 100
+6 100
+7 100
+8 100
+9 100
+10 100
+11 NULL
+12 NULL
+13 NULL
+14 NULL
+15 NULL
+BEGIN;
+DELETE FROM t1;
+ROLLBACK;
+SELECT * FROM t1;
+id value
+11 NULL
+12 NULL
+13 NULL
+14 NULL
+15 NULL
+SET rocksdb_commit_in_the_middle=0;
+SET rocksdb_bulk_load_size= @save_rocksdb_bulk_load_size;
+DROP TABLE t1;
+#
+# Issue #185 Assertion `BaseValid()' failed in void rocksdb::BaseDeltaIterator::Advance()
+#
+CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MEMORY;
+INSERT INTO t2 VALUES (100,NULL),(150,"long varchar"),(200,"varchar"),(250,"long long long varchar");
+Warnings:
+Warning 1366 Incorrect integer value: 'long varchar' for column `test`.`t2`.`data` at row 2
+Warning 1366 Incorrect integer value: 'varchar' for column `test`.`t2`.`data` at row 3
+Warning 1366 Incorrect integer value: 'long long long varchar' for column `test`.`t2`.`data` at row 4
+create TABLE t1 (a int not null, b int not null, primary key(a,b));
+INSERT INTO t1 VALUES (1,1);
+SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4));
+a
+1
+1
+1
+1
+DROP TABLE t1, t2;
+#
+# Issue #189 ha_rocksdb::load_auto_incr_value() creates implicit snapshot and doesn't release
+#
+create table r1 (id int auto_increment primary key, value int);
+insert into r1 (id) values (null), (null), (null), (null), (null);
+create table r2 like r1;
+show create table r2;
+Table Create Table
+r2 CREATE TABLE `r2` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `value` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+begin;
+insert into r1 values (10, 1);
+commit;
+begin;
+select * from r1;
+id value
+1 NULL
+2 NULL
+3 NULL
+4 NULL
+5 NULL
+10 1
+commit;
+drop table r1, r2;
+create table r1 (id int auto_increment, value int, index i(id));
+insert into r1 (id) values (null), (null), (null), (null), (null);
+create table r2 like r1;
+show create table r2;
+Table Create Table
+r2 CREATE TABLE `r2` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `value` int(11) DEFAULT NULL,
+ KEY `i` (`id`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+begin;
+insert into r1 values (10, 1);
+commit;
+begin;
+select * from r1;
+id value
+1 NULL
+2 NULL
+3 NULL
+4 NULL
+5 NULL
+10 1
+commit;
+drop table r1, r2;
+#
+# Issue#211 Crash on LOCK TABLES + START TRANSACTION WITH CONSISTENT SNAPSHOT
+#
+CREATE TABLE t1(c1 INT);
+lock TABLE t1 read local;
+SELECT 1 FROM t1 GROUP BY TRIM(LEADING RAND()FROM'');
+1
+set AUTOCOMMIT=0;
+start transaction with consistent snapshot;
+SELECT * FROM t1;
+c1
+COMMIT;
+UNLOCK TABLES;
+DROP TABLE t1;
+#
+# Issue#213 Crash on LOCK TABLES + partitions
+#
+CREATE TABLE t1(a INT,b INT,KEY (b)) engine=rocksdb PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1(a)VALUES (20010101101010.999949);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+lock tables t1 write,t1 as t0 write,t1 as t2 write;
+SELECT a FROM t1 ORDER BY a;
+a
+2147483647
+truncate t1;
+INSERT INTO t1 VALUES(X'042000200020',X'042000200020'),(X'200400200020',X'200400200020');
+Warnings:
+Warning 1366 Incorrect integer value: '\x04 \x00 \x00 ' for column `test`.`t1`.`a` at row 1
+Warning 1366 Incorrect integer value: '\x04 \x00 \x00 ' for column `test`.`t1`.`b` at row 1
+Warning 1366 Incorrect integer value: ' \x04\x00 \x00 ' for column `test`.`t1`.`a` at row 2
+Warning 1366 Incorrect integer value: ' \x04\x00 \x00 ' for column `test`.`t1`.`b` at row 2
+UNLOCK TABLES;
+DROP TABLE t1;
+#
+# Issue#250: MyRocks/Innodb different output from query with order by on table with index and decimal type
+# (the test was changed to use VARCHAR, because DECIMAL now supports index-only, and this issue
+# needs a datype that doesn't support index-inly)
+#
+CREATE TABLE t1(
+c1 varchar(10) character set utf8 collate utf8_general_ci NOT NULL,
+c2 varchar(10) character set utf8 collate utf8_general_ci,
+c3 INT,
+INDEX idx(c1,c2)
+);
+INSERT INTO t1 VALUES ('c1-val1','c2-val1',5);
+INSERT INTO t1 VALUES ('c1-val2','c2-val3',6);
+INSERT INTO t1 VALUES ('c1-val3','c2-val3',7);
+SELECT * FROM t1 force index(idx) WHERE c1 <> 'c1-val2' ORDER BY c1 DESC;
+c1 c2 c3
+c1-val3 c2-val3 7
+c1-val1 c2-val1 5
+explain SELECT * FROM t1 force index(idx) WHERE c1 <> '1' ORDER BY c1 DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx idx 32 NULL # Using where
+drop table t1;
+#
+# Issue#267: MyRocks issue with no matching min/max row and count(*)
+#
+CREATE TABLE t1(c1 INT UNSIGNED, c2 INT SIGNED, INDEX idx2(c2));
+INSERT INTO t1 VALUES(1,null);
+INSERT INTO t1 VALUES(2,null);
+SELECT count(*) as total_rows, min(c2) as min_value FROM t1;
+total_rows min_value
+2 NULL
+DROP TABLE t1;
+#
+# Issue#263: MyRocks auto_increment skips values if you insert a negative value
+#
+CREATE TABLE t1(a INT AUTO_INCREMENT KEY);
+INSERT INTO t1 VALUES(0),(-1),(0);
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 3 # # NULL latin1_swedish_ci NULL 0 N
+SELECT * FROM t1;
+a
+-1
+1
+2
+DROP TABLE t1;
+CREATE TABLE t1(a INT AUTO_INCREMENT KEY);
+INSERT INTO t1 VALUES(0),(10),(0);
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 12 # # NULL latin1_swedish_ci NULL 0 N
+SELECT * FROM t1;
+a
+1
+10
+11
+DROP TABLE t1;
+#
+# Issue #411: Setting rocksdb_commit_in_the_middle commits transaction
+# without releasing iterator
+#
+CREATE TABLE t1 (id1 bigint(20),
+id2 bigint(20),
+id3 bigint(20),
+PRIMARY KEY (id1, id2, id3))
+DEFAULT CHARSET=latin1;
+CREATE TABLE t2 (id1 bigint(20),
+id2 bigint(20),
+PRIMARY KEY (id1, id2))
+DEFAULT CHARSET=latin1;
+set rocksdb_commit_in_the_middle=1;
+SET @save_rocksdb_bulk_load_size= @@rocksdb_bulk_load_size;
+set rocksdb_bulk_load_size = 100;
+DELETE t2, t1 FROM t2 LEFT JOIN t1 ON t2.id2 = t1.id2 AND t2.id1 = t1.id1 WHERE t2.id1 = 0;
+SET rocksdb_bulk_load_size= @save_rocksdb_bulk_load_size;
+SET rocksdb_commit_in_the_middle=0;
+DROP TABLE t1, t2;
+#
+# MDEV-21831: Assertion `length == pack_length()' failed in Field_inet6::sort_string upon
+# INSERT into RocksDB table
+#
+CREATE TABLE t1 (a INET6 NOT NULL, KEY (a)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES ('41::1'),('61::1');
+DROP TABLE t1;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_cf_options.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_cf_options.result
new file mode 100644
index 00000000..80b6301a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_cf_options.result
@@ -0,0 +1,64 @@
+create table t1 (a int,
+primary key (a) comment 'cf1') engine=rocksdb;
+create table t2 (a int,
+primary key (a) comment 'cf2') engine=rocksdb;
+create table t3 (a int,
+primary key (a) comment 'z') engine=rocksdb;
+insert into t1 values (1);
+insert into t2 values (2);
+insert into t3 values (2);
+# restart
+
+Default options for all column families:
+
+select cf_name, option_type, value
+from information_schema.rocksdb_cf_options
+where option_type in ('WRITE_BUFFER_SIZE',
+'TARGET_FILE_SIZE_BASE',
+'MAX_BYTES_FOR_LEVEL_MULTIPLIER')
+order by cf_name, option_type;
+cf_name option_type value
+cf1 MAX_BYTES_FOR_LEVEL_MULTIPLIER 10.000000
+cf1 TARGET_FILE_SIZE_BASE 1048576
+cf1 WRITE_BUFFER_SIZE 12582912
+cf2 MAX_BYTES_FOR_LEVEL_MULTIPLIER 10.000000
+cf2 TARGET_FILE_SIZE_BASE 1048576
+cf2 WRITE_BUFFER_SIZE 12582912
+default MAX_BYTES_FOR_LEVEL_MULTIPLIER 10.000000
+default TARGET_FILE_SIZE_BASE 1048576
+default WRITE_BUFFER_SIZE 12582912
+z MAX_BYTES_FOR_LEVEL_MULTIPLIER 10.000000
+z TARGET_FILE_SIZE_BASE 1048576
+z WRITE_BUFFER_SIZE 12582912
+__system__ MAX_BYTES_FOR_LEVEL_MULTIPLIER 10.000000
+__system__ TARGET_FILE_SIZE_BASE 1048576
+__system__ WRITE_BUFFER_SIZE 12582912
+# restart: --rocksdb_override_cf_options=cf1={write_buffer_size=8m;target_file_size_base=2m};cf2={write_buffer_size=16m;max_bytes_for_level_multiplier=8};z={target_file_size_base=4m};
+
+Individualized options for column families:
+
+select cf_name, option_type, value
+from information_schema.rocksdb_cf_options
+where option_type in ('WRITE_BUFFER_SIZE',
+'TARGET_FILE_SIZE_BASE',
+'MAX_BYTES_FOR_LEVEL_MULTIPLIER')
+order by cf_name, option_type;
+cf_name option_type value
+cf1 MAX_BYTES_FOR_LEVEL_MULTIPLIER 10.000000
+cf1 TARGET_FILE_SIZE_BASE 2097152
+cf1 WRITE_BUFFER_SIZE 8388608
+cf2 MAX_BYTES_FOR_LEVEL_MULTIPLIER 8.000000
+cf2 TARGET_FILE_SIZE_BASE 1048576
+cf2 WRITE_BUFFER_SIZE 16777216
+default MAX_BYTES_FOR_LEVEL_MULTIPLIER 10.000000
+default TARGET_FILE_SIZE_BASE 1048576
+default WRITE_BUFFER_SIZE 12582912
+z MAX_BYTES_FOR_LEVEL_MULTIPLIER 10.000000
+z TARGET_FILE_SIZE_BASE 4194304
+z WRITE_BUFFER_SIZE 12582912
+__system__ MAX_BYTES_FOR_LEVEL_MULTIPLIER 10.000000
+__system__ TARGET_FILE_SIZE_BASE 1048576
+__system__ WRITE_BUFFER_SIZE 12582912
+# restart: --rocksdb_override_cf_options=cf1={write_buffer_size=8m;target_file_size_base=2m};cf2={write_buffer_size=16m;max_bytes_for_level_multiplier=8};z={target_file_size_base=4m};
+
+drop table t1,t2,t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_cf_per_partition.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_cf_per_partition.result
new file mode 100644
index 00000000..32bb70a7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_cf_per_partition.result
@@ -0,0 +1,425 @@
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+name VARCHAR(25) NOT NULL,
+event DATE,
+PRIMARY KEY (`c1`, `c2`) COMMENT 'testcomment'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 4, 7),
+PARTITION custom_p1 VALUES IN (2, 5, 8),
+PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='testcomment';
+cf_name
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+name VARCHAR(25) NOT NULL,
+event DATE,
+PRIMARY KEY (`c1`, `c2`) COMMENT 'rev:testrevcomment'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 4, 7),
+PARTITION custom_p1 VALUES IN (2, 5, 8),
+PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='rev:testrevcomment';
+cf_name
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+name VARCHAR(25) NOT NULL,
+event DATE,
+PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=my_custom_cf;custom_p2_cfname=baz'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 4, 7),
+PARTITION custom_p1 VALUES IN (2, 5, 8),
+PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'my_custom_cf';
+set @@global.rocksdb_compact_cf = 'baz';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='foo';
+cf_name
+foo
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='my_custom_cf';
+cf_name
+my_custom_cf
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='baz';
+cf_name
+baz
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+name VARCHAR(25) NOT NULL,
+event DATE,
+PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=t1-p0;custom_p1_cfname=rev:bar;custom_p2_cfname=t1-p2'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 4, 7),
+PARTITION custom_p1 VALUES IN (2, 5, 8),
+PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+set @@global.rocksdb_compact_cf = 't1-p0';
+set @@global.rocksdb_compact_cf = 'rev:bar';
+set @@global.rocksdb_compact_cf = 't1-p2';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='t1-p0';
+cf_name
+t1-p0
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='rev:bar';
+cf_name
+rev:bar
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='t1-p2';
+cf_name
+t1-p2
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+name VARCHAR(25) NOT NULL,
+event DATE,
+PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=cf-zero;custom_p1_cfname=cf-one;custom_p2_cfname=cf-zero'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 4, 7),
+PARTITION custom_p1 VALUES IN (2, 5, 8),
+PARTITION custom_p2 VALUES IN (3, 6, 9),
+PARTITION custom_p3 VALUES IN (10, 20, 30)
+);
+set @@global.rocksdb_compact_cf = 'cf-zero';
+set @@global.rocksdb_compact_cf = 'cf-one';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='cf-zero';
+cf_name
+cf-zero
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='cf-one';
+cf_name
+cf-one
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+name VARCHAR(25) NOT NULL,
+event DATE,
+PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 4, 7),
+PARTITION custom_p1 VALUES IN (2, 5, 8),
+PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+INSERT INTO t1 VALUES (1, 1, "one", null);
+INSERT INTO t1 VALUES (2, 2, "two", null);
+INSERT INTO t1 VALUES (3, 3, "three", null);
+INSERT INTO t1 VALUES (5, 5, "five", null);
+INSERT INTO t1 VALUES (9, 9, "nine", null);
+SELECT * FROM t1;
+c1 c2 name event
+1 1 one NULL
+2 2 two NULL
+5 5 five NULL
+3 3 three NULL
+9 9 nine NULL
+ALTER TABLE t1 DROP PRIMARY KEY;
+SELECT * FROM t1;
+c1 c2 name event
+1 1 one NULL
+2 2 two NULL
+5 5 five NULL
+3 3 three NULL
+9 9 nine NULL
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'bar';
+set @@global.rocksdb_compact_cf = 'baz';
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+name VARCHAR(25) NOT NULL,
+event DATE,
+PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 4, 7),
+PARTITION custom_p1 VALUES IN (2, 5, 8),
+PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+INSERT INTO t1 VALUES (1, 1, "one", null);
+INSERT INTO t1 VALUES (2, 2, "two", null);
+INSERT INTO t1 VALUES (3, 3, "three", null);
+INSERT INTO t1 VALUES (5, 5, "five", null);
+INSERT INTO t1 VALUES (9, 9, "nine", null);
+ALTER TABLE t1 DROP PRIMARY KEY;
+ALTER TABLE t1 ADD PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=p0_cf;custom_p1_cfname=p1_cf';
+set @@global.rocksdb_compact_cf = 'p0_cf';
+set @@global.rocksdb_compact_cf = 'p1_cf';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='p0_cf';
+cf_name
+p0_cf
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='p1_cf';
+cf_name
+p1_cf
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+name VARCHAR(25) NOT NULL,
+event DATE,
+PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 4, 7),
+PARTITION custom_p1 VALUES IN (2, 5, 8),
+PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+INSERT INTO t1 VALUES (1, 1, "one", null);
+INSERT INTO t1 VALUES (2, 2, "two", null);
+INSERT INTO t1 VALUES (3, 3, "three", null);
+INSERT INTO t1 VALUES (5, 5, "five", null);
+INSERT INTO t1 VALUES (9, 9, "nine", null);
+ALTER TABLE t1 PARTITION BY LIST(c1) (
+PARTITION custom_p3 VALUES IN (1, 4, 7),
+PARTITION custom_p4 VALUES IN (2, 5, 8, 3, 6, 9)
+);
+ALTER TABLE t1 DROP PRIMARY KEY;
+ALTER TABLE t1 ADD PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p3_cfname=p3_cf;custom_p4_cfname=p4_cf';
+set @@global.rocksdb_compact_cf = 'p3_cf';
+set @@global.rocksdb_compact_cf = 'p4_cf';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='p3_cf';
+cf_name
+p3_cf
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='p4_cf';
+cf_name
+p4_cf
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+name VARCHAR(25) NOT NULL,
+event DATE,
+PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=;'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 4, 7),
+PARTITION custom_p1 VALUES IN (2, 5, 8),
+PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+DROP TABLE t1;
+CREATE TABLE `t2` (
+`col1` bigint(20) NOT NULL,
+`col2` varbinary(64) NOT NULL,
+`col3` varbinary(256) NOT NULL,
+`col4` bigint(20) NOT NULL,
+`col5` mediumblob NOT NULL,
+PRIMARY KEY (`col1`,`col2`,`col3`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+PARTITION BY LIST COLUMNS (`col2`) (
+PARTITION custom_p0 VALUES IN (0x12345),
+PARTITION custom_p1 VALUES IN (0x23456),
+PARTITION custom_p2 VALUES IN (0x34567),
+PARTITION custom_p3 VALUES IN (0x45678),
+PARTITION custom_p4 VALUES IN (0x56789),
+PARTITION custom_p5 VALUES IN (0x6789A),
+PARTITION custom_p6 VALUES IN (0x789AB),
+PARTITION custom_p7 VALUES IN (0x89ABC)
+);
+DROP TABLE t2;
+CREATE TABLE `t2` (
+`col1` bigint(20) NOT NULL,
+`col2` varbinary(64) NOT NULL,
+`col3` varbinary(256) NOT NULL,
+`col4` bigint(20) NOT NULL,
+`col5` mediumblob NOT NULL,
+PRIMARY KEY (`col1`,`col2`,`col3`) COMMENT 'custom_p0_cfname=my_cf0;custom_p1_cfname=my_cf1'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+PARTITION BY LIST COLUMNS (`col2`) (
+PARTITION custom_p0 VALUES IN (0x12345),
+PARTITION custom_p1 VALUES IN (0x23456),
+PARTITION custom_p2 VALUES IN (0x34567),
+PARTITION custom_p3 VALUES IN (0x45678),
+PARTITION custom_p4 VALUES IN (0x56789),
+PARTITION custom_p5 VALUES IN (0x6789A),
+PARTITION custom_p6 VALUES IN (0x789AB),
+PARTITION custom_p7 VALUES IN (0x89ABC)
+);
+set @@global.rocksdb_compact_cf = 'my_cf0';
+set @@global.rocksdb_compact_cf = 'my_cf1';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='my_cf0';
+cf_name
+my_cf0
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='my_cf1';
+cf_name
+my_cf1
+INSERT INTO t2 VALUES (100, 0x12345, 0x1, 1, 0x2);
+INSERT INTO t2 VALUES (200, 0x12345, 0x1, 1, 0x2);
+INSERT INTO t2 VALUES (300, 0x12345, 0x1, 1, 0x2);
+INSERT INTO t2 VALUES (100, 0x23456, 0x2, 1, 0x3);
+INSERT INTO t2 VALUES (100, 0x34567, 0x4, 1, 0x5);
+INSERT INTO t2 VALUES (400, 0x89ABC, 0x4, 1, 0x5);
+SELECT col1, HEX(col2), HEX(col3), col4, HEX(col5) FROM t2;
+col1 HEX(col2) HEX(col3) col4 HEX(col5)
+100 012345 01 1 02
+200 012345 01 1 02
+300 012345 01 1 02
+100 023456 02 1 03
+100 034567 04 1 05
+400 089ABC 04 1 05
+EXPLAIN PARTITIONS SELECT HEX(col2) FROM t2 where col2 = 0x12345;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 custom_p0 index NULL PRIMARY 332 NULL 3 Using where; Using index
+EXPLAIN PARTITIONS SELECT HEX(col2) FROM t2 where col2 = 0x23456;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 custom_p1 index NULL PRIMARY 332 NULL 2 Using where; Using index
+ALTER TABLE t2 DROP PRIMARY KEY;
+ALTER TABLE t2 ADD PRIMARY KEY (`col1`,`col2`,`col3`) COMMENT 'custom_p0_cfname=new_cf0;custom_p1_cfname=new_cf1';
+set @@global.rocksdb_compact_cf = 'new_cf0';
+set @@global.rocksdb_compact_cf = 'new_cf1';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='new_cf0';
+cf_name
+new_cf0
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='new_cf1';
+cf_name
+new_cf1
+INSERT INTO t2 VALUES (500, 0x12345, 0x5, 1, 0x2);
+INSERT INTO t2 VALUES (700, 0x23456, 0x7, 1, 0x3);
+EXPLAIN PARTITIONS SELECT HEX(col2) FROM t2 where col2 = 0x12345;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 custom_p0 index NULL PRIMARY 332 NULL 4 Using where; Using index
+EXPLAIN PARTITIONS SELECT HEX(col2) FROM t2 where col2 = 0x23456;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 custom_p1 index NULL PRIMARY 332 NULL 2 Using where; Using index
+SELECT col1, HEX(col2), HEX(col3), col4, HEX(col5) FROM t2;
+col1 HEX(col2) HEX(col3) col4 HEX(col5)
+100 012345 01 1 02
+200 012345 01 1 02
+300 012345 01 1 02
+500 012345 05 1 02
+100 023456 02 1 03
+700 023456 07 1 03
+100 034567 04 1 05
+400 089ABC 04 1 05
+DROP TABLE t2;
+CREATE TABLE `t2` (
+`col1` bigint(20) NOT NULL,
+`col2` varbinary(64) NOT NULL,
+`col3` varbinary(256) NOT NULL,
+`col4` bigint(20) NOT NULL,
+`col5` mediumblob NOT NULL,
+PRIMARY KEY (`col1`,`col2`,`col3`) COMMENT 'custom_p0_cfname=test_cf0;custom_p1_cfname=test_cf1',
+KEY (`col2`, `col4`) COMMENT 'custom_p5_cfname=test_cf5'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+PARTITION BY LIST COLUMNS (`col2`) (
+PARTITION custom_p0 VALUES IN (0x12345),
+PARTITION custom_p1 VALUES IN (0x23456),
+PARTITION custom_p2 VALUES IN (0x34567),
+PARTITION custom_p3 VALUES IN (0x45678),
+PARTITION custom_p4 VALUES IN (0x56789),
+PARTITION custom_p5 VALUES IN (0x6789A),
+PARTITION custom_p6 VALUES IN (0x789AB),
+PARTITION custom_p7 VALUES IN (0x89ABC)
+);
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='test_cf0';
+cf_name
+test_cf0
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='test_cf1';
+cf_name
+test_cf1
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='test_cf5';
+cf_name
+test_cf5
+INSERT INTO t2 VALUES (100, 0x12345, 0x1, 1, 0x2);
+INSERT INTO t2 VALUES (200, 0x12345, 0x1, 1, 0x2);
+INSERT INTO t2 VALUES (300, 0x12345, 0x1, 1, 0x2);
+INSERT INTO t2 VALUES (100, 0x23456, 0x2, 1, 0x3);
+INSERT INTO t2 VALUES (100, 0x34567, 0x4, 1, 0x5);
+INSERT INTO t2 VALUES (400, 0x89ABC, 0x4, 1, 0x5);
+INSERT INTO t2 VALUES (500, 0x6789A, 0x5, 1, 0x7);
+EXPLAIN PARTITIONS SELECT * FROM t2 WHERE col2 = 0x6789A AND col4 = 1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 custom_p5 ref col2 col2 74 const,const 1 Using where
+ALTER TABLE t2 DROP KEY `col2`;
+ALTER TABLE t2 ADD KEY (`col3`, `col4`) COMMENT 'custom_p5_cfname=another_cf_for_p5';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='another_cf_for_p5';
+cf_name
+another_cf_for_p5
+ANALYZE TABLE t2;
+Table Op Msg_type Msg_text
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze Warning Engine-independent statistics are not collected for column 'col5'
+test.t2 analyze status OK
+EXPLAIN PARTITIONS SELECT * FROM t2 WHERE col3 = 0x4 AND col2 = 0x34567;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 custom_p2 ref col3 col3 258 const # Using where
+DROP TABLE t2;
+CREATE TABLE `t2` (
+`col1` bigint(20) NOT NULL,
+`col2` varbinary(64) NOT NULL,
+`col3` varbinary(256) NOT NULL,
+`col4` bigint(20) NOT NULL,
+`col5` mediumblob NOT NULL,
+PRIMARY KEY (`col1`,`col2`,`col3`) COMMENT 'custom_p0_cfname=test_cf0;custom_p1_cfname=test_cf1',
+UNIQUE KEY (`col2`, `col4`) COMMENT 'custom_p5_cfname=unique_test_cf5'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+PARTITION BY LIST COLUMNS (`col2`) (
+PARTITION custom_p0 VALUES IN (0x12345),
+PARTITION custom_p1 VALUES IN (0x23456),
+PARTITION custom_p2 VALUES IN (0x34567),
+PARTITION custom_p3 VALUES IN (0x45678),
+PARTITION custom_p4 VALUES IN (0x56789),
+PARTITION custom_p5 VALUES IN (0x6789A),
+PARTITION custom_p6 VALUES IN (0x789AB),
+PARTITION custom_p7 VALUES IN (0x89ABC)
+);
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='unique_test_cf5';
+cf_name
+unique_test_cf5
+INSERT INTO t2 VALUES (100, 0x12345, 0x1, 1, 0x2);
+INSERT INTO t2 VALUES (200, 0x12345, 0x1, 1, 0x2);
+ERROR 23000: Duplicate entry '\x01#E-1' for key 'col2'
+INSERT INTO t2 VALUES (300, 0x12345, 0x1, 1, 0x2);
+ERROR 23000: Duplicate entry '\x01#E-1' for key 'col2'
+INSERT INTO t2 VALUES (100, 0x23456, 0x2, 1, 0x3);
+INSERT INTO t2 VALUES (100, 0x34567, 0x4, 1, 0x5);
+INSERT INTO t2 VALUES (400, 0x89ABC, 0x4, 1, 0x5);
+INSERT INTO t2 VALUES (500, 0x6789A, 0x5, 1, 0x7);
+DROP TABLE t2;
+CREATE TABLE t1 (
+`a` int,
+PRIMARY KEY (a) COMMENT "sharedcf"
+) ENGINE=ROCKSDB;
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='sharedcf';
+cf_name
+sharedcf
+CREATE TABLE t2 (
+`a` INT,
+`b` DATE,
+`c` VARCHAR(42),
+PRIMARY KEY (`a`) COMMENT "custom_p0_cfname=sharedcf;custom_p2_cfname=notsharedcf"
+) ENGINE=ROCKSDB
+PARTITION BY LIST(`a`) (
+PARTITION custom_p0 VALUES IN (1, 4, 7),
+PARTITION custom_p1 VALUES IN (2, 5, 8),
+PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='notsharedcf';
+cf_name
+notsharedcf
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1 (
+a INT NOT NULL,
+PRIMARY KEY (a) COMMENT 'p1_cfname=foo;'
+) ENGINE=ROCKSDB
+PARTITION BY LIST COLUMNS(a)
+(PARTITION p1 VALUES IN (1) ENGINE = ROCKSDB);
+INSERT INTO t1 values (1);
+TRUNCATE TABLE t1;
+SELECT * FROM t1;
+a
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_cf_reverse.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_cf_reverse.result
new file mode 100644
index 00000000..1c85343c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_cf_reverse.result
@@ -0,0 +1,120 @@
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (
+pk int primary key,
+a int not null,
+b int not null,
+key(a) comment 'rev:foo',
+key(b) comment 'bar'
+) engine=rocksdb;
+insert into t1 select a,a,a from t0;
+insert into t1 select a+10,a+10,a+10 from t0;
+# Primary key is not in a reverse-ordered CF, so full table scan
+# returns rows in ascending order:
+select * from t1;
+pk a b
+0 0 0
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+8 8 8
+9 9 9
+10 10 10
+11 11 11
+12 12 12
+13 13 13
+14 14 14
+15 15 15
+16 16 16
+17 17 17
+18 18 18
+19 19 19
+explain
+select a from t1 order by a limit 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 4 NULL # Using index
+select a from t1 order by a limit 5;
+a
+0
+1
+2
+3
+4
+explain
+select b from t1 order by b limit 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL b 4 NULL # Using index
+select a from t1 order by a limit 5;
+a
+0
+1
+2
+3
+4
+explain
+select a from t1 order by a desc limit 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 4 NULL # Using index
+select a from t1 order by a desc limit 5;
+a
+19
+18
+17
+16
+15
+explain
+select b from t1 order by b desc limit 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL b 4 NULL # Using index
+select b from t1 order by b desc limit 5;
+b
+19
+18
+17
+16
+15
+drop table t1;
+#
+# Try a primary key in a reverse-ordered CF.
+#
+create table t2 (
+pk int,
+a int not null,
+primary key(pk) comment 'rev:cf1'
+) engine=rocksdb;
+insert into t2 select a,a from t0;
+# Primary key is in a reverse-ordered CF, so full table scan
+# returns rows in descending order:
+select * from t2;
+pk a
+9 9
+8 8
+7 7
+6 6
+5 5
+4 4
+3 3
+2 2
+1 1
+0 0
+set autocommit=0;
+begin;
+delete from t2 where a=3 or a=7;
+select * from t2;
+pk a
+9 9
+8 8
+6 6
+5 5
+4 4
+2 2
+1 1
+0 0
+rollback;
+set autocommit=1;
+drop table t2;
+drop table t0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_checksums.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_checksums.result
new file mode 100644
index 00000000..e4b757ef
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_checksums.result
@@ -0,0 +1,129 @@
+set @save_rocksdb_store_row_debug_checksums=@@global.rocksdb_store_row_debug_checksums;
+set @save_rocksdb_verify_row_debug_checksums=@@global.rocksdb_verify_row_debug_checksums;
+set @save_rocksdb_checksums_pct=@@global.rocksdb_checksums_pct;
+show variables like 'rocksdb_%checksum%';
+Variable_name Value
+rocksdb_checksums_pct 100
+rocksdb_store_row_debug_checksums OFF
+rocksdb_verify_row_debug_checksums OFF
+create table t1 (pk int primary key, a int, b int, key(a), key(b)) engine=rocksdb;
+insert into t1 values (1,1,1),(2,2,2),(3,3,3);
+check table t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+CHECKTABLE t1: Checking table t1
+CHECKTABLE t1: Checking index a
+CHECKTABLE t1: ... 3 index entries checked (0 had checksums)
+CHECKTABLE t1: Checking index b
+CHECKTABLE t1: ... 3 index entries checked (0 had checksums)
+CHECKTABLE t1: 0 table records had checksums
+drop table t1;
+set session rocksdb_store_row_debug_checksums=on;
+create table t2 (pk int primary key, a int, b int, key(a), key(b)) engine=rocksdb;
+insert into t2 values (1,1,1),(2,2,2),(3,3,3);
+check table t2;
+Table Op Msg_type Msg_text
+test.t2 check status OK
+CHECKTABLE t2: Checking table t2
+CHECKTABLE t2: Checking index a
+CHECKTABLE t2: ... 3 index entries checked (3 had checksums)
+CHECKTABLE t2: Checking index b
+CHECKTABLE t2: ... 3 index entries checked (3 had checksums)
+CHECKTABLE t2: 3 table records had checksums
+# Now, make a table that has both rows with checksums and without
+create table t3 (pk int primary key, a int, b int, key(a), key(b)) engine=rocksdb;
+insert into t3 values (1,1,1),(2,2,2),(3,3,3);
+set session rocksdb_store_row_debug_checksums=off;
+update t3 set b=3 where a=2;
+set session rocksdb_store_row_debug_checksums=on;
+check table t3;
+Table Op Msg_type Msg_text
+test.t3 check status OK
+CHECKTABLE t3: Checking table t3
+CHECKTABLE t3: Checking index a
+CHECKTABLE t3: ... 3 index entries checked (3 had checksums)
+CHECKTABLE t3: Checking index b
+CHECKTABLE t3: ... 3 index entries checked (2 had checksums)
+CHECKTABLE t3: 2 table records had checksums
+set session rocksdb_store_row_debug_checksums=on;
+set session rocksdb_checksums_pct=5;
+create table t4 (pk int primary key, a int, b int, key(a), key(b)) engine=rocksdb;
+check table t4;
+Table Op Msg_type Msg_text
+test.t4 check status OK
+4000 index entries had around 200 checksums
+4000 index entries had around 200 checksums
+Around 200 table records had checksums
+set session rocksdb_checksums_pct=100;
+#
+# Ok, table t2 has all rows with checksums. Simulate a few checksum mismatches.
+#
+insert into mtr.test_suppressions values
+('Checksum mismatch in key of key-value pair for index'),
+('Checksum mismatch in value of key-value pair for index'),
+('Data with incorrect checksum');
+# 1. Start with mismatch in key checksum of the PK.
+set session debug_dbug= "+d,myrocks_simulate_bad_pk_checksum1";
+set session rocksdb_verify_row_debug_checksums=off;
+select * from t3;
+pk a b
+1 1 1
+2 2 3
+3 3 3
+set session rocksdb_verify_row_debug_checksums=on;
+select * from t3;
+ERROR HY000: Internal error: Record checksum mismatch
+select * from t4;
+ERROR HY000: Internal error: Record checksum mismatch
+set session debug_dbug= "-d,myrocks_simulate_bad_pk_checksum1";
+# 2. Continue with mismatch in pk value checksum.
+set session debug_dbug= "+d,myrocks_simulate_bad_pk_checksum2";
+set session rocksdb_verify_row_debug_checksums=off;
+select * from t3;
+pk a b
+1 1 1
+2 2 3
+3 3 3
+set session rocksdb_verify_row_debug_checksums=on;
+select * from t3;
+ERROR HY000: Internal error: Record checksum mismatch
+select * from t4;
+ERROR HY000: Internal error: Record checksum mismatch
+set session debug_dbug= "-d,myrocks_simulate_bad_pk_checksum2";
+# 3. Check if we catch checksum mismatches for secondary indexes
+explain
+select * from t3 force index(a) where a<4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 range a a 5 NULL # Using index condition
+select * from t3 force index(a) where a<4;
+pk a b
+1 1 1
+2 2 3
+3 3 3
+set session debug_dbug= "+d,myrocks_simulate_bad_key_checksum1";
+select * from t3 force index(a) where a<4;
+ERROR HY000: Internal error: Record checksum mismatch
+select * from t4 force index(a) where a<1000000;
+ERROR HY000: Internal error: Record checksum mismatch
+set session debug_dbug= "-d,myrocks_simulate_bad_key_checksum1";
+# 4. The same for index-only reads?
+explain
+select a from t3 force index(a) where a<4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 range a a 5 NULL # Using where; Using index
+select a from t3 force index(a) where a<4;
+a
+1
+2
+3
+set session debug_dbug= "+d,myrocks_simulate_bad_key_checksum1";
+select a from t3 force index(a) where a<4;
+ERROR HY000: Internal error: Record checksum mismatch
+select a from t4 force index(a) where a<1000000;
+ERROR HY000: Internal error: Record checksum mismatch
+set session debug_dbug= "-d,myrocks_simulate_bad_key_checksum1";
+set @@global.rocksdb_store_row_debug_checksums=@save_rocksdb_store_row_debug_checksums;
+set @@global.rocksdb_verify_row_debug_checksums=@save_rocksdb_verify_row_debug_checksums;
+set @@global.rocksdb_checksums_pct=@save_rocksdb_checksums_pct;
+# restart
+drop table t2,t3,t4;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_concurrent_delete.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_concurrent_delete.result
new file mode 100644
index 00000000..9106e79f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_concurrent_delete.result
@@ -0,0 +1,671 @@
+connect con, localhost, root,,;
+connection default;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+SET debug_sync='RESET';
+CREATE TABLE t1 (pk INT PRIMARY KEY COMMENT "", a INT);
+INSERT INTO t1 VALUES(1,1), (2,2), (3,3), (4,4), (5,5);
+--PK first row delete
+connection con;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk ASC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 1;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+2 2
+3 3
+4 4
+5 5
+--PK middle row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk ASC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 3;
+SET debug_sync='now SIGNAL go';
+connection con;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+--PK end row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk ASC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 5;
+SET debug_sync='now SIGNAL go';
+connection con;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+connect con, localhost, root,,;
+connection default;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+SET debug_sync='RESET';
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT, index a(a));
+INSERT INTO t1 VALUES(1,1), (2,2), (3,3), (4,4), (5,5);
+--SK first row delete
+connection con;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+SET debug_sync='rocksdb_concurrent_delete_sk SIGNAL parked WAIT_FOR go';
+SELECT a FROM t1 FORCE INDEX(a) FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 1;
+SET debug_sync='now SIGNAL go';
+connection con;
+a
+2
+3
+4
+5
+--SK middle row delete
+SET debug_sync='rocksdb_concurrent_delete_sk SIGNAL parked WAIT_FOR go';
+SELECT a FROM t1 FORCE INDEX(a) FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 3;
+SET debug_sync='now SIGNAL go';
+connection con;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+--SK end row delete
+SET debug_sync='rocksdb_concurrent_delete_sk SIGNAL parked WAIT_FOR go';
+SELECT a FROM t1 FORCE INDEX(a) FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 5;
+SET debug_sync='now SIGNAL go';
+connection con;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+connect con, localhost, root,,;
+connection default;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+SET debug_sync='RESET';
+CREATE TABLE t1 (pk INT PRIMARY KEY COMMENT "", a INT);
+INSERT INTO t1 VALUES(1,1), (2,2), (3,3), (4,4), (5,5);
+--PK first row delete
+connection con;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk DESC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 5;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+4 4
+3 3
+2 2
+1 1
+--PK middle row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk DESC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 3;
+SET debug_sync='now SIGNAL go';
+connection con;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+--PK end row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk DESC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 1;
+SET debug_sync='now SIGNAL go';
+connection con;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+connect con, localhost, root,,;
+connection default;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+SET debug_sync='RESET';
+CREATE TABLE t1 (pk INT PRIMARY KEY COMMENT "rev:cf2", a INT);
+INSERT INTO t1 VALUES(1,1), (2,2), (3,3), (4,4), (5,5);
+--PK first row delete
+connection con;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk ASC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 1;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+2 2
+3 3
+4 4
+5 5
+--PK middle row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk ASC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 3;
+SET debug_sync='now SIGNAL go';
+connection con;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+--PK end row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk ASC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 5;
+SET debug_sync='now SIGNAL go';
+connection con;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+connect con, localhost, root,,;
+connection default;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+SET debug_sync='RESET';
+CREATE TABLE t1 (pk INT PRIMARY KEY COMMENT "rev:cf2", a INT);
+INSERT INTO t1 VALUES(1,1), (2,2), (3,3), (4,4), (5,5);
+--PK first row delete
+connection con;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk DESC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 5;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+4 4
+3 3
+2 2
+1 1
+--PK middle row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk DESC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 3;
+SET debug_sync='now SIGNAL go';
+connection con;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+--PK end row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk DESC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 1;
+SET debug_sync='now SIGNAL go';
+connection con;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+connect con, localhost, root,,;
+connection default;
+set debug_sync='RESET';
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+create table t1 (id1 int, id2 int, value int, primary key (id1, id2), index sk (id1, value)) engine=rocksdb;
+insert into t1 values (1, 1, 1),(1, 2, 1),(1, 3, 1),(1, 4, 1),(1, 5, 1),(2, 2, 2);
+--First row delete with PRIMARY
+connection con;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
+update t1 force index (PRIMARY) set value=100 where id1=1;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+delete from t1 where id1=1 and id2=1;
+set debug_sync='now SIGNAL go';
+connection con;
+select * from t1 where id1=1;
+id1 id2 value
+1 2 100
+1 3 100
+1 4 100
+1 5 100
+--Middle row delete with PRIMARY
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
+update t1 force index (PRIMARY) set value=200 where id1=1;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+delete from t1 where id1=1 and id2=3;
+set debug_sync='now SIGNAL go';
+connection con;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+select * from t1 where id1=1;
+id1 id2 value
+1 2 100
+1 4 100
+1 5 100
+--End row delete with PRIMARY
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
+update t1 force index (PRIMARY) set value=300 where id1=1;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+delete from t1 where id1=1 and id2=5;
+set debug_sync='now SIGNAL go';
+connection con;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+select * from t1 where id1=1;
+id1 id2 value
+1 2 100
+1 4 100
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+connect con, localhost, root,,;
+connection default;
+set debug_sync='RESET';
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+create table t1 (id1 int, id2 int, value int, primary key (id1, id2), index sk (id1, value)) engine=rocksdb;
+insert into t1 values (1, 1, 1),(1, 2, 1),(1, 3, 1),(1, 4, 1),(1, 5, 1),(2, 2, 2);
+--First row delete with sk
+connection con;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
+update t1 force index (sk) set value=100 where id1=1;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+delete from t1 where id1=1 and id2=1;
+set debug_sync='now SIGNAL go';
+connection con;
+select * from t1 where id1=1;
+id1 id2 value
+1 2 100
+1 3 100
+1 4 100
+1 5 100
+--Middle row delete with sk
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
+update t1 force index (sk) set value=200 where id1=1;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+delete from t1 where id1=1 and id2=3;
+set debug_sync='now SIGNAL go';
+connection con;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+select * from t1 where id1=1;
+id1 id2 value
+1 2 100
+1 4 100
+1 5 100
+--End row delete with sk
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
+update t1 force index (sk) set value=300 where id1=1;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+delete from t1 where id1=1 and id2=5;
+set debug_sync='now SIGNAL go';
+connection con;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+select * from t1 where id1=1;
+id1 id2 value
+1 2 100
+1 4 100
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+connect con, localhost, root,,;
+connection default;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SET debug_sync='RESET';
+CREATE TABLE t1 (pk INT PRIMARY KEY COMMENT "", a INT);
+INSERT INTO t1 VALUES(1,1), (2,2), (3,3), (4,4), (5,5);
+--PK first row delete
+connection con;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk ASC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 1;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+2 2
+3 3
+4 4
+5 5
+--PK middle row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk ASC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 3;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+2 2
+4 4
+5 5
+--PK end row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk ASC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 5;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+2 2
+4 4
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+connect con, localhost, root,,;
+connection default;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SET debug_sync='RESET';
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT, index a(a));
+INSERT INTO t1 VALUES(1,1), (2,2), (3,3), (4,4), (5,5);
+--SK first row delete
+connection con;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SET debug_sync='rocksdb_concurrent_delete_sk SIGNAL parked WAIT_FOR go';
+SELECT a FROM t1 FORCE INDEX(a) FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 1;
+SET debug_sync='now SIGNAL go';
+connection con;
+a
+2
+3
+4
+5
+--SK middle row delete
+SET debug_sync='rocksdb_concurrent_delete_sk SIGNAL parked WAIT_FOR go';
+SELECT a FROM t1 FORCE INDEX(a) FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 3;
+SET debug_sync='now SIGNAL go';
+connection con;
+a
+2
+4
+5
+--SK end row delete
+SET debug_sync='rocksdb_concurrent_delete_sk SIGNAL parked WAIT_FOR go';
+SELECT a FROM t1 FORCE INDEX(a) FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 5;
+SET debug_sync='now SIGNAL go';
+connection con;
+a
+2
+4
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+connect con, localhost, root,,;
+connection default;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SET debug_sync='RESET';
+CREATE TABLE t1 (pk INT PRIMARY KEY COMMENT "", a INT);
+INSERT INTO t1 VALUES(1,1), (2,2), (3,3), (4,4), (5,5);
+--PK first row delete
+connection con;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk DESC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 5;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+4 4
+3 3
+2 2
+1 1
+--PK middle row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk DESC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 3;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+4 4
+2 2
+1 1
+--PK end row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk DESC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 1;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+4 4
+2 2
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+connect con, localhost, root,,;
+connection default;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SET debug_sync='RESET';
+CREATE TABLE t1 (pk INT PRIMARY KEY COMMENT "rev:cf2", a INT);
+INSERT INTO t1 VALUES(1,1), (2,2), (3,3), (4,4), (5,5);
+--PK first row delete
+connection con;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk ASC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 1;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+2 2
+3 3
+4 4
+5 5
+--PK middle row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk ASC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 3;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+2 2
+4 4
+5 5
+--PK end row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk ASC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 5;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+2 2
+4 4
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+connect con, localhost, root,,;
+connection default;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SET debug_sync='RESET';
+CREATE TABLE t1 (pk INT PRIMARY KEY COMMENT "rev:cf2", a INT);
+INSERT INTO t1 VALUES(1,1), (2,2), (3,3), (4,4), (5,5);
+--PK first row delete
+connection con;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk DESC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 5;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+4 4
+3 3
+2 2
+1 1
+--PK middle row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk DESC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 3;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+4 4
+2 2
+1 1
+--PK end row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+SELECT * FROM t1 order by t1.pk DESC FOR UPDATE;
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+DELETE FROM t1 WHERE pk = 1;
+SET debug_sync='now SIGNAL go';
+connection con;
+pk a
+4 4
+2 2
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+connect con, localhost, root,,;
+connection default;
+set debug_sync='RESET';
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+create table t1 (id1 int, id2 int, value int, primary key (id1, id2), index sk (id1, value)) engine=rocksdb;
+insert into t1 values (1, 1, 1),(1, 2, 1),(1, 3, 1),(1, 4, 1),(1, 5, 1),(2, 2, 2);
+--First row delete with PRIMARY
+connection con;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
+update t1 force index (PRIMARY) set value=100 where id1=1;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+delete from t1 where id1=1 and id2=1;
+set debug_sync='now SIGNAL go';
+connection con;
+select * from t1 where id1=1;
+id1 id2 value
+1 2 100
+1 3 100
+1 4 100
+1 5 100
+--Middle row delete with PRIMARY
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
+update t1 force index (PRIMARY) set value=200 where id1=1;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+delete from t1 where id1=1 and id2=3;
+set debug_sync='now SIGNAL go';
+connection con;
+select * from t1 where id1=1;
+id1 id2 value
+1 2 200
+1 4 200
+1 5 200
+--End row delete with PRIMARY
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
+update t1 force index (PRIMARY) set value=300 where id1=1;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+delete from t1 where id1=1 and id2=5;
+set debug_sync='now SIGNAL go';
+connection con;
+select * from t1 where id1=1;
+id1 id2 value
+1 2 300
+1 4 300
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+connect con, localhost, root,,;
+connection default;
+set debug_sync='RESET';
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+create table t1 (id1 int, id2 int, value int, primary key (id1, id2), index sk (id1, value)) engine=rocksdb;
+insert into t1 values (1, 1, 1),(1, 2, 1),(1, 3, 1),(1, 4, 1),(1, 5, 1),(2, 2, 2);
+--First row delete with sk
+connection con;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
+update t1 force index (sk) set value=100 where id1=1;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+delete from t1 where id1=1 and id2=1;
+set debug_sync='now SIGNAL go';
+connection con;
+select * from t1 where id1=1;
+id1 id2 value
+1 2 100
+1 3 100
+1 4 100
+1 5 100
+--Middle row delete with sk
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
+update t1 force index (sk) set value=200 where id1=1;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+delete from t1 where id1=1 and id2=3;
+set debug_sync='now SIGNAL go';
+connection con;
+select * from t1 where id1=1;
+id1 id2 value
+1 2 200
+1 4 200
+1 5 200
+--End row delete with sk
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
+update t1 force index (sk) set value=300 where id1=1;
+connection default;
+set debug_sync='now WAIT_FOR parked';
+delete from t1 where id1=1 and id2=5;
+set debug_sync='now SIGNAL go';
+connection con;
+select * from t1 where id1=1;
+id1 id2 value
+1 2 300
+1 4 300
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_datadir.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_datadir.result
new file mode 100644
index 00000000..40c53f6f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_datadir.result
@@ -0,0 +1,2 @@
+Check for MANIFEST files
+MANIFEST-000006
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_detect_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_detect_rc.result
new file mode 100644
index 00000000..ea250694
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_detect_rc.result
@@ -0,0 +1,89 @@
+set @prior_rocksdb_lock_wait_timeout = @@rocksdb_lock_wait_timeout;
+set @prior_rocksdb_deadlock_detect = @@rocksdb_deadlock_detect;
+set global rocksdb_lock_wait_timeout = 100000;
+set global rocksdb_deadlock_detect = ON;
+create table t (i int primary key);
+create table r1 (id int primary key, value int);
+insert into r1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10);
+create table r2 like r1;
+insert into r2 select * from r1;
+connect con1,localhost,root,,;
+begin;
+update r2 set value=100 where id=9;
+connect con2,localhost,root,,;
+begin;
+update r1 set value=100 where id=8;
+select * from r2 for update;;
+connection con1;
+select * from r1 for update;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+rollback;
+connection con2;
+id value
+1 1
+2 2
+3 3
+4 4
+5 5
+6 6
+7 7
+8 8
+9 9
+10 10
+rollback;
+connection con1;
+begin;
+insert into t values (1);
+connection con2;
+begin;
+insert into t values (2);
+connect con3,localhost,root,,;
+begin;
+insert into t values (3);
+connection con1;
+select * from t where i = 2 for update;
+connection con2;
+select * from t where i = 3 for update;
+connection con3;
+select * from t;
+i
+3
+insert into t values (4), (1);
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+# Transaction should be rolled back
+select * from t;
+i
+rollback;
+connection con2;
+i
+rollback;
+connection con1;
+i
+rollback;
+connection default;
+create table t1 (id int primary key, value int, value2 int, index(value)) engine=rocksdb;
+insert into t1 values (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10);
+connection con1;
+begin;
+update t1 force index (value) set value2=value2+1 where value=3;
+connection con2;
+begin;
+update t1 force index (value) set value2=value2+1 where value=2;
+update t1 force index (value) set value2=value2+1 where value=4;
+connection con1;
+update t1 force index (value) set value2=value2+1 where value=4;
+connection con2;
+update t1 force index (value) set value2=value2+1 where value=3;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+connection con1;
+rollback;
+connection con2;
+rollback;
+drop table t1;
+connection default;
+disconnect con1;
+disconnect con2;
+disconnect con3;
+set global rocksdb_lock_wait_timeout = @prior_rocksdb_lock_wait_timeout;
+set global rocksdb_deadlock_detect = @prior_rocksdb_deadlock_detect;
+drop table t,r1,r2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_detect_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_detect_rr.result
new file mode 100644
index 00000000..ea250694
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_detect_rr.result
@@ -0,0 +1,89 @@
+set @prior_rocksdb_lock_wait_timeout = @@rocksdb_lock_wait_timeout;
+set @prior_rocksdb_deadlock_detect = @@rocksdb_deadlock_detect;
+set global rocksdb_lock_wait_timeout = 100000;
+set global rocksdb_deadlock_detect = ON;
+create table t (i int primary key);
+create table r1 (id int primary key, value int);
+insert into r1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10);
+create table r2 like r1;
+insert into r2 select * from r1;
+connect con1,localhost,root,,;
+begin;
+update r2 set value=100 where id=9;
+connect con2,localhost,root,,;
+begin;
+update r1 set value=100 where id=8;
+select * from r2 for update;;
+connection con1;
+select * from r1 for update;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+rollback;
+connection con2;
+id value
+1 1
+2 2
+3 3
+4 4
+5 5
+6 6
+7 7
+8 8
+9 9
+10 10
+rollback;
+connection con1;
+begin;
+insert into t values (1);
+connection con2;
+begin;
+insert into t values (2);
+connect con3,localhost,root,,;
+begin;
+insert into t values (3);
+connection con1;
+select * from t where i = 2 for update;
+connection con2;
+select * from t where i = 3 for update;
+connection con3;
+select * from t;
+i
+3
+insert into t values (4), (1);
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+# Transaction should be rolled back
+select * from t;
+i
+rollback;
+connection con2;
+i
+rollback;
+connection con1;
+i
+rollback;
+connection default;
+create table t1 (id int primary key, value int, value2 int, index(value)) engine=rocksdb;
+insert into t1 values (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10);
+connection con1;
+begin;
+update t1 force index (value) set value2=value2+1 where value=3;
+connection con2;
+begin;
+update t1 force index (value) set value2=value2+1 where value=2;
+update t1 force index (value) set value2=value2+1 where value=4;
+connection con1;
+update t1 force index (value) set value2=value2+1 where value=4;
+connection con2;
+update t1 force index (value) set value2=value2+1 where value=3;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+connection con1;
+rollback;
+connection con2;
+rollback;
+drop table t1;
+connection default;
+disconnect con1;
+disconnect con2;
+disconnect con3;
+set global rocksdb_lock_wait_timeout = @prior_rocksdb_lock_wait_timeout;
+set global rocksdb_deadlock_detect = @prior_rocksdb_deadlock_detect;
+drop table t,r1,r2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_stress_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_stress_rc.result
new file mode 100644
index 00000000..f97da009
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_stress_rc.result
@@ -0,0 +1,8 @@
+create table t1 (a int primary key, b int) engine=rocksdb;
+set @prior_rocksdb_lock_wait_timeout = @@rocksdb_lock_wait_timeout;
+set @prior_rocksdb_deadlock_detect = @@rocksdb_deadlock_detect;
+set global rocksdb_lock_wait_timeout = 100000;
+set global rocksdb_deadlock_detect = ON;
+set global rocksdb_lock_wait_timeout = @prior_rocksdb_lock_wait_timeout;
+set global rocksdb_deadlock_detect = @prior_rocksdb_deadlock_detect;
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_stress_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_stress_rr.result
new file mode 100644
index 00000000..f97da009
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_deadlock_stress_rr.result
@@ -0,0 +1,8 @@
+create table t1 (a int primary key, b int) engine=rocksdb;
+set @prior_rocksdb_lock_wait_timeout = @@rocksdb_lock_wait_timeout;
+set @prior_rocksdb_deadlock_detect = @@rocksdb_deadlock_detect;
+set global rocksdb_lock_wait_timeout = 100000;
+set global rocksdb_deadlock_detect = ON;
+set global rocksdb_lock_wait_timeout = @prior_rocksdb_lock_wait_timeout;
+set global rocksdb_deadlock_detect = @prior_rocksdb_deadlock_detect;
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_debug.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_debug.result
new file mode 100644
index 00000000..a245fa85
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_debug.result
@@ -0,0 +1,11 @@
+#
+# Issue #728: Assertion `covers_key(b)' failed in int
+# myrocks::Rdb_key_def::cmp_full_keys(const rocks db::Slice&,
+# const rocksdb::Slice&)
+#
+CREATE TABLE t2(c1 TINYINT SIGNED KEY,c2 TINYINT UNSIGNED,c3 INT);
+INSERT INTO t2(c1)VALUES(0);
+SELECT * FROM t2 WHERE c1<=127 ORDER BY c1 DESC;
+c1 c2 c3
+0 NULL NULL
+DROP TABLE t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp.result
new file mode 100644
index 00000000..101e159e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp.result
@@ -0,0 +1,257 @@
+select * from information_schema.engines where engine = 'rocksdb';
+ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
+ROCKSDB DEFAULT RocksDB storage engine YES YES YES
+drop table if exists t0,t1,t2,t3;
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1(a int) engine=myisam;
+insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
+create table t2 (
+pk int primary key,
+kp1 int,
+kp2 int,
+col1 int,
+key (kp1,kp2) comment 'cf1'
+) engine=rocksdb;
+insert into t2 select a,a,a,a from t1;
+# Try a basic case:
+explain
+select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 5 NULL # Using index condition
+select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0;
+pk kp1 kp2 col1
+2 2 2 2
+4 4 4 4
+6 6 6 6
+8 8 8 8
+10 10 10 10
+# Check that ICP doesnt work for columns where column value
+# cant be restored from mem-comparable form:
+create table t3 (
+pk int primary key,
+kp1 int,
+kp2 varchar(10) collate utf8_general_ci,
+col1 int,
+key (kp1,kp2) comment 'cf1'
+) engine=rocksdb;
+insert into t3 select a,a/10,a,a from t1;
+# This must not use ICP:
+explain
+select * from t3 where kp1=3 and kp2 like '%foo%';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 ref kp1 kp1 5 const # Using where
+explain format=json
+select * from t3 where kp1 between 2 and 4 and mod(kp1,3)=0 and kp2 like '%foo%';
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t3",
+ "access_type": "range",
+ "possible_keys": ["kp1"],
+ "key": "kp1",
+ "key_length": "5",
+ "used_key_parts": ["kp1"],
+ "rows": 1000,
+ "filtered": 100,
+ "index_condition": "t3.kp1 between 2 and 4 and t3.kp1 MOD 3 = 0",
+ "attached_condition": "t3.kp2 like '%foo%'"
+ }
+ }
+}
+# Check that we handle the case where out-of-range is encountered sooner
+# than matched index condition
+explain
+select * from t2 where kp1< 3 and kp2+1>50000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 5 NULL # Using index condition
+select * from t2 where kp1< 3 and kp2+1>50000;
+pk kp1 kp2 col1
+explain
+select * from t2 where kp1< 3 and kp2+1>50000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 5 NULL # Using index condition
+select * from t2 where kp1< 3 and kp2+1>50000;
+pk kp1 kp2 col1
+# Try doing backwards scans
+# MariaDB: ICP is not supported for reverse scans.
+explain
+select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 5 NULL # Using where
+select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc;
+pk kp1 kp2 col1
+10 10 10 10
+8 8 8 8
+6 6 6 6
+4 4 4 4
+2 2 2 2
+explain
+select * from t2 where kp1 >990 and mod(kp2,2)=0 order by kp1 desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 5 NULL # Using where
+select * from t2 where kp1 >990 and mod(kp2,2)=0 order by kp1 desc;
+pk kp1 kp2 col1
+998 998 998 998
+996 996 996 996
+994 994 994 994
+992 992 992 992
+explain
+select * from t2 where kp1< 3 and kp2+1>50000 order by kp1 desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 5 NULL # Using where
+select * from t2 where kp1< 3 and kp2+1>50000 order by kp1 desc;
+pk kp1 kp2 col1
+drop table t0,t1,t2,t3;
+#
+# Check how ICP affects counters
+#
+# First, some preparations
+#
+# in facebook/mysql-5.6, it was:
+# select ROWS_READ, ROWS_REQUESTED, ROWS_INDEX_FIRST, ROWS_INDEX_NEXT
+#
+# In MariaDB, we do:
+create procedure save_read_stats()
+begin
+set @rr=(select ROWS_READ
+from information_schema.table_statistics
+where table_name='t4' and table_schema=database());
+set @rif= (select VARIABLE_VALUE
+from information_schema.session_status
+where VARIABLE_NAME='Handler_read_first');
+set @rin=(select VARIABLE_VALUE
+from information_schema.session_status
+where VARIABLE_NAME='Handler_read_next');
+set @icp_attempts=(select VARIABLE_VALUE
+from information_schema.session_status
+where VARIABLE_NAME='Handler_icp_attempts');
+set @icp_matches=(select VARIABLE_VALUE
+from information_schema.session_status
+where VARIABLE_NAME='Handler_icp_match');
+end|
+create procedure get_read_stats()
+begin
+select
+(select ROWS_READ
+from information_schema.table_statistics
+where table_name='t4' and table_schema=database()
+) - @rr as ROWS_READ_DIFF,
+(select VARIABLE_VALUE - @rif
+from information_schema.session_status
+where VARIABLE_NAME='Handler_read_first') as ROWS_INDEX_FIRST,
+(select VARIABLE_VALUE - @rin
+from information_schema.session_status
+where VARIABLE_NAME='Handler_read_next') as ROWS_INDEX_NEXT,
+(select VARIABLE_VALUE - @icp_attempts
+from information_schema.session_status
+where VARIABLE_NAME='Handler_icp_attempts') as ICP_ATTEMPTS,
+(select VARIABLE_VALUE - @icp_matches
+from information_schema.session_status
+where VARIABLE_NAME='Handler_icp_match') as ICP_MATCHES;
+end|
+create table t4 (
+id int,
+id1 int,
+id2 int,
+value int,
+value2 varchar(100),
+primary key (id),
+key id1_id2 (id1, id2) comment 'cf1'
+) engine=rocksdb charset=latin1 collate latin1_bin;
+insert into t4 values
+(1,1,1,1,1), (2,1,2,2,2), (3,1,3,3,3),(4,1,4,4,4),(5,1,5,5,5),
+(6,1,6,6,6), (7,1,7,7,7), (8,1,8,8,8),(9,1,9,9,9),(10,1,10,10,10);
+#
+# Now, the test itself
+#
+call save_read_stats();
+call get_read_stats();
+ROWS_READ_DIFF ROWS_INDEX_FIRST ROWS_INDEX_NEXT ICP_ATTEMPTS ICP_MATCHES
+0 0 0 0 0
+# ============== index-only query ==============
+explain
+select id1,id2 from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ref id1_id2 id1_id2 5 const # Using where; Using index
+call save_read_stats();
+select id1,id2 from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+id1 id2
+1 1
+call get_read_stats();
+ROWS_READ_DIFF 10
+ROWS_INDEX_FIRST 0
+ROWS_INDEX_NEXT 10
+ICP_ATTEMPTS 0
+ICP_MATCHES 0
+# ============== Query without ICP ==============
+set optimizer_switch='index_condition_pushdown=off';
+explain
+select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ref id1_id2 id1_id2 5 const # Using where
+call save_read_stats();
+select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+id id1 id2 value value2
+1 1 1 1 1
+call get_read_stats();
+ROWS_READ_DIFF 10
+ROWS_INDEX_FIRST 0
+ROWS_INDEX_NEXT 10
+ICP_ATTEMPTS 0
+ICP_MATCHES 0
+# ============== Query with ICP ==============
+set optimizer_switch='index_condition_pushdown=on';
+explain
+select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ref id1_id2 id1_id2 5 const # Using index condition
+call save_read_stats();
+select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+id id1 id2 value value2
+1 1 1 1 1
+call get_read_stats();
+ROWS_READ_DIFF 1
+ROWS_INDEX_FIRST 0
+ROWS_INDEX_NEXT 1
+ICP_ATTEMPTS 10
+ICP_MATCHES 1
+drop table t4;
+drop procedure save_read_stats;
+drop procedure get_read_stats;
+#
+# Issue #67: Inefficient index condition pushdown
+#
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (
+pk int not null primary key,
+key1 bigint(20) unsigned,
+col1 int,
+key (key1)
+) engine=rocksdb;
+insert into t1
+select
+A.a+10*B.a+100*C.a,
+A.a+10*B.a+100*C.a,
+1234
+from t0 A, t0 B, t0 C;
+set @count=0;
+explain
+select * from t1 force index(key1) where key1=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref key1 key1 9 const #
+set @count_diff =(select (value - @count) from information_schema.rocksdb_perf_context
+where table_schema=database() and table_name='t1' and stat_type='INTERNAL_KEY_SKIPPED_COUNT');
+select * from t1 force index(key1) where key1=1;
+pk key1 col1
+1 1 1234
+set @count_diff =(select (value - @count) from information_schema.rocksdb_perf_context
+where table_schema=database() and table_name='t1' and stat_type='INTERNAL_KEY_SKIPPED_COUNT');
+# The following must be =1, or in any case not 999:
+select @count_diff as "INTERNAL_KEY_SKIPPED_COUNT increment";
+INTERNAL_KEY_SKIPPED_COUNT increment
+1
+drop table t0,t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp_rev.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp_rev.result
new file mode 100644
index 00000000..b00e0e14
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_icp_rev.result
@@ -0,0 +1,223 @@
+select * from information_schema.engines where engine = 'rocksdb';
+ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
+ROCKSDB DEFAULT RocksDB storage engine YES YES YES
+drop table if exists t0,t1,t2,t3;
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1(a int) engine=myisam;
+insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
+create table t2 (
+pk int primary key,
+kp1 int,
+kp2 int,
+col1 int,
+key (kp1,kp2) comment 'rev:cf1'
+) engine=rocksdb;
+insert into t2 select a,a,a,a from t1;
+# Try a basic case:
+explain
+select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 5 NULL # Using index condition
+select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0;
+pk kp1 kp2 col1
+2 2 2 2
+4 4 4 4
+6 6 6 6
+8 8 8 8
+10 10 10 10
+# Check that ICP doesnt work for columns where column value
+# cant be restored from mem-comparable form:
+create table t3 (
+pk int primary key,
+kp1 int,
+kp2 varchar(10) collate utf8_general_ci,
+col1 int,
+key (kp1,kp2) comment 'rev:cf1'
+) engine=rocksdb;
+insert into t3 select a,a/10,a,a from t1;
+# This must not use ICP:
+explain
+select * from t3 where kp1=3 and kp2 like '%foo%';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 ref kp1 kp1 5 const # Using where
+explain format=json
+select * from t3 where kp1 between 2 and 4 and mod(kp1,3)=0 and kp2 like '%foo%';
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t3",
+ "access_type": "range",
+ "possible_keys": ["kp1"],
+ "key": "kp1",
+ "key_length": "5",
+ "used_key_parts": ["kp1"],
+ "rows": 1000,
+ "filtered": 100,
+ "index_condition": "t3.kp1 between 2 and 4 and t3.kp1 MOD 3 = 0",
+ "attached_condition": "t3.kp2 like '%foo%'"
+ }
+ }
+}
+# Check that we handle the case where out-of-range is encountered sooner
+# than matched index condition
+explain
+select * from t2 where kp1< 3 and kp2+1>50000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 5 NULL # Using index condition
+select * from t2 where kp1< 3 and kp2+1>50000;
+pk kp1 kp2 col1
+explain
+select * from t2 where kp1< 3 and kp2+1>50000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 5 NULL # Using index condition
+select * from t2 where kp1< 3 and kp2+1>50000;
+pk kp1 kp2 col1
+# Try doing backwards scans
+# MariaDB: ICP is not supported for reverse scans.
+explain
+select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 5 NULL # Using where
+select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc;
+pk kp1 kp2 col1
+10 10 10 10
+8 8 8 8
+6 6 6 6
+4 4 4 4
+2 2 2 2
+explain
+select * from t2 where kp1 >990 and mod(kp2,2)=0 order by kp1 desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 5 NULL # Using where
+select * from t2 where kp1 >990 and mod(kp2,2)=0 order by kp1 desc;
+pk kp1 kp2 col1
+998 998 998 998
+996 996 996 996
+994 994 994 994
+992 992 992 992
+explain
+select * from t2 where kp1< 3 and kp2+1>50000 order by kp1 desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range kp1 kp1 5 NULL # Using where
+select * from t2 where kp1< 3 and kp2+1>50000 order by kp1 desc;
+pk kp1 kp2 col1
+drop table t0,t1,t2,t3;
+#
+# Check how ICP affects counters
+#
+# First, some preparations
+#
+# in facebook/mysql-5.6, it was:
+# select ROWS_READ, ROWS_REQUESTED, ROWS_INDEX_FIRST, ROWS_INDEX_NEXT
+#
+# In MariaDB, we do:
+create procedure save_read_stats()
+begin
+set @rr=(select ROWS_READ
+from information_schema.table_statistics
+where table_name='t4' and table_schema=database());
+set @rif= (select VARIABLE_VALUE
+from information_schema.session_status
+where VARIABLE_NAME='Handler_read_first');
+set @rin=(select VARIABLE_VALUE
+from information_schema.session_status
+where VARIABLE_NAME='Handler_read_next');
+set @icp_attempts=(select VARIABLE_VALUE
+from information_schema.session_status
+where VARIABLE_NAME='Handler_icp_attempts');
+set @icp_matches=(select VARIABLE_VALUE
+from information_schema.session_status
+where VARIABLE_NAME='Handler_icp_match');
+end|
+create procedure get_read_stats()
+begin
+select
+(select ROWS_READ
+from information_schema.table_statistics
+where table_name='t4' and table_schema=database()
+) - @rr as ROWS_READ_DIFF,
+(select VARIABLE_VALUE - @rif
+from information_schema.session_status
+where VARIABLE_NAME='Handler_read_first') as ROWS_INDEX_FIRST,
+(select VARIABLE_VALUE - @rin
+from information_schema.session_status
+where VARIABLE_NAME='Handler_read_next') as ROWS_INDEX_NEXT,
+(select VARIABLE_VALUE - @icp_attempts
+from information_schema.session_status
+where VARIABLE_NAME='Handler_icp_attempts') as ICP_ATTEMPTS,
+(select VARIABLE_VALUE - @icp_matches
+from information_schema.session_status
+where VARIABLE_NAME='Handler_icp_match') as ICP_MATCHES;
+end|
+create table t4 (
+id int,
+id1 int,
+id2 int,
+value int,
+value2 varchar(100),
+primary key (id),
+key id1_id2 (id1, id2) comment 'rev:cf1'
+) engine=rocksdb charset=latin1 collate latin1_bin;
+insert into t4 values
+(1,1,1,1,1), (2,1,2,2,2), (3,1,3,3,3),(4,1,4,4,4),(5,1,5,5,5),
+(6,1,6,6,6), (7,1,7,7,7), (8,1,8,8,8),(9,1,9,9,9),(10,1,10,10,10);
+#
+# Now, the test itself
+#
+call save_read_stats();
+call get_read_stats();
+ROWS_READ_DIFF ROWS_INDEX_FIRST ROWS_INDEX_NEXT ICP_ATTEMPTS ICP_MATCHES
+0 0 0 0 0
+# ============== index-only query ==============
+explain
+select id1,id2 from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ref id1_id2 id1_id2 5 const # Using where; Using index
+call save_read_stats();
+select id1,id2 from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+id1 id2
+1 1
+call get_read_stats();
+ROWS_READ_DIFF 10
+ROWS_INDEX_FIRST 0
+ROWS_INDEX_NEXT 10
+ICP_ATTEMPTS 0
+ICP_MATCHES 0
+# ============== Query without ICP ==============
+set optimizer_switch='index_condition_pushdown=off';
+explain
+select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ref id1_id2 id1_id2 5 const # Using where
+call save_read_stats();
+select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+id id1 id2 value value2
+1 1 1 1 1
+call get_read_stats();
+ROWS_READ_DIFF 10
+ROWS_INDEX_FIRST 0
+ROWS_INDEX_NEXT 10
+ICP_ATTEMPTS 0
+ICP_MATCHES 0
+# ============== Query with ICP ==============
+set optimizer_switch='index_condition_pushdown=on';
+explain
+select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ref id1_id2 id1_id2 5 const # Using index condition
+call save_read_stats();
+select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
+id id1 id2 value value2
+1 1 1 1 1
+call get_read_stats();
+ROWS_READ_DIFF 1
+ROWS_INDEX_FIRST 0
+ROWS_INDEX_NEXT 1
+ICP_ATTEMPTS 10
+ICP_MATCHES 1
+drop table t4;
+drop procedure save_read_stats;
+drop procedure get_read_stats;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_locks.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_locks.result
new file mode 100644
index 00000000..c0995973
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_locks.result
@@ -0,0 +1,64 @@
+create table t1 (pk int not null primary key) engine=rocksdb;
+insert into t1 values (1),(2),(3);
+set autocommit=0;
+begin;
+select * from t1 where pk=1 for update;
+pk
+1
+connect con1,localhost,root,,;
+connection con1;
+call mtr.add_suppression("Got snapshot conflict errors");
+### Connection con1
+set @@rocksdb_lock_wait_timeout=500;
+set autocommit=0;
+begin;
+select * from t1 where pk=1 for update;;
+connection default;
+### Connection default
+rollback;
+connection con1;
+pk
+1
+rollback;
+connection default;
+begin;
+select * from t1 where pk=1 for update;
+pk
+1
+connection con1;
+### Connection con1
+set @@rocksdb_lock_wait_timeout=2;
+set autocommit=0;
+begin;
+select * from t1 where pk=1 for update;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection default;
+rollback;
+set autocommit=1;
+connection con1;
+drop table t1;
+connection default;
+#
+# Now, test what happens if another transaction modified the record and committed
+#
+CREATE TABLE t1 (
+id int primary key,
+value int
+) engine=rocksdb collate latin1_bin;
+insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10);
+connection con1;
+BEGIN;
+SELECT * FROM t1 WHERE id=3;
+id value
+3 3
+connection default;
+BEGIN;
+UPDATE t1 SET value=30 WHERE id=3;
+COMMIT;
+connection con1;
+SELECT * FROM t1 WHERE id=3 FOR UPDATE;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction (snapshot conflict)
+ROLLBACK;
+disconnect con1;
+connection default;
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_parts.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_parts.result
new file mode 100644
index 00000000..70bef39e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_parts.result
@@ -0,0 +1,152 @@
+drop table if exists t1,t2;
+# Tests for MyRocks + partitioning
+#
+# MyRocks Issue #70: Server crashes in Rdb_key_def::get_primary_key_tuple
+#
+CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, KEY(f2)) ENGINE=RocksDB
+PARTITION BY HASH(pk) PARTITIONS 2;
+INSERT INTO t1 VALUES (1, 6, NULL), (2, NULL, 1);
+CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT) ENGINE=RocksDB;
+INSERT INTO t2 VALUES (1, 1), (2, 1);
+SELECT f1 FROM t1 WHERE f2 = ( SELECT f1 FROM t2 WHERE pk = 2 );
+f1
+NULL
+drop table t1,t2;
+#
+# Issue#105: key_info[secondary_key].actual_key_parts does not include primary key on partitioned tables
+#
+CREATE TABLE t1 (
+id INT PRIMARY KEY,
+a set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') CHARACTER SET utf8,
+b set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') CHARACTER SET utf8 default null,
+c set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') CHARACTER SET utf8 not null,
+INDEX (a),
+INDEX (b),
+INDEX (c)
+) ENGINE=RocksDB PARTITION BY key (id) partitions 2;
+INSERT INTO t1 (id, b) VALUES (28, 3);
+Warnings:
+Warning 1364 Field 'c' doesn't have a default value
+UPDATE t1 SET id=8 WHERE c < 8 LIMIT 1;
+check table t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+drop table t1;
+#
+# Issue #105, another testcase
+#
+create table t1 (
+pk int primary key,
+col1 int,
+col2 int,
+key (col1) comment 'rev:cf_issue105'
+) engine=rocksdb partition by hash(pk) partitions 2;
+insert into t1 values (1,10,10);
+insert into t1 values (2,10,10);
+insert into t1 values (11,20,20);
+insert into t1 values (12,20,20);
+set @tmp_rfirr= @@rocksdb_force_index_records_in_range;
+set rocksdb_force_index_records_in_range= 12;
+explain select * from t1 force index(col1) where col1=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref col1 col1 5 const #
+select * from t1 force index(col1) where col1=10;
+pk col1 col2
+1 10 10
+2 10 10
+select * from t1 use index () where col1=10;
+pk col1 col2
+2 10 10
+1 10 10
+set rocksdb_force_index_records_in_range= @tmp_rfirr;
+drop table t1;
+#
+# Issue #108: Index-only scans do not work for partitioned tables and extended keys
+#
+create table t1 (
+pk int primary key,
+col1 int,
+col2 int,
+key (col1)
+) engine=rocksdb partition by hash(pk) partitions 2;
+insert into t1 values (1,10,10);
+insert into t1 values (2,10,10);
+insert into t1 values (11,20,20);
+insert into t1 values (12,20,20);
+# The following must use "Using index"
+explain select pk from t1 force index(col1) where col1=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref col1 col1 5 const 2000 Using index
+drop table t1;
+#
+# Issue #214: subqueries cause crash
+#
+create TABLE t1(a int,b int,c int,primary key(a,b))
+partition by list (b*a) (partition x1 values in (1) tablespace ts1,
+partition x2 values in (3,11,5,7) tablespace ts2,
+partition x3 values in (16,8,5+19,70-43) tablespace ts3);
+create table t2(b binary(2));
+set session optimizer_switch='materialization=off';
+insert into t1(a,b) values(1,7);
+select a from t1 where a in (select a from t1 where a in (select b from t2));
+a
+drop table t1, t2;
+#
+# Issue #260: altering name to invalid value leaves table unaccessible
+#
+CREATE TABLE t1 (c1 INT NOT NULL, c2 CHAR(5)) PARTITION BY HASH(c1) PARTITIONS 4;
+INSERT INTO t1 VALUES(1,'a');
+RENAME TABLE t1 TO db3.t3;
+ERROR HY000: Error on rename of './test/t1' to './db3/t3' (errno: -1 "Internal error < 0 (Not system error)")
+SELECT * FROM t1;
+c1 c2
+1 a
+SHOW TABLES;
+Tables_in_test
+t1
+RENAME TABLE t1 TO test.t3;
+SELECT * FROM t3;
+c1 c2
+1 a
+SHOW TABLES;
+Tables_in_test
+t3
+CREATE DATABASE db3;
+USE test;
+RENAME TABLE t3 to db3.t2;
+USE db3;
+SELECT * FROM t2;
+c1 c2
+1 a
+SHOW TABLES;
+Tables_in_db3
+t2
+DROP TABLE t2;
+use test;
+DROP DATABASE db3;
+#
+# MDEV-13153 Assertion `global_status_var.global_memory_used == 0 '
+# failed upon server restart with partitioned RocksDB table
+#
+CREATE TABLE t1 (a INT) ENGINE=RocksDB PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a) VALUES (1),(2);
+ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
+# restart
+SELECT 1;
+1
+1
+DROP TABLE t1;
+#
+# MDEV-15245: Assertion `false' failed in myrocks::ha_rocksdb::position
+#
+CREATE TABLE t1 (a INT) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 (b INT) ENGINE=RocksDB
+PARTITION BY RANGE(b)
+(PARTITION p0 VALUES LESS THAN (1),
+PARTITION p1 VALUES LESS THAN MAXVALUE);
+INSERT INTO t2 VALUES (NULL),(0);
+CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.* FROM t1, t2;
+UPDATE v1 SET b = 5;
+drop view v1;
+drop table t1,t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_qcache.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_qcache.result
new file mode 100644
index 00000000..28479217
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_qcache.result
@@ -0,0 +1,45 @@
+set @save_query_cache_type=@@global.query_cache_type;
+set @save_query_cache_size=@@global.query_cache_size;
+set @@global.query_cache_type=1;
+set @@global.query_cache_size=1024*1024;
+create table t1 (pk int primary key, c char(8)) engine=RocksDB;
+insert into t1 values (1,'new'),(2,'new');
+select * from t1;
+pk c
+1 new
+2 new
+connect con1,localhost,root,,;
+update t1 set c = 'updated';
+connection default;
+flush status;
+show status like 'Qcache_hits';
+Variable_name Value
+Qcache_hits 0
+show global status like 'Qcache_hits';
+Variable_name Value
+Qcache_hits 0
+select * from t1;
+pk c
+1 updated
+2 updated
+select sql_no_cache * from t1;
+pk c
+1 updated
+2 updated
+select * from t1 where pk = 1;
+pk c
+1 updated
+show status like 'Qcache_hits';
+Variable_name Value
+Qcache_hits 0
+# MariaDB: Qcache_not_cached is not incremented for select sql_no_cache queries
+# so the following query produces 2, not 3:
+show status like 'Qcache_not_cached';
+Variable_name Value
+Qcache_not_cached 2
+show global status like 'Qcache_hits';
+Variable_name Value
+Qcache_hits 0
+drop table t1;
+set @@global.query_cache_type=@save_query_cache_type;
+set @@global.query_cache_size=@save_query_cache_size;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_range.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_range.result
new file mode 100644
index 00000000..918859ea
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_range.result
@@ -0,0 +1,293 @@
+select * from information_schema.engines where engine = 'rocksdb';
+ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
+ROCKSDB DEFAULT RocksDB storage engine YES YES YES
+drop table if exists t0,t1,t2,t3,t4,t5;
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1(a int) engine=myisam;
+insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
+create table t2 (
+pk int not null,
+a int not null,
+b int not null,
+primary key(pk),
+key(a) comment 'rev:cf1'
+) engine=rocksdb;
+insert into t2 select A.a, FLOOR(A.a/10), A.a from t1 A;
+#
+# HA_READ_KEY_EXACT tests
+#
+# Original failure was here:
+explain
+select * from t2 force index (a) where a=0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref a a 4 const #
+select * from t2 force index (a) where a=0;
+pk a b
+0 0 0
+1 0 1
+2 0 2
+3 0 3
+4 0 4
+5 0 5
+6 0 6
+7 0 7
+8 0 8
+9 0 9
+# The rest are for code coverage:
+explain
+select * from t2 force index (a) where a=2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref a a 4 const #
+select * from t2 force index (a) where a=2;
+pk a b
+20 2 20
+21 2 21
+22 2 22
+23 2 23
+24 2 24
+25 2 25
+26 2 26
+27 2 27
+28 2 28
+29 2 29
+explain
+select * from t2 force index (a) where a=3 and pk=33;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 const a a 8 const,const #
+select * from t2 force index (a) where a=3 and pk=33;
+pk a b
+33 3 33
+select * from t2 force index (a) where a=99 and pk=99;
+pk a b
+select * from t2 force index (a) where a=0 and pk=0;
+pk a b
+0 0 0
+select * from t2 force index (a) where a=-1;
+pk a b
+select * from t2 force index (a) where a=-1 and pk in (101,102);
+pk a b
+select * from t2 force index (a) where a=100 and pk in (101,102);
+pk a b
+#
+# #36: Range in form tbl.key >= const doesn't work in reverse column family
+#
+explain
+select count(*) from t2 force index (a) where a>=0 and a <=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range a a 4 NULL # Using where; Using index
+select count(*) from t2 force index (a) where a>=0 and a <=1;
+count(*)
+20
+explain
+select count(*) from t2 force index (a) where a>=-1 and a <=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range a a 4 NULL # Using where; Using index
+select count(*) from t2 force index (a) where a>=-1 and a <=1;
+count(*)
+20
+explain
+select * from t2 force index (a) where a=0 and pk>=3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range a a 8 NULL # Using index condition
+select * from t2 force index (a) where a=0 and pk>=3;
+pk a b
+3 0 3
+4 0 4
+5 0 5
+6 0 6
+7 0 7
+8 0 8
+9 0 9
+# Try edge cases where we fall over the end of the table
+create table t3 like t2;
+insert into t3 select * from t2;
+select * from t3 where pk>=1000000;
+pk a b
+select * from t2 where pk>=1000000;
+pk a b
+#
+# #42: Range in form tbl.key > const doesn't work in reverse column family
+#
+explain
+select count(*) from t2 force index (a) where a>0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range a a 4 NULL # Using where; Using index
+select count(*) from t2 force index (a) where a>0;
+count(*)
+990
+explain
+select count(*) from t2 force index (a) where a>99;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range a a 4 NULL # Using where; Using index
+select count(*) from t2 force index (a) where a>99;
+count(*)
+0
+select * from t2 where pk>1000000;
+pk a b
+select * from t3 where pk>1000000;
+pk a b
+explain
+select count(*) from t2 force index (a) where a=2 and pk>25;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range a a 8 NULL # Using where; Using index
+select count(*) from t2 force index (a) where a=2 and pk>25;
+count(*)
+4
+select * from t2 force index (a) where a>-10 and a < 1;
+pk a b
+0 0 0
+1 0 1
+2 0 2
+3 0 3
+4 0 4
+5 0 5
+6 0 6
+7 0 7
+8 0 8
+9 0 9
+select * from t3 force index (a) where a>-10 and a < 1;
+pk a b
+0 0 0
+1 0 1
+2 0 2
+3 0 3
+4 0 4
+5 0 5
+6 0 6
+7 0 7
+8 0 8
+9 0 9
+#
+# #46: index_read_map(HA_READ_BEFORE_KEY) does not work in reverse column family
+#
+select max(a) from t2 where a < 2;
+max(a)
+1
+select max(a) from t2 where a < -1;
+max(a)
+NULL
+select max(pk) from t2 where a=3 and pk < 6;
+max(pk)
+NULL
+select max(pk) from t2 where pk < 200000;
+max(pk)
+999
+select max(pk) from t2 where pk < 20;
+max(pk)
+19
+select max(a) from t3 where a < 2;
+max(a)
+1
+select max(a) from t3 where a < -1;
+max(a)
+NULL
+select max(pk) from t3 where pk < 200000;
+max(pk)
+999
+select max(pk) from t3 where pk < 20;
+max(pk)
+19
+select max(pk) from t2 where a=3 and pk < 33;
+max(pk)
+32
+select max(pk) from t3 where a=3 and pk < 33;
+max(pk)
+32
+#
+# #48: index_read_map(HA_READ_PREFIX_LAST) does not work in reverse CF
+#
+# Tests for search_flag=HA_READ_PREFIX_LAST_OR_PREV
+# Note: the next explain has "Using index condition" in fb/mysql-5.6
+# but "Using where" in MariaDB because the latter does not
+# support ICP over reverse scans.
+explain
+select * from t2 where a between 99 and 2000 order by a desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range a a 4 NULL # Using where
+select * from t2 where a between 99 and 2000 order by a desc;
+pk a b
+999 99 999
+998 99 998
+997 99 997
+996 99 996
+995 99 995
+994 99 994
+993 99 993
+992 99 992
+991 99 991
+990 99 990
+select max(a) from t2 where a <=10;
+max(a)
+10
+select max(a) from t2 where a <=-4;
+max(a)
+NULL
+select max(pk) from t2 where a=5 and pk <=55;
+max(pk)
+55
+select max(pk) from t2 where a=5 and pk <=55555;
+max(pk)
+59
+select max(pk) from t2 where a=5 and pk <=0;
+max(pk)
+NULL
+select max(pk) from t2 where pk <=-1;
+max(pk)
+NULL
+select max(pk) from t2 where pk <=999999;
+max(pk)
+999
+select max(pk) from t3 where pk <=-1;
+max(pk)
+NULL
+select max(pk) from t3 where pk <=999999;
+max(pk)
+999
+#
+# Tests for search_flag=HA_READ_PREFIX_LAST
+#
+create table t4 (
+pk int primary key,
+a int,
+b int,
+c int,
+key(a,b,c)
+) engine=rocksdb;
+insert into t4 select pk,pk,pk,pk from t2 where pk < 100;
+explain
+select * from t4 where a=1 and b in (1) order by c desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ref a a 10 const,const # Using where; Using index
+select * from t4 where a=1 and b in (1) order by c desc;
+pk a b c
+1 1 1 1
+explain
+select * from t4 where a=5 and b in (4) order by c desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ref a a 10 const,const # Using where; Using index
+select * from t4 where a=5 and b in (4) order by c desc;
+pk a b c
+# HA_READ_PREFIX_LAST for reverse-ordered CF
+create table t5 (
+pk int primary key,
+a int,
+b int,
+c int,
+key(a,b,c) comment 'rev:cf2'
+) engine=rocksdb;
+insert into t5 select pk,pk,pk,pk from t2 where pk < 100;
+explain
+select * from t5 where a=1 and b in (1) order by c desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t5 ref a a 10 const,const # Using where; Using index
+select * from t5 where a=1 and b in (1) order by c desc;
+pk a b c
+1 1 1 1
+explain
+select * from t5 where a=5 and b in (4) order by c desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t5 ref a a 10 const,const # Using where; Using index
+select * from t5 where a=5 and b in (4) order by c desc;
+pk a b c
+drop table t0,t1,t2,t3,t4,t5;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_range2.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_range2.result
new file mode 100644
index 00000000..bcda9341
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_range2.result
@@ -0,0 +1,29 @@
+create table t1 (id1 bigint, id2 bigint, c1 bigint, c2 bigint, c3 bigint, c4 bigint, c5 bigint, c6 bigint, c7 bigint, primary key (id1, id2), index i(c1, c2));
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+select count(*) from t1;
+count(*)
+10000
+explain select c1 from t1 where c1 > 5 limit 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index i i 18 NULL # Using where; Using index
+drop table t1;
+#
+# MDEV-17414: MyROCKS order desc limit 1 fails
+#
+create table t1 (date date);
+insert into t1 values ('2018-10-04'), ('2018-10-05');
+select * from t1 where date < '2018-10-09' order by date desc limit 1;
+date
+2018-10-05
+alter table t1 add index date_index (date);
+select * from t1 where date < '2018-10-05' order by date desc limit 1;
+date
+2018-10-04
+# this should not produce an empty set:
+select * from t1 where date < '2018-10-09' order by date desc limit 1;
+date
+2018-10-05
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_read_free_rpl.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_read_free_rpl.result
new file mode 100644
index 00000000..fabf077e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_read_free_rpl.result
@@ -0,0 +1,335 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+drop table if exists t1;
+create table t1 (id int primary key, value int);
+insert into t1 values (1,1), (2,2), (3,3), (4,4);
+include/sync_slave_sql_with_master.inc
+
+# regular update/delete. With rocks_read_free_rpl=PK_SK, rocksdb_rows_read does not increase on slaves
+
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+update t1 set value=value+1 where id=1;
+delete from t1 where id=4;
+select * from t1;
+id value
+1 2
+2 2
+3 3
+include/sync_slave_sql_with_master.inc
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+select * from t1;
+id value
+1 2
+2 2
+3 3
+
+# "rocks_read_free_rpl=PK_SK" makes "row not found error" not happen anymore
+
+include/stop_slave.inc
+delete from t1 where id in (2, 3);
+include/start_slave.inc
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+update t1 set value=value+1 where id=3;
+delete from t1 where id=2;
+select * from t1;
+id value
+1 2
+3 4
+include/sync_slave_sql_with_master.inc
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+select * from t1;
+id value
+1 2
+3 4
+
+## tables without primary key -- read free replication should be disabled
+
+
+#no index
+
+drop table t1;
+create table t1 (c1 int, c2 int);
+insert into t1 values (1,1), (2,2),(3,3),(4,4),(5,5);
+include/sync_slave_sql_with_master.inc
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+update t1 set c2=100 where c1=3;
+delete from t1 where c1 <= 2;
+include/sync_slave_sql_with_master.inc
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+false
+select * from t1;
+c1 c2
+3 100
+4 4
+5 5
+
+#secondary index only
+
+drop table t1;
+create table t1 (c1 int, c2 int, index i(c1));
+insert into t1 values (1,1), (2,2),(3,3),(4,4),(5,5);
+include/sync_slave_sql_with_master.inc
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+update t1 set c2=100 where c1=3;
+delete from t1 where c1 <= 2;
+include/sync_slave_sql_with_master.inc
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+false
+select * from t1;
+c1 c2
+3 100
+4 4
+5 5
+
+## large row operations -- primary key modification, secondary key modification
+
+drop table t1;
+create table t1 (id1 bigint, id2 bigint, c1 bigint, c2 bigint, c3 bigint, c4 bigint, c5 bigint, c6 bigint, c7 bigint, primary key (id1, id2), index i(c1, c2));
+include/sync_slave_sql_with_master.inc
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+
+#updating all secondary keys by 1
+
+include/sync_slave_sql_with_master.inc
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+include/diff_tables.inc [master:t1, slave:t1]
+
+#updating all primary keys by 2
+
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+include/sync_slave_sql_with_master.inc
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+include/diff_tables.inc [master:t1, slave:t1]
+
+#updating secondary keys after truncating t1 on slave
+
+truncate table t1;
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+update t1 set c2=c2+10;
+include/sync_slave_sql_with_master.inc
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+include/diff_tables.inc [master:t1, slave:t1]
+
+#updating primary keys after truncating t1 on slave
+
+truncate table t1;
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+update t1 set id2=id2+10;
+include/sync_slave_sql_with_master.inc
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+include/diff_tables.inc [master:t1, slave:t1]
+
+#deleting half rows
+
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+delete from t1 where id1 <= 5000;
+include/sync_slave_sql_with_master.inc
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+include/diff_tables.inc [master:t1, slave:t1]
+
+# rocksdb_read_free_rpl = PK_ONLY i.e. it only works on tables with only PK
+
+[on slave]
+stop slave;
+set @@global.rocksdb_read_free_rpl = PK_ONLY;
+start slave;
+[on master]
+create table t2 (id int primary key, i1 int, i2 int, value int);
+create table u2 (id int primary key, i1 int, i2 int, value int, index(i1), index(i2));
+insert into t2 values (1,1,1,1),(2,2,2,2),(3,3,3,3);
+insert into u2 values (1,1,1,1),(2,2,2,2),(3,3,3,3);
+include/sync_slave_sql_with_master.inc
+[on slave]
+delete from t2 where id <= 2;
+delete from u2 where id <= 2;
+[on master]
+update t2 set i2=100, value=100 where id=1;
+update u2 set i2=100, value=100 where id=1;
+[on slave]
+call mtr.add_suppression("Slave SQL.*Could not execute Update_rows event on table test.u2.*Error_code.*");
+call mtr.add_suppression("Slave: Can't find record in 'u2'.*");
+include/wait_for_slave_sql_error.inc [errno=1032]
+select count(*) from t2 force index(primary);
+count(*)
+2
+select * from t2 where id=1;
+id i1 i2 value
+1 1 100 100
+select i1 from t2 where i1=1;
+i1
+1
+select i2 from t2 where i2=100;
+i2
+100
+select count(*) from u2 force index(primary);
+count(*)
+1
+select count(*) from u2 force index(i1);
+count(*)
+1
+select count(*) from u2 force index(i2);
+count(*)
+1
+select * from u2 where id=1;
+id i1 i2 value
+select i1 from u2 where i1=1;
+i1
+select i2 from u2 where i2=100;
+i2
+include/wait_for_slave_sql_to_start.inc
+[on slave]
+stop slave;
+set @@global.rocksdb_read_free_rpl = PK_SK;
+start slave;
+
+# some tables with read-free replication on and some with it off
+
+[on slave]
+stop slave;
+set @@global.rocksdb_read_free_rpl_tables = "t.*";
+start slave;
+[on master]
+drop table if exists t2;
+drop table if exists u2;
+create table t2 (id int primary key, i1 int, i2 int, value int);
+create table u2 (id int primary key, i1 int, i2 int, value int);
+insert into t2 values (1,1,1,1),(2,2,2,2),(3,3,3,3);
+insert into u2 values (1,1,1,1),(2,2,2,2),(3,3,3,3);
+include/sync_slave_sql_with_master.inc
+[on slave]
+delete from t2 where id <= 2;
+delete from u2 where id <= 2;
+[on master]
+update t2 set i2=100, value=100 where id=1;
+update u2 set i2=100, value=100 where id=1;
+[on slave]
+call mtr.add_suppression("Slave SQL.*Could not execute Update_rows event on table test.u2.*Error_code.*");
+call mtr.add_suppression("Slave: Can't find record in 'u2'.*");
+include/wait_for_slave_sql_error.inc [errno=1032]
+select count(*) from t2 force index(primary);
+count(*)
+2
+select * from t2 where id=1;
+id i1 i2 value
+1 1 100 100
+select i1 from t2 where i1=1;
+i1
+1
+select i2 from t2 where i2=100;
+i2
+100
+select count(*) from u2 force index(primary);
+count(*)
+1
+select * from u2 where id=1;
+id i1 i2 value
+select i1 from u2 where i1=1;
+i1
+select i2 from u2 where i2=100;
+i2
+include/wait_for_slave_sql_to_start.inc
+[on slave]
+stop slave;
+set @@global.rocksdb_read_free_rpl_tables = ".*";
+start slave;
+
+# secondary keys lose rows
+
+[on master]
+create table t3 (id int primary key, i1 int, i2 int, value int, index(i1),
+index(i2));
+insert into t3 values (1,1,1,1),(2,2,2,2),(3,3,3,3);
+include/sync_slave_sql_with_master.inc
+[on slave]
+delete from t3 where id <= 2;
+[on master]
+update t3 set i2=100, value=100 where id=1;
+include/sync_slave_sql_with_master.inc
+select count(*) from t3 force index(primary);
+count(*)
+2
+select count(*) from t3 force index(i1);
+count(*)
+1
+select count(*) from t3 force index(i2);
+count(*)
+2
+select * from t3 where id=1;
+id i1 i2 value
+1 1 100 100
+select i1 from t3 where i1=1;
+i1
+select i2 from t3 where i2=100;
+i2
+100
+
+# secondary keys have extra rows
+
+[on master]
+create table t4 (id int primary key, i1 int, i2 int, value int, index(i1), index(i2));
+insert into t4 values (1,1,1,1),(2,2,2,2),(3,3,3,3);
+include/sync_slave_sql_with_master.inc
+[on slave]
+update t4 set i1=100 where id=1;
+[on master]
+delete from t4 where id=1;
+include/sync_slave_sql_with_master.inc
+[on slave]
+select count(*) from t4 force index(primary);
+count(*)
+2
+select count(*) from t4 force index(i1);
+count(*)
+3
+select count(*) from t4 force index(i2);
+count(*)
+2
+select i1 from t4 where i1=100;
+i1
+100
+
+# inserts are also read-free
+
+[on master]
+drop table if exists t2;
+drop table if exists t3;
+create table t2 (id int primary key, i1 int, i2 int);
+create table t3 (id int primary key, i1 int, i2 int, key(i1));
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+insert into t2 values(1, 1, 1);
+insert into t2 values(2, 2, 2);
+insert into t3 values(1, 1, 1);
+insert into t3 values(2, 2, 2);
+include/sync_slave_sql_with_master.inc
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+select * from t2;
+id i1 i2
+1 1 1
+2 2 2
+select * from t3;
+id i1 i2
+1 1 1
+2 2 2
+drop table t1, t2, t3, t4, u2;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_read_free_rpl_stress.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_read_free_rpl_stress.result
new file mode 100644
index 00000000..9e3c7a05
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_read_free_rpl_stress.result
@@ -0,0 +1,35 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+include/stop_slave.inc
+set @@global.rocksdb_read_free_rpl = PK_SK;
+include/start_slave.inc
+include/sync_slave_sql_with_master.inc
+include/diff_tables.inc [master:t1, slave:t1]
+include/diff_tables.inc [master:t2, slave:t2]
+include/diff_tables.inc [master:t3, slave:t3]
+include/diff_tables.inc [master:t4, slave:t4]
+include/diff_tables.inc [master:t5, slave:t5]
+include/diff_tables.inc [master:t6, slave:t6]
+include/diff_tables.inc [master:t7, slave:t7]
+include/diff_tables.inc [master:t8, slave:t8]
+include/sync_slave_sql_with_master.inc
+include/stop_slave.inc
+set @@global.rocksdb_read_free_rpl = PK_ONLY;
+include/start_slave.inc
+include/sync_slave_sql_with_master.inc
+include/diff_tables.inc [master:t1, slave:t1]
+include/diff_tables.inc [master:t2, slave:t2]
+include/diff_tables.inc [master:t3, slave:t3]
+include/diff_tables.inc [master:t4, slave:t4]
+include/diff_tables.inc [master:t5, slave:t5]
+include/diff_tables.inc [master:t6, slave:t6]
+include/diff_tables.inc [master:t7, slave:t7]
+include/diff_tables.inc [master:t8, slave:t8]
+include/sync_slave_sql_with_master.inc
+include/stop_slave.inc
+set @@global.rocksdb_read_free_rpl = default;
+include/start_slave.inc
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_row_stats.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_row_stats.result
new file mode 100644
index 00000000..8c02de98
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_row_stats.result
@@ -0,0 +1,66 @@
+create table t1 (a int primary key) engine=rocksdb;
+Verify rocksdb_rows_inserted
+select variable_value into @old_rows_inserted from information_schema.global_status where variable_name = 'rocksdb_rows_inserted';
+insert into t1 values(1);
+select variable_value into @new_rows_inserted from information_schema.global_status where variable_name = 'rocksdb_rows_inserted';
+select @new_rows_inserted - @old_rows_inserted;
+@new_rows_inserted - @old_rows_inserted
+1
+Verify rocksdb_rows_updated
+select variable_value into @old_rows_updated from information_schema.global_status where variable_name = 'rocksdb_rows_updated';
+update t1 set a=2 where a=1;
+select variable_value into @new_rows_updated from information_schema.global_status where variable_name = 'rocksdb_rows_updated';
+select @new_rows_updated - @old_rows_updated;
+@new_rows_updated - @old_rows_updated
+1
+Verify rocksdb_rows_read
+select variable_value into @old_rows_read from information_schema.global_status where variable_name = 'rocksdb_rows_read';
+select * from t1;
+a
+2
+select variable_value into @new_rows_read from information_schema.global_status where variable_name = 'rocksdb_rows_read';
+select @new_rows_read - @old_rows_read;
+@new_rows_read - @old_rows_read
+1
+Verify rocksdb_rows_deleted
+select variable_value into @old_rows_deleted from information_schema.global_status where variable_name = 'rocksdb_rows_deleted';
+delete from t1;
+select variable_value into @new_rows_deleted from information_schema.global_status where variable_name = 'rocksdb_rows_deleted';
+select @new_rows_deleted - @old_rows_deleted;
+@new_rows_deleted - @old_rows_deleted
+1
+use mysql;
+create table t1(a int primary key) engine=rocksdb;
+Verify rocksdb_system_rows_inserted
+select variable_value into @old_system_rows_inserted from information_schema.global_status where variable_name = 'rocksdb_system_rows_inserted';
+insert into t1 values(1);
+select variable_value into @new_system_rows_inserted from information_schema.global_status where variable_name = 'rocksdb_system_rows_inserted';
+select @new_system_rows_inserted - @old_system_rows_inserted;
+@new_system_rows_inserted - @old_system_rows_inserted
+1
+Verify rocksdb_system_rows_updated
+select variable_value into @old_system_rows_updated from information_schema.global_status where variable_name = 'rocksdb_system_rows_updated';
+update t1 set a=2 where a=1;
+select variable_value into @new_system_rows_updated from information_schema.global_status where variable_name = 'rocksdb_system_rows_updated';
+select @new_system_rows_updated - @old_system_rows_updated;
+@new_system_rows_updated - @old_system_rows_updated
+1
+Verify rocksdb_system_rows_read
+select variable_value into @old_system_rows_read from information_schema.global_status where variable_name = 'rocksdb_system_rows_read';
+select * from t1;
+a
+2
+select variable_value into @new_system_rows_read from information_schema.global_status where variable_name = 'rocksdb_system_rows_read';
+select @new_system_rows_read - @old_system_rows_read;
+@new_system_rows_read - @old_system_rows_read
+1
+Verify rocksdb_system_rows_deleted
+select variable_value into @old_system_rows_deleted from information_schema.global_status where variable_name = 'rocksdb_system_rows_deleted';
+delete from t1;
+select variable_value into @new_system_rows_deleted from information_schema.global_status where variable_name = 'rocksdb_system_rows_deleted';
+select @new_system_rows_deleted - @old_system_rows_deleted;
+@new_system_rows_deleted - @old_system_rows_deleted
+1
+drop table t1;
+use test;
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_table_stats_sampling_pct_change.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_table_stats_sampling_pct_change.result
new file mode 100644
index 00000000..1e8aa578
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_table_stats_sampling_pct_change.result
@@ -0,0 +1,23 @@
+drop table if exists t1;
+SET @ORIG_PCT = @@ROCKSDB_TABLE_STATS_SAMPLING_PCT;
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = 100;
+create table t1 (pk int primary key) engine=rocksdb;
+set global rocksdb_force_flush_memtable_now = true;
+select table_rows from information_schema.tables
+where table_schema = database() and table_name = 't1';
+table_rows
+10000
+drop table t1;
+drop table if exists t2;
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = 10;
+create table t2 (pk int primary key) engine=rocksdb;
+set global rocksdb_force_flush_memtable_now = true;
+select table_rows from information_schema.tables
+where table_schema = database() and table_name = 't2';
+table_rows
+10000
+select table_name from information_schema.tables where table_schema = database() and table_name = 't2';
+table_name
+t2
+drop table t2;
+SET GLOBAL ROCKSDB_TABLE_STATS_SAMPLING_PCT = @ORIG_PCT;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_timeout_rollback.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_timeout_rollback.result
new file mode 100644
index 00000000..adf05d06
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_timeout_rollback.result
@@ -0,0 +1,84 @@
+drop table if exists t1;
+SET @@global.rocksdb_rollback_on_timeout = 1;
+show variables like 'rocksdb_rollback_on_timeout';
+Variable_name Value
+rocksdb_rollback_on_timeout ON
+create table t1 (a int unsigned not null primary key) engine = rocksdb;
+insert into t1 values (1);
+commit;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con2;
+begin work;
+insert into t1 values (5);
+insert into t1 values (6);
+update t1 set a = a + 1 where a = 1;
+connection con1;
+begin work;
+insert into t1 values (7);
+insert into t1 values (8);
+update t1 set a = a + 1 where a = 1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+select * from t1;
+a
+1
+commit;
+connection con2;
+select * from t1;
+a
+2
+5
+6
+commit;
+connection default;
+select * from t1;
+a
+2
+5
+6
+SET @@global.rocksdb_rollback_on_timeout = 0;
+show variables like 'rocksdb_rollback_on_timeout';
+Variable_name Value
+rocksdb_rollback_on_timeout OFF
+connection con2;
+begin work;
+insert into t1 values (9);
+insert into t1 values (10);
+update t1 set a = a + 1 where a = 2;
+connection con1;
+begin work;
+insert into t1 values (11);
+insert into t1 values (12);
+update t1 set a = a + 1 where a = 2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+select * from t1;
+a
+2
+5
+6
+11
+12
+commit;
+connection con2;
+select * from t1;
+a
+3
+5
+6
+9
+10
+commit;
+connection default;
+select * from t1;
+a
+3
+5
+6
+9
+10
+11
+12
+SET @@global.rocksdb_rollback_on_timeout = DEFAULT;
+drop table t1;
+disconnect con1;
+disconnect con2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rollback_savepoint.result b/storage/rocksdb/mysql-test/rocksdb/r/rollback_savepoint.result
new file mode 100644
index 00000000..18b76818
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rollback_savepoint.result
@@ -0,0 +1,29 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'a');
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 SELECT * FROM t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+SAVEPOINT a;
+SELECT * FROM t1 ORDER BY pk;
+a b pk
+1 a 1
+2 b 2
+3 a 3
+ROLLBACK TO SAVEPOINT a;
+SAVEPOINT a;
+SELECT * FROM t2 ORDER BY pk;
+a b pk
+1 a 1
+2 b 2
+3 a 3
+ROLLBACK TO SAVEPOINT a;
+connection con2;
+ALTER TABLE t1 RENAME TO t3;
+connection default;
+DROP TABLE t2, t3;
+disconnect con1;
+disconnect con2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rpl_row_not_found.result b/storage/rocksdb/mysql-test/rocksdb/r/rpl_row_not_found.result
new file mode 100644
index 00000000..8cdfa910
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rpl_row_not_found.result
@@ -0,0 +1,56 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+drop table if exists t1;
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1(a int) engine=myisam;
+insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
+create table t2 (
+pk int primary key,
+kp1 int,
+kp2 int,
+col1 int,
+key (kp1,kp2)
+) engine=rocksdb;
+insert into t2 select a,a,a,a from t1;
+create table t3 like t2;
+insert into t3 select * from t2;
+include/sync_slave_sql_with_master.inc
+set global debug= 'd,dbug.rocksdb.get_row_by_rowid';
+include/stop_slave.inc
+include/start_slave.inc
+update t2 set col1=100 where kp1 between 1 and 3 and mod(kp2,2)=0;
+set debug_sync= 'now WAIT_FOR Reached';
+set global debug = '';
+set sql_log_bin=0;
+delete from t2 where pk=2;
+delete from t2 where pk=3;
+set debug_sync= 'now SIGNAL signal.rocksdb.get_row_by_rowid_let_running';
+include/sync_slave_sql_with_master.inc
+select * from t2 where pk < 5;
+pk kp1 kp2 col1
+0 0 0 0
+1 1 1 1
+4 4 4 4
+set global debug= 'd,dbug.rocksdb.get_row_by_rowid';
+include/stop_slave.inc
+include/start_slave.inc
+update t3 set col1=100 where kp1 between 1 and 4 and mod(kp2,2)=0;
+call mtr.add_suppression("Deadlock found when trying to get lock");
+set debug_sync= 'now WAIT_FOR Reached';
+set global debug = '';
+set sql_log_bin=0;
+delete from t3 where pk=2;
+delete from t3 where pk=3;
+set debug_sync= 'now SIGNAL signal.rocksdb.get_row_by_rowid_let_running';
+include/sync_slave_sql_with_master.inc
+select * from t3 where pk < 5;
+pk kp1 kp2 col1
+0 0 0 0
+1 1 1 1
+4 4 4 100
+drop table t0, t1, t2, t3;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rpl_row_not_found_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/rpl_row_not_found_rc.result
new file mode 100644
index 00000000..8cdfa910
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rpl_row_not_found_rc.result
@@ -0,0 +1,56 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+drop table if exists t1;
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1(a int) engine=myisam;
+insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
+create table t2 (
+pk int primary key,
+kp1 int,
+kp2 int,
+col1 int,
+key (kp1,kp2)
+) engine=rocksdb;
+insert into t2 select a,a,a,a from t1;
+create table t3 like t2;
+insert into t3 select * from t2;
+include/sync_slave_sql_with_master.inc
+set global debug= 'd,dbug.rocksdb.get_row_by_rowid';
+include/stop_slave.inc
+include/start_slave.inc
+update t2 set col1=100 where kp1 between 1 and 3 and mod(kp2,2)=0;
+set debug_sync= 'now WAIT_FOR Reached';
+set global debug = '';
+set sql_log_bin=0;
+delete from t2 where pk=2;
+delete from t2 where pk=3;
+set debug_sync= 'now SIGNAL signal.rocksdb.get_row_by_rowid_let_running';
+include/sync_slave_sql_with_master.inc
+select * from t2 where pk < 5;
+pk kp1 kp2 col1
+0 0 0 0
+1 1 1 1
+4 4 4 4
+set global debug= 'd,dbug.rocksdb.get_row_by_rowid';
+include/stop_slave.inc
+include/start_slave.inc
+update t3 set col1=100 where kp1 between 1 and 4 and mod(kp2,2)=0;
+call mtr.add_suppression("Deadlock found when trying to get lock");
+set debug_sync= 'now WAIT_FOR Reached';
+set global debug = '';
+set sql_log_bin=0;
+delete from t3 where pk=2;
+delete from t3 where pk=3;
+set debug_sync= 'now SIGNAL signal.rocksdb.get_row_by_rowid_let_running';
+include/sync_slave_sql_with_master.inc
+select * from t3 where pk < 5;
+pk kp1 kp2 col1
+0 0 0 0
+1 1 1 1
+4 4 4 100
+drop table t0, t1, t2, t3;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rpl_row_rocksdb.result b/storage/rocksdb/mysql-test/rocksdb/r/rpl_row_rocksdb.result
new file mode 100644
index 00000000..de47f3b3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rpl_row_rocksdb.result
@@ -0,0 +1,45 @@
+include/master-slave.inc
+[connection master]
+connection master;
+drop table if exists t1;
+connection master;
+select @@binlog_format;
+@@binlog_format
+ROW
+create table t1 (pk int primary key) engine=rocksdb;
+insert into t1 values (1),(2),(3);
+include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t1;
+pk
+1
+2
+3
+connection master;
+drop table t1;
+#
+# Issue #18: slave crash on update with row based binary logging
+#
+create table t1 (id int primary key, value int, value2 int, index(value)) engine=rocksdb;
+insert into t1 values (1,1,1);
+insert into t1 values (2,1,1);
+insert into t1 values (3,1,1);
+insert into t1 values (4,1,1);
+insert into t1 values (5,1,1);
+update t1 set value2=100 where id=1;
+update t1 set value2=200 where id=2;
+update t1 set value2=300 where id=3;
+include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t1 where id=1;
+id value value2
+1 1 100
+select * from t1 where id=2;
+id value value2
+2 1 200
+select * from t1 where id=3;
+id value value2
+3 1 300
+connection master;
+drop table t1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rpl_row_stats.result b/storage/rocksdb/mysql-test/rocksdb/r/rpl_row_stats.result
new file mode 100644
index 00000000..a14d2693
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rpl_row_stats.result
@@ -0,0 +1,98 @@
+include/master-slave.inc
+[connection master]
+connection master;
+drop table if exists t1;
+connection master;
+create procedure save_read_stats()
+begin
+/*select rows_requested into @rq from information_schema.table_statistics
+where table_schema=database() and table_name='t1';*/
+select rows_read into @rr_is from information_schema.table_statistics
+where table_schema=database() and table_name='t1';
+select variable_value into @rr from information_schema.global_status
+where variable_name='rocksdb_rows_read';
+select variable_value into @ru from information_schema.global_status
+where variable_name='rocksdb_rows_updated';
+select variable_value into @rd from information_schema.global_status
+where variable_name='rocksdb_rows_deleted';
+end//
+create procedure get_read_stats()
+begin
+/*select rows_requested - @rq as rows_requested from
+information_schema.table_statistics
+where table_schema=database() and table_name='t1';*/
+select rows_read - @rr_is as rows_read_userstat from
+information_schema.table_statistics
+where table_schema=database() and table_name='t1';
+select variable_value - @rr as rows_read from
+information_schema.global_status
+where variable_name='rocksdb_rows_read';
+select variable_value - @ru as rows_updated from
+information_schema.global_status
+where variable_name='rocksdb_rows_updated';
+select variable_value - @rd as rows_deleted from
+information_schema.global_status
+where variable_name='rocksdb_rows_deleted';
+end//
+create table t1 (id int primary key, value int);
+insert into t1 values (1,1), (2,2), (3,3), (4,4), (5,5);
+include/sync_slave_sql_with_master.inc
+connection slave;
+call save_read_stats();
+connection master;
+update t1 set value=value+1 where id=1;
+update t1 set value=value+1 where id=3;
+select * from t1;
+id value
+1 2
+2 2
+3 4
+4 4
+5 5
+include/sync_slave_sql_with_master.inc
+connection slave;
+call get_read_stats();
+rows_read_userstat
+2
+rows_read
+2
+rows_updated
+2
+rows_deleted
+0
+select * from t1;
+id value
+1 2
+2 2
+3 4
+4 4
+5 5
+call save_read_stats();
+connection master;
+delete from t1 where id in (4,5);
+select * from t1;
+id value
+1 2
+2 2
+3 4
+include/sync_slave_sql_with_master.inc
+connection slave;
+call get_read_stats();
+rows_read_userstat
+2
+rows_read
+2
+rows_updated
+0
+rows_deleted
+2
+select * from t1;
+id value
+1 2
+2 2
+3 4
+connection master;
+drop table t1;
+drop procedure save_read_stats;
+drop procedure get_read_stats;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rpl_row_triggers.result b/storage/rocksdb/mysql-test/rocksdb/r/rpl_row_triggers.result
new file mode 100644
index 00000000..69acc4a9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rpl_row_triggers.result
@@ -0,0 +1,286 @@
+include/master-slave.inc
+[connection master]
+# Test of row replication with triggers on the slave side
+connection master;
+CREATE TABLE t1 (C1 CHAR(1) primary key, C2 CHAR(1));
+SELECT * FROM t1;
+C1 C2
+connection slave;
+connection slave;
+SET @old_slave_exec_mode= @@global.slave_exec_mode;
+SET @old_slave_run_triggers_for_rbr= @@global.slave_run_triggers_for_rbr;
+SET @@global.slave_exec_mode= IDEMPOTENT;
+SET @@global.slave_run_triggers_for_rbr= YES;
+SELECT * FROM t1;
+C1 C2
+create table t2 (id char(2) primary key, cnt int, o char(1), n char(1));
+insert into t2 values
+('u0', 0, ' ', ' '),('u1', 0, ' ', ' '),
+('d0', 0, ' ', ' '),('d1', 0, ' ', ' '),
+('i0', 0, ' ', ' '),('i1', 0, ' ', ' ');
+create trigger t1_cnt_b before update on t1 for each row
+update t2 set cnt=cnt+1, o=old.C1, n=new.C1 where id = 'u0';
+create trigger t1_cnt_db before delete on t1 for each row
+update t2 set cnt=cnt+1, o=old.C1, n=' ' where id = 'd0';
+create trigger t1_cnt_ib before insert on t1 for each row
+update t2 set cnt=cnt+1, n=new.C1, o=' ' where id = 'i0';
+create trigger t1_cnt_a after update on t1 for each row
+update t2 set cnt=cnt+1, o=old.C1, n=new.C1 where id = 'u1';
+create trigger t1_cnt_da after delete on t1 for each row
+update t2 set cnt=cnt+1, o=old.C1, n=' ' where id = 'd1';
+create trigger t1_cnt_ia after insert on t1 for each row
+update t2 set cnt=cnt+1, n=new.C1, o=' ' where id = 'i1';
+SELECT * FROM t2 order by id;
+id cnt o n
+d0 0
+d1 0
+i0 0
+i1 0
+u0 0
+u1 0
+connection master;
+# INSERT triggers test
+insert into t1 values ('a','b');
+connection slave;
+connection slave;
+SELECT * FROM t2 order by id;
+id cnt o n
+d0 0
+d1 0
+i0 1 a
+i1 1 a
+u0 0
+u1 0
+connection master;
+# UPDATE triggers test
+update t1 set C1= 'd';
+connection slave;
+connection slave;
+SELECT * FROM t2 order by id;
+id cnt o n
+d0 0
+d1 0
+i0 1 a
+i1 1 a
+u0 1 a d
+u1 1 a d
+connection master;
+# DELETE triggers test
+delete from t1 where C1='d';
+connection slave;
+connection slave;
+SELECT * FROM t2 order by id;
+id cnt o n
+d0 1 d
+d1 1 d
+i0 1 a
+i1 1 a
+u0 1 a d
+u1 1 a d
+# INSERT triggers which cause also UPDATE test (insert duplicate row)
+insert into t1 values ('0','1');
+SELECT * FROM t2 order by id;
+id cnt o n
+d0 1 d
+d1 1 d
+i0 2 0
+i1 2 0
+u0 1 a d
+u1 1 a d
+connection master;
+insert into t1 values ('0','1');
+connection slave;
+connection slave;
+SELECT * FROM t2 order by id;
+id cnt o n
+d0 1 d
+d1 1 d
+i0 3 0
+i1 3 0
+u0 2 0 0
+u1 2 0 0
+# INSERT triggers which cause also DELETE test
+# (insert duplicate row in table referenced by foreign key)
+insert into t1 values ('1','1');
+connection master;
+drop table if exists t1;
+connection slave;
+connection slave;
+SET @@global.slave_exec_mode= @old_slave_exec_mode;
+SET @@global.slave_run_triggers_for_rbr= @old_slave_run_triggers_for_rbr;
+drop table t2;
+connection master;
+CREATE TABLE t1 (i INT);
+CREATE TABLE t2 (i INT);
+connection slave;
+SET @old_slave_run_triggers_for_rbr= @@global.slave_run_triggers_for_rbr;
+SET GLOBAL slave_run_triggers_for_rbr=YES;
+CREATE TRIGGER tr AFTER INSERT ON t1 FOR EACH ROW
+INSERT INTO t2 VALUES (new.i);
+connection master;
+BEGIN;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+COMMIT;
+connection slave;
+select * from t2;
+i
+1
+2
+SET @@global.slave_run_triggers_for_rbr= @old_slave_run_triggers_for_rbr;
+connection master;
+drop tables t2,t1;
+connection slave;
+# Triggers on slave do not work if master has some
+connection master;
+CREATE TABLE t1 (C1 CHAR(1) primary key, C2 CHAR(1));
+SELECT * FROM t1;
+C1 C2
+create trigger t1_dummy before delete on t1 for each row
+set @dummy= 1;
+connection slave;
+connection slave;
+SET @old_slave_exec_mode= @@global.slave_exec_mode;
+SET @old_slave_run_triggers_for_rbr= @@global.slave_run_triggers_for_rbr;
+SET @@global.slave_exec_mode= IDEMPOTENT;
+SET @@global.slave_run_triggers_for_rbr= YES;
+SELECT * FROM t1;
+C1 C2
+create table t2 (id char(2) primary key, cnt int, o char(1), n char(1));
+insert into t2 values
+('u0', 0, ' ', ' '),('u1', 0, ' ', ' '),
+('d0', 0, ' ', ' '),('d1', 0, ' ', ' '),
+('i0', 0, ' ', ' '),('i1', 0, ' ', ' ');
+create trigger t1_cnt_b before update on t1 for each row
+update t2 set cnt=cnt+1, o=old.C1, n=new.C1 where id = 'u0';
+create trigger t1_cnt_ib before insert on t1 for each row
+update t2 set cnt=cnt+1, n=new.C1, o=' ' where id = 'i0';
+create trigger t1_cnt_a after update on t1 for each row
+update t2 set cnt=cnt+1, o=old.C1, n=new.C1 where id = 'u1';
+create trigger t1_cnt_da after delete on t1 for each row
+update t2 set cnt=cnt+1, o=old.C1, n=' ' where id = 'd1';
+create trigger t1_cnt_ia after insert on t1 for each row
+update t2 set cnt=cnt+1, n=new.C1, o=' ' where id = 'i1';
+SELECT * FROM t2 order by id;
+id cnt o n
+d0 0
+d1 0
+i0 0
+i1 0
+u0 0
+u1 0
+connection master;
+# INSERT triggers test
+insert into t1 values ('a','b');
+connection slave;
+connection slave;
+SELECT * FROM t2 order by id;
+id cnt o n
+d0 0
+d1 0
+i0 0
+i1 0
+u0 0
+u1 0
+connection master;
+# UPDATE triggers test
+update t1 set C1= 'd';
+connection slave;
+connection slave;
+SELECT * FROM t2 order by id;
+id cnt o n
+d0 0
+d1 0
+i0 0
+i1 0
+u0 0
+u1 0
+connection master;
+# DELETE triggers test
+delete from t1 where C1='d';
+connection slave;
+connection slave;
+SELECT * FROM t2 order by id;
+id cnt o n
+d0 0
+d1 0
+i0 0
+i1 0
+u0 0
+u1 0
+# INSERT triggers which cause also UPDATE test (insert duplicate row)
+insert into t1 values ('0','1');
+SELECT * FROM t2 order by id;
+id cnt o n
+d0 0
+d1 0
+i0 1 0
+i1 1 0
+u0 0
+u1 0
+connection master;
+insert into t1 values ('0','1');
+connection slave;
+connection slave;
+SELECT * FROM t2 order by id;
+id cnt o n
+d0 0
+d1 0
+i0 1 0
+i1 1 0
+u0 0
+u1 0
+# INSERT triggers which cause also DELETE test
+# (insert duplicate row in table referenced by foreign key)
+insert into t1 values ('1','1');
+connection master;
+drop table if exists t1;
+connection slave;
+connection slave;
+SET @@global.slave_exec_mode= @old_slave_exec_mode;
+SET @@global.slave_run_triggers_for_rbr= @old_slave_run_triggers_for_rbr;
+drop table t2;
+#
+# MDEV-5513: Trigger is applied to the rows after first one
+#
+connection master;
+create table t1 (a int, b int);
+create table tlog (a int auto_increment primary key);
+set sql_log_bin=0;
+create trigger tr1 after insert on t1 for each row insert into tlog values (null);
+set sql_log_bin=1;
+connection slave;
+connection slave;
+set @slave_run_triggers_for_rbr.saved = @@slave_run_triggers_for_rbr;
+set global slave_run_triggers_for_rbr=1;
+create trigger tr2 before insert on t1 for each row set new.b = new.a;
+connection master;
+insert into t1 values (1,10),(2,20),(3,30);
+connection slave;
+select * from t1;
+a b
+1 10
+2 20
+3 30
+#
+# Verify slave skips running triggers if master ran and logged the row events for triggers
+#
+create table t4(a int, b int);
+delete from tlog;
+create trigger tr4 before insert on t4 for each row insert into tlog values (null);
+insert into t4 values (1, 10),(2, 20);
+select * from tlog;
+a
+4
+5
+select * from t4;
+a b
+1 10
+2 20
+select * from tlog;
+a
+4
+5
+set global slave_run_triggers_for_rbr = @slave_run_triggers_for_rbr.saved;
+drop table t1, tlog, t4;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rpl_savepoint.result b/storage/rocksdb/mysql-test/rocksdb/r/rpl_savepoint.result
new file mode 100644
index 00000000..5746119e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rpl_savepoint.result
@@ -0,0 +1,110 @@
+include/master-slave.inc
+[connection master]
+connection master;
+drop table if exists t1;
+connection master;
+create table t1 (id int primary key, value int);
+insert into t1 values (1,1), (2,2), (3,3);
+begin;
+insert into t1 values (11, 1);
+savepoint a;
+insert into t1 values (12, 1);
+rollback to savepoint a;
+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.
+commit;
+select * from t1;
+id value
+1 1
+2 2
+3 3
+include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t1;
+id value
+1 1
+2 2
+3 3
+connection master;
+begin;
+insert into t1 values (21, 1);
+savepoint a;
+insert into t1 values (22, 1);
+rollback to savepoint a;
+ERROR HY000: MyRocks currently does not support ROLLBACK TO SAVEPOINT if modifying rows.
+insert into t1 values (23, 1);
+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.
+commit;
+select * from t1;
+id value
+1 1
+2 2
+3 3
+include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t1;
+id value
+1 1
+2 2
+3 3
+connection master;
+begin;
+insert into t1 values (31, 1);
+savepoint a;
+insert into t1 values (32, 1);
+savepoint b;
+insert into t1 values (33, 1);
+rollback to savepoint a;
+ERROR HY000: MyRocks currently does not support ROLLBACK TO SAVEPOINT if modifying rows.
+insert into t1 values (34, 1);
+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.
+rollback;
+select * from t1;
+id value
+1 1
+2 2
+3 3
+include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t1;
+id value
+1 1
+2 2
+3 3
+connection master;
+SET autocommit=off;
+select * from t1;
+id value
+1 1
+2 2
+3 3
+SAVEPOINT A;
+select * from t1;
+id value
+1 1
+2 2
+3 3
+SAVEPOINT A;
+insert into t1 values (35, 35);
+ROLLBACK TO SAVEPOINT A;
+ERROR HY000: MyRocks currently does not support ROLLBACK TO SAVEPOINT if modifying rows.
+START TRANSACTION;
+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 * from t1;
+id value
+1 1
+2 2
+3 3
+include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t1;
+id value
+1 1
+2 2
+3 3
+connection master;
+drop table t1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rpl_statement.result b/storage/rocksdb/mysql-test/rocksdb/r/rpl_statement.result
new file mode 100644
index 00000000..df1a6051
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rpl_statement.result
@@ -0,0 +1,57 @@
+include/master-slave.inc
+[connection master]
+connection master;
+drop table if exists t1;
+connection master;
+select @@binlog_format;
+@@binlog_format
+STATEMENT
+create table t1 (pk int primary key) engine=rocksdb;
+insert into t1 values (1),(2),(3);
+ERROR HY000: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging.
+set session rocksdb_unsafe_for_binlog=on;
+insert into t1 values (1),(2),(3);
+select * from t1;
+pk
+1
+2
+3
+delete from t1;
+set session rocksdb_unsafe_for_binlog=off;
+insert into t1 values (1),(2),(3);
+ERROR HY000: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging.
+set binlog_format=row;
+insert into t1 values (1),(2),(3);
+include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t1;
+pk
+1
+2
+3
+connection master;
+drop table t1;
+create table t1 (id int primary key, value int, value2 int, index(value)) engine=rocksdb;
+insert into t1 values (1,1,1);
+insert into t1 values (2,1,1);
+insert into t1 values (3,1,1);
+insert into t1 values (4,1,1);
+insert into t1 values (5,1,1);
+update t1 set value2=100 where id=1;
+update t1 set value2=200 where id=2;
+update t1 set value2=300 where id=3;
+include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t1 where id=1;
+id value value2
+1 1 100
+select * from t1 where id=2;
+id value value2
+2 1 200
+select * from t1 where id=3;
+id value value2
+3 1 300
+connection master;
+drop table t1;
+set binlog_format=row;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rpl_statement_not_found.result b/storage/rocksdb/mysql-test/rocksdb/r/rpl_statement_not_found.result
new file mode 100644
index 00000000..9e71ffa7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rpl_statement_not_found.result
@@ -0,0 +1,70 @@
+include/master-slave.inc
+[connection master]
+connection master;
+drop table if exists t1;
+connection master;
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1(a int) engine=myisam;
+insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
+create table t2 (
+pk int primary key,
+kp1 int,
+kp2 int,
+col1 int,
+key (kp1,kp2)
+) engine=rocksdb;
+set @tmp_binlog_format=@@binlog_format;
+set @@binlog_format=ROW;
+insert into t2 select a,a,a,a from t1;
+create table t3 like t2;
+insert into t3 select * from t2;
+set binlog_format=@tmp_binlog_format;
+include/sync_slave_sql_with_master.inc
+connection slave;
+set global debug_dbug= 'd,dbug.rocksdb.get_row_by_rowid';
+include/stop_slave.inc
+include/start_slave.inc
+connection master;
+update t2 set col1=100 where kp1 between 1 and 3 and mod(kp2,2)=0;
+connection slave;
+set debug_sync= 'now WAIT_FOR Reached';
+set global debug_dbug = '';
+set sql_log_bin=0;
+delete from t2 where pk=2;
+delete from t2 where pk=3;
+set debug_sync= 'now SIGNAL signal.rocksdb.get_row_by_rowid_let_running';
+connection master;
+include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t2 where pk < 5;
+pk kp1 kp2 col1
+0 0 0 0
+1 1 1 1
+4 4 4 4
+connection slave;
+set global debug_dbug= 'd,dbug.rocksdb.get_row_by_rowid';
+include/stop_slave.inc
+include/start_slave.inc
+connection master;
+update t3 set col1=100 where kp1 between 1 and 4 and mod(kp2,2)=0;
+connection slave;
+call mtr.add_suppression("Deadlock found when trying to get lock");
+set debug_sync= 'now WAIT_FOR Reached';
+set global debug_dbug = '';
+set sql_log_bin=0;
+delete from t3 where pk=2;
+delete from t3 where pk=3;
+set debug_sync= 'now SIGNAL signal.rocksdb.get_row_by_rowid_let_running';
+connection master;
+include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t3 where pk < 5;
+pk kp1 kp2 col1
+0 0 0 0
+1 1 1 1
+4 4 4 100
+set debug_sync='RESET';
+connection master;
+drop table t0, t1, t2, t3;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rqg_examples.result b/storage/rocksdb/mysql-test/rocksdb/r/rqg_examples.result
new file mode 100644
index 00000000..76679593
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rqg_examples.result
@@ -0,0 +1,3 @@
+CREATE DATABASE IF NOT EXISTS rqg_examples;
+Running test with grammar file example.yy
+DROP DATABASE rqg_examples;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rqg_runtime.result b/storage/rocksdb/mysql-test/rocksdb/r/rqg_runtime.result
new file mode 100644
index 00000000..1b872f82
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rqg_runtime.result
@@ -0,0 +1,30 @@
+call mtr.add_suppression("Did not write failed ");
+call mtr.add_suppression("Can't open and lock privilege tables");
+call mtr.add_suppression("Attempt to delete the trigger file");
+SET @ORIG_EVENT_SCHEDULER = @@EVENT_SCHEDULER;
+CREATE TABLE mysql.user_temp LIKE mysql.user;
+INSERT mysql.user_temp SELECT * FROM mysql.user;
+CREATE TABLE mysql.tables_priv_temp LIKE mysql.tables_priv;
+INSERT mysql.tables_priv_temp SELECT * FROM mysql.tables_priv_temp;
+CREATE DATABASE IF NOT EXISTS rqg_runtime;
+Running test with grammar file alter_online.yy
+DROP DATABASE rqg_runtime;
+CREATE DATABASE IF NOT EXISTS rqg_runtime;
+Running test with grammar file concurrency_1.yy
+DROP DATABASE rqg_runtime;
+CREATE DATABASE IF NOT EXISTS rqg_runtime;
+Running test with grammar file connect_kill_sql.yy
+DROP DATABASE rqg_runtime;
+CREATE DATABASE IF NOT EXISTS rqg_runtime;
+Running test with grammar file metadata_stability.yy
+DROP DATABASE rqg_runtime;
+DELETE FROM mysql.tables_priv;
+DELETE FROM mysql.user;
+INSERT mysql.user SELECT * FROM mysql.user_temp;
+INSERT mysql.tables_priv SELECT * FROM mysql.tables_priv_temp;
+DROP TABLE mysql.user_temp;
+DROP TABLE mysql.tables_priv_temp;
+DROP TABLE IF EXISTS test.executors;
+DROP DATABASE IF EXISTS testdb_N;
+DROP DATABASE IF EXISTS testdb_S;
+SET GLOBAL EVENT_SCHEDULER = @ORIG_EVENT_SCHEDULER;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rqg_transactions.result b/storage/rocksdb/mysql-test/rocksdb/r/rqg_transactions.result
new file mode 100644
index 00000000..23705d49
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/rqg_transactions.result
@@ -0,0 +1,11 @@
+call mtr.add_suppression("Deadlock found when trying to get lock");
+CREATE DATABASE IF NOT EXISTS rqg_transactions;
+Running test with grammar file transactions.yy
+Running test with grammar file repeatable_read.yy
+Running test with grammar file transaction_durability.yy
+Running test with grammar file transactions-flat.yy
+Running test with grammar file combinations.yy
+Running test with grammar file repeatable_read.yy
+Running test with grammar file transaction_durability.yy
+Running test with grammar file transactions-flat.yy
+DROP DATABASE rqg_transactions;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/secondary_key_update_lock.result b/storage/rocksdb/mysql-test/rocksdb/r/secondary_key_update_lock.result
new file mode 100644
index 00000000..14217824
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/secondary_key_update_lock.result
@@ -0,0 +1,18 @@
+connect con, localhost, root,,;
+connection default;
+create table t1 (a int primary key, b int unique key) engine = rocksdb;
+insert into t1 values(1, 1);
+connection con;
+begin;
+update t1 set b = 2 where b = 1;
+connection default;
+insert into t1 values(2, 1);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection con;
+rollback;
+select * from t1;
+a b
+1 1
+connection default;
+drop table t1;
+disconnect con;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/select.result b/storage/rocksdb/mysql-test/rocksdb/r/select.result
new file mode 100644
index 00000000..7ea43adc
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/select.result
@@ -0,0 +1,380 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (100,'foobar'),(1,'z'),(200,'bar');
+CREATE TABLE t2 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (a,b) SELECT a, b FROM t1;
+INSERT INTO t1 (a,b) SELECT a, b FROM t2;
+SELECT * FROM t1;
+a b pk
+1 z 2
+1 z 5
+100 foobar 1
+100 foobar 4
+200 bar 3
+200 bar 6
+SELECT DISTINCT a FROM t1;
+a
+1
+100
+200
+SELECT ALL b, a FROM t1;
+b a
+bar 200
+bar 200
+foobar 100
+foobar 100
+z 1
+z 1
+SELECT STRAIGHT_JOIN SQL_CACHE t1.* FROM t2, t1 WHERE t1.a <> t2.a;
+a b pk
+1 z 2
+1 z 2
+1 z 5
+1 z 5
+100 foobar 1
+100 foobar 1
+100 foobar 4
+100 foobar 4
+200 bar 3
+200 bar 3
+200 bar 6
+200 bar 6
+SELECT SQL_SMALL_RESULT SQL_NO_CACHE t1.a FROM t1, t2;
+a
+1
+1
+1
+1
+1
+1
+100
+100
+100
+100
+100
+100
+200
+200
+200
+200
+200
+200
+SELECT SQL_BIG_RESULT SQL_CALC_FOUND_ROWS DISTINCT(t2.a)
+FROM t1 t1_1, t2, t1 t1_2;
+a
+1
+100
+200
+SELECT FOUND_ROWS();
+FOUND_ROWS()
+3
+SET @save_query_cache=@@global.query_cache_size;
+SET GLOBAL query_cache_size = 1024*1024;
+SELECT SQL_CACHE * FROM t1, t2;
+a b pk a b pk
+1 z 2 1 z 2
+1 z 2 100 foobar 1
+1 z 2 200 bar 3
+1 z 5 1 z 2
+1 z 5 100 foobar 1
+1 z 5 200 bar 3
+100 foobar 1 1 z 2
+100 foobar 1 100 foobar 1
+100 foobar 1 200 bar 3
+100 foobar 4 1 z 2
+100 foobar 4 100 foobar 1
+100 foobar 4 200 bar 3
+200 bar 3 1 z 2
+200 bar 3 100 foobar 1
+200 bar 3 200 bar 3
+200 bar 6 1 z 2
+200 bar 6 100 foobar 1
+200 bar 6 200 bar 3
+SET @@global.query_cache_size=@save_query_cache;
+SELECT a+10 AS field1, CONCAT(b,':',b) AS field2 FROM t1
+WHERE b > 'b' AND a IS NOT NULL
+GROUP BY 2 DESC, field1 ASC
+HAVING field1 < 1000
+ORDER BY field2, 1 DESC, field1*2
+LIMIT 5 OFFSET 1;
+field1 field2
+11 z:z
+110 foobar:foobar
+SELECT SUM(a), MAX(a), b FROM t1 GROUP BY b WITH ROLLUP;
+SUM(a) MAX(a) b
+2 1 z
+200 100 foobar
+400 200 bar
+602 200 NULL
+SELECT * FROM t2 WHERE a>0 PROCEDURE ANALYSE();
+Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
+test.t2.a 1 200 1 3 0 0 100.3333 81.2418 ENUM('1','100','200') NOT NULL
+test.t2.b bar z 1 6 0 0 3.3333 NULL ENUM('bar','foobar','z') NOT NULL
+test.t2.pk 1 3 1 1 0 0 2.0000 0.8165 ENUM('1','2','3') NOT NULL
+SELECT t1.a, t2.b FROM t2, t1 WHERE t1.a = t2.a ORDER BY t2.b, t1.a
+INTO OUTFILE '<DATADIR>/select.out'
+CHARACTER SET utf8
+FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '''';
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+200,'bar'
+200,'bar'
+100,'foobar'
+100,'foobar'
+1,'z'
+1,'z'
+SELECT t1.a, t2.b FROM t2, t1 WHERE t1.a = t2.a ORDER BY t2.b, t1.a
+INTO DUMPFILE '<DATADIR>/select.dump';
+ERROR 42000: Result consisted of more than one row
+SELECT t1.*, t2.* FROM t1, t2 ORDER BY t2.b, t1.a, t2.a, t1.b, t1.pk, t2.pk LIMIT 1
+INTO DUMPFILE '<DATADIR>/select.dump';
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+1z2200bar3
+SELECT MIN(a), MAX(a) FROM t1 INTO @min, @max;
+Warnings:
+Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
+SELECT @min, @max;
+@min @max
+1 200
+SELECT t1_1.*, t2.* FROM t2, t1 AS t1_1, t1 AS t1_2
+WHERE t1_1.a = t1_2.a AND t2.a = t1_1.a;
+a b pk a b pk
+1 z 2 1 z 2
+1 z 2 1 z 2
+1 z 5 1 z 2
+1 z 5 1 z 2
+100 foobar 1 100 foobar 1
+100 foobar 1 100 foobar 1
+100 foobar 4 100 foobar 1
+100 foobar 4 100 foobar 1
+200 bar 3 200 bar 3
+200 bar 3 200 bar 3
+200 bar 6 200 bar 3
+200 bar 6 200 bar 3
+SELECT alias1.* FROM ( SELECT a,b FROM t1 ) alias1, t2 WHERE t2.a IN (100,200);
+a b
+1 z
+1 z
+1 z
+1 z
+100 foobar
+100 foobar
+100 foobar
+100 foobar
+200 bar
+200 bar
+200 bar
+200 bar
+SELECT t1.a FROM { OJ t1 LEFT OUTER JOIN t2 ON t1.a = t2.a+10 };
+a
+1
+1
+100
+100
+200
+200
+SELECT t1.* FROM t2 INNER JOIN t1;
+a b pk
+1 z 2
+1 z 2
+1 z 2
+1 z 5
+1 z 5
+1 z 5
+100 foobar 1
+100 foobar 1
+100 foobar 1
+100 foobar 4
+100 foobar 4
+100 foobar 4
+200 bar 3
+200 bar 3
+200 bar 3
+200 bar 6
+200 bar 6
+200 bar 6
+SELECT t1_2.* FROM t1 t1_1 CROSS JOIN t1 t1_2 ON t1_1.b = t1_2.b;
+a b pk
+1 z 2
+1 z 2
+1 z 5
+1 z 5
+100 foobar 1
+100 foobar 1
+100 foobar 4
+100 foobar 4
+200 bar 3
+200 bar 3
+200 bar 6
+200 bar 6
+SELECT t1.a, t2.b FROM t2 STRAIGHT_JOIN t1 WHERE t1.b > t2.b;
+a b
+1 bar
+1 bar
+1 foobar
+1 foobar
+100 bar
+100 bar
+SELECT t1.a, t2.b FROM t2 STRAIGHT_JOIN t1 ON t1.b > t2.b ORDER BY t1.a, t2.b;
+a b
+1 bar
+1 bar
+1 foobar
+1 foobar
+100 bar
+100 bar
+SELECT t2.* FROM t1 LEFT JOIN t2 USING (a) ORDER BY t2.a, t2.b LIMIT 1;
+a b pk
+1 z 2
+SELECT t2.* FROM t2 LEFT OUTER JOIN t1 ON t1.a = t2.a WHERE t1.a IS NOT NULL;
+a b pk
+1 z 2
+1 z 2
+100 foobar 1
+100 foobar 1
+200 bar 3
+200 bar 3
+SELECT SUM(t2.a) FROM t1 RIGHT JOIN t2 ON t2.b = t1.b;
+SUM(t2.a)
+602
+SELECT MIN(t2.a) FROM t1 RIGHT OUTER JOIN t2 USING (b,a);
+MIN(t2.a)
+1
+SELECT alias.b FROM t1 NATURAL JOIN ( SELECT a,b FROM t1 ) alias WHERE b > '';
+b
+bar
+bar
+bar
+bar
+foobar
+foobar
+foobar
+foobar
+z
+z
+z
+z
+SELECT t2.b FROM ( SELECT a,b FROM t1 ) alias NATURAL LEFT JOIN t2 WHERE b IS NOT NULL;
+b
+bar
+bar
+foobar
+foobar
+z
+z
+SELECT t1.*, t2.* FROM t1 NATURAL LEFT OUTER JOIN t2;
+a b pk a b pk
+1 z 2 1 z 2
+1 z 5 NULL NULL NULL
+100 foobar 1 100 foobar 1
+100 foobar 4 NULL NULL NULL
+200 bar 3 200 bar 3
+200 bar 6 NULL NULL NULL
+SELECT t2_2.* FROM t2 t2_1 NATURAL RIGHT JOIN t2 t2_2 WHERE t2_1.a IN ( SELECT a FROM t1 );
+a b pk
+1 z 2
+100 foobar 1
+200 bar 3
+SELECT t1_2.b FROM t1 t1_1 NATURAL RIGHT OUTER JOIN t1 t1_2 INNER JOIN t2;
+b
+bar
+bar
+bar
+bar
+bar
+bar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+z
+z
+z
+z
+z
+z
+SELECT ( SELECT MIN(a) FROM ( SELECT a,b FROM t1 ) alias1 ) AS min_a FROM t2;
+min_a
+1
+1
+1
+SELECT a,b FROM t2 WHERE a = ( SELECT MIN(a) FROM t1 );
+a b
+1 z
+SELECT a,b FROM t2 WHERE b LIKE ( SELECT b FROM t1 ORDER BY b LIMIT 1 );
+a b
+200 bar
+SELECT t2.* FROM t1 t1_outer, t2 WHERE ( t1_outer.a, t2.b ) IN ( SELECT a, b FROM t2 WHERE a = t1_outer.a );
+a b pk
+1 z 2
+1 z 2
+100 foobar 1
+100 foobar 1
+200 bar 3
+200 bar 3
+SELECT a,b FROM t2 WHERE b = ANY ( SELECT b FROM t1 WHERE a > 1 );
+a b
+100 foobar
+200 bar
+SELECT a,b FROM t2 WHERE b > ALL ( SELECT b FROM t1 WHERE b < 'foo' );
+a b
+1 z
+100 foobar
+SELECT a,b FROM t1 WHERE ROW(a, b) = ( SELECT a, b FROM t2 ORDER BY a, b LIMIT 1 );
+a b
+1 z
+1 z
+SELECT a,b FROM t1 WHERE EXISTS ( SELECT a,b FROM t2 WHERE t2.b > t1.b );
+a b
+100 foobar
+100 foobar
+200 bar
+200 bar
+SELECT t1.* FROM t1, t2 ORDER BY ( SELECT b FROM t1 WHERE a IS NULL ORDER BY b LIMIT 1 ) DESC;
+a b pk
+1 z 2
+1 z 2
+1 z 2
+1 z 5
+1 z 5
+1 z 5
+100 foobar 1
+100 foobar 1
+100 foobar 1
+100 foobar 4
+100 foobar 4
+100 foobar 4
+200 bar 3
+200 bar 3
+200 bar 3
+200 bar 6
+200 bar 6
+200 bar 6
+SELECT a, b FROM t1 HAVING a IN ( SELECT a FROM t2 WHERE b = t1.b );
+a b
+1 z
+1 z
+100 foobar
+100 foobar
+200 bar
+200 bar
+SELECT a,b FROM t1 UNION SELECT a,b FROM t2 UNION DISTINCT SELECT a,b FROM t1;
+a b
+1 z
+100 foobar
+200 bar
+SELECT a,b FROM t1 UNION SELECT a,b FROM t2 UNION ALL SELECT a,b FROM t1;
+a b
+1 z
+1 z
+1 z
+100 foobar
+100 foobar
+100 foobar
+200 bar
+200 bar
+200 bar
+DROP TABLE t1, t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/select_for_update.result b/storage/rocksdb/mysql-test/rocksdb/r/select_for_update.result
new file mode 100644
index 00000000..2890941a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/select_for_update.result
@@ -0,0 +1,35 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'a');
+connect con1,localhost,root,,;
+BEGIN;
+SELECT a,b FROM t1 WHERE b='a' FOR UPDATE;
+a b
+1 a
+3 a
+connection default;
+SET lock_wait_timeout = 1;
+SELECT a,b FROM t1 WHERE b='a';
+a b
+1 a
+3 a
+SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t1 SET b='c' WHERE b='a';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection con1;
+COMMIT;
+SELECT a,b FROM t1;
+a b
+1 a
+2 b
+3 a
+disconnect con1;
+connection default;
+UPDATE t1 SET b='c' WHERE b='a';
+SELECT a,b FROM t1;
+a b
+1 c
+2 b
+3 c
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/select_for_update_skip_locked_nowait.result b/storage/rocksdb/mysql-test/rocksdb/r/select_for_update_skip_locked_nowait.result
new file mode 100644
index 00000000..044aa4d6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/select_for_update_skip_locked_nowait.result
@@ -0,0 +1,28 @@
+drop table if exists t1;
+create table t1 (a int primary key) engine=rocksdb;
+insert into t1 values (1), (2), (3);
+Should succeed since no table gets involved
+select 1 for update skip locked;
+1
+1
+select * from nonexistence for update skip locked;
+ERROR 42S02: Table 'test.nonexistence' doesn't exist
+select * from t1 for update skip locked;
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+select * from t1 where a > 1 and a < 3 for update skip locked;
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+insert into t1 select * from t1 for update skip locked;
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+Should succeed since no table gets involved
+select 1 for update nowait;
+1
+1
+select * from nonexistence for update nowait;
+ERROR 42S02: Table 'test.nonexistence' doesn't exist
+select * from t1 for update nowait;
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+select * from t1 where a > 1 and a < 3 for update nowait;
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+insert into t1 select * from t1 for update nowait;
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/select_lock_in_share_mode.result b/storage/rocksdb/mysql-test/rocksdb/r/select_lock_in_share_mode.result
new file mode 100644
index 00000000..b073b887
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/select_lock_in_share_mode.result
@@ -0,0 +1,37 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'a');
+connect con1,localhost,root,,;
+BEGIN;
+SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE;
+a b
+1 a
+3 a
+connection default;
+SET lock_wait_timeout = 1;
+SELECT a,b FROM t1 WHERE b='a';
+a b
+1 a
+3 a
+SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE;
+a b
+1 a
+3 a
+UPDATE t1 SET b='c' WHERE b='a';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection con1;
+COMMIT;
+SELECT a,b FROM t1;
+a b
+1 a
+2 b
+3 a
+disconnect con1;
+connection default;
+UPDATE t1 SET b='c' WHERE b='a';
+SELECT a,b FROM t1;
+a b
+1 c
+2 b
+3 c
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/show_engine.result b/storage/rocksdb/mysql-test/rocksdb/r/show_engine.result
new file mode 100644
index 00000000..eac329a2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/show_engine.result
@@ -0,0 +1,491 @@
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+CREATE TABLE t1 (i INT, PRIMARY KEY (i) COMMENT 'cf_t1') ENGINE = ROCKSDB;
+CREATE TABLE t2 (j INT, PRIMARY KEY (j) COMMENT 'rev:cf_t2') ENGINE = ROCKSDB;
+CREATE TABLE t3 (k INT, PRIMARY KEY (k) COMMENT 'cf_t1') ENGINE = ROCKSDB;
+CREATE TABLE t4 (l INT, PRIMARY KEY (l) COMMENT 'cf_t4') ENGINE = ROCKSDB
+PARTITION BY KEY(l) PARTITIONS 4;
+SET @save.rocksdb_max_background_jobs= @@global.rocksdb_max_background_jobs;
+SET GLOBAL rocksdb_max_background_jobs= 1;
+INSERT INTO t1 VALUES (1), (2), (3);
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+3
+INSERT INTO t2 VALUES (1), (2), (3), (4);
+SELECT COUNT(*) FROM t2;
+COUNT(*)
+4
+INSERT INTO t4 VALUES (1), (2), (3), (4), (5);
+SELECT COUNT(*) FROM t4;
+COUNT(*)
+5
+SET GLOBAL rocksdb_force_flush_memtable_now=1;
+SET GLOBAL rocksdb_compact_cf="cf_t1";
+SHOW ENGINE rocksdb STATUS;
+Type Name Status
+STATISTICS # #
+DBSTATS # #
+CF_COMPACTION # #
+CF_COMPACTION # #
+CF_COMPACTION # #
+CF_COMPACTION # #
+MEMORY_STATS # #
+BG_THREADS # #
+BG_THREADS # #
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_CFSTATS;
+CF_NAME STAT_TYPE VALUE
+__system__ NUM_IMMUTABLE_MEM_TABLE #
+__system__ MEM_TABLE_FLUSH_PENDING #
+__system__ COMPACTION_PENDING #
+__system__ CUR_SIZE_ACTIVE_MEM_TABLE #
+__system__ CUR_SIZE_ALL_MEM_TABLES #
+__system__ NUM_ENTRIES_ACTIVE_MEM_TABLE #
+__system__ NUM_ENTRIES_IMM_MEM_TABLES #
+__system__ NON_BLOCK_CACHE_SST_MEM_USAGE #
+__system__ NUM_LIVE_VERSIONS #
+cf_t1 NUM_IMMUTABLE_MEM_TABLE #
+cf_t1 MEM_TABLE_FLUSH_PENDING #
+cf_t1 COMPACTION_PENDING #
+cf_t1 CUR_SIZE_ACTIVE_MEM_TABLE #
+cf_t1 CUR_SIZE_ALL_MEM_TABLES #
+cf_t1 NUM_ENTRIES_ACTIVE_MEM_TABLE #
+cf_t1 NUM_ENTRIES_IMM_MEM_TABLES #
+cf_t1 NON_BLOCK_CACHE_SST_MEM_USAGE #
+cf_t1 NUM_LIVE_VERSIONS #
+default NUM_IMMUTABLE_MEM_TABLE #
+default MEM_TABLE_FLUSH_PENDING #
+default COMPACTION_PENDING #
+default CUR_SIZE_ACTIVE_MEM_TABLE #
+default CUR_SIZE_ALL_MEM_TABLES #
+default NUM_ENTRIES_ACTIVE_MEM_TABLE #
+default NUM_ENTRIES_IMM_MEM_TABLES #
+default NON_BLOCK_CACHE_SST_MEM_USAGE #
+default NUM_LIVE_VERSIONS #
+rev:cf_t2 NUM_IMMUTABLE_MEM_TABLE #
+rev:cf_t2 MEM_TABLE_FLUSH_PENDING #
+rev:cf_t2 COMPACTION_PENDING #
+rev:cf_t2 CUR_SIZE_ACTIVE_MEM_TABLE #
+rev:cf_t2 CUR_SIZE_ALL_MEM_TABLES #
+rev:cf_t2 NUM_ENTRIES_ACTIVE_MEM_TABLE #
+rev:cf_t2 NUM_ENTRIES_IMM_MEM_TABLES #
+rev:cf_t2 NON_BLOCK_CACHE_SST_MEM_USAGE #
+rev:cf_t2 NUM_LIVE_VERSIONS #
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_DBSTATS;
+STAT_TYPE VALUE
+DB_BACKGROUND_ERRORS #
+DB_NUM_SNAPSHOTS #
+DB_OLDEST_SNAPSHOT_TIME #
+DB_BLOCK_CACHE_USAGE #
+SELECT TABLE_SCHEMA, TABLE_NAME, PARTITION_NAME, COUNT(STAT_TYPE)
+FROM INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT
+WHERE TABLE_SCHEMA = 'test'
+GROUP BY TABLE_NAME, PARTITION_NAME;
+TABLE_SCHEMA TABLE_NAME PARTITION_NAME COUNT(STAT_TYPE)
+test t1 NULL 57
+test t2 NULL 57
+test t4 p0 57
+test t4 p1 57
+test t4 p2 57
+test t4 p3 57
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_CF_OPTIONS;
+CF_NAME OPTION_TYPE VALUE
+__system__ COMPARATOR #
+__system__ MERGE_OPERATOR #
+__system__ COMPACTION_FILTER #
+__system__ COMPACTION_FILTER_FACTORY #
+__system__ WRITE_BUFFER_SIZE #
+__system__ MAX_WRITE_BUFFER_NUMBER #
+__system__ MIN_WRITE_BUFFER_NUMBER_TO_MERGE #
+__system__ NUM_LEVELS #
+__system__ LEVEL0_FILE_NUM_COMPACTION_TRIGGER #
+__system__ LEVEL0_SLOWDOWN_WRITES_TRIGGER #
+__system__ LEVEL0_STOP_WRITES_TRIGGER #
+__system__ MAX_MEM_COMPACTION_LEVEL #
+__system__ TARGET_FILE_SIZE_BASE #
+__system__ TARGET_FILE_SIZE_MULTIPLIER #
+__system__ MAX_BYTES_FOR_LEVEL_BASE #
+__system__ LEVEL_COMPACTION_DYNAMIC_LEVEL_BYTES #
+__system__ MAX_BYTES_FOR_LEVEL_MULTIPLIER #
+__system__ SOFT_RATE_LIMIT #
+__system__ HARD_RATE_LIMIT #
+__system__ RATE_LIMIT_DELAY_MAX_MILLISECONDS #
+__system__ ARENA_BLOCK_SIZE #
+__system__ DISABLE_AUTO_COMPACTIONS #
+__system__ PURGE_REDUNDANT_KVS_WHILE_FLUSH #
+__system__ MAX_SEQUENTIAL_SKIP_IN_ITERATIONS #
+__system__ MEMTABLE_FACTORY #
+__system__ INPLACE_UPDATE_SUPPORT #
+__system__ INPLACE_UPDATE_NUM_LOCKS #
+__system__ MEMTABLE_PREFIX_BLOOM_BITS_RATIO #
+__system__ MEMTABLE_PREFIX_BLOOM_HUGE_PAGE_TLB_SIZE #
+__system__ BLOOM_LOCALITY #
+__system__ MAX_SUCCESSIVE_MERGES #
+__system__ OPTIMIZE_FILTERS_FOR_HITS #
+__system__ MAX_BYTES_FOR_LEVEL_MULTIPLIER_ADDITIONAL #
+__system__ COMPRESSION_TYPE #
+__system__ COMPRESSION_PER_LEVEL #
+__system__ COMPRESSION_OPTS #
+__system__ BOTTOMMOST_COMPRESSION #
+__system__ PREFIX_EXTRACTOR #
+__system__ COMPACTION_STYLE #
+__system__ COMPACTION_OPTIONS_UNIVERSAL #
+__system__ COMPACTION_OPTION_FIFO::MAX_TABLE_FILES_SIZE #
+__system__ TABLE_FACTORY::FLUSH_BLOCK_POLICY_FACTORY #
+__system__ TABLE_FACTORY::CACHE_INDEX_AND_FILTER_BLOCKS #
+__system__ TABLE_FACTORY::CACHE_INDEX_AND_FILTER_BLOCKS_WITH_HIGH_PRIORITY #
+__system__ TABLE_FACTORY::PIN_L0_FILTER_AND_INDEX_BLOCKS_IN_CACHE #
+__system__ TABLE_FACTORY::PIN_TOP_LEVEL_INDEX_AND_FILTER #
+__system__ TABLE_FACTORY::INDEX_TYPE #
+__system__ TABLE_FACTORY::DATA_BLOCK_INDEX_TYPE #
+__system__ TABLE_FACTORY::INDEX_SHORTENING #
+__system__ TABLE_FACTORY::DATA_BLOCK_HASH_TABLE_UTIL_RATIO #
+__system__ TABLE_FACTORY::HASH_INDEX_ALLOW_COLLISION #
+__system__ TABLE_FACTORY::CHECKSUM #
+__system__ TABLE_FACTORY::NO_BLOCK_CACHE #
+__system__ TABLE_FACTORY::BLOCK_CACHE #
+__system__ TABLE_FACTORY::BLOCK_CACHE_NAME #
+__system__ TABLE_FACTORY::BLOCK_CACHE_OPTIONS #
+__system__ TABLE_FACTORY::CAPACITY #
+__system__ TABLE_FACTORY::NUM_SHARD_BITS #
+__system__ TABLE_FACTORY::STRICT_CAPACITY_LIMIT #
+__system__ TABLE_FACTORY::MEMORY_ALLOCATOR #
+__system__ TABLE_FACTORY::HIGH_PRI_POOL_RATIO #
+__system__ TABLE_FACTORY::BLOCK_CACHE_COMPRESSED #
+__system__ TABLE_FACTORY::PERSISTENT_CACHE #
+__system__ TABLE_FACTORY::BLOCK_SIZE #
+__system__ TABLE_FACTORY::BLOCK_SIZE_DEVIATION #
+__system__ TABLE_FACTORY::BLOCK_RESTART_INTERVAL #
+__system__ TABLE_FACTORY::INDEX_BLOCK_RESTART_INTERVAL #
+__system__ TABLE_FACTORY::METADATA_BLOCK_SIZE #
+__system__ TABLE_FACTORY::PARTITION_FILTERS #
+__system__ TABLE_FACTORY::USE_DELTA_ENCODING #
+__system__ TABLE_FACTORY::FILTER_POLICY #
+__system__ TABLE_FACTORY::WHOLE_KEY_FILTERING #
+__system__ TABLE_FACTORY::VERIFY_COMPRESSION #
+__system__ TABLE_FACTORY::READ_AMP_BYTES_PER_BIT #
+__system__ TABLE_FACTORY::FORMAT_VERSION #
+__system__ TABLE_FACTORY::ENABLE_INDEX_COMPRESSION #
+__system__ TABLE_FACTORY::BLOCK_ALIGN #
+cf_t1 COMPARATOR #
+cf_t1 MERGE_OPERATOR #
+cf_t1 COMPACTION_FILTER #
+cf_t1 COMPACTION_FILTER_FACTORY #
+cf_t1 WRITE_BUFFER_SIZE #
+cf_t1 MAX_WRITE_BUFFER_NUMBER #
+cf_t1 MIN_WRITE_BUFFER_NUMBER_TO_MERGE #
+cf_t1 NUM_LEVELS #
+cf_t1 LEVEL0_FILE_NUM_COMPACTION_TRIGGER #
+cf_t1 LEVEL0_SLOWDOWN_WRITES_TRIGGER #
+cf_t1 LEVEL0_STOP_WRITES_TRIGGER #
+cf_t1 MAX_MEM_COMPACTION_LEVEL #
+cf_t1 TARGET_FILE_SIZE_BASE #
+cf_t1 TARGET_FILE_SIZE_MULTIPLIER #
+cf_t1 MAX_BYTES_FOR_LEVEL_BASE #
+cf_t1 LEVEL_COMPACTION_DYNAMIC_LEVEL_BYTES #
+cf_t1 MAX_BYTES_FOR_LEVEL_MULTIPLIER #
+cf_t1 SOFT_RATE_LIMIT #
+cf_t1 HARD_RATE_LIMIT #
+cf_t1 RATE_LIMIT_DELAY_MAX_MILLISECONDS #
+cf_t1 ARENA_BLOCK_SIZE #
+cf_t1 DISABLE_AUTO_COMPACTIONS #
+cf_t1 PURGE_REDUNDANT_KVS_WHILE_FLUSH #
+cf_t1 MAX_SEQUENTIAL_SKIP_IN_ITERATIONS #
+cf_t1 MEMTABLE_FACTORY #
+cf_t1 INPLACE_UPDATE_SUPPORT #
+cf_t1 INPLACE_UPDATE_NUM_LOCKS #
+cf_t1 MEMTABLE_PREFIX_BLOOM_BITS_RATIO #
+cf_t1 MEMTABLE_PREFIX_BLOOM_HUGE_PAGE_TLB_SIZE #
+cf_t1 BLOOM_LOCALITY #
+cf_t1 MAX_SUCCESSIVE_MERGES #
+cf_t1 OPTIMIZE_FILTERS_FOR_HITS #
+cf_t1 MAX_BYTES_FOR_LEVEL_MULTIPLIER_ADDITIONAL #
+cf_t1 COMPRESSION_TYPE #
+cf_t1 COMPRESSION_PER_LEVEL #
+cf_t1 COMPRESSION_OPTS #
+cf_t1 BOTTOMMOST_COMPRESSION #
+cf_t1 PREFIX_EXTRACTOR #
+cf_t1 COMPACTION_STYLE #
+cf_t1 COMPACTION_OPTIONS_UNIVERSAL #
+cf_t1 COMPACTION_OPTION_FIFO::MAX_TABLE_FILES_SIZE #
+cf_t1 TABLE_FACTORY::FLUSH_BLOCK_POLICY_FACTORY #
+cf_t1 TABLE_FACTORY::CACHE_INDEX_AND_FILTER_BLOCKS #
+cf_t1 TABLE_FACTORY::CACHE_INDEX_AND_FILTER_BLOCKS_WITH_HIGH_PRIORITY #
+cf_t1 TABLE_FACTORY::PIN_L0_FILTER_AND_INDEX_BLOCKS_IN_CACHE #
+cf_t1 TABLE_FACTORY::PIN_TOP_LEVEL_INDEX_AND_FILTER #
+cf_t1 TABLE_FACTORY::INDEX_TYPE #
+cf_t1 TABLE_FACTORY::DATA_BLOCK_INDEX_TYPE #
+cf_t1 TABLE_FACTORY::INDEX_SHORTENING #
+cf_t1 TABLE_FACTORY::DATA_BLOCK_HASH_TABLE_UTIL_RATIO #
+cf_t1 TABLE_FACTORY::HASH_INDEX_ALLOW_COLLISION #
+cf_t1 TABLE_FACTORY::CHECKSUM #
+cf_t1 TABLE_FACTORY::NO_BLOCK_CACHE #
+cf_t1 TABLE_FACTORY::BLOCK_CACHE #
+cf_t1 TABLE_FACTORY::BLOCK_CACHE_NAME #
+cf_t1 TABLE_FACTORY::BLOCK_CACHE_OPTIONS #
+cf_t1 TABLE_FACTORY::CAPACITY #
+cf_t1 TABLE_FACTORY::NUM_SHARD_BITS #
+cf_t1 TABLE_FACTORY::STRICT_CAPACITY_LIMIT #
+cf_t1 TABLE_FACTORY::MEMORY_ALLOCATOR #
+cf_t1 TABLE_FACTORY::HIGH_PRI_POOL_RATIO #
+cf_t1 TABLE_FACTORY::BLOCK_CACHE_COMPRESSED #
+cf_t1 TABLE_FACTORY::PERSISTENT_CACHE #
+cf_t1 TABLE_FACTORY::BLOCK_SIZE #
+cf_t1 TABLE_FACTORY::BLOCK_SIZE_DEVIATION #
+cf_t1 TABLE_FACTORY::BLOCK_RESTART_INTERVAL #
+cf_t1 TABLE_FACTORY::INDEX_BLOCK_RESTART_INTERVAL #
+cf_t1 TABLE_FACTORY::METADATA_BLOCK_SIZE #
+cf_t1 TABLE_FACTORY::PARTITION_FILTERS #
+cf_t1 TABLE_FACTORY::USE_DELTA_ENCODING #
+cf_t1 TABLE_FACTORY::FILTER_POLICY #
+cf_t1 TABLE_FACTORY::WHOLE_KEY_FILTERING #
+cf_t1 TABLE_FACTORY::VERIFY_COMPRESSION #
+cf_t1 TABLE_FACTORY::READ_AMP_BYTES_PER_BIT #
+cf_t1 TABLE_FACTORY::FORMAT_VERSION #
+cf_t1 TABLE_FACTORY::ENABLE_INDEX_COMPRESSION #
+cf_t1 TABLE_FACTORY::BLOCK_ALIGN #
+default COMPARATOR #
+default MERGE_OPERATOR #
+default COMPACTION_FILTER #
+default COMPACTION_FILTER_FACTORY #
+default WRITE_BUFFER_SIZE #
+default MAX_WRITE_BUFFER_NUMBER #
+default MIN_WRITE_BUFFER_NUMBER_TO_MERGE #
+default NUM_LEVELS #
+default LEVEL0_FILE_NUM_COMPACTION_TRIGGER #
+default LEVEL0_SLOWDOWN_WRITES_TRIGGER #
+default LEVEL0_STOP_WRITES_TRIGGER #
+default MAX_MEM_COMPACTION_LEVEL #
+default TARGET_FILE_SIZE_BASE #
+default TARGET_FILE_SIZE_MULTIPLIER #
+default MAX_BYTES_FOR_LEVEL_BASE #
+default LEVEL_COMPACTION_DYNAMIC_LEVEL_BYTES #
+default MAX_BYTES_FOR_LEVEL_MULTIPLIER #
+default SOFT_RATE_LIMIT #
+default HARD_RATE_LIMIT #
+default RATE_LIMIT_DELAY_MAX_MILLISECONDS #
+default ARENA_BLOCK_SIZE #
+default DISABLE_AUTO_COMPACTIONS #
+default PURGE_REDUNDANT_KVS_WHILE_FLUSH #
+default MAX_SEQUENTIAL_SKIP_IN_ITERATIONS #
+default MEMTABLE_FACTORY #
+default INPLACE_UPDATE_SUPPORT #
+default INPLACE_UPDATE_NUM_LOCKS #
+default MEMTABLE_PREFIX_BLOOM_BITS_RATIO #
+default MEMTABLE_PREFIX_BLOOM_HUGE_PAGE_TLB_SIZE #
+default BLOOM_LOCALITY #
+default MAX_SUCCESSIVE_MERGES #
+default OPTIMIZE_FILTERS_FOR_HITS #
+default MAX_BYTES_FOR_LEVEL_MULTIPLIER_ADDITIONAL #
+default COMPRESSION_TYPE #
+default COMPRESSION_PER_LEVEL #
+default COMPRESSION_OPTS #
+default BOTTOMMOST_COMPRESSION #
+default PREFIX_EXTRACTOR #
+default COMPACTION_STYLE #
+default COMPACTION_OPTIONS_UNIVERSAL #
+default COMPACTION_OPTION_FIFO::MAX_TABLE_FILES_SIZE #
+default TABLE_FACTORY::FLUSH_BLOCK_POLICY_FACTORY #
+default TABLE_FACTORY::CACHE_INDEX_AND_FILTER_BLOCKS #
+default TABLE_FACTORY::CACHE_INDEX_AND_FILTER_BLOCKS_WITH_HIGH_PRIORITY #
+default TABLE_FACTORY::PIN_L0_FILTER_AND_INDEX_BLOCKS_IN_CACHE #
+default TABLE_FACTORY::PIN_TOP_LEVEL_INDEX_AND_FILTER #
+default TABLE_FACTORY::INDEX_TYPE #
+default TABLE_FACTORY::DATA_BLOCK_INDEX_TYPE #
+default TABLE_FACTORY::INDEX_SHORTENING #
+default TABLE_FACTORY::DATA_BLOCK_HASH_TABLE_UTIL_RATIO #
+default TABLE_FACTORY::HASH_INDEX_ALLOW_COLLISION #
+default TABLE_FACTORY::CHECKSUM #
+default TABLE_FACTORY::NO_BLOCK_CACHE #
+default TABLE_FACTORY::BLOCK_CACHE #
+default TABLE_FACTORY::BLOCK_CACHE_NAME #
+default TABLE_FACTORY::BLOCK_CACHE_OPTIONS #
+default TABLE_FACTORY::CAPACITY #
+default TABLE_FACTORY::NUM_SHARD_BITS #
+default TABLE_FACTORY::STRICT_CAPACITY_LIMIT #
+default TABLE_FACTORY::MEMORY_ALLOCATOR #
+default TABLE_FACTORY::HIGH_PRI_POOL_RATIO #
+default TABLE_FACTORY::BLOCK_CACHE_COMPRESSED #
+default TABLE_FACTORY::PERSISTENT_CACHE #
+default TABLE_FACTORY::BLOCK_SIZE #
+default TABLE_FACTORY::BLOCK_SIZE_DEVIATION #
+default TABLE_FACTORY::BLOCK_RESTART_INTERVAL #
+default TABLE_FACTORY::INDEX_BLOCK_RESTART_INTERVAL #
+default TABLE_FACTORY::METADATA_BLOCK_SIZE #
+default TABLE_FACTORY::PARTITION_FILTERS #
+default TABLE_FACTORY::USE_DELTA_ENCODING #
+default TABLE_FACTORY::FILTER_POLICY #
+default TABLE_FACTORY::WHOLE_KEY_FILTERING #
+default TABLE_FACTORY::VERIFY_COMPRESSION #
+default TABLE_FACTORY::READ_AMP_BYTES_PER_BIT #
+default TABLE_FACTORY::FORMAT_VERSION #
+default TABLE_FACTORY::ENABLE_INDEX_COMPRESSION #
+default TABLE_FACTORY::BLOCK_ALIGN #
+rev:cf_t2 COMPARATOR #
+rev:cf_t2 MERGE_OPERATOR #
+rev:cf_t2 COMPACTION_FILTER #
+rev:cf_t2 COMPACTION_FILTER_FACTORY #
+rev:cf_t2 WRITE_BUFFER_SIZE #
+rev:cf_t2 MAX_WRITE_BUFFER_NUMBER #
+rev:cf_t2 MIN_WRITE_BUFFER_NUMBER_TO_MERGE #
+rev:cf_t2 NUM_LEVELS #
+rev:cf_t2 LEVEL0_FILE_NUM_COMPACTION_TRIGGER #
+rev:cf_t2 LEVEL0_SLOWDOWN_WRITES_TRIGGER #
+rev:cf_t2 LEVEL0_STOP_WRITES_TRIGGER #
+rev:cf_t2 MAX_MEM_COMPACTION_LEVEL #
+rev:cf_t2 TARGET_FILE_SIZE_BASE #
+rev:cf_t2 TARGET_FILE_SIZE_MULTIPLIER #
+rev:cf_t2 MAX_BYTES_FOR_LEVEL_BASE #
+rev:cf_t2 LEVEL_COMPACTION_DYNAMIC_LEVEL_BYTES #
+rev:cf_t2 MAX_BYTES_FOR_LEVEL_MULTIPLIER #
+rev:cf_t2 SOFT_RATE_LIMIT #
+rev:cf_t2 HARD_RATE_LIMIT #
+rev:cf_t2 RATE_LIMIT_DELAY_MAX_MILLISECONDS #
+rev:cf_t2 ARENA_BLOCK_SIZE #
+rev:cf_t2 DISABLE_AUTO_COMPACTIONS #
+rev:cf_t2 PURGE_REDUNDANT_KVS_WHILE_FLUSH #
+rev:cf_t2 MAX_SEQUENTIAL_SKIP_IN_ITERATIONS #
+rev:cf_t2 MEMTABLE_FACTORY #
+rev:cf_t2 INPLACE_UPDATE_SUPPORT #
+rev:cf_t2 INPLACE_UPDATE_NUM_LOCKS #
+rev:cf_t2 MEMTABLE_PREFIX_BLOOM_BITS_RATIO #
+rev:cf_t2 MEMTABLE_PREFIX_BLOOM_HUGE_PAGE_TLB_SIZE #
+rev:cf_t2 BLOOM_LOCALITY #
+rev:cf_t2 MAX_SUCCESSIVE_MERGES #
+rev:cf_t2 OPTIMIZE_FILTERS_FOR_HITS #
+rev:cf_t2 MAX_BYTES_FOR_LEVEL_MULTIPLIER_ADDITIONAL #
+rev:cf_t2 COMPRESSION_TYPE #
+rev:cf_t2 COMPRESSION_PER_LEVEL #
+rev:cf_t2 COMPRESSION_OPTS #
+rev:cf_t2 BOTTOMMOST_COMPRESSION #
+rev:cf_t2 PREFIX_EXTRACTOR #
+rev:cf_t2 COMPACTION_STYLE #
+rev:cf_t2 COMPACTION_OPTIONS_UNIVERSAL #
+rev:cf_t2 COMPACTION_OPTION_FIFO::MAX_TABLE_FILES_SIZE #
+rev:cf_t2 TABLE_FACTORY::FLUSH_BLOCK_POLICY_FACTORY #
+rev:cf_t2 TABLE_FACTORY::CACHE_INDEX_AND_FILTER_BLOCKS #
+rev:cf_t2 TABLE_FACTORY::CACHE_INDEX_AND_FILTER_BLOCKS_WITH_HIGH_PRIORITY #
+rev:cf_t2 TABLE_FACTORY::PIN_L0_FILTER_AND_INDEX_BLOCKS_IN_CACHE #
+rev:cf_t2 TABLE_FACTORY::PIN_TOP_LEVEL_INDEX_AND_FILTER #
+rev:cf_t2 TABLE_FACTORY::INDEX_TYPE #
+rev:cf_t2 TABLE_FACTORY::DATA_BLOCK_INDEX_TYPE #
+rev:cf_t2 TABLE_FACTORY::INDEX_SHORTENING #
+rev:cf_t2 TABLE_FACTORY::DATA_BLOCK_HASH_TABLE_UTIL_RATIO #
+rev:cf_t2 TABLE_FACTORY::HASH_INDEX_ALLOW_COLLISION #
+rev:cf_t2 TABLE_FACTORY::CHECKSUM #
+rev:cf_t2 TABLE_FACTORY::NO_BLOCK_CACHE #
+rev:cf_t2 TABLE_FACTORY::BLOCK_CACHE #
+rev:cf_t2 TABLE_FACTORY::BLOCK_CACHE_NAME #
+rev:cf_t2 TABLE_FACTORY::BLOCK_CACHE_OPTIONS #
+rev:cf_t2 TABLE_FACTORY::CAPACITY #
+rev:cf_t2 TABLE_FACTORY::NUM_SHARD_BITS #
+rev:cf_t2 TABLE_FACTORY::STRICT_CAPACITY_LIMIT #
+rev:cf_t2 TABLE_FACTORY::MEMORY_ALLOCATOR #
+rev:cf_t2 TABLE_FACTORY::HIGH_PRI_POOL_RATIO #
+rev:cf_t2 TABLE_FACTORY::BLOCK_CACHE_COMPRESSED #
+rev:cf_t2 TABLE_FACTORY::PERSISTENT_CACHE #
+rev:cf_t2 TABLE_FACTORY::BLOCK_SIZE #
+rev:cf_t2 TABLE_FACTORY::BLOCK_SIZE_DEVIATION #
+rev:cf_t2 TABLE_FACTORY::BLOCK_RESTART_INTERVAL #
+rev:cf_t2 TABLE_FACTORY::INDEX_BLOCK_RESTART_INTERVAL #
+rev:cf_t2 TABLE_FACTORY::METADATA_BLOCK_SIZE #
+rev:cf_t2 TABLE_FACTORY::PARTITION_FILTERS #
+rev:cf_t2 TABLE_FACTORY::USE_DELTA_ENCODING #
+rev:cf_t2 TABLE_FACTORY::FILTER_POLICY #
+rev:cf_t2 TABLE_FACTORY::WHOLE_KEY_FILTERING #
+rev:cf_t2 TABLE_FACTORY::VERIFY_COMPRESSION #
+rev:cf_t2 TABLE_FACTORY::READ_AMP_BYTES_PER_BIT #
+rev:cf_t2 TABLE_FACTORY::FORMAT_VERSION #
+rev:cf_t2 TABLE_FACTORY::ENABLE_INDEX_COMPRESSION #
+rev:cf_t2 TABLE_FACTORY::BLOCK_ALIGN #
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
+SHOW ENGINE rocksdb MUTEX;
+Type Name Status
+SHOW ENGINE ALL MUTEX;
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+----------LATEST DETECTED DEADLOCKS----------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+Type Name Status
+rocksdb
+============================================================
+TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT
+============================================================
+---------
+SNAPSHOTS
+---------
+LIST OF SNAPSHOTS FOR EACH SESSION:
+---SNAPSHOT, ACTIVE NUM sec
+MySQL thread id TID, OS thread handle PTR, query id QID localhost root ACTION
+SHOW ENGINE rocksdb TRANSACTION STATUS
+lock count 0, write count 0
+insert count 0, update count 0, delete count 0
+----------LATEST DETECTED DEADLOCKS----------
+-----------------------------------------
+END OF ROCKSDB TRANSACTION MONITOR OUTPUT
+=========================================
+
+ROLLBACK;
+START TRANSACTION WITH SHARED ROCKSDB SNAPSHOT;
+File Position Gtid_executed Snapshot_ID
+ 0 1
+SHOW ENGINE rocksdb STATUS;
+Type Name Status
+STATISTICS # #
+DBSTATS # #
+CF_COMPACTION # #
+CF_COMPACTION # #
+CF_COMPACTION # #
+CF_COMPACTION # #
+MEMORY_STATS # #
+BG_THREADS # #
+BG_THREADS # #
+EXPLICIT_SNAPSHOTS # #
+ROLLBACK;
+CREATE EXPLICIT rocksdb SNAPSHOT;
+File Position Gtid_executed Snapshot_ID
+ 0 2
+SHOW ENGINE rocksdb STATUS;
+Type Name Status
+STATISTICS # #
+DBSTATS # #
+CF_COMPACTION # #
+CF_COMPACTION # #
+CF_COMPACTION # #
+CF_COMPACTION # #
+MEMORY_STATS # #
+BG_THREADS # #
+BG_THREADS # #
+EXPLICIT_SNAPSHOTS # #
+RELEASE EXPLICIT rocksdb SNAPSHOT;
+File Position Gtid_executed Snapshot_ID
+ 0 2
+SHOW ENGINE rocksdb STATUS;
+Type Name Status
+STATISTICS # #
+DBSTATS # #
+CF_COMPACTION # #
+CF_COMPACTION # #
+CF_COMPACTION # #
+CF_COMPACTION # #
+MEMORY_STATS # #
+BG_THREADS # #
+BG_THREADS # #
+SET GLOBAL rocksdb_max_background_jobs= @save.rocksdb_max_background_jobs;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/show_table_status.result b/storage/rocksdb/mysql-test/rocksdb/r/show_table_status.result
new file mode 100644
index 00000000..139d323b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/show_table_status.result
@@ -0,0 +1,136 @@
+DROP TABLE IF EXISTS t1, t2, t3;
+CREATE TABLE t1 (a INT, b CHAR(8) PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (100,'a'),(2,'foo');
+CREATE TABLE t2 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t2 (a,b) VALUES (1,'bar');
+set global rocksdb_force_flush_memtable_now = true;
+CREATE TABLE t3 (a INT, b CHAR(8), pk INT PRIMARY KEY) ENGINE=rocksdb CHARACTER SET utf8;
+SHOW TABLE STATUS WHERE name IN ( 't1', 't2', 't3' );
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL latin1_swedish_ci NULL 0 N
+t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL latin1_swedish_ci NULL 0 N
+t3 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL utf8_general_ci NULL 0 N
+SHOW TABLE STATUS WHERE name LIKE 't2';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL latin1_swedish_ci NULL 0 N
+DROP TABLE t1, t2, t3;
+CREATE DATABASE `db_new..............................................end`;
+USE `db_new..............................................end`;
+CREATE TABLE `t1_new..............................................end`(a int) engine=rocksdb;
+INSERT INTO `t1_new..............................................end` VALUES (1);
+SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.table_statistics WHERE TABLE_NAME = 't1_new..............................................end';
+TABLE_SCHEMA db_new..............................................end
+TABLE_NAME t1_new..............................................end
+DROP DATABASE `db_new..............................................end`;
+#
+# MDEV-17171: Bug: RocksDB Tables do not have "Creation Date"
+#
+use test;
+create table t1 (a int) engine=rocksdb;
+select create_time is not null, update_time, check_time
+from information_schema.tables where table_schema=database() and table_name='t1';
+create_time is not null update_time check_time
+1 NULL NULL
+insert into t1 values (1);
+select create_time is not null, update_time is not null, check_time
+from information_schema.tables where table_schema=database() and table_name='t1';
+create_time is not null update_time is not null check_time
+1 1 NULL
+flush tables;
+select create_time is not null, update_time is not null, check_time
+from information_schema.tables where table_schema=database() and table_name='t1';
+create_time is not null update_time is not null check_time
+1 1 NULL
+select create_time, update_time into @create_tm, @update_tm
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+select sleep(3);
+sleep(3)
+0
+insert into t1 values (2);
+select
+create_time=@create_tm /* should not change */ ,
+timestampdiff(second, @update_tm, update_time) > 2,
+check_time
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+create_time=@create_tm 1
+timestampdiff(second, @update_tm, update_time) > 2 1
+check_time NULL
+#
+# Check how create_time survives ALTER TABLE.
+# First, an ALTER TABLE that re-creates the table:
+alter table t1 add b int;
+select
+create_time<>@create_tm /* should change */,
+create_time IS NOT NULL,
+update_time IS NULL
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+create_time<>@create_tm 1
+create_time IS NOT NULL 1
+update_time IS NULL 1
+insert into t1 values (5,5);
+select create_time, update_time into @create_tm, @update_tm
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+# Then, an in-place ALTER TABLE:
+select sleep(2);
+sleep(2) 0
+alter table t1 add key (a);
+# create_time will change as .frm file is rewritten:
+select
+create_time=@create_tm,
+update_time
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+create_time=@create_tm 0
+update_time NULL
+# Check TRUNCATE TABLE
+insert into t1 values (10,10);
+select create_time, update_time into @create_tm, @update_tm
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+select sleep(2);
+sleep(2) 0
+truncate table t1;
+select
+create_time=@create_tm /* should not change */,
+update_time
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+create_time=@create_tm 1
+update_time NULL
+#
+# Check what is left after server restart
+#
+drop table t1;
+create table t1 (a int);
+insert into t1 values (1);
+# Save t1's creation time
+create table t2 as
+select create_time
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+select sleep(2);
+sleep(2) 0
+# restart
+select
+create_time=(select create_time from t2) /* should not change */,
+update_time
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+create_time=(select create_time from t2) 1
+update_time NULL
+drop table t1, t2;
+#
+# Check how it works for partitioned tables
+#
+create table t1 (pk int primary key) partition by hash(pk) partitions 2;
+insert into t1 values (1);
+select create_time IS NOT NULL , update_time IS NOT NULL
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+create_time IS NOT NULL 1
+update_time IS NOT NULL 1
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/shutdown.result b/storage/rocksdb/mysql-test/rocksdb/r/shutdown.result
new file mode 100644
index 00000000..f40aceff
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/shutdown.result
@@ -0,0 +1,9 @@
+DROP TABLE IF EXISTS t1;
+SHOW GLOBAL VARIABLES LIKE "log_bin";
+Variable_name Value
+log_bin ON
+CREATE TABLE t1 (i INT, PRIMARY KEY (i) COMMENT 'cf_t1') ENGINE = ROCKSDB;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1000
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/singledelete.result b/storage/rocksdb/mysql-test/rocksdb/r/singledelete.result
new file mode 100644
index 00000000..da29f325
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/singledelete.result
@@ -0,0 +1,86 @@
+CREATE TABLE t1 (id INT, value int, PRIMARY KEY (id), INDEX (value)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1,1);
+select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+optimize table t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+select case when variable_value-@s > 5 and variable_value-@s < 100 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+case when variable_value-@s > 5 and variable_value-@s < 100 then 'true' else 'false' end
+true
+select case when variable_value-@d < 10 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+case when variable_value-@d < 10 then 'true' else 'false' end
+true
+CREATE TABLE t2 (id INT, value int, PRIMARY KEY (id), INDEX (value)) ENGINE=RocksDB;
+INSERT INTO t2 VALUES (1,1);
+select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+optimize table t2;
+Table Op Msg_type Msg_text
+test.t2 optimize status OK
+select case when variable_value-@s > 5 and variable_value-@s < 100 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+case when variable_value-@s > 5 and variable_value-@s < 100 then 'true' else 'false' end
+true
+select case when variable_value-@d > 9000 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+case when variable_value-@d > 9000 then 'true' else 'false' end
+true
+CREATE TABLE t3 (id INT, value int, PRIMARY KEY (id)) ENGINE=RocksDB;
+INSERT INTO t3 VALUES (1,1);
+select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+optimize table t3;
+Table Op Msg_type Msg_text
+test.t3 optimize status OK
+select case when variable_value-@s = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+case when variable_value-@s = 0 then 'true' else 'false' end
+true
+select case when variable_value-@d > 9000 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+case when variable_value-@d > 9000 then 'true' else 'false' end
+true
+CREATE TABLE t4 (id INT, PRIMARY KEY (id)) ENGINE=RocksDB;
+INSERT INTO t4 VALUES (1);
+select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+optimize table t4;
+Table Op Msg_type Msg_text
+test.t4 optimize status OK
+select case when variable_value-@s > 5 and variable_value-@s < 100 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+case when variable_value-@s > 5 and variable_value-@s < 100 then 'true' else 'false' end
+true
+select case when variable_value-@d < 10 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+case when variable_value-@d < 10 then 'true' else 'false' end
+true
+CREATE TABLE t5 (id1 INT, id2 INT, PRIMARY KEY (id1, id2), INDEX(id2)) ENGINE=RocksDB;
+INSERT INTO t5 VALUES (1, 1);
+select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+optimize table t5;
+Table Op Msg_type Msg_text
+test.t5 optimize status OK
+select case when variable_value-@s > 5 and variable_value-@s < 100 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+case when variable_value-@s > 5 and variable_value-@s < 100 then 'true' else 'false' end
+true
+select case when variable_value-@d < 10 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+case when variable_value-@d < 10 then 'true' else 'false' end
+true
+CREATE TABLE t6 (
+pk VARCHAR(64) COLLATE latin1_swedish_ci PRIMARY KEY
+) ENGINE=RocksDB;
+INSERT INTO t6 VALUES ('a');
+SET GLOBAL rocksdb_force_flush_memtable_now=1;
+SELECT * FROM t6;
+pk
+a
+UPDATE t6 SET pk='A' WHERE pk='a';
+SELECT * FROM t6;
+pk
+A
+DELETE FROM t6 where pk='A';
+SELECT should return nothing;
+SELECT * FROM t6;
+pk
+SET GLOBAL rocksdb_force_flush_memtable_now=1;
+SELECT should return nothing;
+SELECT * FROM t6;
+pk
+DROP TABLE t1, t2, t3, t4, t5, t6;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/skip_core_dump_on_error.result b/storage/rocksdb/mysql-test/rocksdb/r/skip_core_dump_on_error.result
new file mode 100644
index 00000000..60d9f69a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/skip_core_dump_on_error.result
@@ -0,0 +1,31 @@
+create table mz(c int);
+affected rows: 0
+insert into mz values(1);
+affected rows: 1
+commit;
+affected rows: 0
+SET debug= '+d,abort_with_io_write_error';
+affected rows: 0
+set global binlog_error_action=1;
+affected rows: 0
+show session variables like 'debug';
+Variable_name Value
+debug d,abort_with_io_write_error
+affected rows: 1
+show global variables like 'binlog_error_action';
+Variable_name Value
+binlog_error_action ABORT_SERVER
+affected rows: 1
+show global variables like 'skip_core_dump_on_error';
+Variable_name Value
+skip_core_dump_on_error ON
+affected rows: 1
+# crash_during_update
+update mz set c=13;
+ERROR HY000: Binary logging not possible. Message: An error occurred during sync stage of the commit. 'binlog_error_action' is set to 'ABORT_SERVER'. Hence aborting the server.
+# server aborted
+Pattern "mysqld got signal 6" found
+# but no core written
+Pattern "Writing a core file" not found
+drop table mz;
+affected rows: 0
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/skip_validate_tmp_table.result b/storage/rocksdb/mysql-test/rocksdb/r/skip_validate_tmp_table.result
new file mode 100644
index 00000000..d67c4cbb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/skip_validate_tmp_table.result
@@ -0,0 +1,22 @@
+create table t1 (pk int primary key) engine=rocksdb;
+# restart
+show tables;
+Tables_in_test
+#mysql50#t1#sql-test
+t1
+call mtr.add_suppression('Invalid .old.. table or database name .t1#sql-test.');
+set session debug_dbug="+d,gen_sql_table_name";
+rename table t1 to t2;
+set session debug_dbug= "-d,gen_sql_table_name";
+show tables;
+Tables_in_test
+#mysql50#t1#sql-test
+t2
+# restart
+show tables;
+Tables_in_test
+create table t2 (pk int primary key) engine=rocksdb;
+show tables;
+Tables_in_test
+t2
+drop table t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/slow_query_log.result b/storage/rocksdb/mysql-test/rocksdb/r/slow_query_log.result
new file mode 100644
index 00000000..e8a11363
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/slow_query_log.result
@@ -0,0 +1,10 @@
+SET @cur_long_query_time = @@long_query_time;
+SET @@long_query_time = 600;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (id INT PRIMARY KEY, value INT) ENGINE=ROCKSDB;
+SET @@long_query_time = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+7500
+SET @@long_query_time = @cur_long_query_time;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/statistics.result b/storage/rocksdb/mysql-test/rocksdb/r/statistics.result
new file mode 100644
index 00000000..1d099352
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/statistics.result
@@ -0,0 +1,73 @@
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+create table t1(
+id bigint not null primary key auto_increment,
+a varchar(255) not null,
+b bigint,
+index t1_1(b)
+) engine=rocksdb;
+create table t2(
+id bigint not null primary key auto_increment,
+a varchar(255) not null,
+b bigint,
+index t2_1(b) comment 'cf_t3'
+) engine=rocksdb;
+create table t3(
+id bigint not null primary key auto_increment,
+a varchar(255) not null,
+b bigint,
+index t3_1(b) comment 'rev:cf_t4'
+) engine=rocksdb;
+SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE() and table_name <> 't1';
+table_name table_rows
+t2 1000
+t3 1000
+SELECT CASE WHEN table_rows < 100000 then 'true' else 'false' end from information_schema.tables where table_name = 't1';
+CASE WHEN table_rows < 100000 then 'true' else 'false' end
+true
+set global rocksdb_force_flush_memtable_now = true;
+SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE();
+table_name table_rows
+t1 1000
+t2 1000
+t3 1000
+SELECT table_name, data_length>0, index_length>0 FROM information_schema.tables WHERE table_schema = DATABASE();
+table_name data_length>0 index_length>0
+t1 1 1
+t2 1 1
+t3 1 1
+# restart
+SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE();
+table_name table_rows
+t1 1000
+t2 1000
+t3 1000
+SELECT table_name, data_length>0, index_length>0 FROM information_schema.tables WHERE table_schema = DATABASE();
+table_name data_length>0 index_length>0
+t1 1 1
+t2 1 1
+t3 1 1
+analyze table t1,t2,t3,t4,t5;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+test.t3 analyze status Engine-independent statistics collected
+test.t3 analyze status OK
+test.t4 analyze Error Table 'test.t4' doesn't exist
+test.t4 analyze status Operation failed
+test.t5 analyze Error Table 'test.t5' doesn't exist
+test.t5 analyze status Operation failed
+SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE();
+table_name table_rows
+t1 1000
+t2 1000
+t3 1000
+SELECT table_name, data_length>0, index_length>0 FROM information_schema.tables WHERE table_schema = DATABASE();
+table_name data_length>0 index_length>0
+t1 1 1
+t2 1 1
+t3 1 1
+drop table t1, t2, t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/table_stats.result b/storage/rocksdb/mysql-test/rocksdb/r/table_stats.result
new file mode 100644
index 00000000..31cb1b64
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/table_stats.result
@@ -0,0 +1,12 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT, PRIMARY KEY (i) COMMENT 'cf_t1') ENGINE = ROCKSDB;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1000
+SELECT * FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME = "t1";
+TABLE_SCHEMA test
+TABLE_NAME t1
+ROWS_READ 1000
+ROWS_CHANGED 1000
+ROWS_CHANGED_X_INDEXES 1000
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_ai.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_ai.result
new file mode 100644
index 00000000..7cc0cc7c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_ai.result
@@ -0,0 +1,38 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb AUTO_INCREMENT=10;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+a
+10
+ALTER TABLE t1 AUTO_INCREMENT=100;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB AUTO_INCREMENT=100 DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1 ORDER BY a;
+a
+10
+100
+ALTER TABLE t1 AUTO_INCREMENT=50;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB AUTO_INCREMENT=101 DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1 ORDER BY a;
+a
+10
+100
+101
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_avg_row_length.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_avg_row_length.result
new file mode 100644
index 00000000..f904c04e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_avg_row_length.result
@@ -0,0 +1,18 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb AVG_ROW_LENGTH=300;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 AVG_ROW_LENGTH=300
+ALTER TABLE t1 AVG_ROW_LENGTH=30000000;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 AVG_ROW_LENGTH=30000000
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_checksum.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_checksum.result
new file mode 100644
index 00000000..d9cc69ee
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_checksum.result
@@ -0,0 +1,18 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb CHECKSUM=1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 CHECKSUM=1
+ALTER TABLE t1 CHECKSUM=0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_connection.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_connection.result
new file mode 100644
index 00000000..0beddd9f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_connection.result
@@ -0,0 +1,26 @@
+DROP TABLE IF EXISTS t1;
+CREATE DATABASE test_remote;
+CREATE SERVER test_connection FOREIGN DATA WRAPPER mysql
+OPTIONS (USER 'root', HOST 'localhost', DATABASE 'test_remote');
+CREATE SERVER test_connection2 FOREIGN DATA WRAPPER mysql
+OPTIONS (USER 'root', HOST 'localhost', DATABASE 'test_remote');
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb CONNECTION='test_connection';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 CONNECTION='test_connection'
+ALTER TABLE t1 CONNECTION='test_connection2';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 CONNECTION='test_connection2'
+DROP TABLE t1;
+DROP SERVER test_connection;
+DROP SERVER test_connection2;
+DROP DATABASE test_remote;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_data_index_dir.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_data_index_dir.result
new file mode 100644
index 00000000..95dae68b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_data_index_dir.result
@@ -0,0 +1,41 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb DATA DIRECTORY = '/foo/bar/data';
+ERROR HY000: Can't create table `test`.`t1` (errno: 198 "Unknown error 198")
+show warnings;
+Level Code Message
+Error 1005 Can't create table `test`.`t1` (errno: 198 "Unknown error 198")
+Warning 1296 Got error 198 'Specifying DATA DIRECTORY for an individual table is not supported.' from ROCKSDB
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb INDEX DIRECTORY = '/foo/bar/index';
+ERROR HY000: Can't create table `test`.`t1` (errno: 199 "Unknown error 199")
+show warnings;
+Level Code Message
+Error 1005 Can't create table `test`.`t1` (errno: 199 "Unknown error 199")
+Warning 1296 Got error 199 'Specifying INDEX DIRECTORY for an individual table is not supported.' from ROCKSDB
+CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY) ENGINE=rocksdb PARTITION BY RANGE (id)
+(
+PARTITION P0 VALUES LESS THAN (1000)
+DATA DIRECTORY = '/foo/bar/data/',
+PARTITION P1 VALUES LESS THAN (2000)
+DATA DIRECTORY = '/foo/bar/data/',
+PARTITION P2 VALUES LESS THAN (MAXVALUE)
+);
+ERROR HY000: Can't create table `test`.`t1` (errno: 198 "Unknown error 198")
+show warnings;
+Level Code Message
+Error 1005 Can't create table `test`.`t1` (errno: 198 "Unknown error 198")
+Warning 1296 Got error 198 'Specifying DATA DIRECTORY for an individual table is not supported.' from ROCKSDB
+Error 6 Error on delete of './test/t1.par' (Errcode: 2 "No such file or directory")
+CREATE TABLE t1 (id int not null primary key) ENGINE=rocksdb PARTITION BY RANGE (id)
+(
+PARTITION P0 VALUES LESS THAN (1000)
+INDEX DIRECTORY = '/foo/bar/data/',
+PARTITION P1 VALUES LESS THAN (2000)
+INDEX DIRECTORY = '/foo/bar/data/',
+PARTITION P2 VALUES LESS THAN (MAXVALUE)
+);
+ERROR HY000: Can't create table `test`.`t1` (errno: 199 "Unknown error 199")
+show warnings;
+Level Code Message
+Error 1005 Can't create table `test`.`t1` (errno: 199 "Unknown error 199")
+Warning 1296 Got error 199 'Specifying INDEX DIRECTORY for an individual table is not supported.' from ROCKSDB
+Error 6 Error on delete of './test/t1.par' (Errcode: 2 "No such file or directory")
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_delay_key_write.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_delay_key_write.result
new file mode 100644
index 00000000..c5d1ad8a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_delay_key_write.result
@@ -0,0 +1,18 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb DELAY_KEY_WRITE=1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 DELAY_KEY_WRITE=1
+ALTER TABLE t1 DELAY_KEY_WRITE=0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_insert_method.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_insert_method.result
new file mode 100644
index 00000000..bd5e65f5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_insert_method.result
@@ -0,0 +1,18 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb INSERT_METHOD=FIRST;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 INSERT_METHOD=NO;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_key_block_size.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_key_block_size.result
new file mode 100644
index 00000000..6c34d08b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_key_block_size.result
@@ -0,0 +1,18 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb KEY_BLOCK_SIZE=8;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=8
+ALTER TABLE t1 KEY_BLOCK_SIZE=1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`) KEY_BLOCK_SIZE=8
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=1
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_max_rows.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_max_rows.result
new file mode 100644
index 00000000..679e00e0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_max_rows.result
@@ -0,0 +1,18 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb MAX_ROWS=10000000;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 MAX_ROWS=10000000
+ALTER TABLE t1 MAX_ROWS=30000000;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 MAX_ROWS=30000000
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_min_rows.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_min_rows.result
new file mode 100644
index 00000000..bc650434
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_min_rows.result
@@ -0,0 +1,18 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb MIN_ROWS=1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 MIN_ROWS=1
+ALTER TABLE t1 MIN_ROWS=10000;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 MIN_ROWS=10000
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_pack_keys.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_pack_keys.result
new file mode 100644
index 00000000..b42d3f4d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_pack_keys.result
@@ -0,0 +1,18 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb PACK_KEYS=1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 PACK_KEYS=1
+ALTER TABLE t1 PACK_KEYS=0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 PACK_KEYS=0
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_password.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_password.result
new file mode 100644
index 00000000..80ec7949
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_password.result
@@ -0,0 +1,18 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb PASSWORD='password';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 PASSWORD='new_password';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_row_format.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_row_format.result
new file mode 100644
index 00000000..a0c480ea
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_row_format.result
@@ -0,0 +1,18 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT, b CHAR(8) PRIMARY KEY) ENGINE=rocksdb ROW_FORMAT=FIXED;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) NOT NULL,
+ PRIMARY KEY (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
+ALTER TABLE t1 ROW_FORMAT=DYNAMIC;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) NOT NULL,
+ PRIMARY KEY (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_union.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_union.result
new file mode 100644
index 00000000..fb021dbd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_opt_union.result
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS t1, child1, child2;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=rocksdb UNION(child1);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ALTER TABLE t1 UNION = (child1,child2);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+DROP TABLE t1, child1, child2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tbl_standard_opts.result b/storage/rocksdb/mysql-test/rocksdb/r/tbl_standard_opts.result
new file mode 100644
index 00000000..ecfc7293
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tbl_standard_opts.result
@@ -0,0 +1,46 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb
+DEFAULT CHARACTER SET = utf8
+COLLATE = utf8_general_ci
+COMMENT = 'standard table options'
+;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8 COMMENT='standard table options'
+ALTER TABLE t1 COMMENT = 'table altered';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8 COMMENT='table altered'
+ALTER TABLE t1 ENGINE=MEMORY;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=utf8 COMMENT='table altered'
+ALTER TABLE t1 ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8 COMMENT='table altered'
+ALTER TABLE t1 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` char(8) CHARACTER SET utf8 DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COMMENT='table altered'
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/tmpdir.result b/storage/rocksdb/mysql-test/rocksdb/r/tmpdir.result
new file mode 100644
index 00000000..4c1e0221
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/tmpdir.result
@@ -0,0 +1,32 @@
+# If rocksdb_tmpdir is NULL or "", temporary file will be created in
+# server configuration variable location(--tmpdir)
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=RocksDB;
+show session variables like 'rocksdb_tmpdir';
+Variable_name Value
+rocksdb_tmpdir
+# Connection con1
+connect con1,localhost,root;
+show session variables like 'rocksdb_tmpdir';
+Variable_name Value
+rocksdb_tmpdir
+ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE;
+connection default;
+disconnect con1;
+DROP TABLE t1;
+# rocksdb_tmpdir with valid location.
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=RocksDB;
+set @tmpdir = @@global.tmpdir;
+set global rocksdb_tmpdir = @tmpdir;
+show session variables like 'rocksdb_tmpdir';
+Variable_name Value
+rocksdb_tmpdir
+# Connection con3
+connect con2,localhost,root;
+show session variables like 'rocksdb_tmpdir';
+Variable_name Value
+rocksdb_tmpdir MYSQL_TMP_DIR/mysqld.1
+ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE;
+disconnect con2;
+connection default;
+set global rocksdb_tmpdir=NULL;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/transaction.result b/storage/rocksdb/mysql-test/rocksdb/r/transaction.result
new file mode 100644
index 00000000..8a5825b9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/transaction.result
@@ -0,0 +1,977 @@
+create table t1 (id int primary key, value int, value2 varchar(100), index(value)) engine=rocksdb;
+insert into t1 values (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),(6,6,6),(8,8,8),(9,9,9),(10,10,10);
+begin;
+insert into t1 values (11,11,11);
+select * from t1 where id=1;
+id value value2
+1 1 1
+select * from t1 where value=1;
+id value value2
+1 1 1
+select value from t1 where value=1;
+value
+1
+select * from t1 where value2=1;
+id value value2
+1 1 1
+select * from t1 where id=5;
+id value value2
+5 5 5
+select * from t1 where value=5;
+id value value2
+5 5 5
+select value from t1 where value=5;
+value
+5
+select * from t1 where value2=5;
+id value value2
+5 5 5
+select * from t1 where id < 3 order by id;
+id value value2
+1 1 1
+2 2 2
+select * from t1 where value < 3 order by id;
+id value value2
+1 1 1
+2 2 2
+select value from t1 where value < 3 order by id;
+value
+1
+2
+select * from t1 where value2 < 3 order by id;
+id value value2
+1 1 1
+2 2 2
+select * from t1 order by id;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+8 8 8
+9 9 9
+10 10 10
+11 11 11
+select value from t1 order by id;
+value
+1
+2
+3
+4
+5
+6
+8
+9
+10
+11
+rollback;
+begin;
+insert into t1 values (7,7,7);
+select * from t1 where id=1;
+id value value2
+1 1 1
+select * from t1 where value=1;
+id value value2
+1 1 1
+select value from t1 where value=1;
+value
+1
+select * from t1 where value2=1;
+id value value2
+1 1 1
+select * from t1 where id=5;
+id value value2
+5 5 5
+select * from t1 where value=5;
+id value value2
+5 5 5
+select value from t1 where value=5;
+value
+5
+select * from t1 where value2=5;
+id value value2
+5 5 5
+select * from t1 where id < 3 order by id;
+id value value2
+1 1 1
+2 2 2
+select * from t1 where value < 3 order by id;
+id value value2
+1 1 1
+2 2 2
+select value from t1 where value < 3 order by id;
+value
+1
+2
+select * from t1 where value2 < 3 order by id;
+id value value2
+1 1 1
+2 2 2
+select * from t1 order by id;
+id value value2
+1 1 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+7 7 7
+8 8 8
+9 9 9
+10 10 10
+select value from t1 order by id;
+value
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+rollback;
+begin;
+update t1 set value2=100 where id=1;
+select * from t1 where id=1;
+id value value2
+1 1 100
+select * from t1 where value=1;
+id value value2
+1 1 100
+select value from t1 where value=1;
+value
+1
+select * from t1 where value2=1;
+id value value2
+select * from t1 where id=5;
+id value value2
+5 5 5
+select * from t1 where value=5;
+id value value2
+5 5 5
+select value from t1 where value=5;
+value
+5
+select * from t1 where value2=5;
+id value value2
+5 5 5
+select * from t1 where id < 3 order by id;
+id value value2
+1 1 100
+2 2 2
+select * from t1 where value < 3 order by id;
+id value value2
+1 1 100
+2 2 2
+select value from t1 where value < 3 order by id;
+value
+1
+2
+select * from t1 where value2 < 3 order by id;
+id value value2
+2 2 2
+select * from t1 order by id;
+id value value2
+1 1 100
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+8 8 8
+9 9 9
+10 10 10
+select value from t1 order by id;
+value
+1
+2
+3
+4
+5
+6
+8
+9
+10
+rollback;
+begin;
+update t1 set value=100 where id=1;
+select * from t1 where id=1;
+id value value2
+1 100 1
+select * from t1 where value=1;
+id value value2
+select value from t1 where value=1;
+value
+select * from t1 where value2=1;
+id value value2
+1 100 1
+select * from t1 where id=5;
+id value value2
+5 5 5
+select * from t1 where value=5;
+id value value2
+5 5 5
+select value from t1 where value=5;
+value
+5
+select * from t1 where value2=5;
+id value value2
+5 5 5
+select * from t1 where id < 3 order by id;
+id value value2
+1 100 1
+2 2 2
+select * from t1 where value < 3 order by id;
+id value value2
+2 2 2
+select value from t1 where value < 3 order by id;
+value
+2
+select * from t1 where value2 < 3 order by id;
+id value value2
+1 100 1
+2 2 2
+select * from t1 order by id;
+id value value2
+1 100 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+8 8 8
+9 9 9
+10 10 10
+select value from t1 order by id;
+value
+100
+2
+3
+4
+5
+6
+8
+9
+10
+rollback;
+begin;
+update t1 set id=100 where id=1;
+select * from t1 where id=1;
+id value value2
+select * from t1 where value=1;
+id value value2
+100 1 1
+select value from t1 where value=1;
+value
+1
+select * from t1 where value2=1;
+id value value2
+100 1 1
+select * from t1 where id=5;
+id value value2
+5 5 5
+select * from t1 where value=5;
+id value value2
+5 5 5
+select value from t1 where value=5;
+value
+5
+select * from t1 where value2=5;
+id value value2
+5 5 5
+select * from t1 where id < 3 order by id;
+id value value2
+2 2 2
+select * from t1 where value < 3 order by id;
+id value value2
+2 2 2
+100 1 1
+select value from t1 where value < 3 order by id;
+value
+2
+1
+select * from t1 where value2 < 3 order by id;
+id value value2
+2 2 2
+100 1 1
+select * from t1 order by id;
+id value value2
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+8 8 8
+9 9 9
+10 10 10
+100 1 1
+select value from t1 order by id;
+value
+2
+3
+4
+5
+6
+8
+9
+10
+1
+rollback;
+begin;
+update t1 set value2=100 where value=1;
+select * from t1 where id=1;
+id value value2
+1 1 100
+select * from t1 where value=1;
+id value value2
+1 1 100
+select value from t1 where value=1;
+value
+1
+select * from t1 where value2=1;
+id value value2
+select * from t1 where id=5;
+id value value2
+5 5 5
+select * from t1 where value=5;
+id value value2
+5 5 5
+select value from t1 where value=5;
+value
+5
+select * from t1 where value2=5;
+id value value2
+5 5 5
+select * from t1 where id < 3 order by id;
+id value value2
+1 1 100
+2 2 2
+select * from t1 where value < 3 order by id;
+id value value2
+1 1 100
+2 2 2
+select value from t1 where value < 3 order by id;
+value
+1
+2
+select * from t1 where value2 < 3 order by id;
+id value value2
+2 2 2
+select * from t1 order by id;
+id value value2
+1 1 100
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+8 8 8
+9 9 9
+10 10 10
+select value from t1 order by id;
+value
+1
+2
+3
+4
+5
+6
+8
+9
+10
+rollback;
+begin;
+update t1 set value=100 where value=1;
+select * from t1 where id=1;
+id value value2
+1 100 1
+select * from t1 where value=1;
+id value value2
+select value from t1 where value=1;
+value
+select * from t1 where value2=1;
+id value value2
+1 100 1
+select * from t1 where id=5;
+id value value2
+5 5 5
+select * from t1 where value=5;
+id value value2
+5 5 5
+select value from t1 where value=5;
+value
+5
+select * from t1 where value2=5;
+id value value2
+5 5 5
+select * from t1 where id < 3 order by id;
+id value value2
+1 100 1
+2 2 2
+select * from t1 where value < 3 order by id;
+id value value2
+2 2 2
+select value from t1 where value < 3 order by id;
+value
+2
+select * from t1 where value2 < 3 order by id;
+id value value2
+1 100 1
+2 2 2
+select * from t1 order by id;
+id value value2
+1 100 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+8 8 8
+9 9 9
+10 10 10
+select value from t1 order by id;
+value
+100
+2
+3
+4
+5
+6
+8
+9
+10
+rollback;
+begin;
+update t1 set id=100 where value=1;
+select * from t1 where id=1;
+id value value2
+select * from t1 where value=1;
+id value value2
+100 1 1
+select value from t1 where value=1;
+value
+1
+select * from t1 where value2=1;
+id value value2
+100 1 1
+select * from t1 where id=5;
+id value value2
+5 5 5
+select * from t1 where value=5;
+id value value2
+5 5 5
+select value from t1 where value=5;
+value
+5
+select * from t1 where value2=5;
+id value value2
+5 5 5
+select * from t1 where id < 3 order by id;
+id value value2
+2 2 2
+select * from t1 where value < 3 order by id;
+id value value2
+2 2 2
+100 1 1
+select value from t1 where value < 3 order by id;
+value
+2
+1
+select * from t1 where value2 < 3 order by id;
+id value value2
+2 2 2
+100 1 1
+select * from t1 order by id;
+id value value2
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+8 8 8
+9 9 9
+10 10 10
+100 1 1
+select value from t1 order by id;
+value
+2
+3
+4
+5
+6
+8
+9
+10
+1
+rollback;
+begin;
+update t1 set value2=100 where value2=1;
+select * from t1 where id=1;
+id value value2
+1 1 100
+select * from t1 where value=1;
+id value value2
+1 1 100
+select value from t1 where value=1;
+value
+1
+select * from t1 where value2=1;
+id value value2
+select * from t1 where id=5;
+id value value2
+5 5 5
+select * from t1 where value=5;
+id value value2
+5 5 5
+select value from t1 where value=5;
+value
+5
+select * from t1 where value2=5;
+id value value2
+5 5 5
+select * from t1 where id < 3 order by id;
+id value value2
+1 1 100
+2 2 2
+select * from t1 where value < 3 order by id;
+id value value2
+1 1 100
+2 2 2
+select value from t1 where value < 3 order by id;
+value
+1
+2
+select * from t1 where value2 < 3 order by id;
+id value value2
+2 2 2
+select * from t1 order by id;
+id value value2
+1 1 100
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+8 8 8
+9 9 9
+10 10 10
+select value from t1 order by id;
+value
+1
+2
+3
+4
+5
+6
+8
+9
+10
+rollback;
+begin;
+update t1 set value=100 where value2=1;
+select * from t1 where id=1;
+id value value2
+1 100 1
+select * from t1 where value=1;
+id value value2
+select value from t1 where value=1;
+value
+select * from t1 where value2=1;
+id value value2
+1 100 1
+select * from t1 where id=5;
+id value value2
+5 5 5
+select * from t1 where value=5;
+id value value2
+5 5 5
+select value from t1 where value=5;
+value
+5
+select * from t1 where value2=5;
+id value value2
+5 5 5
+select * from t1 where id < 3 order by id;
+id value value2
+1 100 1
+2 2 2
+select * from t1 where value < 3 order by id;
+id value value2
+2 2 2
+select value from t1 where value < 3 order by id;
+value
+2
+select * from t1 where value2 < 3 order by id;
+id value value2
+1 100 1
+2 2 2
+select * from t1 order by id;
+id value value2
+1 100 1
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+8 8 8
+9 9 9
+10 10 10
+select value from t1 order by id;
+value
+100
+2
+3
+4
+5
+6
+8
+9
+10
+rollback;
+begin;
+update t1 set id=100 where value2=1;
+select * from t1 where id=1;
+id value value2
+select * from t1 where value=1;
+id value value2
+100 1 1
+select value from t1 where value=1;
+value
+1
+select * from t1 where value2=1;
+id value value2
+100 1 1
+select * from t1 where id=5;
+id value value2
+5 5 5
+select * from t1 where value=5;
+id value value2
+5 5 5
+select value from t1 where value=5;
+value
+5
+select * from t1 where value2=5;
+id value value2
+5 5 5
+select * from t1 where id < 3 order by id;
+id value value2
+2 2 2
+select * from t1 where value < 3 order by id;
+id value value2
+2 2 2
+100 1 1
+select value from t1 where value < 3 order by id;
+value
+2
+1
+select * from t1 where value2 < 3 order by id;
+id value value2
+2 2 2
+100 1 1
+select * from t1 order by id;
+id value value2
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+8 8 8
+9 9 9
+10 10 10
+100 1 1
+select value from t1 order by id;
+value
+2
+3
+4
+5
+6
+8
+9
+10
+1
+rollback;
+begin;
+delete from t1 where id=1;
+select * from t1 where id=1;
+id value value2
+select * from t1 where value=1;
+id value value2
+select value from t1 where value=1;
+value
+select * from t1 where value2=1;
+id value value2
+select * from t1 where id=5;
+id value value2
+5 5 5
+select * from t1 where value=5;
+id value value2
+5 5 5
+select value from t1 where value=5;
+value
+5
+select * from t1 where value2=5;
+id value value2
+5 5 5
+select * from t1 where id < 3 order by id;
+id value value2
+2 2 2
+select * from t1 where value < 3 order by id;
+id value value2
+2 2 2
+select value from t1 where value < 3 order by id;
+value
+2
+select * from t1 where value2 < 3 order by id;
+id value value2
+2 2 2
+select * from t1 order by id;
+id value value2
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+8 8 8
+9 9 9
+10 10 10
+select value from t1 order by id;
+value
+2
+3
+4
+5
+6
+8
+9
+10
+rollback;
+begin;
+delete from t1 where value=1;
+select * from t1 where id=1;
+id value value2
+select * from t1 where value=1;
+id value value2
+select value from t1 where value=1;
+value
+select * from t1 where value2=1;
+id value value2
+select * from t1 where id=5;
+id value value2
+5 5 5
+select * from t1 where value=5;
+id value value2
+5 5 5
+select value from t1 where value=5;
+value
+5
+select * from t1 where value2=5;
+id value value2
+5 5 5
+select * from t1 where id < 3 order by id;
+id value value2
+2 2 2
+select * from t1 where value < 3 order by id;
+id value value2
+2 2 2
+select value from t1 where value < 3 order by id;
+value
+2
+select * from t1 where value2 < 3 order by id;
+id value value2
+2 2 2
+select * from t1 order by id;
+id value value2
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+8 8 8
+9 9 9
+10 10 10
+select value from t1 order by id;
+value
+2
+3
+4
+5
+6
+8
+9
+10
+rollback;
+begin;
+delete from t1 where value2=1;
+select * from t1 where id=1;
+id value value2
+select * from t1 where value=1;
+id value value2
+select value from t1 where value=1;
+value
+select * from t1 where value2=1;
+id value value2
+select * from t1 where id=5;
+id value value2
+5 5 5
+select * from t1 where value=5;
+id value value2
+5 5 5
+select value from t1 where value=5;
+value
+5
+select * from t1 where value2=5;
+id value value2
+5 5 5
+select * from t1 where id < 3 order by id;
+id value value2
+2 2 2
+select * from t1 where value < 3 order by id;
+id value value2
+2 2 2
+select value from t1 where value < 3 order by id;
+value
+2
+select * from t1 where value2 < 3 order by id;
+id value value2
+2 2 2
+select * from t1 order by id;
+id value value2
+2 2 2
+3 3 3
+4 4 4
+5 5 5
+6 6 6
+8 8 8
+9 9 9
+10 10 10
+select value from t1 order by id;
+value
+2
+3
+4
+5
+6
+8
+9
+10
+rollback;
+begin;
+insert into t1 values (11,11,11);
+insert into t1 values (12,12,12);
+insert into t1 values (13,13,13);
+delete from t1 where id=9;
+delete from t1 where value=8;
+update t1 set id=100 where value2=5;
+update t1 set value=103 where value=4;
+update t1 set id=115 where id=3;
+select * from t1 where id=1;
+id value value2
+1 1 1
+select * from t1 where value=1;
+id value value2
+1 1 1
+select value from t1 where value=1;
+value
+1
+select * from t1 where value2=1;
+id value value2
+1 1 1
+select * from t1 where id=5;
+id value value2
+select * from t1 where value=5;
+id value value2
+100 5 5
+select value from t1 where value=5;
+value
+5
+select * from t1 where value2=5;
+id value value2
+100 5 5
+select * from t1 where id < 3 order by id;
+id value value2
+1 1 1
+2 2 2
+select * from t1 where value < 3 order by id;
+id value value2
+1 1 1
+2 2 2
+select value from t1 where value < 3 order by id;
+value
+1
+2
+select * from t1 where value2 < 3 order by id;
+id value value2
+1 1 1
+2 2 2
+select * from t1 order by id;
+id value value2
+1 1 1
+2 2 2
+4 103 4
+6 6 6
+10 10 10
+11 11 11
+12 12 12
+13 13 13
+100 5 5
+115 3 3
+select value from t1 order by id;
+value
+1
+2
+103
+6
+10
+11
+12
+13
+5
+3
+rollback;
+drop table t1;
+#
+# #802: MyRocks: Statement rollback doesnt work correctly for nested statements
+#
+create table t1 (a varchar(100)) engine=rocksdb;
+create table t2(a int) engine=rocksdb;
+insert into t2 values (1), (2);
+create table t3(a varchar(100)) engine=rocksdb;
+create function func() returns varchar(100) deterministic
+begin
+insert into t3 values ('func-called');
+set @a= (select a from t2);
+return 'func-returned';
+end;//
+begin;
+insert into t1 values (func());
+ERROR 21000: Subquery returns more than 1 row
+select * from t1;
+a
+# The following must not produce 'func-called':
+select * from t3;
+a
+rollback;
+drop function func;
+drop table t1,t2,t3;
+#
+# MDEV-16710: Slave SQL: Could not execute Update_rows_v1 event with RocksDB and triggers
+# Issue#857: MyRocks: Incorrect behavior when multiple statements fail inside a transaction
+#
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (b INT PRIMARY KEY) ENGINE=RocksDB;
+CREATE TRIGGER tr AFTER INSERT ON t2 FOR EACH ROW INSERT INTO non_existing_table VALUES (NULL);
+BEGIN;
+DELETE FROM t1;
+INSERT INTO t2 VALUES (1);
+INSERT INTO t2 VALUES (2);
+# Must return empty result:
+SELECT * FROM t1;
+a
+COMMIT;
+drop table t1,t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/truncate_partition.result b/storage/rocksdb/mysql-test/rocksdb/r/truncate_partition.result
new file mode 100644
index 00000000..67f655b6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/truncate_partition.result
@@ -0,0 +1,620 @@
+#
+# table(hidden key)
+#
+CREATE TABLE t1 (
+a INT,
+b INT
+) ENGINE=ROCKSDB
+PARTITION BY RANGE (b) (
+PARTITION p0 VALUES LESS THAN (3),
+PARTITION p1 VALUES LESS THAN (6),
+PARTITION p2 VALUES LESS THAN MAXVALUE
+);
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t1;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+TRUNCATE TABLE t1;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+INSERT INTO t1 (a,b) VALUES (1, 1), (2, 4), (3, 8);
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 1
+2 4
+3 8
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 1
+2 4
+SELECT a FROM t1 WHERE b > 2;
+a
+2
+SELECT b from t1 where a != 3;
+b
+1
+4
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+SELECT a,b FROM t1 ORDER BY b;
+a b
+1 1
+SELECT a FROM t1 WHERE b > 2;
+a
+SELECT b from t1 where a != 3;
+b
+1
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+SELECT a,b FROM t1 ORDER BY a;
+a b
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+INSERT INTO t1 (a,b) VALUES (4, 1), (5, 4), (6, 8);
+SELECT a,b FROM t1;
+a b
+4 1
+5 4
+6 8
+SELECT a FROM t1 WHERE b < 5;
+a
+4
+5
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+SELECT a,b FROM t1;
+a b
+4 1
+5 4
+INSERT INTO t1(a,b) VALUES(7, 1);
+SELECT b from t1 WHERE a > 2;
+b
+1
+1
+4
+SELECT a,b FROM t1;
+a b
+4 1
+5 4
+7 1
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+SELECT a,b FROM t1;
+a b
+4 1
+7 1
+INSERT INTO t1(a,b) VALUES(8, 4);
+SELECT a,b FROM t1;
+a b
+4 1
+7 1
+8 4
+SELECT b from t1 WHERE a < 9;
+b
+1
+1
+4
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+SELECT a,b FROM t1;
+a b
+8 4
+INSERT INTO t1(a,b) VALUES(9, 8);
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+set global rocksdb_force_flush_memtable_now = true;
+set global rocksdb_compact_cf = 'default';
+SELECT b FROM t1 WHERE a < 5;
+b
+1
+2
+3
+4
+TRUNCATE TABLE t1;
+SELECT b FROM t1 WHERE a < 5;
+b
+DROP TABLE t1;
+#
+# table(secondary key)
+#
+CREATE TABLE t1(
+a INT,
+b INT,
+KEY (b)
+) ENGINE=ROCKSDB
+PARTITION BY HASH(a) PARTITIONS 3;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t1;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+TRUNCATE TABLE t1;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+INSERT INTO t1 (a,b) VALUES (1, 1), (2, 4), (3, 8);
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 1
+2 4
+3 8
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 1
+3 8
+SELECT a FROM t1 WHERE b > 2;
+a
+3
+SELECT b from t1 where a != 3;
+b
+1
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+SELECT a,b FROM t1 ORDER BY b;
+a b
+3 8
+SELECT a FROM t1 WHERE b > 2;
+a
+3
+SELECT b from t1 where a != 3;
+b
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+SELECT a,b FROM t1 ORDER BY a;
+a b
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+INSERT INTO t1 (a,b) VALUES (4, 1), (5, 4), (6, 8);
+SELECT a,b FROM t1;
+a b
+4 1
+5 4
+6 8
+SELECT a FROM t1 WHERE b < 5;
+a
+4
+5
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+SELECT a,b FROM t1;
+a b
+4 1
+6 8
+INSERT INTO t1(a,b) VALUES(7, 1);
+SELECT b from t1 WHERE a > 2;
+b
+1
+1
+8
+SELECT a,b FROM t1;
+a b
+4 1
+6 8
+7 1
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+SELECT a,b FROM t1;
+a b
+6 8
+INSERT INTO t1(a,b) VALUES(8, 4);
+SELECT a,b FROM t1;
+a b
+6 8
+8 4
+SELECT b from t1 WHERE a < 9;
+b
+4
+8
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+SELECT a,b FROM t1;
+a b
+8 4
+INSERT INTO t1(a,b) VALUES(9, 8);
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+set global rocksdb_force_flush_memtable_now = true;
+set global rocksdb_compact_cf = 'default';
+SELECT b FROM t1 WHERE a < 5;
+b
+1
+2
+3
+4
+TRUNCATE TABLE t1;
+SELECT b FROM t1 WHERE a < 5;
+b
+DROP TABLE t1;
+#
+# table(primary key, auto increment)
+#
+CREATE TABLE t1(
+a INT NOT NULL AUTO_INCREMENT,
+b INT,
+PRIMARY KEY(a)
+) ENGINE=ROCKSDB
+PARTITION BY KEY() PARTITIONS 3;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t1;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+TRUNCATE TABLE t1;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+INSERT INTO t1 (a,b) VALUES (1, 1), (2, 4), (3, 8);
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 1
+2 4
+3 8
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 1
+SELECT a FROM t1 WHERE b > 2;
+a
+SELECT b from t1 where a != 3;
+b
+1
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+SELECT a,b FROM t1 ORDER BY b;
+a b
+SELECT a FROM t1 WHERE b > 2;
+a
+SELECT b from t1 where a != 3;
+b
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+SELECT a,b FROM t1 ORDER BY a;
+a b
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+INSERT INTO t1 (a,b) VALUES (4, 1), (5, 4), (6, 8);
+SELECT a,b FROM t1;
+a b
+4 1
+5 4
+6 8
+SELECT a FROM t1 WHERE b < 5;
+a
+4
+5
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+SELECT a,b FROM t1;
+a b
+4 1
+5 4
+6 8
+INSERT INTO t1(a,b) VALUES(7, 1);
+SELECT b from t1 WHERE a > 2;
+b
+1
+1
+4
+8
+SELECT a,b FROM t1;
+a b
+4 1
+5 4
+6 8
+7 1
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+SELECT a,b FROM t1;
+a b
+4 1
+5 4
+INSERT INTO t1(a,b) VALUES(8, 4);
+SELECT a,b FROM t1;
+a b
+4 1
+5 4
+8 4
+SELECT b from t1 WHERE a < 9;
+b
+1
+4
+4
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+SELECT a,b FROM t1;
+a b
+8 4
+INSERT INTO t1(a,b) VALUES(9, 8);
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+set global rocksdb_force_flush_memtable_now = true;
+set global rocksdb_compact_cf = 'default';
+SELECT b FROM t1 WHERE a < 5;
+b
+1
+2
+3
+4
+TRUNCATE TABLE t1;
+SELECT b FROM t1 WHERE a < 5;
+b
+DROP TABLE t1;
+#
+# table(cf)
+#
+CREATE TABLE t1 (
+a INT,
+b INT,
+PRIMARY KEY (`a`, `b`) COMMENT 'testcomment'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(a) (
+PARTITION p0 VALUES IN (1, 4, 7),
+PARTITION p1 VALUES IN (2, 5, 8),
+PARTITION p2 VALUES IN (3, 6, 9)
+);
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t1;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+TRUNCATE TABLE t1;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+INSERT INTO t1 (a,b) VALUES (1, 1), (2, 4), (3, 8);
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 1
+2 4
+3 8
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 1
+2 4
+SELECT a FROM t1 WHERE b > 2;
+a
+2
+SELECT b from t1 where a != 3;
+b
+1
+4
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+SELECT a,b FROM t1 ORDER BY b;
+a b
+1 1
+SELECT a FROM t1 WHERE b > 2;
+a
+SELECT b from t1 where a != 3;
+b
+1
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+SELECT a,b FROM t1 ORDER BY a;
+a b
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+INSERT INTO t1 (a,b) VALUES (4, 1), (5, 4), (6, 8);
+SELECT a,b FROM t1;
+a b
+4 1
+5 4
+6 8
+SELECT a FROM t1 WHERE b < 5;
+a
+4
+5
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+SELECT a,b FROM t1;
+a b
+4 1
+5 4
+INSERT INTO t1(a,b) VALUES(7, 1);
+SELECT b from t1 WHERE a > 2;
+b
+1
+1
+4
+SELECT a,b FROM t1;
+a b
+4 1
+5 4
+7 1
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+SELECT a,b FROM t1;
+a b
+4 1
+7 1
+INSERT INTO t1(a,b) VALUES(8, 4);
+SELECT a,b FROM t1;
+a b
+4 1
+7 1
+8 4
+SELECT b from t1 WHERE a < 9;
+b
+1
+1
+4
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+SELECT a,b FROM t1;
+a b
+8 4
+INSERT INTO t1(a,b) VALUES(9, 8);
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+set global rocksdb_force_flush_memtable_now = true;
+set global rocksdb_compact_cf = 'default';
+SELECT b FROM t1 WHERE a < 5;
+b
+1
+2
+3
+4
+TRUNCATE TABLE t1;
+SELECT b FROM t1 WHERE a < 5;
+b
+DROP TABLE t1;
+#
+# table(reverse cf)
+#
+CREATE TABLE t1 (
+a INT,
+b INT,
+PRIMARY KEY (`a`, `b`) COMMENT 'p0_cfname=rev:foo;p1_cfname=bar;p2_cfname=baz'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(a) (
+PARTITION p0 VALUES IN (1, 4, 7),
+PARTITION p1 VALUES IN (2, 5, 8),
+PARTITION p2 VALUES IN (3, 6, 9)
+);
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t1;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+TRUNCATE TABLE t1;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+INSERT INTO t1 (a,b) VALUES (1, 1), (2, 4), (3, 8);
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 1
+2 4
+3 8
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 1
+2 4
+SELECT a FROM t1 WHERE b > 2;
+a
+2
+SELECT b from t1 where a != 3;
+b
+1
+4
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+SELECT a,b FROM t1 ORDER BY b;
+a b
+1 1
+SELECT a FROM t1 WHERE b > 2;
+a
+SELECT b from t1 where a != 3;
+b
+1
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+SELECT a,b FROM t1 ORDER BY a;
+a b
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+INSERT INTO t1 (a,b) VALUES (4, 1), (5, 4), (6, 8);
+SELECT a,b FROM t1;
+a b
+4 1
+5 4
+6 8
+SELECT a FROM t1 WHERE b < 5;
+a
+4
+5
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+SELECT a,b FROM t1;
+a b
+4 1
+5 4
+INSERT INTO t1(a,b) VALUES(7, 1);
+SELECT b from t1 WHERE a > 2;
+b
+1
+1
+4
+SELECT a,b FROM t1;
+a b
+4 1
+5 4
+7 1
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+SELECT a,b FROM t1;
+a b
+4 1
+7 1
+INSERT INTO t1(a,b) VALUES(8, 4);
+SELECT a,b FROM t1;
+a b
+4 1
+7 1
+8 4
+SELECT b from t1 WHERE a < 9;
+b
+1
+1
+4
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+SELECT a,b FROM t1;
+a b
+8 4
+INSERT INTO t1(a,b) VALUES(9, 8);
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+set global rocksdb_force_flush_memtable_now = true;
+set global rocksdb_compact_cf = 'default';
+SELECT b FROM t1 WHERE a < 5;
+b
+1
+2
+3
+4
+TRUNCATE TABLE t1;
+SELECT b FROM t1 WHERE a < 5;
+b
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/truncate_table.result b/storage/rocksdb/mysql-test/rocksdb/r/truncate_table.result
new file mode 100644
index 00000000..47048677
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/truncate_table.result
@@ -0,0 +1,33 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+TRUNCATE TABLE t1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c');
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+DROP TABLE t1;
+CREATE TABLE t1 (a INT KEY AUTO_INCREMENT, c CHAR(8)) ENGINE=rocksdb;
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed # # # 0 0 0 1 # # NULL latin1_swedish_ci NULL 0 N
+INSERT INTO t1 (c) VALUES ('a'),('b'),('c');
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed # # # 0 0 0 4 # # NULL latin1_swedish_ci NULL 0 N
+TRUNCATE TABLE t1;
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed # # # 0 0 0 1 # # NULL latin1_swedish_ci NULL 0 N
+INSERT INTO t1 (c) VALUES ('d');
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 ROCKSDB 10 Fixed # # # 0 0 0 2 # # NULL latin1_swedish_ci NULL 0 N
+SELECT a,c FROM t1;
+a c
+1 d
+DROP TABLE t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
+HANDLER t1 OPEN AS h1;
+ERROR HY000: Storage engine ROCKSDB of the table `test`.`t1` doesn't have this option
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/truncate_table3.result b/storage/rocksdb/mysql-test/rocksdb/r/truncate_table3.result
new file mode 100644
index 00000000..7c5631a2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/truncate_table3.result
@@ -0,0 +1,23 @@
+call mtr.add_suppression("Column family 'cf1' not found");
+call mtr.add_suppression("Column family 'rev:cf2' not found");
+DROP TABLE IF EXISTS t1;
+call mtr.add_suppression("Column family 'cf1' not found");
+call mtr.add_suppression("Column family 'rev:cf2' not found");
+set global rocksdb_compact_cf = 'cf1';
+set global rocksdb_compact_cf = 'rev:cf2';
+set global rocksdb_signal_drop_index_thread = 1;
+# restart
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c varchar(500) not null,
+primary key (a,b) comment 'cf1',
+key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+DELETE FROM t1;
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_compact_read_bytes';
+truncate table t1;
+select case when variable_value-@a < 500000 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_compact_read_bytes';
+case when variable_value-@a < 500000 then 'true' else 'false' end
+true
+DROP TABLE IF EXISTS t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/trx_info.result b/storage/rocksdb/mysql-test/rocksdb/r/trx_info.result
new file mode 100644
index 00000000..ada2e127
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/trx_info.result
@@ -0,0 +1,13 @@
+DROP TABLE IF EXISTS t1;
+create table t1 (a int) engine=rocksdb;
+insert into t1 values (1);
+insert into t1 values (2);
+set autocommit=0;
+select * from t1 for update;
+a
+1
+2
+select * from information_schema.rocksdb_trx;
+TRANSACTION_ID STATE NAME WRITE_COUNT LOCK_COUNT TIMEOUT_SEC WAITING_KEY WAITING_COLUMN_FAMILY_ID IS_REPLICATION SKIP_TRX_API READ_ONLY HAS_DEADLOCK_DETECTION NUM_ONGOING_BULKLOAD THREAD_ID QUERY
+_TRX_ID_ STARTED _NAME_ 0 2 1 _KEY_ 0 0 0 0 0 0 _THREAD_ID_ select * from information_schema.rocksdb_trx
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/trx_info_rpl.result b/storage/rocksdb/mysql-test/rocksdb/r/trx_info_rpl.result
new file mode 100644
index 00000000..b096e42a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/trx_info_rpl.result
@@ -0,0 +1,16 @@
+include/master-slave.inc
+[connection master]
+DROP TABLE IF EXISTS t1;
+connection slave;
+include/stop_slave.inc
+create table t1 (a int, b int, primary key (a), unique key (b)) engine=rocksdb;
+connection master;
+connection slave;
+show variables like 'rpl_skip_tx_api';
+Variable_name Value
+rpl_skip_tx_api ON
+include/start_slave.inc
+found
+connection master;
+DROP TABLE t1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/ttl_primary.result b/storage/rocksdb/mysql-test/rocksdb/r/ttl_primary.result
new file mode 100644
index 00000000..2903e9aa
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/ttl_primary.result
@@ -0,0 +1,489 @@
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64) NOT NULL,
+`c` varbinary(256) NOT NULL,
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`b`,`a`,`c`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', 'b', 'c', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('d', 'e', 'f', UNIX_TIMESTAMP(), 'g');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+2
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+b int NOT NULL,
+ts bigint(20) UNSIGNED NOT NULL,
+c int NOT NULL,
+PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, UNIX_TIMESTAMP(), 5);
+INSERT INTO t1 values (2, 4, UNIX_TIMESTAMP(), 6);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+2
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+ts bigint(20) UNSIGNED NOT NULL,
+PRIMARY KEY (a,c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, 5, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, 4, 6, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+2
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+ts bigint(20) UNSIGNED NOT NULL,
+PRIMARY KEY (a,c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, 5, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, 4, 6, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+2
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+b int,
+c int,
+ts bigint(20) UNSIGNED NOT NULL,
+PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, NULL, NULL, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, NULL, NULL, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+2
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64),
+`c` varbinary(256),
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', NULL, 'bc', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('d', 'efghijk', NULL, UNIX_TIMESTAMP(), 'l');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+2
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, 5);
+INSERT INTO t1 values (2, 4, 6);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+2
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a int,
+ts bigint(20) UNSIGNED NOT NULL,
+PRIMARY KEY (a, ts)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;ttl_col=ts;';
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, UNIX_TIMESTAMP());
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+2
+set global rocksdb_debug_ttl_snapshot_ts = -10;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+2
+set global rocksdb_debug_ttl_snapshot_ts = 10;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+b int NOT NULL,
+ts bigint(20) UNSIGNED NOT NULL,
+c int NOT NULL,
+PRIMARY KEY (a, ts)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, UNIX_TIMESTAMP(), 5);
+INSERT INTO t1 values (2, 4, UNIX_TIMESTAMP(), 6);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+2
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64),
+`c` varbinary(256),
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`a`, `ts`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', NULL, 'bc', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('de', 'fghijk', NULL, UNIX_TIMESTAMP(), 'l');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+2
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a INT NOT NULL,
+b varbinary(64) NOT NULL,
+c varbinary(256) NOT NULL,
+ts bigint(20) UNSIGNED NOT NULL,
+value mediumblob NOT NULL,
+PRIMARY KEY (b,a,c)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=10;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, 'b', 'c', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values (2, 'e', 'f', UNIX_TIMESTAMP(), 'g');
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (3, 'i', 'j', UNIX_TIMESTAMP(), 'k');
+INSERT INTO t1 values (4, 'm', 'n', UNIX_TIMESTAMP(), 'o');
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_debug_ttl_snapshot_ts = -3600;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT a FROM t1;
+a
+1
+2
+3
+4
+set global rocksdb_compact_cf='default';
+SELECT a FROM t1;
+a
+3
+4
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT a FROM t1;
+a
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) UNSIGNED NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+ts bigint(20),
+PRIMARY KEY (a,c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+ERROR HY000: TTL column (ts) in MyRocks must be an unsigned non-null 64-bit integer, exist inside the table, and have an accompanying ttl duration.
+CREATE TABLE t1 (
+a bigint(20) UNSIGNED NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+ts int,
+PRIMARY KEY (a,c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+ERROR HY000: TTL column (ts) in MyRocks must be an unsigned non-null 64-bit integer, exist inside the table, and have an accompanying ttl duration.
+CREATE TABLE t1 (
+a bigint(20) UNSIGNED NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+PRIMARY KEY (a,c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=abc;';
+ERROR HY000: TTL duration (abc) in MyRocks must be an unsigned non-null 64-bit integer.
+CREATE TABLE t1 (
+a bigint(20) UNSIGNED NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+PRIMARY KEY (a,c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=abc;';
+ERROR HY000: TTL column (abc) in MyRocks must be an unsigned non-null 64-bit integer, exist inside the table, and have an accompanying ttl duration.
+CREATE TABLE t1 (
+a bigint(20) UNSIGNED NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+PRIMARY KEY (a,c)
+) ENGINE=rocksdb
+COMMENT='ttl_col=abc;';
+ERROR HY000: TTL column (abc) in MyRocks must be an unsigned non-null 64-bit integer, exist inside the table, and have an accompanying ttl duration.
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=500;';
+INSERT INTO t1 values (1);
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1
+DROP TABLE t1;
+CREATE TABLE t1 (
+a INT PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+INSERT INTO t1 values (1);
+SELECT * FROM t1;
+a
+1
+set global rocksdb_debug_ttl_rec_ts = -300;
+ALTER TABLE t1 COMMENT = 'ttl_duration=1';
+set global rocksdb_debug_ttl_rec_ts = 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COMMENT='ttl_duration=1'
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a INT PRIMARY KEY,
+b INT
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+ALTER TABLE t1 DROP PRIMARY KEY;
+ERROR HY000: TTL support is currently disabled when table has a hidden PK.
+DROP TABLE t1;
+CREATE TABLE t1 (
+a INT PRIMARY KEY,
+b INT
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;';
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (2,2);
+ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b);
+set global rocksdb_debug_ttl_snapshot_ts = -3600;
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+2
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) UNSIGNED NOT NULL,
+b int,
+PRIMARY KEY (a,b)
+) ENGINE=rocksdb
+COMMENT='asdadfasdfsadfadf ;ttl_duration=1; asfasdfasdfadfa';
+INSERT INTO t1 values (UNIX_TIMESTAMP(), 1);
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+ALTER TABLE t1 COMMENT = 'adsf;;ttl_duration=5;asfasdfa;ttl_col=a;asdfasdf;';
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (UNIX_TIMESTAMP(), 2);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;';
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1);
+INSERT INTO t1 values (3);
+INSERT INTO t1 values (5);
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (7);
+INSERT INTO t1 values (9);
+set global rocksdb_debug_ttl_rec_ts = 0;
+UPDATE t1 SET a=a+1;
+SELECT * FROM t1;
+a
+10
+2
+4
+6
+8
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT * FROM t1;
+a
+10
+8
+DROP TABLE t1;
+CREATE TABLE t1 (
+a INT,
+b bigint(20) UNSIGNED NOT NULL,
+PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;ttl_col=b;';
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+INSERT INTO t1 values (3, UNIX_TIMESTAMP());
+INSERT INTO t1 values (5, UNIX_TIMESTAMP());
+INSERT INTO t1 values (7, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 300;
+UPDATE t1 SET b=UNIX_TIMESTAMP() WHERE a < 4;
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT a FROM t1;
+a
+1
+3
+5
+7
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT a FROM t1;
+a
+1
+3
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1);
+INSERT INTO t1 values (2);
+INSERT INTO t1 values (3);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_enable_ttl=0;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_enable_ttl=1;
+set global rocksdb_compact_cf='default';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+variable_value-@c
+3
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+INSERT INTO t1 values (1);
+INSERT INTO t1 values (2);
+INSERT INTO t1 values (3);
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+variable_value-@c
+0
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/ttl_primary_read_filtering.result b/storage/rocksdb/mysql-test/rocksdb/r/ttl_primary_read_filtering.result
new file mode 100644
index 00000000..558924e6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/ttl_primary_read_filtering.result
@@ -0,0 +1,283 @@
+CREATE TABLE t1 (
+a int PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1);
+INSERT INTO t1 values (2);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+SELECT * FROM t1;
+a
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_compact_cf='default';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+variable_value-@c
+2
+DROP TABLE t1;
+CREATE TABLE t1 (
+a int PRIMARY KEY,
+b BIGINT UNSIGNED NOT NULL
+) ENGINE=rocksdb
+COMMENT='ttl_duration=10;';
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (2, UNIX_TIMESTAMP());
+INSERT INTO t1 values (3, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+SELECT a FROM t1;
+a
+2
+3
+set global rocksdb_compact_cf='default';
+SELECT a FROM t1;
+a
+2
+3
+set global rocksdb_debug_ttl_read_filter_ts = -310;
+SELECT a FROM t1;
+a
+set global rocksdb_debug_ttl_read_filter_ts = 0;
+DROP TABLE t1;
+CREATE TABLE t1 (
+a int PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1);
+INSERT INTO t1 values (3);
+INSERT INTO t1 values (5);
+INSERT INTO t1 values (7);
+set global rocksdb_debug_ttl_rec_ts = 0;
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+SELECT * FROM t1;
+a
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+variable_value-@a
+4
+set global rocksdb_enable_ttl_read_filtering=0;
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+SELECT * FROM t1;
+a
+1
+3
+5
+7
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+variable_value-@a
+0
+set global rocksdb_enable_ttl_read_filtering=1;
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+SELECT * FROM t1;
+a
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+variable_value-@a
+4
+DROP TABLE t1;
+set global ROCKSDB_COMPACT_CF= 'default';
+CREATE TABLE t1 (
+a int,
+b int,
+c int,
+PRIMARY KEY (a,b,c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (0,0,0);
+INSERT INTO t1 values (0,0,1);
+INSERT INTO t1 values (0,1,0);
+INSERT INTO t1 values (0,1,1);
+INSERT INTO t1 values (1,1,2);
+INSERT INTO t1 values (1,2,1);
+INSERT INTO t1 values (1,2,2);
+INSERT INTO t1 values (1,2,3);
+set global rocksdb_debug_ttl_rec_ts = 0;
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_force_flush_memtable_now=1;
+SELECT * FROM t1 WHERE a=1 AND b=2 AND c=2;
+a b c
+SELECT * FROM t1 WHERE a = 1;
+a b c
+SELECT max(a) from t1 where a < 3;
+max(a)
+NULL
+SELECT max(a) from t1 where a < 2 AND b = 1 AND c < 3;
+max(a)
+NULL
+SELECT min(a) from t1 where a >= 1;
+min(a)
+NULL
+SELECT min(a) from t1 where a > 1;
+min(a)
+NULL
+select * from t1 where a=1 and b in (1) order by c desc;
+a b c
+select max(a) from t1 where a <=10;
+max(a)
+NULL
+select a from t1 where a > 0 and a <= 2;
+a
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+variable_value-@c
+0
+set global rocksdb_compact_cf='default';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+variable_value-@c
+8
+DROP TABLE t1;
+CREATE TABLE t1 (
+a int PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+set global rocksdb_debug_ttl_rec_ts = -110;
+INSERT INTO t1 values (1);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT * FROM t1;
+a
+INSERT INTO t1 values (1);
+SELECT * FROM t1;
+a
+1
+DROP TABLE t1;
+set global rocksdb_force_flush_memtable_now=1;
+CREATE TABLE t1 (
+a int PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT * FROM t1;
+a
+UPDATE t1 set a = 1;
+DROP TABLE t1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+CREATE TABLE t1 (
+a int PRIMARY KEY,
+b int
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+set global rocksdb_debug_ttl_rec_ts = -110;
+INSERT INTO t1 values (1,1);
+INSERT INTO t1 values (3,3);
+set global rocksdb_debug_ttl_rec_ts = 0;
+INSERT INTO t1 values (5,5);
+UPDATE t1 set a = 1;
+SELECT * FROM t1;
+a b
+1 5
+set global rocksdb_enable_ttl_read_filtering=0;
+SELECT * FROM t1;
+a b
+1 5
+3 3
+set global rocksdb_enable_ttl_read_filtering=1;
+UPDATE t1 set a = 999 where a = 1;
+SELECT * FROM t1;
+a b
+999 5
+UPDATE t1 set a = a - 1;
+SELECT * FROM t1;
+a b
+998 5
+DROP TABLE t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+CREATE TABLE t1 (
+a int PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;';
+INSERT INTO t1 values (1);
+connection con1;
+# Creating Snapshot (start transaction)
+BEGIN;
+SELECT * FROM t1;
+a
+1
+SELECT * FROM t1;
+a
+1
+# Switching to connection 2
+connection con2;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+SELECT * FROM t1;
+a
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+variable_value-@a
+1
+# Switching to connection 1
+connection con1;
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+SELECT * FROM t1;
+a
+1
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+variable_value-@a
+0
+UPDATE t1 set a = a + 1;
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+SELECT * FROM t1;
+a
+2
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+variable_value-@a
+0
+COMMIT;
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+SELECT * FROM t1;
+a
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+variable_value-@a
+1
+DROP TABLE t1;
+disconnect con1;
+disconnect con2;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+CREATE TABLE t1 (
+a int PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+# On Connection 1
+connection con1;
+# Creating Snapshot (start transaction)
+BEGIN;
+SELECT * FROM t1;
+a
+# On Connection 2
+connection con2;
+set global rocksdb_debug_ttl_rec_ts = -2;
+INSERT INTO t1 values (1);
+INSERT INTO t1 values (3);
+INSERT INTO t1 values (5);
+INSERT INTO t1 values (7);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+# On Connection 1
+connection con1;
+SELECT * FROM t1;
+a
+# On Connection 2
+connection con2;
+SELECT * FROM t1;
+a
+set global rocksdb_enable_ttl_read_filtering=0;
+SELECT * FROM t1;
+a
+1
+3
+5
+7
+set global rocksdb_enable_ttl_read_filtering=1;
+disconnect con2;
+disconnect con1;
+connection default;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/ttl_primary_with_partitions.result b/storage/rocksdb/mysql-test/rocksdb/r/ttl_primary_with_partitions.result
new file mode 100644
index 00000000..d6d9e290
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/ttl_primary_with_partitions.result
@@ -0,0 +1,256 @@
+CREATE TABLE t1 (
+c1 INT,
+PRIMARY KEY (`c1`)
+) ENGINE=ROCKSDB
+COMMENT="custom_p0_ttl_duration=1;"
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 4, 7),
+PARTITION custom_p1 VALUES IN (2, 5, 8),
+PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+set global rocksdb_debug_ttl_rec_ts = -3600;
+INSERT INTO t1 values (1);
+INSERT INTO t1 values (2);
+INSERT INTO t1 values (3);
+INSERT INTO t1 values (4);
+INSERT INTO t1 values (5);
+INSERT INTO t1 values (6);
+INSERT INTO t1 values (7);
+INSERT INTO t1 values (8);
+INSERT INTO t1 values (9);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT * FROM t1;
+c1
+1
+2
+3
+4
+5
+6
+7
+8
+9
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT * FROM t1;
+c1
+2
+3
+5
+6
+8
+9
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+name VARCHAR(25) NOT NULL,
+PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=my_custom_cf;custom_p2_cfname=baz'
+) ENGINE=ROCKSDB
+COMMENT="custom_p0_ttl_duration=1;custom_p1_ttl_duration=7;"
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 4, 7),
+PARTITION custom_p1 VALUES IN (2, 5, 8),
+PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+set global rocksdb_debug_ttl_rec_ts = -1200;
+INSERT INTO t1 values (1,1,'a');
+INSERT INTO t1 values (4,4,'aaaa');
+INSERT INTO t1 values (7,7,'aaaaaaa');
+set global rocksdb_debug_ttl_rec_ts = 1200;
+INSERT INTO t1 values (2,2,'aa');
+INSERT INTO t1 values (3,3,'aaa');
+INSERT INTO t1 values (5,5,'aaaaa');
+INSERT INTO t1 values (6,6,'aaaaaa');
+INSERT INTO t1 values (8,8,'aaaaaaaa');
+INSERT INTO t1 values (9,9,'aaaaaaaaa');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT * FROM t1;
+c1 c2 name
+1 1 a
+2 2 aa
+3 3 aaa
+4 4 aaaa
+5 5 aaaaa
+6 6 aaaaaa
+7 7 aaaaaaa
+8 8 aaaaaaaa
+9 9 aaaaaaaaa
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'my_custom_cf';
+SELECT * FROM t1;
+c1 c2 name
+2 2 aa
+3 3 aaa
+5 5 aaaaa
+6 6 aaaaaa
+8 8 aaaaaaaa
+9 9 aaaaaaaaa
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set @@global.rocksdb_compact_cf = 'foo';
+SELECT * FROM t1;
+c1 c2 name
+2 2 aa
+3 3 aaa
+5 5 aaaaa
+6 6 aaaaaa
+8 8 aaaaaaaa
+9 9 aaaaaaaaa
+set @@global.rocksdb_compact_cf = 'my_custom_cf';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT * FROM t1;
+c1 c2 name
+3 3 aaa
+6 6 aaaaaa
+9 9 aaaaaaaaa
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+name VARCHAR(25) NOT NULL,
+event DATE,
+PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz;'
+) ENGINE=ROCKSDB
+COMMENT="custom_p0_ttl_duration=9999;custom_p2_ttl_duration=5;"
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 2, 3),
+PARTITION custom_p1 VALUES IN (4, 5, 6),
+PARTITION custom_p2 VALUES IN (7, 8, 9)
+);
+INSERT INTO t1 VALUES (1, 1, "one", null);
+INSERT INTO t1 VALUES (2, 2, "two", null);
+INSERT INTO t1 VALUES (3, 3, "three", null);
+INSERT INTO t1 VALUES (4, 4, "four", null);
+INSERT INTO t1 VALUES (5, 5, "five", null);
+INSERT INTO t1 VALUES (6, 6, "six", null);
+INSERT INTO t1 VALUES (7, 7, "seven", null);
+INSERT INTO t1 VALUES (8, 8, "eight", null);
+INSERT INTO t1 VALUES (9, 9, "nine", null);
+SELECT * FROM t1;
+c1 c2 name event
+1 1 one NULL
+2 2 two NULL
+3 3 three NULL
+4 4 four NULL
+5 5 five NULL
+6 6 six NULL
+7 7 seven NULL
+8 8 eight NULL
+9 9 nine NULL
+set global rocksdb_debug_ttl_rec_ts = 600;
+ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(`c2`,`c1`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz;';
+set global rocksdb_debug_ttl_rec_ts = 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) NOT NULL,
+ `c2` int(11) NOT NULL,
+ `name` varchar(25) NOT NULL,
+ `event` date DEFAULT NULL,
+ PRIMARY KEY (`c2`,`c1`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz;'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COMMENT='custom_p0_ttl_duration=9999;custom_p2_ttl_duration=5;'
+ PARTITION BY LIST (`c1`)
+(PARTITION `custom_p0` VALUES IN (1,2,3) ENGINE = ROCKSDB,
+ PARTITION `custom_p1` VALUES IN (4,5,6) ENGINE = ROCKSDB,
+ PARTITION `custom_p2` VALUES IN (7,8,9) ENGINE = ROCKSDB)
+set global rocksdb_debug_ttl_snapshot_ts = 100;
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'baz';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT * FROM t1;
+c1 c2 name event
+1 1 one NULL
+2 2 two NULL
+3 3 three NULL
+4 4 four NULL
+5 5 five NULL
+6 6 six NULL
+7 7 seven NULL
+8 8 eight NULL
+9 9 nine NULL
+set global rocksdb_debug_ttl_snapshot_ts = 1200;
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'baz';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT * FROM t1;
+c1 c2 name event
+1 1 one NULL
+2 2 two NULL
+3 3 three NULL
+4 4 four NULL
+5 5 five NULL
+6 6 six NULL
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 BIGINT,
+c2 BIGINT UNSIGNED NOT NULL,
+name VARCHAR(25) NOT NULL,
+event DATE,
+PRIMARY KEY (`c1`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz;'
+) ENGINE=ROCKSDB
+COMMENT="ttl_duration=1;custom_p1_ttl_duration=100;custom_p1_ttl_col=c2;custom_p2_ttl_duration=5000;"
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 2, 3),
+PARTITION custom_p1 VALUES IN (4, 5, 6),
+PARTITION custom_p2 VALUES IN (7, 8, 9)
+);
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 VALUES (1, UNIX_TIMESTAMP(), "one", null);
+INSERT INTO t1 VALUES (2, UNIX_TIMESTAMP(), "two", null);
+INSERT INTO t1 VALUES (3, UNIX_TIMESTAMP(), "three", null);
+set global rocksdb_debug_ttl_rec_ts = 0;
+INSERT INTO t1 VALUES (4, UNIX_TIMESTAMP(), "four", null);
+INSERT INTO t1 VALUES (5, UNIX_TIMESTAMP(), "five", null);
+INSERT INTO t1 VALUES (6, UNIX_TIMESTAMP(), "six", null);
+INSERT INTO t1 VALUES (7, UNIX_TIMESTAMP(), "seven", null);
+INSERT INTO t1 VALUES (8, UNIX_TIMESTAMP(), "eight", null);
+INSERT INTO t1 VALUES (9, UNIX_TIMESTAMP(), "nine", null);
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'baz';
+set @@global.rocksdb_compact_cf = 'bar';
+SELECT c1 FROM t1;
+c1
+4
+5
+6
+7
+8
+9
+set global rocksdb_debug_ttl_snapshot_ts = 600;
+set @@global.rocksdb_compact_cf = 'bar';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT c1 FROM t1;
+c1
+7
+8
+9
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 BIGINT,
+c2 BIGINT UNSIGNED NOT NULL,
+PRIMARY KEY (`c1`, `c2`)
+) ENGINE=ROCKSDB
+COMMENT="ttl_duration=100;ttl_col=c2;"
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1),
+PARTITION custom_p1 VALUES IN (2),
+PARTITION custom_p2 VALUES IN (3)
+);
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, UNIX_TIMESTAMP());
+INSERT INTO t1 values (3, UNIX_TIMESTAMP());
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT c1 FROM t1;
+c1
+1
+2
+3
+set global rocksdb_debug_ttl_snapshot_ts = 300;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT c1 FROM t1;
+c1
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/ttl_rows_examined.result b/storage/rocksdb/mysql-test/rocksdb/r/ttl_rows_examined.result
new file mode 100644
index 00000000..97a2eff5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/ttl_rows_examined.result
@@ -0,0 +1,45 @@
+set debug_sync='RESET';
+set global rocksdb_debug_ttl_read_filter_ts = -10;
+connect conn1, localhost, root,,test;
+connect conn2, localhost, root,,test;
+connection conn1;
+CREATE TABLE t_re (
+a INT, b INT, PRIMARY KEY (a)
+) ENGINE=ROCKSDB
+COMMENT 'ttl_duration=1';
+affected rows: 0
+set global rocksdb_debug_ttl_rec_ts = -13;
+affected rows: 0
+insert into t_re values (1,1);
+affected rows: 1
+insert into t_re values (2,2);
+affected rows: 1
+set global rocksdb_debug_ttl_rec_ts = 0;
+affected rows: 0
+commit;
+affected rows: 0
+set debug_sync='rocksdb.ttl_rows_examined SIGNAL parked WAIT_FOR go';
+affected rows: 0
+SELECT * FROM t_re;
+connection conn2;
+set debug_sync='now WAIT_FOR parked';
+affected rows: 0
+SHOW PROCESSLIST;
+Id User Host db Command Time State Info Progress
+### ### ### ### Query ### debug sync point: rocksdb.ttl_rows_examined SELECT * FROM t_re 0.000
+### ### ### ### Query ### starting SHOW PROCESSLIST 0.000
+### ### ### ### Sleep ### NULL 0.000
+affected rows: 3
+set debug_sync='now SIGNAL go';
+affected rows: 0
+connection conn1;
+a b
+affected rows: 0
+set debug_sync='RESET';
+affected rows: 0
+set global rocksdb_debug_ttl_read_filter_ts = DEFAULT;
+affected rows: 0
+drop table t_re;
+affected rows: 0
+disconnect conn1;
+disconnect conn2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary.result b/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary.result
new file mode 100644
index 00000000..1f748a38
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary.result
@@ -0,0 +1,709 @@
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64) NOT NULL,
+`c` varbinary(256) NOT NULL,
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`b`,`a`,`c`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', 'b', 'c', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('d', 'e', 'f', UNIX_TIMESTAMP(), 'g');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+2
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+2
+DROP TABLE t1;
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64) NOT NULL,
+`c` varbinary(256) NOT NULL,
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`b`,`a`,`c`),
+KEY kb (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', 'b', 'c', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('d', 'e', 'f', UNIX_TIMESTAMP(), 'g');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+2
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+b int NOT NULL,
+ts bigint(20) UNSIGNED NOT NULL,
+c int NOT NULL,
+PRIMARY KEY (a),
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, UNIX_TIMESTAMP(), 5);
+INSERT INTO t1 values (2, 4, UNIX_TIMESTAMP(), 6);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+2
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+ts bigint(20) UNSIGNED NOT NULL,
+PRIMARY KEY (a,c),
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, 5, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, 4, 6, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+2
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+b int,
+c int,
+ts bigint(20) UNSIGNED NOT NULL,
+PRIMARY KEY (a),
+KEY kbc (b, c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, NULL, NULL, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, NULL, NULL, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+2
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64),
+`c` varbinary(256),
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`a`),
+KEY kbc (`b`, `c`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', NULL, 'bc', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('d', 'efghijk', NULL, UNIX_TIMESTAMP(), 'l');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+2
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+PRIMARY KEY (a),
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, 5);
+INSERT INTO t1 values (2, 4, 6);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+2
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a int,
+ts bigint(20) UNSIGNED NOT NULL,
+PRIMARY KEY (a, ts),
+KEY kt (ts)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;ttl_col=ts;';
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, UNIX_TIMESTAMP());
+SELECT COUNT(*) FROM t1 FORCE INDEX(kt);
+COUNT(*)
+2
+set global rocksdb_debug_ttl_snapshot_ts = -10;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX(kt);
+COUNT(*)
+2
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_debug_ttl_snapshot_ts = 10;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT COUNT(*) FROM t1 FORCE INDEX(kt);
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+b int NOT NULL,
+ts bigint(20) UNSIGNED NOT NULL,
+c int NOT NULL,
+PRIMARY KEY (a, ts),
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, UNIX_TIMESTAMP(), 5);
+INSERT INTO t1 values (2, 4, UNIX_TIMESTAMP(), 6);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+2
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64),
+`c` varbinary(256),
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`a`, `ts`),
+KEY kb (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', NULL, 'bc', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('de', 'fghijk', NULL, UNIX_TIMESTAMP(), 'l');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+2
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a INT NOT NULL,
+b varbinary(64) NOT NULL,
+c varbinary(256) NOT NULL,
+ts bigint(20) UNSIGNED NOT NULL,
+value mediumblob NOT NULL,
+PRIMARY KEY (b,a,c),
+KEY kb (b)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=10;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, 'b', 'c', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values (2, 'e', 'f', UNIX_TIMESTAMP(), 'g');
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (3, 'i', 'j', UNIX_TIMESTAMP(), 'k');
+INSERT INTO t1 values (4, 'm', 'n', UNIX_TIMESTAMP(), 'o');
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_debug_ttl_snapshot_ts = -3600;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT a FROM t1 FORCE INDEX (kb);
+a
+1
+2
+3
+4
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT a FROM t1 FORCE INDEX (kb);
+a
+3
+4
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT a FROM t1 FORCE INDEX (kb);
+a
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) UNSIGNED NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+ts bigint(20),
+PRIMARY KEY (a,c),
+KEY (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+ERROR HY000: TTL column (ts) in MyRocks must be an unsigned non-null 64-bit integer, exist inside the table, and have an accompanying ttl duration.
+CREATE TABLE t1 (
+a bigint(20) UNSIGNED NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+ts int,
+PRIMARY KEY (a,c),
+KEY (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+ERROR HY000: TTL column (ts) in MyRocks must be an unsigned non-null 64-bit integer, exist inside the table, and have an accompanying ttl duration.
+CREATE TABLE t1 (
+a bigint(20) UNSIGNED NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+PRIMARY KEY (a,c),
+KEY (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=abc;';
+ERROR HY000: TTL duration (abc) in MyRocks must be an unsigned non-null 64-bit integer.
+CREATE TABLE t1 (
+a bigint(20) UNSIGNED NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+PRIMARY KEY (a,c),
+KEY (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=abc;';
+ERROR HY000: TTL column (abc) in MyRocks must be an unsigned non-null 64-bit integer, exist inside the table, and have an accompanying ttl duration.
+CREATE TABLE t1 (
+a bigint(20) UNSIGNED NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+PRIMARY KEY (a,c),
+KEY (b)
+) ENGINE=rocksdb
+COMMENT='ttl_col=abc;';
+ERROR HY000: TTL column (abc) in MyRocks must be an unsigned non-null 64-bit integer, exist inside the table, and have an accompanying ttl duration.
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+b int NOT NULL,
+PRIMARY KEY (a),
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=500;';
+INSERT INTO t1 values (1, 1);
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+1
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+1
+DROP TABLE t1;
+CREATE TABLE t1 (
+a INT PRIMARY KEY,
+b INT NOT NULL,
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+INSERT INTO t1 values (1, 1);
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+1 1
+set global rocksdb_debug_ttl_rec_ts = -300;
+ALTER TABLE t1 COMMENT = 'ttl_duration=1';
+set global rocksdb_debug_ttl_rec_ts = 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) NOT NULL,
+ PRIMARY KEY (`a`),
+ KEY `kb` (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COMMENT='ttl_duration=1'
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a INT PRIMARY KEY,
+b INT,
+KEY (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+ALTER TABLE t1 DROP PRIMARY KEY;
+ERROR HY000: TTL support is currently disabled when table has a hidden PK.
+DROP TABLE t1;
+CREATE TABLE t1 (
+a INT PRIMARY KEY,
+b INT,
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;';
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (2,2);
+ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b);
+set global rocksdb_debug_ttl_snapshot_ts = -3600;
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+2
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) UNSIGNED NOT NULL,
+b int,
+PRIMARY KEY (a,b),
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='asdadfasdfsadfadf ;ttl_duration=1; asfasdfasdfadfa';
+INSERT INTO t1 values (UNIX_TIMESTAMP(), 1);
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+1
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+0
+ALTER TABLE t1 COMMENT = 'adsf;;ttl_duration=5;asfasdfa;ttl_col=a;asdfasdf;';
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (UNIX_TIMESTAMP(), 2);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+1
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+b int NOT NULL,
+PRIMARY KEY (a),
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;';
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, 0);
+INSERT INTO t1 values (3, 0);
+INSERT INTO t1 values (5, 0);
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (7, 0);
+INSERT INTO t1 values (9, 0);
+set global rocksdb_debug_ttl_rec_ts = 0;
+UPDATE t1 SET a=a+1;
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+10 0
+2 0
+4 0
+6 0
+8 0
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT * FROM t1;
+a b
+10 0
+8 0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a INT,
+b bigint(20) UNSIGNED NOT NULL,
+PRIMARY KEY (a),
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;ttl_col=b;';
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+INSERT INTO t1 values (3, UNIX_TIMESTAMP());
+INSERT INTO t1 values (5, UNIX_TIMESTAMP());
+INSERT INTO t1 values (7, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 300;
+UPDATE t1 SET b=(UNIX_TIMESTAMP()+1) WHERE a < 4;
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT a FROM t1 FORCE INDEX (kb);
+a
+1
+3
+5
+7
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT a FROM t1 FORCE INDEX (kb);
+a
+1
+3
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+b int NOT NULL,
+PRIMARY KEY (a),
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 1);
+INSERT INTO t1 values (2, 1);
+INSERT INTO t1 values (3, 1);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_enable_ttl=0;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_enable_ttl=1;
+set global rocksdb_compact_cf='default';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+variable_value-@c
+6
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a bigint(20) NOT NULL,
+b int NOT NULL,
+PRIMARY KEY (a),
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+INSERT INTO t1 values (1, 1);
+INSERT INTO t1 values (2, 2);
+INSERT INTO t1 values (3, 3);
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+variable_value-@c
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+a INT,
+b bigint(20) UNSIGNED NOT NULL,
+PRIMARY KEY (a, b),
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;ttl_col=b;';
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+INSERT INTO t1 values (3, UNIX_TIMESTAMP());
+INSERT INTO t1 values (5, UNIX_TIMESTAMP());
+INSERT INTO t1 values (7, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 300;
+UPDATE t1 SET b=(UNIX_TIMESTAMP()+1) WHERE a < 4;
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT a FROM t1 FORCE INDEX (kb);
+a
+1
+3
+5
+7
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT a FROM t1 FORCE INDEX (kb);
+a
+1
+3
+DROP TABLE t1;
+CREATE TABLE t1 (
+a INT,
+b bigint(20) UNSIGNED NOT NULL,
+PRIMARY KEY (a, b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;ttl_col=b;';
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+INSERT INTO t1 values (3, UNIX_TIMESTAMP());
+INSERT INTO t1 values (5, UNIX_TIMESTAMP());
+INSERT INTO t1 values (7, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 300;
+UPDATE t1 SET b=(UNIX_TIMESTAMP()+1) WHERE a < 4;
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT a FROM t1;
+a
+1
+3
+5
+7
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT a FROM t1;
+a
+1
+3
+DROP TABLE t1;
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64) NOT NULL,
+`c` varbinary(256) NOT NULL,
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`b`,`a`,`c`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', 'b', 'c', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('d', 'e', 'f', UNIX_TIMESTAMP(), 'g');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*);
+COUNT(*)
+1
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+SELECT COUNT(*);
+COUNT(*)
+1
+CREATE INDEX kb on t1 (b);
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64) NOT NULL,
+`c` varbinary(256) NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`b`,`a`,`c`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', 'b', 'c', 'd');
+INSERT INTO t1 values ('d', 'e', 'f', 'g');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*);
+COUNT(*)
+1
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+SELECT COUNT(*);
+COUNT(*)
+1
+CREATE INDEX kb on t1 (b);
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+0
+DROP TABLE t1;
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64) NOT NULL,
+`c` varbinary(256) NOT NULL,
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`b`,`a`,`c`, `ts`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', 'b', 'c', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('d', 'e', 'f', UNIX_TIMESTAMP(), 'g');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*);
+COUNT(*)
+1
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+SELECT COUNT(*);
+COUNT(*)
+1
+CREATE INDEX kb on t1 (b);
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+COUNT(*)
+0
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_read_filtering.result b/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_read_filtering.result
new file mode 100644
index 00000000..395c84ed
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_read_filtering.result
@@ -0,0 +1,511 @@
+CREATE TABLE t1 (
+a int PRIMARY KEY,
+b int NOT NULL,
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 1);
+INSERT INTO t1 values (2, 2);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+variable_value-@c
+2
+DROP TABLE t1;
+CREATE TABLE t1 (
+a int PRIMARY KEY,
+b BIGINT UNSIGNED NOT NULL,
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=10;';
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (2, UNIX_TIMESTAMP());
+INSERT INTO t1 values (3, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+# 1 should be hidden
+SELECT a FROM t1 FORCE INDEX (PRIMARY);
+a
+2
+3
+SELECT a FROM t1 FORCE INDEX (kb);
+a
+2
+3
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+# none should be hidden yet, compaction runs but records aren't expired
+SELECT a FROM t1 FORCE INDEX (PRIMARY);
+a
+2
+3
+SELECT a FROM t1 FORCE INDEX (kb);
+a
+2
+3
+# all should be hidden now, even though compaction hasn't run again
+set global rocksdb_debug_ttl_read_filter_ts = -310;
+SELECT a FROM t1 FORCE INDEX (PRIMARY);
+a
+SELECT a FROM t1 FORCE INDEX (kb);
+a
+set global rocksdb_debug_ttl_read_filter_ts = 0;
+DROP TABLE t1;
+CREATE TABLE t1 (
+a int PRIMARY KEY,
+b int NOT NULL,
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 1);
+INSERT INTO t1 values (3, 3);
+INSERT INTO t1 values (5, 5);
+INSERT INTO t1 values (7, 7);
+set global rocksdb_debug_ttl_rec_ts = 0;
+# should return nothing.
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+set global rocksdb_enable_ttl_read_filtering=0;
+# should return everything
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+1 1
+3 3
+5 5
+7 7
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+1 1
+3 3
+5 5
+7 7
+set global rocksdb_enable_ttl_read_filtering=1;
+# should return nothing.
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+DROP TABLE t1;
+set global rocksdb_compact_cf= 'default';
+# Read filtering index scan tests (None of these queries should return any results)
+CREATE TABLE t1 (
+a int,
+b int,
+c int,
+PRIMARY KEY (a,b,c),
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (0,0,0);
+INSERT INTO t1 values (0,0,1);
+INSERT INTO t1 values (0,1,0);
+INSERT INTO t1 values (0,1,1);
+INSERT INTO t1 values (1,1,2);
+INSERT INTO t1 values (1,2,1);
+INSERT INTO t1 values (1,2,2);
+INSERT INTO t1 values (1,2,3);
+set global rocksdb_debug_ttl_rec_ts = 0;
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_force_flush_memtable_now=1;
+SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE a=1 AND b=2 AND c=2;
+a b c
+SELECT * FROM t1 FORCE INDEX (kb) WHERE a=1 AND b=2 AND c=2;
+a b c
+SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE a = 1;
+a b c
+SELECT * FROM t1 FORCE INDEX (kb) WHERE a = 1;
+a b c
+SELECT max(a) FROM t1 FORCE INDEX (PRIMARY) WHERE a < 3;
+max(a)
+NULL
+SELECT max(a) FROM t1 FORCE INDEX (kb) WHERE a < 3;
+max(a)
+NULL
+SELECT max(a) FROM t1 FORCE INDEX (PRIMARY) WHERE a < 2 AND b = 1 AND c < 3;
+max(a)
+NULL
+SELECT max(a) FROM t1 FORCE INDEX (kb) WHERE a < 2 AND b = 1 AND c < 3;
+max(a)
+NULL
+SELECT min(a) FROM t1 FORCE INDEX (PRIMARY) WHERE a >= 1;
+min(a)
+NULL
+SELECT min(a) FROM t1 FORCE INDEX (kb) WHERE a >= 1;
+min(a)
+NULL
+SELECT min(a) FROM t1 FORCE INDEX (PRIMARY) WHERE a > 1;
+min(a)
+NULL
+SELECT min(a) FROM t1 FORCE INDEX (kb) WHERE a > 1;
+min(a)
+NULL
+SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE a=1 and b in (1) order by c desc;
+a b c
+SELECT * FROM t1 FORCE INDEX (kb) WHERE a=1 and b in (1) order by c desc;
+a b c
+SELECT max(a) FROM t1 FORCE INDEX (PRIMARY) WHERE a <=10;
+max(a)
+NULL
+SELECT max(a) FROM t1 FORCE INDEX (kb) WHERE a <=10;
+max(a)
+NULL
+SELECT a FROM t1 FORCE INDEX (PRIMARY) WHERE a > 0 and a <= 2;
+a
+SELECT a FROM t1 FORCE INDEX (kb) WHERE a > 0 and a <= 2;
+a
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+variable_value-@c
+0
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+variable_value-@c
+8
+DROP TABLE t1;
+# Attempt to update expired value, should filter out
+set global rocksdb_force_flush_memtable_now=1;
+CREATE TABLE t1 (
+a int PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a
+SELECT * FROM t1;
+a
+# No error is thrown here, under the hood index_next_with_direction is
+# filtering out the record from being seen in the first place.
+UPDATE t1 set a = 1;
+DROP TABLE t1;
+# Ensure no rows can disappear in the middle of long-running transactions
+# Also ensure repeatable-read works as expected
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+CREATE TABLE t1 (
+a int PRIMARY KEY,
+b int NOT NULL,
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;';
+INSERT INTO t1 values (1, 1);
+connection con1;
+# Creating Snapshot (start transaction)
+BEGIN;
+# Nothing filtered out here
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+1 1
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+1 1
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+1 1
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+1 1
+# Switching to connection 2
+connection con2;
+# compaction doesn't do anything since con1 snapshot is still open
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+# read filtered out, because on a different connection, on
+# this connection the records have 'expired' already so they are filtered out
+# even though they have not yet been removed by compaction
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+# Switching to connection 1
+connection con1;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+1 1
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+1 1
+UPDATE t1 set a = a + 1;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+2 1
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+2 1
+COMMIT;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+DROP TABLE t1;
+disconnect con1;
+disconnect con2;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+CREATE TABLE t1 (
+a int PRIMARY KEY,
+b int NOT NULL,
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+# On Connection 1
+connection con1;
+# Creating Snapshot (start transaction)
+BEGIN;
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+# On Connection 2
+connection con2;
+set global rocksdb_debug_ttl_rec_ts = -2;
+INSERT INTO t1 values (1, 1);
+INSERT INTO t1 values (3, 3);
+INSERT INTO t1 values (5, 5);
+INSERT INTO t1 values (7, 7);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+# On Connection 1
+connection con1;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+# On Connection 2
+connection con2;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+set global rocksdb_enable_ttl_read_filtering=0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+1 1
+3 3
+5 5
+7 7
+SELECT * FROM t1 FORCE INDEX (kb);
+a b
+1 1
+3 3
+5 5
+7 7
+set global rocksdb_enable_ttl_read_filtering=1;
+disconnect con2;
+disconnect con1;
+connection default;
+DROP TABLE t1;
+CREATE TABLE t1 (
+a int,
+b int,
+ts bigint(20) UNSIGNED NOT NULL,
+PRIMARY KEY (a),
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+set global rocksdb_debug_ttl_rec_ts = 100;
+INSERT INTO t1 VALUES (1, 1, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (2, 2, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (3, 3, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (4, 4, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (5, 5, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (6, 6, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (7, 7, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (8, 8, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (9, 9, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (10, 10, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+# None are expired
+SELECT a, b FROM t1 FORCE INDEX (kb);
+a b
+1 1
+2 2
+3 3
+4 4
+5 5
+6 6
+7 7
+8 8
+9 9
+10 10
+set global rocksdb_debug_ttl_rec_ts = -100;
+UPDATE t1 SET ts=(UNIX_TIMESTAMP()+1) WHERE a IN (4, 7);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+# 4 and 7 should be gone
+SELECT a, b FROM t1 FORCE INDEX (kb);
+a b
+1 1
+2 2
+3 3
+5 5
+6 6
+8 8
+9 9
+10 10
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+name VARCHAR(25) NOT NULL,
+PRIMARY KEY (c1, c2),
+KEY kc2 (c2)
+) ENGINE=ROCKSDB
+COMMENT='ttl_duration=1;';
+set global rocksdb_debug_ttl_rec_ts = -1200;
+INSERT INTO t1 values (1,1,'a');
+INSERT INTO t1 values (2,2,'b');
+set global rocksdb_debug_ttl_rec_ts = 1200;
+INSERT INTO t1 values (3,3,'c');
+INSERT INTO t1 values (4,4,'d');
+set global rocksdb_debug_ttl_rec_ts = -1200;
+INSERT INTO t1 values (5,5,'e');
+INSERT INTO t1 values (6,6,'f');
+set global rocksdb_debug_ttl_rec_ts = 1200;
+INSERT INTO t1 values (7,7,'g');
+INSERT INTO t1 values (8,8,'h');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+c1 c2 name
+3 3 c
+4 4 d
+7 7 g
+8 8 h
+SELECT * FROM t1 FORCE INDEX (kc2);
+c1 c2 name
+3 3 c
+4 4 d
+7 7 g
+8 8 h
+SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE c1 > 5;
+c1 c2 name
+7 7 g
+8 8 h
+SELECT * FROM t1 FORCE INDEX (kc2) WHERE c2 > 5;
+c1 c2 name
+7 7 g
+8 8 h
+SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE 3 < c1 AND c1 < 6;
+c1 c2 name
+4 4 d
+SELECT * FROM t1 FORCE INDEX (kc2) WHERE 3 < c2 AND c2 < 6;
+c1 c2 name
+4 4 d
+DROP TABLE t1;
+CREATE TABLE t1 (
+a int,
+b int,
+PRIMARY KEY (a),
+KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1800;';
+set global rocksdb_debug_ttl_rec_ts = 0;
+INSERT INTO t1 values (1,1);
+INSERT INTO t1 values (2,2);
+INSERT INTO t1 values (7,7);
+INSERT INTO t1 values (10,10);
+INSERT INTO t1 values (11,11);
+INSERT INTO t1 values (12,12);
+set global rocksdb_debug_ttl_rec_ts = 450;
+INSERT INTO t1 values (3,3);
+INSERT INTO t1 values (4,4);
+INSERT INTO t1 values (8,8);
+INSERT INTO t1 values (16,16);
+INSERT INTO t1 values (17,17);
+INSERT INTO t1 values (18,18);
+set global rocksdb_debug_ttl_rec_ts = 900;
+INSERT INTO t1 values (5,5);
+INSERT INTO t1 values (6,6);
+INSERT INTO t1 values (9,9);
+INSERT INTO t1 values (13,13);
+INSERT INTO t1 values (14,14);
+INSERT INTO t1 values (15,15);
+set global rocksdb_debug_ttl_rec_ts = 0;
+# Should see everything
+SELECT * FROM t1;
+a b
+1 1
+2 2
+3 3
+4 4
+5 5
+6 6
+7 7
+8 8
+9 9
+10 10
+11 11
+12 12
+13 13
+14 14
+15 15
+16 16
+17 17
+18 18
+# Should have no records from the first group
+set global rocksdb_debug_ttl_read_filter_ts = -1800;
+SELECT * FROM t1;
+a b
+3 3
+4 4
+5 5
+6 6
+8 8
+9 9
+13 13
+14 14
+15 15
+16 16
+17 17
+18 18
+SELECT * FROM t1 FORCE INDEX (kb) WHERE a > 5 AND a < 15;
+a b
+6 6
+8 8
+9 9
+13 13
+14 14
+# Should only have records from the last group
+set global rocksdb_debug_ttl_read_filter_ts = -1800 - 450;
+SELECT * FROM t1;
+a b
+5 5
+6 6
+9 9
+13 13
+14 14
+15 15
+SELECT * FROM t1 FORCE INDEX (kb) WHERE a < 10;
+a b
+5 5
+6 6
+9 9
+# Should be empty
+set global rocksdb_debug_ttl_read_filter_ts = -1800 - 900;
+SELECT * FROM t1;
+a b
+set global rocksdb_debug_ttl_read_filter_ts = 0;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_read_filtering_multiple_index.result b/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_read_filtering_multiple_index.result
new file mode 100644
index 00000000..e4c36157
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_read_filtering_multiple_index.result
@@ -0,0 +1,82 @@
+CREATE TABLE t1 (
+a int NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+PRIMARY KEY (a),
+KEY kb (b) COMMENT 'kb',
+KEY kc (c) COMMENT 'kc'
+) ENGINE=ROCKSDB
+COMMENT='ttl_duration=1';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 1, 1);
+INSERT INTO t1 values (2, 2, 2);
+set global rocksdb_debug_ttl_rec_ts = 100;
+INSERT INTO t1 values (3, 3, 3);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='kb';
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b c
+3 3 3
+SELECT * FROM t1 FORCE INDEX (kb);
+a b c
+3 3 3
+SELECT * FROM t1 FORCE INDEX (kc);
+a b c
+3 3 3
+DROP TABLE t1;
+CREATE TABLE t1 (
+a int NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+PRIMARY KEY (a),
+KEY kb (b) COMMENT 'kb',
+KEY kc (c) COMMENT 'kc'
+) ENGINE=ROCKSDB
+COMMENT='ttl_duration=1';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 1, 1);
+INSERT INTO t1 values (2, 2, 2);
+set global rocksdb_debug_ttl_rec_ts = 100;
+INSERT INTO t1 values (3, 3, 3);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b c
+3 3 3
+SELECT * FROM t1 FORCE INDEX (kb);
+a b c
+3 3 3
+SELECT * FROM t1 FORCE INDEX (kc);
+a b c
+3 3 3
+DROP TABLE t1;
+CREATE TABLE t1 (
+a int NOT NULL,
+b int NOT NULL,
+c int NOT NULL,
+PRIMARY KEY (a),
+KEY kb (b) COMMENT 'kb',
+KEY kc (c) COMMENT 'kc'
+) ENGINE=ROCKSDB
+COMMENT='ttl_duration=1';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 1, 1);
+INSERT INTO t1 values (2, 2, 2);
+set global rocksdb_debug_ttl_rec_ts = 100;
+INSERT INTO t1 values (3, 3, 3);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_compact_cf='kb';
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b c
+3 3 3
+SELECT * FROM t1 FORCE INDEX (kb);
+a b c
+3 3 3
+SELECT * FROM t1 FORCE INDEX (kc);
+a b c
+3 3 3
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_with_partitions.result b/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_with_partitions.result
new file mode 100644
index 00000000..713c7e92
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/ttl_secondary_with_partitions.result
@@ -0,0 +1,389 @@
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+PRIMARY KEY (`c1`),
+KEY kc2 (`c2`)
+) ENGINE=ROCKSDB
+COMMENT="custom_p0_ttl_duration=1;"
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 4, 7),
+PARTITION custom_p1 VALUES IN (2, 5, 8),
+PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+set global rocksdb_debug_ttl_rec_ts = -3600;
+INSERT INTO t1 values (1, 1);
+INSERT INTO t1 values (2, 2);
+INSERT INTO t1 values (3, 3);
+INSERT INTO t1 values (4, 4);
+INSERT INTO t1 values (5, 5);
+INSERT INTO t1 values (6, 6);
+INSERT INTO t1 values (7, 7);
+INSERT INTO t1 values (8, 8);
+INSERT INTO t1 values (9, 9);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+c1 c2
+1 1
+2 2
+3 3
+4 4
+5 5
+6 6
+7 7
+8 8
+9 9
+SELECT * FROM t1 FORCE INDEX (kc2);
+c1 c2
+1 1
+2 2
+3 3
+4 4
+5 5
+6 6
+7 7
+8 8
+9 9
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+c1 c2
+2 2
+3 3
+5 5
+6 6
+8 8
+9 9
+SELECT * FROM t1 FORCE INDEX (kc2);
+c1 c2
+2 2
+3 3
+5 5
+6 6
+8 8
+9 9
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+name VARCHAR(25) NOT NULL,
+PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=my_custom_cf;custom_p2_cfname=baz',
+KEY kc2 (`c2`)
+) ENGINE=ROCKSDB
+COMMENT="custom_p0_ttl_duration=1;custom_p1_ttl_duration=7;"
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 4, 7),
+PARTITION custom_p1 VALUES IN (2, 5, 8),
+PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+set global rocksdb_debug_ttl_rec_ts = -1200;
+INSERT INTO t1 values (1,1,'a');
+INSERT INTO t1 values (4,4,'aaaa');
+INSERT INTO t1 values (7,7,'aaaaaaa');
+set global rocksdb_debug_ttl_rec_ts = 1200;
+INSERT INTO t1 values (2,2,'aa');
+INSERT INTO t1 values (3,3,'aaa');
+INSERT INTO t1 values (5,5,'aaaaa');
+INSERT INTO t1 values (6,6,'aaaaaa');
+INSERT INTO t1 values (8,8,'aaaaaaaa');
+INSERT INTO t1 values (9,9,'aaaaaaaaa');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+c1 c2 name
+1 1 a
+2 2 aa
+3 3 aaa
+4 4 aaaa
+5 5 aaaaa
+6 6 aaaaaa
+7 7 aaaaaaa
+8 8 aaaaaaaa
+9 9 aaaaaaaaa
+SELECT * FROM t1 FORCE INDEX (kc2);
+c1 c2 name
+1 1 a
+2 2 aa
+3 3 aaa
+4 4 aaaa
+5 5 aaaaa
+6 6 aaaaaa
+7 7 aaaaaaa
+8 8 aaaaaaaa
+9 9 aaaaaaaaa
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'my_custom_cf';
+set @@global.rocksdb_compact_cf = 'default';
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+c1 c2 name
+2 2 aa
+3 3 aaa
+5 5 aaaaa
+6 6 aaaaaa
+8 8 aaaaaaaa
+9 9 aaaaaaaaa
+SELECT * FROM t1 FORCE INDEX (kc2);
+c1 c2 name
+2 2 aa
+3 3 aaa
+5 5 aaaaa
+6 6 aaaaaa
+8 8 aaaaaaaa
+9 9 aaaaaaaaa
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set @@global.rocksdb_compact_cf = 'foo';
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+c1 c2 name
+2 2 aa
+3 3 aaa
+5 5 aaaaa
+6 6 aaaaaa
+8 8 aaaaaaaa
+9 9 aaaaaaaaa
+SELECT * FROM t1 FORCE INDEX (kc2);
+c1 c2 name
+2 2 aa
+3 3 aaa
+5 5 aaaaa
+6 6 aaaaaa
+8 8 aaaaaaaa
+9 9 aaaaaaaaa
+set @@global.rocksdb_compact_cf = 'my_custom_cf';
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+c1 c2 name
+3 3 aaa
+6 6 aaaaaa
+9 9 aaaaaaaaa
+SELECT * FROM t1 FORCE INDEX (kc2);
+c1 c2 name
+3 3 aaa
+6 6 aaaaaa
+9 9 aaaaaaaaa
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+name VARCHAR(25) NOT NULL,
+event DATE,
+PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz;',
+KEY kc2 (c2)
+) ENGINE=ROCKSDB
+COMMENT="custom_p0_ttl_duration=9999;custom_p2_ttl_duration=5;"
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 2, 3),
+PARTITION custom_p1 VALUES IN (4, 5, 6),
+PARTITION custom_p2 VALUES IN (7, 8, 9)
+);
+INSERT INTO t1 VALUES (1, 1, "one", null);
+INSERT INTO t1 VALUES (2, 2, "two", null);
+INSERT INTO t1 VALUES (3, 3, "three", null);
+INSERT INTO t1 VALUES (4, 4, "four", null);
+INSERT INTO t1 VALUES (5, 5, "five", null);
+INSERT INTO t1 VALUES (6, 6, "six", null);
+INSERT INTO t1 VALUES (7, 7, "seven", null);
+INSERT INTO t1 VALUES (8, 8, "eight", null);
+INSERT INTO t1 VALUES (9, 9, "nine", null);
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+c1 c2 name event
+1 1 one NULL
+2 2 two NULL
+3 3 three NULL
+4 4 four NULL
+5 5 five NULL
+6 6 six NULL
+7 7 seven NULL
+8 8 eight NULL
+9 9 nine NULL
+SELECT * FROM t1 FORCE INDEX (kc2);
+c1 c2 name event
+1 1 one NULL
+2 2 two NULL
+3 3 three NULL
+4 4 four NULL
+5 5 five NULL
+6 6 six NULL
+7 7 seven NULL
+8 8 eight NULL
+9 9 nine NULL
+set global rocksdb_debug_ttl_rec_ts = 600;
+ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(`c2`,`c1`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz;';
+set global rocksdb_debug_ttl_rec_ts = 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) NOT NULL,
+ `c2` int(11) NOT NULL,
+ `name` varchar(25) NOT NULL,
+ `event` date DEFAULT NULL,
+ PRIMARY KEY (`c2`,`c1`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz;',
+ KEY `kc2` (`c2`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COMMENT='custom_p0_ttl_duration=9999;custom_p2_ttl_duration=5;'
+ PARTITION BY LIST (`c1`)
+(PARTITION `custom_p0` VALUES IN (1,2,3) ENGINE = ROCKSDB,
+ PARTITION `custom_p1` VALUES IN (4,5,6) ENGINE = ROCKSDB,
+ PARTITION `custom_p2` VALUES IN (7,8,9) ENGINE = ROCKSDB)
+set global rocksdb_debug_ttl_snapshot_ts = 100;
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'baz';
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+c1 c2 name event
+1 1 one NULL
+2 2 two NULL
+3 3 three NULL
+4 4 four NULL
+5 5 five NULL
+6 6 six NULL
+7 7 seven NULL
+8 8 eight NULL
+9 9 nine NULL
+SELECT * FROM t1 FORCE INDEX (kc2);
+c1 c2 name event
+1 1 one NULL
+2 2 two NULL
+3 3 three NULL
+4 4 four NULL
+5 5 five NULL
+6 6 six NULL
+7 7 seven NULL
+8 8 eight NULL
+9 9 nine NULL
+set global rocksdb_debug_ttl_snapshot_ts = 1200;
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'baz';
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+c1 c2 name event
+1 1 one NULL
+2 2 two NULL
+3 3 three NULL
+4 4 four NULL
+5 5 five NULL
+6 6 six NULL
+SELECT * FROM t1 FORCE INDEX (kc2);
+c1 c2 name event
+1 1 one NULL
+2 2 two NULL
+3 3 three NULL
+4 4 four NULL
+5 5 five NULL
+6 6 six NULL
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 BIGINT,
+c2 BIGINT UNSIGNED NOT NULL,
+name VARCHAR(25) NOT NULL,
+event DATE,
+PRIMARY KEY (`c1`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz;',
+KEY kc2 (`c2`)
+) ENGINE=ROCKSDB
+COMMENT="ttl_duration=1;custom_p1_ttl_duration=100;custom_p1_ttl_col=c2;custom_p2_ttl_duration=5000;"
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 2, 3),
+PARTITION custom_p1 VALUES IN (4, 5, 6),
+PARTITION custom_p2 VALUES IN (7, 8, 9)
+);
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 VALUES (1, UNIX_TIMESTAMP(), "one", null);
+INSERT INTO t1 VALUES (2, UNIX_TIMESTAMP(), "two", null);
+INSERT INTO t1 VALUES (3, UNIX_TIMESTAMP(), "three", null);
+set global rocksdb_debug_ttl_rec_ts = 0;
+INSERT INTO t1 VALUES (4, UNIX_TIMESTAMP(), "four", null);
+INSERT INTO t1 VALUES (5, UNIX_TIMESTAMP(), "five", null);
+INSERT INTO t1 VALUES (6, UNIX_TIMESTAMP(), "six", null);
+INSERT INTO t1 VALUES (7, UNIX_TIMESTAMP(), "seven", null);
+INSERT INTO t1 VALUES (8, UNIX_TIMESTAMP(), "eight", null);
+INSERT INTO t1 VALUES (9, UNIX_TIMESTAMP(), "nine", null);
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'baz';
+set @@global.rocksdb_compact_cf = 'bar';
+set @@global.rocksdb_compact_cf = 'default';
+SELECT c1 FROM t1 FORCE INDEX (PRIMARY);
+c1
+4
+5
+6
+7
+8
+9
+SELECT c1 FROM t1 FORCE INDEX (kc2);
+c1
+4
+5
+6
+7
+8
+9
+set global rocksdb_debug_ttl_snapshot_ts = 600;
+set @@global.rocksdb_compact_cf = 'bar';
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT c1 FROM t1 FORCE INDEX (PRIMARY);
+c1
+7
+8
+9
+SELECT c1 FROM t1 FORCE INDEX (kc2);
+c1
+7
+8
+9
+DROP TABLE t1;
+CREATE TABLE t1 (
+c1 INT,
+c2 INT,
+PRIMARY KEY (`c1`) COMMENT 'custom_p0_cfname=foo;'
+) ENGINE=ROCKSDB
+COMMENT="custom_p0_ttl_duration=1;"
+PARTITION BY LIST(c1) (
+PARTITION custom_p0 VALUES IN (1, 4, 7),
+PARTITION custom_p1 VALUES IN (2, 5, 8),
+PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+set global rocksdb_debug_ttl_rec_ts = -3600;
+INSERT INTO t1 values (1, 1);
+INSERT INTO t1 values (4, 4);
+INSERT INTO t1 values (7, 7);
+set global rocksdb_debug_ttl_rec_ts = 0;
+INSERT INTO t1 values (2, 2);
+INSERT INTO t1 values (3, 3);
+INSERT INTO t1 values (5, 5);
+INSERT INTO t1 values (6, 6);
+INSERT INTO t1 values (8, 8);
+INSERT INTO t1 values (9, 9);
+SELECT * FROM t1;
+c1 c2
+1 1
+2 2
+3 3
+4 4
+5 5
+6 6
+7 7
+8 8
+9 9
+CREATE INDEX kc2 on t1 (c2);
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='foo';
+set global rocksdb_compact_cf='default';
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+c1 c2
+2 2
+3 3
+5 5
+6 6
+8 8
+9 9
+SELECT * FROM t1 FORCE INDEX (kc2);
+c1 c2
+2 2
+3 3
+5 5
+6 6
+8 8
+9 9
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_binary.result b/storage/rocksdb/mysql-test/rocksdb/r/type_binary.result
new file mode 100644
index 00000000..bbdd6d21
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_binary.result
@@ -0,0 +1,48 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+b BINARY ,
+b0 BINARY(0) ,
+b1 BINARY(1) ,
+b20 BINARY(20) ,
+b255 BINARY(255) ,
+pk BINARY PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b binary(1) YES NULL
+b0 binary(0) YES NULL
+b1 binary(1) YES NULL
+b20 binary(20) YES NULL
+b255 binary(255) YES NULL
+pk binary(1) NO PRI NULL
+INSERT INTO t1 VALUES ('','','','','','');
+INSERT INTO t1 VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.','a');
+SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255), HEX(pk) FROM t1 ORDER BY pk;
+HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255) HEX(pk)
+00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00
+61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000 61
+INSERT INTO t1 VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256),'b');
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b0' at row 1
+Warning 1265 Data truncated for column 'b1' at row 1
+Warning 1265 Data truncated for column 'b20' at row 1
+Warning 1265 Data truncated for column 'b255' at row 1
+INSERT INTO t1 SELECT b255, b255, b255, b255, CONCAT('a',b255,b255), 'c' FROM t1;
+ERROR 23000: Duplicate entry 'c' for key 'PRIMARY'
+SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255), HEX(pk) FROM t1 ORDER BY pk;
+HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255) HEX(pk)
+00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00
+61 61 6161616161616161616161616161616161616161 787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 62
+61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000 61
+ALTER TABLE t1 ADD COLUMN b257 BINARY(257) ;
+ERROR 42000: Column length too big for column 'b257' (max = 255); use BLOB or TEXT instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b binary(1) YES NULL
+b0 binary(0) YES NULL
+b1 binary(1) YES NULL
+b20 binary(20) YES NULL
+b255 binary(255) YES NULL
+pk binary(1) NO PRI NULL
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_binary_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_binary_indexes.result
new file mode 100644
index 00000000..c5cffdc1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_binary_indexes.result
@@ -0,0 +1,80 @@
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (b BINARY,
+b20 BINARY(20) PRIMARY KEY,
+v16 VARBINARY(16),
+v128 VARBINARY(128)
+) ENGINE=rocksdb;
+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 PRIMARY 1 b20 A 1000 NULL NULL LSMTREE
+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(b20) FROM t1 ORDER BY b20;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 20 NULL # Using index
+SELECT HEX(b20) FROM t1 ORDER BY b20;
+HEX(b20)
+6368617231000000000000000000000000000000
+6368617232000000000000000000000000000000
+6368617233000000000000000000000000000000
+6368617234000000000000000000000000000000
+EXPLAIN SELECT HEX(b20) FROM t1 IGNORE INDEX (PRIMARY) ORDER BY b20 DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL # Using filesort
+SELECT HEX(b20) FROM t1 ORDER BY b20 DESC;
+HEX(b20)
+6368617234000000000000000000000000000000
+6368617233000000000000000000000000000000
+6368617232000000000000000000000000000000
+6368617231000000000000000000000000000000
+DROP TABLE t1;
+CREATE TABLE t1 (b BINARY,
+b20 BINARY(20),
+v16 VARBINARY(16),
+v128 VARBINARY(128),
+pk VARBINARY(10) PRIMARY KEY,
+INDEX (v16(10))
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 1 v16 1 v16 A 500 10 NULL YES LSMTREE
+INSERT INTO t1 (b,b20,v16,v128,pk) VALUES ('a','char1','varchar1a','varchar1b',1),('a','char2','varchar2a','varchar2b',2),('b','char3','varchar1a','varchar1b',3),('c','char4','varchar3a','varchar3b',4),('d','char5','varchar4a','varchar3b',5),('e','char6','varchar2a','varchar3b',6);
+INSERT INTO t1 (b,b20,v16,v128,pk) SELECT b,b20,v16,v128,pk+100 FROM 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
+1 SIMPLE t1 range v16 v16 13 NULL # Using where
+SELECT HEX(SUBSTRING(v16,7,3)) FROM t1 WHERE v16 LIKE 'varchar%';
+HEX(SUBSTRING(v16,7,3))
+723161
+723161
+723161
+723161
+723261
+723261
+723261
+723261
+723361
+723361
+723461
+723461
+EXPLAIN SELECT HEX(SUBSTRING(v16,0,3)) FROM t1 FORCE INDEX (v16) WHERE v16 LIKE 'varchar%';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v16 v16 13 NULL # Using where
+SELECT HEX(SUBSTRING(v16,7,3)) FROM t1 FORCE INDEX (v16) WHERE v16 LIKE 'varchar%';
+HEX(SUBSTRING(v16,7,3))
+723161
+723161
+723161
+723161
+723261
+723261
+723261
+723261
+723361
+723361
+723461
+723461
+DROP TABLE t1;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_bit.result b/storage/rocksdb/mysql-test/rocksdb/r/type_bit.result
new file mode 100644
index 00000000..fa84cbde
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_bit.result
@@ -0,0 +1,53 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+a BIT ,
+b BIT(20) ,
+c BIT(64) ,
+d BIT(1) ,
+PRIMARY KEY (c)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a bit(1) YES NULL
+b bit(20) YES NULL
+c bit(64) NO PRI NULL
+d bit(1) YES NULL
+ALTER TABLE t1 DROP COLUMN d;
+ALTER TABLE t1 ADD COLUMN d BIT(0) ;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a bit(1) YES NULL
+b bit(20) YES NULL
+c bit(64) NO PRI NULL
+d bit(1) YES NULL
+INSERT INTO t1 (a,b,c,d) VALUES (0,POW(2,20)-1,b'1111111111111111111111111111111111111111111111111111111111111111',1);
+SELECT BIN(a), HEX(b), c+0 FROM t1 WHERE d>0;
+BIN(a) HEX(b) c+0
+0 FFFFF 18446744073709551615
+INSERT INTO t1 (a,b,c,d) VALUES (1,0,-2,0);
+SELECT a+0, b+0, c+0 FROM t1 WHERE d<100;
+a+0 b+0 c+0
+0 1048575 18446744073709551615
+1 0 18446744073709551614
+INSERT INTO t1 (a,b,c,d) VALUES (b'1', 'f', 0xFF, 0x0);
+SELECT a+0, b+0, c+0 FROM t1 WHERE d IN (0, 2);
+a+0 b+0 c+0
+1 0 18446744073709551614
+1 102 255
+DELETE FROM t1;
+INSERT INTO t1 (a,b,c,d) VALUES (0x10,0,0,1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+SELECT a+0,b+0,c+0,d+0 FROM t1;
+a+0 b+0 c+0 d+0
+1 0 0 1
+INSERT INTO t1 (a,b,c,d) VALUES (0x01,0,0x10000000000000000,0);
+Warnings:
+Warning 1264 Out of range value for column 'c' at row 1
+SELECT a+0,b+0,c+0,d+0 FROM t1;
+a+0 b+0 c+0 d+0
+1 0 0 1
+1 0 18446744073709551615 0
+DROP TABLE t1;
+CREATE TABLE t1 (pk INT PRIMARY KEY, a BIT(65) ) ENGINE=rocksdb;
+ERROR 42000: Display width out of range for 'a' (max = 64)
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_bit_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_bit_indexes.result
new file mode 100644
index 00000000..8da878eb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_bit_indexes.result
@@ -0,0 +1,58 @@
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+a BIT,
+b BIT(20) PRIMARY KEY,
+c BIT(32),
+d BIT(64)
+) ENGINE=rocksdb;
+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 PRIMARY 1 b A 1000 NULL NULL LSMTREE
+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 b+0 FROM t1 ORDER BY b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 3 NULL # Using index
+SELECT b+0 FROM t1 ORDER BY b;
+b+0
+11
+12
+13
+16
+100
+101
+256
+1000
+65535
+1048575
+DROP TABLE t1;
+# TODO: Unique indexes are not enforced
+CREATE TABLE t1 (
+a BIT,
+b BIT(20),
+c BIT(32),
+d BIT(64),
+pk BIT(10) PRIMARY KEY,
+INDEX(a)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 1 a 1 a A 500 NULL NULL YES LSMTREE
+INSERT INTO t1 (a,b,c,d,pk) VALUES
+(0,0xFFFFF,0,1,1),(0,256,0xAAA,0x12345,2),(1,16,0,0xFFFFFFF,3),(0,11,12,13,4),
+(1,100,101,102,5),(0,12,13,14,6),(1,13,14,15,7),(0,101,201,202,8),(1,1000,1001,1002,9),
+(1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF,10);
+EXPLAIN SELECT DISTINCT a+0 FROM t1 ORDER BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL # Using temporary; Using filesort
+SELECT DISTINCT a+0 FROM t1 ORDER BY a;
+a+0
+0
+1
+DROP TABLE t1;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_blob.result b/storage/rocksdb/mysql-test/rocksdb/r/type_blob.result
new file mode 100644
index 00000000..3b2bee74
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_blob.result
@@ -0,0 +1,57 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+b BLOB ,
+b0 BLOB(0) ,
+b1 BLOB(1) ,
+b300 BLOB(300) ,
+bm BLOB(65535) ,
+b70k BLOB(70000) ,
+b17m BLOB(17000000) ,
+t TINYBLOB ,
+m MEDIUMBLOB ,
+l LONGBLOB
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+b blob YES NULL
+b0 blob YES NULL
+b1 tinyblob YES NULL
+b300 blob YES NULL
+bm blob YES NULL
+b70k mediumblob YES NULL
+b17m longblob YES NULL
+t tinyblob YES NULL
+m mediumblob YES NULL
+l longblob YES NULL
+INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+('','','','','','','','','',''),
+('a','b','c','d','e','f','g','h','i','j'),
+('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), HEX(REPEAT('g',1048576)), REPEAT('h',255), REPEAT('i',1048576), HEX(REPEAT('j',1048576)) );
+SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(b) LENGTH(b0) LENGTH(b1) LENGTH(b300) LENGTH(bm) LENGTH(b70k) LENGTH(b17m) LENGTH(t) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 2097152 255 1048576 2097152
+INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b0' at row 1
+Warning 1265 Data truncated for column 'b1' at row 1
+Warning 1265 Data truncated for column 'b300' at row 1
+Warning 1265 Data truncated for column 'bm' at row 1
+Warning 1265 Data truncated for column 't' at row 1
+SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(b) LENGTH(b0) LENGTH(b1) LENGTH(b300) LENGTH(bm) LENGTH(b70k) LENGTH(b17m) LENGTH(t) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+65535 65535 255 65535 65535 1048576 2097152 255 1048576 2097152
+ALTER TABLE t1 ADD COLUMN bbb BLOB(4294967296);
+ERROR 42000: Display width out of range for 'bbb' (max = 4294967295)
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_blob_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_blob_indexes.result
new file mode 100644
index 00000000..1e614a2b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_blob_indexes.result
@@ -0,0 +1,198 @@
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+b BLOB,
+t TINYBLOB,
+m MEDIUMBLOB,
+l LONGBLOB,
+PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+Warnings:
+Warning 1280 Name 'b' ignored for PRIMARY key.
+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 PRIMARY 1 b A 1000 32 NULL LSMTREE
+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(b,16) AS f FROM t1 WHERE b IN ('test1','test2') ORDER BY f;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # #
+SELECT SUBSTRING(b,16) AS f FROM t1 WHERE b IN ('test1','test2') ORDER BY f;
+f
+
+
+EXPLAIN SELECT SUBSTRING(b,16) AS f FROM t1 USE INDEX () WHERE b IN ('test1','test2') ORDER BY f;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # NULL # # # #
+SELECT SUBSTRING(b,16) AS f FROM t1 USE INDEX () WHERE b IN ('test1','test2') ORDER BY f;
+f
+
+
+DROP TABLE t1;
+CREATE TABLE t1 (
+b BLOB,
+t TINYBLOB,
+m MEDIUMBLOB,
+l LONGBLOB,
+pk INT AUTO_INCREMENT PRIMARY KEY,
+UNIQUE INDEX l_t (l(256),t(64))
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk # # NULL NULL # #
+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
+1 SIMPLE t1 range l_t l_t 259 NULL # Using where; Using filesort
+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
+1 SIMPLE t1 range l_t l_t 259 NULL # Using where; Using filesort
+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;
+CREATE TABLE t1 (
+b BLOB,
+t TINYBLOB,
+m MEDIUMBLOB,
+l LONGBLOB,
+pk INT AUTO_INCREMENT PRIMARY KEY,
+INDEX (m(128))
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 1 m 1 m A 500 128 NULL YES LSMTREE
+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(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref m m 131 const # Using where; Using filesort
+SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+f
+EXPLAIN SELECT SUBSTRING(m,128) AS f FROM t1 IGNORE INDEX FOR ORDER BY (m) WHERE m = 'test1' ORDER BY f DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref m m 131 const # Using where; Using filesort
+SELECT SUBSTRING(m,128) AS f FROM t1 IGNORE INDEX FOR ORDER BY (m) WHERE m = 'test1' ORDER BY f DESC;
+f
+DROP TABLE t1;
+CREATE TABLE t1 (
+b BLOB,
+PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+Warnings:
+Warning 1280 Name 'b' ignored for PRIMARY key.
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+SELECT b FROM t1;
+b
+00000000000000000000000000000000
+00000000000000000000000000000001
+00000000000000000000000000000002
+DROP TABLE t1;
+CREATE TABLE t1 (
+b TINYBLOB,
+PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+Warnings:
+Warning 1280 Name 'b' ignored for PRIMARY key.
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+SELECT b FROM t1;
+b
+00000000000000000000000000000000
+00000000000000000000000000000001
+00000000000000000000000000000002
+DROP TABLE t1;
+CREATE TABLE t1 (
+b MEDIUMBLOB,
+PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+Warnings:
+Warning 1280 Name 'b' ignored for PRIMARY key.
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+SELECT b FROM t1;
+b
+00000000000000000000000000000000
+00000000000000000000000000000001
+00000000000000000000000000000002
+DROP TABLE t1;
+CREATE TABLE t1 (
+b LONGBLOB,
+PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+Warnings:
+Warning 1280 Name 'b' ignored for PRIMARY key.
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+SELECT b FROM t1;
+b
+00000000000000000000000000000000
+00000000000000000000000000000001
+00000000000000000000000000000002
+DROP TABLE t1;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_bool.result b/storage/rocksdb/mysql-test/rocksdb/r/type_bool.result
new file mode 100644
index 00000000..bfe2c18a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_bool.result
@@ -0,0 +1,73 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+b1 BOOL ,
+b2 BOOLEAN
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+b1 tinyint(1) YES NULL
+b2 tinyint(1) YES NULL
+INSERT INTO t1 (b1,b2) VALUES (1,TRUE);
+SELECT b1,b2 FROM t1;
+b1 b2
+1 1
+INSERT INTO t1 (b1,b2) VALUES (FALSE,0);
+SELECT b1,b2 FROM t1;
+b1 b2
+0 0
+1 1
+INSERT INTO t1 (b1,b2) VALUES (2,3);
+SELECT b1,b2 FROM t1;
+b1 b2
+0 0
+1 1
+2 3
+INSERT INTO t1 (b1,b2) VALUES (-1,-2);
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+1 1
+2 3
+SELECT IF(b1,'true','false') AS a, IF(b2,'true','false') AS b FROM t1;
+a b
+false false
+true true
+true true
+true true
+SELECT b1,b2 FROM t1 WHERE b1 = TRUE;
+b1 b2
+1 1
+SELECT b1,b2 FROM t1 WHERE b2 = FALSE;
+b1 b2
+0 0
+INSERT INTO t1 (b1,b2) VALUES ('a','b');
+Warnings:
+Warning 1366 Incorrect integer value: 'a' for column `test`.`t1`.`b1` at row 1
+Warning 1366 Incorrect integer value: 'b' for column `test`.`t1`.`b2` at row 1
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+0 0
+1 1
+2 3
+INSERT INTO t1 (b1,b2) VALUES (128,-129);
+Warnings:
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b2' at row 1
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+0 0
+1 1
+127 -128
+2 3
+ALTER TABLE t1 ADD COLUMN b3 BOOLEAN UNSIGNED ;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNSIGNED' at line 1
+ALTER TABLE ADD COLUMN b3 BOOL ZEROFILL ;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ADD COLUMN b3 BOOL ZEROFILL' at line 1
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_char.result b/storage/rocksdb/mysql-test/rocksdb/r/type_char.result
new file mode 100644
index 00000000..1786dfae
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_char.result
@@ -0,0 +1,76 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c CHAR ,
+c0 CHAR(0) ,
+c1 CHAR(1) ,
+c20 CHAR(20) ,
+c255 CHAR(255) ,
+PRIMARY KEY (c255)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c char(1) YES NULL
+c0 char(0) YES NULL
+c1 char(1) YES NULL
+c20 char(20) YES NULL
+c255 char(255) NO PRI NULL
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('','','','','');
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.');
+SELECT c,c0,c1,c20,c255 FROM t1;
+c c0 c1 c20 c255
+
+a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+Warning 1265 Data truncated for column 'c0' at row 1
+Warning 1265 Data truncated for column 'c1' at row 1
+Warning 1265 Data truncated for column 'c20' at row 1
+Warning 1265 Data truncated for column 'c255' at row 1
+INSERT INTO t1 (c,c0,c1,c20,c255) SELECT c255, c255, c255, c255, CONCAT('a',c255,c1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 5
+Warning 1265 Data truncated for column 'c0' at row 5
+Warning 1265 Data truncated for column 'c1' at row 5
+Warning 1265 Data truncated for column 'c20' at row 5
+Warning 1265 Data truncated for column 'c' at row 6
+Warning 1265 Data truncated for column 'c0' at row 6
+Warning 1265 Data truncated for column 'c1' at row 6
+Warning 1265 Data truncated for column 'c20' at row 6
+Warning 1265 Data truncated for column 'c255' at row 6
+SELECT c,c0,c1,c20,c255 FROM t1;
+c c0 c1 c20 c255
+
+ a
+C C Creating an article aCreating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.b
+a a aaaaaaaaaaaaaaaaaaaa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
+x x xxxxxxxxxxxxxxxxxxxx axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+SELECT DISTINCT c20, REPEAT('a',LENGTH(c20)), COUNT(*) FROM t1 GROUP BY c1, c20;
+c20 REPEAT('a',LENGTH(c20)) COUNT(*)
+ 2
+Creating an article aaaaaaaaaaaaaaaaaaa 1
+aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa 1
+abcdefghi klmnopqrst aaaaaaaaaaaaaaaaaaaa 1
+xxxxxxxxxxxxxxxxxxxx aaaaaaaaaaaaaaaaaaaa 1
+ALTER TABLE t1 ADD COLUMN c257 CHAR(257) ;
+ERROR 42000: Column length too big for column 'c257' (max = 255); use BLOB or TEXT instead
+DROP TABLE t1;
+CREATE TABLE t1(c1 CHAR(0) NOT NULL);
+INSERT INTO t1 VALUES('a');
+Warnings:
+Warning 1265 Data truncated for column 'c1' at row 1
+SELECT * FROM t1;
+c1
+
+DROP TABLE t1;
+CREATE TABLE t1(a char(10) character set utf8 collate utf8_bin primary key);
+INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');
+(SELECT * FROM t1 LIMIT 1) UNION (SELECT * FROM t1);
+a
+five
+four
+one
+three
+two
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes.result
new file mode 100644
index 00000000..3a99e6a1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes.result
@@ -0,0 +1,73 @@
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+c CHAR,
+c20 CHAR(20) PRIMARY KEY,
+v16 VARCHAR(16),
+v128 VARCHAR(128)
+) ENGINE=rocksdb;
+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 PRIMARY 1 c20 A 1000 NULL NULL LSMTREE
+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 c20 FROM t1 ORDER BY c20;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 20 NULL # Using index
+SELECT c20 FROM t1 ORDER BY c20;
+c20
+char1
+char2
+char3
+char4
+EXPLAIN SELECT c20 FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY c20;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 20 NULL # Using index
+SELECT c20 FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY c20;
+c20
+char1
+char2
+char3
+char4
+DROP TABLE t1;
+CREATE TABLE t1 (
+c CHAR,
+c20 CHAR(20),
+v16 VARCHAR(16),
+v128 VARCHAR(128),
+pk VARCHAR(64) PRIMARY KEY,
+INDEX (v16)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 1 v16 1 v16 A 500 NULL NULL YES LSMTREE
+INSERT INTO t1 (c,c20,v16,v128,pk) VALUES ('a','char1','varchar1a','varchar1b','1'),('a','char2','varchar2a','varchar2b','2'),('b','char3','varchar1a','varchar1b','3'),('c','char4','varchar3a','varchar3b','4');
+EXPLAIN SELECT SUBSTRING(v16,0,3) FROM t1 WHERE v16 LIKE 'varchar%';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v16 v16 19 NULL # Using where; Using index
+SELECT SUBSTRING(v16,7,3) FROM t1 WHERE v16 LIKE 'varchar%';
+SUBSTRING(v16,7,3)
+r1a
+r1a
+r2a
+r3a
+EXPLAIN SELECT SUBSTRING(v16,0,3) FROM t1 IGNORE INDEX (v16) WHERE v16 LIKE 'varchar%';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where
+SELECT SUBSTRING(v16,7,3) FROM t1 IGNORE INDEX (v16) WHERE v16 LIKE 'varchar%';
+SUBSTRING(v16,7,3)
+r1a
+r1a
+r2a
+r3a
+EXPLAIN SELECT c,c20,v16,v128 FROM t1 WHERE v16 = 'varchar1a' OR v16 = 'varchar3a' ORDER BY v16;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL v16 NULL NULL NULL # Using where; Using filesort
+SELECT c,c20,v16,v128 FROM t1 WHERE v16 = 'varchar1a' OR v16 = 'varchar3a' ORDER BY v16;
+c c20 v16 v128
+a char1 varchar1a varchar1b
+b char3 varchar1a varchar1b
+c char4 varchar3a varchar3b
+DROP TABLE t1;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes_collation.result b/storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes_collation.result
new file mode 100644
index 00000000..cb560895
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes_collation.result
@@ -0,0 +1,91 @@
+set session debug_dbug= "+d,myrocks_enable_unknown_collation_index_only_scans";
+create table t (id int not null auto_increment primary key,
+c varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci,
+key sk (c));
+insert into t (c) values ('☀'), ('ß');
+explain select c from t;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL sk 27 NULL # Using index
+select c from t;
+c
+ß
+☀
+drop table t;
+set session debug_dbug= "-d,myrocks_enable_unknown_collation_index_only_scans";
+create table t (id int not null auto_increment,
+c1 varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci,
+c2 char(1) CHARACTER SET latin1 COLLATE latin1_general_ci,
+primary key (id),
+key sk1 (c1),
+key sk2 (c2));
+explain select hex(c1) from t order by c1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL sk1 4 NULL # Using index
+explain select hex(c1) from t IGNORE INDEX (sk1) order by c1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ALL NULL NULL NULL NULL # Using filesort
+explain select hex(c2) from t order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL sk2 2 NULL # Using index
+explain select hex(c2) from t IGNORE INDEX (sk1) order by c2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t index NULL sk2 2 NULL # Using index
+truncate t;
+insert into t (c1, c2) values ('Asdf ', 'Asdf ');
+Warnings:
+Warning 1265 Data truncated for column 'c1' at row 1
+Warning 1265 Data truncated for column 'c2' at row 1
+select char_length(c1), char_length(c2), c1, c2 from t;
+char_length(c1) char_length(c2) c1 c2
+1 1 A A
+drop table t;
+create table t (id int not null auto_increment,
+c2 char(255) CHARACTER SET latin1 COLLATE latin1_general_ci,
+primary key (id),
+unique key sk2 (c2));
+insert into t (c2) values ('Asdf');
+insert into t (c2) values ('asdf ');
+ERROR 23000: Duplicate entry 'asdf' for key 'sk2'
+drop table t;
+create table t (id int not null auto_increment,
+c1 varchar(256) CHARACTER SET latin1 COLLATE latin1_swedish_ci,
+primary key (id),
+unique key sk1 (c1));
+insert into t (c1) values ('Asdf');
+insert into t (c1) values ('asdf ');
+ERROR 23000: Duplicate entry 'asdf ' for key 'sk1'
+insert into t (c1) values ('asdf');
+ERROR 23000: Duplicate entry 'asdf' for key 'sk1'
+drop table t;
+create table t (id int not null auto_increment,
+c1 varchar(256) CHARACTER SET latin1 COLLATE latin1_swedish_ci,
+primary key (id),
+unique key sk1 (c1(1)));
+insert into t (c1) values ('Asdf');
+insert into t (c1) values ('bbbb ');
+insert into t (c1) values ('a ');
+ERROR 23000: Duplicate entry 'a' for key 'sk1'
+explain select c1 from t;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ALL NULL NULL NULL NULL #
+select c1 from t;
+c1
+Asdf
+bbbb
+drop table t;
+set session rocksdb_verify_row_debug_checksums = on;
+create table t (id int primary key, email varchar(100), KEY email_i (email(30))) engine=rocksdb default charset=latin1;
+insert into t values (1, ' a');
+explain select 'email_i' as index_name, count(*) AS count from t force index(email_i);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ALL NULL NULL NULL NULL #
+select 'email_i' as index_name, count(*) AS count from t force index(email_i);
+index_name count
+email_i 1
+drop table t;
+create table t (id int primary key, email varchar(767), KEY email_i (email)) engine=rocksdb default charset=latin1;
+insert into t values (1, REPEAT('a', 700));
+select 'email_i' as index_name, count(*) AS count from t force index(email_i);
+index_name count
+email_i 1
+drop table t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_date_time.result b/storage/rocksdb/mysql-test/rocksdb/r/type_date_time.result
new file mode 100644
index 00000000..91e7ac25
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_date_time.result
@@ -0,0 +1,56 @@
+DROP TABLE IF EXISTS t1;
+set @save_time_zone=@@time_zone;
+set time_zone='UTC';
+CREATE TABLE t1 (
+d DATE ,
+dt DATETIME ,
+ts TIMESTAMP ,
+t TIME ,
+y YEAR ,
+y4 YEAR(4) ,
+y2 YEAR(2) ,
+pk DATETIME PRIMARY KEY
+) ENGINE=rocksdb;
+Warnings:
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d date YES NULL
+dt datetime YES NULL
+ts timestamp YES NULL
+t time YES NULL
+y year(4) YES NULL
+y4 year(4) YES NULL
+y2 year(2) YES NULL
+pk datetime NO PRI NULL
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y,y4,y2,pk) VALUES
+('1000-01-01', '1000-01-01 00:00:00', FROM_UNIXTIME(1), '-838:59:59', '1901', '1901', '00','2012-12-12 12:12:12'),
+('9999-12-31', '9999-12-31 23:59:59', FROM_UNIXTIME(2147483647), '838:59:59', '2155', '2155', '99','2012-12-12 12:12:13'),
+('0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '00:00:00', '0', '0', '0','2012-12-12 12:12:14'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),YEAR(@tm),YEAR(@tm),'2012-12-12 12:12:15');
+SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+d dt ts t y y4 y2
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 00
+1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
+2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
+9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
+INSERT INTO t1 (d,dt,ts,t,y,y4,y2,pk) VALUES
+('999-13-32', '999-11-31 00:00:00', '0', '-839:00:00', '1900', '1900', '-1','2012-12-12 12:12:16');
+Warnings:
+Warning 1265 Data truncated for column 'd' at row 1
+Warning 1265 Data truncated for column 'dt' at row 1
+Warning 1265 Data truncated for column 'ts' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 'y' at row 1
+Warning 1264 Out of range value for column 'y4' at row 1
+Warning 1264 Out of range value for column 'y2' at row 1
+SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+d dt ts t y y4 y2
+1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
+9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 00
+2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 -838:59:59 0000 0000 00
+set time_zone=@save_time_zone;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_date_time_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_date_time_indexes.result
new file mode 100644
index 00000000..77d07035
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_date_time_indexes.result
@@ -0,0 +1,119 @@
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+d DATE,
+dt DATETIME PRIMARY KEY,
+ts TIMESTAMP,
+t TIME,
+y YEAR
+) ENGINE=rocksdb;
+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 PRIMARY 1 dt A 1000 NULL NULL LSMTREE
+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 dt FROM t1 ORDER BY dt LIMIT 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 5 NULL # Using index
+SELECT dt FROM t1 ORDER BY dt LIMIT 3;
+dt
+2010-11-22 11:43:14
+2010-11-22 12:33:54
+2011-08-27 21:33:56
+EXPLAIN SELECT dt FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY dt LIMIT 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 5 NULL # Using index
+SELECT dt FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY dt LIMIT 3;
+dt
+2010-11-22 11:43:14
+2010-11-22 12:33:54
+2011-08-27 21:33:56
+INSERT INTO t1 (d,dt,ts,t,y) VALUES
+('2012-01-11', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000');
+ERROR 23000: Duplicate entry '2010-11-22 12:33:54' for key 'PRIMARY'
+DROP TABLE t1;
+CREATE TABLE t1 (
+d DATE,
+dt DATETIME,
+ts TIMESTAMP,
+t TIME,
+y YEAR,
+pk TIME PRIMARY KEY,
+INDEX (ts)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 1 ts 1 ts A 500 NULL NULL YES LSMTREE
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y,pk) VALUES
+('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000','12:00:00'),
+('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001','12:01:00'),
+('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999','12:02:00'),
+('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998','12:03:00'),
+('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994','12:04:00'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),'12:05:00');
+EXPLAIN SELECT ts FROM t1 WHERE ts > NOW();
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range ts ts 5 NULL # Using where; Using index
+SELECT ts FROM t1 WHERE ts > NOW();
+ts
+EXPLAIN SELECT ts FROM t1 USE INDEX () WHERE ts > NOW();
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where
+SELECT ts FROM t1 USE INDEX () WHERE ts > NOW();
+ts
+DROP TABLE t1;
+CREATE TABLE t1 (
+d DATE,
+dt DATETIME,
+ts TIMESTAMP,
+t TIME,
+y YEAR,
+pk TIME PRIMARY KEY,
+INDEX (y,t)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 1 y 1 y A 250 NULL NULL YES LSMTREE
+t1 1 y 2 t A 500 NULL NULL YES LSMTREE
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y,pk) VALUES
+('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000','18:18:18'),
+('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001','19:18:18'),
+('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999','20:18:18'),
+('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998','21:18:18'),
+('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994','22:18:18'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),'23:18:18');
+EXPLAIN SELECT y, COUNT(*) FROM t1 GROUP BY y;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL y 6 NULL # Using index
+SELECT y, COUNT(*) FROM t1 GROUP BY y;
+y COUNT(*)
+1994 1
+1998 1
+1999 1
+2000 1
+2001 1
+2012 1
+EXPLAIN SELECT y, COUNT(*) FROM t1 USE INDEX FOR GROUP BY () GROUP BY y;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL y 6 NULL # Using index; Using temporary; Using filesort
+SELECT y, COUNT(*) FROM t1 USE INDEX FOR GROUP BY () GROUP BY y;
+y COUNT(*)
+1994 1
+1998 1
+1999 1
+2000 1
+2001 1
+2012 1
+DROP TABLE t1;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_decimal.result b/storage/rocksdb/mysql-test/rocksdb/r/type_decimal.result
new file mode 100644
index 00000000..668a9276
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_decimal.result
@@ -0,0 +1,105 @@
+drop table if exists t1, t2;
+#
+# Check that DECIMAL datatype supports 'index-only' scans and is decoded correctly.
+# (Decoding happens from the mem-comparable image in the index, regardless
+# of whether the value part has original value or not)
+#
+create table t1 (
+pk int not null primary key,
+col1 decimal (2,1) signed,
+col2 decimal (2,1) unsigned,
+filler varchar(100),
+key key1(col1, col2)
+)engine=rocksdb;
+insert into t1 values
+(1,-9.1, 0.7, 'filler'),
+(2,-8.2, 1.6, 'filler'),
+(3, 0.3, 2.5, 'filler'),
+(4, 1.4, 3.4, 'filler'),
+(5, 2.5, 4.3, 'filler'),
+(6, 3.3, 5.3, 'filler');
+insert into t1 select pk+100, 9.0, 9.0, 'extra-data' from t1;
+insert into t1 select pk+200, 9.0, 9.0, 'extra-data' from t1;
+insert into t1 select pk+1000, 9.0, 9.0, 'extra-data' from t1;
+insert into t1 select pk+10000, 9.0, 9.0, 'extra-data' from t1;
+insert into t1 select pk+100000, 9.0, 9.0, 'extra-data' from t1;
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+# The following can't use index-only:
+explain select * from t1 where col1 between -8 and 8;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range key1 key1 3 NULL # Using index condition
+# This will use index-only:
+explain
+select col1, col2 from t1 where col1 between -8 and 8;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range key1 key1 3 NULL # Using where; Using index
+select col1, col2 from t1 where col1 between -8 and 8;
+col1 col2
+0.3 2.5
+1.4 3.4
+2.5 4.3
+3.3 5.3
+insert into t1 values (11, NULL, 0.9, 'row1-with-null');
+insert into t1 values (10, -8.4, NULL, 'row2-with-null');
+explain
+select col1, col2 from t1 force index(key1) where col1 is null or col1 < -7;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range key1 key1 3 NULL # Using where; Using index
+select col1, col2 from t1 force index(key1) where col1 is null or col1 < -7;
+col1 col2
+NULL 0.9
+-9.1 0.7
+-8.4 NULL
+-8.2 1.6
+# Try an UPDATE
+select * from t1 where pk in (3,4);
+pk col1 col2 filler
+3 0.3 2.5 filler
+4 1.4 3.4 filler
+update t1 set col2= col2+0.2 where pk in (3,4);
+select * from t1 where pk in (3,4);
+pk col1 col2 filler
+3 0.3 2.7 filler
+4 1.4 3.6 filler
+drop table t1;
+#
+# Try another DECIMAL-based type that takes more space
+#
+create table t1 (
+pk int not null primary key,
+col1 decimal (12,6) signed,
+col2 decimal (12,6) unsigned,
+filler varchar(100),
+key key1(col1, col2)
+)engine=rocksdb;
+insert into t1 values
+(1,-900.001, 000.007, 'filler'),
+(2,-700.002, 100.006, 'filler'),
+(3, 000.003, 200.005, 'filler'),
+(4, 100.004, 300.004, 'filler'),
+(5, 200.005, 400.003, 'filler'),
+(6, 300.003, 500.003, 'filler');
+insert into t1 select pk+100, col1+20000, col2+20000, 'extra-data' from t1;
+insert into t1 select pk+200, col1+20000, col2+20000, 'extra-data' from t1;
+insert into t1 select pk+1000, col1+20000, col2+20000, 'extra-data' from t1;
+insert into t1 select pk+10000, col1+20000, col2+20000, 'extra-data' from t1;
+insert into t1 select pk+100000, col1+20000, col2+20000, 'extra-data' from t1;
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain
+select col1, col2 from t1 force index(key1) where col1 between -800 and 800;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range key1 key1 7 NULL # Using where; Using index
+select col1, col2 from t1 force index(key1) where col1 between -800 and 800;
+col1 col2
+-700.002000 100.006000
+0.003000 200.005000
+100.004000 300.004000
+200.005000 400.003000
+300.003000 500.003000
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_enum.result b/storage/rocksdb/mysql-test/rocksdb/r/type_enum.result
new file mode 100644
index 00000000..ed66303c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_enum.result
@@ -0,0 +1,47 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+a ENUM('') ,
+b ENUM('test1','test2','test3','test4','test5') ,
+c ENUM('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') ,
+PRIMARY KEY (b)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a enum('') YES NULL
+b enum('test1','test2','test3','test4','test5') NO PRI NULL
+c enum('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') YES NULL
+INSERT INTO t1 (a,b,c) VALUES ('','test2','4'),('',5,2);
+SELECT a,b,c FROM t1;
+a b c
+ test2 4
+ test5 2
+INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+
+ 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('') YES NULL
+b enum('test1','test2','test3','test4','test5') NO PRI NULL
+c enum('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') YES NULL
+e enum('a','A') YES NULL
+INSERT INTO t1 (a,b,c,e) VALUES ('','test3','75','A');
+SELECT a,b,c,e FROM t1;
+a b c e
+ NULL
+ test2 4 NULL
+ test3 75 a
+ test5 2 NULL
+SELECT a,b,c,e FROM t1 WHERE b='test2' OR a != '';
+a b c e
+ test2 4 NULL
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_enum_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_enum_indexes.result
new file mode 100644
index 00000000..70bbc840
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_enum_indexes.result
@@ -0,0 +1,69 @@
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+DROP TABLE IF EXISTS t1;
+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
+) ENGINE=rocksdb;
+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 PRIMARY 1 c A 1000 NULL NULL LSMTREE
+EXPLAIN SELECT c FROM t1 WHERE c BETWEEN '1d' AND '6u';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 1 NULL # Using where; Using index
+SELECT c FROM t1 WHERE c BETWEEN '1d' AND '6u';
+c
+1d
+1j
+4z
+5a
+5b
+EXPLAIN SELECT c FROM t1 USE INDEX () WHERE c BETWEEN '1d' AND '6u';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where
+SELECT c FROM t1 USE INDEX () WHERE c BETWEEN '1d' AND '6u';
+c
+1d
+1j
+4z
+5a
+5b
+DROP TABLE t1;
+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'),
+pk ENUM('1','2','3','4','5','6','7','8','9') PRIMARY KEY,
+INDEX(b)
+) ENGINE=rocksdb;
+INSERT INTO t1 (a,b,c,pk) VALUES
+('N.America','test1','5a',1),('Europe','test1','5b',2),('Europe','test2','6v',3),
+('Africa','test3','4z',4),('Africa','test4','1j',5),('Antarctica','test4','1d',6);
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 1 b 1 b A 500 NULL NULL YES LSMTREE
+EXPLAIN SELECT DISTINCT b FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL b 2 NULL #
+SELECT DISTINCT b FROM t1;
+b
+test1
+test2
+test3
+test4
+EXPLAIN SELECT DISTINCT b FROM t1 IGNORE INDEX (b);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL # Using temporary
+SELECT DISTINCT b FROM t1 IGNORE INDEX (b);
+b
+test1
+test2
+test3
+test4
+DROP TABLE t1;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_fixed.result b/storage/rocksdb/mysql-test/rocksdb/r/type_fixed.result
new file mode 100644
index 00000000..055952ea
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_fixed.result
@@ -0,0 +1,131 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+d DECIMAL ,
+d0 DECIMAL(0) ,
+d1_1 DECIMAL(1,1) ,
+d10_2 DECIMAL(10,2) ,
+d60_10 DECIMAL(60,10) ,
+n NUMERIC ,
+n0_0 NUMERIC(0,0) ,
+n1 NUMERIC(1) ,
+n20_4 NUMERIC(20,4) ,
+n65_4 NUMERIC(65,4) ,
+pk NUMERIC PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d decimal(10,0) YES NULL
+d0 decimal(10,0) YES NULL
+d1_1 decimal(1,1) YES NULL
+d10_2 decimal(10,2) YES NULL
+d60_10 decimal(60,10) YES NULL
+n decimal(10,0) YES NULL
+n0_0 decimal(10,0) YES NULL
+n1 decimal(1,0) YES NULL
+n20_4 decimal(20,4) YES NULL
+n65_4 decimal(65,4) YES NULL
+pk decimal(10,0) NO PRI NULL
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807,1);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999,3);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807,4);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999,5);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+6
+);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999,7);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111,8);
+Warnings:
+Note 1265 Data truncated for column 'd' at row 1
+Note 1265 Data truncated for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Note 1265 Data truncated for column 'd10_2' at row 1
+Note 1265 Data truncated for column 'd60_10' at row 1
+Note 1265 Data truncated for column 'n' at row 1
+Note 1265 Data truncated for column 'n0_0' at row 1
+Note 1265 Data truncated for column 'n1' at row 1
+Note 1265 Data truncated for column 'n20_4' at row 1
+Note 1265 Data truncated for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.00 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.0000 9999999999999999999999999999999999999999999999999999999999999.1111
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66) ;
+ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6) ;
+ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66) ;
+ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 38
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_fixed_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_fixed_indexes.result
new file mode 100644
index 00000000..3f6a0f5d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_fixed_indexes.result
@@ -0,0 +1,129 @@
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+d1 DECIMAL(10,2) PRIMARY KEY,
+d2 DECIMAL(60,10),
+n1 NUMERIC,
+n2 NUMERIC(65,4)
+) ENGINE=rocksdb;
+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 PRIMARY 1 d1 A 1000 NULL NULL LSMTREE
+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 d1 FROM t1 ORDER BY d1 DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 5 NULL # Using index
+SELECT d1 FROM t1 ORDER BY d1 DESC;
+d1
+99999999.99
+100.00
+15.00
+11.14
+10.22
+10.00
+0.00
+EXPLAIN SELECT d1 FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY d1 DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 5 NULL # Using index; Using filesort
+SELECT d1 FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY d1 DESC;
+d1
+99999999.99
+100.00
+15.00
+11.14
+10.22
+10.00
+0.00
+DROP TABLE t1;
+CREATE TABLE t1 (
+d1 DECIMAL(10,2),
+d2 DECIMAL(60,10),
+n1 NUMERIC,
+n2 NUMERIC(65,4),
+pk NUMERIC PRIMARY KEY,
+UNIQUE INDEX n1_n2 (n1,n2)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 0 n1_n2 1 n1 A 500 NULL NULL YES LSMTREE
+t1 0 n1_n2 2 n2 A 1000 NULL NULL YES LSMTREE
+INSERT INTO t1 (d1,d2,n1,n2,pk) VALUES
+(10.22,60.12345,123456,14.3456,1),
+(10.0,60.12345,123456,14,2),
+(11.14,15,123456,13,3),
+(100,100,1,2,4),
+(0,0,0,0,5),
+(4540424564.23,3343303441.0,12,13,6),
+(15,17,23,100000,7);
+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
+1 SIMPLE t1 index NULL n1_n2 37 NULL # Using index; Using temporary
+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;
+CREATE TABLE t1 (
+d1 DECIMAL(10,2),
+d2 DECIMAL(60,10),
+n1 NUMERIC,
+n2 NUMERIC(65,4),
+pk DECIMAL(20,10) PRIMARY KEY,
+INDEX (d2)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 1 d2 1 d2 A 500 NULL NULL YES LSMTREE
+INSERT INTO t1 (d1,d2,n1,n2,pk) VALUES
+(10.22,60.12345,123456,14.3456,1),
+(10.0,60.12345,123456,14,2),
+(11.14,15,123456,13,3),
+(100,100,1,2,4),
+(0,0,0,0,5),
+(4540424564.23,3343303441.0,12,13,6),
+(15,17,23,100000,7);
+Warnings:
+Warning 1264 Out of range value for column 'd1' at row 6
+EXPLAIN SELECT d2, COUNT(*) FROM t1 GROUP BY d2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL d2 29 NULL # Using index
+SELECT d2, COUNT(*) FROM t1 GROUP BY d2;
+d2 COUNT(*)
+0.0000000000 1
+100.0000000000 1
+15.0000000000 1
+17.0000000000 1
+3343303441.0000000000 1
+60.1234500000 2
+EXPLAIN SELECT d2, COUNT(*) FROM t1 IGNORE INDEX FOR GROUP BY (d2) GROUP BY d2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL d2 29 NULL # Using index; Using temporary; Using filesort
+SELECT d2, COUNT(*) FROM t1 IGNORE INDEX FOR GROUP BY (d2) GROUP BY d2;
+d2 COUNT(*)
+0.0000000000 1
+100.0000000000 1
+15.0000000000 1
+17.0000000000 1
+3343303441.0000000000 1
+60.1234500000 2
+DROP TABLE t1;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_float.result b/storage/rocksdb/mysql-test/rocksdb/r/type_float.result
new file mode 100644
index 00000000..371b550d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_float.result
@@ -0,0 +1,314 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+f FLOAT ,
+f0 FLOAT(0) ,
+r1_1 REAL(1,1) ,
+f23_0 FLOAT(23) ,
+f20_3 FLOAT(20,3) ,
+d DOUBLE ,
+d1_0 DOUBLE(1,0) ,
+d10_10 DOUBLE PRECISION (10,10) ,
+d53 DOUBLE(53,0) ,
+d53_10 DOUBLE(53,10) ,
+pk DOUBLE PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+f float YES NULL
+f0 float YES NULL
+r1_1 double(1,1) YES NULL
+f23_0 float YES NULL
+f20_3 float(20,3) YES NULL
+d double YES NULL
+d1_0 double(1,0) YES NULL
+d10_10 double(10,10) YES NULL
+d53 double(53,0) YES NULL
+d53_10 double(53,10) YES NULL
+pk double NO PRI NULL
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999,1);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 11111111.111
+d10_10 0.0123456789
+d1_0 8
+d53 1234566789123456800
+d53_10 100000000000000000.0000000000
+f0 12345.1
+f20_3 56789.988
+f23_0 123457000
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+99999999999999999999999999999999999999,
+99999999999999999999999999999999999999.9999999999999999,
+0.9,
+99999999999999999999999999999999999999.9,
+99999999999999999.999,
+999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+9,
+0.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999,
+3
+);
+Warnings:
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 0
+d 11111111.111
+d 1e81
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 0
+d1_0 8
+d1_0 9
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 0
+f 1e38
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999,4);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+SELECT
+CONCAT('', MAX(f)),
+CONCAT('', MAX(f0)),
+CONCAT('', MAX(r1_1)),
+CONCAT('', MAX(f23_0)),
+CONCAT('', MAX(f20_3)),
+CONCAT('', MAX(d)),
+CONCAT('', MAX(d1_0)),
+CONCAT('', MAX(d10_10)),
+CONCAT('', MAX(d53)),
+CONCAT('', MAX(d53_10)) FROM t1;
+CONCAT('', MAX(f)) 1e38
+CONCAT('', MAX(d)) 1e81
+CONCAT('', MAX(d10_10)) 0.9999999999
+CONCAT('', MAX(d1_0)) 9
+CONCAT('', MAX(d53)) 100000000000000000000000000000000000000000000000000000
+CONCAT('', MAX(d53_10)) 10000000000000000000000000000000000000000000.0000000000
+CONCAT('', MAX(f0)) 1e38
+CONCAT('', MAX(f20_3)) 99999998430674940.000
+CONCAT('', MAX(f23_0)) 1e38
+CONCAT('', MAX(r1_1)) 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+9999999999999999999999999999999999999999999999999999999999999.9999,
+5
+);
+Warnings:
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e61
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 0.9999999999
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f 3.40282e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+999999999999999999999999999999999999999,
+999999999999999999999999999999999999999.9999999999999999,
+1.9,
+999999999999999999999999999999999999999.9,
+999999999999999999.999,
+9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+99,
+1.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999,
+6
+);
+Warnings:
+Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e61
+d 1e65
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 0.9999999999
+d10_10 0.9999999999
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f 3.40282e38
+f 3.40282e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f0 3.40282e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+f23_0 3.40282e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) ;
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1) ;
+ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35) ;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result
new file mode 100644
index 00000000..ca6ed6d5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result
@@ -0,0 +1,189 @@
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+f FLOAT PRIMARY KEY,
+r REAL(20,3),
+d DOUBLE,
+dp DOUBLE PRECISION (64,10)
+) ENGINE=rocksdb;
+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 PRIMARY 1 f A 1000 NULL NULL LSMTREE
+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 f FROM t1 ORDER BY f;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 4 NULL # Using index
+SELECT f FROM t1 ORDER BY f;
+f
+-1
+0
+1.2345
+17.5843
+4644
+EXPLAIN SELECT f FROM t1 IGNORE INDEX (PRIMARY) ORDER BY f;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL # Using filesort
+SELECT f FROM t1 IGNORE INDEX (PRIMARY) ORDER BY f;
+f
+-1
+0
+1.2345
+17.5843
+4644
+DROP TABLE t1;
+CREATE TABLE t1 (
+f FLOAT,
+r REAL(20,3),
+d DOUBLE,
+dp DOUBLE PRECISION (64,10),
+pk DOUBLE PRIMARY KEY,
+UNIQUE KEY r_dp (r,dp)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 0 r_dp 1 r A 500 NULL NULL YES LSMTREE
+t1 0 r_dp 2 dp A 1000 NULL NULL YES LSMTREE
+INSERT INTO t1 (f,r,d,dp,pk) VALUES
+(1.2345,1422.22,1.2345,1234567.89,1),
+(0,0,0,0,2),
+(-1,-1,-1,-1,3),
+(17.5843,4953453454.44,29229114.0,1111111.23,4),
+(4644,1422.22,466664.999,0.5,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
+1 SIMPLE t1 index r_dp r_dp 18 NULL # Using where; Using index
+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;
+CREATE TABLE t1 (
+f FLOAT,
+r REAL(20,3),
+d DOUBLE,
+dp DOUBLE PRECISION (64,10),
+pk FLOAT PRIMARY KEY,
+UNIQUE KEY(d)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 0 d 1 d A 1000 NULL NULL YES LSMTREE
+INSERT INTO t1 (f,r,d,dp,pk) VALUES
+(1.2345,1422.22,1.2345,1234567.89,1),
+(0,0,0,0,2),
+(-1,-1,-1,-1,3),
+(17.5843,4953453454.44,29229114.0,1111111.23,4),
+(4644,1422.22,466664.999,0.5,5);
+EXPLAIN SELECT DISTINCT d FROM t1 ORDER BY d;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL d 9 NULL # Using index
+SELECT DISTINCT d FROM t1 ORDER BY d;
+d
+-1
+0
+1.2345
+466664.999
+29229114
+DROP TABLE t1;
+CREATE TABLE t1 (
+f FLOAT,
+r REAL(20,3),
+d DOUBLE,
+dp DOUBLE PRECISION (64,10),
+pk FLOAT PRIMARY KEY,
+KEY(d)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 1 d 1 d A 500 NULL NULL YES LSMTREE
+INSERT INTO t1 (f,r,d,dp,pk) VALUES
+(1.2345,1422.22,1.2345,1234567.89,1),
+(0,0,0,0,2),
+(-1,-1,-1,-1,3),
+(17.5843,4953453454.44,29229114.0,1111111.23,4),
+(4644,1422.22,466664.999,0.5,5);
+EXPLAIN SELECT DISTINCT d FROM t1 ORDER BY d;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL d 9 NULL # Using index for group-by
+SELECT DISTINCT d FROM t1 ORDER BY d;
+d
+-1
+0
+1.2345
+466664.999
+29229114
+DROP TABLE t1;
+CREATE TABLE t1 (
+f FLOAT,
+r REAL(20,3),
+d DOUBLE,
+dp DOUBLE PRECISION (64,10),
+pk FLOAT PRIMARY KEY,
+UNIQUE KEY(f)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 0 f 1 f A 1000 NULL NULL YES LSMTREE
+INSERT INTO t1 (f,r,d,dp,pk) VALUES
+(1.2345,1422.22,1.2345,1234567.89,1),
+(0,0,0,0,2),
+(-1,-1,-1,-1,3),
+(17.5843,4953453454.44,29229114.0,1111111.23,4),
+(4644,1422.22,466664.999,0.5,5);
+INSERT INTO t1 (f,r,d,dp,pk) VALUES
+(1.2345,0,0,0,6);
+ERROR 23000: Duplicate entry '1.2345' for key 'f'
+EXPLAIN SELECT DISTINCT f FROM t1 ORDER BY f;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL f 5 NULL # Using index
+SELECT DISTINCT f FROM t1 ORDER BY f;
+f
+-1
+0
+1.2345
+17.5843
+4644
+DROP TABLE t1;
+CREATE TABLE t1 (
+f FLOAT,
+r REAL(20,3),
+d DOUBLE,
+dp DOUBLE PRECISION (64,10),
+pk FLOAT PRIMARY KEY,
+KEY(f)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 1 f 1 f A 500 NULL NULL YES LSMTREE
+INSERT INTO t1 (f,r,d,dp,pk) VALUES
+(1.2345,1422.22,1.2345,1234567.89,1),
+(0,0,0,0,2),
+(-1,-1,-1,-1,3),
+(17.5843,4953453454.44,29229114.0,1111111.23,4),
+(4644,1422.22,466664.999,0.5,5);
+INSERT INTO t1 (f,r,d,dp,pk) VALUES
+(1.2345,0,0,0,6);
+EXPLAIN SELECT DISTINCT f FROM t1 ORDER BY f;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL f 5 NULL # Using index for group-by
+SELECT DISTINCT f FROM t1 ORDER BY f;
+f
+-1
+0
+1.2345
+17.5843
+4644
+DROP TABLE t1;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_int.result b/storage/rocksdb/mysql-test/rocksdb/r/type_int.result
new file mode 100644
index 00000000..30604291
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_int.result
@@ -0,0 +1,212 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+i INT ,
+i0 INT(0) ,
+i1 INT(1) ,
+i20 INT(20) ,
+t TINYINT ,
+t0 TINYINT(0) ,
+t1 TINYINT(1) ,
+t20 TINYINT(20) ,
+s SMALLINT ,
+s0 SMALLINT(0) ,
+s1 SMALLINT(1) ,
+s20 SMALLINT(20) ,
+m MEDIUMINT ,
+m0 MEDIUMINT(0) ,
+m1 MEDIUMINT(1) ,
+m20 MEDIUMINT(20) ,
+b BIGINT ,
+b0 BIGINT(0) ,
+b1 BIGINT(1) ,
+b20 BIGINT(20) ,
+pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+i int(11) YES NULL
+i0 int(11) YES NULL
+i1 int(1) YES NULL
+i20 int(20) YES NULL
+t tinyint(4) YES NULL
+t0 tinyint(4) YES NULL
+t1 tinyint(1) YES NULL
+t20 tinyint(20) YES NULL
+s smallint(6) YES NULL
+s0 smallint(6) YES NULL
+s1 smallint(1) YES NULL
+s20 smallint(20) YES NULL
+m mediumint(9) YES NULL
+m0 mediumint(9) YES NULL
+m1 mediumint(1) YES NULL
+m20 mediumint(20) YES NULL
+b bigint(20) YES NULL
+b0 bigint(20) YES NULL
+b1 bigint(1) YES NULL
+b20 bigint(20) YES NULL
+pk int(11) NO PRI NULL auto_increment
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 8
+Warning 1264 Out of range value for column 'i0' at row 8
+Warning 1264 Out of range value for column 'i1' at row 8
+Warning 1264 Out of range value for column 'i20' at row 8
+Warning 1264 Out of range value for column 't' at row 8
+Warning 1264 Out of range value for column 't0' at row 8
+Warning 1264 Out of range value for column 't1' at row 8
+Warning 1264 Out of range value for column 't20' at row 8
+Warning 1264 Out of range value for column 's' at row 8
+Warning 1264 Out of range value for column 's0' at row 8
+Warning 1264 Out of range value for column 's1' at row 8
+Warning 1264 Out of range value for column 's20' at row 8
+Warning 1264 Out of range value for column 'm' at row 8
+Warning 1264 Out of range value for column 'm0' at row 8
+Warning 1264 Out of range value for column 'm1' at row 8
+Warning 1264 Out of range value for column 'm20' at row 8
+Warning 1264 Out of range value for column 'i' at row 9
+Warning 1264 Out of range value for column 'i0' at row 9
+Warning 1264 Out of range value for column 'i1' at row 9
+Warning 1264 Out of range value for column 'i20' at row 9
+Warning 1264 Out of range value for column 't' at row 9
+Warning 1264 Out of range value for column 't0' at row 9
+Warning 1264 Out of range value for column 't1' at row 9
+Warning 1264 Out of range value for column 't20' at row 9
+Warning 1264 Out of range value for column 's' at row 9
+Warning 1264 Out of range value for column 's0' at row 9
+Warning 1264 Out of range value for column 's1' at row 9
+Warning 1264 Out of range value for column 's20' at row 9
+Warning 1264 Out of range value for column 'm' at row 9
+Warning 1264 Out of range value for column 'm0' at row 9
+Warning 1264 Out of range value for column 'm1' at row 9
+Warning 1264 Out of range value for column 'm20' at row 9
+Warning 1264 Out of range value for column 'i' at row 10
+Warning 1264 Out of range value for column 'i0' at row 10
+Warning 1264 Out of range value for column 'i1' at row 10
+Warning 1264 Out of range value for column 'i20' at row 10
+Warning 1264 Out of range value for column 't' at row 10
+Warning 1264 Out of range value for column 't0' at row 10
+Warning 1264 Out of range value for column 't1' at row 10
+Warning 1264 Out of range value for column 't20' at row 10
+Warning 1264 Out of range value for column 's' at row 10
+Warning 1264 Out of range value for column 's0' at row 10
+Warning 1264 Out of range value for column 's1' at row 10
+Warning 1264 Out of range value for column 's20' at row 10
+Warning 1264 Out of range value for column 'm' at row 10
+Warning 1264 Out of range value for column 'm0' at row 10
+Warning 1264 Out of range value for column 'm1' at row 10
+Warning 1264 Out of range value for column 'm20' at row 10
+Warning 1264 Out of range value for column 'i' at row 11
+Warning 1264 Out of range value for column 'i0' at row 11
+Warning 1264 Out of range value for column 'i1' at row 11
+Warning 1264 Out of range value for column 'i20' at row 11
+Warning 1264 Out of range value for column 't' at row 11
+Warning 1264 Out of range value for column 't0' at row 11
+Warning 1264 Out of range value for column 't1' at row 11
+Warning 1264 Out of range value for column 't20' at row 11
+Warning 1264 Out of range value for column 's' at row 11
+Warning 1264 Out of range value for column 's0' at row 11
+Warning 1264 Out of range value for column 's1' at row 11
+Warning 1264 Out of range value for column 's20' at row 11
+Warning 1264 Out of range value for column 'm' at row 11
+Warning 1264 Out of range value for column 'm0' at row 11
+Warning 1264 Out of range value for column 'm1' at row 11
+Warning 1264 Out of range value for column 'm20' at row 11
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+ALTER TABLE t1 ADD COLUMN i257 INT(257) ;
+ERROR 42000: Display width out of range for 'i257' (max = 255)
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_int_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_int_indexes.result
new file mode 100644
index 00000000..e4c47f04
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_int_indexes.result
@@ -0,0 +1,99 @@
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+i INT PRIMARY KEY,
+t TINYINT,
+s SMALLINT,
+m MEDIUMINT,
+b BIGINT
+) ENGINE=rocksdb;
+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);
+EXPLAIN SELECT i FROM t1 ORDER BY i;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 4 NULL # Using index
+SELECT i FROM t1 ORDER BY i;
+i
+1
+2
+3
+5
+10
+11
+12
+101
+1000
+10001
+DROP TABLE t1;
+CREATE TABLE t1 (
+i INT,
+t TINYINT,
+s SMALLINT,
+m MEDIUMINT,
+b BIGINT,
+pk SMALLINT AUTO_INCREMENT PRIMARY KEY,
+INDEX s_m (s,m)
+) ENGINE=rocksdb;
+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);
+EXPLAIN SELECT s, m FROM t1 WHERE s != 10 AND m != 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index s_m s_m 7 NULL # Using where; Using index
+SELECT s, m FROM t1 WHERE s != 10 AND m != 1;
+s m
+10000 1000000
+10000 1000000
+10002 10003
+103 104
+12 13
+13 14
+14 15
+3 4
+4 5
+5 6
+DROP TABLE t1;
+# RocksDB: unique indexes allowed
+CREATE TABLE t1 (
+i INT,
+t TINYINT,
+s SMALLINT,
+m MEDIUMINT,
+b BIGINT,
+pk MEDIUMINT AUTO_INCREMENT PRIMARY KEY,
+UNIQUE KEY b_t (b,t)
+) ENGINE=rocksdb;
+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;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_set.result b/storage/rocksdb/mysql-test/rocksdb/r/type_set.result
new file mode 100644
index 00000000..5f875d14
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_set.result
@@ -0,0 +1,49 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+a SET('') ,
+b SET('test1','test2','test3','test4','test5') ,
+c SET('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') ,
+PRIMARY KEY (c)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a set('') YES NULL
+b set('test1','test2','test3','test4','test5') YES NULL
+c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') NO PRI NULL
+INSERT INTO t1 (a,b,c) VALUES
+('','test2,test3','01,34,44,,23'),
+('',5,2),
+(',','test4,test2','');
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+ test1,test3 02
+ test2,test3 01,23,34,44
+ test2,test4
+INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+ 01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50'51,52,53,54,55,56,57,58,59,60,61,62,63,64
+ test1,test3 02
+ 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('') YES NULL
+b set('test1','test2','test3','test4','test5') YES NULL
+c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') NO PRI NULL
+e set('a','A') YES NULL
+ALTER TABLE t1 ADD COLUMN f SET('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i') ;
+ERROR HY000: Too many strings for column f and SET
+SELECT a,b,c,e FROM t1 WHERE FIND_IN_SET('test2',b)>0 OR a != '';
+a b c e
+ test2,test3 01,23,34,44 NULL
+ test2,test4 NULL
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_set_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_set_indexes.result
new file mode 100644
index 00000000..391649e0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_set_indexes.result
@@ -0,0 +1,115 @@
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+a SET('N.America','S.America','Africa','Antarctica','Australia','Europe','Asia'),
+b SET('test1','test2','test3','test4','test5'),
+c SET('01','22','23','33','34','39','40','44','50','63','64') PRIMARY KEY
+) ENGINE=rocksdb;
+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 PRIMARY 1 c A 1000 NULL NULL LSMTREE
+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 c FROM t1 ORDER BY c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 2 NULL # Using index
+SELECT c FROM t1 ORDER BY c;
+c
+
+01
+22
+39
+34,44
+01,23,34,44
+50
+EXPLAIN SELECT c FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 2 NULL # Using index; Using filesort
+SELECT c FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY c;
+c
+
+01
+22
+39
+34,44
+01,23,34,44
+50
+INSERT INTO t1 (a,b,c) VALUES ('Antarctica','test3','02');
+ERROR 23000: Duplicate entry '22' for key 'PRIMARY'
+INSERT INTO t1 (a,b,c) VALUES ('','test1','34,44');
+ERROR 23000: Duplicate entry '34,44' for key 'PRIMARY'
+DROP TABLE t1;
+CREATE TABLE t1 (
+a SET('N.America','S.America','Africa','Antarctica','Australia','Europe','Asia'),
+b SET('test1','test2','test3','test4','test5'),
+c SET('01','22','23','33','34','39','40','44','50','63','64'),
+pk SET('1','2','3','4','5','6','7','8','9') PRIMARY KEY,
+INDEX(a)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 1 a 1 a A 500 NULL NULL YES LSMTREE
+INSERT INTO t1 (a,b,c,pk) VALUES
+('','test2,test3','01,34,44,23',1),
+('',5,2,2),
+('N.America,Asia','test4,test2','',3),
+('Africa,Europe,Asia','test2,test3','01',4),
+('Antarctica','test3','34,44',5),
+('Asia','test5','50',6),
+('Europe,S.America','test1,','39',7);
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 7
+EXPLAIN SELECT a FROM t1 WHERE FIND_IN_SET('Europe',a) > 0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where
+SELECT a FROM t1 WHERE FIND_IN_SET('Europe',a) > 0;
+a
+Africa,Europe,Asia
+S.America,Europe
+DROP TABLE t1;
+CREATE TABLE t1 (
+a SET('N.America','S.America','Africa','Antarctica','Australia','Europe','Asia'),
+b SET('test1','test2','test3','test4','test5'),
+c SET('01','22','23','33','34','39','40','44','50','63','64'),
+pk SET('1','2','3','4','5','6','7','8','9') PRIMARY KEY,
+UNIQUE INDEX b_a (b,a)
+) ENGINE=rocksdb;
+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 PRIMARY 1 pk A 1000 NULL NULL LSMTREE
+t1 0 b_a 1 b A 500 NULL NULL YES LSMTREE
+t1 0 b_a 2 a A 1000 NULL NULL YES LSMTREE
+INSERT INTO t1 (a,b,c,pk) VALUES
+('','test2,test3','01,34,44,23',1),
+('',5,2,2),
+('N.America,Asia','test4,test2','',3),
+('Africa,Europe,Asia','test2,test3','01',4),
+('Antarctica','test3','34,44',5),
+('Asia','test5','50',6),
+('Europe,S.America','test1,','39',7);
+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
+1 SIMPLE t1 ALL NULL NULL NULL NULL # Using temporary; Using filesort
+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;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_text.result b/storage/rocksdb/mysql-test/rocksdb/r/type_text.result
new file mode 100644
index 00000000..4e118bb9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_text.result
@@ -0,0 +1,57 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+pk INT AUTO_INCREMENT PRIMARY KEY,
+t TEXT ,
+t0 TEXT(0) ,
+t1 TEXT(1) ,
+t300 TEXT(300) ,
+tm TEXT(65535) ,
+t70k TEXT(70000) ,
+t17m TEXT(17000000) ,
+tt TINYTEXT ,
+m MEDIUMTEXT ,
+l LONGTEXT
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+pk int(11) NO PRI NULL auto_increment
+t text YES NULL
+t0 text YES NULL
+t1 tinytext YES NULL
+t300 text YES NULL
+tm text YES NULL
+t70k mediumtext YES NULL
+t17m longtext YES NULL
+tt tinytext YES NULL
+m mediumtext YES NULL
+l longtext YES NULL
+INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+('','','','','','','','','',''),
+('a','b','c','d','e','f','g','h','i','j'),
+('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',255), REPEAT('i',1048576), REPEAT('j',1048576) );
+SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(t) LENGTH(t0) LENGTH(t1) LENGTH(t300) LENGTH(tm) LENGTH(t70k) LENGTH(t17m) LENGTH(tt) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+Warnings:
+Warning 1265 Data truncated for column 't' at row 1
+Warning 1265 Data truncated for column 't0' at row 1
+Warning 1265 Data truncated for column 't1' at row 1
+Warning 1265 Data truncated for column 't300' at row 1
+Warning 1265 Data truncated for column 'tm' at row 1
+Warning 1265 Data truncated for column 'tt' at row 1
+SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(t) LENGTH(t0) LENGTH(t1) LENGTH(t300) LENGTH(tm) LENGTH(t70k) LENGTH(t17m) LENGTH(tt) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+ALTER TABLE t1 ADD COLUMN ttt TEXT(4294967296) ;
+ERROR 42000: Display width out of range for 'ttt' (max = 4294967295)
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_text_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_text_indexes.result
new file mode 100644
index 00000000..7db5c23c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_text_indexes.result
@@ -0,0 +1,181 @@
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+t TEXT,
+tt TINYTEXT,
+m MEDIUMTEXT,
+l LONGTEXT,
+PRIMARY KEY t (t(32))
+) ENGINE=rocksdb;
+Warnings:
+Warning 1280 Name 't' ignored for PRIMARY key.
+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 PRIMARY 1 t A 1000 32 NULL LSMTREE
+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(t,16) AS f FROM t1 WHERE t IN ('test1','test2') ORDER BY f;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 34 NULL # Using where; Using filesort
+SELECT SUBSTRING(t,16) AS f FROM t1 WHERE t IN ('test1','test2') ORDER BY f;
+f
+
+
+EXPLAIN SELECT SUBSTRING(t,16) AS f FROM t1 IGNORE INDEX (PRIMARY) WHERE t IN ('test1','test2') ORDER BY f;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where; Using filesort
+SELECT SUBSTRING(t,16) AS f FROM t1 IGNORE INDEX (PRIMARY) WHERE t IN ('test1','test2') ORDER BY f;
+f
+
+
+DROP TABLE t1;
+CREATE TABLE t1 (
+t TEXT,
+tt TINYTEXT,
+m MEDIUMTEXT,
+l LONGTEXT,
+pk TINYTEXT PRIMARY KEY,
+UNIQUE INDEX l_tt (l(256),tt(64))
+) ENGINE=rocksdb;
+ERROR 42000: BLOB/TEXT column 'pk' used in key specification without a key length
+CREATE TABLE t1 (
+t TEXT,
+tt TINYTEXT,
+m MEDIUMTEXT,
+l LONGTEXT,
+pk MEDIUMTEXT,
+PRIMARY KEY mt (pk(1)),
+INDEX (m(128))
+) ENGINE=rocksdb;
+Warnings:
+Warning 1280 Name 'mt' ignored for PRIMARY key.
+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 PRIMARY 1 pk A 1000 1 NULL LSMTREE
+t1 1 m 1 m A 500 128 NULL YES LSMTREE
+INSERT INTO t1 (t,tt,m,l,pk) VALUES
+('','','','','0'),
+('a','b','c','d','1'),
+('b','d','c','b','2'),
+('test1','test2','test3','test4','3'),
+(REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128),'4'),
+('abc','def','ghi','jkl','5'),
+('test2','test3','test4','test5','6'),
+('test3','test4','test5','test6','7'),
+(REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128),'8'),
+(REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128),'9');
+EXPLAIN SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref m m 131 const # Using where; Using filesort
+SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+f
+DROP TABLE t1;
+CREATE TABLE t1 (
+b TEXT,
+PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+Warnings:
+Warning 1280 Name 'b' ignored for PRIMARY key.
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+SELECT b FROM t1;
+b
+00000000000000000000000000000000
+00000000000000000000000000000001
+00000000000000000000000000000002
+DROP TABLE t1;
+CREATE TABLE t1 (
+b TINYTEXT,
+PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+Warnings:
+Warning 1280 Name 'b' ignored for PRIMARY key.
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+SELECT b FROM t1;
+b
+00000000000000000000000000000000
+00000000000000000000000000000001
+00000000000000000000000000000002
+DROP TABLE t1;
+CREATE TABLE t1 (
+b MEDIUMTEXT,
+PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+Warnings:
+Warning 1280 Name 'b' ignored for PRIMARY key.
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+SELECT b FROM t1;
+b
+00000000000000000000000000000000
+00000000000000000000000000000001
+00000000000000000000000000000002
+DROP TABLE t1;
+CREATE TABLE t1 (
+b LONGTEXT,
+PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+Warnings:
+Warning 1280 Name 'b' ignored for PRIMARY key.
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+SELECT b FROM t1;
+b
+00000000000000000000000000000000
+00000000000000000000000000000001
+00000000000000000000000000000002
+DROP TABLE t1;
+CREATE TABLE t1 (
+b LONGTEXT CHARACTER SET "binary" COLLATE "binary",
+PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+Warnings:
+Warning 1280 Name 'b' ignored for PRIMARY key.
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+INSERT INTO t1 (b) VALUES (''), (_binary 0x0), (' ');
+SELECT hex(b) FROM t1;
+hex(b)
+
+00
+20
+3030303030303030303030303030303030303030303030303030303030303030
+3030303030303030303030303030303030303030303030303030303030303031
+3030303030303030303030303030303030303030303030303030303030303032
+DROP TABLE t1;
+CREATE TABLE t1 (
+b LONGTEXT CHARACTER SET "latin1" COLLATE "latin1_bin",
+PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+Warnings:
+Warning 1280 Name 'b' ignored for PRIMARY key.
+INSERT INTO t1 (b) VALUES (''), (_binary 0x0), (' ');
+ERROR 23000: Duplicate entry ' ' for key 'PRIMARY'
+INSERT INTO t1 (b) VALUES (''), (_binary 0x0);
+SELECT hex(b) FROM t1;
+hex(b)
+00
+
+DROP TABLE t1;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_varbinary.result b/storage/rocksdb/mysql-test/rocksdb/r/type_varbinary.result
new file mode 100644
index 00000000..6de8c033
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_varbinary.result
@@ -0,0 +1,93 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (
+v0 VARBINARY(0) ,
+v1 VARBINARY(1) ,
+v64 VARBINARY(64) ,
+v65000 VARBINARY(65000) ,
+PRIMARY KEY (v64)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varbinary(0) YES NULL
+v1 varbinary(1) YES NULL
+v64 varbinary(64) NO PRI NULL
+v65000 varbinary(65000) YES NULL
+CREATE TABLE t2 (v VARBINARY(65532) , PRIMARY KEY(v(255))) ENGINE=rocksdb;
+SHOW COLUMNS IN t2;
+Field Type Null Key Default Extra
+v varbinary(65532) NO PRI NULL
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+SELECT HEX(v0), HEX(v1), HEX(v64), HEX(v65000) FROM t1;
+HEX(v0) HEX(v1) HEX(v64) HEX(v65000)
+
+ 79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E2057652776652070726F7669646564206C696E6B7320746F20416D617A6F6E2E636F6D206865726520666F7220636F6E76656E69656E63652C2062757420746865792063616E20626520666F756E64206174206D616E79206F7468657220626F6F6B73746F7265732C20626F7468206F6E6C696E6520616E64206F66662E0A0A2020496620796F752077616E7420746F206861766520796F7572206661766F72697465204D7953514C202F204D61726961444220626F6F6B206C697374656420686572652C20706C65617365206C65617665206120636F6D6D656E742E0A2020466F7220646576656C6F706572732077686F2077616E7420746F20636F6465206F6E204D617269614442206F72204D7953514C0A0A2020202020202A20556E6465727374616E64696E67204D7953514C20496E7465726E616C73206279205361736861205061636865762C20666F726D6572204D7953514C20646576656C6F706572206174204D7953514C2041422E0A2020202020202020202020206F205468697320697320746865206F6E6C7920626F6F6B207765206B6E6F772061626F75742074686174206465736372696265732074686520696E7465726E616C73206F66204D617269614442202F204D7953514C2E2041206D757374206861766520666F7220616E796F6E652077686F2077616E747320746F20756E6465727374616E6420616E6420646576656C6F70206F6E204D617269614442210A2020202020202020202020206F204E6F7420616C6C20746F706963732061726520636F766572656420616E6420736F6D652070617274732061726520736C696768746C79206F757464617465642C20627574207374696C6C20746865206265737420626F6F6B206F6E207468697320746F7069632E200A2020202020202A204D7953514C20352E3120506C7567696E20446576656C6F706D656E742062792053657267656920476F6C75626368696B20616E6420416E64726577204875746368696E67730A2020202020202020202020206F2041206D757374207265616420666F7220616E796F6E652077616E74696E6720746F207772697465206120706C7567696E20666F72204D6172696144422C207772697474656E20627920746865205365726765692077686F2064657369676E65642074686520706C7567696E20696E7465726661636520666F72204D7953514C20616E64204D61726961444221200A0A2020466F72204D617269614442202F204D7953514C20656E642075736572730A0A2020202020202A204D61726961444220437261736820436F757273652062792042656E20466F7274610A2020202020202020202020206F204669727374204D61726961444220626F6F6B210A2020202020202020202020206F20466F722070656F706C652077686F2077616E7420746F206C6561726E2053514C20616E642074686520626173696373206F66204D6172696144422E0A2020202020202020202020206F204E6F77207368697070696E672E20507572636861736520617420416D617A6F6E2E636F6D206F7220796F7572206661766F7269746520626F6F6B73656C6C65722E200A0A2020202020202A2053514C2D393920436F6D706C6574652C205265616C6C792062792050657465722047756C75747A616E20262054727564792050656C7A65722E0A2020202020202020202020206F2045766572797468696E6720796F752077616E74656420746F206B6E6F772061626F7574207468652053514C203939207374616E646172642E20457863656C6C656E74207265666572656E636520626F6F6B210A2020202020202020202020206F204672656520746F207265616420696E20746865204B6E6F776C656467656261736521200A0A2020202020202A204D7953514C20283474682045646974696F6E29206279205061756C204475426F69730A2020202020202020202020206F20546865202764656661756C742720626F6F6B20746F207265616420696620796F7520776F6E7420746F206C6561726E20746F20757365204D7953514C202F204D6172696144422E200A0A2020202020202A204D7953514C20436F6F6B626F6F6B206279205061756C204475426F69730A2020202020202020202020206F2041206C6F74206F66206578616D706C6573206F6620686F7720746F20757365204D7953514C2E204173207769746820616C6C206F66205061756C277320626F6F6B732C206974277320776F727468206974732077656967687420696E20676F6C6420616E64206576656E20656E6A6F7961626C652072656164696E6720666F7220737563682061202764727927207375626A6563742E200A0A2020202020202A204869676820506572666F726D616E6365204D7953514C2C205365636F6E642045646974696F6E2C204279204261726F6E20536368776172747A2C205065746572205A6169747365762C20566164696D20546B616368656E6B6F2C204A6572656D7920442E205A61776F646E792C2041726A656E204C656E747A2C20446572656B204A2E2042616C6C696E672C20657420616C2E0A2020202020202020202020206F20224869676820506572666F726D616E6365204D7953514C2069732074686520646566696E697469766520677569646520746F206275696C64696E6720666173742C2072656C6961626C652073797374656D732077697468204D7953514C2E205772697474656E206279206E6F74656420657870657274732077697468207965617273206F66207265616C2D776F726C6420657870657269656E6365206275696C64696E672076657279206C617267652073797374656D732C207468697320626F6F6B20636F7665727320657665727920617370656374206F66204D7953514C20706572666F726D616E636520696E2064657461696C2C20616E6420666F6375736573206F6E20726F627573746E6573732C2073656375726974792C20616E64206461746120696E746567726974792E204C6561726E20616476616E63656420746563686E697175657320696E20646570746820736F20796F752063616E206272696E67206F7574204D7953514C27732066756C6C20706F7765722E22202846726F6D2074686520626F6F6B206465736372697074696F6E206174204F275265696C6C7929200A0A2020202020202A204D7953514C2041646D696E20436F6F6B626F6F6B0A2020202020202020202020206F204120717569636B20737465702D62792D7374657020677569646520666F72204D7953514C20757365727320616E642064617461626173652061646D696E6973747261746F727320746F207461636B6C65207265616C2D776F726C64206368616C6C656E6765732077697468204D7953514C20636F6E66696775726174696F6E20616E642061646D696E697374726174696F6E200A0A2020202020202A204D7953514C20352E302043657274696669636174696F6E2053747564792047756964652C204279205061756C204475426F69732C2053746566616E2048696E7A2C204361727374656E20506564657273656E0A2020202020202020202020206F205468697320697320746865206F6666696369616C20677569646520746F20636F766572207468652070617373696E67206F66207468652074776F204D7953514C2043657274696669636174696F6E206578616D696E6174696F6E732E2049742069732076616C69642074696C6C2076657273696F6E20352E30206F6620746865207365727665722C20736F207768696C65206974206D697373657320616C6C2074686520666561747572657320617661696C61626C6520696E204D7953514C20352E3120616E6420677265617465722028696E636C7564696E67204D61726961444220352E3120616E642067726561746572292C2069742070726F7669646573206120676F6F6420626173696320756E6465727374616E64696E67206F66204D7953514C20666F722074686520656E642D757365722E20
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 1
+Warning 1265 Data truncated for column 'v1' at row 1
+Warning 1265 Data truncated for column 'v64' at row 1
+Warning 1265 Data truncated for column 'v65000' at row 1
+INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, CONCAT('a',v65000), CONCAT(v65000,v1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 5
+Warning 1265 Data truncated for column 'v1' at row 5
+Warning 1265 Data truncated for column 'v64' at row 5
+Warning 1265 Data truncated for column 'v0' at row 6
+Warning 1265 Data truncated for column 'v1' at row 6
+Warning 1265 Data truncated for column 'v64' at row 6
+Warning 1265 Data truncated for column 'v65000' at row 6
+SELECT HEX(v0), HEX(v1), HEX(v64), LENGTH(HEX(v65000)) FROM t1;
+HEX(v0) HEX(v1) HEX(v64) LENGTH(HEX(v65000))
+ 0
+ 61 0
+ 48 61486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E205765277665 5932
+ 61 61616263646566676869206162636465666768692061626364656667686920616263646566676869206162636465666768692061626364656667686920616263 130000
+ 79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 5930
+ 79 63636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363 130000
+ALTER TABLE t1 ADD COLUMN v65536 VARBINARY(65536) ;
+Warnings:
+Note 1246 Converting column 'v65536' from VARBINARY to BLOB
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varbinary(0) YES NULL
+v1 varbinary(1) YES NULL
+v64 varbinary(64) NO PRI NULL
+v65000 varbinary(65000) YES NULL
+v65536 mediumblob YES NULL
+DROP TABLE t1, t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_varchar.result b/storage/rocksdb/mysql-test/rocksdb/r/type_varchar.result
new file mode 100644
index 00000000..4c5ef475
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_varchar.result
@@ -0,0 +1,775 @@
+#
+# A basic test whether endspace-aware variable length encoding
+# works when in PK
+#
+create table t1 ( pk varchar(10) primary key, col1 int not null) ;
+insert into t1 values ('a', 1);
+select * from t1;
+pk col1
+a 1
+drop table t1;
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (
+v0 VARCHAR(0) ,
+v1 VARCHAR(1) ,
+v64 VARCHAR(64) ,
+v65000 VARCHAR(65000) ,
+PRIMARY KEY (v64)
+) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varchar(0) YES NULL
+v1 varchar(1) YES NULL
+v64 varchar(64) NO PRI NULL
+v65000 varchar(65000) YES NULL
+CREATE TABLE t2 (v VARCHAR(65532), PRIMARY KEY (v(255))) ENGINE=rocksdb;
+SHOW COLUMNS IN t2;
+Field Type Null Key Default Extra
+v varchar(65532) NO PRI NULL
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+SELECT v0,v1,v64,v65000 FROM t1;
+v0 v1 v64 v65000
+
+
+
+
+
+
+
+
+
+
+
+ y Once there, double check that an article doesn't already exist Here is a list of recommended books on MariaDB and MySQL. We've provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+ o "High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL's full power." (From the book description at O'Reilly)
+ o A lot of examples of how to use MySQL. As with all of Paul's books, it's worth its weight in gold and even enjoyable reading for such a 'dry' subject.
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Free to read in the Knowledgebase!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+ o The 'default' book to read if you wont to learn to use MySQL / MariaDB.
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ * MariaDB Crash Course by Ben Forta
+ * MySQL (4th Edition) by Paul DuBois
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ * MySQL Admin Cookbook
+ * MySQL Cookbook by Paul DuBois
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ For MariaDB / MySQL end users
+ For developers who want to code on MariaDB or MySQL
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 1
+Warning 1265 Data truncated for column 'v1' at row 1
+Warning 1265 Data truncated for column 'v64' at row 1
+Warning 1265 Data truncated for column 'v65000' at row 1
+INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, CONCAT('a',v65000), CONCAT(v65000,v1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 5
+Warning 1265 Data truncated for column 'v1' at row 5
+Warning 1265 Data truncated for column 'v64' at row 5
+Warning 1265 Data truncated for column 'v65000' at row 5
+Warning 1265 Data truncated for column 'v0' at row 6
+Warning 1265 Data truncated for column 'v1' at row 6
+Warning 1265 Data truncated for column 'v64' at row 6
+SELECT v0, v1, v64, LENGTH(v65000) FROM t1;
+v0 v1 v64 LENGTH(v65000)
+ 0
+ a 0
+ H aHere is a list of recommended books on MariaDB and MySQL. We've 2966
+ a aabcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abc 65000
+ y Once there, double check that an article doesn't already exist 2965
+ y cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 65000
+ALTER TABLE t1 ADD COLUMN v65536 VARCHAR(65536) ;
+Warnings:
+Note 1246 Converting column 'v65536' from VARCHAR to TEXT
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varchar(0) YES NULL
+v1 varchar(1) YES NULL
+v64 varchar(64) NO PRI NULL
+v65000 varchar(65000) YES NULL
+v65536 mediumtext YES NULL
+DROP TABLE t1, t2;
+#
+# Endspace-comparison tests:
+#
+#
+# Issue 257: Sort order for varchars is different between
+# MyISAM/InnoDB vs MyRocks
+#
+create table t1 (
+pk varchar(64) CHARACTER SET latin1 COLLATE latin1_bin,
+col1 varchar(64),
+primary key (pk)
+);
+insert into t1 values ('a','a');
+insert into t1 values ('a ', 'a-space');
+ERROR 23000: Duplicate entry 'a ' for key 'PRIMARY'
+insert into t1 values('b ', 'b-2x-space');
+insert into t1 values ('b', 'b');
+ERROR 23000: Duplicate entry 'b' for key 'PRIMARY'
+select pk, hex(pk), col1 from t1;
+pk hex(pk) col1
+a 61 a
+b 622020 b-2x-space
+insert into t1 values ('a\t', 'a-tab');
+insert into t1 values ('a \t', 'a-space-tab');
+select pk, hex(pk), col1 from t1 order by pk;
+pk hex(pk) col1
+a 6109 a-tab
+a 612009 a-space-tab
+a 61 a
+b 622020 b-2x-space
+# Try longer values
+insert into t1 values (concat('a', repeat(' ',10)), 'a-10-x-space');
+ERROR 23000: Duplicate entry 'a ' for key 'PRIMARY'
+insert into t1 values (concat('c', repeat(' ',10)), 'c-10-x-space');
+select * from t1;
+pk col1
+a a-tab
+a a-space-tab
+a a
+b b-2x-space
+c c-10-x-space
+drop table t1;
+# Secondary index
+create table t1 (
+pk int not null primary key,
+col1 varchar(64) CHARACTER SET latin1 COLLATE latin1_bin,
+col2 varchar(64),
+key (col1)
+);
+insert into t1 values (0, 'ab', 'a-b');
+insert into t1 values (1, 'a ', 'a-space');
+insert into t1 values (2, 'a', 'a');
+insert into t1 values (3, 'a \t', 'a-tab');
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+# Must show 'using index' for latin1_bin and utf8_bin:
+explain
+select col1, hex(col1) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL col1 67 NULL # Using index
+select col1, hex(col1) from t1;
+col1 hex(col1)
+a 61202009
+a 6120
+a 61
+ab 6162
+# Must show 'using index' for latin1_bin and utf8_bin:
+explain
+select col1, hex(col1) from t1 force index(col1) where col1 < 'b';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 # col1 col1 67 NULL # Using where; Using index
+select col1, hex(col1) from t1 force index(col1) where col1 < 'b';
+col1 hex(col1)
+a 61202009
+a 6120
+a 61
+ab 6162
+delete from t1;
+insert into t1 values(10, '', 'empty');
+insert into t1 values(11, repeat(' ', 8), '8x-space');
+insert into t1 values(12, repeat(' ', 16), '16x-space');
+insert into t1 values(13, repeat(' ', 24), '24x-space');
+insert into t1 values(14, concat(repeat(' ', 16),'a'), '16x-space-a');
+insert into t1 values(21, repeat(' ', 9), '9x-space');
+insert into t1 values(22, repeat(' ',17), '17x-space');
+insert into t1 values(23, repeat(' ',18), '18x-space');
+explain
+select pk, col1, hex(col1), length(col1) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 # NULL col1 67 NULL # Using index
+select pk, col1, hex(col1), length(col1) from t1;
+pk col1 hex(col1) length(col1)
+10 0
+11 2020202020202020 8
+12 20202020202020202020202020202020 16
+13 202020202020202020202020202020202020202020202020 24
+21 202020202020202020 9
+22 2020202020202020202020202020202020 17
+23 202020202020202020202020202020202020 18
+14 a 2020202020202020202020202020202061 17
+drop table t1;
+create table t1 (pk int primary key, a varchar(512), key(a)) engine=rocksdb;
+insert into t1 values (1, concat('a', repeat(' ', 300)));
+insert into t1 values (2, concat('b', repeat(' ', 300)));
+select pk,length(a) from t1 force index(a) where a < 'zz';
+pk length(a)
+1 301
+2 301
+select pk,length(a),rtrim(a) from t1 force index(a) where a < 'zz';
+pk length(a) rtrim(a)
+1 301 a
+2 301 b
+select pk,length(a),rtrim(a) from t1 ignore index(a) where a < 'zz';
+pk length(a) rtrim(a)
+1 301 a
+2 301 b
+drop table t1;
+#
+# Issue 257: Sort order for varchars is different between
+# MyISAM/InnoDB vs MyRocks
+#
+create table t1 (
+pk varchar(64) CHARACTER SET utf8 COLLATE utf8_bin,
+col1 varchar(64),
+primary key (pk)
+);
+insert into t1 values ('a','a');
+insert into t1 values ('a ', 'a-space');
+ERROR 23000: Duplicate entry 'a ' for key 'PRIMARY'
+insert into t1 values('b ', 'b-2x-space');
+insert into t1 values ('b', 'b');
+ERROR 23000: Duplicate entry 'b' for key 'PRIMARY'
+select pk, hex(pk), col1 from t1;
+pk hex(pk) col1
+a 61 a
+b 622020 b-2x-space
+insert into t1 values ('a\t', 'a-tab');
+insert into t1 values ('a \t', 'a-space-tab');
+select pk, hex(pk), col1 from t1 order by pk;
+pk hex(pk) col1
+a 6109 a-tab
+a 612009 a-space-tab
+a 61 a
+b 622020 b-2x-space
+# Try longer values
+insert into t1 values (concat('a', repeat(' ',10)), 'a-10-x-space');
+ERROR 23000: Duplicate entry 'a ' for key 'PRIMARY'
+insert into t1 values (concat('c', repeat(' ',10)), 'c-10-x-space');
+select * from t1;
+pk col1
+a a-tab
+a a-space-tab
+a a
+b b-2x-space
+c c-10-x-space
+drop table t1;
+# Secondary index
+create table t1 (
+pk int not null primary key,
+col1 varchar(64) CHARACTER SET utf8 COLLATE utf8_bin,
+col2 varchar(64),
+key (col1)
+);
+insert into t1 values (0, 'ab', 'a-b');
+insert into t1 values (1, 'a ', 'a-space');
+insert into t1 values (2, 'a', 'a');
+insert into t1 values (3, 'a \t', 'a-tab');
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+# Must show 'using index' for latin1_bin and utf8_bin:
+explain
+select col1, hex(col1) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL col1 195 NULL # Using index
+select col1, hex(col1) from t1;
+col1 hex(col1)
+a 61202009
+a 6120
+a 61
+ab 6162
+# Must show 'using index' for latin1_bin and utf8_bin:
+explain
+select col1, hex(col1) from t1 force index(col1) where col1 < 'b';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 # col1 col1 195 NULL # Using where; Using index
+select col1, hex(col1) from t1 force index(col1) where col1 < 'b';
+col1 hex(col1)
+a 61202009
+a 6120
+a 61
+ab 6162
+delete from t1;
+insert into t1 values(10, '', 'empty');
+insert into t1 values(11, repeat(' ', 8), '8x-space');
+insert into t1 values(12, repeat(' ', 16), '16x-space');
+insert into t1 values(13, repeat(' ', 24), '24x-space');
+insert into t1 values(14, concat(repeat(' ', 16),'a'), '16x-space-a');
+insert into t1 values(21, repeat(' ', 9), '9x-space');
+insert into t1 values(22, repeat(' ',17), '17x-space');
+insert into t1 values(23, repeat(' ',18), '18x-space');
+explain
+select pk, col1, hex(col1), length(col1) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 # NULL col1 195 NULL # Using index
+select pk, col1, hex(col1), length(col1) from t1;
+pk col1 hex(col1) length(col1)
+10 0
+11 2020202020202020 8
+12 20202020202020202020202020202020 16
+13 202020202020202020202020202020202020202020202020 24
+21 202020202020202020 9
+22 2020202020202020202020202020202020 17
+23 202020202020202020202020202020202020 18
+14 a 2020202020202020202020202020202061 17
+drop table t1;
+create table t1 (pk int primary key, a varchar(512), key(a)) engine=rocksdb;
+insert into t1 values (1, concat('a', repeat(' ', 300)));
+insert into t1 values (2, concat('b', repeat(' ', 300)));
+select pk,length(a) from t1 force index(a) where a < 'zz';
+pk length(a)
+1 301
+2 301
+select pk,length(a),rtrim(a) from t1 force index(a) where a < 'zz';
+pk length(a) rtrim(a)
+1 301 a
+2 301 b
+select pk,length(a),rtrim(a) from t1 ignore index(a) where a < 'zz';
+pk length(a) rtrim(a)
+1 301 a
+2 301 b
+drop table t1;
+#
+# Issue 257: Sort order for varchars is different between
+# MyISAM/InnoDB vs MyRocks
+#
+create table t1 (
+pk varchar(64) CHARACTER SET ucs2 COLLATE ucs2_bin,
+col1 varchar(64),
+primary key (pk)
+);
+insert into t1 values ('a','a');
+insert into t1 values ('a ', 'a-space');
+ERROR 23000: Duplicate entry 'a ' for key 'PRIMARY'
+insert into t1 values('b ', 'b-2x-space');
+insert into t1 values ('b', 'b');
+ERROR 23000: Duplicate entry 'b' for key 'PRIMARY'
+select pk, hex(pk), col1 from t1;
+pk hex(pk) col1
+a 0061 a
+b 006200200020 b-2x-space
+insert into t1 values ('a\t', 'a-tab');
+insert into t1 values ('a \t', 'a-space-tab');
+select pk, hex(pk), col1 from t1 order by pk;
+pk hex(pk) col1
+a 00610009 a-tab
+a 006100200009 a-space-tab
+a 0061 a
+b 006200200020 b-2x-space
+# Try longer values
+insert into t1 values (concat('a', repeat(' ',10)), 'a-10-x-space');
+ERROR 23000: Duplicate entry 'a ' for key 'PRIMARY'
+insert into t1 values (concat('c', repeat(' ',10)), 'c-10-x-space');
+select * from t1;
+pk col1
+a a-tab
+a a-space-tab
+a a
+b b-2x-space
+c c-10-x-space
+drop table t1;
+# Secondary index
+create table t1 (
+pk int not null primary key,
+col1 varchar(64) CHARACTER SET ucs2 COLLATE ucs2_bin,
+col2 varchar(64),
+key (col1)
+);
+insert into t1 values (0, 'ab', 'a-b');
+insert into t1 values (1, 'a ', 'a-space');
+insert into t1 values (2, 'a', 'a');
+insert into t1 values (3, 'a \t', 'a-tab');
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+# Must show 'using index' for latin1_bin and utf8_bin:
+explain
+select col1, hex(col1) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL #
+select col1, hex(col1) from t1;
+col1 hex(col1)
+ab 00610062
+a 00610020
+a 0061
+a 0061002000200009
+# Must show 'using index' for latin1_bin and utf8_bin:
+explain
+select col1, hex(col1) from t1 force index(col1) where col1 < 'b';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 # col1 col1 131 NULL # Using where
+select col1, hex(col1) from t1 force index(col1) where col1 < 'b';
+col1 hex(col1)
+a 0061002000200009
+a 00610020
+a 0061
+ab 00610062
+delete from t1;
+insert into t1 values(10, '', 'empty');
+insert into t1 values(11, repeat(' ', 8), '8x-space');
+insert into t1 values(12, repeat(' ', 16), '16x-space');
+insert into t1 values(13, repeat(' ', 24), '24x-space');
+insert into t1 values(14, concat(repeat(' ', 16),'a'), '16x-space-a');
+insert into t1 values(21, repeat(' ', 9), '9x-space');
+insert into t1 values(22, repeat(' ',17), '17x-space');
+insert into t1 values(23, repeat(' ',18), '18x-space');
+explain
+select pk, col1, hex(col1), length(col1) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 # NULL NULL NULL NULL #
+select pk, col1, hex(col1), length(col1) from t1;
+pk col1 hex(col1) length(col1)
+10 0
+11 00200020002000200020002000200020 16
+12 0020002000200020002000200020002000200020002000200020002000200020 32
+13 002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020 48
+14 a 00200020002000200020002000200020002000200020002000200020002000200061 34
+21 002000200020002000200020002000200020 18
+22 00200020002000200020002000200020002000200020002000200020002000200020 34
+23 002000200020002000200020002000200020002000200020002000200020002000200020 36
+drop table t1;
+create table t1 (pk int primary key, a varchar(512), key(a)) engine=rocksdb;
+insert into t1 values (1, concat('a', repeat(' ', 300)));
+insert into t1 values (2, concat('b', repeat(' ', 300)));
+select pk,length(a) from t1 force index(a) where a < 'zz';
+pk length(a)
+1 301
+2 301
+select pk,length(a),rtrim(a) from t1 force index(a) where a < 'zz';
+pk length(a) rtrim(a)
+1 301 a
+2 301 b
+select pk,length(a),rtrim(a) from t1 ignore index(a) where a < 'zz';
+pk length(a) rtrim(a)
+1 301 a
+2 301 b
+drop table t1;
+#
+# Issue 257: Sort order for varchars is different between
+# MyISAM/InnoDB vs MyRocks
+#
+create table t1 (
+pk varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
+col1 varchar(64),
+primary key (pk)
+);
+insert into t1 values ('a','a');
+insert into t1 values ('a ', 'a-space');
+ERROR 23000: Duplicate entry 'a ' for key 'PRIMARY'
+insert into t1 values('b ', 'b-2x-space');
+insert into t1 values ('b', 'b');
+ERROR 23000: Duplicate entry 'b' for key 'PRIMARY'
+select pk, hex(pk), col1 from t1;
+pk hex(pk) col1
+a 61 a
+b 622020 b-2x-space
+insert into t1 values ('a\t', 'a-tab');
+insert into t1 values ('a \t', 'a-space-tab');
+select pk, hex(pk), col1 from t1 order by pk;
+pk hex(pk) col1
+a 6109 a-tab
+a 612009 a-space-tab
+a 61 a
+b 622020 b-2x-space
+# Try longer values
+insert into t1 values (concat('a', repeat(' ',10)), 'a-10-x-space');
+ERROR 23000: Duplicate entry 'a ' for key 'PRIMARY'
+insert into t1 values (concat('c', repeat(' ',10)), 'c-10-x-space');
+select * from t1;
+pk col1
+a a-tab
+a a-space-tab
+a a
+b b-2x-space
+c c-10-x-space
+drop table t1;
+# Secondary index
+create table t1 (
+pk int not null primary key,
+col1 varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
+col2 varchar(64),
+key (col1)
+);
+insert into t1 values (0, 'ab', 'a-b');
+insert into t1 values (1, 'a ', 'a-space');
+insert into t1 values (2, 'a', 'a');
+insert into t1 values (3, 'a \t', 'a-tab');
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+# Must show 'using index' for latin1_bin and utf8_bin:
+explain
+select col1, hex(col1) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL #
+select col1, hex(col1) from t1;
+col1 hex(col1)
+ab 6162
+a 6120
+a 61
+a 61202009
+# Must show 'using index' for latin1_bin and utf8_bin:
+explain
+select col1, hex(col1) from t1 force index(col1) where col1 < 'b';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 # col1 col1 259 NULL # Using where
+select col1, hex(col1) from t1 force index(col1) where col1 < 'b';
+col1 hex(col1)
+a 61202009
+a 6120
+a 61
+ab 6162
+delete from t1;
+insert into t1 values(10, '', 'empty');
+insert into t1 values(11, repeat(' ', 8), '8x-space');
+insert into t1 values(12, repeat(' ', 16), '16x-space');
+insert into t1 values(13, repeat(' ', 24), '24x-space');
+insert into t1 values(14, concat(repeat(' ', 16),'a'), '16x-space-a');
+insert into t1 values(21, repeat(' ', 9), '9x-space');
+insert into t1 values(22, repeat(' ',17), '17x-space');
+insert into t1 values(23, repeat(' ',18), '18x-space');
+explain
+select pk, col1, hex(col1), length(col1) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 # NULL NULL NULL NULL #
+select pk, col1, hex(col1), length(col1) from t1;
+pk col1 hex(col1) length(col1)
+10 0
+11 2020202020202020 8
+12 20202020202020202020202020202020 16
+13 202020202020202020202020202020202020202020202020 24
+14 a 2020202020202020202020202020202061 17
+21 202020202020202020 9
+22 2020202020202020202020202020202020 17
+23 202020202020202020202020202020202020 18
+drop table t1;
+create table t1 (pk int primary key, a varchar(512), key(a)) engine=rocksdb;
+insert into t1 values (1, concat('a', repeat(' ', 300)));
+insert into t1 values (2, concat('b', repeat(' ', 300)));
+select pk,length(a) from t1 force index(a) where a < 'zz';
+pk length(a)
+1 301
+2 301
+select pk,length(a),rtrim(a) from t1 force index(a) where a < 'zz';
+pk length(a) rtrim(a)
+1 301 a
+2 301 b
+select pk,length(a),rtrim(a) from t1 ignore index(a) where a < 'zz';
+pk length(a) rtrim(a)
+1 301 a
+2 301 b
+drop table t1;
+#
+# Issue 257: Sort order for varchars is different between
+# MyISAM/InnoDB vs MyRocks
+#
+create table t1 (
+pk varchar(64) CHARACTER SET utf16 COLLATE utf16_bin,
+col1 varchar(64),
+primary key (pk)
+);
+insert into t1 values ('a','a');
+insert into t1 values ('a ', 'a-space');
+ERROR 23000: Duplicate entry 'a ' for key 'PRIMARY'
+insert into t1 values('b ', 'b-2x-space');
+insert into t1 values ('b', 'b');
+ERROR 23000: Duplicate entry 'b' for key 'PRIMARY'
+select pk, hex(pk), col1 from t1;
+pk hex(pk) col1
+a 0061 a
+b 006200200020 b-2x-space
+insert into t1 values ('a\t', 'a-tab');
+insert into t1 values ('a \t', 'a-space-tab');
+select pk, hex(pk), col1 from t1 order by pk;
+pk hex(pk) col1
+a 00610009 a-tab
+a 006100200009 a-space-tab
+a 0061 a
+b 006200200020 b-2x-space
+# Try longer values
+insert into t1 values (concat('a', repeat(' ',10)), 'a-10-x-space');
+ERROR 23000: Duplicate entry 'a ' for key 'PRIMARY'
+insert into t1 values (concat('c', repeat(' ',10)), 'c-10-x-space');
+select * from t1;
+pk col1
+a a-tab
+a a-space-tab
+a a
+b b-2x-space
+c c-10-x-space
+drop table t1;
+# Secondary index
+create table t1 (
+pk int not null primary key,
+col1 varchar(64) CHARACTER SET utf16 COLLATE utf16_bin,
+col2 varchar(64),
+key (col1)
+);
+insert into t1 values (0, 'ab', 'a-b');
+insert into t1 values (1, 'a ', 'a-space');
+insert into t1 values (2, 'a', 'a');
+insert into t1 values (3, 'a \t', 'a-tab');
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+# Must show 'using index' for latin1_bin and utf8_bin:
+explain
+select col1, hex(col1) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL #
+select col1, hex(col1) from t1;
+col1 hex(col1)
+ab 00610062
+a 00610020
+a 0061
+a 0061002000200009
+# Must show 'using index' for latin1_bin and utf8_bin:
+explain
+select col1, hex(col1) from t1 force index(col1) where col1 < 'b';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 # col1 col1 259 NULL # Using where
+select col1, hex(col1) from t1 force index(col1) where col1 < 'b';
+col1 hex(col1)
+a 0061002000200009
+a 00610020
+a 0061
+ab 00610062
+delete from t1;
+insert into t1 values(10, '', 'empty');
+insert into t1 values(11, repeat(' ', 8), '8x-space');
+insert into t1 values(12, repeat(' ', 16), '16x-space');
+insert into t1 values(13, repeat(' ', 24), '24x-space');
+insert into t1 values(14, concat(repeat(' ', 16),'a'), '16x-space-a');
+insert into t1 values(21, repeat(' ', 9), '9x-space');
+insert into t1 values(22, repeat(' ',17), '17x-space');
+insert into t1 values(23, repeat(' ',18), '18x-space');
+explain
+select pk, col1, hex(col1), length(col1) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 # NULL NULL NULL NULL #
+select pk, col1, hex(col1), length(col1) from t1;
+pk col1 hex(col1) length(col1)
+10 0
+11 00200020002000200020002000200020 16
+12 0020002000200020002000200020002000200020002000200020002000200020 32
+13 002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020 48
+14 a 00200020002000200020002000200020002000200020002000200020002000200061 34
+21 002000200020002000200020002000200020 18
+22 00200020002000200020002000200020002000200020002000200020002000200020 34
+23 002000200020002000200020002000200020002000200020002000200020002000200020 36
+drop table t1;
+create table t1 (pk int primary key, a varchar(512), key(a)) engine=rocksdb;
+insert into t1 values (1, concat('a', repeat(' ', 300)));
+insert into t1 values (2, concat('b', repeat(' ', 300)));
+select pk,length(a) from t1 force index(a) where a < 'zz';
+pk length(a)
+1 301
+2 301
+select pk,length(a),rtrim(a) from t1 force index(a) where a < 'zz';
+pk length(a) rtrim(a)
+1 301 a
+2 301 b
+select pk,length(a),rtrim(a) from t1 ignore index(a) where a < 'zz';
+pk length(a) rtrim(a)
+1 301 a
+2 301 b
+drop table t1;
+create table t1 (
+pk int primary key,
+col1 varchar(10) collate utf8mb4_bin not null,
+col2 varchar(20),
+key(col1)
+) engine=rocksdb;
+insert into t1 values (1, 'ab','ab');
+insert into t1 values (2, 'ab\0','ab0');
+select pk, hex(col1), col2 from t1 force index(col1) order by col1;
+pk hex(col1) col2
+2 616200 ab0
+1 6162 ab
+select pk, hex(col1), col2 from t1 ignore index(col1) order by col1;
+pk hex(col1) col2
+2 616200 ab0
+1 6162 ab
+drop table t1;
+create table t (id int primary key, email varchar(100), KEY email_i (email(30)));
+insert into t values (1, 'abcabcabcabcabcabcabcabcabcabcabc ');
+explain select 'email_i' as index_name, count(*) AS count from t force index(email_i);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ALL NULL NULL NULL NULL #
+select 'email_i' as index_name, count(*) AS count from t force index(email_i);
+index_name count
+email_i 1
+drop table t;
+set @save_rocksdb_checksums_pct = @@global.rocksdb_checksums_pct;
+set @save_rocksdb_verify_row_debug_checksums = @@session.rocksdb_verify_row_debug_checksums;
+set global rocksdb_checksums_pct = 100;
+set session rocksdb_verify_row_debug_checksums = on;
+create table t (id int primary key, email varchar(100), KEY email_i (email(30)));
+insert into t values (1, 'a');
+explain select 'email_i' as index_name, count(*) AS count from t force index(email_i);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t ALL NULL NULL NULL NULL #
+select 'email_i' as index_name, count(*) AS count from t force index(email_i);
+index_name count
+email_i 1
+drop table t;
+set global rocksdb_checksums_pct = @save_rocksdb_checksums_pct;
+set session rocksdb_verify_row_debug_checksums = @save_rocksdb_verify_row_debug_checksums;
+drop table if exists t;
+Warnings:
+Note 1051 Unknown table 'test.t'
+create table t (h varchar(31) character set utf8 collate utf8_bin not null, i varchar(19) collate latin1_bin not null, primary key(i), key(h)) engine=rocksdb;
+insert into t(i,h) values('a','b');
+check table t;
+Table Op Msg_type Msg_text
+test.t check status OK
+alter table t modify h varchar(31) character set cp1257 collate cp1257_bin not null;
+check table t;
+Table Op Msg_type Msg_text
+test.t check status OK
+drop table t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/unique_check.result b/storage/rocksdb/mysql-test/rocksdb/r/unique_check.result
new file mode 100644
index 00000000..db9b1190
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/unique_check.result
@@ -0,0 +1,117 @@
+connect con1, localhost, root,,;
+connect con2, localhost, root,,;
+connect con3, localhost, root,,;
+connection default;
+set debug_sync='RESET';
+drop table if exists t1;
+create table t1 (id int, value int, primary key (id)) engine=rocksdb;
+create table t2 (id int, id2 int, value int, primary key (id), unique key (id2)) engine=rocksdb;
+connection con1;
+begin;
+insert into t1 values (1,1);
+connection con2;
+set session rocksdb_lock_wait_timeout=50;
+begin;
+insert into t1 values (1,2);
+connection con1;
+commit;
+connection con2;
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+commit;
+select * from t1;
+id value
+1 1
+truncate table t1;
+connection con1;
+begin;
+insert into t2 values (1,1,1);
+connection con2;
+begin;
+insert into t2 values (2,1,2);
+connection con1;
+commit;
+connection con2;
+ERROR 23000: Duplicate entry '1' for key 'id2'
+commit;
+select * from t2;
+id id2 value
+1 1 1
+truncate table t2;
+connection con1;
+begin;
+insert into t1 values (1,1);
+connection con2;
+begin;
+insert into t1 values (1,2);
+connection con1;
+rollback;
+connection con2;
+commit;
+select * from t1;
+id value
+1 2
+truncate table t1;
+connection con1;
+begin;
+insert into t2 values (1,1,1);
+connection con2;
+begin;
+insert into t2 values (2,1,2);
+connection con1;
+rollback;
+connection con2;
+commit;
+select * from t2;
+id id2 value
+2 1 2
+truncate table t2;
+connection con1;
+set debug_sync='rocksdb.update_write_row_after_unique_check SIGNAL parked1 WAIT_FOR go';
+insert into t1 values (1,1);
+connection default;
+set debug_sync='now WAIT_FOR parked1';
+connection con2;
+set debug_sync='rocksdb.update_write_row_after_unique_check SIGNAL parked2 WAIT_FOR go';
+insert into t2 values (1,1,1);
+connection default;
+set debug_sync='now WAIT_FOR parked2';
+connection con3;
+set session rocksdb_lock_wait_timeout=1;
+insert into t1 values (1,2);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+insert into t2 values (2,1,2);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection default;
+set debug_sync='now SIGNAL go';
+connection con1;
+connection con2;
+connection default;
+insert into t1 values (1,2);
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+insert into t2 values (2,1,2);
+ERROR 23000: Duplicate entry '1' for key 'id2'
+select * from t1;
+id value
+1 1
+select * from t2;
+id id2 value
+1 1 1
+connection default;
+set debug_sync='RESET';
+disconnect con1;
+disconnect con2;
+disconnect con3;
+drop table t1, t2;
+connection default;
+drop table if exists t1,t2,t3;
+create table t1 (id int, value int, primary key (id)) engine=rocksdb;
+create table t2 (id int, id2 int, value int, primary key (id), unique key (id2)) engine=rocksdb;
+create table t3 (id int, value int) engine=rocksdb;
+SET @old_val = @@session.unique_checks;
+set @@session.unique_checks = FALSE;
+insert into t1 values (1, 1), (1, 2);
+insert into t2 values (1, 1, 1), (1, 2, 1);
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+insert into t3 values (1, 1), (1, 1);
+set @@session.unique_checks = @old_val;
+drop table t1, t2, t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/unique_sec.result b/storage/rocksdb/mysql-test/rocksdb/r/unique_sec.result
new file mode 100644
index 00000000..a37e7f1c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/unique_sec.result
@@ -0,0 +1,221 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE t1 (id1 INT NOT NULL, id2 INT NOT NULL, id3 VARCHAR(32),
+id4 INT, id5 VARCHAR(32),
+value1 INT, value2 INT, value3 VARCHAR(32),
+PRIMARY KEY (id1, id2) ,
+UNIQUE INDEX (id2, id1) ,
+UNIQUE INDEX (id2, id3, id4) ,
+INDEX (id1) ,
+INDEX (id3, id1) ,
+UNIQUE INDEX(id5) ,
+INDEX (id2, id5)) ENGINE=ROCKSDB;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+# Test inserting a key that returns duplicate error
+INSERT INTO t1 VALUES (1, 1, 11, 11, 11, 11, 11, 11);
+ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
+INSERT INTO t1 VALUES (5, 5, 11, 11, 11, 11, 11, 11);
+ERROR 23000: Duplicate entry '5-5' for key 'PRIMARY'
+INSERT INTO t1 VALUES (10, 10, 11, 11, 11, 11, 11, 11);
+ERROR 23000: Duplicate entry '10-10' for key 'PRIMARY'
+INSERT INTO t1 VALUES (11, 1, 1, 1, 11, 11, 11, 11);
+ERROR 23000: Duplicate entry '1-1-1' for key 'id2_2'
+INSERT INTO t1 VALUES (11, 5, 5, 5, 11, 11, 11, 11);
+ERROR 23000: Duplicate entry '5-5-5' for key 'id2_2'
+INSERT INTO t1 VALUES (11, 10, 10, 10, 11, 11, 11, 11);
+ERROR 23000: Duplicate entry '10-10-10' for key 'id2_2'
+INSERT INTO t1 VALUES (11, 11, 11, 11, 1, 11, 11, 11);
+ERROR 23000: Duplicate entry '1' for key 'id5'
+INSERT INTO t1 VALUES (11, 11, 11, 11, 5, 11, 11, 11);
+ERROR 23000: Duplicate entry '5' for key 'id5'
+INSERT INTO t1 VALUES (11, 11, 11, 11, 10, 11, 11, 11);
+ERROR 23000: Duplicate entry '10' for key 'id5'
+# Test updating a key that returns duplicate error
+UPDATE t1 SET id2=1, id3=1, id4=1 WHERE id1=2;
+ERROR 23000: Duplicate entry '1-1-1' for key 'id2_2'
+UPDATE t1 SET id2=1, id3=1, id4=1;
+ERROR 23000: Duplicate entry '1-1-1' for key 'id2_2'
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+# Test updating a key to itself
+UPDATE t1 set id2=id4;
+UPDATE t1 set id5=id3, value1=value2;
+UPDATE t1 set value3=value1;
+# Test modifying values should not cause duplicates
+UPDATE t1 SET value1=value3+1;
+UPDATE t1 SET value3=value3 div 2;
+UPDATE t1 SET value2=value3;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+# Test NULL values are considered unique
+INSERT INTO t1 VALUES (20, 20, 20, NULL, NULL, 20, 20, 20);
+INSERT INTO t1 VALUES (21, 20, 20, NULL, NULL, 20, 20, 20);
+INSERT INTO t1 VALUES (22, 20, 20, NULL, NULL, 20, 20, 20);
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+13
+# Adding multiple rows where one of the rows fail the duplicate
+# check should fail the whole statement
+INSERT INTO t1 VALUES (23, 23, 23, 23, 23, 23, 23, 23),
+(24, 24, 24, 24, 24, 24, 24, 24),
+(25, 10, 10, 10, 25, 25, 25, 25),
+(26, 26, 26, 26, 26, 26, 26, 26);
+ERROR 23000: Duplicate entry '10-10-10' for key 'id2_2'
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+13
+connection con1;
+BEGIN;
+INSERT INTO t1 VALUES (30, 31, 32, 33, 34, 30, 30, 30);
+connection con2;
+BEGIN;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+13
+# Primary key should prevent duplicate on insert
+INSERT INTO t1 VALUES (30, 31, 30, 30, 30, 30, 30, 30);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# Primary key should prevent duplicate on update
+UPDATE t1 SET id1=30, id2=31 WHERE id2=10;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# Unique secondary key should prevent duplicate on insert
+INSERT INTO t1 VALUES (31, 31, 32, 33, 30, 30, 30, 30);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t1 VALUES (32, 32, 32, 32, 34, 32, 32, 32);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# Unique secondary key should prevent duplicate on update
+UPDATE t1 SET id2=31, id3=32, id4=33 WHERE id2=8;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t1 SET id5=34 WHERE id2=8;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# Adding multiple rows where one of the rows fail the duplicate
+# check should fail the whole statement
+INSERT INTO t1 VALUES (35, 35, 35, 35, 35, 35, 35, 35),
+(36, 36, 36, 36, 36, 36, 36, 36),
+(37, 31, 32, 33, 37, 37, 37, 37),
+(38, 38, 38, 38, 38, 38, 38, 38);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t1 VALUES (35, 35, 35, 35, 35, 35, 35, 35),
+(36, 36, 36, 36, 36, 36, 36, 36),
+(37, 37, 37, 37, 34, 37, 37, 37),
+(38, 38, 38, 38, 38, 38, 38, 38);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# NULL values are unique and duplicates in value fields are ignored
+INSERT INTO t1 VALUES (37, 31, 32, NULL, 37, 37, 37, 37),
+(38, 31, 32, NULL, 38, 37, 37, 37),
+(39, 31, 32, NULL, 39, 37, 37, 37);
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+16
+# Fail on duplicate key update for row added in our transaction
+UPDATE t1 SET id5=37 WHERE id1=38;
+ERROR 23000: Duplicate entry '37' for key 'id5'
+# Fail on lock timeout for row modified in another transaction
+UPDATE t1 SET id5=34 WHERE id1=38;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# NULL values are unique
+UPDATE t1 SET id5=NULL WHERE value1 > 37;
+connection con1;
+COMMIT;
+connection con2;
+COMMIT;
+connection con2;
+BEGIN;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+17
+connection con1;
+BEGIN;
+INSERT INTO t1 VALUES (40, 40, 40, 40, 40, 40, 40, 40);
+connection con2;
+# When transaction is pending, fail on lock acquisition
+INSERT INTO t1 VALUES (40, 40, 40, 40, 40, 40, 40, 40);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t1 VALUES (41, 40, 40, 40, 40, 40, 40, 40);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+17
+connection con1;
+COMMIT;
+connection con2;
+# When transaction is committed, fail on duplicate key
+INSERT INTO t1 VALUES (40, 40, 40, 40, 40, 40, 40, 40);
+Got one of the listed errors
+INSERT INTO t1 VALUES (41, 40, 40, 40, 40, 40, 40, 40);
+ERROR 23000: Duplicate entry '40-40-40' for key 'id2_2'
+ROLLBACK;
+SELECT * FROM t1;
+id1 id2 id3 id4 id5 value1 value2 value3
+1 1 1 1 1 2 0 0
+2 2 2 2 2 3 1 1
+3 3 3 3 3 4 1 1
+4 4 4 4 4 5 2 2
+5 5 5 5 5 6 2 2
+6 6 6 6 6 7 3 3
+7 7 7 7 7 8 3 3
+8 8 8 8 8 9 4 4
+9 9 9 9 9 10 4 4
+10 10 10 10 10 11 5 5
+20 20 20 NULL NULL 20 20 20
+21 20 20 NULL NULL 20 20 20
+22 20 20 NULL NULL 20 20 20
+30 31 32 33 34 30 30 30
+37 31 32 NULL 37 37 37 37
+38 31 32 NULL 38 37 37 37
+39 31 32 NULL 39 37 37 37
+40 40 40 40 40 40 40 40
+disconnect con1;
+disconnect con2;
+connection default;
+DROP TABLE t1;
+#
+# Issue #88: Creating unique index over column with duplicate values succeeds
+#
+create table t1 (pk int primary key, a int) engine=rocksdb;
+insert into t1 values
+(1, 1),
+(2, 2),
+(3, 3),
+(4, 1),
+(5, 5);
+alter table t1 add unique(a);
+ERROR 23000: Duplicate entry '1' for key 'a'
+drop table t1;
+#
+# Issue #111
+#
+CREATE TABLE t2 (pk int, a int, PRIMARY KEY (pk, a), UNIQUE KEY (a)) ENGINE=ROCKSDB PARTITION BY KEY (a) PARTITIONS 16;
+INSERT INTO t2 VALUES (1,1);
+INSERT INTO t2 VALUES (1,1);
+ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
+INSERT INTO t2 VALUES (2,1);
+ERROR 23000: Duplicate entry '1' for key 'a'
+DROP TABLE t2;
+#
+# Issue #491 (https://github.com/facebook/mysql-5.6/issues/491)
+#
+CREATE TABLE t (a BLOB, PRIMARY KEY(a(2)), UNIQUE KEY (a(1))) engine=rocksdb;
+INSERT INTO t VALUES('a');
+CHECK TABLE t EXTENDED;
+Table Op Msg_type Msg_text
+test.t check status OK
+DROP TABLE t;
+CREATE TABLE t (a VARCHAR(255), PRIMARY KEY(a), UNIQUE KEY (a(1))) engine=rocksdb;
+INSERT INTO t VALUES('a');
+CHECK TABLE t EXTENDED;
+Table Op Msg_type Msg_text
+test.t check status OK
+DROP TABLE t;
+CREATE TABLE t (a VARCHAR(255), PRIMARY KEY(a(2)), UNIQUE KEY (a(1))) engine=rocksdb;
+INSERT INTO t VALUES('a');
+CHECK TABLE t EXTENDED;
+Table Op Msg_type Msg_text
+test.t check status OK
+DROP TABLE t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/unique_sec_rev_cf.result b/storage/rocksdb/mysql-test/rocksdb/r/unique_sec_rev_cf.result
new file mode 100644
index 00000000..210c7409
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/unique_sec_rev_cf.result
@@ -0,0 +1,177 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE t1 (id1 INT NOT NULL, id2 INT NOT NULL, id3 VARCHAR(32),
+id4 INT, id5 VARCHAR(32),
+value1 INT, value2 INT, value3 VARCHAR(32),
+PRIMARY KEY (id1, id2) COMMENT 'rev:cf',
+UNIQUE INDEX (id2, id1) COMMENT 'rev:cf',
+UNIQUE INDEX (id2, id3, id4) COMMENT 'rev:cf',
+INDEX (id1) COMMENT 'rev:cf',
+INDEX (id3, id1) COMMENT 'rev:cf',
+UNIQUE INDEX(id5) COMMENT 'rev:cf',
+INDEX (id2, id5)) ENGINE=ROCKSDB;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+# Test inserting a key that returns duplicate error
+INSERT INTO t1 VALUES (1, 1, 11, 11, 11, 11, 11, 11);
+ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
+INSERT INTO t1 VALUES (5, 5, 11, 11, 11, 11, 11, 11);
+ERROR 23000: Duplicate entry '5-5' for key 'PRIMARY'
+INSERT INTO t1 VALUES (10, 10, 11, 11, 11, 11, 11, 11);
+ERROR 23000: Duplicate entry '10-10' for key 'PRIMARY'
+INSERT INTO t1 VALUES (11, 1, 1, 1, 11, 11, 11, 11);
+ERROR 23000: Duplicate entry '1-1-1' for key 'id2_2'
+INSERT INTO t1 VALUES (11, 5, 5, 5, 11, 11, 11, 11);
+ERROR 23000: Duplicate entry '5-5-5' for key 'id2_2'
+INSERT INTO t1 VALUES (11, 10, 10, 10, 11, 11, 11, 11);
+ERROR 23000: Duplicate entry '10-10-10' for key 'id2_2'
+INSERT INTO t1 VALUES (11, 11, 11, 11, 1, 11, 11, 11);
+ERROR 23000: Duplicate entry '1' for key 'id5'
+INSERT INTO t1 VALUES (11, 11, 11, 11, 5, 11, 11, 11);
+ERROR 23000: Duplicate entry '5' for key 'id5'
+INSERT INTO t1 VALUES (11, 11, 11, 11, 10, 11, 11, 11);
+ERROR 23000: Duplicate entry '10' for key 'id5'
+# Test updating a key that returns duplicate error
+UPDATE t1 SET id2=1, id3=1, id4=1 WHERE id1=2;
+ERROR 23000: Duplicate entry '1-1-1' for key 'id2_2'
+UPDATE t1 SET id2=1, id3=1, id4=1;
+ERROR 23000: Duplicate entry '1-1-1' for key 'id2_2'
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+# Test updating a key to itself
+UPDATE t1 set id2=id4;
+UPDATE t1 set id5=id3, value1=value2;
+UPDATE t1 set value3=value1;
+# Test modifying values should not cause duplicates
+UPDATE t1 SET value1=value3+1;
+UPDATE t1 SET value3=value3 div 2;
+UPDATE t1 SET value2=value3;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+# Test NULL values are considered unique
+INSERT INTO t1 VALUES (20, 20, 20, NULL, NULL, 20, 20, 20);
+INSERT INTO t1 VALUES (21, 20, 20, NULL, NULL, 20, 20, 20);
+INSERT INTO t1 VALUES (22, 20, 20, NULL, NULL, 20, 20, 20);
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+13
+# Adding multiple rows where one of the rows fail the duplicate
+# check should fail the whole statement
+INSERT INTO t1 VALUES (23, 23, 23, 23, 23, 23, 23, 23),
+(24, 24, 24, 24, 24, 24, 24, 24),
+(25, 10, 10, 10, 25, 25, 25, 25),
+(26, 26, 26, 26, 26, 26, 26, 26);
+ERROR 23000: Duplicate entry '10-10-10' for key 'id2_2'
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+13
+connection con1;
+BEGIN;
+INSERT INTO t1 VALUES (30, 31, 32, 33, 34, 30, 30, 30);
+connection con2;
+BEGIN;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+13
+# Primary key should prevent duplicate on insert
+INSERT INTO t1 VALUES (30, 31, 30, 30, 30, 30, 30, 30);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# Primary key should prevent duplicate on update
+UPDATE t1 SET id1=30, id2=31 WHERE id2=10;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# Unique secondary key should prevent duplicate on insert
+INSERT INTO t1 VALUES (31, 31, 32, 33, 30, 30, 30, 30);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t1 VALUES (32, 32, 32, 32, 34, 32, 32, 32);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# Unique secondary key should prevent duplicate on update
+UPDATE t1 SET id2=31, id3=32, id4=33 WHERE id2=8;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t1 SET id5=34 WHERE id2=8;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# Adding multiple rows where one of the rows fail the duplicate
+# check should fail the whole statement
+INSERT INTO t1 VALUES (35, 35, 35, 35, 35, 35, 35, 35),
+(36, 36, 36, 36, 36, 36, 36, 36),
+(37, 31, 32, 33, 37, 37, 37, 37),
+(38, 38, 38, 38, 38, 38, 38, 38);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t1 VALUES (35, 35, 35, 35, 35, 35, 35, 35),
+(36, 36, 36, 36, 36, 36, 36, 36),
+(37, 37, 37, 37, 34, 37, 37, 37),
+(38, 38, 38, 38, 38, 38, 38, 38);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# NULL values are unique and duplicates in value fields are ignored
+INSERT INTO t1 VALUES (37, 31, 32, NULL, 37, 37, 37, 37),
+(38, 31, 32, NULL, 38, 37, 37, 37),
+(39, 31, 32, NULL, 39, 37, 37, 37);
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+16
+# Fail on duplicate key update for row added in our transaction
+UPDATE t1 SET id5=37 WHERE id1=38;
+ERROR 23000: Duplicate entry '37' for key 'id5'
+# Fail on lock timeout for row modified in another transaction
+UPDATE t1 SET id5=34 WHERE id1=38;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# NULL values are unique
+UPDATE t1 SET id5=NULL WHERE value1 > 37;
+connection con1;
+COMMIT;
+connection con2;
+COMMIT;
+connection con2;
+BEGIN;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+17
+connection con1;
+BEGIN;
+INSERT INTO t1 VALUES (40, 40, 40, 40, 40, 40, 40, 40);
+connection con2;
+# When transaction is pending, fail on lock acquisition
+INSERT INTO t1 VALUES (40, 40, 40, 40, 40, 40, 40, 40);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t1 VALUES (41, 40, 40, 40, 40, 40, 40, 40);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+17
+connection con1;
+COMMIT;
+connection con2;
+# When transaction is committed, fail on duplicate key
+INSERT INTO t1 VALUES (40, 40, 40, 40, 40, 40, 40, 40);
+Got one of the listed errors
+INSERT INTO t1 VALUES (41, 40, 40, 40, 40, 40, 40, 40);
+ERROR 23000: Duplicate entry '40-40-40' for key 'id2_2'
+ROLLBACK;
+SELECT * FROM t1;
+id1 id2 id3 id4 id5 value1 value2 value3
+40 40 40 40 40 40 40 40
+39 31 32 NULL 39 37 37 37
+38 31 32 NULL 38 37 37 37
+37 31 32 NULL 37 37 37 37
+30 31 32 33 34 30 30 30
+22 20 20 NULL NULL 20 20 20
+21 20 20 NULL NULL 20 20 20
+20 20 20 NULL NULL 20 20 20
+10 10 10 10 10 11 5 5
+9 9 9 9 9 10 4 4
+8 8 8 8 8 9 4 4
+7 7 7 7 7 8 3 3
+6 6 6 6 6 7 3 3
+5 5 5 5 5 6 2 2
+4 4 4 4 4 5 2 2
+3 3 3 3 3 4 1 1
+2 2 2 2 2 3 1 1
+1 1 1 1 1 2 0 0
+disconnect con1;
+disconnect con2;
+connection default;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/unsupported_tx_isolations.result b/storage/rocksdb/mysql-test/rocksdb/r/unsupported_tx_isolations.result
new file mode 100644
index 00000000..32776e19
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/unsupported_tx_isolations.result
@@ -0,0 +1,18 @@
+DROP TABLE IF EXISTS t1;
+create table t1 (id int primary key, value int) engine=rocksdb;
+insert into t1 values (1,1);
+SET session transaction isolation level read uncommitted;
+begin;
+insert into t1 values (2,1);
+ERROR HY000: MyRocks supports only READ COMMITTED and REPEATABLE READ isolation levels. Please change from current isolation level READ-UNCOMMITTED
+select * from t1 where id=1;
+ERROR HY000: MyRocks supports only READ COMMITTED and REPEATABLE READ isolation levels. Please change from current isolation level READ-UNCOMMITTED
+rollback;
+SET session transaction isolation level serializable;
+begin;
+insert into t1 values (2,1);
+ERROR HY000: MyRocks supports only READ COMMITTED and REPEATABLE READ isolation levels. Please change from current isolation level SERIALIZABLE
+select * from t1 where id=1;
+ERROR HY000: MyRocks supports only READ COMMITTED and REPEATABLE READ isolation levels. Please change from current isolation level SERIALIZABLE
+rollback;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/update.result b/storage/rocksdb/mysql-test/rocksdb/r/update.result
new file mode 100644
index 00000000..791fddd2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/update.result
@@ -0,0 +1,121 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+UPDATE t1 SET a=a+100;
+SELECT a,b FROM t1;
+a b
+101 a
+101 a
+10100 foobar
+10100 foobar
+102 b
+102 b
+103 c
+103 c
+104 d
+104 d
+105 e
+105 e
+UPDATE t1 SET a=a-100, b=DEFAULT WHERE a>100;
+SELECT a,b FROM t1;
+a b
+1 NULL
+1 NULL
+10000 NULL
+10000 NULL
+2 NULL
+2 NULL
+3 NULL
+3 NULL
+4 NULL
+4 NULL
+5 NULL
+5 NULL
+UPDATE t1 SET b = 'update' WHERE a <= 4 ORDER BY b DESC, a ASC LIMIT 1;
+SELECT a,b FROM t1;
+a b
+1 NULL
+1 update
+10000 NULL
+10000 NULL
+2 NULL
+2 NULL
+3 NULL
+3 NULL
+4 NULL
+4 NULL
+5 NULL
+5 NULL
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+BEGIN;
+UPDATE t1 SET a=a+100;
+UPDATE t1 SET a=a-50, b=DEFAULT WHERE a>100;
+COMMIT;
+SELECT * FROM t1 ORDER BY pk;
+a b pk
+10050 NULL 12
+10050 NULL 6
+51 NULL 1
+51 NULL 7
+52 NULL 2
+52 NULL 8
+53 NULL 3
+53 NULL 9
+54 NULL 10
+54 NULL 4
+55 NULL 11
+55 NULL 5
+BEGIN;
+UPDATE t1 SET b = 'update' WHERE a <= 4 ORDER BY a DESC, b ASC LIMIT 3;
+UPDATE t1 SET b = '';
+ROLLBACK;
+SELECT * FROM t1 ORDER BY pk;
+a b pk
+51 NULL 1
+52 NULL 2
+53 NULL 3
+54 NULL 4
+55 NULL 5
+10050 NULL 6
+51 NULL 7
+52 NULL 8
+53 NULL 9
+54 NULL 10
+55 NULL 11
+10050 NULL 12
+BEGIN;
+UPDATE t1 SET b = 'update2' WHERE a <= 100;
+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;
+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 * FROM t1 ORDER BY pk;
+a b pk
+51 NULL 1
+52 NULL 2
+53 NULL 3
+54 NULL 4
+55 NULL 5
+10050 NULL 6
+51 NULL 7
+52 NULL 8
+53 NULL 9
+54 NULL 10
+55 NULL 11
+10050 NULL 12
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b CHAR(8), UNIQUE INDEX(a)) ENGINE=RocksDB;
+INSERT INTO t1 (a,b) VALUES (1,'foo'),(2,'bar');
+UPDATE t1 SET a=a+100;
+SELECT * FROM t1;
+a b
+101 foo
+102 bar
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/update_ignore.result b/storage/rocksdb/mysql-test/rocksdb/r/update_ignore.result
new file mode 100644
index 00000000..d36371be
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/update_ignore.result
@@ -0,0 +1,57 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+CREATE TABLE t2 (c CHAR(8), d INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+UPDATE IGNORE t1 SET b = 'upd1' WHERE b IS NOT NULL ORDER BY a LIMIT 1;
+SELECT a,b FROM t1 ORDER BY pk;
+a b
+1 upd1
+2 b
+3 c
+4 d
+5 e
+10000 foobar
+1 a
+2 b
+3 c
+4 d
+5 e
+10000 foobar
+UPDATE t1, t2 SET b = 'upd2a', c = 'upd2b'
+WHERE c < b OR a != ( SELECT 1 UNION SELECT 2 );
+ERROR 21000: Subquery returns more than 1 row
+UPDATE IGNORE t1, t2 SET b = 'upd2a', c = 'upd2b'
+WHERE c < b OR a != ( SELECT 1 UNION SELECT 2 );
+Warnings:
+Warning 1242 Subquery returns more than 1 row
+SELECT a,b FROM t1 ORDER BY pk;
+a b
+1 upd2a
+2 upd2a
+3 upd2a
+4 upd2a
+5 upd2a
+10000 upd2a
+1 a
+2 upd2a
+3 upd2a
+4 upd2a
+5 upd2a
+10000 upd2a
+SELECT c,d FROM t2 ORDER BY pk;
+c d
+upd2b 1
+upd2b 2
+upd2b 3
+upd2b 4
+upd2b 5
+upd2b 10000
+upd2b 1
+upd2b 2
+upd2b 3
+upd2b 4
+upd2b 5
+upd2b 10000
+DROP TABLE t1, t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/update_multi.result b/storage/rocksdb/mysql-test/rocksdb/r/update_multi.result
new file mode 100644
index 00000000..294c07b2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/update_multi.result
@@ -0,0 +1,691 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES
+(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+CREATE TABLE t2 (c CHAR(8), d INT, pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+UPDATE t1 STRAIGHT_JOIN t2 SET t1.a = t2.d+100, t2.c = 'multi'
+WHERE c < b AND a + d != 1;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar 10000
+foobar 10000
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+UPDATE t2 STRAIGHT_JOIN t1 SET t2.d = DEFAULT
+WHERE c = 'foobar' and b = c;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar NULL
+foobar NULL
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES
+(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+CREATE TABLE t2 (c CHAR(8), d INT, pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+UPDATE t1 STRAIGHT_JOIN t2 SET t1.a = t2.d+100, t2.c = 'multi'
+WHERE c < b AND a + d != 1;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar 10000
+foobar 10000
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+UPDATE t2 STRAIGHT_JOIN t1 SET t2.d = DEFAULT
+WHERE c = 'foobar' and b = c;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar NULL
+foobar NULL
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES
+(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+CREATE TABLE t2 (c CHAR(8), d INT, pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+UPDATE t1 STRAIGHT_JOIN t2 SET t1.a = t2.d+100, t2.c = 'multi'
+WHERE c < b AND a + d != 1;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar 10000
+foobar 10000
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+UPDATE t2 STRAIGHT_JOIN t1 SET t2.d = DEFAULT
+WHERE c = 'foobar' and b = c;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar NULL
+foobar NULL
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES
+(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+CREATE TABLE t2 (c CHAR(8), d INT, pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+UPDATE t1 STRAIGHT_JOIN t2 SET t1.a = t2.d+100, t2.c = 'multi'
+WHERE c < b AND a + d != 1;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar 10000
+foobar 10000
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+UPDATE t2 STRAIGHT_JOIN t1 SET t2.d = DEFAULT
+WHERE c = 'foobar' and b = c;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar NULL
+foobar NULL
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES
+(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+CREATE TABLE t2 (c CHAR(8), d INT, pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+UPDATE t1 STRAIGHT_JOIN t2 SET t1.a = t2.d+100, t2.c = 'multi'
+WHERE c < b AND a + d != 1;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar 10000
+foobar 10000
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+UPDATE t2 STRAIGHT_JOIN t1 SET t2.d = DEFAULT
+WHERE c = 'foobar' and b = c;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar NULL
+foobar NULL
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES
+(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+CREATE TABLE t2 (c CHAR(8), d INT, pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+UPDATE t1 STRAIGHT_JOIN t2 SET t1.a = t2.d+100, t2.c = 'multi'
+WHERE c < b AND a + d != 1;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar 10000
+foobar 10000
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+UPDATE t2 STRAIGHT_JOIN t1 SET t2.d = DEFAULT
+WHERE c = 'foobar' and b = c;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar NULL
+foobar NULL
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES
+(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+CREATE TABLE t2 (c CHAR(8), d INT, pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+UPDATE t1 STRAIGHT_JOIN t2 SET t1.a = t2.d+100, t2.c = 'multi'
+WHERE c < b AND a + d != 1;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar 10000
+foobar 10000
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+UPDATE t2 STRAIGHT_JOIN t1 SET t2.d = DEFAULT
+WHERE c = 'foobar' and b = c;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar NULL
+foobar NULL
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES
+(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+CREATE TABLE t2 (c CHAR(8), d INT, pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+UPDATE t1 STRAIGHT_JOIN t2 SET t1.a = t2.d+100, t2.c = 'multi'
+WHERE c < b AND a + d != 1;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar 10000
+foobar 10000
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+UPDATE t2 STRAIGHT_JOIN t1 SET t2.d = DEFAULT
+WHERE c = 'foobar' and b = c;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar NULL
+foobar NULL
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES
+(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+CREATE TABLE t2 (c CHAR(8), d INT, pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+UPDATE t1 STRAIGHT_JOIN t2 SET t1.a = t2.d+100, t2.c = 'multi'
+WHERE c < b AND a + d != 1;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar 10000
+foobar 10000
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+UPDATE t2 STRAIGHT_JOIN t1 SET t2.d = DEFAULT
+WHERE c = 'foobar' and b = c;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar NULL
+foobar NULL
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES
+(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+CREATE TABLE t2 (c CHAR(8), d INT, pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+UPDATE t1 STRAIGHT_JOIN t2 SET t1.a = t2.d+100, t2.c = 'multi'
+WHERE c < b AND a + d != 1;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar 10000
+foobar 10000
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+UPDATE t2 STRAIGHT_JOIN t1 SET t2.d = DEFAULT
+WHERE c = 'foobar' and b = c;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar NULL
+foobar NULL
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+DROP TABLE t1, t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/update_with_keys.result b/storage/rocksdb/mysql-test/rocksdb/r/update_with_keys.result
new file mode 100644
index 00000000..576fe6f6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/update_with_keys.result
@@ -0,0 +1,38 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, INDEX(b)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
+UPDATE t1 SET a=100, b='f' WHERE b IN ('b','c');
+UPDATE t1 SET b='m' WHERE b = 'f';
+UPDATE t1 SET b='z' WHERE a < 2;
+UPDATE t1 SET b='';
+SELECT a,b FROM t1;
+a b
+1
+100
+100
+4
+5
+6
+7
+8
+DROP TABLE t1;
+# RocksDB: skip the test for secondary UNIQUE keys.
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+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 'PRIMARY'
+UPDATE t1 SET a=12345 ORDER BY a DESC, b LIMIT 1;
+SELECT a,b FROM t1;
+a b
+0 a
+12345 e
+200 f
+201 a
+202 b
+203 c
+204 d
+UPDATE t1 SET a=80 WHERE a IN (202,203);
+ERROR 23000: Duplicate entry '80' for key 'PRIMARY'
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/use_direct_io_for_flush_and_compaction.result b/storage/rocksdb/mysql-test/rocksdb/r/use_direct_io_for_flush_and_compaction.result
new file mode 100644
index 00000000..8a4ee14c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/use_direct_io_for_flush_and_compaction.result
@@ -0,0 +1,18 @@
+Checking direct reads
+CREATE TABLE t1 (pk INT PRIMARY KEY DEFAULT '0', a INT(11), b CHAR(8)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL DEFAULT 0,
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (1, 1,'a');
+INSERT INTO t1 (a,b) VALUES (2,'b');
+set global rocksdb_force_flush_memtable_now=1;
+SELECT a,b FROM t1;
+a b
+1 a
+2 b
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/use_direct_reads.result b/storage/rocksdb/mysql-test/rocksdb/r/use_direct_reads.result
new file mode 100644
index 00000000..8a4ee14c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/use_direct_reads.result
@@ -0,0 +1,18 @@
+Checking direct reads
+CREATE TABLE t1 (pk INT PRIMARY KEY DEFAULT '0', a INT(11), b CHAR(8)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL DEFAULT 0,
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (1, 1,'a');
+INSERT INTO t1 (a,b) VALUES (2,'b');
+set global rocksdb_force_flush_memtable_now=1;
+SELECT a,b FROM t1;
+a b
+1 a
+2 b
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/use_direct_reads_writes.result b/storage/rocksdb/mysql-test/rocksdb/r/use_direct_reads_writes.result
new file mode 100644
index 00000000..eda49c58
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/use_direct_reads_writes.result
@@ -0,0 +1,22 @@
+call mtr.add_suppression("rocksdb");
+call mtr.add_suppression("Aborting");
+# This shows that RocksDB plugin is loaded:
+select plugin_name, plugin_type from information_schema.plugins where plugin_name='RocksDB';
+plugin_name plugin_type
+ROCKSDB STORAGE ENGINE
+Checking direct reads
+# restart
+FOUND 1 /enable both use_direct_reads/ in use_direct_reads_writes.err
+Checking direct writes
+# restart
+FOUND 1 /enable both use_direct_io_for_flush_and_compaction/ in use_direct_reads_writes.err
+Checking rocksdb_flush_log_at_trx_commit
+# restart
+FOUND 1 /rocksdb_flush_log_at_trx_commit needs to be/ in use_direct_reads_writes.err
+Validate flush_log settings when direct writes is enabled
+set global rocksdb_flush_log_at_trx_commit=0;
+set global rocksdb_flush_log_at_trx_commit=1;
+ERROR 42000: Variable 'rocksdb_flush_log_at_trx_commit' can't be set to the value of '1'
+set global rocksdb_flush_log_at_trx_commit=2;
+ERROR 42000: Variable 'rocksdb_flush_log_at_trx_commit' can't be set to the value of '2'
+# restart
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/validate_datadic.result b/storage/rocksdb/mysql-test/rocksdb/r/validate_datadic.result
new file mode 100644
index 00000000..5d9a6342
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/validate_datadic.result
@@ -0,0 +1,9 @@
+call mtr.add_suppression('RocksDB: Schema mismatch');
+CREATE TABLE t1 (pk int primary key) ENGINE=ROCKSDB;
+CREATE TABLE t2 (pk int primary key) ENGINE=ROCKSDB PARTITION BY KEY(pk) PARTITIONS 4;
+"Expect errors that we are missing two .frm files"
+FOUND 1 /RocksDB: Schema mismatch - Table test.t1 is registered in RocksDB but does not have a .frm file/ in validate_datadic.err
+FOUND 1 /RocksDB: Schema mismatch - Table test.t2 is registered in RocksDB but does not have a .frm file/ in validate_datadic.err
+"Expect an error that we have an extra .frm file"
+FOUND 1 /Schema mismatch - A .frm file exists for table test.t1_dummy, but that table is not registered in RocksDB/ in validate_datadic.err
+DROP TABLE t1, t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/varbinary_format.result b/storage/rocksdb/mysql-test/rocksdb/r/varbinary_format.result
new file mode 100644
index 00000000..8b4634bb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/varbinary_format.result
@@ -0,0 +1,260 @@
+CREATE TABLE t1(
+vb VARBINARY(64) primary key
+) ENGINE=rocksdb;
+INSERT INTO t1 values(0x00);
+INSERT INTO t1 values(0x0000);
+INSERT INTO t1 values(0x0000000000000000);
+INSERT INTO t1 values(0x000000);
+INSERT INTO t1 values(0x000000000000000000000000000000000000000000000000000000000000000000);
+INSERT INTO t1 values(0x00000000000000000000000000000000000000000000000000000000000000);
+INSERT INTO t1 values(0x0000000000000000000000000000000000000000000000000000000000000000);
+INSERT INTO t1 values(0x00000000);
+INSERT INTO t1 values(0x0000000000);
+INSERT INTO t1 values(0x00000000000000000000);
+INSERT INTO t1 values(0x000000000000);
+INSERT INTO t1 values(0x00000000000000);
+INSERT INTO t1 values(0x000000000000000000);
+SELECT hex(vb) FROM t1;
+hex(vb)
+00
+0000
+000000
+00000000
+0000000000
+000000000000
+00000000000000
+0000000000000000
+000000000000000000
+00000000000000000000
+00000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000000
+BEGIN;
+SELECT hex(vb) FROM t1 FOR UPDATE;
+hex(vb)
+00
+0000
+000000
+00000000
+0000000000
+000000000000
+00000000000000
+0000000000000000
+000000000000000000
+00000000000000000000
+00000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000000
+SELECT SUBSTRING(a.key,9) FROM information_schema.rocksdb_locks AS a ORDER BY a.key;
+SUBSTRING(a.key,9)
+000000000000000001
+000000000000000002
+000000000000000003
+000000000000000004
+000000000000000005
+000000000000000006
+000000000000000007
+000000000000000008
+000000000000000009000000000000000001
+000000000000000009000000000000000002
+000000000000000009000000000000000009000000000000000009000000000000000007
+000000000000000009000000000000000009000000000000000009000000000000000008
+000000000000000009000000000000000009000000000000000009000000000000000009000000000000000001
+ROLLBACK;
+DROP TABLE t1;
+set session debug_dbug= '+d,MYROCKS_LEGACY_VARBINARY_FORMAT';
+CREATE TABLE t1(
+vb VARBINARY(64) primary key
+) ENGINE=rocksdb;
+set session debug_dbug= '-d,MYROCKS_LEGACY_VARBINARY_FORMAT';
+INSERT INTO t1 values(0x00);
+INSERT INTO t1 values(0x0000);
+INSERT INTO t1 values(0x0000000000000000);
+INSERT INTO t1 values(0x000000);
+INSERT INTO t1 values(0x000000000000000000000000000000000000000000000000000000000000000000);
+INSERT INTO t1 values(0x00000000000000000000000000000000000000000000000000000000000000);
+INSERT INTO t1 values(0x0000000000000000000000000000000000000000000000000000000000000000);
+INSERT INTO t1 values(0x00000000);
+INSERT INTO t1 values(0x0000000000);
+INSERT INTO t1 values(0x00000000000000000000);
+INSERT INTO t1 values(0x000000000000);
+INSERT INTO t1 values(0x00000000000000);
+INSERT INTO t1 values(0x000000000000000000);
+SELECT hex(vb) FROM t1;
+hex(vb)
+00
+0000
+000000
+00000000
+0000000000
+000000000000
+00000000000000
+0000000000000000
+000000000000000000
+00000000000000000000
+00000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000000
+BEGIN;
+SELECT hex(vb) FROM t1 FOR UPDATE;
+hex(vb)
+00
+0000
+000000
+00000000
+0000000000
+000000000000
+00000000000000
+0000000000000000
+000000000000000000
+00000000000000000000
+00000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000000
+SELECT SUBSTRING(a.key,9) FROM information_schema.rocksdb_locks AS a ORDER BY a.key;
+SUBSTRING(a.key,9)
+0000000000000000f8
+0000000000000000f9
+0000000000000000fa
+0000000000000000fb
+0000000000000000fc
+0000000000000000fd
+0000000000000000fe
+0000000000000000ff0000000000000000f7
+0000000000000000ff0000000000000000f8
+0000000000000000ff0000000000000000f9
+0000000000000000ff0000000000000000ff0000000000000000ff0000000000000000fe
+0000000000000000ff0000000000000000ff0000000000000000ff0000000000000000ff0000000000000000f7
+0000000000000000ff0000000000000000ff0000000000000000ff0000000000000000ff0000000000000000f8
+ROLLBACK;
+DROP TABLE t1;
+CREATE TABLE t1(
+vc VARCHAR(64) collate 'binary' primary key
+) ENGINE=rocksdb;
+INSERT INTO t1 values('a');
+INSERT INTO t1 values('aa');
+INSERT INTO t1 values('aaaaaaaa');
+INSERT INTO t1 values('aaa');
+INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+INSERT INTO t1 values('aaaa');
+INSERT INTO t1 values('aaaaa');
+INSERT INTO t1 values('aaaaaaaaaa');
+INSERT INTO t1 values('aaaaaa');
+INSERT INTO t1 values('aaaaaaa');
+INSERT INTO t1 values('aaaaaaaaa');
+SELECT * FROM t1;
+vc
+a
+aa
+aaa
+aaaa
+aaaaa
+aaaaaa
+aaaaaaa
+aaaaaaaa
+aaaaaaaaa
+aaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+BEGIN;
+SELECT * FROM t1 FOR UPDATE;
+vc
+a
+aa
+aaa
+aaaa
+aaaaa
+aaaaaa
+aaaaaaa
+aaaaaaaa
+aaaaaaaaa
+aaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+SELECT SUBSTRING(a.key,9) FROM information_schema.rocksdb_locks AS a ORDER BY a.key;
+SUBSTRING(a.key,9)
+610000000000000001
+616100000000000002
+616161000000000003
+616161610000000004
+616161616100000005
+616161616161000006
+616161616161610007
+616161616161616108
+616161616161616109610000000000000001
+616161616161616109616100000000000002
+616161616161616109616161616161616109616161616161616109616161616161610007
+616161616161616109616161616161616109616161616161616109616161616161616108
+616161616161616109616161616161616109616161616161616109616161616161616109610000000000000001
+ROLLBACK;
+DROP TABLE t1;
+set session debug_dbug= '+d,MYROCKS_LEGACY_VARBINARY_FORMAT';
+CREATE TABLE t1(
+vc VARCHAR(64) collate 'binary' primary key
+) ENGINE=rocksdb;
+set session debug_dbug= '-d,MYROCKS_LEGACY_VARBINARY_FORMAT';
+INSERT INTO t1 values('a');
+INSERT INTO t1 values('aa');
+INSERT INTO t1 values('aaaaaaaa');
+INSERT INTO t1 values('aaa');
+INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+INSERT INTO t1 values('aaaa');
+INSERT INTO t1 values('aaaaa');
+INSERT INTO t1 values('aaaaaaaaaa');
+INSERT INTO t1 values('aaaaaa');
+INSERT INTO t1 values('aaaaaaa');
+INSERT INTO t1 values('aaaaaaaaa');
+SELECT * FROM t1;
+vc
+a
+aa
+aaa
+aaaa
+aaaaa
+aaaaaa
+aaaaaaa
+aaaaaaaa
+aaaaaaaaa
+aaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+BEGIN;
+SELECT * FROM t1 FOR UPDATE;
+vc
+a
+aa
+aaa
+aaaa
+aaaaa
+aaaaaa
+aaaaaaa
+aaaaaaaa
+aaaaaaaaa
+aaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+SELECT SUBSTRING(a.key,9) FROM information_schema.rocksdb_locks AS a ORDER BY a.key;
+SUBSTRING(a.key,9)
+6100000000000000f8
+6161000000000000f9
+6161610000000000fa
+6161616100000000fb
+6161616161000000fc
+6161616161610000fd
+6161616161616100fe
+6161616161616161ff0000000000000000f7
+6161616161616161ff6100000000000000f8
+6161616161616161ff6161000000000000f9
+6161616161616161ff6161616161616161ff6161616161616161ff6161616161616100fe
+6161616161616161ff6161616161616161ff6161616161616161ff6161616161616161ff0000000000000000f7
+6161616161616161ff6161616161616161ff6161616161616161ff6161616161616161ff6100000000000000f8
+ROLLBACK;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/write_sync.result b/storage/rocksdb/mysql-test/rocksdb/r/write_sync.result
new file mode 100644
index 00000000..d0a9b034
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/write_sync.result
@@ -0,0 +1,30 @@
+SET GLOBAL rocksdb_write_disable_wal=false;
+SET GLOBAL rocksdb_write_ignore_missing_column_families=true;
+create table aaa (id int primary key, i int) engine rocksdb;
+set @save_rocksdb_flush_log_at_trx_commit=@@global.rocksdb_flush_log_at_trx_commit;
+SET GLOBAL rocksdb_flush_log_at_trx_commit=1;
+insert aaa(id, i) values(0,1);
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_wal_synced';
+insert aaa(id, i) values(1,1);
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
+variable_value-@a
+1
+insert aaa(id, i) values(2,1);
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
+variable_value-@a
+2
+insert aaa(id, i) values(3,1);
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
+variable_value-@a
+3
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_wal_synced';
+SET GLOBAL rocksdb_flush_log_at_trx_commit=0;
+insert aaa(id, i) values(4,1);
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_wal_synced';
+SET GLOBAL rocksdb_flush_log_at_trx_commit=2;
+insert aaa(id, i) values(5,1);
+truncate table aaa;
+drop table aaa;
+set @@global.rocksdb_flush_log_at_trx_commit=@save_rocksdb_flush_log_at_trx_commit;
+SET GLOBAL rocksdb_write_disable_wal=false;
+SET GLOBAL rocksdb_write_ignore_missing_column_families=false;
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/xa.result b/storage/rocksdb/mysql-test/rocksdb/r/xa.result
new file mode 100644
index 00000000..8cb6f39b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/r/xa.result
@@ -0,0 +1,70 @@
+#
+# MDEV-742 fixes
+# MDEV-13155: XA recovery not supported for RocksDB
+# as well.
+call mtr.add_suppression("Found .* prepared XA transactions");
+connect con1,localhost,root,,test;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT) ENGINE=RocksDB;
+XA START 'xa1';
+INSERT INTO t1 (a) VALUES (1),(2);
+XA END 'xa1';
+XA PREPARE 'xa1';
+connect con2,localhost,root,,test;
+XA START 'xa2';
+INSERT INTO t1 (a) VALUES (3);
+INSERT INTO t1 (a) VALUES (4);
+XA END 'xa2';
+XA PREPARE 'xa2';
+connect con3,localhost,root,,test;
+XA START 'xa3';
+INSERT INTO t1 (a) VALUES (5);
+INSERT INTO t1 (a) VALUES (6);
+XA END 'xa3';
+XA PREPARE 'xa3';
+disconnect con3;
+connection default;
+SELECT * FROM t1;
+a
+Must be all three XA:s in
+XA RECOVER;
+formatID gtrid_length bqual_length data
+1 3 0 xa3
+1 3 0 xa1
+1 3 0 xa2
+# restart
+connect con3,localhost,root,,test;
+XA RECOVER;
+formatID gtrid_length bqual_length data
+1 3 0 xa3
+1 3 0 xa1
+1 3 0 xa2
+XA ROLLBACK 'xa1';
+XA COMMIT 'xa2';
+XA ROLLBACK 'xa3';
+SELECT a FROM t1;
+a
+3
+4
+connect con4,localhost,root,,test;
+XA START 'xa4';
+INSERT INTO t1 (a) VALUES (7);
+INSERT INTO t1 (a) VALUES (8);
+XA END 'xa4';
+XA PREPARE 'xa4';
+connection default;
+# Now restart through graceful shutdown
+# restart
+connect con5,localhost,root,,test;
+Must have 'xa4'
+XA RECOVER;
+formatID gtrid_length bqual_length data
+1 3 0 xa4
+XA COMMIT 'xa4';
+SELECT a FROM t1;
+a
+3
+4
+7
+8
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/slow_query_log.awk b/storage/rocksdb/mysql-test/rocksdb/slow_query_log.awk
new file mode 100644
index 00000000..a921f472
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/slow_query_log.awk
@@ -0,0 +1,25 @@
+/Query_time:/ {
+ results["Rows_examined:"] = "uninit";
+ results["RocksDB_key_skipped:"] = "uninit";
+ results["RocksDB_del_skipped:"] = "uninit";
+
+ for (i = 2; i <= NF; i = i+2) {
+ results[$i] = $(i+1);
+ }
+
+ # If the output format has changed and we don't find these keys,
+ # error out.
+ if (results["Rows_examined:"] == "uninit" ||
+ results["RocksDB_key_skipped:"] == "uninit" ||
+ results["RocksDB_del_skipped:"] == "uninit") {
+ exit(-2);
+ }
+
+ if (results["Rows_examined:"] == 0) {
+ next
+ }
+ if (results["RocksDB_key_skipped:"] == 0 ||
+ results["RocksDB_del_skipped:"] == 0) {
+ exit(-1);
+ }
+}
diff --git a/storage/rocksdb/mysql-test/rocksdb/suite.opt b/storage/rocksdb/mysql-test/rocksdb/suite.opt
new file mode 100644
index 00000000..8ca2405f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/suite.opt
@@ -0,0 +1 @@
+--plugin-load=$HA_ROCKSDB_SO --default-storage-engine=rocksdb
diff --git a/storage/rocksdb/mysql-test/rocksdb/suite.pm b/storage/rocksdb/mysql-test/rocksdb/suite.pm
new file mode 100644
index 00000000..633e883f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/suite.pm
@@ -0,0 +1,28 @@
+package My::Suite::Rocksdb;
+
+use My::SysInfo;
+
+#
+# Note: ../rocksdb_sys_vars/suite.pm file has a similar
+# function. If you modify this file, consider modifying that one, too.
+#
+@ISA = qw(My::Suite);
+use My::Find;
+use File::Basename;
+use strict;
+
+#sub is_default { not $::opt_embedded_server }
+
+my $sst_dump=
+::mtr_exe_maybe_exists(
+ "$::bindir/storage/rocksdb$::opt_vs_config/sst_dump",
+ "$::path_client_bindir/sst_dump");
+return "RocksDB is not compiled, no sst_dump" unless $sst_dump;
+$ENV{MARIAROCKS_SST_DUMP}="$sst_dump";
+
+## Temporarily disable testing under valgrind, due to MDEV-12439
+#return "RocksDB tests disabled under valgrind" if ($::opt_valgrind);
+
+
+bless { };
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/1st.test b/storage/rocksdb/mysql-test/rocksdb/t/1st.test
new file mode 100644
index 00000000..cecef8b7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/1st.test
@@ -0,0 +1,36 @@
+--source include/have_rocksdb.inc
+
+#
+# This test checks some very basic capabilities
+# which will be used in almost every other test,
+# and will not be checked through support* variables.
+# If this test does not pass, there is no point
+# at executing other ones.
+#
+# Minimal requirements:
+# - supported column types: INT, CHAR (default CHAR(8), INT(11));
+# - column attributes as declared in define_engine.inc ($default_col_opts)
+# (by default empty, which means no additional attributes apart from the type);
+# - table attributes as declared in define_engine.inc ($default_tbl_opts)
+# (by default empty, which means no additional attributes apart from ENGINE);
+# - CREATE TABLE .. (column1 <column options>, column2 <column options>) ENGINE=<storage_engine>;
+# - INSERT INTO TABLE .. VALUES (val1,val2);
+# - DROP TABLE ..
+# - SELECT a,b FROM ..
+# - SHOW CREATE TABLE ..
+# - SHOW COLUMNS IN ...
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (pk INT PRIMARY KEY DEFAULT '0', a INT(11), b CHAR(8)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+SHOW COLUMNS IN t1;
+INSERT INTO t1 VALUES (1, 1,'a');
+INSERT INTO t1 (a,b) VALUES (2,'b');
+--sorted_result
+SELECT a,b FROM t1;
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/2pc_group_commit-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/2pc_group_commit-master.opt
new file mode 100644
index 00000000..83ed8522
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/2pc_group_commit-master.opt
@@ -0,0 +1 @@
+--binlog-format=row
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/2pc_group_commit.test b/storage/rocksdb/mysql-test/rocksdb/t/2pc_group_commit.test
new file mode 100644
index 00000000..aeadf538
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/2pc_group_commit.test
@@ -0,0 +1,168 @@
+--source include/have_rocksdb.inc
+--source include/have_log_bin.inc
+--source include/not_windows.inc
+--echo # Disable for valgrind because this takes too long
+--source include/not_valgrind.inc
+
+# MariaDB: tooling to slowdown commits (also when running on ramdisk, we need
+# write_prepared for some reason, this is set in the .opt file)
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+--source include/have_write_prepared.inc
+
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqlslap;
+--enable_warnings
+
+CREATE DATABASE mysqlslap;
+USE mysqlslap;
+CREATE TABLE t1(id BIGINT AUTO_INCREMENT, value BIGINT, PRIMARY KEY(id)) ENGINE=rocksdb;
+
+SET @save_rocksdb_enable_2pc= @@rocksdb_enable_2pc;
+SET @save_rocksdb_flush_log_at_trx_commit= @@rocksdb_flush_log_at_trx_commit;
+
+
+#
+# In MariaDB, regular group commit operation does not cause increment of
+# rocksdb_wal_group_syncs.
+#
+
+--echo # 2PC enabled, MyRocks durability enabled
+SET GLOBAL rocksdb_enable_2pc=1;
+SET GLOBAL rocksdb_flush_log_at_trx_commit=1;
+
+--echo ##
+--echo ## 2PC + durability + single thread
+--echo ##
+select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
+select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
+select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+--exec $MYSQL_SLAP --silent --concurrency=1 --number-of-queries=1000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)"
+select IF(variable_value - @b1 = 1000, 'OK', variable_value - @b1) as Binlog_commits
+from information_schema.global_status where variable_name='Binlog_commits';
+select IF(variable_value - @b2 = 1000, 'OK', variable_value - @b2) as Binlog_group_commits
+from information_schema.global_status where variable_name='Binlog_group_commits';
+--echo # Prepare operations sync, commits don't. We expect slightly more than 1K syncs:
+select IF(variable_value - @b3 between 1000 and 1500, 'OK', variable_value - @b3) as Rocksdb_wal_synced
+from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+
+# SQL layer solution is sufficient for Binlog counts but not RocksDB.
+#set @tmp_bcwc= @@binlog_commit_wait_count;
+#set @tmp_bcwu= @@binlog_commit_wait_usec;
+#set global binlog_commit_wait_count=30;
+#set global binlog_commit_wait_usec=500*1000;
+
+# RocksDB-side solution:
+
+set debug_dbug='+d,rocksdb_enable_delay_commits';
+create table dummy10(a int) engine=rocksdb;
+drop table dummy10;
+set debug_dbug='-d,rocksdb_enable_delay_commits';
+
+--echo ##
+--echo ## 2PC + durability + group commit
+--echo ##
+select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
+select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
+select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+
+--exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=10000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)"
+
+select IF(variable_value - @b1 = 10000, 'OK', variable_value - @b1) as Binlog_commits
+from information_schema.global_status where variable_name='Binlog_commits';
+select IF(variable_value - @b2 between 100 and 5000, 'OK', variable_value - @b2) as Binlog_group_commits
+from information_schema.global_status where variable_name='Binlog_group_commits';
+select IF(variable_value - @b3 between 1 and 9000, 'OK', variable_value - @b3)
+from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+
+#set global binlog_commit_wait_count= @tmp_bcwc;
+#set global binlog_commit_wait_usec= @tmp_bcwu;
+
+set debug_dbug='+d,rocksdb_disable_delay_commits';
+create table dummy10(a int) engine=rocksdb;
+drop table dummy10;
+set debug_dbug='-d,rocksdb_disable_delay_commits';
+
+--echo ##
+--echo # 2PC enabled, MyRocks durability disabled, single thread
+--echo ##
+SET GLOBAL rocksdb_enable_2pc=1;
+SET GLOBAL rocksdb_flush_log_at_trx_commit=0;
+
+select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
+select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
+select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+--exec $MYSQL_SLAP --silent --concurrency=1 --number-of-queries=1000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)"
+
+select IF(variable_value - @b1 = 1000, 'OK', variable_value - @b1) as Binlog_commits
+from information_schema.global_status where variable_name='Binlog_commits';
+select IF(variable_value - @b2 = 1000, 'OK', variable_value - @b2) as Binlog_group_commits
+from information_schema.global_status where variable_name='Binlog_group_commits';
+select IF(variable_value - @b3 < 10, 'OK', variable_value - @b3)
+from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+
+--echo ##
+--echo # 2PC enabled, MyRocks durability disabled, concurrent workload
+--echo ##
+
+select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
+select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
+select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+
+--exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=10000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)"
+
+select IF(variable_value - @b1 = 10000, 'OK', variable_value - @b1) as Binlog_commits
+from information_schema.global_status where variable_name='Binlog_commits';
+select IF(variable_value - @b2 < 8000, 'OK', variable_value - @b2) as Binlog_group_commits
+from information_schema.global_status where variable_name='Binlog_group_commits';
+select IF(variable_value - @b3 < 10, 'OK', variable_value - @b3)
+from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+
+##
+## The next two are disabled because they don't add any test coverage in
+## MariaDB. @@rocksdb_enable_2pc=0 is a MyRocks-internal setting, binlog
+## [group] commit still happens, and syncing RocksDB WAL too.
+##
+
+--disable_parsing
+--echo ##
+--echo # 2PC disabled, MyRocks durability enabled, one thread
+--echo ##
+SET GLOBAL rocksdb_enable_2pc=0;
+SET GLOBAL rocksdb_flush_log_at_trx_commit=1;
+
+select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
+select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
+select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+
+--exec $MYSQL_SLAP --silent --concurrency=1 --number-of-queries=1000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)"
+
+select variable_value - @b1 as Binlog_commits
+from information_schema.global_status where variable_name='Binlog_commits';
+select variable_value - @b2 as Binlog_group_commits
+from information_schema.global_status where variable_name='Binlog_group_commits';
+select variable_value - @b3 as Rocksdb_wal_synced
+from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+
+--echo ##
+--echo # 2PC disabled, MyRocks durability enabled, concurrent workload
+--echo ##
+select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
+select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
+select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+--exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=10000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)"
+
+select variable_value - @b1 as Binlog_commits
+from information_schema.global_status where variable_name='Binlog_commits';
+select variable_value - @b2 as Binlog_group_commits
+from information_schema.global_status where variable_name='Binlog_group_commits';
+select variable_value - @b3 as Rocksdb_wal_synced
+from information_schema.global_status where variable_name='Rocksdb_wal_synced';
+--enable_parsing
+
+SET GLOBAL rocksdb_enable_2pc= @save_rocksdb_enable_2pc;
+SET GLOBAL rocksdb_flush_log_at_trx_commit= @save_rocksdb_flush_log_at_trx_commit;
+
+DROP TABLE t1;
+DROP DATABASE mysqlslap;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace.test b/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace.test
new file mode 100644
index 00000000..df7790ee
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace.test
@@ -0,0 +1,417 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+##
+## test adding index inplace
+##
+
+# test basic add
+CREATE TABLE t1 (a INT, b INT, KEY ka(a), KEY kab(a,b)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+CHECK TABLE t1;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(kb) WHERE b > 5;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(kab) WHERE a > 2;
+DROP TABLE t1;
+
+# test add + drop (simultaneous)
+CREATE TABLE t1 (a INT, b INT, KEY ka(a), KEY kab(a,b)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+ALTER TABLE t1 ADD INDEX kb(b), DROP INDEX ka, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+CHECK TABLE t1;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(kb) WHERE b > 5;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(kab) WHERE a > 2;
+DROP TABLE t1;
+
+## test multi-drop + multi-add
+CREATE TABLE t1 (a INT, b INT, KEY ka(a), KEY kab(a,b)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+ALTER TABLE t1 DROP INDEX ka, DROP INDEX kab, ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD INDEX kb(b), ADD INDEX kab(a,b), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+CHECK TABLE t1;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(kb) WHERE b > 5;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(kab) WHERE a > 2;
+DROP TABLE t1;
+
+# test multi add + drop (simultaneous)
+CREATE TABLE t1 (a INT, b INT, KEY ka(a), KEY kab(a,b)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+ALTER TABLE t1 ADD INDEX kb(b), DROP INDEX ka, ADD INDEX kba(b,a), DROP INDEX kab, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+CHECK TABLE t1;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(kb) WHERE b > 5;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(kba) WHERE a > 2;
+DROP TABLE t1;
+
+# test dropping and adding a key simultaneously w/ same name but different col
+CREATE TABLE t1 (a INT, b INT, KEY ka(a), KEY kab(a,b)) ENGINE=RocksDB;
+ALTER TABLE t1 DROP INDEX ka, ADD INDEX ka(b), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+CHECK TABLE t1;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(ka) WHERE b > 5;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(kab) WHERE a > 2;
+DROP TABLE t1;
+
+##
+## test adding index inplace w/ various column types
+##
+
+# test basic add
+CREATE TABLE t1 (pk CHAR(8) PRIMARY KEY, a VARCHAR(11), b INT UNSIGNED) ENGINE=rocksdb charset utf8 collate utf8_bin;
+SHOW CREATE TABLE t1;
+SHOW COLUMNS IN t1;
+INSERT INTO t1 VALUES ('aaa', '1111', 1);
+INSERT INTO t1 VALUES ('bbb', '2222', 2);
+INSERT INTO t1 VALUES ('ccc', '3333', 3);
+ALTER TABLE t1 ADD INDEX kab(a,b), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+CHECK TABLE t1;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(kab) WHERE a > '2' AND b < 3;
+DROP TABLE t1;
+
+## test add + drop (simultaneous)
+CREATE TABLE t1 (pk CHAR(8) PRIMARY KEY, a VARCHAR(11), b INT UNSIGNED) ENGINE=rocksdb charset utf8 collate utf8_bin;
+SHOW CREATE TABLE t1;
+SHOW COLUMNS IN t1;
+INSERT INTO t1 VALUES ('aaa', '1111', 1);
+INSERT INTO t1 VALUES ('bbb', '2222', 2);
+INSERT INTO t1 VALUES ('ccc', '3333', 3);
+ALTER TABLE t1 ADD INDEX kab(a,b), ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD INDEX ka(a), DROP INDEX kab, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+CHECK TABLE t1;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(ka) WHERE a > '2' AND b < 3;
+DROP TABLE t1;
+
+### test multi-drop + multi-add
+CREATE TABLE t1 (pk CHAR(8) PRIMARY KEY, a VARCHAR(11), b INT UNSIGNED) ENGINE=rocksdb charset utf8 collate utf8_bin;
+SHOW CREATE TABLE t1;
+SHOW COLUMNS IN t1;
+INSERT INTO t1 VALUES ('aaa', '1111', 1);
+INSERT INTO t1 VALUES ('bbb', '2222', 2);
+INSERT INTO t1 VALUES ('ccc', '3333', 3);
+ALTER TABLE t1 ADD INDEX kab(a,b), ADD INDEX ka(a), ADD INDEX kb(b), ALGORITHM=INPLACE;
+ALTER TABLE t1 DROP INDEX ka, DROP INDEX kb, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+CHECK TABLE t1;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(kab) WHERE a > '2' AND b < 3;
+DROP TABLE t1;
+
+##
+## test adding via CREATE/DROP index syntax
+##
+CREATE TABLE t1 (a INT, b INT, KEY ka(a), KEY kab(a,b)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+CREATE INDEX kb on t1 (b);
+CREATE INDEX kba on t1 (b,a);
+DROP INDEX ka on t1;
+DROP INDEX kab on t1;
+SHOW CREATE TABLE t1;
+CHECK TABLE t1;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(kb) WHERE b > 5;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(kba) WHERE a > 2;
+DROP TABLE t1;
+
+#
+# Create tables with partitions and try to update/select from them.
+#
+CREATE TABLE t1 (i INT, j INT, k INT, PRIMARY KEY (i), KEY(j)) ENGINE = ROCKSDB PARTITION BY KEY(i) PARTITIONS 4;
+
+--disable_query_log
+let $max = 100;
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO t1 VALUES ($i, $i, $i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
+DROP INDEX kij ON t1;
+SHOW CREATE TABLE t1;
+
+SELECT * FROM t1 ORDER BY i LIMIT 10;
+SELECT COUNT(*) FROM t1;
+
+DROP TABLE t1;
+
+# test failure in prepare phase (due to collation)
+set @tmp_rocksdb_strict_collation_check= @@rocksdb_strict_collation_check;
+set global rocksdb_strict_collation_check=1;
+CREATE TABLE t1 (a INT, b TEXT);
+
+--echo # MariaDB no longer gives ER_UNSUPPORTED_COLLATION
+ALTER TABLE t1 ADD KEY kb(b(10));
+ALTER TABLE t1 ADD PRIMARY KEY(a);
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT, b TEXT collate utf8_general_ci);
+--echo # MariaDB no longer gives ER_UNSUPPORTED_COLLATION
+ALTER TABLE t1 ADD KEY kb(b(10));
+ALTER TABLE t1 ADD PRIMARY KEY(a);
+DROP TABLE t1;
+
+set global rocksdb_strict_collation_check= @tmp_rocksdb_strict_collation_check;
+
+# make sure race condition between connection close and alter on another
+# connection is handled
+
+set global rocksdb_bulk_load=1;
+
+--echo # Establish connection con1 (user=root)
+connect (con1,localhost,root,,);
+
+--echo # Switch to connection con1
+connection con1;
+
+show global variables like 'rocksdb_bulk_load%';
+show session variables like 'rocksdb_bulk_load%';
+
+CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i)) ENGINE = ROCKSDB;
+
+INSERT INTO t1 VALUES (1,1);
+
+# Disconnect connection 1, this starts the code path that will call
+# rocksdb_close_connection, ending the bulk load.
+--echo # Disconnecting on con1
+disconnect con1;
+
+--echo # Establish connection con2 (user=root)
+connect (con2,localhost,root,,);
+--echo # Switch to connection con2
+connection con2;
+
+# when alter table happens, it tries to close all other TABLE instances
+# when acquiring the exclusive lock for alter table (this happens in SQL layer)
+# make sure bulk_load now handles this possible race condition properly
+ALTER TABLE t1 ADD INDEX kj(j), ALGORITHM=INPLACE;
+
+SELECT COUNT(*) FROM t1 FORCE INDEX(PRIMARY);
+SELECT COUNT(*) FROM t1 FORCE INDEX(kj);
+
+DROP TABLE t1;
+disconnect con2;
+
+# make sure implicilty closing the alter from another session works
+
+--echo # Establish connection con1 (user=root)
+connect (con1,localhost,root,,);
+--echo # Establish connection con2 (user=root)
+connect (con2,localhost,root,,);
+
+--echo # Switch to connection con1
+connection con1;
+
+CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i)) ENGINE = ROCKSDB;
+
+set rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES (1,1);
+
+--echo # Switch to connection con2
+connection con2;
+
+# here, the bulk load hasn't been completed yet, and we are in conn2
+# therefore select count returns 0
+SELECT COUNT(*) FROM t1 FORCE INDEX(PRIMARY);
+
+# implicilty close the table from connection 2
+ALTER TABLE t1 ADD INDEX kj(j), ALGORITHM=INPLACE;
+
+SELECT COUNT(*) FROM t1 FORCE INDEX(PRIMARY);
+SELECT COUNT(*) FROM t1 FORCE INDEX(kj);
+
+set global rocksdb_bulk_load=0;
+
+DROP TABLE t1;
+
+connection default;
+
+
+SET @prior_rocksdb_merge_combine_read_size= @@rocksdb_merge_combine_read_size;
+SET @prior_rocksdb_strict_collation_check= @@rocksdb_strict_collation_check;
+SET @prior_rocksdb_merge_buf_size = @@rocksdb_merge_buf_size;
+
+SET global rocksdb_strict_collation_check = off;
+SET session rocksdb_merge_combine_read_size = 566;
+SET session rocksdb_merge_buf_size = 340;
+
+show variables like 'rocksdb_bulk_load%';
+CREATE TABLE t1 (a VARCHAR(80)) ENGINE=RocksDB;
+INSERT INTO t1 (a) VALUES (REPEAT("a", 80));
+INSERT INTO t1 (a) VALUES (REPEAT("a", 80));
+INSERT INTO t1 (a) VALUES (REPEAT("a", 80));
+INSERT INTO t1 (a) VALUES (REPEAT("a", 80));
+ALTER TABLE t1 ADD INDEX ka(a), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+CHECK TABLE t1;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(ka) WHERE a > "";
+DROP TABLE t1;
+
+SET session rocksdb_merge_buf_size = @prior_rocksdb_merge_buf_size;
+SET session rocksdb_merge_combine_read_size = @prior_rocksdb_merge_combine_read_size;
+SET global rocksdb_strict_collation_check = @prior_rocksdb_strict_collation_check;
+
+# Test to make sure index statistics are updating properly
+CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i)) ENGINE = ROCKSDB;
+
+--disable_query_log
+let $max = 100;
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO t1 VALUES ($i, $i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+set global rocksdb_force_flush_memtable_now=1;
+
+--let $data_length_old = query_get_value("select INDEX_LENGTH from information_schema.tables where table_schema=database() and table_name='t1'", INDEX_LENGTH, 1)
+
+## uncomment to see the actual values
+#--replace_column 8 #
+#SHOW TABLE STATUS WHERE name LIKE 't1';
+
+# Now do an alter and see what happens
+ALTER TABLE t1 ADD INDEX kj(j), ALGORITHM=INPLACE;
+
+--let $data_length_new = query_get_value("select INDEX_LENGTH from information_schema.tables where table_schema=database() and table_name='t1'", INDEX_LENGTH, 1)
+--disable_query_log
+--eval select $data_length_old < $data_length_new as "larger"
+
+--source include/restart_mysqld.inc
+--source include/wait_until_connected_again.inc
+--let $data_length_new = query_get_value("select INDEX_LENGTH from information_schema.tables where table_schema=database() and table_name='t1'", INDEX_LENGTH, 1)
+--disable_query_log
+--eval select $data_length_old < $data_length_new as "larger"
+
+analyze table t1;
+--let $data_length_new = query_get_value("select INDEX_LENGTH from information_schema.tables where table_schema=database() and table_name='t1'", INDEX_LENGTH, 1)
+--disable_query_log
+--eval select $data_length_old < $data_length_new as "larger"
+
+--source include/restart_mysqld.inc
+--source include/wait_until_connected_again.inc
+--let $data_length_new = query_get_value("select INDEX_LENGTH from information_schema.tables where table_schema=database() and table_name='t1'", INDEX_LENGTH, 1)
+--disable_query_log
+--eval select $data_length_old < $data_length_new as "larger"
+
+# verifying multiple analyze table won't change stats
+--disable_query_log
+let $max = 10;
+let $i = 1;
+while ($i <= $max) {
+ let $analyze = ANALYZE TABLE t1;
+ inc $i;
+ eval $analyze;
+}
+--enable_query_log
+
+--let $data_length_new2 = query_get_value("select INDEX_LENGTH from information_schema.tables where table_schema=database() and table_name='t1'", INDEX_LENGTH, 1)
+--eval select $data_length_new2 < $data_length_new * 1.5 as "same"
+
+
+--enable_query_log
+
+## uncomment to see the actual values
+#--replace_column 8 #
+#SHOW TABLE STATUS WHERE name LIKE 't1';
+
+DROP TABLE t1;
+
+# https://github.com/facebook/mysql-5.6/issues/602
+# Add then drop same index should be optimized out.
+CREATE TABLE t1 (
+a INT PRIMARY KEY,
+b INT,
+c INT,
+KEY kbc(b,c)) ENGINE = ROCKSDB;
+INSERT INTO t1 (a,b,c) VALUES (1,1,1);
+INSERT INTO t1 (a,b,c) VALUES (2,2,2);
+INSERT INTO t1 (a,b,c) VALUES (3,3,3);
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 DROP INDEX kbc, ADD INDEX kbc(b,c), ALGORITHM=INPLACE;
+ALTER TABLE t1 DROP INDEX kbc;
+DROP TABLE t1;
+
+# Make sure changing key part prefix length causes index rebuild as well.
+CREATE TABLE t1 (
+a INT PRIMARY KEY,
+b varchar(10),
+index kb(b(5))
+) ENGINE = ROCKSDB charset utf8 collate utf8_bin;
+
+INSERT INTO t1 (a,b) VALUES (1,'1111122222');
+INSERT INTO t1 (a,b) VALUES (2,'2222233333');
+INSERT INTO t1 (a,b) VALUES (3,'3333344444');
+
+--let $start_max_index_id = query_get_value(SELECT * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where type = 'MAX_INDEX_ID', VALUE, 1)
+
+ALTER TABLE t1 DROP INDEX kb, ADD INDEX kb(b(8)), ALGORITHM=INPLACE;
+SELECT * FROM t1 FORCE INDEX(kb);
+
+--let $end_max_index_id = query_get_value(SELECT * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where type = 'MAX_INDEX_ID', VALUE, 1)
+
+if ($end_max_index_id <= $start_max_index_id) {
+ echo Max index ID did not increase;
+}
+
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+# Cardinality checks for indexes statistics
+SET @prior_rocksdb_table_stats_sampling_pct = @@rocksdb_table_stats_sampling_pct;
+set global rocksdb_table_stats_sampling_pct = 100;
+
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
+
+INSERT INTO t1 (a, b) VALUES (1, 10);
+INSERT INTO t1 (a, b) VALUES (2, 10);
+INSERT INTO t1 (a, b) VALUES (3, 20);
+INSERT INTO t1 (a, b) VALUES (4, 20);
+
+set global rocksdb_force_flush_memtable_now=1;
+analyze table t1;
+
+SHOW INDEX in t1;
+
+ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE;
+SHOW INDEX in t1;
+
+DROP TABLE t1;
+SET global rocksdb_table_stats_sampling_pct = @prior_rocksdb_table_stats_sampling_pct;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_cardinality-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_cardinality-master.opt
new file mode 100644
index 00000000..436edf2b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_cardinality-master.opt
@@ -0,0 +1 @@
+--rocksdb_table_stats_sampling_pct=100
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_cardinality.test b/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_cardinality.test
new file mode 100644
index 00000000..148edf7a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_cardinality.test
@@ -0,0 +1,44 @@
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Test that fast secondary index creation updates cardinality properly
+CREATE TABLE t1 (i INT PRIMARY KEY, j INT) ENGINE = ROCKSDB;
+INSERT INTO t1 VALUES (1,2), (2,4), (3,6), (4,8), (5,10);
+
+SET debug_sync= 'rocksdb.commit_in_place_alter_table WAIT_FOR flushed';
+send ALTER TABLE t1 ADD INDEX kj(j), ALGORITHM=INPLACE;
+
+connect (con1,localhost,root,,);
+
+# Flush memtable out to SST
+SET GLOBAL rocksdb_force_flush_memtable_now = 1;
+SET debug_sync= 'now SIGNAL flushed';
+
+connection default;
+reap;
+
+# Return the data for the primary key of t1
+--replace_column 1 # 2 # 3 SSTNAME 5 # 6 # 7 # 8 # 9 #
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP
+WHERE INDEX_NUMBER =
+ (SELECT INDEX_NUMBER FROM INFORMATION_SCHEMA.ROCKSDB_DDL
+ WHERE TABLE_NAME = 't1' AND INDEX_NAME = "PRIMARY");
+
+# Return the data for the secondary index of t1
+--replace_column 1 # 2 # 3 SSTNAME 5 # 6 # 7 # 8 # 9 #
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP
+WHERE INDEX_NUMBER =
+ (SELECT INDEX_NUMBER FROM INFORMATION_SCHEMA.ROCKSDB_DDL
+ WHERE TABLE_NAME = 't1' AND INDEX_NAME = "kj");
+
+disconnect con1;
+SET debug_sync='RESET';
+
+# cleanup
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_crash.test b/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_crash.test
new file mode 100644
index 00000000..4f34cbe8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_crash.test
@@ -0,0 +1,118 @@
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+--source include/have_partition.inc
+--source include/not_valgrind.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# test crash recovery
+#
+
+CREATE TABLE t1 (a INT, b INT, KEY ka(a), KEY kab(a,b)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+
+--echo # crash_during_online_index_creation
+flush logs;
+
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug_dbug="+d,crash_during_online_index_creation";
+--error 2013
+ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE;
+
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+SET SESSION debug_dbug="-d,crash_during_online_index_creation";
+
+SHOW CREATE TABLE t1;
+CHECK TABLE t1;
+
+DROP TABLE t1;
+
+#
+# Test crash recovery with partitioned tables
+#
+CREATE TABLE t1 (i INT, j INT, k INT, PRIMARY KEY (i), KEY(j)) ENGINE = ROCKSDB PARTITION BY KEY(i) PARTITIONS 4;
+
+--disable_query_log
+let $max = 100;
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO t1 VALUES ($i, $i, $i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+--echo # crash_during_index_creation_partition
+flush logs;
+
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug_dbug="+d,crash_during_index_creation_partition";
+--error 2013
+ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
+
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+SET SESSION debug_dbug="-d,crash_during_index_creation_partition";
+
+SHOW CREATE TABLE t1;
+
+# here, the index numbers should be higher because previously 4 index numbers
+# were allocated for the partitioned table
+ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
+
+SELECT * FROM t1 ORDER BY i LIMIT 10;
+SELECT COUNT(*) FROM t1;
+
+DROP TABLE t1;
+
+#
+# Test rollback on partitioned tables for inplace alter
+#
+CREATE TABLE t1 (i INT, j INT, k INT, PRIMARY KEY (i), KEY(j)) ENGINE = ROCKSDB PARTITION BY KEY(i) PARTITIONS 4;
+
+--disable_query_log
+let $max = 100;
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO t1 VALUES ($i, $i, $i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+--echo # crash_during_index_creation_partition
+flush logs;
+
+SET SESSION debug_dbug="+d,myrocks_simulate_index_create_rollback";
+
+--error 1105
+ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
+SET SESSION debug_dbug="-d,myrocks_simulate_index_create_rollback";
+SHOW CREATE TABLE t1;
+
+# here, the index numbers should be higher because previously 4 index numbers
+# were allocated for the partitioned table
+ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
+
+SHOW CREATE TABLE t1;
+SELECT COUNT(*) FROM t1;
+
+DROP TABLE t1;
+
+# Cleanup temporary #sql files. In the future server will remove these
+# automatically but for now we need to do the delete explicit
+
+--disable_query_log
+--disable_result_log
+let $datadir=`select @@datadir`;
+--remove_files_wildcard $datadir/test #sql*
+--enable_result_log
+--enable_query_log
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_sstfilewriter.test b/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_sstfilewriter.test
new file mode 100644
index 00000000..61a10a60
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_sstfilewriter.test
@@ -0,0 +1,113 @@
+--source include/have_rocksdb.inc
+
+# This test requires ~1.3G of disk space
+--source include/big_test.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+# Create a table with a primary key and one secondary key as well as one
+# more column
+CREATE TABLE t1(pk CHAR(5) PRIMARY KEY, a char(30), b char(30)) COLLATE 'latin1_bin';
+
+--let $file = `SELECT CONCAT(@@datadir, "test_loadfile.txt")`
+
+# Create a text file with data to import into the table.
+# The primary key is in sorted order and the secondary keys are randomly generated
+--let ROCKSDB_INFILE = $file
+perl;
+my $fn = $ENV{'ROCKSDB_INFILE'};
+open(my $fh, '>>', $fn) || die "perl open($fn): $!";
+my $max = 300000;
+my @chars = ("A".."Z", "a".."z", "0".."9");
+my @lowerchars = ("a".."z");
+my @powers_of_26 = (26 * 26 * 26 * 26, 26 * 26 * 26, 26 * 26, 26, 1);
+for (my $ii = 0; $ii < $max; $ii++)
+{
+ my $pk;
+ my $tmp = $ii;
+ foreach (@powers_of_26)
+ {
+ $pk .= $lowerchars[$tmp / $_];
+ $tmp = $tmp % $_;
+ }
+
+ my $num = int(rand(25)) + 6;
+ my $a;
+ $a .= $chars[rand(@chars)] for 1..$num;
+
+ $num = int(rand(25)) + 6;
+ my $b;
+ $b .= $chars[rand(@chars)] for 1..$num;
+ print $fh "$pk\t$a\t$b\n";
+}
+close($fh);
+EOF
+
+--file_exists $file
+
+set rocksdb_bulk_load=1;
+set rocksdb_bulk_load_size=10000;
+--disable_query_log
+--echo LOAD DATA INFILE <input_file> INTO TABLE t1;
+eval LOAD DATA INFILE '$file' INTO TABLE t1;
+--enable_query_log
+set rocksdb_bulk_load=0;
+
+# Make sure all the data is there.
+select count(pk) from t1;
+select count(a) from t1;
+select count(b) from t1;
+
+# now do fast secondary index creation
+ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE;
+# disable duplicate index warning
+--disable_warnings
+# now do same index using copy algorithm
+# hitting max row locks (1M)
+set @tmp= @@rocksdb_max_row_locks;
+set session rocksdb_max_row_locks=1000;
+--error ER_GET_ERRMSG
+ALTER TABLE t1 ADD INDEX kb_copy(b), ALGORITHM=COPY;
+set session rocksdb_bulk_load=1;
+ALTER TABLE t1 ADD INDEX kb_copy(b), ALGORITHM=COPY;
+set session rocksdb_bulk_load=0;
+--enable_warnings
+set session rocksdb_max_row_locks=@tmp;
+
+# checksum testing
+SELECT COUNT(*) as c FROM
+(SELECT COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `b`, CONCAT(ISNULL(`b`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `t1` FORCE INDEX(`kb`)
+UNION DISTINCT
+SELECT COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#',
+`b`, CONCAT(ISNULL(`b`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `t1` FORCE
+INDEX(`kb_copy`)) as temp;
+
+select count(*) from t1 FORCE INDEX(kb);
+select count(*) from t1 FORCE INDEX(kb_copy);
+select count(*) from t1 FORCE INDEX(PRIMARY);
+
+# drop the index
+ALTER TABLE t1 DROP INDEX kb, ALGORITHM=INPLACE;
+ALTER TABLE t1 DROP INDEX kb_copy, ALGORITHM=INPLACE;
+
+# add two indexes simultaneously
+ALTER TABLE t1 ADD INDEX kb(b), ADD INDEX kab(a,b), ALGORITHM=INPLACE;
+SELECT COUNT(*) FROM t1 FORCE INDEX(kab);
+SELECT COUNT(*) FROM t1 FORCE INDEX(kb);
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+# Reverse CF testing, needs to be added to SSTFileWriter in reverse order
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT, KEY kab(a,b)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+ALTER TABLE t1 DROP INDEX kab, ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD INDEX kb(b) comment 'rev:cf1', ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+SELECT COUNT(*) FROM t1 FORCE INDEX(kb);
+DROP TABLE t1;
+--remove_file $file
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/add_unique_index_inplace.test b/storage/rocksdb/mysql-test/rocksdb/t/add_unique_index_inplace.test
new file mode 100644
index 00000000..cf0546d1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/add_unique_index_inplace.test
@@ -0,0 +1,101 @@
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+# test adding duplicate value before unique index
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+
+INSERT INTO t1 (a,b) VALUES (4,5);
+
+# should cause error here, duplicate value on b
+--error 1062
+ALTER TABLE t1 ADD UNIQUE INDEX kb(b), ALGORITHM=INPLACE;
+
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+# test dup value AFTER unique index
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+ALTER TABLE t1 ADD UNIQUE INDEX kb(b), ALGORITHM=INPLACE;
+
+# should error here, duplicate value on b
+--error 1062
+INSERT INTO t1 (a,b) VALUES (4,5);
+
+# should succeed
+INSERT INTO t1 (a,b) VALUES (5,8);
+
+SHOW CREATE TABLE t1;
+SELECT * FROM t1 FORCE INDEX(kb);
+DROP TABLE t1;
+
+# test what happens when duplicate nulls exist
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, NULL);
+INSERT INTO t1 (a, b) VALUES (3, NULL);
+
+# should pass, because in MySQL we allow multiple NULLS in unique key
+ALTER TABLE t1 ADD UNIQUE INDEX kb(b), ALGORITHM=INPLACE;
+INSERT INTO t1 (a, b) VALUES (4, NULL);
+
+SHOW CREATE TABLE t1;
+SELECT COUNT(*) FROM t1 FORCE INDEX(kb);
+DROP TABLE t1;
+
+## test case with multi-part key with nulls
+CREATE TABLE t1 (a INT, b INT, c INT, PRIMARY KEY ka(a)) ENGINE=RocksDB;
+INSERT INTO t1 (a,b,c) VALUES (1,1,NULL);
+INSERT INTO t1 (a,b,c) VALUES (2,1,NULL);
+INSERT INTO t1 (a,b,c) VALUES (3,1,NULL);
+INSERT INTO t1 (a,b,c) VALUES (4,1,5);
+
+# should pass
+ALTER TABLE t1 ADD UNIQUE INDEX kbc(b,c), ALGORITHM=INPLACE;
+
+SHOW CREATE TABLE t1;
+SELECT COUNT(*) FROM t1 FORCE INDEX(kbc);
+DROP TABLE t1;
+
+## test case with table w/ no primary key, and we try to add unique key
+CREATE TABLE t1 (a INT, b INT) ENGINE=RocksDB;
+INSERT INTO t1 (a, b) VALUES (1, 5);
+INSERT INTO t1 (a, b) VALUES (2, 6);
+INSERT INTO t1 (a, b) VALUES (3, 7);
+
+# should succeed, we can add unique index on table w/ no pk
+ALTER TABLE t1 ADD UNIQUE INDEX kb(b);
+INSERT INTO t1 (a, b) VALUES (4, 8);
+--error ER_DUP_ENTRY
+INSERT INTO t1 (a, b) VALUES (5, 5);
+
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+# Test changing key with same name and parts from not unique to unique, should
+# fail.
+CREATE TABLE t1 (
+a INT PRIMARY KEY,
+b INT,
+c INT,
+KEY kbc(b,c)) ENGINE = ROCKSDB;
+INSERT INTO t1 (a,b,c) VALUES (1,1,1);
+INSERT INTO t1 (a,b,c) VALUES (2,2,2);
+INSERT INTO t1 (a,b,c) VALUES (3,2,2);
+
+# should cause error here, duplicate value 2-2
+--error 1062
+ALTER TABLE t1 DROP INDEX kbc, ADD UNIQUE INDEX kbc(b,c), ALGORITHM=INPLACE;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/allow_no_pk_concurrent_insert.test b/storage/rocksdb/mysql-test/rocksdb/t/allow_no_pk_concurrent_insert.test
new file mode 100644
index 00000000..8dda4372
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/allow_no_pk_concurrent_insert.test
@@ -0,0 +1,22 @@
+
+#
+# Tests concurrent inserts for tables with no primary key.
+#
+
+--source include/have_rocksdb.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+--echo # Binary must be compiled with debug for this test
+--source include/have_debug.inc
+
+# create the actual table
+CREATE TABLE t1 (a INT) ENGINE=rocksdb;
+
+let $exec = python ../storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_insert.py root 127.0.0.1 $MASTER_MYPORT test t1 100 4;
+exec $exec;
+
+SELECT COUNT(*) from t1;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/allow_no_primary_key.test b/storage/rocksdb/mysql-test/rocksdb/t/allow_no_primary_key.test
new file mode 100644
index 00000000..5f2a37f2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/allow_no_primary_key.test
@@ -0,0 +1,126 @@
+--source include/have_rocksdb.inc
+
+#
+# This test checks some very basic capabilities
+# for tables without primary keys. A hidden pk will be generated under the hood
+# in myrocks. Everything should work here as normal.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# test CREATE
+CREATE TABLE t1 (a INT, b CHAR(8)) ENGINE=rocksdb;
+--source no_primary_key_basic_ops.inc
+DROP TABLE t1;
+
+## test ALTER
+CREATE TABLE t1 (a INT, c CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (1,'a'),(5,'z');
+ALTER TABLE t1 ADD COLUMN b INT;
+SHOW CREATE TABLE t1;
+
+--sorted_result
+SELECT * FROM t1;
+ALTER TABLE t1 DROP COLUMN b;
+SHOW CREATE TABLE t1;
+--sorted_result
+SELECT * FROM t1;
+DROP TABLE t1;
+
+## test creating a table with primary and then dropping that key
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+ALTER TABLE t1 DROP COLUMN pk;
+--source no_primary_key_basic_ops.inc
+DROP TABLE t1;
+
+# test CHECK TABLE
+# CHECK TABLE statements
+#
+# Note: the output is likely to be different for the engine under test,
+# in which case rdiff will be needed. Or, the output might say that
+# the storage engine does not support CHECK.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+
+CREATE TABLE t2 (a INT, b CHAR(8)) ENGINE=rocksdb;
+
+CHECK TABLE t1;
+INSERT INTO t1 (a,b) VALUES (3,'c');
+INSERT INTO t2 (a,b) VALUES (4,'d');
+CHECK TABLE t1, t2 FOR UPGRADE;
+INSERT INTO t2 (a,b) VALUES (5,'e');
+CHECK TABLE t2 QUICK;
+INSERT INTO t1 (a,b) VALUES (6,'f');
+CHECK TABLE t1 FAST;
+INSERT INTO t1 (a,b) VALUES (7,'g');
+INSERT INTO t2 (a,b) VALUES (8,'h');
+CHECK TABLE t2, t1 MEDIUM;
+INSERT INTO t1 (a,b) VALUES (9,'i');
+INSERT INTO t2 (a,b) VALUES (10,'j');
+CHECK TABLE t1, t2 EXTENDED;
+INSERT INTO t1 (a,b) VALUES (11,'k');
+CHECK TABLE t1 CHANGED;
+
+DROP TABLE t1, t2;
+
+# test unique keys with no primary key
+CREATE TABLE t1 (a INT, b CHAR(8), UNIQUE INDEX(a)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+--error ER_DUP_ENTRY
+INSERT INTO t1 (a,b) VALUES (1,'c');
+SELECT * FROM t1;
+SELECT * FROM t1 WHERE a = 2;
+EXPLAIN SELECT * FROM t1 WHERE a = 2;
+
+DROP TABLE t1;
+
+## test restarting a table that has no data
+CREATE TABLE t1 (a INT, b CHAR(8)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+SHOW COLUMNS IN t1;
+--source include/restart_mysqld.inc
+
+## single delete statement should remove MULTIPLE rows (aka duplicate rows)
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (36,'foo');
+DELETE FROM t1 WHERE a = 35 AND b = 'foo';
+--sorted_result
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # Issue #834/MDEV-15304 ALTER TABLE table_with_hidden_pk causes Can't
+--echo # write; duplicate key in table error and/or crash
+--echo #
+CREATE TABLE t1 (a INT, KEY(a)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1),(1+1);
+create table t2 (a int);
+insert into t2 values (10),(20),(30);
+
+BEGIN;
+select * from t2;
+
+connect (con1,localhost,root,,);
+connection con1;
+alter table t1 force;
+
+connection default;
+select * from t1;
+
+connection con1;
+insert into t1 values (100);
+select * from t1;
+
+disconnect con1;
+connection default;
+rollback;
+drop table t1,t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/allow_no_primary_key_with_sk.test b/storage/rocksdb/mysql-test/rocksdb/t/allow_no_primary_key_with_sk.test
new file mode 100644
index 00000000..18ccf2e3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/allow_no_primary_key_with_sk.test
@@ -0,0 +1,149 @@
+--source include/have_rocksdb.inc
+
+#
+# This test checks some very basic capabilities
+# for tables without primary keys. A hidden pk will be generated under the hood
+# in myrocks. Everything should work here as normal.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+## test CREATE with SK
+CREATE TABLE t1 (a INT, b CHAR(8), KEY(a)) ENGINE=rocksdb;
+--source no_primary_key_basic_ops.inc
+DROP TABLE t1;
+
+## test adding/dropping sk w/no pk
+CREATE TABLE t1 (a INT, b CHAR(8)) ENGINE=rocksdb;
+ALTER TABLE t1 ADD INDEX (b);
+--source no_primary_key_basic_ops.inc
+
+ALTER TABLE t1 DROP INDEX b;
+--source no_primary_key_basic_ops.inc
+DROP TABLE t1;
+
+# test dropping pk w/ sk
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+ALTER TABLE t1 DROP COLUMN pk;
+--source no_primary_key_basic_ops.inc
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-4313: RocksDB: Server crashes in Rdb_key_def::setup on dropping the primary key column
+--echo #
+CREATE TABLE t1 (pk INT PRIMARY KEY, i INT NOT NULL, KEY(i)) ENGINE=RocksDB;
+ALTER TABLE t1 DROP COLUMN `pk`;
+DROP TABLE t1;
+
+# create table with multiple sk, make sure it still works
+# test CREATE with SK
+CREATE TABLE t1 (a INT, b CHAR(8), KEY(a), KEY(b)) ENGINE=rocksdb;
+--source no_primary_key_basic_ops.inc
+DROP TABLE t1;
+
+# test CREATE table with multi-part sk
+CREATE TABLE t1 (a INT, b CHAR(8), KEY(a, b)) ENGINE=rocksdb;
+--source no_primary_key_basic_ops.inc
+DROP TABLE t1;
+
+# test CREATE table with more than one sk
+CREATE TABLE t1 (a INT, b CHAR(8), KEY(a), KEY(b)) ENGINE=rocksdb;
+--source no_primary_key_basic_ops.inc
+DROP TABLE t1;
+
+# test check table with sk
+CREATE TABLE t1 (a INT, b CHAR(8), KEY(a)) ENGINE=rocksdb;
+INSERT INTO t1 (a) VALUES (1),(2),(5);
+CHECK TABLE t1;
+INSERT INTO t1 (a) VALUES (6),(8),(12);
+CHECK TABLE t1 FOR UPGRADE;
+INSERT INTO t1 (a) VALUES (13),(15),(16);
+CHECK TABLE t1 QUICK;
+INSERT INTO t1 (a) VALUES (17),(120),(132);
+CHECK TABLE t1 FAST;
+INSERT INTO t1 (a) VALUES (801),(900),(7714);
+CHECK TABLE t1 MEDIUM;
+INSERT INTO t1 (a) VALUES (8760),(10023),(12000);
+CHECK TABLE t1 EXTENDED;
+INSERT INTO t1 (a) VALUES (13345),(24456),(78302),(143028);
+CHECK TABLE t1 CHANGED;
+DROP TABLE t1;
+
+## tables with multi-part secondary indexes + columns that dont belong to any
+## secondary indexes
+CREATE TABLE t1 (a INT, b INT, c INT, d INT, KEY kab(a, b), KEY kbc(b, c), KEY kabc(a,b,c)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+SHOW COLUMNS IN t1;
+
+INSERT INTO t1 (a,b,c,d) VALUES (1,2,3,4);
+INSERT INTO t1 (a,b,c,d) VALUES (5,6,7,8);
+INSERT INTO t1 (a,b,c,d) VALUES (10,11,12,13);
+INSERT INTO t1 (a,b,c,d) VALUES (14,15,16,17);
+
+--sorted_result
+SELECT * FROM t1;
+--sorted_result
+SELECT * FROM t1 WHERE a = 1 OR a = 10;
+--sorted_result
+SELECT * FROM t1 WHERE c = 3 OR d = 17;
+--sorted_result
+SELECT * FROM t1 WHERE a > 5 OR d > 5;
+
+# force some of these selects to use different indexes and/or have the columns
+# being selected also not contain column d
+--sorted_result
+SELECT a, b, c FROM t1 FORCE INDEX (kabc) WHERE a=1 OR b=11;
+--sorted_result
+SELECT d FROM t1 FORCE INDEX (kbc) WHERE b > 6 AND c > 12;
+
+UPDATE t1 SET a=a+100;
+UPDATE t1 SET a=a-100, b=99 WHERE a>100;
+--sorted_result
+SELECT * FROM t1;
+
+DELETE FROM t1 WHERE a>5;
+DELETE FROM t1 WHERE b=99 AND d>4;
+--sorted_result
+SELECT * FROM t1;
+
+TRUNCATE TABLE t1;
+DROP TABLE t1;
+
+## secondary indexes live in reverse column families
+CREATE TABLE t1 (a INT, b CHAR(8), KEY ka(a) comment 'rev:cf1', KEY kb(b)
+comment 'rev:cf1', KEY kab(a,b) comment 'rev:cf2') ENGINE=rocksdb;
+--source no_primary_key_basic_ops.inc
+DROP TABLE t1;
+
+## https://github.com/facebook/mysql-5.6/issues/209
+## Accidental single delete caused data inconsistency
+CREATE TABLE t1 (col1 int, col2 int, KEY kcol1(col1)) ENGINE=ROCKSDB;
+INSERT INTO t1 (col1, col2) values (2,2);
+ALTER TABLE t1 ADD COLUMN extra INT;
+UPDATE t1 SET col2 = 1;
+select * from t1;
+DELETE FROM t1 WHERE col1 = 2;
+
+# flush memtable to cause compaction to occur.
+# During compaction, if a SingleDelete occurs then the delete marker and the
+# key it is deleting are both removed. This will cause data inconsistency if
+# SingleDelete is called on PK, since we do multiple Put() operations to update
+# primary keys.
+set global rocksdb_force_flush_memtable_now = true;
+
+select * from t1;
+DROP TABLE t1;
+
+## https://github.com/facebook/mysql-5.6/issues/736
+create table t1 (i int auto_increment, key(i)) engine=rocksdb;
+insert into t1 values();
+insert into t1 values();
+insert into t1 values();
+
+show create table t1;
+--source include/restart_mysqld.inc
+show create table t1;
+
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/allow_to_start_after_corruption-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/allow_to_start_after_corruption-master.opt
new file mode 100644
index 00000000..70c12060
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/allow_to_start_after_corruption-master.opt
@@ -0,0 +1 @@
+--rocksdb_flush_log_at_trx_commit=1
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/allow_to_start_after_corruption.test b/storage/rocksdb/mysql-test/rocksdb/t/allow_to_start_after_corruption.test
new file mode 100644
index 00000000..e084b57f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/allow_to_start_after_corruption.test
@@ -0,0 +1,77 @@
+--source include/have_rocksdb.inc
+--source include/not_valgrind.inc
+
+--let $restart_noprint=2
+
+--echo #
+--echo # Test how MyRocks behaves when RocksDB reports corrupted data.
+--echo #
+
+--source include/have_debug.inc
+
+# use custom error log to assert on error message in search_pattern_in_file.inc
+--let LOG=$MYSQLTEST_VARDIR/tmp/allow_to_start_after_corruption_debug.err
+--let SEARCH_FILE=$LOG
+
+# restart server to change error log and ignore corruptopn on startup
+--let $_mysqld_option=--log-error=$LOG --rocksdb_allow_to_start_after_corruption=1
+--source include/restart_mysqld_with_option.inc
+
+--echo #
+--echo # Test server crashes on corrupted data and restarts
+--echo #
+create table t1 (
+ pk int not null primary key,
+ col1 varchar(10)
+) engine=rocksdb;
+
+insert into t1 values (1,1),(2,2),(3,3);
+
+select * from t1 where pk=1;
+set session debug_dbug= "+d,rocksdb_return_status_corrupted";
+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--error 2013
+select * from t1 where pk=1;
+--source include/wait_until_disconnected.inc
+--let SEARCH_PATTERN=data corruption detected
+--source include/search_pattern_in_file.inc
+--remove_file $LOG
+
+--echo #
+--echo # The same for scan queries
+--echo #
+
+--source include/start_mysqld_with_option.inc
+select * from t1;
+set session debug_dbug= "+d,rocksdb_return_status_corrupted";
+--exec echo "wait" > $_expect_file_name
+--error 2013
+select * from t1;
+--source include/wait_until_disconnected.inc
+--let SEARCH_PATTERN=data corruption detected
+--source include/search_pattern_in_file.inc
+--remove_file $LOG
+
+--echo #
+--echo # Test restart failure. The server is shutdown at this point.
+--echo #
+
+# remove flag to ignore corruption
+--let $_mysqld_option=--log-error=$LOG
+--error 0
+--exec $MYSQLD_CMD --plugin_load=$HA_ROCKSDB_SO $_mysqld_option
+--let SEARCH_PATTERN=The server will exit normally and stop restart attempts
+--source include/search_pattern_in_file.inc
+--remove_file $LOG
+
+--echo #
+--echo # Remove corruption file and restart cleanly
+--echo #
+
+--exec rm $MYSQLTEST_VARDIR/mysqld.$_server_id/data/#rocksdb/ROCKSDB_CORRUPTED
+--source include/start_mysqld_with_option.inc
+
+drop table t1;
+
+# Restart mysqld with default options
+--source include/restart_mysqld.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/alter_table.test b/storage/rocksdb/mysql-test/rocksdb/t/alter_table.test
new file mode 100644
index 00000000..2603311d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/alter_table.test
@@ -0,0 +1,94 @@
+--source include/have_rocksdb.inc
+
+#
+# Basic ALTER TABLE statements.
+#
+# USAGE of table options in ALTER statements
+# is covered in tbl_standard_opts and tbl_opt*.tests.
+#
+# Index operations are covered in index* tests.
+#
+# ALTER OFFLINE is not covered as it is not supported, as of 5.5.23
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT, c CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (1,1,'a'),(2,5,'z');
+
+# Column operations
+
+ALTER TABLE t1 ADD COLUMN b INT;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 ALTER COLUMN a SET DEFAULT '0';
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 ALTER a DROP DEFAULT;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 CHANGE COLUMN b b1 CHAR(8) FIRST;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 CHANGE b1 b INT AFTER c;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 CHANGE b b CHAR(8);
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 MODIFY COLUMN b INT;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 MODIFY COLUMN b CHAR(8) FIRST;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 MODIFY COLUMN b INT AFTER a;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 DROP COLUMN b;
+SHOW CREATE TABLE t1;
+
+
+# Rename table
+
+ALTER TABLE t1 RENAME TO t2;
+--error ER_NO_SUCH_TABLE
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+
+
+# ORDER BY
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT, b INT) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (1,1,5),(2,2,2),(3,4,3);
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 ORDER BY b ASC, a DESC, pk DESC;
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+# Character set, collate
+
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT, b CHAR(8), c CHAR(8)) ENGINE=rocksdb CHARACTER SET latin1 COLLATE latin1_general_cs;
+INSERT INTO t1 VALUES (1,5,'z','t');
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 DEFAULT CHARACTER SET = latin1 COLLATE latin1_general_ci;
+SHOW CREATE TABLE t1;
+
+
+# A 'null' ALTER operation
+
+ALTER TABLE t1 FORCE;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/analyze_table.test b/storage/rocksdb/mysql-test/rocksdb/t/analyze_table.test
new file mode 100644
index 00000000..b24398b1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/analyze_table.test
@@ -0,0 +1,57 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+#
+# ANALYZE TABLE statements
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT(11), b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (1,1,'a'),(2,2,'b');
+CREATE TABLE t2 (pk INT PRIMARY KEY, a INT(11), b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (3,3,'c');
+ANALYZE TABLE t1;
+INSERT INTO t2 VALUES (1,4,'d');
+ANALYZE NO_WRITE_TO_BINLOG TABLE t2;
+INSERT INTO t1 VALUES (4,5,'e');
+INSERT INTO t2 VALUES (2,6,'f');
+ANALYZE LOCAL TABLE t1, t2;
+
+DROP TABLE t1, t2;
+
+ --let $create_definition = a $int_indexed_col, $default_index(a)
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT(11), KEY(a)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (1,1),(2,2),(3,4),(4,7);
+ANALYZE TABLE t1;
+INSERT INTO t1 VALUES (5,8),(6,10),(7,11),(8,12);
+ANALYZE TABLE t1;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-12465: Server crashes in my_scan_weight_utf8_bin upon
+--echo # collecting stats for RocksDB table
+--echo #
+
+CREATE TABLE t1 (
+ pk INT,
+ f1 CHAR(255),
+ f2 TEXT,
+ f3 VARCHAR(255),
+ f4 TEXT,
+ PRIMARY KEY (pk),
+ KEY (f4(255))
+) ENGINE=RocksDB
+ CHARSET utf8
+ COLLATE utf8_bin
+ PARTITION BY KEY (pk) PARTITIONS 2;
+INSERT INTO t1 VALUES
+(1,'foo','bar','foo','bar'), (2,'bar','foo','bar','foo');
+
+ANALYZE TABLE t1 PERSISTENT FOR ALL;
+
+drop table t1;
+
+--echo # End of 10.2 tests
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/apply_changes_iter.test b/storage/rocksdb/mysql-test/rocksdb/t/apply_changes_iter.test
new file mode 100644
index 00000000..4f759a8e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/apply_changes_iter.test
@@ -0,0 +1,44 @@
+--source include/have_rocksdb.inc
+
+# Tests the Apply_changes_iter class for walking forward and backwards
+# with data in both the transaction class and in the rocksdb storage layer
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+CREATE TABLE t1 (
+ pk INT NOT NULL PRIMARY KEY,
+ key1 INT NOT NULL,
+ KEY (key1)
+) ENGINE=ROCKSDB;
+
+INSERT INTO t1 VALUES (12,12);
+INSERT INTO t1 VALUES (6,6);
+BEGIN;
+INSERT INTO t1 VALUES (8,8), (10,10);
+SELECT * FROM t1 WHERE key1 BETWEEN 4 and 11 ORDER BY KEY1 DESC;
+SELECT * FROM t1 WHERE key1 BETWEEN 4 and 11 ORDER BY KEY1 ASC;
+SELECT * FROM t1 IGNORE INDEX(key1) WHERE key1 BETWEEN 4 and 11 ORDER BY key1 DESC;
+SELECT * FROM t1 IGNORE INDEX(key1) WHERE key1 BETWEEN 4 and 11 ORDER BY key1 ASC;
+ROLLBACK;
+
+CREATE TABLE t2 (
+ pk INT NOT NULL PRIMARY KEY,
+ key1 INT NOT NULL,
+ KEY (key1) COMMENT 'rev:cf'
+) ENGINE=ROCKSDB;
+
+INSERT INTO t2 VALUES (12,12);
+INSERT INTO t2 VALUES (6,6);
+BEGIN;
+INSERT INTO t2 VALUES (8,8), (10,10);
+SELECT * FROM t2 WHERE key1 BETWEEN 4 and 11 ORDER BY KEY1 DESC;
+SELECT * FROM t2 WHERE key1 BETWEEN 4 and 11 ORDER BY KEY1 ASC;
+SELECT * FROM t2 IGNORE INDEX(key1) WHERE key1 BETWEEN 4 and 11 ORDER BY key1 DESC;
+SELECT * FROM t2 IGNORE INDEX(key1) WHERE key1 BETWEEN 4 and 11 ORDER BY key1 ASC;
+ROLLBACK;
+
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe.cnf b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe.cnf
new file mode 100644
index 00000000..a43c4617
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe.cnf
@@ -0,0 +1,8 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+binlog_format=row
+[mysqld.2]
+binlog_format=row
+slave_parallel_workers=1
+#rpl_skip_tx_api=ON
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe.test b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe.test
new file mode 100644
index 00000000..e61ba720
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe.test
@@ -0,0 +1,9 @@
+--source include/have_rocksdb.inc
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+
+create table t (i int primary key auto_increment) engine=rocksdb;
+
+--source include/autoinc_crash_safe.inc
+
+--source include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe_partition.cnf b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe_partition.cnf
new file mode 100644
index 00000000..0c0b6140
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe_partition.cnf
@@ -0,0 +1,8 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+binlog_format=row
+[mysqld.2]
+binlog_format=row
+#slave_parallel_workers=1
+#rpl_skip_tx_api=ON
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe_partition.test b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe_partition.test
new file mode 100644
index 00000000..56cf93db
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_crash_safe_partition.test
@@ -0,0 +1,10 @@
+--source include/have_rocksdb.inc
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+--source include/have_partition.inc
+
+create table t (i int primary key auto_increment) engine=rocksdb partition by key (i) partitions 3;
+
+--source include/autoinc_crash_safe.inc
+
+--source include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_debug-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_debug-master.opt
new file mode 100644
index 00000000..06917181
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_debug-master.opt
@@ -0,0 +1 @@
+--binlog-format=row --rocksdb-flush-log-at-trx-commit=1
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_debug.test b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_debug.test
new file mode 100644
index 00000000..99e28f3b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_debug.test
@@ -0,0 +1,121 @@
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+--source include/have_log_bin.inc
+--source include/not_valgrind.inc
+
+--let $restart_noprint=2
+
+--echo #
+--echo # Testing upgrading from server without merges for auto_increment
+--echo # to new server with such support.
+--echo #
+
+set debug_dbug='+d,myrocks_autoinc_upgrade';
+create table t (i int primary key auto_increment);
+insert into t values ();
+insert into t values ();
+insert into t values ();
+select * from t;
+
+delete from t where i > 1;
+select * from t;
+
+select table_name, index_name, auto_increment
+ from information_schema.rocksdb_ddl where table_name = 't';
+
+set debug_dbug='-d,myrocks_autoinc_upgrade';
+
+--source include/restart_mysqld.inc
+
+insert into t values ();
+insert into t values ();
+insert into t values ();
+select * from t;
+
+select table_name, index_name, auto_increment
+ from information_schema.rocksdb_ddl where table_name = 't';
+
+delete from t where i > 1;
+
+--source include/restart_mysqld.inc
+
+insert into t values ();
+insert into t values ();
+insert into t values ();
+select * from t;
+
+drop table t;
+
+--echo #
+--echo # Testing crash safety of transactions.
+--echo #
+create table t (i int primary key auto_increment);
+insert into t values ();
+insert into t values ();
+insert into t values ();
+
+--echo # Before anything
+begin;
+insert into t values ();
+insert into t values ();
+set debug_dbug="+d,crash_commit_before";
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--error 2013
+commit;
+--source include/wait_until_disconnected.inc
+--enable_reconnect
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+select max(i) into @row_max from t;
+select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
+
+--echo # After engine prepare
+begin;
+insert into t values ();
+insert into t values ();
+set debug_dbug="+d,crash_commit_after_prepare";
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--error 2013
+commit;
+--source include/wait_until_disconnected.inc
+--enable_reconnect
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+select max(i) into @row_max from t;
+select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
+
+--echo # After binlog
+begin;
+insert into t values ();
+insert into t values ();
+set debug_dbug="+d,crash_commit_after_log";
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--error 2013
+commit;
+--source include/wait_until_disconnected.inc
+--enable_reconnect
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+select max(i) into @row_max from t;
+select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
+
+--echo # After everything
+begin;
+insert into t values ();
+insert into t values ();
+set debug_dbug="+d,crash_commit_after";
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--error 2013
+commit;
+--source include/wait_until_disconnected.inc
+--enable_reconnect
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+select max(i) into @row_max from t;
+select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
+
+drop table t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_secondary.test b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_secondary.test
new file mode 100644
index 00000000..68ad21be
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_secondary.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (pk INT PRIMARY KEY, a INT AUTO_INCREMENT, KEY(a)) ENGINE=rocksdb;
+INSERT INTO t1 (pk) VALUES (3), (2), (1);
+SELECT * FROM t1;
+
+--source include/restart_mysqld.inc
+
+INSERT INTO t1 (pk) VALUES (4);
+SELECT * FROM t1;
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars.test b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars.test
new file mode 100644
index 00000000..08532448
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars.test
@@ -0,0 +1,171 @@
+--source include/have_rocksdb.inc
+
+#
+# auto-increment-offset and auto-increment-increment
+#
+
+############################################
+# TODO:
+# This test currently produces wrong result
+# on the line 36 of the result file and further
+# due to bug MySQL:47118.
+# When/if the bug is fixed,
+# the result will need to be updated
+############################################
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo #---------------------------
+--echo # auto_increment_offset
+--echo #---------------------------
+SET auto_increment_offset = 200;
+
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+
+# If auto_increment_offset is greater than auto_increment_increment,
+# the offset is ignored
+
+INSERT INTO t1 (a,b) VALUES (NULL,'a'),(NULL,'b'),(NULL,'c');
+SELECT LAST_INSERT_ID();
+SELECT a,b FROM t1 ORDER BY a;
+
+--echo #---------------------------
+--echo # auto_increment_increment
+--echo #---------------------------
+
+SET auto_increment_increment = 300;
+# offset should not be ignored anymore
+
+INSERT INTO t1 (a,b) VALUES (NULL,'d'),(NULL,'e'),(NULL,'f');
+SELECT LAST_INSERT_ID();
+SELECT a,b FROM t1 ORDER BY a;
+
+SET auto_increment_increment = 50;
+INSERT INTO t1 (a,b) VALUES (NULL,'g'),(NULL,'h'),(NULL,'i');
+SELECT LAST_INSERT_ID();
+SELECT a,b FROM t1 ORDER BY a;
+DROP TABLE t1;
+
+
+--echo #---------------------------
+--echo # offset is greater than the max value
+--echo #---------------------------
+
+SET auto_increment_increment = 500;
+SET auto_increment_offset = 300;
+
+CREATE TABLE t1 (a TINYINT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+--echo # In MariaDB, this is an error:
+--error HA_ERR_AUTOINC_ERANGE
+INSERT INTO t1 (a) VALUES (NULL);
+SELECT LAST_INSERT_ID();
+SELECT a FROM t1 ORDER BY a;
+DROP TABLE t1;
+
+--echo #---------------------------
+--echo # test large autoincrement values
+--echo #---------------------------
+
+SET auto_increment_increment = 1;
+SET auto_increment_offset = 1;
+CREATE TABLE t1 (a BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (18446744073709551613, 'a');
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (NULL, 'b');
+SHOW CREATE TABLE t1;
+--error ER_AUTOINC_READ_FAILED
+INSERT INTO t1 VALUES (NULL, 'c');
+SELECT * FROM t1;
+DROP TABLE t1;
+
+SET auto_increment_increment = 300;
+CREATE TABLE t1 (a BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (18446744073709551613, 'a');
+SHOW CREATE TABLE t1;
+--error ER_AUTOINC_READ_FAILED
+INSERT INTO t1 VALUES (NULL, 'b');
+SHOW CREATE TABLE t1;
+--error ER_AUTOINC_READ_FAILED
+INSERT INTO t1 VALUES (NULL, 'c');
+SELECT * FROM t1;
+DROP TABLE t1;
+
+SET auto_increment_offset = 200;
+CREATE TABLE t1 (a BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (18446744073709551613, 'a');
+SHOW CREATE TABLE t1;
+--error ER_AUTOINC_READ_FAILED
+INSERT INTO t1 VALUES (NULL, 'b');
+SHOW CREATE TABLE t1;
+--error ER_AUTOINC_READ_FAILED
+INSERT INTO t1 VALUES (NULL, 'c');
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo #----------------------------------
+--echo # Issue #792 Crash in autoincrement
+--echo #----------------------------------
+
+CREATE TABLE t1(C1 DOUBLE AUTO_INCREMENT KEY,C2 CHAR) ENGINE=ROCKSDB;
+INSERT INTO t1 VALUES(2177,0);
+DROP TABLE t1;
+
+CREATE TABLE t0(c0 BLOB) ENGINE=ROCKSDB;
+INSERT INTO t0 VALUES(0);
+ALTER TABLE t0 AUTO_INCREMENT=0;
+DROP TABLE t0;
+
+--echo #---------------------------------------------------------------
+--echo # MDEV-16703 Assertion failed in load_auto_incr_value_from_index
+--echo #---------------------------------------------------------------
+
+CREATE TABLE t1 (pk INT AUTO_INCREMENT, a INT, PRIMARY KEY(pk)) ENGINE=RocksDB;
+INSERT INTO t1 (a) VALUES (1);
+UPDATE t1 SET pk = 3;
+ALTER TABLE t1 AUTO_INCREMENT 2;
+DROP TABLE t1;
+
+--echo #----------------------------------
+--echo # Issue #792 Crash in autoincrement
+--echo #----------------------------------
+
+CREATE TABLE t1(C1 DOUBLE AUTO_INCREMENT KEY,C2 CHAR) ENGINE=ROCKSDB;
+INSERT INTO t1 VALUES(2177,0);
+DROP TABLE t1;
+
+CREATE TABLE t0(c0 BLOB) ENGINE=ROCKSDB;
+INSERT INTO t0 VALUES(0);
+ALTER TABLE t0 AUTO_INCREMENT=0;
+DROP TABLE t0;
+
+--echo #----------------------------------
+--echo # Issue #869 Crash in autoincrement
+--echo #----------------------------------
+
+CREATE TABLE t1 (pk INT AUTO_INCREMENT, a INT, PRIMARY KEY(pk)) ENGINE=RocksDB;
+INSERT INTO t1 (a) VALUES (1);
+UPDATE t1 SET pk = 3;
+ALTER TABLE t1 AUTO_INCREMENT 2;
+DROP TABLE t1;
+
+--echo #----------------------------------
+--echo # Issue #902 Debug assert in autoincrement with small field type
+--echo #----------------------------------
+
+SET auto_increment_increment=100, auto_increment_offset=10;
+CREATE TABLE t1(i INT AUTO_INCREMENT PRIMARY KEY) ENGINE=ROCKSDB AUTO_INCREMENT=18446744073709551615;
+# ha_rocksdb::get_auto_increment would assert here
+--error ER_AUTOINC_READ_FAILED
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+ALTER TABLE t1 AUTO_INCREMENT=1;
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+ALTER TABLE t1 AUTO_INCREMENT=18446744073709551615;
+# ha_rocksdb::get_auto_increment would assert here
+--error ER_AUTOINC_READ_FAILED
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars_thread.test b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars_thread.test
new file mode 100644
index 00000000..5a40d28e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars_thread.test
@@ -0,0 +1,65 @@
+--source include/have_rocksdb.inc
+--source include/have_debug_sync.inc
+
+--echo #---------------------------
+--echo # two threads inserting simultaneously with increment > 1
+--echo # Issue #390
+--echo #---------------------------
+
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+
+# Set up connections
+connect (con1, localhost, root,,);
+SET auto_increment_increment = 2;
+SET auto_increment_offset = 1;
+# Insert one row to set up the conditions that caused the original failure
+INSERT INTO t1 VALUES(NULL);
+
+connect (con2, localhost, root,,);
+SET auto_increment_increment = 2;
+SET auto_increment_offset = 1;
+
+connect (con3, localhost, root,,);
+
+# Start each thread on an insert that will block waiting for a signal
+connection con1;
+SET debug_sync='rocksdb.autoinc_vars2 SIGNAL go2';
+SET debug_sync='rocksdb.autoinc_vars SIGNAL parked1 WAIT_FOR go1';
+send INSERT INTO t1 VALUES(NULL);
+
+connection default;
+SET debug_sync='now WAIT_FOR parked1';
+
+connection con2;
+SET debug_sync='rocksdb.autoinc_vars SIGNAL parked2 WAIT_FOR go2';
+send INSERT INTO t1 VALUES(NULL);
+
+# Wait for both threads to be at debug_sync point
+connection default;
+SET debug_sync='now WAIT_FOR parked2';
+
+
+# Signal both threads to continue
+# (In MariaDB, we signal one of them which continues and signals the other)
+send SET debug_sync='now SIGNAL go1';
+connection con3;
+# MariaDB: do nothing here
+
+connection default;
+reap;
+
+connection con1;
+reap;
+
+connection con2;
+reap;
+
+connection default;
+SET debug_sync='RESET';
+
+disconnect con1;
+disconnect con2;
+
+SELECT * FROM t1;
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars_thread_2.test b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars_thread_2.test
new file mode 100644
index 00000000..b64af164
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars_thread_2.test
@@ -0,0 +1,142 @@
+--source include/have_rocksdb.inc
+
+--echo #---------------------------
+--echo # ten threads inserting simultaneously with increment > 1
+--echo # Issue #390
+--echo #---------------------------
+
+# Run 10 simulatenous threads each inserting 10,000 rows
+let $num_threads = 10;
+let $num_rows_per_thread = 100000;
+
+# Create the table with an AUTO_INCREMENT primary key and a separate colum
+# to store which thread created the row
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, thr INT) ENGINE=rocksdb;
+
+# For each thread...
+# 1) set up a connection
+# 2) create a file that can be used for LOAD DATA INFILE ...
+let $i = `SELECT $num_threads`;
+while ($i > 0)
+{
+ dec $i;
+
+ # Set up connection
+ connect (con$i, localhost, root,,);
+
+ # Set up the auto_increment_* variables for each thread
+ eval SET auto_increment_increment = 100;
+ eval SET auto_increment_offset = $i + 1;
+ let $file = `SELECT CONCAT(@@datadir, "test_insert_", $i, ".txt")`;
+
+ # Pass variables into perl
+ let ROCKSDB_INFILE = $file;
+ let ROCKSDB_THREAD = `SELECT $i`;
+ let ROCKSDB_ROWS_PER_THREAD = `SELECT $num_rows_per_thread`;
+
+ # Create a file to load
+ perl;
+ my $fn = $ENV{'ROCKSDB_INFILE'};
+ my $thr = $ENV{'ROCKSDB_THREAD'};
+ my $num = $ENV{'ROCKSDB_ROWS_PER_THREAD'};
+ open(my $fh, '>>', $fn) || die "perl open($fn): $!";
+ binmode $fh;
+ for (my $ii = 0; $ii < $num; $ii++)
+ {
+ print $fh "\\N\t$thr\n"
+ }
+ close($fh);
+ EOF
+}
+
+# For each connection start the LOAD DATA INFILE in the background
+connection default;
+let $i = `SELECT $num_threads`;
+while ($i > 0)
+{
+ dec $i;
+
+ connection con$i;
+ let $file = `SELECT CONCAT(@@datadir, "test_insert_", $i, ".txt")`;
+ --disable_query_log
+ --echo LOAD DATA INFILE <input_file> INTO TABLE t1;
+ send_eval LOAD DATA INFILE '$file' INTO TABLE t1;
+ --enable_query_log
+}
+
+# Reap each connection's background result
+connection default;
+let $i = `SELECT $num_threads`;
+while ($i > 0)
+{
+ dec $i;
+
+ connection con$i;
+ reap;
+}
+
+# Make sure we have the required number of rows
+connection default;
+SELECT COUNT(*) FROM t1;
+SELECT thr, COUNT(pk) FROM t1 GROUP BY thr;
+
+# Cleanup the connection and file used for LOAD DATA INFILE
+let $i = `SELECT $num_threads`;
+while ($i > 0)
+{
+ dec $i;
+
+ disconnect con$i;
+ let $file = `SELECT CONCAT(@@datadir, "test_insert_", "$i", ".txt")`;
+ remove_file $file;
+}
+
+# Validate each row. For each row, the created 'thr' column shows which
+# thread created the row. The pk that was automatically generated should
+# therefore match a certain pattern. For thread 0, the pk should be in
+# the sequence [1, 101, 201, 301, ...]; for thread 1, it should be in the
+# sequence [2, 102, 202, 302, ...], etc. The pk for each row should be
+# smallest value in the sequence for thread 'thr' that is greater than
+# the pk in the previous row.
+let $file = `SELECT CONCAT(@@datadir, "test_export.txt")`;
+--disable_query_log
+--echo SELECT * FROM t1 ORDER BY pk INTO OUTFILE <output_file>;
+eval SELECT * FROM t1 ORDER BY pk INTO OUTFILE "$file";
+--enable_query_log
+
+let ROCKSDB_OUTFILE = $file;
+
+perl;
+my $fn = $ENV{'ROCKSDB_OUTFILE'};
+my $last_pk = 0;
+open(my $fh, '<', $fn) || die "perl open($fn): $!";
+while (<$fh>)
+{
+ if ($_ =~ m/^(.*)\t(.*)$/)
+ {
+ my $pk = $1;
+ my $thr = $2;
+
+ my $expected_pk = int($last_pk / 100) * 100 + ($thr + 1);
+ $expected_pk += 100 if $expected_pk <= $last_pk;
+
+ if ($expected_pk != $pk)
+ {
+ die "Incorrect next pk ($pk); expected $expected_pk (previous: $last_pk)"
+ }
+
+ $last_pk = $pk;
+ }
+ else
+ {
+ die "output file has incorrect format: $_";
+ }
+}
+print stdout "All pk values matched their expected values\n";
+EOF
+
+remove_file $file;
+
+# Drop the table to finally clean up
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/binlog_rotate_crash.test b/storage/rocksdb/mysql-test/rocksdb/t/binlog_rotate_crash.test
new file mode 100644
index 00000000..dd42001b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/binlog_rotate_crash.test
@@ -0,0 +1,31 @@
+--source include/have_rocksdb.inc
+--source include/have_log_bin.inc
+--source include/have_debug_sync.inc
+
+--echo #
+--echo # MDEV-25305: MyRocks: Killing server during RESET MASTER can lose last transactions
+--echo #
+
+set global rocksdb_flush_log_at_trx_commit=1;
+
+create table t1 (a int, b int, key(a)) engine=rocksdb;
+insert into t1 values (1,1),(2,2);
+select * from t1;
+flush tables;
+
+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+restart
+EOF
+
+set @@debug_dbug="+d,crash_after_reset_master";
+
+--disable_reconnect
+--error 0,2013
+RESET MASTER;
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--echo # Must show the inserted rows:
+select * from t1;
+
+drop table t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rc.cnf b/storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rc.cnf
new file mode 100644
index 00000000..a76f1244
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rc.cnf
@@ -0,0 +1,11 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+sync_binlog=0
+binlog_format=row
+slave-exec-mode=strict
+
+[mysqld.2]
+sync_binlog=0
+binlog_format=row
+slave-exec-mode=strict
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rc.test
new file mode 100644
index 00000000..9b5c4571
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rc.test
@@ -0,0 +1,3 @@
+let $trx_isolation = READ COMMITTED;
+--source blind_delete_without_tx_api.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rr.cnf b/storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rr.cnf
new file mode 100644
index 00000000..a76f1244
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rr.cnf
@@ -0,0 +1,11 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+sync_binlog=0
+binlog_format=row
+slave-exec-mode=strict
+
+[mysqld.2]
+sync_binlog=0
+binlog_format=row
+slave-exec-mode=strict
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rr.test
new file mode 100644
index 00000000..4369f6ba
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/blind_delete_rr.test
@@ -0,0 +1,3 @@
+let $trx_isolation = REPEATABLE READ;
+--source blind_delete_without_tx_api.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/blind_delete_without_tx_api.inc b/storage/rocksdb/mysql-test/rocksdb/t/blind_delete_without_tx_api.inc
new file mode 100644
index 00000000..4f03695b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/blind_delete_without_tx_api.inc
@@ -0,0 +1,132 @@
+--source include/have_rocksdb.inc
+--source include/have_binlog_format_row.inc
+
+source include/master-slave.inc;
+
+connection master;
+
+eval SET SESSION TRANSACTION ISOLATION LEVEL $trx_isolation;
+set @save_rocksdb_blind_delete_primary_key=@@session.rocksdb_blind_delete_primary_key;
+set @save_rocksdb_master_skip_tx_api=@@session.rocksdb_master_skip_tx_api;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+create table t1 (id int primary key, value int, value2 varchar(200)) engine=rocksdb;
+create table t2 (id int primary key, value int, value2 varchar(200), index(value)) engine=rocksdb;
+
+--disable_query_log
+let $t = 1;
+while ($t <= 2) {
+ let $i = 1;
+ while ($i <= 10000) {
+ let $insert = INSERT INTO t$t VALUES($i, $i, REPEAT('x', 150));
+ inc $i;
+ eval $insert;
+ }
+ inc $t;
+}
+--enable_query_log
+
+SET session rocksdb_blind_delete_primary_key=1;
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+# Deleting 1000 rows from t1
+--disable_query_log
+let $i = 1;
+while ($i <= 1000) {
+ let $insert = DELETE FROM t1 WHERE id=$i;
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+SELECT count(*) FROM t1;
+
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $trx_isolation;
+SELECT count(*) FROM t1;
+connection master;
+
+# Deleting 1000 rows from t2 (blind delete disabled because of secondary key)
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+--disable_query_log
+let $i = 1;
+while ($i <= 1000) {
+ let $insert = DELETE FROM t2 WHERE id=$i;
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+SELECT count(*) FROM t2;
+
+SET session rocksdb_master_skip_tx_api=1;
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+--disable_query_log
+let $t = 1;
+while ($t <= 2) {
+ let $i = 1001;
+ while ($i <= 2000) {
+ let $insert = DELETE FROM t$t WHERE id=$i;
+ inc $i;
+ eval $insert;
+ }
+ inc $t;
+}
+--enable_query_log
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+SELECT count(*) FROM t1;
+SELECT count(*) FROM t2;
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+SELECT count(*) FROM t1;
+SELECT count(*) FROM t2;
+connection master;
+
+
+# Range Deletes (blind delete disabled)
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+DELETE FROM t1 WHERE id BETWEEN 3001 AND 4000;
+DELETE FROM t2 WHERE id BETWEEN 3001 AND 4000;
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_deleted_blind';
+SELECT count(*) FROM t1;
+SELECT count(*) FROM t2;
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+SELECT count(*) FROM t1;
+SELECT count(*) FROM t2;
+connection master;
+
+
+# Deleting same keys (slaves stop)
+DELETE FROM t1 WHERE id = 10;
+SELECT count(*) FROM t1;
+connection slave;
+call mtr.add_suppression("Slave SQL.*Could not execute Delete_rows event on table test.t1.*Error_code.*");
+call mtr.add_suppression("Slave: Can't find record in 't1'.*");
+# wait until we have the expected error
+--let $slave_sql_errno= convert_error(ER_KEY_NOT_FOUND)
+--source include/wait_for_slave_sql_error.inc
+
+connection slave;
+set @save_rocksdb_read_free_rpl=@@global.rocksdb_read_free_rpl;
+set global rocksdb_read_free_rpl=PK_SK;
+START SLAVE;
+connection master;
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+SELECT count(*) FROM t1;
+connection master;
+
+
+# cleanup
+connection slave;
+set global rocksdb_read_free_rpl=@save_rocksdb_read_free_rpl;
+connection master;
+SET session rocksdb_blind_delete_primary_key=@save_rocksdb_blind_delete_primary_key;
+SET session rocksdb_master_skip_tx_api=@save_rocksdb_master_skip_tx_api;
+
+DROP TABLE t1, t2;
+--source include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter-master.opt
new file mode 100644
index 00000000..bf9d0624
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter-master.opt
@@ -0,0 +1,2 @@
+--rocksdb_default_cf_options=write_buffer_size=256k;block_based_table_factory={filter_policy=bloomfilter:10:false;whole_key_filtering=0;};prefix_extractor=capped:20
+--rocksdb_override_cf_options=cf_short_prefix={prefix_extractor=capped:4};rev:cf_short_prefix={prefix_extractor=capped:4};cf_long_prefix={prefix_extractor=capped:240};rev:cf_long_prefix={prefix_extractor=capped:240}
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.inc b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.inc
new file mode 100644
index 00000000..1fb9ef8a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.inc
@@ -0,0 +1,78 @@
+--source include/have_rocksdb.inc
+
+DELIMITER //;
+CREATE PROCEDURE bloom_start()
+BEGIN
+ select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+ select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+END//
+CREATE PROCEDURE bloom_end()
+BEGIN
+select case when variable_value-@c > 0 then 'true' else 'false' end as checked from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+END//
+DELIMITER ;//
+
+#BF is sometimes invoked and useful
+--let $CF=
+--source bloomfilter_table_def.inc
+--source bloomfilter_load_select.inc
+
+#BF is always invoked but not useful at all
+--let $CF=COMMENT 'cf_short_prefix'
+--source bloomfilter_table_def.inc
+--source bloomfilter_load_select.inc
+
+--let $CF=COMMENT 'rev:cf_short_prefix'
+--source bloomfilter_table_def.inc
+--source bloomfilter_load_select.inc
+
+#BF is most of the time invoked and useful
+--let $CF=COMMENT 'cf_long_prefix'
+--source bloomfilter_table_def.inc
+--source bloomfilter_load_select.inc
+
+--let $CF=COMMENT 'rev:cf_long_prefix'
+--source bloomfilter_table_def.inc
+--source bloomfilter_load_select.inc
+
+
+# BUG: Prev() with prefix lookup should not use prefix bloom filter
+create table r1 (id1 bigint, id2 bigint, id3 bigint, v1 int, v2 text, primary key (id1, id2, id3)) engine=rocksdb DEFAULT CHARSET=latin1 collate latin1_bin;
+--disable_query_log
+let $max = 100;
+let $i = 1;
+
+create table t10(a int primary key);
+insert into t10 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t11(a int primary key);
+insert into t11 select A.a + B.a* 10 + C.a * 100 from t10 A, t10 B, t10 C;
+
+set @a=0;
+set rocksdb_bulk_load=1;
+while ($i <= $max) {
+ inc $i;
+ eval insert into r1 select @a:=@a+1, @a, @a, @a, @a from t11;
+}
+set rocksdb_bulk_load=0;
+
+drop table t10, t11;
+
+--enable_query_log
+call bloom_start();
+select * from r1 where id1=1 and id2 in (1) order by id3 asc;
+call bloom_end();
+call bloom_start();
+select * from r1 where id1=1 and id2 in (1) order by id3 desc;
+call bloom_end();
+
+# cleanup
+DROP PROCEDURE bloom_start;
+DROP PROCEDURE bloom_end;
+truncate table t1;
+optimize table t1;
+truncate table t2;
+optimize table t2;
+drop table if exists t1;
+drop table if exists t2;
+drop table if exists r1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.test b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.test
new file mode 100644
index 00000000..efcf9ee1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.test
@@ -0,0 +1 @@
+--source bloomfilter.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter2-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter2-master.opt
new file mode 100644
index 00000000..f3824106
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter2-master.opt
@@ -0,0 +1 @@
+--rocksdb_default_cf_options=write_buffer_size=64k;block_based_table_factory={filter_policy=bloomfilter:10:false;whole_key_filtering=0;};prefix_extractor=capped:24
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter2.test b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter2.test
new file mode 100644
index 00000000..c4f1570e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter2.test
@@ -0,0 +1,103 @@
+--source include/have_rocksdb.inc
+
+## Test 0: Eq cond len includs VARCHAR, and real cond len < prefix bloom len < VARCHAR definition len
+CREATE TABLE t0 (id1 VARCHAR(30), id2 INT, value INT, PRIMARY KEY (id1, id2)) ENGINE=rocksdb collate latin1_bin;
+--disable_query_log
+let $i = 1;
+while ($i <= 10000) {
+ let $insert = INSERT INTO t0 VALUES('X', $i, $i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+# BF not used
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+SELECT COUNT(*) FROM t0 WHERE id1='X' AND id2>=1;
+select case when variable_value-@u = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+
+DROP TABLE t0;
+
+
+## Test 1: Eq cond len is shorter than prefix bloom len
+CREATE TABLE t1 (id1 BIGINT, id2 INT, id3 BIGINT, value INT, PRIMARY KEY (id1, id2, id3)) ENGINE=rocksdb;
+
+--disable_query_log
+let $i = 1;
+while ($i <= 10000) {
+ let $insert = INSERT INTO t1 VALUES(1, 1, $i, $i);
+ eval $insert;
+ inc $i;
+}
+--enable_query_log
+
+# BF not used (4+8+4=16)
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3>=2;
+select case when variable_value-@u = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+
+# BF not used (4+8=12)
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2>=1 AND id3>=2;
+select case when variable_value-@u = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+
+DROP TABLE t1;
+
+
+## Test 2: Long IN and short IN (varchar) -- can_use_bloom_filter changes within the same query
+CREATE TABLE t2 (id1 INT, id2 VARCHAR(100), id3 BIGINT, value INT, PRIMARY KEY (id1, id2, id3)) ENGINE=rocksdb collate latin1_bin;
+--disable_query_log
+let $i = 1;
+while ($i <= 10000) {
+ let $insert = INSERT INTO t2 VALUES($i, $i, $i, $i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+# BF used for large cond, not used for short cond
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+select count(*) from t2 WHERE id1=100 and id2 IN ('00000000000000000000', '100');
+select case when variable_value-@u > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+select count(*) from t2 WHERE id1=200 and id2 IN ('00000000000000000000', '200');
+select case when variable_value-@u > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+
+# BF not used because cond length is too small in all cases
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+select count(*) from t2 WHERE id1=200 and id2 IN ('3', '200');
+select case when variable_value-@u = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+
+DROP TABLE t2;
+
+
+## Test 3: Eq cond len is longer than prefix bloom len
+CREATE TABLE t3 (id1 BIGINT, id2 BIGINT, id3 BIGINT, id4 BIGINT, PRIMARY KEY (id1, id2, id3, id4)) ENGINE=rocksdb collate latin1_bin;
+--disable_query_log
+let $i = 1;
+while ($i <= 10000) {
+ if ($i != 5000) {
+ let $insert = INSERT INTO t3 VALUES(1, $i, $i, $i);
+ eval $insert;
+ }
+ inc $i;
+}
+--enable_query_log
+
+# Full BF works with Get(), Block based does not.
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_useful';
+SELECT COUNT(*) FROM t3 WHERE id1=1 AND id2=5000 AND id3=1 AND id4=1;
+select case when variable_value-@u > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_useful';
+
+# BF used (4+8+8+8)
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+SELECT COUNT(*) FROM t3 WHERE id1=1 AND id2=1 AND id3=1;
+select case when variable_value-@u > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+SELECT COUNT(*) FROM t3 WHERE id1=1 AND id2=1 AND id3=1 AND id4 <= 500;
+select case when variable_value-@u > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_useful';
+
+DROP TABLE t3;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter3-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter3-master.opt
new file mode 100644
index 00000000..a21608c7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter3-master.opt
@@ -0,0 +1,4 @@
+--rocksdb_default_cf_options=write_buffer_size=64k;block_based_table_factory={filter_policy=bloomfilter:10:false;whole_key_filtering=0;};prefix_extractor=capped:20
+--rocksdb_debug_optimizer_n_rows=1000
+--rocksdb_table_stats_sampling_pct=100
+--rocksdb_info_log_level=debug_level
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter3.test b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter3.test
new file mode 100644
index 00000000..dc2a0da5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter3.test
@@ -0,0 +1,136 @@
+--source include/have_rocksdb.inc
+
+--source include/restart_mysqld.inc
+CREATE TABLE `linktable` (
+ `id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+ `id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+ `link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `visibility` tinyint(3) NOT NULL DEFAULT '0',
+ `data` varchar(255) NOT NULL DEFAULT '',
+ `time` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `version` int(11) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (link_type, `id1`,`id2`) COMMENT 'cf_link_pk',
+ KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`version`,`data`) COMMENT 'rev:cf_link_id1_type',
+ KEY `id1_type2` (`id1`,`link_type`,`time`,`version`,`data`,`visibility`) COMMENT 'rev:cf_link_id1_type2',
+ KEY `id1_type3` (`id1`,`visibility`,`time`,`version`,`data`,`link_type`) COMMENT 'rev:cf_link_id1_type3'
+) ENGINE=RocksDB DEFAULT COLLATE=latin1_bin;
+
+--disable_query_log
+call mtr.add_suppression("LibRocksDB");
+let $i = 1;
+while ($i <= 10000) {
+ let $insert = INSERT INTO linktable VALUES($i, $i, $i, $i, 1, 1, $i, $i, $i);
+ eval $insert;
+ inc $i;
+}
+--enable_query_log
+
+## HA_READ_PREFIX_LAST_OR_PREV
+# BF len 21
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type`) where id1 = 100 and link_type = 1 and time >= 0 and time <= 9223372036854775807 and visibility = 1 order by time desc;
+select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+
+# BF len 20
+
+--echo # MariaDB: we don't have optimizer_force_index_for_range, but we can use EITS
+--echo # to get the query plan we want.
+set @tmp_use_stat_tables= @@use_stat_tables;
+set use_stat_tables='preferably';
+analyze table linktable persistent for all;
+flush tables;
+explain select * from linktable;
+--echo # This must use range(id1_type2), key_len=24
+explain
+select id1, id2, link_type, visibility, data, time, version from linktable
+FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 and time >= 0 and time <= 9223372036854775807 order by time desc;
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+# MariaDB: no support for optimizer_force_index_for_range:
+#set @tmp_force_index_for_range=@@optimizer_force_index_for_range;
+#set optimizer_force_index_for_range=on;
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 and time >= 0 and time <= 9223372036854775807 order by time desc;
+select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+#set global optimizer_force_index_for_range=@tmp_force_index_for_range;
+
+# BF len 13
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type3`) where id1 = 100 and time >= 0 and time <= 9223372036854775807 and visibility = 1 order by time desc;
+select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+
+## HA_READ_PREFIX_LAST_OR_PREV (no end range)
+# BF len 20
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type`) where id1 = 100 and link_type = 1 and visibility = 1 and time >= 0 order by time desc;
+select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+
+# BF len 19
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 and time >= 0 order by time desc;
+select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+
+--echo ## HA_READ_PREFIX_LAST
+--echo # BF len 20
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type`) where id1 = 100 and link_type = 1 and visibility = 1 order by time desc;
+select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+
+--echo # BF len 19
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 order by time desc;
+select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+
+--echo # BF len 12
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type3`) where id1 = 100 and visibility = 1 order by time desc;
+select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+
+
+DROP TABLE linktable;
+--source include/restart_mysqld.inc
+
+--echo #
+--echo # bloom filter prefix is 20 byte
+--echo # Create a key which is longer than that, so that we see that
+--echo # eq_cond_len= slice.size() - 1;
+--echo # doesnt work.
+--echo #
+--echo # indexnr 4
+--echo # kp0 + 4 = 8
+--echo # kp1 + 8 = 16
+--echo # kp2 + 8 = 24 24>20 byte length prefix
+--echo # kp3 + 8 = 28
+
+create table t1 (
+ pk int primary key,
+ kp0 int not null,
+ kp1 bigint not null,
+ kp2 bigint not null,
+ kp3 bigint not null,
+ key kp12(kp0, kp1, kp2, kp3) comment 'rev:x1'
+) engine=rocksdb;
+
+insert into t1 values (1, 1,1, 1,1);
+insert into t1 values (10,1,1,0x12FFFFFFFFFF,1);
+insert into t1 values (11,1,1,0x12FFFFFFFFFF,1);
+insert into t1 values (20,2,2,0x12FFFFFFFFFF,1);
+insert into t1 values (21,2,2,0x12FFFFFFFFFF,1);
+
+--source include/restart_mysqld.inc
+
+--replace_column 9 #
+explain
+select * from t1 where kp0=1 and kp1=1 and kp2=0x12FFFFFFFFFF order by kp3 desc;
+show status like '%rocksdb_bloom_filter_prefix%';
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+select * from t1 where kp0=1 and kp1=1 and kp2=0x12FFFFFFFFFF order by kp3 desc;
+show status like '%rocksdb_bloom_filter_prefix%';
+--echo # The following MUST show TRUE:
+select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+
+drop table t1;
+# Key length is 4 + 8 + 8 = 20
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter4-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter4-master.opt
new file mode 100644
index 00000000..0a325757
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter4-master.opt
@@ -0,0 +1 @@
+--rocksdb_default_cf_options=write_buffer_size=16k;block_based_table_factory={filter_policy=bloomfilter:10:false;whole_key_filtering=0;};prefix_extractor=capped:12
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter4.test b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter4.test
new file mode 100644
index 00000000..76ec6ca1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter4.test
@@ -0,0 +1,52 @@
+--source include/have_rocksdb.inc
+
+# Fixing issue#230 -- Prefix bloom filter + reverse column family misses some rows
+# This test inserts 20,000 rows into t1, then selecting one by one from stored procedure.
+# If the select does not return any row, it is wrong.
+
+CREATE TABLE t1 (
+ `id1` int unsigned NOT NULL DEFAULT '0',
+ `id2` int unsigned NOT NULL DEFAULT '0',
+ `link_type` int unsigned NOT NULL DEFAULT '0',
+ `visibility` tinyint NOT NULL DEFAULT '0',
+ `data` varchar(255) NOT NULL DEFAULT '',
+ `time` int unsigned NOT NULL DEFAULT '0',
+ `version` int unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (id1, link_type, visibility, id2) COMMENT 'rev:cf_link_pk'
+) ENGINE=RocksDB DEFAULT COLLATE=latin1_bin;
+
+DELIMITER //;
+CREATE PROCEDURE select_test()
+BEGIN
+ DECLARE id1_cond INT;
+ SET id1_cond = 1;
+ WHILE id1_cond <= 20000 DO
+ SELECT count(*) AS cnt FROM (SELECT id1 FROM t1 FORCE INDEX (PRIMARY) WHERE id1 = id1_cond AND link_type = 1 AND visibility = 1 ORDER BY id2 DESC) AS t INTO @cnt;
+ IF @cnt < 1 THEN
+ SELECT id1_cond, @cnt;
+ END IF;
+ SET id1_cond = id1_cond + 1;
+ END WHILE;
+END//
+DELIMITER ;//
+
+--disable_query_log
+let $i = 1;
+while ($i <= 20000) {
+ let $insert = INSERT INTO t1 VALUES($i, $i, 1, 1, $i, $i, $i);
+ eval $insert;
+ inc $i;
+}
+--enable_query_log
+
+--echo "Skipping bloom filter"
+SET session rocksdb_skip_bloom_filter_on_read=1;
+CALL select_test();
+
+--echo "Using bloom filter"
+SET session rocksdb_skip_bloom_filter_on_read=0;
+CALL select_test();
+
+DROP PROCEDURE select_test;
+drop table t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter5-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter5-master.opt
new file mode 100644
index 00000000..4576d20f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter5-master.opt
@@ -0,0 +1,3 @@
+--rocksdb_default_cf_options=write_buffer_size=256k;block_based_table_factory={filter_policy=bloomfilter:10:false;whole_key_filtering=0;}
+--rocksdb_override_cf_options=rev:bf5_1={prefix_extractor=capped:4};bf5_1={prefix_extractor=capped:4}
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter5.test b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter5.test
new file mode 100644
index 00000000..11890dcf
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter5.test
@@ -0,0 +1,86 @@
+
+--echo #
+--echo # Issue #809: Wrong query result with bloom filters
+--echo #
+
+create table t1 (
+ id1 bigint not null,
+ id2 bigint not null,
+ id3 varchar(100) not null,
+ id4 int not null,
+ id5 int not null,
+ value bigint,
+ value2 varchar(100),
+ primary key (id1, id2, id3, id4) COMMENT 'rev:bf5_1'
+) engine=ROCKSDB;
+
+
+create table t2(a int);
+insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t3(seq int);
+insert into t3
+select
+ 1+ A.a + B.a* 10 + C.a * 100 + D.a * 1000
+from t2 A, t2 B, t2 C, t2 D;
+
+insert t1
+select
+ (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc"
+from t3;
+
+set global rocksdb_force_flush_memtable_now=1;
+
+--echo # Full table scan
+explain
+select * from t1 limit 10;
+select * from t1 limit 10;
+
+--echo # An index scan starting from the end of the table:
+explain
+select * from t1 order by id1 desc,id2 desc, id3 desc, id4 desc limit 1;
+select * from t1 order by id1 desc,id2 desc, id3 desc, id4 desc limit 1;
+
+# A testcase for an assertion that the fix is removing
+# The only requirement for the used column family is that it is reverse-ordered
+create table t4 (
+ pk int unsigned not null primary key,
+ kp1 int unsigned not null,
+ kp2 int unsigned not null,
+ col1 int unsigned,
+ key(kp1, kp2) comment 'rev:bf5_2'
+) engine=rocksdb;
+
+insert into t4 values (1, 0xFFFF, 0xFFF, 12345);
+
+--echo # This must not fail an assert:
+select * from t4 force index(kp1) where kp1=0xFFFFFFFF and kp2<=0xFFFFFFFF order by kp2 desc;
+
+
+--echo #
+--echo # Issue #881: Issue #809 still occurs for reverse scans on forward cfs
+--echo #
+
+# The same as t1 above but uses forward-ordered column family:
+
+create table t5 (
+ id1 bigint not null,
+ id2 bigint not null,
+ id3 varchar(100) not null,
+ id4 int not null,
+ id5 int not null,
+ value bigint,
+ value2 varchar(100),
+ primary key (id1, id2, id3, id4) COMMENT 'bf5_1'
+) engine=ROCKSDB;
+
+insert into t5 select * from t1;
+
+set global rocksdb_force_flush_memtable_now=1;
+
+--echo # An index scan starting from the end of the table:
+explain
+select * from t5 order by id1 desc,id2 desc, id3 desc, id4 desc limit 1;
+select * from t5 order by id1 desc,id2 desc, id3 desc, id4 desc limit 1;
+
+drop table t1,t2,t3,t4,t5;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_bulk_load-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_bulk_load-master.opt
new file mode 100644
index 00000000..c28681ef
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_bulk_load-master.opt
@@ -0,0 +1,2 @@
+--rocksdb_default_cf_options=write_buffer_size=16k;block_based_table_factory={filter_policy=bloomfilter:10:false;whole_key_filtering=0;};prefix_extractor=capped:12
+--rocksdb_override_cf_options=cf2={optimize_filters_for_hits=true}
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_bulk_load.test b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_bulk_load.test
new file mode 100644
index 00000000..09d9d734
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_bulk_load.test
@@ -0,0 +1,35 @@
+--source include/have_rocksdb.inc
+
+create table r1 (id bigint primary key, value bigint) engine=rocksdb;
+create table r2 (id bigint, value bigint, primary key (id) comment 'cf2') engine=rocksdb;
+set session rocksdb_bulk_load=1;
+--disable_query_log
+let $t = 1;
+let $i = 1;
+while ($t <= 2) {
+ while ($i <= 1000) {
+ let $insert = INSERT INTO r$t VALUES($i, $i);
+ #skipping a row
+ if ($i != 100) {
+ eval $insert;
+ }
+ inc $i;
+ }
+ inc $t;
+}
+--enable_query_log
+set session rocksdb_bulk_load=0;
+
+# bloom filter should be useful on insert (calling GetForUpdate)
+select variable_value into @h from information_schema.global_status where variable_name='rocksdb_block_cache_filter_hit';
+insert into r1 values (100, 100);
+select variable_value-@h from information_schema.global_status where variable_name='rocksdb_block_cache_filter_hit';
+
+# cf2 has no bloo filter in the bottommost level
+select variable_value into @h from information_schema.global_status where variable_name='rocksdb_block_cache_filter_hit';
+insert into r2 values (100, 100);
+select variable_value-@h from information_schema.global_status where variable_name='rocksdb_block_cache_filter_hit';
+
+DROP TABLE r1, r2;
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_load_select.inc b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_load_select.inc
new file mode 100644
index 00000000..cf8b2684
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_load_select.inc
@@ -0,0 +1,190 @@
+source include/have_sequence.inc;
+
+# loading some data (larger than write buf size) to cause compaction
+insert t1
+ select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc"
+ from seq_1_to_10000;
+insert t2 select * from t1;
+set global rocksdb_force_flush_memtable_now=1;
+
+# BF conditions (prefix short(4B)|medium(20B)|long(240B))
+#0 no eq condition (o, x, x)
+## cond length 4, key length > 4
+call bloom_start();
+select count(*) from t1;
+call bloom_end();
+call bloom_start();
+select count(*) from t2;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index(PRIMARY) where id1 >= 1;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2 >= 1;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index(id3_id4) where id3 >= '1';
+call bloom_end();
+
+#1 cond length == prefix length (o, o, x)
+## cond length 4+8+8=20, key length > 20
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=2 and id1=1;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=24 and id1=12;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=88 and id1=44;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=100 and id1=50;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index(id2_id1) where id2=428 and id1=214;
+call bloom_end();
+## (cond_length == extended_key_length(4+8+4+4=20) == prefix_length)
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=1 and id4=1 and id5=1;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=23 and id4=115 and id5=115;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=500 and id4=2500 and id5=2500;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id2_id4_id5) where id2=601 and id4=3005 and id5=3005;
+call bloom_end();
+
+#2 cond length < actual key length and cond_length < prefix length (o, x, x)
+## for long prefix key, most cases falling into this category, unless all key colums are used.
+## cond length 4+8=12, key length > 12
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=23;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=345;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=456;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=1;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=23;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=345;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id2_id4) where id2=456;
+call bloom_end();
+
+#3 both actual key length and cond length >= prefix length (o, o, o/x)
+## cond length 4+8+9+8+4=33
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=1 and id3='1' and id1=1 order by id4;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36 and id3='36' and id1=18 order by id4;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124' and id1=62 order by id4;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=888 and id3='888' and id1=444 order by id4;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=124 and id3='124';
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=1 and id3='1' and id4=1;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id2_id3) where id2=12 and id3='12' and id4=60;
+call bloom_end();
+## 4+8+9=25
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=1 and id3='1';
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (id2_id3) where id2=23 and id3='23';
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=1 and id3='1';
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (id3_id2) where id2=23 and id3='23';
+call bloom_end();
+
+#4 actual key length > prefix length and cond length < prefix length (o, x, x)
+## cond length 4+8=12
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=1;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=12;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=23;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=100;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (PRIMARY) where id1=234;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=36;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (id2_id3_id1_id4) where id2=234;
+call bloom_end();
+
+#5 cond length == extended key length < prefix length (o, o, o)
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=1 and id4=1;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=23 and id4=115;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=500 and id4=2500;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id2) where id2=601 and id4=3005;
+call bloom_end();
+## 4+9+4=17
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='1' and id4=1;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id3_id4) where id3='12' and id4=60;
+call bloom_end();
+
+#6 cond length == non-extended key length < prefix length, actual key length > prefix length (o, x, x)
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=1;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=23;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=345;
+call bloom_end();
+call bloom_start();
+select count(*) from t1 force index (id2) where id2=456;
+call bloom_end();
+## 4+9+4=17
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='100' and id5=500;
+call bloom_end();
+call bloom_start();
+select count(*) from t2 force index (id3_id5) where id3='240' and id5=1200;
+call bloom_end();
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_skip-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_skip-master.opt
new file mode 100644
index 00000000..5c62c7cf
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_skip-master.opt
@@ -0,0 +1,3 @@
+--rocksdb_default_cf_options=write_buffer_size=256k;block_based_table_factory={filter_policy=bloomfilter:10:false;whole_key_filtering=0;};prefix_extractor=capped:20
+--rocksdb_override_cf_options=cf_short_prefix={prefix_extractor=capped:4};cf_long_prefix={prefix_extractor=capped:240}
+--rocksdb_skip_bloom_filter_on_read=1
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_skip.test b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_skip.test
new file mode 100644
index 00000000..efcf9ee1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_skip.test
@@ -0,0 +1 @@
+--source bloomfilter.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_table_def.inc b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_table_def.inc
new file mode 100644
index 00000000..2bc9bb64
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_table_def.inc
@@ -0,0 +1,33 @@
+eval create or replace table t1 (
+ id1 bigint not null,
+ id2 bigint not null,
+ id3 varchar(100) not null,
+ id4 int not null,
+ id5 int not null,
+ value bigint,
+ value2 varchar(100),
+ primary key (id1, id2, id3, id4) $CF,
+ index id2 (id2) $CF,
+ index id2_id1 (id2, id1) $CF,
+ index id2_id3 (id2, id3) $CF,
+ index id2_id4 (id2, id4) $CF,
+ index id2_id3_id1_id4 (id2, id3, id1, id4) $CF,
+ index id3_id2 (id3, id2) $CF
+) engine=ROCKSDB;
+
+eval create or replace table t2 (
+ id1 bigint not null,
+ id2 bigint not null,
+ id3 varchar(100) not null,
+ id4 int not null,
+ id5 int not null,
+ value bigint,
+ value2 varchar(100),
+ primary key (id4) $CF,
+ index id2 (id2) $CF,
+ index id2_id3 (id2, id3) $CF,
+ index id2_id4 (id2, id4) $CF,
+ index id2_id4_id5 (id2, id4, id5) $CF,
+ index id3_id4 (id3, id4) $CF,
+ index id3_id5 (id3, id5) $CF
+) engine=ROCKSDB;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bulk_load.test b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load.test
new file mode 100644
index 00000000..b1afc5b2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load.test
@@ -0,0 +1,11 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+# This test requires ~2.3G of disk space
+--source include/big_test.inc
+
+--let pk_cf=cf1
+--let pk_cf_name=cf1
+--let data_order_desc=0
+
+--source ../include/bulk_load.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_drop_table.test b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_drop_table.test
new file mode 100644
index 00000000..18e40fbf
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_drop_table.test
@@ -0,0 +1,19 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE t1 (pk INT, PRIMARY KEY (pk)) ENGINE=ROCKSDB;
+
+SET rocksdb_bulk_load_allow_unsorted=1;
+SET rocksdb_bulk_load=1;
+
+INSERT INTO t1 VALUES (1);
+
+--connect (con1,localhost,root,,)
+DROP TABLE t1;
+
+--connection default
+--disconnect con1
+
+# This would have crashed the server prior to the fix
+SET rocksdb_bulk_load=0;
+--error ER_NO_SUCH_TABLE
+SELECT * FROM t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_errors.test b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_errors.test
new file mode 100644
index 00000000..04097848
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_errors.test
@@ -0,0 +1,168 @@
+--source include/have_rocksdb.inc
+--source include/count_sessions.inc
+
+--let LOG1=$MYSQLTEST_VARDIR/tmp/rocksdb.bulk_load_errors.1.err
+--let $_mysqld_option=--log-error=$LOG1
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--source include/restart_mysqld_with_option.inc
+
+### Bulk load ###
+CREATE TABLE t1(pk INT, PRIMARY KEY(pk)) ENGINE=ROCKSDB;
+
+# Make sure we get an error with out of order keys during bulk load
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES(10);
+INSERT INTO t1 VALUES(11);
+--error ER_KEYS_OUT_OF_ORDER
+INSERT INTO t1 VALUES(9);
+SET rocksdb_bulk_load=0;
+
+# Make sure only 10 and 11 got into the table
+SELECT * FROM t1;
+
+# Make sure we get an error with overlapping data
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t1 VALUES(2);
+INSERT INTO t1 VALUES(20);
+INSERT INTO t1 VALUES(21);
+
+--error ER_OVERLAPPING_KEYS
+SET rocksdb_bulk_load=0;
+
+SHOW VARIABLES LIKE 'rocksdb_bulk_load';
+call mtr.add_suppression('finalizing last SST file while setting bulk loading variable');
+
+SELECT * FROM t1;
+
+--let SEARCH_FILE=$LOG1
+--let SEARCH_PATTERN=RocksDB: Error [0-9]+ finalizing last SST file while setting bulk loading variable
+--source include/search_pattern_in_file.inc
+
+--let LOG2=$MYSQLTEST_VARDIR/tmp/rocksdb.bulk_load_errors.2.err
+--let $_mysqld_option=--log-error=$LOG2
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--source include/restart_mysqld_with_option.inc
+--remove_file $LOG1
+
+
+# Make sure we get an error in log when we disconnect and do not assert the server
+--connect (con1,localhost,root,,)
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t1 VALUES(2);
+INSERT INTO t1 VALUES(20);
+INSERT INTO t1 VALUES(21);
+let $ID = `SELECT connection_id()`;
+--connection default
+--disconnect con1
+
+SELECT * FROM t1;
+
+--disable_parsing
+# MariaDB: no support for $RPC_PROTOCOL
+if (`SELECT $RPC_PROTOCOL > 0`) {
+ # for --rpc_protocol mode wait for the background detached session to
+ # go away
+ let $wait_condition =
+ SELECT COUNT(*) = 0
+ FROM information_schema.srv_sessions
+ WHERE id = $ID;
+ --source include/wait_condition.inc
+}
+
+if (`SELECT $RPC_PROTOCOL = 0`) {
+ # for non --rpc_protocol mode simply wait until the number of sessions
+ # returns to earlier levels
+ --source include/wait_until_count_sessions.inc
+}
+--enable_parsing
+# MariaDB:
+--source include/wait_until_count_sessions.inc
+
+# Note: in MariaDB, session count will be decremented *before*
+# myrocks::rocksdb_close_connection is called. This causes a race condition:
+# we may grep the error log before bulk load is finalized.
+# To prevent that, do a soft restart of the server (I wasnt able to find
+# any other reliable way)
+--source include/restart_mysqld_with_option.inc
+
+--let SEARCH_FILE=$LOG2
+--let SEARCH_PATTERN=RocksDB: Error [0-9]+ finalizing last SST file while disconnecting
+--source include/search_pattern_in_file.inc
+
+--let LOG3=$MYSQLTEST_VARDIR/tmp/rocksdb.bulk_load_errors.3.err
+--let $_mysqld_option=--log-error=$LOG3
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--source include/restart_mysqld_with_option.inc
+--remove_file $LOG2
+
+TRUNCATE TABLE t1;
+
+### Bulk load with unsorted PKs ###
+SET rocksdb_bulk_load_allow_unsorted=1;
+
+# We should not get an error with out of order PKs
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES(100);
+INSERT INTO t1 VALUES(101);
+INSERT INTO t1 VALUES(99);
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1;
+TRUNCATE TABLE t1;
+
+# We should get an error with duplicate PKs in the same bulk load
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES(201);
+INSERT INTO t1 VALUES(200);
+INSERT INTO t1 VALUES(202);
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES(201);
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1;
+
+SET rocksdb_bulk_load_allow_unsorted=DEFAULT;
+DROP TABLE t1;
+
+# This would trigger a debug assertion that is just an error in release builds
+CREATE TABLE t1(c1 INT KEY) ENGINE=ROCKSDB;
+SET rocksdb_bulk_load=1;
+--error ER_KEYS_OUT_OF_ORDER
+INSERT INTO t1 VALUES (),(),();
+SET rocksdb_bulk_load=0;
+DROP TABLE t1;
+
+# Crash when table open cache closes handler with bulk load operation not finalized
+SET @orig_table_open_cache=@@global.table_open_cache;
+CREATE TABLE t1(a INT AUTO_INCREMENT, b INT, PRIMARY KEY (a)) ENGINE=ROCKSDB DEFAULT CHARSET=latin1;
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES(13, 0);
+INSERT INTO t1 VALUES(2, 'test 2');
+INSERT INTO t1 VALUES(@id, @arg04);
+SET @@global.table_open_cache=FALSE;
+INSERT INTO t1 VALUES(51479+0.333333333,1);
+DROP TABLE t1;
+SET @@global.table_open_cache=@orig_table_open_cache;
+
+--let SEARCH_FILE=$LOG3
+--let SEARCH_PATTERN=RocksDB: Error [0-9]+ finalizing bulk load while closing handler
+--source include/search_pattern_in_file.inc
+
+--source include/restart_mysqld.inc
+
+--remove_file $LOG3
+
+# Switch between tables, but also introduce duplicate key errors
+CREATE TABLE t1 (pk INT, PRIMARY KEY (pk)) ENGINE=ROCKSDB;
+CREATE TABLE t2 (pk INT, PRIMARY KEY (pk)) ENGINE=ROCKSDB;
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 VALUES (1), (2);
+INSERT INTO t2 VALUES (1), (2);
+INSERT INTO t1 VALUES (1);
+--error ER_OVERLAPPING_KEYS
+INSERT INTO t2 VALUES (3);
+SET rocksdb_bulk_load=0;
+DROP TABLE t1;
+DROP TABLE t2;
+
+--source include/wait_until_count_sessions.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_rev_cf.test b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_rev_cf.test
new file mode 100644
index 00000000..f011964d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_rev_cf.test
@@ -0,0 +1,10 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+--source include/big_test.inc
+
+--let pk_cf=rev:cf1
+--let pk_cf_name=cf1
+--let data_order_desc=0
+
+--source ../include/bulk_load.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_rev_cf_and_data.test b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_rev_cf_and_data.test
new file mode 100644
index 00000000..37f19a39
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_rev_cf_and_data.test
@@ -0,0 +1,10 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+--source include/big_test.inc
+
+--let pk_cf=rev:cf1
+--let pk_cf_name=cf1
+--let data_order_desc=1
+
+--source ../include/bulk_load.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_rev_data.test b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_rev_data.test
new file mode 100644
index 00000000..4f3ffd23
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_rev_data.test
@@ -0,0 +1,10 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+--source include/big_test.inc
+
+--let pk_cf=cf1
+--let pk_cf_name=cf1
+--let data_order_desc=1
+
+--source ../include/bulk_load.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_sk.test b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_sk.test
new file mode 100644
index 00000000..0fb47f74
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_sk.test
@@ -0,0 +1,119 @@
+--source include/have_rocksdb.inc
+
+SET rocksdb_bulk_load_size=15;
+
+CREATE TABLE t4 (a INT, b INT, c INT,
+ PRIMARY KEY (a),
+ KEY (b),
+ KEY (c) COMMENT "rev:cf") ENGINE=ROCKSDB;
+CREATE TABLE t3 (a INT, b INT, c INT,
+ PRIMARY KEY (a),
+ KEY (b),
+ KEY (c) COMMENT "rev:cf") ENGINE=ROCKSDB;
+CREATE TABLE t2 (a INT, b INT, c INT,
+ PRIMARY KEY (a),
+ KEY (b),
+ KEY (c) COMMENT "rev:cf") ENGINE=ROCKSDB;
+CREATE TABLE t1 (a INT, b INT, c INT,
+ PRIMARY KEY (a),
+ KEY (b),
+ KEY (c) COMMENT "rev:cf") ENGINE=ROCKSDB;
+
+### Setup the control table ###
+--disable_query_log
+let $sign = 1;
+let $max = 10;
+let $i = 1;
+while ($i <= $max) {
+ let $a = 1 + $sign * $i;
+ let $b = 1 - $sign * $i;
+ let $sign = -$sign;
+ let $insert = INSERT INTO t3 VALUES ($a, $b, $b);
+ eval $insert;
+ inc $i;
+}
+--enable_query_log
+
+### Bulk load PK only ###
+SET rocksdb_bulk_load=1;
+INSERT INTO t1 SELECT * FROM t3 FORCE INDEX (PRIMARY) ORDER BY a;
+SELECT count(*) FROM t1 FORCE INDEX (PRIMARY);
+SELECT count(*) FROM t1 FORCE INDEX (b);
+SELECT count(*) FROM t1 FORCE INDEX (c);
+SET rocksdb_bulk_load=0;
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+SELECT b FROM t1 FORCE INDEX (b);
+SELECT c FROM t1 FORCE INDEX (c);
+--echo Checksums should match
+CHECKSUM TABLE t3;
+CHECKSUM TABLE t1;
+
+### Bulk load PK and SK but require PK order ###
+SET rocksdb_bulk_load_allow_sk=1;
+SET rocksdb_bulk_load=1;
+INSERT INTO t4 SELECT * FROM t3 FORCE INDEX (PRIMARY) ORDER BY a;
+SELECT count(*) FROM t4 FORCE INDEX (PRIMARY);
+SELECT count(*) FROM t4 FORCE INDEX (b);
+SELECT count(*) FROM t4 FORCE INDEX (c);
+SET rocksdb_bulk_load=0;
+SELECT * FROM t4 FORCE INDEX (PRIMARY);
+SELECT b FROM t4 FORCE INDEX (b);
+SELECT c FROM t4 FORCE INDEX (c);
+--echo Checksums should match
+CHECKSUM TABLE t3;
+CHECKSUM TABLE t4;
+
+### Bulk load both PK and SK in random order for all ###
+SET rocksdb_bulk_load_allow_unsorted=1;
+SET rocksdb_bulk_load_allow_sk=1;
+SET rocksdb_bulk_load=1;
+
+INSERT INTO t2 SELECT * FROM t3 WHERE b >= 0 ORDER BY b;
+INSERT INTO t2 SELECT * FROM t3 WHERE b < 0 ORDER BY b;
+SELECT count(*) FROM t2 FORCE INDEX (PRIMARY);
+SELECT count(*) FROM t2 FORCE INDEX (b);
+SELECT count(*) FROM t2 FORCE INDEX (c);
+
+--disable_query_log
+let $sign = 1;
+let $max = 20;
+let $i = 11;
+while ($i <= $max) {
+ let $a = 1 + $sign * $i;
+ let $b = 1 - $sign * $i;
+ let $sign = -$sign;
+ let $insert = INSERT INTO t2 VALUES ($a, $b, $b);
+ eval $insert;
+ inc $i;
+}
+--enable_query_log
+SELECT count(*) FROM t2 FORCE INDEX (PRIMARY);
+SELECT count(*) FROM t2 FORCE INDEX (b);
+SELECT count(*) FROM t2 FORCE INDEX (c);
+SET rocksdb_bulk_load=0;
+
+--disable_query_log
+let $sign = 1;
+let $max = 20;
+let $i = 11;
+while ($i <= $max) {
+ let $a = 1 + $sign * $i;
+ let $b = 1 - $sign * $i;
+ let $sign = -$sign;
+ let $insert = INSERT INTO t3 VALUES ($a, $b, $b);
+ eval $insert;
+ inc $i;
+}
+--enable_query_log
+
+SELECT * FROM t2 FORCE INDEX (PRIMARY);
+SELECT b FROM t2 FORCE INDEX (b);
+SELECT c FROM t2 FORCE INDEX (c);
+--echo Checksums should match
+CHECKSUM TABLE t3;
+CHECKSUM TABLE t2;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_unsorted.test b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_unsorted.test
new file mode 100644
index 00000000..2abeae34
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_unsorted.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+--let pk_cf=cf1
+
+--source ../include/bulk_load_unsorted.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_unsorted_errors.test b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_unsorted_errors.test
new file mode 100644
index 00000000..eee4f713
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_unsorted_errors.test
@@ -0,0 +1,8 @@
+--source include/have_rocksdb.inc
+--source include/not_debug.inc
+
+# Cannot change unsorted input preference during bulk load
+SET rocksdb_bulk_load=1;
+--error ER_ERROR_WHEN_EXECUTING_COMMAND
+SET rocksdb_bulk_load_allow_unsorted=1;
+SET rocksdb_bulk_load=0;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_unsorted_rev.test b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_unsorted_rev.test
new file mode 100644
index 00000000..de9a5c26
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bulk_load_unsorted_rev.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+
+--let pk_cf=rev:cf1
+
+--source ../include/bulk_load_unsorted.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic.inc b/storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic.inc
new file mode 100644
index 00000000..1f5c9fbb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic.inc
@@ -0,0 +1,213 @@
+--source include/have_rocksdb.inc
+
+--source ../include/bypass_create_table.inc
+
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+SELECT /*+ no_bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+SELECT id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+
+SELECT /*+bypassabc*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+SELECT /*+bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+SELECT /* +bypassabc*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+SELECT /*aaaaaaaaabbbbbbbbb*/ id1,id2,id1_type,id2_type,data,version
+from link_table WHERE id1=1 and id2=2 and link_type=3;
+SELECT /*+*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+SELECT /*+b*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+SELECT /*+byp*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+SELECT /*+bypw*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+SELECT /*-b*/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+SELECT /**/ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+
+--echo # Point query
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2 IN (2, 3, 4) and link_type=3;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2 IN (2) and link_type=3;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1 IN (1) and id2 IN (2) and link_type=3;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1 IN (1, 2) and id2 IN (2, 3, 4) and link_type=3;
+
+--echo # Prefix range query
+
+--echo # Prefix range query with SK
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 3 AND time = 10
+ORDER BY TIME DESC LIMIT 10;
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 3 AND time = 10
+ORDER BY TIME ASC LIMIT 10;
+
+--echo # Prefix range query with SK with limits
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 10;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 5;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 0;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 0,10;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 0,5;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 0,1;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1,0;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1,10;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1,5;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1,1;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 1,0;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 5,10;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 5,5;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 5,1;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 5,0;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 10,10;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 10,5;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 10,1;
+
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (id1_type)
+WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
+ORDER BY TIME DESC LIMIT 10,0;
+
+--echo # Prefix range query with PK
+SELECT /*+ bypass */ id1, id2, link_type FROM link_table FORCE INDEX (PRIMARY)
+WHERE link_type=3 and id1=1 ORDER BY id2 DESC;
+SELECT /*+ bypass */ id1, id2, link_type FROM link_table FORCE INDEX (PRIMARY)
+WHERE link_type=3 and id1=1 ORDER BY id2 ASC;
+
+--echo # Prefix range query with PK + value
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (PRIMARY)
+WHERE link_type=3 and id1=1 ORDER BY id2 DESC;
+SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
+FROM link_table FORCE INDEX (PRIMARY)
+WHERE link_type=3 and id1=1 ORDER BY id2 ASC;
+
+--echo # Transaction
+BEGIN;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+UPDATE link_table set data="bcd" WHERE id1=1 and id2=2 and link_type = 3;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+COMMIT;
+
+BEGIN;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+UPDATE link_table set data="cde" WHERE id1=1 and id2=2 and link_type = 3;
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+ROLLBACK;
+
+SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version from link_table
+WHERE id1=1 and id2=2 and link_type=3;
+
+--echo # Data types
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3";
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3" AND id1="1";
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3" AND id1=True;
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3" AND id1=b'1';
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3" AND id1=x'01';
+SELECT /*+ bypass */ id1 FROM link_table where link_type="3" AND id1=NULL;
+
+DROP TABLE count_table;
+DROP TABLE link_table;
+DROP TABLE link_table3;
+DROP TABLE link_table2;
+DROP TABLE id_table;
+DROP TABLE node_table;
+DROP TABLE link_table5;
+DROP TABLE link_table6;
+DROP TABLE link_table4;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic.test b/storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic.test
new file mode 100644
index 00000000..51064356
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic.test
@@ -0,0 +1,3 @@
+--source include/have_rocksdb.inc
+
+--source bypass_select_basic.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic_bloom-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic_bloom-master.opt
new file mode 100644
index 00000000..81bc90b0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic_bloom-master.opt
@@ -0,0 +1,3 @@
+--rocksdb_default_cf_options=write_buffer_size=128m;target_file_size_base=32m;max_bytes_for_level_base=512m;level0_file_num_compaction_trigger=4;level0_slowdown_writes_trigger=20;level0_stop_writes_trigger=30;max_write_buffer_number=4;compression_per_level=kLZ4Compression;bottommost_compression=kZSTD;compression_opts=-14:6:0;block_based_table_factory={cache_index_and_filter_blocks=1;filter_policy=bloomfilter:10:false;whole_key_filtering=0};prefix_extractor=capped:12;level_compaction_dynamic_level_bytes=true;optimize_filters_for_hits=true;memtable_prefix_bloom_size_ratio=0.039;max_compaction_bytes=402653184;report_bg_io_stats=true;compaction_pri=kMinOverlappingRatio;soft_pending_compaction_bytes_limit=20480000000
+--rocksdb_override_cf_options=cf_assoc={prefix_extractor=capped:28};cf_assoc_count={prefix_extractor=capped:20};rev:cf_assoc_id1_type={prefix_extractor=capped:20};cf_fbobj_type_id={prefix_extractor=capped:16};cf_assoc_disagg={prefix_extractor=capped:20};__system__={write_buffer_size=16m};
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic_bloom.test b/storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic_bloom.test
new file mode 100644
index 00000000..51064356
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bypass_select_basic_bloom.test
@@ -0,0 +1,3 @@
+--source include/have_rocksdb.inc
+
+--source bypass_select_basic.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bytes_written.test b/storage/rocksdb/mysql-test/rocksdb/t/bytes_written.test
new file mode 100644
index 00000000..f0361707
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/bytes_written.test
@@ -0,0 +1,22 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS stats_test_table;
+--enable_warnings
+
+# Create the table
+CREATE TABLE stats_test_table (a INT, b INT, PRIMARY KEY (a)) ENGINE=ROCKSDB;
+
+# Ensure appropriate perf_context_level is set
+SET GLOBAL rocksdb_perf_context_level=3;
+
+# Insert some values
+INSERT INTO stats_test_table VALUES (7,1);
+INSERT INTO stats_test_table VALUES (2,2);
+
+# Verify the bytes written are updated in the table stats
+SELECT io_write_bytes > 0 FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME = "stats_test_table";
+
+# Cleanup
+DROP TABLE stats_test_table;
+SET GLOBAL rocksdb_perf_context_level=DEFAULT;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/cardinality-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/cardinality-master.opt
new file mode 100644
index 00000000..2cd3c805
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/cardinality-master.opt
@@ -0,0 +1,3 @@
+--skip-rocksdb_debug_optimizer_no_zero_cardinality
+--rocksdb_compaction_sequential_deletes=0
+--rocksdb_table_stats_sampling_pct=100
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/cardinality.test b/storage/rocksdb/mysql-test/rocksdb/t/cardinality.test
new file mode 100644
index 00000000..1dcb176e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/cardinality.test
@@ -0,0 +1,119 @@
+--source include/have_rocksdb.inc
+
+--source include/restart_mysqld.inc
+
+set use_stat_tables= 'COMPLEMENTARY';
+
+# Test memtable cardinality statistics
+CREATE TABLE t0 (id int PRIMARY KEY, a int, INDEX ix_a (a)) engine=rocksdb;
+
+# populate the table with 10 reconds where cardinality of id is N and a is N/2.
+insert into t0 values (0, 0),(1, 1),(2, 2),(3, 3),(4, 4),
+(5, 4),(6, 4),(7, 4),(8, 4),(9, 4);
+
+# Assert no cardinality data exists before ANALYZE TABLE is done
+SELECT cardinality FROM information_schema.statistics where table_name="t0" and
+column_name="id";
+SELECT cardinality FROM information_schema.statistics where table_name="t0" and
+column_name="a";
+
+--disable_result_log
+ANALYZE TABLE t0;
+--enable_result_log
+
+SELECT table_rows into @N FROM information_schema.tables
+WHERE table_name = "t0";
+SELECT FLOOR(@N/cardinality) FROM
+information_schema.statistics where table_name="t0" and column_name="id";
+SELECT FLOOR(@N/cardinality) FROM
+information_schema.statistics where table_name="t0" and column_name="a";
+
+# Flush the table and re-run the test as statistics is calculated a bit
+# differently for memtable and SST files
+SET GLOBAL rocksdb_force_flush_memtable_now = 1;
+--disable_result_log
+ANALYZE TABLE t0;
+--enable_result_log
+
+SELECT table_rows into @N FROM information_schema.tables
+WHERE table_name = "t0";
+SELECT FLOOR(@N/cardinality) FROM
+information_schema.statistics where table_name="t0" and column_name="id";
+SELECT FLOOR(@N/cardinality) FROM
+information_schema.statistics where table_name="t0" and column_name="a";
+
+drop table t0;
+
+# Test big table on SST
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t10,t11;
+--enable_warnings
+
+create table t1(
+ id bigint not null primary key,
+ i1 bigint, #unique
+ i2 bigint, #repeating
+ c1 varchar(20), #unique
+ c2 varchar(20), #repeating
+ index t1_1(id, i1),
+ index t1_2(i1, i2),
+ index t1_3(i2, i1),
+ index t1_4(c1, c2),
+ index t1_5(c2, c1)
+) engine=rocksdb;
+
+--disable_query_log
+create table t10(a int primary key);
+insert into t10 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t11(a int primary key);
+insert into t11 select A.a + B.a* 10 + C.a * 100 from t10 A, t10 B, t10 C;
+
+set @a=0;
+let $i=0;
+set rocksdb_bulk_load=1;
+while ($i<100)
+{
+ inc $i;
+ eval insert into t1 select (@a:=@a+1), @a, @a div 10, @a, @a div 10 from t11;
+}
+set rocksdb_bulk_load=0;
+
+drop table t10;
+drop table t11;
+--enable_query_log
+
+# Flush memtable out to SST and display index cardinalities
+optimize table t1;
+show index in t1;
+SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE();
+
+--echo restarting...
+--source include/restart_mysqld.inc
+
+# display index cardinalities after the restart
+show index in t1;
+SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE();
+
+CREATE TABLE t2 (a INT, b INT, c INT, d INT, e INT, f INT, g INT,
+ PRIMARY KEY (a), KEY (c, b, a, d, e, f, g))
+ ENGINE=ROCKSDB;
+--disable_query_log
+let $i=0;
+while ($i<100)
+{
+ inc $i;
+ eval insert t2 values($i, $i div 10, 1, 1, 1, 1, 1);
+}
+--enable_query_log
+
+# Cardinality of key c should be 1 for c, 10 for b, 100 for a and the other fields.
+SET GLOBAL rocksdb_force_flush_memtable_now = 1;
+ANALYZE TABLE t2;
+--echo cardinality of the columns after 'a' must be equal to the cardinality of column 'a'
+SELECT CARDINALITY INTO @c FROM information_schema.statistics WHERE TABLE_NAME='t2' AND INDEX_NAME='c' AND COLUMN_NAME='a';
+SELECT COLUMN_NAME, CARDINALITY = @c FROM information_schema.statistics WHERE TABLE_NAME='t2' AND INDEX_NAME='c' AND SEQ_IN_INDEX > 3;
+
+drop table t1, t2;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/check_flags.test b/storage/rocksdb/mysql-test/rocksdb/t/check_flags.test
new file mode 100644
index 00000000..9afe562f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/check_flags.test
@@ -0,0 +1,117 @@
+--source include/have_rocksdb.inc
+--source include/have_debug_sync.inc
+
+set debug_sync='RESET';
+set global rocksdb_debug_ttl_read_filter_ts = -10;
+
+connect (conn1, localhost, root,,);
+--let $conn1_id = `SELECT CONNECTION_ID()`
+connection default;
+
+CREATE TABLE t1 (id INT, value INT, KEY (id), KEY (value)) ENGINE=ROCKSDB;
+CREATE TABLE t2 (id INT, value INT) ENGINE=ROCKSDB;
+CREATE TABLE t3 (id INT, kp1 INT, PRIMARY KEY (id), KEY(kp1)) ENGINE=ROCKSDB COMMENT='ttl_duration=1';
+
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4), (5,5);
+INSERT INTO t2 SELECT * FROM t1;
+INSERT INTO t3 SELECT * FROM t1;
+
+connection conn1;
+set debug_sync='rocksdb.check_flags_rmi SIGNAL parked WAIT_FOR go';
+send SELECT value FROM t1 WHERE value = 3;
+
+connection default;
+set debug_sync='now WAIT_FOR parked';
+--echo KILL QUERY \$conn1_id;
+--disable_query_log
+eval KILL QUERY $conn1_id;
+--enable_query_log
+set debug_sync='now SIGNAL go';
+
+connection conn1;
+--error ER_QUERY_INTERRUPTED
+--reap
+
+set debug_sync='RESET';
+
+connection conn1;
+set debug_sync='rocksdb.check_flags_rmi_scan SIGNAL parked WAIT_FOR go';
+send SELECT DISTINCT(id) FROM t1 WHERE value = 5 AND id IN (1, 3, 5);
+
+connection default;
+set debug_sync='now WAIT_FOR parked';
+--echo KILL QUERY \$conn1_id;
+--disable_query_log
+eval KILL QUERY $conn1_id;
+--enable_query_log
+set debug_sync='now SIGNAL go';
+
+connection conn1;
+--error ER_QUERY_INTERRUPTED
+--reap
+
+set debug_sync='RESET';
+
+connection conn1;
+set debug_sync='rocksdb.check_flags_inwd SIGNAL parked WAIT_FOR go';
+send SELECT value FROM t1 WHERE value > 3;
+
+connection default;
+set debug_sync='now WAIT_FOR parked';
+--echo KILL QUERY \$conn1_id;
+--disable_query_log
+eval KILL QUERY $conn1_id;
+--enable_query_log
+set debug_sync='now SIGNAL go';
+
+connection conn1;
+--error ER_QUERY_INTERRUPTED
+--reap
+
+set debug_sync='RESET';
+
+connection conn1;
+set debug_sync='rocksdb.check_flags_rnwd SIGNAL parked WAIT_FOR go';
+send SELECT id FROM t2;
+
+connection default;
+set debug_sync='now WAIT_FOR parked';
+--echo KILL QUERY \$conn1_id;
+--disable_query_log
+eval KILL QUERY $conn1_id;
+--enable_query_log
+set debug_sync='now SIGNAL go';
+
+connection conn1;
+--error ER_QUERY_INTERRUPTED
+--reap
+
+set debug_sync='RESET';
+
+
+connection conn1;
+set debug_sync='rocksdb.check_flags_ser SIGNAL parked WAIT_FOR go';
+send SELECT kp1 FROM t3 ORDER BY kp1;
+
+connection default;
+set debug_sync='now WAIT_FOR parked';
+--echo KILL QUERY \$conn1_id;
+--disable_query_log
+eval KILL QUERY $conn1_id;
+--enable_query_log
+set debug_sync='now SIGNAL go';
+
+connection conn1;
+--error ER_QUERY_INTERRUPTED
+--reap
+
+connection default;
+--disconnect conn1
+
+set debug_sync='RESET';
+
+set global rocksdb_debug_ttl_read_filter_ts = DEFAULT;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/check_ignore_unknown_options.test b/storage/rocksdb/mysql-test/rocksdb/t/check_ignore_unknown_options.test
new file mode 100644
index 00000000..15a7d319
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/check_ignore_unknown_options.test
@@ -0,0 +1,56 @@
+--disable_warnings
+let $MYSQLD_DATADIR= `select @@datadir`;
+let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
+let $error_log= $MYSQLTEST_VARDIR/log/my_restart.err;
+select variable_name, variable_value from information_schema.global_variables where variable_name="rocksdb_ignore_unknown_options";
+
+#
+# MariaDB: The following shell commands are not portable so we are
+# using perl instead:
+#--exec find $MYSQLD_DATADIR/#rocksdb/OPTIONS* | sort -t- -k 2 -n | tail -1 | xargs -0 -I {} -t sh -c "sed -i 's/rocksdb_version=.*/rocksdb_version=99.9.9/' {}"
+#--exec find $MYSQLD_DATADIR/#rocksdb/OPTIONS* | sort -t- -k 2 -n | tail -1 | xargs -0 -I {} -t sh -c "echo hello=world>>{}"
+
+perl;
+ my $path=$ENV{MYSQLTEST_VARDIR} . "/mysqld.1/data/\#rocksdb";
+ opendir(my $dh, $path) || die "Can't opendir $some_dir: $!";
+ my @files = grep { /^OPTIONS/ } readdir($dh);
+ closedir($dh);
+
+ sub compare_second_as_number {
+ local $aa= shift;
+ local $bb= shift;
+ $aa =~ s/OPTIONS-//;
+ $bb =~ s/OPTIONS-//;
+ return $aa <=> $bb;
+ }
+
+ @sorted_files = sort { compare_second_as_number($a, $b); } @files;
+ my $last_file= $sorted_files[-1];
+
+ my $contents="";
+ open(my $fh, "<", "$path/$last_file") || die ("Couldn't open $path/$last_file");
+ while (<$fh>) {
+ $_ =~ s/rocksdb_version=.*/rocksdb_version=99.9.9/;
+ $contents .= $_;
+ }
+ close($fh);
+ $contents .= "hello=world\n";
+ open(my $fh, ">", "$path/$last_file") || die("Can't open $path/$file for writing");
+ print $fh $contents;
+ close($fh);
+EOF
+
+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--shutdown_server
+
+--error 1
+--exec $MYSQLD_CMD --plugin_load=$HA_ROCKSDB_SO --rocksdb_ignore_unknown_options=0 --log-error=$error_log
+
+let SEARCH_FILE= $error_log;
+let SEARCH_PATTERN= RocksDB: Compatibility check against existing database options failed;
+--source include/search_pattern_in_file.inc
+--remove_file $error_log
+--enable_reconnect
+--exec echo "restart" > $restart_file
+--source include/wait_until_connected_again.inc
+select variable_name, variable_value from information_schema.global_variables where variable_name="rocksdb_ignore_unknown_options";
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/check_log_for_xa.py b/storage/rocksdb/mysql-test/rocksdb/t/check_log_for_xa.py
new file mode 100644
index 00000000..a3d50f30
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/check_log_for_xa.py
@@ -0,0 +1,31 @@
+import sys
+import re
+
+"""
+Example usage:
+ python check_log_for_xa.py path/to/log/mysqld.2.err rollback,commit,prepare
+"""
+
+log_path = sys.argv[1]
+desired_filters = sys.argv[2]
+
+all_filters = [
+ ('rollback', re.compile('(\[Note\] rollback xid .+)')),
+ ('commit', re.compile('(\[Note\] commit xid .+)')),
+ ('prepare',
+ re.compile('(\[Note\] Found \d+ prepared transaction\(s\) in \w+)')),
+]
+
+active_filters = filter(lambda f: f[0] in desired_filters, all_filters)
+
+results = set()
+with open(log_path) as log:
+ for line in log:
+ line = line.strip()
+ for f in active_filters:
+ match = f[1].search(line)
+ if match:
+ results.add("**found '%s' log entry**" % f[0])
+
+for res in results:
+ print res
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/check_table.inc b/storage/rocksdb/mysql-test/rocksdb/t/check_table.inc
new file mode 100644
index 00000000..c108a973
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/check_table.inc
@@ -0,0 +1,54 @@
+#
+# CHECK TABLE statements
+#
+# Note: the output is likely to be different for the engine under test,
+# in which case rdiff will be needed. Or, the output might say that
+# the storage engine does not support CHECK.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+
+CREATE TABLE t2 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+
+CHECK TABLE t1;
+INSERT INTO t1 (a,b) VALUES (3,'c');
+INSERT INTO t2 (a,b) VALUES (4,'d');
+CHECK TABLE t1, t2 FOR UPGRADE;
+INSERT INTO t2 (a,b) VALUES (5,'e');
+CHECK TABLE t2 QUICK;
+INSERT INTO t1 (a,b) VALUES (6,'f');
+CHECK TABLE t1 FAST;
+INSERT INTO t1 (a,b) VALUES (7,'g');
+INSERT INTO t2 (a,b) VALUES (8,'h');
+CHECK TABLE t2, t1 MEDIUM;
+INSERT INTO t1 (a,b) VALUES (9,'i');
+INSERT INTO t2 (a,b) VALUES (10,'j');
+CHECK TABLE t1, t2 EXTENDED;
+INSERT INTO t1 (a,b) VALUES (11,'k');
+CHECK TABLE t1 CHANGED;
+
+DROP TABLE t1, t2;
+
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, KEY(a)) ENGINE=rocksdb;
+INSERT INTO t1 (a) VALUES (1),(2),(5);
+CHECK TABLE t1;
+INSERT INTO t1 (a) VALUES (6),(8),(12);
+CHECK TABLE t1 FOR UPGRADE;
+INSERT INTO t1 (a) VALUES (13),(15),(16);
+CHECK TABLE t1 QUICK;
+INSERT INTO t1 (a) VALUES (17),(120),(132);
+CHECK TABLE t1 FAST;
+INSERT INTO t1 (a) VALUES (801),(900),(7714);
+CHECK TABLE t1 MEDIUM;
+INSERT INTO t1 (a) VALUES (8760),(10023),(12000);
+CHECK TABLE t1 EXTENDED;
+INSERT INTO t1 (a) VALUES (13345),(24456),(78302),(143028);
+CHECK TABLE t1 CHANGED;
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/check_table.test b/storage/rocksdb/mysql-test/rocksdb/t/check_table.test
new file mode 100644
index 00000000..4d349f7a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/check_table.test
@@ -0,0 +1,12 @@
+--source include/have_rocksdb.inc
+
+#
+# CHECK TABLE statements
+#
+# Note: the output is likely to be different for the engine under test,
+# in which case rdiff will be needed. Or, the output might say that
+# the storage engine does not support CHECK.
+#
+
+--source check_table.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/checkpoint.test b/storage/rocksdb/mysql-test/rocksdb/t/checkpoint.test
new file mode 100644
index 00000000..68fe02bb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/checkpoint.test
@@ -0,0 +1,107 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+--enable_warnings
+
+# Start from clean slate
+#--source include/restart_mysqld.inc
+
+CREATE TABLE t1 (
+ a int not null,
+ b int not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+CREATE TABLE t2 (
+ a int not null,
+ b int not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+CREATE TABLE t3 (
+ a int not null,
+ b int not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+CREATE TABLE t4 (
+ a int not null,
+ b int not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+# Populate tables
+let $max = 1000;
+let $table = t1;
+--source drop_table_repopulate_table.inc
+let $table = t2;
+--source drop_table_repopulate_table.inc
+let $table = t3;
+--source drop_table_repopulate_table.inc
+let $table = t4;
+--source drop_table_repopulate_table.inc
+
+# Make sure new table gets unique indices
+CREATE TABLE t5 (
+ a int not null,
+ b int not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+let $max = 1000;
+let $table = t5;
+--source drop_table_repopulate_table.inc
+
+# Create checkpoint without trailing '/'
+let $checkpoint = $MYSQL_TMP_DIR/checkpoint;
+let $succeeds = 1;
+--source set_checkpoint.inc
+
+# Create checkpoint with a trailing '/'
+let $checkpoint = $MYSQL_TMP_DIR/checkpoint/;
+let $succeeds = 1;
+--source set_checkpoint.inc
+
+# Set checkpoint dir as empty string, which fails
+let $checkpoint = ;
+let $succeeds = 0;
+--source set_checkpoint.inc
+
+# Set checkpoint as a directory that does not exist, which fails
+let $checkpoint = /does/not/exist;
+let $succeeds = 0;
+--source set_checkpoint.inc
+
+# Set checkpoint as a directory that already exists, which fails
+let $checkpoint = $MYSQL_TMP_DIR/already-existing-directory;
+--mkdir $checkpoint
+let $succeeds = 0;
+--source set_checkpoint.inc
+rmdir $checkpoint;
+
+--disable_result_log
+truncate table t1;
+optimize table t1;
+truncate table t2;
+optimize table t2;
+truncate table t3;
+optimize table t3;
+truncate table t4;
+optimize table t4;
+truncate table t5;
+optimize table t5;
+drop table if exists t1;
+drop table if exists t2;
+drop table if exists t3;
+drop table if exists t4;
+drop table if exists t5;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/checksum_table.test b/storage/rocksdb/mysql-test/rocksdb/t/checksum_table.test
new file mode 100644
index 00000000..51c639a8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/checksum_table.test
@@ -0,0 +1,84 @@
+--source include/have_rocksdb.inc
+
+#
+# CHECKSUM TABLE statements for standard CHECKSUM properties.
+# Live checksums are covered in checksum_table_live.test
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb CHECKSUM=0;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+
+CREATE TABLE t2 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb CHECKSUM=0;
+
+CHECKSUM TABLE t1;
+CHECKSUM TABLE t2, t1;
+CHECKSUM TABLE t1, t2 QUICK;
+CHECKSUM TABLE t1, t2 EXTENDED;
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # Issue #110: SQL command checksum returns inconsistent result
+--echo #
+create table t1 (pk int primary key, col1 varchar(10)) engine=rocksdb;
+insert into t1 values (2,'fooo');
+insert into t1 values (1,NULL);
+checksum table t1;
+checksum table t1;
+select * from t1 where pk=2;
+checksum table t1;
+checksum table t1;
+flush tables;
+checksum table t1;
+checksum table t1;
+
+drop table t1;
+
+--echo #
+--echo # The following test is about making sure MyRocks CHECKSUM TABLE
+--echo # values are the same as with InnoDB.
+--echo # If you see checksum values changed, make sure their counterparts
+--echo # in suite/innodb/r/checksum-matches-myrocks.result match.
+--echo #
+
+create table t1 (pk int primary key, col1 varchar(10)) engine=rocksdb;
+insert into t1 values (2,'fooo');
+insert into t1 values (1,NULL);
+checksum table t1;
+drop table t1;
+
+create table t1 (
+ pk bigint unsigned primary key,
+ col1 varchar(10),
+ col2 tinyint,
+ col3 double
+) engine=rocksdb;
+
+--echo # MariaDB has changed the checksumming algorithm
+--echo # Enable the old algorithm:
+set @tmp_old=@@old;
+set old=1;
+
+
+checksum table t1;
+
+insert into t1 values (1, NULL, NULL, NULL);
+insert into t1 values (2, 'foo', NULL, NULL);
+checksum table t1;
+
+insert into t1 values (3, NULL, 123, NULL);
+insert into t1 values (4, NULL, NULL, 2.78);
+checksum table t1;
+
+insert into t1 values (5, 'xxxYYYzzzT', NULL, 2.78);
+insert into t1 values (6, '', NULL, 2.78);
+checksum table t1;
+
+set old=@tmp_old;
+
+drop table t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/checksum_table_live.test b/storage/rocksdb/mysql-test/rocksdb/t/checksum_table_live.test
new file mode 100644
index 00000000..da278ed7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/checksum_table_live.test
@@ -0,0 +1,24 @@
+--source include/have_rocksdb.inc
+
+#
+# CHECKSUM TABLE statements for live CHECKSUM.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+# For most engines CHECKSUM=1 option will be ignored,
+# and the results will be different
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb CHECKSUM=1;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb CHECKSUM=1;
+
+CHECKSUM TABLE t1;
+CHECKSUM TABLE t2, t1;
+CHECKSUM TABLE t1, t2 QUICK;
+CHECKSUM TABLE t1, t2 EXTENDED;
+
+DROP TABLE t1, t2;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/col_not_null.inc b/storage/rocksdb/mysql-test/rocksdb/t/col_not_null.inc
new file mode 100644
index 00000000..2d3c9292
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/col_not_null.inc
@@ -0,0 +1,55 @@
+#
+# NOT NULL attribute in columns
+#
+# Usage:
+# let $col_type = <column type>;
+# let $col_default = <default value for a column>;
+# --source col_not_null.inc
+#
+# We will add NOT NULL to the column options;
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo #----------------------------------
+--echo # $col_type NOT NULL columns without a default
+--echo #----------------------------------
+
+eval CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c $col_type NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+
+--error ER_BAD_NULL_ERROR
+INSERT INTO t1 (c) VALUES (NULL);
+eval INSERT INTO t1 (c) VALUES ($col_default);
+SELECT HEX(c) FROM t1;
+
+DROP TABLE t1;
+
+--echo #----------------------------------
+--echo # $col_type NOT NULL columns with a default
+--echo #----------------------------------
+
+eval CREATE TABLE t1 (
+ pk INT AUTO_INCREMENT PRIMARY KEY,
+ c $col_type NOT NULL DEFAULT $col_default
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+--error ER_INVALID_DEFAULT
+eval ALTER TABLE t1 ADD COLUMN err $col_type NOT NULL DEFAULT NULL;
+
+--error ER_BAD_NULL_ERROR
+INSERT INTO t1 (c) VALUES (NULL);
+
+eval INSERT INTO t1 (c) VALUES ($col_default);
+eval INSERT INTO t1 () VALUES ();
+
+# HEX should be universal for all column types
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+
+DROP TABLE t1;
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/col_not_null_timestamp.inc b/storage/rocksdb/mysql-test/rocksdb/t/col_not_null_timestamp.inc
new file mode 100644
index 00000000..812ada6f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/col_not_null_timestamp.inc
@@ -0,0 +1,70 @@
+#
+# NOT NULL attribute in TIMESTAMP columns
+#
+# This is a copy of col_not_null.inc, except that
+# instead of getting an error on inserting NULL into a non-NULL column,
+# we are getting the current timestamp (see MySQL:68472).
+# If the bug is ever fixed, this include file won't be needed anymore.
+
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo #----------------------------------
+--echo # $col_type NOT NULL column without a default
+--echo #----------------------------------
+
+eval CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c $col_type NOT NULL) ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+
+# Here where the non-standard behavior strikes:
+# instead of an error we are getting the current timestamp
+
+# As of mysql-5.6.11, this no longer works, and we get an error:
+# (MariaDB doesn't have this patch, so it doesnt produce an error):
+# --error ER_BAD_NULL_ERROR
+INSERT INTO t1 (c) VALUES (NULL);
+eval INSERT INTO t1 (c) VALUES ($col_default);
+SELECT HEX(c) FROM t1;
+
+DROP TABLE t1;
+
+--echo #----------------------------------
+--echo # $col_type NOT NULL columns with a default
+--echo #----------------------------------
+
+eval CREATE TABLE t1 (
+ pk INT AUTO_INCREMENT PRIMARY KEY,
+ c $col_type NOT NULL DEFAULT $col_default
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+--error ER_INVALID_DEFAULT
+eval ALTER TABLE t1 ADD COLUMN err $col_type NOT NULL DEFAULT NULL;
+
+# Here where the non-standard behavior strikes:
+# instead of an error we are getting the current timestamp
+
+# As of mysql-5.6.11, this no longer works, and we get an error:
+# (MariaDB doesn't have this patch, so it doesnt produce an error):
+# --error ER_BAD_NULL_ERROR
+
+# Since we don't produce an error, the row will get inserted. Make it
+# deterministic:
+set @save_ts=@@timestamp;
+set timestamp=1478923914;
+
+INSERT INTO t1 (c) VALUES (NULL);
+set timestamp=@save_ts;
+
+eval INSERT INTO t1 (c) VALUES ($col_default);
+eval INSERT INTO t1 () VALUES ();
+
+# HEX should be universal for all column types
+SELECT pk, HEX(c) FROM t1 ORDER BY pk;
+
+DROP TABLE t1;
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/col_null.inc b/storage/rocksdb/mysql-test/rocksdb/t/col_null.inc
new file mode 100644
index 00000000..7ebfee0b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/col_null.inc
@@ -0,0 +1,34 @@
+#
+# NULL attribute and DEFAULT NULL in columns
+#
+# Usage:
+# let $col_type = <column type>;
+# let $col_default = <default non-null value for a column>;
+# --source col_null.inc
+#
+# We will add NULL attribute to the column options.
+#
+
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+eval CREATE TABLE t1 (
+ c $col_type NULL,
+ c1 $col_type NULL DEFAULT NULL,
+ c2 $col_type NULL DEFAULT $col_default,
+ pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+INSERT INTO t1 (c,c1,c2) VALUES (NULL,NULL,NULL);
+eval INSERT INTO t1 (c,c1,c2) VALUES ($col_default,$col_default,$col_default);
+INSERT INTO t1 () VALUES ();
+
+SELECT pk, HEX(c), HEX(c1), HEX(c2) FROM t1 ORDER BY pk;
+SELECT pk, HEX(c2) FROM t1 ORDER BY pk;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/col_opt_default.test b/storage/rocksdb/mysql-test/rocksdb/t/col_opt_default.test
new file mode 100644
index 00000000..6f91ee7c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/col_opt_default.test
@@ -0,0 +1,27 @@
+--source include/have_rocksdb.inc
+
+#
+# Check whether DEFAULT column attribute
+# is supported in CREATE and ALTER TABLE.
+# If the attribute is supported at all, it will be covered
+# in more details in col_option_null and col_option_not_null tests.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT PRIMARY KEY DEFAULT '0') ENGINE=rocksdb;
+SHOW COLUMNS IN t1;
+
+INSERT INTO t1 (a) VALUES (1);
+SELECT a FROM t1;
+
+ALTER TABLE t1 ADD COLUMN b CHAR(8) DEFAULT '';
+SHOW COLUMNS IN t1;
+
+INSERT INTO t1 (b) VALUES ('a');
+SELECT a,b FROM t1 ORDER BY a,b;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/col_opt_not_null.test b/storage/rocksdb/mysql-test/rocksdb/t/col_opt_not_null.test
new file mode 100644
index 00000000..1de4ccee
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/col_opt_not_null.test
@@ -0,0 +1,229 @@
+--source include/have_rocksdb.inc
+
+#
+# NOT NULL column attribute
+#
+
+#########################################
+# TODO:
+# Currently the test produces incorrect (?) result
+# due to bug MySQL:68472. If the bug is ever fixed,
+# the test and result files will need to be updated.
+#########################################
+
+
+let $extra_col_opts = NOT NULL;
+
+--echo ########################
+--echo # BINARY columns
+--echo ########################
+
+--source type_binary.inc
+--let $col_type = BINARY
+--let $col_default = 0
+--source col_not_null.inc
+
+--echo ########################
+--echo # VARBINARY columns
+--echo ########################
+
+--source type_varbinary.inc
+--let $col_type = VARBINARY(64)
+--let $col_default = 'test'
+--source col_not_null.inc
+
+--echo ########################
+--echo # BIT columns
+--echo ########################
+
+--source type_bit.inc
+--let $col_type = BIT
+--let $col_default = 1
+--source col_not_null.inc
+
+--echo ########################
+--echo # BLOB columns
+--echo ########################
+
+--source type_blob.inc
+
+--let $col_default = ''
+
+--let $col_type = BLOB
+--source col_not_null.inc
+
+--let $col_type = TINYBLOB
+--source col_not_null.inc
+
+--let $col_type = MEDIUMBLOB
+--source col_not_null.inc
+
+--let $col_type = LONGBLOB
+--source col_not_null.inc
+
+--echo ########################
+--echo # BOOL columns
+--echo ########################
+
+--source type_bool.inc
+--let $col_type = BOOL
+--let $col_default = '0'
+--source col_not_null.inc
+
+--echo ########################
+--echo # CHAR columns
+--echo ########################
+
+--source type_char.inc
+--let $col_type = CHAR
+--let $col_default = '_'
+--source col_not_null.inc
+
+--echo ########################
+--echo # VARCHAR columns
+--echo ########################
+
+--source type_varchar.inc
+--let $col_type = VARCHAR(64)
+--let $col_default = 'test default'
+--source col_not_null.inc
+
+--echo ########################
+--echo # date and time columns
+--echo ########################
+
+set @col_opt_not_nullsave_time_zone=@@time_zone;
+set time_zone='UTC';
+
+--source type_date_time.inc
+
+SET TIMESTAMP=UNIX_TIMESTAMP('2013-12-12 12:12:12');
+
+--let $col_type = DATE
+--let $col_default = '2012-12-21'
+--source col_not_null.inc
+
+--let $col_type = DATETIME
+--let $col_default = '2012-12-21 12:21:12'
+--source col_not_null.inc
+
+# Even with explicit-defaults-for-timestamps, we still can't use
+# the standard include file, due to bug MySQL:68472
+
+--let $col_type = TIMESTAMP
+--let $col_default = '2012-12-21 12:21:12'
+--source col_not_null_timestamp.inc
+
+--let $col_type = TIME
+--let $col_default = '12:21:12'
+--source col_not_null.inc
+
+--let $col_type = YEAR
+--let $col_default = '2012'
+--source col_not_null.inc
+
+--let $col_type = YEAR(2)
+--let $col_default = '12'
+--source col_not_null.inc
+
+set time_zone= @col_opt_not_nullsave_time_zone;
+
+--echo ########################
+--echo # ENUM columns
+--echo ########################
+
+--source type_enum.inc
+
+--let $col_type = ENUM('test1','test2','test3')
+--let $col_default = 'test2'
+--source col_not_null.inc
+
+--echo ########################
+--echo # Fixed point columns (NUMERIC, DECIMAL)
+--echo ########################
+
+--source type_fixed.inc
+
+--let $col_type = DECIMAL
+--let $col_default = 1.1
+--source col_not_null.inc
+
+--let $col_type = NUMERIC
+--let $col_default = 0
+--source col_not_null.inc
+
+--echo ########################
+--echo # Floating point columns (FLOAT, DOUBLE)
+--echo ########################
+
+--source type_float.inc
+
+--let $col_type = FLOAT
+--let $col_default = 1.1
+--source col_not_null.inc
+
+--let $col_type = DOUBLE
+--let $col_default = 0
+--source col_not_null.inc
+
+--echo ########################
+--echo # INT columns
+--echo ########################
+
+--source type_int.inc
+
+--let $col_type = INT
+--let $col_default = 2147483647
+--source col_not_null.inc
+
+--let $col_type = TINYINT
+--let $col_default = 127
+--source col_not_null.inc
+
+--let $col_type = SMALLINT
+--let $col_default = 0
+--source col_not_null.inc
+
+--let $col_type = MEDIUMINT
+--let $col_default = 1
+--source col_not_null.inc
+
+--let $col_type = BIGINT
+--let $col_default = 9223372036854775807
+--source col_not_null.inc
+
+--echo ########################
+--echo # SET columns
+--echo ########################
+
+--source type_set.inc
+--let $col_type = SET('test1','test2','test3')
+--let $col_default = 'test2,test3'
+--source col_not_null.inc
+
+--echo ########################
+--echo # TEXT columns
+--echo ########################
+
+--source type_text.inc
+
+--let $col_default = ''
+
+--let $col_type = TEXT
+--source col_not_null.inc
+
+--let $col_type = TINYTEXT
+--source col_not_null.inc
+
+--let $col_type = MEDIUMTEXT
+--source col_not_null.inc
+
+--let $col_type = LONGTEXT
+--source col_not_null.inc
+
+
+--let $col_type =
+--let $col_default =
+--let $extra_col_opts =
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/col_opt_null.test b/storage/rocksdb/mysql-test/rocksdb/t/col_opt_null.test
new file mode 100644
index 00000000..c41abb78
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/col_opt_null.test
@@ -0,0 +1,220 @@
+--source include/have_rocksdb.inc
+
+#
+# NULL column attribute
+#
+
+let $extra_col_opts = NULL;
+
+
+--echo ########################
+--echo # BINARY columns
+--echo ########################
+
+--source type_binary.inc
+--let $col_type = BINARY
+--let $col_default = 0
+--source col_null.inc
+
+--echo ########################
+--echo # VARBINARY columns
+--echo ########################
+
+--source type_varbinary.inc
+--let $col_type = VARBINARY(64)
+--let $col_default = 'test'
+--source col_null.inc
+
+--echo ########################
+--echo # BIT columns
+--echo ########################
+
+--source type_bit.inc
+--let $col_type = BIT
+--let $col_default = 1
+--source col_null.inc
+
+--echo ########################
+--echo # BLOB columns
+--echo ########################
+
+--source type_blob.inc
+
+--let $col_default = ''
+
+--let $col_type = BLOB
+--source col_null.inc
+
+--let $col_type = TINYBLOB
+--source col_null.inc
+
+--let $col_type = MEDIUMBLOB
+--source col_null.inc
+
+--let $col_type = LONGBLOB
+--source col_null.inc
+
+--echo ########################
+--echo # BOOL columns
+--echo ########################
+
+--source type_bool.inc
+--let $col_type = BOOL
+--let $col_default = '0'
+--source col_null.inc
+
+
+--echo ########################
+--echo # CHAR columns
+--echo ########################
+
+--source type_char.inc
+--let $col_type = CHAR
+--let $col_default = '_'
+--source col_null.inc
+
+--echo ########################
+--echo # VARCHAR columns
+--echo ########################
+
+
+--source type_varchar.inc
+--let $col_type = VARCHAR(64)
+--let $col_default = 'test default'
+--source col_null.inc
+
+
+--echo ########################
+--echo # date and time columns
+--echo ########################
+
+set @col_opt_nullsave_time_zone=@@time_zone;
+set time_zone='UTC';
+
+--source type_date_time.inc
+
+--let $col_type = DATE
+--let $col_default = '2012-12-21'
+--source col_null.inc
+
+--let $col_type = DATETIME
+--let $col_default = '2012-12-21 12:21:12'
+--source col_null.inc
+
+--let $col_type = TIMESTAMP
+--let $col_default = '2012-12-21 12:21:12'
+--source col_null.inc
+
+--let $col_type = TIME
+--let $col_default = '12:21:12'
+--source col_null.inc
+
+--let $col_type = YEAR
+--let $col_default = '2012'
+--source col_null.inc
+
+--let $col_type = YEAR(2)
+--let $col_default = '12'
+--source col_null.inc
+
+set time_zone=@col_opt_nullsave_time_zone;
+
+--echo ########################
+--echo # ENUM columns
+--echo ########################
+
+--source type_enum.inc
+--let $col_type = ENUM('test1','test2','test3')
+--let $col_default = 'test2'
+--source col_null.inc
+
+--echo ########################
+--echo # Fixed point columns (NUMERIC, DECIMAL)
+--echo ########################
+
+--source type_fixed.inc
+
+--let $col_type = DECIMAL
+--let $col_default = 1.1
+--source col_null.inc
+
+--let $col_type = NUMERIC
+--let $col_default = 0
+--source col_null.inc
+
+--echo ########################
+--echo # Floating point columns (FLOAT, DOUBLE)
+--echo ########################
+
+--source type_float.inc
+
+--let $col_type = FLOAT
+--let $col_default = 1.1
+--source col_null.inc
+
+--let $col_type = DOUBLE
+--let $col_default = 0
+--source col_null.inc
+
+--echo ########################
+--echo # INT columns
+--echo ########################
+
+--source type_int.inc
+
+--let $col_type = INT
+--let $col_default = 2147483647
+--source col_null.inc
+
+--let $col_type = TINYINT
+--let $col_default = 127
+--source col_null.inc
+
+--let $col_type = SMALLINT
+--let $col_default = 0
+--source col_null.inc
+
+--let $col_type = MEDIUMINT
+--let $col_default = 1
+--source col_null.inc
+
+--let $col_type = BIGINT
+--let $col_default = 9223372036854775807
+--source col_null.inc
+
+--echo ########################
+--echo # SET columns
+--echo ########################
+
+--source type_set.inc
+--let $col_type = SET('test1','test2','test3')
+--let $col_default = 'test2,test3'
+--source col_null.inc
+
+
+--echo ########################
+--echo # TEXT columns
+--echo ########################
+
+--source type_text.inc
+
+--let $col_default = ''
+
+--let $col_type = TEXT
+--source col_null.inc
+
+--let $col_type = TINYTEXT
+--source col_null.inc
+
+--let $col_type = MEDIUMTEXT
+--source col_null.inc
+
+--let $col_type = LONGTEXT
+--source col_null.inc
+
+
+--let $col_type =
+--let $col_default =
+--let $extra_col_opts =
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/col_opt_unsigned.test b/storage/rocksdb/mysql-test/rocksdb/t/col_opt_unsigned.test
new file mode 100644
index 00000000..25cda84c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/col_opt_unsigned.test
@@ -0,0 +1,74 @@
+--source include/have_rocksdb.inc
+
+#
+# UNSIGNED column attribute
+#
+
+--let $extra_col_opts = UNSIGNED
+
+--echo ########################
+--echo # Fixed point columns (NUMERIC, DECIMAL)
+--echo ########################
+
+--source type_fixed.inc
+
+CREATE TABLE t1 (
+ a DECIMAL UNSIGNED,
+ b NUMERIC UNSIGNED,
+ PRIMARY KEY (a)
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+INSERT INTO t1 (a,b) VALUES (1.0,-1.0);
+INSERT INTO t1 (a,b) VALUES (-100,100);
+--sorted_result
+SELECT a,b FROM t1;
+DROP TABLE t1;
+
+--echo ########################
+--echo # Floating point columns (FLOAT, DOUBLE)
+--echo ########################
+
+--source type_float.inc
+
+CREATE TABLE t1 (
+ a DOUBLE UNSIGNED,
+ b FLOAT UNSIGNED,
+ PRIMARY KEY (b)
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+INSERT INTO t1 (a,b) VALUES (1.0,-1.0);
+INSERT INTO t1 (a,b) VALUES (-100,100);
+--sorted_result
+SELECT a,b FROM t1;
+DROP TABLE t1;
+
+--echo ########################
+--echo # INT columns
+--echo ########################
+
+--source type_int.inc
+
+CREATE TABLE t1 (
+ t TINYINT UNSIGNED,
+ s SMALLINT UNSIGNED,
+ m MEDIUMINT UNSIGNED,
+ i INT UNSIGNED,
+ b BIGINT UNSIGNED,
+ PRIMARY KEY (b)
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+INSERT INTO t1 (t,s,m,i,b) VALUES (255,65535,16777215,4294967295,18446744073709551615);
+INSERT INTO t1 (t,s,m,i,b) VALUES (-1,-1,-1,-1,-1);
+--sorted_result
+SELECT t,s,m,i,b FROM t1;
+
+DROP TABLE t1;
+
+--let $extra_col_opts =
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/col_opt_zerofill.test b/storage/rocksdb/mysql-test/rocksdb/t/col_opt_zerofill.test
new file mode 100644
index 00000000..37982ae0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/col_opt_zerofill.test
@@ -0,0 +1,67 @@
+--source include/have_rocksdb.inc
+
+#
+# ZEROFILL column attribute
+#
+
+let $extra_col_opts = ZEROFILL;
+
+--echo ########################
+--echo # Fixed point columns (NUMERIC, DECIMAL)
+--echo ########################
+
+--source type_fixed.inc
+
+CREATE TABLE t1 (
+ a DECIMAL ZEROFILL,
+ b NUMERIC ZEROFILL,
+ PRIMARY KEY (a)
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+INSERT INTO t1 (a,b) VALUES (1.1,1234);
+SELECT a,b FROM t1;
+DROP TABLE t1;
+
+--echo ########################
+--echo # Floating point columns (FLOAT, DOUBLE)
+--echo ########################
+
+--source type_float.inc
+
+CREATE TABLE t1 (
+ a DOUBLE ZEROFILL,
+ b FLOAT ZEROFILL,
+ PRIMARY KEY (b)
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+INSERT INTO t1 (a,b) VALUES (1,1234.5);
+SELECT a,b FROM t1;
+DROP TABLE t1;
+
+--echo ########################
+--echo # INT columns
+--echo ########################
+
+--source type_int.inc
+
+CREATE TABLE t1 (
+ t TINYINT ZEROFILL,
+ s SMALLINT ZEROFILL,
+ m MEDIUMINT ZEROFILL,
+ i INT ZEROFILL,
+ b BIGINT ZEROFILL,
+ PRIMARY KEY (b)
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+INSERT INTO t1 (t,s,m,i,b) VALUES (1,10,100,1000,0);
+SELECT t,s,m,i,b FROM t1;
+DROP TABLE t1;
+
+--let $extra_col_opts =
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/collation-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/collation-master.opt
new file mode 100644
index 00000000..79e59163
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/collation-master.opt
@@ -0,0 +1 @@
+--rocksdb_strict_collation_check=ON
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/collation.test b/storage/rocksdb/mysql-test/rocksdb/t/collation.test
new file mode 100644
index 00000000..3b808bc3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/collation.test
@@ -0,0 +1,211 @@
+--source include/have_rocksdb.inc
+# MariaDB doesn't have server variables to check for GCC version, so the
+# following check is commented out:
+# --source include/have_fullregex.inc
+
+call mtr.add_suppression("Invalid pattern");
+
+# ci non-indexed column is allowed
+CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text) engine=rocksdb charset utf8;
+# ci indexed column is not allowed
+--error ER_UNSUPPORTED_COLLATION
+ALTER TABLE t1 ADD INDEX (value);
+DROP TABLE t1;
+
+# ci indexed column is not allowed
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value)) engine=rocksdb charset utf8;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value3(50))) engine=rocksdb charset utf8;
+# ci indexed column with rocksdb_strict_collation_check=OFF is allowed.
+SET GLOBAL rocksdb_strict_collation_check=0;
+CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value3(50))) engine=rocksdb charset utf8;
+DROP TABLE t1;
+SET GLOBAL rocksdb_strict_collation_check=1;
+
+# cs indexed column is allowed
+CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value2)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+
+# cs latin1_bin is allowed
+CREATE TABLE t1 (id varchar(20), value varchar(50), value2 varchar(50), value3 text, primary key (id), index(value, value2)) engine=rocksdb charset latin1 collate latin1_bin;
+# THIS SHOULD FAIL BUT IT DOES NOT
+ALTER TABLE t1 collate=latin1_general_ci;
+DROP TABLE t1;
+
+# cs utf8_bin is allowed
+CREATE TABLE t1 (id varchar(20), value varchar(50), value2 varchar(50), value3 text, primary key (id), index(value, value2)) engine=rocksdb charset utf8 collate utf8_bin;
+DROP TABLE t1;
+
+# cs mixed latin1_bin and utf8_bin is allowed
+CREATE TABLE t1 (id varchar(20) collate latin1_bin, value varchar(50) collate utf8_bin, value2 varchar(50) collate latin1_bin, value3 text, primary key (id), index(value, value2)) engine=rocksdb;
+DROP TABLE t1;
+
+# ci indexed column is not allowed unless table name is in exception list
+SET GLOBAL rocksdb_strict_collation_exceptions=t1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE t2 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+
+# test regex for exception list
+SET GLOBAL rocksdb_strict_collation_exceptions="t.*";
+CREATE TABLE t123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t123;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE s123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+
+SET GLOBAL rocksdb_strict_collation_exceptions=".t.*";
+CREATE TABLE xt123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE xt123;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE t123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+
+# test multiple entries in the list with commas
+SET GLOBAL rocksdb_strict_collation_exceptions="s.*,t.*";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+
+# test multiple entries in the list with vertical bar
+SET GLOBAL rocksdb_strict_collation_exceptions="s.*|t.*";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+
+# test multiple entries in the list and extra comma at the front
+SET GLOBAL rocksdb_strict_collation_exceptions=",s.*,t.*";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+
+# test multiple entries in the list and extra vertical bar at the front
+SET GLOBAL rocksdb_strict_collation_exceptions="|s.*|t.*";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+
+# test multiple entries in the list and extra comma in the middle
+SET GLOBAL rocksdb_strict_collation_exceptions="s.*,,t.*";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+
+# test multiple entries in the list and extra vertical bar in the middle
+SET GLOBAL rocksdb_strict_collation_exceptions="s.*||t.*";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+
+# test multiple entries in the list and extra comma at the end
+SET GLOBAL rocksdb_strict_collation_exceptions="s.*,t.*,";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+
+# test multiple entries in the list and extra vertical bar at the end
+SET GLOBAL rocksdb_strict_collation_exceptions="s.*|t.*|";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+
+# test multiple entries in the list and tons of commas and vertical bars just for the fun of it
+SET GLOBAL rocksdb_strict_collation_exceptions="||||,,,,s.*,,|,,||,t.*,,|||,,,";
+CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE s1;
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8;
+
+# test allowing alters to create temporary tables
+SET GLOBAL rocksdb_strict_collation_exceptions='t1';
+CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb;
+ALTER TABLE t1 AUTO_INCREMENT=1;
+DROP TABLE t1;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE t2 (id INT primary key, value varchar(50), index(value)) engine=rocksdb;
+CREATE TABLE t2 (id INT primary key, value varchar(50)) engine=rocksdb;
+--error ER_UNSUPPORTED_COLLATION
+ALTER TABLE t2 ADD INDEX(value);
+DROP TABLE t2;
+
+
+# test invalid regex (missing end bracket)
+SET GLOBAL rocksdb_strict_collation_exceptions="[a-b";
+let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err;
+let SEARCH_PATTERN=Invalid pattern in strict_collation_exceptions: \[a-b;
+source include/search_pattern_in_file.inc;
+CREATE TABLE a (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8;
+SET GLOBAL rocksdb_strict_collation_exceptions="[a-b]";
+CREATE TABLE a (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8;
+CREATE TABLE b (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE c (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE a, b;
+
+call mtr.add_suppression("Invalid pattern in strict_collation_exceptions:");
+# test invalid regex (trailing escape)
+SET GLOBAL rocksdb_strict_collation_exceptions="abc\\";
+let SEARCH_PATTERN=Invalid pattern in strict_collation_exceptions: abc;
+source include/search_pattern_in_file.inc;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE abc (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8;
+SET GLOBAL rocksdb_strict_collation_exceptions="abc";
+CREATE TABLE abc (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8;
+--error ER_UNSUPPORTED_COLLATION
+CREATE TABLE abcd (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8;
+DROP TABLE abc;
+
+# test bad regex (null caused a crash) - Issue 493
+SET GLOBAL rocksdb_strict_collation_exceptions=null;
+
+# test for warnings instead of errors
+--let $_mysqld_option=--rocksdb_error_on_suboptimal_collation=0
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--source include/restart_mysqld_with_option.inc
+
+SET GLOBAL rocksdb_strict_collation_check=1;
+
+# ci indexed column is not optimal, should emit a warning
+CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value)) engine=rocksdb charset utf8;
+DROP TABLE t1;
+
+# ci non-indexed column is allowed
+CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text) engine=rocksdb charset utf8;
+# ci indexed column is not allowed, should emit a warning
+ALTER TABLE t1 ADD INDEX (value);
+DROP TABLE t1;
+
+# cs latin1_bin is allowed
+CREATE TABLE t1 (id varchar(20), value varchar(50), value2 varchar(50), value3 text, primary key (id), index(value, value2)) engine=rocksdb charset latin1 collate latin1_bin;
+# THIS SHOULD WARN BUT IT DOES NOT
+ALTER TABLE t1 collate=latin1_general_ci;
+DROP TABLE t1;
+
+# cleanup
+--source include/restart_mysqld.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/collation_exception-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/collation_exception-master.opt
new file mode 100644
index 00000000..13563edb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/collation_exception-master.opt
@@ -0,0 +1,2 @@
+--rocksdb_strict_collation_check=ON
+--rocksdb_strict_collation_exceptions='r1.lol'
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/collation_exception.test b/storage/rocksdb/mysql-test/rocksdb/t/collation_exception.test
new file mode 100644
index 00000000..334b1bb2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/collation_exception.test
@@ -0,0 +1,29 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE `r1.lol` (
+ `c1` int(10) NOT NULL DEFAULT '0',
+ `c2` int(11) NOT NULL DEFAULT '0',
+ `c3` int(1) NOT NULL DEFAULT '0',
+ `c4` int(11) NOT NULL DEFAULT '0',
+ `c5` int(11) NOT NULL DEFAULT '0',
+ `c6` varchar(100) NOT NULL DEFAULT '',
+ `c7` varchar(100) NOT NULL DEFAULT '',
+ `c8` varchar(255) NOT NULL DEFAULT '',
+ `c9` int(10) NOT NULL DEFAULT '125',
+ `c10` int(10) NOT NULL DEFAULT '125',
+ `c11` text NOT NULL,
+ `c12` int(11) NOT NULL DEFAULT '0',
+ `c13` int(10) NOT NULL DEFAULT '0',
+ `c14` text NOT NULL,
+ `c15` blob NOT NULL,
+ `c16` int(11) NOT NULL DEFAULT '0',
+ `c17` int(11) NOT NULL DEFAULT '0',
+ `c18` int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (`c1`),
+ KEY i1 (`c4`),
+ KEY i2 (`c7`),
+ KEY i3 (`c2`)) ENGINE=RocksDB DEFAULT CHARSET=latin1;
+
+DROP INDEX i1 ON `r1.lol`;
+DROP TABLE `r1.lol`;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/com_rpc_tx.cnf b/storage/rocksdb/mysql-test/rocksdb/t/com_rpc_tx.cnf
new file mode 100644
index 00000000..49ebd28c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/com_rpc_tx.cnf
@@ -0,0 +1,4 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+binlog_format=row
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/com_rpc_tx.test b/storage/rocksdb/mysql-test/rocksdb/t/com_rpc_tx.test
new file mode 100644
index 00000000..963f6c24
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/com_rpc_tx.test
@@ -0,0 +1,90 @@
+--source "include/have_rocksdb.inc"
+--source "include/have_log_bin.inc"
+# Don't run this with --rpc_protocol because it is doing its own work with
+# the RPC protocol
+--source "include/not_rpc_protocol.inc"
+
+#
+# This test was created because 2pc transactions were failing in MyRocks
+# when using detached sessions. The test generates two separate transactions
+# in two detached sessions and then attempts to commit them as simultaneously
+# as possible. This consistently showed the problem but succeeds after the
+# fix was put in place.
+
+CREATE DATABASE db_rpc;
+USE db_rpc;
+CREATE TABLE t1(pk INT PRIMARY KEY) ENGINE=rocksdb;
+
+SET GLOBAL rocksdb_enable_2pc=1;
+
+connect(con2,localhost,root,,);
+connection default;
+
+query_attrs_add rpc_role root;
+query_attrs_add rpc_db db_rpc;
+SET autocommit = 0;
+let $rpc_id1 = get_rpc_id();
+if ($rpc_id1 == "") {
+ echo "Fail: rpc_id not returned as expected";
+}
+
+SET autocommit = 0;
+let $rpc_id2 = get_rpc_id();
+if ($rpc_id2 == "") {
+ echo "Fail: rpc_id not returned as expected";
+}
+
+query_attrs_delete rpc_role;
+query_attrs_delete rpc_db;
+
+query_attrs_add rpc_id $rpc_id1;
+BEGIN;
+query_attrs_delete rpc_id;
+
+query_attrs_add rpc_id $rpc_id2;
+BEGIN;
+query_attrs_delete rpc_id;
+
+query_attrs_add rpc_id $rpc_id1;
+SELECT * from t1;
+query_attrs_delete rpc_id;
+
+query_attrs_add rpc_id $rpc_id2;
+SELECT * from t1;
+query_attrs_delete rpc_id;
+
+query_attrs_add rpc_id $rpc_id1;
+INSERT INTO t1 VALUES(1);
+query_attrs_delete rpc_id;
+
+query_attrs_add rpc_id $rpc_id2;
+INSERT INTO t1 VALUES(2);
+query_attrs_delete rpc_id;
+
+query_attrs_add rpc_id $rpc_id1;
+send COMMIT;
+
+connection con2;
+query_attrs_add rpc_id $rpc_id2;
+send COMMIT;
+
+connection default;
+reap;
+query_attrs_delete rpc_id;
+
+connection con2;
+reap;
+query_attrs_delete rpc_id;
+
+connection default;
+disconnect con2;
+
+SELECT * from db_rpc.t1;
+
+disable_query_log;
+eval KILL $rpc_id1;
+eval KILL $rpc_id2;
+enable_query_log;
+
+DROP DATABASE db_rpc;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/commit_in_the_middle_ddl.test b/storage/rocksdb/mysql-test/rocksdb/t/commit_in_the_middle_ddl.test
new file mode 100644
index 00000000..02f45779
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/commit_in_the_middle_ddl.test
@@ -0,0 +1,27 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS a;
+--enable_warnings
+
+create table a (id int, value int, primary key (id) comment 'cf_a') engine=rocksdb;
+
+--disable_query_log
+let $i = 1;
+while ($i <= 100000) {
+ let $insert = INSERT INTO a VALUES($i, $i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+set rocksdb_bulk_load=1;
+set rocksdb_commit_in_the_middle=1;
+alter table a add index v (value) COMMENT 'cf_a';
+set rocksdb_bulk_load=0;
+set rocksdb_commit_in_the_middle=0;
+select count(*) from a force index(primary);
+select count(*) from a force index(v);
+
+DROP TABLE a;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/compact_deletes-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/compact_deletes-master.opt
new file mode 100644
index 00000000..3b4871f8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/compact_deletes-master.opt
@@ -0,0 +1,3 @@
+--rocksdb_debug_optimizer_n_rows=1000
+--rocksdb_records_in_range=50
+--rocksdb_compaction_sequential_deletes_count_sd=1
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/compact_deletes.test b/storage/rocksdb/mysql-test/rocksdb/t/compact_deletes.test
new file mode 100644
index 00000000..b61da676
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/compact_deletes.test
@@ -0,0 +1,88 @@
+--source include/not_windows.inc
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS r1;
+--enable_warnings
+
+create table r1 (
+ id1 int,
+ id2 int,
+ type int,
+ value varchar(100),
+ value2 int,
+ value3 int,
+ primary key (type, id1, id2),
+ index id1_type (id1, type, value2, value, id2)
+) engine=rocksdb collate latin1_bin;
+
+select 'loading data';
+
+--disable_query_log
+let $i=0;
+while ($i<1000)
+{
+ inc $i;
+ eval insert r1(id1, id2, type, value, value2, value3)
+ values($i,$i,$i, 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',$i,$i);
+}
+--enable_query_log
+
+set global rocksdb_force_flush_memtable_now=1;
+optimize table r1;
+
+--echo Test 1: Do a bunch of updates without setting the compaction sysvar
+--echo Expect: no compaction
+let $window = 0;
+let $deletes = 0;
+let $file_size = 0;
+let $secondary_only = 0;
+let $primary = 1;
+let $no_more_deletes = 0;
+--source compact_deletes_test.inc
+
+--echo Test 2: Do a bunch of updates and set the compaction sysvar
+--echo Expect: compaction
+let $window = 1000;
+let $deletes = 990;
+let $file_size = 0;
+let $secondary_only = 0;
+let $primary = 1;
+let $no_more_deletes = 1;
+--source compact_deletes_test.inc
+
+--echo Test 3: Do a bunch of updates and set the compaction sysvar and a file size to something large
+--echo Expect: no compaction
+let $window = 1000;
+let $deletes = 1000;
+let $file_size = 1000000;
+let $secondary_only = 0;
+let $primary = 1;
+let $no_more_deletes = 0;
+--source compact_deletes_test.inc
+
+--echo Test 4: Do a bunch of secondary key updates and set the compaction sysvar
+--echo Expect: compaction
+let $window = 1000;
+let $deletes = 50;
+let $file_size = 0;
+let $secondary_only = 1;
+let $primary = 0;
+let $no_more_deletes = 1;
+--source compact_deletes_test.inc
+
+--echo Test 5: Do a bunch of secondary key updates and set the compaction sysvar,
+--echo and rocksdb_compaction_sequential_deletes_count_sd turned on
+--echo Expect: compaction
+let $window = 1000;
+let $deletes = 50;
+let $file_size = 0;
+let $secondary_only = 1;
+let $primary = 0;
+let $no_more_deletes = 1;
+SET @save_rocksdb_compaction_sequential_deletes_count_sd = @@global.rocksdb_compaction_sequential_deletes_count_sd;
+SET GLOBAL rocksdb_compaction_sequential_deletes_count_sd= ON;
+--source compact_deletes_test.inc
+SET GLOBAL rocksdb_compaction_sequential_deletes_count_sd= @save_rocksdb_compaction_sequential_deletes_count_sd;
+
+drop table r1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/compact_deletes_test.inc b/storage/rocksdb/mysql-test/rocksdb/t/compact_deletes_test.inc
new file mode 100644
index 00000000..0a0d6705
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/compact_deletes_test.inc
@@ -0,0 +1,72 @@
+# Usage:
+# let $window = <window size>;
+# let $deletes = <number of deletes per window>;
+# let $file_size = <min size of the file>;
+# --source compact_deletes_test.inc
+#
+
+let $save_rocksdb_compaction_sequential_deletes_window = `SELECT @@rocksdb_compaction_sequential_deletes_window`;
+eval set global rocksdb_compaction_sequential_deletes_window=$window;
+let $save_rocksdb_compaction_sequential_deletes = `SELECT @@rocksdb_compaction_sequential_deletes`;
+eval set global rocksdb_compaction_sequential_deletes= $deletes;
+let $save_rocksdb_compaction_sequential_deletes_file_size = `SELECT @@rocksdb_compaction_sequential_deletes_file_size`;
+eval set global rocksdb_compaction_sequential_deletes_file_size=$file_size;
+--disable_query_log
+let $i=0;
+while ($i<1000)
+{
+ inc $i;
+ if ($secondary_only)
+ {
+ eval update r1 set value2=value2+1 where id1=$i;
+ }
+ if ($primary)
+ {
+ eval update r1 set id2=id2+10000 where id1=500;
+ }
+}
+--enable_query_log
+set global rocksdb_force_flush_memtable_now=1;
+--sleep 1
+
+--disable_query_log
+let $wait_timeout= 300; # Override default 30 seconds with 300.
+let $wait_condition = select count(*) = 0
+ as c from information_schema.rocksdb_global_info
+ where TYPE = 'DDL_DROP_INDEX_ONGOING';
+--source include/wait_condition.inc
+--enable_query_log
+
+let NO_MORE_DELETES=$no_more_deletes;
+perl;
+ $num_retries=240;
+ $retry=0;
+ print "wait_for_delete: $ENV{no_more_deletes}\n";
+ while ($retry++ < $num_retries) {
+ $total_d=$total_e=0;
+ for $f (<$ENV{MYSQLTEST_VARDIR}/mysqld.1/data/#rocksdb/*.sst>) {
+ # excluding system cf
+ $filename= "$ENV{MARIAROCKS_SST_DUMP} --command=scan --output_hex --file=$f";
+ open(D, '-|', $filename) || die("Can't open file $filename: $!");
+ while (<D>) {
+ next unless /'(\d{8})/ and $1 >= 8;
+ $total_d++ if /: [07]/;
+ $total_e++ if /: 1/;
+ }
+ close D;
+ }
+ last if $total_e and not ($total_d and $ENV{no_more_deletes});
+ sleep 1;
+ }
+
+ unless ($total_e) {
+ print "No records in the database\n";
+ exit;
+ }
+
+ print $total_d ? "There are deletes left\n" : "No more deletes left\n";
+EOF
+
+eval SET GLOBAL rocksdb_compaction_sequential_deletes= $save_rocksdb_compaction_sequential_deletes;
+eval SET GLOBAL rocksdb_compaction_sequential_deletes_file_size= $save_rocksdb_compaction_sequential_deletes_file_size;
+eval SET GLOBAL rocksdb_compaction_sequential_deletes_window= $save_rocksdb_compaction_sequential_deletes_window;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/compression_zstd.test b/storage/rocksdb/mysql-test/rocksdb/t/compression_zstd.test
new file mode 100644
index 00000000..c2216f76
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/compression_zstd.test
@@ -0,0 +1,14 @@
+--source include/have_rocksdb.inc
+
+let $no_zstd=`select @@rocksdb_supported_compression_types NOT LIKE '%ZSTD%'`;
+
+if ($no_zstd)
+{
+ -- Skip Requires RocksDB to be built with ZStandard Compression support
+}
+
+--let $restart_parameters=--rocksdb_default_cf_options=compression_per_level=kZSTDNotFinalCompression;compression_opts=-14:4:0;
+--source include/restart_mysqld.inc
+
+create table t (id int primary key) engine=rocksdb;
+drop table t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/concurrent_alter.test b/storage/rocksdb/mysql-test/rocksdb/t/concurrent_alter.test
new file mode 100644
index 00000000..aee65383
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/concurrent_alter.test
@@ -0,0 +1,39 @@
+--source include/have_rocksdb.inc
+
+# Bash
+--source include/not_windows.inc
+
+#
+# Generate concurrent requests to alter a table using mysqlslap
+#
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqlslap;
+--enable_warnings
+
+CREATE DATABASE mysqlslap;
+
+use mysqlslap;
+
+CREATE TABLE a1 (a int, b int) ENGINE=ROCKSDB;
+INSERT INTO a1 VALUES (1, 1);
+
+--write_file $MYSQL_TMP_DIR/concurrent_alter.sh
+$MYSQL_SLAP --silent --delimiter=";" --query="alter table a1 add index bx(b); alter table a1 drop index bx" --concurrency=1 --iterations=25 &
+$MYSQL_SLAP --silent --delimiter=";" --query="alter table a1 add index ax(a); alter table a1 drop index ax" --concurrency=1 --iterations=25 &
+sleep 2
+$MYSQL_SLAP --silent --delimiter=";" --query="select * from a1 where a=1" --concurrency=16 --iterations=1000 &
+$MYSQL_SLAP --silent --delimiter=";" --query="select * from a1 where b=1" --concurrency=16 --iterations=1000
+sleep 2
+$MYSQL_SLAP --silent --delimiter=";" --query="select * from a1 where a=1" --concurrency=16 --iterations=1000 &
+$MYSQL_SLAP --silent --delimiter=";" --query="select * from a1 where b=1" --concurrency=16 --iterations=1000
+wait
+EOF
+
+--exec sh $MYSQL_TMP_DIR/concurrent_alter.sh
+
+let $server_charset=`select @@character_set_server`;
+--replace_result $server_charset DEFAULT_CHARSET
+SHOW CREATE TABLE a1;
+
+DROP DATABASE mysqlslap;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_read_committed.opt b/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_read_committed.opt
new file mode 100644
index 00000000..418e4c3f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_read_committed.opt
@@ -0,0 +1 @@
+--rocksdb_default_cf_options=disable_auto_compactions=true \ No newline at end of file
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_read_committed.test b/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_read_committed.test
new file mode 100644
index 00000000..4dfa5abb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_read_committed.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+let $trx_isolation = READ COMMITTED;
+
+--source consistent_snapshot.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_repeatable_read.opt b/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_repeatable_read.opt
new file mode 100644
index 00000000..418e4c3f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_repeatable_read.opt
@@ -0,0 +1 @@
+--rocksdb_default_cf_options=disable_auto_compactions=true \ No newline at end of file
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_repeatable_read.test b/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_repeatable_read.test
new file mode 100644
index 00000000..c9f28dbc
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_repeatable_read.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+let $trx_isolation = REPEATABLE READ;
+
+--source consistent_snapshot.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_serializable.opt b/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_serializable.opt
new file mode 100644
index 00000000..418e4c3f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_serializable.opt
@@ -0,0 +1 @@
+--rocksdb_default_cf_options=disable_auto_compactions=true \ No newline at end of file
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_serializable.test b/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_serializable.test
new file mode 100644
index 00000000..57b45050
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/cons_snapshot_serializable.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+let $trx_isolation = SERIALIZABLE;
+
+--source consistent_snapshot.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/consistent_snapshot.inc b/storage/rocksdb/mysql-test/rocksdb/t/consistent_snapshot.inc
new file mode 100644
index 00000000..ca7510b1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/consistent_snapshot.inc
@@ -0,0 +1,136 @@
+#
+# TRANSACTION WITH CONSISTENT SNAPSHOT
+#
+
+--enable_connect_log
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+
+CREATE TABLE t1 (a INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=ROCKSDB;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $trx_isolation;
+
+# While a consistent snapshot transaction is executed,
+# no external inserts should be visible to the transaction.
+# But it should only work this way for REPEATABLE-READ and SERIALIZABLE
+
+--error 0,ER_ISOLATION_LEVEL_WITH_CONSISTENT_SNAPSHOT
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+--echo ERROR: $mysql_errno
+
+connection con2;
+select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
+
+connection con1;
+COMMIT;
+
+# verifying snapshot is released after finishing transaction
+connection con2;
+select * from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
+
+connection con1;
+--error 0,ER_ISOLATION_LEVEL_WITH_CONSISTENT_SNAPSHOT
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+--echo ERROR: $mysql_errno
+
+connection con2;
+INSERT INTO t1 (a) VALUES (1);
+
+connection con1;
+--echo # If consistent read works on this isolation level ($trx_isolation), the following SELECT should not return the value we inserted (1)
+SELECT a FROM t1;
+COMMIT;
+
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+CREATE TABLE r1 (id int primary key, value int, value2 int) engine=ROCKSDB;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $trx_isolation;
+insert into r1 values (1,1,1),(2,2,2),(3,3,3),(4,4,4);
+
+BEGIN;
+
+connection con2;
+INSERT INTO r1 values (5,5,5);
+
+connection con1;
+SELECT * FROM r1; # 5
+
+connection con2;
+INSERT INTO r1 values (6,6,6);
+
+connection con1;
+SELECT * FROM r1; # 5
+COMMIT;
+SELECT * FROM r1; # 6
+
+--error 0,ER_ISOLATION_LEVEL_WITH_CONSISTENT_SNAPSHOT
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+--echo ERROR: $mysql_errno
+
+connection con2;
+INSERT INTO r1 values (7,7,7);
+
+connection con1;
+SELECT * FROM r1; # 6
+
+connection con2;
+INSERT INTO r1 values (8,8,8);
+
+connection con1;
+SELECT * FROM r1; # 6
+COMMIT;
+SELECT * FROM r1; # 8
+
+--error 0,ER_ISOLATION_LEVEL_WITH_CONSISTENT_SNAPSHOT
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+--echo ERROR: $mysql_errno
+
+connection con2;
+INSERT INTO r1 values (9,9,9);
+
+connection con1;
+--error 0,ER_ISOLATION_LEVEL_WITH_CONSISTENT_SNAPSHOT
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+--echo ERROR: $mysql_errno
+
+connection con2;
+INSERT INTO r1 values (10,10,10);
+
+connection con1;
+SELECT * FROM r1; # 9
+
+--error 0,ER_ISOLATION_LEVEL_WITH_CONSISTENT_SNAPSHOT
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+--echo ERROR: $mysql_errno
+# Succeeds with Read Committed, Fails with Repeatable Read
+--error 0,ER_UPDATES_WITH_CONSISTENT_SNAPSHOT
+INSERT INTO r1 values (11,11,11);
+--echo ERROR: $mysql_errno
+SELECT * FROM r1; # self changes should be visible
+
+
+drop table r1;
+
+connection default;
+disconnect con1;
+disconnect con2;
+
+
+--source include/wait_until_count_sessions.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/corrupted_data_reads_debug.test b/storage/rocksdb/mysql-test/rocksdb/t/corrupted_data_reads_debug.test
new file mode 100644
index 00000000..eca0830c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/corrupted_data_reads_debug.test
@@ -0,0 +1,80 @@
+--source include/have_rocksdb.inc
+
+--echo #
+--echo # Test how MyRocks handles reading corrupted data from disk.
+--echo # Data corruption is simulated at source-code level.
+--echo #
+
+--source include/have_debug.inc
+
+
+--echo #
+--echo # A test for case when data in the table *record* is longer
+--echo # than table DDL expects it to be
+--echo #
+create table t1 (
+ pk int not null primary key,
+ col1 varchar(10)
+) engine=rocksdb;
+
+insert into t1 values (1,1),(2,2),(3,3);
+
+select * from t1;
+
+set @tmp1=@@rocksdb_verify_row_debug_checksums;
+set rocksdb_verify_row_debug_checksums=1;
+set session debug_dbug= "+d,myrocks_simulate_bad_row_read1";
+--error ER_GET_ERRMSG
+select * from t1 where pk=1;
+set session debug_dbug= "-d,myrocks_simulate_bad_row_read1";
+set rocksdb_verify_row_debug_checksums=@tmp1;
+
+select * from t1 where pk=1;
+
+set session debug_dbug= "+d,myrocks_simulate_bad_row_read2";
+--error ER_GET_ERRMSG
+select * from t1 where pk=1;
+set session debug_dbug= "-d,myrocks_simulate_bad_row_read2";
+
+set session debug_dbug= "+d,myrocks_simulate_bad_row_read3";
+--error ER_GET_ERRMSG
+select * from t1 where pk=1;
+set session debug_dbug= "-d,myrocks_simulate_bad_row_read3";
+
+insert into t1 values(4,'0123456789');
+select * from t1;
+drop table t1;
+
+--echo #
+--echo # A test for case when index data is longer than table DDL
+--echo # expects it to be
+--echo #
+
+create table t2 (
+ pk varchar(4) not null primary key,
+ col1 int not null
+) engine=rocksdb collate latin1_bin;
+
+insert into t2 values ('ABCD',1);
+select * from t2;
+set session debug_dbug= "+d,myrocks_simulate_bad_pk_read1";
+--error ER_GET_ERRMSG
+select * from t2;
+set session debug_dbug= "-d,myrocks_simulate_bad_pk_read1";
+
+drop table t2;
+
+create table t2 (
+ pk varchar(4) not null primary key,
+ col1 int not null
+) engine=rocksdb;
+
+insert into t2 values ('ABCD',1);
+
+select * from t2;
+set session debug_dbug= "+d,myrocks_simulate_bad_pk_read1";
+--error ER_GET_ERRMSG
+select * from t2;
+set session debug_dbug= "-d,myrocks_simulate_bad_pk_read1";
+
+drop table t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/covered_unpack_info_format.test b/storage/rocksdb/mysql-test/rocksdb/t/covered_unpack_info_format.test
new file mode 100644
index 00000000..ccd91a61
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/covered_unpack_info_format.test
@@ -0,0 +1,79 @@
+# Disable until covered unpack_info format enabled in prod
+--source include/have_debug.inc
+--source include/not_debug.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+#
+# Normal case
+#
+
+CREATE TABLE t1 (
+ id INT,
+ fake_id INT,
+ bigfield VARCHAR(4096),
+ PRIMARY KEY (id),
+ KEY bf (bigfield(32)),
+ KEY fid (fake_id, bigfield(32))
+) ENGINE=rocksdb;
+
+INSERT INTO t1 VALUES (1, 1001, REPEAT('a', 1)),
+ (8, 1008, REPEAT('b', 8)),
+ (24, 1024, REPEAT('c', 24)),
+ (31, 1031, REPEAT('d', 31)),
+ (32, 1032, REPEAT('x', 32)),
+ (33, 1033, REPEAT('y', 33)),
+ (128, 1128, REPEAT('z', 128));
+
+SELECT * FROM t1;
+
+--let $prefix_index_check_title= Eligible for optimization, access via fake_id only
+--let $prefix_index_check_read_avoided_delta= 2
+--let $prefix_index_check_query= SELECT id, bigfield FROM t1 FORCE INDEX(fid) WHERE fake_id = 1031
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+--let $prefix_index_check_title= Not eligible for optimization, access via fake_id of big row.
+--let $prefix_index_check_read_avoided_delta= 0
+--let $prefix_index_check_query= SELECT id, bigfield FROM t1 FORCE INDEX(fid) WHERE fake_id = 1033
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+DROP TABLE t1;
+
+#
+# Create same table with older format to test compatibility
+#
+
+set session debug= '+d,MYROCKS_NO_COVERED_BITMAP_FORMAT';
+CREATE TABLE t1 (
+ id INT,
+ fake_id INT,
+ bigfield VARCHAR(4096),
+ PRIMARY KEY (id),
+ KEY bf (bigfield(32)),
+ KEY fid (fake_id, bigfield(32))
+) ENGINE=rocksdb;
+set session debug= '-d,MYROCKS_NO_COVERED_BITMAP_FORMAT';
+
+INSERT INTO t1 VALUES (1, 1001, REPEAT('a', 1)),
+ (8, 1008, REPEAT('b', 8)),
+ (24, 1024, REPEAT('c', 24)),
+ (31, 1031, REPEAT('d', 31)),
+ (32, 1032, REPEAT('x', 32)),
+ (33, 1033, REPEAT('y', 33)),
+ (128, 1128, REPEAT('z', 128));
+
+SELECT * FROM t1;
+
+--let $prefix_index_check_title= No longer eligible for optimization since no covered bitmap was stored.
+--let $prefix_index_check_read_avoided_delta= 0
+--let $prefix_index_check_query= SELECT id, bigfield FROM t1 FORCE INDEX(fid) WHERE fake_id = 1031
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+--let $prefix_index_check_title= Not eligible for optimization.
+--let $prefix_index_check_read_avoided_delta= 0
+--let $prefix_index_check_query= SELECT id, bigfield FROM t1 FORCE INDEX(fid) WHERE fake_id = 1033
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/create_no_primary_key_table-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/create_no_primary_key_table-master.opt
new file mode 100644
index 00000000..ce274af3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/create_no_primary_key_table-master.opt
@@ -0,0 +1 @@
+--block_create_no_primary_key=TRUE
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/create_no_primary_key_table.test b/storage/rocksdb/mysql-test/rocksdb/t/create_no_primary_key_table.test
new file mode 100644
index 00000000..3ef35cb2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/create_no_primary_key_table.test
@@ -0,0 +1,63 @@
+USE mysql;
+CREATE TABLE mysql_table (a INT) ENGINE=ROCKSDB;
+-- error ER_BLOCK_NO_PRIMARY_KEY
+CREATE TABLE test.mysql_table (a INT) ENGINE=ROCKSDB;
+USE test;
+-- error ER_BLOCK_NO_PRIMARY_KEY
+CREATE TABLE mysql_table (a INT) ENGINE=ROCKSDB;
+-- error ER_BLOCK_NO_PRIMARY_KEY
+CREATE TABLE IF NOT EXISTS mysql_table_2 (a INT) ENGINE=ROCKSDB;
+-- error ER_TABLE_MUST_HAVE_COLUMNS
+CREATE TABLE mysql_table_no_cols ENGINE=ROCKSDB;
+CREATE TABLE mysql.mysql_table_2 (a INT) ENGINE=ROCKSDB;
+
+CREATE TABLE mysql_primkey (a INT PRIMARY KEY, b INT, c INT, d INT, INDEX (c)) ENGINE=ROCKSDB;
+ALTER TABLE mysql_primkey DROP b, DROP a, ADD (f INT PRIMARY KEY);
+-- error ER_BLOCK_NO_PRIMARY_KEY
+ALTER TABLE mysql_primkey DROP PRIMARY KEY;
+
+CREATE TABLE mysql_primkey2 (a INT PRIMARY KEY, b INT, c INT) ENGINE=ROCKSDB;
+ALTER TABLE mysql_primkey2 DROP b;
+ALTER TABLE mysql_primkey2 ADD (b INT);
+-- error ER_BLOCK_NO_PRIMARY_KEY
+ALTER TABLE mysql_primkey2 DROP c, DROP A;
+
+CREATE TABLE mysql_primkey3 (a INT PRIMARY KEY, b INT, c INT, INDEX indexonb (b), INDEX indexonc (c)) ENGINE=ROCKSDB;
+ALTER TABLE mysql_primkey3 DROP INDEX indexonb;
+ALTER TABLE mysql_primkey3 DROP c;
+ALTER TABLE mysql_primkey3 DROP PRIMARY KEY, ADD PRIMARY KEY(b);
+
+CREATE TABLE mysql_primkey4(a INT, b INT, PRIMARY KEY(a), INDEX si (a, b)) ENGINE=ROCKSDB;
+DROP INDEX si ON mysql_primkey4;
+-- error ER_BLOCK_NO_PRIMARY_KEY
+DROP INDEX `PRIMARY` ON mysql_primkey4;
+
+ALTER TABLE mysql.mysql_table ADD PRIMARY KEY (a);
+ALTER TABLE mysql.mysql_table DROP PRIMARY KEY;
+
+SET default_storage_engine=ROCKSDB;
+-- error ER_BLOCK_NO_PRIMARY_KEY
+CREATE TABLE mysql_noeng(a INT, b INT);
+
+# Disable no_engine_substitution
+SET sql_mode="";
+-- error ER_BLOCK_NO_PRIMARY_KEY
+CREATE TABLE mysql_noeng_sub(a INT, b INT) ENGINE=BOGUS_ENGINE;
+
+CREATE TABLE mysql_primkey5 LIKE mysql_primkey;
+
+SET @@global.block_create_no_primary_key = false;
+CREATE TABLE mysql_no_primkey (a INT) ENGINE=ROCKSDB;
+SET @@global.block_create_no_primary_key = true;
+-- error ER_BLOCK_NO_PRIMARY_KEY
+CREATE TABLE mysql_block_no_primkey LIKE mysql_no_primkey;
+
+DROP TABLE mysql_primkey;
+DROP TABLE mysql_primkey2;
+DROP TABLE mysql_primkey3;
+DROP TABLE mysql_primkey4;
+DROP TABLE mysql_primkey5;
+DROP TABLE mysql_no_primkey;
+USE mysql;
+DROP TABLE mysql_table;
+DROP TABLE mysql_table_2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/create_table.test b/storage/rocksdb/mysql-test/rocksdb/t/create_table.test
new file mode 100644
index 00000000..4fffe749
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/create_table.test
@@ -0,0 +1,192 @@
+--source include/have_rocksdb.inc
+
+#
+# Basic CREATE TABLE statements
+#
+
+#############################################
+# TODO:
+# A part of the test is currently disabled
+# because temporary tables are not supported
+#############################################
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+# Simple create table with minimal table options
+# which are defined in have_engine.inc
+# (default empty) plus ENGINE=
+
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+
+# IF NOT EXISTS
+CREATE TABLE IF NOT EXISTS t1 (a INT PRIMARY KEY) ENGINE=rocksdb;
+
+# CREATE .. LIKE
+
+CREATE TABLE t2 LIKE t1;
+SHOW CREATE TABLE t2;
+
+--error ER_ILLEGAL_HA_CREATE_OPTION
+CREATE TEMPORARY TABLE t2 (a INT PRIMARY KEY) ENGINE=rocksdb;
+
+--disable_parsing
+
+DROP TABLE t2;
+
+CREATE TEMPORARY TABLE t2 LIKE t1;
+
+SHOW CREATE TABLE t2;
+DROP TEMPORARY TABLE t2;
+
+--enable_parsing
+
+DROP TABLE t2;
+
+DROP TABLE IF EXISTS t1;
+
+# CREATE .. AS SELECT
+
+# Use the engine as default
+
+SET default_storage_engine = rocksdb;
+
+CREATE TABLE t1 (a INT PRIMARY KEY);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT PRIMARY KEY) AS SELECT 1 AS a UNION SELECT 2 AS a;
+SHOW CREATE TABLE t1;
+--sorted_result
+SELECT * FROM t1;
+
+# Just to add FLUSH LOGS into the mix while we are in the most common test
+FLUSH LOGS;
+
+DROP TABLE IF EXISTS t1;
+
+# CREATE TABLE with MAX_INDEXES (64) keys and no primary key
+# MyRocks adds a hidden primary key, so make sure we don't break anything
+CREATE TABLE t1(c1 INT,c2 INT,c3 INT,c4 INT,c5 INT,c6 INT,c7 INT,c8 INT,c9 INT,
+ c10 INT,c11 INT,c12 INT,c13 INT,c14 INT,c15 INT,c16 INT,c17 INT,
+ c18 INT,c19 INT,c20 INT,c21 INT,c22 INT,c23 INT,c24 INT,c25 INT,
+ c26 INT,c27 INT,c28 INT,c29 INT,c30 INT,c31 INT,c32 INT,c33 INT,
+ c34 INT,c35 INT,c36 INT,c37 INT,c38 INT,c39 INT,c40 INT,c41 INT,
+ c42 INT,c43 INT,c44 INT,c45 INT,c46 INT,c47 INT,c48 INT,c49 INT,
+ c50 INT,c51 INT,c52 INT,c53 INT,c54 INT,c55 INT,c56 INT,c57 INT,
+ c58 INT,c59 INT,c60 INT,c61 INT,c62 INT,c63 INT,c64 INT,c65 INT,
+ c66 INT,c67 INT,c68 INT,c69 INT,c70 INT,c71 INT,c72 INT,c73 INT,
+ c74 INT,c75 INT,c76 INT,c77 INT,c78 INT,c79 INT,c80 INT,c81 INT,
+ c82 INT,c83 INT,c84 INT,c85 INT,c86 INT,c87 INT,c88 INT,c89 INT,
+ c90 INT,c91 INT,c92 INT,c93 INT,c94 INT,c95 INT,c96 INT,c97 INT,
+ c98 INT,c99 INT,c100 INT,c101 INT,c102 INT,c103 INT,c104 INT,
+ c105 INT,c106 INT,c107 INT,c108 INT,c109 INT,c110 INT,c111 INT,
+ c112 INT,c113 INT,c114 INT,c115 INT,c116 INT,c117 INT,c118 INT,
+ c119 INT,c120 INT,c121 INT,c122 INT,c123 INT,c124 INT,c125 INT,
+ c126 INT,c127 INT,c128 INT,c129 INT,c130 INT,c131 INT,c132 INT,
+ c133 INT,c134 INT,c135 INT,c136 INT,c137 INT,c138 INT,c139 INT,
+ c140 INT,c141 INT,c142 INT,c143 INT,c144 INT,c145 INT,c146 INT,
+ c147 INT,c148 INT,c149 INT,c150 INT,c151 INT,c152 INT,c153 INT,
+ c154 INT,c155 INT,c156 INT,c157 INT,c158 INT,c159 INT,c160 INT,
+ c161 INT,c162 INT,c163 INT,c164 INT,c165 INT,c166 INT,c167 INT,
+ c168 INT,c169 INT,c170 INT,c171 INT,c172 INT,c173 INT,c174 INT,
+ c175 INT,c176 INT,c177 INT,c178 INT,c179 INT,c180 INT,c181 INT,
+ c182 INT,c183 INT,c184 INT,c185 INT,c186 INT,c187 INT,c188 INT,
+ c189 INT,c190 INT,c191 INT,c192 INT,c193 INT,c194 INT,c195 INT,
+ c196 INT,c197 INT,c198 INT,c199 INT,c200 INT,c201 INT,c202 INT,
+ c203 INT,c204 INT,c205 INT,c206 INT,c207 INT,c208 INT,c209 INT,
+ c210 INT,c211 INT,c212 INT,c213 INT,c214 INT,c215 INT,c216 INT,
+ c217 INT,c218 INT,c219 INT,c220 INT,c221 INT,c222 INT,c223 INT,
+ c224 INT,c225 INT,c226 INT,c227 INT,c228 INT,c229 INT,c230 INT,
+ c231 INT,c232 INT,c233 INT,c234 INT,c235 INT,c236 INT,c237 INT,
+ c238 INT,c239 INT,c240 INT,c241 INT,c242 INT,c243 INT,c244 INT,
+ c245 INT,c246 INT,c247 INT,c248 INT,c249 INT,c250 INT,c251 INT,
+ c252 INT,c253 INT,c254 INT,c255 INT,c256 INT,c257 INT,c258 INT,
+ c259 INT,c260 INT,c261 INT,c262 INT,c263 INT,c264 INT,c265 INT,
+ c266 INT,c267 INT,c268 INT,c269 INT,c270 INT,c271 INT,c272 INT,
+ c273 INT,c274 INT,c275 INT,c276 INT,c277 INT,c278 INT,c279 INT,
+ c280 INT,c281 INT,c282 INT,c283 INT,c284 INT,c285 INT,c286 INT,
+ c287 INT,c288 INT,c289 INT,c290 INT,c291 INT,c292 INT,c293 INT,
+ c294 INT,c295 INT,c296 INT,c297 INT,c298 INT,c299 INT,c300 INT,
+ c301 INT,c302 INT,c303 INT,c304 INT,c305 INT,c306 INT,c307 INT,
+ c308 INT,c309 INT,c310 INT,c311 INT,c312 INT,c313 INT,c314 INT,
+ c315 INT,c316 INT,c317 INT,c318 INT,c319 INT,c320 INT,c321 INT,
+ c322 INT,c323 INT,c324 INT,c325 INT,c326 INT,c327 INT,c328 INT,
+ c329 INT,c330 INT,c331 INT,c332 INT,c333 INT,c334 INT,c335 INT,
+ c336 INT,c337 INT,c338 INT,c339 INT,c340 INT,c341 INT,c342 INT,
+ c343 INT,c344 INT,c345 INT,c346 INT,c347 INT,c348 INT,c349 INT,
+ c350 INT,c351 INT,c352 INT,c353 INT,c354 INT,c355 INT,c356 INT,
+ c357 INT,c358 INT,c359 INT,c360 INT,c361 INT,c362 INT,c363 INT,
+ c364 INT,c365 INT,c366 INT,c367 INT,c368 INT,c369 INT,c370 INT,
+ c371 INT,c372 INT,c373 INT,c374 INT,c375 INT,c376 INT,c377 INT,
+ c378 INT,c379 INT,c380 INT,c381 INT,c382 INT,c383 INT,c384 INT,
+ c385 INT,c386 INT,c387 INT,c388 INT,c389 INT,c390 INT,c391 INT,
+ c392 INT,c393 INT,c394 INT,c395 INT,c396 INT,c397 INT,c398 INT,
+ c399 INT,c400 INT,c401 INT,c402 INT,c403 INT,c404 INT,c405 INT,
+ c406 INT,c407 INT,c408 INT,c409 INT,c410 INT,c411 INT,c412 INT,
+ c413 INT,c414 INT,c415 INT,c416 INT,c417 INT,c418 INT,c419 INT,
+ c420 INT,c421 INT,c422 INT,c423 INT,c424 INT,c425 INT,c426 INT,
+ c427 INT,c428 INT,c429 INT,c430 INT,c431 INT,c432 INT,c433 INT,
+ c434 INT,c435 INT,c436 INT,c437 INT,c438 INT,c439 INT,c440 INT,
+ c441 INT,c442 INT,c443 INT,c444 INT,c445 INT,c446 INT,c447 INT,
+ c448 INT,
+ KEY (c1,c2,c3,c4,c5,c6,c7),KEY (c8,c9,c10,c11,c12,c13,c14),
+ KEY (c15,c16,c17,c18,c19,c20,c21),KEY (c22,c23,c24,c25,c26,c27,c28),
+ KEY (c29,c30,c31,c32,c33,c34,c35),KEY (c36,c37,c38,c39,c40,c41,c42),
+ KEY (c43,c44,c45,c46,c47,c48,c49),KEY (c50,c51,c52,c53,c54,c55,c56),
+ KEY (c57,c58,c59,c60,c61,c62,c63),KEY (c64,c65,c66,c67,c68,c69,c70),
+ KEY (c71,c72,c73,c74,c75,c76,c77),KEY (c78,c79,c80,c81,c82,c83,c84),
+ KEY (c85,c86,c87,c88,c89,c90,c91),KEY (c92,c93,c94,c95,c96,c97,c98),
+ KEY (c99,c100,c101,c102,c103,c104,c105),
+ KEY (c106,c107,c108,c109,c110,c111,c112),
+ KEY (c113,c114,c115,c116,c117,c118,c119),
+ KEY (c120,c121,c122,c123,c124,c125,c126),
+ KEY (c127,c128,c129,c130,c131,c132,c133),
+ KEY (c134,c135,c136,c137,c138,c139,c140),
+ KEY (c141,c142,c143,c144,c145,c146,c147),
+ KEY (c148,c149,c150,c151,c152,c153,c154),
+ KEY (c155,c156,c157,c158,c159,c160,c161),
+ KEY (c162,c163,c164,c165,c166,c167,c168),
+ KEY (c169,c170,c171,c172,c173,c174,c175),
+ KEY (c176,c177,c178,c179,c180,c181,c182),
+ KEY (c183,c184,c185,c186,c187,c188,c189),
+ KEY (c190,c191,c192,c193,c194,c195,c196),
+ KEY (c197,c198,c199,c200,c201,c202,c203),
+ KEY (c204,c205,c206,c207,c208,c209,c210),
+ KEY (c211,c212,c213,c214,c215,c216,c217),
+ KEY (c218,c219,c220,c221,c222,c223,c224),
+ KEY (c225,c226,c227,c228,c229,c230,c231),
+ KEY (c232,c233,c234,c235,c236,c237,c238),
+ KEY (c239,c240,c241,c242,c243,c244,c245),
+ KEY (c246,c247,c248,c249,c250,c251,c252),
+ KEY (c253,c254,c255,c256,c257,c258,c259),
+ KEY (c260,c261,c262,c263,c264,c265,c266),
+ KEY (c267,c268,c269,c270,c271,c272,c273),
+ KEY (c274,c275,c276,c277,c278,c279,c280),
+ KEY (c281,c282,c283,c284,c285,c286,c287),
+ KEY (c288,c289,c290,c291,c292,c293,c294),
+ KEY (c295,c296,c297,c298,c299,c300,c301),
+ KEY (c302,c303,c304,c305,c306,c307,c308),
+ KEY (c309,c310,c311,c312,c313,c314,c315),
+ KEY (c316,c317,c318,c319,c320,c321,c322),
+ KEY (c323,c324,c325,c326,c327,c328,c329),
+ KEY (c330,c331,c332,c333,c334,c335,c336),
+ KEY (c337,c338,c339,c340,c341,c342,c343),
+ KEY (c344,c345,c346,c347,c348,c349,c350),
+ KEY (c351,c352,c353,c354,c355,c356,c357),
+ KEY (c358,c359,c360,c361,c362,c363,c364),
+ KEY (c365,c366,c367,c368,c369,c370,c371),
+ KEY (c372,c373,c374,c375,c376,c377,c378),
+ KEY (c379,c380,c381,c382,c383,c384,c385),
+ KEY (c386,c387,c388,c389,c390,c391,c392),
+ KEY (c393,c394,c395,c396,c397,c398,c399),
+ KEY (c400,c401,c402,c403,c404,c405,c406),
+ KEY (c407,c408,c409,c410,c411,c412,c413),
+ KEY (c414,c415,c416,c417,c418,c419,c420),
+ KEY (c421,c422,c423,c424,c425,c426,c427),
+ KEY (c428,c429,c430,c431,c432,c433,c434),
+ KEY (c435,c436,c437,c438,c439,c440,c441),
+ KEY (c442,c443,c444,c445,c446,c447,c448));
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ddl_high_priority.test b/storage/rocksdb/mysql-test/rocksdb/t/ddl_high_priority.test
new file mode 100644
index 00000000..01bb5cfa
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ddl_high_priority.test
@@ -0,0 +1,18 @@
+# Test high priority DDL
+# There are two modes of high priority DDL:
+# 1. Through the system variable high_priority_ddl
+# 2. Through syntax: CREATE/ALTER/DROP/OPTIMIZE HIGH_PRIORITY ...
+
+--source include/have_rocksdb.inc
+
+--echo ##
+--echo ## Using the system variable high_priority_ddl"
+--echo ##
+--let $use_sys_var = 1;
+--source include/ddl_high_priority.inc
+
+--echo ##
+--echo ## Using HIGH_PRIORITY syntax
+--echo ##
+--let $use_sys_var = 0;
+--source include/ddl_high_priority.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/deadlock.test b/storage/rocksdb/mysql-test/rocksdb/t/deadlock.test
new file mode 100644
index 00000000..656be9eb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/deadlock.test
@@ -0,0 +1,44 @@
+--echo #
+--echo # Validate that deadlock errors don't occur with a high level of concurrency
+--echo #
+
+--source include/have_rocksdb.inc
+--source include/big_test.inc
+
+--echo # Disable for valgrind because this takes too long
+--source include/not_valgrind.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqlslap;
+--enable_warnings
+
+CREATE DATABASE mysqlslap;
+USE mysqlslap;
+CREATE TABLE t1(id1 BIGINT, id2 BIGINT, count INT, PRIMARY KEY(id1, id2), KEY(id2)) ENGINE=rocksdb;
+CREATE TABLE t1rev(id1 BIGINT, id2 BIGINT, count INT, PRIMARY KEY(id1, id2) COMMENT "rev:cf2", KEY(id2) COMMENT "rev:cf2") ENGINE=rocksdb;
+
+SET @save = @@global.rocksdb_lock_wait_timeout;
+SET GLOBAL rocksdb_lock_wait_timeout = 60;
+
+--exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=50000 --query="INSERT INTO t1 VALUES(1, 1, 1) ON DUPLICATE KEY UPDATE count=count+1"
+SELECT count from t1;
+--exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=50000 --query="UPDATE t1 SET count=count+1 WHERE id1=1 AND id2=1"
+SELECT count from t1;
+--exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=50000 --query="UPDATE t1 SET count=count+1 WHERE id2=1"
+SELECT count from t1;
+--exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=50000 --query="UPDATE t1 SET count=count+1"
+SELECT count from t1;
+
+# Same tests on a table with reverse orderings
+--exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=50000 --query="INSERT INTO t1rev VALUES(1, 1, 1) ON DUPLICATE KEY UPDATE count=count+1"
+SELECT count from t1rev;
+--exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=50000 --query="UPDATE t1rev SET count=count+1 WHERE id1=1 AND id2=1"
+SELECT count from t1rev;
+--exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=50000 --query="UPDATE t1rev SET count=count+1 WHERE id2=1"
+SELECT count from t1rev;
+--exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=50000 --query="UPDATE t1rev SET count=count+1"
+SELECT count from t1rev;
+
+SET GLOBAL rocksdb_lock_wait_timeout = @save;
+
+DROP DATABASE mysqlslap;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/deadlock_stats.test b/storage/rocksdb/mysql-test/rocksdb/t/deadlock_stats.test
new file mode 100644
index 00000000..a9b30a42
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/deadlock_stats.test
@@ -0,0 +1,3 @@
+let $engine=rocksdb;
+
+--source include/deadlock_stats.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/deadlock_tracking.test b/storage/rocksdb/mysql-test/rocksdb/t/deadlock_tracking.test
new file mode 100644
index 00000000..8ceebef8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/deadlock_tracking.test
@@ -0,0 +1,185 @@
+set @prior_lock_wait_timeout = @@rocksdb_lock_wait_timeout;
+set @prior_deadlock_detect = @@rocksdb_deadlock_detect;
+set @prior_max_latest_deadlocks = @@rocksdb_max_latest_deadlocks;
+set global rocksdb_deadlock_detect = on;
+set global rocksdb_lock_wait_timeout = 10000;
+--echo # Clears deadlock buffer of any prior deadlocks.
+set global rocksdb_max_latest_deadlocks = 0;
+set global rocksdb_max_latest_deadlocks = @prior_max_latest_deadlocks;
+let $engine = rocksdb;
+
+--source include/count_sessions.inc
+connect (con1,localhost,root,,);
+let $con1= `SELECT CONNECTION_ID()`;
+
+connect (con2,localhost,root,,);
+let $con2= `SELECT CONNECTION_ID()`;
+
+connect (con3,localhost,root,,);
+let $con3= `SELECT CONNECTION_ID()`;
+
+connection default;
+eval create table t (i int primary key) engine=$engine;
+insert into t values (1), (2), (3);
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /WAITING KEY: [0-9a-f]{16}/KEY/ /TRANSACTION ID: [0-9]*/TXN_ID/ /TIMESTAMP: [0-9]*/TSTAMP/
+show engine rocksdb transaction status;
+
+echo Deadlock #1;
+--source include/simple_deadlock.inc
+connection default;
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /WAITING KEY: [0-9a-f]{16}/KEY/ /TRANSACTION ID: [0-9]*/TXN_ID/ /TIMESTAMP: [0-9]*/TSTAMP/
+show engine rocksdb transaction status;
+
+echo Deadlock #2;
+--source include/simple_deadlock.inc
+connection default;
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /WAITING KEY: [0-9a-f]{16}/KEY/ /TRANSACTION ID: [0-9]*/TXN_ID/ /TIMESTAMP: [0-9]*/TSTAMP/
+show engine rocksdb transaction status;
+set global rocksdb_max_latest_deadlocks = 10;
+
+echo Deadlock #3;
+--source include/simple_deadlock.inc
+connection default;
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /WAITING KEY: [0-9a-f]{16}/KEY/ /TRANSACTION ID: [0-9]*/TXN_ID/ /TIMESTAMP: [0-9]*/TSTAMP/
+show engine rocksdb transaction status;
+set global rocksdb_max_latest_deadlocks = 1;
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /WAITING KEY: [0-9a-f]{16}/KEY/ /TRANSACTION ID: [0-9]*/TXN_ID/ /TIMESTAMP: [0-9]*/TSTAMP/
+show engine rocksdb transaction status;
+
+connection con3;
+set rocksdb_deadlock_detect_depth = 2;
+
+echo Deadlock #4;
+connection con1;
+begin;
+select * from t where i=1 for update;
+
+connection con2;
+begin;
+select * from t where i=2 for update;
+
+connection con3;
+begin;
+select * from t where i=3 for update;
+
+connection con1;
+send select * from t where i=2 for update;
+
+connection con2;
+let $wait_condition = select count(*) = 1 from information_schema.rocksdb_trx
+where thread_id = $con1 and waiting_key != "";
+--source include/wait_condition.inc
+
+send select * from t where i=3 for update;
+
+connection con3;
+let $wait_condition = select count(*) = 1 from information_schema.rocksdb_trx
+where thread_id = $con2 and waiting_key != "";
+--source include/wait_condition.inc
+
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_row_lock_deadlocks';
+--error ER_LOCK_DEADLOCK
+select * from t where i=1 for update;
+select case when variable_value-@a = 1 then 'true' else 'false' end as deadlocks from information_schema.global_status where variable_name='rocksdb_row_lock_deadlocks';
+rollback;
+
+connection con2;
+reap;
+rollback;
+
+connection con1;
+reap;
+rollback;
+
+connection default;
+set global rocksdb_max_latest_deadlocks = 5;
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /WAITING KEY: [0-9a-f]{16}/KEY/ /TRANSACTION ID: [0-9]*/TXN_ID/ /TIMESTAMP: [0-9]*/TSTAMP/
+show engine rocksdb transaction status;
+
+echo Deadlock #5;
+connection con1;
+begin;
+select * from t where i=1 for update;
+
+connection con2;
+begin;
+select * from t where i=2 for update;
+
+connection con3;
+begin;
+select * from t where i=3 lock in share mode;
+
+connection con1;
+select * from t where i=100 for update;
+select * from t where i=101 for update;
+send select * from t where i=2 for update;
+
+connection con2;
+let $wait_condition = select count(*) = 1 from information_schema.rocksdb_trx
+where thread_id = $con1 and waiting_key != "";
+--source include/wait_condition.inc
+
+select * from t where i=3 lock in share mode;
+select * from t where i=200 for update;
+select * from t where i=201 for update;
+
+--error ER_LOCK_DEADLOCK
+select * from t where i=1 lock in share mode;
+rollback;
+
+connection con1;
+reap;
+rollback;
+
+connection con3;
+rollback;
+
+connection default;
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /WAITING KEY: [0-9a-f]{16}/KEY/ /TRANSACTION ID: [0-9]*/TXN_ID/ /TIMESTAMP: [0-9]*/TSTAMP/
+show engine rocksdb transaction status;
+
+echo Deadlock #6;
+connection con1;
+create table t1 (id int primary key, value int) engine=rocksdb;
+insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5);
+begin;
+update t1 set value=value+100 where id=1;
+update t1 set value=value+100 where id=2;
+
+connection con2;
+begin;
+update t1 set value=value+200 where id=3;
+
+connection con1;
+send update t1 set value=value+100 where id=3;
+
+connection con2;
+let $wait_condition = select count(*) = 1 from information_schema.rocksdb_trx
+where thread_id = $con1 and waiting_key != "";
+--source include/wait_condition.inc
+--error ER_LOCK_DEADLOCK
+update t1 set value=value+200 where id=1;
+
+# con2 tx is automatically rolled back
+connection con1;
+reap;
+select * from t1;
+drop table t1;
+
+connection default;
+
+disconnect con1;
+disconnect con2;
+disconnect con3;
+
+set global rocksdb_lock_wait_timeout = @prior_lock_wait_timeout;
+set global rocksdb_deadlock_detect = @prior_deadlock_detect;
+drop table t;
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /WAITING KEY: [0-9a-f]{16}/KEY/ /TRANSACTION ID: [0-9]*/TXN_ID/ /INDEX_ID: [0-9a-f]*/IDX_ID/ /TIMESTAMP: [0-9]*/TSTAMP/
+show engine rocksdb transaction status;
+set global rocksdb_max_latest_deadlocks = 0;
+--echo # Clears deadlock buffer of any existent deadlocks.
+set global rocksdb_max_latest_deadlocks = @prior_max_latest_deadlocks;
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /WAITING KEY: [0-9a-f]{16}/KEY/ /TRANSACTION ID: [0-9]*/TXN_ID/ /INDEX_ID: [0-9a-f]*/IDX_ID/ /TIMESTAMP: [0-9]*/TSTAMP/
+show engine rocksdb transaction status;
+--source include/wait_until_count_sessions.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/delete.test b/storage/rocksdb/mysql-test/rocksdb/t/delete.test
new file mode 100644
index 00000000..c829dd9d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/delete.test
@@ -0,0 +1,101 @@
+--source include/have_rocksdb.inc
+
+#
+# Basic DELETE statements.
+# DELETE LOW_PRIORITY is covered in delete_low_prio test
+# DELETE QUICK is covered in delete_quick test (syntax only)
+# DELETE IGNORE is covered in delete_ignore test
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (10000,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+
+# Single-table DELETE
+
+DELETE FROM t1 WHERE b IN ('c');
+--sorted_result
+SELECT a,b FROM t1;
+
+DELETE FROM t1 WHERE a < 0 OR b = 'a';
+--sorted_result
+SELECT a,b FROM t1;
+
+# ORDER BY and LIMIT
+DELETE FROM t1 WHERE a <= 4 ORDER BY b DESC LIMIT 1;
+--sorted_result
+SELECT a,b FROM t1;
+
+# Multi-table DELETE
+
+CREATE TABLE t2 (c CHAR(8), d INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+--sorted_result
+SELECT c,d FROM t2;
+
+DELETE t2.* FROM t1, t2 WHERE c < b AND a + d != 1;
+--sorted_result
+SELECT a,b FROM t1;
+--sorted_result
+SELECT c,d FROM t2;
+
+DELETE FROM t2, t1.* USING t2, t1 WHERE c = 'foobar' and b = c;
+--sorted_result
+SELECT a,b FROM t1;
+--sorted_result
+SELECT c,d FROM t2;
+
+DELETE FROM t1;
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1, t2;
+
+
+#
+# Transactional DELETE
+#
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'f'),(7,'g'),(8,'h'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+
+BEGIN;
+DELETE FROM t1 WHERE b IN ('c');
+--sorted_result
+SELECT a,b FROM t1;
+DELETE FROM t1 WHERE a < 0 OR b = 'a';
+COMMIT;
+--sorted_result
+SELECT a,b FROM t1;
+
+# Savepoints
+
+BEGIN;
+DELETE FROM t1 WHERE a <= 4 ORDER BY b DESC LIMIT 1;
+SAVEPOINT spt1;
+
+DELETE FROM t1;
+RELEASE SAVEPOINT spt1;
+ROLLBACK;
+--sorted_result
+SELECT a,b FROM t1;
+
+BEGIN;
+DELETE FROM t1 WHERE a <= 4 ORDER BY b DESC LIMIT 1;
+SAVEPOINT spt1;
+DELETE FROM t1;
+INSERT INTO t1 (a,b) VALUES (1,'a');
+--error ER_ROLLBACK_TO_SAVEPOINT
+ROLLBACK TO SAVEPOINT spt1;
+--error ER_ROLLBACK_ONLY
+COMMIT;
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/delete_ignore.test b/storage/rocksdb/mysql-test/rocksdb/t/delete_ignore.test
new file mode 100644
index 00000000..d087d80f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/delete_ignore.test
@@ -0,0 +1,37 @@
+--source include/have_rocksdb.inc
+
+#
+# DELETE IGNORE
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+
+INSERT INTO t1 (a,b) VALUES (10000,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+
+CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY, c CHAR(8), d INT) ENGINE=rocksdb;
+
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+--sorted_result
+SELECT a,b FROM t1;
+--sorted_result
+SELECT c,d FROM t2;
+
+DELETE IGNORE FROM t1 WHERE b IS NOT NULL ORDER BY a LIMIT 1;
+--sorted_result
+SELECT a,b FROM t1;
+
+DELETE IGNORE t1.*, t2.* FROM t1, t2 WHERE c < b OR a != ( SELECT 1 UNION SELECT 2 );
+--sorted_result
+SELECT a,b FROM t1;
+--sorted_result
+SELECT c,d FROM t2;
+
+# Cleanup
+DROP TABLE t1, t2;
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/delete_quick.test b/storage/rocksdb/mysql-test/rocksdb/t/delete_quick.test
new file mode 100644
index 00000000..127ef47d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/delete_quick.test
@@ -0,0 +1,32 @@
+--source include/have_rocksdb.inc
+
+#
+# DELETE QUICK syntax.
+# For now we only check that the keyword is accepted,
+# without actually checking whether the feature works.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8), PRIMARY KEY (a)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+
+DELETE QUICK FROM t1 WHERE a = 1 OR b > 'foo';
+--sorted_result
+SELECT a,b FROM t1;
+
+CREATE TABLE t2 (c CHAR(8), d INT, PRIMARY KEY (c)) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+--sorted_result
+SELECT c,d FROM t2;
+
+DELETE QUICK FROM t2, t1.* USING t2, t1 WHERE c IS NULL OR a = d;
+--sorted_result
+SELECT a,b FROM t1;
+--sorted_result
+SELECT c,d FROM t2;
+
+DROP TABLE t1, t2;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/delete_with_keys.test b/storage/rocksdb/mysql-test/rocksdb/t/delete_with_keys.test
new file mode 100644
index 00000000..f4d890eb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/delete_with_keys.test
@@ -0,0 +1,39 @@
+--source include/have_rocksdb.inc
+
+#
+# DELETE statements for tables with keys
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, KEY(b)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
+DELETE FROM t1 WHERE b > 'y';
+DELETE FROM t1 WHERE a=2;
+
+--sorted_result
+SELECT a,b FROM t1;
+DELETE FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
+DELETE FROM t1 WHERE b > 'y';
+DELETE FROM t1 WHERE a=2;
+
+--sorted_result
+SELECT a,b FROM t1;
+DELETE FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT, b INT, c INT, pk INT AUTO_INCREMENT PRIMARY KEY, KEY(a), KEY (b)) ENGINE=rocksdb;
+
+INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6),(7,8,9);
+DELETE FROM t1 WHERE a = 10 OR b = 20 ORDER BY c LIMIT 1;
+--sorted_result
+SELECT a,b,c FROM t1;
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/describe.test b/storage/rocksdb/mysql-test/rocksdb/t/describe.test
new file mode 100644
index 00000000..9bc5d299
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/describe.test
@@ -0,0 +1,24 @@
+--source include/have_rocksdb.inc
+
+#
+# DESCRIBE statement
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8), PRIMARY KEY (a)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (100,'foo'),(2, 'b');
+
+CREATE TABLE t2 (a INT, b CHAR(8), PRIMARY KEY (b)) ENGINE=rocksdb CHARACTER SET utf8;
+INSERT INTO t2 (a,b) VALUES (1, 'bar');
+
+CREATE TABLE t3 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb CHARACTER SET utf8;
+
+DESCRIBE t1;
+DESC t2 a;
+DESCRIBE t3 '%';
+
+DROP TABLE t1, t2, t3;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def
new file mode 100644
index 00000000..627d7da4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def
@@ -0,0 +1,98 @@
+##
+## See also: storage/rocksdb/mysql-test/rocksdb/suite.pm - tests on
+## platforms and under valgrind are disabled from there.
+##
+
+##
+## Tests that are disabled in the upstream
+##
+cons_snapshot_serializable : Consistent read does not work on serializable
+level_read_uncommitted : Not supported
+level_serializable: Not supported
+
+
+##
+## Tests that require FB/MySQL specific features for which there are
+## no plans of ever porting them into MariaDB
+##
+optimizer_loose_index_scans: MariaDB doesnt support Skip Scan
+mysqldump : MariaDB's mysqldump doesn't support --print-ordering-key
+mysqldump2 : MariaDB's mysqldump doesn't support --print-ordering-key
+native_procedure : Not supported in MariaDB
+slow_query_log: MDEV-11480
+select_for_update_skip_locked_nowait: MDEV-11481
+create_no_primary_key_table: MariaDB doesn't have --block_create_no_primary_key
+explicit_snapshot: MariaDB doesn't support Shared/Explicit snapshots
+percona_nonflushing_analyze_debug : Requires Percona Server's Non-flushing ANALYZE feature
+com_rpc_tx : Requires connection attributes and detached sessions
+mysqlbinlog_blind_replace: requires @@enable_blind_replace support
+optimize_myrocks_replace_into_base: requires @@enable_blind_replace support
+optimize_myrocks_replace_into_lock: requires @@enable_blind_replace support
+rocksdb.skip_core_dump_on_error: requires @@binlog_error_action support
+bypass_select_basic_bloom : Query bypass is not supported
+bypass_select_basic : Query bypass is not supported
+
+rocksdb_read_free_rpl : Read-Free replication is not supported
+rocksdb_read_free_rpl_stress : Read-Free replication is not supported
+
+blind_delete_rr : Read-Free replication is not supported
+blind_delete_rc : Read-Free replication is not supported
+
+force_shutdown: requires support for SHUTDOWN statement which calls exit().
+
+##
+## Tests that do not fit MariaDB's test environment. Upstream seems to test
+## on boxes with much more RAM and CPU, some tests are more of a stress tests
+## than functional tests or bug testcases.
+##
+rqg_examples : Test that use RQG are disabled
+rqg_runtime : Test that use RQG are disabled
+rqg_transactions : Test that use RQG are disabled
+allow_no_pk_concurrent_insert: stress test
+rocksdb_deadlock_stress_rc: stress test
+rocksdb_deadlock_stress_rr: stress test
+use_direct_reads: Direct IO is not supported on all filesystems
+
+##
+## Tests which hit a problem elsewhere (Upstream, SQL layer, etc)
+##
+persistent_cache: Upstream RocksDB bug https://github.com/facebook/mysql-5.6/issues/579
+collation: Fails on gcc 4.8 and before, MDEV-12433
+col_opt_zerofill: MDEV-14729 (also MDEV-14165 which was fixed): problem in the client
+
+
+##
+## Tests that require FB/MySQL specific features which MariaDB
+## currently doesnt have but eventually might get:
+##
+gap_lock_issue254: MDEV-11735: MyRocks: Gap Lock detector support
+gap_lock_raise_error: MDEV-11735: MyRocks: Gap Lock detector support
+show_engine : MariaRocks: MariaDB doesnt support SHOW ENGINE rocksdb TRANSACTION STATUS
+issue243_transactionStatus: MariaDB doesnt support SHOW ENGINE rocksdb TRANSACTION STATUS
+rpl_row_not_found : MariaDB doesnt support slave_exec_mode='SEMI_STRICT'
+rpl_row_not_found_rc : MariaDB doesnt support slave_exec_mode='SEMI_STRICT'
+
+ddl_high_priority: Needs fractional @@lock_wait_timeout
+deadlock_tracking : Needs SHOW ENGINE ROCKSDB TRANSACTION STATUS
+bytes_written: Needs I_S.TABLE_STATISTICS.IO_WRITE_BYTES
+trx_info_rpl : MariaRocks: @@rpl_skip_tx_api doesn't work, yet.
+lock_wait_timeout_stats: MDEV-13404
+rpl_row_triggers : Requires read-free slave.
+
+##
+## Test failures (in buildbot or else where)
+##
+
+compact_deletes: MDEV-12663 : rocksdb.compact_deletes times out and causes other tests to fail
+blind_delete_without_tx_api: MDEV-12286: rocksdb.blind_delete_without_tx_api test fails
+information_schema: MDEV-14372: unstable testcase
+
+##
+## Tests that fail for some other reason
+##
+
+mysqlbinlog_gtid_skip_empty_trans_rocksdb : MariaRocks: requires GTIDs
+drop_table: Hangs on shutdown
+add_index_inplace: not stable result
+rocksdb_range2 : result difference, update after MDEV-16746 is fixed
+add_index_inplace: FORCE INDEX gives wrong count
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/drop_database.test b/storage/rocksdb/mysql-test/rocksdb/t/drop_database.test
new file mode 100644
index 00000000..174a4bbf
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/drop_database.test
@@ -0,0 +1,11 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS test_drop_database;
+--enable_warnings
+
+CREATE DATABASE test_drop_database;
+CREATE TABLE t1 (a int, b int, c int, primary key (a), unique key (b)) ENGINE=ROCKSDB;
+ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (a);
+DROP TABLE t1;
+DROP DATABASE test_drop_database;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/drop_index_inplace.test b/storage/rocksdb/mysql-test/rocksdb/t/drop_index_inplace.test
new file mode 100644
index 00000000..57d7cdf5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/drop_index_inplace.test
@@ -0,0 +1,116 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+##
+## test dropping index inplace
+##
+
+CREATE TABLE t1 (a INT, b INT AUTO_INCREMENT, KEY ka(a), KEY kb(a,b), PRIMARY KEY(b)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (a) VALUES (1);
+INSERT INTO t1 (a) VALUES (3);
+INSERT INTO t1 (a) VALUES (5);
+
+ALTER TABLE t1 DROP INDEX ka, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+
+# Key ka does not exist in table t1
+--error 1176
+SELECT * FROM t1 FORCE INDEX(ka) where a > 1;
+
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(kb) where a > 1;
+--sorted_result
+SELECT * FROM t1 where b > 1;
+
+DROP TABLE t1;
+
+##
+## test dropping multiple indexes at once and multi-part indexes
+##
+
+CREATE TABLE t1 (a INT AUTO_INCREMENT, b INT, c INT, KEY kb(b), KEY kbc(b,c), KEY kc(c), PRIMARY KEY(a)) ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) VALUES (1,2);
+INSERT INTO t1 (b,c) VALUES (3,4);
+INSERT INTO t1 (b,c) VALUES (5,6);
+ALTER TABLE t1 DROP INDEX kb, DROP INDEX kbc, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+
+
+# test restarting to make sure everything is still ok and persisted properly
+--source include/restart_mysqld.inc
+
+SHOW CREATE TABLE t1;
+
+INSERT INTO t1 (b,c) VALUES (1,2);
+INSERT INTO t1 (b,c) VALUES (3,4);
+INSERT INTO t1 (b,c) VALUES (5,6);
+
+--sorted_result
+SELECT * FROM t1 FORCE INDEX(kc) where c > 3;
+--sorted_result
+SELECT * FROM t1 where b > 3;
+
+DROP TABLE t1;
+
+# test dropping pk to see if thats still ok
+CREATE TABLE t1 (a INT, b INT, c INT, KEY kb(b), KEY kbc(b,c), KEY kc(c), PRIMARY KEY(a)) ENGINE=rocksdb;
+SHOW INDEX IN t1;
+ALTER TABLE t1 DROP INDEX kb, DROP INDEX kbc, ALGORITHM=INPLACE;
+SHOW INDEX IN t1;
+
+ALTER TABLE t1 DROP PRIMARY KEY;
+SHOW INDEX IN t1;
+# test dropping index on tables with no pk
+ALTER TABLE t1 DROP INDEX kc, ALGORITHM=INPLACE;
+SHOW INDEX IN t1;
+
+DROP TABLE t1;
+
+# test dropping unique keys
+CREATE TABLE t1 (a INT AUTO_INCREMENT, b INT, c INT, PRIMARY KEY(a)) ENGINE=rocksdb;
+ALTER TABLE t1 ADD UNIQUE INDEX kb(b);
+ALTER TABLE t1 ADD UNIQUE INDEX kbc(b,c);
+ALTER TABLE t1 ADD UNIQUE INDEX kc(c);
+SHOW INDEX IN t1;
+
+ALTER TABLE t1 DROP INDEX kb, DROP INDEX kbc;
+SHOW INDEX IN t1;
+
+# test restarting to make sure everything is still ok and persisted properly
+--source include/restart_mysqld.inc
+
+--sorted_result
+INSERT INTO t1 (b,c) VALUES (1,2);
+INSERT INTO t1 (b,c) VALUES (3,4);
+INSERT INTO t1 (b,c) VALUES (5,6);
+SELECT * FROM t1 FORCE INDEX(kc) where c > 3;
+
+# test dropping index on tables with no pk
+ALTER TABLE t1 DROP INDEX kc, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+# case where dropping column, where column is the key, we dont want to use
+# inplace in this scenario
+CREATE TABLE IF NOT EXISTS t1 (col1 INT, col2 INT, col3 INT);
+INSERT INTO t1 (col1,col2,col3) VALUES (1,2,3);
+ALTER TABLE t1 ADD KEY idx ( col1, col2 );
+ANALYZE TABLE t1;
+ALTER TABLE t1 DROP COLUMN col2;
+ALTER TABLE t1 DROP COLUMN col3;
+DROP TABLE t1;
+
+# case drop and add at same time, should not use inplace algorithm yet
+CREATE TABLE IF NOT EXISTS t1 (col1 INT, col2 INT, col3 INT);
+INSERT INTO t1 (col1,col2,col3) VALUES (1,2,3);
+ALTER TABLE t1 ADD KEY idx ( col1, col2 );
+ANALYZE TABLE t1;
+ALTER TABLE t1 DROP COLUMN col2;
+ALTER TABLE t1 DROP COLUMN col3;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/drop_stats_procedure.inc b/storage/rocksdb/mysql-test/rocksdb/t/drop_stats_procedure.inc
new file mode 100644
index 00000000..b4000440
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/drop_stats_procedure.inc
@@ -0,0 +1,3 @@
+drop procedure save_read_stats;
+drop procedure get_read_stats;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/drop_table-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/drop_table-master.opt
new file mode 100644
index 00000000..f40e9db5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/drop_table-master.opt
@@ -0,0 +1,3 @@
+--rocksdb_max_subcompactions=1
+--rocksdb_default_cf_options=write_buffer_size=512k;target_file_size_base=512k;level0_file_num_compaction_trigger=2;level0_slowdown_writes_trigger=-1;level0_stop_writes_trigger=1000;max_bytes_for_level_base=1m
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/drop_table.test b/storage/rocksdb/mysql-test/rocksdb/t/drop_table.test
new file mode 100644
index 00000000..9667c7ba
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/drop_table.test
@@ -0,0 +1,145 @@
+--source include/have_rocksdb.inc
+call mtr.add_suppression("Column family 'cf1' not found");
+call mtr.add_suppression("Column family 'rev:cf2' not found");
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+--enable_warnings
+
+call mtr.add_suppression("Column family 'cf1' not found");
+call mtr.add_suppression("Column family 'rev:cf2' not found");
+call mtr.add_suppression("LibRocksDB");
+
+# Start from clean slate
+set global rocksdb_compact_cf = 'cf1';
+set global rocksdb_compact_cf = 'rev:cf2';
+set global rocksdb_signal_drop_index_thread = 1;
+--source include/restart_mysqld.inc
+
+CREATE TABLE t1 (
+ a int not null,
+ b int not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+CREATE TABLE t2 (
+ a int not null,
+ b int not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+CREATE TABLE t3 (
+ a int not null,
+ b int not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+CREATE TABLE t4 (
+ a int not null,
+ b int not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+# Populate tables
+let $max = 1000;
+let $table = t1;
+--source drop_table_repopulate_table.inc
+let $table = t2;
+--source drop_table_repopulate_table.inc
+let $table = t3;
+--source drop_table_repopulate_table.inc
+let $table = t4;
+--source drop_table_repopulate_table.inc
+
+drop table t2;
+
+# Restart the server before t2's indices are deleted
+--source include/restart_mysqld.inc
+
+let $table = t1;
+--source drop_table_repopulate_table.inc
+let $table = t4;
+--source drop_table_repopulate_table.inc
+
+drop table t3;
+
+# Insert enough data to trigger compactions that eliminate t2 and t3
+let $max = 50000;
+let $table = t1;
+--source drop_table_repopulate_table.inc
+let $table = t4;
+--source drop_table_repopulate_table.inc
+
+# Run manual compaction, then restarting mysqld
+# and confirming it is not blocked.
+SET GLOBAL rocksdb_max_manual_compactions = 2;
+SET GLOBAL rocksdb_debug_manual_compaction_delay = 3600;
+connect (con1, localhost, root,,);
+connect (con2, localhost, root,,);
+connect (con3, localhost, root,,);
+connection con1;
+send SET GLOBAL rocksdb_compact_cf='cf1';
+connection con2;
+send SET GLOBAL rocksdb_compact_cf='rev:cf2';
+connection default;
+let $wait_condition = select count(*) = 2 from information_schema.processlist where info like 'SET GLOBAL rocksdb_compact_cf%';
+--source include/wait_condition.inc
+# longer enough than manual compaction thread to start compaction
+--sleep 2
+select * from information_schema.global_status where variable_name='rocksdb_manual_compactions_running';
+
+connection con3;
+--error ER_INTERNAL_ERROR
+SET GLOBAL rocksdb_compact_cf='cf1';
+--error ER_INTERNAL_ERROR
+SET GLOBAL rocksdb_compact_cf='rev:cf2';
+
+connection default;
+--source include/restart_mysqld.inc
+
+drop table t4;
+
+# Restart the server before t4's indices are deleted
+--source include/restart_mysqld.inc
+
+# Make sure new table gets unique indices
+CREATE TABLE t5 (
+ a int not null,
+ b int not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+let $max = 1000;
+let $table = t5;
+--source drop_table_repopulate_table.inc
+
+drop table t5;
+
+# Manually compact column families, cleaning up all lingering data
+set global rocksdb_compact_cf = 'cf1';
+set global rocksdb_compact_cf = 'rev:cf2';
+
+# Signal thread to check for dropped indices
+set global rocksdb_signal_drop_index_thread = 1;
+
+let $show_rpl_debug_info= 1; # to force post-failure printout
+let $wait_timeout= 300; # Override default 30 seconds with 300.
+let $wait_condition = select count(*) = 0
+ as c from information_schema.rocksdb_global_info
+ where TYPE = 'DDL_DROP_INDEX_ONGOING';
+--source include/wait_condition.inc
+
+## Upstream has removed the following:
+--disable_parsing
+--enable_parsing
+# Cleanup
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/drop_table2.test b/storage/rocksdb/mysql-test/rocksdb/t/drop_table2.test
new file mode 100644
index 00000000..a9012aea
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/drop_table2.test
@@ -0,0 +1,131 @@
+--source include/have_rocksdb.inc
+
+call mtr.add_suppression("Column family 'cf1' not found");
+call mtr.add_suppression("Column family 'rev:cf2' not found");
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+--enable_warnings
+
+call mtr.add_suppression("Column family 'cf1' not found");
+call mtr.add_suppression("Column family 'rev:cf2' not found");
+
+# Start from clean slate
+set global rocksdb_compact_cf = 'cf1';
+set global rocksdb_compact_cf = 'rev:cf2';
+set global rocksdb_signal_drop_index_thread = 1;
+--source include/restart_mysqld.inc
+
+CREATE TABLE t1 (
+ a int not null,
+ b int not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+CREATE TABLE t2 (
+ a int not null,
+ b int not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+CREATE TABLE t3 (
+ a int not null,
+ b int not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+CREATE TABLE t4 (
+ a int not null,
+ b int not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+# Populate tables
+let $max = 1000;
+let $table = t1;
+--source drop_table_repopulate_table.inc
+let $table = t2;
+--source drop_table_repopulate_table.inc
+let $table = t3;
+--source drop_table_repopulate_table.inc
+let $table = t4;
+--source drop_table_repopulate_table.inc
+
+
+# Restart the server before t2's indices are deleted
+--source include/restart_mysqld.inc
+
+let $table = t1;
+--source drop_table_repopulate_table.inc
+let $table = t4;
+--source drop_table_repopulate_table.inc
+
+
+# Insert enough data to trigger compactions that eliminate t2 and t3
+let $max = 50000;
+let $table = t1;
+--source drop_table_repopulate_table.inc
+let $table = t4;
+--source drop_table_repopulate_table.inc
+
+
+# Restart the server before t4's indices are deleted
+--source include/restart_mysqld.inc
+
+# Make sure new table gets unique indices
+CREATE TABLE t5 (
+ a int not null,
+ b int not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+let $max = 1000;
+let $table = t5;
+--source drop_table_repopulate_table.inc
+
+set @@global.rocksdb_compact_cf = 'cf1';
+set @@global.rocksdb_compact_cf = 'rev:cf2';
+set @@global.rocksdb_compact_cf = 'default';
+
+perl;
+$size+=-s $_ for (<$ENV{MYSQLTEST_VARDIR}/mysqld.1/data/\#rocksdb/*.sst>);
+$filename= "$ENV{MYSQLTEST_VARDIR}/tmp/size_output";
+open(F, '>', $filename) || die("Can't open file $filename: $!");
+print F $size;
+EOF
+drop table t1;
+drop table t2;
+drop table t3;
+drop table t4;
+drop table t5;
+
+set @@global.rocksdb_compact_cf = 'cf1';
+set @@global.rocksdb_compact_cf = 'rev:cf2';
+set @@global.rocksdb_compact_cf = 'default';
+
+let $show_rpl_debug_info= 1; # to force post-failure printout
+let $wait_timeout= 300; # Override default 30 seconds with 300.
+let $wait_condition = select count(*) = 0
+ as c from information_schema.rocksdb_global_info
+ where TYPE = 'DDL_DROP_INDEX_ONGOING';
+--source include/wait_condition.inc
+
+# Check that space is reclaimed
+perl;
+$size+=-s $_ for (<$ENV{MYSQLTEST_VARDIR}/mysqld.1/data/\#rocksdb/*.sst>);
+$filename= "$ENV{MYSQLTEST_VARDIR}/tmp/size_output";
+open(F, '<', $filename) || die("Can't open file $filename: $!");
+$old=<F>;
+print "Compacted\n" if $old > $size * 2;
+EOF
+
+# Cleanup
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/drop_table3-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/drop_table3-master.opt
new file mode 100644
index 00000000..a9ebc4ec
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/drop_table3-master.opt
@@ -0,0 +1,2 @@
+--rocksdb_max_subcompactions=1
+--rocksdb_default_cf_options=write_buffer_size=16k;target_file_size_base=16k;level0_slowdown_writes_trigger=-1;level0_stop_writes_trigger=1000;compression_per_level=kNoCompression;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/drop_table3.inc b/storage/rocksdb/mysql-test/rocksdb/t/drop_table3.inc
new file mode 100644
index 00000000..1a044384
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/drop_table3.inc
@@ -0,0 +1,52 @@
+--source include/have_rocksdb.inc
+
+call mtr.add_suppression("Column family 'cf1' not found");
+call mtr.add_suppression("Column family 'rev:cf2' not found");
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+call mtr.add_suppression("Column family 'cf1' not found");
+call mtr.add_suppression("Column family 'rev:cf2' not found");
+
+# Start from clean slate
+set global rocksdb_compact_cf = 'cf1';
+set global rocksdb_compact_cf = 'rev:cf2';
+set global rocksdb_signal_drop_index_thread = 1;
+--source include/restart_mysqld.inc
+
+CREATE TABLE t1 (
+ a int not null,
+ b int not null,
+ c varchar(500) not null,
+ primary key (a,b) comment 'cf1',
+ key (b) comment 'rev:cf2'
+) ENGINE=RocksDB;
+
+# Populate tables
+let $max = 50000;
+let $table = t1;
+--source drop_table3_repopulate_table.inc
+
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_compact_read_bytes';
+if ($truncate_table)
+{
+ truncate table t1;
+}
+if ($drop_table)
+{
+ drop table t1;
+}
+
+let $show_rpl_debug_info= 1; # to force post-failure printout
+let $wait_timeout= 300; # Override default 30 seconds with 300.
+let $wait_condition = select count(*) = 0
+ as c from information_schema.rocksdb_global_info
+ where TYPE = 'DDL_DROP_INDEX_ONGOING';
+--source include/wait_condition.inc
+
+select case when variable_value-@a < 500000 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_compact_read_bytes';
+
+# Cleanup
+DROP TABLE IF EXISTS t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/drop_table3.test b/storage/rocksdb/mysql-test/rocksdb/t/drop_table3.test
new file mode 100644
index 00000000..b3a6bf99
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/drop_table3.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+
+-- let $truncate_table = 0
+-- let $drop_table = 1
+-- source drop_table3.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/drop_table3_repopulate_table.inc b/storage/rocksdb/mysql-test/rocksdb/t/drop_table3_repopulate_table.inc
new file mode 100644
index 00000000..c34af072
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/drop_table3_repopulate_table.inc
@@ -0,0 +1,15 @@
+# Usage:
+# let $max = <count>;
+# let $table = <table name>;
+# --source drop_table_repopulate_table.inc
+#
+eval DELETE FROM $table;
+
+--disable_query_log
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO $table VALUES ($i, $i, rpad('a', 499, 'b'));
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/drop_table_repopulate_table.inc b/storage/rocksdb/mysql-test/rocksdb/t/drop_table_repopulate_table.inc
new file mode 100644
index 00000000..6faf41ef
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/drop_table_repopulate_table.inc
@@ -0,0 +1,15 @@
+# Usage:
+# let $max = <count>;
+# let $table = <table name>;
+# --source drop_table_repopulate_table.inc
+#
+eval DELETE FROM $table;
+
+--disable_query_log
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO $table VALUES ($i, $i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/drop_table_sync.inc b/storage/rocksdb/mysql-test/rocksdb/t/drop_table_sync.inc
new file mode 100644
index 00000000..c6a3ccde
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/drop_table_sync.inc
@@ -0,0 +1,6 @@
+let $show_rpl_debug_info= 1; # to force post-failure printout
+let $wait_timeout= 300; # Override default 30 seconds with 300.
+let $wait_condition = select count(*) = 0
+ as c from information_schema.rocksdb_global_info
+ where TYPE = 'DDL_DROP_INDEX_ONGOING';
+--source include/wait_condition.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/dup_key_update.test b/storage/rocksdb/mysql-test/rocksdb/t/dup_key_update.test
new file mode 100644
index 00000000..b4a0c9e5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/dup_key_update.test
@@ -0,0 +1,45 @@
+--source include/have_rocksdb.inc
+
+# Test insert ... on duplicate key update statements
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+CREATE TABLE t1 (id1 INT, id2 INT, id3 INT,
+ PRIMARY KEY (id1, id2, id3),
+ UNIQUE KEY (id3, id1)) ENGINE=ROCKSDB;
+
+CREATE TABLE t2 (id1 INT, id2 INT, id3 INT,
+ PRIMARY KEY (id1, id2, id3),
+ UNIQUE KEY (id3, id1) COMMENT 'rev:cf') ENGINE=ROCKSDB;
+
+
+--source include/dup_key_update.inc
+
+# Cleanup
+DROP TABLE t1;
+DROP TABLE t2;
+
+set global rocksdb_large_prefix=1;
+CREATE TABLE t1 (id1 varchar(128) CHARACTER SET latin1 COLLATE latin1_bin,
+ id2 varchar(256) CHARACTER SET utf8 COLLATE utf8_bin,
+ id3 varchar(200) CHARACTER SET latin1 COLLATE latin1_swedish_ci,
+ PRIMARY KEY (id1, id2, id3),
+ UNIQUE KEY (id3, id1)) ENGINE=ROCKSDB;
+set global rocksdb_large_prefix=DEFAULT;
+
+set global rocksdb_large_prefix=1;
+CREATE TABLE t2 (id1 varchar(128) CHARACTER SET latin1 COLLATE latin1_bin,
+ id2 varchar(256) CHARACTER SET utf8 COLLATE utf8_bin,
+ id3 varchar(200) CHARACTER SET latin1 COLLATE latin1_swedish_ci,
+ PRIMARY KEY (id1, id2, id3),
+ UNIQUE KEY (id3, id1) COMMENT 'rev:cf') ENGINE=ROCKSDB;
+set global rocksdb_large_prefix=DEFAULT;
+
+--source include/dup_key_update.inc
+
+# Cleanup
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/duplicate_table.test b/storage/rocksdb/mysql-test/rocksdb/t/duplicate_table.test
new file mode 100644
index 00000000..875f8514
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/duplicate_table.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+--disable_warnings
+DROP TABLE IF EXISTS t;
+--enable_warnings
+CREATE TABLE t(id int primary key) engine=rocksdb;
+INSERT INTO t values (1), (2), (3);
+--error ER_TABLE_EXISTS_ERROR
+CREATE TABLE t(id int primary key) engine=rocksdb;
+FLUSH TABLES;
+move_file $MYSQLTEST_VARDIR/mysqld.1/data/test/t.frm $MYSQLTEST_VARDIR/mysqld.1/data/test/t.frm.tmp;
+--error ER_METADATA_INCONSISTENCY
+CREATE TABLE t(id int primary key) engine=rocksdb;
+move_file $MYSQLTEST_VARDIR/mysqld.1/data/test/t.frm.tmp $MYSQLTEST_VARDIR/mysqld.1/data/test/t.frm;
+FLUSH TABLES;
+SELECT * FROM t;
+DROP TABLE t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/explicit_snapshot-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/explicit_snapshot-master.opt
new file mode 100644
index 00000000..d7dd66b4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/explicit_snapshot-master.opt
@@ -0,0 +1 @@
+--log-bin --binlog_format=row --gtid_mode=ON --enforce_gtid_consistency --log-slave-updates
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/explicit_snapshot.test b/storage/rocksdb/mysql-test/rocksdb/t/explicit_snapshot.test
new file mode 100644
index 00000000..efe1980b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/explicit_snapshot.test
@@ -0,0 +1,263 @@
+source include/have_log_bin.inc;
+source include/have_rocksdb.inc;
+
+disable_warnings;
+DROP TABLE IF EXISTS t1;
+enable_warnings;
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+CREATE TABLE T1 (a INT PRIMARY KEY AUTO_INCREMENT) ENGINE=ROCKSDB;
+INSERT INTO T1 VALUES();
+
+#
+
+echo "con1: Creating explict snapshot";
+let $snapshot=
+ query_get_value(CREATE EXPLICIT ROCKSDB SNAPSHOT, Snapshot_ID, 1);
+SELECT * FROM T1;
+
+connection con2;
+echo "con2: Inserting a row";
+INSERT INTO T1 VALUES();
+SELECT * FROM T1;
+echo "con2: Attaching snapshot id $snapshot";
+disable_result_log;
+eval ATTACH EXPLICIT ROCKSDB SNAPSHOT $snapshot;
+enable_result_log;
+echo "con2: New row should not be visible";
+SELECT * FROM T1;
+echo "con2: Releasing snapshot";
+disable_result_log;
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+enable_result_log;
+echo "con2: New row should be visible";
+SELECT * FROM T1;
+
+connection con1;
+echo "con1: New row should not be visible";
+SELECT * FROM T1;
+echo "con1: Releasing snapshot";
+disable_result_log;
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+enable_result_log;
+echo "con1: New row should be visible";
+SELECT * FROM T1;
+
+#
+
+echo "con1: Starting shared snapshot";
+let $snapshot=
+query_get_value(START TRANSACTION WITH SHARED ROCKSDB SNAPSHOT, Snapshot_ID, 1);
+SELECT * FROM T1;
+
+connection con2;
+echo "con2: Inserting a row";
+INSERT INTO T1 VALUES();
+SELECT * FROM T1;
+echo "con2: Starting existing snapshot";
+disable_result_log;
+eval START TRANSACTION WITH EXISTING ROCKSDB SNAPSHOT $snapshot;
+enable_result_log;
+echo "con2: New row should not be visible";
+SELECT * FROM T1;
+COMMIT;
+echo "con2: New row should be visible";
+SELECT * FROM T1;
+
+connection con1;
+COMMIT;
+echo "con1: New row should be visible";
+SELECT * FROM T1;
+
+## Negative test cases
+
+connection con1;
+echo "con1: Creating explict snapshot";
+let $snapshot=
+ query_get_value(CREATE EXPLICIT ROCKSDB SNAPSHOT, Snapshot_ID, 1);
+echo "con2: Trying to insert row";
+error ER_UPDATES_WITH_EXPLICIT_SNAPSHOT;
+INSERT INTO T1 VALUES();
+
+connection con2;
+echo "con2: Attaching existing snapshot";
+disable_result_log;
+eval ATTACH EXPLICIT ROCKSDB SNAPSHOT $snapshot;
+enable_result_log;
+echo "con2: Trying to insert row";
+error ER_UPDATES_WITH_EXPLICIT_SNAPSHOT;
+INSERT INTO T1 VALUES();
+
+connection con1;
+disable_result_log;
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+enable_result_log;
+connection con2;
+disable_result_log;
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+enable_result_log;
+
+connection con1;
+echo "con1: Starting shared snapshot";
+let $snapshot=
+query_get_value(START TRANSACTION WITH SHARED ROCKSDB SNAPSHOT, Snapshot_ID, 1);
+echo "con1: Trying to insert row";
+error ER_UPDATES_WITH_CONSISTENT_SNAPSHOT;
+INSERT INTO T1 VALUES();
+
+connection con2;
+echo "con2: Starting existing snapshot";
+disable_result_log;
+eval START TRANSACTION WITH EXISTING ROCKSDB SNAPSHOT $snapshot;
+enable_result_log;
+echo "con2: Trying to insert row";
+error ER_UPDATES_WITH_CONSISTENT_SNAPSHOT;
+INSERT INTO T1 VALUES();
+
+connection con1;
+COMMIT;
+connection con2;
+COMMIT;
+
+## Test how overlapping explicit snapshot statements work
+
+connection con1;
+echo "con1: Creating explicit snapshot";
+disable_result_log;
+CREATE EXPLICIT ROCKSDB SNAPSHOT;
+enable_result_log;
+SELECT * FROM T1;
+
+connection con2;
+echo "con2: Inserting a row";
+INSERT INTO T1 VALUES();
+SELECT * FROM T1;
+
+connection con1;
+echo "con1: New row should not be seen";
+SELECT * FROM T1;
+echo "con1: Creating another explicit snapshot";
+disable_result_log;
+CREATE EXPLICIT ROCKSDB SNAPSHOT;
+enable_result_log;
+echo "con1: Now the new row should be seen";
+SELECT * FROM T1;
+
+#
+
+echo "con1: Starting transaction with consistent snapshot";
+disable_result_log;
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+enable_result_log;
+SELECT * FROM T1;
+
+connection con2;
+echo "con2: Inserting a row";
+INSERT INTO T1 VALUES();
+SELECT * FROM T1;
+
+connection con1;
+echo "con1: The new row should not be seen";
+SELECT * FROM T1;
+
+echo "con1: Creating another explicit snapshot";
+disable_result_log;
+CREATE EXPLICIT ROCKSDB SNAPSHOT;
+enable_result_log;
+echo "con1: The new row should still not be seen";
+SELECT * FROM T1;
+
+echo "con1: Committing trx";
+COMMIT;
+echo "con1: The new row should now be seen because of the new explicit snapshot created above";
+SELECT * FROM T1;
+
+connection con1;
+echo "con1: Releasing explicit snapshot";
+disable_result_log;
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+enable_result_log;
+
+#
+
+echo "con1: Starting transaction with shared snapshot";
+disable_result_log;
+START TRANSACTION WITH SHARED ROCKSDB SNAPSHOT;
+enable_result_log;
+SELECT * FROM T1;
+
+connection con2;
+echo "con2: Inserting a row";
+INSERT INTO T1 VALUES();
+SELECT * FROM T1;
+
+connection con1;
+echo "con1: The new row should not be seen";
+SELECT * FROM T1;
+
+echo "con1: Starting another transaction with shared snapshot";
+disable_result_log;
+START TRANSACTION WITH SHARED ROCKSDB SNAPSHOT;
+enable_result_log;
+echo "con1: The new row should now be seen";
+SELECT * FROM T1;
+COMMIT;
+
+#
+
+echo "con1: Creating explicit snapshot";
+disable_result_log;
+CREATE EXPLICIT ROCKSDB SNAPSHOT;
+enable_result_log;
+SELECT * FROM T1;
+
+echo "con1: Releasing explicit snapshot";
+disable_result_log;
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+enable_result_log;
+
+echo "con1: Releasing explicit snapshot again";
+error ER_UNKNOWN_ERROR;
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+
+#
+
+echo "con1: Starting transaction with shared snapshot";
+disable_result_log;
+START TRANSACTION WITH SHARED ROCKSDB SNAPSHOT;
+enable_result_log;
+SELECT * FROM T1;
+
+connection con2;
+echo "con2: Inserting a row";
+INSERT INTO T1 VALUES();
+SELECT * FROM T1;
+
+connection con1;
+echo "con1: Creating explicit snapshot";
+disable_result_log;
+CREATE EXPLICIT ROCKSDB SNAPSHOT;
+enable_result_log;
+SELECT * FROM T1;
+
+echo "con1: Releasing explicit snapshot";
+disable_result_log;
+RELEASE EXPLICIT ROCKSDB SNAPSHOT;
+enable_result_log;
+
+echo "con1: The new row should not be seen";
+SELECT* FROM T1;
+COMMIT;
+
+#
+
+## Cleanup
+DROP TABLE T1;
+
+connection default;
+disconnect con1;
+disconnect con2;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/fail_system_cf.test b/storage/rocksdb/mysql-test/rocksdb/t/fail_system_cf.test
new file mode 100644
index 00000000..25581970
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/fail_system_cf.test
@@ -0,0 +1,17 @@
+--source include/have_rocksdb.inc
+
+#
+# Any create table using the system column family should fail
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--error ER_WRONG_ARGUMENTS
+CREATE TABLE t1 (i INT, PRIMARY KEY (i) COMMENT '__system__') ENGINE = ROCKSDB;
+
+#cleanup
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/fast_prefix_index_fetch.test b/storage/rocksdb/mysql-test/rocksdb/t/fast_prefix_index_fetch.test
new file mode 100644
index 00000000..0b6cf42a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/fast_prefix_index_fetch.test
@@ -0,0 +1,120 @@
+# Disable until covered unpack_info format enabled in prod
+--source include/have_debug.inc
+--source include/not_debug.inc
+
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (
+ id INT,
+ fake_id INT,
+ bigfield VARCHAR(4096),
+ PRIMARY KEY (id),
+ KEY bf (bigfield(32)),
+ KEY fid (fake_id, bigfield(32))
+) ENGINE=rocksdb;
+
+INSERT INTO t1 VALUES (1, 1001, REPEAT('a', 1)),
+ (8, 1008, REPEAT('b', 8)),
+ (24, 1024, REPEAT('c', 24)),
+ (31, 1031, REPEAT('d', 31)),
+ (32, 1032, REPEAT('x', 32)),
+ (33, 1033, REPEAT('y', 33)),
+ (128, 1128, REPEAT('z', 128));
+
+SELECT * FROM t1;
+
+--disable_query_log
+
+--let $prefix_index_check_title= Baseline sanity check
+--let $prefix_index_check_read_avoided_delta= 0
+--let $prefix_index_check_query= SELECT "no-op query"
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+--let $prefix_index_check_title= Eligible for optimization.
+--let $prefix_index_check_read_avoided_delta= 2
+--let $prefix_index_check_query= SELECT id, bigfield FROM t1 FORCE INDEX(bf) WHERE bigfield = REPEAT('d', 31)
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+--let $prefix_index_check_title= Eligible for optimization, access via fake_id only
+--let $prefix_index_check_read_avoided_delta= 2
+--let $prefix_index_check_query= SELECT id, bigfield FROM t1 FORCE INDEX(fid) WHERE fake_id = 1031
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+--let $prefix_index_check_title= Not eligible for optimization, access via fake_id of big row.
+--let $prefix_index_check_read_avoided_delta= 0
+--let $prefix_index_check_query= SELECT id, bigfield FROM t1 FORCE INDEX(fid) WHERE fake_id = 1033
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+# The secondary_index_read call isn't covered because the next record in the
+# index has a bigfield value of length 33, so only one of two lookups are
+# covered here.
+--let $prefix_index_check_title= Eligible for optimization.
+--let $prefix_index_check_read_avoided_delta= 1
+--let $prefix_index_check_query= SELECT id, bigfield FROM t1 FORCE INDEX(bf) WHERE bigfield = REPEAT('x', 32)
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+--let $prefix_index_check_title= Not eligible for optimization.
+--let $prefix_index_check_read_avoided_delta= 0
+--let $prefix_index_check_query= SELECT id, bigfield FROM t1 FORCE INDEX(bf) WHERE bigfield = REPEAT('y', 33)
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+--let $prefix_index_check_title= Eligible for optimization.
+--let $prefix_index_check_read_avoided_delta= 2
+--let $prefix_index_check_query= SELECT id, bigfield FROM t1 FORCE INDEX(bf) WHERE bigfield = REPEAT('b', 8)
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+--let $prefix_index_check_title= Eligible for optimization.
+--let $prefix_index_check_read_avoided_delta= 2
+--let $prefix_index_check_query= SELECT id, bigfield FROM t1 FORCE INDEX(bf) WHERE bigfield = REPEAT('c', 24)
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+--let $prefix_index_check_title= Not eligible for optimization.
+--let $prefix_index_check_read_avoided_delta= 0
+--let $prefix_index_check_query= SELECT id, bigfield FROM t1 FORCE INDEX(bf) WHERE bigfield = REPEAT('z', 128)
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+DROP TABLE t1;
+
+--echo #
+--echo # Test that multi-byte charsets are handled correctly
+--echo #
+
+SET NAMES utf8;
+
+CREATE TABLE t1 (
+ a INT PRIMARY KEY,
+ b VARCHAR(30) CHARACTER SET utf8 collate utf8_bin,
+ KEY k (b(2))
+) ENGINE=rocksdb;
+
+INSERT INTO t1 VALUES
+ (1, 'a'),
+ (2, 'cc'),
+ (3, 'ŽŽ'),
+ (4, 'žžžž');
+
+--let $prefix_index_check_title= Charset record obviously shorter than the prefix
+--let $prefix_index_check_query= SELECT * FROM t1 FORCE INDEX(k) WHERE b = "a"
+--let $prefix_index_check_read_avoided_delta= 2
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+--let $prefix_index_check_title= Charset record shorter than prefix
+--let $prefix_index_check_query= SELECT * FROM t1 FORCE INDEX(k) WHERE b = "cc"
+--let $prefix_index_check_read_avoided_delta= 2
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+--let $prefix_index_check_title= Charset record with glyphs shorter than prefix
+--let $prefix_index_check_query= SELECT * FROM t1 FORCE INDEX(k) WHERE b = "ŽŽ"
+--let $prefix_index_check_read_avoided_delta= 1
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+--let $prefix_index_check_title= Charset record longer than prefix
+--let $prefix_index_check_query= SELECT * FROM t1 FORCE INDEX(k) WHERE b = "žžžž"
+--let $prefix_index_check_read_avoided_delta= 0
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/force_shutdown.test b/storage/rocksdb/mysql-test/rocksdb/t/force_shutdown.test
new file mode 100644
index 00000000..1817bc06
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/force_shutdown.test
@@ -0,0 +1,97 @@
+--source include/have_rocksdb.inc
+
+--source include/have_debug.inc
+--source include/not_valgrind.inc
+
+connect (conn1, localhost, root,,test);
+
+create table t1 (
+ pk int not null primary key,
+ col1 varchar(10)
+) engine=rocksdb;
+
+insert into t1 values (1,1),(2,2),(3,3);
+
+connection conn1;
+set session debug= "+d,myrocks_busy_loop_on_row_read";
+send select * from t1 where pk=1;
+
+--echo # testing unclean shutdown on stuck instance
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where info = 'select * from t1 where pk=1';
+--source include/wait_condition.inc
+--echo # Run shutdown sql command with forcing kill (exit code 127)
+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--error 2006,2013
+shutdown 1;
+--source include/wait_until_disconnected.inc
+
+--echo # verifying exit code is printed
+let $error_log=$MYSQLTEST_VARDIR/log/testlog.err;
+let SEARCH_FILE=$error_log;
+--echo # restart the server
+--exec echo "restart:--log-error=$error_log" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+--error 2006,2013
+shutdown 230;
+--source include/wait_until_disconnected.inc
+let SEARCH_PATTERN=COM_SHUTDOWN received from host/user = localhost/root, exit code 230;
+--source include/search_pattern_in_file.inc
+
+--echo # restart the server
+--exec echo "restart:" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+--echo # verifying SHUTDOWN is refused if exit code > 255
+--error ER_UNKNOWN_ERROR
+SHUTDOWN 256;
+--error ER_UNKNOWN_ERROR
+SHUTDOWN 10000;
+
+--echo # verifying SHUTDOWN is refused if instances are not read only
+--error ER_UNKNOWN_ERROR
+SHUTDOWN 0 read_only;
+--error ER_UNKNOWN_ERROR
+SHUTDOWN 127 read_only;
+--error 2006,2013
+SHUTDOWN 127;
+--source include/wait_until_disconnected.inc
+
+--echo # restart the server
+--exec echo "restart:" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+connect (conn2, localhost, root,,test);
+
+connection conn2;
+set session debug= "+d,myrocks_busy_loop_on_row_read";
+send select * from t1 where pk=1;
+
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where info = 'select * from t1 where pk=1';
+--source include/wait_condition.inc
+
+SET GLOBAL read_only=1;
+--echo # verifying SHUTDOWN read_only works with read_only instance
+--echo # Run shutdown sql command with forcing kill (exit code 127)
+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--error 2006,2013
+shutdown 255 read_only;
+--source include/wait_until_disconnected.inc
+
+--echo # restart the server
+--exec echo "restart:" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+disconnect conn1;
+disconnect conn2;
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/foreign_key.test b/storage/rocksdb/mysql-test/rocksdb/t/foreign_key.test
new file mode 100644
index 00000000..675a337c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/foreign_key.test
@@ -0,0 +1,47 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (b INT PRIMARY KEY);
+
+# Try simple foreign key - should fail
+--error ER_NOT_SUPPORTED_YET
+CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, FOREIGN KEY (b) REFERENCES t1(b));
+
+# Try simple valid syntax with 'foreign' as part - should succeed
+CREATE TABLE t2 (a INT NOT NULL, bforeign INT NOT NULL);
+DROP TABLE t2;
+
+# Try simple valid syntax with 'foreign' and 'key' as part (with no space) - should succeed
+CREATE TABLE t2 (a INT NOT NULL, foreignkey INT NOT NULL);
+DROP TABLE t2;
+
+# Try with valid id containing 'foreign' and then a foreign key - should fail
+--error ER_NOT_SUPPORTED_YET
+CREATE TABLE t2 (a INT NOT NULL, bforeign INT not null, FOREIGN KEY (bforeign) REFERENCES t1(b));
+
+CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL);
+# Alter with foreign key - should fail
+--error ER_NOT_SUPPORTED_YET
+ALTER TABLE t2 ADD FOREIGN KEY (b) REFERENCES t1(b);
+DROP TABLE t2;
+
+# Alter with valid syntax that contains 'foreign' - should succeed
+CREATE TABLE t2 (a INT NOT NULL);
+ALTER TABLE t2 ADD bforeign INT NOT NULL;
+DROP TABLE t2;
+
+# Alter with valid syntax that contains 'foreign' and 'key' (no space) - should succeed
+CREATE TABLE t2 (a INT NOT NULL);
+ALTER TABLE t2 ADD foreignkey INT NOT NULL;
+DROP TABLE t2;
+
+# Alter with valid syntax that contains 'foreign' and then foreign key - should fail
+CREATE TABLE t2 (a INT NOT NULL);
+--error ER_NOT_SUPPORTED_YET
+ALTER TABLE t2 ADD bforeign INT NOT NULL, ADD FOREIGN KEY (bforeign) REFERENCES t1(b);
+DROP TABLE t2;
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/gap_lock_issue254-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/gap_lock_issue254-master.opt
new file mode 100644
index 00000000..f0b7f4b5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/gap_lock_issue254-master.opt
@@ -0,0 +1 @@
+--binlog-format=row --binlog-row-image=full --gap-lock-raise-error=1
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/gap_lock_issue254.test b/storage/rocksdb/mysql-test/rocksdb/t/gap_lock_issue254.test
new file mode 100644
index 00000000..af7c9b1a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/gap_lock_issue254.test
@@ -0,0 +1,14 @@
+-- source include/have_binlog_format_row.inc
+-- source include/have_rocksdb.inc
+
+# For issue#254
+create table t (id int primary key, value int);
+begin;
+update t set value=100 where id in (1, 2);
+commit;
+begin;
+--error ER_UNKNOWN_ERROR
+select * from t for update;
+commit;
+drop table t;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/gap_lock_raise_error.test b/storage/rocksdb/mysql-test/rocksdb/t/gap_lock_raise_error.test
new file mode 100644
index 00000000..59fe7e6f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/gap_lock_raise_error.test
@@ -0,0 +1,37 @@
+--source include/have_rocksdb.inc
+
+let $engine=rocksdb;
+--source include/gap_lock_raise_error_all.inc
+
+SET @save_gap_lock_exceptions = @@global.gap_lock_exceptions;
+
+SET GLOBAL gap_lock_exceptions="t.*";
+--source include/gap_lock_raise_error_init.inc
+
+set session autocommit=0;
+--error ER_UNKNOWN_ERROR
+select * from gap1 limit 1 for update;
+--error ER_UNKNOWN_ERROR
+select * from gap1 where value != 100 limit 1 for update;
+
+--source include/gap_lock_raise_error_cleanup.inc
+
+SET GLOBAL gap_lock_exceptions="gap.*";
+--source include/gap_lock_raise_error_init.inc
+
+set session autocommit=0;
+select * from gap1 limit 1 for update;
+select * from gap1 where value != 100 limit 1 for update;
+
+--source include/gap_lock_raise_error_cleanup.inc
+
+# This test has been temporarily removed because it fails when the server
+# is compiled using GCC 4.8 as full regular expression handling was added
+# in GCC 4.9. We need to add the ability to detect if full regex is
+# available before re-enabling this test.
+## Make sure we handle invalid regex expressions and generate a warning
+#--exec echo "" >$MYSQLTEST_VARDIR/log/mysqld.1.err
+#SET GLOBAL gap_lock_exceptions="[a-b,abc\\";
+#--exec grep -A 2 "Invalid pattern" $MYSQLTEST_VARDIR/log/mysqld.1.err | cut -d] -f2
+
+SET GLOBAL gap_lock_exceptions=@save_gap_lock_exceptions;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/get_error_message.test b/storage/rocksdb/mysql-test/rocksdb/t/get_error_message.test
new file mode 100644
index 00000000..b4c9e2da
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/get_error_message.test
@@ -0,0 +1,27 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+--source include/not_windows.inc # Data directory option not availablr
+
+#
+# Create tables with partitions and try to generate an error while creating
+# partitions.
+#
+--disable_warnings
+
+DROP TABLE IF EXISTS t1;
+
+--enable_warnings
+
+CREATE TABLE t1(a INT,b INT,KEY (a)) PARTITION BY HASH (a) PARTITIONS 3;
+
+SHOW TABLES;
+
+--disable_query_log
+call mtr.add_suppression("Failed to execute action for entry.*");
+--enable_query_log
+
+--error ER_WRONG_TABLE_NAME
+ALTER TABLE t1 ADD PARTITION(PARTITION p3 DATA DIRECTORY='G:/mysqltest/p3Data' INDEX DIRECTORY='H:/mysqltest/p3Index');
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/group_min_max-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/group_min_max-master.opt
new file mode 100644
index 00000000..ba9364e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/group_min_max-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/group_min_max.test b/storage/rocksdb/mysql-test/rocksdb/t/group_min_max.test
new file mode 100644
index 00000000..eb66bd0e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/group_min_max.test
@@ -0,0 +1,9 @@
+--source include/have_debug.inc
+set @debug_tmp= @@debug_dbug;
+set global debug_dbug="+d,force_group_by";
+
+let $engine=RocksDB;
+--source include/group_min_max.inc
+
+set global debug_dbug=@debug_tmp;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ha_extra_keyread.test b/storage/rocksdb/mysql-test/rocksdb/t/ha_extra_keyread.test
new file mode 100644
index 00000000..0d0fad2e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ha_extra_keyread.test
@@ -0,0 +1,15 @@
+--source include/have_debug.inc
+--source include/have_rocksdb.inc
+
+CREATE TABLE t1 (a INT, b CHAR(8), KEY ab(a, b)) ENGINE=rocksdb DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_bin;
+INSERT INTO t1 (a,b) VALUES (76,'bar');
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (77,'baz');
+
+SET debug_dbug="+d,dbug.rocksdb.HA_EXTRA_KEYREAD";
+
+SELECT b FROM t1 FORCE INDEX(ab) WHERE a=35;
+
+
+SET debug_dbug="-d,dbug.rocksdb.HA_EXTRA_KEYREAD";
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test b/storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test
new file mode 100644
index 00000000..22b5d697
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test
@@ -0,0 +1,53 @@
+--source include/have_rocksdb.inc
+
+#
+# Basic HANDLER counts
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+FLUSH STATUS;
+CREATE TABLE t1 (id INT PRIMARY KEY, a VARCHAR(100), b INT,
+INDEX b(b)) ENGINE=rocksdb;
+INSERT INTO t1 (id,a,b) VALUES (1,'foobar',100),(2,'z',0),(3,'bar',50);
+SHOW SESSION STATUS LIKE 'Handler_write%';
+
+UPDATE t1 SET b=1000 WHERE id=1;
+SHOW SESSION STATUS LIKE 'Handler_update%';
+
+DELETE FROM t1 WHERE id=2;
+SHOW SESSION STATUS LIKE 'Handler_delete%';
+
+INSERT INTO t1 (id,b) VALUES(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10);
+SHOW SESSION STATUS LIKE 'Handler_write%';
+
+FLUSH STATUS;
+SELECT * FROM t1 WHERE id=8;
+SHOW SESSION STATUS LIKE 'Handler_read%';
+
+FLUSH STATUS;
+SET GLOBAL rocksdb_force_flush_memtable_and_lzero_now=1;
+SELECT * FROM t1 WHERE b=6;
+SHOW SESSION STATUS LIKE 'Handler_read%';
+
+FLUSH STATUS;
+--sorted_result
+SELECT * FROM t1;
+SHOW SESSION STATUS LIKE 'Handler_read%';
+
+FLUSH STATUS;
+SELECT * FROM t1 FORCE INDEX(b) WHERE b <=5 ORDER BY b;
+SHOW SESSION STATUS LIKE 'Handler_read%';
+
+FLUSH STATUS;
+SELECT * FROM t1 WHERE id >=8 ORDER BY id;
+SHOW SESSION STATUS LIKE 'Handler_read%';
+
+FLUSH STATUS;
+SELECT * FROM t1 WHERE id < 8 ORDER BY id;
+SHOW SESSION STATUS LIKE 'Handler_read%';
+
+# Cleanup
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/hermitage.inc b/storage/rocksdb/mysql-test/rocksdb/t/hermitage.inc
new file mode 100644
index 00000000..17baf5b6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/hermitage.inc
@@ -0,0 +1,257 @@
+--enable_connect_log
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+### See full test cases here:
+### https://github.com/ept/hermitage/blob/master/mysql.md
+
+--disable_warnings
+DROP TABLE IF EXISTS test;
+--enable_warnings
+
+connect (con1,localhost,root,,);
+eval SET SESSION TRANSACTION ISOLATION LEVEL $trx_isolation;
+connect (con2,localhost,root,,);
+eval SET SESSION TRANSACTION ISOLATION LEVEL $trx_isolation;
+connect (con3,localhost,root,,);
+eval SET SESSION TRANSACTION ISOLATION LEVEL $trx_isolation;
+
+connection con1;
+
+create table test (id int primary key, value int) engine=rocksdb;
+
+### Prevents Aborted Reads (G1a)
+--source hermitage_init.inc
+
+connection con1;
+select * from test;
+update test set value = 101 where id = 1;
+connection con2;
+select * from test; # Still shows 1 => 10
+connection con1;
+rollback;
+connection con2; # Still shows 1 => 10
+select * from test;
+commit;
+
+
+### Prevents Intermediate Reads (G1b)
+--source hermitage_init.inc
+
+connection con1;
+update test set value = 101 where id = 1;
+connection con2;
+select * from test; # Still shows 1 => 10
+connection con1;
+update test set value = 11 where id = 1;
+commit;
+connection con2;
+select * from test; # Now shows 1 => 11
+commit;
+
+
+### Prevents Circular Information Flow (G1c)
+--source hermitage_init.inc
+
+connection con1;
+update test set value = 11 where id = 1;
+connection con2;
+update test set value = 22 where id = 2;
+connection con1;
+select * from test where id = 2; # Still shows 2 => 20
+connection con2;
+select * from test where id = 1; # Still shows 1 => 10
+connection con1;
+commit;
+connection con2;
+commit;
+
+
+### prevents Observed Transaction Vanishes (OTV)
+--source hermitage_init.inc
+
+connection con1;
+update test set value = 11 where id = 1;
+update test set value = 19 where id = 2;
+connection con2;
+send update test set value = 12 where id = 1;
+connection con1;
+commit;
+connection con2;
+reap;
+connection con3;
+select * from test; # Shows 1 => 11, 2 => 19
+connection con2;
+update test set value = 18 where id = 2;
+connection con3;
+select * from test; # Shows 1 => 11, 2 => 19
+connection con2;
+commit;
+connection con3;
+select * from test; # Shows 1 => 12, 2 => 18
+commit;
+
+
+### Predicate-Many-Preceders (PMP) -- RC does not prevent, RR prevents
+--source hermitage_init.inc
+
+connection con1;
+select * from test where value = 30;
+connection con2;
+insert into test (id, value) values(3, 30);
+commit;
+connection con1;
+# RC: Returns the newly inserted row
+# RR: Still returns nothing
+select * from test where value % 3 = 0;
+commit;
+
+--source hermitage_init.inc
+connection con1;
+update test set value = value + 10;
+connection con2;
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_snapshot_conflict_errors';
+select * from test;
+send delete from test where value = 20;
+connection con1;
+commit;
+connection con2;
+if ($trx_isolation == "READ COMMITTED")
+{
+ reap;
+ # RC: Returns 2 => 30
+ select * from test;
+}
+if ($trx_isolation == "REPEATABLE READ")
+{
+ --error ER_LOCK_DEADLOCK
+ reap;
+ select variable_value-@a from information_schema.global_status where variable_name='rocksdb_snapshot_conflict_errors';
+
+}
+commit;
+
+
+### Lost Update (P4) -- RC does not prevent, RR prevents
+--source hermitage_init.inc
+
+connection con1;
+select * from test where id = 1;
+connection con2;
+select * from test where id = 1;
+connection con1;
+update test set value = 11 where id = 1;
+connection con2;
+send update test set value = 12 where id = 1;
+connection con1;
+commit;
+connection con2;
+if ($trx_isolation == "READ COMMITTED")
+{
+ reap;
+ # RC: Returns 1 => 12
+ select * from test;
+}
+if ($trx_isolation == "REPEATABLE READ")
+{
+ --error ER_LOCK_DEADLOCK
+ reap;
+}
+commit;
+
+
+### Read Skew (G-single) -- RC does not prevent, RR prevents
+--source hermitage_init.inc
+
+connection con1;
+select * from test where id = 1;
+connection con2;
+select * from test where id = 1;
+select * from test where id = 2;
+update test set value = 12 where id = 1;
+update test set value = 18 where id = 2;
+commit;
+connection con1;
+select * from test where id = 2; # RC shows 18, RR shows 20
+commit;
+
+# test using predicate dependencies
+--source hermitage_init.inc
+
+connection con1;
+select * from test where value % 5 = 0;
+connection con2;
+update test set value = 12 where value = 10;
+commit;
+connection con1;
+# RC: returns 1 => 12, RR: returns nothing
+select * from test where value % 3 = 0;
+commit;
+
+# on a write predicate
+--source hermitage_init.inc
+
+connection con1;
+select * from test where id = 1;
+connection con2;
+select * from test;
+update test set value = 12 where id = 1;
+update test set value = 18 where id = 2;
+commit;
+connection con1;
+if ($trx_isolation == "READ COMMITTED")
+{
+ delete from test where value = 20; # doesn't delete anything
+ select * from test where id = 2; # shows 2 => 18
+}
+if ($trx_isolation == "REPEATABLE READ")
+{
+ --error ER_LOCK_DEADLOCK
+ delete from test where value = 20;
+}
+commit;
+
+
+### Write Skew (G2-item) -- Neither RC/RR prevents
+--source hermitage_init.inc
+
+connection con1;
+select * from test where id in (1,2);
+connection con2;
+select * from test where id in (1,2);
+connection con1;
+update test set value = 11 where id = 1;
+connection con2;
+update test set value = 21 where id = 2;
+connection con1;
+commit;
+connection con2;
+commit;
+
+### Anti-Dependency Cycles (G2) -- Neither RC/RR prevents
+--source hermitage_init.inc
+
+connection con1;
+select * from test where value % 3 = 0;
+connection con2;
+select * from test where value % 3 = 0;
+connection con1;
+insert into test (id, value) values(3, 30);
+connection con2;
+insert into test (id, value) values(4, 42);
+connection con1;
+commit;
+connection con2;
+commit;
+select * from test where value % 3 = 0; # Either. Returns 3 => 30, 4 => 42
+connection con1;
+select * from test where value % 3 = 0;
+
+
+connection default;
+drop table test;
+
+disconnect con1;
+disconnect con2;
+disconnect con3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/hermitage.test b/storage/rocksdb/mysql-test/rocksdb/t/hermitage.test
new file mode 100644
index 00000000..e4138e8d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/hermitage.test
@@ -0,0 +1,10 @@
+--source include/have_rocksdb.inc
+
+# Hermitage is an attempt to test transaction isolation levels.
+# https://github.com/ept/hermitage
+
+let $trx_isolation = READ COMMITTED;
+--source hermitage.inc
+
+let $trx_isolation = REPEATABLE READ;
+--source hermitage.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/hermitage_init.inc b/storage/rocksdb/mysql-test/rocksdb/t/hermitage_init.inc
new file mode 100644
index 00000000..4f3f03ef
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/hermitage_init.inc
@@ -0,0 +1,8 @@
+connection con1;
+truncate table test;
+insert into test (id, value) values (1, 10), (2, 20);
+begin;
+connection con2;
+begin;
+connection con3;
+begin;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/i_s.test b/storage/rocksdb/mysql-test/rocksdb/t/i_s.test
new file mode 100644
index 00000000..c9dc98c9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/i_s.test
@@ -0,0 +1,21 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
+ WHERE TABLE_SCHEMA='INFORMATION_SCHEMA'
+ AND TABLE_NAME LIKE 'ROCKSDB%'
+ ORDER BY TABLE_NAME;
+
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_CF_OPTIONS;
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_CFSTATS;
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_COMPACTION_STATS;
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_DBSTATS;
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_DDL;
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_DEADLOCK;
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO;
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP;
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_LOCKS;
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT;
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT_GLOBAL;
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_SST_PROPS;
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROCKSDB_TRX;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/i_s_ddl.test b/storage/rocksdb/mysql-test/rocksdb/t/i_s_ddl.test
new file mode 100644
index 00000000..716f3720
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/i_s_ddl.test
@@ -0,0 +1,29 @@
+--source include/have_rocksdb.inc
+
+#
+# Information Schema DDL
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS is_ddl_t1;
+DROP TABLE IF EXISTS is_ddl_t2;
+DROP TABLE IF EXISTS is_ddl_t3;
+--enable_warnings
+
+CREATE TABLE is_ddl_t1 (i INT, j INT, k INT, l INT,
+ PRIMARY KEY (i), KEY (j), KEY (k, l) COMMENT 'kl_cf')
+ ENGINE = ROCKSDB;
+
+CREATE TABLE is_ddl_t2 (x INT, y INT, z INT,
+ PRIMARY KEY (z, y) COMMENT 'zy_cf',
+ KEY (x)) ENGINE = ROCKSDB;
+CREATE TABLE is_ddl_t3 (a INT, b INT, c INT, PRIMARY KEY (a)) ENGINE = ROCKSDB
+ COMMENT "ttl_duration=3600;";
+
+--sorted_result
+SELECT TABLE_SCHEMA,TABLE_NAME,PARTITION_NAME,INDEX_NAME,INDEX_TYPE,KV_FORMAT_VERSION,CF,TTL_DURATION,INDEX_FLAGS FROM INFORMATION_SCHEMA.ROCKSDB_DDL WHERE TABLE_NAME like 'is_ddl_t%';
+
+# cleanup
+DROP TABLE is_ddl_t1;
+DROP TABLE is_ddl_t2;
+DROP TABLE is_ddl_t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/i_s_deadlock.test b/storage/rocksdb/mysql-test/rocksdb/t/i_s_deadlock.test
new file mode 100644
index 00000000..e0479d6a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/i_s_deadlock.test
@@ -0,0 +1,158 @@
+--source include/have_rocksdb.inc
+
+set @prior_lock_wait_timeout = @@rocksdb_lock_wait_timeout;
+set @prior_deadlock_detect = @@rocksdb_deadlock_detect;
+set @prior_max_latest_deadlocks = @@rocksdb_max_latest_deadlocks;
+set global rocksdb_deadlock_detect = on;
+set global rocksdb_lock_wait_timeout = 10000;
+--echo # Clears deadlock buffer of any prior deadlocks.
+set global rocksdb_max_latest_deadlocks = 0;
+set global rocksdb_max_latest_deadlocks = @prior_max_latest_deadlocks;
+
+# needed by simple_deadlock.inc
+let $engine = rocksdb;
+
+--source include/count_sessions.inc
+connect (con1,localhost,root,,);
+let $con1= `SELECT CONNECTION_ID()`;
+
+connect (con2,localhost,root,,);
+let $con2= `SELECT CONNECTION_ID()`;
+
+connect (con3,localhost,root,,);
+let $con3= `SELECT CONNECTION_ID()`;
+
+connection default;
+show create table information_schema.rocksdb_deadlock;
+
+create table t (i int primary key) engine=rocksdb;
+insert into t values (1), (2), (3);
+select * from information_schema.rocksdb_deadlock;
+
+echo Deadlock #1;
+--source include/simple_deadlock.inc
+connection default;
+--replace_column 1 DEADLOCK_ID 2 TIMESTAMP 3 TRANSACTION_ID 5 WAITING_KEY
+select * from information_schema.rocksdb_deadlock;
+
+echo Deadlock #2;
+--source include/simple_deadlock.inc
+connection default;
+--replace_column 1 DEADLOCK_ID 2 TIMESTAMP 3 TRANSACTION_ID 5 WAITING_KEY
+select * from information_schema.rocksdb_deadlock;
+set global rocksdb_max_latest_deadlocks = 10;
+
+echo Deadlock #3;
+--source include/simple_deadlock.inc
+connection default;
+--replace_column 1 DEADLOCK_ID 2 TIMESTAMP 3 TRANSACTION_ID 5 WAITING_KEY
+select * from information_schema.rocksdb_deadlock;
+set global rocksdb_max_latest_deadlocks = 1;
+--replace_column 1 DEADLOCK_ID 2 TIMESTAMP 3 TRANSACTION_ID 5 WAITING_KEY
+select * from information_schema.rocksdb_deadlock;
+
+connection con3;
+set rocksdb_deadlock_detect_depth = 2;
+
+echo Deadlock #4;
+connection con1;
+begin;
+select * from t where i=1 for update;
+
+connection con2;
+begin;
+select * from t where i=2 for update;
+
+connection con3;
+begin;
+select * from t where i=3 for update;
+
+connection con1;
+send select * from t where i=2 for update;
+
+connection con2;
+let $wait_condition = select count(*) = 1 from information_schema.rocksdb_trx
+where thread_id = $con1 and waiting_key != "";
+--source include/wait_condition.inc
+
+send select * from t where i=3 for update;
+
+connection con3;
+let $wait_condition = select count(*) = 1 from information_schema.rocksdb_trx
+where thread_id = $con2 and waiting_key != "";
+--source include/wait_condition.inc
+
+--error ER_LOCK_DEADLOCK
+select * from t where i=1 for update;
+rollback;
+
+connection con2;
+reap;
+rollback;
+
+connection con1;
+reap;
+rollback;
+
+connection default;
+set global rocksdb_max_latest_deadlocks = 5;
+--replace_column 1 DEADLOCK_ID 2 TIMESTAMP 3 TRANSACTION_ID 5 WAITING_KEY
+select * from information_schema.rocksdb_deadlock;
+
+echo Deadlock #5;
+connection con1;
+begin;
+select * from t where i=1 for update;
+
+connection con2;
+begin;
+select * from t where i=2 for update;
+
+connection con3;
+begin;
+select * from t where i=3 lock in share mode;
+
+connection con1;
+select * from t where i=100 for update;
+select * from t where i=101 for update;
+send select * from t where i=2 for update;
+
+connection con2;
+let $wait_condition = select count(*) = 1 from information_schema.rocksdb_trx
+where thread_id = $con1 and waiting_key != "";
+--source include/wait_condition.inc
+
+select * from t where i=3 lock in share mode;
+select * from t where i=200 for update;
+select * from t where i=201 for update;
+
+--error ER_LOCK_DEADLOCK
+select * from t where i=1 lock in share mode;
+rollback;
+
+connection con1;
+reap;
+rollback;
+
+connection con3;
+rollback;
+
+connection default;
+--replace_column 1 DEADLOCK_ID 2 TIMESTAMP 3 TRANSACTION_ID 5 WAITING_KEY
+select * from information_schema.rocksdb_deadlock;
+
+disconnect con1;
+disconnect con2;
+disconnect con3;
+
+set global rocksdb_lock_wait_timeout = @prior_lock_wait_timeout;
+set global rocksdb_deadlock_detect = @prior_deadlock_detect;
+drop table t;
+--replace_column 1 DEADLOCK_ID 2 TIMESTAMP 3 TRANSACTION_ID 5 WAITING_KEY 7 INDEX_NAME 8 TABLE_NAME
+select * from information_schema.rocksdb_deadlock;
+set global rocksdb_max_latest_deadlocks = 0;
+--echo # Clears deadlock buffer of any existent deadlocks.
+set global rocksdb_max_latest_deadlocks = @prior_max_latest_deadlocks;
+--replace_column 1 DEADLOCK_ID 2 TRANSACTION_ID 4 WAITING_KEY
+select * from information_schema.rocksdb_deadlock;
+--source include/wait_until_count_sessions.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/index.inc b/storage/rocksdb/mysql-test/rocksdb/t/index.inc
new file mode 100644
index 00000000..8b000a25
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/index.inc
@@ -0,0 +1,155 @@
+#
+# Basic syntax related to indexes:
+# unique and non-unique keys,
+# single- and multi-column keys,
+# index option COMMENT.
+#
+# See other index* tests for operations
+# which are less likely to be supported
+#
+# PRIMARY KEY syntax is covered in index_primary test.
+# Index types BTREE|HASH -- in index_type_btree|hash tests.
+# SPATIAL -- in type_spatial_indexes test.
+# FULLTEXT -- in fulltext_search test.
+# KEY_BLOCK_SIZE -- in index_key_block_size test.
+#
+# Usage to call the test from another test:
+#
+# A calling test may define $index_type, in which case
+# USING clause will be added to the syntax.
+#
+
+################################################
+# TODO:
+# A part of the test is disabled because unique indexes
+# are not currently supported
+################################################
+
+
+let $using_index_type = ;
+if ($index_type)
+{
+ let $using_index_type = USING $index_type;
+}
+
+
+eval CREATE TABLE t1 (a INT,
+ b CHAR(8),
+ pk INT PRIMARY KEY,
+ KEY $using_index_type (a)
+) ENGINE=rocksdb;
+
+--replace_column 7 #
+SHOW KEYS IN t1;
+DROP TABLE t1;
+
+eval CREATE TABLE t1 (a INT,
+ b CHAR(8),
+ pk INT PRIMARY KEY,
+ KEY a_b $using_index_type (a,b) COMMENT 'a_b index'
+) ENGINE=rocksdb;
+
+--replace_column 7 #
+SHOW KEYS IN t1;
+DROP TABLE t1;
+
+eval CREATE TABLE t1 (a INT,
+ b CHAR(8),
+ pk INT PRIMARY KEY,
+ KEY $using_index_type (a),
+ KEY $using_index_type (b)
+) ENGINE=rocksdb;
+
+--replace_column 7 #
+SHOW KEYS IN t1;
+DROP TABLE t1;
+
+--disable_parsing
+
+eval CREATE TABLE t1 (a INT,
+ b CHAR(8),
+ pk INT PRIMARY KEY,
+ UNIQUE INDEX $using_index_type (a)
+) ENGINE=rocksdb;
+
+--replace_column 7 #
+SHOW KEYS IN t1;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+--error ER_DUP_ENTRY,ER_DUP_KEY
+INSERT INTO t1 (a,b) VALUES (1,'c');
+
+DROP TABLE t1;
+
+--source drop_table_sync.inc
+
+--enable_parsing
+
+#
+# ALTER TABLE
+#
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (100,'z');
+
+eval ALTER TABLE t1 ADD KEY (a) $using_index_type COMMENT 'simple index on a';
+--replace_column 7 #
+SHOW INDEX FROM t1;
+ALTER TABLE t1 DROP KEY a;
+DROP TABLE t1;
+
+--disable_parsing
+
+eval CREATE TABLE t1 (a INT,
+ b CHAR(8),
+ pk INT AUTO_INCREMENT PRIMARY KEY,
+ UNIQUE INDEX $using_index_type (a)
+) ENGINE=rocksdb;
+
+--replace_column 7 #
+SHOW KEYS IN t1;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+--error ER_DUP_ENTRY,ER_DUP_KEY
+INSERT INTO t1 (a,b) VALUES (1,'c');
+
+ALTER TABLE t1 DROP INDEX a;
+INSERT INTO t1 (a,b) VALUES (1,'c');
+--error ER_DUP_ENTRY
+eval ALTER TABLE t1 ADD UNIQUE INDEX a(a) $using_index_type;
+DROP TABLE t1;
+
+--enable_parsing
+
+#
+# Test index prefix length limits.
+#
+set global rocksdb_large_prefix=0;
+
+CREATE TABLE t1 (
+ a BLOB(1024),
+ KEY (a(767))
+) ENGINE=rocksdb;
+DROP TABLE t1;
+
+# Should display warning
+CREATE TABLE t1 (
+ a BLOB(1024),
+ KEY (a(768))
+) ENGINE=rocksdb;
+DROP TABLE t1;
+
+set global rocksdb_large_prefix=1;
+
+CREATE TABLE t1 (
+ a BLOB(4096),
+ KEY (a(3072))
+) ENGINE=rocksdb;
+DROP TABLE t1;
+
+# Should display warning
+CREATE TABLE t1 (
+ a BLOB(4096),
+ KEY (a(3073))
+) ENGINE=rocksdb;
+DROP TABLE t1;
+
+set global rocksdb_large_prefix=DEFAULT;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/index.test b/storage/rocksdb/mysql-test/rocksdb/t/index.test
new file mode 100644
index 00000000..e0c6175b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/index.test
@@ -0,0 +1,44 @@
+--source include/have_rocksdb.inc
+
+#
+# Basic syntax related to indexes:
+# unique and non-unique keys,
+# single- and multi-column keys,
+# index option COMMENT.
+#
+# See other index* tests for operations
+# which are less likely to be supported
+#
+# PRIMARY KEY syntax is covered in index_primary test.
+# Index types BTREE|HASH -- in index_type_btree|hash tests.
+# SPATIAL -- in type_spatial_indexes test.
+# FULLTEXT -- in fulltext_search test.
+# KEY_BLOCK_SIZE -- in index_key_block_size test.
+#
+
+# (Default index type)
+
+--source index.inc
+
+--echo #
+--echo # Issue #376: MyRocks: ORDER BY optimizer is unable to use the index extension
+--echo #
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1(a int);
+insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
+create table t2 (
+ pk int not null,
+ a int not null,
+ b int not null,
+ primary key(pk),
+ key(a)
+) engine=rocksdb;
+insert into t2 select A.a, FLOOR(A.a/10), A.a from t1 A;
+
+--echo # This must have type=range, index=a, and must not have 'Using filesort':
+--replace_column 9 #
+explain select * from t2 force index (a) where a=0 and pk>=3 order by pk;
+
+drop table t0,t1,t2;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/index_file_map-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/index_file_map-master.opt
new file mode 100644
index 00000000..436edf2b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/index_file_map-master.opt
@@ -0,0 +1 @@
+--rocksdb_table_stats_sampling_pct=100
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/index_file_map.test b/storage/rocksdb/mysql-test/rocksdb/t/index_file_map.test
new file mode 100644
index 00000000..8b0e2339
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/index_file_map.test
@@ -0,0 +1,54 @@
+--source include/have_rocksdb.inc
+
+#
+# Information Schema index file map
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+
+CREATE TABLE t1 (i INT PRIMARY KEY, j INT, INDEX(j)) ENGINE = ROCKSDB;
+CREATE TABLE t2 (k INT PRIMARY KEY, l INT REFERENCES t1.i) ENGINE = ROCKSDB;
+
+INSERT INTO t1 VALUES (1,2), (2,4), (3,6), (4,8), (5,10);
+INSERT INTO t2 VALUES (100,1), (200,2), (300,3), (400,4);
+
+COMMIT;
+
+# Flush memtable out to SST
+SET GLOBAL rocksdb_force_flush_memtable_now = 1;
+
+###############################################################################
+# Test that expected index_file_map data exists
+###############################################################################
+
+# Return the data for the primary key of t1
+--replace_column 1 # 2 # 3 SSTNAME 5 # 6 # 7 # 8 # 9 #
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP
+WHERE INDEX_NUMBER =
+ (SELECT INDEX_NUMBER FROM INFORMATION_SCHEMA.ROCKSDB_DDL
+ WHERE TABLE_NAME = 't1' AND INDEX_NAME = "PRIMARY");
+
+# Return the data for the secondary index of t1
+--replace_column 1 # 2 # 3 SSTNAME 5 # 6 # 7 # 8 # 9 #
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP
+WHERE INDEX_NUMBER =
+ (SELECT INDEX_NUMBER FROM INFORMATION_SCHEMA.ROCKSDB_DDL
+ WHERE TABLE_NAME = 't1' AND INDEX_NAME = "j");
+
+# Return the data for the primary index of t2
+--replace_column 1 # 2 # 3 SSTNAME 5 # 6 # 7 # 8 # 9 #
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP
+WHERE INDEX_NUMBER =
+ (SELECT INDEX_NUMBER FROM INFORMATION_SCHEMA.ROCKSDB_DDL
+ WHERE TABLE_NAME = 't2' AND INDEX_NAME = "PRIMARY");
+
+# The number of sst files should be 1 or more
+select count(*) > 0 from information_schema.rocksdb_sst_props;
+
+# cleanup
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/index_key_block_size.test b/storage/rocksdb/mysql-test/rocksdb/t/index_key_block_size.test
new file mode 100644
index 00000000..f156aec0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/index_key_block_size.test
@@ -0,0 +1,70 @@
+--source include/have_rocksdb.inc
+
+#
+# KEY_BLOCK_SIZE index option.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT,
+ b CHAR(8),
+ pk INT PRIMARY KEY,
+ KEY (a) KEY_BLOCK_SIZE=8
+) ENGINE=rocksdb;
+
+--replace_column 7 #
+SHOW KEYS IN t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT,
+ b CHAR(8),
+ pk INT PRIMARY KEY,
+ KEY ind1(b ASC) KEY_BLOCK_SIZE=0
+) ENGINE=rocksdb;
+
+--replace_column 7 #
+SHOW INDEX IN t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT,
+ b CHAR(8),
+ PRIMARY KEY ind2(b(1) DESC) KEY_BLOCK_SIZE=32768 COMMENT 'big key_block_size value'
+) ENGINE=rocksdb;
+
+--replace_column 7 #
+SHOW INDEX IN t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT,
+ b CHAR(8),
+ pk INT AUTO_INCREMENT PRIMARY KEY,
+ KEY a_b(a,b) KEY_BLOCK_SIZE=8192
+) ENGINE=rocksdb;
+
+--replace_column 7 #
+SHOW INDEX IN t1;
+
+DROP TABLE t1;
+
+--source drop_table_sync.inc
+
+#
+# ALTER TABLE
+#
+
+CREATE TABLE t1 (a INT,
+ b CHAR(8),
+ PRIMARY KEY (b)
+) ENGINE=rocksdb;
+
+INSERT INTO t1 (a,b) VALUES (100,'z');
+
+ALTER TABLE t1 ADD KEY(a) KEY_BLOCK_SIZE 8192;
+--replace_column 7 #
+SHOW INDEX FROM t1;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb-master.opt
new file mode 100644
index 00000000..c07b063f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb-master.opt
@@ -0,0 +1 @@
+--rocksdb_strict_collation_check=off --binlog_format=row --log-bin
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb.test b/storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb.test
new file mode 100644
index 00000000..887b4dd6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb.test
@@ -0,0 +1,110 @@
+--source include/have_rocksdb.inc
+
+#
+# index_merge_rocksdb test copied over from index_merge_ror.inc
+#
+# Triggers issue # https://github.com/facebook/mysql-5.6/issues/604
+
+CREATE TABLE t1
+(
+ /* fields/keys for row retrieval tests */
+ key1 INT,
+ key2 INT,
+ key3 INT,
+ key4 INT,
+
+ /* make rows much bigger then keys */
+ filler1 CHAR(200),
+
+ KEY(key1),
+ KEY(key2)
+) ENGINE=ROCKSDB;
+
+# fill table
+CREATE TABLE t0 AS SELECT * FROM t1;
+--disable_query_log
+--echo # Printing of many insert into t0 values (....) disabled.
+let $cnt=100;
+while ($cnt)
+{
+ eval INSERT INTO t0 VALUES (0, 0, 0, 0, 'data1');
+ dec $cnt;
+}
+
+--echo # Printing of many insert into t1 select .... from t0 disabled.
+let $1=4;
+while ($1)
+{
+ let $2=4;
+ while ($2)
+ {
+ let $3=4;
+ while ($3)
+ {
+ eval INSERT INTO t1 SELECT key1, key2, key3, key4, filler1 FROM t0;
+ dec $3;
+ }
+ dec $2;
+ }
+ dec $1;
+}
+
+--echo # Printing of many insert into t1 (...) values (....) disabled.
+# Row retrieval tests
+# -1 is used for values 'out of any range we are using'
+# insert enough rows for index intersection to be used for (key1,key2)
+INSERT INTO t1 (key1, key2, key3, key4, filler1) VALUES (100, 100, 100, 100,'key1-key2-key3-key4');
+let $cnt=400;
+while ($cnt)
+{
+ eval INSERT INTO t1 (key1, key2, key3, key4, filler1) VALUES (100, -1, 100, -1,'key1-key3');
+ dec $cnt;
+}
+let $cnt=400;
+while ($cnt)
+{
+ eval INSERT INTO t1 (key1, key2, key3, key4, filler1) VALUES (-1, 100, -1, 100,'key2-key4');
+ dec $cnt;
+}
+--enable_query_log
+
+SELECT COUNT(*) FROM t1;
+
+# flush the table first as statistics is calculated a bit differently for memtable and SST files
+SET GLOBAL rocksdb_force_flush_memtable_now = 1;
+
+-- disable_query_log
+-- disable_result_log
+ANALYZE TABLE t1;
+-- enable_result_log
+-- enable_query_log
+
+--replace_column 9 #
+EXPLAIN UPDATE t1 SET filler1='to be deleted' WHERE key1=100 AND key2=100;
+UPDATE t1 SET filler1='to be deleted' WHERE key1=100 and key2=100;
+
+DROP TABLE t0, t1;
+
+# Issue624 - MyRocks executes index_merge query plan incorrectly
+create table t1 (key1 int, key2 int, key3 int, key (key1), key (key2), key(key3)) engine=rocksdb;
+insert into t1 values (1, 100, 100), (1, 200, 200), (1, 300, 300);
+--disable_query_log
+let $i = 1;
+while ($i <= 1000) {
+ let $insert = INSERT INTO t1 VALUES(1000,1000,1000);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+set global rocksdb_force_flush_memtable_now=1;
+analyze table t1;
+
+--replace_column 9 #
+explain select * from t1 where key1 = 1;
+--replace_column 9 #
+explain select key1,key2 from t1 where key1 = 1 or key2 = 1;
+select * from t1 where key1 = 1;
+select key1,key2 from t1 where key1 = 1 or key2 = 1;
+
+drop table t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb2-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb2-master.opt
new file mode 100644
index 00000000..7681c42e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb2-master.opt
@@ -0,0 +1 @@
+--rocksdb_strict_collation_check=off --binlog_format=row --log-bin --rocksdb_records_in_range=2
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb2.test b/storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb2.test
new file mode 100644
index 00000000..2306558f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/index_merge_rocksdb2.test
@@ -0,0 +1,72 @@
+# Skiping this test from Valgrind execution as per Bug-14627884
+--source include/not_valgrind.inc
+# Adding big test option for this test.
+--source include/big_test.inc
+
+# t/index_merge_innodb.test
+#
+# Index merge tests (the test is called 'index_merge_rocksdb2' because
+# 'index_merge_rocksdb' has already existed before copying 'index_merge_innodb')
+#
+# Last update:
+# 2006-08-07 ML test refactored (MySQL 5.1)
+# Main code of several index_merge tests
+# -> include/index_merge*.inc
+# wrapper t/index_merge_innodb.test sources now several
+# include/index_merge*.inc files
+#
+
+--source include/have_rocksdb.inc
+let $engine_type= RocksDB;
+# skipping because too unstable in MyRocks
+let $skip_ror_EXPLAIN_for_MyRocks = 1;
+let $random_rows_in_EXPLAIN = 1;
+let $sorted_result = 1;
+# According to Oracle: "InnoDB's estimate for the index cardinality
+# depends on a pseudo random number generator (it picks up random
+# pages to sample). After an optimization that was made in r2625 two
+# EXPLAINs started returning a different number of rows (3 instead of
+# 4)", so:
+let $index_merge_random_rows_in_EXPLAIN = 1;
+# RocksDB does not support Merge tables (affects include/index_merge1.inc)
+let $merge_table_support= 0;
+
+set global rocksdb_force_flush_memtable_now=1;
+--source include/index_merge1.inc
+set global rocksdb_force_flush_memtable_now=1;
+--source include/index_merge_ror.inc
+set global rocksdb_force_flush_memtable_now=1;
+--source include/index_merge2.inc
+
+set global rocksdb_force_flush_memtable_now=1;
+--source include/index_merge_2sweeps.inc
+set global rocksdb_force_flush_memtable_now=1;
+--source include/index_merge_ror_cpk.inc
+
+set global rocksdb_force_flush_memtable_now=1;
+--echo #
+--echo # Bug#11747423 32254: INDEX MERGE USED UNNECESSARILY
+--echo #
+CREATE TABLE t1 (
+ id INT NOT NULL PRIMARY KEY,
+ id2 INT NOT NULL,
+ id3 INT NOT NULL,
+ KEY (id2),
+ KEY (id3),
+ KEY covering_index (id2,id3)
+) ENGINE=RocksDB;
+
+INSERT INTO t1 VALUES (0, 0, 0), (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5), (6, 6, 6), (7, 7, 7);
+INSERT INTO t1 SELECT id + 8, id2 + 8, id3 +8 FROM t1;
+INSERT INTO t1 SELECT id + 16, 7, 0 FROM t1;
+
+-- disable_query_log
+-- disable_result_log
+set global rocksdb_force_flush_memtable_now=1;
+analyze table t1;
+-- enable_result_log
+-- enable_query_log
+
+EXPLAIN SELECT SQL_NO_CACHE count(*) FROM t1 WHERE id2=7 AND id3=0;
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/index_primary.test b/storage/rocksdb/mysql-test/rocksdb/t/index_primary.test
new file mode 100644
index 00000000..5dcfbaa8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/index_primary.test
@@ -0,0 +1,96 @@
+--source include/have_rocksdb.inc
+
+#
+# Basic syntax related to primary keys
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT PRIMARY KEY,
+ b CHAR(8)
+) ENGINE=rocksdb;
+
+--replace_column 7 #
+SHOW KEYS IN t1;
+
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+--error ER_DUP_ENTRY
+INSERT INTO t1 (a,b) VALUES (1,'c');
+
+DROP TABLE t1;
+
+--error ER_MULTIPLE_PRI_KEY
+CREATE TABLE t1 (a INT PRIMARY KEY,
+ b CHAR(8) PRIMARY KEY
+) ENGINE=rocksdb;
+
+CREATE TABLE t1 (a INT,
+ b CHAR(8),
+ PRIMARY KEY (a,b)
+) ENGINE=rocksdb;
+
+--replace_column 7 #
+SHOW INDEX IN t1;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(1,'b'),(2,'a'),(2,'b');
+--error ER_DUP_ENTRY
+INSERT INTO t1 (a,b) VALUES (1,'b');
+ DROP TABLE t1;
+
+# KEY in a column definition means PK!
+
+CREATE TABLE t1 (a INT KEY,
+ b CHAR(8),
+ KEY (b)
+) ENGINE=rocksdb;
+
+--replace_column 7 #
+SHOW INDEX IN t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT,
+ b CHAR(8) PRIMARY KEY
+) ENGINE=rocksdb;
+
+--replace_column 7 #
+SHOW INDEX IN t1;
+
+--error ER_MULTIPLE_PRI_KEY
+ALTER TABLE t1 ADD CONSTRAINT PRIMARY KEY pk (a);
+--replace_column 7 #
+SHOW KEYS IN t1;
+DROP TABLE t1;
+
+#
+# Test index prefix length limits.
+#
+set global rocksdb_large_prefix=0;
+
+CREATE TABLE t1 (
+ a BLOB(1024),
+ PRIMARY KEY (a(767))
+) ENGINE=rocksdb;
+DROP TABLE t1;
+
+--error ER_TOO_LONG_KEY
+CREATE TABLE t1 (
+ a BLOB(1024),
+ PRIMARY KEY (a(768))
+) ENGINE=rocksdb;
+
+set global rocksdb_large_prefix=1;
+
+CREATE TABLE t1 (
+ a BLOB(4096),
+ PRIMARY KEY (a(3072))
+) ENGINE=rocksdb;
+DROP TABLE t1;
+
+--error ER_TOO_LONG_KEY
+CREATE TABLE t1 (
+ a BLOB(4096),
+ PRIMARY KEY (a(3073))
+) ENGINE=rocksdb;
+
+set global rocksdb_large_prefix=DEFAULT;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/index_type_btree.test b/storage/rocksdb/mysql-test/rocksdb/t/index_type_btree.test
new file mode 100644
index 00000000..4adc5b55
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/index_type_btree.test
@@ -0,0 +1,12 @@
+--source include/have_rocksdb.inc
+
+#
+# Index type BTREE
+#
+
+let $index_type = BTREE;
+
+--source index.inc
+
+let $index_type =;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/index_type_hash.test b/storage/rocksdb/mysql-test/rocksdb/t/index_type_hash.test
new file mode 100644
index 00000000..f3dc9cf5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/index_type_hash.test
@@ -0,0 +1,12 @@
+--source include/have_rocksdb.inc
+
+#
+# Index type HASH
+#
+
+let $index_type = HASH;
+
+--source index.inc
+
+let $index_type =;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/information_schema-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/information_schema-master.opt
new file mode 100644
index 00000000..86379847
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/information_schema-master.opt
@@ -0,0 +1 @@
+--binlog_format=row --log_slave_updates
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/information_schema.test b/storage/rocksdb/mysql-test/rocksdb/t/information_schema.test
new file mode 100644
index 00000000..09998b9a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/information_schema.test
@@ -0,0 +1,89 @@
+--source include/have_rocksdb.inc
+--source include/have_log_bin.inc
+
+--source include/restart_mysqld.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+--enable_warnings
+
+# MariaDB: the following is for handling the case where the tests
+# is started on a totally empty datadir, where no MyRocks table has
+# ever been created). In that case, there is no MAX_INDEX_ID.
+# Create/drop a table so that we do have MAX_INDEX_ID.
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK=1;
+create table t1 (a int) engine=rocksdb;
+drop table t1;
+
+--let $max_index_id = query_get_value(SELECT * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where type = 'MAX_INDEX_ID', VALUE, 1)
+--replace_result $max_index_id max_index_id
+select * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where type<>'DDL_DROP_INDEX_ONGOING';
+select count(*) from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where type<>'DDL_DROP_INDEX_ONGOING';
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK=0;
+
+select VALUE into @keysIn from INFORMATION_SCHEMA.ROCKSDB_COMPACTION_STATS where CF_NAME = 'default' and LEVEL = 'Sum' and TYPE = 'KeyIn';
+
+CREATE TABLE t1 (i1 INT, i2 INT, PRIMARY KEY (i1)) ENGINE = ROCKSDB;
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+
+set global rocksdb_force_flush_memtable_now = true;
+# No binlog coordinates in MariaDB: --let $MASTER_UUID = query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
+--let $max_index_id = query_get_value(SELECT * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where type = 'MAX_INDEX_ID', VALUE, 1)
+# No binlog coordinates in MariaDB: --replace_result $MASTER_UUID uuid $max_index_id max_index_id
+--replace_result $max_index_id max_index_id
+select * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO;
+select count(*) from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO;
+
+set global rocksdb_force_flush_memtable_now = true;
+set global rocksdb_compact_cf='default';
+select case when VALUE-@keysIn >= 3 then 'true' else 'false' end from INFORMATION_SCHEMA.ROCKSDB_COMPACTION_STATS where CF_NAME = 'default' and LEVEL = 'Sum' and TYPE = 'KeyIn';
+
+CREATE INDEX tindex1 on t1 (i1);
+--let $start_max_index_id = query_get_value(SELECT * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where type = 'MAX_INDEX_ID', VALUE, 1)
+
+CREATE INDEX tindex2 on t1 (i2);
+--let $end_max_index_id = query_get_value(SELECT * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where type = 'MAX_INDEX_ID', VALUE, 1)
+
+if ($end_max_index_id <= $start_max_index_id) {
+ echo Max index ID did not increase;
+}
+
+select * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where TYPE = 'CF_FLAGS';
+
+CREATE TABLE t2 (
+ a int,
+ b int,
+ c int,
+ d int,
+ PRIMARY KEY (a) COMMENT "cf_a",
+ KEY (b) COMMENT "cf_b",
+ KEY (c) COMMENT "cf_c",
+ KEY (d) COMMENT "rev:cf_d") ENGINE=ROCKSDB;
+
+select * from INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO where TYPE = 'CF_FLAGS';
+
+CREATE TABLE t3 (a INT, PRIMARY KEY (a)) ENGINE=ROCKSDB;
+insert into t3 (a) values (1), (2), (3);
+SET @ORIG_ROCKSDB_PAUSE_BACKGROUND_WORK = @@GLOBAL.ROCKSDB_PAUSE_BACKGROUND_WORK;
+--let $t3_index_id = query_get_value(SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_DDL WHERE TABLE_NAME = 't3', INDEX_NUMBER, 1)
+--let $t3_cf_id = query_get_value(SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_DDL WHERE TABLE_NAME = 't3', COLUMN_FAMILY, 1)
+SHOW GLOBAL VARIABLES LIKE 'ROCKSDB_PAUSE_BACKGROUND_WORK';
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK=1;
+SHOW GLOBAL VARIABLES LIKE 'ROCKSDB_PAUSE_BACKGROUND_WORK';
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK=1;
+SHOW GLOBAL VARIABLES LIKE 'ROCKSDB_PAUSE_BACKGROUND_WORK';
+DROP TABLE t3;
+--let $result = query_get_value("SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_GLOBAL_INFO WHERE TYPE = 'DDL_DROP_INDEX_ONGOING' AND NAME LIKE 'cf_id:$t3_cf_id,index_id:$t3_index_id'", NAME, 1)
+--echo $result
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK=0;
+SHOW GLOBAL VARIABLES LIKE 'ROCKSDB_PAUSE_BACKGROUND_WORK';
+--echo next line shouldn't cause assertion to fail
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK=0;
+SHOW GLOBAL VARIABLES LIKE 'ROCKSDB_PAUSE_BACKGROUND_WORK';
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_ROCKSDB_PAUSE_BACKGROUND_WORK;
+
+DROP TABLE t1;
+DROP TABLE t2;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/init_stats_procedure.inc b/storage/rocksdb/mysql-test/rocksdb/t/init_stats_procedure.inc
new file mode 100644
index 00000000..dda253bc
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/init_stats_procedure.inc
@@ -0,0 +1,40 @@
+# This inc script creates two procedures -- save_read_stats() and
+# get_read_stats(). get_read_stats() prints differential rocksdb_rows_read,
+# rocksdb_rows_updated, and rocksdb_rows_deleted values since calling
+# save_read_stats().
+
+delimiter //;
+create procedure save_read_stats()
+begin
+ /*select rows_requested into @rq from information_schema.table_statistics
+ where table_schema=database() and table_name='t1';*/
+ select rows_read into @rr_is from information_schema.table_statistics
+ where table_schema=database() and table_name='t1';
+ select variable_value into @rr from information_schema.global_status
+ where variable_name='rocksdb_rows_read';
+ select variable_value into @ru from information_schema.global_status
+ where variable_name='rocksdb_rows_updated';
+ select variable_value into @rd from information_schema.global_status
+ where variable_name='rocksdb_rows_deleted';
+end//
+
+create procedure get_read_stats()
+begin
+ /*select rows_requested - @rq as rows_requested from
+ information_schema.table_statistics
+ where table_schema=database() and table_name='t1';*/
+ select rows_read - @rr_is as rows_read_userstat from
+ information_schema.table_statistics
+ where table_schema=database() and table_name='t1';
+ select variable_value - @rr as rows_read from
+ information_schema.global_status
+ where variable_name='rocksdb_rows_read';
+ select variable_value - @ru as rows_updated from
+ information_schema.global_status
+ where variable_name='rocksdb_rows_updated';
+ select variable_value - @rd as rows_deleted from
+ information_schema.global_status
+ where variable_name='rocksdb_rows_deleted';
+end//
+delimiter ;//
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/innodb_i_s_tables_disabled-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/innodb_i_s_tables_disabled-master.opt
new file mode 100644
index 00000000..b3565b5f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/innodb_i_s_tables_disabled-master.opt
@@ -0,0 +1,30 @@
+--loose-enable-innodb_trx
+--loose-enable-innodb_file_status
+--loose-enable-innodb_locks
+--loose-enable-innodb_lock_waits
+--loose-enable-innodb_cmp
+--loose-enable-innodb_cmp_reset
+--loose-enable-innodb_cmp_per_index
+--loose-enable-innodb_cmp_per_index_reset
+--loose-enable-innodb_cmpmem
+--loose-enable-innodb_cmpmem_reset
+--loose-enable-innodb_metrics
+--loose-enable-innodb_ft_default_stopword
+--loose-enable-innodb_ft_deleted
+--loose-enable-innodb_ft_being_deleted
+--loose-enable-innodb_ft_index_cache
+--loose-enable-innodb_ft_index_table
+--loose-enable-innodb_ft_config
+--loose-enable-innodb_buffer_pool_stats
+--loose-enable-innodb_buffer_page
+--loose-enable-innodb_buffer_page_lru
+--loose-enable-innodb_sys_tables
+--loose-enable-innodb_sys_tablestats
+--loose-enable-innodb_sys_indexes
+--loose-enable-innodb_sys_columns
+--loose-enable-innodb_sys_fields
+--loose-enable-innodb_sys_foreign
+--loose-enable-innodb_sys_foreign_cols
+--loose-enable-innodb_sys_tablespaces
+--loose-enable-innodb_sys_datafiles
+--loose-enable-innodb_sys_docstore_fields
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/innodb_i_s_tables_disabled.test b/storage/rocksdb/mysql-test/rocksdb/t/innodb_i_s_tables_disabled.test
new file mode 100644
index 00000000..4ff48e13
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/innodb_i_s_tables_disabled.test
@@ -0,0 +1,43 @@
+--source include/have_rocksdb.inc
+
+# Make sure that the InnoDb information schema tables are disabled when InnoDB
+# is turned off and attempting to access them doesn't crash.
+
+# Disable warnings, as the table names in warnings appear in lower or uppercase
+# depending on platform
+
+--disable_warnings
+
+SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX;
+#Not in MariaDB: SELECT * FROM INFORMATION_SCHEMA.INNODB_FILE_STATUS;
+
+SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_CMP;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_CMP_RESET;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_CMP_PER_INDEX;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_CMP_PER_INDEX_RESET;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_CMPMEM;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_CMPMEM_RESET;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DEFAULT_STOPWORD;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DELETED;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_CONFIG;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE_LRU;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_DATAFILES;
+#Not in MariaDB: SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_DOCSTORE_FIELDS;
+
+--enable_warnings
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/insert.test b/storage/rocksdb/mysql-test/rocksdb/t/insert.test
new file mode 100644
index 00000000..aebd3f76
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/insert.test
@@ -0,0 +1,99 @@
+--source include/have_rocksdb.inc
+
+#
+# Basic INSERT statements
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+
+# INSERT [INTO] .. VALUES|VALUE ..
+
+INSERT INTO t1 VALUES (100,'foobar',100),(1,'a',101),(2,'b',103),(3,'c',104),(4,'d',105),(5,'e',106);
+--sorted_result
+SELECT a,b FROM t1;
+
+INSERT t1 VALUE (10,'foo',107),(11,'abc',108);
+--sorted_result
+SELECT a,b FROM t1;
+
+INSERT INTO t1 (b,a) VALUES ('test',0);
+--sorted_result
+SELECT a,b FROM t1;
+
+INSERT INTO t1 VALUES (DEFAULT,DEFAULT,NULL);
+--sorted_result
+SELECT a,b FROM t1;
+
+INSERT t1 (a) VALUE (10),(20);
+--sorted_result
+SELECT a,b FROM t1;
+
+# INSERT [INTO] .. SET
+
+INSERT INTO t1 SET a = 11, b = 'f';
+--sorted_result
+SELECT a,b FROM t1;
+
+INSERT t1 SET b = DEFAULT;
+--sorted_result
+SELECT a,b FROM t1;
+
+
+# INSERT .. SELECT
+
+CREATE TABLE t2 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+
+INSERT INTO t2 SELECT a,b,pk FROM t1;
+INSERT INTO t1 (a) SELECT a FROM t2 WHERE b = 'foo';
+--sorted_result
+SELECT a,b FROM t1;
+
+INSERT t1 (a,b) SELECT a,b FROM t1;
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1, t2;
+
+#
+# Transactional INSERT
+#
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+
+BEGIN;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(100,'foo');
+INSERT t1 (a,b) VALUE (10,'foo'),(11,'abc');
+COMMIT;
+--sorted_result
+SELECT a,b FROM t1;
+
+BEGIN;
+INSERT INTO t1 (b,a) VALUES ('test',0);
+SAVEPOINT spt1;
+INSERT INTO t1 (a,b) VALUES (DEFAULT,DEFAULT);
+RELEASE SAVEPOINT spt1;
+INSERT INTO t1 (a,b) VALUES (DEFAULT,DEFAULT);
+ROLLBACK;
+--sorted_result
+SELECT a,b FROM t1;
+
+BEGIN;
+INSERT t1 (a) VALUE (10),(20);
+SAVEPOINT spt1;
+INSERT INTO t1 SET a = 11, b = 'f';
+INSERT t1 SET b = DEFAULT;
+--error ER_ROLLBACK_TO_SAVEPOINT
+ROLLBACK TO SAVEPOINT spt1;
+INSERT INTO t1 (b,a) VALUES ('test1',10);
+--error ER_ROLLBACK_ONLY
+COMMIT;
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/insert_optimized_config.test b/storage/rocksdb/mysql-test/rocksdb/t/insert_optimized_config.test
new file mode 100644
index 00000000..a24851d9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/insert_optimized_config.test
@@ -0,0 +1,51 @@
+--source include/have_rocksdb.inc
+--source include/have_write_committed.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# reload with load optimized config
+let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
+--exec echo "wait" > $restart_file
+--shutdown_server
+--source include/wait_until_disconnected.inc
+-- exec echo "restart:--rocksdb_write_disable_wal=1 --rocksdb_flush_log_at_trx_commit=0 --rocksdb_default_cf_options=write_buffer_size=16k;target_file_size_base=16k;level0_file_num_compaction_trigger=4;level0_slowdown_writes_trigger=256;level0_stop_writes_trigger=256;max_write_buffer_number=16;compression_per_level=kNoCompression;memtable=vector:1024 --rocksdb_override_cf_options=__system__={memtable=skip_list:16} --rocksdb_compaction_sequential_deletes=0 --rocksdb_compaction_sequential_deletes_window=0 --rocksdb_allow_concurrent_memtable_write=0" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- enable_reconnect
+-- source include/wait_until_connected_again.inc
+
+create table t1(
+ id bigint not null primary key,
+ i1 bigint, #unique
+ i2 bigint, #repeating
+ c1 varchar(20), #unique
+ c2 varchar(20), #repeating
+ index t1_2(i1)
+) engine=rocksdb;
+
+--disable_query_log
+set rocksdb_bulk_load=1;
+let $i=0;
+while ($i<50000)
+{
+ inc $i;
+ eval insert t1(id, i1, i2, c1, c2) values($i, $i, $i div 10, $i, $i div 10);
+}
+set rocksdb_bulk_load=0;
+--enable_query_log
+
+select count(*), sum(id), sum(i1), sum(i2) from t1;
+
+# reload without load optimized config
+let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
+--exec echo "wait" > $restart_file
+--shutdown_server
+--source include/wait_until_disconnected.inc
+-- exec echo "restart:--rocksdb_write_disable_wal=0 --rocksdb_default_cf_options=write_buffer_size=64k;target_file_size_base=64k;max_bytes_for_level_base=1m;compression_per_level=kNoCompression;" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- enable_reconnect
+-- source include/wait_until_connected_again.inc
+
+select count(*), sum(id), sum(i1), sum(i2) from t1;
+
+drop table t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/insert_with_keys.test b/storage/rocksdb/mysql-test/rocksdb/t/insert_with_keys.test
new file mode 100644
index 00000000..1332fe14
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/insert_with_keys.test
@@ -0,0 +1,169 @@
+--source include/have_rocksdb.inc
+
+#
+# INSERT statements for tables with keys
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, KEY(b)) ENGINE=rocksdb;
+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');
+INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
+--sorted_result
+SELECT a,b FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, UNIQUE INDEX(a)) ENGINE=rocksdb;
+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');
+--error ER_DUP_ENTRY
+INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+--error ER_DUP_ENTRY
+INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
+INSERT INTO t1 (a,b) VALUES (0,'');
+--sorted_result
+SELECT a,b FROM t1;
+
+INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+INSERT INTO t1 (a,b) VALUES (3,'a'),(4,'d') ON DUPLICATE KEY UPDATE a = a+10;
+
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, UNIQUE INDEX(a,b)) ENGINE=rocksdb;
+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');
+--error ER_DUP_ENTRY
+INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+--sorted_result
+SELECT a,b FROM t1;
+
+INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z') ON DUPLICATE KEY UPDATE a = a+VALUES(a);
+--sorted_result
+SELECT a,b FROM t1;
+
+--error ER_DUP_ENTRY
+INSERT INTO t1 (a,b) VALUES (101,'x'),(101,'x');
+
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+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');
+--error ER_DUP_ENTRY
+INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+--error ER_DUP_ENTRY
+INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
+INSERT INTO t1 (a,b) VALUES (0,'');
+--sorted_result
+SELECT a,b FROM t1;
+
+INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z') ON DUPLICATE KEY UPDATE b = CONCAT(b,b);
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+#
+# INSERT on DUPLICATE KEY UPDATE with multiple keys
+#
+--echo
+--echo INSERT on DUPLICATE KEY UPDATE with multiple keys
+--echo
+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(255)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (3,'a'), (4,'a'), (5,'a'), (6,'a'), (7,'a'), (8,'a'), (9,'a'), (10,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (3,'a'), (4,'a'), (5,'a'), (6,'a'), (7,'a'), (8,'a'), (9,'a'), (10,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+#
+# INSERT on DUPLICATE KEY UPDATE with secondary key
+#
+--echo
+--echo INSERT on DUPLICATE KEY UPDATE with secondary key
+--echo
+CREATE TABLE t1 (a INT, b CHAR(8), c INT DEFAULT 0, pk INT AUTO_INCREMENT PRIMARY KEY, UNIQUE INDEX(a,b)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d'), (5,'e'), (6,'f'), (7,'g'), (8,'h'), (9,'i'), (10,'j') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d'), (5,'e'), (6,'f'), (7,'g'), (8,'h'), (9,'i'), (10,'j') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c') ON DUPLICATE KEY UPDATE c = c + 1;
+
+--sorted_result
+SELECT a,b,c,pk FROM t1;
+
+DROP TABLE t1;
+
+--echo
+--echo Disable caching and see if it still functions properly
+--echo
+SELECT @@rocksdb_enable_insert_with_update_caching;
+SET GLOBAL rocksdb_enable_insert_with_update_caching=0;
+SELECT @@rocksdb_enable_insert_with_update_caching;
+
+#
+# INSERT on DUPLICATE KEY UPDATE with multiple keys
+#
+--echo
+--echo INSERT on DUPLICATE KEY UPDATE with multiple keys
+--echo
+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(255)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (3,'a'), (4,'a'), (5,'a'), (6,'a'), (7,'a'), (8,'a'), (9,'a'), (10,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (3,'a'), (4,'a'), (5,'a'), (6,'a'), (7,'a'), (8,'a'), (9,'a'), (10,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a'), (1,'a'), (2,'a') ON DUPLICATE KEY UPDATE b = CONCAT(b, 'a');
+
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+#
+# INSERT on DUPLICATE KEY UPDATE with secondary key
+#
+--echo
+--echo INSERT on DUPLICATE KEY UPDATE with secondary key
+--echo
+CREATE TABLE t1 (a INT, b CHAR(8), c INT DEFAULT 0, pk INT AUTO_INCREMENT PRIMARY KEY, UNIQUE INDEX(a,b)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a');
+INSERT INTO t1 (a,b) VALUES (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a'), (1,'a') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d'), (5,'e'), (6,'f'), (7,'g'), (8,'h'), (9,'i'), (10,'j') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d'), (5,'e'), (6,'f'), (7,'g'), (8,'h'), (9,'i'), (10,'j') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b'), (1,'a'), (2,'b') ON DUPLICATE KEY UPDATE c = c + 1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c'), (1,'a'), (2,'c') ON DUPLICATE KEY UPDATE c = c + 1;
+
+--sorted_result
+SELECT a,b,c,pk FROM t1;
+
+DROP TABLE t1;
+
+--echo
+--echo Cleanup
+--echo
+SET GLOBAL rocksdb_enable_insert_with_update_caching=1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/issue100.test b/storage/rocksdb/mysql-test/rocksdb/t/issue100.test
new file mode 100644
index 00000000..b0b3eb7a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/issue100.test
@@ -0,0 +1,23 @@
+--source include/have_rocksdb.inc
+
+create table t1 (
+ id int,
+ value int,
+ primary key (id)
+) engine=rocksdb;
+
+insert into t1 values(1,1),(2,2);
+set autocommit=0;
+
+begin;
+insert into t1 values (50,50);
+select * from t1;
+
+update t1 set id=id+100;
+
+select * from t1;
+
+rollback;
+set autocommit=1;
+
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/issue100_delete-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/issue100_delete-master.opt
new file mode 100644
index 00000000..436edf2b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/issue100_delete-master.opt
@@ -0,0 +1 @@
+--rocksdb_table_stats_sampling_pct=100
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/issue100_delete.test b/storage/rocksdb/mysql-test/rocksdb/t/issue100_delete.test
new file mode 100644
index 00000000..743bf7dd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/issue100_delete.test
@@ -0,0 +1,19 @@
+--source include/have_rocksdb.inc
+
+create table ten(a int primary key);
+insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table one_k(a int primary key);
+insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;
+
+create table t100(pk int primary key, a int, b int, key(a));
+insert into t100 select a,a,a from test.one_k;
+
+set global rocksdb_force_flush_memtable_now=1;
+select num_rows, entry_deletes, entry_singledeletes from information_schema.rocksdb_index_file_map where index_number = (select max(index_number) from information_schema.rocksdb_index_file_map) order by entry_deletes, entry_singledeletes;
+
+update t100 set a=a+1;
+set global rocksdb_force_flush_memtable_now=1;
+select num_rows, entry_deletes, entry_singledeletes from information_schema.rocksdb_index_file_map where index_number = (select max(index_number) from information_schema.rocksdb_index_file_map) order by entry_deletes, entry_singledeletes;
+
+drop table ten, t100, one_k;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/issue111.test b/storage/rocksdb/mysql-test/rocksdb/t/issue111.test
new file mode 100644
index 00000000..671ea470
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/issue111.test
@@ -0,0 +1,38 @@
+--source include/have_rocksdb.inc
+
+connect (con2,localhost,root,,);
+connection default;
+
+create table t1 (
+ pk int not null primary key,
+ col1 int not null,
+ col2 int not null,
+ key(col1)
+) engine=rocksdb;
+
+create table ten(a int primary key);
+insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table one_k(a int primary key);
+insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;
+
+insert into t1 select a,a,a from one_k;
+
+--echo # Start the transaction, get the snapshot
+begin;
+select * from t1 where col1<10;
+
+--echo # Connect with another connection and make a conflicting change
+connection con2;
+
+begin;
+update t1 set col2=123456 where pk=0;
+commit;
+
+connection default;
+
+--error ER_LOCK_DEADLOCK
+update t1 set col2=col2+1 where col1 < 10 limit 5;
+
+disconnect con2;
+drop table t1, ten, one_k;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/issue243_transactionStatus.test b/storage/rocksdb/mysql-test/rocksdb/t/issue243_transactionStatus.test
new file mode 100644
index 00000000..0997bde3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/issue243_transactionStatus.test
@@ -0,0 +1,80 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (
+ id INT,
+ val1 INT,
+ val2 INT,
+ PRIMARY KEY (id)
+) ENGINE=rocksdb;
+
+#
+# DB operations without Transaction , every count should be 0
+# so there's no count related output
+#
+INSERT INTO t1 VALUES(1,1,1),(2,1,2);
+SELECT * FROM t1;
+UPDATE t1 SET val1=2 WHERE id=2;
+SELECT * FROM t1;
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /0x[0-9a-f]+/PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+
+#
+# DB operations with Tansaction, insert_count, update_count, delete_count
+# and total write_count should be printed
+# Cases: rollback, commit transaction
+#
+SET AUTOCOMMIT=0;
+START TRANSACTION;
+INSERT INTO t1 VALUES(20,1,1),(30,30,30);
+SELECT * FROM t1;
+UPDATE t1 SET val1=20, val2=20 WHERE id=20;
+SELECT * FROM t1;
+DELETE FROM t1 WHERE id=30;
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /0x[0-9a-f]+/PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+
+ROLLBACK;
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /0x[0-9a-f]+/PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+
+START TRANSACTION;
+INSERT INTO t1 VALUES(40,40,40);
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /0x[0-9a-f]+/PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+COMMIT;
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /0x[0-9a-f]+/PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+
+SET AUTOCOMMIT=1;
+DROP TABLE t1;
+
+#
+# Secondary Key Tests
+#
+--disable_warnings
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+CREATE TABLE t2 (
+ id1 INT,
+ id2 INT,
+ value INT,
+ PRIMARY KEY (id1),
+ KEY (id2)
+) ENGINE=rocksdb;
+
+SET AUTOCOMMIT=0;
+START TRANSACTION;
+INSERT INTO t2 VALUES(1,2,0),(10,20,30);
+UPDATE t2 SET value=3 WHERE id2=2;
+DELETE FROM t2 WHERE id1=10;
+
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /0x[0-9a-f]+/PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+ROLLBACK;
+SET AUTOCOMMIT=1;
+DROP TABLE t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/issue255.test b/storage/rocksdb/mysql-test/rocksdb/t/issue255.test
new file mode 100644
index 00000000..686f45b4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/issue255.test
@@ -0,0 +1,52 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE t1 (pk BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT);
+
+INSERT INTO t1 VALUES (5);
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+INSERT INTO t1 VALUES ('538647864786478647864');
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SELECT * FROM t1;
+--replace_column 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES ();
+SELECT * FROM t1;
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES ();
+SELECT * FROM t1;
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (pk TINYINT NOT NULL PRIMARY KEY AUTO_INCREMENT);
+
+INSERT INTO t1 VALUES (5);
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+INSERT INTO t1 VALUES (1000);
+SELECT * FROM t1;
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES ();
+SELECT * FROM t1;
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES ();
+SELECT * FROM t1;
+--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/issue290.test b/storage/rocksdb/mysql-test/rocksdb/t/issue290.test
new file mode 100644
index 00000000..5ea8799c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/issue290.test
@@ -0,0 +1,40 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE `linktable` (
+ `id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+ `id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+ `link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `visibility` tinyint(3) NOT NULL DEFAULT '0',
+ `data` varchar(255) NOT NULL DEFAULT '',
+ `time` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `version` int(11) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (link_type, `id1`,`id2`) COMMENT 'cf_link_pk',
+ KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`id2`,`version`,`data`) COMMENT 'rev:cf_link_id1_type'
+) ENGINE=RocksDB DEFAULT COLLATE=latin1_bin;
+--disable_query_log
+let $i = 1;
+while ($i <= 10000) {
+ let $insert = INSERT INTO linktable (id1, link_type, id2) values (1, 1, $i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+set global rocksdb_force_flush_memtable_now=1;
+
+insert into linktable (id1, link_type, id2) values (2, 1, 1);
+insert into linktable (id1, link_type, id2) values (2, 1, 2);
+insert into linktable (id1, link_type, id2) values (2, 1, 3);
+insert into linktable (id1, link_type, id2) values (2, 1, 4);
+insert into linktable (id1, link_type, id2) values (2, 1, 5);
+insert into linktable (id1, link_type, id2) values (2, 1, 6);
+insert into linktable (id1, link_type, id2) values (2, 1, 7);
+insert into linktable (id1, link_type, id2) values (2, 1, 8);
+insert into linktable (id1, link_type, id2) values (2, 1, 9);
+insert into linktable (id1, link_type, id2) values (2, 1, 10);
+
+--replace_column 9 #
+explain select id1, id2, link_type, data from linktable force index(primary) where id1=2 and link_type=1 and (id2=1 or id2=2 or id2=3 or id2=4 or id2=5);
+
+drop table linktable;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/issue314.test b/storage/rocksdb/mysql-test/rocksdb/t/issue314.test
new file mode 100644
index 00000000..822969a3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/issue314.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+CREATE TABLE t1(a int);
+SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
+INSERT INTO t1 VALUES(1);
+--error ER_ISOLATION_MODE_NOT_SUPPORTED
+select * from t1;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+select * from t1;
+drop table t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/issue495.test b/storage/rocksdb/mysql-test/rocksdb/t/issue495.test
new file mode 100644
index 00000000..5dcc7c19
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/issue495.test
@@ -0,0 +1,34 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+--disable_warnings
+drop table if exists t;
+--enable_warnings
+
+create table t (
+ a int,
+ b int,
+ c varchar(12249) collate latin1_bin,
+ d datetime,
+ e int,
+ f int,
+ g blob,
+ h int,
+ i int,
+ key (b,e),
+ key (h,b)
+) engine=rocksdb
+partition by linear hash (i) partitions 8 ;
+
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+insert into t values (1,1,'a',now(),1,1,'a',1,1);
+select i from t group by h;
+select i from t group by h;
+
+drop table t;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/issue884.test b/storage/rocksdb/mysql-test/rocksdb/t/issue884.test
new file mode 100644
index 00000000..6bf3e517
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/issue884.test
@@ -0,0 +1,43 @@
+--source include/have_rocksdb.inc
+
+create table test (
+ a bigint(20) not null,
+ b bigint(20) not null,
+ c varchar(500) not null,
+ d bigint(20) not null,
+ e bigint(20) not null,
+ f varchar(500) not null,
+ g varchar(500) not null,
+ h varchar(500) not null,
+ i varchar(1000) not null,
+ j varchar(16384) not null,
+ k varchar(200) not null,
+ l varchar(500) not null,
+ m varchar(100) not null,
+ n bigint(20) not null,
+ primary key (a, b, m, c(100), l(100), d, e, f(100), g(100), h(100), n),
+ key n (n),
+ key d (d, a)
+) engine = rocksdb default charset = latin1;
+
+--disable_query_log
+let $i = 1000;
+while ($i) {
+ --eval insert into test values (10, 1, "i", $i / 100, $i, "f", "g", "h", "i", "j", "k", "l", "m", $i);
+ --eval insert into test values (10, 2, "i", $i / 100, $i, "f", "g", "h", "i", "j", "k", "l", "m", $i);
+ --eval insert into test values (10, 3, "i", $i / 100, $i, "f", "g", "h", "i", "j", "k", "l", "m", $i);
+ --eval insert into test values (10, 4, "i", $i / 100, $i, "f", "g", "h", "i", "j", "k", "l", "m", $i);
+ --eval insert into test values (10, 5, "i", $i / 100, $i, "f", "g", "h", "i", "j", "k", "l", "m", $i);
+ dec $i;
+}
+set global rocksdb_force_flush_memtable_now = true;
+analyze table test;
+--enable_query_log
+
+--replace_column 9 #
+explain
+select * from test where d = 10 and a = 10 and b = 2;
+select * from test where d = 10 and a = 10 and b = 2;
+
+
+drop table test;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/issue896.test b/storage/rocksdb/mysql-test/rocksdb/t/issue896.test
new file mode 100644
index 00000000..ba57fb99
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/issue896.test
@@ -0,0 +1,17 @@
+# issue 896 : Segmentation fault in myrocks::Rdb_string_reader::read
+--source include/have_rocksdb.inc
+
+CREATE TABLE `t1` (
+`a` bigint(20) NOT NULL,
+`b` varchar(10) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+`u` bigint(20) unsigned NOT NULL,
+`d` bigint(20) DEFAULT NULL,
+PRIMARY KEY (`a`,`b`),
+KEY `d` (`d`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='ttl_duration=1000;ttl_col=u';
+INSERT INTO t1 VALUES (100, 'aaabbb', UNIX_TIMESTAMP(), 200);
+--replace_column 9 #
+EXPLAIN SELECT COUNT(*) FROM t1 FORCE INDEX(d);
+--echo # segfault here without the fix
+SELECT COUNT(*) FROM t1 FORCE INDEX(d);
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/issue900.test b/storage/rocksdb/mysql-test/rocksdb/t/issue900.test
new file mode 100644
index 00000000..ce52e0ad
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/issue900.test
@@ -0,0 +1,13 @@
+--source include/have_rocksdb.inc
+
+# Issue 900 : Segmentation fault in myrocks::Rdb_string_reader::read
+CREATE TABLE t1(c1 VARCHAR(1) CHARACTER SET 'utf8' COLLATE 'utf8_bin', c2 YEAR, c3 REAL(1,0) UNSIGNED, PRIMARY KEY(c1)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES(0,'0','0');
+INSERT INTO t1 VALUES('{0}','0','0');
+INSERT INTO t1 VALUES('1','0','1');
+# Would segfault here
+--error ER_DUP_ENTRY
+ALTER TABLE t1 ADD INDEX(c3), ADD UNIQUE (c3);
+--error ER_KEY_DOES_NOT_EXISTS
+SELECT c3 FROM t1 FORCE INDEX(c3) ORDER BY c3;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/iterator_bounds-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/iterator_bounds-master.opt
new file mode 100644
index 00000000..d7743993
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/iterator_bounds-master.opt
@@ -0,0 +1,2 @@
+--rocksdb_default_cf_options=write_buffer_size=256k;block_based_table_factory={filter_policy=bloomfilter:10:false;whole_key_filtering=0;}
+--rocksdb_override_cf_options=rev:bf5_1={prefix_extractor=capped:12};
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/iterator_bounds.test b/storage/rocksdb/mysql-test/rocksdb/t/iterator_bounds.test
new file mode 100644
index 00000000..2cced2a1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/iterator_bounds.test
@@ -0,0 +1,29 @@
+#
+# Issue #878: Descending scans from reverse column families return no results
+# due to iterator bounds
+#
+
+create table t (i int primary key) engine=rocksdb;
+
+let $cond=1;
+while ($cond)
+{
+ --disable_query_log
+ truncate table t;
+ --enable_query_log
+ let $cond=`select RIGHT(HEX(index_number), 2) != "FD" from information_schema.rocksdb_ddl where table_name = 't'`;
+}
+
+# Index id is now at FD. Create a table with primary and secondary key, so
+# that the secondary key index id ends in 0xFF.
+
+drop table t;
+create table t (i int primary key, j int, key(j) comment 'rev:bf5_2') engine=rocksdb;
+select RIGHT(HEX(index_number), 2) from information_schema.rocksdb_ddl where table_name = 't';
+
+insert into t values (1, 1);
+
+select j from t order by j asc;
+select j from t order by j desc;
+
+drop table t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/kill.test b/storage/rocksdb/mysql-test/rocksdb/t/kill.test
new file mode 100644
index 00000000..a2809d96
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/kill.test
@@ -0,0 +1,9 @@
+--source include/have_binlog_format_row.inc
+--source include/have_rocksdb.inc
+
+CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=RocksDB;
+LOCK TABLE t1 WRITE;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+--error ER_ISOLATION_MODE_NOT_SUPPORTED
+FLUSH TABLES;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/level_read_committed.test b/storage/rocksdb/mysql-test/rocksdb/t/level_read_committed.test
new file mode 100644
index 00000000..bedf87a8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/level_read_committed.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+let $trx_isolation = READ COMMITTED;
+
+--source transaction_isolation.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/level_read_uncommitted.opt b/storage/rocksdb/mysql-test/rocksdb/t/level_read_uncommitted.opt
new file mode 100644
index 00000000..418e4c3f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/level_read_uncommitted.opt
@@ -0,0 +1 @@
+--rocksdb_default_cf_options=disable_auto_compactions=true \ No newline at end of file
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/level_read_uncommitted.test b/storage/rocksdb/mysql-test/rocksdb/t/level_read_uncommitted.test
new file mode 100644
index 00000000..8ee3af60
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/level_read_uncommitted.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+let $trx_isolation = READ UNCOMMITTED;
+--source transaction_isolation.inc
+--source consistent_snapshot.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/level_repeatable_read.test b/storage/rocksdb/mysql-test/rocksdb/t/level_repeatable_read.test
new file mode 100644
index 00000000..cf29073f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/level_repeatable_read.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+
+let $trx_isolation = REPEATABLE READ;
+--source transaction_isolation.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/level_serializable.test b/storage/rocksdb/mysql-test/rocksdb/t/level_serializable.test
new file mode 100644
index 00000000..9b5db0e8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/level_serializable.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+
+let $trx_isolation = SERIALIZABLE;
+--source transaction_isolation.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/loaddata.inc b/storage/rocksdb/mysql-test/rocksdb/t/loaddata.inc
new file mode 100644
index 00000000..1d83598a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/loaddata.inc
@@ -0,0 +1,117 @@
+--source include/have_rocksdb.inc
+
+#
+# Basic LOAD DATA statements
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+
+let $datadir = `SELECT @@datadir`;
+
+--write_file $datadir/se_loaddata.dat
+1,foo,
+2,bar,
+3,,
+4,abc,
+EOF
+
+--replace_result $datadir <DATADIR>
+eval
+LOAD DATA INFILE '$datadir/se_loaddata.dat' INTO TABLE t1
+ FIELDS TERMINATED BY ',' (a,b);
+--sorted_result
+SELECT a,b FROM t1;
+
+--replace_result $datadir <DATADIR>
+eval
+LOAD DATA LOCAL INFILE '$datadir/se_loaddata.dat' INTO TABLE t1
+ CHARACTER SET utf8 COLUMNS TERMINATED BY ','
+ ESCAPED BY '/' (a,b);
+--sorted_result
+SELECT a,b FROM t1;
+
+--remove_file $datadir/se_loaddata.dat
+--write_file $datadir/se_loaddata.dat
+5;YYY;
+102;'zzz';
+0;'test';
+EOF
+
+--replace_result $datadir <DATADIR>
+eval
+LOAD DATA LOCAL INFILE '$datadir/se_loaddata.dat' INTO TABLE t1
+ FIELDS TERMINATED BY ';'
+ (a) SET b='loaded';
+
+--sorted_result
+SELECT a,b FROM t1;
+
+--remove_file $datadir/se_loaddata.dat
+--write_file $datadir/se_loaddata.dat
+prefix:5;'foo';
+prefix:6;'';
+prefix:100;foo;
+prefix:7;'test';suffix
+101;abc;
+102;'z';
+prefix:0;;
+EOF
+
+--replace_result $datadir <DATADIR>
+eval
+LOAD DATA INFILE '$datadir/se_loaddata.dat' INTO TABLE t1
+ FIELDS TERMINATED BY ';'
+ OPTIONALLY ENCLOSED BY ''''
+ LINES STARTING BY 'prefix:'
+ IGNORE 2 LINES (a,b);
+
+--sorted_result
+SELECT a,b FROM t1;
+
+--remove_file $datadir/se_loaddata.dat
+--write_file $datadir/se_loaddata.dat
+1 foo
+2 bar
+3
+4 abc
+EOF
+
+--replace_result $datadir <DATADIR>
+eval
+LOAD DATA INFILE '$datadir/se_loaddata.dat' INTO TABLE t1;
+--sorted_result
+SELECT a,b FROM t1;
+--remove_file $datadir/se_loaddata.dat
+
+
+--write_file $datadir/se_replacedata.dat
+1 aaa
+2 bbb
+3 ccc
+4 ddd
+EOF
+
+--replace_result $datadir <DATADIR>
+if ($skip_unique_check == 1)
+{
+ --error ER_ON_DUPLICATE_DISABLED
+ eval
+ LOAD DATA INFILE '$datadir/se_replacedata.dat' REPLACE INTO TABLE t1;
+}
+if ($skip_unique_check == 0)
+{
+ eval
+ LOAD DATA INFILE '$datadir/se_replacedata.dat' REPLACE INTO TABLE t1;
+}
+--sorted_result
+SELECT a,b FROM t1;
+--remove_file $datadir/se_replacedata.dat
+
+
+# Cleanup
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/loaddata.test b/storage/rocksdb/mysql-test/rocksdb/t/loaddata.test
new file mode 100644
index 00000000..1f59d5ce
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/loaddata.test
@@ -0,0 +1,7 @@
+--source include/have_rocksdb.inc
+
+let $skip_unique_check = 0;
+--source loaddata.inc
+let $skip_unique_check = 1;
+set session unique_checks=0;
+--source loaddata.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/lock.test b/storage/rocksdb/mysql-test/rocksdb/t/lock.test
new file mode 100644
index 00000000..9ce5e566
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/lock.test
@@ -0,0 +1,224 @@
+--source include/have_rocksdb.inc
+
+# Standard table locking:
+# LOCK TABLE .. READ
+# LOCK TABLE .. [LOW_PRIORITY] WRITE
+# UNLOCK TABLES
+#
+# and global locking:
+# FLUSH TABLES [..] WITH READ LOCK
+#
+############################################
+# TODO:
+# A part of the test is currently disabled
+# because temporary tables are not supported
+############################################
+
+--enable_connect_log
+
+# Save the initial number of concurrent sessions.
+--source include/count_sessions.inc
+
+connect (con1,localhost,root,,);
+SET lock_wait_timeout=1;
+
+connection default;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3;
+--enable_warnings
+
+CREATE TABLE t1 (id INT, id2 INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (id,id2) VALUES (1,1),(1,2),(1,3);
+
+# LOW_PRIORITY has no effect, but is still syntactically correct
+LOCK TABLE t1 LOW_PRIORITY WRITE;
+SELECT id2,COUNT(DISTINCT id) FROM t1 GROUP BY id2;
+
+UPDATE t1 SET id=-1 WHERE id=1;
+
+connection con1;
+# With WRITE lock held by connection 'default',
+# nobody else can access the table
+--error ER_LOCK_WAIT_TIMEOUT
+SELECT id,id2 FROM t1;
+--error ER_LOCK_WAIT_TIMEOUT
+LOCK TABLE t1 READ;
+
+connection default;
+LOCK TABLE t1 READ;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+UPDATE t1 SET id=1 WHERE id=1;
+
+connection con1;
+# With READ lock held by connection 'default',
+# it should be possible to read from the table
+# or acquire another READ lock,
+# but not update it or acquire WRITE lock
+SELECT COUNT(DISTINCT id) FROM t1;
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE t1 SET id=2 WHERE id=2;
+--error ER_LOCK_WAIT_TIMEOUT
+LOCK TABLE t1 WRITE;
+LOCK TABLE t1 READ;
+UNLOCK TABLES;
+
+
+--connection default
+
+--error ER_TABLE_NOT_LOCKED
+CREATE TABLE t2 (a INT, b CHAR(8), PRIMARY KEY(a)) ENGINE=rocksdb;
+
+--disable_parsing
+
+CREATE TEMPORARY TABLE t2 (a INT, b CHAR(8), PRIMARY KEY(a)) ENGINE=rocksdb;
+DROP TABLE IF EXISTS t2;
+
+--enable_parsing
+
+UNLOCK TABLES;
+
+CREATE TABLE t2 (id INT, id2 INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+LOCK TABLE t1 WRITE, t2 WRITE;
+INSERT INTO t2 (id,id2) SELECT id,id2 FROM t1;
+UPDATE t1 SET id=1 WHERE id=-1;
+DROP TABLE t1,t2;
+
+#
+# INSERT ... SELECT with lock tables
+#
+
+CREATE TABLE t1 (i1 INT, nr INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+CREATE TABLE t2 (nr INT, nm INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (nr,nm) VALUES (1,3);
+INSERT INTO t2 (nr,nm) VALUES (2,4);
+
+LOCK TABLES t1 WRITE, t2 READ;
+INSERT INTO t1 (i1,nr) SELECT 1, nr FROM t2 WHERE nm=3;
+INSERT INTO t1 (i1,nr) SELECT 2, nr FROM t2 WHERE nm=4;
+UNLOCK TABLES;
+
+LOCK TABLES t1 WRITE;
+--error ER_TABLE_NOT_LOCKED
+INSERT INTO t1 (i1,nr) SELECT i1, nr FROM t1;
+UNLOCK TABLES;
+LOCK TABLES t1 WRITE, t1 AS t1_alias READ;
+INSERT INTO t1 (i1,nr) SELECT i1, nr FROM t1 AS t1_alias;
+--error ER_TABLE_NOT_LOCKED
+DROP TABLE t1,t2;
+UNLOCK TABLES;
+DROP TABLE t1,t2;
+
+#
+# Check that a dropped table is removed from a lock
+
+CREATE TABLE t1 (a INT, b CHAR(8), PRIMARY KEY(a)) ENGINE=rocksdb;
+CREATE TABLE t2 (a INT, b CHAR(8), PRIMARY KEY(b)) ENGINE=rocksdb;
+CREATE TABLE t3 (a INT, b CHAR(8), pk INT PRIMARY KEY) ENGINE=rocksdb;
+LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE;
+# This removes one table after the other from the lock.
+DROP TABLE t2, t3, t1;
+#
+# Check that a lock merge works
+
+CREATE TABLE t1 (a INT, b CHAR(8), PRIMARY KEY(a)) ENGINE=rocksdb;
+CREATE TABLE t2 (a INT, b CHAR(8), PRIMARY KEY(b)) ENGINE=rocksdb;
+CREATE TABLE t3 (a INT, b CHAR(8), pk INT PRIMARY KEY) ENGINE=rocksdb;
+LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t1 AS t4 READ;
+
+ALTER TABLE t2 ADD COLUMN c2 INT;
+
+DROP TABLE t1, t2, t3;
+
+# FLUSH TABLES is not permitted when there is an active LOCK TABLES .. READ,
+# FLUSH TABLES .. WITH READ LOCK should be used instead
+# (and for other connections the table is locked)
+
+CREATE TABLE t1 (a INT, b CHAR(8), PRIMARY KEY(a)) ENGINE=rocksdb;
+CREATE TABLE t2 (a INT, b CHAR(8), PRIMARY KEY(b)) ENGINE=rocksdb;
+
+LOCK TABLE t1 READ, t2 READ;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+FLUSH TABLE t1;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+FLUSH TABLES;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+FLUSH TABLES t1, t2 WITH READ LOCK;
+UNLOCK TABLES;
+
+FLUSH TABLES t1, t2 WITH READ LOCK;
+
+--connection con1
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+
+--connection default
+UNLOCK TABLES;
+
+# Global lock
+
+FLUSH TABLES WITH READ LOCK;
+
+--connection con1
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+
+--connection default
+UNLOCK TABLES;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+FLUSH TABLES WITH READ LOCK;
+--error ER_CANT_UPDATE_WITH_READLOCK
+DROP TABLE t1, t2;
+UNLOCK TABLES;
+DROP TABLE t1, t2;
+
+--disconnect con1
+
+#
+# Ensure that FLUSH TABLES doesn't substitute a base locked table
+# with a temporary one.
+#
+
+CREATE TABLE t1 (a INT, b CHAR(8), PRIMARY KEY(a)) ENGINE=rocksdb;
+CREATE TABLE t2 (a INT, b CHAR(8), PRIMARY KEY(b)) ENGINE=rocksdb;
+
+LOCK TABLE t1 WRITE, t2 WRITE;
+
+--disable_parsing
+
+CREATE TEMPORARY TABLE t1 (a INT, b CHAR(8), PRIMARY KEY(a)) ENGINE=rocksdb;
+FLUSH TABLE t1;
+DROP TEMPORARY TABLE t1;
+
+--enable_parsing
+
+SELECT a,b FROM t1;
+UNLOCK TABLES;
+DROP TABLE t1, t2;
+
+CREATE TABLE t1 (i INT) ENGINE=MyISAM;
+HANDLER t1 OPEN h;
+CREATE TABLE t2 (i INT) ENGINE=RocksDB;
+LOCK TABLES t2 WRITE;
+
+--connect (con1,localhost,root,,test)
+--connection con1
+--send
+FLUSH TABLES WITH READ LOCK;
+
+--connection default
+INSERT INTO t2 VALUES (1);
+UNLOCK TABLES;
+HANDLER h CLOSE;
+
+--connection con1
+--reap
+--disconnect con1
+
+--connection default
+DROP TABLE t1, t2;
+
+# Check that all connections opened by test cases in this file are really
+# gone so execution of other tests won't be affected by their presence.
+--source include/wait_until_count_sessions.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/lock_info.test b/storage/rocksdb/mysql-test/rocksdb/t/lock_info.test
new file mode 100644
index 00000000..1b624cf3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/lock_info.test
@@ -0,0 +1,31 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+create table t1 (a int, primary key(a) comment 'lock_into_cf1') engine=rocksdb;
+insert into t1 values (1);
+insert into t1 values (2);
+
+create table t2 (a int, primary key(a) comment 'lock_info_cf2') engine=rocksdb;
+insert into t2 values (1);
+insert into t2 values (2);
+
+set autocommit=0;
+select * from t1 for update;
+select * from t2 for update;
+
+use information_schema;
+--replace_column 2 _txn_id_ 3 _key_
+select rocksdb_ddl.cf, rocksdb_locks.transaction_id, rocksdb_locks.key
+from rocksdb_locks
+left join rocksdb_ddl
+on rocksdb_locks.column_family_id=rocksdb_ddl.column_family
+order by rocksdb_ddl.cf;
+
+use test;
+
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/lock_rows_not_exist.test b/storage/rocksdb/mysql-test/rocksdb/t/lock_rows_not_exist.test
new file mode 100644
index 00000000..a51a516a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/lock_rows_not_exist.test
@@ -0,0 +1,110 @@
+--source include/have_rocksdb.inc
+
+--enable_connect_log
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+#1. Using all primary key columns, with equal conditions
+connection con1;
+CREATE TABLE t (id1 int, id2 int, id3 int, value int, PRIMARY KEY (id1, id2, id3)) ENGINE=RocksDB;
+
+#1.1 SELECT FOR UPDATE
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+SELECT * FROM t WHERE id1=1 AND id2=1 AND id3=1 FOR UPDATE;
+
+connection con2;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+BEGIN;
+--error ER_LOCK_WAIT_TIMEOUT
+SELECT * FROM t WHERE id1=1 AND id2=1 AND id3=1 FOR UPDATE;
+SELECT * FROM t WHERE id1=1 AND id2=1 AND id3=2 FOR UPDATE;
+
+#1.2 UPDATE
+connection con1;
+ROLLBACK;
+BEGIN;
+UPDATE t SET value=value+100 WHERE id1=1 AND id2=1 AND id3=1;
+
+connection con2;
+ROLLBACK;
+BEGIN;
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE t SET value=value+100 WHERE id1=1 AND id2=1 AND id3=1;
+UPDATE t SET value=value+100 WHERE id1=1 AND id2=0 AND id3=1;
+
+#1.3 DELETE
+connection con1;
+ROLLBACK;
+BEGIN;
+DELETE FROM t WHERE id1=1 AND id2=1 AND id3=1;
+
+connection con2;
+ROLLBACK;
+BEGIN;
+--error ER_LOCK_WAIT_TIMEOUT
+DELETE FROM t WHERE id1=1 AND id2=1 AND id3=1;
+DELETE FROM t WHERE id1=1 AND id2=1 AND id3=0;
+
+--disable_parsing
+#
+# The following is commented out because RocksDB's Transaction API doesn't
+# "support" READ COMMITTED, in particular, it doesn't release row locks
+# after each statement. (MyRocks is able to request a new snapshot for
+# every statement, but this won't free the locks. TODO: Is the behavior
+# that is tested below really needed?)
+#
+connection con1;
+ROLLBACK;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+SELECT * FROM t WHERE id1=1 AND id2=1 AND id3=1 FOR UPDATE;
+
+connection con2;
+ROLLBACK;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+BEGIN;
+SELECT * FROM t WHERE id1=1 AND id2=1 AND id3=1 FOR UPDATE;
+SELECT * FROM t WHERE id1=1 AND id2=1 AND id3=2 FOR UPDATE;
+
+connection con1;
+ROLLBACK;
+BEGIN;
+UPDATE t SET value=value+100 WHERE id1=1 AND id2=1 AND id3=1;
+
+connection con2;
+ROLLBACK;
+BEGIN;
+UPDATE t SET value=value+100 WHERE id1=1 AND id2=1 AND id3=1;
+UPDATE t SET value=value+100 WHERE id1=1 AND id2=0 AND id3=1;
+
+connection con1;
+ROLLBACK;
+BEGIN;
+DELETE FROM t WHERE id1=1 AND id2=1 AND id3=1;
+
+connection con2;
+ROLLBACK;
+BEGIN;
+DELETE FROM t WHERE id1=1 AND id2=1 AND id3=1;
+DELETE FROM t WHERE id1=1 AND id2=1 AND id3=0;
+
+connection con1;
+ROLLBACK;
+connection con2;
+ROLLBACK;
+
+--enable_parsing
+connection default;
+disconnect con1;
+disconnect con2;
+
+DROP TABLE t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/lock_wait_timeout_stats.test b/storage/rocksdb/mysql-test/rocksdb/t/lock_wait_timeout_stats.test
new file mode 100644
index 00000000..5288680c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/lock_wait_timeout_stats.test
@@ -0,0 +1,38 @@
+create table t (a int primary key) engine=rocksdb;
+
+begin;
+insert into t values (0);
+
+--source include/count_sessions.inc
+--connect (con1,localhost,root,,)
+--connection con1
+set @@rocksdb_lock_wait_timeout=1;
+select ROW_LOCK_WAIT_TIMEOUTS from information_schema.table_statistics where table_name="t";
+begin;
+
+--connect (con2,localhost,root,,)
+--connection con2
+set @@rocksdb_lock_wait_timeout=1;
+begin;
+
+--connection con1
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_row_lock_wait_timeouts';
+--error ER_LOCK_WAIT_TIMEOUT
+insert into t values(0);
+select ROW_LOCK_WAIT_TIMEOUTS from information_schema.table_statistics where table_name="t";
+select ROW_LOCK_WAIT_TIMEOUTS from information_schema.table_statistics where table_name="t";
+select case when variable_value-@a = 1 then 'true' else 'false' end as waits from information_schema.global_status where variable_name='rocksdb_row_lock_wait_timeouts';
+
+--connection con2
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_row_lock_wait_timeouts';
+--error ER_LOCK_WAIT_TIMEOUT
+insert into t values(0);
+select ROW_LOCK_WAIT_TIMEOUTS from information_schema.table_statistics where table_name="t";
+select ROW_LOCK_WAIT_TIMEOUTS from information_schema.table_statistics where table_name="t";
+select case when variable_value-@a = 1 then 'true' else 'false' end as waits from information_schema.global_status where variable_name='rocksdb_row_lock_wait_timeouts';
+
+--disconnect con1
+--connection default
+--disconnect con2
+drop table t;
+--source include/wait_until_count_sessions.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues.test
new file mode 100644
index 00000000..41e2f695
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues.test
@@ -0,0 +1,3 @@
+--source include/have_rocksdb.inc
+
+--echo tests moved to rocksdb.locking_issues_case*
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_1_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_1_rc.test
new file mode 100644
index 00000000..3fd183bf
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_1_rc.test
@@ -0,0 +1,4 @@
+--source include/have_rocksdb.inc
+
+let $isolation_level = READ COMMITTED;
+--source include/locking_issues_case1_1.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_1_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_1_rr.test
new file mode 100644
index 00000000..cd4a0bd3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_1_rr.test
@@ -0,0 +1,4 @@
+--source include/have_rocksdb.inc
+
+let $isolation_level = REPEATABLE READ;
+--source include/locking_issues_case1_1.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_2_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_2_rc.test
new file mode 100644
index 00000000..3fe052a4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_2_rc.test
@@ -0,0 +1,4 @@
+--source include/have_rocksdb.inc
+
+let $isolation_level = READ COMMITTED;
+--source include/locking_issues_case1_2.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_2_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_2_rr.test
new file mode 100644
index 00000000..02263273
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_2_rr.test
@@ -0,0 +1,4 @@
+--source include/have_rocksdb.inc
+
+let $isolation_level = REPEATABLE READ;
+--source include/locking_issues_case1_2.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rc.test
new file mode 100644
index 00000000..d780b524
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rc.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+
+let $lock_scanned_rows=0;
+let $isolation_level = READ COMMITTED;
+--source include/locking_issues_case2.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rc_lsr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rc_lsr.test
new file mode 100644
index 00000000..bd46f93a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rc_lsr.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+
+let $lock_scanned_rows=1;
+let $isolation_level = READ COMMITTED;
+--source include/locking_issues_case2.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rr.test
new file mode 100644
index 00000000..b820fddb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rr.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+
+let $lock_scanned_rows=0;
+let $isolation_level = REPEATABLE READ;
+--source include/locking_issues_case2.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rr_lsr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rr_lsr.test
new file mode 100644
index 00000000..33d3b752
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rr_lsr.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+
+let $lock_scanned_rows=1;
+let $isolation_level = REPEATABLE READ;
+--source include/locking_issues_case2.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case3_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case3_rc.test
new file mode 100644
index 00000000..7dc7f878
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case3_rc.test
@@ -0,0 +1,4 @@
+--source include/have_rocksdb.inc
+
+let $isolation_level = READ COMMITTED;
+--source include/locking_issues_case3.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case3_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case3_rr.test
new file mode 100644
index 00000000..7c81dacc
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case3_rr.test
@@ -0,0 +1,4 @@
+--source include/have_rocksdb.inc
+
+let $isolation_level = REPEATABLE READ;
+--source include/locking_issues_case3.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case4_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case4_rc.test
new file mode 100644
index 00000000..edc1111b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case4_rc.test
@@ -0,0 +1,4 @@
+--source include/have_rocksdb.inc
+
+let $isolation_level = READ COMMITTED;
+--source include/locking_issues_case4.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case4_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case4_rr.test
new file mode 100644
index 00000000..8c26c2d1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case4_rr.test
@@ -0,0 +1,4 @@
+--source include/have_rocksdb.inc
+
+let $isolation_level = REPEATABLE READ;
+--source include/locking_issues_case4.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case5_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case5_rc.test
new file mode 100644
index 00000000..10bedcf2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case5_rc.test
@@ -0,0 +1,4 @@
+--source include/have_rocksdb.inc
+
+let $isolation_level = READ COMMITTED;
+--source include/locking_issues_case5.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case5_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case5_rr.test
new file mode 100644
index 00000000..6de3847c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case5_rr.test
@@ -0,0 +1,4 @@
+--source include/have_rocksdb.inc
+
+let $isolation_level = REPEATABLE READ;
+--source include/locking_issues_case5.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case6_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case6_rc.test
new file mode 100644
index 00000000..9409bde0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case6_rc.test
@@ -0,0 +1,4 @@
+--source include/have_rocksdb.inc
+
+let $isolation_level = READ COMMITTED;
+--source include/locking_issues_case6.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case6_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case6_rr.test
new file mode 100644
index 00000000..0c7a8a11
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case6_rr.test
@@ -0,0 +1,4 @@
+--source include/have_rocksdb.inc
+
+let $isolation_level = REPEATABLE READ;
+--source include/locking_issues_case6.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rc.test
new file mode 100644
index 00000000..f8e874a1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rc.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+
+let $lock_scanned_rows=0;
+let $isolation_level = READ COMMITTED;
+--source include/locking_issues_case7.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rc_lsr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rc_lsr.test
new file mode 100644
index 00000000..0f97ca2f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rc_lsr.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+
+let $lock_scanned_rows=1;
+let $isolation_level = READ COMMITTED;
+--source include/locking_issues_case7.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rr.test
new file mode 100644
index 00000000..c8cec956
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rr.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+
+let $lock_scanned_rows=0;
+let $isolation_level = REPEATABLE READ;
+--source include/locking_issues_case7.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rr_lsr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rr_lsr.test
new file mode 100644
index 00000000..875e81a1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rr_lsr.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+
+let $lock_scanned_rows=1;
+let $isolation_level = REPEATABLE READ;
+--source include/locking_issues_case7.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_ignore_dirs.test b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_ignore_dirs.test
new file mode 100644
index 00000000..49591dd6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_ignore_dirs.test
@@ -0,0 +1,17 @@
+--source include/have_rocksdb.inc
+
+
+--echo #
+--echo # RocksDB plugin adds #rocksdb to ignore_db_dirs
+--echo #
+
+select @@ignore_db_dirs;
+
+--let $_mysqld_option=--ignore-db-dirs=aa --ignore-db-dirs=bbb
+--source include/restart_mysqld_with_option.inc
+
+select @@ignore_db_dirs;
+
+--let $_mysqld_option=--ignore-db-dirs=#rocksdb
+--source include/restart_mysqld_with_option.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_misc_binlog-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_misc_binlog-master.opt
new file mode 100644
index 00000000..beae84b3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_misc_binlog-master.opt
@@ -0,0 +1 @@
+--log-bin
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_misc_binlog.test b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_misc_binlog.test
new file mode 100644
index 00000000..e32679e8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_misc_binlog.test
@@ -0,0 +1,40 @@
+--source include/have_rocksdb.inc
+
+create table t1 (a int) engine=rocksdb;
+
+--echo # Should have binlog ON
+select @@log_bin;
+
+set binlog_format='row';
+
+--echo # Should succeed
+optimize table t1;
+
+--echo #
+--echo # MDEV-13602: rocksdb.index_merge_rocksdb2 failed in buildbot
+--echo #
+
+lock tables t1 write;
+insert into t1 values(1);
+unlock tables;
+
+set @tmp_bf= @@binlog_format;
+set binlog_format='STATEMENT';
+lock tables t1 write;
+--error ER_BINLOG_STMT_MODE_AND_ROW_ENGINE
+insert into t1 values(1);
+unlock tables;
+set @@binlog_format=@tmp_bf;
+
+drop table t1;
+
+--echo #
+--echo # MDEV-17045: MyRocks tables cannot be updated when binlog_format=MIXED.
+--echo #
+set @tmp_bf= @@binlog_format;
+set binlog_format='MIXED';
+create table t1 (pk int primary key) engine=rocksdb;
+insert into t1 values (1);
+drop table t1;
+set @@binlog_format=@tmp_bf;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_plugin-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_plugin-master.opt
new file mode 100644
index 00000000..0f0a3ef3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_plugin-master.opt
@@ -0,0 +1 @@
+--default-storage-engine=myisam --plugin-load='' --ignore-db-dirs=#rocksdb
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_plugin.test b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_plugin.test
new file mode 100644
index 00000000..0cf56c0c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_plugin.test
@@ -0,0 +1,59 @@
+--source include/have_log_bin.inc
+--source include/have_binlog_format_row.inc
+--source include/not_windows.inc
+
+--echo #
+--echo # MDEV-14843: Assertion `s_tx_list.size() == 0' failed in myrocks::Rdb_transaction::term_mutex
+--echo #
+
+#
+# On Linux, wsrep plugin is always loaded so XA is enabled at this point.
+# On Windows, there is no wsrep, so we get this warning:
+# Warning 1105 Cannot enable tc-log at run-time. XA features of ROCKSDB are disabled
+#
+--disable_warnings
+INSTALL SONAME 'ha_rocksdb';
+--enable_warnings
+
+connect (con1,localhost,root,,test);
+CREATE TABLE t1 (i INT) ENGINE=RocksDB;
+insert into t1 values (1);
+DROP TABLE t1;
+
+connection default;
+# Cleanup
+UNINSTALL SONAME 'ha_rocksdb';
+SELECT ENGINE, SUPPORT FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE='ROCKSDB';
+disconnect con1;
+# Unfortunately this is the only more or less reliable way to wait until
+# connection done ha_close_connections(). It doesn't work on Windows due
+# to different thread handling.
+let $wait_condition= SELECT VARIABLE_VALUE=1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='Threads_cached';
+--source include/wait_condition.inc
+
+--echo #
+--echo # MDEV-15686: Loading MyRocks plugin back after it has been unloaded causes a crash
+--echo #
+call mtr.add_suppression("Plugin 'ROCKSDB.*' init function returned error.");
+call mtr.add_suppression("Plugin 'ROCKSDB.*' registration as a INFORMATION SCHEMA failed.");
+call mtr.add_suppression("Plugin 'ROCKSDB' registration as a STORAGE ENGINE failed");
+
+--echo #
+--echo # There are two possible scenarios:
+
+--echo # ha_rocksdb.{dll,so} is still loaded into mysqld's address space. Its
+--echo # global variables are in the state that doesn't allow it to be
+--echo # initialized back (this is what MDEV-15686 is about). This is handled
+--echo # by intentionally returning an error from rocksdb_init_func.
+--echo #
+--echo # The second case is when ha_rocksdb.{ddl,so} has been fully unloaded
+--echo # and so it will be now loaded as if it happens for the first time.
+
+--error 0,ER_INTERNAL_ERROR
+INSTALL SONAME 'ha_rocksdb';
+
+--echo # Whatever happened on the previous step, restore things to the way they
+--echo # were at testcase start.
+--error 0,ER_SP_DOES_NOT_EXIST
+UNINSTALL SONAME 'ha_rocksdb';
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test
new file mode 100644
index 00000000..99d4e2d1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test
@@ -0,0 +1,114 @@
+--source include/have_rocksdb.inc
+
+--echo #
+--echo # MDEV-14433: RocksDB may show empty or incorrect output with rocksdb_strict_collation_check=off
+--echo #
+set global rocksdb_strict_collation_check=off;
+set @tmp_rscc=@@rocksdb_strict_collation_check;
+
+CREATE TABLE t1(
+ a varchar(10) NOT NULL,
+ b char(1) DEFAULT 'X',
+ c char(2) NOT NULL DEFAULT '??',
+ d varchar(10) NOT NULL,
+ e int(11) DEFAULT 0,
+ PRIMARY KEY (a,d),
+ KEY (e)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8;
+
+insert into t1 select 1,1,1,1,0;
+insert into t1 select 2,1,1,1,0;
+insert into t1 select 3,1,1,1,0;
+
+--replace_column 9 #
+explain
+select a from t1 force index(e) where e<10000;
+select a from t1;
+select * from t1;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-14563: Wrong query plan for query with no PK
+--echo #
+
+CREATE TABLE t1(
+ pk int primary key,
+ a varchar(10) NOT NULL,
+ e int(11) DEFAULT 0,
+ KEY (a)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8;
+insert into t1 values (1,1,1),(2,2,2);
+--replace_column 9 #
+explain select a from t1 where a <'zzz';
+
+CREATE TABLE t2(
+ pk int,
+ a varchar(10) NOT NULL,
+ e int(11) DEFAULT 0,
+ KEY (a)
+) ENGINE=ROCKSDB DEFAULT CHARSET=utf8;
+insert into t2 values (1,1,1),(2,2,2);
+--replace_column 9 #
+explain select a from t2 where a <'zzz';
+
+drop table t1,t2;
+
+set global rocksdb_strict_collation_check=@tmp_rscc;
+
+--echo #
+--echo # MDEV-14389: MyRocks and NOPAD collations
+--echo #
+
+--error ER_MYROCKS_CANT_NOPAD_COLLATION
+create table t1 (pk varchar(10) collate latin1_nopad_bin, primary key(pk)) engine=rocksdb;
+
+set global rocksdb_strict_collation_check=off;
+--error ER_MYROCKS_CANT_NOPAD_COLLATION
+create table t1 (pk varchar(10) collate latin1_nopad_bin, primary key(pk)) engine=rocksdb;
+
+set global rocksdb_strict_collation_check=@tmp_rscc;
+
+--echo #
+--echo # MDEV-14679: RocksdB plugin fails to load with "Loading of unknown plugin ROCKSDB_CFSTATS
+--echo #
+select plugin_name, plugin_maturity from information_schema.plugins where plugin_name like '%rocksdb%';
+
+
+--echo #
+--echo # MDEV-12466 : Assertion `thd->transaction.stmt.is_empty() || thd->in_sub_stmt || ...
+--echo #
+
+CREATE TABLE t1 (i INT) ENGINE=RocksDB;
+--error ER_ILLEGAL_HA
+FLUSH TABLE t1 FOR EXPORT;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-16154 Server crashes in in myrocks::ha_rocksdb::load_auto_incr_value_from_inde
+--echo #
+CREATE TABLE t1 (a INT) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1);
+ALTER TABLE t1 AUTO_INCREMENT 10;
+
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-16155: UPDATE on RocksDB table with unique constraint does not work
+--echo #
+CREATE TABLE t1 (a INT, b CHAR(8), UNIQUE INDEX(a)) ENGINE=RocksDB;
+INSERT INTO t1 (a,b) VALUES (1,'foo'),(2,'bar');
+UPDATE t1 SET a=a+100;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # MDEV-15319: [SQL Layer] Server crashes in Field::set_null / myrocks::ha_rocksdb::convert_record_from_storage_format
+--echo # (just a testcase)
+--echo #
+
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 ENGINE=RocksDB AS SELECT VALUE(i) AS a FROM t1;
+DELETE FROM t2;
+DROP TABLE t1,t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_rpl.test b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_rpl.test
new file mode 100644
index 00000000..ed9eb029
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_rpl.test
@@ -0,0 +1,14 @@
+--source include/have_rocksdb.inc
+--source include/have_binlog_format_row.inc
+
+--echo #
+--echo # MDEV-15472: Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failure ...
+--echo #
+select @@log_bin;
+select @@binlog_format;
+CREATE OR REPLACE TABLE t1 (i INT) ENGINE=RocksDB;
+LOCK TABLE t1 WRITE;
+FLUSH TABLES;
+UNLOCK TABLES;
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/max_open_files.test b/storage/rocksdb/mysql-test/rocksdb/t/max_open_files.test
new file mode 100644
index 00000000..c7c5e7b2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/max_open_files.test
@@ -0,0 +1,53 @@
+--source include/have_rocksdb.inc
+
+# Basic Sysbench run fails with basic MyROCKS install due to lack of open files
+
+# test for over limit
+CALL mtr.add_suppression("RocksDB: rocksdb_max_open_files should not be greater than the open_files_limit*");
+
+--let $over_rocksdb_max_open_files=`SELECT @@global.open_files_limit + 100`
+--let $under_rocksdb_max_open_files=`SELECT @@global.open_files_limit -1`
+--let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/rocksdb.max_open_files.err
+--let SEARCH_PATTERN=RocksDB: rocksdb_max_open_files should not be greater than the open_files_limit
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR $over_rocksdb_max_open_files over_rocksdb_max_open_files
+--let $_mysqld_option=--log-error=$SEARCH_FILE --rocksdb_max_open_files=$over_rocksdb_max_open_files
+--source include/restart_mysqld_with_option.inc
+--source include/search_pattern_in_file.inc
+
+SELECT FLOOR(@@global.open_files_limit / 2) = @@global.rocksdb_max_open_files;
+
+# test for within limit
+--let $_mysqld_option=--rocksdb_max_open_files=$under_rocksdb_max_open_files
+--source include/restart_mysqld_with_option.inc
+
+SELECT @@global.open_files_limit - 1 = @@global.rocksdb_max_open_files;
+
+# test for minimal value
+--let $_mysqld_option=--rocksdb_max_open_files=0
+--source include/restart_mysqld_with_option.inc
+
+SELECT @@global.rocksdb_max_open_files;
+
+# verify that we can still do work with no descriptor cache
+CREATE TABLE t1(a INT) ENGINE=ROCKSDB;
+INSERT INTO t1 VALUES(0),(1),(2),(3),(4);
+SET GLOBAL rocksdb_force_flush_memtable_and_lzero_now=1;
+DROP TABLE t1;
+
+# test for unlimited
+--let $_mysqld_option=--rocksdb_max_open_files=-1
+--source include/restart_mysqld_with_option.inc
+
+SELECT @@global.rocksdb_max_open_files;
+
+# test for auto-tune
+--let $_mysqld_option=--rocksdb_max_open_files=-2
+--source include/restart_mysqld_with_option.inc
+
+SELECT FLOOR(@@global.open_files_limit / 2) = @@global.rocksdb_max_open_files;
+
+# cleanup
+--let _$mysqld_option=
+--source include/restart_mysqld.inc
+--remove_file $SEARCH_FILE
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/misc.test b/storage/rocksdb/mysql-test/rocksdb/t/misc.test
new file mode 100644
index 00000000..b8efd038
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/misc.test
@@ -0,0 +1,45 @@
+--source include/have_rocksdb.inc
+
+#
+# Different statements not related to an engine,
+# but added to provide function coverage for handler.cc and handler.h.
+# The test can be disabled or removed later.
+#
+
+# hits get_error_message(int, String*)
+
+INSERT INTO mysql.event (
+ db,
+ name,
+ body,
+ definer,
+ interval_value,
+ interval_field,
+ originator,
+ character_set_client,
+ collation_connection,
+ db_collation,
+ body_utf8)
+values (
+ database(),
+ "ev1",
+ "select 1",
+ user(),
+ 100,
+ "SECOND_MICROSECOND",
+ 1,
+ 'utf8',
+ 'utf8_general_ci',
+ 'utf8_general_ci',
+ 'select 1');
+
+--error ER_NOT_SUPPORTED_YET
+SHOW EVENTS;
+DROP EVENT ev1;
+
+# hits get_foreign_key_list(THD*, List<st_foreign_key_info>*)
+--sorted_result
+SELECT TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
+FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE ORDER BY TABLE_NAME;
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/multi_varchar_sk_lookup.test b/storage/rocksdb/mysql-test/rocksdb/t/multi_varchar_sk_lookup.test
new file mode 100644
index 00000000..cb65cf91
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/multi_varchar_sk_lookup.test
@@ -0,0 +1,49 @@
+# Disable until covered unpack_info format enabled in prod
+--source include/have_debug.inc
+--source include/not_debug.inc
+
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS T1;
+--enable_warnings
+
+CREATE TABLE T1 (
+ P1 VARCHAR(64), P2 VARCHAR(64), P3 VARCHAR(64), P4 VARCHAR(64),
+ S1 VARCHAR(64), S2 VARCHAR(64), S3 VARCHAR(64), S4 VARCHAR(64),
+ S5 VARCHAR(64), S6 VARCHAR(64), S7 VARCHAR(64), S8 VARCHAR(64),
+ S9 VARCHAR(64), S10 VARCHAR(64), S11 VARCHAR(64), S12 VARCHAR(64),
+ S13 VARCHAR(64), S14 VARCHAR(64), S15 VARCHAR(64), S16 VARCHAR(64),
+ PRIMARY KEY (P1(8), P2(8), P3(8), P4(8)),
+ KEY SK (S1(8), S2(8), S3(8), S4(8),
+ S5(8), S6(8), S7(8), S8(8),
+ S9(8), S10(8), S11(8), S12(8),
+ S13(8), S14(8), S15(8), S16(8))
+) ENGINE=rocksdb;
+
+INSERT INTO T1 VALUES ('1', '2', '3', '4',
+ '5', '6', '7', '8',
+ '9', '10', '11', '12',
+ '13', '14', '15', '16',
+ '17', '18', '19', '20');
+
+SELECT * FROM T1;
+
+--let $prefix_index_check_title= Not eligible for optimization, shorter than prefix length.
+--let $prefix_index_check_read_avoided_delta= 0
+--let $prefix_index_check_query= SELECT P4, S2 FROM T1 FORCE INDEX(SK) WHERE S1='5'
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+DELETE FROM T1;
+INSERT INTO T1 VALUES ('100000000', '200000000', '300000000', '400000000',
+ '500000000', '600000000', '700000000', '800000000',
+ '900000000', '100000000', '110000000', '120000000',
+ '130000000', '140000000', '150000000', '160000000',
+ '170000000', '180000000', '190000000', '200000000');
+
+--let $prefix_index_check_title= Not eligible for optimization, longer than prefix length.
+--let $prefix_index_check_read_avoided_delta= 0
+--let $prefix_index_check_query= SELECT P4, S2 FROM T1 FORCE INDEX(SK) WHERE S1='5'
+--source suite/rocksdb/include/prefix_index_only_query_check.inc
+
+DROP TABLE T1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mysqlbinlog_blind_replace.test b/storage/rocksdb/mysql-test/rocksdb/t/mysqlbinlog_blind_replace.test
new file mode 100644
index 00000000..2b033023
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mysqlbinlog_blind_replace.test
@@ -0,0 +1,62 @@
+#
+# This test is intended to check that when blind replace is enabled,
+# mysqlbinlog is able to pass this information in the captured binlog
+# events and we are able to reapply such events
+#
+
+--source include/have_log_bin.inc
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+
+reset master;
+set GLOBAL binlog_format= 'ROW';
+SET GLOBAL enable_blind_replace=ON;
+set binlog_format=row;
+
+create table t5 (c1 int primary key, c2 int);
+insert into t5 values (1, 1);
+insert into t5 values (2, 2);
+insert into t5 values (3, 3);
+select * from t5;
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t5 values (1, 11);
+replace into t5 values (2, 22);
+replace into t5 values (3, 33);
+
+# Ensure that this was a blind replace
+select case when variable_value-@c = 3 then 'true' else 'false' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+select * from t5;
+--source include/show_binlog_events.inc
+
+flush logs;
+
+# Capture binlog events using mysqlbinlog
+let $MYSQLD_DATADIR= `select @@datadir`;
+--let $log_file_name = query_get_value("SHOW BINARY LOGS", Log_name, 1)
+--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$log_file_name > $MYSQLTEST_VARDIR/tmp/mysqlbinlog-output
+
+# Drop the table. This will be recreated when we reapply binlog events
+drop table t5;
+reset master;
+
+# Now replay the binlog events
+--echo Replaying binlog events containing blind replace statements should work
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/mysqlbinlog-output
+select * from t5;
+--source include/show_binlog_events.inc
+
+drop table t5;
+reset master;
+
+# Replay the same binlog events again, but with blind_replace turned off
+--echo Replaying the same binlog events with blind replace disabled should work
+--echo The server should internally convert such events into updates
+SET GLOBAL enable_blind_replace=OFF;
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/mysqlbinlog-output
+select * from t5;
+
+--source include/show_binlog_events.inc
+
+set GLOBAL binlog_format=DEFAULT;
+SET GLOBAL enable_blind_replace=DEFAULT;
+drop table t5;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mysqlbinlog_gtid_skip_empty_trans_rocksdb-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/mysqlbinlog_gtid_skip_empty_trans_rocksdb-master.opt
new file mode 100644
index 00000000..53303252
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mysqlbinlog_gtid_skip_empty_trans_rocksdb-master.opt
@@ -0,0 +1 @@
+--binlog_format=row --gtid_mode=ON --enforce_gtid_consistency --log_bin --log_slave_updates
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mysqlbinlog_gtid_skip_empty_trans_rocksdb.test b/storage/rocksdb/mysql-test/rocksdb/t/mysqlbinlog_gtid_skip_empty_trans_rocksdb.test
new file mode 100644
index 00000000..0c04b604
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mysqlbinlog_gtid_skip_empty_trans_rocksdb.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+################################################################################
+# Test the --skip-empty-trans option for mysqlbinlog with rocksdb
+################################################################################
+--disable_warnings
+--source include/have_gtid.inc
+--enable_warnings
+
+reset master;
+set timestamp=1000000000;
+let $storage_engine=rocksdb;
+
+# Test row based replication
+set SESSION binlog_format = 'ROW';
+--source include/mysqlbinlog_gtid_skip_empty_trans_input.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mysqldump-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/mysqldump-master.opt
new file mode 100644
index 00000000..2672d4ff
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mysqldump-master.opt
@@ -0,0 +1 @@
+--binlog_format=row
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mysqldump.test b/storage/rocksdb/mysql-test/rocksdb/t/mysqldump.test
new file mode 100644
index 00000000..473bebdd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mysqldump.test
@@ -0,0 +1,67 @@
+--source include/have_rocksdb.inc
+--source include/have_log_bin.inc
+--source include/restart_mysqld.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+create table r1 (id1 int, id2 int, id3 varchar(100), id4 int, value1 int, value2 int, value3 int, value4 int, primary key (id1, id2, id3, id4), KEY (value1, value2, value3)) engine=rocksdb;
+insert into r1 values (1,1,1,1,1,1,1,1);
+insert into r1 values (1,1,1,2,2,2,2,2);
+insert into r1 values (1,1,2,1,3,3,3,3);
+insert into r1 values (1,1,2,2,4,4,4,4);
+insert into r1 values (1,2,1,1,5,5,5,5);
+insert into r1 values (1,2,1,2,6,6,6,6);
+insert into r1 values (1,2,2,1,7,7,7,7);
+insert into r1 values (1,2,2,2,8,8,8,8);
+insert into r1 values (2,1,1,1,9,9,9,9);
+insert into r1 values (2,1,1,2,10,10,10,10);
+insert into r1 values (2,1,2,1,11,11,11,11);
+insert into r1 values (2,1,2,2,12,12,12,12);
+insert into r1 values (2,2,1,1,13,13,13,13);
+insert into r1 values (2,2,1,2,14,14,14,14);
+insert into r1 values (2,2,2,1,15,15,15,15);
+insert into r1 values (2,2,2,2,16,16,16,16);
+
+connection con2;
+BEGIN;
+insert into r1 values (5,5,5,5,5,5,5,5);
+update r1 set value1=value1+100 where id1=1 and id2=1 and id3='1';
+
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec ASAN_OPTIONS="detect_leaks=0" $MYSQL_DUMP --skip-comments --single-transaction --master-data=2 --print-ordering-key --rocksdb --order-by-primary-desc --rocksdb_bulk_load test
+
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec ASAN_OPTIONS="detect_leaks=0" $MYSQL_DUMP --skip-comments --single-transaction --master-data=2 --print-ordering-key --rocksdb --order-by-primary-desc --rocksdb_bulk_load --rocksdb_bulk_load_allow_sk test
+
+rollback;
+
+connection con1;
+
+let SEARCH_FILE=$MYSQLTEST_VARDIR/mysqld.1/mysqld.log;
+let SEARCH_PATTERN=START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+source include/search_pattern_in_file.inc;
+
+set @save_default_storage_engine=@@global.default_storage_engine;
+SET GLOBAL default_storage_engine=rocksdb;
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec ASAN_OPTIONS="detect_leaks=0" $MYSQL_DUMP --skip-comments --single-transaction --master-data=2 --print-ordering-key test
+source include/search_pattern_in_file.inc;
+
+# Sanity test mysqldump when the --innodb-stats-on-metadata is specified (no effect)
+--echo ==== mysqldump with --innodb-stats-on-metadata ====
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec ASAN_OPTIONS="detect_leaks=0" $MYSQL_DUMP --skip-comments --single-transaction --master-data=2 --print-ordering-key --innodb-stats-on-metadata test
+
+# testing mysqldump work with statement based binary logging
+SET GLOBAL binlog_format=statement;
+--exec ASAN_OPTIONS="detect_leaks=0" $MYSQL_DUMP --skip-comments --single-transaction --master-data=2 --print-ordering-key test > /dev/null
+SET GLOBAL binlog_format=row;
+
+drop table r1;
+reset master;
+set @@global.default_storage_engine=@save_default_storage_engine;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mysqldump2-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/mysqldump2-master.opt
new file mode 100644
index 00000000..2672d4ff
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mysqldump2-master.opt
@@ -0,0 +1 @@
+--binlog_format=row
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mysqldump2.test b/storage/rocksdb/mysql-test/rocksdb/t/mysqldump2.test
new file mode 100644
index 00000000..4f4f5ed0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mysqldump2.test
@@ -0,0 +1,43 @@
+--source include/have_rocksdb.inc
+
+--source include/have_log_bin.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+create table t1 (id int primary key, value int, value2 varchar(200), index(value)) engine=rocksdb;
+
+--disable_query_log
+let $i = 1;
+while ($i <= 50000) {
+ let $insert = INSERT INTO t1 VALUES($i, $i, REPEAT('x', 150));
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+optimize table t1;
+
+#wiping block cache
+let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
+--exec echo "wait" > $restart_file
+--shutdown_server
+--source include/wait_until_disconnected.inc
+-- exec echo "restart:--rocksdb_default_cf_options=write_buffer_size=64k;target_file_size_base=64k;max_bytes_for_level_base=1m;compression_per_level=kNoCompression;disable_auto_compactions=true;level0_stop_writes_trigger=1000 " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- enable_reconnect
+-- source include/wait_until_connected_again.inc
+
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_block_cache_add';
+
+--exec ASAN_OPTIONS="detect_leaks=0" $MYSQL_DUMP --skip-comments --single-transaction --master-data=2 --print-ordering-key --rocksdb test > /dev/null
+
+# verifying block cache was not filled
+select case when variable_value - @a > 20 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_block_cache_add';
+
+select count(*) from t1;
+
+# verifying block cache was filled
+select case when variable_value - @a > 100 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_block_cache_add';
+
+#cleanup
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/native_procedure-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/native_procedure-master.opt
new file mode 100644
index 00000000..6c4cea3d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/native_procedure-master.opt
@@ -0,0 +1 @@
+$NP_EXAMPLE_LIB_OPT
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/native_procedure.test b/storage/rocksdb/mysql-test/rocksdb/t/native_procedure.test
new file mode 100644
index 00000000..d4f38a60
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/native_procedure.test
@@ -0,0 +1,2 @@
+let $engine=rocksdb;
+--source include/native_procedure.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/negative_stats.test b/storage/rocksdb/mysql-test/rocksdb/t/negative_stats.test
new file mode 100644
index 00000000..9de41d17
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/negative_stats.test
@@ -0,0 +1,26 @@
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (i1 INT, PRIMARY KEY (i1)) ENGINE = ROCKSDB;
+
+--disable_query_log
+let $max = 10000;
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO t1 VALUES ($i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+SET GLOBAL ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW=1;
+
+set session debug_dbug= "+d,myrocks_simulate_negative_stats";
+SELECT CASE WHEN DATA_LENGTH < 1024 * 1024 THEN 'true' ELSE 'false' END FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
+set session debug_dbug= "-d,myrocks_simulate_negative_stats";
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/no_merge_sort.test b/storage/rocksdb/mysql-test/rocksdb/t/no_merge_sort.test
new file mode 100644
index 00000000..ccef7182
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/no_merge_sort.test
@@ -0,0 +1,32 @@
+--source include/have_rocksdb.inc
+
+# For Issue#117 MyRocks does merge sort with small data sets
+
+let $datadir = `SELECT @@datadir`;
+
+--disable_query_log
+let $i= 0;
+while ($i < 30) {
+ DROP TABLE IF EXISTS ti_nk;
+
+ CREATE TABLE `ti_nk` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` varchar(36) COLLATE latin1_bin NOT NULL,
+ PRIMARY KEY (`c`)
+ );
+ let $j = 0;
+ while ($j < 200) {
+ eval insert into ti_nk values ($j, $j, md5($j));
+ inc $j;
+ }
+
+ select variable_value into @s from information_schema.global_status where variable_name='Sort_merge_passes';
+ eval SELECT a, b, c FROM ti_nk ORDER BY a,b,c INTO OUTFILE '$datadir/select.out';
+ --remove_file $datadir/select.out
+ select case when variable_value-@s = 0 then 'true' else 'false' end as skip_merge_sort from information_schema.global_status where variable_name='Sort_merge_passes';
+ inc $i;
+}
+--enable_query_log
+
+DROP TABLE ti_nk;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/no_primary_key_basic_ops.inc b/storage/rocksdb/mysql-test/rocksdb/t/no_primary_key_basic_ops.inc
new file mode 100644
index 00000000..0dcd4521
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/no_primary_key_basic_ops.inc
@@ -0,0 +1,65 @@
+#
+# This include file checks some very basic capabilities for restart insert
+# update and delete for tables with no pk
+# NOTE: requires table with structure similar to
+# CREATE TABLE t1 (a INT, b CHAR(8)) ENGINE=rocksdb;
+#
+
+SHOW CREATE TABLE t1;
+SHOW COLUMNS IN t1;
+
+### test INSERT
+INSERT INTO t1 (a,b) VALUES (76,'bar');
+INSERT INTO t1 (a,b) VALUES (35,'foo');
+INSERT INTO t1 (a,b) VALUES (77,'baz');
+
+## test SELECT w/ index scans
+--sorted_result
+SELECT * FROM t1 WHERE a = 35;
+--sorted_result
+SELECT * FROM t1 WHERE a = 35 AND b = 'foo';
+--sorted_result
+SELECT * FROM t1 WHERE a = 77 OR b = 'bar';
+--sorted_result
+SELECT * FROM t1 WHERE a > 35;
+--sorted_result
+SELECT * FROM t1;
+
+# test UPDATE
+UPDATE t1 SET a=a+100;
+--sorted_result
+SELECT * FROM t1;
+
+UPDATE t1 SET a=a-100, b='bbb' WHERE a>100;
+--sorted_result
+SELECT * FROM t1;
+UPDATE t1 SET a=300, b='ccc' WHERE a>70;
+--sorted_result
+SELECT * FROM t1;
+UPDATE t1 SET a=123 WHERE a=35;
+--sorted_result
+SELECT * FROM t1;
+UPDATE t1 SET a=321 WHERE b='ccc';
+--sorted_result
+SELECT * FROM t1;
+
+
+## test RESTART/OPEN
+--source include/restart_mysqld.inc
+## test insert after restart
+INSERT INTO t1 (a,b) VALUES (45,'bob');
+--sorted_result
+SELECT * FROM t1;
+
+# test DELETE
+DELETE FROM t1 WHERE a=123;
+--sorted_result
+SELECT * FROM t1;
+
+DELETE FROM t1 WHERE b > 'bbb' AND a > 100;
+--sorted_result
+SELECT * FROM t1;
+
+# test TRUNCATE
+TRUNCATE TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/optimize_myrocks_replace_into_base.test b/storage/rocksdb/mysql-test/rocksdb/t/optimize_myrocks_replace_into_base.test
new file mode 100644
index 00000000..b37f532a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/optimize_myrocks_replace_into_base.test
@@ -0,0 +1,96 @@
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+
+SET @prior_rocksdb_perf_context_level = @@rocksdb_perf_context_level;
+SET GLOBAL rocksdb_perf_context_level=3;
+SET GLOBAL enable_blind_replace=ON;
+
+#
+# case 1: table only with primary key, support replace blind write
+#
+create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(1,11);
+select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+drop table t1;
+
+#
+# case 2: table only with primary key but with trigger, not support replace blind write
+#
+create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
+create trigger trg before insert on t1 for each row set @a:=1;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(1,11);
+select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+drop table t1;
+
+
+#
+# case 3: table without primary key, not support replace blind write
+#
+
+create table t1(c1 int,c2 int) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(1,11);
+select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+drop table t1;
+
+
+create table t1(c1 int,c2 int unique) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(1,11);
+select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+drop table t1;
+
+
+
+#
+# case 4: table with primary key and secondary key, not support replace blind write
+#
+create table t1(c1 int primary key,c2 int unique) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(1,11);
+select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+drop table t1;
+
+
+create table t1(c1 int primary key,c2 int, key idx1(c2)) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(1,11);
+select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+drop table t1;
+
+
+
+#
+# case 5: Disabling blind replace through enable_blind_replace should work
+SET GLOBAL enable_blind_replace=OFF;
+create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(1,11);
+select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+drop table t1;
+
+SET GLOBAL enable_blind_replace=DEFAULT;
+SET GLOBAL rocksdb_perf_context_level = @prior_rocksdb_perf_context_level;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/optimize_myrocks_replace_into_lock.test b/storage/rocksdb/mysql-test/rocksdb/t/optimize_myrocks_replace_into_lock.test
new file mode 100644
index 00000000..6cce429a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/optimize_myrocks_replace_into_lock.test
@@ -0,0 +1,88 @@
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+
+# Enable blind replace
+SET GLOBAL enable_blind_replace=ON;
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+
+#
+# case 1: update is blocked by replace into
+#
+connection con1;
+SELECT @@global.enable_blind_replace;
+begin;
+replace into t1 values(1,11);
+
+
+connection con2;
+SELECT @@global.enable_blind_replace;
+begin;
+send update t1 set c2=22 where c1=1;
+
+
+connection default;
+# Check that the above update is blocked
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = 'Waiting for row lock' and
+ info = 'update t1 set c2=22 where c1=1';
+--source include/wait_condition.inc
+
+
+connection con1;
+commit;
+
+connection con2;
+--echo # Reap update.
+--reap
+commit;
+select * from t1;
+
+
+#
+# cast 2: replace into is blocked by update
+#
+
+connection con1;
+SELECT @@global.enable_blind_replace;
+begin;
+update t1 set c2=55 where c1=1;
+
+connection con2;
+SELECT @@global.enable_blind_replace;
+begin;
+send replace into t1 values(1,66);
+
+
+connection default;
+# Check that the above replace into is blocked
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = 'Waiting for row lock' and
+ info = 'replace into t1 values(1,66)';
+--source include/wait_condition.inc
+
+
+connection con1;
+commit;
+
+connection con2;
+--echo # Reap replace into.
+--reap
+commit;
+select * from t1;
+
+connection default;
+drop table t1;
+
+disconnect con1;
+disconnect con2;
+
+# Disable blind replace
+SET GLOBAL enable_blind_replace=DEFAULT;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/optimize_table-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/optimize_table-master.opt
new file mode 100644
index 00000000..71f74ee5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/optimize_table-master.opt
@@ -0,0 +1 @@
+--rocksdb_default_cf_options=write_buffer_size=64k;target_file_size_base=64k;max_bytes_for_level_base=1m;compression_per_level=kNoCompression
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/optimize_table.inc b/storage/rocksdb/mysql-test/rocksdb/t/optimize_table.inc
new file mode 100644
index 00000000..5f66937c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/optimize_table.inc
@@ -0,0 +1,20 @@
+# run a check script to verify sst files reduced enough during each optimize table
+perl;
+
+$size += -s $_ for (<$ENV{datadir}/#rocksdb/*.sst>);
+$file= "$ENV{MYSQL_TMP_DIR}/sst_size.dat";
+
+if (-f $file) {
+ open(F, '<', $file) || die("Can't open file $file: $!");
+ $old = <F>;
+ close F;
+ if ($old - $size < 1e6) {
+ print "sst file reduction was not enough $old -> $size (minimum 1000kb)\n";
+ } else {
+ print "sst file reduction ok\n";
+ }
+}
+open(F, '>', $file) || die("Can't open file $file: $!");
+print F $size;
+close F;
+EOF
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/optimize_table.test b/storage/rocksdb/mysql-test/rocksdb/t/optimize_table.test
new file mode 100644
index 00000000..50df3f9c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/optimize_table.test
@@ -0,0 +1,81 @@
+--source include/have_rocksdb.inc
+
+#
+# OPTIMIZE TABLE statements
+#
+
+let datadir = `SELECT @@datadir`;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6;
+--enable_warnings
+create table t1 (id int primary key, value int, value2 varchar(200), index(value)) engine=rocksdb;
+create table t2 (id int primary key, value int, value2 varchar(200), index(value)) engine=rocksdb;
+create table t3 (id int primary key, value int, value2 varchar(200), index(value)) engine=rocksdb;
+create table t4 (id int, value int, value2 varchar(200), primary key (id) comment 'rev:cf_i', index(value) comment 'rev:cf_i') engine=rocksdb;
+create table t5 (id int, value int, value2 varchar(200), primary key (id) comment 'rev:cf_i', index(value) comment 'rev:cf_i') engine=rocksdb;
+create table t6 (id int, value int, value2 varchar(200), primary key (id) comment 'rev:cf_i', index(value) comment 'rev:cf_i') engine=rocksdb;
+
+--disable_query_log
+let $t = 1;
+while ($t <= 6) {
+ let $i = 1;
+ while ($i <= 10000) {
+ let $insert = INSERT INTO t$t VALUES($i, $i, REPEAT('x', 150));
+ inc $i;
+ eval $insert;
+ }
+ inc $t;
+}
+--enable_query_log
+
+# Disable auto compaction so that effects of optimize table are stable
+let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
+--exec echo "wait" > $restart_file
+--shutdown_server
+--source include/wait_until_disconnected.inc
+-- exec echo "restart:--rocksdb_default_cf_options=write_buffer_size=64k;target_file_size_base=64k;max_bytes_for_level_base=1m;compression_per_level=kNoCompression;disable_auto_compactions=true;level0_stop_writes_trigger=1000 " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- enable_reconnect
+-- source include/wait_until_connected_again.inc
+
+select count(*) from t1;
+select count(*) from t2;
+select count(*) from t3;
+select count(*) from t4;
+select count(*) from t5;
+select count(*) from t6;
+delete from t1 where id <= 9900;
+delete from t2 where id <= 9900;
+delete from t3 where id <= 9900;
+delete from t4 where id <= 9900;
+delete from t5 where id <= 9900;
+delete from t6 where id <= 9900;
+
+source optimize_table.inc;
+optimize table t1;
+source optimize_table.inc;
+optimize table t3;
+source optimize_table.inc;
+optimize table t4;
+source optimize_table.inc;
+optimize table t6;
+source optimize_table.inc;
+
+select count(*) from t1;
+select count(*) from t2;
+select count(*) from t3;
+select count(*) from t4;
+select count(*) from t5;
+select count(*) from t6;
+
+#cleanup
+optimize table t2;
+optimize table t5;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
+DROP TABLE t5;
+DROP TABLE t6;
+--remove_file $MYSQL_TMP_DIR/sst_size.dat
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/optimizer_loose_index_scans.test b/storage/rocksdb/mysql-test/rocksdb/t/optimizer_loose_index_scans.test
new file mode 100644
index 00000000..db66da3b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/optimizer_loose_index_scans.test
@@ -0,0 +1,4 @@
+--source include/have_rocksdb.inc
+
+let $engine=rocksdb;
+--source include/loose_index_scans.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/partition.test b/storage/rocksdb/mysql-test/rocksdb/t/partition.test
new file mode 100644
index 00000000..5954c0d9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/partition.test
@@ -0,0 +1,762 @@
+
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+#
+# Create tables with partitions and try to update/select from them.
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS VAR_POP;
+DROP TABLE IF EXISTS TEMP0;
+DROP TABLE IF EXISTS VAR_SAMP;
+DROP TABLE IF EXISTS ti;
+DROP TABLE IF EXISTS members;
+DROP TABLE IF EXISTS members_2;
+DROP TABLE IF EXISTS employees;
+DROP TABLE IF EXISTS employees_2;
+DROP TABLE IF EXISTS employees_3;
+DROP TABLE IF EXISTS quarterly_report_status;
+DROP TABLE IF EXISTS employees_4;
+DROP TABLE IF EXISTS h2;
+DROP TABLE IF EXISTS rcx;
+DROP TABLE IF EXISTS r1;
+DROP TABLE IF EXISTS rc1;
+DROP TABLE IF EXISTS rx;
+DROP TABLE IF EXISTS rc2;
+DROP TABLE IF EXISTS rc3;
+DROP TABLE IF EXISTS rc4;
+DROP TABLE IF EXISTS employees_by_lname;
+DROP TABLE IF EXISTS customers_1;
+DROP TABLE IF EXISTS customers_2;
+DROP TABLE IF EXISTS customers_3;
+DROP TABLE IF EXISTS employees_hash;
+DROP TABLE IF EXISTS employees_hash_1;
+DROP TABLE IF EXISTS t1_hash;
+DROP TABLE IF EXISTS employees_linear_hash;
+DROP TABLE IF EXISTS t1_linear_hash;
+DROP TABLE IF EXISTS k1;
+DROP TABLE IF EXISTS k2;
+DROP TABLE IF EXISTS tm1;
+DROP TABLE IF EXISTS tk;
+DROP TABLE IF EXISTS ts;
+DROP TABLE IF EXISTS ts_1;
+DROP TABLE IF EXISTS ts_3;
+DROP TABLE IF EXISTS ts_4;
+DROP TABLE IF EXISTS ts_5;
+DROP TABLE IF EXISTS trb3;
+DROP TABLE IF EXISTS tr;
+DROP TABLE IF EXISTS members_3;
+DROP TABLE IF EXISTS clients;
+DROP TABLE IF EXISTS clients_lk;
+DROP TABLE IF EXISTS trb1;
+
+--enable_warnings
+
+CREATE TABLE t1 (i INT, j INT, k INT, PRIMARY KEY (i)) ENGINE = ROCKSDB PARTITION BY KEY(i) PARTITIONS 4;
+
+--disable_query_log
+let $max = 1000;
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO t1 VALUES ($i, $i, $i);
+ inc $i;
+ eval $insert;
+}
+
+ALTER TABLE t1 REBUILD PARTITION p0, p1;
+ALTER TABLE t1 OPTIMIZE PARTITION p0, p1;
+ALTER TABLE t1 ANALYZE PARTITION p3;
+ALTER TABLE t1 REPAIR PARTITION p0,p1;
+ALTER TABLE t1 CHECK PARTITION p1;
+
+# Parition string is "#P#". To verify that parsing is done correctly then we'll
+# verify if tables containing "P" somwhere can be created correctly.
+CREATE TABLE VAR_POP (a int) ENGINE = ROCKSDB;
+CREATE TABLE TEMP0 (a int) ENGINE = ROCKSDB PARTITION BY HASH (a) PARTITIONS 3;
+CREATE TABLE VAR_SAMP (a int) ENGINE = ROCKSDB PARTITION BY HASH (a) PARTITIONS 10;
+
+--enable_query_log
+
+select lower(table_name) as tname
+from information_schema.tables
+where table_schema=database()
+order by tname;
+
+SELECT * FROM t1 ORDER BY i LIMIT 10;
+SELECT COUNT(*) FROM t1;
+
+#
+# Test-cases above are copied from
+# https://dev.mysql.com/doc/refman/5.6/en/partitioning.html to validate that the
+# partitioning related examples work with MyRocks.
+#
+
+# Create a table that is partitioned by hash into 6 partitions.
+CREATE TABLE ti(
+ id INT,
+ amount DECIMAL(7,2),
+ tr_date DATE
+) ENGINE=ROCKSDB
+ PARTITION BY HASH(MONTH(tr_date))
+ PARTITIONS 6;
+
+CREATE TABLE members (
+ firstname VARCHAR(25) NOT NULL,
+ lastname VARCHAR(25) NOT NULL,
+ username VARCHAR(16) NOT NULL,
+ email VARCHAR(35),
+ joined DATE NOT NULL
+) ENGINE=ROCKSDB
+ PARTITION BY KEY(joined)
+ PARTITIONS 6;
+
+CREATE TABLE members_2 (
+ firstname VARCHAR(25) NOT NULL,
+ lastname VARCHAR(25) NOT NULL,
+ username VARCHAR(16) NOT NULL,
+ email VARCHAR(35),
+ joined DATE NOT NULL
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE(YEAR(joined)) (
+ PARTITION p0 VALUES LESS THAN (1960),
+ PARTITION p1 VALUES LESS THAN (1970),
+ PARTITION p2 VALUES LESS THAN (1980),
+ PARTITION p3 VALUES LESS THAN (1990),
+ PARTITION p4 VALUES LESS THAN MAXVALUE
+ );
+
+# Partition names are not case-sensitive.
+--error 1517
+CREATE TABLE t2 (val INT)
+ ENGINE=ROCKSDB
+ PARTITION BY LIST(val)(
+ PARTITION mypart VALUES IN (1,3,5),
+ PARTITION MyPart VALUES IN (2,4,6)
+ );
+
+CREATE TABLE employees (
+ id INT NOT NULL,
+ fname VARCHAR(30),
+ lname VARCHAR(30),
+ hired DATE NOT NULL DEFAULT '1970-01-01',
+ separated DATE NOT NULL DEFAULT '9999-12-31',
+ job_code INT NOT NULL,
+ store_id INT NOT NULL
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE (store_id) (
+ PARTITION p0 VALUES LESS THAN (6),
+ PARTITION p1 VALUES LESS THAN (11),
+ PARTITION p2 VALUES LESS THAN (16),
+ PARTITION p3 VALUES LESS THAN MAXVALUE
+ );
+
+CREATE TABLE employees_2 (
+ id INT NOT NULL,
+ fname VARCHAR(30),
+ lname VARCHAR(30),
+ hired DATE NOT NULL DEFAULT '1970-01-01',
+ separated DATE NOT NULL DEFAULT '9999-12-31',
+ job_code INT NOT NULL,
+ store_id INT NOT NULL
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE (job_code) (
+ PARTITION p0 VALUES LESS THAN (100),
+ PARTITION p1 VALUES LESS THAN (1000),
+ PARTITION p2 VALUES LESS THAN (10000)
+ );
+
+CREATE TABLE employees_3 (
+ id INT NOT NULL,
+ fname VARCHAR(30),
+ lname VARCHAR(30),
+ hired DATE NOT NULL DEFAULT '1970-01-01',
+ separated DATE NOT NULL DEFAULT '9999-12-31',
+ job_code INT,
+ store_id INT
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE (YEAR(separated)) (
+ PARTITION p0 VALUES LESS THAN (1991),
+ PARTITION p1 VALUES LESS THAN (1996),
+ PARTITION p2 VALUES LESS THAN (2001),
+ PARTITION p3 VALUES LESS THAN MAXVALUE
+ );
+
+CREATE TABLE quarterly_report_status (
+ report_id INT NOT NULL,
+ report_status VARCHAR(20) NOT NULL,
+ report_updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE (UNIX_TIMESTAMP(report_updated)) (
+ PARTITION p0 VALUES LESS THAN ( UNIX_TIMESTAMP('2008-01-01 00:00:00') ),
+ PARTITION p1 VALUES LESS THAN ( UNIX_TIMESTAMP('2008-04-01 00:00:00') ),
+ PARTITION p2 VALUES LESS THAN ( UNIX_TIMESTAMP('2008-07-01 00:00:00') ),
+ PARTITION p3 VALUES LESS THAN ( UNIX_TIMESTAMP('2008-10-01 00:00:00') ),
+ PARTITION p4 VALUES LESS THAN ( UNIX_TIMESTAMP('2009-01-01 00:00:00') ),
+ PARTITION p5 VALUES LESS THAN ( UNIX_TIMESTAMP('2009-04-01 00:00:00') ),
+ PARTITION p6 VALUES LESS THAN ( UNIX_TIMESTAMP('2009-07-01 00:00:00') ),
+ PARTITION p7 VALUES LESS THAN ( UNIX_TIMESTAMP('2009-10-01 00:00:00') ),
+ PARTITION p8 VALUES LESS THAN ( UNIX_TIMESTAMP('2010-01-01 00:00:00') ),
+ PARTITION p9 VALUES LESS THAN (MAXVALUE)
+ );
+
+CREATE TABLE employees_4 (
+ id INT NOT NULL,
+ fname VARCHAR(30),
+ lname VARCHAR(30),
+ hired DATE NOT NULL DEFAULT '1970-01-01',
+ separated DATE NOT NULL DEFAULT '9999-12-31',
+ job_code INT,
+ store_id INT
+) ENGINE=ROCKSDB
+ PARTITION BY LIST(store_id) (
+ PARTITION pNorth VALUES IN (3,5,6,9,17),
+ PARTITION pEast VALUES IN (1,2,10,11,19,20),
+ PARTITION pWest VALUES IN (4,12,13,14,18),
+ PARTITION pCentral VALUES IN (7,8,15,16)
+ );
+
+CREATE TABLE h2 (
+ c1 INT,
+ c2 INT
+) ENGINE=ROCKSDB
+ PARTITION BY LIST(c1) (
+ PARTITION p0 VALUES IN (1, 4, 7),
+ PARTITION p1 VALUES IN (2, 5, 8)
+ );
+
+# ERROR 1526 (HY000): Table has no partition for value 3
+--error 1526
+INSERT INTO h2 VALUES (3, 5);
+
+CREATE TABLE rcx (
+ a INT,
+ b INT,
+ c CHAR(3),
+ d INT
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE COLUMNS(a,d,c) (
+ PARTITION p0 VALUES LESS THAN (5,10,'ggg'),
+ PARTITION p1 VALUES LESS THAN (10,20,'mmm'),
+ PARTITION p2 VALUES LESS THAN (15,30,'sss'),
+ PARTITION p3 VALUES LESS THAN (MAXVALUE,MAXVALUE,MAXVALUE)
+ );
+
+CREATE TABLE r1 (
+ a INT,
+ b INT
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE (a) (
+ PARTITION p0 VALUES LESS THAN (5),
+ PARTITION p1 VALUES LESS THAN (MAXVALUE)
+ );
+
+INSERT INTO r1 VALUES (5,10), (5,11), (5,12);
+
+CREATE TABLE rc1 (
+ a INT,
+ b INT
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE COLUMNS(a, b) (
+ PARTITION p0 VALUES LESS THAN (5, 12),
+ PARTITION p3 VALUES LESS THAN (MAXVALUE, MAXVALUE)
+ );
+
+INSERT INTO rc1 VALUES (5,10), (5,11), (5,12);
+SELECT (5,10) < (5,12), (5,11) < (5,12), (5,12) < (5,12);
+
+CREATE TABLE rx (
+ a INT,
+ b INT
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE COLUMNS (a) (
+ PARTITION p0 VALUES LESS THAN (5),
+ PARTITION p1 VALUES LESS THAN (MAXVALUE)
+ );
+
+INSERT INTO rx VALUES (5,10), (5,11), (5,12);
+
+CREATE TABLE rc2 (
+ a INT,
+ b INT
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE COLUMNS(a,b) (
+ PARTITION p0 VALUES LESS THAN (0,10),
+ PARTITION p1 VALUES LESS THAN (10,20),
+ PARTITION p2 VALUES LESS THAN (10,30),
+ PARTITION p3 VALUES LESS THAN (MAXVALUE,MAXVALUE)
+ );
+
+CREATE TABLE rc3 (
+ a INT,
+ b INT
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE COLUMNS(a,b) (
+ PARTITION p0 VALUES LESS THAN (0,10),
+ PARTITION p1 VALUES LESS THAN (10,20),
+ PARTITION p2 VALUES LESS THAN (10,30),
+ PARTITION p3 VALUES LESS THAN (10,35),
+ PARTITION p4 VALUES LESS THAN (20,40),
+ PARTITION p5 VALUES LESS THAN (MAXVALUE,MAXVALUE)
+);
+
+CREATE TABLE rc4 (
+ a INT,
+ b INT,
+ c INT
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE COLUMNS(a,b,c) (
+ PARTITION p0 VALUES LESS THAN (0,25,50),
+ PARTITION p1 VALUES LESS THAN (10,20,100),
+ PARTITION p2 VALUES LESS THAN (10,30,50),
+ PARTITION p3 VALUES LESS THAN (MAXVALUE,MAXVALUE,MAXVALUE)
+ );
+
+SELECT (0,25,50) < (10,20,100), (10,20,100) < (10,30,50);
+
+-- ERROR 1493 (HY000): VALUES LESS THAN value must be strictly increasing for each partition
+
+--error 1493
+CREATE TABLE rcf (
+ a INT,
+ b INT,
+ c INT
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE COLUMNS(a,b,c) (
+ PARTITION p0 VALUES LESS THAN (0,25,50),
+ PARTITION p1 VALUES LESS THAN (20,20,100),
+ PARTITION p2 VALUES LESS THAN (10,30,50),
+ PARTITION p3 VALUES LESS THAN (MAXVALUE,MAXVALUE,MAXVALUE)
+ );
+
+CREATE TABLE employees_by_lname (
+ id INT NOT NULL,
+ fname VARCHAR(30),
+ lname VARCHAR(30),
+ hired DATE NOT NULL DEFAULT '1970-01-01',
+ separated DATE NOT NULL DEFAULT '9999-12-31',
+ job_code INT NOT NULL,
+ store_id INT NOT NULL
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE COLUMNS (lname) (
+ PARTITION p0 VALUES LESS THAN ('g'),
+ PARTITION p1 VALUES LESS THAN ('m'),
+ PARTITION p2 VALUES LESS THAN ('t'),
+ PARTITION p3 VALUES LESS THAN (MAXVALUE)
+ );
+
+ALTER TABLE employees_by_lname PARTITION BY RANGE COLUMNS (lname) (
+ PARTITION p0 VALUES LESS THAN ('g'),
+ PARTITION p1 VALUES LESS THAN ('m'),
+ PARTITION p2 VALUES LESS THAN ('t'),
+ PARTITION p3 VALUES LESS THAN (MAXVALUE)
+);
+
+ALTER TABLE employees_by_lname PARTITION BY RANGE COLUMNS (hired) (
+ PARTITION p0 VALUES LESS THAN ('1970-01-01'),
+ PARTITION p1 VALUES LESS THAN ('1980-01-01'),
+ PARTITION p2 VALUES LESS THAN ('1990-01-01'),
+ PARTITION p3 VALUES LESS THAN ('2000-01-01'),
+ PARTITION p4 VALUES LESS THAN ('2010-01-01'),
+ PARTITION p5 VALUES LESS THAN (MAXVALUE)
+);
+
+CREATE TABLE customers_1 (
+ first_name VARCHAR(25),
+ last_name VARCHAR(25),
+ street_1 VARCHAR(30),
+ street_2 VARCHAR(30),
+ city VARCHAR(15),
+ renewal DATE
+) ENGINE=ROCKSDB
+ PARTITION BY LIST COLUMNS(city) (
+ PARTITION pRegion_1 VALUES IN('Oskarshamn', 'Högsby', 'Mönsterås'),
+ PARTITION pRegion_2 VALUES IN('Vimmerby', 'Hultsfred', 'Västervik'),
+ PARTITION pRegion_3 VALUES IN('Nässjö', 'Eksjö', 'Vetlanda'),
+ PARTITION pRegion_4 VALUES IN('Uppvidinge', 'Alvesta', 'Växjo')
+ );
+
+CREATE TABLE customers_2 (
+ first_name VARCHAR(25),
+ last_name VARCHAR(25),
+ street_1 VARCHAR(30),
+ street_2 VARCHAR(30),
+ city VARCHAR(15),
+ renewal DATE
+) ENGINE=ROCKSDB
+ PARTITION BY LIST COLUMNS(renewal) (
+ PARTITION pWeek_1 VALUES IN('2010-02-01', '2010-02-02', '2010-02-03',
+ '2010-02-04', '2010-02-05', '2010-02-06', '2010-02-07'),
+ PARTITION pWeek_2 VALUES IN('2010-02-08', '2010-02-09', '2010-02-10',
+ '2010-02-11', '2010-02-12', '2010-02-13', '2010-02-14'),
+ PARTITION pWeek_3 VALUES IN('2010-02-15', '2010-02-16', '2010-02-17',
+ '2010-02-18', '2010-02-19', '2010-02-20', '2010-02-21'),
+ PARTITION pWeek_4 VALUES IN('2010-02-22', '2010-02-23', '2010-02-24',
+ '2010-02-25', '2010-02-26', '2010-02-27', '2010-02-28')
+ );
+
+CREATE TABLE customers_3 (
+ first_name VARCHAR(25),
+ last_name VARCHAR(25),
+ street_1 VARCHAR(30),
+ street_2 VARCHAR(30),
+ city VARCHAR(15),
+ renewal DATE
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE COLUMNS(renewal) (
+ PARTITION pWeek_1 VALUES LESS THAN('2010-02-09'),
+ PARTITION pWeek_2 VALUES LESS THAN('2010-02-15'),
+ PARTITION pWeek_3 VALUES LESS THAN('2010-02-22'),
+ PARTITION pWeek_4 VALUES LESS THAN('2010-03-01')
+ );
+
+CREATE TABLE employees_hash (
+ id INT NOT NULL,
+ fname VARCHAR(30),
+ lname VARCHAR(30),
+ hired DATE NOT NULL DEFAULT '1970-01-01',
+ separated DATE NOT NULL DEFAULT '9999-12-31',
+ job_code INT,
+ store_id INT
+) ENGINE=ROCKSDB
+ PARTITION BY HASH(store_id)
+ PARTITIONS 4;
+
+CREATE TABLE employees_hash_1 (
+ id INT NOT NULL,
+ fname VARCHAR(30),
+ lname VARCHAR(30),
+ hired DATE NOT NULL DEFAULT '1970-01-01',
+ separated DATE NOT NULL DEFAULT '9999-12-31',
+ job_code INT,
+ store_id INT
+) ENGINE=ROCKSDB
+ PARTITION BY HASH( YEAR(hired) )
+ PARTITIONS 4;
+
+CREATE TABLE t1_hash (
+ col1 INT,
+ col2 CHAR(5),
+ col3 DATE
+) ENGINE=ROCKSDB
+ PARTITION BY HASH( YEAR(col3) )
+ PARTITIONS 4;
+
+CREATE TABLE employees_linear_hash (
+ id INT NOT NULL,
+ fname VARCHAR(30),
+ lname VARCHAR(30),
+ hired DATE NOT NULL DEFAULT '1970-01-01',
+ separated DATE NOT NULL DEFAULT '9999-12-31',
+ job_code INT,
+ store_id INT
+) ENGINE=ROCKSDB
+ PARTITION BY LINEAR HASH( YEAR(hired) )
+ PARTITIONS 4;
+
+CREATE TABLE t1_linear_hash (
+ col1 INT,
+ col2 CHAR(5),
+ col3 DATE
+) ENGINE=ROCKSDB
+ PARTITION BY LINEAR HASH( YEAR(col3) )
+ PARTITIONS 6;
+
+CREATE TABLE k1 (
+ id INT NOT NULL PRIMARY KEY,
+ name VARCHAR(20)
+) ENGINE=ROCKSDB
+ PARTITION BY KEY()
+ PARTITIONS 2;
+
+CREATE TABLE k2 (
+ id INT NOT NULL,
+ name VARCHAR(20),
+ UNIQUE KEY (id)
+) ENGINE=ROCKSDB
+ PARTITION BY KEY()
+ PARTITIONS 2;
+
+CREATE TABLE tm1 (
+ s1 CHAR(32) PRIMARY KEY
+) ENGINE=ROCKSDB
+ PARTITION BY KEY(s1)
+ PARTITIONS 10;
+
+CREATE TABLE tk (
+ col1 INT NOT NULL,
+ col2 CHAR(5),
+ col3 DATE
+) ENGINE=ROCKSDB
+ PARTITION BY LINEAR KEY (col1)
+ PARTITIONS 3;
+
+CREATE TABLE ts (
+ id INT,
+ purchased DATE
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE( YEAR(purchased) )
+ SUBPARTITION BY HASH( TO_DAYS(purchased) )
+ SUBPARTITIONS 2 (
+ PARTITION p0 VALUES LESS THAN (1990),
+ PARTITION p1 VALUES LESS THAN (2000),
+ PARTITION p2 VALUES LESS THAN MAXVALUE
+ );
+
+CREATE TABLE ts_1 (
+ id INT,
+ purchased DATE
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE( YEAR(purchased) )
+ SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
+ PARTITION p0 VALUES LESS THAN (1990) (
+ SUBPARTITION s0,
+ SUBPARTITION s1
+ ),
+ PARTITION p1 VALUES LESS THAN (2000) (
+ SUBPARTITION s2,
+ SUBPARTITION s3
+ ),
+ PARTITION p2 VALUES LESS THAN MAXVALUE (
+ SUBPARTITION s4,
+ SUBPARTITION s5
+ )
+ );
+
+--error 1064
+CREATE TABLE ts_2 (
+ id INT,
+ purchased DATE
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE( YEAR(purchased) )
+ SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
+ PARTITION p0 VALUES LESS THAN (1990) (
+ SUBPARTITION s0,
+ SUBPARTITION s1
+ ),
+ PARTITION p1 VALUES LESS THAN (2000),
+ PARTITION p2 VALUES LESS THAN MAXVALUE (
+ SUBPARTITION s2,
+ SUBPARTITION s3
+ )
+ );
+
+CREATE TABLE ts_3 (
+ id INT,
+ purchased DATE
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE( YEAR(purchased) )
+ SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
+ PARTITION p0 VALUES LESS THAN (1990) (
+ SUBPARTITION s0,
+ SUBPARTITION s1
+ ),
+ PARTITION p1 VALUES LESS THAN (2000) (
+ SUBPARTITION s2,
+ SUBPARTITION s3
+ ),
+ PARTITION p2 VALUES LESS THAN MAXVALUE (
+ SUBPARTITION s4,
+ SUBPARTITION s5
+ )
+ );
+
+CREATE TABLE ts_4 (
+ id INT,
+ purchased DATE
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE( YEAR(purchased) )
+ SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
+ PARTITION p0 VALUES LESS THAN (1990) (
+ SUBPARTITION s0,
+ SUBPARTITION s1
+ ),
+ PARTITION p1 VALUES LESS THAN (2000) (
+ SUBPARTITION s2,
+ SUBPARTITION s3
+ ),
+ PARTITION p2 VALUES LESS THAN MAXVALUE (
+ SUBPARTITION s4,
+ SUBPARTITION s5
+ )
+ );
+
+CREATE TABLE ts_5 (
+ id INT,
+ purchased DATE
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE(YEAR(purchased))
+ SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
+ PARTITION p0 VALUES LESS THAN (1990) (
+ SUBPARTITION s0a,
+ SUBPARTITION s0b
+ ),
+ PARTITION p1 VALUES LESS THAN (2000) (
+ SUBPARTITION s1a,
+ SUBPARTITION s1b
+ ),
+ PARTITION p2 VALUES LESS THAN MAXVALUE (
+ SUBPARTITION s2a,
+ SUBPARTITION s2b
+ )
+ );
+
+CREATE TABLE trb3 (
+ id INT,
+ name VARCHAR(50),
+ purchased DATE
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE( YEAR(purchased) ) (
+ PARTITION p0 VALUES LESS THAN (1990),
+ PARTITION p1 VALUES LESS THAN (1995),
+ PARTITION p2 VALUES LESS THAN (2000),
+ PARTITION p3 VALUES LESS THAN (2005)
+ );
+
+ALTER TABLE trb3 PARTITION BY KEY(id) PARTITIONS 2;
+
+CREATE TABLE tr (
+ id INT,
+ name VARCHAR(50),
+ purchased DATE
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE( YEAR(purchased) ) (
+ PARTITION p0 VALUES LESS THAN (1990),
+ PARTITION p1 VALUES LESS THAN (1995),
+ PARTITION p2 VALUES LESS THAN (2000),
+ PARTITION p3 VALUES LESS THAN (2005)
+ );
+
+INSERT INTO tr VALUES
+ (1, 'desk organiser', '2003-10-15'),
+ (2, 'CD player', '1993-11-05'),
+ (3, 'TV set', '1996-03-10'),
+ (4, 'bookcase', '1982-01-10'),
+ (5, 'exercise bike', '2004-05-09'),
+ (6, 'sofa', '1987-06-05'),
+ (7, 'popcorn maker', '2001-11-22'),
+ (8, 'aquarium', '1992-08-04'),
+ (9, 'study desk', '1984-09-16'),
+ (10, 'lava lamp', '1998-12-25');
+
+SELECT * FROM tr WHERE purchased BETWEEN '1995-01-01' AND '1999-12-31';
+
+ALTER TABLE tr DROP PARTITION p2;
+
+SELECT * FROM tr WHERE purchased BETWEEN '1995-01-01' AND '1999-12-31';
+
+CREATE TABLE members_3 (
+ id INT,
+ fname VARCHAR(25),
+ lname VARCHAR(25),
+ dob DATE
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE( YEAR(dob) ) (
+ PARTITION p0 VALUES LESS THAN (1970),
+ PARTITION p1 VALUES LESS THAN (1980),
+ PARTITION p2 VALUES LESS THAN (1990)
+ );
+
+ALTER TABLE members_3 ADD PARTITION (PARTITION p3 VALUES LESS THAN (2000));
+
+# ERROR 1493 (HY000): VALUES LESS THAN value must be strictly increasing for each partition
+--error 1493
+ALTER TABLE members_3 ADD PARTITION (PARTITION n VALUES LESS THAN (1960));
+
+CREATE TABLE clients (
+ id INT,
+ fname VARCHAR(30),
+ lname VARCHAR(30),
+ signed DATE
+) ENGINE=ROCKSDB
+ PARTITION BY HASH( MONTH(signed) )
+ PARTITIONS 12;
+
+ALTER TABLE clients COALESCE PARTITION 4;
+
+CREATE TABLE clients_lk (
+ id INT,
+ fname VARCHAR(30),
+ lname VARCHAR(30),
+ signed DATE
+) ENGINE=ROCKSDB
+ PARTITION BY LINEAR KEY(signed)
+ PARTITIONS 12;
+
+# ERROR 1508 (HY000): Cannot remove all partitions, use DROP TABLE instead
+--error 1508
+ALTER TABLE clients COALESCE PARTITION 18;
+
+ALTER TABLE clients ADD PARTITION PARTITIONS 6;
+
+CREATE TABLE trb1 (
+ id INT,
+ name VARCHAR(50),
+ purchased DATE
+) ENGINE=ROCKSDB
+ PARTITION BY RANGE(id) (
+ PARTITION p0 VALUES LESS THAN (3),
+ PARTITION p1 VALUES LESS THAN (7),
+ PARTITION p2 VALUES LESS THAN (9),
+ PARTITION p3 VALUES LESS THAN (11)
+ );
+
+INSERT INTO trb1 VALUES
+ (1, 'desk organiser', '2003-10-15'),
+ (2, 'CD player', '1993-11-05'),
+ (3, 'TV set', '1996-03-10'),
+ (4, 'bookcase', '1982-01-10'),
+ (5, 'exercise bike', '2004-05-09'),
+ (6, 'sofa', '1987-06-05'),
+ (7, 'popcorn maker', '2001-11-22'),
+ (8, 'aquarium', '1992-08-04'),
+ (9, 'study desk', '1984-09-16'),
+ (10, 'lava lamp', '1998-12-25');
+
+ALTER TABLE trb1 ADD PRIMARY KEY (id);
+
+# Clean up.
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS VAR_POP;
+DROP TABLE IF EXISTS TEMP0;
+DROP TABLE IF EXISTS VAR_SAMP;
+DROP TABLE IF EXISTS ti;
+DROP TABLE IF EXISTS members;
+DROP TABLE IF EXISTS members_2;
+DROP TABLE IF EXISTS employees;
+DROP TABLE IF EXISTS employees_2;
+DROP TABLE IF EXISTS employees_3;
+DROP TABLE IF EXISTS quarterly_report_status;
+DROP TABLE IF EXISTS employees_4;
+DROP TABLE IF EXISTS h2;
+DROP TABLE IF EXISTS rcx;
+DROP TABLE IF EXISTS r1;
+DROP TABLE IF EXISTS rc1;
+DROP TABLE IF EXISTS rx;
+DROP TABLE IF EXISTS rc2;
+DROP TABLE IF EXISTS rc3;
+DROP TABLE IF EXISTS rc4;
+DROP TABLE IF EXISTS employees_by_lname;
+DROP TABLE IF EXISTS customers_1;
+DROP TABLE IF EXISTS customers_2;
+DROP TABLE IF EXISTS customers_3;
+DROP TABLE IF EXISTS employees_hash;
+DROP TABLE IF EXISTS employees_hash_1;
+DROP TABLE IF EXISTS t1_hash;
+DROP TABLE IF EXISTS employees_linear_hash;
+DROP TABLE IF EXISTS t1_linear_hash;
+DROP TABLE IF EXISTS k1;
+DROP TABLE IF EXISTS k2;
+DROP TABLE IF EXISTS tm1;
+DROP TABLE IF EXISTS tk;
+DROP TABLE IF EXISTS ts;
+DROP TABLE IF EXISTS ts_1;
+DROP TABLE IF EXISTS ts_3;
+DROP TABLE IF EXISTS ts_4;
+DROP TABLE IF EXISTS ts_5;
+DROP TABLE IF EXISTS trb3;
+DROP TABLE IF EXISTS tr;
+DROP TABLE IF EXISTS members_3;
+DROP TABLE IF EXISTS clients;
+DROP TABLE IF EXISTS clients_lk;
+DROP TABLE IF EXISTS trb1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/percona_nonflushing_analyze_debug.test b/storage/rocksdb/mysql-test/rocksdb/t/percona_nonflushing_analyze_debug.test
new file mode 100644
index 00000000..c0c73e68
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/percona_nonflushing_analyze_debug.test
@@ -0,0 +1,11 @@
+--source include/have_debug_sync.inc
+--source include/have_rocksdb.inc
+
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1), (2), (3);
+
+--let $percona_nonflushing_analyze_table= t1
+--source include/percona_nonflushing_analyze_debug.inc
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/perf_context.test b/storage/rocksdb/mysql-test/rocksdb/t/perf_context.test
new file mode 100644
index 00000000..ee41324a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/perf_context.test
@@ -0,0 +1,96 @@
+--source include/have_rocksdb.inc
+
+#
+# Information Schema perf context
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+
+SET @prior_rocksdb_perf_context_level = @@rocksdb_perf_context_level;
+SET GLOBAL rocksdb_perf_context_level=3;
+
+CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i)) ENGINE = ROCKSDB;
+CREATE TABLE t2 (k INT, PRIMARY KEY (k)) ENGINE = ROCKSDB;
+
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4), (5,5);
+
+###############################################################################
+# Test that expected perf context stats exists
+###############################################################################
+
+# Check per-table perf context
+--replace_column 5 #
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT WHERE TABLE_NAME = 't1';
+
+# Check global perf context
+--replace_column 2 #
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT_GLOBAL;
+
+###############################################################################
+# Test iteration skip counters
+###############################################################################
+
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT
+WHERE TABLE_NAME = 't1'
+AND STAT_TYPE in ('INTERNAL_KEY_SKIPPED_COUNT', 'INTERNAL_DELETE_SKIPPED_COUNT');
+
+SELECT * FROM t1;
+
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT
+WHERE TABLE_NAME = 't1'
+AND STAT_TYPE in ('INTERNAL_KEY_SKIPPED_COUNT', 'INTERNAL_DELETE_SKIPPED_COUNT');
+
+SELECT * FROM t1 WHERE j BETWEEN 1 AND 5;
+
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT
+WHERE TABLE_NAME = 't1'
+AND STAT_TYPE in ('INTERNAL_KEY_SKIPPED_COUNT', 'INTERNAL_DELETE_SKIPPED_COUNT');
+
+###############################################################################
+# Test write I/O stats
+###############################################################################
+
+# Statistics for multi-statement transactions cannot be attributed to
+# individual tables but should show up in global perf context stats
+set @tmp_flush_log= @@rocksdb_flush_log_at_trx_commit;
+set global rocksdb_flush_log_at_trx_commit=1;
+
+BEGIN;
+INSERT INTO t2 VALUES (1), (2);
+INSERT INTO t2 VALUES (3), (4);
+COMMIT;
+
+SELECT COUNT(*) from INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT
+WHERE TABLE_NAME = 't2'
+AND STAT_TYPE = 'IO_WRITE_NANOS'
+AND VALUE > 0;
+
+SELECT COUNT(*) from INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT_GLOBAL
+WHERE STAT_TYPE = 'IO_WRITE_NANOS' AND VALUE > 0;
+
+SELECT VALUE INTO @a from INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT_GLOBAL
+WHERE STAT_TYPE = 'IO_WRITE_NANOS';
+
+# Single statement writes do show up in per-table stats
+INSERT INTO t2 VALUES (5), (6), (7), (8);
+
+SELECT COUNT(*) from INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT
+WHERE TABLE_NAME = 't2'
+AND STAT_TYPE = 'IO_WRITE_NANOS'
+AND VALUE > 0;
+
+SELECT VALUE INTO @b from INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT_GLOBAL
+WHERE STAT_TYPE = 'IO_WRITE_NANOS';
+
+SELECT CASE WHEN @b - @a > 0 THEN 'true' ELSE 'false' END;
+
+# cleanup
+DROP TABLE t1;
+DROP TABLE t2;
+SET GLOBAL rocksdb_perf_context_level = @prior_rocksdb_perf_context_level;
+set global rocksdb_flush_log_at_trx_commit= @tmp_flush_log;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/persistent_cache.test b/storage/rocksdb/mysql-test/rocksdb/t/persistent_cache.test
new file mode 100644
index 00000000..49e5e5c1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/persistent_cache.test
@@ -0,0 +1,41 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $_server_id= `SELECT @@server_id`
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
+--let $_cache_file_name= $MYSQLTEST_VARDIR/tmp/persistent_cache
+--exec echo "wait" >$_expect_file_name
+
+# restart server with correct parameters
+shutdown_server;
+--exec echo "restart:--rocksdb_persistent_cache_path=$_cache_file_name --rocksdb_persistent_cache_size_mb=100" >$_expect_file_name
+--sleep 5
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+
+
+# insert values and flush out of memtable
+CREATE TABLE t1 (a int primary key) ENGINE=ROCKSDB;
+insert into t1 values (1);
+set global rocksdb_force_flush_memtable_now=1;
+
+# pull data through cache
+select * from t1 where a = 1;
+
+# restart server to re-read cache
+--exec echo "wait" >$_expect_file_name
+shutdown_server;
+--exec echo "restart:--rocksdb_persistent_cache_path=$_cache_file_name --rocksdb_persistent_cache_size_mb=100" >$_expect_file_name
+--sleep 5
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+
+# pull values from cache again
+select * from t1 where a = 1;
+
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/prefix_extractor_override-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/prefix_extractor_override-master.opt
new file mode 100644
index 00000000..ca7e3636
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/prefix_extractor_override-master.opt
@@ -0,0 +1 @@
+--rocksdb_default_cf_options=write_buffer_size=64k;block_based_table_factory={filter_policy=bloomfilter:10:false;whole_key_filtering=0;};prefix_extractor=capped:24;disable_auto_compactions=true
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/prefix_extractor_override.test b/storage/rocksdb/mysql-test/rocksdb/t/prefix_extractor_override.test
new file mode 100644
index 00000000..8fa43e15
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/prefix_extractor_override.test
@@ -0,0 +1,96 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (id1 BIGINT, id2 BIGINT, id3 BIGINT, id4 BIGINT, PRIMARY KEY (id1, id2, id3, id4) comment 'cf1') ENGINE=rocksdb collate latin1_bin;
+--disable_query_log
+let $i = 1;
+while ($i <= 100) {
+ let $insert = INSERT INTO t1 VALUES(1, $i, $i, $i);
+ eval $insert;
+ inc $i;
+}
+--enable_query_log
+set global rocksdb_force_flush_memtable_now = 1;
+
+--echo
+--echo Original Prefix Extractor:
+--echo
+--sorted_result
+SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%';
+
+# BF used (4+8+8+8)
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
+select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+
+--let $_mysqld_option=--rocksdb_override_cf_options=cf1={prefix_extractor=capped:26};
+
+--echo
+--echo Prefix Extractor (after override_cf_options set, should not be changed):
+--echo
+--sorted_result
+SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%';
+
+SET @@global.rocksdb_update_cf_options = 'cf1={prefix_extractor=capped:26};';
+--echo
+--echo Changed Prefix Extractor (after update_cf_options set, without restart):
+--echo
+--sorted_result
+# Restart no longer needed
+SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%';
+
+# set cf_options for non-existent cf2, cf2 should be created automatically
+SET @@global.rocksdb_update_cf_options = 'cf2={prefix_extractor=capped:28};';
+SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%';
+
+# Satisfies can_use_bloom_filter (4+8+8+8), but can't use because the old SST
+# files have old prefix extractor
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
+select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+
+# Insert more data into t1, verify it uses new bloom filter
+--disable_query_log
+let $i = 101;
+while ($i <= 200) {
+ let $insert = INSERT INTO t1 VALUES(1, $i, $i, $i);
+ eval $insert;
+ inc $i;
+}
+--enable_query_log
+
+set global rocksdb_force_flush_memtable_now = 1;
+
+# BF used w/ new prefix extractor (4+8+8+8) (still increments once because it
+# needs to check the new SST file, but doesnt increment for SST file with old
+# extractor)
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
+select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+
+# should have 2 sst files, one with old prefix extractor and one with new
+SELECT COUNT(*) FROM information_schema.rocksdb_index_file_map WHERE COLUMN_FAMILY != 1;
+
+# update some old data, force compaction, verify that new SST files use
+# new bloom filter
+UPDATE t1 SET id1=1,id2 = 30,id3 = 30 WHERE id4 >= 0 AND id4 <=10;
+set global rocksdb_force_flush_memtable_now = 1;
+
+# should have 3 sst files, one with old prefix extractor and two with new
+SELECT COUNT(*) FROM information_schema.rocksdb_index_file_map WHERE COLUMN_FAMILY != 1;
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
+select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+
+SET @@global.rocksdb_update_cf_options = '';
+set global rocksdb_compact_cf='cf1';
+
+# Select the updated, make sure bloom filter is checked now
+select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=30 AND id3=30;
+select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/read_only_tx-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/read_only_tx-master.opt
new file mode 100644
index 00000000..221b35c6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/read_only_tx-master.opt
@@ -0,0 +1 @@
+--rocksdb_default_cf_options=write_buffer_size=16k --log-bin --binlog_format=row --log-slave-updates
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/read_only_tx.test b/storage/rocksdb/mysql-test/rocksdb/t/read_only_tx.test
new file mode 100644
index 00000000..3a1025a3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/read_only_tx.test
@@ -0,0 +1,70 @@
+--source include/have_log_bin.inc
+--source include/have_rocksdb.inc
+--source include/count_sessions.inc
+--disable_warnings
+#--source include/have_gtid.inc
+--enable_warnings
+#-- let $uuid = `select @@server_uuid;`
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+CREATE TABLE t1 (id INT, value int, PRIMARY KEY (id), INDEX (value)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1,1);
+
+# Read-only, long-running transaction. SingleDelete/Put shouldn't increase much.
+select variable_value into @p from information_schema.global_status where variable_name='rocksdb_number_sst_entry_put';
+select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+#-- replace_result $uuid uuid
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+
+connection con2;
+--disable_query_log
+let $i = 1;
+while ($i <= 10000) {
+ let $update = UPDATE t1 SET value=value+1 WHERE id=1;
+ inc $i;
+ eval $update;
+}
+--enable_query_log
+
+connection con1;
+select case when variable_value-@p < 1000 then 'true' else variable_value-@p end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_put';
+select case when variable_value-@s < 100 then 'true' else variable_value-@s end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+SELECT * FROM t1;
+--error ER_UPDATES_WITH_CONSISTENT_SNAPSHOT
+INSERT INTO t1 values (2, 2);
+ROLLBACK;
+SELECT * FROM t1;
+INSERT INTO t1 values (2, 2);
+SELECT * FROM t1 ORDER BY id;
+
+# Regular long-running transaction.
+# No "Transaction could not check for conflicts for opearation" error should happen.
+BEGIN;
+
+connection con2;
+--disable_query_log
+let $i = 5;
+while ($i <= 10000) {
+ let $insert = INSERT INTO t1 VALUES ($i, $i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+connection con1;
+SELECT COUNT(*) FROM t1;
+COMMIT;
+
+connection default;
+disconnect con1;
+disconnect con2;
+OPTIMIZE TABLE t1;
+DROP TABLE t1;
+reset master;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/records_in_range-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/records_in_range-master.opt
new file mode 100644
index 00000000..75a17cc1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/records_in_range-master.opt
@@ -0,0 +1,3 @@
+--rocksdb_debug_optimizer_n_rows=20000
+--rocksdb_records_in_range=1000
+--rocksdb_table_stats_sampling_pct=100
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/records_in_range.test b/storage/rocksdb/mysql-test/rocksdb/t/records_in_range.test
new file mode 100644
index 00000000..68fb1a09
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/records_in_range.test
@@ -0,0 +1,146 @@
+--source include/have_rocksdb.inc
+--source include/restart_mysqld.inc
+--source include/default_optimizer_switch.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Create the table and insert some keys
+CREATE TABLE t1 (
+ i INT,
+ a INT,
+ b INT,
+ PRIMARY KEY (i),
+ KEY ka(a),
+ KEY kb(b) comment 'rev:cf1'
+) ENGINE = rocksdb;
+
+--disable_query_log
+let $max = 20000;
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO t1 VALUES ($i, $i, $i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+# get results for records_in_range prior to memtable flush
+# normal CF
+explain extended select * from t1 where a> 500 and a< 750;
+explain extended select * from t1 where a< 750;
+explain extended select * from t1 where a> 500;
+explain extended select * from t1 where a>=0 and a<=1000;
+
+#reverse CF
+explain extended select * from t1 where b> 500 and b< 750;
+explain extended select * from t1 where b< 750;
+explain extended select * from t1 where b> 500;
+explain extended select * from t1 where b>=0 and b<=1000;
+
+## cost calculation differences between covering vs non-covering (#298)
+set @save_rocksdb_records_in_range = @@session.rocksdb_records_in_range;
+set rocksdb_records_in_range = 15000;
+# covering, range
+explain extended select a from t1 where a < 750;
+# non-covering, full
+explain extended select a, b from t1 where a < 750;
+# covering, ref
+explain extended select a from t1 where a = 700;
+# non-covering, ref
+explain extended select a,b from t1 where a = 700;
+# covering, full index
+explain extended select a from t1 where a in (700, 800);
+# non-covering, full
+explain extended select a,b from t1 where a in (700, 800);
+set rocksdb_records_in_range=8000;
+# covering, range
+explain extended select a from t1 where a in (700, 800);
+# non-covering, full
+explain extended select a,b from t1 where a in (700, 800);
+set rocksdb_records_in_range = @save_rocksdb_records_in_range;
+
+# flush memtable and repeat
+set global rocksdb_force_flush_memtable_now = true;
+# normal CF
+explain extended select * from t1 where a> 500 and a< 750;
+explain extended select * from t1 where a< 750;
+explain extended select * from t1 where a> 500;
+explain extended select * from t1 where a>=0 and a<=1000;
+
+#reverse CF
+explain extended select * from t1 where b> 500 and b< 750;
+explain extended select * from t1 where b< 750;
+explain extended select * from t1 where b> 500;
+explain extended select * from t1 where b>=0 and b<=1000;
+
+# a set of 1
+explain extended select * from t1 where a>= 500 and a<= 500;
+explain extended select * from t1 where b>= 500 and b<= 500;
+
+# two indexes
+explain extended select * from t1 where a< 750 and b> 500 and b< 750;
+
+# composite index
+drop index ka on t1;
+drop index kb on t1;
+create index kab on t1(a,b);
+set global rocksdb_force_flush_memtable_now = true;
+explain extended select * from t1 where a< 750 and b> 500 and b< 750;
+
+# override records in range
+set rocksdb_records_in_range=444;
+explain extended select * from t1 where a< 750 and b> 500 and b< 750;
+set rocksdb_records_in_range=0;
+
+# issue 82
+## forward cf
+CREATE TABLE `linktable` (
+ `id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+ `id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+ `link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `visibility` tinyint(3) NOT NULL DEFAULT '0',
+ `data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '',
+ `time` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `version` int(11) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link_pk',
+ KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`version`,`data`) COMMENT 'cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
+
+insert into linktable values (1,1,1,1,1,1,1,1,1);
+insert into linktable values (1,1,2,1,1,1,1,1,1);
+insert into linktable values (1,1,3,1,1,1,1,1,1);
+insert into linktable values (1,1,4,1,1,1,1,1,1);
+set global rocksdb_force_flush_memtable_now = true;
+explain select id1, id2, link_type, visibility, data, time, version from linktable where id1 = 1 and link_type = 1 and id2 in (1, 2);
+drop table linktable;
+
+## rev cf
+CREATE TABLE `linktable` (
+ `id1` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `id1_type` int(10) unsigned NOT NULL DEFAULT '0',
+ `id2` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `id2_type` int(10) unsigned NOT NULL DEFAULT '0',
+ `link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `visibility` tinyint(3) NOT NULL DEFAULT '0',
+ `data` varchar(255) COLLATE latin1_bin NOT NULL DEFAULT '',
+ `time` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `version` int(11) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (`link_type`,`id1`,`id2`) COMMENT 'cf_link_pk',
+ KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`version`,`data`) COMMENT 'rev:cf_link_id1_type'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
+
+insert into linktable values (1,1,1,1,1,1,1,1,1);
+insert into linktable values (1,1,2,1,1,1,1,1,1);
+insert into linktable values (1,1,3,1,1,1,1,1,1);
+insert into linktable values (1,1,4,1,1,1,1,1,1);
+set global rocksdb_force_flush_memtable_now = true;
+explain select id1, id2, link_type, visibility, data, time, version from linktable where id1 = 1 and link_type = 1 and id2 in (1, 2);
+drop table linktable;
+
+#cleanup
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/repair_table.inc b/storage/rocksdb/mysql-test/rocksdb/t/repair_table.inc
new file mode 100644
index 00000000..47d6a299
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/repair_table.inc
@@ -0,0 +1,38 @@
+#
+# REPAIR TABLE statements
+#
+# Note: the output is likely to be different for the engine under test,
+# in which case rdiff will be needed. Or, the output might say that
+# the storage engine does not support REPAIR.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a INT, b CHAR(8) PRIMARY KEY) ENGINE=rocksdb;
+
+REPAIR TABLE t1;
+
+INSERT INTO t1 (a,b) VALUES (3,'c');
+INSERT INTO t2 (a,b) VALUES (4,'d');
+REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2;
+INSERT INTO t2 (a,b) VALUES (5,'e'),(6,'f');
+REPAIR LOCAL TABLE t2;
+INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
+INSERT INTO t2 (a,b) VALUES (9,'i');
+REPAIR LOCAL TABLE t2, t1 EXTENDED;
+INSERT INTO t1 (a,b) VALUES (10,'j');
+INSERT INTO t2 (a,b) VALUES (11,'k');
+REPAIR TABLE t1, t2 QUICK USE_FRM;
+INSERT INTO t1 (a,b) VALUES (12,'l');
+INSERT INTO t2 (a,b) VALUES (13,'m');
+REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2 QUICK EXTENDED USE_FRM;
+FLUSH TABLE t1;
+
+DROP TABLE t1, t2;
+
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/repair_table.test b/storage/rocksdb/mysql-test/rocksdb/t/repair_table.test
new file mode 100644
index 00000000..5c4807ce
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/repair_table.test
@@ -0,0 +1,8 @@
+--source include/have_rocksdb.inc
+
+#
+# REPAIR TABLE statements
+#
+
+--source repair_table.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/replace.test b/storage/rocksdb/mysql-test/rocksdb/t/replace.test
new file mode 100644
index 00000000..3ac37330
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/replace.test
@@ -0,0 +1,54 @@
+--source include/have_rocksdb.inc
+
+#
+# Basic REPLACE statements
+#
+
+###########################################
+# TODO:
+# A part of the test is currently disabled
+# because unique indexes are not supported
+###########################################
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+
+# When there is no duplicate key, REPLACE should work as INSERT
+
+REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+--sorted_result
+SELECT a,b FROM t1;
+
+REPLACE t1 (a,b) VALUE (10,'foo'),(10,'foo');
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+--disable_parsing
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, UNIQUE INDEX (a)) ENGINE=rocksdb;
+REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
+--error ER_DUP_ENTRY
+INSERT INTO t1 (a,b) VALUES (2,'d');
+REPLACE INTO t1 (a,b) VALUES (2,'d');
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+--enable_parsing
+
+CREATE TABLE t1 (a INT, b CHAR(8), PRIMARY KEY (b)) ENGINE=rocksdb;
+REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
+--error ER_DUP_ENTRY
+INSERT INTO t1 (a,b) VALUES (4,'b');
+REPLACE INTO t1 (a,b) VALUES (4,'b');
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb-master.opt
new file mode 100644
index 00000000..6ad42e58
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000 --rocksdb_records_in_range=50
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb.test
new file mode 100644
index 00000000..f7de167b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb.test
@@ -0,0 +1,1974 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+--source include/have_write_committed.inc
+
+#
+# RocksDB Storage Engine tests
+#
+select ENGINE,COMMENT,TRANSACTIONS,XA,SAVEPOINTS from information_schema.engines where engine = 'rocksdb';
+
+--disable_warnings
+drop table if exists t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
+drop table if exists t11,t12,t13,t14,t15,t16,t17,t18,t19,t20;
+drop table if exists t21,t22,t23,t24,t25,t26,t27,t28,t29;
+drop table if exists t30,t31,t32,t33,t34,t35,t36,t37,t38,t39;
+drop table if exists t40,t41,t42,t43,t44,t45,t46,t47,t48,t49;
+--enable_warnings
+
+# Disable background compaction to prevent stats from affect explain output
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+
+--echo #
+--echo # Issue #1: Don't update indexes if index values have not changed
+--echo #
+# [Jay Edgar] I moved this test first because it uses the
+# rocksdb_number_keys_written value, but this value is affected out of band
+# by drop tables. There is a background thread that periodically processes
+# through the list of dropped keys and if any are gone from the database it
+# deletes information related to the key - and this delete causes this count
+# to be incorrect. I moved this test first and made the whole test require
+# a fresh server to hopefully avoid tihs.
+create table t1 (
+ pk int primary key,
+ a int,
+ b int,
+ key(a)
+) engine=rocksdb;
+
+insert into t1 values
+(1,1,1), (2,2,2), (3,3,3), (4,4,4);
+
+set @var1=(select variable_value
+ from information_schema.global_status
+ where variable_name='rocksdb_number_keys_written');
+
+--echo # Do an update that doesn't change the key 'a'.
+update t1 set b=3334341 where a=2;
+
+set @var2=(select variable_value
+ from information_schema.global_status
+ where variable_name='rocksdb_number_keys_written');
+--echo # The following should produce 1
+select @var2 - @var1;
+
+--echo # Do an update that sets the key to the same value
+update t1 set a=pk where a=3;
+set @var3=(select variable_value
+ from information_schema.global_status
+ where variable_name='rocksdb_number_keys_written');
+--echo # We have 'updated' column to the same value, so the following must return 0:
+select @var3 - @var2;
+drop table t1;
+
+create table t0 (a int primary key) engine=rocksdb;
+show create table t0;
+drop table t0;
+
+create table t1 (a int primary key, b int) engine=rocksdb;
+insert into t1 values (1,1);
+insert into t1 values (2,2);
+
+select * from t1;
+
+--echo # Check that we can create another table and insert there
+create table t2 (a varchar(10) primary key, b varchar(10)) engine=rocksdb;
+insert into t2 value ('abc','def');
+insert into t2 value ('hijkl','mnopq');
+select * from t2;
+
+--echo # Select again from t1 to see that records from different tables dont mix
+select * from t1;
+
+explain select * from t2 where a='no-such-key';
+--replace_column 9 #
+explain select * from t2 where a='abc';
+select * from t2 where a='abc';
+
+--echo # Try a composite PK
+create table t3 (
+ pk1 int,
+ pk2 varchar(10),
+ col1 varchar(10),
+ primary key(pk1, pk2)
+) engine=rocksdb;
+
+insert into t3 values (2,'two', 'row#2');
+insert into t3 values (3,'three', 'row#3');
+insert into t3 values (1,'one', 'row#1');
+
+select * from t3;
+select * from t3 where pk1=3 and pk2='three';
+
+drop table t1, t2, t3;
+
+--echo #
+--echo # Test blob values
+--echo #
+
+create table t4 (a int primary key, b blob) engine=rocksdb;
+insert into t4 values (1, repeat('quux-quux', 60));
+insert into t4 values (10, repeat('foo-bar', 43));
+insert into t4 values (5, repeat('foo-bar', 200));
+
+insert into t4 values (2, NULL);
+
+
+select
+ a,
+ (case a
+ when 1 then b=repeat('quux-quux', 60)
+ when 10 then b=repeat('foo-bar', 43)
+ when 5 then b=repeat('foo-bar', 200)
+ when 2 then b is null
+ else 'IMPOSSIBLE!' end) as CMP
+from t4;
+
+drop table t4;
+
+--echo #
+--echo # Test blobs of various sizes
+--echo #
+
+--echo # TINYBLOB
+create table t5 (a int primary key, b tinyblob) engine=rocksdb;
+insert into t5 values (1, repeat('quux-quux', 6));
+insert into t5 values (10, repeat('foo-bar', 4));
+insert into t5 values (5, repeat('foo-bar', 2));
+select
+ a,
+ (case a
+ when 1 then b=repeat('quux-quux', 6)
+ when 10 then b=repeat('foo-bar', 4)
+ when 5 then b=repeat('foo-bar', 2)
+ else 'IMPOSSIBLE!' end) as CMP
+from t5;
+drop table t5;
+
+--echo # MEDIUMBLOB
+create table t6 (a int primary key, b mediumblob) engine=rocksdb;
+insert into t6 values (1, repeat('AB', 65000));
+insert into t6 values (10, repeat('bbb', 40000));
+insert into t6 values (5, repeat('foo-bar', 2));
+select
+ a,
+ (case a
+ when 1 then b=repeat('AB', 65000)
+ when 10 then b=repeat('bbb', 40000)
+ when 5 then b=repeat('foo-bar', 2)
+ else 'IMPOSSIBLE!' end) as CMP
+from t6;
+drop table t6;
+
+--echo # LONGBLOB
+create table t7 (a int primary key, b longblob) engine=rocksdb;
+insert into t7 values (1, repeat('AB', 65000));
+insert into t7 values (10, repeat('bbb', 40000));
+insert into t7 values (5, repeat('foo-bar', 2));
+select
+ a,
+ (case a
+ when 1 then b=repeat('AB', 65000)
+ when 10 then b=repeat('bbb', 40000)
+ when 5 then b=repeat('foo-bar', 2)
+ else 'IMPOSSIBLE!' end) as CMP
+from t7;
+drop table t7;
+
+
+--echo #
+--echo # Check if DELETEs work
+--echo #
+create table t8 (a varchar(10) primary key, col1 varchar(12)) engine=rocksdb;
+
+insert into t8 values
+ ('one', 'eins'),
+ ('two', 'zwei'),
+ ('three', 'drei'),
+ ('four', 'vier'),
+ ('five', 'funf');
+
+--echo # Delete by PK
+--replace_column 9 #
+explain delete from t8 where a='three';
+delete from t8 where a='three';
+
+select * from t8;
+
+--echo # Delete while doing a full table scan
+delete from t8 where col1='eins' or col1='vier';
+select * from t8;
+
+--echo # delete w/o WHERE:
+delete from t8;
+select * from t8;
+
+--echo #
+--echo # Test UPDATEs
+--echo #
+insert into t8 values
+ ('one', 'eins'),
+ ('two', 'zwei'),
+ ('three', 'drei'),
+ ('four', 'vier'),
+ ('five', 'funf');
+
+update t8 set col1='dva' where a='two';
+
+update t8 set a='fourAAA' where col1='vier';
+
+select * from t8;
+delete from t8;
+
+--echo #
+--echo # Basic transactions tests
+--echo #
+begin;
+insert into t8 values ('trx1-val1', 'data');
+insert into t8 values ('trx1-val2', 'data');
+rollback;
+select * from t8;
+
+begin;
+insert into t8 values ('trx1-val1', 'data');
+insert into t8 values ('trx1-val2', 'data');
+commit;
+select * from t8;
+
+drop table t8;
+
+--echo #
+--echo # Check if DROP TABLE works
+--echo #
+create table t8 (a varchar(10) primary key, col1 varchar(12)) engine=rocksdb;
+select * from t8;
+insert into t8 values ('foo','foo');
+drop table t8;
+create table t8 (a varchar(10) primary key, col1 varchar(12)) engine=rocksdb;
+select * from t8;
+drop table t8;
+
+--echo #
+--echo # MDEV-3961: Assertion ... on creating a TEMPORARY RocksDB table
+--echo #
+--error ER_ILLEGAL_HA_CREATE_OPTION
+CREATE TEMPORARY TABLE t10 (pk INT PRIMARY KEY) ENGINE=RocksDB;
+
+--echo #
+--echo # MDEV-3963: JOIN or WHERE conditions involving keys on RocksDB tables don't work
+--echo #
+CREATE TABLE t10 (i INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t10 VALUES (1),(3);
+CREATE TABLE t11 (j INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t11 VALUES (1),(4);
+
+select * from t10;
+select * from t11;
+--replace_column 9 #
+EXPLAIN
+SELECT * FROM t10, t11 WHERE i=j;
+SELECT * FROM t10, t11 WHERE i=j;
+
+DROP TABLE t10,t11;
+
+--echo #
+--echo # MDEV-3962: SELECT with ORDER BY causes "ERROR 1030 (HY000): Got error 122
+--echo #
+CREATE TABLE t12 (pk INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t12 VALUES (2),(1);
+SELECT * FROM t12 ORDER BY pk;
+DROP TABLE t12;
+
+--echo #
+--echo # MDEV-3964: Assertion `!pk_descr' fails in ha_rocksdb::open on adding partitions ...
+--echo #
+create table t14 (pk int primary key) engine=RocksDB partition by hash(pk) partitions 2;
+#--error ER_GET_ERRNO
+#alter table t14 add partition partitions 2;
+# ^^ works, but causes weird warnings in error log.
+drop table t14;
+
+--echo #
+--echo # MDEV-3960: Server crashes on running DISCARD TABLESPACE on a RocksDB table
+--echo #
+create table t9 (i int primary key) engine=rocksdb;
+--error ER_ILLEGAL_HA
+alter table t9 discard tablespace;
+drop table t9;
+
+--echo #
+--echo # MDEV-3959: Assertion `slice->size() == table->s->reclength' fails ...
+--echo # on accessing a table after ALTER
+--echo #
+CREATE TABLE t15 (a INT, rocksdb_pk INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t15 VALUES (1,1),(5,2);
+#--error ER_ILLEGAL_HA
+ALTER TABLE t15 DROP COLUMN a;
+DROP TABLE t15;
+
+--echo #
+--echo # MDEV-3968: UPDATE produces a wrong result while modifying a PK on a RocksDB table
+--echo #
+create table t16 (pk int primary key, a char(8)) engine=RocksDB;
+insert into t16 values (1,'a'),(2,'b'),(3,'c'),(4,'d');
+
+#
+# Not anymore: The following query will still eat a record because of CANT-SEE-OWN-CHANGES
+# property.
+#
+--error ER_DUP_ENTRY
+update t16 set pk=100, a = 'updated' where a in ('b','c');
+select * from t16;
+drop table t16;
+
+--echo #
+--echo # MDEV-3970: A set of assorted crashes on inserting a row into a RocksDB table
+--echo #
+--disable_warnings
+drop table if exists t_very_long_table_name;
+--enable_warnings
+
+CREATE TABLE `t_very_long_table_name` (
+ `c` char(1) NOT NULL,
+ `c0` char(0) NOT NULL,
+ `c1` char(1) NOT NULL,
+ `c20` char(20) NOT NULL,
+ `c255` char(255) NOT NULL,
+ PRIMARY KEY (`c255`)
+ ) ENGINE=RocksDB DEFAULT CHARSET=latin1;
+INSERT INTO t_very_long_table_name VALUES ('a', '', 'c', REPEAT('a',20), REPEAT('x',255));
+drop table t_very_long_table_name;
+
+
+--echo #
+--echo # Test table locking and read-before-write checks.
+--echo #
+create table t17 (pk varchar(12) primary key, col1 varchar(12)) engine=rocksdb;
+insert into t17 values ('row1', 'val1');
+
+--error ER_DUP_ENTRY
+insert into t17 values ('row1', 'val1-try2');
+--error ER_DUP_ENTRY
+insert into t17 values ('ROW1', 'val1-try2');
+
+insert into t17 values ('row2', 'val2');
+insert into t17 values ('row3', 'val3');
+
+--echo # This is ok
+update t17 set pk='row4' where pk='row1';
+
+--echo # This will try to overwrite another row:
+--error ER_DUP_ENTRY
+update t17 set pk='row3' where pk='row2';
+
+select * from t17;
+
+--echo #
+--echo # Locking tests
+--echo #
+
+connect (con1,localhost,root,,);
+
+--echo # First, make sure there's no locking when transactions update different rows
+connection con1;
+set autocommit=0;
+update t17 set col1='UPD1' where pk='row2';
+
+connection default;
+update t17 set col1='UPD2' where pk='row3';
+
+connection con1;
+commit;
+
+connection default;
+select * from t17;
+
+--echo # Check the variable
+show variables like 'rocksdb_lock_wait_timeout';
+set rocksdb_lock_wait_timeout=2; # seconds
+show variables like 'rocksdb_lock_wait_timeout';
+
+--echo # Try updating the same row from two transactions
+connection con1;
+begin;
+update t17 set col1='UPD2-AA' where pk='row2';
+
+connection default;
+--error ER_LOCK_WAIT_TIMEOUT
+update t17 set col1='UPD2-BB' where pk='row2';
+
+set rocksdb_lock_wait_timeout=1000; # seconds
+--send
+ update t17 set col1='UPD2-CC' where pk='row2';
+
+connection con1;
+rollback;
+
+connection default;
+reap;
+select * from t17 where pk='row2';
+
+drop table t17;
+
+disconnect con1;
+--echo #
+--echo # MDEV-4035: RocksDB: SELECT produces different results inside a transaction (read is not repeatable)
+--echo #
+--enable_connect_log
+
+create table t18 (pk int primary key, i int) engine=RocksDB;
+begin;
+select * from t18;
+select * from t18 where pk = 1;
+
+--connect (con1,localhost,root,,)
+insert into t18 values (1,100);
+
+--connection default
+select * from t18;
+select * from t18 where pk = 1;
+commit;
+
+drop table t18;
+
+--echo #
+--echo # MDEV-4036: RocksDB: INSERT .. ON DUPLICATE KEY UPDATE does not work, produces ER_DUP_KEY
+--echo #
+create table t19 (pk int primary key, i int) engine=RocksDB;
+insert into t19 values (1,1);
+insert into t19 values (1,100) on duplicate key update i = 102;
+select * from t19;
+drop table t19;
+
+--echo # MDEV-4037: RocksDB: REPLACE doesn't work, produces ER_DUP_KEY
+create table t20 (pk int primary key, i int) engine=RocksDB;
+insert into t20 values (1,1);
+replace into t20 values (1,100);
+select * from t20;
+drop table t20;
+
+--echo #
+--echo # MDEV-4041: Server crashes in Primary_key_comparator::get_hashnr on INSERT
+--echo #
+create table t21 (v varbinary(16) primary key, i int) engine=RocksDB;
+insert into t21 values ('a',1);
+select * from t21;
+drop table t21;
+
+--echo #
+--echo # MDEV-4047: RocksDB: Assertion `0' fails in Protocol::end_statement() on multi-table INSERT IGNORE
+--echo #
+
+CREATE TABLE t22 (a int primary key) ENGINE=RocksDB;
+INSERT INTO t22 VALUES (1),(2);
+CREATE TABLE t23 (b int primary key) ENGINE=RocksDB;
+INSERT INTO t23 SELECT * FROM t22;
+DELETE IGNORE t22.*, t23.* FROM t22, t23 WHERE b < a;
+DROP TABLE t22,t23;
+
+--echo #
+--echo # MDEV-4046: RocksDB: Multi-table DELETE locks itself and ends with ER_LOCK_WAIT_TIMEOUT
+--echo #
+CREATE TABLE t24 (pk int primary key) ENGINE=RocksDB;
+INSERT INTO t24 VALUES (1),(2);
+
+CREATE TABLE t25 LIKE t24;
+INSERT INTO t25 SELECT * FROM t24;
+
+DELETE t25.* FROM t24, t25;
+DROP TABLE t24,t25;
+
+--echo #
+--echo # MDEV-4044: RocksDB: UPDATE or DELETE with ORDER BY locks itself
+--echo #
+create table t26 (pk int primary key, c char(1)) engine=RocksDB;
+insert into t26 values (1,'a'),(2,'b');
+update t26 set c = 'x' order by pk limit 1;
+delete from t26 order by pk limit 1;
+select * from t26;
+drop table t26;
+
+
+--echo #
+--echo # Test whether SELECT ... FOR UPDATE puts locks
+--echo #
+create table t27(pk varchar(10) primary key, col1 varchar(20)) engine=RocksDB;
+insert into t27 values
+ ('row1', 'row1data'),
+ ('row2', 'row2data'),
+ ('row3', 'row3data');
+
+connection con1;
+begin;
+select * from t27 where pk='row3' for update;
+
+connection default;
+set rocksdb_lock_wait_timeout=1;
+--error ER_LOCK_WAIT_TIMEOUT
+update t27 set col1='row2-modified' where pk='row3';
+
+connection con1;
+rollback;
+connection default;
+disconnect con1;
+
+drop table t27;
+
+--echo #
+--echo # MDEV-4060: RocksDB: Assertion `! trx->batch' fails in
+--echo #
+create table t28 (pk int primary key, a int) engine=RocksDB;
+insert into t28 values (1,10),(2,20);
+begin;
+update t28 set a = 100 where pk = 3;
+rollback;
+select * from t28;
+drop table t28;
+
+
+--echo #
+--echo # Secondary indexes
+--echo #
+create table t30 (
+ pk varchar(16) not null primary key,
+ key1 varchar(16) not null,
+ col1 varchar(16) not null,
+ key(key1)
+) engine=rocksdb;
+
+insert into t30 values ('row1', 'row1-key', 'row1-data');
+insert into t30 values ('row2', 'row2-key', 'row2-data');
+insert into t30 values ('row3', 'row3-key', 'row3-data');
+
+--replace_column 9 #
+explain
+select * from t30 where key1='row2-key';
+select * from t30 where key1='row2-key';
+
+--replace_column 9 #
+explain
+select * from t30 where key1='row1';
+--echo # This will produce nothing:
+select * from t30 where key1='row1';
+
+--replace_column 9 #
+explain
+select key1 from t30;
+select key1 from t30;
+
+--echo # Create a duplicate record
+insert into t30 values ('row2a', 'row2-key', 'row2a-data');
+
+--echo # Can we see it?
+select * from t30 where key1='row2-key';
+
+delete from t30 where pk='row2';
+select * from t30 where key1='row2-key';
+
+--echo #
+--echo # Range scans on secondary index
+--echo #
+delete from t30;
+insert into t30 values
+ ('row1', 'row1-key', 'row1-data'),
+ ('row2', 'row2-key', 'row2-data'),
+ ('row3', 'row3-key', 'row3-data'),
+ ('row4', 'row4-key', 'row4-data'),
+ ('row5', 'row5-key', 'row5-data');
+
+--replace_column 9 #
+explain
+select * from t30 where key1 <='row3-key';
+select * from t30 where key1 <='row3-key';
+
+--replace_column 9 #
+explain
+select * from t30 where key1 between 'row2-key' and 'row4-key';
+select * from t30 where key1 between 'row2-key' and 'row4-key';
+
+--replace_column 9 #
+explain
+select * from t30 where key1 in ('row2-key','row4-key');
+select * from t30 where key1 in ('row2-key','row4-key');
+
+--replace_column 9 #
+explain
+select key1 from t30 where key1 in ('row2-key','row4-key');
+select key1 from t30 where key1 in ('row2-key','row4-key');
+
+--replace_column 9 #
+explain
+select * from t30 where key1 > 'row1-key' and key1 < 'row4-key';
+select * from t30 where key1 > 'row1-key' and key1 < 'row4-key';
+
+--replace_column 9 #
+explain
+select * from t30 order by key1 limit 3;
+select * from t30 order by key1 limit 3;
+
+--replace_column 9 #
+explain
+select * from t30 order by key1 desc limit 3;
+select * from t30 order by key1 desc limit 3;
+
+--echo #
+--echo # Range scans on primary key
+--echo #
+--replace_column 9 #
+explain
+select * from t30 where pk <='row3';
+select * from t30 where pk <='row3';
+
+--replace_column 9 #
+explain
+select * from t30 where pk between 'row2' and 'row4';
+select * from t30 where pk between 'row2' and 'row4';
+
+--replace_column 9 #
+explain
+select * from t30 where pk in ('row2','row4');
+select * from t30 where pk in ('row2','row4');
+
+--replace_column 9 #
+explain
+select * from t30 order by pk limit 3;
+select * from t30 order by pk limit 3;
+
+drop table t30;
+
+
+--echo #
+--echo # MDEV-3841: RocksDB: Reading by PK prefix does not work
+--echo #
+create table t31 (i int, j int, k int, primary key(i,j,k)) engine=RocksDB;
+insert into t31 values (1,10,100),(2,20,200);
+select * from t31 where i = 1;
+select * from t31 where j = 10;
+select * from t31 where k = 100;
+select * from t31 where i = 1 and j = 10;
+select * from t31 where i = 1 and k = 100;
+select * from t31 where j = 10 and k = 100;
+select * from t31 where i = 1 and j = 10 and k = 100;
+drop table t31;
+
+--echo #
+--echo # MDEV-4055: RocksDB: UPDATE/DELETE by a multi-part PK does not work
+--echo #
+create table t32 (i int, j int, k int, primary key(i,j,k), a varchar(8)) engine=RocksDB;
+insert into t32 values
+ (1,10,100,''),
+ (2,20,200,'');
+select * from t32 where i = 1 and j = 10 and k = 100;
+update t32 set a = 'updated' where i = 1 and j = 10 and k = 100;
+select * from t32;
+drop table t32;
+
+--echo #
+--echo # MDEV-3841: RocksDB: Assertion `0' fails in ha_rocksdb::index_read_map on range select with ORDER BY .. DESC
+--echo #
+CREATE TABLE t33 (pk INT PRIMARY KEY, a CHAR(1)) ENGINE=RocksDB;
+INSERT INTO t33 VALUES (1,'a'),(2,'b');
+SELECT * FROM t33 WHERE pk <= 10 ORDER BY pk DESC;
+DROP TABLE t33;
+
+--echo #
+--echo # MDEV-4081: RocksDB throws error 122 on an attempt to create a table with unique index
+--echo #
+#--error ER_GET_ERRMSG
+--echo # Unique indexes can be created, but uniqueness won't be enforced
+create table t33 (pk int primary key, u int, unique index(u)) engine=RocksDB;
+drop table t33;
+
+--echo #
+--echo # MDEV-4077: RocksDB: Wrong result (duplicate row) on select with range
+--echo #
+CREATE TABLE t34 (pk INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t34 VALUES (10),(11);
+SELECT pk FROM t34 WHERE pk > 5 AND pk < 15;
+SELECT pk FROM t34 WHERE pk BETWEEN 5 AND 15;
+SELECT pk FROM t34 WHERE pk > 5;
+SELECT pk FROM t34 WHERE pk < 15;
+drop table t34;
+
+--echo #
+--echo # MDEV-4086: RocksDB does not allow a query with multi-part pk and index and ORDER BY .. DEC
+--echo #
+create table t35 (a int, b int, c int, d int, e int, primary key (a,b,c), key (a,c,d,e)) engine=RocksDB;
+insert into t35 values (1,1,1,1,1),(2,2,2,2,2);
+select * from t35 where a = 1 and c = 1 and d = 1 order by e desc;
+drop table t35;
+
+--echo #
+--echo # MDEV-4084: RocksDB: Wrong result on IN subquery with index
+--echo #
+CREATE TABLE t36 (pk INT PRIMARY KEY, a INT, KEY(a)) ENGINE=RocksDB;
+INSERT INTO t36 VALUES (1,10),(2,20);
+SELECT 3 IN ( SELECT a FROM t36 );
+drop table t36;
+
+--echo #
+--echo # MDEV-4084: RocksDB: Wrong result on IN subquery with index
+--echo #
+CREATE TABLE t37 (pk INT PRIMARY KEY, a INT, b CHAR(1), KEY(a), KEY(a,b))
+ ENGINE=RocksDB;
+INSERT INTO t37 VALUES (1,10,'x'), (2,20,'y');
+SELECT MAX(a) FROM t37 WHERE a < 100;
+DROP TABLE t37;
+
+--echo #
+--echo # MDEV-4090: RocksDB: Wrong result (duplicate rows) on range access with secondary key and ORDER BY DESC
+--echo #
+CREATE TABLE t38 (pk INT PRIMARY KEY, i INT, KEY(i)) ENGINE=RocksDB;
+INSERT INTO t38 VALUES (1,10), (2,20);
+SELECT i FROM t38 WHERE i NOT IN (8) ORDER BY i DESC;
+drop table t38;
+
+--echo #
+--echo # MDEV-4092: RocksDB: Assertion `in_table(pa, a_len)' fails in Rdb_key_def::cmp_full_keys
+--echo # with a multi-part key and ORDER BY .. DESC
+--echo #
+CREATE TABLE t40 (pk1 INT PRIMARY KEY, a INT, b VARCHAR(1), KEY(b,a)) ENGINE=RocksDB;
+INSERT INTO t40 VALUES (1, 7,'x'),(2,8,'y');
+
+CREATE TABLE t41 (pk2 INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t41 VALUES (1),(2);
+
+SELECT * FROM t40, t41 WHERE pk1 = pk2 AND b = 'o' ORDER BY a DESC;
+DROP TABLE t40,t41;
+
+--echo #
+--echo # MDEV-4093: RocksDB: IN subquery by secondary key with NULL among values returns true instead of NULL
+--echo #
+CREATE TABLE t42 (pk INT PRIMARY KEY, a INT, KEY(a)) ENGINE=RocksDB;
+INSERT INTO t42 VALUES (1, NULL),(2, 8);
+SELECT ( 3 ) NOT IN ( SELECT a FROM t42 );
+DROP TABLE t42;
+
+--echo #
+--echo # MDEV-4094: RocksDB: Wrong result on SELECT and ER_KEY_NOT_FOUND on
+--echo # DELETE with search by NULL-able secondary key ...
+--echo #
+CREATE TABLE t43 (pk INT PRIMARY KEY, a INT, b CHAR(1), KEY(a)) ENGINE=RocksDB;
+INSERT INTO t43 VALUES (1,8,'g'),(2,9,'x');
+UPDATE t43 SET pk = 10 WHERE a = 8;
+REPLACE INTO t43 ( a ) VALUES ( 8 );
+REPLACE INTO t43 ( b ) VALUES ( 'y' );
+SELECT * FROM t43 WHERE a = 8;
+DELETE FROM t43 WHERE a = 8;
+DROP TABLE t43;
+
+--echo #
+--echo # Basic AUTO_INCREMENT tests
+--echo #
+create table t44(pk int primary key auto_increment, col1 varchar(12)) engine=rocksdb;
+insert into t44 (col1) values ('row1');
+insert into t44 (col1) values ('row2');
+insert into t44 (col1) values ('row3');
+select * from t44;
+drop table t44;
+
+--echo #
+--echo # ALTER TABLE tests
+--echo #
+create table t45 (pk int primary key, col1 varchar(12)) engine=rocksdb;
+insert into t45 values (1, 'row1');
+insert into t45 values (2, 'row2');
+alter table t45 rename t46;
+select * from t46;
+drop table t46;
+--error ER_BAD_TABLE_ERROR
+drop table t45;
+
+
+--echo #
+--echo # Check Bulk loading
+--echo # Bulk loading used to overwrite existing data
+--echo # Now it fails if there is data overlap with what
+--echo # already exists
+--echo #
+# We exclude rocksdb_max_open_files here because it value is dependent on
+# the value of the servers open_file_limit and is expected to be different
+# across distros and installs
+
+--replace_regex /[a-f0-9]{40}/#/
+show variables
+where
+ variable_name like 'rocksdb%' and
+ variable_name not like 'rocksdb_max_open_files' and
+ variable_name not like 'rocksdb_supported_compression_types';
+
+create table t47 (pk int primary key, col1 varchar(12)) engine=rocksdb;
+insert into t47 values (1, 'row1');
+insert into t47 values (2, 'row2');
+set rocksdb_bulk_load=1;
+insert into t47 values (3, 'row3'),(4, 'row4');
+set rocksdb_bulk_load=0;
+# Check concurrent bulk loading
+--connect (con1,localhost,root,,)
+set rocksdb_bulk_load=1;
+insert into t47 values (10, 'row10'),(11, 'row11');
+--connection default
+set rocksdb_bulk_load=1;
+insert into t47 values (100, 'row100'),(101, 'row101');
+--disconnect con1
+--connection default
+set rocksdb_bulk_load=0;
+--disable_query_log
+let $wait_condition = select count(*) = 8 as c from t47;
+--source include/wait_condition.inc
+--enable_query_log
+select * from t47;
+drop table t47;
+
+--echo #
+--echo # Fix TRUNCATE over empty table (transaction is committed when it wasn't
+--echo # started)
+--echo #
+create table t48(pk int primary key auto_increment, col1 varchar(12)) engine=rocksdb;
+set autocommit=0;
+#--error ER_ILLEGAL_HA
+truncate table t48;
+set autocommit=1;
+drop table t48;
+
+--echo #
+--echo # MDEV-4059: RocksDB: query waiting for a lock cannot be killed until query timeout exceeded
+--echo #
+--enable_connect_log
+
+create table t49 (pk int primary key, a int) engine=RocksDB;
+insert into t49 values (1,10),(2,20);
+begin;
+update t49 set a = 100 where pk = 1;
+
+--connect (con1,localhost,root,,)
+--let $con1_id = `SELECT CONNECTION_ID()`
+set rocksdb_lock_wait_timeout=60;
+set @var1= to_seconds(now());
+send update t49 set a = 1000 where pk = 1;
+
+--connect (con2,localhost,root,,)
+--echo kill query \$con1_id;
+--disable_query_log
+# If we immeditely kill the query - internally the condition broadcast can
+# occur before the lock is waiting on the condition, thus the broadcast call
+# is lost. Sleep 1 second to avoid this condition.
+--sleep 1
+eval kill query $con1_id;
+--enable_query_log
+--connection con1
+--error ER_QUERY_INTERRUPTED
+--reap
+set @var2= to_seconds(now());
+
+# We expect the time to kill query in con1 should be below
+# rocksdb_lock_wait_timeout (60).
+select if ((@var2 - @var1) < 60, "passed", (@var2 - @var1)) as 'result';
+
+--connection default
+--disconnect con1
+
+commit;
+drop table t49;
+
+--echo #
+--echo # Index-only tests for INT-based columns
+--echo #
+create table t1 (pk int primary key, key1 int, col1 int, key(key1)) engine=rocksdb;
+insert into t1 values (1,1,1);
+insert into t1 values (2,2,2);
+insert into t1 values (-5,-5,-5);
+--echo # INT column uses index-only:
+--replace_column 9 #
+explain
+select key1 from t1 where key1=2;
+select key1 from t1 where key1=2;
+select key1 from t1 where key1=-5;
+drop table t1;
+
+
+create table t2 (pk int primary key, key1 int unsigned, col1 int, key(key1)) engine=rocksdb;
+insert into t2 values (1,1,1), (2,2,2);
+--echo # INT UNSIGNED column uses index-only:
+--replace_column 9 #
+explain
+select key1 from t2 where key1=2;
+select key1 from t2 where key1=2;
+drop table t2;
+
+
+create table t3 (pk bigint primary key, key1 bigint, col1 int, key(key1)) engine=rocksdb;
+insert into t3 values (1,1,1), (2,2,2);
+--echo # BIGINT uses index-only:
+--replace_column 9 #
+explain
+select key1 from t3 where key1=2;
+select key1 from t3 where key1=2;
+drop table t3;
+
+--echo #
+--echo # Index-only reads for string columns
+--echo #
+create table t1 (
+ pk int primary key,
+ key1 char(10) character set binary,
+ col1 int,
+ key (key1)
+) engine=rocksdb;
+insert into t1 values(1, 'one',11), (2,'two',22);
+--replace_column 9 #
+explain
+select key1 from t1 where key1='one';
+--echo # The following will produce no rows. This looks like a bug,
+--echo # but it is actually correct behavior. Binary strings are end-padded
+--echo # with \0 character (and not space). Comparison does not ignore
+--echo # the tail of \0.
+select key1 from t1 where key1='one';
+--replace_column 9 #
+explain
+select hex(key1) from t1 where key1='one\0\0\0\0\0\0\0';
+select hex(key1) from t1 where key1='one\0\0\0\0\0\0\0';
+drop table t1;
+
+
+create table t2 (
+ pk int primary key,
+ key1 char(10) collate latin1_bin,
+ col1 int,
+ key (key1)
+) engine=rocksdb;
+insert into t2 values(1, 'one',11), (2,'two',22);
+--replace_column 9 #
+explain
+select key1 from t2 where key1='one';
+select key1 from t2 where key1='one';
+drop table t2;
+
+
+create table t3 (
+ pk int primary key,
+ key1 char(10) collate utf8_bin,
+ col1 int,
+ key (key1)
+) engine=rocksdb;
+insert into t3 values(1, 'one',11), (2,'two',22);
+--replace_column 9 #
+explain
+select key1 from t3 where key1='one';
+select key1 from t3 where key1='one';
+drop table t3;
+
+
+--echo # a VARCHAR column
+create table t4 (
+ pk int primary key,
+ key1 varchar(10) collate latin1_bin,
+ key(key1)
+) engine=rocksdb;
+insert into t4 values(1, 'one'), (2,'two'),(3,'threee'),(55,'fifty-five');
+
+--replace_column 9 #
+explain
+select key1 from t4 where key1='two';
+select key1 from t4 where key1='two';
+
+select key1 from t4 where key1='fifty-five';
+
+--replace_column 9 #
+explain
+select key1 from t4 where key1 between 's' and 'u';
+select key1 from t4 where key1 between 's' and 'u';
+
+drop table t4;
+
+--echo #
+--echo # MDEV-4305: RocksDB: Assertion `((keypart_map + 1) & keypart_map) == 0' fails in calculate_key_len
+--echo #
+CREATE TABLE t1 (pk1 INT, pk2 CHAR(32), i INT, PRIMARY KEY(pk1,pk2), KEY(i)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1,'test1',6),(2,'test2',8);
+SELECT * FROM t1 WHERE i != 3 OR pk1 > 9;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-4298: RocksDB: Assertion `thd->is_error() || kill_errno' fails in ha_rows filesort
+--echo #
+call mtr.add_suppression("Sort aborted");
+CREATE TABLE t1 (pk INT PRIMARY KEY, i INT, KEY(i)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1,1),(2,2);
+BEGIN;
+UPDATE t1 SET i = 100;
+
+--connect (con1,localhost,root,,test)
+--error ER_LOCK_WAIT_TIMEOUT
+DELETE IGNORE FROM t1 ORDER BY i;
+--disconnect con1
+
+--connection default
+COMMIT;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-4324: RocksDB: Valgrind "Use of uninitialised value" warnings on inserting value into varchar field
+--echo # (testcase only)
+--echo #
+CREATE TABLE t1 (pk INT PRIMARY KEY, c VARCHAR(4)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1,'foo'), (2,'bar');
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-4304: RocksDB: Index-only scan by a field with utf8_bin collation returns garbage symbols
+--echo #
+CREATE TABLE t1 (pk INT PRIMARY KEY, c1 CHAR(1), c2 CHAR(1), KEY(c1)) ENGINE=RocksDB CHARSET utf8 COLLATE utf8_bin;
+INSERT INTO t1 VALUES (1,'h','h');
+SELECT * FROM t1;
+SELECT c1 FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-4300: RocksDB: Server crashes in inline_mysql_mutex_lock on SELECT .. FOR UPDATE
+--echo #
+CREATE TABLE t2 (pk INT PRIMARY KEY, i INT, KEY (i)) ENGINE=RocksDB;
+INSERT INTO t2 VALUES (1,4),(2,5);
+SELECT 1 FROM t2 WHERE i < 0 FOR UPDATE;
+DROP TABLE t2;
+
+--echo #
+--echo # MDEV-4301: RocksDB: Assertion `pack_info != __null' fails in Rdb_key_def::unpack_record
+--echo #
+CREATE TABLE t1 (pk INT PRIMARY KEY, i INT, c CHAR(1), KEY(c,i)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1,4,'d'),(2,8,'e');
+SELECT MAX( pk ) FROM t1 WHERE i = 105 AND c = 'h';
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-4337: RocksDB: Inconsistent results comparing a char field with an int field
+--echo #
+create table t1 (c char(1), i int, primary key(c), key(i)) engine=RocksDB;
+insert into t1 values ('2',2),('6',6);
+select * from t1 where c = i;
+select * from t1 ignore index (i) where c = i;
+drop table t1;
+
+
+--echo #
+--echo # Test statement rollback inside a transaction
+--echo #
+create table t1 (pk varchar(12) primary key) engine=rocksdb;
+insert into t1 values ('old-val1'),('old-val2');
+
+create table t2 (pk varchar(12) primary key) engine=rocksdb;
+insert into t2 values ('new-val2'),('old-val1');
+
+begin;
+insert into t1 values ('new-val1');
+--error ER_DUP_ENTRY
+insert into t1 select * from t2;
+commit;
+
+select * from t1;
+drop table t1, t2;
+
+--echo #
+--echo # MDEV-4383: RocksDB: Wrong result of DELETE .. ORDER BY .. LIMIT:
+--echo # rows that should be deleted remain in the table
+--echo #
+CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=RocksDB;
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=RocksDB;
+
+INSERT INTO t1 (pk) VALUES (NULL),(NULL);
+BEGIN;
+INSERT INTO t2 (pk) VALUES (NULL),(NULL);
+INSERT INTO t1 (pk) VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+
+--enable_info
+SELECT * FROM t1 ORDER BY pk LIMIT 9;
+DELETE FROM t1 ORDER BY pk LIMIT 9;
+SELECT * FROM t1 ORDER BY pk LIMIT 9;
+--disable_info
+
+DROP TABLE t1,t2;
+
+--echo #
+--echo # MDEV-4374: RocksDB: Valgrind warnings 'Use of uninitialised value' on
+--echo # inserting into a varchar column
+--echo #
+CREATE TABLE t1 (pk INT PRIMARY KEY, a VARCHAR(32)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
+DROP TABLE t1;
+
+
+--echo #
+--echo # MDEV-4061: RocksDB: Changes from an interrupted query are still applied
+--echo #
+
+--enable_connect_log
+
+create table t1 (pk int primary key, a int) engine=RocksDB;
+insert into t1 values (1,10),(2,20);
+
+--let $con_id = `select connection_id()`
+
+set autocommit = 1;
+--send
+update t1 set a = sleep(100) where pk = 1;
+
+--connect (con1,localhost,root,,)
+
+let $wait_condition= select State='User sleep' from information_schema.processlist where id=$con_id/* or srv_id=$con_id*/;
+--source include/wait_condition.inc
+
+--echo kill query \$con_id;
+--disable_query_log
+eval kill query $con_id;
+--enable_query_log
+
+--connection default
+--error ER_QUERY_INTERRUPTED
+--reap
+
+select * from t1;
+--disconnect con1
+--disable_connect_log
+drop table t1;
+
+
+--echo #
+--echo # MDEV-4099: RocksDB: Wrong results with index and range access after INSERT IGNORE or REPLACE
+--echo #
+CREATE TABLE t1 (pk INT PRIMARY KEY, a SMALLINT, b INT, KEY (a)) ENGINE=RocksDB;
+INSERT IGNORE INTO t1 VALUES (1, 157, 0), (2, 1898, -504403), (1, -14659, 0);
+SELECT * FROM t1;
+SELECT pk FROM t1;
+SELECT * FROM t1 WHERE a != 97;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Test @@rocksdb_max_row_locks
+--echo #
+CREATE TABLE t1 (pk INT PRIMARY KEY, a int) ENGINE=RocksDB;
+set @a=-1;
+insert into t1 select (@a:=@a+1), 1234 from information_schema.session_variables limit 100;
+set @tmp1= @@rocksdb_max_row_locks;
+set rocksdb_max_row_locks= 20;
+--error ER_GET_ERRMSG
+update t1 set a=a+10;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Test AUTO_INCREMENT behavior problem,
+--echo # "explicit insert into an auto-inc column is not noticed by RocksDB"
+--echo #
+create table t1 (i int primary key auto_increment) engine=RocksDB;
+
+insert into t1 values (null);
+insert into t1 values (null);
+select * from t1;
+drop table t1;
+
+create table t2 (i int primary key auto_increment) engine=RocksDB;
+
+insert into t2 values (1);
+select * from t2;
+
+--echo # this fails (ie. used to fail), RocksDB engine did not notice use of '1' above
+insert into t2 values (null);
+select * from t2;
+
+--echo # but then this succeeds, so previous statement must have incremented next number counter
+insert into t2 values (null);
+select * from t2;
+drop table t2;
+
+--echo #
+--echo # Fix Issue#2: AUTO_INCREMENT value doesn't survive server shutdown
+--echo #
+create table t1 (i int primary key auto_increment) engine=RocksDB;
+
+insert into t1 values (null);
+insert into t1 values (null);
+
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
+
+--source include/restart_mysqld.inc
+
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+
+insert into t1 values (null);
+select * from t1;
+
+drop table t1;
+
+--echo #
+--echo # Fix Issue #3: SHOW TABLE STATUS shows Auto_increment=0
+--echo #
+create table t1 (i int primary key auto_increment) engine=RocksDB;
+
+insert into t1 values (null),(null);
+--replace_column 7 # 12 # 13 #
+show table status like 't1';
+drop table t1;
+
+--echo #
+--echo # Fix Issue #4: Crash when using pseudo-unique keys
+--echo #
+CREATE TABLE t1 (
+ i INT,
+ t TINYINT,
+ s SMALLINT,
+ m MEDIUMINT,
+ b BIGINT,
+ pk MEDIUMINT AUTO_INCREMENT PRIMARY KEY,
+ UNIQUE KEY b_t (b,t)
+) ENGINE=rocksdb;
+
+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;
+DROP TABLE t1;
+
+--echo #
+--echo # Fix issue #5: Transaction rollback doesn't undo all changes.
+--echo #
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t1 (id int auto_increment primary key, value int) engine=rocksdb;
+
+set autocommit=0;
+begin;
+set @a:=0;
+insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4;
+insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4;
+insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4;
+rollback;
+select count(*) from t1;
+
+set autocommit=1;
+drop table t0, t1;
+
+--echo #
+--echo # Check status variables
+--echo # NOTE: We exclude rocksdb_num_get_for_update_calls because it's a debug only status var
+--echo #
+--replace_column 2 #
+show status where variable_name like 'rocksdb%' and variable_name not like '%num_get_for_update%';
+
+select VARIABLE_NAME from INFORMATION_SCHEMA.global_status where VARIABLE_NAME LIKE 'rocksdb%' and VARIABLE_NAME NOT LIKE '%num_get_for_update%';
+--echo # RocksDB-SE's status variables are global internally
+--echo # but they are shown as both session and global, like InnoDB's status vars.
+select VARIABLE_NAME from INFORMATION_SCHEMA.session_status where VARIABLE_NAME LIKE 'rocksdb%' and VARIABLE_NAME NOT LIKE '%num_get_for_update%';
+
+
+--echo #
+--echo # Fix issue #9: HA_ERR_INTERNAL_ERROR when running linkbench
+--echo #
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t1 (
+ pk int primary key,
+ col1 varchar(255),
+ key(col1)
+) engine=rocksdb;
+insert into t1 select a, repeat('123456789ABCDEF-', 15) from t0;
+select * from t1 where pk=3;
+drop table t0, t1;
+
+--echo #
+--echo # Fix issue #10: Segfault in Rdb_key_def::get_primary_key_tuple
+--echo #
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+CREATE TABLE t1 (
+ id1 bigint(20) unsigned NOT NULL DEFAULT '0',
+ id2 bigint(20) unsigned NOT NULL DEFAULT '0',
+ link_type bigint(20) unsigned NOT NULL DEFAULT '0',
+ visibility tinyint(3) NOT NULL DEFAULT '0',
+ data varchar(255) NOT NULL DEFAULT '',
+ time bigint(20) unsigned NOT NULL DEFAULT '0',
+ version int(11) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (link_type,id1,id2)
+) engine=rocksdb;
+
+insert into t1 select a,a,a,1,a,a,a from t0;
+
+alter table t1 add index id1_type (id1,link_type,visibility,time,version,data);
+select * from t1 where id1 = 3;
+
+drop table t0,t1;
+
+--echo #
+--echo # Test column families
+--echo #
+
+create table t1 (
+ pk int primary key,
+ col1 int,
+ col2 int,
+ key(col1) comment 'cf3',
+ key(col2) comment 'cf4'
+) engine=rocksdb;
+
+insert into t1 values (1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5);
+
+--replace_column 9 #
+explain
+select * from t1 where col1=2;
+select * from t1 where col1=2;
+
+--replace_column 9 #
+explain
+select * from t1 where col2=3;
+select * from t1 where col2=3;
+
+select * from t1 where pk=4;
+
+drop table t1;
+
+--echo #
+--echo # Try primary key in a non-default CF:
+--echo #
+create table t1 (
+ pk int,
+ col1 int,
+ col2 int,
+ key(col1) comment 'cf3',
+ key(col2) comment 'cf4',
+ primary key (pk) comment 'cf5'
+) engine=rocksdb;
+insert into t1 values (1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5);
+
+--replace_column 9 #
+explain
+select * from t1 where col1=2;
+select * from t1 where col1=2;
+
+select * from t1 where pk=4;
+
+drop table t1;
+
+--echo #
+--echo # Issue #15: SIGSEGV from reading in blob data
+--echo #
+CREATE TABLE t1 (
+ id int not null,
+ blob_col text,
+ PRIMARY KEY (id)
+) ENGINE=ROCKSDB CHARSET=latin1;
+
+INSERT INTO t1 SET id=123, blob_col=repeat('z',64000) ON DUPLICATE KEY UPDATE blob_col=VALUES(blob_col);
+INSERT INTO t1 SET id=123, blob_col='' ON DUPLICATE KEY UPDATE blob_col=VALUES(blob_col);
+DROP TABLE t1;
+
+
+--echo #
+--echo # Issue #17: Automatic per-index column families
+--echo # (Now deprecated)
+--echo #
+--error ER_PER_INDEX_CF_DEPRECATED
+create table t1 (
+ id int not null,
+ key1 int,
+ PRIMARY KEY (id),
+ index (key1) comment '$per_index_cf'
+) engine=rocksdb;
+
+
+--echo #
+--echo # Issue #22: SELECT ... FOR UPDATE takes a long time
+--echo #
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t1 (
+ id1 int,
+ id2 int,
+ value1 int,
+ value2 int,
+ primary key(id1, id2) COMMENT 'new_column_family',
+ key(id2)
+) engine=rocksdb default charset=latin1 collate=latin1_bin;
+
+insert into t1 select A.a, B.a, 31, 1234 from t0 A, t0 B;
+
+--replace_column 9 #
+explain
+select * from t1 where id1=30 and value1=30 for update;
+
+set @var1=(select variable_value
+ from information_schema.global_status
+ where variable_name='rocksdb_number_keys_read');
+
+select * from t1 where id1=3 and value1=3 for update;
+
+set @var2=(select variable_value
+ from information_schema.global_status
+ where variable_name='rocksdb_number_keys_read');
+--echo # The following must return true (before the fix, the difference was 70):
+select if((@var2 - @var1) < 30, 1, @var2-@var1);
+
+drop table t0,t1;
+
+--echo #
+--echo # Issue #33: SELECT ... FROM rocksdb_table ORDER BY primary_key uses sorting
+--echo #
+create table t1 (id int primary key, value int) engine=rocksdb;
+insert into t1 values (1,1),(2,2),(3,3);
+--echo # The following must not use 'Using filesort':
+--replace_column 9 #
+explain select * from t1 ORDER BY id;
+drop table t1;
+
+--echo #
+--echo # Issue #26: Index-only scans for DATETIME and TIMESTAMP
+--echo #
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+--echo # Try a DATETIME column:
+create table t1 (
+ pk int auto_increment primary key,
+ kp1 datetime,
+ kp2 int,
+ col1 int,
+ key(kp1, kp2)
+) engine=rocksdb;
+insert into t1 (kp1,kp2)
+select date_add('2015-01-01 12:34:56', interval a day), a from t0;
+
+select * from t1;
+
+--echo # This must show 'Using index'
+--replace_column 9 #
+explain
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+
+--echo # Now, the same with NOT NULL column
+create table t2 (
+ pk int auto_increment primary key,
+ kp1 datetime not null,
+ kp2 int,
+ col1 int,
+ key(kp1, kp2)
+) engine=rocksdb;
+insert into t2 select * from t1;
+--echo # This must show 'Using index'
+--replace_column 9 #
+explain
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+drop table t1,t2;
+
+--echo # Try a DATE column:
+create table t1 (
+ pk int auto_increment primary key,
+ kp1 date,
+ kp2 int,
+ col1 int,
+ key(kp1, kp2)
+) engine=rocksdb;
+insert into t1 (kp1,kp2)
+select date_add('2015-01-01', interval a day), a from t0;
+
+select * from t1;
+
+--echo # This must show 'Using index'
+--replace_column 9 #
+explain
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2015-01-01' and '2015-01-05';
+
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2015-01-01' and '2015-01-05';
+
+--echo # Now, the same with NOT NULL column
+create table t2 (
+ pk int auto_increment primary key,
+ kp1 date not null,
+ kp2 int,
+ col1 int,
+ key(kp1, kp2)
+) engine=rocksdb;
+insert into t2 select * from t1;
+--echo # This must show 'Using index'
+--replace_column 9 #
+explain
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+drop table t1,t2;
+
+--echo #
+--echo # Try a TIMESTAMP column:
+--echo #
+create table t1 (
+ pk int auto_increment primary key,
+ kp1 timestamp,
+ kp2 int,
+ col1 int,
+ key(kp1, kp2)
+) engine=rocksdb;
+insert into t1 (kp1,kp2)
+select date_add('2015-01-01 12:34:56', interval a day), a from t0;
+
+select * from t1;
+
+--echo # This must show 'Using index'
+--replace_column 9 #
+explain
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+
+--echo # Now, the same with NOT NULL column
+create table t2 (
+ pk int auto_increment primary key,
+ kp1 timestamp not null,
+ kp2 int,
+ col1 int,
+ key(kp1, kp2)
+) engine=rocksdb;
+insert into t2 select * from t1;
+--echo # This must show 'Using index'
+--replace_column 9 #
+explain
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59';
+drop table t1,t2;
+
+--echo #
+--echo # Try a TIME column:
+--echo #
+create table t1 (
+ pk int auto_increment primary key,
+ kp1 time,
+ kp2 int,
+ col1 int,
+ key(kp1, kp2)
+) engine=rocksdb;
+--disable_warnings
+insert into t1 (kp1,kp2)
+select date_add('2015-01-01 09:00:00', interval a minute), a from t0;
+--enable_warnings
+
+select * from t1;
+
+--echo # This must show 'Using index'
+--replace_column 9 #
+explain
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '09:01:00' and '09:05:00';
+
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '09:01:00' and '09:05:00';
+
+--echo # Now, the same with NOT NULL column
+create table t2 (
+ pk int auto_increment primary key,
+ kp1 time not null,
+ kp2 int,
+ col1 int,
+ key(kp1, kp2)
+) engine=rocksdb;
+insert into t2 select * from t1;
+--echo # This must show 'Using index'
+--replace_column 9 #
+explain
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '09:01:00' and '09:05:00';
+
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '09:01:00' and '09:05:00';
+drop table t1,t2;
+
+--echo #
+--echo # Try a YEAR column:
+--echo #
+create table t1 (
+ pk int auto_increment primary key,
+ kp1 year,
+ kp2 int,
+ col1 int,
+ key(kp1, kp2)
+) engine=rocksdb;
+--disable_warnings
+insert into t1 (kp1,kp2) select 2015+a, a from t0;
+--enable_warnings
+
+select * from t1;
+
+--echo # This must show 'Using index'
+--replace_column 9 #
+explain
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2016' and '2020';
+
+select kp1,kp2 from t1 force index (kp1)
+where kp1 between '2016' and '2020';
+
+--echo # Now, the same with NOT NULL column
+create table t2 (
+ pk int auto_increment primary key,
+ kp1 year not null,
+ kp2 int,
+ col1 int,
+ key(kp1, kp2)
+) engine=rocksdb;
+insert into t2 select * from t1;
+--echo # This must show 'Using index'
+--replace_column 9 #
+explain
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2016' and '2020';
+
+select kp1,kp2 from t2 force index (kp1)
+where kp1 between '2016' and '2020';
+
+drop table t1,t2;
+
+--echo #
+--echo # Issue #57: Release row locks on statement errors
+--echo #
+create table t1 (id int primary key) engine=rocksdb;
+insert into t1 values (1), (2), (3);
+begin;
+insert into t1 values (4), (5), (6);
+--error ER_DUP_ENTRY
+insert into t1 values (7), (8), (2), (9);
+select * from t1;
+
+-- connect(con1,localhost,root,,)
+--connection con1
+begin;
+--error ER_LOCK_WAIT_TIMEOUT
+select * from t1 where id=4 for update;
+
+select * from t1 where id=7 for update;
+
+select * from t1 where id=9 for update;
+
+--connection default
+-- disconnect con1
+drop table t1;
+
+--echo #Index on blob column
+SET @old_mode = @@sql_mode;
+SET sql_mode = 'strict_all_tables';
+create table t1 (a int, b text, c varchar(400), Primary Key(a), Key(c, b(255))) engine=rocksdb;
+drop table t1;
+set global rocksdb_large_prefix=1;
+create table t1 (a int, b text, c varchar(400), Primary Key(a), Key(b(1255))) engine=rocksdb;
+set global rocksdb_large_prefix=0;
+insert into t1 values (1, '1abcde', '1abcde'), (2, '2abcde', '2abcde'), (3, '3abcde', '3abcde');
+select * from t1;
+--replace_column 9 #
+explain select * from t1 where b like '1%';
+--replace_column 9 #
+explain select b, a from t1 where b like '1%';
+update t1 set b= '12345' where b = '2abcde';
+select * from t1;
+drop table t1;
+# In MariaDB, the error becomes a warning:
+# --error ER_TOO_LONG_KEY
+create table t1 (a int, b text, c varchar(400), Primary Key(a), Key(b(2255))) engine=rocksdb;
+drop table t1;
+SET sql_mode = @old_mode;
+
+drop table t0;
+
+--echo #
+--echo # Fix assertion failure (attempt to overrun the key buffer) for prefix indexes
+--echo #
+
+create table t1 (
+ pk int primary key,
+ col1 varchar(100),
+ key (col1(10))
+) engine=rocksdb;
+
+insert into t1 values (1, repeat('0123456789', 9));
+
+drop table t1;
+
+--echo #
+--echo # Issue #76: Assertion `buf == table->record[0]' fails in virtual int ha_rocksdb::delete_row(const uchar*)
+--echo #
+
+CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT) ENGINE=RocksDB;
+CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT) ENGINE=RocksDB;
+
+CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW DELETE FROM t2 WHERE pk = old.pk;
+
+INSERT INTO t1 VALUES (1,1);
+REPLACE INTO t1 VALUES (1,2);
+
+SELECT * FROM t1;
+DROP TABLE t1, t2;
+
+--echo #
+--echo # Issue #99: UPDATE for table with VARCHAR pk gives "Can't find record" error
+--echo #
+create table t1(a int primary key);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t2 (
+ a varchar(32) primary key,
+ col1 int
+) engine=rocksdb;
+
+insert into t2
+select concat('v-', 100 + A.a*100 + B.a), 12345 from t1 A, t1 B;
+update t2 set a=concat('x-', a) where a between 'v-1002' and 'v-1004';
+
+drop table t1,t2;
+
+--echo #
+--echo # Issue #131: Assertion `v->cfd_->internal_comparator().Compare(start, end) <= 0' failed
+--echo #
+CREATE TABLE t2(c1 INTEGER UNSIGNED NOT NULL, c2 INTEGER NULL, c3 TINYINT, c4 SMALLINT , c5 MEDIUMINT, c6 INT, c7 BIGINT, PRIMARY KEY(c1,c6)) ENGINE=RocksDB;
+INSERT INTO t2 VALUES (1,1,1,1,1,1,1);
+SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6;
+EXPLAIN SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6;
+drop table t2;
+
+--echo #
+--echo # Issue #135: register transaction was not being called for statement
+--echo #
+--disable_warnings
+DROP DATABASE IF EXISTS test_db;
+--enable_warnings
+CREATE DATABASE test_db;
+CREATE TABLE test_db.t1(c1 INT PRIMARY KEY);
+LOCK TABLES test_db.t1 READ;
+SET AUTOCOMMIT=0;
+SELECT c1 FROM test_db.t1;
+START TRANSACTION WITH CONSISTENT SNAPSHOT, READ ONLY;
+DROP DATABASE test_db;
+
+--echo #
+--echo # Issue #143: Split rocksdb_bulk_load option into two
+--echo #
+CREATE TABLE t1 (id int primary key, value int) engine=RocksDB;
+SET unique_checks=0;
+INSERT INTO t1 VALUES(1, 1);
+INSERT INTO t1 VALUES(1, 2);
+INSERT INTO t1 VALUES(1, 3);
+SELECT * FROM t1;
+--error ER_ON_DUPLICATE_DISABLED
+REPLACE INTO t1 VALUES(4, 4);
+--error ER_ON_DUPLICATE_DISABLED
+INSERT INTO t1 VALUES(5, 5) ON DUPLICATE KEY UPDATE value=value+1;
+TRUNCATE TABLE t1;
+SET @save_rocksdb_bulk_load_size= @@rocksdb_bulk_load_size;
+SET unique_checks=1;
+SET rocksdb_commit_in_the_middle=1;
+SET rocksdb_bulk_load_size=10;
+BEGIN;
+INSERT INTO t1 (id) VALUES(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
+ (11),(12),(13),(14),(15),(16),(17),(18),(19);
+ROLLBACK;
+SELECT * FROM t1;
+INSERT INTO t1 (id) VALUES (11),(12),(13),(14),(15);
+BEGIN;
+UPDATE t1 SET value=100;
+ROLLBACK;
+SELECT * FROM t1;
+BEGIN;
+DELETE FROM t1;
+ROLLBACK;
+SELECT * FROM t1;
+SET rocksdb_commit_in_the_middle=0;
+SET rocksdb_bulk_load_size= @save_rocksdb_bulk_load_size;
+DROP TABLE t1;
+
+--echo #
+--echo # Issue #185 Assertion `BaseValid()' failed in void rocksdb::BaseDeltaIterator::Advance()
+--echo #
+CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MEMORY;
+INSERT INTO t2 VALUES (100,NULL),(150,"long varchar"),(200,"varchar"),(250,"long long long varchar");
+create TABLE t1 (a int not null, b int not null, primary key(a,b));
+INSERT INTO t1 VALUES (1,1);
+SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4));
+DROP TABLE t1, t2;
+
+--echo #
+--echo # Issue #189 ha_rocksdb::load_auto_incr_value() creates implicit snapshot and doesn't release
+--echo #
+--connect (con1,localhost,root,,)
+create table r1 (id int auto_increment primary key, value int);
+insert into r1 (id) values (null), (null), (null), (null), (null);
+connection con1;
+create table r2 like r1;
+show create table r2;
+connection default;
+begin;
+insert into r1 values (10, 1);
+commit;
+connection con1;
+begin;
+select * from r1;
+commit;
+connection default;
+drop table r1, r2;
+
+# hidden primary key
+create table r1 (id int auto_increment, value int, index i(id));
+insert into r1 (id) values (null), (null), (null), (null), (null);
+connection con1;
+create table r2 like r1;
+show create table r2;
+connection default;
+begin;
+insert into r1 values (10, 1);
+commit;
+connection con1;
+begin;
+select * from r1;
+commit;
+connection default;
+drop table r1, r2;
+
+disconnect con1;
+
+--echo #
+--echo # Issue#211 Crash on LOCK TABLES + START TRANSACTION WITH CONSISTENT SNAPSHOT
+--echo #
+CREATE TABLE t1(c1 INT);
+lock TABLE t1 read local;
+SELECT 1 FROM t1 GROUP BY TRIM(LEADING RAND()FROM'');
+set AUTOCOMMIT=0;
+start transaction with consistent snapshot;
+SELECT * FROM t1;
+COMMIT;
+UNLOCK TABLES;
+DROP TABLE t1;
+
+--echo #
+--echo # Issue#213 Crash on LOCK TABLES + partitions
+--echo #
+CREATE TABLE t1(a INT,b INT,KEY (b)) engine=rocksdb PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1(a)VALUES (20010101101010.999949);
+lock tables t1 write,t1 as t0 write,t1 as t2 write;
+SELECT a FROM t1 ORDER BY a;
+truncate t1;
+INSERT INTO t1 VALUES(X'042000200020',X'042000200020'),(X'200400200020',X'200400200020');
+UNLOCK TABLES;
+DROP TABLE t1;
+
+--echo #
+--echo # Issue#250: MyRocks/Innodb different output from query with order by on table with index and decimal type
+--echo # (the test was changed to use VARCHAR, because DECIMAL now supports index-only, and this issue
+--echo # needs a datype that doesn't support index-inly)
+--echo #
+
+CREATE TABLE t1(
+ c1 varchar(10) character set utf8 collate utf8_general_ci NOT NULL,
+ c2 varchar(10) character set utf8 collate utf8_general_ci,
+ c3 INT,
+ INDEX idx(c1,c2)
+);
+INSERT INTO t1 VALUES ('c1-val1','c2-val1',5);
+INSERT INTO t1 VALUES ('c1-val2','c2-val3',6);
+INSERT INTO t1 VALUES ('c1-val3','c2-val3',7);
+SELECT * FROM t1 force index(idx) WHERE c1 <> 'c1-val2' ORDER BY c1 DESC;
+--replace_column 9 #
+explain SELECT * FROM t1 force index(idx) WHERE c1 <> '1' ORDER BY c1 DESC;
+drop table t1;
+
+--echo #
+--echo # Issue#267: MyRocks issue with no matching min/max row and count(*)
+--echo #
+CREATE TABLE t1(c1 INT UNSIGNED, c2 INT SIGNED, INDEX idx2(c2));
+INSERT INTO t1 VALUES(1,null);
+INSERT INTO t1 VALUES(2,null);
+SELECT count(*) as total_rows, min(c2) as min_value FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # Issue#263: MyRocks auto_increment skips values if you insert a negative value
+--echo #
+# We have slightly different behavior regarding auto-increment values than
+# InnoDB, so the results of the SHOW TABLE STATUS command will be slightly
+# different. InnoDB will reserve 3 values but only use 2 of them (because
+# the user hard-coded a -1 as the second value). MyRocks will only reserve
+# the values as needed, so only 2 values will be used. This means that the
+# SHOW TABLE STATUS in InnoDB will indicate that the next auto-increment
+# value is 4 while MyRocks will show it as 3.
+CREATE TABLE t1(a INT AUTO_INCREMENT KEY);
+INSERT INTO t1 VALUES(0),(-1),(0);
+--replace_column 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+SELECT * FROM t1;
+DROP TABLE t1;
+CREATE TABLE t1(a INT AUTO_INCREMENT KEY);
+INSERT INTO t1 VALUES(0),(10),(0);
+--replace_column 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # Issue #411: Setting rocksdb_commit_in_the_middle commits transaction
+--echo # without releasing iterator
+--echo #
+
+CREATE TABLE t1 (id1 bigint(20),
+ id2 bigint(20),
+ id3 bigint(20),
+ PRIMARY KEY (id1, id2, id3))
+ DEFAULT CHARSET=latin1;
+
+CREATE TABLE t2 (id1 bigint(20),
+ id2 bigint(20),
+ PRIMARY KEY (id1, id2))
+ DEFAULT CHARSET=latin1;
+
+
+set rocksdb_commit_in_the_middle=1;
+SET @save_rocksdb_bulk_load_size= @@rocksdb_bulk_load_size;
+set rocksdb_bulk_load_size = 100;
+
+--disable_query_log
+let $j = 10000;
+while ($j)
+{
+ --eval insert into t1 (id1, id2, id3) values (0, $j, 0);
+ --eval insert into t2 (id1, id2) values (0, $j);
+ dec $j;
+}
+--enable_query_log
+
+DELETE t2, t1 FROM t2 LEFT JOIN t1 ON t2.id2 = t1.id2 AND t2.id1 = t1.id1 WHERE t2.id1 = 0;
+
+SET rocksdb_bulk_load_size= @save_rocksdb_bulk_load_size;
+SET rocksdb_commit_in_the_middle=0;
+DROP TABLE t1, t2;
+
+--echo #
+--echo # MDEV-21831: Assertion `length == pack_length()' failed in Field_inet6::sort_string upon
+--echo # INSERT into RocksDB table
+--echo #
+
+CREATE TABLE t1 (a INET6 NOT NULL, KEY (a)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES ('41::1'),('61::1');
+DROP TABLE t1;
+
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_options-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_options-master.opt
new file mode 100644
index 00000000..95d819ee
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_options-master.opt
@@ -0,0 +1 @@
+--rocksdb_default_cf_options="write_buffer_size=12m;target_file_size_base=1m;max_bytes_for_level_multiplier=10"
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_options-master.sh b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_options-master.sh
new file mode 100755
index 00000000..9381de1f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_options-master.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+cat > $MYSQL_TMP_DIR/cf_configs.cnf <<EOL
+
+EOL
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_options.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_options.test
new file mode 100644
index 00000000..9482c217
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_options.test
@@ -0,0 +1,75 @@
+--source include/have_rocksdb.inc
+
+let MYSQLD_DATADIR= `SELECT @@datadir`;
+let file= $MYSQL_TMP_DIR/cf_configs.cnf;
+
+# create new column families with no configs in cf_configs.cnf file
+
+create table t1 (a int,
+ primary key (a) comment 'cf1') engine=rocksdb;
+create table t2 (a int,
+ primary key (a) comment 'cf2') engine=rocksdb;
+create table t3 (a int,
+ primary key (a) comment 'z') engine=rocksdb;
+
+insert into t1 values (1);
+insert into t2 values (2);
+insert into t3 values (2);
+
+# restart with new column families in DB
+
+--source include/restart_mysqld.inc
+
+# check column family options in log -- should be all default settings
+
+--echo
+--echo Default options for all column families:
+--echo
+select cf_name, option_type, value
+ from information_schema.rocksdb_cf_options
+ where option_type in ('WRITE_BUFFER_SIZE',
+ 'TARGET_FILE_SIZE_BASE',
+ 'MAX_BYTES_FOR_LEVEL_MULTIPLIER')
+ order by cf_name, option_type;
+# restart with cf configs for cf1 and cf2
+
+--let $restart_parameters=--rocksdb_override_cf_options=cf1={write_buffer_size=8m;target_file_size_base=2m};cf2={write_buffer_size=16m;max_bytes_for_level_multiplier=8};z={target_file_size_base=4m};
+--source include/restart_mysqld.inc
+
+# check column family options in log -- should reflect individual settings
+
+--echo
+--echo Individualized options for column families:
+--echo
+select cf_name, option_type, value
+ from information_schema.rocksdb_cf_options
+ where option_type in ('WRITE_BUFFER_SIZE',
+ 'TARGET_FILE_SIZE_BASE',
+ 'MAX_BYTES_FOR_LEVEL_MULTIPLIER')
+ order by cf_name, option_type;
+
+# syntax error in options (no equal sign)
+
+--exec echo "restart:--rocksdb_override_cf_options=cf1" > $_expect_file_name
+--error 1
+--source include/wait_until_connected_again.inc
+
+# invalid cf option config (no curly braces)
+
+--exec echo "restart:--rocksdb_override_cf_options=cf1=write_buffer_size=8m" > $_expect_file_name
+--error 1
+--source include/wait_until_connected_again.inc
+
+# invalid cf option config (cf listed twice)
+
+--exec echo "restart:--rocksdb_override_cf_options=cf1={write_buffer_size=8m};cf1={target_file_size_base=2m}" > $_expect_file_name
+--error 1
+--source include/wait_until_connected_again.inc
+
+# clean up
+
+--source include/restart_mysqld.inc
+
+--echo
+drop table t1,t2,t3;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_per_partition.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_per_partition.test
new file mode 100644
index 00000000..fcbd8527
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_per_partition.test
@@ -0,0 +1,513 @@
+--source include/have_rocksdb.inc
+
+--source include/have_partition.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+#
+# Create a table with multiple partitions, but in the comment don't specify
+# that per-partition based column families (CF) should be created. Expect that
+# default CF will be used and new one won't be created.
+#
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ name VARCHAR(25) NOT NULL,
+ event DATE,
+ PRIMARY KEY (`c1`, `c2`) COMMENT 'testcomment'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 4, 7),
+ PARTITION custom_p1 VALUES IN (2, 5, 8),
+ PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+
+# Expecting no results here.
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='testcomment';
+
+DROP TABLE t1;
+
+#
+# Same test case as above, only with the reverse CF. Should result in the same
+# behavior. No new CF-s created, only default one will be used.
+#
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ name VARCHAR(25) NOT NULL,
+ event DATE,
+ PRIMARY KEY (`c1`, `c2`) COMMENT 'rev:testrevcomment'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 4, 7),
+ PARTITION custom_p1 VALUES IN (2, 5, 8),
+ PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+
+# Expecting no results here.
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='rev:testrevcomment';
+
+DROP TABLE t1;
+
+#
+# Create a table with multiple partitions and request for separate CF to be
+# created per every partition. As a result we expect three different CF-s to be
+# created.
+#
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ name VARCHAR(25) NOT NULL,
+ event DATE,
+ PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=my_custom_cf;custom_p2_cfname=baz'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 4, 7),
+ PARTITION custom_p1 VALUES IN (2, 5, 8),
+ PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'my_custom_cf';
+set @@global.rocksdb_compact_cf = 'baz';
+
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='foo';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='my_custom_cf';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='baz';
+
+DROP TABLE t1;
+
+#
+# Same test case as above, only one of the partitions has "rev:" prefix. The
+# intent here is to make sure that qualifier can specify reverse CF as well.
+#
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ name VARCHAR(25) NOT NULL,
+ event DATE,
+ PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=t1-p0;custom_p1_cfname=rev:bar;custom_p2_cfname=t1-p2'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 4, 7),
+ PARTITION custom_p1 VALUES IN (2, 5, 8),
+ PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+
+set @@global.rocksdb_compact_cf = 't1-p0';
+set @@global.rocksdb_compact_cf = 'rev:bar';
+set @@global.rocksdb_compact_cf = 't1-p2';
+
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='t1-p0';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='rev:bar';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='t1-p2';
+
+DROP TABLE t1;
+
+
+#
+# Create a table with multiple partitions and assign two partitions to the same
+# CF, third one gets a separate partition, and fourth one will belong to a
+# default one. As a result we expect two new CF-s to be created.
+#
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ name VARCHAR(25) NOT NULL,
+ event DATE,
+ PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=cf-zero;custom_p1_cfname=cf-one;custom_p2_cfname=cf-zero'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 4, 7),
+ PARTITION custom_p1 VALUES IN (2, 5, 8),
+ PARTITION custom_p2 VALUES IN (3, 6, 9),
+ PARTITION custom_p3 VALUES IN (10, 20, 30)
+);
+
+set @@global.rocksdb_compact_cf = 'cf-zero';
+set @@global.rocksdb_compact_cf = 'cf-one';
+
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='cf-zero';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='cf-one';
+
+DROP TABLE t1;
+
+#
+# Create a table with CF-s per partition and verify that ALTER TABLE + DROP
+# INDEX work for that scenario and data is persisted.
+#
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ name VARCHAR(25) NOT NULL,
+ event DATE,
+ PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 4, 7),
+ PARTITION custom_p1 VALUES IN (2, 5, 8),
+ PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+
+INSERT INTO t1 VALUES (1, 1, "one", null);
+INSERT INTO t1 VALUES (2, 2, "two", null);
+INSERT INTO t1 VALUES (3, 3, "three", null);
+INSERT INTO t1 VALUES (5, 5, "five", null);
+INSERT INTO t1 VALUES (9, 9, "nine", null);
+
+SELECT * FROM t1;
+ALTER TABLE t1 DROP PRIMARY KEY;
+SELECT * FROM t1;
+
+#
+# Verify that we can compact custom CF-s.
+#
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'bar';
+set @@global.rocksdb_compact_cf = 'baz';
+
+DROP TABLE t1;
+
+#
+# Create a table with CF-s per partition and verify that ALTER TABLE + DROP
+# INDEX + ADD INDEX work for that scenario and data is persisted and new cf_name_str
+# are created.
+#
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ name VARCHAR(25) NOT NULL,
+ event DATE,
+ PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 4, 7),
+ PARTITION custom_p1 VALUES IN (2, 5, 8),
+ PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+
+INSERT INTO t1 VALUES (1, 1, "one", null);
+INSERT INTO t1 VALUES (2, 2, "two", null);
+INSERT INTO t1 VALUES (3, 3, "three", null);
+INSERT INTO t1 VALUES (5, 5, "five", null);
+INSERT INTO t1 VALUES (9, 9, "nine", null);
+
+ALTER TABLE t1 DROP PRIMARY KEY;
+ALTER TABLE t1 ADD PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=p0_cf;custom_p1_cfname=p1_cf';
+
+set @@global.rocksdb_compact_cf = 'p0_cf';
+set @@global.rocksdb_compact_cf = 'p1_cf';
+
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='p0_cf';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='p1_cf';
+
+DROP TABLE t1;
+
+#
+# Create a table CF-s per partition, use ALTER TABLE to change the way it's
+# partitioned and verify that new CF-s will be created.
+#
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ name VARCHAR(25) NOT NULL,
+ event DATE,
+ PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 4, 7),
+ PARTITION custom_p1 VALUES IN (2, 5, 8),
+ PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+
+INSERT INTO t1 VALUES (1, 1, "one", null);
+INSERT INTO t1 VALUES (2, 2, "two", null);
+INSERT INTO t1 VALUES (3, 3, "three", null);
+INSERT INTO t1 VALUES (5, 5, "five", null);
+INSERT INTO t1 VALUES (9, 9, "nine", null);
+
+ALTER TABLE t1 PARTITION BY LIST(c1) (
+ PARTITION custom_p3 VALUES IN (1, 4, 7),
+ PARTITION custom_p4 VALUES IN (2, 5, 8, 3, 6, 9)
+);
+
+ALTER TABLE t1 DROP PRIMARY KEY;
+ALTER TABLE t1 ADD PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p3_cfname=p3_cf;custom_p4_cfname=p4_cf';
+
+set @@global.rocksdb_compact_cf = 'p3_cf';
+set @@global.rocksdb_compact_cf = 'p4_cf';
+
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='p3_cf';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='p4_cf';
+
+DROP TABLE t1;
+
+#
+# Create a table CF-s per partition, use empty qualifier name. Verify that no
+# new CF-s are created. This will also make sure that nothing gets added for
+# `custom_p2`.
+#
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ name VARCHAR(25) NOT NULL,
+ event DATE,
+ PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=;'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 4, 7),
+ PARTITION custom_p1 VALUES IN (2, 5, 8),
+ PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+
+DROP TABLE t1;
+
+#
+# Verify some basic partition related operations when using PARTITION BY LIST
+# COLUMNS on a VARBINARY column on a table with more complicated schema.
+#
+
+#
+# Verify that creating the table without COMMENT actually works.
+#
+CREATE TABLE `t2` (
+ `col1` bigint(20) NOT NULL,
+ `col2` varbinary(64) NOT NULL,
+ `col3` varbinary(256) NOT NULL,
+ `col4` bigint(20) NOT NULL,
+ `col5` mediumblob NOT NULL,
+ PRIMARY KEY (`col1`,`col2`,`col3`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ PARTITION BY LIST COLUMNS (`col2`) (
+ PARTITION custom_p0 VALUES IN (0x12345),
+ PARTITION custom_p1 VALUES IN (0x23456),
+ PARTITION custom_p2 VALUES IN (0x34567),
+ PARTITION custom_p3 VALUES IN (0x45678),
+ PARTITION custom_p4 VALUES IN (0x56789),
+ PARTITION custom_p5 VALUES IN (0x6789A),
+ PARTITION custom_p6 VALUES IN (0x789AB),
+ PARTITION custom_p7 VALUES IN (0x89ABC)
+);
+
+DROP TABLE t2;
+
+#
+# Create the same table with two custom CF-s per partition as specified in the
+# COMMENT.
+#
+CREATE TABLE `t2` (
+ `col1` bigint(20) NOT NULL,
+ `col2` varbinary(64) NOT NULL,
+ `col3` varbinary(256) NOT NULL,
+ `col4` bigint(20) NOT NULL,
+ `col5` mediumblob NOT NULL,
+ PRIMARY KEY (`col1`,`col2`,`col3`) COMMENT 'custom_p0_cfname=my_cf0;custom_p1_cfname=my_cf1'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ PARTITION BY LIST COLUMNS (`col2`) (
+ PARTITION custom_p0 VALUES IN (0x12345),
+ PARTITION custom_p1 VALUES IN (0x23456),
+ PARTITION custom_p2 VALUES IN (0x34567),
+ PARTITION custom_p3 VALUES IN (0x45678),
+ PARTITION custom_p4 VALUES IN (0x56789),
+ PARTITION custom_p5 VALUES IN (0x6789A),
+ PARTITION custom_p6 VALUES IN (0x789AB),
+ PARTITION custom_p7 VALUES IN (0x89ABC)
+);
+
+# Verify that CF-s were created earlier.
+set @@global.rocksdb_compact_cf = 'my_cf0';
+set @@global.rocksdb_compact_cf = 'my_cf1';
+
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='my_cf0';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='my_cf1';
+
+# Insert some random data.
+INSERT INTO t2 VALUES (100, 0x12345, 0x1, 1, 0x2);
+INSERT INTO t2 VALUES (200, 0x12345, 0x1, 1, 0x2);
+INSERT INTO t2 VALUES (300, 0x12345, 0x1, 1, 0x2);
+INSERT INTO t2 VALUES (100, 0x23456, 0x2, 1, 0x3);
+INSERT INTO t2 VALUES (100, 0x34567, 0x4, 1, 0x5);
+INSERT INTO t2 VALUES (400, 0x89ABC, 0x4, 1, 0x5);
+
+# Verify it's there.
+SELECT col1, HEX(col2), HEX(col3), col4, HEX(col5) FROM t2;
+
+# Verify it's being fetched from the right partition. This tests partitioning
+# functionality, but we want to make sure that by adding CF-s per partition we
+# don't regress anything.
+EXPLAIN PARTITIONS SELECT HEX(col2) FROM t2 where col2 = 0x12345;
+EXPLAIN PARTITIONS SELECT HEX(col2) FROM t2 where col2 = 0x23456;
+
+# Delete the current PK and create a new one referencing different CF-s. We
+# need to verity that new CF-s will be created and no data will be lost in
+# process.
+ALTER TABLE t2 DROP PRIMARY KEY;
+ALTER TABLE t2 ADD PRIMARY KEY (`col1`,`col2`,`col3`) COMMENT 'custom_p0_cfname=new_cf0;custom_p1_cfname=new_cf1';
+
+# Verify that new CF-s are created as well.
+set @@global.rocksdb_compact_cf = 'new_cf0';
+set @@global.rocksdb_compact_cf = 'new_cf1';
+
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='new_cf0';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='new_cf1';
+
+# Insert some more random data.
+INSERT INTO t2 VALUES (500, 0x12345, 0x5, 1, 0x2);
+INSERT INTO t2 VALUES (700, 0x23456, 0x7, 1, 0x3);
+
+# Verify that partition mappings are still intact.
+EXPLAIN PARTITIONS SELECT HEX(col2) FROM t2 where col2 = 0x12345;
+EXPLAIN PARTITIONS SELECT HEX(col2) FROM t2 where col2 = 0x23456;
+
+# Verify that no data is lost.
+SELECT col1, HEX(col2), HEX(col3), col4, HEX(col5) FROM t2;
+
+DROP TABLE t2;
+
+#
+# Create the same table with two custom CF-s per partition as specified in the
+# COMMENT. Use both the PK and SK when creating the table.
+#
+CREATE TABLE `t2` (
+ `col1` bigint(20) NOT NULL,
+ `col2` varbinary(64) NOT NULL,
+ `col3` varbinary(256) NOT NULL,
+ `col4` bigint(20) NOT NULL,
+ `col5` mediumblob NOT NULL,
+ PRIMARY KEY (`col1`,`col2`,`col3`) COMMENT 'custom_p0_cfname=test_cf0;custom_p1_cfname=test_cf1',
+ KEY (`col2`, `col4`) COMMENT 'custom_p5_cfname=test_cf5'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ PARTITION BY LIST COLUMNS (`col2`) (
+ PARTITION custom_p0 VALUES IN (0x12345),
+ PARTITION custom_p1 VALUES IN (0x23456),
+ PARTITION custom_p2 VALUES IN (0x34567),
+ PARTITION custom_p3 VALUES IN (0x45678),
+ PARTITION custom_p4 VALUES IN (0x56789),
+ PARTITION custom_p5 VALUES IN (0x6789A),
+ PARTITION custom_p6 VALUES IN (0x789AB),
+ PARTITION custom_p7 VALUES IN (0x89ABC)
+);
+
+# Verify that CF-s were created for PK.
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='test_cf0';
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='test_cf1';
+
+# Verify that CF-s were created for SK.
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='test_cf5';
+
+# Insert some random data.
+INSERT INTO t2 VALUES (100, 0x12345, 0x1, 1, 0x2);
+INSERT INTO t2 VALUES (200, 0x12345, 0x1, 1, 0x2);
+INSERT INTO t2 VALUES (300, 0x12345, 0x1, 1, 0x2);
+INSERT INTO t2 VALUES (100, 0x23456, 0x2, 1, 0x3);
+INSERT INTO t2 VALUES (100, 0x34567, 0x4, 1, 0x5);
+INSERT INTO t2 VALUES (400, 0x89ABC, 0x4, 1, 0x5);
+INSERT INTO t2 VALUES (500, 0x6789A, 0x5, 1, 0x7);
+
+# Basic verification that correct partition and key are used when searching.
+EXPLAIN PARTITIONS SELECT * FROM t2 WHERE col2 = 0x6789A AND col4 = 1;
+
+# Remove the key.
+ALTER TABLE t2 DROP KEY `col2`;
+
+# Add a new key and expect new CF to be created as well.
+ALTER TABLE t2 ADD KEY (`col3`, `col4`) COMMENT 'custom_p5_cfname=another_cf_for_p5';
+
+# Verify that CF-s were created for SK.
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='another_cf_for_p5';
+
+# Verify that correct partition and key are used when searching.
+ANALYZE TABLE t2;
+--replace_column 10 #
+EXPLAIN PARTITIONS SELECT * FROM t2 WHERE col3 = 0x4 AND col2 = 0x34567;
+
+DROP TABLE t2;
+
+#
+# Verify the same scenario as before, but with a UNIQUE KEY in addition to PK.
+#
+CREATE TABLE `t2` (
+ `col1` bigint(20) NOT NULL,
+ `col2` varbinary(64) NOT NULL,
+ `col3` varbinary(256) NOT NULL,
+ `col4` bigint(20) NOT NULL,
+ `col5` mediumblob NOT NULL,
+ PRIMARY KEY (`col1`,`col2`,`col3`) COMMENT 'custom_p0_cfname=test_cf0;custom_p1_cfname=test_cf1',
+ UNIQUE KEY (`col2`, `col4`) COMMENT 'custom_p5_cfname=unique_test_cf5'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ PARTITION BY LIST COLUMNS (`col2`) (
+ PARTITION custom_p0 VALUES IN (0x12345),
+ PARTITION custom_p1 VALUES IN (0x23456),
+ PARTITION custom_p2 VALUES IN (0x34567),
+ PARTITION custom_p3 VALUES IN (0x45678),
+ PARTITION custom_p4 VALUES IN (0x56789),
+ PARTITION custom_p5 VALUES IN (0x6789A),
+ PARTITION custom_p6 VALUES IN (0x789AB),
+ PARTITION custom_p7 VALUES IN (0x89ABC)
+);
+
+# Verify that CF-s were created for SK.
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='unique_test_cf5';
+
+INSERT INTO t2 VALUES (100, 0x12345, 0x1, 1, 0x2);
+
+--error ER_DUP_ENTRY
+INSERT INTO t2 VALUES (200, 0x12345, 0x1, 1, 0x2);
+
+--error ER_DUP_ENTRY
+INSERT INTO t2 VALUES (300, 0x12345, 0x1, 1, 0x2);
+
+INSERT INTO t2 VALUES (100, 0x23456, 0x2, 1, 0x3);
+INSERT INTO t2 VALUES (100, 0x34567, 0x4, 1, 0x5);
+INSERT INTO t2 VALUES (400, 0x89ABC, 0x4, 1, 0x5);
+INSERT INTO t2 VALUES (500, 0x6789A, 0x5, 1, 0x7);
+
+DROP TABLE t2;
+
+#
+# Verify that both partitioned and non-partitioned table can share a CF.
+#
+CREATE TABLE t1 (
+ `a` int,
+ PRIMARY KEY (a) COMMENT "sharedcf"
+) ENGINE=ROCKSDB;
+
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='sharedcf';
+
+#
+# We expect this to succeed.
+#
+CREATE TABLE t2 (
+ `a` INT,
+ `b` DATE,
+ `c` VARCHAR(42),
+ PRIMARY KEY (`a`) COMMENT "custom_p0_cfname=sharedcf;custom_p2_cfname=notsharedcf"
+) ENGINE=ROCKSDB
+ PARTITION BY LIST(`a`) (
+ PARTITION custom_p0 VALUES IN (1, 4, 7),
+ PARTITION custom_p1 VALUES IN (2, 5, 8),
+ PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+
+SELECT DISTINCT(cf_name) FROM information_schema.rocksdb_cfstats WHERE cf_name='notsharedcf';
+
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+
+
+# Test that truncating table actually removes rows.
+CREATE TABLE t1 (
+ a INT NOT NULL,
+ PRIMARY KEY (a) COMMENT 'p1_cfname=foo;'
+) ENGINE=ROCKSDB
+PARTITION BY LIST COLUMNS(a)
+(PARTITION p1 VALUES IN (1) ENGINE = ROCKSDB);
+
+INSERT INTO t1 values (1);
+TRUNCATE TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_reverse-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_reverse-master.opt
new file mode 100644
index 00000000..ba9364e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_reverse-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_reverse.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_reverse.test
new file mode 100644
index 00000000..8e30332b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_cf_reverse.test
@@ -0,0 +1,71 @@
+--source include/have_rocksdb.inc
+
+#
+# RocksDB-SE tests for reverse-ordered Column Families
+#
+
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t1 (
+ pk int primary key,
+ a int not null,
+ b int not null,
+ key(a) comment 'rev:foo',
+ key(b) comment 'bar'
+) engine=rocksdb;
+
+insert into t1 select a,a,a from t0;
+insert into t1 select a+10,a+10,a+10 from t0;
+
+--echo # Primary key is not in a reverse-ordered CF, so full table scan
+--echo # returns rows in ascending order:
+select * from t1;
+
+--replace_column 9 #
+explain
+select a from t1 order by a limit 5;
+select a from t1 order by a limit 5;
+
+--replace_column 9 #
+explain
+select b from t1 order by b limit 5;
+select a from t1 order by a limit 5;
+
+--replace_column 9 #
+explain
+select a from t1 order by a desc limit 5;
+select a from t1 order by a desc limit 5;
+
+--replace_column 9 #
+explain
+select b from t1 order by b desc limit 5;
+select b from t1 order by b desc limit 5;
+
+drop table t1;
+
+--echo #
+--echo # Try a primary key in a reverse-ordered CF.
+--echo #
+
+create table t2 (
+ pk int,
+ a int not null,
+ primary key(pk) comment 'rev:cf1'
+) engine=rocksdb;
+
+insert into t2 select a,a from t0;
+--echo # Primary key is in a reverse-ordered CF, so full table scan
+--echo # returns rows in descending order:
+select * from t2;
+
+set autocommit=0;
+begin;
+delete from t2 where a=3 or a=7;
+select * from t2;
+rollback;
+set autocommit=1;
+
+drop table t2;
+drop table t0;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_checksums-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_checksums-master.opt
new file mode 100644
index 00000000..320c48e5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_checksums-master.opt
@@ -0,0 +1,3 @@
+--rocksdb_debug_optimizer_n_rows=1000
+--rocksdb_records_in_range=50
+--log_warnings=3
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_checksums.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_checksums.test
new file mode 100644
index 00000000..42a4c83f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_checksums.test
@@ -0,0 +1,152 @@
+--source include/have_rocksdb.inc
+
+#
+# Tests for row checksums feature
+#
+--source include/have_debug.inc
+
+--let LOG=$MYSQLTEST_VARDIR/tmp/rocksdb_checksum.err
+--let $_mysqld_option=--log-error=$LOG
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--source include/restart_mysqld_with_option.inc
+
+set @save_rocksdb_store_row_debug_checksums=@@global.rocksdb_store_row_debug_checksums;
+set @save_rocksdb_verify_row_debug_checksums=@@global.rocksdb_verify_row_debug_checksums;
+set @save_rocksdb_checksums_pct=@@global.rocksdb_checksums_pct;
+
+show variables like 'rocksdb_%checksum%';
+
+create table t1 (pk int primary key, a int, b int, key(a), key(b)) engine=rocksdb;
+insert into t1 values (1,1,1),(2,2,2),(3,3,3);
+check table t1;
+--let SEARCH_FILE=$LOG
+--let SEARCH_PATTERN=0 table records had checksums
+--let SEARCH_PATTERN=CHECKTABLE t1[^\n]*
+--let SEARCH_OUTPUT=matches
+--source include/search_pattern_in_file.inc
+
+drop table t1;
+
+set session rocksdb_store_row_debug_checksums=on;
+create table t2 (pk int primary key, a int, b int, key(a), key(b)) engine=rocksdb;
+insert into t2 values (1,1,1),(2,2,2),(3,3,3);
+check table t2;
+--let SEARCH_PATTERN=CHECKTABLE t2[^\n]*
+--source include/search_pattern_in_file.inc
+
+--echo # Now, make a table that has both rows with checksums and without
+create table t3 (pk int primary key, a int, b int, key(a), key(b)) engine=rocksdb;
+insert into t3 values (1,1,1),(2,2,2),(3,3,3);
+set session rocksdb_store_row_debug_checksums=off;
+update t3 set b=3 where a=2;
+set session rocksdb_store_row_debug_checksums=on;
+check table t3;
+--let SEARCH_PATTERN=CHECKTABLE t3[^\n]*
+--source include/search_pattern_in_file.inc
+
+set session rocksdb_store_row_debug_checksums=on;
+set session rocksdb_checksums_pct=5;
+create table t4 (pk int primary key, a int, b int, key(a), key(b)) engine=rocksdb;
+--disable_query_log
+let $i=0;
+let $x= 100000;
+while ($i<4000)
+{
+ inc $i;
+ eval insert t4(pk,a,b) values($i, $i, $i div 10);
+ eval update t4 set a= a+$x where a=$i;
+ eval update t4 set pk=pk+$x where pk=$i;
+}
+--enable_query_log
+check table t4;
+perl;
+$total=4000;
+$pct=5;
+@out=();
+
+$filename= "$ENV{LOG}";
+print $filename "\n";
+open(F, '<', $filename) || die("Can't open file $filename: $!");
+while(<F>) {
+ @out=() if /^CURRENT_TEST:/;
+ if (/(\d+) index entries checked \((\d+) had checksums/) {
+ if ($1 == $total and $2 >= $total*($pct-2)/100 and $2 <= $total*($pct+2)/100) {
+ push @out, sprintf "%d index entries had around %d checksums\n", $total, $total*$pct/100;
+ }
+ } elsif (/(\d+) table records had checksums/) {
+ if ($1 >= $total*($pct-2)/100 and $1 <= $total*($pct+2)/100) {
+ push @out, sprintf "Around %d table records had checksums\n", $total*$pct/100;
+ }
+ }
+}
+print @out;
+EOF
+set session rocksdb_checksums_pct=100;
+
+--echo #
+--echo # Ok, table t2 has all rows with checksums. Simulate a few checksum mismatches.
+--echo #
+insert into mtr.test_suppressions values
+ ('Checksum mismatch in key of key-value pair for index'),
+ ('Checksum mismatch in value of key-value pair for index'),
+ ('Data with incorrect checksum');
+
+--echo # 1. Start with mismatch in key checksum of the PK.
+set session debug_dbug= "+d,myrocks_simulate_bad_pk_checksum1";
+set session rocksdb_verify_row_debug_checksums=off;
+select * from t3;
+set session rocksdb_verify_row_debug_checksums=on;
+--error ER_INTERNAL_ERROR
+select * from t3;
+--error ER_INTERNAL_ERROR
+select * from t4;
+set session debug_dbug= "-d,myrocks_simulate_bad_pk_checksum1";
+
+--echo # 2. Continue with mismatch in pk value checksum.
+set session debug_dbug= "+d,myrocks_simulate_bad_pk_checksum2";
+set session rocksdb_verify_row_debug_checksums=off;
+select * from t3;
+set session rocksdb_verify_row_debug_checksums=on;
+--error ER_INTERNAL_ERROR
+select * from t3;
+--error ER_INTERNAL_ERROR
+select * from t4;
+set session debug_dbug= "-d,myrocks_simulate_bad_pk_checksum2";
+
+--echo # 3. Check if we catch checksum mismatches for secondary indexes
+--replace_column 9 #
+explain
+select * from t3 force index(a) where a<4;
+select * from t3 force index(a) where a<4;
+
+set session debug_dbug= "+d,myrocks_simulate_bad_key_checksum1";
+--error ER_INTERNAL_ERROR
+select * from t3 force index(a) where a<4;
+--error ER_INTERNAL_ERROR
+select * from t4 force index(a) where a<1000000;
+set session debug_dbug= "-d,myrocks_simulate_bad_key_checksum1";
+
+--echo # 4. The same for index-only reads?
+--disable_query_log
+set global rocksdb_force_flush_memtable_now=1;
+--enable_query_log
+--replace_column 9 #
+explain
+select a from t3 force index(a) where a<4;
+select a from t3 force index(a) where a<4;
+
+set session debug_dbug= "+d,myrocks_simulate_bad_key_checksum1";
+--error ER_INTERNAL_ERROR
+select a from t3 force index(a) where a<4;
+--error ER_INTERNAL_ERROR
+select a from t4 force index(a) where a<1000000;
+set session debug_dbug= "-d,myrocks_simulate_bad_key_checksum1";
+
+set @@global.rocksdb_store_row_debug_checksums=@save_rocksdb_store_row_debug_checksums;
+set @@global.rocksdb_verify_row_debug_checksums=@save_rocksdb_verify_row_debug_checksums;
+set @@global.rocksdb_checksums_pct=@save_rocksdb_checksums_pct;
+
+--source include/restart_mysqld.inc
+#--remove_file $LOG
+
+drop table t2,t3,t4;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete.inc b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete.inc
new file mode 100644
index 00000000..5336c77e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete.inc
@@ -0,0 +1,109 @@
+# MariaDB: including the below too many times causes really long argv list
+# in win_main()'s argument which blows up some limit on Windows.
+# Comment it out:
+#--source include/have_rocksdb.inc
+--source include/have_debug_sync.inc
+
+--source include/count_sessions.inc
+
+# Usage:
+#
+# let $order = ASC; # or DESC
+# let $comment = "rev:cf2"; # or ""
+# --source suite/rocksdb/t/rocksdb_concurrent_delete.inc
+
+let $first_row = -1; # Error this should never happen
+if ($order == 'ASC')
+{
+ let $first_row = 1;
+ let $middle_row = 3;
+ let $end_row = 5;
+}
+if ($order == 'DESC')
+{
+ let $first_row = 5;
+ let $middle_row = 3;
+ let $end_row = 1;
+}
+
+connect (con, localhost, root,,);
+connection default;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+
+SET debug_sync='RESET';
+
+eval CREATE TABLE t1 (pk INT PRIMARY KEY COMMENT $comment, a INT);
+INSERT INTO t1 VALUES(1,1), (2,2), (3,3), (4,4), (5,5);
+
+# This will cause the SELECT to block after finding the first row, but
+# before locking and reading it.
+--echo --PK first row delete
+connection con;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+send_eval SELECT * FROM t1 order by t1.pk $order FOR UPDATE;
+
+# While that connection is waiting, delete the first row (the one con
+# is about to lock and read
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+eval DELETE FROM t1 WHERE pk = $first_row;
+
+# Signal the waiting select to continue
+SET debug_sync='now SIGNAL go';
+
+# Now get the results from the select. The first entry (1,1) (or (3,3) when
+# using reverse ordering) should be missing. Prior to the fix the SELECT
+# would have returned: "1815: Internal error: NotFound:"
+connection con;
+reap;
+
+# Deleting a middle row
+--echo --PK middle row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+send_eval SELECT * FROM t1 order by t1.pk $order FOR UPDATE;
+
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+eval DELETE FROM t1 WHERE pk = $middle_row;
+SET debug_sync='now SIGNAL go';
+
+connection con;
+if ($isolation_level == "REPEATABLE READ")
+{
+ --error ER_LOCK_DEADLOCK
+ reap;
+}
+if ($isolation_level == "READ COMMITTED")
+{
+ reap;
+}
+
+# Deleting the end row
+--echo --PK end row delete
+SET debug_sync='rocksdb_concurrent_delete SIGNAL parked WAIT_FOR go';
+send_eval SELECT * FROM t1 order by t1.pk $order FOR UPDATE;
+
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+eval DELETE FROM t1 WHERE pk = $end_row;
+SET debug_sync='now SIGNAL go';
+
+connection con;
+if ($isolation_level == "REPEATABLE READ")
+{
+ --error ER_LOCK_DEADLOCK
+ reap;
+}
+if ($isolation_level == "READ COMMITTED")
+{
+ reap;
+}
+
+
+# Cleanup
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+--source include/wait_until_count_sessions.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete.test
new file mode 100644
index 00000000..47818bfd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete.test
@@ -0,0 +1,38 @@
+# rocksdb_concurrent_delete test case covers snapshot conflicts, and
+# verifying locking reads not stopping scanning when hitting row not found.
+# The following code coverages are covered.
+#
+# 1. PK full scan (key=NULL)
+# first row, and other rows
+# ha_rnd_next -> rnd_next -> rnd_next_with_direction
+#
+# 2. PK range scan (key=PRIMARY)
+# first row
+# read_range_first -> index_read_map_impl -> read_row_from_primary_key
+# next row
+# index_next -> index_next_with_direction -> rnd_next_with_direction
+#
+# 3. SK full scan
+# first row
+# index_first -> index_first_intern -> index_next_with_direction -> secondary_index_read
+# next row
+# index_next -> index_next_with_direction -> secondary_index_read
+#
+# 4. SK range scan
+# first row
+# read_range_first -> index_read_map_impl -> read_row_from_secondary_key
+# next row
+# index_next -> index_next_with_direction -> secondary_index_read
+#
+# In all cases, RR gets snapshot conflict errors if non-first rows get
+# deleted by another transaction after scanning.
+
+--source include/have_rocksdb.inc
+--source include/have_debug_sync.inc
+
+let $isolation_level = REPEATABLE READ;
+--source rocksdb_concurrent_delete_main.inc
+
+let $isolation_level = READ COMMITTED;
+--source rocksdb_concurrent_delete_main.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete_main.inc b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete_main.inc
new file mode 100644
index 00000000..bcd86af9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete_main.inc
@@ -0,0 +1,30 @@
+--source include/have_rocksdb.inc
+--source include/have_debug_sync.inc
+
+# This validates the fix for Issue #144. The problem was that with more
+# than one client accessing/deleting the same row there was a possibility
+# of client A finding a row (through Next() or Prev()) but the row being
+# deleted before the GetForUpdate() call could occur. When this happened
+# a nearly useless error was being returned.
+
+let $order=ASC;
+let $comment="";
+--source rocksdb_concurrent_delete.inc
+--source rocksdb_concurrent_delete_sk.inc
+
+let $order=DESC;
+let $comment="";
+--source rocksdb_concurrent_delete.inc
+
+let $order=ASC;
+let $comment="rev:cf2";
+--source rocksdb_concurrent_delete.inc
+
+let $order=DESC;
+let $comment="rev:cf2";
+--source rocksdb_concurrent_delete.inc
+
+let $index=PRIMARY;
+--source rocksdb_concurrent_delete_range.inc
+let $index=sk;
+--source rocksdb_concurrent_delete_range.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete_range.inc b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete_range.inc
new file mode 100644
index 00000000..a8552714
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete_range.inc
@@ -0,0 +1,85 @@
+--source include/have_rocksdb.inc
+--source include/have_debug_sync.inc
+
+--source include/count_sessions.inc
+
+# This is a test case to reproduce https://github.com/facebook/mysql-5.6/issues/162
+# Expected output of the last select for update was (1,2,100) and (1,3,100), but
+# currently it returns (1,2,1) and (1,3,1), which must be fixed.
+
+connect (con, localhost, root,,);
+connection default;
+
+set debug_sync='RESET';
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+create table t1 (id1 int, id2 int, value int, primary key (id1, id2), index sk (id1, value)) engine=rocksdb;
+insert into t1 values (1, 1, 1),(1, 2, 1),(1, 3, 1),(1, 4, 1),(1, 5, 1),(2, 2, 2);
+
+# deleting a first row
+--echo --First row delete with $index
+connection con;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
+send_eval update t1 force index ($index) set value=100 where id1=1;
+
+connection default;
+set debug_sync='now WAIT_FOR parked';
+delete from t1 where id1=1 and id2=1;
+set debug_sync='now SIGNAL go';
+
+connection con;
+reap;
+select * from t1 where id1=1;
+
+# deleting a middle row
+--echo --Middle row delete with $index
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
+send_eval update t1 force index ($index) set value=200 where id1=1;
+
+connection default;
+set debug_sync='now WAIT_FOR parked';
+delete from t1 where id1=1 and id2=3;
+set debug_sync='now SIGNAL go';
+
+connection con;
+if ($isolation_level == "REPEATABLE READ")
+{
+ --error ER_LOCK_DEADLOCK
+ reap;
+}
+if ($isolation_level == "READ COMMITTED")
+{
+ reap;
+}
+select * from t1 where id1=1;
+
+# deleting the end row
+--echo --End row delete with $index
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+set debug_sync='rocksdb.get_row_by_rowid SIGNAL parked WAIT_FOR go';
+send_eval update t1 force index ($index) set value=300 where id1=1;
+
+connection default;
+set debug_sync='now WAIT_FOR parked';
+delete from t1 where id1=1 and id2=5;
+set debug_sync='now SIGNAL go';
+
+connection con;
+if ($isolation_level == "REPEATABLE READ")
+{
+ --error ER_LOCK_DEADLOCK
+ reap;
+}
+if ($isolation_level == "READ COMMITTED")
+{
+ reap;
+}
+select * from t1 where id1=1;
+
+# Cleanup
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+--source include/wait_until_count_sessions.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete_sk.inc b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete_sk.inc
new file mode 100644
index 00000000..ac0b5d76
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_delete_sk.inc
@@ -0,0 +1,82 @@
+--source include/have_rocksdb.inc
+--source include/have_debug_sync.inc
+
+--source include/count_sessions.inc
+
+connect (con, localhost, root,,);
+connection default;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+
+SET debug_sync='RESET';
+
+eval CREATE TABLE t1 (pk INT PRIMARY KEY, a INT, index a(a));
+INSERT INTO t1 VALUES(1,1), (2,2), (3,3), (4,4), (5,5);
+
+# This will cause the SELECT to block after finding the first row, but
+# before locking and reading it.
+--echo --SK first row delete
+connection con;
+eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
+SET debug_sync='rocksdb_concurrent_delete_sk SIGNAL parked WAIT_FOR go';
+send_eval SELECT a FROM t1 FORCE INDEX(a) FOR UPDATE;
+
+# While that connection is waiting, delete the first row (the one con
+# is about to lock and read
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+eval DELETE FROM t1 WHERE pk = 1;
+
+# Signal the waiting select to continue
+SET debug_sync='now SIGNAL go';
+
+connection con;
+reap;
+
+# Deleting a middle row
+--echo --SK middle row delete
+SET debug_sync='rocksdb_concurrent_delete_sk SIGNAL parked WAIT_FOR go';
+send_eval SELECT a FROM t1 FORCE INDEX(a) FOR UPDATE;
+
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+eval DELETE FROM t1 WHERE pk = 3;
+SET debug_sync='now SIGNAL go';
+
+connection con;
+if ($isolation_level == "REPEATABLE READ")
+{
+ --error ER_LOCK_DEADLOCK
+ reap;
+}
+if ($isolation_level == "READ COMMITTED")
+{
+ reap;
+}
+
+# Deleting the end row
+--echo --SK end row delete
+SET debug_sync='rocksdb_concurrent_delete_sk SIGNAL parked WAIT_FOR go';
+send_eval SELECT a FROM t1 FORCE INDEX(a) FOR UPDATE;
+
+connection default;
+SET debug_sync='now WAIT_FOR parked';
+eval DELETE FROM t1 WHERE pk = 5;
+SET debug_sync='now SIGNAL go';
+
+connection con;
+if ($isolation_level == "REPEATABLE READ")
+{
+ --error ER_LOCK_DEADLOCK
+ reap;
+}
+if ($isolation_level == "READ COMMITTED")
+{
+ reap;
+}
+
+# Cleanup
+connection default;
+disconnect con;
+set debug_sync='RESET';
+drop table t1;
+--source include/wait_until_count_sessions.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_insert.py b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_insert.py
new file mode 100644
index 00000000..37b118d5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_concurrent_insert.py
@@ -0,0 +1,95 @@
+"""
+This script tests concurrent inserts on a given table.
+Example Usage (in Mysql Test Framework):
+
+ CREATE TABLE t1 (a INT) ENGINE=rocksdb;
+
+ let $exec = python suite/rocksdb/t/rocksdb_concurrent_insert.py \
+ root 127.0.0.1 $MASTER_MYPORT test t1 100 4;
+ exec $exec;
+
+"""
+import cStringIO
+import hashlib
+import MySQLdb
+import os
+import random
+import signal
+import sys
+import threading
+import time
+import string
+
+def get_insert(table_name, idx):
+ return """INSERT INTO %s (a) VALUES (%d)""" % (table_name, idx)
+
+class Inserter(threading.Thread):
+ Instance = None
+ def __init__(self, con, table_name, num_inserts):
+ threading.Thread.__init__(self)
+ self.finished = False
+ self.num_inserts = num_inserts
+ con.autocommit(False)
+ self.con = con
+ self.rand = random.Random()
+ self.exception = None
+ self.table_name = table_name
+ Inserter.Instance = self
+ self.start()
+ def run(self):
+ try:
+ self.runme()
+ except Exception, e:
+ self.exception = traceback.format_exc()
+ print "caught (%s)" % e
+ finally:
+ self.finish()
+ def runme(self):
+ cur = self.con.cursor()
+ for i in xrange(self.num_inserts):
+ try:
+ cur.execute(get_insert(self.table_name, i))
+ r = self.rand.randint(1,10)
+ if r < 4:
+ self.con.commit()
+ except:
+ cur = self.con.cursor()
+ try:
+ self.con.commit()
+ except Exception, e:
+ self.exception = traceback.format_exc()
+ print "caught (%s)" % e
+ pass
+ def finish(self):
+ self.finished = True
+
+if __name__ == '__main__':
+ if len(sys.argv) != 8:
+ print "Usage: rocksdb_concurrent_insert.py user host port db_name " \
+ "table_name num_inserts num_threads"
+ sys.exit(1)
+
+ user = sys.argv[1]
+ host = sys.argv[2]
+ port = int(sys.argv[3])
+ db = sys.argv[4]
+ table_name = sys.argv[5]
+ num_inserts = int(sys.argv[6])
+ num_workers = int(sys.argv[7])
+
+ worker_failed = False
+ workers = []
+ for i in xrange(num_workers):
+ inserter = Inserter(
+ MySQLdb.connect(user=user, host=host, port=port, db=db), table_name,
+ num_inserts)
+ workers.append(inserter)
+
+ for w in workers:
+ w.join()
+ if w.exception:
+ print "Worker hit an exception:\n%s\n" % w.exception
+ worker_failed = True
+
+ if worker_failed:
+ sys.exit(1)
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_datadir.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_datadir.test
new file mode 100644
index 00000000..4399dd1a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_datadir.test
@@ -0,0 +1,33 @@
+--source include/have_rocksdb.inc
+let $ddir = $MYSQL_TMP_DIR/.rocksdb_datadir.test.install.db;
+let $rdb_ddir = $MYSQL_TMP_DIR/.rocksdb_datadir.test;
+let $sql_file = $MYSQL_TMP_DIR/rocksdb_datadir.sql;
+
+--write_file $sql_file
+CREATE DATABASE mysqltest;
+USE mysqltest;
+CREATE TABLE t1 (a INT PRIMARY KEY);
+INSERT INTO t1 VALUES(42);
+SET GLOBAL rocksdb_force_flush_memtable_now = 1;
+SELECT sleep(1);
+DROP TABLE t1;
+DROP DATABASE mysqltest;
+EOF
+
+# Must ensure this directory exists before launching mysqld
+mkdir $ddir;
+
+let $plugin_dir=`select @@plugin_dir`;
+# Launch mysqld with non-standard rocksdb_datadir
+exec $MYSQLD_BOOTSTRAP_CMD --plugin-dir=$plugin_dir --plugin-load=$HA_ROCKSDB_SO --datadir=$ddir --rocksdb_datadir=$rdb_ddir --default-storage-engine=rocksdb --skip-innodb --default-tmp-storage-engine=MyISAM --rocksdb < $sql_file;
+
+--echo Check for MANIFEST files
+--list_files $rdb_ddir MANIFEST-0000*
+
+# Clean up
+remove_files_wildcard $ddir *;
+remove_files_wildcard $ddir *;
+remove_files_wildcard $rdb_ddir *;
+rmdir $ddir;
+rmdir $rdb_ddir;
+remove_file $sql_file;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect.inc b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect.inc
new file mode 100644
index 00000000..082c6130
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect.inc
@@ -0,0 +1,123 @@
+#
+# Some basic sanity tests for deadlock detection.
+#
+--source include/have_rocksdb.inc
+
+set @prior_rocksdb_lock_wait_timeout = @@rocksdb_lock_wait_timeout;
+set @prior_rocksdb_deadlock_detect = @@rocksdb_deadlock_detect;
+set global rocksdb_lock_wait_timeout = 100000;
+set global rocksdb_deadlock_detect = ON;
+
+create table t (i int primary key);
+create table r1 (id int primary key, value int);
+insert into r1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10);
+create table r2 like r1;
+insert into r2 select * from r1;
+
+# deadlock on scanned locking reads
+connect (con1,localhost,root,,);
+let $con1= `SELECT CONNECTION_ID()`;
+begin;
+update r2 set value=100 where id=9;
+
+connect (con2,localhost,root,,);
+let $con2= `SELECT CONNECTION_ID()`;
+begin;
+update r1 set value=100 where id=8;
+--send select * from r2 for update;
+
+connection con1;
+let $wait_condition =
+`SELECT CONCAT('select count(*) = 1 from information_schema.rocksdb_trx where THREAD_ID = ', '$con2', ' and WAITING_KEY != ""')`;
+--source include/wait_condition.inc
+--error ER_LOCK_DEADLOCK
+select * from r1 for update;
+rollback;
+
+connection con2;
+--reap;
+rollback;
+
+connection con1;
+begin;
+insert into t values (1);
+
+connection con2;
+begin;
+insert into t values (2);
+
+connect (con3,localhost,root,,);
+begin;
+insert into t values (3);
+
+connection con1;
+--send select * from t where i = 2 for update
+
+connection con2;
+let $wait_condition =
+`SELECT CONCAT('select count(*) = 1 from information_schema.rocksdb_trx where THREAD_ID = ', '$con1', ' and WAITING_KEY != ""')`;
+--source include/wait_condition.inc
+
+--send select * from t where i = 3 for update
+
+connection con3;
+let $wait_condition =
+`SELECT CONCAT('select count(*) = 1 from information_schema.rocksdb_trx where THREAD_ID = ', '$con2', ' and WAITING_KEY != ""')`;
+--source include/wait_condition.inc
+
+select * from t;
+--error ER_LOCK_DEADLOCK
+insert into t values (4), (1);
+--echo # Transaction should be rolled back
+select * from t;
+rollback;
+
+connection con2;
+--reap
+rollback;
+
+connection con1;
+--reap
+rollback;
+
+
+connection default;
+create table t1 (id int primary key, value int, value2 int, index(value)) engine=rocksdb;
+insert into t1 values (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10);
+
+connection con1;
+begin;
+update t1 force index (value) set value2=value2+1 where value=3;
+
+connection con2;
+begin;
+update t1 force index (value) set value2=value2+1 where value=2;
+update t1 force index (value) set value2=value2+1 where value=4;
+
+connection con1;
+send update t1 force index (value) set value2=value2+1 where value=4;
+
+connection con2;
+let $wait_condition =
+`SELECT CONCAT('select count(*) = 1 from information_schema.rocksdb_trx where THREAD_ID = ', '$con1', ' and WAITING_KEY != ""')`;
+--source include/wait_condition.inc
+--error ER_LOCK_DEADLOCK
+update t1 force index (value) set value2=value2+1 where value=3;
+
+connection con1;
+--reap
+rollback;
+
+connection con2;
+rollback;
+drop table t1;
+
+
+connection default;
+disconnect con1;
+disconnect con2;
+disconnect con3;
+
+set global rocksdb_lock_wait_timeout = @prior_rocksdb_lock_wait_timeout;
+set global rocksdb_deadlock_detect = @prior_rocksdb_deadlock_detect;
+drop table t,r1,r2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect_rc-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect_rc-master.opt
new file mode 100644
index 00000000..25b80282
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect_rc-master.opt
@@ -0,0 +1 @@
+--transaction-isolation=read-committed
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect_rc.test
new file mode 100644
index 00000000..9757285f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect_rc.test
@@ -0,0 +1 @@
+--source t/rocksdb_deadlock_detect.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect_rr.test
new file mode 100644
index 00000000..9757285f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_detect_rr.test
@@ -0,0 +1 @@
+--source t/rocksdb_deadlock_detect.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress.inc b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress.inc
new file mode 100644
index 00000000..c88c7ebd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress.inc
@@ -0,0 +1,18 @@
+#
+# Stress tests deadlock detection
+#
+
+--source include/have_rocksdb.inc
+
+create table t1 (a int primary key, b int) engine=rocksdb;
+
+set @prior_rocksdb_lock_wait_timeout = @@rocksdb_lock_wait_timeout;
+set @prior_rocksdb_deadlock_detect = @@rocksdb_deadlock_detect;
+set global rocksdb_lock_wait_timeout = 100000;
+set global rocksdb_deadlock_detect = ON;
+
+exec python ../storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress.py root 127.0.0.1 $MASTER_MYPORT test t1 10000 10;
+
+set global rocksdb_lock_wait_timeout = @prior_rocksdb_lock_wait_timeout;
+set global rocksdb_deadlock_detect = @prior_rocksdb_deadlock_detect;
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress.py b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress.py
new file mode 100644
index 00000000..3bc8a3be
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress.py
@@ -0,0 +1,94 @@
+"""
+This script stress tests deadlock detection.
+
+Usage: rocksdb_deadlock_stress.py user host port db_name table_name
+ num_iters num_threads
+"""
+import cStringIO
+import hashlib
+import MySQLdb
+from MySQLdb.constants import ER
+import os
+import random
+import signal
+import sys
+import threading
+import time
+import string
+import traceback
+
+def is_deadlock_error(exc):
+ error_code = exc.args[0]
+ return (error_code == MySQLdb.constants.ER.LOCK_DEADLOCK)
+
+def get_query(table_name, idx):
+ # Let's assume that even indexes will always be acquireable, to make
+ # deadlock detection more interesting.
+ if idx % 2 == 0:
+ return """SELECT * from %s WHERE a = %d LOCK IN SHARE MODE""" % (table_name, idx)
+ else:
+ r = random.randint(1, 3);
+ if r == 1:
+ return """SELECT * from %s WHERE a = %d FOR UPDATE""" % (table_name, idx)
+ elif r == 2:
+ return """INSERT INTO %s VALUES (%d, 1)
+ ON DUPLICATE KEY UPDATE b=b+1""" % (table_name, idx)
+ else:
+ return """DELETE from %s WHERE a = %d""" % (table_name, idx)
+
+class Worker(threading.Thread):
+ def __init__(self, con, table_name, num_iters):
+ threading.Thread.__init__(self)
+ self.con = con
+ self.table_name = table_name
+ self.num_iters = num_iters
+ self.exception = None
+ self.start()
+ def run(self):
+ try:
+ self.runme()
+ except Exception, e:
+ self.exception = traceback.format_exc()
+ def runme(self):
+ cur = self.con.cursor()
+ for x in xrange(self.num_iters):
+ try:
+ for i in random.sample(xrange(100), 10):
+ cur.execute(get_query(self.table_name, i))
+ self.con.commit()
+ except MySQLdb.OperationalError, e:
+ self.con.rollback()
+ cur = self.con.cursor()
+ if not is_deadlock_error(e):
+ raise e
+
+if __name__ == '__main__':
+ if len(sys.argv) != 8:
+ print "Usage: rocksdb_deadlock_stress.py user host port db_name " \
+ "table_name num_iters num_threads"
+ sys.exit(1)
+
+ user = sys.argv[1]
+ host = sys.argv[2]
+ port = int(sys.argv[3])
+ db = sys.argv[4]
+ table_name = sys.argv[5]
+ num_iters = int(sys.argv[6])
+ num_workers = int(sys.argv[7])
+
+ worker_failed = False
+ workers = []
+ for i in xrange(num_workers):
+ w = Worker(
+ MySQLdb.connect(user=user, host=host, port=port, db=db), table_name,
+ num_iters)
+ workers.append(w)
+
+ for w in workers:
+ w.join()
+ if w.exception:
+ print "Worker hit an exception:\n%s\n" % w.exception
+ worker_failed = True
+
+ if worker_failed:
+ sys.exit(1)
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress_rc-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress_rc-master.opt
new file mode 100644
index 00000000..25b80282
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress_rc-master.opt
@@ -0,0 +1 @@
+--transaction-isolation=read-committed
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress_rc.test
new file mode 100644
index 00000000..67e306b8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress_rc.test
@@ -0,0 +1 @@
+--source t/rocksdb_deadlock_stress.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress_rr.test
new file mode 100644
index 00000000..67e306b8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_deadlock_stress_rr.test
@@ -0,0 +1 @@
+--source t/rocksdb_deadlock_stress.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_debug.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_debug.test
new file mode 100644
index 00000000..7cd4e09e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_debug.test
@@ -0,0 +1,14 @@
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+
+--echo #
+--echo # Issue #728: Assertion `covers_key(b)' failed in int
+--echo # myrocks::Rdb_key_def::cmp_full_keys(const rocks db::Slice&,
+--echo # const rocksdb::Slice&)
+--echo #
+
+CREATE TABLE t2(c1 TINYINT SIGNED KEY,c2 TINYINT UNSIGNED,c3 INT);
+INSERT INTO t2(c1)VALUES(0);
+SELECT * FROM t2 WHERE c1<=127 ORDER BY c1 DESC;
+DROP TABLE t2;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp-master.opt
new file mode 100644
index 00000000..acc0bdaa
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=20000 --rocksdb_records_in_range=1000 --rocksdb_perf_context_level=2 --userstat=ON
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp.test
new file mode 100644
index 00000000..8d0ec89e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp.test
@@ -0,0 +1,44 @@
+--source include/have_rocksdb.inc
+
+
+let $cf_name=cf1;
+
+--source include/rocksdb_icp.inc
+
+--echo #
+--echo # Issue #67: Inefficient index condition pushdown
+--echo #
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t1 (
+ pk int not null primary key,
+ key1 bigint(20) unsigned,
+ col1 int,
+ key (key1)
+) engine=rocksdb;
+
+insert into t1
+select
+ A.a+10*B.a+100*C.a,
+ A.a+10*B.a+100*C.a,
+ 1234
+from t0 A, t0 B, t0 C;
+
+set @count=0;
+let $save_query=
+set @count_diff =(select (value - @count) from information_schema.rocksdb_perf_context
+ where table_schema=database() and table_name='t1' and stat_type='INTERNAL_KEY_SKIPPED_COUNT');
+
+--replace_column 9 #
+explain
+select * from t1 force index(key1) where key1=1;
+
+eval $save_query;
+select * from t1 force index(key1) where key1=1;
+eval $save_query;
+--echo # The following must be =1, or in any case not 999:
+select @count_diff as "INTERNAL_KEY_SKIPPED_COUNT increment";
+
+drop table t0,t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp_rev-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp_rev-master.opt
new file mode 100644
index 00000000..fe129d79
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp_rev-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=20000 --rocksdb_records_in_range=1000 --userstat=ON
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp_rev.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp_rev.test
new file mode 100644
index 00000000..33914a4e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_icp_rev.test
@@ -0,0 +1,7 @@
+--source include/have_rocksdb.inc
+
+
+let $cf_name=rev:cf1;
+
+--source include/rocksdb_icp.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_locks-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_locks-master.opt
new file mode 100644
index 00000000..c9d9edb8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_locks-master.opt
@@ -0,0 +1 @@
+--rocksdb_print_snapshot_conflict_queries=1
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_locks.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_locks.test
new file mode 100644
index 00000000..ff092773
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_locks.test
@@ -0,0 +1,94 @@
+--source include/have_rocksdb.inc
+
+#
+# MyRocks-specific tests for locking
+#
+--source include/have_debug.inc
+
+--enable_connect_log
+create table t1 (pk int not null primary key) engine=rocksdb;
+
+insert into t1 values (1),(2),(3);
+
+set autocommit=0;
+begin;
+select * from t1 where pk=1 for update;
+
+--connect (con1,localhost,root,,)
+--connection con1
+call mtr.add_suppression("Got snapshot conflict errors");
+--echo ### Connection con1
+let $ID= `select connection_id()`;
+set @@rocksdb_lock_wait_timeout=500;
+set autocommit=0;
+begin;
+--send select * from t1 where pk=1 for update;
+
+--connection default
+--echo ### Connection default
+
+let $wait_condition=
+ select 1 from INFORMATION_SCHEMA.PROCESSLIST
+ where (ID = $ID /* or SRV_ID = $ID */) and STATE = "Waiting for row lock";
+--source include/wait_condition.inc
+## Waiting for row lock
+## select connection_id();
+## select state='Waiting for row lock' from information_schema.processlist where id=2;
+
+rollback;
+
+connection con1;
+reap;
+rollback;
+connection default;
+
+##
+## Now, repeat the same test but let the wait time out.
+##
+begin;
+select * from t1 where pk=1 for update;
+
+--connection con1
+--echo ### Connection con1
+set @@rocksdb_lock_wait_timeout=2;
+set autocommit=0;
+begin;
+--error ER_LOCK_WAIT_TIMEOUT
+select * from t1 where pk=1 for update;
+
+--connection default
+
+rollback;
+set autocommit=1;
+
+--connection con1
+drop table t1;
+--connection default
+
+--echo #
+--echo # Now, test what happens if another transaction modified the record and committed
+--echo #
+
+CREATE TABLE t1 (
+ id int primary key,
+ value int
+) engine=rocksdb collate latin1_bin;
+insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10);
+
+--connection con1
+BEGIN;
+SELECT * FROM t1 WHERE id=3;
+
+--connection default
+BEGIN;
+UPDATE t1 SET value=30 WHERE id=3;
+COMMIT;
+
+--connection con1
+--error ER_LOCK_DEADLOCK
+SELECT * FROM t1 WHERE id=3 FOR UPDATE;
+
+ROLLBACK;
+--disconnect con1
+--connection default
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_parts-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_parts-master.opt
new file mode 100644
index 00000000..ba9364e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_parts-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_parts.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_parts.test
new file mode 100644
index 00000000..b8d41ae9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_parts.test
@@ -0,0 +1,160 @@
+--source include/have_rocksdb.inc
+
+--source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+--echo # Tests for MyRocks + partitioning
+
+--echo #
+--echo # MyRocks Issue #70: Server crashes in Rdb_key_def::get_primary_key_tuple
+--echo #
+CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, KEY(f2)) ENGINE=RocksDB
+PARTITION BY HASH(pk) PARTITIONS 2;
+INSERT INTO t1 VALUES (1, 6, NULL), (2, NULL, 1);
+
+CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT) ENGINE=RocksDB;
+INSERT INTO t2 VALUES (1, 1), (2, 1);
+
+SELECT f1 FROM t1 WHERE f2 = ( SELECT f1 FROM t2 WHERE pk = 2 );
+
+drop table t1,t2;
+
+--echo #
+--echo # Issue#105: key_info[secondary_key].actual_key_parts does not include primary key on partitioned tables
+--echo #
+CREATE TABLE t1 (
+ id INT PRIMARY KEY,
+ a set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') CHARACTER SET utf8,
+ b set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') CHARACTER SET utf8 default null,
+ c set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') CHARACTER SET utf8 not null,
+ INDEX (a),
+ INDEX (b),
+ INDEX (c)
+) ENGINE=RocksDB PARTITION BY key (id) partitions 2;
+
+INSERT INTO t1 (id, b) VALUES (28, 3);
+UPDATE t1 SET id=8 WHERE c < 8 LIMIT 1;
+check table t1;
+drop table t1;
+
+--echo #
+--echo # Issue #105, another testcase
+--echo #
+create table t1 (
+ pk int primary key,
+ col1 int,
+ col2 int,
+ key (col1) comment 'rev:cf_issue105'
+) engine=rocksdb partition by hash(pk) partitions 2;
+
+insert into t1 values (1,10,10);
+insert into t1 values (2,10,10);
+
+insert into t1 values (11,20,20);
+insert into t1 values (12,20,20);
+
+set @tmp_rfirr= @@rocksdb_force_index_records_in_range;
+set rocksdb_force_index_records_in_range= 12;
+
+--replace_column 9 #
+explain select * from t1 force index(col1) where col1=10;
+select * from t1 force index(col1) where col1=10;
+select * from t1 use index () where col1=10;
+
+set rocksdb_force_index_records_in_range= @tmp_rfirr;
+
+drop table t1;
+
+--echo #
+--echo # Issue #108: Index-only scans do not work for partitioned tables and extended keys
+--echo #
+create table t1 (
+ pk int primary key,
+ col1 int,
+ col2 int,
+ key (col1)
+) engine=rocksdb partition by hash(pk) partitions 2;
+
+insert into t1 values (1,10,10);
+insert into t1 values (2,10,10);
+
+insert into t1 values (11,20,20);
+insert into t1 values (12,20,20);
+--echo # The following must use "Using index"
+explain select pk from t1 force index(col1) where col1=10;
+
+drop table t1;
+
+--echo #
+--echo # Issue #214: subqueries cause crash
+--echo #
+create TABLE t1(a int,b int,c int,primary key(a,b))
+ partition by list (b*a) (partition x1 values in (1) tablespace ts1,
+ partition x2 values in (3,11,5,7) tablespace ts2,
+ partition x3 values in (16,8,5+19,70-43) tablespace ts3);
+create table t2(b binary(2));
+set session optimizer_switch='materialization=off';
+insert into t1(a,b) values(1,7);
+select a from t1 where a in (select a from t1 where a in (select b from t2));
+
+drop table t1, t2;
+
+--echo #
+--echo # Issue #260: altering name to invalid value leaves table unaccessible
+--echo #
+CREATE TABLE t1 (c1 INT NOT NULL, c2 CHAR(5)) PARTITION BY HASH(c1) PARTITIONS 4;
+INSERT INTO t1 VALUES(1,'a');
+--replace_result \\ /
+--error ER_ERROR_ON_RENAME
+RENAME TABLE t1 TO db3.t3;
+SELECT * FROM t1;
+SHOW TABLES;
+# try it again to the same database
+RENAME TABLE t1 TO test.t3;
+SELECT * FROM t3;
+SHOW TABLES;
+# now try it again but with another existing database
+CREATE DATABASE db3;
+USE test;
+RENAME TABLE t3 to db3.t2;
+USE db3;
+SELECT * FROM t2;
+SHOW TABLES;
+# cleanup
+DROP TABLE t2;
+use test;
+DROP DATABASE db3;
+
+--echo #
+--echo # MDEV-13153 Assertion `global_status_var.global_memory_used == 0 '
+--echo # failed upon server restart with partitioned RocksDB table
+--echo #
+CREATE TABLE t1 (a INT) ENGINE=RocksDB PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a) VALUES (1),(2);
+ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
+--source include/restart_mysqld.inc
+SELECT 1;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-15245: Assertion `false' failed in myrocks::ha_rocksdb::position
+--echo #
+CREATE TABLE t1 (a INT) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1),(2);
+# partitioning
+CREATE TABLE t2 (b INT) ENGINE=RocksDB
+PARTITION BY RANGE(b)
+(PARTITION p0 VALUES LESS THAN (1),
+ PARTITION p1 VALUES LESS THAN MAXVALUE);
+
+
+INSERT INTO t2 VALUES (NULL),(0);
+CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.* FROM t1, t2;
+UPDATE v1 SET b = 5;
+
+drop view v1;
+drop table t1,t2;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_qcache-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_qcache-master.opt
new file mode 100644
index 00000000..a00258bc
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_qcache-master.opt
@@ -0,0 +1 @@
+--query_cache_type=1
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_qcache.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_qcache.test
new file mode 100644
index 00000000..0369e758
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_qcache.test
@@ -0,0 +1,43 @@
+--source include/have_rocksdb.inc
+
+# Important:
+# The test needs to be run with --mysqld=--query-cache-type=1
+
+--source include/have_query_cache.inc
+set @save_query_cache_type=@@global.query_cache_type;
+set @save_query_cache_size=@@global.query_cache_size;
+set @@global.query_cache_type=1;
+set @@global.query_cache_size=1024*1024;
+
+--enable_connect_log
+
+create table t1 (pk int primary key, c char(8)) engine=RocksDB;
+insert into t1 values (1,'new'),(2,'new');
+
+select * from t1;
+
+--connect (con1,localhost,root,,)
+
+update t1 set c = 'updated';
+#select * from t1;
+
+--connection default
+flush status;
+show status like 'Qcache_hits';
+show global status like 'Qcache_hits';
+select * from t1;
+select sql_no_cache * from t1;
+select * from t1 where pk = 1;
+show status like 'Qcache_hits';
+--echo # MariaDB: Qcache_not_cached is not incremented for select sql_no_cache queries
+--echo # so the following query produces 2, not 3:
+show status like 'Qcache_not_cached';
+show global status like 'Qcache_hits';
+
+drop table t1;
+
+#
+# Cleanup
+#
+set @@global.query_cache_type=@save_query_cache_type;
+set @@global.query_cache_size=@save_query_cache_size;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_range-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_range-master.opt
new file mode 100644
index 00000000..6ad42e58
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_range-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000 --rocksdb_records_in_range=50
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_range.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_range.test
new file mode 100644
index 00000000..f4b6096c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_range.test
@@ -0,0 +1,196 @@
+--source include/have_rocksdb.inc
+
+#
+# Range access test for RocksDB storage engine
+#
+select * from information_schema.engines where engine = 'rocksdb';
+
+--disable_warnings
+drop table if exists t0,t1,t2,t3,t4,t5;
+--enable_warnings
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t1(a int) engine=myisam;
+insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
+
+create table t2 (
+ pk int not null,
+ a int not null,
+ b int not null,
+ primary key(pk),
+ key(a) comment 'rev:cf1'
+) engine=rocksdb;
+
+# 10 pk values for each value of a...
+insert into t2 select A.a, FLOOR(A.a/10), A.a from t1 A;
+
+--echo #
+--echo # HA_READ_KEY_EXACT tests
+--echo #
+
+--echo # Original failure was here:
+--replace_column 9 #
+explain
+select * from t2 force index (a) where a=0;
+select * from t2 force index (a) where a=0;
+
+--echo # The rest are for code coverage:
+--replace_column 9 #
+explain
+select * from t2 force index (a) where a=2;
+select * from t2 force index (a) where a=2;
+
+--replace_column 9 #
+explain
+select * from t2 force index (a) where a=3 and pk=33;
+select * from t2 force index (a) where a=3 and pk=33;
+
+select * from t2 force index (a) where a=99 and pk=99;
+select * from t2 force index (a) where a=0 and pk=0;
+select * from t2 force index (a) where a=-1;
+select * from t2 force index (a) where a=-1 and pk in (101,102);
+select * from t2 force index (a) where a=100 and pk in (101,102);
+
+
+--echo #
+--echo # #36: Range in form tbl.key >= const doesn't work in reverse column family
+--echo #
+--replace_column 9 #
+explain
+select count(*) from t2 force index (a) where a>=0 and a <=1;
+select count(*) from t2 force index (a) where a>=0 and a <=1;
+
+--replace_column 9 #
+explain
+select count(*) from t2 force index (a) where a>=-1 and a <=1;
+select count(*) from t2 force index (a) where a>=-1 and a <=1;
+
+--replace_column 9 #
+explain
+select * from t2 force index (a) where a=0 and pk>=3;
+select * from t2 force index (a) where a=0 and pk>=3;
+
+--echo # Try edge cases where we fall over the end of the table
+create table t3 like t2;
+insert into t3 select * from t2;
+
+select * from t3 where pk>=1000000;
+select * from t2 where pk>=1000000;
+
+--echo #
+--echo # #42: Range in form tbl.key > const doesn't work in reverse column family
+--echo #
+--replace_column 9 #
+explain
+select count(*) from t2 force index (a) where a>0;
+select count(*) from t2 force index (a) where a>0;
+
+--replace_column 9 #
+explain
+select count(*) from t2 force index (a) where a>99;
+select count(*) from t2 force index (a) where a>99;
+
+select * from t2 where pk>1000000;
+select * from t3 where pk>1000000;
+
+--replace_column 9 #
+explain
+select count(*) from t2 force index (a) where a=2 and pk>25;
+select count(*) from t2 force index (a) where a=2 and pk>25;
+
+
+select * from t2 force index (a) where a>-10 and a < 1;
+select * from t3 force index (a) where a>-10 and a < 1;
+
+
+--echo #
+--echo # #46: index_read_map(HA_READ_BEFORE_KEY) does not work in reverse column family
+--echo #
+select max(a) from t2 where a < 2;
+select max(a) from t2 where a < -1;
+
+select max(pk) from t2 where a=3 and pk < 6;
+
+select max(pk) from t2 where pk < 200000;
+select max(pk) from t2 where pk < 20;
+
+select max(a) from t3 where a < 2;
+select max(a) from t3 where a < -1;
+select max(pk) from t3 where pk < 200000;
+select max(pk) from t3 where pk < 20;
+
+select max(pk) from t2 where a=3 and pk < 33;
+select max(pk) from t3 where a=3 and pk < 33;
+
+--echo #
+--echo # #48: index_read_map(HA_READ_PREFIX_LAST) does not work in reverse CF
+--echo #
+
+--echo # Tests for search_flag=HA_READ_PREFIX_LAST_OR_PREV
+--echo # Note: the next explain has "Using index condition" in fb/mysql-5.6
+--echo # but "Using where" in MariaDB because the latter does not
+--echo # support ICP over reverse scans.
+--replace_column 9 #
+explain
+select * from t2 where a between 99 and 2000 order by a desc;
+select * from t2 where a between 99 and 2000 order by a desc;
+
+select max(a) from t2 where a <=10;
+select max(a) from t2 where a <=-4;
+
+select max(pk) from t2 where a=5 and pk <=55;
+select max(pk) from t2 where a=5 and pk <=55555;
+select max(pk) from t2 where a=5 and pk <=0;
+
+select max(pk) from t2 where pk <=-1;
+select max(pk) from t2 where pk <=999999;
+select max(pk) from t3 where pk <=-1;
+select max(pk) from t3 where pk <=999999;
+
+--echo #
+--echo # Tests for search_flag=HA_READ_PREFIX_LAST
+--echo #
+
+create table t4 (
+ pk int primary key,
+ a int,
+ b int,
+ c int,
+ key(a,b,c)
+) engine=rocksdb;
+
+insert into t4 select pk,pk,pk,pk from t2 where pk < 100;
+
+--replace_column 9 #
+explain
+select * from t4 where a=1 and b in (1) order by c desc;
+select * from t4 where a=1 and b in (1) order by c desc;
+
+--replace_column 9 #
+explain
+select * from t4 where a=5 and b in (4) order by c desc;
+select * from t4 where a=5 and b in (4) order by c desc;
+
+--echo # HA_READ_PREFIX_LAST for reverse-ordered CF
+create table t5 (
+ pk int primary key,
+ a int,
+ b int,
+ c int,
+ key(a,b,c) comment 'rev:cf2'
+) engine=rocksdb;
+
+insert into t5 select pk,pk,pk,pk from t2 where pk < 100;
+
+--replace_column 9 #
+explain
+select * from t5 where a=1 and b in (1) order by c desc;
+select * from t5 where a=1 and b in (1) order by c desc;
+
+--replace_column 9 #
+explain
+select * from t5 where a=5 and b in (4) order by c desc;
+select * from t5 where a=5 and b in (4) order by c desc;
+
+drop table t0,t1,t2,t3,t4,t5;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_range2.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_range2.test
new file mode 100644
index 00000000..28010d13
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_range2.test
@@ -0,0 +1,33 @@
+--source include/have_rocksdb.inc
+
+# Issue#212 MyRocks chooses full index scan even if range scan is more efficient
+# rocksdb_debug_optimizer_n_rows must not be set.
+
+create table t1 (id1 bigint, id2 bigint, c1 bigint, c2 bigint, c3 bigint, c4 bigint, c5 bigint, c6 bigint, c7 bigint, primary key (id1, id2), index i(c1, c2));
+--disable_query_log
+let $i=0;
+while ($i<10000)
+{
+ inc $i;
+ eval insert t1(id1, id2, c1, c2, c3, c4, c5, c6, c7)
+ values($i, 0, $i, 0, 0, 0, 0, 0, 0);
+}
+--enable_query_log
+analyze table t1;
+select count(*) from t1;
+--replace_column 9 #
+explain select c1 from t1 where c1 > 5 limit 10;
+drop table t1;
+
+--echo #
+--echo # MDEV-17414: MyROCKS order desc limit 1 fails
+--echo #
+create table t1 (date date);
+insert into t1 values ('2018-10-04'), ('2018-10-05');
+select * from t1 where date < '2018-10-09' order by date desc limit 1; # Works as expected
+alter table t1 add index date_index (date);
+select * from t1 where date < '2018-10-05' order by date desc limit 1; # Works as expected
+--echo # this should not produce an empty set:
+select * from t1 where date < '2018-10-09' order by date desc limit 1;
+drop table t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl.cnf b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl.cnf
new file mode 100644
index 00000000..9ceb0cc0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl.cnf
@@ -0,0 +1,16 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+sync_binlog=0
+binlog_format=row
+rocksdb_read_free_rpl=PK_SK
+slave-exec-mode=strict
+rocksdb_perf_context_level=3
+
+[mysqld.2]
+sync_binlog=0
+binlog_format=row
+rocksdb_read_free_rpl=PK_SK
+slave-exec-mode=strict
+rocksdb_default_cf_options=write_buffer_size=16k;target_file_size_base=16k
+rocksdb_perf_context_level=3
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl.test
new file mode 100644
index 00000000..e1fb9db0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl.test
@@ -0,0 +1,414 @@
+source include/have_rocksdb.inc;
+source include/master-slave.inc;
+source include/have_debug.inc;
+
+
+connection master;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+# initialization/insert
+connection master;
+create table t1 (id int primary key, value int);
+insert into t1 values (1,1), (2,2), (3,3), (4,4);
+--source include/sync_slave_sql_with_master.inc
+
+--let $diff_tables= master:t1, slave:t1
+
+--echo
+--echo # regular update/delete. With rocks_read_free_rpl=PK_SK, rocksdb_rows_read does not increase on slaves
+--echo
+connection slave;
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+connection master;
+update t1 set value=value+1 where id=1;
+delete from t1 where id=4;
+select * from t1;
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+select * from t1;
+
+
+--echo
+--echo # "rocks_read_free_rpl=PK_SK" makes "row not found error" not happen anymore
+--echo
+connection slave;
+--source include/stop_slave.inc
+delete from t1 where id in (2, 3);
+--source include/start_slave.inc
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+
+connection master;
+update t1 set value=value+1 where id=3;
+delete from t1 where id=2;
+select * from t1;
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+select * from t1;
+
+
+--echo
+--echo ## tables without primary key -- read free replication should be disabled
+--echo
+--echo
+--echo #no index
+--echo
+connection master;
+drop table t1;
+create table t1 (c1 int, c2 int);
+insert into t1 values (1,1), (2,2),(3,3),(4,4),(5,5);
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+connection master;
+update t1 set c2=100 where c1=3;
+delete from t1 where c1 <= 2;
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+select * from t1;
+
+--echo
+--echo #secondary index only
+--echo
+connection master;
+drop table t1;
+create table t1 (c1 int, c2 int, index i(c1));
+insert into t1 values (1,1), (2,2),(3,3),(4,4),(5,5);
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+connection master;
+update t1 set c2=100 where c1=3;
+delete from t1 where c1 <= 2;
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+select * from t1;
+
+
+
+--echo
+--echo ## large row operations -- primary key modification, secondary key modification
+--echo
+connection master;
+drop table t1;
+create table t1 (id1 bigint, id2 bigint, c1 bigint, c2 bigint, c3 bigint, c4 bigint, c5 bigint, c6 bigint, c7 bigint, primary key (id1, id2), index i(c1, c2));
+
+--disable_query_log
+let $i=1;
+while ($i<=10000)
+{
+ eval insert t1(id1,id2,c1,c2,c3,c4,c5,c6,c7)
+ values($i,0,$i,0,0,0,0,0,0);
+ inc $i;
+}
+--enable_query_log
+
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+connection master;
+
+--echo
+--echo #updating all secondary keys by 1
+--echo
+--disable_query_log
+let $i=1;
+while ($i<=10000)
+{
+ eval update t1 set c2=c2+1 where id1=$i and id2=0;
+ inc $i;
+}
+--enable_query_log
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+connection master;
+--source include/diff_tables.inc
+
+--echo
+--echo #updating all primary keys by 2
+--echo
+connection slave;
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+connection master;
+--disable_query_log
+let $i=1;
+while ($i<=10000)
+{
+ eval update t1 set id2=id2+2 where id1=$i and id2=0;
+ inc $i;
+}
+--enable_query_log
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+connection master;
+--source include/diff_tables.inc
+
+--echo
+--echo #updating secondary keys after truncating t1 on slave
+--echo
+connection slave;
+truncate table t1;
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+connection master;
+update t1 set c2=c2+10;
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+connection master;
+--source include/diff_tables.inc
+
+--echo
+--echo #updating primary keys after truncating t1 on slave
+--echo
+connection slave;
+truncate table t1;
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+connection master;
+update t1 set id2=id2+10;
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+connection master;
+--source include/diff_tables.inc
+
+--echo
+--echo #deleting half rows
+--echo
+connection slave;
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+connection master;
+delete from t1 where id1 <= 5000;
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+connection master;
+--source include/diff_tables.inc
+
+--echo
+--echo # rocksdb_read_free_rpl = PK_ONLY i.e. it only works on tables with only PK
+--echo
+connection slave;
+--echo [on slave]
+stop slave;
+set @@global.rocksdb_read_free_rpl = PK_ONLY;
+start slave;
+connection master;
+--echo [on master]
+create table t2 (id int primary key, i1 int, i2 int, value int);
+create table u2 (id int primary key, i1 int, i2 int, value int, index(i1), index(i2));
+insert into t2 values (1,1,1,1),(2,2,2,2),(3,3,3,3);
+insert into u2 values (1,1,1,1),(2,2,2,2),(3,3,3,3);
+--source include/sync_slave_sql_with_master.inc
+
+# make a mismatch between the slave and the master
+connection slave;
+--echo [on slave]
+delete from t2 where id <= 2;
+delete from u2 where id <= 2;
+
+# make changes on the master
+connection master;
+--echo [on master]
+update t2 set i2=100, value=100 where id=1;
+update u2 set i2=100, value=100 where id=1;
+
+connection slave;
+--echo [on slave]
+call mtr.add_suppression("Slave SQL.*Could not execute Update_rows event on table test.u2.*Error_code.*");
+call mtr.add_suppression("Slave: Can't find record in 'u2'.*");
+# wait until we have the expected error
+--let $slave_sql_errno= convert_error(ER_KEY_NOT_FOUND)
+--source include/wait_for_slave_sql_error.inc
+
+# query the t2 table on the slave
+connection slave;
+select count(*) from t2 force index(primary);
+select * from t2 where id=1;
+select i1 from t2 where i1=1;
+select i2 from t2 where i2=100;
+
+# query the u2 table on the slave
+select count(*) from u2 force index(primary);
+select count(*) from u2 force index(i1);
+select count(*) from u2 force index(i2);
+select * from u2 where id=1;
+select i1 from u2 where i1=1;
+select i2 from u2 where i2=100;
+
+# the slave replication thread stopped because of the errors;
+# cleanup the problem and restart it
+--disable_query_log
+insert into u2 values(1,1,1,1), (2,2,2,2);
+start slave sql_thread;
+--source include/wait_for_slave_sql_to_start.inc
+--enable_query_log
+
+connection slave;
+--echo [on slave]
+stop slave;
+set @@global.rocksdb_read_free_rpl = PK_SK;
+start slave;
+
+--echo
+--echo # some tables with read-free replication on and some with it off
+--echo
+# We'll set the table filter to all tables starting with 't'
+connection slave;
+--echo [on slave]
+stop slave;
+set @@global.rocksdb_read_free_rpl_tables = "t.*";
+start slave;
+connection master;
+--echo [on master]
+drop table if exists t2;
+drop table if exists u2;
+create table t2 (id int primary key, i1 int, i2 int, value int);
+create table u2 (id int primary key, i1 int, i2 int, value int);
+insert into t2 values (1,1,1,1),(2,2,2,2),(3,3,3,3);
+insert into u2 values (1,1,1,1),(2,2,2,2),(3,3,3,3);
+--source include/sync_slave_sql_with_master.inc
+
+# make a mismatch between the slave and the master
+connection slave;
+--echo [on slave]
+delete from t2 where id <= 2;
+delete from u2 where id <= 2;
+
+# make changes on the master
+connection master;
+--echo [on master]
+update t2 set i2=100, value=100 where id=1;
+update u2 set i2=100, value=100 where id=1;
+
+connection slave;
+--echo [on slave]
+call mtr.add_suppression("Slave SQL.*Could not execute Update_rows event on table test.u2.*Error_code.*");
+call mtr.add_suppression("Slave: Can't find record in 'u2'.*");
+# wait until we have the expected error
+--let $slave_sql_errno= convert_error(ER_KEY_NOT_FOUND)
+--source include/wait_for_slave_sql_error.inc
+
+# query the t2 table on the slave
+connection slave;
+select count(*) from t2 force index(primary);
+select * from t2 where id=1;
+select i1 from t2 where i1=1;
+select i2 from t2 where i2=100;
+
+# query the u2 table on the slave
+select count(*) from u2 force index(primary);
+select * from u2 where id=1;
+select i1 from u2 where i1=1;
+select i2 from u2 where i2=100;
+
+# the slave replication thread stopped because of the errors;
+# cleanup the problem and restart it
+--disable_query_log
+insert into u2 values(1,1,1,1), (2,2,2,2);
+start slave sql_thread;
+--source include/wait_for_slave_sql_to_start.inc
+--enable_query_log
+
+connection slave;
+--echo [on slave]
+stop slave;
+set @@global.rocksdb_read_free_rpl_tables = ".*";
+start slave;
+
+--echo
+--echo # secondary keys lose rows
+--echo
+connection master;
+--echo [on master]
+create table t3 (id int primary key, i1 int, i2 int, value int, index(i1),
+index(i2));
+insert into t3 values (1,1,1,1),(2,2,2,2),(3,3,3,3);
+--source include/sync_slave_sql_with_master.inc
+
+# make a mismatch between the slave and the master
+connection slave;
+--echo [on slave]
+delete from t3 where id <= 2;
+
+# make changes on the master
+connection master;
+--echo [on master]
+update t3 set i2=100, value=100 where id=1;
+
+# make sure the slave is caught up
+--source include/sync_slave_sql_with_master.inc
+
+# query the t3 table on the slave
+connection slave;
+select count(*) from t3 force index(primary);
+select count(*) from t3 force index(i1);
+select count(*) from t3 force index(i2);
+select * from t3 where id=1;
+select i1 from t3 where i1=1;
+select i2 from t3 where i2=100;
+
+--echo
+--echo # secondary keys have extra rows
+--echo
+connection master;
+--echo [on master]
+create table t4 (id int primary key, i1 int, i2 int, value int, index(i1), index(i2));
+insert into t4 values (1,1,1,1),(2,2,2,2),(3,3,3,3);
+--source include/sync_slave_sql_with_master.inc
+
+# make a mismatch between the slave and the master
+connection slave;
+--echo [on slave]
+update t4 set i1=100 where id=1;
+
+# make changes on the master
+connection master;
+--echo [on master]
+delete from t4 where id=1;
+
+# make sure the slave is caught up
+--source include/sync_slave_sql_with_master.inc
+
+# query the t4 table on the slave
+connection slave;
+--echo [on slave]
+select count(*) from t4 force index(primary);
+select count(*) from t4 force index(i1);
+select count(*) from t4 force index(i2);
+select i1 from t4 where i1=100;
+
+--echo
+--echo # inserts are also read-free
+--echo
+connection master;
+--echo [on master]
+drop table if exists t2;
+drop table if exists t3;
+create table t2 (id int primary key, i1 int, i2 int);
+create table t3 (id int primary key, i1 int, i2 int, key(i1));
+connection slave;
+select variable_value into @up from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+connection master;
+insert into t2 values(1, 1, 1);
+insert into t2 values(2, 2, 2);
+insert into t3 values(1, 1, 1);
+insert into t3 values(2, 2, 2);
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select case when variable_value-@up > 0 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+select * from t2;
+select * from t3;
+
+# cleanup
+connection master;
+drop table t1, t2, t3, t4, u2;
+
+--source include/rpl_end.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl_stress.cnf b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl_stress.cnf
new file mode 100644
index 00000000..f225d5dd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl_stress.cnf
@@ -0,0 +1,17 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+sync_binlog=0
+binlog_format=row
+rocksdb_perf_context_level=3
+
+[mysqld.2]
+sync_binlog=0
+binlog_format=row
+slave-exec-mode=strict
+rocksdb_perf_context_level=3
+slave_use_idempotent_for_recovery=YES
+slave_parallel_workers=8
+mts_dependency_replication=STMT
+mts_dependency_order_commits=0
+slave_tx_isolation=READ-COMMITTED
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl_stress.inc b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl_stress.inc
new file mode 100644
index 00000000..e69bcce7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl_stress.inc
@@ -0,0 +1,69 @@
+
+disable_query_log;
+
+# Create a schema with different kinds of tables (with different kinds of keys)
+connection master;
+create table t1(a int, b int, c int, d int); #no keys
+create table t2(a int primary key, b int, c int, d int); #only pk
+create table t3(a int, b int, c int, d int, key(b)); #only sk
+create table t4(a int, b int unique, c int, d int); #only unique sk
+create table t5(a int primary key, b int, c int, d int, key(b)); #pk + sk
+create table t6(a int primary key, b int unique, c int, d int); #pk + unique sk
+create table t7(a int, b int unique, c int, d int, key(c)); #sk + unique sk
+create table t8(a int primary key, b int unique, c int, d int, key(c)); #pk + sk + unique sk
+
+# Insert a bunch of rows
+let $iter = 0;
+while ($iter < 1000) {
+ let $t = 1;
+ while ($t <= 8) {
+ eval insert into t$t values($iter, $iter, $iter, $iter);
+ inc $t;
+ }
+ inc $iter;
+}
+
+let $iter = 0;
+while ($iter < 10) {
+ let $t = 1;
+ while ($t <= 8) {
+ eval update t$t set a = a + 10000 where a > 900; # update pk (if any)
+ eval update t$t set b = b + 10000 where b > 900; # update sk or unique (if any)
+ eval update t$t set c = c + 10000 where c > 900; # update sk or unique(if any)
+ eval update t$t set d = d + 10000 where d > 900; # update non key col
+
+ eval delete from t$t where a < 25;
+ eval delete from t$t where b < 50;
+ eval delete from t$t where c < 75;
+ eval delete from t$t where d < 100;
+
+ # Re-insert the deleted rows
+ let $i = 0;
+ while ($i < 100) {
+ eval insert into t$t values($i, $i, $i, $i);
+ inc $i;
+ }
+ inc $t;
+ }
+ inc $iter;
+}
+source include/sync_slave_sql_with_master.inc;
+
+connection master;
+let $t = 1;
+while ($t <= 8) {
+ let $diff_tables = master:t$t, slave:t$t;
+ source include/diff_tables.inc;
+ inc $t;
+}
+
+# Cleanup
+connection master;
+let $t = 1;
+while ($t <= 8) {
+ eval drop table t$t;
+ inc $t;
+}
+source include/sync_slave_sql_with_master.inc;
+
+enable_query_log;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl_stress.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl_stress.test
new file mode 100644
index 00000000..31e65db8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_read_free_rpl_stress.test
@@ -0,0 +1,22 @@
+source include/have_rocksdb.inc;
+source include/master-slave.inc;
+source include/not_valgrind.inc;
+
+connection slave;
+source include/stop_slave.inc;
+set @@global.rocksdb_read_free_rpl = PK_SK;
+source include/start_slave.inc;
+source rocksdb_read_free_rpl_stress.inc;
+
+connection slave;
+source include/stop_slave.inc;
+set @@global.rocksdb_read_free_rpl = PK_ONLY;
+source include/start_slave.inc;
+source rocksdb_read_free_rpl_stress.inc;
+
+connection slave;
+source include/stop_slave.inc;
+set @@global.rocksdb_read_free_rpl = default;
+source include/start_slave.inc;
+
+source include/rpl_end.inc;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_row_stats.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_row_stats.test
new file mode 100644
index 00000000..ebcc741f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_row_stats.test
@@ -0,0 +1,57 @@
+source include/have_rocksdb.inc;
+create table t1 (a int primary key) engine=rocksdb;
+
+-- echo Verify rocksdb_rows_inserted
+select variable_value into @old_rows_inserted from information_schema.global_status where variable_name = 'rocksdb_rows_inserted';
+insert into t1 values(1);
+select variable_value into @new_rows_inserted from information_schema.global_status where variable_name = 'rocksdb_rows_inserted';
+select @new_rows_inserted - @old_rows_inserted;
+
+-- echo Verify rocksdb_rows_updated
+select variable_value into @old_rows_updated from information_schema.global_status where variable_name = 'rocksdb_rows_updated';
+update t1 set a=2 where a=1;
+select variable_value into @new_rows_updated from information_schema.global_status where variable_name = 'rocksdb_rows_updated';
+select @new_rows_updated - @old_rows_updated;
+
+-- echo Verify rocksdb_rows_read
+select variable_value into @old_rows_read from information_schema.global_status where variable_name = 'rocksdb_rows_read';
+select * from t1;
+select variable_value into @new_rows_read from information_schema.global_status where variable_name = 'rocksdb_rows_read';
+select @new_rows_read - @old_rows_read;
+
+-- echo Verify rocksdb_rows_deleted
+select variable_value into @old_rows_deleted from information_schema.global_status where variable_name = 'rocksdb_rows_deleted';
+delete from t1;
+select variable_value into @new_rows_deleted from information_schema.global_status where variable_name = 'rocksdb_rows_deleted';
+select @new_rows_deleted - @old_rows_deleted;
+
+use mysql;
+create table t1(a int primary key) engine=rocksdb;
+
+-- echo Verify rocksdb_system_rows_inserted
+select variable_value into @old_system_rows_inserted from information_schema.global_status where variable_name = 'rocksdb_system_rows_inserted';
+insert into t1 values(1);
+select variable_value into @new_system_rows_inserted from information_schema.global_status where variable_name = 'rocksdb_system_rows_inserted';
+select @new_system_rows_inserted - @old_system_rows_inserted;
+
+-- echo Verify rocksdb_system_rows_updated
+select variable_value into @old_system_rows_updated from information_schema.global_status where variable_name = 'rocksdb_system_rows_updated';
+update t1 set a=2 where a=1;
+select variable_value into @new_system_rows_updated from information_schema.global_status where variable_name = 'rocksdb_system_rows_updated';
+select @new_system_rows_updated - @old_system_rows_updated;
+
+-- echo Verify rocksdb_system_rows_read
+select variable_value into @old_system_rows_read from information_schema.global_status where variable_name = 'rocksdb_system_rows_read';
+select * from t1;
+select variable_value into @new_system_rows_read from information_schema.global_status where variable_name = 'rocksdb_system_rows_read';
+select @new_system_rows_read - @old_system_rows_read;
+
+-- echo Verify rocksdb_system_rows_deleted
+select variable_value into @old_system_rows_deleted from information_schema.global_status where variable_name = 'rocksdb_system_rows_deleted';
+delete from t1;
+select variable_value into @new_system_rows_deleted from information_schema.global_status where variable_name = 'rocksdb_system_rows_deleted';
+select @new_system_rows_deleted - @old_system_rows_deleted;
+
+drop table t1;
+use test;
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_table_stats_sampling_pct_change.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_table_stats_sampling_pct_change.test
new file mode 100644
index 00000000..5eaeff5c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_table_stats_sampling_pct_change.test
@@ -0,0 +1,80 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# First set sampling rate to 100% and make sure that the baseline is
+# correct and we get the correct number of rows as a result.
+#
+SET @ORIG_PCT = @@ROCKSDB_TABLE_STATS_SAMPLING_PCT;
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = 100;
+
+create table t1 (pk int primary key) engine=rocksdb;
+
+--disable_query_log
+let $i = 0;
+let $n = 10000;
+
+while ($i < $n)
+{
+ inc $i;
+ eval insert t1(pk) values($i);
+}
+--enable_query_log
+
+set global rocksdb_force_flush_memtable_now = true;
+
+# This should return 10K rows.
+select table_rows from information_schema.tables
+where table_schema = database() and table_name = 't1';
+
+let $t1_len = `select data_length from information_schema.tables where table_schema = database() and table_name = 't1'`;
+
+drop table t1;
+
+--disable_warnings
+drop table if exists t2;
+--enable_warnings
+
+#
+# Now, set the sampling rate to 10% and expect to see the same amount of
+# rows.
+#
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = 10;
+
+create table t2 (pk int primary key) engine=rocksdb;
+
+--disable_query_log
+let $i = 0;
+let $n = 10000;
+
+while ($i < $n)
+{
+ inc $i;
+ eval insert t2(pk) values($i);
+}
+--enable_query_log
+
+set global rocksdb_force_flush_memtable_now = true;
+
+# This should return 10K rows as well.
+select table_rows from information_schema.tables
+where table_schema = database() and table_name = 't2';
+
+let $t2_len = `select data_length from information_schema.tables where table_schema = database() and table_name = 't2'`;
+let $diff = `select abs($t1_len - $t2_len)`;
+
+#
+# Table sizes are approximations and for this particular case we allow about
+# 10% deviation.
+#
+if ($diff < 6000) {
+ select table_name from information_schema.tables where table_schema = database() and table_name = 't2';
+}
+
+drop table t2;
+
+SET GLOBAL ROCKSDB_TABLE_STATS_SAMPLING_PCT = @ORIG_PCT;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_timeout_rollback-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_timeout_rollback-master.opt
new file mode 100644
index 00000000..8d8ae3d6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_timeout_rollback-master.opt
@@ -0,0 +1 @@
+--rocksdb_lock_wait_timeout=2
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_timeout_rollback.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_timeout_rollback.test
new file mode 100644
index 00000000..d47af90d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_timeout_rollback.test
@@ -0,0 +1,78 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+SET @@global.rocksdb_rollback_on_timeout = 1;
+show variables like 'rocksdb_rollback_on_timeout';
+
+create table t1 (a int unsigned not null primary key) engine = rocksdb;
+insert into t1 values (1);
+commit;
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con2;
+begin work;
+insert into t1 values (5);
+insert into t1 values (6);
+
+update t1 set a = a + 1 where a = 1;
+
+connection con1;
+begin work;
+insert into t1 values (7);
+insert into t1 values (8);
+
+# This statement will time out. The whole transaction will be
+# rolled back. So values 7 and 8 are not inserted.
+--error ER_LOCK_WAIT_TIMEOUT
+update t1 set a = a + 1 where a = 1;
+
+select * from t1;
+commit;
+
+connection con2;
+select * from t1;
+commit;
+
+connection default;
+select * from t1;
+
+SET @@global.rocksdb_rollback_on_timeout = 0;
+show variables like 'rocksdb_rollback_on_timeout';
+
+connection con2;
+begin work;
+insert into t1 values (9);
+insert into t1 values (10);
+
+update t1 set a = a + 1 where a = 2;
+
+connection con1;
+begin work;
+insert into t1 values (11);
+insert into t1 values (12);
+
+# This statement will time out. Only this statement will be
+# rolled back. So values 11 and 12 are inserted.
+--error ER_LOCK_WAIT_TIMEOUT
+update t1 set a = a + 1 where a = 2;
+
+select * from t1;
+commit;
+
+connection con2;
+select * from t1;
+commit;
+
+connection default;
+select * from t1;
+
+SET @@global.rocksdb_rollback_on_timeout = DEFAULT;
+
+drop table t1;
+disconnect con1;
+disconnect con2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rollback_savepoint.test b/storage/rocksdb/mysql-test/rocksdb/t/rollback_savepoint.test
new file mode 100644
index 00000000..c46d8b07
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rollback_savepoint.test
@@ -0,0 +1,33 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'a');
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 SELECT * FROM t1;
+
+--connect (con1,localhost,root,,)
+--connect (con2,localhost,root,,)
+
+--connection con1
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+SAVEPOINT a;
+SELECT * FROM t1 ORDER BY pk;
+ROLLBACK TO SAVEPOINT a;
+SAVEPOINT a;
+SELECT * FROM t2 ORDER BY pk;
+ROLLBACK TO SAVEPOINT a;
+
+# should not be blocked
+--connection con2
+ALTER TABLE t1 RENAME TO t3;
+
+--connection default
+DROP TABLE t2, t3;
+
+--disconnect con1
+--disconnect con2
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found.cnf b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found.cnf
new file mode 100644
index 00000000..44100e59
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found.cnf
@@ -0,0 +1,9 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+binlog_format=row
+[mysqld.2]
+binlog_format=row
+slave_parallel_workers=4
+slave_exec_mode=SEMI_STRICT
+rocksdb_lock_wait_timeout=5
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found.inc b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found.inc
new file mode 100644
index 00000000..9575abb7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found.inc
@@ -0,0 +1,98 @@
+--source include/have_rocksdb.inc
+--source include/master-slave.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+
+connection master;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+connection master;
+
+create table t0 (a int) engine=myisam;
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1(a int) engine=myisam;
+insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
+create table t2 (
+ pk int primary key,
+ kp1 int,
+ kp2 int,
+ col1 int,
+ key (kp1,kp2)
+) engine=rocksdb;
+# Use RBR for next few statements to avoid the
+# 'Unsafe statement written to the binary log' warnings.
+set @tmp_binlog_format=@@binlog_format;
+set @@binlog_format=ROW;
+insert into t2 select a,a,a,a from t1;
+create table t3 like t2;
+insert into t3 select * from t2;
+set binlog_format=@tmp_binlog_format;
+
+
+# For GitHub issue#166
+# Slave is suspended at ha_rocksdb::read_range_first() -> index_read_map_impl()
+# -> ha_rocksdb::get_row_by_rowid() -- which is after creating an iterator,
+# Seek(), Next() (getting pk=1)
+# and before GetForUpdate() and before creating a snapshot.
+# Deletes remove pk=2 and pk=3, then resumes update on slave.
+# The update resumes with GetForUpdate(pk=1),
+# index_next() -> secondary_index_read() -> get_row_by_rowid(pk=2)
+# then doesn't find a row.
+# The slave should not stop with error (Can't find a record).
+
+--source include/sync_slave_sql_with_master.inc
+
+connection slave;
+let $old_debug = `select @@global.debug`;
+set global debug_dbug= 'd,dbug.rocksdb.get_row_by_rowid';
+--source include/stop_slave.inc
+--source include/start_slave.inc
+
+connection master;
+update t2 set col1=100 where kp1 between 1 and 3 and mod(kp2,2)=0;
+
+connection slave;
+set debug_sync= 'now WAIT_FOR Reached';
+eval set global debug_dbug = '$old_debug';
+set sql_log_bin=0;
+delete from t2 where pk=2;
+delete from t2 where pk=3;
+set debug_sync= 'now SIGNAL signal.rocksdb.get_row_by_rowid_let_running';
+
+connection master;
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t2 where pk < 5;
+
+# For GitHub issue#162 (result file must be updated after fixing #162)
+connection slave;
+set global debug_dbug= 'd,dbug.rocksdb.get_row_by_rowid';
+--source include/stop_slave.inc
+--source include/start_slave.inc
+
+connection master;
+update t3 set col1=100 where kp1 between 1 and 4 and mod(kp2,2)=0;
+
+connection slave;
+call mtr.add_suppression("Deadlock found when trying to get lock");
+set debug_sync= 'now WAIT_FOR Reached';
+eval set global debug_dbug = '$old_debug';
+set sql_log_bin=0;
+delete from t3 where pk=2;
+delete from t3 where pk=3;
+set debug_sync= 'now SIGNAL signal.rocksdb.get_row_by_rowid_let_running';
+
+connection master;
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+# col1 for pk=4 should be 100
+select * from t3 where pk < 5;
+
+set debug_sync='RESET';
+# Cleanup
+connection master;
+drop table t0, t1, t2, t3;
+--source include/rpl_end.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found.test b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found.test
new file mode 100644
index 00000000..36188427
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found.test
@@ -0,0 +1,4 @@
+--source include/have_binlog_format_row.inc
+
+--source rpl_row_not_found.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found_rc.cnf b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found_rc.cnf
new file mode 100644
index 00000000..110d18ab
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found_rc.cnf
@@ -0,0 +1,11 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+binlog_format=row
+transaction_isolation=read-committed
+[mysqld.2]
+binlog_format=row
+slave_parallel_workers=4
+slave_exec_mode=SEMI_STRICT
+rocksdb_lock_wait_timeout=5
+transaction_isolation=read-committed
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found_rc.test
new file mode 100644
index 00000000..36188427
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_not_found_rc.test
@@ -0,0 +1,4 @@
+--source include/have_binlog_format_row.inc
+
+--source rpl_row_not_found.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_rocksdb.cnf b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_rocksdb.cnf
new file mode 100644
index 00000000..09a1c853
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_rocksdb.cnf
@@ -0,0 +1 @@
+!include suite/rpl/my.cnf
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_rocksdb.test b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_rocksdb.test
new file mode 100644
index 00000000..b103dfc3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_rocksdb.test
@@ -0,0 +1,48 @@
+--source include/have_rocksdb.inc
+
+source include/master-slave.inc;
+source include/have_binlog_format_row.inc;
+
+connection master;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+connection master;
+
+select @@binlog_format;
+create table t1 (pk int primary key) engine=rocksdb;
+insert into t1 values (1),(2),(3);
+
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+
+select * from t1;
+
+connection master;
+drop table t1;
+
+--echo #
+--echo # Issue #18: slave crash on update with row based binary logging
+--echo #
+create table t1 (id int primary key, value int, value2 int, index(value)) engine=rocksdb;
+insert into t1 values (1,1,1);
+insert into t1 values (2,1,1);
+insert into t1 values (3,1,1);
+insert into t1 values (4,1,1);
+insert into t1 values (5,1,1);
+update t1 set value2=100 where id=1;
+update t1 set value2=200 where id=2;
+update t1 set value2=300 where id=3;
+
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t1 where id=1;
+select * from t1 where id=2;
+select * from t1 where id=3;
+
+connection master;
+drop table t1;
+
+--source include/rpl_end.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_stats-slave.opt b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_stats-slave.opt
new file mode 100644
index 00000000..039295e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_stats-slave.opt
@@ -0,0 +1 @@
+--userstat=ON
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_stats.cnf b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_stats.cnf
new file mode 100644
index 00000000..09a1c853
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_stats.cnf
@@ -0,0 +1 @@
+!include suite/rpl/my.cnf
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_stats.test b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_stats.test
new file mode 100644
index 00000000..db4d1ca6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_stats.test
@@ -0,0 +1,47 @@
+--source include/have_rocksdb.inc
+
+source include/have_binlog_format_row.inc;
+source include/master-slave.inc;
+
+connection master;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+# initialization/insert
+connection master;
+# creating save_read_stats() and get_read_stats() procedures
+--source init_stats_procedure.inc
+
+create table t1 (id int primary key, value int);
+insert into t1 values (1,1), (2,2), (3,3), (4,4), (5,5);
+--source include/sync_slave_sql_with_master.inc
+
+connection slave;
+call save_read_stats();
+connection master;
+update t1 set value=value+1 where id=1;
+update t1 set value=value+1 where id=3;
+select * from t1;
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+call get_read_stats();
+select * from t1;
+call save_read_stats();
+
+connection master;
+delete from t1 where id in (4,5);
+select * from t1;
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+call get_read_stats();
+select * from t1;
+
+
+# cleanup
+connection master;
+drop table t1;
+--source drop_stats_procedure.inc
+
+--source include/rpl_end.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_triggers.cnf b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_triggers.cnf
new file mode 100644
index 00000000..b0a37fd3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_triggers.cnf
@@ -0,0 +1,19 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+binlog_format=row
+gtid_mode=ON
+enforce_gtid_consistency
+log_slave_updates
+binlog_row_image=FULL
+rocksdb_read_free_rpl=PK_SK
+rocksdb_strict_collation_check=0
+[mysqld.2]
+binlog_format=row
+gtid_mode=ON
+enforce_gtid_consistency
+log_slave_updates
+binlog_row_image=FULL
+rocksdb_read_free_rpl=PK_SK
+rocksdb_strict_collation_check=0
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_triggers.test b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_triggers.test
new file mode 100644
index 00000000..4490353b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_row_triggers.test
@@ -0,0 +1,262 @@
+-- source include/have_binlog_format_row.inc
+-- source include/have_rbr_triggers.inc
+-- source include/have_rocksdb.inc
+-- source include/master-slave.inc
+
+-- echo # Test of row replication with triggers on the slave side
+connection master;
+CREATE TABLE t1 (C1 CHAR(1) primary key, C2 CHAR(1));
+SELECT * FROM t1;
+
+sync_slave_with_master;
+
+connection slave;
+SET @old_slave_exec_mode= @@global.slave_exec_mode;
+SET @old_slave_run_triggers_for_rbr= @@global.slave_run_triggers_for_rbr;
+SET @@global.slave_exec_mode= IDEMPOTENT;
+SET @@global.slave_run_triggers_for_rbr= YES;
+SELECT * FROM t1;
+create table t2 (id char(2) primary key, cnt int, o char(1), n char(1));
+insert into t2 values
+ ('u0', 0, ' ', ' '),('u1', 0, ' ', ' '),
+ ('d0', 0, ' ', ' '),('d1', 0, ' ', ' '),
+ ('i0', 0, ' ', ' '),('i1', 0, ' ', ' ');
+create trigger t1_cnt_b before update on t1 for each row
+ update t2 set cnt=cnt+1, o=old.C1, n=new.C1 where id = 'u0';
+create trigger t1_cnt_db before delete on t1 for each row
+ update t2 set cnt=cnt+1, o=old.C1, n=' ' where id = 'd0';
+create trigger t1_cnt_ib before insert on t1 for each row
+ update t2 set cnt=cnt+1, n=new.C1, o=' ' where id = 'i0';
+create trigger t1_cnt_a after update on t1 for each row
+ update t2 set cnt=cnt+1, o=old.C1, n=new.C1 where id = 'u1';
+create trigger t1_cnt_da after delete on t1 for each row
+ update t2 set cnt=cnt+1, o=old.C1, n=' ' where id = 'd1';
+create trigger t1_cnt_ia after insert on t1 for each row
+ update t2 set cnt=cnt+1, n=new.C1, o=' ' where id = 'i1';
+SELECT * FROM t2 order by id;
+
+connection master;
+--echo # INSERT triggers test
+insert into t1 values ('a','b');
+
+sync_slave_with_master;
+
+connection slave;
+SELECT * FROM t2 order by id;
+
+connection master;
+--echo # UPDATE triggers test
+update t1 set C1= 'd';
+sync_slave_with_master;
+
+connection slave;
+SELECT * FROM t2 order by id;
+
+connection master;
+--echo # DELETE triggers test
+delete from t1 where C1='d';
+
+sync_slave_with_master;
+
+connection slave;
+SELECT * FROM t2 order by id;
+--echo # INSERT triggers which cause also UPDATE test (insert duplicate row)
+insert into t1 values ('0','1');
+SELECT * FROM t2 order by id;
+
+connection master;
+insert into t1 values ('0','1');
+
+sync_slave_with_master;
+
+connection slave;
+SELECT * FROM t2 order by id;
+--echo # INSERT triggers which cause also DELETE test
+--echo # (insert duplicate row in table referenced by foreign key)
+insert into t1 values ('1','1');
+
+connection master;
+# Foreign key is not supported in MyRocks
+#CREATE TABLE t3 (C1 CHAR(1) primary key, FOREIGN KEY (C1) REFERENCES t1(C1) );
+#insert into t1 values ('1','1');
+
+#sync_slave_with_master;
+
+#connection slave;
+#SELECT * FROM t2 order by id;
+
+#connection master;
+#drop table t3,t1;
+drop table if exists t1;
+
+sync_slave_with_master;
+
+connection slave;
+SET @@global.slave_exec_mode= @old_slave_exec_mode;
+SET @@global.slave_run_triggers_for_rbr= @old_slave_run_triggers_for_rbr;
+drop table t2;
+
+--connection master
+CREATE TABLE t1 (i INT);
+CREATE TABLE t2 (i INT);
+
+--sync_slave_with_master
+SET @old_slave_run_triggers_for_rbr= @@global.slave_run_triggers_for_rbr;
+SET GLOBAL slave_run_triggers_for_rbr=YES;
+CREATE TRIGGER tr AFTER INSERT ON t1 FOR EACH ROW
+ INSERT INTO t2 VALUES (new.i);
+
+--connection master
+BEGIN;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+COMMIT;
+--sync_slave_with_master
+select * from t2;
+SET @@global.slave_run_triggers_for_rbr= @old_slave_run_triggers_for_rbr;
+--connection master
+drop tables t2,t1;
+
+--sync_slave_with_master
+
+-- echo # Triggers on slave do not work if master has some
+
+connection master;
+CREATE TABLE t1 (C1 CHAR(1) primary key, C2 CHAR(1));
+SELECT * FROM t1;
+create trigger t1_dummy before delete on t1 for each row
+ set @dummy= 1;
+
+sync_slave_with_master;
+
+connection slave;
+SET @old_slave_exec_mode= @@global.slave_exec_mode;
+SET @old_slave_run_triggers_for_rbr= @@global.slave_run_triggers_for_rbr;
+SET @@global.slave_exec_mode= IDEMPOTENT;
+SET @@global.slave_run_triggers_for_rbr= YES;
+SELECT * FROM t1;
+create table t2 (id char(2) primary key, cnt int, o char(1), n char(1));
+insert into t2 values
+ ('u0', 0, ' ', ' '),('u1', 0, ' ', ' '),
+ ('d0', 0, ' ', ' '),('d1', 0, ' ', ' '),
+ ('i0', 0, ' ', ' '),('i1', 0, ' ', ' ');
+create trigger t1_cnt_b before update on t1 for each row
+ update t2 set cnt=cnt+1, o=old.C1, n=new.C1 where id = 'u0';
+create trigger t1_cnt_ib before insert on t1 for each row
+ update t2 set cnt=cnt+1, n=new.C1, o=' ' where id = 'i0';
+create trigger t1_cnt_a after update on t1 for each row
+ update t2 set cnt=cnt+1, o=old.C1, n=new.C1 where id = 'u1';
+create trigger t1_cnt_da after delete on t1 for each row
+ update t2 set cnt=cnt+1, o=old.C1, n=' ' where id = 'd1';
+create trigger t1_cnt_ia after insert on t1 for each row
+ update t2 set cnt=cnt+1, n=new.C1, o=' ' where id = 'i1';
+SELECT * FROM t2 order by id;
+
+connection master;
+--echo # INSERT triggers test
+insert into t1 values ('a','b');
+
+sync_slave_with_master;
+
+connection slave;
+SELECT * FROM t2 order by id;
+connection master;
+--echo # UPDATE triggers test
+update t1 set C1= 'd';
+
+sync_slave_with_master;
+
+connection slave;
+SELECT * FROM t2 order by id;
+
+connection master;
+--echo # DELETE triggers test
+delete from t1 where C1='d';
+
+sync_slave_with_master;
+
+connection slave;
+SELECT * FROM t2 order by id;
+--echo # INSERT triggers which cause also UPDATE test (insert duplicate row)
+insert into t1 values ('0','1');
+SELECT * FROM t2 order by id;
+
+
+connection master;
+insert into t1 values ('0','1');
+
+sync_slave_with_master;
+
+connection slave;
+SELECT * FROM t2 order by id;
+--echo # INSERT triggers which cause also DELETE test
+--echo # (insert duplicate row in table referenced by foreign key)
+insert into t1 values ('1','1');
+
+connection master;
+
+# Foreign Key is not supported in MyRocks
+#CREATE TABLE t3 (C1 CHAR(1) primary key, FOREIGN KEY (C1) REFERENCES t1(C1) );
+#insert into t1 values ('1','1');
+
+#sync_slave_with_master;
+
+#connection slave;
+#SELECT * FROM t2 order by id;
+
+#connection master;
+#drop table t3,t1;
+drop table if exists t1;
+
+sync_slave_with_master;
+
+connection slave;
+SET @@global.slave_exec_mode= @old_slave_exec_mode;
+SET @@global.slave_run_triggers_for_rbr= @old_slave_run_triggers_for_rbr;
+drop table t2;
+
+--echo #
+--echo # MDEV-5513: Trigger is applied to the rows after first one
+--echo #
+
+--connection master
+create table t1 (a int, b int);
+create table tlog (a int auto_increment primary key);
+set sql_log_bin=0;
+create trigger tr1 after insert on t1 for each row insert into tlog values (null);
+set sql_log_bin=1;
+
+sync_slave_with_master;
+--connection slave
+
+set @slave_run_triggers_for_rbr.saved = @@slave_run_triggers_for_rbr;
+set global slave_run_triggers_for_rbr=1;
+create trigger tr2 before insert on t1 for each row set new.b = new.a;
+
+--connection master
+insert into t1 values (1,10),(2,20),(3,30);
+
+--sync_slave_with_master
+select * from t1;
+
+--echo #
+--echo # Verify slave skips running triggers if master ran and logged the row events for triggers
+--echo #
+--connection master
+create table t4(a int, b int);
+delete from tlog;
+create trigger tr4 before insert on t4 for each row insert into tlog values (null);
+insert into t4 values (1, 10),(2, 20);
+select * from tlog;
+
+--sync_slave_with_master
+select * from t4;
+select * from tlog;
+
+# Cleanup
+set global slave_run_triggers_for_rbr = @slave_run_triggers_for_rbr.saved;
+--connection master
+drop table t1, tlog, t4;
+sync_slave_with_master;
+
+--source include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_savepoint.cnf b/storage/rocksdb/mysql-test/rocksdb/t/rpl_savepoint.cnf
new file mode 100644
index 00000000..09a1c853
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_savepoint.cnf
@@ -0,0 +1 @@
+!include suite/rpl/my.cnf
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_savepoint.test b/storage/rocksdb/mysql-test/rocksdb/t/rpl_savepoint.test
new file mode 100644
index 00000000..56d14f92
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_savepoint.test
@@ -0,0 +1,91 @@
+--source include/have_rocksdb.inc
+
+source include/have_binlog_format_row.inc;
+source include/master-slave.inc;
+
+connection master;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+connection master;
+
+create table t1 (id int primary key, value int);
+insert into t1 values (1,1), (2,2), (3,3);
+
+begin;
+insert into t1 values (11, 1);
+savepoint a;
+insert into t1 values (12, 1);
+--error ER_ROLLBACK_TO_SAVEPOINT
+rollback to savepoint a;
+--error ER_ROLLBACK_ONLY
+commit;
+commit;
+select * from t1;
+
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+
+select * from t1;
+
+connection master;
+begin;
+insert into t1 values (21, 1);
+savepoint a;
+insert into t1 values (22, 1);
+--error ER_ROLLBACK_TO_SAVEPOINT
+rollback to savepoint a;
+--error ER_ROLLBACK_ONLY
+insert into t1 values (23, 1);
+--error ER_ROLLBACK_ONLY
+commit;
+commit;
+select * from t1;
+
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t1;
+
+
+connection master;
+begin;
+insert into t1 values (31, 1);
+savepoint a;
+insert into t1 values (32, 1);
+savepoint b;
+insert into t1 values (33, 1);
+--error ER_ROLLBACK_TO_SAVEPOINT
+rollback to savepoint a;
+--error ER_ROLLBACK_ONLY
+insert into t1 values (34, 1);
+rollback;
+select * from t1;
+
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t1;
+
+### GitHub Issue#195
+connection master;
+SET autocommit=off;
+select * from t1;
+SAVEPOINT A;
+select * from t1;
+SAVEPOINT A;
+insert into t1 values (35, 35);
+--error ER_ROLLBACK_TO_SAVEPOINT
+ROLLBACK TO SAVEPOINT A;
+--error ER_ROLLBACK_ONLY
+START TRANSACTION;
+select * from t1;
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t1;
+
+
+connection master;
+drop table t1;
+
+--source include/rpl_end.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_statement.cnf b/storage/rocksdb/mysql-test/rocksdb/t/rpl_statement.cnf
new file mode 100644
index 00000000..6e5130c1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_statement.cnf
@@ -0,0 +1,7 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+binlog_format=statement
+[mysqld.2]
+binlog_format=mixed
+rocksdb_lock_wait_timeout=5
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_statement.test b/storage/rocksdb/mysql-test/rocksdb/t/rpl_statement.test
new file mode 100644
index 00000000..cb5f5e04
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_statement.test
@@ -0,0 +1,59 @@
+--source include/have_rocksdb.inc
+source include/master-slave.inc;
+
+source include/have_binlog_format_statement.inc;
+
+connection master;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+connection master;
+
+select @@binlog_format;
+create table t1 (pk int primary key) engine=rocksdb;
+--error ER_BINLOG_STMT_MODE_AND_ROW_ENGINE
+insert into t1 values (1),(2),(3);
+
+set session rocksdb_unsafe_for_binlog=on;
+insert into t1 values (1),(2),(3);
+select * from t1;
+delete from t1;
+set session rocksdb_unsafe_for_binlog=off;
+
+--error ER_BINLOG_STMT_MODE_AND_ROW_ENGINE
+insert into t1 values (1),(2),(3);
+
+set binlog_format=row;
+insert into t1 values (1),(2),(3);
+
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+
+select * from t1;
+
+connection master;
+drop table t1;
+
+create table t1 (id int primary key, value int, value2 int, index(value)) engine=rocksdb;
+insert into t1 values (1,1,1);
+insert into t1 values (2,1,1);
+insert into t1 values (3,1,1);
+insert into t1 values (4,1,1);
+insert into t1 values (5,1,1);
+update t1 set value2=100 where id=1;
+update t1 set value2=200 where id=2;
+update t1 set value2=300 where id=3;
+
+--source include/sync_slave_sql_with_master.inc
+connection slave;
+select * from t1 where id=1;
+select * from t1 where id=2;
+select * from t1 where id=3;
+
+connection master;
+drop table t1;
+set binlog_format=row;
+
+--source include/rpl_end.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_statement_not_found.cnf b/storage/rocksdb/mysql-test/rocksdb/t/rpl_statement_not_found.cnf
new file mode 100644
index 00000000..470b073d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_statement_not_found.cnf
@@ -0,0 +1,9 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+binlog_format=statement
+rocksdb_unsafe_for_binlog=1
+[mysqld.2]
+binlog_format=row
+slave_parallel_workers=4
+rocksdb_lock_wait_timeout=5
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rpl_statement_not_found.test b/storage/rocksdb/mysql-test/rocksdb/t/rpl_statement_not_found.test
new file mode 100644
index 00000000..019e83ac
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rpl_statement_not_found.test
@@ -0,0 +1,3 @@
+--source include/have_binlog_format_statement.inc
+--source rpl_row_not_found.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rqg.inc b/storage/rocksdb/mysql-test/rocksdb/t/rqg.inc
new file mode 100644
index 00000000..0f3246de
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rqg.inc
@@ -0,0 +1,44 @@
+#
+# Random Query Generator tests
+#
+# Arguments needed to be set by the test when including this one:
+# $TESTDIR : name of sub-directory in conf containing the data/grammar files
+# $GRAMMAR_FILES: space separated list of grammar files
+# $DATA_FILE: name of the data file
+#
+
+let $MYSQL_BASEDIR = `SELECT @@BASEDIR`;
+let RQG_BASE = $MYSQL_BASEDIR/rqg/rqg/common/mariadb-patches;
+let MYSQL_SOCKET = `SELECT @@SOCKET`;
+let GRAMMAR_FILES = $GRAMMAR_FILES;
+let DATA_FILE = $DATA_FILE;
+let TESTDIR = $TESTDIR;
+let $TESTDB = rqg_$TESTDIR;
+let TESTDB = $TESTDB;
+
+--eval CREATE DATABASE IF NOT EXISTS $TESTDB
+
+--perl
+
+$ENV{'RQG_HOME'}=$ENV{'RQG_BASE'};
+foreach $grammar_file (split(/ /, $ENV{'GRAMMAR_FILES'})) {
+
+ # Errors from the gentest.pl file will be captured in the results file
+ my $cmd = "perl $ENV{'RQG_BASE'}/gentest.pl " .
+ "--dsn=DBI:MariaDB:host=:port=:user=root:database=$ENV{'TESTDB'}" .
+ ":mariadb_socket=$ENV{'MYSQL_SOCKET'} " .
+ "--gendata=$ENV{'RQG_BASE'}/conf/$ENV{'TESTDIR'}/$ENV{'DATA_FILE'} " .
+ "--grammar=$ENV{'RQG_BASE'}/conf/$ENV{'TESTDIR'}/$grammar_file " .
+ "--threads=5 --queries=10000 --duration=60 --sqltrace 2>&1 >> " .
+ "$ENV{'MYSQLTEST_VARDIR'}/tmp/$ENV{'TESTDB'}.log";
+
+ print "Running test with grammar file $grammar_file\n";
+ system($cmd);
+ if ($? != 0) {
+ print ("Failure running test! Command executed: $cmd\n");
+ }
+}
+
+EOF
+
+--eval DROP DATABASE $TESTDB
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rqg_examples-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rqg_examples-master.opt
new file mode 100644
index 00000000..5b714857
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rqg_examples-master.opt
@@ -0,0 +1 @@
+--rocksdb_strict_collation_check=0
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rqg_examples.test b/storage/rocksdb/mysql-test/rocksdb/t/rqg_examples.test
new file mode 100644
index 00000000..80bae004
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rqg_examples.test
@@ -0,0 +1,12 @@
+--source include/have_rocksdb.inc
+# Don't run the RQG tests with --rpc_protocol because the connections and
+# queries will be coming from Perl where we don't have any ability to
+# specify the query attributes needed for the RPC protocol.
+--source include/not_rpc_protocol.inc
+
+# RQG's examples test
+let $TESTDIR = examples;
+let $GRAMMAR_FILES = example.yy;
+let $DATA_FILE = example.zz;
+
+--source rqg.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rqg_runtime-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rqg_runtime-master.opt
new file mode 100644
index 00000000..f4942738
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rqg_runtime-master.opt
@@ -0,0 +1 @@
+--rocksdb_strict_collation_check=0 --secure-file-priv=/tmp
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rqg_runtime.test b/storage/rocksdb/mysql-test/rocksdb/t/rqg_runtime.test
new file mode 100644
index 00000000..2e560c86
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rqg_runtime.test
@@ -0,0 +1,58 @@
+--source include/have_rocksdb.inc
+# Don't run the RQG tests with --rpc_protocol because the connections and
+# queries will be coming from Perl where we don't have any ability to
+# specify the query attributes needed for the RPC protocol.
+--source include/not_rpc_protocol.inc
+
+call mtr.add_suppression("Did not write failed ");
+call mtr.add_suppression("Can't open and lock privilege tables");
+call mtr.add_suppression("Attempt to delete the trigger file");
+
+SET @ORIG_EVENT_SCHEDULER = @@EVENT_SCHEDULER;
+
+# mysql.user and mysql.tables_priv are modified by the
+# tests, so they need to be restored to the original
+# state.
+--disable_warnings
+CREATE TABLE mysql.user_temp LIKE mysql.user;
+INSERT mysql.user_temp SELECT * FROM mysql.user;
+CREATE TABLE mysql.tables_priv_temp LIKE mysql.tables_priv;
+INSERT mysql.tables_priv_temp SELECT * FROM mysql.tables_priv_temp;
+--enable_warnings
+
+# RQG's runtime test
+let $TESTDIR = runtime;
+
+let $GRAMMAR_FILES = alter_online.yy;
+let $DATA_FILE = alter_online.zz;
+
+--source rqg.inc
+
+let $GRAMMAR_FILES = concurrency_1.yy;
+let $DATA_FILE = concurrency_1.zz;
+
+--source rqg.inc
+
+let $GRAMMAR_FILES = connect_kill_sql.yy;
+let $DATA_FILE = connect_kill_data.zz;
+
+--source rqg.inc
+
+let $GRAMMAR_FILES = metadata_stability.yy;
+let $DATA_FILE = metadata_stability.zz;
+
+--source rqg.inc
+
+--disable_warnings
+DELETE FROM mysql.tables_priv;
+DELETE FROM mysql.user;
+INSERT mysql.user SELECT * FROM mysql.user_temp;
+INSERT mysql.tables_priv SELECT * FROM mysql.tables_priv_temp;
+DROP TABLE mysql.user_temp;
+DROP TABLE mysql.tables_priv_temp;
+DROP TABLE IF EXISTS test.executors;
+DROP DATABASE IF EXISTS testdb_N;
+DROP DATABASE IF EXISTS testdb_S;
+--enable_warnings
+
+SET GLOBAL EVENT_SCHEDULER = @ORIG_EVENT_SCHEDULER;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rqg_transactions-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/rqg_transactions-master.opt
new file mode 100644
index 00000000..5b714857
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rqg_transactions-master.opt
@@ -0,0 +1 @@
+--rocksdb_strict_collation_check=0
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rqg_transactions.test b/storage/rocksdb/mysql-test/rocksdb/t/rqg_transactions.test
new file mode 100644
index 00000000..383b9aed
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rqg_transactions.test
@@ -0,0 +1,14 @@
+--source include/have_rocksdb.inc
+# Don't run the RQG tests with --rpc_protocol because the connections and
+# queries will be coming from Perl where we don't have any ability to
+# specify the query attributes needed for the RPC protocol.
+--source include/not_rpc_protocol.inc
+
+call mtr.add_suppression("Deadlock found when trying to get lock");
+
+# RQG's transactions test
+let $TESTDIR = transactions;
+let $GRAMMAR_FILES = transactions.yy repeatable_read.yy transaction_durability.yy transactions-flat.yy combinations.yy repeatable_read.yy transaction_durability.yy transactions-flat.yy;
+let $DATA_FILE = transactions.zz;
+
+--source rqg.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/se-innodb.out b/storage/rocksdb/mysql-test/rocksdb/t/se-innodb.out
new file mode 100644
index 00000000..406e5066
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/se-innodb.out
@@ -0,0 +1 @@
+Can't open perl script "./mtr": No such file or directory
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/secondary_key_update_lock.test b/storage/rocksdb/mysql-test/rocksdb/t/secondary_key_update_lock.test
new file mode 100644
index 00000000..b43a32b6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/secondary_key_update_lock.test
@@ -0,0 +1,26 @@
+--source include/have_rocksdb.inc
+
+# Tests if locks are held for the secondary keys of old rows in updates
+
+connect (con, localhost, root,,);
+
+connection default;
+create table t1 (a int primary key, b int unique key) engine = rocksdb;
+insert into t1 values(1, 1);
+
+connection con;
+begin;
+update t1 set b = 2 where b = 1; # this should lock the row where b = 1
+
+connection default;
+error ER_LOCK_WAIT_TIMEOUT;
+insert into t1 values(2, 1); # should error out with lock_wait_timeout
+
+connection con;
+rollback;
+select * from t1;
+
+# Cleanup
+connection default;
+drop table t1;
+disconnect con;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/select.test b/storage/rocksdb/mysql-test/rocksdb/t/select.test
new file mode 100644
index 00000000..3d9bdc7b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/select.test
@@ -0,0 +1,202 @@
+--source include/have_rocksdb.inc
+
+#
+# Basic SELECT statements
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (100,'foobar'),(1,'z'),(200,'bar');
+
+CREATE TABLE t2 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (a,b) SELECT a, b FROM t1;
+INSERT INTO t1 (a,b) SELECT a, b FROM t2;
+
+--sorted_result
+SELECT * FROM t1;
+
+# Modifiers
+
+--sorted_result
+SELECT DISTINCT a FROM t1;
+
+--sorted_result
+SELECT ALL b, a FROM t1;
+
+# Optimizer and cache directives should not have any visible effect here,
+# but we will add them for completness
+
+--sorted_result
+SELECT STRAIGHT_JOIN SQL_CACHE t1.* FROM t2, t1 WHERE t1.a <> t2.a;
+
+--sorted_result
+SELECT SQL_SMALL_RESULT SQL_NO_CACHE t1.a FROM t1, t2;
+
+--sorted_result
+SELECT SQL_BIG_RESULT SQL_CALC_FOUND_ROWS DISTINCT(t2.a)
+ FROM t1 t1_1, t2, t1 t1_2;
+SELECT FOUND_ROWS();
+
+SET @save_query_cache=@@global.query_cache_size;
+SET GLOBAL query_cache_size = 1024*1024;
+--sorted_result
+SELECT SQL_CACHE * FROM t1, t2;
+SET @@global.query_cache_size=@save_query_cache;
+
+# Combination of main clauses
+
+--sorted_result
+SELECT a+10 AS field1, CONCAT(b,':',b) AS field2 FROM t1
+WHERE b > 'b' AND a IS NOT NULL
+GROUP BY 2 DESC, field1 ASC
+HAVING field1 < 1000
+ORDER BY field2, 1 DESC, field1*2
+LIMIT 5 OFFSET 1;
+
+# ROLLUP
+--sorted_result
+SELECT SUM(a), MAX(a), b FROM t1 GROUP BY b WITH ROLLUP;
+
+# Procedure
+
+--sorted_result
+SELECT * FROM t2 WHERE a>0 PROCEDURE ANALYSE();
+
+# SELECT INTO
+let $datadir = `SELECT @@datadir`;
+
+--replace_result $datadir <DATADIR>
+eval
+SELECT t1.a, t2.b FROM t2, t1 WHERE t1.a = t2.a ORDER BY t2.b, t1.a
+ INTO OUTFILE '$datadir/select.out'
+ CHARACTER SET utf8
+ FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '''';
+--cat_file $datadir/select.out
+--remove_file $datadir/select.out
+
+--replace_result $datadir <DATADIR>
+--error ER_TOO_MANY_ROWS
+eval
+SELECT t1.a, t2.b FROM t2, t1 WHERE t1.a = t2.a ORDER BY t2.b, t1.a
+ INTO DUMPFILE '$datadir/select.dump';
+--remove_file $datadir/select.dump
+--replace_result $datadir <DATADIR>
+eval
+SELECT t1.*, t2.* FROM t1, t2 ORDER BY t2.b, t1.a, t2.a, t1.b, t1.pk, t2.pk LIMIT 1
+ INTO DUMPFILE '$datadir/select.dump';
+
+--cat_file $datadir/select.dump
+--echo
+--remove_file $datadir/select.dump
+
+SELECT MIN(a), MAX(a) FROM t1 INTO @min, @max;
+SELECT @min, @max;
+
+# Joins
+
+--sorted_result
+SELECT t1_1.*, t2.* FROM t2, t1 AS t1_1, t1 AS t1_2
+ WHERE t1_1.a = t1_2.a AND t2.a = t1_1.a;
+
+--sorted_result
+SELECT alias1.* FROM ( SELECT a,b FROM t1 ) alias1, t2 WHERE t2.a IN (100,200);
+
+--sorted_result
+SELECT t1.a FROM { OJ t1 LEFT OUTER JOIN t2 ON t1.a = t2.a+10 };
+
+--sorted_result
+SELECT t1.* FROM t2 INNER JOIN t1;
+
+--sorted_result
+SELECT t1_2.* FROM t1 t1_1 CROSS JOIN t1 t1_2 ON t1_1.b = t1_2.b;
+
+--sorted_result
+SELECT t1.a, t2.b FROM t2 STRAIGHT_JOIN t1 WHERE t1.b > t2.b;
+
+SELECT t1.a, t2.b FROM t2 STRAIGHT_JOIN t1 ON t1.b > t2.b ORDER BY t1.a, t2.b;
+
+SELECT t2.* FROM t1 LEFT JOIN t2 USING (a) ORDER BY t2.a, t2.b LIMIT 1;
+
+--sorted_result
+SELECT t2.* FROM t2 LEFT OUTER JOIN t1 ON t1.a = t2.a WHERE t1.a IS NOT NULL;
+
+SELECT SUM(t2.a) FROM t1 RIGHT JOIN t2 ON t2.b = t1.b;
+
+SELECT MIN(t2.a) FROM t1 RIGHT OUTER JOIN t2 USING (b,a);
+
+--sorted_result
+SELECT alias.b FROM t1 NATURAL JOIN ( SELECT a,b FROM t1 ) alias WHERE b > '';
+
+--sorted_result
+SELECT t2.b FROM ( SELECT a,b FROM t1 ) alias NATURAL LEFT JOIN t2 WHERE b IS NOT NULL;
+
+--sorted_result
+SELECT t1.*, t2.* FROM t1 NATURAL LEFT OUTER JOIN t2;
+
+--sorted_result
+SELECT t2_2.* FROM t2 t2_1 NATURAL RIGHT JOIN t2 t2_2 WHERE t2_1.a IN ( SELECT a FROM t1 );
+
+--sorted_result
+SELECT t1_2.b FROM t1 t1_1 NATURAL RIGHT OUTER JOIN t1 t1_2 INNER JOIN t2;
+
+# Subquery as scalar operand, subquery in the FROM clause
+
+--sorted_result
+SELECT ( SELECT MIN(a) FROM ( SELECT a,b FROM t1 ) alias1 ) AS min_a FROM t2;
+
+# Comparison using subqueries
+
+--sorted_result
+SELECT a,b FROM t2 WHERE a = ( SELECT MIN(a) FROM t1 );
+
+--sorted_result
+SELECT a,b FROM t2 WHERE b LIKE ( SELECT b FROM t1 ORDER BY b LIMIT 1 );
+
+# Subquery with IN, correlated subquery
+
+--sorted_result
+SELECT t2.* FROM t1 t1_outer, t2 WHERE ( t1_outer.a, t2.b ) IN ( SELECT a, b FROM t2 WHERE a = t1_outer.a );
+
+# Subquery with ANY, ALL
+
+--sorted_result
+SELECT a,b FROM t2 WHERE b = ANY ( SELECT b FROM t1 WHERE a > 1 );
+
+--sorted_result
+SELECT a,b FROM t2 WHERE b > ALL ( SELECT b FROM t1 WHERE b < 'foo' );
+
+# Row subqueries
+
+--sorted_result
+SELECT a,b FROM t1 WHERE ROW(a, b) = ( SELECT a, b FROM t2 ORDER BY a, b LIMIT 1 );
+
+# Subquery with EXISTS
+
+--sorted_result
+SELECT a,b FROM t1 WHERE EXISTS ( SELECT a,b FROM t2 WHERE t2.b > t1.b );
+
+# Subquery in ORDER BY
+
+--sorted_result
+SELECT t1.* FROM t1, t2 ORDER BY ( SELECT b FROM t1 WHERE a IS NULL ORDER BY b LIMIT 1 ) DESC;
+
+# Subquery in HAVING
+
+--sorted_result
+SELECT a, b FROM t1 HAVING a IN ( SELECT a FROM t2 WHERE b = t1.b );
+
+# Union
+
+--sorted_result
+SELECT a,b FROM t1 UNION SELECT a,b FROM t2 UNION DISTINCT SELECT a,b FROM t1;
+
+--sorted_result
+SELECT a,b FROM t1 UNION SELECT a,b FROM t2 UNION ALL SELECT a,b FROM t1;
+
+
+# Cleanup
+DROP TABLE t1, t2;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/select_for_update.test b/storage/rocksdb/mysql-test/rocksdb/t/select_for_update.test
new file mode 100644
index 00000000..14fdfb78
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/select_for_update.test
@@ -0,0 +1,55 @@
+--source include/have_rocksdb.inc
+
+#
+# SELECT .. FOR UPDATE
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--enable_connect_log
+
+--source include/count_sessions.inc
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'a');
+
+--connect (con1,localhost,root,,)
+BEGIN;
+--sorted_result
+SELECT a,b FROM t1 WHERE b='a' FOR UPDATE;
+
+--connection default
+SET lock_wait_timeout = 1;
+
+# Should still be able to select
+
+--sorted_result
+SELECT a,b FROM t1 WHERE b='a';
+
+# ... but not with LOCK IN SHARE MODE
+
+--sorted_result
+--error ER_LOCK_WAIT_TIMEOUT
+SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE;
+
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE t1 SET b='c' WHERE b='a';
+
+--connection con1
+COMMIT;
+--sorted_result
+SELECT a,b FROM t1;
+
+--disconnect con1
+--connection default
+# Now it can be updated all right
+UPDATE t1 SET b='c' WHERE b='a';
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+--source include/wait_until_count_sessions.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/select_for_update_skip_locked_nowait.test b/storage/rocksdb/mysql-test/rocksdb/t/select_for_update_skip_locked_nowait.test
new file mode 100644
index 00000000..c6ebbfa3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/select_for_update_skip_locked_nowait.test
@@ -0,0 +1,48 @@
+--source include/have_rocksdb.inc
+
+##############################################################################
+## SKIP LOCKED | NOWAIT are *not* supported for SELECT...FOR UPDATE in RocksDB
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (a int primary key) engine=rocksdb;
+
+insert into t1 values (1), (2), (3);
+
+### SKIP LOCKED
+
+--echo Should succeed since no table gets involved
+select 1 for update skip locked;
+
+--error ER_NO_SUCH_TABLE
+select * from nonexistence for update skip locked;
+
+--error ER_ILLEGAL_HA
+select * from t1 for update skip locked;
+
+--error ER_ILLEGAL_HA
+select * from t1 where a > 1 and a < 3 for update skip locked;
+
+--error ER_ILLEGAL_HA
+insert into t1 select * from t1 for update skip locked;
+
+### NOWAIT
+
+--echo Should succeed since no table gets involved
+select 1 for update nowait;
+
+--error ER_NO_SUCH_TABLE
+select * from nonexistence for update nowait;
+
+--error ER_ILLEGAL_HA
+select * from t1 for update nowait;
+
+--error ER_ILLEGAL_HA
+select * from t1 where a > 1 and a < 3 for update nowait;
+
+--error ER_ILLEGAL_HA
+insert into t1 select * from t1 for update nowait;
+
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/select_lock_in_share_mode.test b/storage/rocksdb/mysql-test/rocksdb/t/select_lock_in_share_mode.test
new file mode 100644
index 00000000..23ce6d45
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/select_lock_in_share_mode.test
@@ -0,0 +1,54 @@
+--source include/have_rocksdb.inc
+
+#
+# SELECT .. LOCK IN SHARE MODE
+#
+# If the engine has its own lock timeouts,
+# it makes sense to set them to minimum to decrease
+# the duration of the test.
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--enable_connect_log
+
+--source include/count_sessions.inc
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'a');
+
+--connect (con1,localhost,root,,)
+BEGIN;
+--sorted_result
+SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE;
+
+--connection default
+SET lock_wait_timeout = 1;
+
+# Should still be able to select
+
+--sorted_result
+SELECT a,b FROM t1 WHERE b='a';
+--sorted_result
+SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE;
+
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE t1 SET b='c' WHERE b='a';
+
+--connection con1
+COMMIT;
+--sorted_result
+SELECT a,b FROM t1;
+
+--disconnect con1
+--connection default
+# Now it can be updated all right
+UPDATE t1 SET b='c' WHERE b='a';
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+--source include/wait_until_count_sessions.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/set_checkpoint.inc b/storage/rocksdb/mysql-test/rocksdb/t/set_checkpoint.inc
new file mode 100644
index 00000000..aae9db6c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/set_checkpoint.inc
@@ -0,0 +1,30 @@
+# Usage:
+# let $checkpoint = <value to set the checkpoint>;
+# let $succeeds = <1 if checkpoint creation should succeed, 0 otherwise>;
+# --source set_checkpoint.inc
+
+
+if ($succeeds)
+{
+ # Create checkpoint
+ --replace_result '$checkpoint' [CHECKPOINT]
+ eval SET GLOBAL ROCKSDB_CREATE_CHECKPOINT = '$checkpoint';
+
+ # Check checkpoint
+ --list_files $checkpoint CURRENT
+
+ # Cleanup
+ --remove_files_wildcard $checkpoint *
+ --rmdir $checkpoint
+ --disable_abort_on_error
+ --enable_abort_on_error
+}
+if (!$succeeds)
+{
+ --disable_result_log
+ --disable_query_log
+ --error ER_GET_ERRMSG
+ eval SET GLOBAL ROCKSDB_CREATE_CHECKPOINT = '$checkpoint';
+ --enable_query_log
+ --enable_result_log
+}
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/show_engine.test b/storage/rocksdb/mysql-test/rocksdb/t/show_engine.test
new file mode 100644
index 00000000..ccca197d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/show_engine.test
@@ -0,0 +1,103 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+--source include/restart_mysqld.inc
+
+#
+# SHOW ENGINE STATUS command
+# Checking that the command doesn't produce an error.
+# If it starts producing an actual result, the result file
+# will need to be updated, and possibly masked.
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+--enable_warnings
+
+CREATE TABLE t1 (i INT, PRIMARY KEY (i) COMMENT 'cf_t1') ENGINE = ROCKSDB;
+CREATE TABLE t2 (j INT, PRIMARY KEY (j) COMMENT 'rev:cf_t2') ENGINE = ROCKSDB;
+CREATE TABLE t3 (k INT, PRIMARY KEY (k) COMMENT 'cf_t1') ENGINE = ROCKSDB;
+
+# With partition based column family creation we now expect all the partitions
+# to belong to a default column family because mapping wasn't specified in
+# this case.
+CREATE TABLE t4 (l INT, PRIMARY KEY (l) COMMENT 'cf_t4') ENGINE = ROCKSDB
+ PARTITION BY KEY(l) PARTITIONS 4;
+
+SET @save.rocksdb_max_background_jobs= @@global.rocksdb_max_background_jobs;
+SET GLOBAL rocksdb_max_background_jobs= 1;
+
+INSERT INTO t1 VALUES (1), (2), (3);
+SELECT COUNT(*) FROM t1;
+
+INSERT INTO t2 VALUES (1), (2), (3), (4);
+SELECT COUNT(*) FROM t2;
+
+INSERT INTO t4 VALUES (1), (2), (3), (4), (5);
+SELECT COUNT(*) FROM t4;
+
+SET GLOBAL rocksdb_force_flush_memtable_now=1;
+SET GLOBAL rocksdb_compact_cf="cf_t1";
+--replace_column 2 # 3 #
+SHOW ENGINE rocksdb STATUS;
+
+# Fetch data from information schema as well
+--replace_column 3 #
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_CFSTATS;
+
+--replace_column 2 #
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_DBSTATS;
+
+SELECT TABLE_SCHEMA, TABLE_NAME, PARTITION_NAME, COUNT(STAT_TYPE)
+FROM INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT
+WHERE TABLE_SCHEMA = 'test'
+GROUP BY TABLE_NAME, PARTITION_NAME;
+
+--replace_column 3 #
+SELECT * FROM INFORMATION_SCHEMA.ROCKSDB_CF_OPTIONS;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
+
+SHOW ENGINE rocksdb MUTEX;
+# For SHOW ALL MUTEX even the number of lines is volatile, so the result logging is disabled
+--disable_result_log
+SHOW ENGINE ALL MUTEX;
+--enable_result_log
+
+# The output from SHOW ENGINE ROCKSDB TRANSACTION STATUS has some
+# non-deterministic results. Replace the timestamp with 'TIMESTAMP', the
+# number of seconds active with 'NUM', the thread id with 'TID' and the thread
+# pointer with 'PTR'. This test may fail in the future if it is being run in
+# parallel with other tests as the number of snapshots would then be greater
+# than expected. We may need to turn off the result log if that is the case.
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /0x[0-9a-f]+/PTR/
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+
+#select sleep(10);
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /0x[0-9a-f]+/PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
+SHOW ENGINE rocksdb TRANSACTION STATUS;
+
+ROLLBACK;
+
+# Check if explicit snapshots are correctly populated
+START TRANSACTION WITH SHARED ROCKSDB SNAPSHOT;
+--replace_column 2 # 3 #
+SHOW ENGINE rocksdb STATUS;
+ROLLBACK;
+CREATE EXPLICIT rocksdb SNAPSHOT;
+--replace_column 2 # 3 #
+SHOW ENGINE rocksdb STATUS;
+RELEASE EXPLICIT rocksdb SNAPSHOT;
+--replace_column 2 # 3 #
+SHOW ENGINE rocksdb STATUS;
+
+
+# Restore old values
+SET GLOBAL rocksdb_max_background_jobs= @save.rocksdb_max_background_jobs;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/show_table_status-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/show_table_status-master.opt
new file mode 100644
index 00000000..843f7012
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/show_table_status-master.opt
@@ -0,0 +1,3 @@
+--rocksdb_debug_optimizer_n_rows=1000
+--rocksdb_table_stats_sampling_pct=100
+--userstat=ON
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/show_table_status.test b/storage/rocksdb/mysql-test/rocksdb/t/show_table_status.test
new file mode 100644
index 00000000..55854710
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/show_table_status.test
@@ -0,0 +1,175 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+--source include/not_windows.inc # decorated database names is too long, exceeded OS limits
+
+#
+# SHOW TABLE STATUS statement
+#
+
+###################################
+# TODO:
+# The result file is likely to change
+# if MDEV-4197 is fixed
+###################################
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8) PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (100,'a'),(2,'foo');
+
+CREATE TABLE t2 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t2 (a,b) VALUES (1,'bar');
+
+set global rocksdb_force_flush_memtable_now = true;
+
+CREATE TABLE t3 (a INT, b CHAR(8), pk INT PRIMARY KEY) ENGINE=rocksdb CHARACTER SET utf8;
+
+--replace_column 6 # 7 # 12 # 13 #
+SHOW TABLE STATUS WHERE name IN ( 't1', 't2', 't3' );
+
+# Some statistics don't get updated as quickly. The Data_length and
+# Avg_row_length are trailing statistics, meaning they don't get updated
+# for the current SST until the next SST is written. Insert a bunch of data,
+# then flush, then insert a bit more and do another flush to get them to show
+# up.
+
+--disable_query_log
+let $count = 2;
+let $max = 10000;
+while ($count < $max) {
+ eval INSERT INTO t2 (a) VALUES ($count);
+ inc $count;
+}
+
+set global rocksdb_force_flush_memtable_now = true;
+eval INSERT INTO t2 (a) VALUES ($max);
+set global rocksdb_force_flush_memtable_now = true;
+--enable_query_log
+
+# We expect the number of rows to be 10000. Data_len and Avg_row_len
+# may vary, depending on built-in compression library.
+--replace_column 6 # 7 # 12 # 13 #
+SHOW TABLE STATUS WHERE name LIKE 't2';
+DROP TABLE t1, t2, t3;
+
+#
+# Confirm that long db and table names work.
+#
+
+CREATE DATABASE `db_new..............................................end`;
+USE `db_new..............................................end`;
+CREATE TABLE `t1_new..............................................end`(a int) engine=rocksdb;
+INSERT INTO `t1_new..............................................end` VALUES (1);
+--query_vertical SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.table_statistics WHERE TABLE_NAME = 't1_new..............................................end'
+DROP DATABASE `db_new..............................................end`;
+--echo #
+--echo # MDEV-17171: Bug: RocksDB Tables do not have "Creation Date"
+--echo #
+use test;
+create table t1 (a int) engine=rocksdb;
+
+select create_time is not null, update_time, check_time
+from information_schema.tables where table_schema=database() and table_name='t1';
+
+insert into t1 values (1);
+select create_time is not null, update_time is not null, check_time
+from information_schema.tables where table_schema=database() and table_name='t1';
+
+flush tables;
+select create_time is not null, update_time is not null, check_time
+from information_schema.tables where table_schema=database() and table_name='t1';
+
+select create_time, update_time into @create_tm, @update_tm
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+
+select sleep(3);
+insert into t1 values (2);
+
+--vertical_results
+select
+ create_time=@create_tm /* should not change */ ,
+ timestampdiff(second, @update_tm, update_time) > 2,
+ check_time
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+
+--echo #
+--echo # Check how create_time survives ALTER TABLE.
+--echo # First, an ALTER TABLE that re-creates the table:
+alter table t1 add b int;
+select
+ create_time<>@create_tm /* should change */,
+ create_time IS NOT NULL,
+ update_time IS NULL
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+
+insert into t1 values (5,5);
+
+select create_time, update_time into @create_tm, @update_tm
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+
+--echo # Then, an in-place ALTER TABLE:
+select sleep(2);
+alter table t1 add key (a);
+
+--echo # create_time will change as .frm file is rewritten:
+select
+ create_time=@create_tm,
+ update_time
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+
+--echo # Check TRUNCATE TABLE
+insert into t1 values (10,10);
+select create_time, update_time into @create_tm, @update_tm
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+
+select sleep(2);
+truncate table t1;
+
+select
+ create_time=@create_tm /* should not change */,
+ update_time
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+
+
+--echo #
+--echo # Check what is left after server restart
+--echo #
+drop table t1;
+create table t1 (a int);
+insert into t1 values (1);
+--echo # Save t1's creation time
+create table t2 as
+select create_time
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+
+select sleep(2);
+--source include/restart_mysqld.inc
+
+select
+ create_time=(select create_time from t2) /* should not change */,
+ update_time
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+
+drop table t1, t2;
+
+--echo #
+--echo # Check how it works for partitioned tables
+--echo #
+create table t1 (pk int primary key) partition by hash(pk) partitions 2;
+insert into t1 values (1);
+
+select create_time IS NOT NULL , update_time IS NOT NULL
+from information_schema.tables
+where table_schema=database() and table_name='t1';
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/shutdown-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/shutdown-master.opt
new file mode 100644
index 00000000..d6c7939e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/shutdown-master.opt
@@ -0,0 +1 @@
+--log-bin --binlog_format=row --rocksdb_default_cf_options=write_buffer_size=64k
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/shutdown.test b/storage/rocksdb/mysql-test/rocksdb/t/shutdown.test
new file mode 100644
index 00000000..f76bc9f6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/shutdown.test
@@ -0,0 +1,36 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Ensure bin log is enabled.
+SHOW GLOBAL VARIABLES LIKE "log_bin";
+
+# Create the table and insert some keys
+CREATE TABLE t1 (i INT, PRIMARY KEY (i) COMMENT 'cf_t1') ENGINE = ROCKSDB;
+
+--disable_query_log
+let $max = 1000;
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO t1 VALUES ($i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+# Restart the server
+let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
+--exec echo "wait" > $restart_file
+--shutdown_server
+--source include/wait_until_disconnected.inc
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- enable_reconnect
+-- source include/wait_until_connected_again.inc
+
+# Verify table has correct rows
+SELECT COUNT(*) FROM t1;
+
+#cleanup
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/singledelete-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/singledelete-master.opt
new file mode 100644
index 00000000..a3d2d07e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/singledelete-master.opt
@@ -0,0 +1 @@
+--rocksdb_default_cf_options=write_buffer_size=16k --rocksdb_strict_collation_check=0
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/singledelete.test b/storage/rocksdb/mysql-test/rocksdb/t/singledelete.test
new file mode 100644
index 00000000..5a9d17e0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/singledelete.test
@@ -0,0 +1,105 @@
+--source include/have_rocksdb.inc
+
+# only SingleDelete increases
+CREATE TABLE t1 (id INT, value int, PRIMARY KEY (id), INDEX (value)) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1,1);
+select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+--disable_query_log
+let $i = 1;
+while ($i <= 10000) {
+ let $update = UPDATE t1 SET value=value+1 WHERE value=$i;
+ inc $i;
+ eval $update;
+}
+--enable_query_log
+optimize table t1;
+select case when variable_value-@s > 5 and variable_value-@s < 100 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+select case when variable_value-@d < 10 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+
+
+# both SingleDelete and Delete increases
+CREATE TABLE t2 (id INT, value int, PRIMARY KEY (id), INDEX (value)) ENGINE=RocksDB;
+INSERT INTO t2 VALUES (1,1);
+select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+--disable_query_log
+let $i = 1;
+while ($i <= 10000) {
+ let $update = UPDATE t2 SET id=id+1 WHERE id=$i;
+ inc $i;
+ eval $update;
+}
+--enable_query_log
+optimize table t2;
+select case when variable_value-@s > 5 and variable_value-@s < 100 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+select case when variable_value-@d > 9000 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+
+# only Delete increases
+CREATE TABLE t3 (id INT, value int, PRIMARY KEY (id)) ENGINE=RocksDB;
+INSERT INTO t3 VALUES (1,1);
+select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+--disable_query_log
+let $i = 1;
+while ($i <= 10000) {
+ let $update = UPDATE t3 SET id=id+1 WHERE id=$i;
+ inc $i;
+ eval $update;
+}
+--enable_query_log
+optimize table t3;
+select case when variable_value-@s = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+select case when variable_value-@d > 9000 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+
+# only SingleDelete increases
+CREATE TABLE t4 (id INT, PRIMARY KEY (id)) ENGINE=RocksDB;
+INSERT INTO t4 VALUES (1);
+select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+--disable_query_log
+let $i = 1;
+while ($i <= 10000) {
+ let $update = UPDATE t4 SET id=id+1 WHERE id=$i;
+ inc $i;
+ eval $update;
+}
+--enable_query_log
+optimize table t4;
+select case when variable_value-@s > 5 and variable_value-@s < 100 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+select case when variable_value-@d < 10 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+
+# only SingleDelete increases
+CREATE TABLE t5 (id1 INT, id2 INT, PRIMARY KEY (id1, id2), INDEX(id2)) ENGINE=RocksDB;
+INSERT INTO t5 VALUES (1, 1);
+select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+--disable_query_log
+let $i = 1;
+while ($i <= 10000) {
+ let $update = UPDATE t5 SET id1=id1+1 WHERE id1=$i;
+ inc $i;
+ eval $update;
+}
+--enable_query_log
+optimize table t5;
+select case when variable_value-@s > 5 and variable_value-@s < 100 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete';
+select case when variable_value-@d < 10 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete';
+
+# SingleDelete used for PK. Verify old PK is always deleted.
+CREATE TABLE t6 (
+ pk VARCHAR(64) COLLATE latin1_swedish_ci PRIMARY KEY
+) ENGINE=RocksDB;
+INSERT INTO t6 VALUES ('a');
+SET GLOBAL rocksdb_force_flush_memtable_now=1;
+SELECT * FROM t6;
+UPDATE t6 SET pk='A' WHERE pk='a';
+SELECT * FROM t6;
+DELETE FROM t6 where pk='A';
+--echo SELECT should return nothing;
+SELECT * FROM t6;
+SET GLOBAL rocksdb_force_flush_memtable_now=1;
+--echo SELECT should return nothing;
+SELECT * FROM t6;
+
+DROP TABLE t1, t2, t3, t4, t5, t6;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/skip_core_dump_on_error-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/skip_core_dump_on_error-master.opt
new file mode 100644
index 00000000..c07b063f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/skip_core_dump_on_error-master.opt
@@ -0,0 +1 @@
+--rocksdb_strict_collation_check=off --binlog_format=row --log-bin
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/skip_core_dump_on_error.test b/storage/rocksdb/mysql-test/rocksdb/t/skip_core_dump_on_error.test
new file mode 100644
index 00000000..451eed05
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/skip_core_dump_on_error.test
@@ -0,0 +1,53 @@
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+--source include/not_valgrind.inc
+
+--enable_connect_log
+--enable_info
+
+# setup search pattern and file (new log error file)
+--let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/skip_core_dump_on_error.err
+
+# restart the server with the custom error log file
+--let $_mysqld_option=--log-error=$SEARCH_FILE --default-storage-engine=rocksdb
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--source include/restart_mysqld_with_option.inc
+
+# setup
+create table mz(c int);
+insert into mz values(1);
+commit;
+
+# simulate a write error
+SET debug= '+d,abort_with_io_write_error';
+
+# we want to abort server if we fail to write (ABORT_SERVER)
+set global binlog_error_action=1;
+
+# diplay the values of the key parameters
+show session variables like 'debug';
+show global variables like 'binlog_error_action';
+show global variables like 'skip_core_dump_on_error';
+
+--echo # crash_during_update
+# tell client that crash is expected
+--error 1598
+# run an update to trigger a write error
+update mz set c=13;
+
+# should find server abort (prints: Pattern "..." found)
+--echo # server aborted
+--let SEARCH_PATTERN=mysqld got signal 6
+--source include/search_pattern.inc
+
+# should not find a core dump (prints: Pattern "..." not found)
+--echo # but no core written
+--let SEARCH_PATTERN=Writing a core file
+--source include/search_pattern.inc
+
+--let _$mysqld_option=
+--source include/start_mysqld.inc
+--remove_file $SEARCH_FILE
+
+# tidy up
+drop table mz;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/skip_validate_tmp_table.test b/storage/rocksdb/mysql-test/rocksdb/t/skip_validate_tmp_table.test
new file mode 100644
index 00000000..c4321462
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/skip_validate_tmp_table.test
@@ -0,0 +1,39 @@
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+
+--let $_server_id= `SELECT @@server_id`
+
+create table t1 (pk int primary key) engine=rocksdb;
+
+# Create a .frm file without a matching table
+--exec cp $MYSQLTEST_VARDIR/mysqld.$_server_id/data/test/t1.frm $MYSQLTEST_VARDIR/mysqld.$_server_id/data/test/t1#sql-test.frm
+
+--source include/restart_mysqld.inc
+
+show tables;
+
+# MariaDB produces a warning:
+call mtr.add_suppression('Invalid .old.. table or database name .t1#sql-test.');
+
+# This will append '#sql-test' to the end of new name
+set session debug_dbug="+d,gen_sql_table_name";
+rename table t1 to t2;
+set session debug_dbug= "-d,gen_sql_table_name";
+
+show tables;
+
+# Remove the corresponding .frm files
+--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.$_server_id/data/test *t1*.frm
+--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.$_server_id/data/test *t2*.frm
+
+# Restart the server with a table registered in RocksDB but does not have a .frm file
+--source include/restart_mysqld.inc
+
+show tables;
+
+# try to recreate a table with the same name
+create table t2 (pk int primary key) engine=rocksdb;
+
+show tables;
+
+drop table t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/slow_query_log-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/slow_query_log-master.opt
new file mode 100644
index 00000000..fc5c3ed4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/slow_query_log-master.opt
@@ -0,0 +1 @@
+--log-slow-extra --rocksdb-perf-context-level=2
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/slow_query_log.test b/storage/rocksdb/mysql-test/rocksdb/t/slow_query_log.test
new file mode 100644
index 00000000..9f1694ab
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/slow_query_log.test
@@ -0,0 +1,37 @@
+--source include/have_rocksdb.inc
+#Unixism (exec awk)
+-- source include/not_windows.inc
+
+SET @cur_long_query_time = @@long_query_time;
+# Set the long query time to something big so that nothing unexpected gets into it
+SET @@long_query_time = 600;
+# Test the slow query log feature
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (id INT PRIMARY KEY, value INT) ENGINE=ROCKSDB;
+
+--disable_query_log
+let $max = 10000;
+let $i = 1;
+while ($i < $max) {
+ let $insert = INSERT INTO t1 VALUES ($i, $i);
+ inc $i;
+ eval $insert;
+}
+
+DELETE FROM t1 WHERE id < 2500;
+--enable_query_log
+
+SET @@long_query_time = 0;
+# we expect this query to be reflected in the slow query log
+SELECT COUNT(*) FROM t1;
+
+SET @@long_query_time = @cur_long_query_time;
+
+# Verify the output of the slow query log contains counts for the skipped keys
+--exec awk -f suite/rocksdb/slow_query_log.awk $MYSQLTEST_VARDIR/mysqld.1/mysqld-slow.log
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/statistics-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/statistics-master.opt
new file mode 100644
index 00000000..8a56deb0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/statistics-master.opt
@@ -0,0 +1,3 @@
+--rocksdb_default_cf_options=max_write_buffer_number_to_maintain=10
+--rocksdb_debug_optimizer_n_rows=1000
+--rocksdb_table_stats_sampling_pct=100
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/statistics.test b/storage/rocksdb/mysql-test/rocksdb/t/statistics.test
new file mode 100644
index 00000000..25a1224c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/statistics.test
@@ -0,0 +1,82 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+--enable_warnings
+
+# table with index in default CF
+create table t1(
+ id bigint not null primary key auto_increment,
+ a varchar(255) not null,
+ b bigint,
+ index t1_1(b)
+) engine=rocksdb;
+
+# a table with index in a different CF
+create table t2(
+ id bigint not null primary key auto_increment,
+ a varchar(255) not null,
+ b bigint,
+ index t2_1(b) comment 'cf_t3'
+) engine=rocksdb;
+
+# a table wint index in a reverse CF
+create table t3(
+ id bigint not null primary key auto_increment,
+ a varchar(255) not null,
+ b bigint,
+ index t3_1(b) comment 'rev:cf_t4'
+) engine=rocksdb;
+
+--disable_query_log
+let $i=0;
+while ($i<100000)
+{
+ inc $i;
+ eval insert t1(a,b) values(concat('a',$i,'b',$i,'c',$i), $i);
+ if ($i<5000)
+ {
+ eval insert t2(a,b) values(concat('a',$i,'b',$i,'c',$i), $i);
+ eval insert t3(a,b) values(concat('a',$i,'b',$i,'c',$i), $i);
+ }
+}
+--enable_query_log
+
+# should have some statistics before the memtable flush
+--sorted_result
+SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE() and table_name <> 't1';
+
+# due to inconsistencies in when the memtable is flushed, just verify t1 has fewer
+# than the expected number of rows.
+--sorted_result
+SELECT CASE WHEN table_rows < 100000 then 'true' else 'false' end from information_schema.tables where table_name = 't1';
+
+# flush and get even better statistics
+set global rocksdb_force_flush_memtable_now = true;
+--sorted_result
+SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE();
+--sorted_result
+SELECT table_name, data_length>0, index_length>0 FROM information_schema.tables WHERE table_schema = DATABASE();
+
+# restart the server, check the stats
+--source include/restart_mysqld.inc
+
+# give the server a chance to load in statistics
+--sleep 5
+
+--sorted_result
+SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE();
+--sorted_result
+SELECT table_name, data_length>0, index_length>0 FROM information_schema.tables WHERE table_schema = DATABASE();
+
+analyze table t1,t2,t3,t4,t5;
+
+# make sure that stats do not change after calling analyze table
+--sorted_result
+SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE();
+--sorted_result
+SELECT table_name, data_length>0, index_length>0 FROM information_schema.tables WHERE table_schema = DATABASE();
+
+drop table t1, t2, t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/table_stats-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/table_stats-master.opt
new file mode 100644
index 00000000..be8a06ea
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/table_stats-master.opt
@@ -0,0 +1 @@
+--userstat
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/table_stats.test b/storage/rocksdb/mysql-test/rocksdb/t/table_stats.test
new file mode 100644
index 00000000..3eb58098
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/table_stats.test
@@ -0,0 +1,29 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Create the table and insert some keys
+CREATE TABLE t1 (i INT, PRIMARY KEY (i) COMMENT 'cf_t1') ENGINE = ROCKSDB;
+
+--disable_query_log
+let $max = 1000;
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO t1 VALUES ($i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+# Verify table has correct rows
+SELECT COUNT(*) FROM t1;
+
+# Verify the table stats are returned
+--vertical_results
+SELECT * FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME = "t1";
+--horizontal_results
+
+#cleanup
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_ai.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_ai.test
new file mode 100644
index 00000000..8fb4539b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_ai.test
@@ -0,0 +1,29 @@
+--source include/have_rocksdb.inc
+
+#
+# Check whether AUTO_INCREMENT option
+# is supported in CREATE and ALTER TABLE
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb AUTO_INCREMENT=10;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+
+ALTER TABLE t1 AUTO_INCREMENT=100;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1 ORDER BY a;
+
+ALTER TABLE t1 AUTO_INCREMENT=50;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1 ORDER BY a;
+
+DROP TABLE t1;
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_avg_row_length.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_avg_row_length.test
new file mode 100644
index 00000000..3e6797a8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_avg_row_length.test
@@ -0,0 +1,23 @@
+--source include/have_rocksdb.inc
+
+#
+# Check whether AVG_ROW_LENGTH option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb AVG_ROW_LENGTH=300;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 AVG_ROW_LENGTH=30000000;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_checksum.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_checksum.test
new file mode 100644
index 00000000..3b49b967
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_checksum.test
@@ -0,0 +1,19 @@
+--source include/have_rocksdb.inc
+
+#
+# Check whether CHECKSUM option is supported
+# in CREATE and ALTER TABLE.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb CHECKSUM=1;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 CHECKSUM=0;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_connection.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_connection.test
new file mode 100644
index 00000000..b97b3dd9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_connection.test
@@ -0,0 +1,32 @@
+--source include/have_rocksdb.inc
+
+#
+# Check whether CONNECTION option is supported
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE DATABASE test_remote;
+CREATE SERVER test_connection FOREIGN DATA WRAPPER mysql
+OPTIONS (USER 'root', HOST 'localhost', DATABASE 'test_remote');
+CREATE SERVER test_connection2 FOREIGN DATA WRAPPER mysql
+OPTIONS (USER 'root', HOST 'localhost', DATABASE 'test_remote');
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb CONNECTION='test_connection';
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 CONNECTION='test_connection2';
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+DROP SERVER test_connection;
+DROP SERVER test_connection2;
+DROP DATABASE test_remote;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_data_index_dir.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_data_index_dir.test
new file mode 100644
index 00000000..6fcfd491
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_data_index_dir.test
@@ -0,0 +1,60 @@
+--source include/have_rocksdb.inc
+
+--source include/have_partition.inc
+--source include/not_windows.inc
+
+#
+# Check that when either DATA DIRECTORY or INDEX DIRECTORY are specified
+# then MyRocks returns an appropriate error. We don't support this
+# functionality and therefore shouldn't just silently accept the values.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# On a Mac, strerror() prints "Unknown error: nn", as
+# opposed to "Unknown error nn" on Linux/etc.
+# Replacing 'error:' with 'error' below to make the output uniform.
+
+--replace_result error: error
+--error ER_CANT_CREATE_TABLE
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb DATA DIRECTORY = '/foo/bar/data';
+--replace_result error: error
+show warnings;
+
+--replace_result error: error
+--error ER_CANT_CREATE_TABLE
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb INDEX DIRECTORY = '/foo/bar/index';
+--replace_result error: error
+show warnings;
+
+#
+# Verify that we'll get the same error codes when using the partitions.
+#
+
+--replace_result error: error
+--error ER_CANT_CREATE_TABLE
+CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY) ENGINE=rocksdb PARTITION BY RANGE (id)
+(
+ PARTITION P0 VALUES LESS THAN (1000)
+ DATA DIRECTORY = '/foo/bar/data/',
+ PARTITION P1 VALUES LESS THAN (2000)
+ DATA DIRECTORY = '/foo/bar/data/',
+ PARTITION P2 VALUES LESS THAN (MAXVALUE)
+);
+--replace_result error: error
+show warnings;
+
+--replace_result error: error
+--error ER_CANT_CREATE_TABLE
+CREATE TABLE t1 (id int not null primary key) ENGINE=rocksdb PARTITION BY RANGE (id)
+(
+ PARTITION P0 VALUES LESS THAN (1000)
+ INDEX DIRECTORY = '/foo/bar/data/',
+ PARTITION P1 VALUES LESS THAN (2000)
+ INDEX DIRECTORY = '/foo/bar/data/',
+ PARTITION P2 VALUES LESS THAN (MAXVALUE)
+);
+--replace_result error: error
+show warnings;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_delay_key_write.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_delay_key_write.test
new file mode 100644
index 00000000..85cd45e9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_delay_key_write.test
@@ -0,0 +1,23 @@
+--source include/have_rocksdb.inc
+
+#
+# Check whether DELAY_KEY_WRITE option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb DELAY_KEY_WRITE=1;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 DELAY_KEY_WRITE=0;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_insert_method.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_insert_method.test
new file mode 100644
index 00000000..e289827a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_insert_method.test
@@ -0,0 +1,23 @@
+--source include/have_rocksdb.inc
+
+#
+# Check whether INSERT_METHOD option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted (and apparently ignored)
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb INSERT_METHOD=FIRST;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 INSERT_METHOD=NO;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_key_block_size.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_key_block_size.test
new file mode 100644
index 00000000..d927c785
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_key_block_size.test
@@ -0,0 +1,23 @@
+--source include/have_rocksdb.inc
+
+#
+# Check whether KEY_BLOCK_SIZE option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb KEY_BLOCK_SIZE=8;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 KEY_BLOCK_SIZE=1;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_max_rows.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_max_rows.test
new file mode 100644
index 00000000..35aa0f4d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_max_rows.test
@@ -0,0 +1,23 @@
+--source include/have_rocksdb.inc
+
+#
+# Check whether MAX_ROWS option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb MAX_ROWS=10000000;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 MAX_ROWS=30000000;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_min_rows.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_min_rows.test
new file mode 100644
index 00000000..d62a8771
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_min_rows.test
@@ -0,0 +1,23 @@
+--source include/have_rocksdb.inc
+
+#
+# Check whether MIN_ROWS option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb MIN_ROWS=1;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 MIN_ROWS=10000;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_pack_keys.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_pack_keys.test
new file mode 100644
index 00000000..acdb612b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_pack_keys.test
@@ -0,0 +1,23 @@
+--source include/have_rocksdb.inc
+
+#
+# Check whether PACK KEYS option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb PACK_KEYS=1;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 PACK_KEYS=0;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_password.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_password.test
new file mode 100644
index 00000000..e897992e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_password.test
@@ -0,0 +1,27 @@
+--source include/have_rocksdb.inc
+
+#
+# Check whether PASSWORD option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+# This option is not supported by any known engines,
+# that's why the result file does not contain it;
+# but it's syntactically acceptable.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb PASSWORD='password';
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 PASSWORD='new_password';
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_row_format.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_row_format.test
new file mode 100644
index 00000000..de834d23
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_row_format.test
@@ -0,0 +1,23 @@
+--source include/have_rocksdb.inc
+
+#
+# Check whether ROW_FORMAT option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8) PRIMARY KEY) ENGINE=rocksdb ROW_FORMAT=FIXED;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 ROW_FORMAT=DYNAMIC;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_union.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_union.test
new file mode 100644
index 00000000..d3c371b1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_opt_union.test
@@ -0,0 +1,28 @@
+--source include/have_rocksdb.inc
+
+#
+# Check whether UNION option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, child1, child2;
+--enable_warnings
+
+--disable_query_log
+CREATE TABLE child1 (a INT PRIMARY KEY) ENGINE=MyISAM;
+CREATE TABLE child2 (a INT PRIMARY KEY) ENGINE=MyISAM;
+--enable_query_log
+
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=rocksdb UNION(child1);
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 UNION = (child1,child2);
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1, child1, child2;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tbl_standard_opts.test b/storage/rocksdb/mysql-test/rocksdb/t/tbl_standard_opts.test
new file mode 100644
index 00000000..5d60c02a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tbl_standard_opts.test
@@ -0,0 +1,42 @@
+--source include/have_rocksdb.inc
+
+#
+# Standard options in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the options
+# have any real effect on the table, only
+# that they are accepted
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Create table with standard options
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb
+ DEFAULT CHARACTER SET = utf8
+ COLLATE = utf8_general_ci
+ COMMENT = 'standard table options'
+;
+SHOW CREATE TABLE t1;
+
+# Alter comment
+
+ALTER TABLE t1 COMMENT = 'table altered';
+SHOW CREATE TABLE t1;
+
+# Alter ENGINE value
+
+ALTER TABLE t1 ENGINE=MEMORY;
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 ENGINE=rocksdb;
+SHOW CREATE TABLE t1;
+
+# Alter character set and collation
+
+ALTER TABLE t1 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/tmpdir.test b/storage/rocksdb/mysql-test/rocksdb/t/tmpdir.test
new file mode 100644
index 00000000..28615264
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/tmpdir.test
@@ -0,0 +1,35 @@
+--source include/have_rocksdb.inc
+
+--echo # If rocksdb_tmpdir is NULL or "", temporary file will be created in
+--echo # server configuration variable location(--tmpdir)
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=RocksDB;
+show session variables like 'rocksdb_tmpdir';
+--echo # Connection con1
+connect (con1,localhost,root);
+show session variables like 'rocksdb_tmpdir';
+
+ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE;
+connection default;
+disconnect con1;
+DROP TABLE t1;
+
+--echo # rocksdb_tmpdir with valid location.
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=RocksDB;
+set @tmpdir = @@global.tmpdir;
+set global rocksdb_tmpdir = @tmpdir;
+show session variables like 'rocksdb_tmpdir';
+
+--echo # Connection con3
+connect (con2,localhost,root);
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+show session variables like 'rocksdb_tmpdir';
+
+ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE;
+disconnect con2;
+connection default;
+set global rocksdb_tmpdir=NULL;
+DROP TABLE t1;
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/transaction.test b/storage/rocksdb/mysql-test/rocksdb/t/transaction.test
new file mode 100644
index 00000000..129484ba
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/transaction.test
@@ -0,0 +1,158 @@
+--source include/have_rocksdb.inc
+
+create table t1 (id int primary key, value int, value2 varchar(100), index(value)) engine=rocksdb;
+
+insert into t1 values (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),(6,6,6),(8,8,8),(9,9,9),(10,10,10);
+
+# insert
+begin;
+insert into t1 values (11,11,11);
+--source transaction_select.inc
+rollback;
+
+# insert in the middle
+begin;
+insert into t1 values (7,7,7);
+--source transaction_select.inc
+rollback;
+
+# update non-index column by primary key
+begin;
+update t1 set value2=100 where id=1;
+--source transaction_select.inc
+rollback;
+
+# update secondary key by primary key
+begin;
+update t1 set value=100 where id=1;
+--source transaction_select.inc
+rollback;
+
+# update primary key by primary key
+begin;
+update t1 set id=100 where id=1;
+--source transaction_select.inc
+rollback;
+
+# update non-index column key by secondary key
+begin;
+update t1 set value2=100 where value=1;
+--source transaction_select.inc
+rollback;
+
+# update secondary key by secondary key
+begin;
+update t1 set value=100 where value=1;
+--source transaction_select.inc
+rollback;
+
+# update primary key by secondary key
+begin;
+update t1 set id=100 where value=1;
+--source transaction_select.inc
+rollback;
+
+# update non-index column by non-index column
+begin;
+update t1 set value2=100 where value2=1;
+--source transaction_select.inc
+rollback;
+
+# update secondary key by non-index column
+begin;
+update t1 set value=100 where value2=1;
+--source transaction_select.inc
+rollback;
+
+# update primary key column by non-index column
+begin;
+update t1 set id=100 where value2=1;
+--source transaction_select.inc
+rollback;
+
+
+# delete by primary key
+begin;
+delete from t1 where id=1;
+--source transaction_select.inc
+rollback;
+
+# delete by secondary key
+begin;
+delete from t1 where value=1;
+--source transaction_select.inc
+rollback;
+
+# delete by non-index column
+begin;
+delete from t1 where value2=1;
+--source transaction_select.inc
+rollback;
+
+# mixed
+begin;
+insert into t1 values (11,11,11);
+insert into t1 values (12,12,12);
+insert into t1 values (13,13,13);
+delete from t1 where id=9;
+delete from t1 where value=8;
+update t1 set id=100 where value2=5;
+update t1 set value=103 where value=4;
+update t1 set id=115 where id=3;
+--source transaction_select.inc
+rollback;
+
+drop table t1;
+
+--echo #
+--echo # #802: MyRocks: Statement rollback doesnt work correctly for nested statements
+--echo #
+create table t1 (a varchar(100)) engine=rocksdb;
+create table t2(a int) engine=rocksdb;
+insert into t2 values (1), (2);
+
+create table t3(a varchar(100)) engine=rocksdb;
+
+delimiter //;
+create function func() returns varchar(100) deterministic
+begin
+ insert into t3 values ('func-called');
+ set @a= (select a from t2);
+ return 'func-returned';
+end;//
+delimiter ;//
+
+begin;
+--error ER_SUBQUERY_NO_1_ROW
+insert into t1 values (func());
+select * from t1;
+--echo # The following must not produce 'func-called':
+select * from t3;
+
+rollback;
+drop function func;
+drop table t1,t2,t3;
+
+--echo #
+--echo # MDEV-16710: Slave SQL: Could not execute Update_rows_v1 event with RocksDB and triggers
+--echo # Issue#857: MyRocks: Incorrect behavior when multiple statements fail inside a transaction
+--echo #
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=RocksDB;
+INSERT INTO t1 VALUES (1);
+
+CREATE TABLE t2 (b INT PRIMARY KEY) ENGINE=RocksDB;
+
+CREATE TRIGGER tr AFTER INSERT ON t2 FOR EACH ROW INSERT INTO non_existing_table VALUES (NULL);
+
+BEGIN;
+DELETE FROM t1;
+--error 0,ER_NO_SUCH_TABLE
+INSERT INTO t2 VALUES (1);
+--error 0,ER_NO_SUCH_TABLE
+INSERT INTO t2 VALUES (2);
+--echo # Must return empty result:
+SELECT * FROM t1;
+COMMIT;
+
+drop table t1,t2;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/transaction_isolation.inc b/storage/rocksdb/mysql-test/rocksdb/t/transaction_isolation.inc
new file mode 100644
index 00000000..dbd1d906
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/transaction_isolation.inc
@@ -0,0 +1,150 @@
+#
+# Basic check for transaction isolation.
+# The results should be different depending on the isolation level.
+# For some isolation levels, some statements will end with a timeout.
+# If the engine has its own timeout parameters, reduce them to minimum,
+# otherwise the test will take very long.
+# If the timeout value is greater than the testcase-timeout the test is run with,
+# it might fail due to the testcase timeout.
+#
+
+--enable_connect_log
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+connect (con1,localhost,root,,);
+eval SET SESSION TRANSACTION ISOLATION LEVEL $trx_isolation;
+connect (con2,localhost,root,,);
+eval SET SESSION TRANSACTION ISOLATION LEVEL $trx_isolation;
+
+connection con1;
+
+CREATE TABLE t1 (a INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+
+START TRANSACTION;
+--sorted_result
+SELECT a FROM t1; # First snapshot
+
+connection con2;
+
+BEGIN;
+--error 0,ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 (a) VALUES(1);
+
+connection con1;
+--sorted_result
+SELECT a FROM t1; # Second snapshot
+
+connection con2;
+--error 0,ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 (a) VALUES (2);
+
+connection con1;
+--sorted_result
+SELECT a FROM t1; # Third snapshot
+
+--error 0,ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 (a) SELECT a+100 FROM t1;
+
+--sorted_result
+SELECT a FROM t1;
+
+connection con2;
+--sorted_result
+SELECT a FROM t1; # Inside the transaction
+COMMIT;
+--sorted_result
+SELECT a FROM t1; # Outside the transaction
+
+connection con1;
+--sorted_result
+SELECT a FROM t1; # Inside the transaction
+
+# Note: INSERT .. SELECT might be tricky, for example for InnoDB
+# even with REPEATABLE-READ it works as if it is executed with READ COMMITTED.
+# The test will have a 'logical' result for repeatable read, even although
+# we currently don't have an engine which works this way.
+
+--error 0,ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 (a) SELECT a+200 FROM t1;
+
+--sorted_result
+SELECT a FROM t1;
+COMMIT;
+--sorted_result
+SELECT a FROM t1; # Outside the transaction
+
+connection con2;
+--sorted_result
+SELECT a FROM t1; # After both transactions have committed
+
+# Now test with an error in one statement to make sure the snapshots are
+# Held/released when expected
+connection default;
+CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (a) VALUES (1);
+COMMIT;
+
+connection con1;
+BEGIN;
+--sorted_result
+SELECT a from t2;
+--error ER_DUP_ENTRY
+INSERT INTO t2 (a) VALUES (1), (3); # failure
+
+connection con2;
+--error 0,ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t2 (a) VALUES (2);
+COMMIT;
+
+connection con1;
+--sorted_result
+SELECT a from t2;
+COMMIT;
+
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+DROP TABLE t2;
+
+CREATE TABLE t3 (
+ pk int unsigned PRIMARY KEY,
+ count int unsigned DEFAULT '0'
+) ENGINE=ROCKSDB;
+
+connect (con1,localhost,root,,);
+eval SET SESSION TRANSACTION ISOLATION LEVEL $trx_isolation;
+connect (con2,localhost,root,,);
+eval SET SESSION TRANSACTION ISOLATION LEVEL $trx_isolation;
+
+connection con1;
+BEGIN;
+SELECT * FROM t3;
+
+connection con2;
+BEGIN;
+INSERT INTO t3 (pk) VALUES(1) ON DUPLICATE KEY UPDATE count=count+1;
+COMMIT;
+
+connection con1;
+--error 0,ER_LOCK_DEADLOCK
+INSERT INTO t3 (pk) VALUES(1) ON DUPLICATE KEY UPDATE count=count+1;
+COMMIT;
+
+# count will be 0 for repeatable read (because the last insert failed)
+# and 1 for read committed
+SELECT count FROM t3;
+
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t3;
+
+--source include/wait_until_count_sessions.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/transaction_select.inc b/storage/rocksdb/mysql-test/rocksdb/t/transaction_select.inc
new file mode 100644
index 00000000..932a450e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/transaction_select.inc
@@ -0,0 +1,14 @@
+select * from t1 where id=1;
+select * from t1 where value=1;
+select value from t1 where value=1;
+select * from t1 where value2=1;
+select * from t1 where id=5;
+select * from t1 where value=5;
+select value from t1 where value=5;
+select * from t1 where value2=5;
+select * from t1 where id < 3 order by id;
+select * from t1 where value < 3 order by id;
+select value from t1 where value < 3 order by id;
+select * from t1 where value2 < 3 order by id;
+select * from t1 order by id;
+select value from t1 order by id;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/truncate_partition.inc b/storage/rocksdb/mysql-test/rocksdb/t/truncate_partition.inc
new file mode 100644
index 00000000..2193aa9f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/truncate_partition.inc
@@ -0,0 +1,102 @@
+
+# Truncate table multiple times
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t1;
+
+# Truncate partition multiple times
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+
+# TRUNCATE multiple times
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+
+# TRUNCATE multiple times
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+
+# TRUNCATE different partition
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+TRUNCATE TABLE t1;
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+
+# Insert value once and truncate multiple times
+INSERT INTO t1 (a,b) VALUES (1, 1), (2, 4), (3, 8);
+SELECT a,b FROM t1 ORDER BY a;
+
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+SELECT a,b FROM t1 ORDER BY a;
+SELECT a FROM t1 WHERE b > 2;
+SELECT b from t1 where a != 3;
+
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+SELECT a,b FROM t1 ORDER BY b;
+SELECT a FROM t1 WHERE b > 2;
+SELECT b from t1 where a != 3;
+
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+SELECT a,b FROM t1 ORDER BY a;
+
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+
+# Insert value multiple times and truncate multiple times
+INSERT INTO t1 (a,b) VALUES (4, 1), (5, 4), (6, 8);
+--sorted_result
+SELECT a,b FROM t1;
+--sorted_result
+SELECT a FROM t1 WHERE b < 5;
+
+ALTER TABLE t1 TRUNCATE PARTITION p2;
+--sorted_result
+SELECT a,b FROM t1;
+INSERT INTO t1(a,b) VALUES(7, 1);
+--sorted_result
+SELECT b from t1 WHERE a > 2;
+--sorted_result
+SELECT a,b FROM t1;
+
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+--sorted_result
+SELECT a,b FROM t1;
+INSERT INTO t1(a,b) VALUES(8, 4);
+--sorted_result
+SELECT a,b FROM t1;
+--sorted_result
+SELECT b from t1 WHERE a < 9;
+
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+--sorted_result
+SELECT a,b FROM t1;
+INSERT INTO t1(a,b) VALUES(9, 8);
+
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+
+# manual commpact
+set global rocksdb_force_flush_memtable_now = true;
+set global rocksdb_compact_cf = 'default';
+
+--disable_query_log
+let $i = 0;
+while($i < 9)
+{
+ inc $i;
+ eval insert t1 values($i, $i);
+}
+--enable_query_log
+--sorted_result
+SELECT b FROM t1 WHERE a < 5;
+
+TRUNCATE TABLE t1;
+SELECT b FROM t1 WHERE a < 5;
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/truncate_partition.test b/storage/rocksdb/mysql-test/rocksdb/t/truncate_partition.test
new file mode 100644
index 00000000..f9a89517
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/truncate_partition.test
@@ -0,0 +1,83 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+#
+# TRUNCATE PARTITION
+#
+
+
+# Hidden Key table
+--echo #
+--echo # table(hidden key)
+--echo #
+CREATE TABLE t1 (
+ a INT,
+ b INT
+) ENGINE=ROCKSDB
+PARTITION BY RANGE (b) (
+ PARTITION p0 VALUES LESS THAN (3),
+ PARTITION p1 VALUES LESS THAN (6),
+ PARTITION p2 VALUES LESS THAN MAXVALUE
+);
+
+--source truncate_partition.inc
+
+
+--echo #
+--echo # table(secondary key)
+--echo #
+CREATE TABLE t1(
+ a INT,
+ b INT,
+ KEY (b)
+) ENGINE=ROCKSDB
+PARTITION BY HASH(a) PARTITIONS 3;
+
+--source truncate_partition.inc
+
+
+--echo #
+--echo # table(primary key, auto increment)
+--echo #
+CREATE TABLE t1(
+ a INT NOT NULL AUTO_INCREMENT,
+ b INT,
+ PRIMARY KEY(a)
+) ENGINE=ROCKSDB
+PARTITION BY KEY() PARTITIONS 3;
+
+--source truncate_partition.inc
+
+
+--echo #
+--echo # table(cf)
+--echo #
+CREATE TABLE t1 (
+ a INT,
+ b INT,
+ PRIMARY KEY (`a`, `b`) COMMENT 'testcomment'
+) ENGINE=ROCKSDB
+ PARTITION BY LIST(a) (
+ PARTITION p0 VALUES IN (1, 4, 7),
+ PARTITION p1 VALUES IN (2, 5, 8),
+ PARTITION p2 VALUES IN (3, 6, 9)
+);
+
+--source truncate_partition.inc
+
+
+--echo #
+--echo # table(reverse cf)
+--echo #
+CREATE TABLE t1 (
+ a INT,
+ b INT,
+ PRIMARY KEY (`a`, `b`) COMMENT 'p0_cfname=rev:foo;p1_cfname=bar;p2_cfname=baz'
+) ENGINE=ROCKSDB
+PARTITION BY LIST(a) (
+ PARTITION p0 VALUES IN (1, 4, 7),
+ PARTITION p1 VALUES IN (2, 5, 8),
+ PARTITION p2 VALUES IN (3, 6, 9)
+);
+
+--source truncate_partition.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/truncate_table.test b/storage/rocksdb/mysql-test/rocksdb/t/truncate_table.test
new file mode 100644
index 00000000..1001eeb6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/truncate_table.test
@@ -0,0 +1,74 @@
+--source include/have_rocksdb.inc
+
+#
+# TRUNCATE TABLE
+#
+
+########################################
+# TODO:
+# A part of the test is disabled because
+# HANDLER is not supported. If it ever
+# changes, the test will complain about
+# NOT producing ER_ILLEGAL_HA
+########################################
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+TRUNCATE TABLE t1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c');
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+DROP TABLE t1;
+
+
+# Truncate resets auto-increment value on the table
+
+CREATE TABLE t1 (a INT KEY AUTO_INCREMENT, c CHAR(8)) ENGINE=rocksdb;
+
+#--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 #
+--replace_column 5 # 6 # 7 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+INSERT INTO t1 (c) VALUES ('a'),('b'),('c');
+#--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 #
+--replace_column 5 # 6 # 7 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+TRUNCATE TABLE t1;
+#--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 #
+--replace_column 5 # 6 # 7 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+INSERT INTO t1 (c) VALUES ('d');
+#--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 #
+--replace_column 5 # 6 # 7 # 12 # 13 #
+SHOW TABLE STATUS LIKE 't1';
+
+--sorted_result
+SELECT a,c FROM t1;
+DROP TABLE t1;
+
+# Truncate closes handlers
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
+
+--error ER_ILLEGAL_HA
+HANDLER t1 OPEN AS h1;
+
+--disable_parsing
+
+HANDLER h1 READ FIRST;
+TRUNCATE TABLE t1;
+--error ER_UNKNOWN_TABLE
+HANDLER h1 READ NEXT;
+HANDLER t1 OPEN AS h2;
+HANDLER h2 READ FIRST;
+
+--enable_parsing
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/truncate_table3-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/truncate_table3-master.opt
new file mode 100644
index 00000000..a9ebc4ec
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/truncate_table3-master.opt
@@ -0,0 +1,2 @@
+--rocksdb_max_subcompactions=1
+--rocksdb_default_cf_options=write_buffer_size=16k;target_file_size_base=16k;level0_slowdown_writes_trigger=-1;level0_stop_writes_trigger=1000;compression_per_level=kNoCompression;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/truncate_table3.test b/storage/rocksdb/mysql-test/rocksdb/t/truncate_table3.test
new file mode 100644
index 00000000..b3f95f81
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/truncate_table3.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+
+-- let $truncate_table = 1
+-- let $drop_table = 0
+-- source drop_table3.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/trx_info.test b/storage/rocksdb/mysql-test/rocksdb/t/trx_info.test
new file mode 100644
index 00000000..975bed61
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/trx_info.test
@@ -0,0 +1,17 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+create table t1 (a int) engine=rocksdb;
+insert into t1 values (1);
+insert into t1 values (2);
+
+set autocommit=0;
+select * from t1 for update;
+
+--replace_column 1 _TRX_ID_ 3 _NAME_ 7 _KEY_ 14 _THREAD_ID_
+select * from information_schema.rocksdb_trx;
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/trx_info_rpl.cnf b/storage/rocksdb/mysql-test/rocksdb/t/trx_info_rpl.cnf
new file mode 100644
index 00000000..46771b5a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/trx_info_rpl.cnf
@@ -0,0 +1,11 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+binlog_format=row
+loose-enable-rocksdb_trx
+
+[mysqld.2]
+binlog_format=row
+slave_parallel_workers=1
+rpl_skip_tx_api=ON
+loose-enable-rocksdb_trx
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/trx_info_rpl.test b/storage/rocksdb/mysql-test/rocksdb/t/trx_info_rpl.test
new file mode 100644
index 00000000..91ab266c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/trx_info_rpl.test
@@ -0,0 +1,44 @@
+--source include/have_rocksdb.inc
+--source include/master-slave.inc
+--source include/have_binlog_format_row.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+connection slave;
+--source include/stop_slave.inc
+--enable_warnings
+
+connection master;
+create table t1 (a int, b int, primary key (a), unique key (b)) engine=rocksdb;
+--disable_query_log
+--let $aa= 0
+while ($aa < 1000) {
+ eval insert into t1 values ($aa, $aa);
+ --inc $aa
+}
+--enable_query_log
+
+connection slave;
+show variables like 'rpl_skip_tx_api';
+--source include/start_slave.inc
+
+--let $it=0
+--let $stop=0
+while ($stop != 1) {
+let $count= query_get_value(select count(*) as Value from information_schema.rocksdb_trx, Value, 1);
+ if ($count) {
+ --echo found
+ --let $stop=1
+ }
+
+ if ($it > 1000) {
+ --echo not found
+ --let $stop=1
+ }
+
+ --inc $it
+}
+
+connection master;
+DROP TABLE t1;
+--source include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary-master.opt
new file mode 100644
index 00000000..b991f718
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary-master.opt
@@ -0,0 +1,2 @@
+--rocksdb_enable_ttl_read_filtering=0
+--rocksdb_default_cf_options=disable_auto_compactions=true
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary.test b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary.test
new file mode 100644
index 00000000..38bfb2ee
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary.test
@@ -0,0 +1,545 @@
+--source include/have_debug.inc
+--source include/have_rocksdb.inc
+
+# Basic TTL test
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64) NOT NULL,
+`c` varbinary(256) NOT NULL,
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`b`,`a`,`c`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', 'b', 'c', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('d', 'e', 'f', UNIX_TIMESTAMP(), 'g');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+# column before TTL in value
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ b int NOT NULL,
+ ts bigint(20) UNSIGNED NOT NULL,
+ c int NOT NULL,
+ PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, UNIX_TIMESTAMP(), 5);
+INSERT INTO t1 values (2, 4, UNIX_TIMESTAMP(), 6);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+# multi-part PK w/ TTL
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ ts bigint(20) UNSIGNED NOT NULL,
+ PRIMARY KEY (a,c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, 5, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, 4, 6, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+# multi-part PK w/ TTL
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ ts bigint(20) UNSIGNED NOT NULL,
+ PRIMARY KEY (a,c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, 5, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, 4, 6, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+# nullable column(s) before TTL
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ b int,
+ c int,
+ ts bigint(20) UNSIGNED NOT NULL,
+ PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, NULL, NULL, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, NULL, NULL, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+# variable len columns + null column(s) before TTL
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64),
+`c` varbinary(256),
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`a`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', NULL, 'bc', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('d', 'efghijk', NULL, UNIX_TIMESTAMP(), 'l');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+# TTL implicitly generated (no ttl column)
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, 5);
+INSERT INTO t1 values (2, 4, 6);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+# TTL field as the PK
+CREATE TABLE t1 (
+ a int,
+ ts bigint(20) UNSIGNED NOT NULL,
+ PRIMARY KEY (a, ts)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;ttl_col=ts;';
+
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, UNIX_TIMESTAMP());
+SELECT COUNT(*) FROM t1;
+
+set global rocksdb_debug_ttl_snapshot_ts = -10;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+# should all still be there..
+SELECT COUNT(*) FROM t1;
+
+set global rocksdb_debug_ttl_snapshot_ts = 10;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+
+# TTL field inside multi-part pk
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ b int NOT NULL,
+ ts bigint(20) UNSIGNED NOT NULL,
+ c int NOT NULL,
+ PRIMARY KEY (a, ts)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, UNIX_TIMESTAMP(), 5);
+INSERT INTO t1 values (2, 4, UNIX_TIMESTAMP(), 6);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+# TTL field inside key with variable length things..
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64),
+`c` varbinary(256),
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`a`, `ts`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', NULL, 'bc', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('de', 'fghijk', NULL, UNIX_TIMESTAMP(), 'l');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+# TTL test where you compact (values still exist), real_sleep, then compact again,
+# values should now be gone.
+CREATE TABLE t1 (
+a INT NOT NULL,
+b varbinary(64) NOT NULL,
+c varbinary(256) NOT NULL,
+ts bigint(20) UNSIGNED NOT NULL,
+value mediumblob NOT NULL,
+PRIMARY KEY (b,a,c)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=10;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, 'b', 'c', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values (2, 'e', 'f', UNIX_TIMESTAMP(), 'g');
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (3, 'i', 'j', UNIX_TIMESTAMP(), 'k');
+INSERT INTO t1 values (4, 'm', 'n', UNIX_TIMESTAMP(), 'o');
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+# Nothing should get removed here.
+set global rocksdb_debug_ttl_snapshot_ts = -3600;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+--sorted_result
+SELECT a FROM t1;
+
+# 1 and 2 should get removed here.
+set global rocksdb_compact_cf='default';
+--sorted_result
+SELECT a FROM t1;
+
+# 3 and 4 should get removed here.
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+--sorted_result
+SELECT a FROM t1;
+
+DROP TABLE t1;
+
+# TTL field with nullable ttl column (should fail)
+--error ER_RDB_TTL_COL_FORMAT
+CREATE TABLE t1 (
+ a bigint(20) UNSIGNED NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ ts bigint(20),
+ PRIMARY KEY (a,c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+# TTL field with non 8-bit integer column (should fail)
+--error ER_RDB_TTL_COL_FORMAT
+CREATE TABLE t1 (
+ a bigint(20) UNSIGNED NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ ts int,
+ PRIMARY KEY (a,c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+# TTL duration as some random garbage value
+--error ER_RDB_TTL_DURATION_FORMAT
+CREATE TABLE t1 (
+ a bigint(20) UNSIGNED NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ PRIMARY KEY (a,c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=abc;';
+
+# TTL col is some column outside of the table
+--error ER_RDB_TTL_COL_FORMAT
+CREATE TABLE t1 (
+ a bigint(20) UNSIGNED NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ PRIMARY KEY (a,c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=abc;';
+
+# TTL col must have accompanying duration
+--error ER_RDB_TTL_COL_FORMAT
+CREATE TABLE t1 (
+ a bigint(20) UNSIGNED NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ PRIMARY KEY (a,c)
+) ENGINE=rocksdb
+COMMENT='ttl_col=abc;';
+
+# Make sure it doesn't filter out things early
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=500;';
+
+INSERT INTO t1 values (1);
+SELECT COUNT(*) FROM t1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+# Testing altering table comment with updated TTL duration
+# This should trigger a rebuild of the table
+CREATE TABLE t1 (
+ a INT PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+
+INSERT INTO t1 values (1);
+SELECT * FROM t1;
+
+set global rocksdb_debug_ttl_rec_ts = -300;
+ALTER TABLE t1 COMMENT = 'ttl_duration=1';
+set global rocksdb_debug_ttl_rec_ts = 0;
+SHOW CREATE TABLE t1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+# Tables with hidden PK and SK disabled
+CREATE TABLE t1 (
+ a INT PRIMARY KEY,
+ b INT
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+
+--error ER_RDB_TTL_UNSUPPORTED
+ALTER TABLE t1 DROP PRIMARY KEY;
+
+DROP TABLE t1;
+
+# Test replacing PK, ttl should still work after
+CREATE TABLE t1 (
+ a INT PRIMARY KEY,
+ b INT
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;';
+
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (2,2);
+
+ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b);
+set global rocksdb_debug_ttl_snapshot_ts = -3600;
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+
+--sorted_result
+SELECT COUNT(*) FROM t1;
+
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+
+--sorted_result
+SELECT COUNT(*) FROM t1;
+
+DROP TABLE t1;
+
+# Make sure table comment filled with other text before/after will work
+# (basically, it needs semicolon before and after)
+CREATE TABLE t1 (
+ a bigint(20) UNSIGNED NOT NULL,
+ b int,
+ PRIMARY KEY (a,b)
+) ENGINE=rocksdb
+COMMENT='asdadfasdfsadfadf ;ttl_duration=1; asfasdfasdfadfa';
+INSERT INTO t1 values (UNIX_TIMESTAMP(), 1);
+SELECT COUNT(*) FROM t1;
+
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+
+SELECT COUNT(*) FROM t1;
+
+ALTER TABLE t1 COMMENT = 'adsf;;ttl_duration=5;asfasdfa;ttl_col=a;asdfasdf;';
+
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (UNIX_TIMESTAMP(), 2);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+
+# nothing removed here
+set global rocksdb_compact_cf='default';
+SELECT COUNT(*) FROM t1;
+
+# all removed here
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+SELECT COUNT(*) FROM t1;
+
+DROP TABLE t1;
+
+# Test to make sure that TTL retains original timestamp during update
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;';
+
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1);
+INSERT INTO t1 values (3);
+INSERT INTO t1 values (5);
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (7);
+INSERT INTO t1 values (9);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+UPDATE t1 SET a=a+1;
+--sorted_result
+SELECT * FROM t1;
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# 1,3,5 should be dropped
+--sorted_result
+SELECT * FROM t1;
+DROP TABLE t1;
+
+# test behaviour on update with TTL column, TTL time can be updated here.
+CREATE TABLE t1 (
+ a INT,
+ b bigint(20) UNSIGNED NOT NULL,
+ PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;ttl_col=b;';
+
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+INSERT INTO t1 values (3, UNIX_TIMESTAMP());
+INSERT INTO t1 values (5, UNIX_TIMESTAMP());
+INSERT INTO t1 values (7, UNIX_TIMESTAMP());
+
+set global rocksdb_debug_ttl_rec_ts = 300;
+UPDATE t1 SET b=UNIX_TIMESTAMP() WHERE a < 4;
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+--sorted_result
+SELECT a FROM t1;
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# 5 and 7 should be gone here
+--sorted_result
+SELECT a FROM t1;
+DROP TABLE t1;
+
+# Test rows expired stat variable and disable ttl variable
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1);
+INSERT INTO t1 values (2);
+INSERT INTO t1 values (3);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+set global rocksdb_enable_ttl=0;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_enable_ttl=1;
+set global rocksdb_compact_cf='default';
+
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+
+# Table with TTL won't increment rows expired when no records have been
+# compacted
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ PRIMARY KEY (a)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+
+INSERT INTO t1 values (1);
+INSERT INTO t1 values (2);
+INSERT INTO t1 values (3);
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_read_filtering-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_read_filtering-master.opt
new file mode 100644
index 00000000..aefc2f5d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_read_filtering-master.opt
@@ -0,0 +1 @@
+--rocksdb_default_cf_options=disable_auto_compactions=true
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_read_filtering.test b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_read_filtering.test
new file mode 100644
index 00000000..7a7609f4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_read_filtering.test
@@ -0,0 +1,388 @@
+--source include/have_debug.inc
+--source include/have_rocksdb.inc
+
+# The purpose of read filtering for tables with TTL is to ensure that during a
+# transaction a key which has expired already but not removed by compaction
+# yet, is not returned to the user.
+#
+# Without this the user might be hit with problems such as disappearing rows
+# within a transaction, etc, because the compaction filter ignores snapshots
+# when filtering keys.
+
+# Basic read filtering test
+CREATE TABLE t1 (
+ a int PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1);
+INSERT INTO t1 values (2);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+
+--sorted_result
+SELECT * FROM t1;
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_compact_cf='default';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+
+DROP TABLE t1;
+
+# Test that some rows are hidden but others aren't...
+CREATE TABLE t1 (
+ a int PRIMARY KEY,
+ b BIGINT UNSIGNED NOT NULL
+) ENGINE=rocksdb
+COMMENT='ttl_duration=10;';
+
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (2, UNIX_TIMESTAMP());
+INSERT INTO t1 values (3, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+set global rocksdb_force_flush_memtable_now=1;
+
+# 1 should be hidden even though compaction hasn't run.
+--sorted_result
+SELECT a FROM t1;
+
+set global rocksdb_compact_cf='default';
+
+# none should be hidden yet, compaction runs but records aren't expired
+--sorted_result
+SELECT a FROM t1;
+
+# all should be hidden now, even though compaction hasn't run again
+set global rocksdb_debug_ttl_read_filter_ts = -310;
+--sorted_result
+SELECT a FROM t1;
+set global rocksdb_debug_ttl_read_filter_ts = 0;
+
+DROP TABLE t1;
+
+# Test the filtering code explicitly.
+CREATE TABLE t1 (
+ a int PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1);
+INSERT INTO t1 values (3);
+INSERT INTO t1 values (5);
+INSERT INTO t1 values (7);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+# should return nothing.
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+--sorted_result
+SELECT * FROM t1;
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+
+# disable filtering
+set global rocksdb_enable_ttl_read_filtering=0;
+
+# should return everything
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+--sorted_result
+SELECT * FROM t1;
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+
+# enable filtering
+set global rocksdb_enable_ttl_read_filtering=1;
+
+# should return nothing.
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+--sorted_result
+SELECT * FROM t1;
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+
+DROP TABLE t1;
+# Compact away the dropped data
+set global ROCKSDB_COMPACT_CF= 'default';
+
+# Read filtering index scan tests (None of these queries should return any results)
+CREATE TABLE t1 (
+ a int,
+ b int,
+ c int,
+ PRIMARY KEY (a,b,c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (0,0,0);
+INSERT INTO t1 values (0,0,1);
+INSERT INTO t1 values (0,1,0);
+INSERT INTO t1 values (0,1,1);
+INSERT INTO t1 values (1,1,2);
+INSERT INTO t1 values (1,2,1);
+INSERT INTO t1 values (1,2,2);
+INSERT INTO t1 values (1,2,3);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+
+set global rocksdb_force_flush_memtable_now=1;
+
+# HA_READ_KEY_EXACT, using full key
+SELECT * FROM t1 WHERE a=1 AND b=2 AND c=2;
+
+# HA_READ_KEY_EXACT, not using full key
+SELECT * FROM t1 WHERE a = 1;
+
+# HA_READ_BEFORE_KEY, not using full key
+SELECT max(a) from t1 where a < 3;
+
+#HA_READ_BEFORE_KEY, using full key
+SELECT max(a) from t1 where a < 2 AND b = 1 AND c < 3;
+
+# HA_READ_KEY_OR_NEXT
+SELECT min(a) from t1 where a >= 1;
+
+# HA_READ_AFTER_KEY, /* Find next rec. after key-record */
+SELECT min(a) from t1 where a > 1;
+
+# HA_READ_PREFIX_LAST, /* Last key with the same prefix */
+select * from t1 where a=1 and b in (1) order by c desc;
+
+# HA_READ_PREFIX_LAST_OR_PREV, /* Last or prev key with the same prefix */
+select max(a) from t1 where a <=10;
+
+# need to test read_range_first()
+# calls into read_range_next() and uses compare_keys() to see if its out of
+# range
+select a from t1 where a > 0 and a <= 2;
+
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_compact_cf='default';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+DROP TABLE t1;
+
+# duplicate PK value attempt to be inserted when old one is expired...
+# in this case, we pretend the expired key was not found and insert into PK
+CREATE TABLE t1 (
+ a int PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+set global rocksdb_debug_ttl_rec_ts = -110;
+INSERT INTO t1 values (1);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+SELECT * FROM t1;
+
+# this should work, even if old value is not filtered out yet.
+INSERT INTO t1 values (1);
+
+# should show (1) result
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+# Attempt to update expired value, should filter out
+set global rocksdb_force_flush_memtable_now=1;
+CREATE TABLE t1 (
+ a int PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+--sorted_result
+SELECT * FROM t1;
+
+# No error is thrown here, under the hood rnd_next_with_direction is
+# filtering out the record from being seen in the first place.
+UPDATE t1 set a = 1;
+DROP TABLE t1;
+
+##
+## More tests on update behaviour with expired keys.
+##
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+CREATE TABLE t1 (
+ a int PRIMARY KEY,
+ b int
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+
+set global rocksdb_debug_ttl_rec_ts = -110;
+INSERT INTO t1 values (1,1);
+INSERT INTO t1 values (3,3);
+set global rocksdb_debug_ttl_rec_ts = 0;
+INSERT INTO t1 values (5,5);
+
+# expired key (1) is still around under the hood, but
+# this time rnd_next_with_direction finds non-expired key (5). So the
+# execution flow in the SQL layer moves onto update_write_row, where it then
+# finds the duplicate key (1). But the duplicate key is expired, so it allows
+# the overwrite.
+UPDATE t1 set a = 1;
+
+--sorted_result
+SELECT * FROM t1;
+
+set global rocksdb_enable_ttl_read_filtering=0;
+# 1,1 should be gone, even with read filtering disabled as it has been
+# overwritten
+--sorted_result
+SELECT * FROM t1;
+set global rocksdb_enable_ttl_read_filtering=1;
+
+# get_row_by_rowid tested here via index_read_map_impl
+UPDATE t1 set a = 999 where a = 1;
+--sorted_result
+SELECT * FROM t1;
+
+UPDATE t1 set a = a - 1;
+--sorted_result
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+# Ensure no rows can disappear in the middle of long-running transactions
+# Also ensure repeatable-read works as expected
+--source include/count_sessions.inc
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+CREATE TABLE t1 (
+ a int PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;';
+
+INSERT INTO t1 values (1);
+
+connection con1;
+--echo # Creating Snapshot (start transaction)
+BEGIN;
+
+# We need the below snippet in case establishing con1 took an arbitrary
+# amount of time. See https://github.com/facebook/mysql-5.6/pull/617#discussion_r120525391.
+--disable_query_log
+--let $snapshot_size= `SELECT COUNT(*) FROM t1`
+--let $i= 0
+while ($snapshot_size != 1)
+{
+ if ($i == 1000)
+ {
+ --die Your testing host is too slow for reasonable TTL testing
+ }
+
+ $i++;
+ ROLLBACK;
+ INSERT INTO t1 values (1);
+ BEGIN;
+ --let $snapshot_size= `SELECT COUNT(*) FROM t1`
+}
+--enable_query_log
+
+# Nothing filtered out here
+--sorted_result
+SELECT * FROM t1;
+
+--sleep 5
+
+--sorted_result
+SELECT * FROM t1; # <= shouldn't be filtered out here
+
+--echo # Switching to connection 2
+connection con2;
+# compaction doesn't do anything since con1 snapshot is still open
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+# read filtered out, because on a different connection, on
+# this connection the records have 'expired' already so they are filtered out
+# even though they have not yet been removed by compaction
+
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+--sorted_result
+SELECT * FROM t1;
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+
+--echo # Switching to connection 1
+connection con1;
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+--sorted_result
+SELECT * FROM t1; # <= shouldn't be filtered out here
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+
+UPDATE t1 set a = a + 1;
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+--sorted_result
+SELECT * FROM t1; # <= shouldn't be filtered out here
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+
+COMMIT;
+
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+--sorted_result # <= filtered out here because time has passed.
+SELECT * FROM t1;
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
+
+DROP TABLE t1;
+disconnect con1;
+disconnect con2;
+
+#transaction 1, create a snapshot and select * => returns nothing.
+#transaction 2, insert into table, flush
+#transaction 1, select * => returns nothing, but the snapshot should prevent the compaction code from removing the rows, no matter what the ttl duration is.
+#transaction 2, select * -> sees nothing, disable filter, select * -> sees everything, enable filter, select * -> sees nothing.
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+CREATE TABLE t1 (
+ a int PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+
+--echo # On Connection 1
+connection con1;
+--echo # Creating Snapshot (start transaction)
+BEGIN;
+--sorted_result
+SELECT * FROM t1;
+# Sleep 5 secs after creating snapshot, this ensures any records created after
+# this can't be removed by compaction until this snapshot is released.
+--sleep 5
+
+--echo # On Connection 2
+connection con2;
+set global rocksdb_debug_ttl_rec_ts = -2;
+INSERT INTO t1 values (1);
+INSERT INTO t1 values (3);
+INSERT INTO t1 values (5);
+INSERT INTO t1 values (7);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+--echo # On Connection 1
+connection con1;
+--sorted_result
+SELECT * FROM t1;
+
+--echo # On Connection 2
+connection con2;
+--sorted_result
+SELECT * FROM t1;
+set global rocksdb_enable_ttl_read_filtering=0;
+--sorted_result
+SELECT * FROM t1;
+set global rocksdb_enable_ttl_read_filtering=1;
+
+disconnect con2;
+disconnect con1;
+connection default;
+
+DROP TABLE t1;
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_with_partitions-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_with_partitions-master.opt
new file mode 100644
index 00000000..b991f718
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_with_partitions-master.opt
@@ -0,0 +1,2 @@
+--rocksdb_enable_ttl_read_filtering=0
+--rocksdb_default_cf_options=disable_auto_compactions=true
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_with_partitions.test b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_with_partitions.test
new file mode 100644
index 00000000..aba2b594
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_with_partitions.test
@@ -0,0 +1,254 @@
+--source include/have_debug.inc
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+#
+# Create a table with multiple partitions, but in the comment don't specify
+# that per-partition based column families (CF) should be created. Expect that
+# default CF will be used and new one won't be created.
+#
+# In addition, specify TTL on one of the partitions. Insert a few things
+# inside all the partitions, verify after compaction that the rows inside the
+# partition with TTL has disappeared.
+#
+CREATE TABLE t1 (
+ c1 INT,
+ PRIMARY KEY (`c1`)
+) ENGINE=ROCKSDB
+COMMENT="custom_p0_ttl_duration=1;"
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 4, 7),
+ PARTITION custom_p1 VALUES IN (2, 5, 8),
+ PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+
+set global rocksdb_debug_ttl_rec_ts = -3600;
+INSERT INTO t1 values (1);
+INSERT INTO t1 values (2);
+INSERT INTO t1 values (3);
+INSERT INTO t1 values (4);
+INSERT INTO t1 values (5);
+INSERT INTO t1 values (6);
+INSERT INTO t1 values (7);
+INSERT INTO t1 values (8);
+INSERT INTO t1 values (9);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+--sorted_result
+SELECT * FROM t1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# 1,4, and 7 should be gone
+--sorted_result
+SELECT * FROM t1;
+DROP TABLE t1;
+
+#
+# Create a table with multiple partitions and request for separate CF to be
+# created per every partition. As a result we expect three different CF-s to be
+# created.
+#
+# In addition, specify TTL on some of the partitions. Insert a few things
+# inside all the partitions, verify after compaction that the rows inside the
+# partition with TTL has disappeared.
+#
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ name VARCHAR(25) NOT NULL,
+ PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=my_custom_cf;custom_p2_cfname=baz'
+) ENGINE=ROCKSDB
+COMMENT="custom_p0_ttl_duration=1;custom_p1_ttl_duration=7;"
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 4, 7),
+ PARTITION custom_p1 VALUES IN (2, 5, 8),
+ PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+
+set global rocksdb_debug_ttl_rec_ts = -1200;
+INSERT INTO t1 values (1,1,'a');
+INSERT INTO t1 values (4,4,'aaaa');
+INSERT INTO t1 values (7,7,'aaaaaaa');
+
+set global rocksdb_debug_ttl_rec_ts = 1200;
+INSERT INTO t1 values (2,2,'aa');
+INSERT INTO t1 values (3,3,'aaa');
+INSERT INTO t1 values (5,5,'aaaaa');
+INSERT INTO t1 values (6,6,'aaaaaa');
+INSERT INTO t1 values (8,8,'aaaaaaaa');
+INSERT INTO t1 values (9,9,'aaaaaaaaa');
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+--sorted_result
+SELECT * FROM t1;
+
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'my_custom_cf';
+--sorted_result
+SELECT * FROM t1;
+
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set @@global.rocksdb_compact_cf = 'foo';
+--sorted_result
+SELECT * FROM t1;
+
+# Now 2,5,8 should be removed (this verifies that TTL is only operating on the
+# particular CF.
+set @@global.rocksdb_compact_cf = 'my_custom_cf';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+--sorted_result
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+#
+# Create a table with CF-s/TTL per partition and verify that ALTER TABLE + DROP
+# PRIMARY, ADD PRIMARY work for that scenario and data is persisted/filtered as
+# expected.
+#
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ name VARCHAR(25) NOT NULL,
+ event DATE,
+ PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz;'
+) ENGINE=ROCKSDB
+COMMENT="custom_p0_ttl_duration=9999;custom_p2_ttl_duration=5;"
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 2, 3),
+ PARTITION custom_p1 VALUES IN (4, 5, 6),
+ PARTITION custom_p2 VALUES IN (7, 8, 9)
+);
+
+INSERT INTO t1 VALUES (1, 1, "one", null);
+INSERT INTO t1 VALUES (2, 2, "two", null);
+INSERT INTO t1 VALUES (3, 3, "three", null);
+
+INSERT INTO t1 VALUES (4, 4, "four", null);
+INSERT INTO t1 VALUES (5, 5, "five", null);
+INSERT INTO t1 VALUES (6, 6, "six", null);
+
+INSERT INTO t1 VALUES (7, 7, "seven", null);
+INSERT INTO t1 VALUES (8, 8, "eight", null);
+INSERT INTO t1 VALUES (9, 9, "nine", null);
+
+--sorted_result
+SELECT * FROM t1;
+
+# TTL should be reset after alter table
+set global rocksdb_debug_ttl_rec_ts = 600;
+ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(`c2`,`c1`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz;';
+set global rocksdb_debug_ttl_rec_ts = 0;
+SHOW CREATE TABLE t1;
+
+# ...so nothing should be gone here
+set global rocksdb_debug_ttl_snapshot_ts = 100;
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'baz';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+--sorted_result
+SELECT * FROM t1;
+
+set global rocksdb_debug_ttl_snapshot_ts = 1200;
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'baz';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+--sorted_result
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+#
+# Create a table with non-partitioned TTL duration, with partitioned TTL
+# columns
+#
+# In this case the same TTL duration will be applied across different TTL
+# columns in different partitions, except for in p2 where we override the ttl
+# duration.
+#
+CREATE TABLE t1 (
+ c1 BIGINT,
+ c2 BIGINT UNSIGNED NOT NULL,
+ name VARCHAR(25) NOT NULL,
+ event DATE,
+ PRIMARY KEY (`c1`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz;'
+) ENGINE=ROCKSDB
+COMMENT="ttl_duration=1;custom_p1_ttl_duration=100;custom_p1_ttl_col=c2;custom_p2_ttl_duration=5000;"
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 2, 3),
+ PARTITION custom_p1 VALUES IN (4, 5, 6),
+ PARTITION custom_p2 VALUES IN (7, 8, 9)
+);
+
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 VALUES (1, UNIX_TIMESTAMP(), "one", null);
+INSERT INTO t1 VALUES (2, UNIX_TIMESTAMP(), "two", null);
+INSERT INTO t1 VALUES (3, UNIX_TIMESTAMP(), "three", null);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+INSERT INTO t1 VALUES (4, UNIX_TIMESTAMP(), "four", null);
+INSERT INTO t1 VALUES (5, UNIX_TIMESTAMP(), "five", null);
+INSERT INTO t1 VALUES (6, UNIX_TIMESTAMP(), "six", null);
+
+INSERT INTO t1 VALUES (7, UNIX_TIMESTAMP(), "seven", null);
+INSERT INTO t1 VALUES (8, UNIX_TIMESTAMP(), "eight", null);
+INSERT INTO t1 VALUES (9, UNIX_TIMESTAMP(), "nine", null);
+
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'baz';
+set @@global.rocksdb_compact_cf = 'bar';
+
+# here we expect only 1,2,3 to be gone, ttl implicit.
+--sorted_result
+SELECT c1 FROM t1;
+
+# here we expect only 4,5,6 to be gone, ttl based on column c2.
+set global rocksdb_debug_ttl_snapshot_ts = 600;
+set @@global.rocksdb_compact_cf = 'bar';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+--sorted_result
+SELECT c1 FROM t1;
+
+# at this point only 7,8,9 should be left..
+DROP TABLE t1;
+
+#
+# Make sure non-partitioned TTL duration/col still works on table with
+# partitions.
+#
+# Simultaneously tests when TTL col is part of the key in partitioned table
+#
+CREATE TABLE t1 (
+ c1 BIGINT,
+ c2 BIGINT UNSIGNED NOT NULL,
+ PRIMARY KEY (`c1`, `c2`)
+) ENGINE=ROCKSDB
+COMMENT="ttl_duration=100;ttl_col=c2;"
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1),
+ PARTITION custom_p1 VALUES IN (2),
+ PARTITION custom_p2 VALUES IN (3)
+);
+
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, UNIX_TIMESTAMP());
+INSERT INTO t1 values (3, UNIX_TIMESTAMP());
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# everything should still be here
+--sorted_result
+SELECT c1 FROM t1;
+
+set global rocksdb_debug_ttl_snapshot_ts = 300;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+# everything should now be gone
+--sorted_result
+SELECT c1 FROM t1;
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_rows_examined.test b/storage/rocksdb/mysql-test/rocksdb/t/ttl_rows_examined.test
new file mode 100644
index 00000000..714c2c60
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_rows_examined.test
@@ -0,0 +1,57 @@
+--source include/have_rocksdb.inc
+--source include/have_debug_sync.inc
+
+####
+# Bump rows_examined count whenever MyRocks filters out a row due to expired TTL
+####
+
+# clean start
+set debug_sync='RESET';
+set global rocksdb_debug_ttl_read_filter_ts = -10;
+
+--enable_connect_log
+--enable_info
+
+connect (conn1, localhost, root,,test);
+connect (conn2, localhost, root,,test);
+
+connection conn1;
+
+# create table with TTL policy (1s)
+CREATE TABLE t_re (
+ a INT, b INT, PRIMARY KEY (a)
+) ENGINE=ROCKSDB
+COMMENT 'ttl_duration=1';
+
+# start with 2 rows, expired at the insertion time
+set global rocksdb_debug_ttl_rec_ts = -13;
+insert into t_re values (1,1);
+insert into t_re values (2,2);
+set global rocksdb_debug_ttl_rec_ts = 0;
+commit;
+
+# setup signal to stop in code where we skip expired records
+set debug_sync='rocksdb.ttl_rows_examined SIGNAL parked WAIT_FOR go';
+send SELECT * FROM t_re;
+
+connection conn2;
+set debug_sync='now WAIT_FOR parked';
+
+# display "Rows Examined" before returning from call
+--replace_result Execute Query
+--replace_column 1 ### 2 ### 3 ### 4 ### 6 ### 10 ### 11 ### 12 ###
+--sorted_result
+SHOW PROCESSLIST;
+
+set debug_sync='now SIGNAL go';
+
+connection conn1;
+reap;
+
+# tidy up
+set debug_sync='RESET';
+set global rocksdb_debug_ttl_read_filter_ts = DEFAULT;
+drop table t_re;
+
+disconnect conn1;
+disconnect conn2;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary-master.opt
new file mode 100644
index 00000000..b991f718
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary-master.opt
@@ -0,0 +1,2 @@
+--rocksdb_enable_ttl_read_filtering=0
+--rocksdb_default_cf_options=disable_auto_compactions=true
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary.test b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary.test
new file mode 100644
index 00000000..fb439e10
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary.test
@@ -0,0 +1,780 @@
+--source include/have_debug.inc
+--source include/have_rocksdb.inc
+
+# Basic TTL test, pk ignored, no sk
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64) NOT NULL,
+`c` varbinary(256) NOT NULL,
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`b`,`a`,`c`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', 'b', 'c', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('d', 'e', 'f', UNIX_TIMESTAMP(), 'g');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+
+# no rows should be filtered
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+# Basic TTL test
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64) NOT NULL,
+`c` varbinary(256) NOT NULL,
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`b`,`a`,`c`),
+KEY kb (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', 'b', 'c', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('d', 'e', 'f', UNIX_TIMESTAMP(), 'g');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+DROP TABLE t1;
+
+# column before TTL in value
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ b int NOT NULL,
+ ts bigint(20) UNSIGNED NOT NULL,
+ c int NOT NULL,
+ PRIMARY KEY (a),
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, UNIX_TIMESTAMP(), 5);
+INSERT INTO t1 values (2, 4, UNIX_TIMESTAMP(), 6);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+DROP TABLE t1;
+
+# multi-part PK w/ TTL
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ ts bigint(20) UNSIGNED NOT NULL,
+ PRIMARY KEY (a,c),
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, 5, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, 4, 6, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+DROP TABLE t1;
+
+# nullable column(s) before TTL
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ b int,
+ c int,
+ ts bigint(20) UNSIGNED NOT NULL,
+ PRIMARY KEY (a),
+ KEY kbc (b, c)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, NULL, NULL, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, NULL, NULL, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+DROP TABLE t1;
+
+# variable len columns + null column(s) before TTL
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64),
+`c` varbinary(256),
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`a`),
+KEY kbc (`b`, `c`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', NULL, 'bc', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('d', 'efghijk', NULL, UNIX_TIMESTAMP(), 'l');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+DROP TABLE t1;
+
+# TTL implicitly generated (no ttl column)
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ PRIMARY KEY (a),
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, 5);
+INSERT INTO t1 values (2, 4, 6);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+DROP TABLE t1;
+
+# TTL field as the PK
+CREATE TABLE t1 (
+ a int,
+ ts bigint(20) UNSIGNED NOT NULL,
+ PRIMARY KEY (a, ts),
+ KEY kt (ts)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;ttl_col=ts;';
+
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+INSERT INTO t1 values (2, UNIX_TIMESTAMP());
+SELECT COUNT(*) FROM t1 FORCE INDEX(kt);
+
+set global rocksdb_debug_ttl_snapshot_ts = -10;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+# should all still be there..
+SELECT COUNT(*) FROM t1 FORCE INDEX(kt);
+
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_debug_ttl_snapshot_ts = 10;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+set global rocksdb_debug_ttl_ignore_pk=0;
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1 FORCE INDEX(kt);
+DROP TABLE t1;
+
+# TTL field inside multi-part pk
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ b int NOT NULL,
+ ts bigint(20) UNSIGNED NOT NULL,
+ c int NOT NULL,
+ PRIMARY KEY (a, ts),
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 3, UNIX_TIMESTAMP(), 5);
+INSERT INTO t1 values (2, 4, UNIX_TIMESTAMP(), 6);
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+# TTL field inside key with variable length things..
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64),
+`c` varbinary(256),
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`a`, `ts`),
+KEY kb (`b`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', NULL, 'bc', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('de', 'fghijk', NULL, UNIX_TIMESTAMP(), 'l');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*) FROM t1;
+
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+# TTL test where you compact (values still exist), real_sleep, then compact again,
+# values should now be gone.
+CREATE TABLE t1 (
+a INT NOT NULL,
+b varbinary(64) NOT NULL,
+c varbinary(256) NOT NULL,
+ts bigint(20) UNSIGNED NOT NULL,
+value mediumblob NOT NULL,
+PRIMARY KEY (b,a,c),
+KEY kb (b)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=10;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, 'b', 'c', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values (2, 'e', 'f', UNIX_TIMESTAMP(), 'g');
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (3, 'i', 'j', UNIX_TIMESTAMP(), 'k');
+INSERT INTO t1 values (4, 'm', 'n', UNIX_TIMESTAMP(), 'o');
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+# Nothing should get removed here.
+set global rocksdb_debug_ttl_snapshot_ts = -3600;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+--sorted_result
+SELECT a FROM t1 FORCE INDEX (kb);
+
+# 1 and 2 should get removed here.
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+--sorted_result
+SELECT a FROM t1 FORCE INDEX (kb);
+
+# 3 and 4 should get removed here.
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+set global rocksdb_debug_ttl_ignore_pk=0;
+--sorted_result
+SELECT a FROM t1 FORCE INDEX (kb);
+
+DROP TABLE t1;
+
+# TTL field with nullable ttl column (should fail)
+--error ER_RDB_TTL_COL_FORMAT
+CREATE TABLE t1 (
+ a bigint(20) UNSIGNED NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ ts bigint(20),
+ PRIMARY KEY (a,c),
+ KEY (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+# TTL field with non 8-bit integer column (should fail)
+--error ER_RDB_TTL_COL_FORMAT
+CREATE TABLE t1 (
+ a bigint(20) UNSIGNED NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ ts int,
+ PRIMARY KEY (a,c),
+ KEY (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+# TTL duration as some random garbage value
+--error ER_RDB_TTL_DURATION_FORMAT
+CREATE TABLE t1 (
+ a bigint(20) UNSIGNED NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ PRIMARY KEY (a,c),
+ KEY (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=abc;';
+
+# TTL col is some column outside of the table
+--error ER_RDB_TTL_COL_FORMAT
+CREATE TABLE t1 (
+ a bigint(20) UNSIGNED NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ PRIMARY KEY (a,c),
+ KEY (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=abc;';
+
+# TTL col must have accompanying duration
+--error ER_RDB_TTL_COL_FORMAT
+CREATE TABLE t1 (
+ a bigint(20) UNSIGNED NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ PRIMARY KEY (a,c),
+ KEY (b)
+) ENGINE=rocksdb
+COMMENT='ttl_col=abc;';
+
+# Make sure it doesn't filter out things early
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ b int NOT NULL,
+ PRIMARY KEY (a),
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=500;';
+
+INSERT INTO t1 values (1, 1);
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+DROP TABLE t1;
+
+# Testing altering table comment with updated TTL duration
+# This should trigger a rebuild of the table
+CREATE TABLE t1 (
+ a INT PRIMARY KEY,
+ b INT NOT NULL,
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+
+INSERT INTO t1 values (1, 1);
+SELECT * FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_rec_ts = -300;
+ALTER TABLE t1 COMMENT = 'ttl_duration=1';
+set global rocksdb_debug_ttl_rec_ts = 0;
+SHOW CREATE TABLE t1;
+
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+DROP TABLE t1;
+
+# Tables with hidden PK disabled
+CREATE TABLE t1 (
+ a INT PRIMARY KEY,
+ b INT,
+ KEY (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+
+--error ER_RDB_TTL_UNSUPPORTED
+ALTER TABLE t1 DROP PRIMARY KEY;
+
+DROP TABLE t1;
+
+# Test replacing PK, ttl should still work after
+CREATE TABLE t1 (
+ a INT PRIMARY KEY,
+ b INT,
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;';
+
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (2,2);
+
+ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b);
+set global rocksdb_debug_ttl_snapshot_ts = -3600;
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+
+--sorted_result
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+set global rocksdb_debug_ttl_ignore_pk=0;
+
+--sorted_result
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+
+DROP TABLE t1;
+
+# Make sure table comment filled with other text before/after will work
+# (basically, it needs semicolon before and after)
+CREATE TABLE t1 (
+ a bigint(20) UNSIGNED NOT NULL,
+ b int,
+ PRIMARY KEY (a,b),
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='asdadfasdfsadfadf ;ttl_duration=1; asfasdfasdfadfa';
+INSERT INTO t1 values (UNIX_TIMESTAMP(), 1);
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+
+ALTER TABLE t1 COMMENT = 'adsf;;ttl_duration=5;asfasdfa;ttl_col=a;asdfasdf;';
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (UNIX_TIMESTAMP(), 2);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+
+# nothing removed here
+set global rocksdb_compact_cf='default';
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+
+# all removed here
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+set global rocksdb_debug_ttl_ignore_pk=0;
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+
+DROP TABLE t1;
+
+# Test to make sure that TTL retains original timestamp during update
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ b int NOT NULL,
+ PRIMARY KEY (a),
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;';
+
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, 0);
+INSERT INTO t1 values (3, 0);
+INSERT INTO t1 values (5, 0);
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (7, 0);
+INSERT INTO t1 values (9, 0);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+UPDATE t1 SET a=a+1;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+
+# 1,3,5 should be dropped
+--sorted_result
+SELECT * FROM t1;
+DROP TABLE t1;
+
+# test behaviour on update with TTL column, TTL time can be updated here.
+CREATE TABLE t1 (
+ a INT,
+ b bigint(20) UNSIGNED NOT NULL,
+ PRIMARY KEY (a),
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;ttl_col=b;';
+
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+INSERT INTO t1 values (3, UNIX_TIMESTAMP());
+INSERT INTO t1 values (5, UNIX_TIMESTAMP());
+INSERT INTO t1 values (7, UNIX_TIMESTAMP());
+
+set global rocksdb_debug_ttl_rec_ts = 300;
+UPDATE t1 SET b=(UNIX_TIMESTAMP()+1) WHERE a < 4;
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+--sorted_result
+SELECT a FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+
+# 5 and 7 should be gone here
+--sorted_result
+SELECT a FROM t1 FORCE INDEX (kb);
+DROP TABLE t1;
+
+# Test rows expired stat variable and disable ttl variable
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ b int NOT NULL,
+ PRIMARY KEY (a),
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 1);
+INSERT INTO t1 values (2, 1);
+INSERT INTO t1 values (3, 1);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+set global rocksdb_enable_ttl=0;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_enable_ttl=1;
+set global rocksdb_compact_cf='default';
+
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+DROP TABLE t1;
+
+# Table with TTL won't increment rows expired when no records have been
+# compacted
+CREATE TABLE t1 (
+ a bigint(20) NOT NULL,
+ b int NOT NULL,
+ PRIMARY KEY (a),
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=100;';
+
+INSERT INTO t1 values (1, 1);
+INSERT INTO t1 values (2, 2);
+INSERT INTO t1 values (3, 3);
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+
+DROP TABLE t1;
+
+# Test update on TTL column in pk
+CREATE TABLE t1 (
+ a INT,
+ b bigint(20) UNSIGNED NOT NULL,
+ PRIMARY KEY (a, b),
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;ttl_col=b;';
+
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+INSERT INTO t1 values (3, UNIX_TIMESTAMP());
+INSERT INTO t1 values (5, UNIX_TIMESTAMP());
+INSERT INTO t1 values (7, UNIX_TIMESTAMP());
+
+set global rocksdb_debug_ttl_rec_ts = 300;
+UPDATE t1 SET b=(UNIX_TIMESTAMP()+1) WHERE a < 4;
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+--sorted_result
+SELECT a FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_ignore_pk=1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk=0;
+
+# 5 and 7 should be gone here
+--sorted_result
+SELECT a FROM t1 FORCE INDEX (kb);
+DROP TABLE t1;
+
+# test behaviour on update with TTL column, TTL time can be updated here.
+CREATE TABLE t1 (
+ a INT,
+ b bigint(20) UNSIGNED NOT NULL,
+ PRIMARY KEY (a, b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;ttl_col=b;';
+
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+INSERT INTO t1 values (3, UNIX_TIMESTAMP());
+INSERT INTO t1 values (5, UNIX_TIMESTAMP());
+INSERT INTO t1 values (7, UNIX_TIMESTAMP());
+
+set global rocksdb_debug_ttl_rec_ts = 300;
+UPDATE t1 SET b=(UNIX_TIMESTAMP()+1) WHERE a < 4;
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+--sorted_result
+SELECT a FROM t1;
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# 7 should be gone here
+--sorted_result
+SELECT a FROM t1;
+DROP TABLE t1;
+
+# Add index inplace
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64) NOT NULL,
+`c` varbinary(256) NOT NULL,
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`b`,`a`,`c`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', 'b', 'c', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('d', 'e', 'f', UNIX_TIMESTAMP(), 'g');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*);
+
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+
+# nothing filtered out
+SELECT COUNT(*);
+
+CREATE INDEX kb on t1 (b);
+
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+DROP TABLE t1;
+
+# Add index inplace, implicit TTL
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64) NOT NULL,
+`c` varbinary(256) NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`b`,`a`,`c`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', 'b', 'c', 'd');
+INSERT INTO t1 values ('d', 'e', 'f', 'g');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*);
+
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+
+# nothing filtered out
+SELECT COUNT(*);
+
+CREATE INDEX kb on t1 (b);
+
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+DROP TABLE t1;
+
+# Add index inplace, TTL column in PK
+CREATE TABLE t1 (
+`a` binary(8) NOT NULL,
+`b` varbinary(64) NOT NULL,
+`c` varbinary(256) NOT NULL,
+`ts` bigint(20) UNSIGNED NOT NULL,
+`value` mediumblob NOT NULL,
+PRIMARY KEY (`b`,`a`,`c`, `ts`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values ('a', 'b', 'c', UNIX_TIMESTAMP(), 'd');
+INSERT INTO t1 values ('d', 'e', 'f', UNIX_TIMESTAMP(), 'g');
+set global rocksdb_debug_ttl_rec_ts = 0;
+SELECT COUNT(*);
+
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+
+# nothing filtered out
+SELECT COUNT(*);
+
+CREATE INDEX kb on t1 (b);
+
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+
+# should have filtered the rows out since ttl is passed in compaction filter
+SELECT COUNT(*) FROM t1 FORCE INDEX (kb);
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering-master.opt
new file mode 100644
index 00000000..aefc2f5d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering-master.opt
@@ -0,0 +1 @@
+--rocksdb_default_cf_options=disable_auto_compactions=true
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering.test b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering.test
new file mode 100644
index 00000000..f6042cc5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering.test
@@ -0,0 +1,503 @@
+--source include/have_debug.inc
+--source include/have_rocksdb.inc
+
+# The purpose of read filtering for tables with TTL is to ensure that during a
+# transaction a key which has expired already but not removed by compaction
+# yet, is not returned to the user.
+#
+# Without this the user might be hit with problems such as disappearing rows
+# within a transaction, etc, because the compaction filter ignores snapshots
+# when filtering keys.
+
+# Basic read filtering test
+CREATE TABLE t1 (
+ a int PRIMARY KEY,
+ b int NOT NULL,
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 1);
+INSERT INTO t1 values (2, 2);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+set global rocksdb_force_flush_memtable_now=1;
+
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kb);
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+
+DROP TABLE t1;
+
+# Test that some rows are hidden but others aren't...
+CREATE TABLE t1 (
+ a int PRIMARY KEY,
+ b BIGINT UNSIGNED NOT NULL,
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=10;';
+
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 values (1, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 300;
+INSERT INTO t1 values (2, UNIX_TIMESTAMP());
+INSERT INTO t1 values (3, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+set global rocksdb_force_flush_memtable_now=1;
+
+--echo # 1 should be hidden
+--sorted_result
+SELECT a FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT a FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+
+--echo # none should be hidden yet, compaction runs but records aren't expired
+--sorted_result
+SELECT a FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT a FROM t1 FORCE INDEX (kb);
+
+--echo # all should be hidden now, even though compaction hasn't run again
+set global rocksdb_debug_ttl_read_filter_ts = -310;
+--sorted_result
+SELECT a FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT a FROM t1 FORCE INDEX (kb);
+set global rocksdb_debug_ttl_read_filter_ts = 0;
+
+DROP TABLE t1;
+
+# Test the filtering code explicitly.
+CREATE TABLE t1 (
+ a int PRIMARY KEY,
+ b int NOT NULL,
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 1);
+INSERT INTO t1 values (3, 3);
+INSERT INTO t1 values (5, 5);
+INSERT INTO t1 values (7, 7);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+--echo # should return nothing.
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kb);
+
+# disable filtering
+set global rocksdb_enable_ttl_read_filtering=0;
+
+--echo # should return everything
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kb);
+
+# enable filtering
+set global rocksdb_enable_ttl_read_filtering=1;
+
+--echo # should return nothing.
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kb);
+
+DROP TABLE t1;
+
+# Compact away the dropped data
+set global rocksdb_compact_cf= 'default';
+
+--echo # Read filtering index scan tests (None of these queries should return any results)
+CREATE TABLE t1 (
+ a int,
+ b int,
+ c int,
+ PRIMARY KEY (a,b,c),
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (0,0,0);
+INSERT INTO t1 values (0,0,1);
+INSERT INTO t1 values (0,1,0);
+INSERT INTO t1 values (0,1,1);
+INSERT INTO t1 values (1,1,2);
+INSERT INTO t1 values (1,2,1);
+INSERT INTO t1 values (1,2,2);
+INSERT INTO t1 values (1,2,3);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+
+set global rocksdb_force_flush_memtable_now=1;
+
+# HA_READ_KEY_EXACT, using full key
+SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE a=1 AND b=2 AND c=2;
+SELECT * FROM t1 FORCE INDEX (kb) WHERE a=1 AND b=2 AND c=2;
+
+# HA_READ_KEY_EXACT, not using full key
+SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE a = 1;
+SELECT * FROM t1 FORCE INDEX (kb) WHERE a = 1;
+
+# HA_READ_BEFORE_KEY, not using full key
+SELECT max(a) FROM t1 FORCE INDEX (PRIMARY) WHERE a < 3;
+SELECT max(a) FROM t1 FORCE INDEX (kb) WHERE a < 3;
+
+# HA_READ_BEFORE_KEY, using full key
+SELECT max(a) FROM t1 FORCE INDEX (PRIMARY) WHERE a < 2 AND b = 1 AND c < 3;
+SELECT max(a) FROM t1 FORCE INDEX (kb) WHERE a < 2 AND b = 1 AND c < 3;
+
+# HA_READ_KEY_OR_NEXT
+SELECT min(a) FROM t1 FORCE INDEX (PRIMARY) WHERE a >= 1;
+SELECT min(a) FROM t1 FORCE INDEX (kb) WHERE a >= 1;
+
+# HA_READ_AFTER_KEY, /* Find next rec. after key-record */
+SELECT min(a) FROM t1 FORCE INDEX (PRIMARY) WHERE a > 1;
+SELECT min(a) FROM t1 FORCE INDEX (kb) WHERE a > 1;
+
+# HA_READ_PREFIX_LAST, /* Last key with the same prefix */
+SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE a=1 and b in (1) order by c desc;
+SELECT * FROM t1 FORCE INDEX (kb) WHERE a=1 and b in (1) order by c desc;
+
+# HA_READ_PREFIX_LAST_OR_PREV, /* Last or prev key with the same prefix */
+SELECT max(a) FROM t1 FORCE INDEX (PRIMARY) WHERE a <=10;
+SELECT max(a) FROM t1 FORCE INDEX (kb) WHERE a <=10;
+
+# need to test read_range_first()
+# calls into read_range_next() and uses compare_keys() to see if its out of
+# range
+SELECT a FROM t1 FORCE INDEX (PRIMARY) WHERE a > 0 and a <= 2;
+SELECT a FROM t1 FORCE INDEX (kb) WHERE a > 0 and a <= 2;
+
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired';
+DROP TABLE t1;
+
+--echo # Attempt to update expired value, should filter out
+set global rocksdb_force_flush_memtable_now=1;
+CREATE TABLE t1 (
+ a int PRIMARY KEY
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1;
+
+--echo # No error is thrown here, under the hood index_next_with_direction is
+--echo # filtering out the record from being seen in the first place.
+UPDATE t1 set a = 1;
+DROP TABLE t1;
+
+--echo # Ensure no rows can disappear in the middle of long-running transactions
+--echo # Also ensure repeatable-read works as expected
+--source include/count_sessions.inc
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+CREATE TABLE t1 (
+ a int PRIMARY KEY,
+ b int NOT NULL,
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=5;';
+
+INSERT INTO t1 values (1, 1);
+
+connection con1;
+--echo # Creating Snapshot (start transaction)
+BEGIN;
+
+# We need the below snippet in case establishing con1 took an arbitrary
+# amount of time. See https://github.com/facebook/mysql-5.6/pull/617#discussion_r120525391.
+--disable_query_log
+--let $snapshot_size= `SELECT COUNT(*) FROM t1`
+--let $i= 0
+while ($snapshot_size != 1)
+{
+ if ($i == 1000)
+ {
+ --die Your testing host is too slow for reasonable TTL testing
+ }
+
+ $i++;
+ ROLLBACK;
+ INSERT INTO t1 values (1,1);
+ BEGIN;
+ --let $snapshot_size= `SELECT COUNT(*) FROM t1`
+}
+--enable_query_log
+
+--echo # Nothing filtered out here
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kb);
+
+--sleep 5
+
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kb); # <= shouldn't be filtered out here
+
+--echo # Switching to connection 2
+connection con2;
+--echo # compaction doesn't do anything since con1 snapshot is still open
+set global rocksdb_debug_ttl_ignore_pk = 1;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_debug_ttl_ignore_pk = 0;
+--echo # read filtered out, because on a different connection, on
+--echo # this connection the records have 'expired' already so they are filtered out
+--echo # even though they have not yet been removed by compaction
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kb);
+
+--echo # Switching to connection 1
+connection con1;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kb); # <= shouldn't be filtered out here
+
+UPDATE t1 set a = a + 1;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kb); # <= shouldn't be filtered out here
+
+COMMIT;
+
+--sorted_result # <= filtered out here because time has passed.
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kb);
+
+DROP TABLE t1;
+disconnect con1;
+disconnect con2;
+
+#transaction 1, create a snapshot and select * => returns nothing.
+#transaction 2, insert into table, flush
+#transaction 1, select * => returns nothing, but the snapshot should prevent the compaction code from removing the rows, no matter what the ttl duration is.
+#transaction 2, select * -> sees nothing, disable filter, select * -> sees everything, enable filter, select * -> sees nothing.
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+CREATE TABLE t1 (
+ a int PRIMARY KEY,
+ b int NOT NULL,
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;';
+
+--echo # On Connection 1
+connection con1;
+--echo # Creating Snapshot (start transaction)
+BEGIN;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kb);
+# Sleep 5 secs after creating snapshot, this ensures any records created after
+# this can't be removed by compaction until this snapshot is released.
+--sleep 5
+
+--echo # On Connection 2
+connection con2;
+set global rocksdb_debug_ttl_rec_ts = -2;
+INSERT INTO t1 values (1, 1);
+INSERT INTO t1 values (3, 3);
+INSERT INTO t1 values (5, 5);
+INSERT INTO t1 values (7, 7);
+set global rocksdb_debug_ttl_rec_ts = 0;
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+--echo # On Connection 1
+connection con1;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kb);
+
+--echo # On Connection 2
+connection con2;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kb);
+set global rocksdb_enable_ttl_read_filtering=0;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kb);
+set global rocksdb_enable_ttl_read_filtering=1;
+
+disconnect con2;
+disconnect con1;
+connection default;
+
+DROP TABLE t1;
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
+
+# Test that index_next_with_direction skips records properly
+CREATE TABLE t1 (
+ a int,
+ b int,
+ ts bigint(20) UNSIGNED NOT NULL,
+ PRIMARY KEY (a),
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1;ttl_col=ts;';
+
+set global rocksdb_debug_ttl_rec_ts = 100;
+INSERT INTO t1 VALUES (1, 1, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (2, 2, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (3, 3, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (4, 4, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (5, 5, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (6, 6, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (7, 7, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (8, 8, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (9, 9, UNIX_TIMESTAMP());
+INSERT INTO t1 VALUES (10, 10, UNIX_TIMESTAMP());
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+set global rocksdb_force_flush_memtable_now=1;
+--echo # None are expired
+SELECT a, b FROM t1 FORCE INDEX (kb);
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+UPDATE t1 SET ts=(UNIX_TIMESTAMP()+1) WHERE a IN (4, 7);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+--echo # 4 and 7 should be gone
+SELECT a, b FROM t1 FORCE INDEX (kb);
+
+DROP TABLE t1;
+
+# Test range scans with various conditionals
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ name VARCHAR(25) NOT NULL,
+ PRIMARY KEY (c1, c2),
+ KEY kc2 (c2)
+) ENGINE=ROCKSDB
+COMMENT='ttl_duration=1;';
+
+set global rocksdb_debug_ttl_rec_ts = -1200;
+INSERT INTO t1 values (1,1,'a');
+INSERT INTO t1 values (2,2,'b');
+set global rocksdb_debug_ttl_rec_ts = 1200;
+INSERT INTO t1 values (3,3,'c');
+INSERT INTO t1 values (4,4,'d');
+set global rocksdb_debug_ttl_rec_ts = -1200;
+INSERT INTO t1 values (5,5,'e');
+INSERT INTO t1 values (6,6,'f');
+set global rocksdb_debug_ttl_rec_ts = 1200;
+INSERT INTO t1 values (7,7,'g');
+INSERT INTO t1 values (8,8,'h');
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kc2);
+
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE c1 > 5;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kc2) WHERE c2 > 5;
+
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE 3 < c1 AND c1 < 6;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kc2) WHERE 3 < c2 AND c2 < 6;
+
+DROP TABLE t1;
+
+# Test range scans with varying expirations
+CREATE TABLE t1 (
+ a int,
+ b int,
+ PRIMARY KEY (a),
+ KEY kb (b)
+) ENGINE=rocksdb
+COMMENT='ttl_duration=1800;';
+
+set global rocksdb_debug_ttl_rec_ts = 0;
+INSERT INTO t1 values (1,1);
+INSERT INTO t1 values (2,2);
+INSERT INTO t1 values (7,7);
+INSERT INTO t1 values (10,10);
+INSERT INTO t1 values (11,11);
+INSERT INTO t1 values (12,12);
+set global rocksdb_debug_ttl_rec_ts = 450;
+INSERT INTO t1 values (3,3);
+INSERT INTO t1 values (4,4);
+INSERT INTO t1 values (8,8);
+INSERT INTO t1 values (16,16);
+INSERT INTO t1 values (17,17);
+INSERT INTO t1 values (18,18);
+set global rocksdb_debug_ttl_rec_ts = 900;
+INSERT INTO t1 values (5,5);
+INSERT INTO t1 values (6,6);
+INSERT INTO t1 values (9,9);
+INSERT INTO t1 values (13,13);
+INSERT INTO t1 values (14,14);
+INSERT INTO t1 values (15,15);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+--echo # Should see everything
+SELECT * FROM t1;
+
+--echo # Should have no records from the first group
+set global rocksdb_debug_ttl_read_filter_ts = -1800;
+SELECT * FROM t1;
+SELECT * FROM t1 FORCE INDEX (kb) WHERE a > 5 AND a < 15;
+
+--echo # Should only have records from the last group
+set global rocksdb_debug_ttl_read_filter_ts = -1800 - 450;
+SELECT * FROM t1;
+SELECT * FROM t1 FORCE INDEX (kb) WHERE a < 10;
+
+--echo # Should be empty
+set global rocksdb_debug_ttl_read_filter_ts = -1800 - 900;
+SELECT * FROM t1;
+
+set global rocksdb_debug_ttl_read_filter_ts = 0;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering_multiple_index.test b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering_multiple_index.test
new file mode 100644
index 00000000..4f9788ce
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering_multiple_index.test
@@ -0,0 +1,87 @@
+--source include/have_debug.inc
+--source include/have_rocksdb.inc
+
+# Multiple indexes, trigger compaction on sk and check consistency
+CREATE TABLE t1 (
+ a int NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ PRIMARY KEY (a),
+ KEY kb (b) COMMENT 'kb',
+ KEY kc (c) COMMENT 'kc'
+) ENGINE=ROCKSDB
+COMMENT='ttl_duration=1';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 1, 1);
+INSERT INTO t1 values (2, 2, 2);
+set global rocksdb_debug_ttl_rec_ts = 100;
+INSERT INTO t1 values (3, 3, 3);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='kb';
+
+# Results should be consistent
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+SELECT * FROM t1 FORCE INDEX (kb);
+SELECT * FROM t1 FORCE INDEX (kc);
+
+DROP TABLE t1;
+
+# Trigger compaction on pk and check consistency
+CREATE TABLE t1 (
+ a int NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ PRIMARY KEY (a),
+ KEY kb (b) COMMENT 'kb',
+ KEY kc (c) COMMENT 'kc'
+) ENGINE=ROCKSDB
+COMMENT='ttl_duration=1';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 1, 1);
+INSERT INTO t1 values (2, 2, 2);
+set global rocksdb_debug_ttl_rec_ts = 100;
+INSERT INTO t1 values (3, 3, 3);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# Results should be consistent
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+SELECT * FROM t1 FORCE INDEX (kb);
+SELECT * FROM t1 FORCE INDEX (kc);
+
+DROP TABLE t1;
+
+# Trigger compaction on pk and sk and check consistency
+CREATE TABLE t1 (
+ a int NOT NULL,
+ b int NOT NULL,
+ c int NOT NULL,
+ PRIMARY KEY (a),
+ KEY kb (b) COMMENT 'kb',
+ KEY kc (c) COMMENT 'kc'
+) ENGINE=ROCKSDB
+COMMENT='ttl_duration=1';
+
+set global rocksdb_debug_ttl_rec_ts = -100;
+INSERT INTO t1 values (1, 1, 1);
+INSERT INTO t1 values (2, 2, 2);
+set global rocksdb_debug_ttl_rec_ts = 100;
+INSERT INTO t1 values (3, 3, 3);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+set global rocksdb_compact_cf='kb';
+
+# Results should be consistent
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+SELECT * FROM t1 FORCE INDEX (kb);
+SELECT * FROM t1 FORCE INDEX (kc);
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_with_partitions-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_with_partitions-master.opt
new file mode 100644
index 00000000..10a88c30
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_with_partitions-master.opt
@@ -0,0 +1 @@
+--rocksdb_enable_ttl_read_filtering=0
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_with_partitions.test b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_with_partitions.test
new file mode 100644
index 00000000..c10c83f9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_with_partitions.test
@@ -0,0 +1,300 @@
+--source include/have_debug.inc
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+#
+# Create a table with multiple partitions, but in the comment don't specify
+# that per-partition based column families (CF) should be created. Expect that
+# default CF will be used and new one won't be created.
+#
+# In addition, specify TTL on one of the partitions. Insert a few things
+# inside all the partitions, verify after compaction that the rows inside the
+# partition with TTL has disappeared.
+#
+# Add secondary keys to all tables to test compatibility.
+#
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ PRIMARY KEY (`c1`),
+ KEY kc2 (`c2`)
+) ENGINE=ROCKSDB
+COMMENT="custom_p0_ttl_duration=1;"
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 4, 7),
+ PARTITION custom_p1 VALUES IN (2, 5, 8),
+ PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+
+set global rocksdb_debug_ttl_rec_ts = -3600;
+INSERT INTO t1 values (1, 1);
+INSERT INTO t1 values (2, 2);
+INSERT INTO t1 values (3, 3);
+INSERT INTO t1 values (4, 4);
+INSERT INTO t1 values (5, 5);
+INSERT INTO t1 values (6, 6);
+INSERT INTO t1 values (7, 7);
+INSERT INTO t1 values (8, 8);
+INSERT INTO t1 values (9, 9);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kc2);
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='default';
+
+# 1,4, and 7 should be gone
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kc2);
+DROP TABLE t1;
+
+#
+# Create a table with multiple partitions and request for separate CF to be
+# created per every partition. As a result we expect three different CF-s to be
+# created.
+#
+# In addition, specify TTL on some of the partitions. Insert a few things
+# inside all the partitions, verify after compaction that the rows inside the
+# partition with TTL has disappeared.
+#
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ name VARCHAR(25) NOT NULL,
+ PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=my_custom_cf;custom_p2_cfname=baz',
+ KEY kc2 (`c2`)
+) ENGINE=ROCKSDB
+COMMENT="custom_p0_ttl_duration=1;custom_p1_ttl_duration=7;"
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 4, 7),
+ PARTITION custom_p1 VALUES IN (2, 5, 8),
+ PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+
+set global rocksdb_debug_ttl_rec_ts = -1200;
+INSERT INTO t1 values (1,1,'a');
+INSERT INTO t1 values (4,4,'aaaa');
+INSERT INTO t1 values (7,7,'aaaaaaa');
+
+set global rocksdb_debug_ttl_rec_ts = 1200;
+INSERT INTO t1 values (2,2,'aa');
+INSERT INTO t1 values (3,3,'aaa');
+INSERT INTO t1 values (5,5,'aaaaa');
+INSERT INTO t1 values (6,6,'aaaaaa');
+INSERT INTO t1 values (8,8,'aaaaaaaa');
+INSERT INTO t1 values (9,9,'aaaaaaaaa');
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kc2);
+
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'my_custom_cf';
+set @@global.rocksdb_compact_cf = 'default';
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kc2);
+
+set global rocksdb_debug_ttl_snapshot_ts = 3600;
+set @@global.rocksdb_compact_cf = 'foo';
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kc2);
+
+# Now 2,5,8 should be removed (this verifies that TTL is only operating on the
+# particular CF.
+set @@global.rocksdb_compact_cf = 'my_custom_cf';
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kc2);
+
+DROP TABLE t1;
+
+#
+# Create a table with CF-s/TTL per partition and verify that ALTER TABLE + DROP
+# PRIMARY, ADD PRIMARY work for that scenario and data is persisted/filtered as
+# expected.
+#
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ name VARCHAR(25) NOT NULL,
+ event DATE,
+ PRIMARY KEY (`c1`, `c2`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz;',
+ KEY kc2 (c2)
+) ENGINE=ROCKSDB
+COMMENT="custom_p0_ttl_duration=9999;custom_p2_ttl_duration=5;"
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 2, 3),
+ PARTITION custom_p1 VALUES IN (4, 5, 6),
+ PARTITION custom_p2 VALUES IN (7, 8, 9)
+);
+
+INSERT INTO t1 VALUES (1, 1, "one", null);
+INSERT INTO t1 VALUES (2, 2, "two", null);
+INSERT INTO t1 VALUES (3, 3, "three", null);
+
+INSERT INTO t1 VALUES (4, 4, "four", null);
+INSERT INTO t1 VALUES (5, 5, "five", null);
+INSERT INTO t1 VALUES (6, 6, "six", null);
+
+INSERT INTO t1 VALUES (7, 7, "seven", null);
+INSERT INTO t1 VALUES (8, 8, "eight", null);
+INSERT INTO t1 VALUES (9, 9, "nine", null);
+
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kc2);
+
+# TTL should be reset after alter table
+set global rocksdb_debug_ttl_rec_ts = 600;
+ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(`c2`,`c1`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz;';
+set global rocksdb_debug_ttl_rec_ts = 0;
+SHOW CREATE TABLE t1;
+
+# ...so nothing should be gone here
+set global rocksdb_debug_ttl_snapshot_ts = 100;
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'baz';
+# Filter out expired secondary keys too
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kc2);
+
+set global rocksdb_debug_ttl_snapshot_ts = 1200;
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'baz';
+# Filter out expired secondary keys too
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kc2);
+
+DROP TABLE t1;
+
+#
+# Create a table with non-partitioned TTL duration, with partitioned TTL
+# columns
+#
+# In this case the same TTL duration will be applied across different TTL
+# columns in different partitions, except for in p2 where we override the ttl
+# duration.
+#
+CREATE TABLE t1 (
+ c1 BIGINT,
+ c2 BIGINT UNSIGNED NOT NULL,
+ name VARCHAR(25) NOT NULL,
+ event DATE,
+ PRIMARY KEY (`c1`) COMMENT 'custom_p0_cfname=foo;custom_p1_cfname=bar;custom_p2_cfname=baz;',
+ KEY kc2 (`c2`)
+) ENGINE=ROCKSDB
+COMMENT="ttl_duration=1;custom_p1_ttl_duration=100;custom_p1_ttl_col=c2;custom_p2_ttl_duration=5000;"
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 2, 3),
+ PARTITION custom_p1 VALUES IN (4, 5, 6),
+ PARTITION custom_p2 VALUES IN (7, 8, 9)
+);
+
+set global rocksdb_debug_ttl_rec_ts = -300;
+INSERT INTO t1 VALUES (1, UNIX_TIMESTAMP(), "one", null);
+INSERT INTO t1 VALUES (2, UNIX_TIMESTAMP(), "two", null);
+INSERT INTO t1 VALUES (3, UNIX_TIMESTAMP(), "three", null);
+set global rocksdb_debug_ttl_rec_ts = 0;
+
+INSERT INTO t1 VALUES (4, UNIX_TIMESTAMP(), "four", null);
+INSERT INTO t1 VALUES (5, UNIX_TIMESTAMP(), "five", null);
+INSERT INTO t1 VALUES (6, UNIX_TIMESTAMP(), "six", null);
+
+INSERT INTO t1 VALUES (7, UNIX_TIMESTAMP(), "seven", null);
+INSERT INTO t1 VALUES (8, UNIX_TIMESTAMP(), "eight", null);
+INSERT INTO t1 VALUES (9, UNIX_TIMESTAMP(), "nine", null);
+
+set global rocksdb_force_flush_memtable_now=1;
+set @@global.rocksdb_compact_cf = 'foo';
+set @@global.rocksdb_compact_cf = 'baz';
+set @@global.rocksdb_compact_cf = 'bar';
+# Filter out expired secondary keys too
+set @@global.rocksdb_compact_cf = 'default';
+
+# here we expect only 1,2,3 to be gone, ttl implicit.
+--sorted_result
+SELECT c1 FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT c1 FROM t1 FORCE INDEX (kc2);
+
+# here we expect only 4,5,6 to be gone, ttl based on column c2.
+set global rocksdb_debug_ttl_snapshot_ts = 600;
+set @@global.rocksdb_compact_cf = 'bar';
+# Filter out expired secondary keys too
+set @@global.rocksdb_compact_cf = 'default';
+set global rocksdb_debug_ttl_snapshot_ts = 0;
+--sorted_result
+SELECT c1 FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT c1 FROM t1 FORCE INDEX (kc2);
+
+# at this point only 7,8,9 should be left..
+DROP TABLE t1;
+
+#
+# Add index inplace
+#
+CREATE TABLE t1 (
+ c1 INT,
+ c2 INT,
+ PRIMARY KEY (`c1`) COMMENT 'custom_p0_cfname=foo;'
+) ENGINE=ROCKSDB
+COMMENT="custom_p0_ttl_duration=1;"
+PARTITION BY LIST(c1) (
+ PARTITION custom_p0 VALUES IN (1, 4, 7),
+ PARTITION custom_p1 VALUES IN (2, 5, 8),
+ PARTITION custom_p2 VALUES IN (3, 6, 9)
+);
+
+set global rocksdb_debug_ttl_rec_ts = -3600;
+INSERT INTO t1 values (1, 1);
+INSERT INTO t1 values (4, 4);
+INSERT INTO t1 values (7, 7);
+set global rocksdb_debug_ttl_rec_ts = 0;
+INSERT INTO t1 values (2, 2);
+INSERT INTO t1 values (3, 3);
+INSERT INTO t1 values (5, 5);
+INSERT INTO t1 values (6, 6);
+INSERT INTO t1 values (8, 8);
+INSERT INTO t1 values (9, 9);
+
+# Nothing filtered out
+--sorted_result
+SELECT * FROM t1;
+
+CREATE INDEX kc2 on t1 (c2);
+
+set global rocksdb_force_flush_memtable_now=1;
+set global rocksdb_compact_cf='foo';
+set global rocksdb_compact_cf='default';
+
+# 1,4, and 7 should be gone
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+--sorted_result
+SELECT * FROM t1 FORCE INDEX (kc2);
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_binary.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_binary.inc
new file mode 100644
index 00000000..8e2b0e85
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_binary.inc
@@ -0,0 +1,45 @@
+#
+# BINARY column types
+#
+
+# $extra_col_options is set by a calling test
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+eval CREATE TABLE t1 (
+ b BINARY $extra_col_opts,
+ b0 BINARY(0) $extra_col_opts,
+ b1 BINARY(1) $extra_col_opts,
+ b20 BINARY(20) $extra_col_opts,
+ b255 BINARY(255) $extra_col_opts,
+ pk BINARY PRIMARY KEY
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+# Valid values
+
+INSERT INTO t1 VALUES ('','','','','','');
+INSERT INTO t1 VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.','a');
+
+--sorted_result
+SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255), HEX(pk) FROM t1 ORDER BY pk;
+
+# Invalid values
+
+INSERT INTO t1 VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256),'b');
+--error ER_DUP_ENTRY
+INSERT INTO t1 SELECT b255, b255, b255, b255, CONCAT('a',b255,b255), 'c' FROM t1;
+
+--sorted_result
+SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255), HEX(pk) FROM t1 ORDER BY pk;
+
+--error ER_TOO_BIG_FIELDLENGTH
+eval ALTER TABLE t1 ADD COLUMN b257 BINARY(257) $extra_col_opts;
+
+SHOW COLUMNS IN t1;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_binary.test b/storage/rocksdb/mysql-test/rocksdb/t/type_binary.test
new file mode 100644
index 00000000..91749e36
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_binary.test
@@ -0,0 +1,8 @@
+--source include/have_rocksdb.inc
+
+#
+# BINARY column types
+#
+
+--source type_binary.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_binary_indexes-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/type_binary_indexes-master.opt
new file mode 100644
index 00000000..6ad42e58
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_binary_indexes-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000 --rocksdb_records_in_range=50
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_binary_indexes.test b/storage/rocksdb/mysql-test/rocksdb/t/type_binary_indexes.test
new file mode 100644
index 00000000..f4360ed6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_binary_indexes.test
@@ -0,0 +1,99 @@
+--source include/have_rocksdb.inc
+
+#
+# BINARY and VARBINARY columns with indexes
+#
+
+#######################################
+# TODO:
+# A part of the test is disabled
+# because unique keys are not supported
+#######################################
+
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (b BINARY,
+ b20 BINARY(20) PRIMARY KEY,
+ v16 VARBINARY(16),
+ v128 VARBINARY(128)
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (b,b20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+
+--replace_column 9 #
+EXPLAIN SELECT HEX(b20) FROM t1 ORDER BY b20;
+SELECT HEX(b20) FROM t1 ORDER BY b20;
+
+--replace_column 9 #
+EXPLAIN SELECT HEX(b20) FROM t1 IGNORE INDEX (PRIMARY) ORDER BY b20 DESC;
+SELECT HEX(b20) FROM t1 ORDER BY b20 DESC;
+
+DROP TABLE t1;
+
+--disable_parsing
+--error ER_GET_ERRMSG
+CREATE TABLE t1 (b BINARY,
+ b20 BINARY(20),
+ v16 VARBINARY(16),
+ v128 VARBINARY(128),
+ UNIQUE INDEX b_v (b,v128),
+ pk VARBINARY(10) PRIMARY KEY
+) ENGINE=rocksdb;
+
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (b,b20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+
+--replace_column 9 #
+EXPLAIN SELECT HEX(b), HEX(v128) FROM t1 WHERE b != 'a' AND v128 > 'varchar';
+--sorted_result
+SELECT HEX(b), HEX(v128) FROM t1 WHERE b != 'a' AND v128 > 'varchar';
+
+--replace_column 9 #
+EXPLAIN SELECT HEX(b), HEX(v128) FROM t1 USE INDEX (b_v) WHERE b != 'a' AND v128 > 'varchar';
+--sorted_result
+SELECT HEX(b), HEX(v128) FROM t1 USE INDEX (b_v) WHERE b != 'a' AND v128 > 'varchar';
+
+--replace_column 9 #
+EXPLAIN SELECT HEX(v128), COUNT(*) FROM t1 GROUP BY HEX(v128);
+--sorted_result
+SELECT HEX(v128), COUNT(*) FROM t1 GROUP BY HEX(v128);
+
+DROP TABLE t1;
+
+--enable_parsing
+
+CREATE TABLE t1 (b BINARY,
+ b20 BINARY(20),
+ v16 VARBINARY(16),
+ v128 VARBINARY(128),
+ pk VARBINARY(10) PRIMARY KEY,
+ INDEX (v16(10))
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (b,b20,v16,v128,pk) VALUES ('a','char1','varchar1a','varchar1b',1),('a','char2','varchar2a','varchar2b',2),('b','char3','varchar1a','varchar1b',3),('c','char4','varchar3a','varchar3b',4),('d','char5','varchar4a','varchar3b',5),('e','char6','varchar2a','varchar3b',6);
+INSERT INTO t1 (b,b20,v16,v128,pk) SELECT b,b20,v16,v128,pk+100 FROM t1;
+
+--replace_column 9 #
+EXPLAIN SELECT HEX(SUBSTRING(v16,0,3)) FROM t1 WHERE v16 LIKE 'varchar%';
+--sorted_result
+SELECT HEX(SUBSTRING(v16,7,3)) FROM t1 WHERE v16 LIKE 'varchar%';
+
+--replace_column 9 #
+EXPLAIN SELECT HEX(SUBSTRING(v16,0,3)) FROM t1 FORCE INDEX (v16) WHERE v16 LIKE 'varchar%';
+--sorted_result
+SELECT HEX(SUBSTRING(v16,7,3)) FROM t1 FORCE INDEX (v16) WHERE v16 LIKE 'varchar%';
+
+DROP TABLE t1;
+
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_bit.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_bit.inc
new file mode 100644
index 00000000..ba0c6537
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_bit.inc
@@ -0,0 +1,53 @@
+#
+# BIT column type
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Valid values
+
+eval CREATE TABLE t1 (
+ a BIT $extra_col_opts,
+ b BIT(20) $extra_col_opts,
+ c BIT(64) $extra_col_opts,
+ d BIT(1) $extra_col_opts,
+ PRIMARY KEY (c)
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+ALTER TABLE t1 DROP COLUMN d;
+eval ALTER TABLE t1 ADD COLUMN d BIT(0) $extra_col_opts;
+SHOW COLUMNS IN t1;
+
+INSERT INTO t1 (a,b,c,d) VALUES (0,POW(2,20)-1,b'1111111111111111111111111111111111111111111111111111111111111111',1);
+SELECT BIN(a), HEX(b), c+0 FROM t1 WHERE d>0;
+
+INSERT INTO t1 (a,b,c,d) VALUES (1,0,-2,0);
+--sorted_result
+SELECT a+0, b+0, c+0 FROM t1 WHERE d<100;
+
+INSERT INTO t1 (a,b,c,d) VALUES (b'1', 'f', 0xFF, 0x0);
+--sorted_result
+SELECT a+0, b+0, c+0 FROM t1 WHERE d IN (0, 2);
+
+DELETE FROM t1;
+
+# Out of range values
+# (should produce warnings)
+
+INSERT INTO t1 (a,b,c,d) VALUES (0x10,0,0,1);
+SELECT a+0,b+0,c+0,d+0 FROM t1;
+
+INSERT INTO t1 (a,b,c,d) VALUES (0x01,0,0x10000000000000000,0);
+--sorted_result
+SELECT a+0,b+0,c+0,d+0 FROM t1;
+
+DROP TABLE t1;
+
+--error ER_TOO_BIG_DISPLAYWIDTH
+eval CREATE TABLE t1 (pk INT PRIMARY KEY, a BIT(65) $extra_col_opts) ENGINE=rocksdb;
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_bit.test b/storage/rocksdb/mysql-test/rocksdb/t/type_bit.test
new file mode 100644
index 00000000..8d57cabf
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_bit.test
@@ -0,0 +1,8 @@
+--source include/have_rocksdb.inc
+
+#
+# BIT column type
+#
+
+--source type_bit.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_bit_indexes-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/type_bit_indexes-master.opt
new file mode 100644
index 00000000..ba9364e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_bit_indexes-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_bit_indexes.test b/storage/rocksdb/mysql-test/rocksdb/t/type_bit_indexes.test
new file mode 100644
index 00000000..e4f4bb81
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_bit_indexes.test
@@ -0,0 +1,113 @@
+--source include/have_rocksdb.inc
+
+#
+# BIT columns with indexes
+#
+
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (
+ a BIT,
+ b BIT(20) PRIMARY KEY,
+ c BIT(32),
+ d BIT(64)
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+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);
+
+--replace_column 9 #
+EXPLAIN SELECT b+0 FROM t1 ORDER BY b;
+SELECT b+0 FROM t1 ORDER BY b;
+
+DROP TABLE t1;
+
+--echo # TODO: Unique indexes are not enforced
+--disable_parsing
+--error ER_GET_ERRMSG
+CREATE TABLE t1 (
+ a BIT,
+ b BIT(20),
+ c BIT(32),
+ d BIT(64),
+ pk BIT(10) PRIMARY KEY,
+UNIQUE INDEX b_c (b,c)
+) ENGINE=rocksdb;
+
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (a,b,c,d,pk) VALUES
+(0,0xFFFFF,0,1,1),(0,256,0xAAA,0x12345,2),(1,16,0,0xFFFFFFF,3),(0,11,12,13,4),
+(1,100,101,102,5),(0,12,13,14,6),(1,13,14,15,7),(0,101,201,202,8),(1,1000,1001,1002,9),
+(1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF,10);
+
+--replace_column 9 #
+EXPLAIN SELECT HEX(b+c) FROM t1 WHERE c > 1 OR HEX(b) < 0xFFFFFF;
+--sorted_result
+SELECT HEX(b+c) FROM t1 WHERE c > 1 OR HEX(b) < 0xFFFFFF;
+
+DROP TABLE t1;
+
+--enable_parsing
+
+CREATE TABLE t1 (
+ a BIT,
+ b BIT(20),
+ c BIT(32),
+ d BIT(64),
+ pk BIT(10) PRIMARY KEY,
+ INDEX(a)
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (a,b,c,d,pk) VALUES
+(0,0xFFFFF,0,1,1),(0,256,0xAAA,0x12345,2),(1,16,0,0xFFFFFFF,3),(0,11,12,13,4),
+(1,100,101,102,5),(0,12,13,14,6),(1,13,14,15,7),(0,101,201,202,8),(1,1000,1001,1002,9),
+(1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF,10);
+
+--replace_column 9 #
+EXPLAIN SELECT DISTINCT a+0 FROM t1 ORDER BY a;
+SELECT DISTINCT a+0 FROM t1 ORDER BY a;
+
+DROP TABLE t1;
+
+--disable_parsing
+--error ER_GET_ERRMSG
+CREATE TABLE t1 (
+ a BIT,
+ b BIT(20),
+ c BIT(32),
+ d BIT(64),
+ pk BIT(10) PRIMARY KEY,
+ UNIQUE INDEX (d)
+) ENGINE=rocksdb;
+
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (a,b,c,d,pk) VALUES
+(0,0xFFFFF,0,1,1),(0,256,0xAAA,0x12345,2),(1,16,0,0xFFFFFFF,3),(0,11,12,13,4),
+(1,100,101,102,5),(0,12,13,14,6),(1,13,14,15,7),(0,101,201,202,8),(1,1000,1001,1002,9),
+(1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF,10);
+
+--replace_column 9 #
+EXPLAIN SELECT d FROM t1 WHERE d BETWEEN 1 AND 10000;
+--sorted_result
+SELECT d+0 FROM t1 WHERE d BETWEEN 1 AND 10000;
+
+DROP TABLE t1;
+
+--enable_parsing
+
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_blob.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_blob.inc
new file mode 100644
index 00000000..723b3ee5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_blob.inc
@@ -0,0 +1,49 @@
+#
+# BLOB column types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+eval CREATE TABLE t1 (
+ pk INT AUTO_INCREMENT PRIMARY KEY,
+ b BLOB $extra_col_opts,
+ b0 BLOB(0) $extra_col_opts,
+ b1 BLOB(1) $extra_col_opts,
+ b300 BLOB(300) $extra_col_opts,
+ bm BLOB(65535) $extra_col_opts,
+ b70k BLOB(70000) $extra_col_opts,
+ b17m BLOB(17000000) $extra_col_opts,
+ t TINYBLOB $extra_col_opts,
+ m MEDIUMBLOB $extra_col_opts,
+ l LONGBLOB $extra_col_opts
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+# Valid values
+# (cannot get MAX for all columns due to max_allowed_packet limitations)
+
+INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+('','','','','','','','','',''),
+('a','b','c','d','e','f','g','h','i','j'),
+('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), HEX(REPEAT('g',1048576)), REPEAT('h',255), REPEAT('i',1048576), HEX(REPEAT('j',1048576)) );
+
+--sorted_result
+SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+
+# Invalid values (produce warnings, except for mediumblob and longblob columns for which the values are within limits)
+
+INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+
+--sorted_result
+SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+
+--error ER_TOO_BIG_DISPLAYWIDTH
+ALTER TABLE t1 ADD COLUMN bbb BLOB(4294967296);
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_blob.test b/storage/rocksdb/mysql-test/rocksdb/t/type_blob.test
new file mode 100644
index 00000000..54859707
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_blob.test
@@ -0,0 +1,8 @@
+--source include/have_rocksdb.inc
+
+#
+# BLOB column types
+#
+
+--source type_blob.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_blob_indexes-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/type_blob_indexes-master.opt
new file mode 100644
index 00000000..6ad42e58
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_blob_indexes-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000 --rocksdb_records_in_range=50
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_blob_indexes.test b/storage/rocksdb/mysql-test/rocksdb/t/type_blob_indexes.test
new file mode 100644
index 00000000..24c70e8e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_blob_indexes.test
@@ -0,0 +1,176 @@
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+
+#
+# BLOB columns with indexes
+#
+
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (
+ b BLOB,
+ t TINYBLOB,
+ m MEDIUMBLOB,
+ l LONGBLOB,
+ PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+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));
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+EXPLAIN SELECT SUBSTRING(b,16) AS f FROM t1 WHERE b IN ('test1','test2') ORDER BY f;
+SELECT SUBSTRING(b,16) AS f FROM t1 WHERE b IN ('test1','test2') ORDER BY f;
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+EXPLAIN SELECT SUBSTRING(b,16) AS f FROM t1 USE INDEX () WHERE b IN ('test1','test2') ORDER BY f;
+SELECT SUBSTRING(b,16) AS f FROM t1 USE INDEX () WHERE b IN ('test1','test2') ORDER BY f;
+
+DROP TABLE t1;
+
+
+CREATE TABLE t1 (
+ b BLOB,
+ t TINYBLOB,
+ m MEDIUMBLOB,
+ l LONGBLOB,
+ pk INT AUTO_INCREMENT PRIMARY KEY,
+ UNIQUE INDEX l_t (l(256),t(64))
+) ENGINE=rocksdb;
+
+--replace_column 6 # 7 # 10 # 11 #
+SHOW INDEX IN t1;
+
+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));
+
+# Here we are getting possible key l_t, but not the final key
+--replace_column 9 #
+EXPLAIN SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC;
+SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC;
+
+--replace_column 9 #
+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;
+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;
+
+DROP TABLE t1;
+
+
+CREATE TABLE t1 (
+ b BLOB,
+ t TINYBLOB,
+ m MEDIUMBLOB,
+ l LONGBLOB,
+ pk INT AUTO_INCREMENT PRIMARY KEY,
+ INDEX (m(128))
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+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));
+
+--replace_column 9 #
+EXPLAIN SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+
+--replace_column 9 #
+EXPLAIN SELECT SUBSTRING(m,128) AS f FROM t1 IGNORE INDEX FOR ORDER BY (m) WHERE m = 'test1' ORDER BY f DESC;
+SELECT SUBSTRING(m,128) AS f FROM t1 IGNORE INDEX FOR ORDER BY (m) WHERE m = 'test1' ORDER BY f DESC;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ b BLOB,
+ PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+
+SELECT b FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ b TINYBLOB,
+ PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+
+SELECT b FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ b MEDIUMBLOB,
+ PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+
+SELECT b FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ b LONGBLOB,
+ PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+
+SELECT b FROM t1;
+
+DROP TABLE t1;
+
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_bool.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_bool.inc
new file mode 100644
index 00000000..cddc0822
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_bool.inc
@@ -0,0 +1,64 @@
+#
+# BOOLEAN column type
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+eval CREATE TABLE t1 (
+ pk INT AUTO_INCREMENT PRIMARY KEY,
+ b1 BOOL $extra_col_opts,
+ b2 BOOLEAN $extra_col_opts
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+# Valid values
+
+INSERT INTO t1 (b1,b2) VALUES (1,TRUE);
+SELECT b1,b2 FROM t1;
+
+INSERT INTO t1 (b1,b2) VALUES (FALSE,0);
+--sorted_result
+SELECT b1,b2 FROM t1;
+
+INSERT INTO t1 (b1,b2) VALUES (2,3);
+--sorted_result
+SELECT b1,b2 FROM t1;
+
+INSERT INTO t1 (b1,b2) VALUES (-1,-2);
+--sorted_result
+SELECT b1,b2 FROM t1;
+
+--sorted_result
+SELECT IF(b1,'true','false') AS a, IF(b2,'true','false') AS b FROM t1;
+
+--sorted_result
+SELECT b1,b2 FROM t1 WHERE b1 = TRUE;
+
+--sorted_result
+SELECT b1,b2 FROM t1 WHERE b2 = FALSE;
+
+# Invalid values
+
+INSERT INTO t1 (b1,b2) VALUES ('a','b');
+--sorted_result
+SELECT b1,b2 FROM t1;
+
+INSERT INTO t1 (b1,b2) VALUES (128,-129);
+--sorted_result
+SELECT b1,b2 FROM t1;
+
+# This is why we don't have zerofill and unsigned tests
+# for boolean columns:
+--error ER_PARSE_ERROR
+eval ALTER TABLE t1 ADD COLUMN b3 BOOLEAN UNSIGNED $extra_col_opts;
+
+--error ER_PARSE_ERROR
+eval ALTER TABLE ADD COLUMN b3 BOOL ZEROFILL $extra_col_opts;
+
+DROP TABLE t1;
+
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_bool.test b/storage/rocksdb/mysql-test/rocksdb/t/type_bool.test
new file mode 100644
index 00000000..d5a3b9be
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_bool.test
@@ -0,0 +1,8 @@
+--source include/have_rocksdb.inc
+
+#
+# BOOLEAN column type
+#
+
+--source type_bool.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_char.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_char.inc
new file mode 100644
index 00000000..d770dc60
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_char.inc
@@ -0,0 +1,45 @@
+#
+# CHAR column types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+eval CREATE TABLE t1 (
+ c CHAR $extra_col_opts,
+ c0 CHAR(0) $extra_col_opts,
+ c1 CHAR(1) $extra_col_opts,
+ c20 CHAR(20) $extra_col_opts,
+ c255 CHAR(255) $extra_col_opts,
+ PRIMARY KEY (c255)
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+# Valid values
+
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('','','','','');
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.');
+
+--sorted_result
+SELECT c,c0,c1,c20,c255 FROM t1;
+
+# Invalid values
+
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
+INSERT INTO t1 (c,c0,c1,c20,c255) SELECT c255, c255, c255, c255, CONCAT('a',c255,c1) FROM t1;
+
+--sorted_result
+SELECT c,c0,c1,c20,c255 FROM t1;
+
+--sorted_result
+SELECT DISTINCT c20, REPEAT('a',LENGTH(c20)), COUNT(*) FROM t1 GROUP BY c1, c20;
+
+--error ER_TOO_BIG_FIELDLENGTH
+eval ALTER TABLE t1 ADD COLUMN c257 CHAR(257) $extra_col_opts;
+
+DROP TABLE t1;
+
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_char.test b/storage/rocksdb/mysql-test/rocksdb/t/type_char.test
new file mode 100644
index 00000000..347f83ca
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_char.test
@@ -0,0 +1,19 @@
+--source include/have_rocksdb.inc
+
+#
+# CHAR column types
+#
+
+--source type_char.inc
+
+# Issue #226
+CREATE TABLE t1(c1 CHAR(0) NOT NULL);
+INSERT INTO t1 VALUES('a');
+SELECT * FROM t1;
+DROP TABLE t1;
+
+# Issue #259
+CREATE TABLE t1(a char(10) character set utf8 collate utf8_bin primary key);
+INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');
+(SELECT * FROM t1 LIMIT 1) UNION (SELECT * FROM t1);
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes-master.opt
new file mode 100644
index 00000000..ba9364e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes.test b/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes.test
new file mode 100644
index 00000000..6ee2f03e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes.test
@@ -0,0 +1,107 @@
+--source include/have_rocksdb.inc
+
+#
+# CHAR and VARCHAR columns with indexes
+#
+
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (
+ c CHAR,
+ c20 CHAR(20) PRIMARY KEY,
+ v16 VARCHAR(16),
+ v128 VARCHAR(128)
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (c,c20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+
+--replace_column 9 #
+EXPLAIN SELECT c20 FROM t1 ORDER BY c20;
+SELECT c20 FROM t1 ORDER BY c20;
+
+--replace_column 9 #
+EXPLAIN SELECT c20 FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY c20;
+SELECT c20 FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY c20;
+
+DROP TABLE t1;
+
+--disable_parsing
+--error ER_GET_ERRMSG
+CREATE TABLE t1 (
+ c CHAR,
+ c20 CHAR(20),
+ v16 VARCHAR(16),
+ v128 VARCHAR(128),
+ pk CHAR(64) PRIMARY KEY,
+ UNIQUE INDEX c_v (c,v128)
+) ENGINE=rocksdb;
+
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (c,c20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+
+--replace_column 9 #
+EXPLAIN SELECT c, v128 FROM t1 WHERE c != 'a' AND v128 > 'varchar';
+--sorted_result
+SELECT c, v128 FROM t1 WHERE c != 'a' AND v128 > 'varchar';
+
+--replace_column 9 #
+EXPLAIN SELECT v128, COUNT(*) FROM t1 GROUP BY v128;
+--sorted_result
+SELECT v128, COUNT(*) FROM t1 GROUP BY v128;
+
+--replace_column 9 #
+EXPLAIN SELECT v128, COUNT(*) FROM t1 USE INDEX FOR GROUP BY (c_v) GROUP BY v128;
+--sorted_result
+SELECT v128, COUNT(*) FROM t1 USE INDEX FOR GROUP BY (c_v) GROUP BY v128;
+
+SET SESSION optimizer_switch = 'engine_condition_pushdown=on';
+--replace_column 9 #
+EXPLAIN SELECT c,c20,v16,v128 FROM t1 WHERE c > 'a';
+--sorted_result
+SELECT c,c20,v16,v128 FROM t1 WHERE c > 'a';
+SET SESSION optimizer_switch = @@global.optimizer_switch;
+
+DROP TABLE t1;
+
+--enable_parsing
+
+CREATE TABLE t1 (
+ c CHAR,
+ c20 CHAR(20),
+ v16 VARCHAR(16),
+ v128 VARCHAR(128),
+ pk VARCHAR(64) PRIMARY KEY,
+ INDEX (v16)
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (c,c20,v16,v128,pk) VALUES ('a','char1','varchar1a','varchar1b','1'),('a','char2','varchar2a','varchar2b','2'),('b','char3','varchar1a','varchar1b','3'),('c','char4','varchar3a','varchar3b','4');
+
+--replace_column 9 #
+EXPLAIN SELECT SUBSTRING(v16,0,3) FROM t1 WHERE v16 LIKE 'varchar%';
+--sorted_result
+SELECT SUBSTRING(v16,7,3) FROM t1 WHERE v16 LIKE 'varchar%';
+
+--replace_column 9 #
+EXPLAIN SELECT SUBSTRING(v16,0,3) FROM t1 IGNORE INDEX (v16) WHERE v16 LIKE 'varchar%';
+--sorted_result
+SELECT SUBSTRING(v16,7,3) FROM t1 IGNORE INDEX (v16) WHERE v16 LIKE 'varchar%';
+
+--replace_column 9 #
+EXPLAIN SELECT c,c20,v16,v128 FROM t1 WHERE v16 = 'varchar1a' OR v16 = 'varchar3a' ORDER BY v16;
+--sorted_result
+SELECT c,c20,v16,v128 FROM t1 WHERE v16 = 'varchar1a' OR v16 = 'varchar3a' ORDER BY v16;
+
+DROP TABLE t1;
+
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation-master.opt
new file mode 100644
index 00000000..ba9364e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation.test b/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation.test
new file mode 100644
index 00000000..d231236b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation.test
@@ -0,0 +1,126 @@
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+
+# Test if unknown collation works.
+set session debug_dbug= "+d,myrocks_enable_unknown_collation_index_only_scans";
+create table t (id int not null auto_increment primary key,
+ c varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci,
+ key sk (c));
+insert into t (c) values ('☀'), ('ß');
+--replace_column 9 #
+explain select c from t;
+select c from t;
+drop table t;
+set session debug_dbug= "-d,myrocks_enable_unknown_collation_index_only_scans";
+
+# Testing if all characters in latin1 charset get restored correctly. This is
+# done by comparing results from a PK scan.
+create table t (id int not null auto_increment,
+ c1 varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci,
+ c2 char(1) CHARACTER SET latin1 COLLATE latin1_general_ci,
+ primary key (id),
+ key sk1 (c1),
+ key sk2 (c2));
+
+let $i = 0;
+
+--disable_query_log
+while ($i < 256)
+{
+ --eval insert into t (c1, c2) values (CHAR('$i'), CHAR('$i'))
+ inc $i;
+}
+--enable_query_log
+
+--replace_column 9 #
+explain select hex(c1) from t order by c1;
+--replace_column 9 #
+explain select hex(c1) from t IGNORE INDEX (sk1) order by c1;
+
+--replace_column 9 #
+explain select hex(c2) from t order by c2;
+--replace_column 9 #
+explain select hex(c2) from t IGNORE INDEX (sk1) order by c2;
+
+--let $file1=$MYSQLTEST_VARDIR/tmp/filesort_order
+--let $file2=$MYSQLTEST_VARDIR/tmp/sk_order
+--disable_query_log
+--eval select hex(weight_string(c1)) INTO OUTFILE '$file1' from t order by c1
+--eval select hex(weight_string(c1)) INTO OUTFILE '$file2' from t IGNORE INDEX (sk1) order by c1
+--enable_query_log
+
+--diff_files $file1 $file2
+--remove_file $file1
+--remove_file $file2
+
+--disable_query_log
+--eval select hex(weight_string(c2)) INTO OUTFILE '$file1' from t order by c2
+--eval select hex(weight_string(c2)) INTO OUTFILE '$file2' from t IGNORE INDEX (sk1) order by c2
+--enable_query_log
+
+--diff_files $file1 $file2
+--remove_file $file1
+--remove_file $file2
+
+truncate t;
+
+# Test handling of spaces at the end of fields.
+insert into t (c1, c2) values ('Asdf ', 'Asdf ');
+select char_length(c1), char_length(c2), c1, c2 from t;
+
+drop table t;
+
+create table t (id int not null auto_increment,
+ c2 char(255) CHARACTER SET latin1 COLLATE latin1_general_ci,
+ primary key (id),
+ unique key sk2 (c2));
+
+insert into t (c2) values ('Asdf');
+--error ER_DUP_ENTRY
+insert into t (c2) values ('asdf ');
+
+drop table t;
+
+create table t (id int not null auto_increment,
+ c1 varchar(256) CHARACTER SET latin1 COLLATE latin1_swedish_ci,
+ primary key (id),
+ unique key sk1 (c1));
+
+insert into t (c1) values ('Asdf');
+--error ER_DUP_ENTRY
+insert into t (c1) values ('asdf ');
+--error ER_DUP_ENTRY
+insert into t (c1) values ('asdf');
+
+drop table t;
+
+create table t (id int not null auto_increment,
+ c1 varchar(256) CHARACTER SET latin1 COLLATE latin1_swedish_ci,
+ primary key (id),
+ unique key sk1 (c1(1)));
+
+insert into t (c1) values ('Asdf');
+insert into t (c1) values ('bbbb ');
+--error ER_DUP_ENTRY
+insert into t (c1) values ('a ');
+
+--replace_column 9 #
+explain select c1 from t;
+select c1 from t;
+
+drop table t;
+
+# Test varchar keyparts with key prefix
+set session rocksdb_verify_row_debug_checksums = on;
+create table t (id int primary key, email varchar(100), KEY email_i (email(30))) engine=rocksdb default charset=latin1;
+insert into t values (1, ' a');
+--replace_column 9 #
+explain select 'email_i' as index_name, count(*) AS count from t force index(email_i);
+select 'email_i' as index_name, count(*) AS count from t force index(email_i);
+drop table t;
+
+# Test varchar with length greater than 255
+create table t (id int primary key, email varchar(767), KEY email_i (email)) engine=rocksdb default charset=latin1;
+insert into t values (1, REPEAT('a', 700));
+select 'email_i' as index_name, count(*) AS count from t force index(email_i);
+drop table t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_date_time.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_date_time.inc
new file mode 100644
index 00000000..18ed7436
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_date_time.inc
@@ -0,0 +1,47 @@
+#
+# Date and time column types
+# (DATE, DATETIME, TIMESTAMP, TIME, YEAR)
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+set @save_time_zone=@@time_zone;
+set time_zone='UTC';
+eval CREATE TABLE t1 (
+ d DATE $extra_col_opts,
+ dt DATETIME $extra_col_opts,
+ ts TIMESTAMP $extra_col_opts,
+ t TIME $extra_col_opts,
+ y YEAR $extra_col_opts,
+ y4 YEAR(4) $extra_col_opts,
+ y2 YEAR(2) $extra_col_opts,
+ pk DATETIME PRIMARY KEY
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+SET @tm = '2012-04-09 05:27:00';
+
+# Valid values
+# '1970-01-01 00:00:01'
+INSERT INTO t1 (d,dt,ts,t,y,y4,y2,pk) VALUES
+('1000-01-01', '1000-01-01 00:00:00', FROM_UNIXTIME(1), '-838:59:59', '1901', '1901', '00','2012-12-12 12:12:12'),
+('9999-12-31', '9999-12-31 23:59:59', FROM_UNIXTIME(2147483647), '838:59:59', '2155', '2155', '99','2012-12-12 12:12:13'),
+('0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '00:00:00', '0', '0', '0','2012-12-12 12:12:14'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),YEAR(@tm),YEAR(@tm),'2012-12-12 12:12:15');
+
+--sorted_result
+SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+
+# Invalid values
+
+INSERT INTO t1 (d,dt,ts,t,y,y4,y2,pk) VALUES
+('999-13-32', '999-11-31 00:00:00', '0', '-839:00:00', '1900', '1900', '-1','2012-12-12 12:12:16');
+
+SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+set time_zone=@save_time_zone;
+
+DROP TABLE t1;
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_date_time.test b/storage/rocksdb/mysql-test/rocksdb/t/type_date_time.test
new file mode 100644
index 00000000..af4e006c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_date_time.test
@@ -0,0 +1,9 @@
+--source include/have_rocksdb.inc
+
+#
+# Date and time column types
+# (DATE, DATETIME, TIMESTAMP, TIME, YEAR)
+#
+
+--source type_date_time.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_date_time_indexes-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/type_date_time_indexes-master.opt
new file mode 100644
index 00000000..ba9364e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_date_time_indexes-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_date_time_indexes.test b/storage/rocksdb/mysql-test/rocksdb/t/type_date_time_indexes.test
new file mode 100644
index 00000000..06cf86b7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_date_time_indexes.test
@@ -0,0 +1,157 @@
+--source include/have_rocksdb.inc
+
+#
+# Date and time columns with indexes
+# (DATE, DATETIME, TIMESTAMP, TIME, YEAR)
+#
+
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+
+CREATE TABLE t1 (
+ d DATE,
+ dt DATETIME PRIMARY KEY,
+ ts TIMESTAMP,
+ t TIME,
+ y YEAR
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+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));
+
+--replace_column 9 #
+EXPLAIN SELECT dt FROM t1 ORDER BY dt LIMIT 3;
+SELECT dt FROM t1 ORDER BY dt LIMIT 3;
+
+--replace_column 9 #
+EXPLAIN SELECT dt FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY dt LIMIT 3;
+SELECT dt FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY dt LIMIT 3;
+
+--error ER_DUP_ENTRY
+INSERT INTO t1 (d,dt,ts,t,y) VALUES
+('2012-01-11', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000');
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ d DATE,
+ dt DATETIME,
+ ts TIMESTAMP,
+ t TIME,
+ y YEAR,
+ pk TIME PRIMARY KEY,
+ INDEX (ts)
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+SET @tm = '2012-04-09 05:27:00';
+
+INSERT INTO t1 (d,dt,ts,t,y,pk) VALUES
+('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000','12:00:00'),
+('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001','12:01:00'),
+('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999','12:02:00'),
+('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998','12:03:00'),
+('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994','12:04:00'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),'12:05:00');
+
+--replace_column 9 #
+EXPLAIN SELECT ts FROM t1 WHERE ts > NOW();
+--sorted_result
+SELECT ts FROM t1 WHERE ts > NOW();
+
+--replace_column 9 #
+EXPLAIN SELECT ts FROM t1 USE INDEX () WHERE ts > NOW();
+--sorted_result
+SELECT ts FROM t1 USE INDEX () WHERE ts > NOW();
+
+DROP TABLE t1;
+
+--disable_parsing
+--error ER_GET_ERRMSG
+CREATE TABLE t1 (
+ d DATE,
+ dt DATETIME,
+ ts TIMESTAMP,
+ t TIME,
+ y YEAR,
+ pk YEAR PRIMARY KEY,
+ UNIQUE INDEX d_t (d,t)
+) ENGINE=rocksdb;
+
+
+SHOW INDEX IN t1;
+SET @tm = '2012-04-09 05:27:00';
+
+INSERT INTO t1 (d,dt,ts,t,y,pk) VALUES
+('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000','1990'),
+('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001','1991'),
+('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999','1992'),
+('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998','1993'),
+('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994','1994'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),'1995');
+
+--replace_column 9 #
+EXPLAIN SELECT d, t FROM t1 WHERE CONCAT(d,' ',t) != CURRENT_DATE();
+--sorted_result
+SELECT d, t FROM t1 WHERE CONCAT(d,' ',t) != CURRENT_DATE();
+
+--replace_column 9 #
+EXPLAIN SELECT d, t FROM t1 IGNORE INDEX (d_t) WHERE CONCAT(d,' ',t) != CURRENT_DATE();
+--sorted_result
+SELECT d, t FROM t1 IGNORE INDEX (d_t) WHERE CONCAT(d,' ',t) != CURRENT_DATE();
+
+--error ER_DUP_ENTRY
+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');
+
+DROP TABLE t1;
+
+--enable_parsing
+
+CREATE TABLE t1 (
+ d DATE,
+ dt DATETIME,
+ ts TIMESTAMP,
+ t TIME,
+ y YEAR,
+ pk TIME PRIMARY KEY,
+ INDEX (y,t)
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+SET @tm = '2012-04-09 05:27:00';
+
+INSERT INTO t1 (d,dt,ts,t,y,pk) VALUES
+('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000','18:18:18'),
+('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001','19:18:18'),
+('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999','20:18:18'),
+('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998','21:18:18'),
+('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994','22:18:18'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),'23:18:18');
+
+--replace_column 9 #
+EXPLAIN SELECT y, COUNT(*) FROM t1 GROUP BY y;
+--sorted_result
+SELECT y, COUNT(*) FROM t1 GROUP BY y;
+
+--replace_column 9 #
+EXPLAIN SELECT y, COUNT(*) FROM t1 USE INDEX FOR GROUP BY () GROUP BY y;
+--sorted_result
+SELECT y, COUNT(*) FROM t1 USE INDEX FOR GROUP BY () GROUP BY y;
+
+DROP TABLE t1;
+
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_decimal-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/type_decimal-master.opt
new file mode 100644
index 00000000..33e72265
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_decimal-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=10
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_decimal.test b/storage/rocksdb/mysql-test/rocksdb/t/type_decimal.test
new file mode 100644
index 00000000..ee325b34
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_decimal.test
@@ -0,0 +1,88 @@
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+
+--echo #
+--echo # Check that DECIMAL datatype supports 'index-only' scans and is decoded correctly.
+--echo # (Decoding happens from the mem-comparable image in the index, regardless
+--echo # of whether the value part has original value or not)
+--echo #
+
+create table t1 (
+ pk int not null primary key,
+ col1 decimal (2,1) signed,
+ col2 decimal (2,1) unsigned,
+ filler varchar(100),
+ key key1(col1, col2)
+)engine=rocksdb;
+insert into t1 values
+(1,-9.1, 0.7, 'filler'),
+(2,-8.2, 1.6, 'filler'),
+(3, 0.3, 2.5, 'filler'),
+(4, 1.4, 3.4, 'filler'),
+(5, 2.5, 4.3, 'filler'),
+(6, 3.3, 5.3, 'filler');
+insert into t1 select pk+100, 9.0, 9.0, 'extra-data' from t1;
+insert into t1 select pk+200, 9.0, 9.0, 'extra-data' from t1;
+insert into t1 select pk+1000, 9.0, 9.0, 'extra-data' from t1;
+insert into t1 select pk+10000, 9.0, 9.0, 'extra-data' from t1;
+insert into t1 select pk+100000, 9.0, 9.0, 'extra-data' from t1;
+analyze table t1;
+
+--echo # The following can't use index-only:
+--replace_column 9 #
+explain select * from t1 where col1 between -8 and 8;
+
+--echo # This will use index-only:
+--replace_column 9 #
+explain
+select col1, col2 from t1 where col1 between -8 and 8;
+select col1, col2 from t1 where col1 between -8 and 8;
+
+insert into t1 values (11, NULL, 0.9, 'row1-with-null');
+insert into t1 values (10, -8.4, NULL, 'row2-with-null');
+--replace_column 9 #
+explain
+select col1, col2 from t1 force index(key1) where col1 is null or col1 < -7;
+select col1, col2 from t1 force index(key1) where col1 is null or col1 < -7;
+
+--echo # Try an UPDATE
+select * from t1 where pk in (3,4);
+update t1 set col2= col2+0.2 where pk in (3,4);
+select * from t1 where pk in (3,4);
+
+drop table t1;
+
+--echo #
+--echo # Try another DECIMAL-based type that takes more space
+--echo #
+create table t1 (
+ pk int not null primary key,
+ col1 decimal (12,6) signed,
+ col2 decimal (12,6) unsigned,
+ filler varchar(100),
+ key key1(col1, col2)
+)engine=rocksdb;
+insert into t1 values
+(1,-900.001, 000.007, 'filler'),
+(2,-700.002, 100.006, 'filler'),
+(3, 000.003, 200.005, 'filler'),
+(4, 100.004, 300.004, 'filler'),
+(5, 200.005, 400.003, 'filler'),
+(6, 300.003, 500.003, 'filler');
+insert into t1 select pk+100, col1+20000, col2+20000, 'extra-data' from t1;
+insert into t1 select pk+200, col1+20000, col2+20000, 'extra-data' from t1;
+insert into t1 select pk+1000, col1+20000, col2+20000, 'extra-data' from t1;
+insert into t1 select pk+10000, col1+20000, col2+20000, 'extra-data' from t1;
+insert into t1 select pk+100000, col1+20000, col2+20000, 'extra-data' from t1;
+analyze table t1;
+
+--replace_column 9 #
+explain
+select col1, col2 from t1 force index(key1) where col1 between -800 and 800;
+select col1, col2 from t1 force index(key1) where col1 between -800 and 800;
+drop table t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_enum.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_enum.inc
new file mode 100644
index 00000000..8184f626
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_enum.inc
@@ -0,0 +1,50 @@
+#
+# ENUM column type
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Valid values.
+# We cannot test the maximum of 65,536 here,
+# because mysqltest has the standard limit of MAX_QUERY=256K;
+# but we can at least try 257
+
+eval CREATE TABLE t1 (
+ a ENUM('') $extra_col_opts,
+ b ENUM('test1','test2','test3','test4','test5') $extra_col_opts,
+ c ENUM('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') $extra_col_opts,
+ PRIMARY KEY (b)
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+INSERT INTO t1 (a,b,c) VALUES ('','test2','4'),('',5,2);
+SELECT a,b,c FROM t1;
+
+# Out of range values
+# (should produce warnings)
+
+INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+--sorted_result
+SELECT a,b,c FROM t1;
+
+# Non-unique values in enum
+# (should produce a warning)
+eval ALTER TABLE t1 ADD COLUMN e ENUM('a','A') $extra_col_opts;
+SHOW COLUMNS IN t1;
+
+INSERT INTO t1 (a,b,c,e) VALUES ('','test3','75','A');
+--sorted_result
+SELECT a,b,c,e FROM t1;
+
+# Simple comparison
+
+--sorted_result
+SELECT a,b,c,e FROM t1 WHERE b='test2' OR a != '';
+
+DROP TABLE t1;
+
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_enum.test b/storage/rocksdb/mysql-test/rocksdb/t/type_enum.test
new file mode 100644
index 00000000..d79469b2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_enum.test
@@ -0,0 +1,8 @@
+--source include/have_rocksdb.inc
+
+#
+# ENUM column type
+#
+
+--source type_enum.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_enum_indexes-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/type_enum_indexes-master.opt
new file mode 100644
index 00000000..ba9364e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_enum_indexes-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_enum_indexes.test b/storage/rocksdb/mysql-test/rocksdb/t/type_enum_indexes.test
new file mode 100644
index 00000000..d7086a45
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_enum_indexes.test
@@ -0,0 +1,93 @@
+--source include/have_rocksdb.inc
+
+#
+# ENUM columns with indexes
+#
+
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--disable_parsing
+--error ER_GET_ERRMSG
+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'),
+ pk ENUM('1','2','3','4','5','6','7','8','9') PRIMARY KEY,
+ UNIQUE KEY a_b (a,b)
+) ENGINE=rocksdb;
+
+
+INSERT INTO t1 (a,b,c,pk) VALUES
+('N.America','test1','5a',1),('Europe','test1','5b',2),('Europe','test2','6v',3),
+('Africa','test3','4z',4),('Africa','test4','1j',5),('Antarctica','test4','1d',6);
+
+SHOW INDEX IN t1;
+
+--replace_column 9 #
+EXPLAIN SELECT a FROM t1 WHERE b > 'test2' ORDER BY a;
+SELECT a FROM t1 WHERE b > 'test2' ORDER BY a;
+
+--replace_column 9 #
+EXPLAIN SELECT a FROM t1 FORCE INDEX (a_b) WHERE b > 'test2' ORDER BY a;
+SELECT a FROM t1 FORCE INDEX (a_b) WHERE b > 'test2' ORDER BY a;
+
+DROP TABLE t1;
+
+--enable_parsing
+
+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
+) ENGINE=rocksdb;
+
+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;
+
+--replace_column 9 #
+EXPLAIN SELECT c FROM t1 WHERE c BETWEEN '1d' AND '6u';
+--sorted_result
+SELECT c FROM t1 WHERE c BETWEEN '1d' AND '6u';
+
+--replace_column 9 #
+EXPLAIN SELECT c FROM t1 USE INDEX () WHERE c BETWEEN '1d' AND '6u';
+--sorted_result
+SELECT c FROM t1 USE INDEX () WHERE c BETWEEN '1d' AND '6u';
+
+DROP TABLE t1;
+
+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'),
+ pk ENUM('1','2','3','4','5','6','7','8','9') PRIMARY KEY,
+ INDEX(b)
+) ENGINE=rocksdb;
+
+INSERT INTO t1 (a,b,c,pk) VALUES
+('N.America','test1','5a',1),('Europe','test1','5b',2),('Europe','test2','6v',3),
+('Africa','test3','4z',4),('Africa','test4','1j',5),('Antarctica','test4','1d',6);
+
+SHOW INDEX IN t1;
+
+--replace_column 9 #
+EXPLAIN SELECT DISTINCT b FROM t1;
+--sorted_result
+SELECT DISTINCT b FROM t1;
+
+--replace_column 9 #
+EXPLAIN SELECT DISTINCT b FROM t1 IGNORE INDEX (b);
+--sorted_result
+SELECT DISTINCT b FROM t1 IGNORE INDEX (b);
+
+DROP TABLE t1;
+
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_fixed.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_fixed.inc
new file mode 100644
index 00000000..424f7c4f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_fixed.inc
@@ -0,0 +1,85 @@
+#
+# Fixed point types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+eval CREATE TABLE t1 (
+ d DECIMAL $extra_col_opts,
+ d0 DECIMAL(0) $extra_col_opts,
+ d1_1 DECIMAL(1,1) $extra_col_opts,
+ d10_2 DECIMAL(10,2) $extra_col_opts,
+ d60_10 DECIMAL(60,10) $extra_col_opts,
+ n NUMERIC $extra_col_opts,
+ n0_0 NUMERIC(0,0) $extra_col_opts,
+ n1 NUMERIC(1) $extra_col_opts,
+ n20_4 NUMERIC(20,4) $extra_col_opts,
+ n65_4 NUMERIC(65,4) $extra_col_opts,
+ pk NUMERIC $extra_col_opts PRIMARY KEY
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+# Always valid values
+
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807,1);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999,3);
+
+--sorted_result
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+
+# Values which can be valid or not,
+# depending on whether columns are SIGNED or UNSIGNED
+# (if not valid should produce warnings)
+
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807,4);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999,5);
+
+--sorted_result
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+
+--sorted_result
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
+
+# Invalid values
+
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 6
+);
+
+--sorted_result
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999,7);
+--sorted_result
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111,8);
+--sorted_result
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+
+--error ER_TOO_BIG_PRECISION
+eval ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66) $extra_col_opts;
+
+--error ER_TOO_BIG_PRECISION
+eval ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6) $extra_col_opts;
+
+--error ER_TOO_BIG_SCALE
+eval ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66) $extra_col_opts;
+
+DROP TABLE t1;
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_fixed.test b/storage/rocksdb/mysql-test/rocksdb/t/type_fixed.test
new file mode 100644
index 00000000..4f2c09d1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_fixed.test
@@ -0,0 +1,8 @@
+--source include/have_rocksdb.inc
+
+#
+# Fixed point types
+#
+
+--source type_fixed.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_fixed_indexes-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/type_fixed_indexes-master.opt
new file mode 100644
index 00000000..ba9364e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_fixed_indexes-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_fixed_indexes.test b/storage/rocksdb/mysql-test/rocksdb/t/type_fixed_indexes.test
new file mode 100644
index 00000000..e9e6df58
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_fixed_indexes.test
@@ -0,0 +1,107 @@
+--source include/have_rocksdb.inc
+
+#
+# Fixed point columns with indexes
+#
+
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+
+CREATE TABLE t1 (
+ d1 DECIMAL(10,2) PRIMARY KEY,
+ d2 DECIMAL(60,10),
+ n1 NUMERIC,
+ n2 NUMERIC(65,4)
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+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);
+
+--replace_column 9 #
+EXPLAIN SELECT d1 FROM t1 ORDER BY d1 DESC;
+SELECT d1 FROM t1 ORDER BY d1 DESC;
+
+--replace_column 9 #
+EXPLAIN SELECT d1 FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY d1 DESC;
+SELECT d1 FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY d1 DESC;
+
+DROP TABLE t1;
+
+# --error ER_GET_ERRMSG
+CREATE TABLE t1 (
+ d1 DECIMAL(10,2),
+ d2 DECIMAL(60,10),
+ n1 NUMERIC,
+ n2 NUMERIC(65,4),
+ pk NUMERIC PRIMARY KEY,
+ UNIQUE INDEX n1_n2 (n1,n2)
+) ENGINE=rocksdb;
+
+# --disable_parsing
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (d1,d2,n1,n2,pk) VALUES
+(10.22,60.12345,123456,14.3456,1),
+(10.0,60.12345,123456,14,2),
+(11.14,15,123456,13,3),
+(100,100,1,2,4),
+(0,0,0,0,5),
+(4540424564.23,3343303441.0,12,13,6),
+(15,17,23,100000,7);
+
+--replace_column 9 #
+EXPLAIN SELECT DISTINCT n1+n2 FROM t1;
+--sorted_result
+SELECT DISTINCT n1+n2 FROM t1;
+
+DROP TABLE t1;
+
+#--enable_parsing
+
+CREATE TABLE t1 (
+ d1 DECIMAL(10,2),
+ d2 DECIMAL(60,10),
+ n1 NUMERIC,
+ n2 NUMERIC(65,4),
+ pk DECIMAL(20,10) PRIMARY KEY,
+ INDEX (d2)
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (d1,d2,n1,n2,pk) VALUES
+(10.22,60.12345,123456,14.3456,1),
+(10.0,60.12345,123456,14,2),
+(11.14,15,123456,13,3),
+(100,100,1,2,4),
+(0,0,0,0,5),
+(4540424564.23,3343303441.0,12,13,6),
+(15,17,23,100000,7);
+
+--replace_column 9 #
+EXPLAIN SELECT d2, COUNT(*) FROM t1 GROUP BY d2;
+--sorted_result
+SELECT d2, COUNT(*) FROM t1 GROUP BY d2;
+
+--replace_column 9 #
+EXPLAIN SELECT d2, COUNT(*) FROM t1 IGNORE INDEX FOR GROUP BY (d2) GROUP BY d2;
+--sorted_result
+SELECT d2, COUNT(*) FROM t1 IGNORE INDEX FOR GROUP BY (d2) GROUP BY d2;
+
+DROP TABLE t1;
+
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_float.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_float.inc
new file mode 100644
index 00000000..ff58b73a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_float.inc
@@ -0,0 +1,121 @@
+#
+# Float types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+eval CREATE TABLE t1 (
+ f FLOAT $extra_col_opts,
+ f0 FLOAT(0) $extra_col_opts,
+ r1_1 REAL(1,1) $extra_col_opts,
+ f23_0 FLOAT(23) $extra_col_opts,
+ f20_3 FLOAT(20,3) $extra_col_opts,
+ d DOUBLE $extra_col_opts,
+ d1_0 DOUBLE(1,0) $extra_col_opts,
+ d10_10 DOUBLE PRECISION (10,10) $extra_col_opts,
+ d53 DOUBLE(53,0) $extra_col_opts,
+ d53_10 DOUBLE(53,10) $extra_col_opts,
+ pk DOUBLE $extra_col_opts PRIMARY KEY
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+# Always valid values
+
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999,1);
+
+--sorted_result
+--query_vertical SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1
+
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+ 99999999999999999999999999999999999999,
+ 99999999999999999999999999999999999999.9999999999999999,
+ 0.9,
+ 99999999999999999999999999999999999999.9,
+ 99999999999999999.999,
+ 999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+ 9,
+ 0.9999999999,
+ 1999999999999999999999999999999999999999999999999999999,
+ 19999999999999999999999999999999999999999999.9999999999,
+ 3
+);
+
+--sorted_result
+--query_vertical SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1
+
+# Values which can be valid or not,
+# depending on whether columns are SIGNED or UNSIGNED
+# (if not valid should produce warnings)
+
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999,4);
+
+--sorted_result
+--query_vertical SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1
+
+--sorted_result
+query_vertical
+SELECT
+ CONCAT('', MAX(f)),
+ CONCAT('', MAX(f0)),
+ CONCAT('', MAX(r1_1)),
+ CONCAT('', MAX(f23_0)),
+ CONCAT('', MAX(f20_3)),
+ CONCAT('', MAX(d)),
+ CONCAT('', MAX(d1_0)),
+ CONCAT('', MAX(d10_10)),
+ CONCAT('', MAX(d53)),
+ CONCAT('', MAX(d53_10)) FROM t1;
+
+# Invalid values
+
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 9999999999999999999999999999999999999999999999999999999999999.9999,
+ 5
+);
+
+--sorted_result
+--query_vertical SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1
+
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
+ 999999999999999999999999999999999999999,
+ 999999999999999999999999999999999999999.9999999999999999,
+ 1.9,
+ 999999999999999999999999999999999999999.9,
+ 999999999999999999.999,
+ 9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+ 99,
+ 1.9999999999,
+ 1999999999999999999999999999999999999999999999999999999,
+ 19999999999999999999999999999999999999999999.9999999999,
+ 6
+);
+
+--sorted_result
+--query_vertical SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1
+
+# Error occurs on MySQL but not on MariaDB:
+# --error ER_TOO_BIG_DISPLAYWIDTH
+eval ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) $extra_col_opts;
+
+--error ER_TOO_BIG_PRECISION
+eval ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1) $extra_col_opts;
+
+# Error occurs on MySQL but not on MariaDB:
+# --error ER_TOO_BIG_SCALE
+eval ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35) $extra_col_opts;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_float.test b/storage/rocksdb/mysql-test/rocksdb/t/type_float.test
new file mode 100644
index 00000000..1f184999
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_float.test
@@ -0,0 +1,8 @@
+--source include/have_rocksdb.inc
+
+#
+# Float types
+#
+
+--source type_float.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_float_indexes-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/type_float_indexes-master.opt
new file mode 100644
index 00000000..ba9364e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_float_indexes-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_float_indexes.test b/storage/rocksdb/mysql-test/rocksdb/t/type_float_indexes.test
new file mode 100644
index 00000000..907bc614
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_float_indexes.test
@@ -0,0 +1,175 @@
+--source include/have_rocksdb.inc
+
+#
+# Float type columns with indexes
+#
+
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (
+ f FLOAT PRIMARY KEY,
+ r REAL(20,3),
+ d DOUBLE,
+ dp DOUBLE PRECISION (64,10)
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+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);
+
+--replace_column 9 #
+EXPLAIN SELECT f FROM t1 ORDER BY f;
+SELECT f FROM t1 ORDER BY f;
+
+--replace_column 9 #
+EXPLAIN SELECT f FROM t1 IGNORE INDEX (PRIMARY) ORDER BY f;
+SELECT f FROM t1 IGNORE INDEX (PRIMARY) ORDER BY f;
+
+DROP TABLE t1;
+
+#--error ER_GET_ERRMSG
+CREATE TABLE t1 (
+ f FLOAT,
+ r REAL(20,3),
+ d DOUBLE,
+ dp DOUBLE PRECISION (64,10),
+ pk DOUBLE PRIMARY KEY,
+ UNIQUE KEY r_dp (r,dp)
+) ENGINE=rocksdb;
+
+#--disable_parsing
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (f,r,d,dp,pk) VALUES
+(1.2345,1422.22,1.2345,1234567.89,1),
+(0,0,0,0,2),
+(-1,-1,-1,-1,3),
+(17.5843,4953453454.44,29229114.0,1111111.23,4),
+(4644,1422.22,466664.999,0.5,5);
+
+--replace_column 9 #
+EXPLAIN SELECT r, dp FROM t1 WHERE r > 0 or dp > 0;
+--sorted_result
+SELECT r, dp FROM t1 WHERE r > 0 or dp > 0;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ f FLOAT,
+ r REAL(20,3),
+ d DOUBLE,
+ dp DOUBLE PRECISION (64,10),
+ pk FLOAT PRIMARY KEY,
+ UNIQUE KEY(d)
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (f,r,d,dp,pk) VALUES
+(1.2345,1422.22,1.2345,1234567.89,1),
+(0,0,0,0,2),
+(-1,-1,-1,-1,3),
+(17.5843,4953453454.44,29229114.0,1111111.23,4),
+(4644,1422.22,466664.999,0.5,5);
+
+--replace_column 9 #
+EXPLAIN SELECT DISTINCT d FROM t1 ORDER BY d;
+SELECT DISTINCT d FROM t1 ORDER BY d;
+
+DROP TABLE t1;
+
+#--enable_parsing
+
+CREATE TABLE t1 (
+ f FLOAT,
+ r REAL(20,3),
+ d DOUBLE,
+ dp DOUBLE PRECISION (64,10),
+ pk FLOAT PRIMARY KEY,
+ KEY(d)
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (f,r,d,dp,pk) VALUES
+(1.2345,1422.22,1.2345,1234567.89,1),
+(0,0,0,0,2),
+(-1,-1,-1,-1,3),
+(17.5843,4953453454.44,29229114.0,1111111.23,4),
+(4644,1422.22,466664.999,0.5,5);
+
+--replace_column 9 #
+EXPLAIN SELECT DISTINCT d FROM t1 ORDER BY d;
+SELECT DISTINCT d FROM t1 ORDER BY d;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ f FLOAT,
+ r REAL(20,3),
+ d DOUBLE,
+ dp DOUBLE PRECISION (64,10),
+ pk FLOAT PRIMARY KEY,
+ UNIQUE KEY(f)
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (f,r,d,dp,pk) VALUES
+(1.2345,1422.22,1.2345,1234567.89,1),
+(0,0,0,0,2),
+(-1,-1,-1,-1,3),
+(17.5843,4953453454.44,29229114.0,1111111.23,4),
+(4644,1422.22,466664.999,0.5,5);
+
+# Should fail because of 'unique' constraint
+--error ER_DUP_ENTRY
+INSERT INTO t1 (f,r,d,dp,pk) VALUES
+(1.2345,0,0,0,6);
+
+--replace_column 9 #
+EXPLAIN SELECT DISTINCT f FROM t1 ORDER BY f;
+SELECT DISTINCT f FROM t1 ORDER BY f;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ f FLOAT,
+ r REAL(20,3),
+ d DOUBLE,
+ dp DOUBLE PRECISION (64,10),
+ pk FLOAT PRIMARY KEY,
+ KEY(f)
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (f,r,d,dp,pk) VALUES
+(1.2345,1422.22,1.2345,1234567.89,1),
+(0,0,0,0,2),
+(-1,-1,-1,-1,3),
+(17.5843,4953453454.44,29229114.0,1111111.23,4),
+(4644,1422.22,466664.999,0.5,5);
+
+# Should succeed because of no 'unique' constraint
+INSERT INTO t1 (f,r,d,dp,pk) VALUES
+(1.2345,0,0,0,6);
+
+--replace_column 9 #
+EXPLAIN SELECT DISTINCT f FROM t1 ORDER BY f;
+SELECT DISTINCT f FROM t1 ORDER BY f;
+
+DROP TABLE t1;
+
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_int.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_int.inc
new file mode 100644
index 00000000..dbcdfe4f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_int.inc
@@ -0,0 +1,68 @@
+#
+# INT column types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+eval CREATE TABLE t1 (
+ i INT $extra_col_opts,
+ i0 INT(0) $extra_col_opts,
+ i1 INT(1) $extra_col_opts,
+ i20 INT(20) $extra_col_opts,
+ t TINYINT $extra_col_opts,
+ t0 TINYINT(0) $extra_col_opts,
+ t1 TINYINT(1) $extra_col_opts,
+ t20 TINYINT(20) $extra_col_opts,
+ s SMALLINT $extra_col_opts,
+ s0 SMALLINT(0) $extra_col_opts,
+ s1 SMALLINT(1) $extra_col_opts,
+ s20 SMALLINT(20) $extra_col_opts,
+ m MEDIUMINT $extra_col_opts,
+ m0 MEDIUMINT(0) $extra_col_opts,
+ m1 MEDIUMINT(1) $extra_col_opts,
+ m20 MEDIUMINT(20) $extra_col_opts,
+ b BIGINT $extra_col_opts,
+ b0 BIGINT(0) $extra_col_opts,
+ b1 BIGINT(1) $extra_col_opts,
+ b20 BIGINT(20) $extra_col_opts,
+ pk INT AUTO_INCREMENT PRIMARY KEY
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+# Always valid values
+
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
+--sorted_result
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+
+# Values which can be valid or not,
+# depending on whether columns are SIGNED or UNSIGNED
+# (if not valid should produce warnings)
+
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
+
+--sorted_result
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+
+# Invalid values
+
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
+
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
+
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
+
+--sorted_result
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+
+--error ER_TOO_BIG_DISPLAYWIDTH
+eval ALTER TABLE t1 ADD COLUMN i257 INT(257) $extra_col_opts;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_int.test b/storage/rocksdb/mysql-test/rocksdb/t/type_int.test
new file mode 100644
index 00000000..e92f6692
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_int.test
@@ -0,0 +1,8 @@
+--source include/have_rocksdb.inc
+
+#
+# INT column types
+#
+
+--source type_int.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_int_indexes-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/type_int_indexes-master.opt
new file mode 100644
index 00000000..ba9364e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_int_indexes-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_int_indexes.test b/storage/rocksdb/mysql-test/rocksdb/t/type_int_indexes.test
new file mode 100644
index 00000000..c95c3d88
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_int_indexes.test
@@ -0,0 +1,75 @@
+--source include/have_rocksdb.inc
+
+#
+# INT column types with indexes
+#
+
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (
+ i INT PRIMARY KEY,
+ t TINYINT,
+ s SMALLINT,
+ m MEDIUMINT,
+ b BIGINT
+) ENGINE=rocksdb;
+
+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);
+
+--replace_column 9 #
+EXPLAIN SELECT i FROM t1 ORDER BY i;
+SELECT i FROM t1 ORDER BY i;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ i INT,
+ t TINYINT,
+ s SMALLINT,
+ m MEDIUMINT,
+ b BIGINT,
+ pk SMALLINT AUTO_INCREMENT PRIMARY KEY,
+ INDEX s_m (s,m)
+) ENGINE=rocksdb;
+
+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);
+
+--replace_column 9 #
+EXPLAIN SELECT s, m FROM t1 WHERE s != 10 AND m != 1;
+--sorted_result
+SELECT s, m FROM t1 WHERE s != 10 AND m != 1;
+
+DROP TABLE t1;
+
+--echo # RocksDB: unique indexes allowed
+#--error ER_GET_ERRMSG
+CREATE TABLE t1 (
+ i INT,
+ t TINYINT,
+ s SMALLINT,
+ m MEDIUMINT,
+ b BIGINT,
+ pk MEDIUMINT AUTO_INCREMENT PRIMARY KEY,
+ UNIQUE KEY b_t (b,t)
+) ENGINE=rocksdb;
+
+##--disable_parsing
+
+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);
+
+# This query should use the index b_t, we just don't want to run EXPLAIN
+# (to avoid mismatches due to different subquery-related plans)
+SELECT b+t FROM t1 WHERE (b,t) IN ( SELECT b, t FROM t1 WHERE i>1 ) ORDER BY b+t;
+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;
+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;
+
+DROP TABLE t1;
+
+##--enable_parsing
+
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_set.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_set.inc
new file mode 100644
index 00000000..25ae5829
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_set.inc
@@ -0,0 +1,49 @@
+#
+# SET column type
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Valid values.
+
+eval CREATE TABLE t1 (
+ a SET('') $extra_col_opts,
+ b SET('test1','test2','test3','test4','test5') $extra_col_opts,
+ c SET('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') $extra_col_opts,
+ PRIMARY KEY (c)
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+INSERT INTO t1 (a,b,c) VALUES
+('','test2,test3','01,34,44,,23'),
+('',5,2),
+(',','test4,test2','');
+--sorted_result
+SELECT a,b,c FROM t1;
+
+# Out of range values
+# (should produce warnings)
+
+INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+--sorted_result
+SELECT a,b,c FROM t1;
+
+# Non-unique values in set
+# (should produce a warning)
+eval ALTER TABLE t1 ADD COLUMN e SET('a','A') $extra_col_opts;
+
+SHOW COLUMNS IN t1;
+
+--error ER_TOO_BIG_SET
+eval ALTER TABLE t1 ADD COLUMN f SET('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i') $extra_col_opts;
+
+# Simple comparison
+
+--sorted_result
+SELECT a,b,c,e FROM t1 WHERE FIND_IN_SET('test2',b)>0 OR a != '';
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_set.test b/storage/rocksdb/mysql-test/rocksdb/t/type_set.test
new file mode 100644
index 00000000..bd306668
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_set.test
@@ -0,0 +1,8 @@
+--source include/have_rocksdb.inc
+
+#
+# SET column type
+#
+
+--source type_set.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_set_indexes-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/type_set_indexes-master.opt
new file mode 100644
index 00000000..ba9364e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_set_indexes-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_set_indexes.test b/storage/rocksdb/mysql-test/rocksdb/t/type_set_indexes.test
new file mode 100644
index 00000000..983c7025
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_set_indexes.test
@@ -0,0 +1,100 @@
+--source include/have_rocksdb.inc
+
+#
+# SET columns with indexes
+#
+
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (
+ a SET('N.America','S.America','Africa','Antarctica','Australia','Europe','Asia'),
+ b SET('test1','test2','test3','test4','test5'),
+ c SET('01','22','23','33','34','39','40','44','50','63','64') PRIMARY KEY
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+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');
+
+--replace_column 9 #
+EXPLAIN SELECT c FROM t1 ORDER BY c;
+SELECT c FROM t1 ORDER BY c;
+
+--replace_column 9 #
+EXPLAIN SELECT c FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY c;
+SELECT c FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY c;
+
+--error ER_DUP_ENTRY
+INSERT INTO t1 (a,b,c) VALUES ('Antarctica','test3','02');
+
+--error ER_DUP_ENTRY
+INSERT INTO t1 (a,b,c) VALUES ('','test1','34,44');
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ a SET('N.America','S.America','Africa','Antarctica','Australia','Europe','Asia'),
+ b SET('test1','test2','test3','test4','test5'),
+ c SET('01','22','23','33','34','39','40','44','50','63','64'),
+ pk SET('1','2','3','4','5','6','7','8','9') PRIMARY KEY,
+ INDEX(a)
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (a,b,c,pk) VALUES
+('','test2,test3','01,34,44,23',1),
+('',5,2,2),
+('N.America,Asia','test4,test2','',3),
+('Africa,Europe,Asia','test2,test3','01',4),
+('Antarctica','test3','34,44',5),
+('Asia','test5','50',6),
+('Europe,S.America','test1,','39',7);
+
+--replace_column 9 #
+EXPLAIN SELECT a FROM t1 WHERE FIND_IN_SET('Europe',a) > 0;
+--sorted_result
+SELECT a FROM t1 WHERE FIND_IN_SET('Europe',a) > 0;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ a SET('N.America','S.America','Africa','Antarctica','Australia','Europe','Asia'),
+ b SET('test1','test2','test3','test4','test5'),
+ c SET('01','22','23','33','34','39','40','44','50','63','64'),
+ pk SET('1','2','3','4','5','6','7','8','9') PRIMARY KEY,
+ UNIQUE INDEX b_a (b,a)
+) ENGINE=rocksdb;
+
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (a,b,c,pk) VALUES
+('','test2,test3','01,34,44,23',1),
+('',5,2,2),
+('N.America,Asia','test4,test2','',3),
+('Africa,Europe,Asia','test2,test3','01',4),
+('Antarctica','test3','34,44',5),
+('Asia','test5','50',6),
+('Europe,S.America','test1,','39',7);
+
+--replace_column 9 #
+EXPLAIN SELECT DISTINCT a, b FROM t1 ORDER BY b DESC, a;
+--sorted_result
+SELECT DISTINCT a, b FROM t1 ORDER BY b DESC, a;
+
+DROP TABLE t1;
+
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_text.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_text.inc
new file mode 100644
index 00000000..f5c9c3b8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_text.inc
@@ -0,0 +1,49 @@
+#
+# TEXT column types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+eval CREATE TABLE t1 (
+ pk INT AUTO_INCREMENT PRIMARY KEY,
+ t TEXT $extra_col_opts,
+ t0 TEXT(0) $extra_col_opts,
+ t1 TEXT(1) $extra_col_opts,
+ t300 TEXT(300) $extra_col_opts,
+ tm TEXT(65535) $extra_col_opts,
+ t70k TEXT(70000) $extra_col_opts,
+ t17m TEXT(17000000) $extra_col_opts,
+ tt TINYTEXT $extra_col_opts,
+ m MEDIUMTEXT $extra_col_opts,
+ l LONGTEXT $extra_col_opts
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+# Valid values
+# (cannot get MAX for all columns due to max_allowed_packet limitations)
+
+INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+('','','','','','','','','',''),
+('a','b','c','d','e','f','g','h','i','j'),
+('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',255), REPEAT('i',1048576), REPEAT('j',1048576) );
+
+--sorted_result
+SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+
+# Invalid values (produce warnings, except for mediumtext and longtext columns for which the values are within limits)
+
+INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+
+--sorted_result
+SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+
+--error ER_TOO_BIG_DISPLAYWIDTH
+eval ALTER TABLE t1 ADD COLUMN ttt TEXT(4294967296) $extra_col_opts;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_text.test b/storage/rocksdb/mysql-test/rocksdb/t/type_text.test
new file mode 100644
index 00000000..c6dd24ff
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_text.test
@@ -0,0 +1,8 @@
+--source include/have_rocksdb.inc
+
+#
+# TEXT column types
+#
+
+--source type_text.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_text_indexes-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/type_text_indexes-master.opt
new file mode 100644
index 00000000..6ad42e58
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_text_indexes-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000 --rocksdb_records_in_range=50
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_text_indexes.test b/storage/rocksdb/mysql-test/rocksdb/t/type_text_indexes.test
new file mode 100644
index 00000000..5fdc4bff
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_text_indexes.test
@@ -0,0 +1,171 @@
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+
+#
+# TEXT columns with indexes
+#
+
+SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK;
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+
+CREATE TABLE t1 (
+ t TEXT,
+ tt TINYTEXT,
+ m MEDIUMTEXT,
+ l LONGTEXT,
+ PRIMARY KEY t (t(32))
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+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));
+
+--replace_column 9 #
+EXPLAIN SELECT SUBSTRING(t,16) AS f FROM t1 WHERE t IN ('test1','test2') ORDER BY f;
+SELECT SUBSTRING(t,16) AS f FROM t1 WHERE t IN ('test1','test2') ORDER BY f;
+
+--replace_column 9 #
+EXPLAIN SELECT SUBSTRING(t,16) AS f FROM t1 IGNORE INDEX (PRIMARY) WHERE t IN ('test1','test2') ORDER BY f;
+SELECT SUBSTRING(t,16) AS f FROM t1 IGNORE INDEX (PRIMARY) WHERE t IN ('test1','test2') ORDER BY f;
+DROP TABLE t1;
+
+--error ER_BLOB_KEY_WITHOUT_LENGTH
+CREATE TABLE t1 (
+ t TEXT,
+ tt TINYTEXT,
+ m MEDIUMTEXT,
+ l LONGTEXT,
+ pk TINYTEXT PRIMARY KEY,
+ UNIQUE INDEX l_tt (l(256),tt(64))
+) ENGINE=rocksdb;
+
+CREATE TABLE t1 (
+ t TEXT,
+ tt TINYTEXT,
+ m MEDIUMTEXT,
+ l LONGTEXT,
+ pk MEDIUMTEXT,
+ PRIMARY KEY mt (pk(1)),
+ INDEX (m(128))
+) ENGINE=rocksdb;
+
+SHOW INDEX IN t1;
+
+INSERT INTO t1 (t,tt,m,l,pk) VALUES
+('','','','','0'),
+('a','b','c','d','1'),
+('b','d','c','b','2'),
+('test1','test2','test3','test4','3'),
+(REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128),'4'),
+('abc','def','ghi','jkl','5'),
+('test2','test3','test4','test5','6'),
+('test3','test4','test5','test6','7'),
+(REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128),'8'),
+(REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128),'9');
+
+--replace_column 9 #
+EXPLAIN SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ b TEXT,
+ PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+
+SELECT b FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ b TINYTEXT,
+ PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+
+SELECT b FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ b MEDIUMTEXT,
+ PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+
+SELECT b FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ b LONGTEXT,
+ PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+
+SELECT b FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ b LONGTEXT CHARACTER SET "binary" COLLATE "binary",
+ PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+
+INSERT INTO t1 (b) VALUES
+('00000000000000000000000000000000'),
+('00000000000000000000000000000001'),
+('00000000000000000000000000000002');
+INSERT INTO t1 (b) VALUES (''), (_binary 0x0), (' ');
+
+SELECT hex(b) FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ b LONGTEXT CHARACTER SET "latin1" COLLATE "latin1_bin",
+ PRIMARY KEY b (b(32))
+) ENGINE=rocksdb;
+
+--error ER_DUP_ENTRY
+INSERT INTO t1 (b) VALUES (''), (_binary 0x0), (' ');
+
+INSERT INTO t1 (b) VALUES (''), (_binary 0x0);
+SELECT hex(b) FROM t1;
+
+DROP TABLE t1;
+
+SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_varbinary.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_varbinary.inc
new file mode 100644
index 00000000..a9f98831
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_varbinary.inc
@@ -0,0 +1,75 @@
+#
+# VARBINARY column types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+eval CREATE TABLE t1 (
+ v0 VARBINARY(0) $extra_col_opts,
+ v1 VARBINARY(1) $extra_col_opts,
+ v64 VARBINARY(64) $extra_col_opts,
+ v65000 VARBINARY(65000) $extra_col_opts,
+ PRIMARY KEY (v64)
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+eval CREATE TABLE t2 (v VARBINARY(65532) $extra_col_opts, PRIMARY KEY(v(255))) ENGINE=rocksdb;
+SHOW COLUMNS IN t2;
+
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+
+--sorted_result
+SELECT HEX(v0), HEX(v1), HEX(v64), HEX(v65000) FROM t1;
+
+# Invalid values
+
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, CONCAT('a',v65000), CONCAT(v65000,v1) FROM t1;
+
+--sorted_result
+SELECT HEX(v0), HEX(v1), HEX(v64), LENGTH(HEX(v65000)) FROM t1;
+
+eval ALTER TABLE t1 ADD COLUMN v65536 VARBINARY(65536) $extra_col_opts;
+SHOW COLUMNS IN t1;
+
+DROP TABLE t1, t2;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_varbinary.test b/storage/rocksdb/mysql-test/rocksdb/t/type_varbinary.test
new file mode 100644
index 00000000..2ef3da8a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_varbinary.test
@@ -0,0 +1,8 @@
+--source include/have_rocksdb.inc
+
+#
+# VARBINARY column types
+#
+
+--source type_varbinary.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_varchar-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/type_varchar-master.opt
new file mode 100644
index 00000000..33e72265
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_varchar-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=10
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_varchar.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_varchar.inc
new file mode 100644
index 00000000..ce5dbb44
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_varchar.inc
@@ -0,0 +1,77 @@
+#
+# VARCHAR column types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+eval CREATE TABLE t1 (
+ v0 VARCHAR(0) $extra_col_opts,
+ v1 VARCHAR(1) $extra_col_opts,
+ v64 VARCHAR(64) $extra_col_opts,
+ v65000 VARCHAR(65000) $extra_col_opts,
+ PRIMARY KEY (v64)
+) ENGINE=rocksdb;
+
+SHOW COLUMNS IN t1;
+
+CREATE TABLE t2 (v VARCHAR(65532), PRIMARY KEY (v(255))) ENGINE=rocksdb;
+SHOW COLUMNS IN t2;
+
+# Valid values
+
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+
+--sorted_result
+SELECT v0,v1,v64,v65000 FROM t1;
+
+# Invalid values
+
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, CONCAT('a',v65000), CONCAT(v65000,v1) FROM t1;
+
+--sorted_result
+SELECT v0, v1, v64, LENGTH(v65000) FROM t1;
+
+eval ALTER TABLE t1 ADD COLUMN v65536 VARCHAR(65536) $extra_col_opts;
+SHOW COLUMNS IN t1;
+
+DROP TABLE t1, t2;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_varchar.test b/storage/rocksdb/mysql-test/rocksdb/t/type_varchar.test
new file mode 100644
index 00000000..b631615c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_varchar.test
@@ -0,0 +1,82 @@
+--source include/have_rocksdb.inc
+
+#
+# VARCHAR column types
+#
+
+--echo #
+--echo # A basic test whether endspace-aware variable length encoding
+--echo # works when in PK
+--echo #
+create table t1 ( pk varchar(10) primary key, col1 int not null) ;
+insert into t1 values ('a', 1);
+select * from t1;
+drop table t1;
+
+--source type_varchar.inc
+
+
+--echo #
+--echo # Endspace-comparison tests:
+--echo #
+
+--let $character_set_collate=CHARACTER SET latin1 COLLATE latin1_bin
+--source type_varchar_endspace.inc
+
+--let $character_set_collate=CHARACTER SET utf8 COLLATE utf8_bin
+--source type_varchar_endspace.inc
+
+--let $character_set_collate=CHARACTER SET ucs2 COLLATE ucs2_bin
+--source type_varchar_endspace.inc
+
+--let $character_set_collate=CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
+--source type_varchar_endspace.inc
+
+--let $character_set_collate=CHARACTER SET utf16 COLLATE utf16_bin
+--source type_varchar_endspace.inc
+
+create table t1 (
+ pk int primary key,
+ col1 varchar(10) collate utf8mb4_bin not null,
+ col2 varchar(20),
+ key(col1)
+) engine=rocksdb;
+
+insert into t1 values (1, 'ab','ab');
+insert into t1 values (2, 'ab\0','ab0');
+
+select pk, hex(col1), col2 from t1 force index(col1) order by col1;
+select pk, hex(col1), col2 from t1 ignore index(col1) order by col1;
+drop table t1;
+
+# Issue #306 - Do not store trailing spaces for prefixed keys.
+create table t (id int primary key, email varchar(100), KEY email_i (email(30)));
+insert into t values (1, 'abcabcabcabcabcabcabcabcabcabcabc ');
+--replace_column 9 #
+explain select 'email_i' as index_name, count(*) AS count from t force index(email_i);
+select 'email_i' as index_name, count(*) AS count from t force index(email_i);
+drop table t;
+
+set @save_rocksdb_checksums_pct = @@global.rocksdb_checksums_pct;
+set @save_rocksdb_verify_row_debug_checksums = @@session.rocksdb_verify_row_debug_checksums;
+set global rocksdb_checksums_pct = 100;
+set session rocksdb_verify_row_debug_checksums = on;
+create table t (id int primary key, email varchar(100), KEY email_i (email(30)));
+insert into t values (1, 'a');
+--replace_column 9 #
+explain select 'email_i' as index_name, count(*) AS count from t force index(email_i);
+select 'email_i' as index_name, count(*) AS count from t force index(email_i);
+drop table t;
+set global rocksdb_checksums_pct = @save_rocksdb_checksums_pct;
+set session rocksdb_verify_row_debug_checksums = @save_rocksdb_verify_row_debug_checksums;
+
+# Issue #784 - Skip trailing space bytes for non-unpackable fields
+
+drop table if exists t;
+create table t (h varchar(31) character set utf8 collate utf8_bin not null, i varchar(19) collate latin1_bin not null, primary key(i), key(h)) engine=rocksdb;
+insert into t(i,h) values('a','b');
+check table t;
+alter table t modify h varchar(31) character set cp1257 collate cp1257_bin not null;
+check table t;
+drop table t;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_varchar_endspace.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_varchar_endspace.inc
new file mode 100644
index 00000000..494f0ea1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_varchar_endspace.inc
@@ -0,0 +1,85 @@
+--echo #
+--echo # Issue 257: Sort order for varchars is different between
+--echo # MyISAM/InnoDB vs MyRocks
+--echo #
+
+eval create table t1 (
+ pk varchar(64) $character_set_collate,
+ col1 varchar(64),
+ primary key (pk)
+);
+insert into t1 values ('a','a');
+--error ER_DUP_ENTRY
+insert into t1 values ('a ', 'a-space');
+
+insert into t1 values('b ', 'b-2x-space');
+--error ER_DUP_ENTRY
+insert into t1 values ('b', 'b');
+
+select pk, hex(pk), col1 from t1;
+
+insert into t1 values ('a\t', 'a-tab');
+insert into t1 values ('a \t', 'a-space-tab');
+select pk, hex(pk), col1 from t1 order by pk;
+
+--echo # Try longer values
+--error ER_DUP_ENTRY
+insert into t1 values (concat('a', repeat(' ',10)), 'a-10-x-space');
+
+insert into t1 values (concat('c', repeat(' ',10)), 'c-10-x-space');
+select * from t1;
+
+drop table t1;
+
+--echo # Secondary index
+eval create table t1 (
+ pk int not null primary key,
+ col1 varchar(64) $character_set_collate,
+ col2 varchar(64),
+ key (col1)
+);
+insert into t1 values (0, 'ab', 'a-b');
+insert into t1 values (1, 'a ', 'a-space');
+insert into t1 values (2, 'a', 'a');
+insert into t1 values (3, 'a \t', 'a-tab');
+
+analyze table t1;
+--echo # Must show 'using index' for latin1_bin and utf8_bin:
+--replace_column 9 #
+explain
+select col1, hex(col1) from t1;
+select col1, hex(col1) from t1;
+
+--echo # Must show 'using index' for latin1_bin and utf8_bin:
+--replace_column 4 # 9 #
+explain
+select col1, hex(col1) from t1 force index(col1) where col1 < 'b';
+select col1, hex(col1) from t1 force index(col1) where col1 < 'b';
+
+delete from t1;
+insert into t1 values(10, '', 'empty');
+insert into t1 values(11, repeat(' ', 8), '8x-space');
+insert into t1 values(12, repeat(' ', 16), '16x-space');
+insert into t1 values(13, repeat(' ', 24), '24x-space');
+insert into t1 values(14, concat(repeat(' ', 16),'a'), '16x-space-a');
+
+insert into t1 values(21, repeat(' ', 9), '9x-space');
+insert into t1 values(22, repeat(' ',17), '17x-space');
+insert into t1 values(23, repeat(' ',18), '18x-space');
+
+--replace_column 4 # 9 #
+explain
+select pk, col1, hex(col1), length(col1) from t1;
+select pk, col1, hex(col1), length(col1) from t1;
+drop table t1;
+
+create table t1 (pk int primary key, a varchar(512), key(a)) engine=rocksdb;
+insert into t1 values (1, concat('a', repeat(' ', 300)));
+insert into t1 values (2, concat('b', repeat(' ', 300)));
+
+select pk,length(a) from t1 force index(a) where a < 'zz';
+select pk,length(a),rtrim(a) from t1 force index(a) where a < 'zz';
+select pk,length(a),rtrim(a) from t1 ignore index(a) where a < 'zz';
+
+drop table t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/unique_check.test b/storage/rocksdb/mysql-test/rocksdb/t/unique_check.test
new file mode 100644
index 00000000..e2520388
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/unique_check.test
@@ -0,0 +1,173 @@
+--source include/have_rocksdb.inc
+--source include/have_debug_sync.inc
+
+# For GitHub issue#167 -- Unique key check doesn't work
+
+connect (con1, localhost, root,,);
+connect (con2, localhost, root,,);
+connect (con3, localhost, root,,);
+connection default;
+
+--disable_warnings
+set debug_sync='RESET';
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (id int, value int, primary key (id)) engine=rocksdb;
+create table t2 (id int, id2 int, value int, primary key (id), unique key (id2)) engine=rocksdb;
+
+# 1) second insert should be blocked at GetForUpdate(), then returning duplicate key error
+# after con1's commit
+connection con1;
+begin;
+insert into t1 values (1,1);
+
+connection con2;
+let $ID= `select connection_id()`;
+set session rocksdb_lock_wait_timeout=50;
+begin;
+send insert into t1 values (1,2);
+
+connection con1;
+let $wait_condition= select 1 from INFORMATION_SCHEMA.PROCESSLIST
+ where (ID = $ID /* or SRV_ID = $ID*/)
+ and STATE = "Waiting for row lock";
+--source include/wait_condition.inc
+commit;
+
+connection con2;
+--error ER_DUP_ENTRY
+reap;
+commit;
+select * from t1;
+truncate table t1;
+
+# 2) same as 1) but using secondary unique key constraint
+connection con1;
+begin;
+insert into t2 values (1,1,1);
+
+connection con2;
+begin;
+send insert into t2 values (2,1,2);
+
+connection con1;
+--source include/wait_condition.inc
+commit;
+
+connection con2;
+--error ER_DUP_ENTRY
+reap;
+commit;
+select * from t2;
+truncate table t2;
+
+# 3) similar to 1),2) but rolled back
+connection con1;
+begin;
+insert into t1 values (1,1);
+
+connection con2;
+begin;
+send insert into t1 values (1,2);
+
+connection con1;
+--source include/wait_condition.inc
+rollback;
+
+connection con2;
+reap;
+commit;
+select * from t1;
+truncate table t1;
+
+connection con1;
+begin;
+insert into t2 values (1,1,1);
+
+connection con2;
+begin;
+send insert into t2 values (2,1,2);
+
+connection con1;
+--source include/wait_condition.inc
+rollback;
+
+connection con2;
+reap;
+commit;
+select * from t2;
+truncate table t2;
+
+
+# 4) simulating T1 GetForUpdate() -> T2 GetForUpdate(). T2 should fail with lock wait timeout.
+connection con1;
+set debug_sync='rocksdb.update_write_row_after_unique_check SIGNAL parked1 WAIT_FOR go';
+send insert into t1 values (1,1);
+
+connection default;
+set debug_sync='now WAIT_FOR parked1';
+
+connection con2;
+set debug_sync='rocksdb.update_write_row_after_unique_check SIGNAL parked2 WAIT_FOR go';
+send insert into t2 values (1,1,1);
+
+connection default;
+set debug_sync='now WAIT_FOR parked2';
+
+connection con3;
+set session rocksdb_lock_wait_timeout=1;
+--error ER_LOCK_WAIT_TIMEOUT
+insert into t1 values (1,2);
+--error ER_LOCK_WAIT_TIMEOUT
+insert into t2 values (2,1,2);
+
+connection default;
+set debug_sync='now SIGNAL go';
+
+connection con1;
+reap;
+
+connection con2;
+reap;
+
+connection default;
+--error ER_DUP_ENTRY
+insert into t1 values (1,2);
+--error ER_DUP_ENTRY
+insert into t2 values (2,1,2);
+select * from t1;
+select * from t2;
+# Cleanup
+connection default;
+set debug_sync='RESET';
+disconnect con1;
+disconnect con2;
+disconnect con3;
+drop table t1, t2;
+
+# skip_unique checks should skip checks only for tables that don't have
+# secondary indexes
+connection default;
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
+# table with PK only
+create table t1 (id int, value int, primary key (id)) engine=rocksdb;
+# table with PK and SK
+create table t2 (id int, id2 int, value int, primary key (id), unique key (id2)) engine=rocksdb;
+# table with hidden PK
+create table t3 (id int, value int) engine=rocksdb;
+
+SET @old_val = @@session.unique_checks;
+set @@session.unique_checks = FALSE;
+
+insert into t1 values (1, 1), (1, 2);
+--error ER_DUP_ENTRY
+insert into t2 values (1, 1, 1), (1, 2, 1);
+insert into t3 values (1, 1), (1, 1);
+
+set @@session.unique_checks = @old_val;
+# cleanup
+drop table t1, t2, t3;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/unique_sec.inc b/storage/rocksdb/mysql-test/rocksdb/t/unique_sec.inc
new file mode 100644
index 00000000..ecfc0d8f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/unique_sec.inc
@@ -0,0 +1,198 @@
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+
+eval CREATE TABLE t1 (id1 INT NOT NULL, id2 INT NOT NULL, id3 VARCHAR(32),
+ id4 INT, id5 VARCHAR(32),
+ value1 INT, value2 INT, value3 VARCHAR(32),
+ PRIMARY KEY (id1, id2) $CF,
+ UNIQUE INDEX (id2, id1) $CF,
+ UNIQUE INDEX (id2, id3, id4) $CF,
+ INDEX (id1) $CF,
+ INDEX (id3, id1) $CF,
+ UNIQUE INDEX(id5) $CF,
+ INDEX (id2, id5)) ENGINE=ROCKSDB;
+
+--disable_query_log
+let $max = 10;
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO t1 VALUES ($i, $i, $i, $i, $i, $i, $i, $i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+SELECT COUNT(*) FROM t1;
+
+--echo # Test inserting a key that returns duplicate error
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (1, 1, 11, 11, 11, 11, 11, 11);
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (5, 5, 11, 11, 11, 11, 11, 11);
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (10, 10, 11, 11, 11, 11, 11, 11);
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (11, 1, 1, 1, 11, 11, 11, 11);
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (11, 5, 5, 5, 11, 11, 11, 11);
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (11, 10, 10, 10, 11, 11, 11, 11);
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (11, 11, 11, 11, 1, 11, 11, 11);
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (11, 11, 11, 11, 5, 11, 11, 11);
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (11, 11, 11, 11, 10, 11, 11, 11);
+
+--echo # Test updating a key that returns duplicate error
+--error ER_DUP_ENTRY
+UPDATE t1 SET id2=1, id3=1, id4=1 WHERE id1=2;
+--error ER_DUP_ENTRY
+UPDATE t1 SET id2=1, id3=1, id4=1;
+
+SELECT COUNT(*) FROM t1;
+
+--echo # Test updating a key to itself
+UPDATE t1 set id2=id4;
+UPDATE t1 set id5=id3, value1=value2;
+UPDATE t1 set value3=value1;
+
+--echo # Test modifying values should not cause duplicates
+UPDATE t1 SET value1=value3+1;
+UPDATE t1 SET value3=value3 div 2;
+UPDATE t1 SET value2=value3;
+
+SELECT COUNT(*) FROM t1;
+
+--echo # Test NULL values are considered unique
+INSERT INTO t1 VALUES (20, 20, 20, NULL, NULL, 20, 20, 20);
+INSERT INTO t1 VALUES (21, 20, 20, NULL, NULL, 20, 20, 20);
+INSERT INTO t1 VALUES (22, 20, 20, NULL, NULL, 20, 20, 20);
+
+SELECT COUNT(*) FROM t1;
+
+--echo # Adding multiple rows where one of the rows fail the duplicate
+--echo # check should fail the whole statement
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (23, 23, 23, 23, 23, 23, 23, 23),
+ (24, 24, 24, 24, 24, 24, 24, 24),
+ (25, 10, 10, 10, 25, 25, 25, 25),
+ (26, 26, 26, 26, 26, 26, 26, 26);
+SELECT COUNT(*) FROM t1;
+
+# Test open transactions can prevent duplicate keys
+connection con1;
+BEGIN;
+INSERT INTO t1 VALUES (30, 31, 32, 33, 34, 30, 30, 30);
+
+connection con2;
+BEGIN;
+
+SELECT COUNT(*) FROM t1;
+
+--echo # Primary key should prevent duplicate on insert
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 VALUES (30, 31, 30, 30, 30, 30, 30, 30);
+
+--echo # Primary key should prevent duplicate on update
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE t1 SET id1=30, id2=31 WHERE id2=10;
+
+--echo # Unique secondary key should prevent duplicate on insert
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 VALUES (31, 31, 32, 33, 30, 30, 30, 30);
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 VALUES (32, 32, 32, 32, 34, 32, 32, 32);
+
+--echo # Unique secondary key should prevent duplicate on update
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE t1 SET id2=31, id3=32, id4=33 WHERE id2=8;
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE t1 SET id5=34 WHERE id2=8;
+
+--echo # Adding multiple rows where one of the rows fail the duplicate
+--echo # check should fail the whole statement
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 VALUES (35, 35, 35, 35, 35, 35, 35, 35),
+ (36, 36, 36, 36, 36, 36, 36, 36),
+ (37, 31, 32, 33, 37, 37, 37, 37),
+ (38, 38, 38, 38, 38, 38, 38, 38);
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 VALUES (35, 35, 35, 35, 35, 35, 35, 35),
+ (36, 36, 36, 36, 36, 36, 36, 36),
+ (37, 37, 37, 37, 34, 37, 37, 37),
+ (38, 38, 38, 38, 38, 38, 38, 38);
+
+--echo # NULL values are unique and duplicates in value fields are ignored
+INSERT INTO t1 VALUES (37, 31, 32, NULL, 37, 37, 37, 37),
+ (38, 31, 32, NULL, 38, 37, 37, 37),
+ (39, 31, 32, NULL, 39, 37, 37, 37);
+
+SELECT COUNT(*) FROM t1;
+
+--echo # Fail on duplicate key update for row added in our transaction
+--error ER_DUP_ENTRY
+UPDATE t1 SET id5=37 WHERE id1=38;
+
+--echo # Fail on lock timeout for row modified in another transaction
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE t1 SET id5=34 WHERE id1=38;
+
+--echo # NULL values are unique
+UPDATE t1 SET id5=NULL WHERE value1 > 37;
+
+connection con1;
+COMMIT;
+
+connection con2;
+COMMIT;
+
+# Test transaction is reading from latest data
+connection con2;
+BEGIN;
+SELECT COUNT(*) FROM t1;
+
+connection con1;
+BEGIN;
+INSERT INTO t1 VALUES (40, 40, 40, 40, 40, 40, 40, 40);
+
+connection con2;
+--echo # When transaction is pending, fail on lock acquisition
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 VALUES (40, 40, 40, 40, 40, 40, 40, 40);
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 VALUES (41, 40, 40, 40, 40, 40, 40, 40);
+
+SELECT COUNT(*) FROM t1;
+
+connection con1;
+COMMIT;
+
+connection con2;
+--echo # When transaction is committed, fail on duplicate key
+--error ER_DUP_ENTRY,ER_LOCK_DEADLOCK
+INSERT INTO t1 VALUES (40, 40, 40, 40, 40, 40, 40, 40);
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (41, 40, 40, 40, 40, 40, 40, 40);
+
+ROLLBACK;
+
+SELECT * FROM t1;
+
+disconnect con1;
+disconnect con2;
+
+connection default;
+DROP TABLE t1;
+
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/unique_sec.test b/storage/rocksdb/mysql-test/rocksdb/t/unique_sec.test
new file mode 100644
index 00000000..1dedd75f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/unique_sec.test
@@ -0,0 +1,51 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+--let $CF=
+--source unique_sec.inc
+
+--echo #
+--echo # Issue #88: Creating unique index over column with duplicate values succeeds
+--echo #
+create table t1 (pk int primary key, a int) engine=rocksdb;
+
+insert into t1 values
+(1, 1),
+(2, 2),
+(3, 3),
+(4, 1),
+(5, 5);
+
+--error ER_DUP_ENTRY
+alter table t1 add unique(a);
+drop table t1;
+
+--echo #
+--echo # Issue #111
+--echo #
+CREATE TABLE t2 (pk int, a int, PRIMARY KEY (pk, a), UNIQUE KEY (a)) ENGINE=ROCKSDB PARTITION BY KEY (a) PARTITIONS 16;
+
+INSERT INTO t2 VALUES (1,1);
+--error ER_DUP_ENTRY
+INSERT INTO t2 VALUES (1,1);
+--error ER_DUP_ENTRY
+INSERT INTO t2 VALUES (2,1);
+DROP TABLE t2;
+
+--echo #
+--echo # Issue #491 (https://github.com/facebook/mysql-5.6/issues/491)
+--echo #
+CREATE TABLE t (a BLOB, PRIMARY KEY(a(2)), UNIQUE KEY (a(1))) engine=rocksdb;
+INSERT INTO t VALUES('a');
+CHECK TABLE t EXTENDED;
+DROP TABLE t;
+
+CREATE TABLE t (a VARCHAR(255), PRIMARY KEY(a), UNIQUE KEY (a(1))) engine=rocksdb;
+INSERT INTO t VALUES('a');
+CHECK TABLE t EXTENDED;
+DROP TABLE t;
+
+CREATE TABLE t (a VARCHAR(255), PRIMARY KEY(a(2)), UNIQUE KEY (a(1))) engine=rocksdb;
+INSERT INTO t VALUES('a');
+CHECK TABLE t EXTENDED;
+DROP TABLE t;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/unique_sec_rev_cf.test b/storage/rocksdb/mysql-test/rocksdb/t/unique_sec_rev_cf.test
new file mode 100644
index 00000000..dc0bbd8e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/unique_sec_rev_cf.test
@@ -0,0 +1,4 @@
+--source include/have_rocksdb.inc
+
+let $CF=COMMENT 'rev:cf';
+--source unique_sec.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/unsupported_tx_isolations.test b/storage/rocksdb/mysql-test/rocksdb/t/unsupported_tx_isolations.test
new file mode 100644
index 00000000..a15e5d2a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/unsupported_tx_isolations.test
@@ -0,0 +1,25 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+create table t1 (id int primary key, value int) engine=rocksdb;
+insert into t1 values (1,1);
+
+SET session transaction isolation level read uncommitted;
+begin;
+--error ER_ISOLATION_MODE_NOT_SUPPORTED
+insert into t1 values (2,1);
+--error ER_ISOLATION_MODE_NOT_SUPPORTED
+select * from t1 where id=1;
+rollback;
+
+SET session transaction isolation level serializable;
+begin;
+--error ER_ISOLATION_MODE_NOT_SUPPORTED
+insert into t1 values (2,1);
+--error ER_ISOLATION_MODE_NOT_SUPPORTED
+select * from t1 where id=1;
+rollback;
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/update.test b/storage/rocksdb/mysql-test/rocksdb/t/update.test
new file mode 100644
index 00000000..6220c4f5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/update.test
@@ -0,0 +1,82 @@
+--source include/have_rocksdb.inc
+
+#
+# Basic UPDATE statements.
+# UPDATE LOW_PRIORITY is covered in update_low_prio test
+# UPDATE IGNORE is covered in update_ignore test
+# Multi-table update is covered in update_multi test
+#
+
+########################################
+# TODO:
+# The results of the transactional part
+# are unusual due to "can't-see-own-changes"
+########################################
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+
+UPDATE t1 SET a=a+100;
+--sorted_result
+SELECT a,b FROM t1;
+
+UPDATE t1 SET a=a-100, b=DEFAULT WHERE a>100;
+--sorted_result
+SELECT a,b FROM t1;
+
+# ORDER BY and LIMIT
+UPDATE t1 SET b = 'update' WHERE a <= 4 ORDER BY b DESC, a ASC LIMIT 1;
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+#
+# Transactional UPDATE
+#
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+
+BEGIN;
+UPDATE t1 SET a=a+100;
+UPDATE t1 SET a=a-50, b=DEFAULT WHERE a>100;
+COMMIT;
+--sorted_result
+SELECT * FROM t1 ORDER BY pk;
+
+BEGIN;
+UPDATE t1 SET b = 'update' WHERE a <= 4 ORDER BY a DESC, b ASC LIMIT 3;
+UPDATE t1 SET b = '';
+ROLLBACK;
+SELECT * FROM t1 ORDER BY pk;
+
+BEGIN;
+UPDATE t1 SET b = 'update2' WHERE a <= 100;
+SAVEPOINT spt1;
+UPDATE t1 SET b = '';
+--error ER_ROLLBACK_TO_SAVEPOINT
+ROLLBACK TO SAVEPOINT spt1;
+UPDATE t1 SET b = 'upd' WHERE a = 10050;
+--error ER_ROLLBACK_ONLY
+COMMIT;
+SELECT * FROM t1 ORDER BY pk;
+
+DROP TABLE t1;
+
+
+#
+# Issue #830 UPDATE with unique constraint does not work
+#
+
+CREATE TABLE t1 (a INT, b CHAR(8), UNIQUE INDEX(a)) ENGINE=RocksDB;
+INSERT INTO t1 (a,b) VALUES (1,'foo'),(2,'bar');
+UPDATE t1 SET a=a+100;
+SELECT * FROM t1;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/update_ignore-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/update_ignore-master.opt
new file mode 100644
index 00000000..ba9364e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/update_ignore-master.opt
@@ -0,0 +1 @@
+--rocksdb_debug_optimizer_n_rows=1000
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/update_ignore.test b/storage/rocksdb/mysql-test/rocksdb/t/update_ignore.test
new file mode 100644
index 00000000..0208e1b3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/update_ignore.test
@@ -0,0 +1,35 @@
+--source include/have_rocksdb.inc
+
+#
+# UPDATE IGNORE
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+
+CREATE TABLE t2 (c CHAR(8), d INT, pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
+
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+
+UPDATE IGNORE t1 SET b = 'upd1' WHERE b IS NOT NULL ORDER BY a LIMIT 1;
+SELECT a,b FROM t1 ORDER BY pk;
+
+--error ER_SUBQUERY_NO_1_ROW
+UPDATE t1, t2 SET b = 'upd2a', c = 'upd2b'
+ WHERE c < b OR a != ( SELECT 1 UNION SELECT 2 );
+
+UPDATE IGNORE t1, t2 SET b = 'upd2a', c = 'upd2b'
+ WHERE c < b OR a != ( SELECT 1 UNION SELECT 2 );
+
+SELECT a,b FROM t1 ORDER BY pk;
+SELECT c,d FROM t2 ORDER BY pk;
+
+# Cleanup
+DROP TABLE t1, t2;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/update_multi.test b/storage/rocksdb/mysql-test/rocksdb/t/update_multi.test
new file mode 100644
index 00000000..1cb2f128
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/update_multi.test
@@ -0,0 +1,15 @@
+--source include/have_rocksdb.inc
+
+#
+# Multi-table UPDATE statements.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+let $i= 0;
+while ($i < 10) {
+ --source update_multi_exec.inc
+ inc $i;
+}
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/update_multi_exec.inc b/storage/rocksdb/mysql-test/rocksdb/t/update_multi_exec.inc
new file mode 100644
index 00000000..40d73669
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/update_multi_exec.inc
@@ -0,0 +1,27 @@
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES
+(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+
+CREATE TABLE t2 (c CHAR(8), d INT, pk INT AUTO_INCREMENT
+PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+
+UPDATE t1 STRAIGHT_JOIN t2 SET t1.a = t2.d+100, t2.c = 'multi'
+WHERE c < b AND a + d != 1;
+--sorted_result
+SELECT a,b FROM t1;
+--sorted_result
+SELECT c,d FROM t2;
+
+UPDATE t2 STRAIGHT_JOIN t1 SET t2.d = DEFAULT
+WHERE c = 'foobar' and b = c;
+--sorted_result
+SELECT a,b FROM t1;
+--sorted_result
+SELECT c,d FROM t2;
+
+# Cleanup
+DROP TABLE t1, t2;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/update_with_keys.test b/storage/rocksdb/mysql-test/rocksdb/t/update_with_keys.test
new file mode 100644
index 00000000..c53eb9be
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/update_with_keys.test
@@ -0,0 +1,78 @@
+--source include/have_rocksdb.inc
+
+#
+# UPDATE statements for tables with keys
+#
+
+#############################################
+# TODO:
+# The test doesn't work quite as expected,
+# apparently due to "can't see own changes"
+#############################################
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, INDEX(b)) ENGINE=rocksdb;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
+UPDATE t1 SET a=100, b='f' WHERE b IN ('b','c');
+UPDATE t1 SET b='m' WHERE b = 'f';
+UPDATE t1 SET b='z' WHERE a < 2;
+UPDATE t1 SET b='';
+--sorted_result
+SELECT a,b FROM t1;
+DROP TABLE t1;
+
+--echo # RocksDB: skip the test for secondary UNIQUE keys.
+--disable_parsing
+--error ER_GET_ERRMSG
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, UNIQUE INDEX(a)) ENGINE=innodb;
+
+
+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;
+--error ER_DUP_ENTRY
+UPDATE t1 SET a=205 WHERE a=200;
+UPDATE t1 SET a=12345 ORDER BY a, b LIMIT 1;
+--sorted_result
+SELECT a,b FROM t1;
+
+--error ER_DUP_ENTRY
+UPDATE t1 SET a=80 WHERE a IN (202,203);
+--sorted_result
+SELECT a,b FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY, UNIQUE INDEX(a,b)) ENGINE=rocksdb;
+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;
+--error ER_DUP_ENTRY
+UPDATE t1 SET a=100 WHERE a=1;
+--error ER_DUP_ENTRY
+UPDATE t1 SET a=4, b='d' WHERE b='f';
+UPDATE t1 SET a=a+1;
+--sorted_result
+SELECT a,b FROM t1;
+--error ER_DUP_ENTRY
+UPDATE t1 SET b='z';
+DROP TABLE t1;
+
+--enable_parsing
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+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;
+--error ER_DUP_ENTRY
+UPDATE t1 SET a=205 WHERE a=200;
+UPDATE t1 SET a=12345 ORDER BY a DESC, b LIMIT 1;
+
+--sorted_result
+SELECT a,b FROM t1;
+
+--error ER_DUP_ENTRY
+UPDATE t1 SET a=80 WHERE a IN (202,203);
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/use_direct_io_for_flush_and_compaction.test b/storage/rocksdb/mysql-test/rocksdb/t/use_direct_io_for_flush_and_compaction.test
new file mode 100644
index 00000000..782e2a36
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/use_direct_io_for_flush_and_compaction.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+
+--let $io_option=--rocksdb_use_direct_io_for_flush_and_compaction=1
+
+--source ../include/use_direct_io_option.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/use_direct_reads.test b/storage/rocksdb/mysql-test/rocksdb/t/use_direct_reads.test
new file mode 100644
index 00000000..a1b717e8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/use_direct_reads.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+
+--let $io_option=--rocksdb_use_direct_reads=1
+
+--source ../include/use_direct_io_option.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/use_direct_reads_writes.test b/storage/rocksdb/mysql-test/rocksdb/t/use_direct_reads_writes.test
new file mode 100644
index 00000000..53ba5161
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/use_direct_reads_writes.test
@@ -0,0 +1,62 @@
+--source include/have_rocksdb.inc
+--source include/have_direct_io.inc
+
+call mtr.add_suppression("rocksdb");
+call mtr.add_suppression("Aborting");
+
+--echo # This shows that RocksDB plugin is loaded:
+select plugin_name, plugin_type from information_schema.plugins where plugin_name='RocksDB';
+
+# Issue221
+# Turning on both --rocksdb-allow-mmap-reads and --rocksdb-use-direct-reads
+# caused an assertion in RocksDB. Now it should not be allowed and ROCKSDB
+# plugin will not load in such configuration.
+#
+--let LOG=$MYSQLTEST_VARDIR/tmp/use_direct_reads_writes.err
+--let SEARCH_FILE=$LOG
+
+--echo Checking direct reads
+--let $_mysqld_option=--log-error=$LOG --rocksdb_use_direct_reads=1 --rocksdb_allow_mmap_reads=1
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--source include/restart_mysqld_with_invalid_option.inc
+
+--let SEARCH_PATTERN=enable both use_direct_reads
+--source include/search_pattern_in_file.inc
+--remove_file $LOG
+
+
+# Repeat with direct-writes
+--echo Checking direct writes
+--let $_mysqld_option=--log-error=$LOG --rocksdb_use_direct_io_for_flush_and_compaction=1 --rocksdb_allow_mmap_writes=1
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--source include/restart_mysqld_with_invalid_option.inc
+
+--let SEARCH_PATTERN=enable both use_direct_io_for_flush_and_compaction
+--source include/search_pattern_in_file.inc
+--remove_file $LOG
+
+
+# Verify invalid direct-writes and --rocksdb_flush_log_at_trx_commit combination at startup fails
+--echo Checking rocksdb_flush_log_at_trx_commit
+--let $_mysqld_option=--log-error=$LOG --rocksdb_flush_log_at_trx_commit=1 --rocksdb_allow_mmap_writes=1
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--source include/restart_mysqld_with_invalid_option.inc
+
+--let SEARCH_PATTERN=rocksdb_flush_log_at_trx_commit needs to be
+--source include/search_pattern_in_file.inc
+--remove_file $LOG
+
+
+# Verify rocksdb_flush_log_at_trx_commit cannot be changed if direct writes are used
+--echo Validate flush_log settings when direct writes is enabled
+--let $_mysqld_option=--rocksdb_flush_log_at_trx_commit=0 --rocksdb_allow_mmap_writes=1
+--source include/restart_mysqld_with_option.inc
+
+set global rocksdb_flush_log_at_trx_commit=0;
+--error ER_WRONG_VALUE_FOR_VAR
+set global rocksdb_flush_log_at_trx_commit=1;
+--error ER_WRONG_VALUE_FOR_VAR
+set global rocksdb_flush_log_at_trx_commit=2;
+
+# Cleanup
+--source include/restart_mysqld.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/validate_datadic.test b/storage/rocksdb/mysql-test/rocksdb/t/validate_datadic.test
new file mode 100644
index 00000000..e7ab37d2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/validate_datadic.test
@@ -0,0 +1,108 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+#
+# Validate that the server starts when everything is okay, but detects errors
+# if a table exists in the data dictionary but not as an .frm or vice versa.
+# The default mode causes these failures to keep the server from starting, but
+# this is problematic for the test as a server start failure is not easily
+# trappable. Instead use the mode where it will detect the problem and report
+# it in the log bug still start: --rocksdb_validate_tables=2
+#
+
+call mtr.add_suppression('RocksDB: Schema mismatch');
+
+CREATE TABLE t1 (pk int primary key) ENGINE=ROCKSDB;
+CREATE TABLE t2 (pk int primary key) ENGINE=ROCKSDB PARTITION BY KEY(pk) PARTITIONS 4;
+
+# Write file to make mysql-test-run.pl expect the "crash", but don't restart the
+# server until it is told to
+--let $_server_id= `SELECT @@server_id`
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
+--let LOG=$MYSQLTEST_VARDIR/tmp/validate_datadic.err
+
+--exec echo "wait" >$_expect_file_name
+
+# Send shutdown to the connected server and give it 10 seconds to die before
+# zapping it
+shutdown_server;
+
+# Write file to make mysql-test-run.pl start up the server again
+--exec echo "restart" >$_expect_file_name
+--sleep 5
+
+# Turn on reconnect
+--enable_reconnect
+
+# Call script that will poll the server waiting for it to be back online again
+--source include/wait_until_connected_again.inc
+
+# Turn off reconnect again
+--disable_reconnect
+
+# Now shut down again and rename one of the .frm files
+--exec echo "wait" >$_expect_file_name
+shutdown_server;
+
+# Rename the file
+--move_file $MYSQLTEST_VARDIR/mysqld.1/data/test/t1.frm $MYSQLTEST_VARDIR/mysqld.1/data/test/t1.frm.tmp
+--move_file $MYSQLTEST_VARDIR/mysqld.1/data/test/t2.frm $MYSQLTEST_VARDIR/mysqld.1/data/test/t2.frm.tmp
+
+# Attempt to restart the server
+--exec echo "restart:--rocksdb_validate_tables=2 --log-error=$LOG" >$_expect_file_name
+
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+
+# We should now have an error message
+--echo "Expect errors that we are missing two .frm files"
+#--let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err
+#--let SEARCH_PATTERN=Schema mismatch
+#--source include/search_pattern_in_file.inc
+#--let SEARCH_PATTERN=RocksDB: Schema mismatch - Table test.t2 is registered in RocksDB but does not have a .frm file
+#--source include/search_pattern_in_file.inc
+--let SEARCH_FILE=$LOG
+--let SEARCH_PATTERN=RocksDB: Schema mismatch - Table test.t1 is registered in RocksDB but does not have a .frm file
+--source include/search_pattern_in_file.inc
+--let SEARCH_PATTERN=RocksDB: Schema mismatch - Table test.t2 is registered in RocksDB but does not have a .frm file
+--source include/search_pattern_in_file.inc
+
+# Now shut down again and rename one the .frm file back and make a copy of it
+--exec echo "wait" >$_expect_file_name
+shutdown_server;
+--remove_file $LOG
+# Rename the file
+--move_file $MYSQLTEST_VARDIR/mysqld.1/data/test/t1.frm.tmp $MYSQLTEST_VARDIR/mysqld.1/data/test/t1.frm
+--move_file $MYSQLTEST_VARDIR/mysqld.1/data/test/t2.frm.tmp $MYSQLTEST_VARDIR/mysqld.1/data/test/t2.frm
+--copy_file $MYSQLTEST_VARDIR/mysqld.1/data/test/t1.frm $MYSQLTEST_VARDIR/mysqld.1/data/test/t1_dummy.frm
+
+# Attempt to restart the server
+--exec echo "restart:--rocksdb_validate_tables=2 --log-error=$LOG" >$_expect_file_name
+
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+
+# We should now have an error message for the second case
+--echo "Expect an error that we have an extra .frm file"
+--let SEARCH_FILE=$LOG
+--let SEARCH_PATTERN=Schema mismatch - A .frm file exists for table test.t1_dummy, but that table is not registered in RocksDB
+--source include/search_pattern_in_file.inc
+
+# Shut down an clean up
+--exec echo "wait" >$_expect_file_name
+shutdown_server;
+--remove_file $MYSQLTEST_VARDIR/mysqld.1/data/test/t1_dummy.frm
+--exec echo "restart" >$_expect_file_name
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+
+# Remove log file
+--remove_file $LOG
+
+--disable_warnings
+DROP TABLE t1, t2;
+--enable_warnings
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/varbinary_format.test b/storage/rocksdb/mysql-test/rocksdb/t/varbinary_format.test
new file mode 100644
index 00000000..d10082bb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/varbinary_format.test
@@ -0,0 +1,131 @@
+--source include/have_debug.inc
+--source include/have_rocksdb.inc
+
+# Create a table with a varbinary key with the current format and validate
+# that it sorts correctly
+CREATE TABLE t1(
+ vb VARBINARY(64) primary key
+) ENGINE=rocksdb;
+
+INSERT INTO t1 values(0x00);
+INSERT INTO t1 values(0x0000);
+INSERT INTO t1 values(0x0000000000000000);
+INSERT INTO t1 values(0x000000);
+INSERT INTO t1 values(0x000000000000000000000000000000000000000000000000000000000000000000);
+INSERT INTO t1 values(0x00000000000000000000000000000000000000000000000000000000000000);
+INSERT INTO t1 values(0x0000000000000000000000000000000000000000000000000000000000000000);
+INSERT INTO t1 values(0x00000000);
+INSERT INTO t1 values(0x0000000000);
+INSERT INTO t1 values(0x00000000000000000000);
+INSERT INTO t1 values(0x000000000000);
+INSERT INTO t1 values(0x00000000000000);
+INSERT INTO t1 values(0x000000000000000000);
+
+SELECT hex(vb) FROM t1;
+
+# Use the fact that the rocksdb_locks shows the keys as they are encoded to
+# validate that the keys were encoded as expected
+BEGIN;
+SELECT hex(vb) FROM t1 FOR UPDATE;
+SELECT SUBSTRING(a.key,9) FROM information_schema.rocksdb_locks AS a ORDER BY a.key;
+ROLLBACK;
+
+DROP TABLE t1;
+
+# Now create the same table in the old format to show that they can be read
+# and handled correctly
+set session debug_dbug= '+d,MYROCKS_LEGACY_VARBINARY_FORMAT';
+CREATE TABLE t1(
+ vb VARBINARY(64) primary key
+) ENGINE=rocksdb;
+set session debug_dbug= '-d,MYROCKS_LEGACY_VARBINARY_FORMAT';
+
+INSERT INTO t1 values(0x00);
+INSERT INTO t1 values(0x0000);
+INSERT INTO t1 values(0x0000000000000000);
+INSERT INTO t1 values(0x000000);
+INSERT INTO t1 values(0x000000000000000000000000000000000000000000000000000000000000000000);
+INSERT INTO t1 values(0x00000000000000000000000000000000000000000000000000000000000000);
+INSERT INTO t1 values(0x0000000000000000000000000000000000000000000000000000000000000000);
+INSERT INTO t1 values(0x00000000);
+INSERT INTO t1 values(0x0000000000);
+INSERT INTO t1 values(0x00000000000000000000);
+INSERT INTO t1 values(0x000000000000);
+INSERT INTO t1 values(0x00000000000000);
+INSERT INTO t1 values(0x000000000000000000);
+
+SELECT hex(vb) FROM t1;
+
+# Use the fact that the rocksdb_locks shows the keys as they are encoded to
+# validate that the keys were encoded as expected
+BEGIN;
+SELECT hex(vb) FROM t1 FOR UPDATE;
+SELECT SUBSTRING(a.key,9) FROM information_schema.rocksdb_locks AS a ORDER BY a.key;
+ROLLBACK;
+
+DROP TABLE t1;
+
+# Now create a table with a varchar key using a binary collation with the
+# current format and validate that it sorts correctly
+CREATE TABLE t1(
+ vc VARCHAR(64) collate 'binary' primary key
+) ENGINE=rocksdb;
+
+INSERT INTO t1 values('a');
+INSERT INTO t1 values('aa');
+INSERT INTO t1 values('aaaaaaaa');
+INSERT INTO t1 values('aaa');
+INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+INSERT INTO t1 values('aaaa');
+INSERT INTO t1 values('aaaaa');
+INSERT INTO t1 values('aaaaaaaaaa');
+INSERT INTO t1 values('aaaaaa');
+INSERT INTO t1 values('aaaaaaa');
+INSERT INTO t1 values('aaaaaaaaa');
+
+SELECT * FROM t1;
+
+# Use the fact that the rocksdb_locks shows the keys as they are encoded to
+# validate that the keys were encoded as expected
+BEGIN;
+SELECT * FROM t1 FOR UPDATE;
+SELECT SUBSTRING(a.key,9) FROM information_schema.rocksdb_locks AS a ORDER BY a.key;
+ROLLBACK;
+
+DROP TABLE t1;
+
+# Now create the same table in the old format to show that they can be read
+# and handled correctly
+set session debug_dbug= '+d,MYROCKS_LEGACY_VARBINARY_FORMAT';
+CREATE TABLE t1(
+ vc VARCHAR(64) collate 'binary' primary key
+) ENGINE=rocksdb;
+set session debug_dbug= '-d,MYROCKS_LEGACY_VARBINARY_FORMAT';
+
+INSERT INTO t1 values('a');
+INSERT INTO t1 values('aa');
+INSERT INTO t1 values('aaaaaaaa');
+INSERT INTO t1 values('aaa');
+INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+INSERT INTO t1 values('aaaa');
+INSERT INTO t1 values('aaaaa');
+INSERT INTO t1 values('aaaaaaaaaa');
+INSERT INTO t1 values('aaaaaa');
+INSERT INTO t1 values('aaaaaaa');
+INSERT INTO t1 values('aaaaaaaaa');
+
+SELECT * FROM t1;
+
+# Use the fact that the rocksdb_locks shows the keys as they are encoded to
+# validate that the keys were encoded as expected
+BEGIN;
+SELECT * FROM t1 FOR UPDATE;
+SELECT SUBSTRING(a.key,9) FROM information_schema.rocksdb_locks AS a ORDER BY a.key;
+ROLLBACK;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/write_sync.test b/storage/rocksdb/mysql-test/rocksdb/t/write_sync.test
new file mode 100644
index 00000000..7c30d4fc
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/write_sync.test
@@ -0,0 +1,41 @@
+--source include/have_rocksdb.inc
+
+SET GLOBAL rocksdb_write_disable_wal=false;
+SET GLOBAL rocksdb_write_ignore_missing_column_families=true;
+
+create table aaa (id int primary key, i int) engine rocksdb;
+set @save_rocksdb_flush_log_at_trx_commit=@@global.rocksdb_flush_log_at_trx_commit;
+SET GLOBAL rocksdb_flush_log_at_trx_commit=1;
+insert aaa(id, i) values(0,1);
+
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_wal_synced';
+insert aaa(id, i) values(1,1);
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
+insert aaa(id, i) values(2,1);
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
+insert aaa(id, i) values(3,1);
+select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
+
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_wal_synced';
+SET GLOBAL rocksdb_flush_log_at_trx_commit=0;
+insert aaa(id, i) values(4,1);
+
+let $status_var=rocksdb_wal_synced;
+let $status_var_value=`select @a+1`;
+source include/wait_for_status_var.inc;
+
+select variable_value into @a from information_schema.global_status where variable_name='rocksdb_wal_synced';
+SET GLOBAL rocksdb_flush_log_at_trx_commit=2;
+insert aaa(id, i) values(5,1);
+
+let $status_var=rocksdb_wal_synced;
+let $status_var_value=`select @a+1`;
+source include/wait_for_status_var.inc;
+
+truncate table aaa;
+
+# Cleanup
+drop table aaa;
+set @@global.rocksdb_flush_log_at_trx_commit=@save_rocksdb_flush_log_at_trx_commit;
+SET GLOBAL rocksdb_write_disable_wal=false;
+SET GLOBAL rocksdb_write_ignore_missing_column_families=false;
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/xa-master.opt b/storage/rocksdb/mysql-test/rocksdb/t/xa-master.opt
new file mode 100644
index 00000000..70c12060
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/xa-master.opt
@@ -0,0 +1 @@
+--rocksdb_flush_log_at_trx_commit=1
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/xa.test b/storage/rocksdb/mysql-test/rocksdb/t/xa.test
new file mode 100644
index 00000000..0c23e71d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/xa.test
@@ -0,0 +1,73 @@
+--echo #
+--echo # MDEV-742 fixes
+--echo # MDEV-13155: XA recovery not supported for RocksDB
+--echo # as well.
+
+call mtr.add_suppression("Found .* prepared XA transactions");
+
+--connect (con1,localhost,root,,test)
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT) ENGINE=RocksDB;
+
+XA START 'xa1';
+INSERT INTO t1 (a) VALUES (1),(2);
+XA END 'xa1';
+XA PREPARE 'xa1';
+
+--connect (con2,localhost,root,,test)
+XA START 'xa2';
+INSERT INTO t1 (a) VALUES (3);
+INSERT INTO t1 (a) VALUES (4);
+XA END 'xa2';
+XA PREPARE 'xa2';
+
+--connect (con3,localhost,root,,test)
+XA START 'xa3';
+INSERT INTO t1 (a) VALUES (5);
+INSERT INTO t1 (a) VALUES (6);
+XA END 'xa3';
+XA PREPARE 'xa3';
+--disconnect con3
+
+--connection default
+SELECT * FROM t1;
+
+--echo Must be all three XA:s in
+XA RECOVER;
+
+--let $shutdown_timeout= 0
+--source include/restart_mysqld.inc
+
+--connect (con3,localhost,root,,test)
+--disable_abort_on_error
+XA RECOVER; # like above
+XA ROLLBACK 'xa1';
+XA COMMIT 'xa2';
+XA ROLLBACK 'xa3';
+SELECT a FROM t1;
+
+--connect (con4,localhost,root,,test)
+XA START 'xa4';
+INSERT INTO t1 (a) VALUES (7);
+INSERT INTO t1 (a) VALUES (8);
+XA END 'xa4';
+XA PREPARE 'xa4';
+
+--connection default
+--echo # Now restart through graceful shutdown
+--source include/restart_mysqld.inc
+
+
+--connect (con5,localhost,root,,test)
+--disable_abort_on_error
+
+--echo Must have 'xa4'
+XA RECOVER;
+XA COMMIT 'xa4';
+
+SELECT a FROM t1;
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/base.cnf b/storage/rocksdb/mysql-test/rocksdb_hotbackup/base.cnf
new file mode 100644
index 00000000..101dbce2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/base.cnf
@@ -0,0 +1,25 @@
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+!include include/default_client.cnf
+
+[mysqld.1]
+rocksdb
+default-storage-engine=rocksdb
+skip-innodb
+default-tmp-storage-engine=MyISAM
+binlog_format=row
+
+[mysqld.2]
+rocksdb
+default-storage-engine=rocksdb
+skip-innodb
+default-tmp-storage-engine=MyISAM
+binlog_format=row
+
+[ENV]
+MASTER_MYPORT= @mysqld.1.port
+MASTER_MYSOCK= @mysqld.1.socket
+
+SLAVE_MYPORT= @mysqld.2.port
+SLAVE_MYSOCK= @mysqld.2.socket
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/clean_tmpfiles.sh b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/clean_tmpfiles.sh
new file mode 100755
index 00000000..98a1fecc
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/clean_tmpfiles.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+COPY_LOG="${MYSQL_TMP_DIR}/myrocks_hotbackup_copy_log"
+SIGNAL_FILE=${MYSQL_TMP_DIR}/myrocks_hotbackup_signal
+MOVEBACK_LOG="${MYSQL_TMP_DIR}/myrocks_hotbackup_moveback_log"
+rm -f $COPY_LOG
+rm -f $SIGNAL_FILE
+rm -f $MOVEBACK_LOG
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/cleanup.inc b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/cleanup.inc
new file mode 100644
index 00000000..947bf027
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/cleanup.inc
@@ -0,0 +1,3 @@
+
+--source include/rpl_end.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/create_slocket_socket.sh b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/create_slocket_socket.sh
new file mode 100755
index 00000000..db470f52
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/create_slocket_socket.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+src_data_dir="${MYSQLTEST_VARDIR}/mysqld.1/data/"
+python -c "import socket as s; sock = s.socket(s.AF_UNIX); sock.bind('${src_data_dir}/slocket')"
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/create_table.sh b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/create_table.sh
new file mode 100755
index 00000000..2004caca
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/create_table.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+set -e
+
+COPY_LOG=$1
+SIGNAL_FILE=$2
+# Creating a table after myrocks_hotbackup reaches waiting loop
+
+done=0
+while : ; do
+ wait=`tail -1 $COPY_LOG | grep 'Waiting until' | wc -l`
+ if [ "$wait" -eq "1" ]; then
+ break
+ fi
+ sleep 1
+done
+$MYSQL --defaults-group-suffix=.1 db1 -e "create table r10 (id int primary key ) engine=rocksdb"
+touch $SIGNAL_FILE
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/load_data.sh b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/load_data.sh
new file mode 100755
index 00000000..80f1a5e2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/load_data.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+set -e
+
+# Insert 100 batches of 100 records each to a table with following schema:
+# create table db1.t1 (
+# `id` int(10) not null auto_increment,
+# `k` int(10),
+# `data` varchar(2048),
+# primary key (`id`),
+# key (`k`)
+# ) engine=innodb;
+
+MAX_INSERTS=100
+MAX_ROWS_PER_INSERT=100
+
+insertData() {
+ for ((i=1; i<=$MAX_INSERTS; i++));
+ do
+ stmt='INSERT INTO db1.t1 values'
+ for ((j=1; j<=$MAX_ROWS_PER_INSERT; j++));
+ do
+ k=$RANDOM
+ data=$(head -c 2048 /dev/urandom|tr -cd 'a-zA-Z0-9')
+ stmt=$stmt' (NULL, '$k', "'$data'")'
+ if [ $j -lt $MAX_ROWS_PER_INSERT ]; then
+ stmt=$stmt','
+ fi
+ done
+ stmt=$stmt';'
+ $MYSQL --defaults-group-suffix=.1 -e "$stmt"
+ done
+}
+
+NUM_PARALLEL_INSERTS=25
+pids=()
+for ((k=1; k<=$NUM_PARALLEL_INSERTS; k++));
+do
+ insertData &
+ pids+=($!)
+done
+for ((k=1; k<=$NUM_PARALLEL_INSERTS; k++));
+do
+ wait ${pids[k]}
+done
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/load_data_and_run.sh b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/load_data_and_run.sh
new file mode 100755
index 00000000..a8e6fc44
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/load_data_and_run.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+# Initially loads a chunk of data.
+# Then start loading another chunk of data,
+# while simultaneously running a backup
+
+suite/rocksdb_hotbackup/include/load_data.sh 2>&1
+suite/rocksdb_hotbackup/include/load_data.sh 2>&1 &
+suite/rocksdb_hotbackup/include/stream_run.sh 2>&1
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/load_data_slocket.sh b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/load_data_slocket.sh
new file mode 100755
index 00000000..036d6866
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/load_data_slocket.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+set -e
+
+# Insert 10 batches of 10 records each to a table with following schema:
+# create table slocket.t1 (
+# `id` int(10) not null auto_increment,
+# `k` int(10),
+# `data` varchar(2048),
+# primary key (`id`),
+# key (`k`)
+# ) engine=innodb;
+
+MAX_INSERTS=10
+MAX_ROWS_PER_INSERT=10
+
+insertData() {
+ for ((i=1; i<=$MAX_INSERTS; i++));
+ do
+ stmt='INSERT INTO slocket.t1 values'
+ for ((j=1; j<=$MAX_ROWS_PER_INSERT; j++));
+ do
+ k=$RANDOM
+ data=$(head -c 2048 /dev/urandom|tr -cd 'a-zA-Z0-9')
+ stmt=$stmt' (NULL, '$k', "'$data'")'
+ if [ $j -lt $MAX_ROWS_PER_INSERT ]; then
+ stmt=$stmt','
+ fi
+ done
+ stmt=$stmt';'
+ $MYSQL --defaults-group-suffix=.1 -e "$stmt"
+ done
+}
+
+NUM_PARALLEL_INSERTS=25
+pids=()
+for ((k=1; k<=$NUM_PARALLEL_INSERTS; k++));
+do
+ insertData &
+ pids+=($!)
+done
+for ((k=1; k<=$NUM_PARALLEL_INSERTS; k++));
+do
+ wait ${pids[k]}
+done
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/remove_slocket_socket.sh b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/remove_slocket_socket.sh
new file mode 100755
index 00000000..9114629b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/remove_slocket_socket.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+src_data_dir="${MYSQLTEST_VARDIR}/mysqld.1/data/"
+rm "${src_data_dir}/slocket"
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup.inc b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup.inc
new file mode 100644
index 00000000..26c3f2ce
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup.inc
@@ -0,0 +1,16 @@
+--let $rpl_server_count= 2
+--let $rpl_topology= none
+--source include/rpl_init.inc
+--source include/rpl_default_connections.inc
+
+connection server_1;
+create database db1;
+
+create table db1.t1 (
+ `id` int(10) not null auto_increment,
+ `k` int(10),
+ `data` varchar(2048),
+ primary key (`id`),
+ key (`k`)
+) engine=rocksdb;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup_replication_gtid.sh b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup_replication_gtid.sh
new file mode 100755
index 00000000..3c95068a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup_replication_gtid.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+set -e
+
+binlog_line=($(grep -o "Last binlog file position [0-9]*, file name .*\.[0-9]*" ${MYSQLTEST_VARDIR}/log/mysqld.2.err | tail -1))
+binlog_pos=${binlog_line[4]%?}
+binlog_file=${binlog_line[7]}
+
+sql="show gtid_executed in '$binlog_file' from $binlog_pos"
+result=($($MYSQL --defaults-group-suffix=.1 -e "$sql"))
+gtid_executed=${result[1]}
+
+sql="reset master;"
+sql="$sql reset slave;"
+sql="$sql change master to master_host='127.0.0.1', master_port=${MASTER_MYPORT}, master_user='root', master_auto_position=1, master_connect_retry=1;"
+sql="$sql set global gtid_purged='$gtid_executed';"
+sql="$sql start slave;"
+sql="$sql stop slave;"
+sql="$sql change master to master_auto_position=0;"
+sql="$sql start slave;"
+$MYSQL --defaults-group-suffix=.2 -e "$sql"
+echo "$sql" > ${MYSQL_TMP_DIR}/gtid_stmt
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup_replication_gtid_and_sync.inc b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup_replication_gtid_and_sync.inc
new file mode 100644
index 00000000..75dc3196
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup_replication_gtid_and_sync.inc
@@ -0,0 +1,4 @@
+--exec suite/rocksdb_hotbackup/include/setup_replication_gtid.sh
+
+let $slave_sync_timeout = 1800;
+source include/wait_for_slave_to_sync_with_master.inc;
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup_slocket.inc b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup_slocket.inc
new file mode 100644
index 00000000..ce889164
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup_slocket.inc
@@ -0,0 +1,10 @@
+connection server_1;
+create database slocket;
+
+create table slocket.t1 (
+ `id` int(10) not null auto_increment,
+ `k` int(10),
+ `data` varchar(2048),
+ primary key (`id`),
+ key (`k`)
+) engine=rocksdb;
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/stream_run.sh b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/stream_run.sh
new file mode 100755
index 00000000..6108cfbb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/stream_run.sh
@@ -0,0 +1,81 @@
+#!/bin/bash
+
+. suite/rocksdb_hotbackup/include/clean_tmpfiles.sh
+
+if [ "$STREAM_TYPE" == 'wdt' ]; then
+ which wdt >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ # change to tar if wdt is not installed
+ STREAM_TYPE='tar'
+ fi
+fi
+
+set -e
+set -o pipefail
+
+# Takes a full backup from server_1 to server_2
+# using myrocks_hotbackup streaming
+
+checkpoint_dir="${MYSQLTEST_VARDIR}/checkpoint"
+backup_dir="${MYSQLTEST_VARDIR}/backup"
+dest_data_dir="${MYSQLTEST_VARDIR}/mysqld.2/data/"
+
+mysql_dir=$(echo $MYSQL | awk '{print $1}' | xargs dirname)
+PATH=$mysql_dir:$PATH
+
+mkdir -p $checkpoint_dir
+rm -rf $checkpoint_dir/*
+
+mkdir -p $backup_dir
+rm -rf $backup_dir/*
+# delete and recreate the dest dir to make sure all hidden files
+# and directories (such as .rocksdb) are blown away
+rm -rf $dest_data_dir/
+mkdir $dest_data_dir
+
+
+SIGNAL_CONDITION=""
+
+if [ "$FRM" == '1' ]; then
+ suite/rocksdb_hotbackup/include/create_table.sh $COPY_LOG $SIGNAL_FILE 2>&1 &
+fi
+
+if [ "$DEBUG_SIGNAL" == '1' ]; then
+ SIGNAL_CONDITION="--debug_signal_file=$SIGNAL_FILE"
+fi
+
+if [ "$STREAM_TYPE" == 'tar' ]; then
+ BACKUP_CMD="$MYSQL_MYROCKS_HOTBACKUP --user='root' --port=${MASTER_MYPORT} \
+ --stream=tar --checkpoint_dir=$checkpoint_dir $SIGNAL_CONDITION 2> \
+ $COPY_LOG | tar -xi -C $backup_dir"
+elif [ "$STREAM_TYPE" == 'wdt' ]; then
+ BACKUP_CMD="$MYSQL_MYROCKS_HOTBACKUP --user='root' --stream=wdt \
+ --port=${MASTER_MYPORT} --destination=localhost --backup_dir=$backup_dir \
+ --avg_mbytes_per_sec=10 --interval=5 $SIGNAL_CONDITION \
+ --extra_wdt_sender_options='--block_size_mbytes=1' \
+ --checkpoint_dir=$checkpoint_dir 2> \
+ $COPY_LOG"
+elif [ "$STREAM_TYPE" == "xbstream_socket" ]; then
+ BACKUP_CMD="$MYSQL_MYROCKS_HOTBACKUP --user='root' --socket=${MASTER_MYSOCK} \
+ --stream=xbstream --checkpoint_dir=$checkpoint_dir $SIGNAL_CONDITION 2> \
+ $COPY_LOG | xbstream -x \
+ --directory=$backup_dir"
+else
+ BACKUP_CMD="$MYSQL_MYROCKS_HOTBACKUP --user='root' --port=${MASTER_MYPORT} \
+ --stream=xbstream --checkpoint_dir=$checkpoint_dir $SIGNAL_CONDITION 2> \
+ $COPY_LOG | xbstream -x \
+ --directory=$backup_dir"
+fi
+
+echo "myrocks_hotbackup copy phase"
+eval "$BACKUP_CMD"
+
+mkdir ${backup_dir}/test # TODO: Fix skipping empty directories
+
+
+echo "myrocks_hotbackup move-back phase"
+$MYSQL_MYROCKS_HOTBACKUP --move_back --datadir=$dest_data_dir \
+ --rocksdb_datadir=$dest_data_dir/\#rocksdb \
+ --rocksdb_waldir=$dest_data_dir/\#rocksdb \
+ --backup_dir=$backup_dir > $MOVEBACK_LOG 2>&1
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/my.cnf b/storage/rocksdb/mysql-test/rocksdb_hotbackup/my.cnf
new file mode 100644
index 00000000..bd9af04c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/my.cnf
@@ -0,0 +1,2 @@
+# Use settings from xb_base.cnf
+!include base.cnf
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/gtid.result b/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/gtid.result
new file mode 100644
index 00000000..6cec6ca5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/gtid.result
@@ -0,0 +1,23 @@
+include/rpl_init.inc [topology=none]
+include/rpl_default_connections.inc
+create database db1;
+create table db1.t1 (
+`id` int(10) not null auto_increment,
+`k` int(10),
+`data` varchar(2048),
+primary key (`id`),
+key (`k`)
+) engine=rocksdb;
+include/rpl_stop_server.inc [server_number=2]
+myrocks_hotbackup copy phase
+myrocks_hotbackup move-back phase
+include/rpl_start_server.inc [server_number=2]
+stop slave;
+start slave;
+select count(*) from db1.t1;
+count(*)
+500000
+drop database db1;
+stop slave;
+reset slave;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/slocket.result b/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/slocket.result
new file mode 100644
index 00000000..9accd18b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/slocket.result
@@ -0,0 +1,41 @@
+include/rpl_init.inc [topology=none]
+include/rpl_default_connections.inc
+create database db1;
+create table db1.t1 (
+`id` int(10) not null auto_increment,
+`k` int(10),
+`data` varchar(2048),
+primary key (`id`),
+key (`k`)
+) engine=rocksdb;
+create database slocket;
+create table slocket.t1 (
+`id` int(10) not null auto_increment,
+`k` int(10),
+`data` varchar(2048),
+primary key (`id`),
+key (`k`)
+) engine=rocksdb;
+include/rpl_stop_server.inc [server_number=2]
+myrocks_hotbackup copy phase
+myrocks_hotbackup move-back phase
+include/rpl_start_server.inc [server_number=2]
+select count(*) from db1.t1;
+count(*)
+250000
+select count(*) from slocket.t1;
+count(*)
+2500
+drop database slocket;
+drop database db1;
+drop database slocket;
+include/rpl_stop_server.inc [server_number=2]
+myrocks_hotbackup copy phase
+myrocks_hotbackup move-back phase
+include/rpl_start_server.inc [server_number=2]
+select count(*) from db1.t1;
+count(*)
+250000
+drop database db1;
+drop database db1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/stream.result b/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/stream.result
new file mode 100644
index 00000000..d3f2ebc4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/stream.result
@@ -0,0 +1,20 @@
+include/rpl_init.inc [topology=none]
+include/rpl_default_connections.inc
+create database db1;
+create table db1.t1 (
+`id` int(10) not null auto_increment,
+`k` int(10),
+`data` varchar(2048),
+primary key (`id`),
+key (`k`)
+) engine=rocksdb;
+include/rpl_stop_server.inc [server_number=2]
+myrocks_hotbackup copy phase
+myrocks_hotbackup move-back phase
+include/rpl_start_server.inc [server_number=2]
+select count(*) from db1.t1;
+count(*)
+250000
+drop database db1;
+drop database db1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/wdt.result b/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/wdt.result
new file mode 100644
index 00000000..d3f2ebc4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/wdt.result
@@ -0,0 +1,20 @@
+include/rpl_init.inc [topology=none]
+include/rpl_default_connections.inc
+create database db1;
+create table db1.t1 (
+`id` int(10) not null auto_increment,
+`k` int(10),
+`data` varchar(2048),
+primary key (`id`),
+key (`k`)
+) engine=rocksdb;
+include/rpl_stop_server.inc [server_number=2]
+myrocks_hotbackup copy phase
+myrocks_hotbackup move-back phase
+include/rpl_start_server.inc [server_number=2]
+select count(*) from db1.t1;
+count(*)
+250000
+drop database db1;
+drop database db1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/xbstream.result b/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/xbstream.result
new file mode 100644
index 00000000..31ed2677
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/xbstream.result
@@ -0,0 +1,21 @@
+include/rpl_init.inc [topology=none]
+include/rpl_default_connections.inc
+create database db1;
+create table db1.t1 (
+`id` int(10) not null auto_increment,
+`k` int(10),
+`data` varchar(2048),
+primary key (`id`),
+key (`k`)
+) engine=rocksdb;
+include/rpl_stop_server.inc [server_number=2]
+myrocks_hotbackup copy phase
+myrocks_hotbackup copy phase
+myrocks_hotbackup move-back phase
+include/rpl_start_server.inc [server_number=2]
+select count(*) from db1.t1;
+count(*)
+250000
+drop database db1;
+drop database db1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/xbstream_direct.result b/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/xbstream_direct.result
new file mode 100644
index 00000000..31ed2677
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/xbstream_direct.result
@@ -0,0 +1,21 @@
+include/rpl_init.inc [topology=none]
+include/rpl_default_connections.inc
+create database db1;
+create table db1.t1 (
+`id` int(10) not null auto_increment,
+`k` int(10),
+`data` varchar(2048),
+primary key (`id`),
+key (`k`)
+) engine=rocksdb;
+include/rpl_stop_server.inc [server_number=2]
+myrocks_hotbackup copy phase
+myrocks_hotbackup copy phase
+myrocks_hotbackup move-back phase
+include/rpl_start_server.inc [server_number=2]
+select count(*) from db1.t1;
+count(*)
+250000
+drop database db1;
+drop database db1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/xbstream_socket.result b/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/xbstream_socket.result
new file mode 100644
index 00000000..d3f2ebc4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/r/xbstream_socket.result
@@ -0,0 +1,20 @@
+include/rpl_init.inc [topology=none]
+include/rpl_default_connections.inc
+create database db1;
+create table db1.t1 (
+`id` int(10) not null auto_increment,
+`k` int(10),
+`data` varchar(2048),
+primary key (`id`),
+key (`k`)
+) engine=rocksdb;
+include/rpl_stop_server.inc [server_number=2]
+myrocks_hotbackup copy phase
+myrocks_hotbackup move-back phase
+include/rpl_start_server.inc [server_number=2]
+select count(*) from db1.t1;
+count(*)
+250000
+drop database db1;
+drop database db1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/gtid-master.opt b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/gtid-master.opt
new file mode 100644
index 00000000..9d7af67e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/gtid-master.opt
@@ -0,0 +1 @@
+--gtid_mode=on --log_slave_updates=on --enforce_gtid_consistency=on
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/gtid-slave.opt b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/gtid-slave.opt
new file mode 100644
index 00000000..9d7af67e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/gtid-slave.opt
@@ -0,0 +1 @@
+--gtid_mode=on --log_slave_updates=on --enforce_gtid_consistency=on
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/gtid.test b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/gtid.test
new file mode 100644
index 00000000..f9d58da0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/gtid.test
@@ -0,0 +1,47 @@
+
+source suite/rocksdb_hotbackup/include/setup.inc;
+
+--let $rpl_server_number= 2
+--source include/rpl_stop_server.inc
+
+--exec suite/rocksdb_hotbackup/include/load_data_and_run.sh 2>&1
+
+--let $rpl_server_number= 2
+--source include/rpl_start_server.inc
+
+connection server_2;
+let $num_rows = `select count(*) from db1.t1`;
+let $max_id = `select id from db1.t1 order by id desc limit 1`;
+
+if($num_rows != $max_id) {
+ echo Number of rows($num_rows) and last_id($max_id) does not match;
+}
+if($num_rows < 250000) {
+ echo Number of rows($num_rows) is less than 250000;
+}
+if($num_rows > 500000) {
+ echo Number of rows($num_rows) is more than 500000;
+}
+
+--source suite/rocksdb_hotbackup/include/setup_replication_gtid_and_sync.inc
+
+connection server_2;
+select count(*) from db1.t1;
+
+connection server_1;
+let $checksum1 = `checksum tables db1.t1`;
+connection server_2;
+let $checksum2 = `checksum tables db1.t1`;
+
+if($checksum1 != $checksum2) {
+ echo Checksums ($checksum1 and $checksum2) do not match;
+}
+
+connection server_1;
+drop database db1;
+sync_slave_with_master;
+connection server_2;
+stop slave;
+reset slave;
+
+source suite/rocksdb_hotbackup/include/cleanup.inc;
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/slocket.test b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/slocket.test
new file mode 100644
index 00000000..14ad8d23
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/slocket.test
@@ -0,0 +1,46 @@
+source suite/rocksdb_hotbackup/include/setup.inc;
+source suite/rocksdb_hotbackup/include/setup_slocket.inc;
+
+--exec suite/rocksdb_hotbackup/include/load_data.sh 2>&1
+--exec suite/rocksdb_hotbackup/include/load_data_slocket.sh 2>&1
+
+--let $rpl_server_number= 2
+--source include/rpl_stop_server.inc
+
+--exec suite/rocksdb_hotbackup/include/stream_run.sh 2>&1
+
+--let $rpl_server_number= 2
+--source include/rpl_start_server.inc
+
+connection server_2;
+select count(*) from db1.t1;
+select count(*) from slocket.t1;
+
+connection server_1;
+drop database slocket;
+connection server_2;
+drop database db1;
+drop database slocket;
+
+--exec sleep 2
+--exec suite/rocksdb_hotbackup/include/create_slocket_socket.sh 2>&1
+
+--let $rpl_server_number= 2
+--source include/rpl_stop_server.inc
+
+--exec suite/rocksdb_hotbackup/include/stream_run.sh 2>&1
+
+--let $rpl_server_number= 2
+--source include/rpl_start_server.inc
+
+connection server_2;
+select count(*) from db1.t1;
+
+connection server_1;
+drop database db1;
+connection server_2;
+drop database db1;
+
+--exec suite/rocksdb_hotbackup/include/remove_slocket_socket.sh 2>&1
+
+source suite/rocksdb_hotbackup/include/cleanup.inc;
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/stream.test b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/stream.test
new file mode 100644
index 00000000..2b999f3f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/stream.test
@@ -0,0 +1,22 @@
+
+source suite/rocksdb_hotbackup/include/setup.inc;
+
+--exec suite/rocksdb_hotbackup/include/load_data.sh 2>&1
+--let $rpl_server_number= 2
+--source include/rpl_stop_server.inc
+
+--exec STREAM_TYPE=tar suite/rocksdb_hotbackup/include/stream_run.sh 2>&1
+
+--let $rpl_server_number= 2
+--source include/rpl_start_server.inc
+
+connection server_2;
+select count(*) from db1.t1;
+
+connection server_1;
+drop database db1;
+connection server_2;
+drop database db1;
+
+source suite/rocksdb_hotbackup/include/cleanup.inc;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/wdt.test b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/wdt.test
new file mode 100644
index 00000000..2d2ed891
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/wdt.test
@@ -0,0 +1,22 @@
+
+source suite/rocksdb_hotbackup/include/setup.inc;
+
+--let $rpl_server_number= 2
+--source include/rpl_stop_server.inc
+
+--exec suite/rocksdb_hotbackup/include/load_data.sh 2>&1
+--exec STREAM_TYPE=wdt suite/rocksdb_hotbackup/include/stream_run.sh 2>&1
+
+--let $rpl_server_number= 2
+--source include/rpl_start_server.inc
+
+connection server_2;
+select count(*) from db1.t1;
+
+connection server_1;
+drop database db1;
+connection server_2;
+drop database db1;
+
+source suite/rocksdb_hotbackup/include/cleanup.inc;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream.inc b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream.inc
new file mode 100644
index 00000000..52456a68
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream.inc
@@ -0,0 +1,25 @@
+
+source suite/rocksdb_hotbackup/include/setup.inc;
+
+--exec suite/rocksdb_hotbackup/include/load_data.sh 2>&1
+--let $rpl_server_number= 2
+--source include/rpl_stop_server.inc
+
+--error 1
+--exec STREAM_TYPE=xbstream FRM=1 DEBUG_SIGNAL=1 suite/rocksdb_hotbackup/include/stream_run.sh 2>&1
+
+--exec STREAM_TYPE=xbstream suite/rocksdb_hotbackup/include/stream_run.sh 2>&1
+
+--let $rpl_server_number= 2
+--source include/rpl_start_server.inc
+
+connection server_2;
+select count(*) from db1.t1;
+
+connection server_1;
+drop database db1;
+connection server_2;
+drop database db1;
+
+source suite/rocksdb_hotbackup/include/cleanup.inc;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream.test b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream.test
new file mode 100644
index 00000000..18816c34
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream.test
@@ -0,0 +1,7 @@
+--source include/have_rocksdb.inc
+--source xbstream.inc
+let SEARCH_FILE= $MYSQL_TMP_DIR/myrocks_hotbackup_copy_log;
+let SEARCH_PATTERN= Direct I/O: 0;
+--source include/search_pattern_in_file.inc
+
+--exec suite/rocksdb_hotbackup/include/clean_tmpfiles.sh
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream_direct-master.opt b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream_direct-master.opt
new file mode 100644
index 00000000..4ab98aea
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream_direct-master.opt
@@ -0,0 +1 @@
+--rocksdb_use_direct_reads=ON --rocksdb_use_direct_io_for_flush_and_compaction=ON
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream_direct.test b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream_direct.test
new file mode 100644
index 00000000..41357d68
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream_direct.test
@@ -0,0 +1,7 @@
+--source include/have_rocksdb.inc
+--source xbstream.inc
+let SEARCH_FILE= $MYSQL_TMP_DIR/myrocks_hotbackup_copy_log;
+let SEARCH_PATTERN= Direct I/O: 1;
+--source include/search_pattern_in_file.inc
+
+--exec suite/rocksdb_hotbackup/include/clean_tmpfiles.sh
diff --git a/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream_socket.test b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream_socket.test
new file mode 100644
index 00000000..28edff07
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_hotbackup/t/xbstream_socket.test
@@ -0,0 +1,22 @@
+
+source suite/rocksdb_hotbackup/include/setup.inc;
+
+--exec suite/rocksdb_hotbackup/include/load_data.sh 2>&1
+--let $rpl_server_number= 2
+--source include/rpl_stop_server.inc
+
+--exec STREAM_TYPE=xbstream_socket suite/rocksdb_hotbackup/include/stream_run.sh 2>&1
+
+--let $rpl_server_number= 2
+--source include/rpl_start_server.inc
+
+connection server_2;
+select count(*) from db1.t1;
+
+connection server_1;
+drop database db1;
+connection server_2;
+drop database db1;
+
+source suite/rocksdb_hotbackup/include/cleanup.inc;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/combinations b/storage/rocksdb/mysql-test/rocksdb_rpl/combinations
new file mode 100644
index 00000000..eae74316
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/combinations
@@ -0,0 +1,7 @@
+[row-write-committed]
+binlog-format=row
+rocksdb_write_policy=write_committed
+
+[row-write-prepared]
+binlog-format=row
+rocksdb_write_policy=write_prepared
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/include/have_rocksdb.inc b/storage/rocksdb/mysql-test/rocksdb_rpl/include/have_rocksdb.inc
new file mode 100644
index 00000000..1f762d38
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/include/have_rocksdb.inc
@@ -0,0 +1,10 @@
+if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'rocksdb' AND support IN ('YES', 'DEFAULT', 'ENABLED')`)
+{
+ --skip Test requires engine RocksDB.
+}
+
+--disable_query_log
+# Table statistics can vary depending on when the memtables are flushed, so
+# flush them at the beginning of the test to ensure the test runs consistently.
+set global rocksdb_force_flush_memtable_now = true;
+--enable_query_log
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/include/have_rocksdb.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/include/have_rocksdb.opt
new file mode 100644
index 00000000..36d7dda1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/include/have_rocksdb.opt
@@ -0,0 +1,12 @@
+--loose-enable-rocksdb
+--loose-enable-rocksdb_global_info
+--loose-enable-rocksdb_ddl
+--loose-enable-rocksdb_cf_options
+--loose-enable_rocksdb_perf_context
+--loose-enable_rocksdb_perf_context_global
+--loose-enable-rocksdb_index_file_map
+--loose-enable-rocksdb_dbstats
+--loose-enable-rocksdb_cfstats
+--loose-enable-rocksdb_lock_info
+--loose-enable-rocksdb_trx
+--loose-enable-rocksdb_locks
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/include/rpl_gtid_crash_safe.inc b/storage/rocksdb/mysql-test/rocksdb_rpl/include/rpl_gtid_crash_safe.inc
new file mode 100644
index 00000000..f0c0134e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/include/rpl_gtid_crash_safe.inc
@@ -0,0 +1,37 @@
+
+-- let $engine = ROCKSDB
+
+call mtr.add_suppression("Recovery from master pos");
+
+-- let $debug_option = crash_before_update_pos
+-- source extra/rpl_tests/rpl_gtid_crash_safe.inc
+
+-- source include/rpl_reset.inc
+-- let $debug_option = crash_after_update_pos_before_apply
+-- source extra/rpl_tests/rpl_gtid_crash_safe.inc
+
+-- source include/rpl_reset.inc
+-- let $debug_option = crash_before_writing_xid
+-- source extra/rpl_tests/rpl_gtid_crash_safe.inc
+
+-- source include/rpl_reset.inc
+-- let $debug_option = half_binlogged_transaction
+-- source extra/rpl_tests/rpl_gtid_crash_safe.inc
+
+-- source include/rpl_reset.inc
+-- let $debug_option = crash_commit_before
+-- source extra/rpl_tests/rpl_gtid_crash_safe.inc
+
+-- source include/rpl_reset.inc
+-- let $debug_option = crash_commit_after_log
+-- source extra/rpl_tests/rpl_gtid_crash_safe.inc
+
+-- source include/rpl_reset.inc
+-- let $debug_option = crash_commit_after_prepare
+-- source extra/rpl_tests/rpl_gtid_crash_safe.inc
+
+-- source include/rpl_reset.inc
+-- let $debug_option = crash_commit_after
+-- source extra/rpl_tests/rpl_gtid_crash_safe.inc
+
+-- source include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/include/rpl_no_unique_check_on_lag.inc b/storage/rocksdb/mysql-test/rocksdb_rpl/include/rpl_no_unique_check_on_lag.inc
new file mode 100644
index 00000000..d983bdf8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/include/rpl_no_unique_check_on_lag.inc
@@ -0,0 +1,72 @@
+--source include/master-slave.inc
+--source include/have_binlog_format_row.inc
+--source include/not_embedded.inc
+--source include/not_valgrind.inc
+
+call mtr.add_suppression("Slave SQL: Could not execute Write_rows event on table test.t1");
+call mtr.add_suppression(".*Worker.*failed executing transaction");
+call mtr.add_suppression(".*The slave coordinator and worker threads are stopped");
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+connection master;
+CREATE TABLE t1 (id int primary key, value int) engine=RocksDB;
+sync_slave_with_master;
+--let $rsbm = query_get_value(select @@global.reset_seconds_behind_master, @@global.reset_seconds_behind_master, 1)
+set global reset_seconds_behind_master=1;
+
+connection slave;
+INSERT INTO t1 VALUES(1, 0);
+INSERT INTO t1 VALUES(2, 0);
+INSERT INTO t1 VALUES(3, 0);
+
+connection master;
+sync_slave_with_master;
+connection master;
+INSERT INTO t1 VALUES(1, 1);
+
+connection slave;
+--let $slave_sql_errno= 1062
+--let $not_switch_connection= 0
+--let $slave_timeout= 120
+--source include/wait_for_slave_sql_error_and_skip.inc
+set global reset_seconds_behind_master=0;
+--source include/stop_slave_io.inc
+
+connection master;
+INSERT INTO t1 values (4,0);
+--sleep 11
+INSERT INTO t1 VALUES(2, 1);
+
+connection slave;
+--source include/start_slave_io.inc
+
+connection master;
+sync_slave_with_master;
+
+connection slave;
+set global reset_seconds_behind_master=1;
+
+connection master;
+insert into t1 values (5,0);
+--sleep 1
+sync_slave_with_master;
+
+connection master;
+INSERT INTO t1 VALUES(3, 1);
+
+connection slave;
+--let $slave_sql_errno= 1062
+--let $not_switch_connection= 0
+--source include/wait_for_slave_sql_error_and_skip.inc
+
+--echo #
+--echo # Cleanup
+--echo #
+
+connection master;
+DROP TABLE t1;
+eval set global reset_seconds_behind_master=$rsbm;
+--source include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/my.cnf b/storage/rocksdb/mysql-test/rocksdb_rpl/my.cnf
new file mode 100644
index 00000000..518b1653
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/my.cnf
@@ -0,0 +1,17 @@
+!include rpl_1slave_base.cnf
+!include include/default_my.cnf
+
+[server]
+skip-innodb
+default-storage-engine=rocksdb
+
+sql-mode=NO_ENGINE_SUBSTITUTION
+explicit-defaults-for-timestamp=1
+loose-rocksdb_lock_wait_timeout=1
+loose-rocksdb_strict_collation_check=0
+
+loose-rocksdb-flush-log-at-trx-commit=0
+
+# The following is to get rid of the harmless
+# "Deadlock found when trying to get lock" errors, see MDEV-12285.
+log-warnings=1
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/consistent_snapshot_mixed_engines.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/consistent_snapshot_mixed_engines.result
new file mode 100644
index 00000000..31777c45
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/consistent_snapshot_mixed_engines.result
@@ -0,0 +1,68 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+create table i1 (id int primary key , value int) engine=innodb;
+create table r1 (id int primary key , value int) engine=rocksdb;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connection con2;
+insert into i1 values (1,1);
+insert into r1 values (1,1);
+connection con1;
+select * from i1;
+id value
+select * from r1;
+id value
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+File Position Gtid_executed
+master-bin.000001 1115 uuid:1-5
+connection con2;
+insert into i1 values (2,2);
+insert into r1 values (2,2);
+connection con1;
+select * from i1;
+id value
+1 1
+2 2
+select * from r1;
+id value
+1 1
+connection con2;
+insert into i1 values (3,2);
+insert into r1 values (3,2);
+connection con1;
+select * from i1;
+id value
+1 1
+2 2
+select * from r1;
+id value
+1 1
+START TRANSACTION WITH CONSISTENT INNODB SNAPSHOT;
+File Position Gtid_executed
+master-bin.000001 2015 uuid:1-9
+connection con2;
+insert into r1 values (4,4);
+connection con1;
+select * from r1;
+id value
+1 1
+2 2
+3 2
+4 4
+connection con2;
+insert into r1 values (5,5);
+connection con1;
+select * from r1;
+id value
+1 1
+2 2
+3 2
+4 4
+drop table i1;
+drop table r1;
+connection default;
+disconnect con1;
+disconnect con2;
+reset master;
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/mdev12179.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/mdev12179.result
new file mode 100644
index 00000000..a1e501f7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/mdev12179.result
@@ -0,0 +1,283 @@
+include/master-slave.inc
+[connection master]
+connection server_2;
+include/stop_slave.inc
+SET GLOBAL gtid_cleanup_batch_size = 999999999;
+CHANGE MASTER TO master_use_gtid=slave_pos;
+SET sql_log_bin=0;
+CREATE TABLE mysql.gtid_slave_pos_innodb LIKE mysql.gtid_slave_pos;
+ALTER TABLE mysql.gtid_slave_pos_innodb ENGINE=InnoDB;
+CREATE TABLE mysql.gtid_slave_pos_rocksdb LIKE mysql.gtid_slave_pos;
+ALTER TABLE mysql.gtid_slave_pos_rocksdb ENGINE=rocksdb;
+CREATE TABLE mysql.gtid_slave_pos_myisam_redundant LIKE mysql.gtid_slave_pos;
+CREATE TABLE mysql.gtid_slave_pos_innodb_redundant LIKE mysql.gtid_slave_pos;
+ALTER TABLE mysql.gtid_slave_pos_innodb_redundant ENGINE=InnoDB;
+call mtr.add_suppression("Ignoring redundant table.*since.*has the same storage engine");
+include/start_slave.inc
+connection server_1;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=MyISAM;
+CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t3 (a INT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t3 VALUES (1);
+SELECT * FROM t1 ORDER BY a;
+a
+1
+SELECT * FROM t2 ORDER BY a;
+a
+1
+SELECT * FROM t3 ORDER BY a;
+a
+1
+connection server_2;
+SELECT * FROM t1 ORDER BY a;
+a
+1
+SELECT * FROM t2 ORDER BY a;
+a
+1
+SELECT * FROM t3 ORDER BY a;
+a
+1
+SELECT * FROM mysql.gtid_slave_pos ORDER BY sub_id;
+domain_id sub_id server_id seq_no
+0 1 1 1
+0 2 1 2
+0 3 1 3
+0 4 1 4
+SELECT * FROM ( SELECT * FROM mysql.gtid_slave_pos_innodb
+UNION ALL SELECT * FROM mysql.gtid_slave_pos_innodb_redundant) inner_select
+ORDER BY sub_id;
+domain_id sub_id server_id seq_no
+0 5 1 5
+SELECT * FROM mysql.gtid_slave_pos_rocksdb ORDER BY sub_id;
+domain_id sub_id server_id seq_no
+0 6 1 6
+connection server_2;
+FLUSH NO_WRITE_TO_BINLOG STATUS;
+SET sql_log_bin=0;
+SHOW STATUS LIKE "Transactions_multi_engine";
+Variable_name Value
+Transactions_multi_engine 0
+INSERT INTO t1 VALUES (100);
+SHOW STATUS LIKE "Transactions_multi_engine";
+Variable_name Value
+Transactions_multi_engine 0
+INSERT INTO t2 VALUES (101);
+SHOW STATUS LIKE "Transactions_multi_engine";
+Variable_name Value
+Transactions_multi_engine 0
+INSERT INTO t3 VALUES (101);
+SHOW STATUS LIKE "Transactions_multi_engine";
+Variable_name Value
+Transactions_multi_engine 0
+BEGIN;
+INSERT INTO t3 VALUES (102);
+INSERT INTO t2 VALUES (103);
+COMMIT;
+SHOW STATUS LIKE "Transactions_multi_engine";
+Variable_name Value
+Transactions_multi_engine 1
+BEGIN;
+INSERT INTO t2 VALUES (104);
+INSERT INTO t3 VALUES (105);
+COMMIT;
+SHOW STATUS LIKE "Transactions_multi_engine";
+Variable_name Value
+Transactions_multi_engine 2
+UPDATE t2, t3 SET t2.a=106, t3.a=107 WHERE t2.a=104 AND t3.a=105;
+SHOW STATUS LIKE "Transactions_multi_engine";
+Variable_name Value
+Transactions_multi_engine 3
+SET sql_log_bin=1;
+INSERT INTO t1 VALUES (200);
+SHOW STATUS LIKE "Transactions_multi_engine";
+Variable_name Value
+Transactions_multi_engine 3
+INSERT INTO t2 VALUES (201);
+SHOW STATUS LIKE "Transactions_multi_engine";
+Variable_name Value
+Transactions_multi_engine 3
+INSERT INTO t3 VALUES (201);
+SHOW STATUS LIKE "Transactions_multi_engine";
+Variable_name Value
+Transactions_multi_engine 3
+BEGIN;
+INSERT INTO t3 VALUES (202);
+INSERT INTO t2 VALUES (203);
+COMMIT;
+SHOW STATUS LIKE "Transactions_multi_engine";
+Variable_name Value
+Transactions_multi_engine 4
+BEGIN;
+INSERT INTO t2 VALUES (204);
+INSERT INTO t3 VALUES (205);
+COMMIT;
+SHOW STATUS LIKE "Transactions_multi_engine";
+Variable_name Value
+Transactions_multi_engine 5
+UPDATE t2, t3 SET t2.a=206, t3.a=207 WHERE t2.a=204 AND t3.a=205;
+SHOW STATUS LIKE "Transactions_multi_engine";
+Variable_name Value
+Transactions_multi_engine 6
+DELETE FROM t1 WHERE a >= 100;
+DELETE FROM t2 WHERE a >= 100;
+DELETE FROM t3 WHERE a >= 100;
+connection server_1;
+include/save_master_gtid.inc
+connection server_2;
+include/sync_with_master_gtid.inc
+SELECT COUNT(*)>=10 FROM mysql.gtid_slave_pos;
+COUNT(*)>=10
+1
+SELECT COUNT(*)>=10 FROM ( SELECT * FROM mysql.gtid_slave_pos_innodb
+UNION ALL SELECT * FROM mysql.gtid_slave_pos_innodb_redundant) inner_select;
+COUNT(*)>=10
+1
+SELECT COUNT(*)>=10 FROM mysql.gtid_slave_pos_rocksdb;
+COUNT(*)>=10
+1
+SET GLOBAL gtid_cleanup_batch_size = 3;
+connection server_2;
+include/stop_slave.inc
+SET sql_log_bin=0;
+DROP TABLE mysql.gtid_slave_pos_rocksdb;
+DROP TABLE mysql.gtid_slave_pos_myisam_redundant;
+DROP TABLE mysql.gtid_slave_pos_innodb_redundant;
+SET sql_log_bin=1;
+FLUSH NO_WRITE_TO_BINLOG STATUS;
+include/start_slave.inc
+SHOW STATUS LIKE "%transactions%engine";
+Variable_name Value
+Rpl_transactions_multi_engine 0
+Transactions_gtid_foreign_engine 0
+Transactions_multi_engine 0
+connection server_1;
+INSERT INTO t1 VALUES (100);
+connection server_2;
+SHOW STATUS LIKE "%transactions%engine";
+Variable_name Value
+Rpl_transactions_multi_engine 0
+Transactions_gtid_foreign_engine 0
+Transactions_multi_engine 0
+connection server_1;
+INSERT INTO t2 VALUES (101);
+connection server_2;
+SHOW STATUS LIKE "%transactions%engine";
+Variable_name Value
+Rpl_transactions_multi_engine 0
+Transactions_gtid_foreign_engine 0
+Transactions_multi_engine 0
+connection server_1;
+INSERT INTO t3 VALUES (101);
+connection server_2;
+SHOW STATUS LIKE "%transactions%engine";
+Variable_name Value
+Rpl_transactions_multi_engine 0
+Transactions_gtid_foreign_engine 1
+Transactions_multi_engine 0
+connection server_1;
+BEGIN;
+INSERT INTO t3 VALUES (102);
+INSERT INTO t2 VALUES (103);
+COMMIT;
+connection server_2;
+SHOW STATUS LIKE "%transactions%engine";
+Variable_name Value
+Rpl_transactions_multi_engine 1
+Transactions_gtid_foreign_engine 1
+Transactions_multi_engine 1
+connection server_1;
+BEGIN;
+INSERT INTO t2 VALUES (104);
+INSERT INTO t3 VALUES (105);
+COMMIT;
+connection server_2;
+SHOW STATUS LIKE "%transactions%engine";
+Variable_name Value
+Rpl_transactions_multi_engine 2
+Transactions_gtid_foreign_engine 1
+Transactions_multi_engine 2
+connection server_1;
+UPDATE t2, t3 SET t2.a=106, t3.a=107 WHERE t2.a=104 AND t3.a=105;
+connection server_2;
+SHOW STATUS LIKE "%transactions%engine";
+Variable_name Value
+Rpl_transactions_multi_engine 3
+Transactions_gtid_foreign_engine 1
+Transactions_multi_engine 3
+connection server_2;
+connection server_2;
+SHOW VARIABLES LIKE 'log_bin';
+Variable_name Value
+log_bin OFF
+include/start_slave.inc
+SHOW STATUS LIKE "%transactions%engine";
+Variable_name Value
+Rpl_transactions_multi_engine 0
+Transactions_gtid_foreign_engine 0
+Transactions_multi_engine 0
+connection server_1;
+INSERT INTO t1 VALUES (200);
+connection server_2;
+SHOW STATUS LIKE "%transactions%engine";
+Variable_name Value
+Rpl_transactions_multi_engine 0
+Transactions_gtid_foreign_engine 0
+Transactions_multi_engine 0
+connection server_1;
+INSERT INTO t2 VALUES (201);
+connection server_2;
+SHOW STATUS LIKE "%transactions%engine";
+Variable_name Value
+Rpl_transactions_multi_engine 0
+Transactions_gtid_foreign_engine 0
+Transactions_multi_engine 0
+connection server_1;
+INSERT INTO t3 VALUES (201);
+connection server_2;
+SHOW STATUS LIKE "%transactions%engine";
+Variable_name Value
+Rpl_transactions_multi_engine 0
+Transactions_gtid_foreign_engine 1
+Transactions_multi_engine 0
+connection server_1;
+BEGIN;
+INSERT INTO t3 VALUES (202);
+INSERT INTO t2 VALUES (203);
+COMMIT;
+connection server_2;
+SHOW STATUS LIKE "%transactions%engine";
+Variable_name Value
+Rpl_transactions_multi_engine 1
+Transactions_gtid_foreign_engine 1
+Transactions_multi_engine 1
+connection server_1;
+BEGIN;
+INSERT INTO t2 VALUES (204);
+INSERT INTO t3 VALUES (205);
+COMMIT;
+connection server_2;
+SHOW STATUS LIKE "%transactions%engine";
+Variable_name Value
+Rpl_transactions_multi_engine 2
+Transactions_gtid_foreign_engine 1
+Transactions_multi_engine 2
+connection server_1;
+UPDATE t2, t3 SET t2.a=206, t3.a=207 WHERE t2.a=204 AND t3.a=205;
+connection server_2;
+SHOW STATUS LIKE "%transactions%engine";
+Variable_name Value
+Rpl_transactions_multi_engine 3
+Transactions_gtid_foreign_engine 1
+Transactions_multi_engine 3
+connection server_2;
+SET sql_log_bin=0;
+DROP TABLE mysql.gtid_slave_pos_innodb;
+SET sql_log_bin=1;
+connection server_1;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/multiclient_2pc.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/multiclient_2pc.result
new file mode 100644
index 00000000..493107ec
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/multiclient_2pc.result
@@ -0,0 +1,26 @@
+DROP TABLE IF EXISTS t1;
+SET GLOBAL MAX_BINLOG_SIZE = 4096;
+SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
+create table t1 (a int primary key, b int, c varchar(255)) engine=rocksdb;
+'con1'
+SET SESSION debug="d,crash_commit_after_log";
+SET DEBUG_SYNC='rocksdb.prepared SIGNAL parked WAIT_FOR go';
+insert into t1 values (1, 1, "iamtheogthealphaandomega");;
+'con2'
+insert into t1 values (2, 1, "i_am_just_here_to_trigger_a_flush");
+SET GLOBAL ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT = 0;
+SET GLOBAL SYNC_BINLOG = 0;
+SET DEBUG_SYNC='now WAIT_FOR parked';
+SET GLOBAL ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT = 2;
+SET GLOBAL SYNC_BINLOG = 1;
+insert into t1 values (1000000, 1, "i_am_just_here_to_trigger_a_flush");
+SET DEBUG_SYNC='now SIGNAL go';
+**found 'prepare' log entry**
+**found 'commit' log entry**
+select * from t1 where a=1;
+a b c
+1 1 iamtheogthealphaandomega
+select count(*) from t1;
+count(*)
+4096
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/optimize_myrocks_replace_into.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/optimize_myrocks_replace_into.result
new file mode 100644
index 00000000..1b41405f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/optimize_myrocks_replace_into.result
@@ -0,0 +1,282 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+SET @prior_rocksdb_perf_context_level = @@rocksdb_perf_context_level;
+SET GLOBAL rocksdb_perf_context_level=3;
+SET GLOBAL enable_blind_replace=ON;
+create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+c1 c2
+1 1
+2 2
+3 3
+create table t2(c1 int,c2 int, primary key (c1)) engine=rocksdb;
+insert into t2 values(1,1),(2,2),(3,3);
+select * from t2;
+c1 c2
+1 1
+2 2
+3 3
+create table t3(c1 int,c2 int, primary key (c1)) engine=rocksdb;
+insert into t3 values(1,1),(2,2),(3,3);
+select * from t3;
+c1 c2
+1 1
+2 2
+3 3
+SET GLOBAL enable_blind_replace=ON;
+create trigger trg before insert on t2 for each row set @a:=1;
+alter table t3 add constraint slave_unique_key unique (c2);
+connect slave
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+Case 1
+connect master
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(1,11);
+replace into t1 values(2,22);
+replace into t1 values(3,33);
+select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+select * from t1;
+c1 c2
+1 11
+2 22
+3 33
+connect slave
+select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+select * from t1;
+c1 c2
+1 11
+2 22
+3 33
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+Case 2
+connect master
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(2,44),(3,55);
+select case when variable_value-@d > 2 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+select * from t1;
+c1 c2
+1 11
+2 44
+3 55
+connect slave
+select case when variable_value-@d > 2 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+select * from t1;
+c1 c2
+1 11
+2 44
+3 55
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+Case 3
+connect master
+update t1 set c2=66 where c1=3;
+select * from t1;
+c1 c2
+1 11
+2 44
+3 66
+connect slave
+select * from t1;
+c1 c2
+1 11
+2 44
+3 66
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+Case 4
+connect master
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t2 values(1,111);
+replace into t2 values(2,222);
+replace into t2 values(3,333);
+select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+select * from t2;
+c1 c2
+1 111
+2 222
+3 333
+connect slave
+select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+false
+select * from t2;
+c1 c2
+1 111
+2 222
+3 333
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+Case 5
+connect master
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t3 values(1,1111);
+replace into t3 values(2,2222);
+replace into t3 values(3,3333);
+select * from t3;
+c1 c2
+1 1111
+2 2222
+3 3333
+select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+true
+connect slave
+select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+read_free
+false
+select * from t3;
+c1 c2
+1 1111
+2 2222
+3 3333
+select * from t3 use index (slave_unique_key);
+c1 c2
+1 1111
+2 2222
+3 3333
+Case 6
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t1)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # use `test`; create table t2(c1 int,c2 int, primary key (c1)) engine=rocksdb
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t2)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # use `test`; create table t3(c1 int,c2 int, primary key (c1)) engine=rocksdb
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t3)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t1)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t1)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t1)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t1)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t1)
+master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t2)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t2)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t2)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t3)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t3)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Table_map # # table_id: # (test.t3)
+master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+slave-bin.000001 # Query # # use `test`; create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb
+slave-bin.000001 # Query # # BEGIN
+slave-bin.000001 # Table_map # # table_id: # (test.t1)
+slave-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Xid # # COMMIT /* XID */
+slave-bin.000001 # Query # # use `test`; create table t2(c1 int,c2 int, primary key (c1)) engine=rocksdb
+slave-bin.000001 # Query # # BEGIN
+slave-bin.000001 # Table_map # # table_id: # (test.t2)
+slave-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Xid # # COMMIT /* XID */
+slave-bin.000001 # Query # # use `test`; create table t3(c1 int,c2 int, primary key (c1)) engine=rocksdb
+slave-bin.000001 # Query # # BEGIN
+slave-bin.000001 # Table_map # # table_id: # (test.t3)
+slave-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Xid # # COMMIT /* XID */
+slave-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` trigger trg before insert on t2 for each row set @a:=1
+slave-bin.000001 # Query # # use `test`; alter table t3 add constraint slave_unique_key unique (c2)
+slave-bin.000001 # Query # # BEGIN
+slave-bin.000001 # Table_map # # table_id: # (test.t1)
+slave-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Xid # # COMMIT /* XID */
+slave-bin.000001 # Query # # BEGIN
+slave-bin.000001 # Table_map # # table_id: # (test.t1)
+slave-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Xid # # COMMIT /* XID */
+slave-bin.000001 # Query # # BEGIN
+slave-bin.000001 # Table_map # # table_id: # (test.t1)
+slave-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Xid # # COMMIT /* XID */
+slave-bin.000001 # Query # # BEGIN
+slave-bin.000001 # Table_map # # table_id: # (test.t1)
+slave-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Xid # # COMMIT /* XID */
+slave-bin.000001 # Query # # BEGIN
+slave-bin.000001 # Table_map # # table_id: # (test.t1)
+slave-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Xid # # COMMIT /* XID */
+slave-bin.000001 # Query # # BEGIN
+slave-bin.000001 # Table_map # # table_id: # (test.t2)
+slave-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Xid # # COMMIT /* XID */
+slave-bin.000001 # Query # # BEGIN
+slave-bin.000001 # Table_map # # table_id: # (test.t2)
+slave-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Xid # # COMMIT /* XID */
+slave-bin.000001 # Query # # BEGIN
+slave-bin.000001 # Table_map # # table_id: # (test.t2)
+slave-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Xid # # COMMIT /* XID */
+slave-bin.000001 # Query # # BEGIN
+slave-bin.000001 # Table_map # # table_id: # (test.t3)
+slave-bin.000001 # Delete_rows # # table_id: #
+slave-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Xid # # COMMIT /* XID */
+slave-bin.000001 # Query # # BEGIN
+slave-bin.000001 # Table_map # # table_id: # (test.t3)
+slave-bin.000001 # Delete_rows # # table_id: #
+slave-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Xid # # COMMIT /* XID */
+slave-bin.000001 # Query # # BEGIN
+slave-bin.000001 # Table_map # # table_id: # (test.t3)
+slave-bin.000001 # Delete_rows # # table_id: #
+slave-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Xid # # COMMIT /* XID */
+drop table t1;
+drop table t2;
+drop table t3;
+SET GLOBAL rocksdb_perf_context_level = @prior_rocksdb_perf_context_level;
+SET GLOBAL enable_blind_replace=DEFAULT;
+SET GLOBAL enable_blind_replace=DEFAULT;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rocksdb_slave_check_before_image_consistency.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rocksdb_slave_check_before_image_consistency.result
new file mode 100644
index 00000000..a7708222
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rocksdb_slave_check_before_image_consistency.result
@@ -0,0 +1,165 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+call mtr.add_suppression("Error_code: 1032");
+create table t1 (a int primary key, b int, c int) engine = rocksdb;
+create table t2 (a int unique, b int, c int) engine = rocksdb;
+create table t3 (a int, b int, c int, key(a)) engine = rocksdb;
+create table t4 (a int, b int, c int) engine = rocksdb;
+insert into t1 values(1, 1, 1);
+insert into t2 values(1, 1, 1);
+insert into t3 values(1, 1, 1);
+insert into t4 values(1, 1, 1);
+include/sync_slave_sql_with_master.inc
+set @@sql_log_bin = 0;
+update t1 set c = 2;
+update t2 set c = 2;
+update t3 set c = 2;
+update t4 set c = 2;
+set @@sql_log_bin = 1;
+update t1 set b = 2;
+include/wait_for_slave_sql_error.inc [errno=1032]
+set @@sql_log_bin = 0;
+update t1 set c = 1;
+set @@sql_log_bin = 1;
+include/stop_slave.inc
+include/start_slave.inc
+include/sync_slave_sql_with_master.inc
+update t2 set b = 2;
+include/wait_for_slave_sql_error.inc [errno=1032]
+set @@sql_log_bin = 0;
+update t2 set c = 1;
+set @@sql_log_bin = 1;
+include/stop_slave.inc
+include/start_slave.inc
+include/sync_slave_sql_with_master.inc
+update t3 set b = 2;
+include/wait_for_slave_sql_error.inc [errno=1032]
+set @@sql_log_bin = 0;
+update t3 set c = 1;
+set @@sql_log_bin = 1;
+include/stop_slave.inc
+include/start_slave.inc
+include/sync_slave_sql_with_master.inc
+update t4 set b = 2;
+include/wait_for_slave_sql_error.inc [errno=1032]
+set @@sql_log_bin = 0;
+update t4 set c = 1;
+set @@sql_log_bin = 1;
+include/stop_slave.inc
+include/start_slave.inc
+include/sync_slave_sql_with_master.inc
+select * from t1;
+a b c
+1 2 1
+select * from t2;
+a b c
+1 2 1
+select * from t3;
+a b c
+1 2 1
+select * from t4;
+a b c
+1 2 1
+select * from t1;
+a b c
+1 2 1
+select * from t2;
+a b c
+1 2 1
+select * from t3;
+a b c
+1 2 1
+select * from t4;
+a b c
+1 2 1
+drop table t1;
+drop table t2;
+drop table t3;
+drop table t4;
+include/sync_slave_sql_with_master.inc
+include/stop_slave.inc
+set @@global.slave_rows_search_algorithms = 'INDEX_SCAN,TABLE_SCAN,HASH_SCAN';
+include/start_slave.inc
+create table t1 (a int primary key, b int, c int) engine = rocksdb;
+create table t2 (a int unique, b int, c int) engine = rocksdb;
+create table t3 (a int, b int, c int, key(a)) engine = rocksdb;
+create table t4 (a int, b int, c int) engine = rocksdb;
+insert into t1 values(1, 1, 1);
+insert into t2 values(1, 1, 1);
+insert into t3 values(1, 1, 1);
+insert into t4 values(1, 1, 1);
+include/sync_slave_sql_with_master.inc
+set @@sql_log_bin = 0;
+update t1 set c = 2;
+update t2 set c = 2;
+update t3 set c = 2;
+update t4 set c = 2;
+set @@sql_log_bin = 1;
+update t1 set b = 2;
+include/wait_for_slave_sql_error.inc [errno=1032]
+set @@sql_log_bin = 0;
+update t1 set c = 1;
+set @@sql_log_bin = 1;
+include/stop_slave.inc
+include/start_slave.inc
+include/sync_slave_sql_with_master.inc
+update t2 set b = 2;
+include/wait_for_slave_sql_error.inc [errno=1032]
+set @@sql_log_bin = 0;
+update t2 set c = 1;
+set @@sql_log_bin = 1;
+include/stop_slave.inc
+include/start_slave.inc
+include/sync_slave_sql_with_master.inc
+update t3 set b = 2;
+include/wait_for_slave_sql_error.inc [errno=1032]
+set @@sql_log_bin = 0;
+update t3 set c = 1;
+set @@sql_log_bin = 1;
+include/stop_slave.inc
+include/start_slave.inc
+include/sync_slave_sql_with_master.inc
+update t4 set b = 2;
+include/wait_for_slave_sql_error.inc [errno=1032]
+set @@sql_log_bin = 0;
+update t4 set c = 1;
+set @@sql_log_bin = 1;
+include/stop_slave.inc
+include/start_slave.inc
+include/sync_slave_sql_with_master.inc
+select * from t1;
+a b c
+1 2 1
+select * from t2;
+a b c
+1 2 1
+select * from t3;
+a b c
+1 2 1
+select * from t4;
+a b c
+1 2 1
+select * from t1;
+a b c
+1 2 1
+select * from t2;
+a b c
+1 2 1
+select * from t3;
+a b c
+1 2 1
+select * from t4;
+a b c
+1 2 1
+drop table t1;
+drop table t2;
+drop table t3;
+drop table t4;
+include/sync_slave_sql_with_master.inc
+include/stop_slave.inc
+set @@global.slave_rows_search_algorithms = DEFAULT;
+include/start_slave.inc
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_binlog_xid_count.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_binlog_xid_count.result
new file mode 100644
index 00000000..9b46a5b5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_binlog_xid_count.result
@@ -0,0 +1,204 @@
+CREATE TABLE `t` (
+`a` text DEFAULT NULL
+) ENGINE=ROCKSDB;
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+INSERT INTO t SET a=repeat('a', 4096);
+INSERT INTO t SET a=repeat('a', 4096/2);
+DROP TABLE t;
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_crash_safe_wal_corrupt.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_crash_safe_wal_corrupt.result
new file mode 100644
index 00000000..6d061e99
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_crash_safe_wal_corrupt.result
@@ -0,0 +1,135 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+drop table if exists x;
+select @@binlog_format;
+@@binlog_format
+ROW
+create table x (id int primary key, value int, value2 int, index(value)) engine=rocksdb;
+insert into x values (1,1,1);
+insert into x values (2,1,1);
+insert into x values (3,1,1);
+insert into x values (4,1,1);
+insert into x values (5,1,1);
+select @@global.gtid_executed;
+@@global.gtid_executed
+
+
+--- slave state before crash ---
+select * from x;
+id value value2
+1 1 1
+2 1 1
+3 1 1
+4 1 1
+5 1 1
+select @@global.gtid_executed;
+@@global.gtid_executed
+
+select * from mysql.slave_gtid_info;
+Id Database_name Last_gtid
+include/rpl_start_server.inc [server_number=2]
+
+--- slave state after crash recovery, slave stop, one transaction recovered---
+select * from x;
+id value value2
+1 1 1
+2 1 1
+3 1 1
+4 1 1
+select @@global.gtid_executed;
+@@global.gtid_executed
+
+select * from mysql.slave_gtid_info;
+Id Database_name Last_gtid
+
+--- slave state after restart, slave start ---
+include/start_slave.inc
+select * from x;
+id value value2
+1 1 1
+2 1 1
+3 1 1
+4 1 1
+5 1 1
+select @@global.gtid_executed;
+@@global.gtid_executed
+
+select * from mysql.slave_gtid_info;
+Id Database_name Last_gtid
+insert into x values (6,1,1);
+select * from x;
+id value value2
+1 1 1
+2 1 1
+3 1 1
+4 1 1
+5 1 1
+6 1 1
+select @@global.gtid_executed;
+@@global.gtid_executed
+
+select * from mysql.slave_gtid_info;
+Id Database_name Last_gtid
+insert into x values (7,1,1);
+insert into x values (8,1,1);
+insert into x values (9,1,1);
+insert into x values (10,1,1);
+insert into x values (11,1,1);
+insert into x values (12,1,1);
+select * from x;
+id value value2
+1 1 1
+2 1 1
+3 1 1
+4 1 1
+5 1 1
+6 1 1
+7 1 1
+8 1 1
+9 1 1
+10 1 1
+11 1 1
+12 1 1
+select @@global.gtid_executed;
+@@global.gtid_executed
+
+include/rpl_start_server.inc [server_number=2]
+
+--- slave state after crash recovery, slave stop, WAL was corrupted, point in time recovery with wal_recovery_mode=2 ---
+select * from x;
+id value value2
+1 1 1
+2 1 1
+3 1 1
+4 1 1
+5 1 1
+6 1 1
+7 1 1
+8 1 1
+9 1 1
+include/start_slave.inc
+select * from x;
+id value value2
+1 1 1
+2 1 1
+3 1 1
+4 1 1
+5 1 1
+6 1 1
+7 1 1
+8 1 1
+9 1 1
+10 1 1
+11 1 1
+12 1 1
+select @@global.gtid_executed;
+@@global.gtid_executed
+
+select * from mysql.slave_gtid_info;
+Id Database_name Last_gtid
+drop table x;
+include/rpl_end.inc
+Binlog Info Found
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_ddl_high_priority.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_ddl_high_priority.result
new file mode 100644
index 00000000..8a1fd1b9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_ddl_high_priority.result
@@ -0,0 +1,39 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+include/rpl_connect.inc [creating slave_block]
+drop table if exists t1;
+create table t1 (i int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+insert into t1 values (1), (2), (3);
+connection slave
+select * from t1;
+i
+1
+2
+3
+connection slave_block
+lock tables t1 read;
+connection master;
+create high_priority index idx1 on t1 (i);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL,
+ KEY `idx1` (`i`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+connection slave;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL,
+ KEY `idx1` (`i`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+drop table t1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_crash_safe.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_crash_safe.result
new file mode 100644
index 00000000..352ceff2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_crash_safe.result
@@ -0,0 +1,361 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+call mtr.add_suppression("Recovery from master pos");
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 mtr uuid:1
+2 test uuid:4
+SET GLOBAL debug = '+d,crash_before_update_pos';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 mtr uuid:1
+2 test uuid:4
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 mtr uuid:1
+2 test uuid:7
+include/rpl_reset.inc
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+SET GLOBAL debug = '+d,crash_after_update_pos_before_apply';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:6
+include/rpl_reset.inc
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+SET GLOBAL debug = '+d,crash_before_writing_xid';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:6
+include/rpl_reset.inc
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+SET GLOBAL debug = '+d,half_binlogged_transaction';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:6
+include/rpl_reset.inc
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+SET GLOBAL debug = '+d,crash_commit_before';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:6
+include/rpl_reset.inc
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+SET GLOBAL debug = '+d,crash_commit_after_log';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:6
+include/rpl_reset.inc
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+SET GLOBAL debug = '+d,crash_commit_after_prepare';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:6
+include/rpl_reset.inc
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+SET GLOBAL debug = '+d,crash_commit_after';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:6
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_crash_safe_optimized.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_crash_safe_optimized.result
new file mode 100644
index 00000000..a518de2b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_crash_safe_optimized.result
@@ -0,0 +1,361 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+call mtr.add_suppression("Recovery from master pos");
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 mtr
+2 test uuid:4
+SET GLOBAL debug = '+d,crash_before_update_pos';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 mtr
+2 test uuid:4
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 mtr
+2 test uuid:5
+include/rpl_reset.inc
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+SET GLOBAL debug = '+d,crash_after_update_pos_before_apply';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:4
+include/rpl_reset.inc
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+SET GLOBAL debug = '+d,crash_before_writing_xid';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:4
+include/rpl_reset.inc
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+SET GLOBAL debug = '+d,half_binlogged_transaction';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:4
+include/rpl_reset.inc
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+SET GLOBAL debug = '+d,crash_commit_before';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:4
+include/rpl_reset.inc
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+SET GLOBAL debug = '+d,crash_commit_after_log';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:4
+include/rpl_reset.inc
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+SET GLOBAL debug = '+d,crash_commit_after_prepare';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:4
+include/rpl_reset.inc
+create table t1(a int, PRIMARY KEY(a)) ENGINE=ROCKSDB;
+insert into t1 values(1);
+insert into t1 values(2);
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+SET GLOBAL debug = '+d,crash_commit_after';
+insert into t1 values(3);
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:3
+use test;
+select * from t1;
+a
+1
+2
+change master to master_auto_position = 1;
+include/start_slave.inc
+rename table t1 to test1;
+use test;
+select * from test1;
+a
+1
+2
+3
+use test;
+select * from test1;
+a
+1
+2
+3
+drop table test1;
+include/stop_slave.inc
+change master to master_auto_position = 0;
+include/start_slave.inc
+use mysql;
+select * from slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:4
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_crash_safe_wal_corrupt.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_crash_safe_wal_corrupt.result
new file mode 100644
index 00000000..e765e338
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_crash_safe_wal_corrupt.result
@@ -0,0 +1,140 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+drop table if exists x;
+select @@binlog_format;
+@@binlog_format
+ROW
+create table x (id int primary key, value int, value2 int, index(value)) engine=rocksdb;
+insert into x values (1,1,1);
+insert into x values (2,1,1);
+insert into x values (3,1,1);
+insert into x values (4,1,1);
+insert into x values (5,1,1);
+select @@global.gtid_executed;
+@@global.gtid_executed
+uuid:1-7
+
+--- slave state before crash ---
+select * from x;
+id value value2
+1 1 1
+2 1 1
+3 1 1
+4 1 1
+5 1 1
+select @@global.gtid_executed;
+@@global.gtid_executed
+uuid:1-7
+select * from mysql.slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:7
+include/rpl_start_server.inc [server_number=2]
+
+--- slave state after crash recovery, slave stop, one transaction recovered---
+select * from x;
+id value value2
+1 1 1
+2 1 1
+3 1 1
+4 1 1
+select @@global.gtid_executed;
+@@global.gtid_executed
+uuid:1-6
+select * from mysql.slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:6
+
+--- slave state after restart, slave start ---
+include/start_slave.inc
+select * from x;
+id value value2
+1 1 1
+2 1 1
+3 1 1
+4 1 1
+5 1 1
+select @@global.gtid_executed;
+@@global.gtid_executed
+uuid:1-7
+select * from mysql.slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:7
+insert into x values (6,1,1);
+select * from x;
+id value value2
+1 1 1
+2 1 1
+3 1 1
+4 1 1
+5 1 1
+6 1 1
+select @@global.gtid_executed;
+@@global.gtid_executed
+uuid:1-8
+select * from mysql.slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:8
+insert into x values (7,1,1);
+insert into x values (8,1,1);
+insert into x values (9,1,1);
+insert into x values (10,1,1);
+insert into x values (11,1,1);
+insert into x values (12,1,1);
+select * from x;
+id value value2
+1 1 1
+2 1 1
+3 1 1
+4 1 1
+5 1 1
+6 1 1
+7 1 1
+8 1 1
+9 1 1
+10 1 1
+11 1 1
+12 1 1
+select @@global.gtid_executed;
+@@global.gtid_executed
+uuid:1-14
+include/rpl_start_server.inc [server_number=2]
+
+--- slave state after crash recovery, slave stop, WAL was corrupted, point in time recovery with wal_recovery_mode=2 ---
+select * from x;
+id value value2
+1 1 1
+2 1 1
+3 1 1
+4 1 1
+5 1 1
+6 1 1
+7 1 1
+8 1 1
+9 1 1
+include/start_slave.inc
+select * from x;
+id value value2
+1 1 1
+2 1 1
+3 1 1
+4 1 1
+5 1 1
+6 1 1
+7 1 1
+8 1 1
+9 1 1
+10 1 1
+11 1 1
+12 1 1
+select @@global.gtid_executed;
+@@global.gtid_executed
+uuid:1-14
+select * from mysql.slave_gtid_info;
+Id Database_name Last_gtid
+1 test uuid:14
+drop table x;
+include/rpl_end.inc
+Binlog Info Found
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_rocksdb_sys_header.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_rocksdb_sys_header.result
new file mode 100644
index 00000000..b2703ee0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_gtid_rocksdb_sys_header.result
@@ -0,0 +1,16 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+create table t1 (a int primary key) engine=rocksdb;
+insert into t1 values(1);
+SET GLOBAL debug = '+d,crash_before_writing_xid';
+insert into t1 values(2);
+ERROR HY000: Lost connection to MySQL server during query
+include/rpl_reconnect.inc
+SET GLOBAL debug = ``;
+include/start_slave.inc
+RocksDB: Last MySQL Gtid master_uuid:2
+drop table t1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_missing_columns_sk_update.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_missing_columns_sk_update.result
new file mode 100644
index 00000000..19b0a191
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_missing_columns_sk_update.result
@@ -0,0 +1,62 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+set @@sql_log_bin = 0;
+CREATE TABLE `t1` (
+`a` int(10) unsigned NOT NULL DEFAULT '0',
+`b` bigint(20) unsigned NOT NULL DEFAULT '0',
+`c` bigint(20) unsigned NOT NULL DEFAULT '0',
+`d` bigint(20) unsigned NOT NULL DEFAULT '0',
+`e` varbinary(64) DEFAULT NULL,
+`f` int(10) NOT NULL DEFAULT '0',
+`g` int(10) NOT NULL DEFAULT '0',
+`h` int(10) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`a`,`b`),
+KEY `key1` (`a`, `e`(1)),
+KEY `key2` (`a`,`h`)
+) ENGINE=RocksDB;
+set @@sql_log_bin = 1;
+set @@sql_log_bin = 0;
+CREATE TABLE `t1` (
+`a` int(10) unsigned NOT NULL DEFAULT '0',
+`b` bigint(20) unsigned NOT NULL DEFAULT '0',
+`c` bigint(20) unsigned NOT NULL DEFAULT '0',
+`d` bigint(20) unsigned NOT NULL DEFAULT '0',
+`e` varbinary(64) DEFAULT NULL,
+`f` int(10) NOT NULL DEFAULT '0',
+`g` int(10) NOT NULL DEFAULT '0',
+`x` TINYINT(3) UNSIGNED DEFAULT NULL,
+`y` INT(10) DEFAULT NULL,
+`h` int(10) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (`a`,`b`),
+KEY `key1` (`a`, `e`(1)),
+KEY `key2` (`a`,`h`)
+) ENGINE=RocksDB;
+set @@sql_log_bin = 1;
+INSERT INTO t1 VALUES (1, 1, 1, 1, 'a', 1, 1, 1);
+SELECT * FROM t1;
+a b c d e f g h
+1 1 1 1 a 1 1 1
+SELECT * FROM t1;
+a b c d e f g x y h
+1 1 1 1 a 1 1 NULL NULL 1
+UPDATE t1 SET h = 10 WHERE h = 1;
+SELECT * FROM t1;
+a b c d e f g h
+1 1 1 1 a 1 1 10
+SELECT * FROM t1;
+a b c d e f g x y h
+1 1 1 1 a 1 1 NULL NULL 10
+SELECT COUNT(*) FROM t1 FORCE INDEX (key1) WHERE h = 10 AND a = 1;
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 FORCE INDEX (key2) WHERE h = 10 AND a = 1;
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 FORCE INDEX (PRIMARY) WHERE h = 10 AND a = 1;
+COUNT(*)
+1
+DROP TABLE t1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_mts_dependency_unique_key_conflicts.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_mts_dependency_unique_key_conflicts.result
new file mode 100644
index 00000000..0eadc7de
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_mts_dependency_unique_key_conflicts.result
@@ -0,0 +1,44 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+include/stop_slave.inc
+set @save.slave_parallel_workers= @@global.slave_parallel_workers;
+set @save.slave_use_idempotent_for_recovery= @@global.slave_use_idempotent_for_recovery;
+set @save.mts_dependency_replication= @@global.mts_dependency_replication;
+set @save.mts_dependency_order_commits= @@global.mts_dependency_order_commits;
+set @save.debug= @@global.debug;
+set @@global.slave_parallel_workers= 2;
+set @@global.slave_use_idempotent_for_recovery= YES;
+set @@global.mts_dependency_replication= STMT;
+set @@global.mts_dependency_order_commits= false;
+set @@global.debug= '+d,dbug.dep_wait_before_update_execution';
+include/start_slave.inc
+create table t1 (a int primary key, b int unique key) engine = rocksdb;
+insert into t1 values(1, 1);
+include/sync_slave_sql_with_master.inc
+include/stop_slave.inc
+update t1 set b = 2 where a = 1;
+insert into t1 values(2, 1);
+include/start_slave.inc
+set debug_sync="now wait_for signal.reached";
+select * from t1;
+a b
+1 1
+set debug_sync="now signal signal.done";
+include/sync_slave_sql_with_master.inc
+select * from t1;
+a b
+2 1
+1 2
+drop table t1;
+include/sync_slave_sql_with_master.inc
+include/stop_slave.inc
+set @@global.slave_parallel_workers= @save.slave_parallel_workers;
+set @@global.mts_dependency_replication= @save.mts_dependency_replication;
+set @@global.slave_use_idempotent_for_recovery= @save.slave_use_idempotent_for_recovery;
+set @@global.mts_dependency_order_commits= @save.mts_dependency_order_commits;
+set @@global.debug= @save.debug;
+include/start_slave.inc
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_no_unique_check_on_lag.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_no_unique_check_on_lag.result
new file mode 100644
index 00000000..905b56da
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_no_unique_check_on_lag.result
@@ -0,0 +1,34 @@
+#
+# Ensure skip_unique_check is set when lag exceeds lag_threshold
+#
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+call mtr.add_suppression("Slave SQL: Could not execute Write_rows event on table test.t1");
+call mtr.add_suppression(".*Worker.*failed executing transaction");
+call mtr.add_suppression(".*The slave coordinator and worker threads are stopped");
+drop table if exists t1;
+CREATE TABLE t1 (id int primary key, value int) engine=RocksDB;
+set global reset_seconds_behind_master=1;
+INSERT INTO t1 VALUES(1, 0);
+INSERT INTO t1 VALUES(2, 0);
+INSERT INTO t1 VALUES(3, 0);
+INSERT INTO t1 VALUES(1, 1);
+include/wait_for_slave_sql_error_and_skip.inc [errno=1062]
+set global reset_seconds_behind_master=0;
+include/stop_slave_io.inc
+INSERT INTO t1 values (4,0);
+INSERT INTO t1 VALUES(2, 1);
+include/start_slave_io.inc
+set global reset_seconds_behind_master=1;
+insert into t1 values (5,0);
+INSERT INTO t1 VALUES(3, 1);
+include/wait_for_slave_sql_error_and_skip.inc [errno=1062]
+#
+# Cleanup
+#
+DROP TABLE t1;
+set global reset_seconds_behind_master=1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_no_unique_check_on_lag_mts.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_no_unique_check_on_lag_mts.result
new file mode 100644
index 00000000..6c58cb16
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_no_unique_check_on_lag_mts.result
@@ -0,0 +1,31 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+call mtr.add_suppression("Slave SQL: Could not execute Write_rows event on table test.t1");
+call mtr.add_suppression(".*Worker.*failed executing transaction");
+call mtr.add_suppression(".*The slave coordinator and worker threads are stopped");
+drop table if exists t1;
+CREATE TABLE t1 (id int primary key, value int) engine=RocksDB;
+set global reset_seconds_behind_master=1;
+INSERT INTO t1 VALUES(1, 0);
+INSERT INTO t1 VALUES(2, 0);
+INSERT INTO t1 VALUES(3, 0);
+INSERT INTO t1 VALUES(1, 1);
+include/wait_for_slave_sql_error_and_skip.inc [errno=1062]
+set global reset_seconds_behind_master=0;
+include/stop_slave_io.inc
+INSERT INTO t1 values (4,0);
+INSERT INTO t1 VALUES(2, 1);
+include/start_slave_io.inc
+set global reset_seconds_behind_master=1;
+insert into t1 values (5,0);
+INSERT INTO t1 VALUES(3, 1);
+include/wait_for_slave_sql_error_and_skip.inc [errno=1062]
+#
+# Cleanup
+#
+DROP TABLE t1;
+set global reset_seconds_behind_master=1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_2pc_crash_recover.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_2pc_crash_recover.result
new file mode 100644
index 00000000..cf3fe03a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_2pc_crash_recover.result
@@ -0,0 +1,44 @@
+DROP TABLE IF EXISTS t1;
+create table t1 (a int primary key, msg varchar(255)) engine=rocksdb;
+SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
+SET SESSION debug_dbug="d,crash_commit_after_prepare";
+insert into t1 values (1, 'dogz');
+select * from t1;
+a msg
+SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
+SET SESSION debug_dbug="d,crash_commit_after_log";
+insert into t1 values (2, 'catz'), (3, 'men');
+select * from t1;
+a msg
+2 catz
+3 men
+SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
+SET SESSION debug_dbug="d,crash_commit_after";
+insert into t1 values (4, 'cars'), (5, 'foo');
+select * from t1;
+a msg
+2 catz
+3 men
+4 cars
+5 foo
+SET GLOBAL ROCKSDB_ENABLE_2PC = OFF;
+SET SESSION debug_dbug="d,crash_commit_after_log";
+insert into t1 values (6, 'shipz'), (7, 'tankz');
+select * from t1;
+a msg
+2 catz
+3 men
+4 cars
+5 foo
+SET GLOBAL ROCKSDB_ENABLE_2PC = OFF;
+SET SESSION debug_dbug="d,crash_commit_after";
+insert into t1 values (8, 'space'), (9, 'time');
+select * from t1;
+a msg
+2 catz
+3 men
+4 cars
+5 foo
+8 space
+9 time
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_slave_gtid_info_optimized.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_slave_gtid_info_optimized.result
new file mode 100644
index 00000000..1f6acf32
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_slave_gtid_info_optimized.result
@@ -0,0 +1,43 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+Make changes in master
+create table test1 (a int primary key, b int) engine=rocksdb;
+insert into test1 values (1, 1);
+Make sure slave is up-to-date and mysql.slave_gtid_info is good
+select * from test1;
+a b
+1 1
+select id, database_name, last_gtid from mysql.slave_gtid_info;
+id database_name last_gtid
+1 test UUID:2
+Make changes in master
+insert into test1 values (2, 2);
+Make sure slave is up-to-date and mysql.slave_gtid_info is good
+select @@slave_gtid_info;
+@@slave_gtid_info
+OPTIMIZED
+select * from test1;
+a b
+1 1
+2 2
+select * from mysql.slave_gtid_info;
+Id Database_name Last_gtid
+1 test UUID:3
+Make changes in master
+insert into test1 values (3, 3);
+insert into test1 values (4, 4);
+Make sure slave is up-to-date and mysql.slave_gtid_info is good
+select * from test1;
+a b
+1 1
+2 2
+3 3
+4 4
+select id, database_name, last_gtid from mysql.slave_gtid_info;
+id database_name last_gtid
+1 test UUID:5
+DROP TABLE IF EXISTS test1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_snapshot.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_snapshot.result
new file mode 100644
index 00000000..f5e861fe
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_snapshot.result
@@ -0,0 +1,222 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+DROP TABLE IF EXISTS t1;
+# Establish connection con1 (user=root)
+# Establish connection con2 (user=root)
+# Establish connection con3 (user=root)
+# Establish connection con4 (user=root)
+# reset replication to guarantee that master-bin.000001 is used
+include/stop_slave.inc
+RESET SLAVE;
+RESET MASTER;
+RESET MASTER;
+CHANGE MASTER TO master_host="127.0.0.1",master_port=MASTER_PORT,master_user="root";
+Warnings:
+Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note 1760 Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+include/start_slave.inc
+# Switch to connection con1
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 VALUES(1);
+SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+ERROR HY000: Only REPEATABLE READ isolation level is supported for START TRANSACTION WITH CONSISTENT|SHARED|EXISTING SNAPSHOT in RocksDB Storage Engine.
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+ERROR HY000: Only REPEATABLE READ isolation level is supported for START TRANSACTION WITH CONSISTENT|SHARED|EXISTING SNAPSHOT in RocksDB Storage Engine.
+ROLLBACK;
+SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+File Position Gtid_executed
+master-bin.000001 531 UUID:1-2
+# Switch to connection con2
+INSERT INTO t1 VALUES(2);
+INSERT INTO t1 VALUES(3);
+# Switch to connection con1
+SELECT * FROM t1;
+a
+1
+COMMIT;
+SELECT * FROM t1;
+a
+1
+2
+3
+DROP TABLE t1;
+# Switch to connection con1
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 VALUES(1);
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+File Position Gtid_executed
+master-bin.000001 1510 UUID:1-7
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+File Position Gtid_executed
+master-bin.000001 1510 UUID:1-7
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+File Position Gtid_executed
+master-bin.000001 1510 UUID:1-7
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+File Position Gtid_executed
+master-bin.000001 1510 UUID:1-7
+# Switch to connection con2
+INSERT INTO t1 VALUES(2);
+INSERT INTO t1 VALUES(3);
+# Switch to connection con1
+SELECT * FROM t1;
+a
+1
+SELECT * INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/rpl_rocksdb_snapshot.out.file' FROM t1;
+COMMIT;
+# Switch to slave
+CREATE TABLE t1_backup LIKE t1;
+INSERT INTO t1_backup SELECT * FROM t1;
+include/stop_slave.inc
+RESET SLAVE;
+RESET MASTER;
+DELETE FROM t1;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp/rpl_rocksdb_snapshot.out.file' INTO TABLE t1;
+SELECT * FROM t1;
+a
+1
+CHANGE MASTER TO master_host="127.0.0.1",master_port=MASTER_PORT,master_user="root",master_log_file="master-bin.000001",master_log_pos=binlog_pos;
+Warnings:
+Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note 1760 Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+include/start_slave.inc
+SELECT * FROM t1;
+a
+1
+2
+3
+SELECT * FROM t1_backup;
+a
+1
+2
+3
+DROP TABLE t1_backup;
+DROP TABLE t1;
+# Switch to connection con1
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 VALUES(1);
+# async queries from con2
+INSERT INTO t1 VALUES(2);
+# async queries from con3
+INSERT INTO t1 VALUES(21);
+# Switch to connection con1
+# Switch to connection con4
+INSERT INTO t1 VALUES(9);
+# Switch to connection con1
+SELECT * INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/rpl_rocksdb_snapshot.out.file' FROM t1;
+COMMIT;
+# reap async statements
+# Switch to slave
+CREATE TABLE t1_backup LIKE t1;
+INSERT INTO t1_backup SELECT * FROM t1;
+include/stop_slave.inc
+RESET SLAVE;
+RESET MASTER;
+DELETE FROM t1;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp/rpl_rocksdb_snapshot.out.file' INTO TABLE t1;
+CHANGE MASTER TO master_host="127.0.0.1",master_port=MASTER_PORT,master_user="root",master_log_file="master-bin.000001",master_log_pos=binlog_pos;
+Warnings:
+Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note 1760 Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+include/start_slave.inc
+# sync and then query slave
+ShouldBeZero
+0
+DROP TABLE t1_backup;
+DROP TABLE t1;
+# Switch to connection con1
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 VALUES(1);
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+File Position Gtid_executed
+master-bin.000001 3688 UUID:1-18
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+File Position Gtid_executed
+master-bin.000001 3688 UUID:1-18
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+File Position Gtid_executed
+master-bin.000001 3688 UUID:1-18
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+File Position Gtid_executed
+master-bin.000001 3688 UUID:1-18
+# Switch to connection con2
+INSERT INTO t1 VALUES(2);
+INSERT INTO t1 VALUES(3);
+# Switch to connection con1
+SELECT * FROM t1;
+a
+1
+SELECT * INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/rpl_rocksdb_snapshot.out.file' FROM t1;
+COMMIT;
+# Switch to slave
+CREATE TABLE t1_backup LIKE t1;
+INSERT INTO t1_backup SELECT * FROM t1;
+include/stop_slave.inc
+RESET SLAVE;
+RESET MASTER;
+SET @@global.gtid_purged='gtid_executed_from_snapshot';
+DELETE FROM t1;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp/rpl_rocksdb_snapshot.out.file' INTO TABLE t1;
+SELECT * FROM t1;
+a
+1
+CHANGE MASTER TO master_host="127.0.0.1",master_port=MASTER_PORT,master_user="root", master_auto_position=1;
+Warnings:
+Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note 1760 Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+include/start_slave.inc
+SELECT * FROM t1;
+a
+1
+2
+3
+SELECT * FROM t1_backup;
+a
+1
+2
+3
+DROP TABLE t1_backup;
+DROP TABLE t1;
+# Switch to connection con1
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 VALUES(1);
+# async queries from con2
+INSERT INTO t1 VALUES(2);
+# async queries from con3
+INSERT INTO t1 VALUES(21);
+# Switch to connection con1
+# Switch to connection con4
+INSERT INTO t1 VALUES(9);
+# Switch to connection con1
+SELECT * INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/rpl_rocksdb_snapshot.out.file' FROM t1;
+COMMIT;
+# reap async statements
+# Switch to slave
+CREATE TABLE t1_backup LIKE t1;
+INSERT INTO t1_backup SELECT * FROM t1;
+include/stop_slave.inc
+RESET SLAVE;
+RESET MASTER;
+SET @@global.gtid_purged='gtid_executed_from_snapshot';
+DELETE FROM t1;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp/rpl_rocksdb_snapshot.out.file' INTO TABLE t1;
+CHANGE MASTER TO master_host="127.0.0.1",master_port=MASTER_PORT,master_user="root", master_auto_position=1;
+Warnings:
+Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note 1760 Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+include/start_slave.inc
+# sync and then query slave
+ShouldBeZero
+0
+DROP TABLE t1_backup;
+DROP TABLE t1;
+# Switch to connection default + close connections con1 and con2
+include/stop_slave.inc
+CHANGE MASTER to master_auto_position=0;
+include/start_slave.inc
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_snapshot_without_gtid.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_snapshot_without_gtid.result
new file mode 100644
index 00000000..57c1d082
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_snapshot_without_gtid.result
@@ -0,0 +1,15 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+create table t1(a int primary key);
+FLUSH LOGS;
+insert into t1 values(1);
+insert into t1 values(2);
+FLUSH LOGS;
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+File Position Gtid_executed
+master-bin.000003 120
+drop table t1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_stress_crash.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_stress_crash.result
new file mode 100644
index 00000000..d4920b14
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_rocksdb_stress_crash.result
@@ -0,0 +1,28 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+call mtr.add_suppression(".*");
+include/stop_slave.inc
+change master to master_auto_position=1;
+include/start_slave.inc
+call mtr.add_suppression('Slave: Error dropping database');
+stop slave sql_thread;
+insert into test0.benchmark set state='slave is processing load';
+start slave sql_thread;
+use test0;
+insert into benchmark set state='slave ends load';
+use test;
+select * from test1.benchmark into outfile 'benchmark.out';
+select ts from test0.benchmark where state like 'master started load' into @m_0;
+select ts from test0.benchmark where state like 'master ends load' into @m_1;
+select ts from test0.benchmark where state like 'slave takes on load' into @s_m0;
+select ts from test0.benchmark where state like 'slave is supposed to finish with load' into @s_m1;
+select ts from test0.benchmark where state like 'slave ends load' into @s_1;
+select ts from test0.benchmark where state like 'slave is processing load' into @s_0;
+select time_to_sec(@m_1) - time_to_sec(@m_0) as 'delta.out';
+include/stop_slave.inc
+change master to master_auto_position=0;
+include/start_slave.inc
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_skip_trx_api_binlog_format.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_skip_trx_api_binlog_format.result
new file mode 100644
index 00000000..5559bf61
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_skip_trx_api_binlog_format.result
@@ -0,0 +1,27 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+call mtr.add_suppression("Master's binlog format is not ROW but rpl_skip_tx_api is enabled on the slave");
+set global rpl_skip_tx_api=ON;
+set global rocksdb_unsafe_for_binlog=1;
+create table t1(a int);
+set session binlog_format=STATEMENT;
+insert into t1 values(1);
+include/wait_for_slave_sql_error.inc [errno=1756]
+Last_SQL_Error = 'Master's binlog format is not ROW but rpl_skip_tx_api is enabled on the slave, this should only be used when master's binlog format is ROW.'
+"Table after error"
+select * from t1;
+a
+set global rpl_skip_tx_api=OFF;
+include/start_slave.inc
+include/sync_slave_sql_with_master.inc
+"Table after error fixed"
+select * from t1;
+a
+1
+drop table t1;
+set global rocksdb_unsafe_for_binlog=0;
+set global rpl_skip_tx_api=0;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_xa.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_xa.result
new file mode 100644
index 00000000..86f73f2f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_xa.result
@@ -0,0 +1,61 @@
+include/master-slave.inc
+[connection master]
+connection master;
+create table ti (a int, b int) engine=innodb;
+create table t1 (a int, b int) engine=rocksdb;
+insert into ti values(0, 0);
+insert into t1 values(0, 0);
+xa start 't';
+insert into ti values(1, 2);
+insert into t1 values(1, 2);
+xa end 't';
+xa prepare 't';
+xa commit 't';
+connection slave;
+include/diff_tables.inc [master:t1, slave:t1]
+connection master;
+xa start 't';
+insert into ti values(3, 4);
+insert into t1 values(3, 4);
+xa end 't';
+xa prepare 't';
+xa rollback 't';
+connection slave;
+include/diff_tables.inc [master:t1, slave:t1]
+connection master;
+SET pseudo_slave_mode=1;
+create table t2 (a int) engine=rocksdb;
+xa start 't';
+insert into ti values (5, 6);
+insert into t1 values (5, 6);
+xa end 't';
+xa prepare 't';
+xa start 's';
+insert into ti values (7, 8);
+insert into t2 values (0);
+xa end 's';
+xa prepare 's';
+include/save_master_gtid.inc
+connection slave;
+include/sync_with_master_gtid.inc
+xa recover;
+formatID gtrid_length bqual_length data
+1 1 0 t
+1 1 0 s
+connection master;
+xa commit 't';
+xa commit 's';
+SET pseudo_slave_mode=0;
+Warnings:
+Warning 1231 Slave applier execution mode not active, statement ineffective.
+xa start 'r';
+insert into t1 values(7, 8);
+xa end 'r';
+xa prepare 'r';
+xa commit 'r';
+connection slave;
+include/diff_tables.inc [master:t1, slave:t1]
+include/diff_tables.inc [master:t2, slave:t2]
+connection master;
+drop table ti, t1, t2;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/singledelete_idempotent_recovery.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/singledelete_idempotent_recovery.result
new file mode 100644
index 00000000..89e93f6b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/singledelete_idempotent_recovery.result
@@ -0,0 +1,25 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+call mtr.add_suppression("Recovery from master pos");
+drop table if exists r1;
+create table r1 (id1 int, id2 int, primary key (id1, id2), index i (id2)) engine=rocksdb;
+insert into r1 values (1, 1000);
+set global rocksdb_force_flush_memtable_now=1;
+include/rpl_start_server.inc [server_number=2]
+include/start_slave.inc
+insert into r1 values (2,2000);
+delete r1 from r1 force index (i) where id2=1000;
+select id1,id2 from r1 force index (primary) where id1=1 and id2=1000;
+id1 id2
+select id2 from r1 force index (i) where id1=1 and id2=1000;
+id2
+set global rocksdb_compact_cf='default';
+select id1,id2 from r1 force index (primary) where id1=1 and id2=1000;
+id1 id2
+select id2 from r1 force index (i) where id1=1 and id2=1000;
+id2
+drop table r1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/singledelete_idempotent_table.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/singledelete_idempotent_table.result
new file mode 100644
index 00000000..979e2cbf
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/singledelete_idempotent_table.result
@@ -0,0 +1,29 @@
+include/master-slave.inc
+[connection master]
+connection master;
+drop table if exists r1;
+create table r1 (id1 int, id2 int, primary key (id1, id2), index i (id2)) engine=rocksdb;
+insert into r1 values (1, 1000);
+set sql_log_bin=0;
+delete from r1 where id1=1 and id2=1000;
+set sql_log_bin=1;
+connection slave;
+connection slave;
+set global rocksdb_force_flush_memtable_now=1;
+connection master;
+insert into r1 values (1, 1000);
+connection slave;
+connection slave;
+delete r1 from r1 force index (i) where id2=1000;
+select id1,id2 from r1 force index (primary);
+id1 id2
+select id2 from r1 force index (i);
+id2
+set global rocksdb_compact_cf='default';
+select id1,id2 from r1 force index (primary);
+id1 id2
+select id2 from r1 force index (i);
+id2
+connection master;
+drop table r1;
+include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/rpl_1slave_base.cnf b/storage/rocksdb/mysql-test/rocksdb_rpl/rpl_1slave_base.cnf
new file mode 100644
index 00000000..ed8c77bc
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/rpl_1slave_base.cnf
@@ -0,0 +1,51 @@
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+!include include/default_client.cnf
+
+[mysqld.1]
+
+# Run the master.sh script before starting this process
+#!run-master-sh
+
+log-bin= master-bin
+
+loose-innodb
+
+[mysqld.2]
+# Run the slave.sh script before starting this process
+#!run-slave-sh
+
+# Append <testname>-slave.opt file to the list of argument used when
+# starting the mysqld
+#!use-slave-opt
+innodb_use_native_aio = 0
+
+log-bin= slave-bin
+relay-log= slave-relay-bin
+
+log-slave-updates
+master-retry-count= 10
+
+# Values reported by slave when it connect to master
+# and shows up in SHOW SLAVE STATUS;
+report-host= 127.0.0.1
+report-port= @mysqld.2.port
+report-user= root
+
+skip-slave-start
+
+# Directory where slaves find the dumps generated by "load data"
+# on the server. The path need to have constant length otherwise
+# test results will vary, thus a relative path is used.
+slave-load-tmpdir= ../../tmp
+
+loose-innodb
+
+
+[ENV]
+MASTER_MYPORT= @mysqld.1.port
+MASTER_MYSOCK= @mysqld.1.socket
+
+SLAVE_MYPORT= @mysqld.2.port
+SLAVE_MYSOCK= @mysqld.2.socket
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/suite.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/suite.opt
new file mode 100644
index 00000000..761a2108
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/suite.opt
@@ -0,0 +1 @@
+--ignore-db-dirs=.rocksdb --plugin-load=$HA_ROCKSDB_SO --default-storage-engine=rocksdb
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/suite.pm b/storage/rocksdb/mysql-test/rocksdb_rpl/suite.pm
new file mode 100644
index 00000000..1cc123b2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/suite.pm
@@ -0,0 +1,25 @@
+package My::Suite::Rocksdb;
+
+#
+# Note: ../rocksdb_sys_vars/suite.pm file has a similar
+# function. If you modify this file, consider modifying that one, too.
+#
+@ISA = qw(My::Suite);
+use My::Find;
+use File::Basename;
+use strict;
+
+#sub is_default { not $::opt_embedded_server }
+
+my $sst_dump=
+::mtr_exe_maybe_exists(
+ "$::bindir/storage/rocksdb$::opt_vs_config/sst_dump",
+ "$::path_client_bindir/sst_dump");
+return "RocksDB is not compiled, no sst_dump" unless $sst_dump;
+$ENV{MARIAROCKS_SST_DUMP}="$sst_dump";
+
+# Temporarily disable testing under valgrind, due to MDEV-12439
+return "RocksDB tests disabled under valgrind" if ($::opt_valgrind);
+
+bless { };
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/consistent_snapshot_mixed_engines-master.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/consistent_snapshot_mixed_engines-master.opt
new file mode 100644
index 00000000..c747adc9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/consistent_snapshot_mixed_engines-master.opt
@@ -0,0 +1 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_bin --log_slave_updates
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/consistent_snapshot_mixed_engines.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/consistent_snapshot_mixed_engines.test
new file mode 100644
index 00000000..acea1903
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/consistent_snapshot_mixed_engines.test
@@ -0,0 +1,81 @@
+--source include/have_log_bin.inc
+--source include/have_rocksdb.inc
+--source include/have_innodb.inc
+--enable_connect_log
+-- let $uuid = `select @@server_uuid;`
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+create table i1 (id int primary key , value int) engine=innodb;
+create table r1 (id int primary key , value int) engine=rocksdb;
+
+
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+
+# Without setting engine, this takes both InnoDB and RocksDB snapshots
+-- replace_result $uuid uuid
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+
+connection con2;
+insert into i1 values (1,1);
+insert into r1 values (1,1);
+
+connection con1;
+select * from i1;
+select * from r1;
+
+# This takes RocksDB snapshot only but both InnoDB participates in transaction.
+-- replace_result $uuid uuid
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+
+connection con2;
+insert into i1 values (2,2);
+insert into r1 values (2,2);
+
+connection con1;
+# takes InnoDB snapshot here so changes after that not visible
+select * from i1;
+select * from r1;
+
+connection con2;
+insert into i1 values (3,2);
+insert into r1 values (3,2);
+
+connection con1;
+select * from i1;
+select * from r1;
+
+# RocksDB also partipates in transaction
+-- replace_result $uuid uuid
+START TRANSACTION WITH CONSISTENT INNODB SNAPSHOT;
+
+connection con2;
+insert into r1 values (4,4);
+
+connection con1;
+# takes RocksDB snapshot here so changes after that are not visible
+select * from r1;
+
+connection con2;
+insert into r1 values (5,5);
+
+connection con1;
+select * from r1;
+
+drop table i1;
+drop table r1;
+
+connection default;
+disconnect con1;
+disconnect con2;
+reset master;
+--source include/wait_until_count_sessions.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def
new file mode 100644
index 00000000..2147e3e0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def
@@ -0,0 +1,34 @@
+##
+## Tests that require FB/MySQL specific features for which there are
+## no plans to port them to MariaDB
+##
+rpl_no_unique_check_on_lag : unique_check_lag_threshold is not available in MariaDB
+rpl_no_unique_check_on_lag_mts : unique_check_lag_threshold is not available in MariaDB
+consistent_snapshot_mixed_engines : Tests START TRANSACTION WITH CONSISTENT $ENGINE_NAME SNAPSHOT
+rpl_skip_trx_api_binlog_format : requires @@rpl_skip_tx_api
+rpl_ddl_high_priority : DDL commands with HIGH_PRIORITY syntax are not in MariaDB
+rpl_gtid_rocksdb_sys_header : MariaDB doesn't support printing "RocksDB: Last MySQL Gtid UUID" into server stderr on startup
+singledelete_idempotent_recovery: MariaDB doesn't support --slave-use-idempotent-for-recovery
+rpl_mts_dependency_unique_key_conflicts: MariaDB doesn't support --slave-use-idempotent-for-recovery
+rpl_missing_columns_sk_update : Uses log_column_names=ON feature which is only present in FB/MySQL
+optimize_myrocks_replace_into: requires @@enable_blind_replace support.
+rpl_gtid_crash_safe_optimized: requires slave_gtid_info=optimized
+
+##
+## Tests that do not fit MariaDB's test environment (Functional tests only,
+## can't have stress tests)
+##
+rpl_rocksdb_stress_crash : Stress test
+
+##
+## Tests that are disabled for other reasons
+##
+
+multiclient_2pc : Didn't try with MariaDB, yet
+rpl_crash_safe_wal_corrupt : Didn't try with MariaDB, yet
+rpl_gtid_crash_safe : Didn't try with MariaDB, yet
+rpl_gtid_crash_safe_wal_corrupt : Didn't try with MariaDB, yet
+rpl_rocksdb_snapshot : Didn't try with MariaDB, yet
+rpl_rocksdb_snapshot_without_gtid : Didn't try with MariaDB, yet
+rpl_rocksdb_slave_gtid_info_optimized: requires slave-gtid-info=optimized which is an FB/MySQL-only feature
+rocksdb_slave_check_before_image_consistency: requires slave_check_before_image_consistency feature
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/mdev12179.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/mdev12179.test
new file mode 100644
index 00000000..845f1558
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/mdev12179.test
@@ -0,0 +1,317 @@
+--source include/have_rocksdb.inc
+--source include/have_innodb.inc
+--source include/master-slave.inc
+
+--connection server_2
+--source include/stop_slave.inc
+
+# Set GTID cleanup limit high enough that cleanup will not run and we
+# can rely on consistent table output in .result.
+--let $old_gtid_cleanup_batch_size=`SELECT @@GLOBAL.gtid_cleanup_batch_size`
+SET GLOBAL gtid_cleanup_batch_size = 999999999;
+
+CHANGE MASTER TO master_use_gtid=slave_pos;
+SET sql_log_bin=0;
+CREATE TABLE mysql.gtid_slave_pos_innodb LIKE mysql.gtid_slave_pos;
+ALTER TABLE mysql.gtid_slave_pos_innodb ENGINE=InnoDB;
+CREATE TABLE mysql.gtid_slave_pos_rocksdb LIKE mysql.gtid_slave_pos;
+ALTER TABLE mysql.gtid_slave_pos_rocksdb ENGINE=rocksdb;
+CREATE TABLE mysql.gtid_slave_pos_myisam_redundant LIKE mysql.gtid_slave_pos;
+CREATE TABLE mysql.gtid_slave_pos_innodb_redundant LIKE mysql.gtid_slave_pos;
+ALTER TABLE mysql.gtid_slave_pos_innodb_redundant ENGINE=InnoDB;
+call mtr.add_suppression("Ignoring redundant table.*since.*has the same storage engine");
+--source include/start_slave.inc
+
+--connection server_1
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=MyISAM;
+CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t3 (a INT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t3 VALUES (1);
+SELECT * FROM t1 ORDER BY a;
+SELECT * FROM t2 ORDER BY a;
+SELECT * FROM t3 ORDER BY a;
+--save_master_pos
+
+--connection server_2
+--sync_with_master
+SELECT * FROM t1 ORDER BY a;
+SELECT * FROM t2 ORDER BY a;
+SELECT * FROM t3 ORDER BY a;
+SELECT * FROM mysql.gtid_slave_pos ORDER BY sub_id;
+SELECT * FROM ( SELECT * FROM mysql.gtid_slave_pos_innodb
+ UNION ALL SELECT * FROM mysql.gtid_slave_pos_innodb_redundant) inner_select
+ ORDER BY sub_id;
+SELECT * FROM mysql.gtid_slave_pos_rocksdb ORDER BY sub_id;
+
+
+# Test status variable Transactions_multi_engine.
+--connection server_2
+FLUSH NO_WRITE_TO_BINLOG STATUS;
+SET sql_log_bin=0;
+SHOW STATUS LIKE "Transactions_multi_engine";
+INSERT INTO t1 VALUES (100);
+SHOW STATUS LIKE "Transactions_multi_engine";
+INSERT INTO t2 VALUES (101);
+SHOW STATUS LIKE "Transactions_multi_engine";
+INSERT INTO t3 VALUES (101);
+SHOW STATUS LIKE "Transactions_multi_engine";
+BEGIN;
+INSERT INTO t3 VALUES (102);
+INSERT INTO t2 VALUES (103);
+COMMIT;
+SHOW STATUS LIKE "Transactions_multi_engine";
+BEGIN;
+INSERT INTO t2 VALUES (104);
+INSERT INTO t3 VALUES (105);
+COMMIT;
+SHOW STATUS LIKE "Transactions_multi_engine";
+UPDATE t2, t3 SET t2.a=106, t3.a=107 WHERE t2.a=104 AND t3.a=105;
+SHOW STATUS LIKE "Transactions_multi_engine";
+# Try again with binlog enabled.
+SET sql_log_bin=1;
+INSERT INTO t1 VALUES (200);
+SHOW STATUS LIKE "Transactions_multi_engine";
+INSERT INTO t2 VALUES (201);
+SHOW STATUS LIKE "Transactions_multi_engine";
+INSERT INTO t3 VALUES (201);
+SHOW STATUS LIKE "Transactions_multi_engine";
+BEGIN;
+INSERT INTO t3 VALUES (202);
+INSERT INTO t2 VALUES (203);
+COMMIT;
+SHOW STATUS LIKE "Transactions_multi_engine";
+BEGIN;
+INSERT INTO t2 VALUES (204);
+INSERT INTO t3 VALUES (205);
+COMMIT;
+SHOW STATUS LIKE "Transactions_multi_engine";
+UPDATE t2, t3 SET t2.a=206, t3.a=207 WHERE t2.a=204 AND t3.a=205;
+SHOW STATUS LIKE "Transactions_multi_engine";
+
+DELETE FROM t1 WHERE a >= 100;
+DELETE FROM t2 WHERE a >= 100;
+DELETE FROM t3 WHERE a >= 100;
+
+
+# Create a bunch more GTIDs in mysql.gtid_slave_pos* tables to test with.
+--connection server_1
+--disable_query_log
+let $i=10;
+while ($i) {
+ eval INSERT INTO t1 VALUES (300+$i);
+ eval INSERT INTO t2 VALUES (300+$i);
+ eval INSERT INTO t3 VALUES (300+$i);
+ dec $i;
+}
+--enable_query_log
+--source include/save_master_gtid.inc
+
+--connection server_2
+--source include/sync_with_master_gtid.inc
+
+# Check that we have many rows in mysql.gtid_slave_pos now (since
+# @@gtid_cleanup_batch_size was set to a huge value). No need to check
+# for an exact number, since that will require changing .result if
+# anything changes prior to this point, and we just need to know that
+# we have still have some data in the tables to make the following
+# test effective.
+SELECT COUNT(*)>=10 FROM mysql.gtid_slave_pos;
+SELECT COUNT(*)>=10 FROM ( SELECT * FROM mysql.gtid_slave_pos_innodb
+ UNION ALL SELECT * FROM mysql.gtid_slave_pos_innodb_redundant) inner_select;
+SELECT COUNT(*)>=10 FROM mysql.gtid_slave_pos_rocksdb;
+
+# Check that old GTID rows will be deleted when batch delete size is
+# set reasonably. Old row deletion is not 100% deterministic (by design), so
+# we must wait for it to occur, but it should occur eventually.
+SET GLOBAL gtid_cleanup_batch_size = 3;
+let $i=40;
+--disable_query_log
+--let $keep_include_silent=1
+while ($i) {
+ let N=`SELECT 1+($i MOD 3)`;
+ --connection server_1
+ eval UPDATE t$N SET a=a+1 WHERE a=(SELECT MAX(a) FROM t$N);
+ --source include/save_master_gtid.inc
+ --connection server_2
+ --source include/sync_with_master_gtid.inc
+ let $j=50;
+ while ($j) {
+ let $is_done=`SELECT SUM(a)=1 FROM (
+ SELECT COUNT(*) AS a FROM mysql.gtid_slave_pos
+ UNION ALL
+ SELECT COUNT(*) AS a FROM ( SELECT * FROM mysql.gtid_slave_pos_innodb
+ UNION ALL SELECT * FROM mysql.gtid_slave_pos_innodb_redundant) inner_select
+ UNION ALL
+ SELECT COUNT(*) AS a FROM mysql.gtid_slave_pos_rocksdb) outer_select`;
+ if ($is_done) {
+ let $j=0;
+ }
+ if (!$is_done) {
+ real_sleep 0.1;
+ dec $j;
+ }
+ }
+ dec $i;
+ if ($is_done) {
+ let $i=0;
+ }
+}
+--enable_query_log
+--let $keep_include_silent=0
+if (!$is_done) {
+ --echo Timed out waiting for mysql.gtid_slave_pos* tables to be cleaned up
+}
+
+--disable_query_log
+DELETE FROM t1 WHERE a >= 100;
+DELETE FROM t2 WHERE a >= 100;
+DELETE FROM t3 WHERE a >= 100;
+--enable_query_log
+
+
+# Test status variables Rpl_transactions_multi_engine and Transactions_gtid_foreign_engine.
+# Have mysql.gtid_slave_pos* for myisam and innodb but not rocksdb.
+--connection server_2
+--source include/stop_slave.inc
+SET sql_log_bin=0;
+DROP TABLE mysql.gtid_slave_pos_rocksdb;
+DROP TABLE mysql.gtid_slave_pos_myisam_redundant;
+DROP TABLE mysql.gtid_slave_pos_innodb_redundant;
+SET sql_log_bin=1;
+FLUSH NO_WRITE_TO_BINLOG STATUS;
+--source include/start_slave.inc
+SHOW STATUS LIKE "%transactions%engine";
+
+--connection server_1
+INSERT INTO t1 VALUES (100);
+--save_master_pos
+--connection server_2
+--sync_with_master
+SHOW STATUS LIKE "%transactions%engine";
+
+--connection server_1
+INSERT INTO t2 VALUES (101);
+--save_master_pos
+--connection server_2
+--sync_with_master
+SHOW STATUS LIKE "%transactions%engine";
+
+--connection server_1
+INSERT INTO t3 VALUES (101);
+--save_master_pos
+--connection server_2
+--sync_with_master
+SHOW STATUS LIKE "%transactions%engine";
+
+--connection server_1
+BEGIN;
+INSERT INTO t3 VALUES (102);
+INSERT INTO t2 VALUES (103);
+COMMIT;
+--save_master_pos
+--connection server_2
+--sync_with_master
+SHOW STATUS LIKE "%transactions%engine";
+
+--connection server_1
+BEGIN;
+INSERT INTO t2 VALUES (104);
+INSERT INTO t3 VALUES (105);
+COMMIT;
+--save_master_pos
+--connection server_2
+--sync_with_master
+SHOW STATUS LIKE "%transactions%engine";
+
+--connection server_1
+UPDATE t2, t3 SET t2.a=106, t3.a=107 WHERE t2.a=104 AND t3.a=105;
+--save_master_pos
+--connection server_2
+--sync_with_master
+SHOW STATUS LIKE "%transactions%engine";
+
+# Now the same thing, but without binlogging on the slave.
+--connection server_2
+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+wait
+EOF
+--shutdown_server
+--source include/wait_until_disconnected.inc
+
+# Restart without binary log.
+--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+restart: --skip-log-bin
+EOF
+
+--connection server_2
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+SHOW VARIABLES LIKE 'log_bin';
+--source include/start_slave.inc
+SHOW STATUS LIKE "%transactions%engine";
+
+--connection server_1
+INSERT INTO t1 VALUES (200);
+--save_master_pos
+--connection server_2
+--sync_with_master
+SHOW STATUS LIKE "%transactions%engine";
+
+--connection server_1
+INSERT INTO t2 VALUES (201);
+--save_master_pos
+--connection server_2
+--sync_with_master
+SHOW STATUS LIKE "%transactions%engine";
+
+--connection server_1
+INSERT INTO t3 VALUES (201);
+--save_master_pos
+--connection server_2
+--sync_with_master
+SHOW STATUS LIKE "%transactions%engine";
+
+--connection server_1
+BEGIN;
+INSERT INTO t3 VALUES (202);
+INSERT INTO t2 VALUES (203);
+COMMIT;
+--save_master_pos
+--connection server_2
+--sync_with_master
+SHOW STATUS LIKE "%transactions%engine";
+
+--connection server_1
+BEGIN;
+INSERT INTO t2 VALUES (204);
+INSERT INTO t3 VALUES (205);
+COMMIT;
+--save_master_pos
+--connection server_2
+--sync_with_master
+SHOW STATUS LIKE "%transactions%engine";
+
+--connection server_1
+UPDATE t2, t3 SET t2.a=206, t3.a=207 WHERE t2.a=204 AND t3.a=205;
+--save_master_pos
+--connection server_2
+--sync_with_master
+SHOW STATUS LIKE "%transactions%engine";
+
+
+--connection server_2
+SET sql_log_bin=0;
+DROP TABLE mysql.gtid_slave_pos_innodb;
+SET sql_log_bin=1;
+--disable_query_log
+eval SET GLOBAL gtid_cleanup_batch_size = $old_gtid_cleanup_batch_size;
+--enable_query_log
+
+--connection server_1
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+
+--source include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/multiclient_2pc-master.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/multiclient_2pc-master.opt
new file mode 100644
index 00000000..c747adc9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/multiclient_2pc-master.opt
@@ -0,0 +1 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_bin --log_slave_updates
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/multiclient_2pc.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/multiclient_2pc.test
new file mode 100644
index 00000000..ff484171
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/multiclient_2pc.test
@@ -0,0 +1,77 @@
+--source include/have_rocksdb.inc
+--source include/have_binlog_format_row.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+--source include/big_test.inc
+# The test involves a crash which does not seem to be handled well with
+# mysql-test/lib/My/SafeProcess/my_safe_process under valgrind as it hangs
+# forever. The test did not mean to verify the memory leaks so not much
+# coverage should be missed by not running it under valgrind.
+--source include/not_valgrind.inc
+
+--exec echo > $MYSQLTEST_VARDIR/log/mysqld.1.err
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Set it to the minimum so that we can make the binlog rotate with a few inserts
+SET GLOBAL MAX_BINLOG_SIZE = 4096;
+SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
+create table t1 (a int primary key, b int, c varchar(255)) engine=rocksdb;
+
+connect (con1, localhost, root,,);
+connect (con2, localhost, root,,);
+
+# On connection one we insert a row and pause after prepare marker is written to
+# WAL. Connection two then inserts many rows to rotate the binlog. After
+# connection two completes, connection one continues only to crash before commit
+# but after binlog write. On crash recovery we see that connection one's value
+# has been recovered and commited
+connection con1;
+--echo 'con1'
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug="d,crash_commit_after_log";
+SET DEBUG_SYNC='rocksdb.prepared SIGNAL parked WAIT_FOR go';
+--error 0,2013
+--send insert into t1 values (1, 1, "iamtheogthealphaandomega");
+
+connection con2;
+--echo 'con2'
+insert into t1 values (2, 1, "i_am_just_here_to_trigger_a_flush");
+
+# Disable 2PC and syncing for faster inserting of dummy rows
+# These rows only purpose is to rotate the binlog
+SET GLOBAL ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT = 0;
+SET GLOBAL SYNC_BINLOG = 0;
+
+SET DEBUG_SYNC='now WAIT_FOR parked';
+--disable_query_log
+--let $pk= 3
+# binlog size is 4096 bytes so with that many insertion it will definitely rotate
+while ($pk < 4096) {
+ eval insert into t1 values ($pk, 1, "foobardatagoesheresothatmorelogsrollwhichiswhatwewant");
+ --inc $pk
+}
+--enable_query_log
+
+# re-enable 2PC an syncing then write to trigger a flush
+# before we trigger the crash to simulate full-durability
+SET GLOBAL ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT = 2;
+SET GLOBAL SYNC_BINLOG = 1;
+
+insert into t1 values (1000000, 1, "i_am_just_here_to_trigger_a_flush");
+
+--error 0,2013
+SET DEBUG_SYNC='now SIGNAL go';
+--source include/wait_until_disconnected.inc
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+
+--exec python suite/rocksdb/t/check_log_for_xa.py $MYSQLTEST_VARDIR/log/mysqld.1.err commit,prepare,rollback
+
+select * from t1 where a=1;
+select count(*) from t1;
+
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/optimize_myrocks_replace_into.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/optimize_myrocks_replace_into.test
new file mode 100644
index 00000000..82b231d4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/optimize_myrocks_replace_into.test
@@ -0,0 +1,149 @@
+--source include/have_rocksdb.inc
+--source include/master-slave.inc
+--source include/have_debug.inc
+
+connection master;
+SET @prior_rocksdb_perf_context_level = @@rocksdb_perf_context_level;
+SET GLOBAL rocksdb_perf_context_level=3;
+SET GLOBAL enable_blind_replace=ON;
+
+# Create and insert some rows in a table
+create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
+insert into t1 values(1,1),(2,2),(3,3);
+select * from t1;
+
+# Create table which has a trigger only in slave
+create table t2(c1 int,c2 int, primary key (c1)) engine=rocksdb;
+insert into t2 values(1,1),(2,2),(3,3);
+select * from t2;
+
+# Create table which has a secondary key only in slave
+create table t3(c1 int,c2 int, primary key (c1)) engine=rocksdb;
+insert into t3 values(1,1),(2,2),(3,3);
+select * from t3;
+
+sync_slave_with_master;
+
+# Enable blind replace in both slave and master
+connection slave;
+SET GLOBAL enable_blind_replace=ON;
+create trigger trg before insert on t2 for each row set @a:=1;
+alter table t3 add constraint slave_unique_key unique (c2);
+
+connection master;
+
+sync_slave_with_master;
+--echo connect slave
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+
+# Case 1 - 'replace into' on a table with no triggers or secondary keys. Blind replace optimization should kick in both in master and slave
+--echo Case 1
+connection master;
+--echo connect master
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+
+replace into t1 values(1,11);
+replace into t1 values(2,22);
+replace into t1 values(3,33);
+select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+
+select * from t1;
+
+sync_slave_with_master;
+--echo connect slave
+select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+select * from t1;
+
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+
+# Case 2 - Multiple replaces in a single statement. blind replace optimization should kick in
+connection master;
+--echo Case 2
+--echo connect master
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t1 values(2,44),(3,55);
+select case when variable_value-@d > 2 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+select * from t1;
+
+sync_slave_with_master;
+--echo connect slave
+select case when variable_value-@d > 2 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+select * from t1;
+
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+
+# Case 3 - A regular update. This is not a blind replace
+--echo Case 3
+connection master;
+--echo connect master
+update t1 set c2=66 where c1=3;
+select * from t1;
+
+sync_slave_with_master;
+--echo connect slave
+select * from t1;
+
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+
+# Case 4 - Slave has trigger on its table. No triggers on the table in master.
+# Blind replace optimization should kick in on master.
+# Slave should convert this statement into a regular update
+--echo Case 4
+connection master;
+--echo connect master
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t2 values(1,111);
+replace into t2 values(2,222);
+replace into t2 values(3,333);
+select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+select * from t2;
+
+sync_slave_with_master;
+--echo connect slave
+select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+select * from t2;
+
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+
+# Case 5 - Slave has secondary keys on the table. No secondary keys on the table in master
+# Blind replace optimization should kick in on master.
+# Slave should convert this statement into a regular delete_insert
+--echo Case 5
+connection master;
+--echo connect master
+select variable_value into @d from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+replace into t3 values(1,1111);
+replace into t3 values(2,2222);
+replace into t3 values(3,3333);
+select * from t3;
+
+select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+
+sync_slave_with_master;
+--echo connect slave
+select case when variable_value-@d > 3 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
+select * from t3;
+select * from t3 use index (slave_unique_key);
+
+# Case 6 - Just to verify all binlog events.
+# blind replace will generate a write_rows event.
+# Or else, it will be a update_rows event or a delete_rows_write_rows event
+--echo Case 6
+connection master;
+--source include/show_binlog_events.inc
+
+connection slave;
+--source include/show_binlog_events.inc
+
+# Cleanup
+connection master;
+drop table t1;
+drop table t2;
+drop table t3;
+SET GLOBAL rocksdb_perf_context_level = @prior_rocksdb_perf_context_level;
+SET GLOBAL enable_blind_replace=DEFAULT;
+
+connection slave;
+SET GLOBAL enable_blind_replace=DEFAULT;
+
+--source include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rocksdb_slave_check_before_image_consistency-slave.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rocksdb_slave_check_before_image_consistency-slave.opt
new file mode 100644
index 00000000..78b517e9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rocksdb_slave_check_before_image_consistency-slave.opt
@@ -0,0 +1 @@
+--slave_check_before_image_consistency=ON
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rocksdb_slave_check_before_image_consistency.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rocksdb_slave_check_before_image_consistency.test
new file mode 100644
index 00000000..d7db127a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rocksdb_slave_check_before_image_consistency.test
@@ -0,0 +1,22 @@
+source include/master-slave.inc;
+source include/have_binlog_format_row.inc;
+
+call mtr.add_suppression("Error_code: 1032");
+
+let $engine= rocksdb;
+
+source extra/rpl_tests/rpl_slave_check_before_image_consistency.inc;
+
+# check detection with HASH_SCAN enabled
+connection slave;
+source include/stop_slave.inc;
+set @@global.slave_rows_search_algorithms = 'INDEX_SCAN,TABLE_SCAN,HASH_SCAN';
+source include/start_slave.inc;
+source extra/rpl_tests/rpl_slave_check_before_image_consistency.inc;
+
+# cleanup
+source include/stop_slave.inc;
+set @@global.slave_rows_search_algorithms = DEFAULT;
+source include/start_slave.inc;
+
+source include/rpl_end.inc;
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count-master.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count-master.opt
new file mode 100644
index 00000000..ed50a8a3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count-master.opt
@@ -0,0 +1,3 @@
+--innodb --max-binlog-size=4096
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count.test
new file mode 100644
index 00000000..7667f153
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count.test
@@ -0,0 +1,20 @@
+--source include/have_rocksdb.inc
+--source include/have_binlog_format_row.inc
+
+CREATE TABLE `t` (
+ `a` text DEFAULT NULL
+) ENGINE=ROCKSDB;
+
+
+--let $size=`SELECT @@GLOBAL.max_binlog_size`
+--let $loop_cnt= 100
+while ($loop_cnt)
+{
+ --eval INSERT INTO t SET a=repeat('a', $size)
+ --eval INSERT INTO t SET a=repeat('a', $size/2)
+
+ --dec $loop_cnt
+}
+
+# Cleanup
+DROP TABLE t;
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_check_for_binlog_info.pl b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_check_for_binlog_info.pl
new file mode 100644
index 00000000..a5e4d9d8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_check_for_binlog_info.pl
@@ -0,0 +1,19 @@
+my $pid_file = $ARGV[0];
+my $log_file = $ARGV[1];
+
+open(my $fh, '<', $pid_file) || die "Cannot open pid file $pid_file";
+my $slave_pid = <$fh>;
+close($fh);
+
+$slave_pid =~ s/\s//g;
+open(my $log_fh, '<', $log_file) || die "Cannot open log file $log_file";
+
+my $pid_found = 0;
+while (my $line = <$log_fh>) {
+ next unless ($pid_found || $line =~ /^[\d-]* [\d:]* $slave_pid /);
+ $pid_found = 1 unless ($pid_found);
+ if ($line =~ /^RocksDB: Last binlog file position.*slave-bin\..*\n/) {
+ print "Binlog Info Found\n";
+ }
+}
+close($log_fh);
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_crash_safe_wal_corrupt.cnf b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_crash_safe_wal_corrupt.cnf
new file mode 100644
index 00000000..bbffb0ec
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_crash_safe_wal_corrupt.cnf
@@ -0,0 +1,13 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+log_slave_updates
+rocksdb_enable_2pc=OFF
+rocksdb_wal_recovery_mode=2
+
+[mysqld.2]
+relay_log_recovery=1
+relay_log_info_repository=TABLE
+log_slave_updates
+rocksdb_enable_2pc=OFF
+rocksdb_wal_recovery_mode=2
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_crash_safe_wal_corrupt.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_crash_safe_wal_corrupt.test
new file mode 100644
index 00000000..0e40e542
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_crash_safe_wal_corrupt.test
@@ -0,0 +1,12 @@
+--source suite/rocksdb_rpl/t/rpl_gtid_crash_safe_wal_corrupt.inc
+
+connection slave;
+--let slave_pid_file= query_get_value(SELECT @@pid_file, @@pid_file, 1)
+
+# Verify the log file contains the Last binlog line, but only if the slave server's pid is found
+--exec perl suite/rocksdb_rpl/t/rpl_check_for_binlog_info.pl $slave_pid_file $MYSQLTEST_VARDIR/log/mysqld.2.err
+
+--disable_query_log
+connection slave;
+call mtr.add_suppression("Recovery from master pos");
+--enable_query_log
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_ddl_high_priority.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_ddl_high_priority.test
new file mode 100644
index 00000000..7cf4a4d3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_ddl_high_priority.test
@@ -0,0 +1,2 @@
+--source include/have_rocksdb.inc
+--source include/rpl_ddl_high_priority.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe-master.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe-master.opt
new file mode 100644
index 00000000..397310d3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe-master.opt
@@ -0,0 +1 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_slave_updates --rocksdb_enable_2pc=OFF
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe-slave.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe-slave.opt
new file mode 100644
index 00000000..3f959684
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe-slave.opt
@@ -0,0 +1,2 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_slave_updates --rocksdb_enable_2pc=OFF
+--sync_binlog=1000 --relay_log_recovery=1
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe.test
new file mode 100644
index 00000000..5a3e665a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe.test
@@ -0,0 +1,11 @@
+-- source include/have_rocksdb.inc
+-- source include/have_gtid.inc
+-- source include/master-slave.inc
+-- source include/have_debug.inc
+-- source include/not_valgrind.inc
+
+if (`select count(*) = 1 from information_schema.global_variables where variable_name = 'slave_gtid_info' and variable_value = 'optimized';`) {
+ --skip Test does not support row_write_committed_slave_gtid_optimized policy due to subtle behavioral differences. rpl_gtid_crash_safe_optimized covers slave_gtid_info=optimized.
+}
+
+-- source ../include/rpl_gtid_crash_safe.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_optimized-master.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_optimized-master.opt
new file mode 100644
index 00000000..397310d3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_optimized-master.opt
@@ -0,0 +1 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_slave_updates --rocksdb_enable_2pc=OFF
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_optimized-slave.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_optimized-slave.opt
new file mode 100644
index 00000000..e41dcc5e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_optimized-slave.opt
@@ -0,0 +1,2 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_slave_updates --rocksdb_enable_2pc=OFF
+--sync_binlog=1000 --relay_log_recovery=1 --slave_gtid_info=optimized
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_optimized.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_optimized.test
new file mode 100644
index 00000000..c2624032
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_optimized.test
@@ -0,0 +1,11 @@
+-- source include/have_rocksdb.inc
+-- source include/have_gtid.inc
+-- source include/master-slave.inc
+-- source include/have_debug.inc
+-- source include/not_valgrind.inc
+
+if (`select count(*) = 0 from information_schema.global_variables where variable_name = 'slave_gtid_info' and variable_value = 'optimized';`) {
+ --skip Test requires row_write_committed_slave_gtid_optimized policy where slave_gtid_info=optimized
+}
+
+-- source ../include/rpl_gtid_crash_safe.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_wal_corrupt.cnf b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_wal_corrupt.cnf
new file mode 100644
index 00000000..457665f9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_wal_corrupt.cnf
@@ -0,0 +1,18 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+log_slave_updates
+gtid_mode=ON
+enforce_gtid_consistency=ON
+rocksdb_enable_2pc=OFF
+rocksdb_wal_recovery_mode=2
+
+[mysqld.2]
+sync_relay_log_info=100
+relay_log_recovery=1
+relay_log_info_repository=FILE
+log_slave_updates
+gtid_mode=ON
+enforce_gtid_consistency=ON
+rocksdb_enable_2pc=OFF
+rocksdb_wal_recovery_mode=2
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_wal_corrupt.inc b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_wal_corrupt.inc
new file mode 100644
index 00000000..16ad535f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_wal_corrupt.inc
@@ -0,0 +1,154 @@
+source include/have_rocksdb.inc;
+source include/master-slave.inc;
+-- let $uuid = `select @@server_uuid;`
+
+--exec echo > $MYSQLTEST_VARDIR/log/mysqld.1.err
+
+connection master;
+--disable_warnings
+drop table if exists x;
+--enable_warnings
+
+connection master;
+
+select @@binlog_format;
+
+create table x (id int primary key, value int, value2 int, index(value)) engine=rocksdb;
+insert into x values (1,1,1);
+insert into x values (2,1,1);
+insert into x values (3,1,1);
+insert into x values (4,1,1);
+insert into x values (5,1,1);
+-- replace_result $uuid uuid
+select @@global.gtid_executed;
+
+sync_slave_with_master;
+connection slave;
+--let slave_data_dir= query_get_value(SELECT @@DATADIR, @@DATADIR, 1)
+--let slave_pid_file= query_get_value(SELECT @@pid_file, @@pid_file, 1)
+--disable_query_log
+select "--- slave state before crash ---" as "";
+--enable_query_log
+select * from x;
+-- replace_result $uuid uuid
+select @@global.gtid_executed;
+-- replace_result $uuid uuid
+select * from mysql.slave_gtid_info;
+
+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+
+--write_file $MYSQL_TMP_DIR/truncate_tail_wal.sh
+#!/bin/bash
+
+F=`ls -t $slave_data_dir/\#rocksdb/*.log | head -n 1`
+SIZE=`stat -c %s $F`
+NEW_SIZE=`expr $SIZE - 30`
+truncate -s $NEW_SIZE $F
+rc=$?
+if [[ $rc != 0 ]]; then
+ exit 1
+fi
+
+kill -9 `head -1 $slave_pid_file`
+
+exit 0
+EOF
+--chmod 0755 $MYSQL_TMP_DIR/truncate_tail_wal.sh
+--exec $MYSQL_TMP_DIR/truncate_tail_wal.sh
+
+--let $rpl_skip_start_slave= 1
+--source include/rpl_start_server.inc
+--disable_query_log
+select "--- slave state after crash recovery, slave stop, one transaction recovered---" as "";
+--enable_query_log
+connection slave;
+--exec python suite/rocksdb/t/check_log_for_xa.py $MYSQLTEST_VARDIR/log/mysqld.2.err commit,prepare,rollback
+select * from x;
+-- replace_result $uuid uuid
+select @@global.gtid_executed;
+-- replace_result $uuid uuid
+select * from mysql.slave_gtid_info;
+
+--disable_query_log
+select "--- slave state after restart, slave start ---" as "";
+--enable_query_log
+--source include/start_slave.inc
+connection master;
+sync_slave_with_master;
+connection slave;
+select * from x;
+-- replace_result $uuid uuid
+select @@global.gtid_executed;
+-- replace_result $uuid uuid
+select * from mysql.slave_gtid_info;
+
+connection master;
+insert into x values (6,1,1);
+
+sync_slave_with_master;
+connection slave;
+select * from x;
+-- replace_result $uuid uuid
+select @@global.gtid_executed;
+-- replace_result $uuid uuid
+select * from mysql.slave_gtid_info;
+
+connection master;
+insert into x values (7,1,1);
+insert into x values (8,1,1);
+insert into x values (9,1,1);
+insert into x values (10,1,1);
+insert into x values (11,1,1);
+insert into x values (12,1,1);
+select * from x;
+-- replace_result $uuid uuid
+select @@global.gtid_executed;
+sync_slave_with_master;
+
+connection slave;
+
+# Corrupting WAL. MyRocks does point in time recovery with wal_recovery_mode=2.
+# It loses some data but can resync after restarting slave.
+
+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+
+--write_file $MYSQL_TMP_DIR/corrupt_wal.sh
+#!/bin/bash
+
+# expected to be around 950 bytes
+F=`ls -t $slave_data_dir/\#rocksdb/*.log | head -n 1`
+SIZE=`stat -c %s $F`
+OFFSET=$(( $SIZE-500 ))
+dd bs=1 if=/dev/zero of=$F count=100 seek=$OFFSET conv=notrunc
+
+kill -9 `head -1 $slave_pid_file`
+
+exit 0
+EOF
+--chmod 0755 $MYSQL_TMP_DIR/corrupt_wal.sh
+--exec $MYSQL_TMP_DIR/corrupt_wal.sh
+
+--let $rpl_skip_start_slave= 1
+--source include/rpl_start_server.inc
+--disable_query_log
+select "--- slave state after crash recovery, slave stop, WAL was corrupted, point in time recovery with wal_recovery_mode=2 ---" as "";
+--enable_query_log
+select * from x;
+--source include/start_slave.inc
+connection master;
+sync_slave_with_master;
+connection slave;
+select * from x;
+-- replace_result $uuid uuid
+select @@global.gtid_executed;
+-- replace_result $uuid uuid
+select * from mysql.slave_gtid_info;
+
+connection master;
+drop table x;
+
+
+--remove_file $MYSQL_TMP_DIR/truncate_tail_wal.sh
+--remove_file $MYSQL_TMP_DIR/corrupt_wal.sh
+--source include/rpl_end.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_wal_corrupt.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_wal_corrupt.test
new file mode 100644
index 00000000..3b660b26
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_crash_safe_wal_corrupt.test
@@ -0,0 +1,12 @@
+-- source suite/rocksdb_rpl/t/rpl_gtid_crash_safe_wal_corrupt.inc
+
+connection slave;
+-- let _SLAVE_PID_FILE= query_get_value(SELECT @@pid_file, @@pid_file, 1)
+
+# Verify the log file contains the Last binlog line, but only if the slave server's pid is found
+--exec perl suite/rocksdb_rpl/t/rpl_check_for_binlog_info.pl $slave_pid_file $MYSQLTEST_VARDIR/log/mysqld.2.err
+
+--disable_query_log
+connection slave;
+call mtr.add_suppression("Recovery from master pos");
+--enable_query_log
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_rocksdb_sys_header-master.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_rocksdb_sys_header-master.opt
new file mode 100644
index 00000000..d828b6c0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_rocksdb_sys_header-master.opt
@@ -0,0 +1 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_slave_updates
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_rocksdb_sys_header-slave.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_rocksdb_sys_header-slave.opt
new file mode 100644
index 00000000..d828b6c0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_rocksdb_sys_header-slave.opt
@@ -0,0 +1 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_slave_updates
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_rocksdb_sys_header.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_rocksdb_sys_header.test
new file mode 100644
index 00000000..d1793c4a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_gtid_rocksdb_sys_header.test
@@ -0,0 +1,40 @@
+# based on rpl/rpl_gtid_innondb_sys_header.test
+source include/have_rocksdb.inc;
+source include/master-slave.inc;
+source include/have_gtid.inc;
+source include/have_debug.inc;
+source include/not_valgrind.inc;
+
+--let $old_debug = `select @@global.debug;`
+
+connection master;
+create table t1 (a int primary key) engine=rocksdb;
+insert into t1 values(1);
+--eval SET GLOBAL debug = '+d,crash_before_writing_xid'
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--error 2013
+insert into t1 values(2);
+
+--source include/wait_until_disconnected.inc
+--let $rpl_server_number = 1
+--source include/rpl_reconnect.inc
+
+--eval SET GLOBAL debug = `$old_debug`
+
+connection slave;
+disable_warnings;
+source include/start_slave.inc;
+enable_warnings;
+connection master;
+sync_slave_with_master;
+
+connection master;
+--let $master_uuid= query_get_value(select @@server_uuid, @@server_uuid, 1)
+--replace_result $master_uuid master_uuid
+--exec grep 'RocksDB: Last MySQL Gtid $master_uuid' $MYSQLTEST_VARDIR/log/mysqld.1.err
+
+drop table t1;
+source include/rpl_end.inc;
+-- move_file $MYSQLTEST_VARDIR/log/mysqld.1.err $MYSQLTEST_VARDIR/log/mysqld.1.err.orig
+-- write_file $MYSQLTEST_VARDIR/log/mysqld.1.err
+EOF
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_missing_columns_sk_update.cnf b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_missing_columns_sk_update.cnf
new file mode 100644
index 00000000..92ed7198
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_missing_columns_sk_update.cnf
@@ -0,0 +1,13 @@
+!include include/default_mysqld.cnf
+
+[mysqld.1]
+binlog_row_image = COMPLETE
+log_column_names= ON
+
+[mysqld.2]
+binlog_row_image = COMPLETE
+log_column_names= ON
+
+[ENV]
+SERVER_MYPORT_1= @mysqld.1.port
+SERVER_MYPORT_2= @mysqld.2.port
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_missing_columns_sk_update.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_missing_columns_sk_update.test
new file mode 100644
index 00000000..624f54ac
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_missing_columns_sk_update.test
@@ -0,0 +1,69 @@
+source include/master-slave.inc;
+source include/have_binlog_format_row.inc;
+
+# Create a table with SKs on master
+connection master;
+set @@sql_log_bin = 0;
+CREATE TABLE `t1` (
+ `a` int(10) unsigned NOT NULL DEFAULT '0',
+ `b` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `c` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `d` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `e` varbinary(64) DEFAULT NULL,
+ `f` int(10) NOT NULL DEFAULT '0',
+ `g` int(10) NOT NULL DEFAULT '0',
+ `h` int(10) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (`a`,`b`),
+ KEY `key1` (`a`, `e`(1)),
+ KEY `key2` (`a`,`h`)
+) ENGINE=RocksDB;
+set @@sql_log_bin = 1;
+
+# Create same table on slaves but with two extra columns in the middle (x, y)
+connection slave;
+set @@sql_log_bin = 0;
+CREATE TABLE `t1` (
+ `a` int(10) unsigned NOT NULL DEFAULT '0',
+ `b` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `c` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `d` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `e` varbinary(64) DEFAULT NULL,
+ `f` int(10) NOT NULL DEFAULT '0',
+ `g` int(10) NOT NULL DEFAULT '0',
+ `x` TINYINT(3) UNSIGNED DEFAULT NULL,
+ `y` INT(10) DEFAULT NULL,
+ `h` int(10) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (`a`,`b`),
+ KEY `key1` (`a`, `e`(1)),
+ KEY `key2` (`a`,`h`)
+) ENGINE=RocksDB;
+set @@sql_log_bin = 1;
+
+# Insert something in the table
+connection master;
+INSERT INTO t1 VALUES (1, 1, 1, 1, 'a', 1, 1, 1);
+SELECT * FROM t1;
+sync_slave_with_master;
+
+connection slave;
+SELECT * FROM t1;
+
+# Update a column that belongs to an SK
+connection master;
+UPDATE t1 SET h = 10 WHERE h = 1;
+SELECT * FROM t1;
+sync_slave_with_master;
+
+# Check if all keys are updated on the slave
+connection slave;
+SELECT * FROM t1;
+SELECT COUNT(*) FROM t1 FORCE INDEX (key1) WHERE h = 10 AND a = 1;
+SELECT COUNT(*) FROM t1 FORCE INDEX (key2) WHERE h = 10 AND a = 1;
+SELECT COUNT(*) FROM t1 FORCE INDEX (PRIMARY) WHERE h = 10 AND a = 1;
+
+# Cleanup
+connection master;
+DROP TABLE t1;
+sync_slave_with_master;
+
+source include/rpl_end.inc;
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_mts_dependency_unique_key_conflicts.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_mts_dependency_unique_key_conflicts.test
new file mode 100644
index 00000000..5869b9a3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_mts_dependency_unique_key_conflicts.test
@@ -0,0 +1,64 @@
+# RocksDB clone of rpl_mts.rpl_mts_dependency_unique_key_conflicts
+source include/have_rocksdb.inc;
+source include/have_debug_sync.inc;
+source include/master-slave.inc;
+
+connection slave;
+source include/stop_slave.inc;
+set @save.slave_parallel_workers= @@global.slave_parallel_workers;
+set @save.slave_use_idempotent_for_recovery= @@global.slave_use_idempotent_for_recovery;
+set @save.mts_dependency_replication= @@global.mts_dependency_replication;
+set @save.mts_dependency_order_commits= @@global.mts_dependency_order_commits;
+set @save.debug= @@global.debug;
+set @@global.slave_parallel_workers= 2;
+set @@global.slave_use_idempotent_for_recovery= YES;
+set @@global.mts_dependency_replication= STMT;
+set @@global.mts_dependency_order_commits= false;
+set @@global.debug= '+d,dbug.dep_wait_before_update_execution';
+source include/start_slave.inc;
+
+connection master;
+create table t1 (a int primary key, b int unique key) engine = rocksdb;
+insert into t1 values(1, 1);
+source include/sync_slave_sql_with_master.inc;
+source include/stop_slave.inc;
+
+connection master;
+update t1 set b = 2 where a = 1; # this will stall on slave due to dbug_sync
+insert into t1 values(2, 1); # this should wait for the update to finish
+
+connection slave;
+source include/start_slave.inc;
+# wait till one of the workers reach the point just before execution of update
+set debug_sync="now wait_for signal.reached";
+
+# wait till the other worker is waiting after executing the table map for the
+# insert
+let $wait_condition=
+ select count(*)= 1 from information_schema.processlist
+ where state = 'Waiting for dependencies to be satisfied';
+source include/wait_condition.inc;
+
+select * from t1;
+set debug_sync="now signal signal.done";
+
+connection master;
+source include/sync_slave_sql_with_master.inc;
+
+connection slave;
+select * from t1;
+
+# Cleanup
+connection master;
+drop table t1;
+source include/sync_slave_sql_with_master.inc;
+connection slave;
+source include/stop_slave.inc;
+set @@global.slave_parallel_workers= @save.slave_parallel_workers;
+set @@global.mts_dependency_replication= @save.mts_dependency_replication;
+set @@global.slave_use_idempotent_for_recovery= @save.slave_use_idempotent_for_recovery;
+set @@global.mts_dependency_order_commits= @save.mts_dependency_order_commits;
+set @@global.debug= @save.debug;
+source include/start_slave.inc;
+
+source include/rpl_end.inc;
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag-slave.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag-slave.opt
new file mode 100644
index 00000000..1c8dc1e6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag-slave.opt
@@ -0,0 +1 @@
+--unique-check-lag-threshold=5
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag.test
new file mode 100644
index 00000000..cecacda4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag.test
@@ -0,0 +1,7 @@
+--echo #
+--echo # Ensure skip_unique_check is set when lag exceeds lag_threshold
+--echo #
+
+--source include/have_rocksdb.inc
+--source ../include/rpl_no_unique_check_on_lag.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag_mts-slave.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag_mts-slave.opt
new file mode 100644
index 00000000..1c8dc1e6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag_mts-slave.opt
@@ -0,0 +1 @@
+--unique-check-lag-threshold=5
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag_mts.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag_mts.test
new file mode 100644
index 00000000..7e77ec87
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_no_unique_check_on_lag_mts.test
@@ -0,0 +1,3 @@
+--source include/have_rocksdb.inc
+--source ../include/rpl_no_unique_check_on_lag.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_2pc_crash_recover-master.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_2pc_crash_recover-master.opt
new file mode 100644
index 00000000..f8f297c5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_2pc_crash_recover-master.opt
@@ -0,0 +1 @@
+--log_bin --log_slave_updates --rocksdb_flush_log_at_trx_commit=1
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_2pc_crash_recover-slave.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_2pc_crash_recover-slave.opt
new file mode 100644
index 00000000..7a3f630f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_2pc_crash_recover-slave.opt
@@ -0,0 +1 @@
+--log_bin --log_slave_updates
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_2pc_crash_recover.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_2pc_crash_recover.test
new file mode 100644
index 00000000..58b37209
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_2pc_crash_recover.test
@@ -0,0 +1,57 @@
+--source include/have_binlog_format_row.inc
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+--source include/not_valgrind.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+create table t1 (a int primary key, msg varchar(255)) engine=rocksdb;
+
+SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug_dbug="d,crash_commit_after_prepare";
+--error 0,2013
+insert into t1 values (1, 'dogz');
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+select * from t1;
+
+SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug_dbug="d,crash_commit_after_log";
+--error 0,2013
+insert into t1 values (2, 'catz'), (3, 'men');
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+select * from t1;
+
+SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug_dbug="d,crash_commit_after";
+--error 0,2013
+insert into t1 values (4, 'cars'), (5, 'foo');
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+select * from t1;
+
+SET GLOBAL ROCKSDB_ENABLE_2PC = OFF;
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug_dbug="d,crash_commit_after_log";
+--error 0,2013
+insert into t1 values (6, 'shipz'), (7, 'tankz');
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+select * from t1;
+
+SET GLOBAL ROCKSDB_ENABLE_2PC = OFF;
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug_dbug="d,crash_commit_after";
+--error 0,2013
+insert into t1 values (8, 'space'), (9, 'time');
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+select * from t1;
+
+drop table t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_slave_gtid_info_optimized-master.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_slave_gtid_info_optimized-master.opt
new file mode 100644
index 00000000..c747adc9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_slave_gtid_info_optimized-master.opt
@@ -0,0 +1 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_bin --log_slave_updates
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_slave_gtid_info_optimized-slave.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_slave_gtid_info_optimized-slave.opt
new file mode 100644
index 00000000..6cde3c55
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_slave_gtid_info_optimized-slave.opt
@@ -0,0 +1 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_bin --log_slave_updates --slave-gtid-info=optimized
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_slave_gtid_info_optimized.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_slave_gtid_info_optimized.test
new file mode 100644
index 00000000..c8a0c8da
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_slave_gtid_info_optimized.test
@@ -0,0 +1,51 @@
+--source include/have_rocksdb.inc
+--source include/master-slave.inc
+--source include/have_binlog_format_row.inc
+
+if (`select count(*) = 0 from information_schema.global_variables where variable_name = 'slave_gtid_info' and variable_value = 'optimized';`) {
+ --skip Test requires row_write_committed_slave_gtid_optimized policy where slave_gtid_info=optimized
+}
+
+--echo Make changes in master
+create table test1 (a int primary key, b int) engine=rocksdb;
+insert into test1 values (1, 1);
+
+--echo Make sure slave is up-to-date and mysql.slave_gtid_info is good
+sync_slave_with_master slave;
+connection slave;
+select * from test1;
+-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/
+select id, database_name, last_gtid from mysql.slave_gtid_info;
+
+--echo Make changes in master
+connection master;
+insert into test1 values (2, 2);
+
+--echo Make sure slave is up-to-date and mysql.slave_gtid_info is good
+sync_slave_with_master slave;
+connection slave;
+select @@slave_gtid_info;
+select * from test1;
+
+-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/
+select * from mysql.slave_gtid_info;
+
+--echo Make changes in master
+connection master;
+insert into test1 values (3, 3);
+insert into test1 values (4, 4);
+
+--echo Make sure slave is up-to-date and mysql.slave_gtid_info is good
+sync_slave_with_master slave;
+connection slave;
+select * from test1;
+
+-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/
+select id, database_name, last_gtid from mysql.slave_gtid_info;
+
+connection master;
+DROP TABLE IF EXISTS test1;
+
+sync_slave_with_master slave;
+
+--source include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot-master.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot-master.opt
new file mode 100644
index 00000000..c747adc9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot-master.opt
@@ -0,0 +1 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_bin --log_slave_updates
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot-slave.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot-slave.opt
new file mode 100644
index 00000000..c747adc9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot-slave.opt
@@ -0,0 +1 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_bin --log_slave_updates
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot.test
new file mode 100644
index 00000000..200f1cb3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot.test
@@ -0,0 +1,374 @@
+--source include/have_rocksdb.inc
+--source include/master-slave.inc
+--source include/have_binlog_format_row.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo # Establish connection con1 (user=root)
+connect (con1,localhost,root,,);
+--echo # Establish connection con2 (user=root)
+connect (con2,localhost,root,,);
+--echo # Establish connection con3 (user=root)
+connect (con3,localhost,root,,);
+--echo # Establish connection con4 (user=root)
+connect (con4,localhost,root,,);
+
+--echo # reset replication to guarantee that master-bin.000001 is used
+connection slave;
+--source include/stop_slave.inc
+RESET SLAVE;
+RESET MASTER;
+
+connection master;
+RESET MASTER;
+
+connection slave;
+--replace_result $MASTER_MYPORT MASTER_PORT
+eval CHANGE MASTER TO master_host="127.0.0.1",master_port=$MASTER_MYPORT,master_user="root";
+--source include/start_slave.inc
+
+### Test 1:
+### - While a consistent snapshot transaction is executed,
+### no external inserts should be visible to the transaction.
+
+--echo # Switch to connection con1
+connection con1;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 VALUES(1);
+
+SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
+--error ER_ISOLATION_LEVEL_WITH_CONSISTENT_SNAPSHOT
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+--error ER_ISOLATION_LEVEL_WITH_CONSISTENT_SNAPSHOT
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+ROLLBACK;
+SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+
+
+--disable_query_log
+--disable_result_log
+let $x=1000;
+while ($x) {
+ START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+ dec $x;
+}
+--enable_query_log
+--enable_result_log
+
+-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+
+--echo # Switch to connection con2
+connection con2;
+INSERT INTO t1 VALUES(2);
+INSERT INTO t1 VALUES(3);
+
+--echo # Switch to connection con1
+connection con1;
+SELECT * FROM t1; # should fetch one row
+COMMIT;
+
+SELECT * FROM t1; # should fetch three rows
+
+DROP TABLE t1;
+
+### Test 2:
+### - confirm result from snapshot select and replication replay matches original
+
+--echo # Switch to connection con1
+connection con1;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 VALUES(1);
+
+-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+
+let $binlog_pos = query_get_value(START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT, Position, 1);
+
+--echo # Switch to connection con2
+connection con2;
+INSERT INTO t1 VALUES(2);
+INSERT INTO t1 VALUES(3);
+
+--echo # Switch to connection con1
+connection con1;
+SELECT * FROM t1;
+
+--let $outfile = $MYSQLTEST_VARDIR/tmp/rpl_rocksdb_snapshot.out.file
+
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
+eval SELECT * INTO OUTFILE '$outfile' FROM t1;
+COMMIT;
+
+--echo # Switch to slave
+sync_slave_with_master slave;
+
+CREATE TABLE t1_backup LIKE t1;
+INSERT INTO t1_backup SELECT * FROM t1;
+--source include/stop_slave.inc
+RESET SLAVE;
+RESET MASTER;
+DELETE FROM t1;
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
+eval LOAD DATA INFILE '$outfile' INTO TABLE t1;
+SELECT * FROM t1;
+
+--replace_result $MASTER_MYPORT MASTER_PORT $binlog_pos binlog_pos
+eval CHANGE MASTER TO master_host="127.0.0.1",master_port=$MASTER_MYPORT,master_user="root",master_log_file="master-bin.000001",master_log_pos=$binlog_pos;
+--source include/start_slave.inc
+
+connection master;
+sync_slave_with_master slave;
+
+SELECT * FROM t1;
+SELECT * FROM t1_backup;
+DROP TABLE t1_backup;
+
+connection master;
+DROP TABLE t1;
+--remove_file $outfile
+
+### Test 3:
+### - confirm result from snapshot select and replication replay matches original
+### - use non-deterministic concurrency
+
+--echo # Switch to connection con1
+connection con1;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 VALUES(1);
+
+--echo # async queries from con2
+connection con2;
+send INSERT INTO t1 VALUES(2);
+
+--echo # async queries from con3
+connection con3;
+send INSERT INTO t1 VALUES(21);
+
+--echo # Switch to connection con1
+connection con1;
+
+let $binlog_pos = query_get_value(START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT, Position, 1);
+
+--echo # Switch to connection con4
+connection con4;
+INSERT INTO t1 VALUES(9);
+
+--echo # Switch to connection con1
+connection con1;
+
+--let $outfile = $MYSQLTEST_VARDIR/tmp/rpl_rocksdb_snapshot.out.file
+
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
+eval SELECT * INTO OUTFILE '$outfile' FROM t1;
+COMMIT;
+
+--echo # reap async statements
+connection con2;
+reap;
+
+connection con3;
+reap;
+
+--echo # Switch to slave
+sync_slave_with_master slave;
+
+CREATE TABLE t1_backup LIKE t1;
+INSERT INTO t1_backup SELECT * FROM t1;
+--source include/stop_slave.inc
+RESET SLAVE;
+RESET MASTER;
+DELETE FROM t1;
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
+eval LOAD DATA INFILE '$outfile' INTO TABLE t1;
+
+--replace_result $MASTER_MYPORT MASTER_PORT $binlog_pos binlog_pos
+eval CHANGE MASTER TO master_host="127.0.0.1",master_port=$MASTER_MYPORT,master_user="root",master_log_file="master-bin.000001",master_log_pos=$binlog_pos;
+--source include/start_slave.inc
+
+--echo # sync and then query slave
+connection master;
+sync_slave_with_master slave;
+
+let $sum1 = `SELECT SUM(a) from t1`;
+let $sum2 = `SELECT SUM(a) from t1_backup`;
+--disable_query_log
+eval select $sum2 - $sum1 ShouldBeZero;
+--enable_query_log
+
+DROP TABLE t1_backup;
+
+connection master;
+DROP TABLE t1;
+--remove_file $outfile
+
+### Test 4:
+### - confirm result from snapshot select and replication relay using gtid protocol matches original
+
+--echo # Switch to connection con1
+connection con1;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 VALUES(1);
+
+-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+
+let $gtid_executed = query_get_value(START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT, Gtid_executed, 1);
+
+--echo # Switch to connection con2
+connection con2;
+INSERT INTO t1 VALUES(2);
+INSERT INTO t1 VALUES(3);
+
+--echo # Switch to connection con1
+connection con1;
+SELECT * FROM t1;
+
+--let $outfile = $MYSQLTEST_VARDIR/tmp/rpl_rocksdb_snapshot.out.file
+
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
+eval SELECT * INTO OUTFILE '$outfile' FROM t1;
+COMMIT;
+
+--echo # Switch to slave
+sync_slave_with_master slave;
+
+CREATE TABLE t1_backup LIKE t1;
+INSERT INTO t1_backup SELECT * FROM t1;
+--source include/stop_slave.inc
+RESET SLAVE;
+RESET MASTER;
+--replace_result $gtid_executed gtid_executed_from_snapshot
+eval SET @@global.gtid_purged='$gtid_executed';
+DELETE FROM t1;
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
+eval LOAD DATA INFILE '$outfile' INTO TABLE t1;
+SELECT * FROM t1;
+
+--replace_result $MASTER_MYPORT MASTER_PORT
+eval CHANGE MASTER TO master_host="127.0.0.1",master_port=$MASTER_MYPORT,master_user="root", master_auto_position=1;
+--source include/start_slave.inc
+
+connection master;
+sync_slave_with_master slave;
+
+SELECT * FROM t1;
+SELECT * FROM t1_backup;
+DROP TABLE t1_backup;
+
+connection master;
+DROP TABLE t1;
+--remove_file $outfile
+
+### Test 5:
+### - confirm result from snapshot select and replication replay using gtid_protocol matches original
+### - use non-deterministic concurrency
+
+--echo # Switch to connection con1
+connection con1;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=rocksdb;
+INSERT INTO t1 VALUES(1);
+
+--echo # async queries from con2
+connection con2;
+send INSERT INTO t1 VALUES(2);
+
+--echo # async queries from con3
+connection con3;
+send INSERT INTO t1 VALUES(21);
+
+--echo # Switch to connection con1
+connection con1;
+
+let $gtid_executed = query_get_value(START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT, Gtid_executed, 1);
+
+--echo # Switch to connection con4
+connection con4;
+INSERT INTO t1 VALUES(9);
+
+--echo # Switch to connection con1
+connection con1;
+
+--let $outfile = $MYSQLTEST_VARDIR/tmp/rpl_rocksdb_snapshot.out.file
+
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
+eval SELECT * INTO OUTFILE '$outfile' FROM t1;
+COMMIT;
+
+--echo # reap async statements
+connection con2;
+reap;
+
+connection con3;
+reap;
+
+--echo # Switch to slave
+sync_slave_with_master slave;
+
+CREATE TABLE t1_backup LIKE t1;
+INSERT INTO t1_backup SELECT * FROM t1;
+--source include/stop_slave.inc
+RESET SLAVE;
+RESET MASTER;
+--replace_result $gtid_executed gtid_executed_from_snapshot
+eval SET @@global.gtid_purged='$gtid_executed';
+DELETE FROM t1;
+
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
+eval LOAD DATA INFILE '$outfile' INTO TABLE t1;
+
+--replace_result $MASTER_MYPORT MASTER_PORT
+eval CHANGE MASTER TO master_host="127.0.0.1",master_port=$MASTER_MYPORT,master_user="root", master_auto_position=1;
+--source include/start_slave.inc
+
+--echo # sync and then query slave
+connection master;
+sync_slave_with_master slave;
+
+let $sum1 = `SELECT SUM(a) from t1`;
+let $sum2 = `SELECT SUM(a) from t1_backup`;
+--disable_query_log
+eval select $sum2 - $sum1 ShouldBeZero;
+--enable_query_log
+
+DROP TABLE t1_backup;
+
+connection master;
+DROP TABLE t1;
+--remove_file $outfile
+
+--echo # Switch to connection default + close connections con1 and con2
+connection con1;
+disconnect con1;
+--source include/wait_until_disconnected.inc
+connection con2;
+disconnect con2;
+--source include/wait_until_disconnected.inc
+connection con3;
+disconnect con3;
+--source include/wait_until_disconnected.inc
+connection con4;
+disconnect con4;
+--source include/wait_until_disconnected.inc
+
+connection default;
+sync_slave_with_master slave;
+--source include/stop_slave.inc
+CHANGE MASTER to master_auto_position=0;
+--source include/start_slave.inc
+
+--source include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot_without_gtid.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot_without_gtid.test
new file mode 100644
index 00000000..79d71f20
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_snapshot_without_gtid.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+--source include/master-slave.inc
+--source include/have_binlog_format_row.inc
+
+--connection master
+create table t1(a int primary key);
+
+FLUSH LOGS;
+
+insert into t1 values(1);
+insert into t1 values(2);
+
+FLUSH LOGS;
+
+START TRANSACTION WITH CONSISTENT ROCKSDB SNAPSHOT;
+
+drop table t1;
+-- source include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_stress_crash-master.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_stress_crash-master.opt
new file mode 100644
index 00000000..5c5a73bf
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_stress_crash-master.opt
@@ -0,0 +1,2 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_slave_updates
+--binlog_rows_query_log_events=TRUE --rocksdb_unsafe_for_binlog=TRUE
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_stress_crash-slave.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_stress_crash-slave.opt
new file mode 100644
index 00000000..b3d52445
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_stress_crash-slave.opt
@@ -0,0 +1,3 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_slave_updates --max_binlog_size=50000
+--slave_parallel_workers=30 --relay_log_recovery=1 --rocksdb_unsafe_for_binlog=TRUE
+--rocksdb_wal_recovery_mode=2
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_stress_crash.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_stress_crash.test
new file mode 100644
index 00000000..17b86606
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_rocksdb_stress_crash.test
@@ -0,0 +1,26 @@
+-- source include/big_test.inc
+-- source include/master-slave.inc
+-- source include/not_valgrind.inc
+-- source include/have_gtid.inc
+-- source include/have_rocksdb.inc
+
+connection master;
+call mtr.add_suppression(".*");
+sync_slave_with_master;
+-- source include/stop_slave.inc
+change master to master_auto_position=1;
+-- source include/start_slave.inc
+
+-- let $iter=100
+-- let $databases=30
+-- let $num_crashes=100
+-- let $include_silent=1
+-- let $storage_engine='rocksdb'
+-- source extra/rpl_tests/rpl_parallel_load_innodb.test
+-- let $include_silent=0
+
+-- source include/stop_slave.inc
+change master to master_auto_position=0;
+-- source include/start_slave.inc
+
+-- source include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_skip_trx_api_binlog_format-master.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_skip_trx_api_binlog_format-master.opt
new file mode 100644
index 00000000..39bb3238
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_skip_trx_api_binlog_format-master.opt
@@ -0,0 +1,2 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_slave_updates
+--binlog_format=STATEMENT --default-storage-engine=rocksdb
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_skip_trx_api_binlog_format-slave.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_skip_trx_api_binlog_format-slave.opt
new file mode 100644
index 00000000..826f1ee9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_skip_trx_api_binlog_format-slave.opt
@@ -0,0 +1,2 @@
+--gtid_mode=ON --enforce_gtid_consistency --log_slave_updates
+--sync_binlog=1000 --relay_log_recovery=1 --default-storage-engine=rocksdb
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_skip_trx_api_binlog_format.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_skip_trx_api_binlog_format.test
new file mode 100644
index 00000000..1ea9add8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_skip_trx_api_binlog_format.test
@@ -0,0 +1,52 @@
+# Checks if the slave stops executing transactions when master's binlog format
+# is STATEMENT but rpl_skip_tx_api is enabled
+-- source include/have_rocksdb.inc
+-- source include/master-slave.inc
+
+call mtr.add_suppression("Master's binlog format is not ROW but rpl_skip_tx_api is enabled on the slave");
+
+connection slave;
+let $old_rpl_skip_tx_api= `SELECT @@global.rpl_skip_tx_api`;
+set global rpl_skip_tx_api=ON;
+
+connection master;
+let $old_rocksdb_unsafe_for_binlog= `SELECT @@global.rocksdb_unsafe_for_binlog`;
+set global rocksdb_unsafe_for_binlog=1;
+create table t1(a int);
+set session binlog_format=STATEMENT;
+insert into t1 values(1);
+
+# Wait till we hit the binlog format mismatch error
+connection slave;
+let $slave_sql_errno= convert_error(ER_MTS_INCONSISTENT_DATA); # 1756
+let $show_slave_sql_error= 1;
+source include/wait_for_slave_sql_error.inc;
+
+# Print table
+connection slave;
+echo "Table after error";
+select * from t1;
+
+connection slave;
+# Turn off rpl_skip_tx_api and start the slave again
+set global rpl_skip_tx_api=OFF;
+source include/start_slave.inc;
+
+connection slave;
+source include/sync_slave_sql_with_master.inc;
+
+connection slave;
+# Print table again
+echo "Table after error fixed";
+select * from t1;
+
+# Cleanup
+connection master;
+drop table t1;
+eval set global rocksdb_unsafe_for_binlog=$old_rocksdb_unsafe_for_binlog;
+sync_slave_with_master;
+
+connection slave;
+eval set global rpl_skip_tx_api=$old_rpl_skip_tx_api;
+
+-- source include/rpl_end.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_xa.inc b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_xa.inc
new file mode 100644
index 00000000..253d9f16
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_xa.inc
@@ -0,0 +1,84 @@
+#
+# This "body" file checks general properties of XA transaction replication
+# as of MDEV-7974, including XA of mixed engine branches.
+# Parameters:
+# --let rpl_xa_check= SELECT ...
+#
+connection master;
+create table ti (a int, b int) engine=innodb;
+create table t1 (a int, b int) engine=rocksdb;
+insert into ti values(0, 0);
+insert into t1 values(0, 0);
+xa start 't';
+insert into ti values(1, 2);
+insert into t1 values(1, 2);
+xa end 't';
+xa prepare 't';
+xa commit 't';
+
+sync_slave_with_master;
+let $diff_tables= master:t1, slave:t1;
+source include/diff_tables.inc;
+
+connection master;
+
+xa start 't';
+insert into ti values(3, 4);
+insert into t1 values(3, 4);
+xa end 't';
+xa prepare 't';
+xa rollback 't';
+
+sync_slave_with_master;
+let $diff_tables= master:t1, slave:t1;
+source include/diff_tables.inc;
+
+connection master;
+SET pseudo_slave_mode=1;
+create table t2 (a int) engine=rocksdb;
+xa start 't';
+insert into ti values (5, 6);
+insert into t1 values (5, 6);
+xa end 't';
+xa prepare 't';
+xa start 's';
+insert into ti values (7, 8);
+insert into t2 values (0);
+xa end 's';
+xa prepare 's';
+--source include/save_master_gtid.inc
+
+connection slave;
+source include/sync_with_master_gtid.inc;
+if ($rpl_xa_check)
+{
+ --eval $rpl_xa_check
+ if ($rpl_xa_verbose)
+ {
+ --eval SELECT $rpl_xa_check_lhs
+ --eval SELECT $rpl_xa_check_rhs
+ }
+}
+xa recover;
+
+connection master;
+xa commit 't';
+xa commit 's';
+SET pseudo_slave_mode=0;
+
+# pure rocksdb xa
+xa start 'r';
+insert into t1 values(7, 8);
+xa end 'r';
+xa prepare 'r';
+xa commit 'r';
+
+
+sync_slave_with_master;
+let $diff_tables= master:t1, slave:t1;
+source include/diff_tables.inc;
+let $diff_tables= master:t2, slave:t2;
+source include/diff_tables.inc;
+
+connection master;
+drop table ti, t1, t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_xa.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_xa.test
new file mode 100644
index 00000000..34384c74
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_xa.test
@@ -0,0 +1,7 @@
+source include/have_rocksdb.inc;
+source include/have_innodb.inc;
+source include/master-slave.inc;
+source include/have_binlog_format_row.inc;
+
+source rpl_xa.inc;
+source include/rpl_end.inc;
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_recovery.cnf b/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_recovery.cnf
new file mode 100644
index 00000000..71e124ad
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_recovery.cnf
@@ -0,0 +1,15 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+log_slave_updates
+gtid_mode=ON
+enforce_gtid_consistency=ON
+
+[mysqld.2]
+relay_log_recovery=1
+relay_log_info_repository=FILE
+log_slave_updates
+gtid_mode=ON
+enforce_gtid_consistency=ON
+slave_use_idempotent_for_recovery=Yes
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_recovery.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_recovery.test
new file mode 100644
index 00000000..6d953ead
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_recovery.test
@@ -0,0 +1,78 @@
+
+--source include/have_binlog_format_row.inc
+--source include/have_rocksdb.inc
+--source include/master-slave.inc
+--source include/have_gtid.inc
+--source include/not_valgrind.inc
+
+# This is a test case for issue#655 -- SingleDelete on Primary Key may
+# cause extra rows than Secondary Keys
+
+call mtr.add_suppression("Recovery from master pos");
+
+connection master;
+--disable_warnings
+drop table if exists r1;
+--enable_warnings
+create table r1 (id1 int, id2 int, primary key (id1, id2), index i (id2)) engine=rocksdb;
+insert into r1 values (1, 1000);
+
+sync_slave_with_master;
+connection slave;
+set global rocksdb_force_flush_memtable_now=1;
+--let slave_data_dir= query_get_value(SELECT @@DATADIR, @@DATADIR, 1)
+--let slave_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
+--let slave_pid_file= query_get_value(SELECT @@pid_file, @@pid_file, 1)
+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+
+--write_file $MYSQL_TMP_DIR/truncate_tail_binlog.sh
+#!/bin/bash
+
+F=$slave_data_dir/$slave_binlog_file
+SIZE=`stat -c %s $F`
+NEW_SIZE=`expr $SIZE - 100`
+truncate -s $NEW_SIZE $F
+rc=$?
+if [[ $rc != 0 ]]; then
+ exit 1
+fi
+
+kill -9 `head -1 $slave_pid_file`
+
+exit 0
+EOF
+--chmod 0755 $MYSQL_TMP_DIR/truncate_tail_binlog.sh
+--exec $MYSQL_TMP_DIR/truncate_tail_binlog.sh
+
+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
+
+# Crash recovery (losing some binlogs) with slave_use_idempotent_for_recovery may
+# replay same transactions with slave_exec_mode=idempotent implicitly enabled.
+# On slave, the last insert is converted to update with the same key.
+# It should be treated as SD and Put (same as singledelete_idempotent_table.test).
+
+--source include/rpl_start_server.inc
+--source include/start_slave.inc
+
+# Due to the binlogs being truncated, the slave may still think it's processed up to
+# the truncated binlog and select master_pos_wait() can return prematurely. Add
+# a new transaction to the master to force master_pos_wait() to wait.
+connection master;
+insert into r1 values (2,2000);
+sync_slave_with_master;
+
+connection slave;
+delete r1 from r1 force index (i) where id2=1000;
+select id1,id2 from r1 force index (primary) where id1=1 and id2=1000;
+select id2 from r1 force index (i) where id1=1 and id2=1000;
+set global rocksdb_compact_cf='default';
+select id1,id2 from r1 force index (primary) where id1=1 and id2=1000;
+select id2 from r1 force index (i) where id1=1 and id2=1000;
+
+connection master;
+drop table r1;
+
+--remove_file $MYSQL_TMP_DIR/truncate_tail_binlog.sh
+--source include/rpl_end.inc
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.cnf b/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.cnf
new file mode 100644
index 00000000..5f1f87d7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.cnf
@@ -0,0 +1,11 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+log_slave_updates
+
+[mysqld.2]
+relay_log_recovery=1
+#relay_log_info_repository=FILE
+log_slave_updates
+#rbr_idempotent_tables='r1'
+slave_exec_mode=IDEMPOTENT
diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.test
new file mode 100644
index 00000000..00dce7c2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.test
@@ -0,0 +1,44 @@
+
+--source include/have_binlog_format_row.inc
+--source include/have_rocksdb.inc
+--source include/master-slave.inc
+#--source include/have_gtid.inc
+--source include/not_valgrind.inc
+
+# This is a test case for issue#655 -- SingleDelete on Primary Key may
+# cause extra rows than Secondary Keys
+
+connection master;
+--disable_warnings
+drop table if exists r1;
+--enable_warnings
+create table r1 (id1 int, id2 int, primary key (id1, id2), index i (id2)) engine=rocksdb;
+insert into r1 values (1, 1000);
+set sql_log_bin=0;
+delete from r1 where id1=1 and id2=1000;
+set sql_log_bin=1;
+
+sync_slave_with_master;
+connection slave;
+set global rocksdb_force_flush_memtable_now=1;
+
+connection master;
+# same key insert on slave. Since slave sets rbr_idempotent_tables, the insert
+# is converted to update with the same key. MyRocks should call SD and Put for the key
+insert into r1 values (1, 1000);
+sync_slave_with_master;
+
+connection slave;
+delete r1 from r1 force index (i) where id2=1000;
+select id1,id2 from r1 force index (primary);
+select id2 from r1 force index (i);
+set global rocksdb_compact_cf='default';
+select id1,id2 from r1 force index (primary);
+select id2 from r1 force index (i);
+
+connection master;
+drop table r1;
+
+--source include/rpl_end.inc
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_stress/combinations b/storage/rocksdb/mysql-test/rocksdb_stress/combinations
new file mode 100644
index 00000000..b7316c71
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_stress/combinations
@@ -0,0 +1,5 @@
+[write_committed]
+rocksdb_write_policy=write_committed
+
+[write_prepared]
+rocksdb_write_policy=write_prepared
diff --git a/storage/rocksdb/mysql-test/rocksdb_stress/include/have_rocksdb.inc b/storage/rocksdb/mysql-test/rocksdb_stress/include/have_rocksdb.inc
new file mode 100644
index 00000000..1f762d38
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_stress/include/have_rocksdb.inc
@@ -0,0 +1,10 @@
+if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'rocksdb' AND support IN ('YES', 'DEFAULT', 'ENABLED')`)
+{
+ --skip Test requires engine RocksDB.
+}
+
+--disable_query_log
+# Table statistics can vary depending on when the memtables are flushed, so
+# flush them at the beginning of the test to ensure the test runs consistently.
+set global rocksdb_force_flush_memtable_now = true;
+--enable_query_log
diff --git a/storage/rocksdb/mysql-test/rocksdb_stress/include/have_rocksdb.opt b/storage/rocksdb/mysql-test/rocksdb_stress/include/have_rocksdb.opt
new file mode 100644
index 00000000..36d7dda1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_stress/include/have_rocksdb.opt
@@ -0,0 +1,12 @@
+--loose-enable-rocksdb
+--loose-enable-rocksdb_global_info
+--loose-enable-rocksdb_ddl
+--loose-enable-rocksdb_cf_options
+--loose-enable_rocksdb_perf_context
+--loose-enable_rocksdb_perf_context_global
+--loose-enable-rocksdb_index_file_map
+--loose-enable-rocksdb_dbstats
+--loose-enable-rocksdb_cfstats
+--loose-enable-rocksdb_lock_info
+--loose-enable-rocksdb_trx
+--loose-enable-rocksdb_locks
diff --git a/storage/rocksdb/mysql-test/rocksdb_stress/include/rocksdb_stress.inc b/storage/rocksdb/mysql-test/rocksdb_stress/include/rocksdb_stress.inc
new file mode 100644
index 00000000..3838987b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_stress/include/rocksdb_stress.inc
@@ -0,0 +1,57 @@
+# Run the load generator to populate the table and generate concurrent
+# updates. After the load generator is complete, verify the tables on the
+# master and the slave are consistent
+
+--sync_slave_with_master
+
+--connection master
+--let $master_host = 127.0.0.1
+let $MYSQL_BASEDIR = `SELECT @@BASEDIR`;
+
+let $exec =
+ python
+ $MYSQL_BASEDIR/storage/rocksdb/mysql-test/rocksdb_stress/t/load_generator.py \
+ -L $MYSQL_TMP_DIR/load_generator.log -H $master_host -t $table \
+ -P $MASTER_MYPORT -n $num_records -m $max_records \
+ -l $num_loaders -c $num_checkers -r $num_requests \
+ -E $MYSQLTEST_VARDIR/tmp/mysqld.1.expect \
+ -D $reap_delay;
+
+exec $exec;
+
+enable_reconnect;
+source include/wait_until_connected_again.inc;
+
+--let $master_checksum = query_get_value(CHECKSUM TABLE $table, Checksum, 1)
+
+# if sync_slave_with_master had a configurable timeout this would not be needed
+let $slave_sync_timeout = 7200;
+--source include/wait_for_slave_to_sync_with_master.inc
+
+--connection slave
+--let $slave_checksum = query_get_value(CHECKSUM TABLE $table, Checksum, 1)
+
+let $not_same = `SELECT $master_checksum-$slave_checksum`;
+if ($not_same)
+{
+ --die "The checksums of table $table for the master and slave do not match!"
+}
+
+# Cleanup
+--connection master
+--let $cleanup = DROP TABLE $table
+eval $cleanup;
+
+# if sync_slave_with_master had a configurable timeout this would not be needed
+let $slave_sync_timeout = 7200;
+--source include/wait_for_slave_to_sync_with_master.inc
+
+--connection slave
+--source include/stop_slave.inc
+# For stress tests sometimes the replication thread can not connect to master
+# temporarily. This is either because the master crashed and it is recovering
+# or the master is too busy and could not service the slave's requests.
+# mtr's internal check requires that there be no errors in slave status.
+# restarting replication clears the errors.
+--source include/start_slave.inc
+--source include/stop_slave.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_stress/my.cnf b/storage/rocksdb/mysql-test/rocksdb_stress/my.cnf
new file mode 100644
index 00000000..6597d18b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_stress/my.cnf
@@ -0,0 +1,9 @@
+!include include/default_my.cnf
+!include ../storage/rocksdb/mysql-test/rocksdb/my.cnf
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+binlog_format=row
+
+[mysqld.2]
+binlog_format=row
diff --git a/storage/rocksdb/mysql-test/rocksdb_stress/r/rocksdb_stress.result b/storage/rocksdb/mysql-test/rocksdb_stress/r/rocksdb_stress.result
new file mode 100644
index 00000000..9f161b18
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_stress/r/rocksdb_stress.result
@@ -0,0 +1,23 @@
+include/master-slave.inc
+[connection master]
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(id INT PRIMARY KEY,
+thread_id INT NOT NULL,
+request_id BIGINT UNSIGNED NOT NULL,
+update_count INT UNSIGNED NOT NULL DEFAULT 0,
+zero_sum INT DEFAULT 0,
+msg VARCHAR(1024),
+msg_length int,
+msg_checksum varchar(128),
+auto_inc BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
+KEY(auto_inc),
+KEY msg_i(msg(255), zero_sum))
+ENGINE=RocksDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
+stop slave;
+start slave;
+DROP TABLE t1;
+stop slave;
+start slave;
+include/stop_slave.inc
+include/start_slave.inc
+include/stop_slave.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_stress/r/rocksdb_stress_crash.result b/storage/rocksdb/mysql-test/rocksdb_stress/r/rocksdb_stress_crash.result
new file mode 100644
index 00000000..9f161b18
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_stress/r/rocksdb_stress_crash.result
@@ -0,0 +1,23 @@
+include/master-slave.inc
+[connection master]
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(id INT PRIMARY KEY,
+thread_id INT NOT NULL,
+request_id BIGINT UNSIGNED NOT NULL,
+update_count INT UNSIGNED NOT NULL DEFAULT 0,
+zero_sum INT DEFAULT 0,
+msg VARCHAR(1024),
+msg_length int,
+msg_checksum varchar(128),
+auto_inc BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
+KEY(auto_inc),
+KEY msg_i(msg(255), zero_sum))
+ENGINE=RocksDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
+stop slave;
+start slave;
+DROP TABLE t1;
+stop slave;
+start slave;
+include/stop_slave.inc
+include/start_slave.inc
+include/stop_slave.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_stress/suite.opt b/storage/rocksdb/mysql-test/rocksdb_stress/suite.opt
new file mode 100644
index 00000000..22c9d7a3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_stress/suite.opt
@@ -0,0 +1,2 @@
+--plugin-load=$HA_ROCKSDB_SO --default-storage-engine=rocksdb
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_stress/suite.pm b/storage/rocksdb/mysql-test/rocksdb_stress/suite.pm
new file mode 100644
index 00000000..106a1d6a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_stress/suite.pm
@@ -0,0 +1,28 @@
+package My::Suite::Rocksdb;
+
+use My::SysInfo;
+
+#
+# Note: ../rocksdb_sys_vars/suite.pm file has a similar
+# function. If you modify this file, consider modifying that one, too.
+#
+@ISA = qw(My::Suite);
+use My::Find;
+use File::Basename;
+use strict;
+
+#sub is_default { not $::opt_embedded_server }
+
+my $sst_dump=
+::mtr_exe_maybe_exists(
+ "$::bindir/storage/rocksdb$::opt_vs_config/sst_dump",
+ "$::path_client_bindir/sst_dump");
+return "RocksDB is not compiled, no sst_dump" unless $sst_dump;
+$ENV{MARIAROCKS_SST_DUMP}="$sst_dump";
+
+# Temporarily disable testing under valgrind, due to MDEV-12439
+return "RocksDB tests disabled under valgrind" if ($::opt_valgrind);
+
+
+bless { };
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_stress/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb_stress/t/disabled.def
new file mode 100644
index 00000000..42b2f661
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_stress/t/disabled.def
@@ -0,0 +1,2 @@
+rocksdb_stress_crash: Client scipt seems to hang on terminal input in MariaDB
+rocksdb_stress: Client scipt seems to hang on terminal input in MariaDB
diff --git a/storage/rocksdb/mysql-test/rocksdb_stress/t/load_generator.py b/storage/rocksdb/mysql-test/rocksdb_stress/t/load_generator.py
new file mode 100644
index 00000000..c1d3e7fb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_stress/t/load_generator.py
@@ -0,0 +1,1042 @@
+import cStringIO
+import array
+import hashlib
+import MySQLdb
+from MySQLdb.constants import CR
+from MySQLdb.constants import ER
+from collections import deque
+import os
+import random
+import signal
+import sys
+import threading
+import time
+import string
+import traceback
+import logging
+import argparse
+
+# This is a generic load_generator for mysqld which persists across server
+# restarts and attempts to verify both committed and uncommitted transactions
+# are persisted correctly.
+#
+# The table schema used should look something like:
+#
+# CREATE TABLE t1(id INT PRIMARY KEY,
+# thread_id INT NOT NULL,
+# request_id BIGINT UNSIGNED NOT NULL,
+# update_count INT UNSIGNED NOT NULL DEFAULT 0,
+# zero_sum INT DEFAULT 0,
+# msg VARCHAR(1024),
+# msg_length int,
+# msg_checksum varchar(128),
+# KEY msg_i(msg(255), zero_sum))
+# ENGINE=RocksDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
+#
+# zero_sum should always sum up to 0 regardless of when the transaction tries
+# to process the transaction. Each transaction always maintain this sum to 0.
+#
+# request_id should be unique across transactions. It is used during
+# transaction verification and is monotonically increasing..
+#
+# Several threads are spawned at the start of the test to populate the table.
+# Once the table is populated, both loader and checker threads are created.
+#
+# The row id space is split into two sections: exclusive and shared. Each
+# loader thread owns some part of the exclusive section which it maintains
+# complete information on insert/updates/deletes. Since this section is only
+# modified by one thread, the thread can maintain an accurate picture of all
+# changes. The shared section contains rows which multiple threads can
+# update/delete/insert. For checking purposes, the request_id is used to
+# determine if a row is consistent with a committed transaction.
+#
+# Each loader thread's transaction consists of selecting some number of rows
+# randomly. The thread can choose to delete the row, update the row or insert
+# the row if it doesn't exist. The state of rows that are owned by the loader
+# thread are tracked within the thread's id_map. This map contains the row id
+# and the request_id of the latest update. For indicating deleted rows, the
+# -request_id marker is used. Thus, at any point in time, the thread's id_map
+# should reflect the exact state of the rows that are owned.
+#
+# The loader thread also maintains the state of older transactions that were
+# successfully processed in addition to the current transaction, which may or
+# may not be committed. Each transaction state consists of the row id, and the
+# request_id. Again, -request_id is used to indicate a delete. For committed
+# transactions, the thread can verify the request_id of the row is larger than
+# what the thread has recorded. For uncommitted transactions, the thread would
+# verify the request_id of the row does not match that of the transaction. To
+# determine whether or not a transaction succeeded in case of a crash right at
+# commit, each thread always includes a particular row in the transaction which
+# it could use to check the request id against.
+#
+# Checker threads run continuously to verify the checksums on the rows and to
+# verify the zero_sum column sums up to zero at any point in time. The checker
+# threads run both point lookups and range scans for selecting the rows.
+
+class ValidateError(Exception):
+ """Raised when validation fails"""
+ pass
+
+class TestError(Exception):
+ """Raised when the test cannot make forward progress"""
+ pass
+
+CHARS = string.letters + string.digits
+OPTIONS = {}
+
+# max number of rows per transaction
+MAX_ROWS_PER_REQ = 10
+
+# global variable checked by threads to determine if the test is stopping
+TEST_STOP = False
+LOADERS_READY = 0
+
+# global monotonically increasing request id counter
+REQUEST_ID = 1
+REQUEST_ID_LOCK = threading.Lock()
+
+INSERT_ID_SET = set()
+
+def get_next_request_id():
+ global REQUEST_ID
+ with REQUEST_ID_LOCK:
+ REQUEST_ID += 1
+ return REQUEST_ID
+
+# given a percentage value, rolls a 100-sided die and return whether the
+# given value is above or equal to the die roll
+#
+# passing 0 should always return false and 100 should always return true
+def roll_d100(p):
+ assert p >= 0 and p <= 100
+ return p >= random.randint(1, 100)
+
+def sha1(x):
+ return hashlib.sha1(str(x)).hexdigest()
+
+def is_connection_error(exc):
+ error_code = exc.args[0]
+ return (error_code == MySQLdb.constants.CR.CONNECTION_ERROR or
+ error_code == MySQLdb.constants.CR.CONN_HOST_ERROR or
+ error_code == MySQLdb.constants.CR.SERVER_LOST or
+ error_code == MySQLdb.constants.CR.SERVER_GONE_ERROR or
+ error_code == MySQLdb.constants.ER.QUERY_INTERRUPTED or
+ error_code == MySQLdb.constants.ER.SERVER_SHUTDOWN)
+
+def is_deadlock_error(exc):
+ error_code = exc.args[0]
+ return (error_code == MySQLdb.constants.ER.LOCK_DEADLOCK or
+ error_code == MySQLdb.constants.ER.LOCK_WAIT_TIMEOUT)
+
+# should be deterministic given an idx
+def gen_msg(idx, thread_id, request_id):
+ random.seed(idx);
+ # field length is 1024 bytes, but 32 are reserved for the tid and req tag
+ blob_length = random.randint(1, 1024 - 32)
+
+ if roll_d100(50):
+ # blob that cannot be compressed (well, compresses to 85% of original size)
+ msg = ''.join([random.choice(CHARS) for x in xrange(blob_length)])
+ else:
+ # blob that can be compressed
+ msg = random.choice(CHARS) * blob_length
+
+ # append the thread_id and request_id to the end of the msg
+ return ''.join([msg, ' tid: %d req: %d' % (thread_id, request_id)])
+
+def execute(cur, stmt):
+ ROW_COUNT_ERROR = 18446744073709551615L
+ logging.debug("Executing %s" % stmt)
+ cur.execute(stmt)
+ if cur.rowcount < 0 or cur.rowcount == ROW_COUNT_ERROR:
+ raise MySQLdb.OperationalError(MySQLdb.constants.CR.CONNECTION_ERROR,
+ "Possible connection error, rowcount is %d"
+ % cur.rowcount)
+
+def wait_for_workers(workers, min_active = 0):
+ logging.info("Waiting for %d workers", len(workers))
+ # min_active needs to include the current waiting thread
+ min_active += 1
+
+ # polling here allows this thread to be responsive to keyboard interrupt
+ # exceptions, otherwise a user hitting ctrl-c would see the load_generator as
+ # hanging and unresponsive
+ try:
+ while threading.active_count() > min_active:
+ time.sleep(1)
+ except KeyboardInterrupt, e:
+ os._exit(1)
+
+ num_failures = 0
+ for w in workers:
+ w.join()
+ if w.exception:
+ logging.error(w.exception)
+ num_failures += 1
+
+ return num_failures
+
+# base class for worker threads and contains logic for handling reconnecting to
+# the mysqld server during connection failure
+class WorkerThread(threading.Thread):
+ def __init__(self, name):
+ threading.Thread.__init__(self)
+ self.name = name
+ self.exception = None
+ self.con = None
+ self.cur = None
+ self.isolation_level = None
+ self.start_time = time.time()
+ self.total_time = 0
+
+ def run(self):
+ global TEST_STOP
+
+ try:
+ logging.info("Started")
+ self.runme()
+ logging.info("Completed successfully")
+ except Exception, e:
+ self.exception = traceback.format_exc()
+ logging.error(self.exception)
+ TEST_STOP = True
+ finally:
+ self.total_time = time.time() - self.start_time
+ logging.info("Total run time: %.2f s" % self.total_time)
+ self.finish()
+
+ def reconnect(self, timeout=900):
+ global TEST_STOP
+
+ self.con = None
+ SECONDS_BETWEEN_RETRY = 10
+ attempts = 1
+ logging.info("Attempting to connect to MySQL Server")
+ while not self.con and timeout > 0 and not TEST_STOP:
+ try:
+ self.con = MySQLdb.connect(user=OPTIONS.user, host=OPTIONS.host,
+ port=OPTIONS.port, db=OPTIONS.db)
+ if self.con:
+ self.con.autocommit(False)
+ self.cur = self.con.cursor()
+ self.set_isolation_level(self.isolation_level)
+ logging.info("Connection successful after attempt %d" % attempts)
+ break
+ except MySQLdb.Error, e:
+ logging.debug(traceback.format_exc())
+ time.sleep(SECONDS_BETWEEN_RETRY)
+ timeout -= SECONDS_BETWEEN_RETRY
+ attempts += 1
+ return self.con is None
+
+ def get_isolation_level(self):
+ execute(self.cur, "SELECT @@SESSION.tx_isolation")
+ if self.cur.rowcount != 1:
+ raise TestError("Unable to retrieve tx_isolation")
+ return self.cur.fetchone()[0]
+
+ def set_isolation_level(self, isolation_level, persist = False):
+ if isolation_level is not None:
+ execute(self.cur, "SET @@SESSION.tx_isolation = '%s'" % isolation_level)
+ if self.cur.rowcount != 0:
+ raise TestError("Unable to set the isolation level to %s")
+
+ if isolation_level is None or persist:
+ self.isolation_level = isolation_level
+
+# periodically kills the server
+class ReaperWorker(WorkerThread):
+ def __init__(self):
+ WorkerThread.__init__(self, 'reaper')
+ self.start()
+ self.kills = 0
+
+ def finish(self):
+ logging.info('complete with %d kills' % self.kills)
+ if self.con:
+ self.con.close()
+
+ def get_server_pid(self):
+ execute(self.cur, "SELECT @@pid_file")
+ if self.cur.rowcount != 1:
+ raise TestError("Unable to retrieve pid_file")
+ return int(open(self.cur.fetchone()[0]).read())
+
+ def runme(self):
+ global TEST_STOP
+ time_remain = random.randint(10, 30)
+ while not TEST_STOP:
+ if time_remain > 0:
+ time_remain -= 1
+ time.sleep(1)
+ continue
+ if self.reconnect():
+ raise Exception("Unable to connect to MySQL server")
+ logging.info('killing server...')
+ with open(OPTIONS.expect_file, 'w+') as expect_file:
+ expect_file.write('restart')
+ os.kill(self.get_server_pid(), signal.SIGTERM)
+ self.kills += 1
+ time_remain = random.randint(0, 30) + OPTIONS.reap_delay;
+
+# runs initially to populate the table with the given number of rows
+class PopulateWorker(WorkerThread):
+ def __init__(self, thread_id, start_id, num_to_add):
+ WorkerThread.__init__(self, 'populate-%d' % thread_id)
+ self.thread_id = thread_id
+ self.start_id = start_id
+ self.num_to_add = num_to_add
+ self.table = OPTIONS.table
+ self.start()
+
+ def finish(self):
+ if self.con:
+ self.con.commit()
+ self.con.close()
+
+ def runme(self):
+ if self.reconnect():
+ raise Exception("Unable to connect to MySQL server")
+
+ stmt = None
+ for i in xrange(self.start_id, self.start_id + self.num_to_add):
+ stmt = gen_insert(self.table, i, 0, 0, 0)
+ execute(self.cur, stmt)
+ if i % 101 == 0:
+ self.con.commit()
+ check_id(self.con.insert_id())
+ self.con.commit()
+ check_id(self.con.insert_id())
+ logging.info("Inserted %d rows starting at id %d" %
+ (self.num_to_add, self.start_id))
+
+def check_id(id):
+ if id == 0:
+ return
+ if id in INSERT_ID_SET:
+ raise Exception("Duplicate auto_inc id %d" % id)
+ INSERT_ID_SET.add(id)
+
+def populate_table(num_records):
+
+ logging.info("Populate_table started for %d records" % num_records)
+ if num_records == 0:
+ return False
+
+ num_workers = min(10, num_records / 100)
+ workers = []
+
+ N = num_records / num_workers
+ start_id = 0
+ for i in xrange(num_workers):
+ workers.append(PopulateWorker(i, start_id, N))
+ start_id += N
+ if num_records > start_id:
+ workers.append(PopulateWorker(num_workers, start_id,
+ num_records - start_id))
+
+ # Wait for the populate threads to complete
+ return wait_for_workers(workers) > 0
+
+def gen_insert(table, idx, thread_id, request_id, zero_sum):
+ msg = gen_msg(idx, thread_id, request_id)
+ return ("INSERT INTO %s (id, thread_id, request_id, zero_sum, "
+ "msg, msg_length, msg_checksum) VALUES (%d,%d,%d,%d,'%s',%d,'%s')"
+ % (table, idx, thread_id, request_id,
+ zero_sum, msg, len(msg), sha1(msg)))
+
+def gen_update(table, idx, thread_id, request_id, zero_sum):
+ msg = gen_msg(idx, thread_id, request_id)
+ return ("UPDATE %s SET thread_id = %d, request_id = %d, "
+ "update_count = update_count + 1, zero_sum = zero_sum + (%d), "
+ "msg = '%s', msg_length = %d, msg_checksum = '%s' WHERE id = %d "
+ % (table, thread_id, request_id, zero_sum, msg, len(msg),
+ sha1(msg), idx))
+
+def gen_delete(table, idx):
+ return "DELETE FROM %s WHERE id = %d" % (table, idx)
+
+def gen_insert_on_dup(table, idx, thread_id, request_id, zero_sum):
+ msg = gen_msg(idx, thread_id, request_id)
+ msg_checksum = sha1(msg)
+ return ("INSERT INTO %s (id, thread_id, request_id, zero_sum, "
+ "msg, msg_length, msg_checksum) VALUES (%d,%d,%d,%d,'%s',%d,'%s') "
+ "ON DUPLICATE KEY UPDATE "
+ "thread_id=%d, request_id=%d, "
+ "update_count=update_count+1, "
+ "zero_sum=zero_sum + (%d), msg='%s', msg_length=%d, "
+ "msg_checksum='%s'" %
+ (table, idx, thread_id, request_id,
+ zero_sum, msg, len(msg), msg_checksum, thread_id, request_id,
+ zero_sum, msg, len(msg), msg_checksum))
+
+# Each loader thread owns a part of the id space which it maintains inventory
+# for. The loader thread generates inserts, updates and deletes for the table.
+# The latest successful transaction and the latest open transaction are kept to
+# verify after a disconnect that the rows were recovered properly.
+class LoadGenWorker(WorkerThread):
+ TXN_UNCOMMITTED = 0
+ TXN_COMMIT_STARTED = 1
+ TXN_COMMITTED = 2
+
+ def __init__(self, thread_id):
+ WorkerThread.__init__(self, 'loader-%02d' % thread_id)
+ self.thread_id = thread_id
+ self.rand = random.Random()
+ self.rand.seed(thread_id)
+ self.loop_num = 0
+
+ # id_map contains the array of id's owned by this worker thread. It needs
+ # to be offset by start_id for the actual id
+ self.id_map = array.array('l')
+ self.start_id = thread_id * OPTIONS.ids_per_loader
+ self.num_id = OPTIONS.ids_per_loader
+ self.start_share_id = OPTIONS.num_loaders * OPTIONS.ids_per_loader
+ self.max_id = OPTIONS.max_id
+ self.table = OPTIONS.table
+ self.num_requests = OPTIONS.num_requests
+
+ # stores information about the latest series of successful transactions
+ #
+ # each transaction is simply a map of id -> request_id
+ # deleted rows are indicated by -request_id
+ self.prev_txn = deque()
+ self.cur_txn = None
+ self.cur_txn_state = None
+
+ self.start()
+
+ def finish(self):
+ if self.total_time:
+ req_per_sec = self.loop_num / self.total_time
+ else:
+ req_per_sec = -1
+ logging.info("total txns: %d, txn/s: %.2f rps" %
+ (self.loop_num, req_per_sec))
+
+ # constructs the internal hash map of the ids owned by this thread and
+ # the request id of each id
+ def populate_id_map(self):
+ logging.info("Populating id map")
+
+ REQ_ID_COL = 0
+ stmt = "SELECT request_id FROM %s WHERE id = %d"
+
+ # the start_id is used for tracking active transactions, so the row needs
+ # to exist
+ idx = self.start_id
+ execute(self.cur, stmt % (self.table, idx))
+ if self.cur.rowcount > 0:
+ request_id = self.cur.fetchone()[REQ_ID_COL]
+ else:
+ request_id = get_next_request_id()
+ execute(self.cur, gen_insert(self.table, idx, self.thread_id,
+ request_id, 0))
+ self.con.commit()
+ check_id(self.con.insert_id())
+
+ self.id_map.append(request_id)
+
+ self.cur_txn = {idx:request_id}
+ self.cur_txn_state = self.TXN_COMMITTED
+ for i in xrange(OPTIONS.committed_txns):
+ self.prev_txn.append(self.cur_txn)
+
+ # fetch the rest of the row for the id space owned by this thread
+ for idx in xrange(self.start_id + 1, self.start_id + self.num_id):
+ execute(self.cur, stmt % (self.table, idx))
+ if self.cur.rowcount == 0:
+ # Negative number is used to indicated a missing row
+ self.id_map.append(-1)
+ else:
+ res = self.cur.fetchone()
+ self.id_map.append(res[REQ_ID_COL])
+
+ self.con.commit()
+
+ def apply_cur_txn_changes(self):
+ # apply the changes to the id_map
+ for idx in self.cur_txn:
+ if idx < self.start_id + self.num_id:
+ assert idx >= self.start_id
+ self.id_map[idx - self.start_id] = self.cur_txn[idx]
+ self.cur_txn_state = self.TXN_COMMITTED
+
+ self.prev_txn.append(self.cur_txn)
+ self.prev_txn.popleft()
+
+ def verify_txn(self, txn, committed):
+ request_id = txn[self.start_id]
+ if not committed:
+ # if the transaction was not committed, then there should be no rows
+ # in the table that have this request_id
+ cond = '='
+ # it is possible the start_id used to track this transaction is in
+ # the process of being deleted
+ if request_id < 0:
+ request_id = -request_id
+ else:
+ # if the transaction was committed, then no rows modified by this
+ # transaction should have a request_id less than this transaction's id
+ cond = '<'
+ stmt = ("SELECT COUNT(*) FROM %s WHERE id IN (%s) AND request_id %s %d" %
+ (self.table, ','.join(str(x) for x in txn), cond, request_id))
+ execute(self.cur, stmt)
+ if (self.cur.rowcount != 1):
+ raise TestError("Unable to retrieve results for query '%s'" % stmt)
+ count = self.cur.fetchone()[0]
+ if (count > 0):
+ raise TestError("Expected '%s' to return 0 rows, but %d returned "
+ "instead" % (stmt, count))
+ self.con.commit()
+
+ def verify_data(self):
+ # if the state of the current transaction is unknown (i.e. a commit was
+ # issued, but the connection failed before, check the start_id row to
+ # determine if it was committed
+ request_id = self.cur_txn[self.start_id]
+ if self.cur_txn_state == self.TXN_COMMIT_STARTED:
+ assert request_id >= 0
+ idx = self.start_id
+ stmt = "SELECT id, request_id FROM %s where id = %d" % (self.table, idx)
+ execute(self.cur, stmt)
+ if (self.cur.rowcount == 0):
+ raise TestError("Fetching start_id %d via '%s' returned no data! "
+ "This row should never be deleted!" % (idx, stmt))
+ REQUEST_ID_COL = 1
+ res = self.cur.fetchone()
+ if res[REQUEST_ID_COL] == self.cur_txn[idx]:
+ self.apply_cur_txn_changes()
+ else:
+ self.cur_txn_state = self.TXN_UNCOMMITTED
+ self.con.commit()
+
+ # if the transaction was not committed, verify there are no rows at this
+ # request id
+ #
+ # however, if the transaction was committed, then verify none of the rows
+ # have a request_id below the request_id recorded by the start_id row.
+ if self.cur_txn_state == self.TXN_UNCOMMITTED:
+ self.verify_txn(self.cur_txn, False)
+
+ # verify all committed transactions
+ for txn in self.prev_txn:
+ self.verify_txn(txn, True)
+
+ # verify the rows owned by this worker matches the request_id at which
+ # they were set.
+ idx = self.start_id
+ max_map_id = self.start_id + self.num_id
+ row_count = 0
+ ID_COL = 0
+ REQ_ID_COL = ID_COL + 1
+
+ while idx < max_map_id:
+ if (row_count == 0):
+ num_rows_to_check = random.randint(50, 100)
+ execute(self.cur,
+ "SELECT id, request_id FROM %s where id >= %d and id < %d "
+ "ORDER BY id LIMIT %d"
+ % (self.table, idx, max_map_id, num_rows_to_check))
+
+ # prevent future queries from being issued since we've hit the end of
+ # the rows that exist in the table
+ row_count = self.cur.rowcount if self.cur.rowcount != 0 else -1
+
+ # determine the id of the next available row in the table
+ if (row_count > 0):
+ res = self.cur.fetchone()
+ assert idx <= res[ID_COL]
+ next_id = res[ID_COL]
+ row_count -= 1
+ else:
+ next_id = max_map_id
+
+ # rows up to the next id don't exist within the table, verify our
+ # map has them as removed
+ while idx < next_id:
+ # see if the latest transaction may have modified this id. If so, use
+ # that value.
+ if self.id_map[idx - self.start_id] >= 0:
+ raise ValidateError("Row id %d was not found in table, but "
+ "id_map has it at request_id %d" %
+ (idx, self.id_map[idx - self.start_id]))
+ idx += 1
+
+ if idx == max_map_id:
+ break
+
+ if (self.id_map[idx - self.start_id] != res[REQ_ID_COL]):
+ raise ValidateError("Row id %d has req id %d, but %d is the "
+ "expected value!" %
+ (idx, res[REQ_ID_COL],
+ self.id_map[idx - self.start_id]))
+ idx += 1
+
+ self.con.commit()
+ logging.debug("Verified data successfully")
+
+ def execute_one(self):
+ # select a number of rows; perform an insert; update or delete operation on
+ # them
+ num_rows = random.randint(1, MAX_ROWS_PER_REQ)
+ ids = array.array('L')
+
+ # allocate at least one row in the id space owned by this worker
+ idx = random.randint(self.start_id, self.start_id + self.num_id - 1)
+ ids.append(idx)
+
+ for i in xrange(1, num_rows):
+ # The valid ranges for ids is from start_id to start_id + num_id and from
+ # start_share_id to max_id. The randint() uses the range from
+ # start_share_id to max_id + num_id - 1. start_share_id to max_id covers
+ # the shared range. The exclusive range is covered by max_id to max_id +
+ # num_id - 1. If any number lands in this >= max_id section, it is
+ # remapped to start_id and used for selecting a row in the exclusive
+ # section.
+ idx = random.randint(self.start_share_id, self.max_id + self.num_id - 1)
+ if idx >= self.max_id:
+ idx -= self.max_id - self.start_id
+ if ids.count(idx) == 0:
+ ids.append(idx)
+
+ # perform a read of these rows
+ ID_COL = 0
+ ZERO_SUM_COL = ID_COL + 1
+
+ # For repeatable-read isolation levels on MyRocks, during the lock
+ # acquisition part of this transaction, it is possible the selected rows
+ # conflict with another thread's transaction. This results in a deadlock
+ # error that requires the whole transaction to be rolled back because the
+ # transaction's current snapshot will always be reading an older version of
+ # the row. MyRocks will prevent any updates to this row until the
+ # snapshot is released and re-acquired.
+ NUM_RETRIES = 100
+ for i in xrange(NUM_RETRIES):
+ ids_found = {}
+ try:
+ for idx in ids:
+ stmt = ("SELECT id, zero_sum FROM %s WHERE id = %d "
+ "FOR UPDATE" % (self.table, idx))
+ execute(self.cur, stmt)
+ if self.cur.rowcount > 0:
+ res = self.cur.fetchone()
+ ids_found[res[ID_COL]] = res[ZERO_SUM_COL]
+ break
+ except MySQLdb.OperationalError, e:
+ if not is_deadlock_error(e):
+ raise e
+
+ # if a deadlock occurred, rollback the transaction and wait a short time
+ # before retrying.
+ logging.debug("%s generated deadlock, retry %d of %d" %
+ (stmt, i, NUM_RETRIES))
+ self.con.rollback()
+ time.sleep(0.2)
+
+ if i == NUM_RETRIES - 1:
+ raise TestError("Unable to acquire locks after a number of retries "
+ "for query '%s'" % stmt)
+
+ # ensure that the zero_sum column remains summed up to zero at the
+ # end of this operation
+ current_sum = 0
+
+ # all row locks acquired at this point, so allocate a request_id
+ request_id = get_next_request_id()
+ self.cur_txn = {self.start_id:request_id}
+ self.cur_txn_state = self.TXN_UNCOMMITTED
+
+ for idx in ids:
+ stmt = None
+ zero_sum = self.rand.randint(-1000, 1000)
+ action = self.rand.randint(0, 3)
+ is_delete = False
+
+ if idx in ids_found:
+ # for each row found, determine if it should be updated or deleted
+ if action == 0:
+ stmt = gen_delete(self.table, idx)
+ is_delete = True
+ current_sum -= ids_found[idx]
+ else:
+ stmt = gen_update(self.table, idx, self.thread_id, request_id,
+ zero_sum)
+ current_sum += zero_sum
+ else:
+ # if it does not exist, then determine if an insert should happen
+ if action <= 1:
+ stmt = gen_insert(self.table, idx, self.thread_id, request_id,
+ zero_sum)
+ current_sum += zero_sum
+
+ if stmt is not None:
+ # mark in self.cur_txn what these new changes will be
+ if is_delete:
+ self.cur_txn[idx] = -request_id
+ else:
+ self.cur_txn[idx] = request_id
+ execute(self.cur, stmt)
+ if self.cur.rowcount == 0:
+ raise TestError("Executing %s returned row count of 0!" % stmt)
+
+ # the start_id row is used to determine if this transaction has been
+ # committed if the connect fails and it is used to adjust the zero_sum
+ # correctly
+ idx = self.start_id
+ ids.append(idx)
+ self.cur_txn[idx] = request_id
+ stmt = gen_insert_on_dup(self.table, idx, self.thread_id, request_id,
+ -current_sum)
+ execute(self.cur, stmt)
+ if self.cur.rowcount == 0:
+ raise TestError("Executing '%s' returned row count of 0!" % stmt)
+
+ # 90% commit, 10% rollback
+ if roll_d100(90):
+ self.con.rollback()
+ logging.debug("request %s was rolled back" % request_id)
+ else:
+ self.cur_txn_state = self.TXN_COMMIT_STARTED
+ self.con.commit()
+ check_id(self.con.insert_id())
+ if not self.con.get_server_info():
+ raise MySQLdb.OperationalError(MySQLdb.constants.CR.CONNECTION_ERROR,
+ "Possible connection error on commit")
+ self.apply_cur_txn_changes()
+
+ self.loop_num += 1
+ if self.loop_num % 1000 == 0:
+ logging.info("Processed %d transactions so far" % self.loop_num)
+
+ def runme(self):
+ global TEST_STOP, LOADERS_READY
+
+ self.start_time = time.time()
+ if self.reconnect():
+ raise Exception("Unable to connect to MySQL server")
+
+ self.populate_id_map()
+ self.verify_data()
+
+ logging.info("Starting load generator")
+ reconnected = False
+ LOADERS_READY += 1
+
+ while self.loop_num < self.num_requests and not TEST_STOP:
+ try:
+ # verify our data on each reconnect and also on ocassion
+ if reconnected or random.randint(1, 500) == 1:
+ self.verify_data()
+ reconnected = False
+
+ self.execute_one()
+ self.loop_num += 1
+ except MySQLdb.OperationalError, e:
+ if not is_connection_error(e):
+ raise e
+ if self.reconnect():
+ raise Exception("Unable to connect to MySQL server")
+ reconnected = True
+ return
+
+# the checker thread is running read only transactions to verify the row
+# checksums match the message.
+class CheckerWorker(WorkerThread):
+ def __init__(self, thread_id):
+ WorkerThread.__init__(self, 'checker-%02d' % thread_id)
+ self.thread_id = thread_id
+ self.rand = random.Random()
+ self.rand.seed(thread_id)
+ self.max_id = OPTIONS.max_id
+ self.table = OPTIONS.table
+ self.loop_num = 0
+ self.start()
+
+ def finish(self):
+ logging.info("total loops: %d" % self.loop_num)
+
+ def check_zerosum(self):
+ # two methods for checking zero sum
+ # 1. request the server to do it (90% of the time for now)
+ # 2. read all rows and calculate directly
+ if roll_d100(90):
+ stmt = "SELECT SUM(zero_sum) FROM %s" % self.table
+ if roll_d100(50):
+ stmt += " FORCE INDEX(msg_i)"
+ execute(self.cur, stmt)
+
+ if self.cur.rowcount != 1:
+ raise ValidateError("Error with query '%s'" % stmt)
+ res = self.cur.fetchone()[0]
+ if res != 0:
+ raise ValidateError("Expected zero_sum to be 0, but %d returned "
+ "instead" % res)
+ else:
+ cur_isolation_level = self.get_isolation_level()
+ self.set_isolation_level('REPEATABLE-READ')
+ num_rows_to_check = random.randint(500, 1000)
+ idx = 0
+ sum = 0
+
+ stmt = "SELECT id, zero_sum FROM %s where id >= %d ORDER BY id LIMIT %d"
+ ID_COL = 0
+ ZERO_SUM_COL = 1
+
+ while idx < self.max_id:
+ execute(self.cur, stmt % (self.table, idx, num_rows_to_check))
+ if self.cur.rowcount == 0:
+ break
+
+ for i in xrange(self.cur.rowcount - 1):
+ sum += self.cur.fetchone()[ZERO_SUM_COL]
+
+ last_row = self.cur.fetchone()
+ idx = last_row[ID_COL] + 1
+ sum += last_row[ZERO_SUM_COL]
+
+ if sum != 0:
+ raise TestError("Zero sum column expected to total 0, but sum is %d "
+ "instead!" % sum)
+ self.set_isolation_level(cur_isolation_level)
+
+ def check_rows(self):
+ class id_range():
+ def __init__(self, min_id, min_inclusive, max_id, max_inclusive):
+ self.min_id = min_id if min_inclusive else min_id + 1
+ self.max_id = max_id if max_inclusive else max_id - 1
+ def count(self, idx):
+ return idx >= self.min_id and idx <= self.max_id
+
+ stmt = ("SELECT id, msg, msg_length, msg_checksum FROM %s WHERE " %
+ self.table)
+
+ # two methods for checking rows
+ # 1. pick a number of rows at random
+ # 2. range scan
+ if roll_d100(90):
+ ids = []
+ for i in xrange(random.randint(1, MAX_ROWS_PER_REQ)):
+ ids.append(random.randint(0, self.max_id - 1))
+ stmt += "id in (%s)" % ','.join(str(x) for x in ids)
+ else:
+ id1 = random.randint(0, self.max_id - 1)
+ id2 = random.randint(0, self.max_id - 1)
+ min_inclusive = random.randint(0, 1)
+ cond1 = '>=' if min_inclusive else '>'
+ max_inclusive = random.randint(0, 1)
+ cond2 = '<=' if max_inclusive else '<'
+ stmt += ("id %s %d AND id %s %d" %
+ (cond1, min(id1, id2), cond2, max(id1, id2)))
+ ids = id_range(min(id1, id2), min_inclusive, max(id1, id2), max_inclusive)
+
+ execute(self.cur, stmt)
+
+ ID_COL = 0
+ MSG_COL = ID_COL + 1
+ MSG_LENGTH_COL = MSG_COL + 1
+ MSG_CHECKSUM_COL = MSG_LENGTH_COL + 1
+
+ for row in self.cur.fetchall():
+ idx = row[ID_COL]
+ msg = row[MSG_COL]
+ msg_length = row[MSG_LENGTH_COL]
+ msg_checksum = row[MSG_CHECKSUM_COL]
+ if ids.count(idx) < 1:
+ raise ValidateError(
+ "id %d returned from database, but query was '%s'" % (idx, stmt))
+ if (len(msg) != msg_length):
+ raise ValidateError(
+ "id %d contains msg_length %d, but msg '%s' is only %d "
+ "characters long" % (idx, msg_length, msg, len(msg)))
+ if (sha1(msg) != msg_checksum):
+ raise ValidateError("id %d has checksum '%s', but expected checksum "
+ "is '%s'" % (idx, msg_checksum, sha1(msg)))
+
+ def runme(self):
+ global TEST_STOP
+
+ self.start_time = time.time()
+ if self.reconnect():
+ raise Exception("Unable to connect to MySQL server")
+ logging.info("Starting checker")
+
+ while not TEST_STOP:
+ try:
+ # choose one of three options:
+ # 1. compute zero_sum across all rows is 0
+ # 2. read a number of rows and verify checksums
+ if roll_d100(25):
+ self.check_zerosum()
+ else:
+ self.check_rows()
+
+ self.con.commit()
+ self.loop_num += 1
+ if self.loop_num % 10000 == 0:
+ logging.info("Processed %d transactions so far" % self.loop_num)
+ except MySQLdb.OperationalError, e:
+ if not is_connection_error(e):
+ raise e
+ if self.reconnect():
+ raise Exception("Unable to reconnect to MySQL server")
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(description='Concurrent load generator.')
+
+ parser.add_argument('-C, --committed-txns', dest='committed_txns',
+ default=3, type=int,
+ help="number of committed txns to verify")
+
+ parser.add_argument('-c, --num-checkers', dest='num_checkers', type=int,
+ default=4,
+ help="number of reader/checker threads to test with")
+
+ parser.add_argument('-d, --db', dest='db', default='test',
+ help="mysqld server database to test with")
+
+ parser.add_argument('-H, --host', dest='host', default='127.0.0.1',
+ help="mysqld server host ip address")
+
+ parser.add_argument('-i, --ids-per-loader', dest='ids_per_loader',
+ type=int, default=100,
+ help="number of records which each loader owns "
+ "exclusively, up to max-id / 2 / num-loaders")
+
+ parser.add_argument('-L, --log-file', dest='log_file', default=None,
+ help="log file for output")
+
+ parser.add_argument('-l, --num-loaders', dest='num_loaders', type=int,
+ default=16,
+ help="number of loader threads to test with")
+
+ parser.add_argument('-m, --max-id', dest='max_id', type=int, default=1000,
+ help="maximum number of records which the table "
+ "extends to, must be larger than ids_per_loader * "
+ "num_loaders")
+
+ parser.add_argument('-n, --num-records', dest='num_records', type=int,
+ default=0,
+ help="number of records to populate the table with")
+
+ parser.add_argument('-P, --port', dest='port', default=3307, type=int,
+ help='mysqld server host port')
+
+ parser.add_argument('-r, --num-requests', dest='num_requests', type=int,
+ default=100000000,
+ help="number of requests issued per worker thread")
+
+ parser.add_argument('-T, --truncate', dest='truncate', action='store_true',
+ help="truncates or creates the table before the test")
+
+ parser.add_argument('-t, --table', dest='table', default='t1',
+ help="mysqld server table to test with")
+
+ parser.add_argument('-u, --user', dest='user', default='root',
+ help="user to log into the mysql server")
+
+ parser.add_argument('-v, --verbose', dest='verbose', action='store_true',
+ help="enable debug logging")
+
+ parser.add_argument('-E, --expect-file', dest='expect_file', default=None,
+ help="expect file for server restart")
+
+ parser.add_argument('-D, --reap-delay', dest='reap_delay', type=int,
+ default=0,
+ help="seconds to sleep after each server reap")
+
+ OPTIONS = parser.parse_args()
+
+ if OPTIONS.verbose:
+ log_level = logging.DEBUG
+ else:
+ log_level = logging.INFO
+
+ logging.basicConfig(level=log_level,
+ format='%(asctime)s %(threadName)s [%(levelname)s] '
+ '%(message)s',
+ datefmt='%Y-%m-%d %H:%M:%S',
+ filename=OPTIONS.log_file)
+
+ logging.info("Command line given: %s" % ' '.join(sys.argv))
+
+ if (OPTIONS.max_id < 0 or OPTIONS.ids_per_loader <= 0 or
+ OPTIONS.max_id < OPTIONS.ids_per_loader * OPTIONS.num_loaders):
+ logging.error("ids-per-loader must be larger tha 0 and max-id must be "
+ "larger than ids_per_loader * num_loaders")
+ exit(1)
+
+ logging.info("Using table %s.%s for test" % (OPTIONS.db, OPTIONS.table))
+
+ if OPTIONS.truncate:
+ logging.info("Truncating table")
+ con = MySQLdb.connect(user=OPTIONS.user, host=OPTIONS.host,
+ port=OPTIONS.port, db=OPTIONS.db)
+ if not con:
+ raise TestError("Unable to connect to mysqld server to create/truncate "
+ "table")
+ cur = con.cursor()
+ cur.execute("SELECT COUNT(*) FROM INFORMATION_SCHEMA.tables WHERE "
+ "table_schema = '%s' AND table_name = '%s'" %
+ (OPTIONS.db, OPTIONS.table))
+ if cur.rowcount != 1:
+ logging.error("Unable to retrieve information about table %s "
+ "from information_schema!" % OPTIONS.table)
+ exit(1)
+
+ if cur.fetchone()[0] == 0:
+ logging.info("Table %s not found, creating a new one" % OPTIONS.table)
+ cur.execute("CREATE TABLE %s (id INT PRIMARY KEY, "
+ "thread_id INT NOT NULL, "
+ "request_id BIGINT UNSIGNED NOT NULL, "
+ "update_count INT UNSIGNED NOT NULL DEFAULT 0, "
+ "zero_sum INT DEFAULT 0, "
+ "msg VARCHAR(1024), "
+ "msg_length int, "
+ "msg_checksum varchar(128), "
+ "KEY msg_i(msg(255), zero_sum)) "
+ "ENGINE=RocksDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin" %
+ OPTIONS.table)
+ else:
+ logging.info("Table %s found, truncating" % OPTIONS.table)
+ cur.execute("TRUNCATE TABLE %s" % OPTIONS.table)
+ con.commit()
+
+ if populate_table(OPTIONS.num_records):
+ logging.error("Populate table returned an error")
+ exit(1)
+
+ logging.info("Starting %d loaders" % OPTIONS.num_loaders)
+ loaders = []
+ for i in xrange(OPTIONS.num_loaders):
+ loaders.append(LoadGenWorker(i))
+
+ logging.info("Starting %d checkers" % OPTIONS.num_checkers)
+ checkers = []
+ for i in xrange(OPTIONS.num_checkers):
+ checkers.append(CheckerWorker(i))
+
+ while LOADERS_READY < OPTIONS.num_loaders:
+ time.sleep(0.5)
+
+ if OPTIONS.expect_file and OPTIONS.reap_delay > 0:
+ logging.info('Starting reaper')
+ checkers.append(ReaperWorker())
+
+ workers_failed = 0
+ workers_failed += wait_for_workers(loaders, len(checkers))
+
+ if TEST_STOP:
+ logging.error("Detected test failure, aborting")
+ os._exit(1)
+
+ TEST_STOP = True
+
+ workers_failed += wait_for_workers(checkers)
+
+ if workers_failed > 0:
+ logging.error("Test detected %d failures, aborting" % workers_failed)
+ sys.exit(1)
+
+ logging.info("Test completed successfully")
+ sys.exit(0)
diff --git a/storage/rocksdb/mysql-test/rocksdb_stress/t/rocksdb_stress.test b/storage/rocksdb/mysql-test/rocksdb_stress/t/rocksdb_stress.test
new file mode 100644
index 00000000..e48b0c47
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_stress/t/rocksdb_stress.test
@@ -0,0 +1,33 @@
+# basic stress tests for myrocks, just runs the load generator without any crashes
+
+# Don't test this under valgrind, memory leaks will occur
+--disable_warnings
+--source include/not_valgrind.inc
+--source include/have_rocksdb.inc
+--source include/master-slave.inc
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# create the actual table
+CREATE TABLE t1(id INT PRIMARY KEY,
+ thread_id INT NOT NULL,
+ request_id BIGINT UNSIGNED NOT NULL,
+ update_count INT UNSIGNED NOT NULL DEFAULT 0,
+ zero_sum INT DEFAULT 0,
+ msg VARCHAR(1024),
+ msg_length int,
+ msg_checksum varchar(128),
+ auto_inc BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
+ KEY(auto_inc),
+ KEY msg_i(msg(255), zero_sum))
+ENGINE=RocksDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
+
+--let $table = t1
+--let $num_loaders = 8
+--let $num_checkers = 2
+--let $num_records = 200
+--let $max_records = 100000
+--let $num_requests = 10000
+--let $reap_delay = 0
+
+--source include/rocksdb_stress.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_stress/t/rocksdb_stress_crash.test b/storage/rocksdb/mysql-test/rocksdb_stress/t/rocksdb_stress_crash.test
new file mode 100644
index 00000000..3da3dc7b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_stress/t/rocksdb_stress_crash.test
@@ -0,0 +1,34 @@
+# basic stress tests for myrocks, runs the load generator with periodic crashes
+
+# Don't test this under valgrind, memory leaks will occur
+--disable_warnings
+--source include/not_valgrind.inc
+--source include/have_rocksdb.inc
+--source include/master-slave.inc
+--source include/have_binlog_format_row.inc
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# create the actual table
+CREATE TABLE t1(id INT PRIMARY KEY,
+ thread_id INT NOT NULL,
+ request_id BIGINT UNSIGNED NOT NULL,
+ update_count INT UNSIGNED NOT NULL DEFAULT 0,
+ zero_sum INT DEFAULT 0,
+ msg VARCHAR(1024),
+ msg_length int,
+ msg_checksum varchar(128),
+ auto_inc BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
+ KEY(auto_inc),
+ KEY msg_i(msg(255), zero_sum))
+ENGINE=RocksDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
+
+--let $table = t1
+--let $num_loaders = 8
+--let $num_checkers = 2
+--let $num_records = 200
+--let $max_records = 100000
+--let $num_requests = 10000
+--let $reap_delay = 180
+
+--source include/rocksdb_stress.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/include/correctboolvalue.inc b/storage/rocksdb/mysql-test/rocksdb_sys_vars/include/correctboolvalue.inc
new file mode 100644
index 00000000..f675aec1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/include/correctboolvalue.inc
@@ -0,0 +1,25 @@
+##
+# $input the value of a boolean type
+# $output the value of int type
+##
+--let $int_value=$value
+if ($value==on)
+{
+ --let $int_value=1
+}
+
+if ($value==off)
+{
+ --let $int_value=0
+}
+
+# MySQL allows 'true' and 'false' on bool values
+if ($value==true)
+{
+ --let $int_value=1
+}
+
+if ($value==false)
+{
+ --let $int_value=0
+}
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/include/have_rocksdb.inc b/storage/rocksdb/mysql-test/rocksdb_sys_vars/include/have_rocksdb.inc
new file mode 100644
index 00000000..1f762d38
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/include/have_rocksdb.inc
@@ -0,0 +1,10 @@
+if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'rocksdb' AND support IN ('YES', 'DEFAULT', 'ENABLED')`)
+{
+ --skip Test requires engine RocksDB.
+}
+
+--disable_query_log
+# Table statistics can vary depending on when the memtables are flushed, so
+# flush them at the beginning of the test to ensure the test runs consistently.
+set global rocksdb_force_flush_memtable_now = true;
+--enable_query_log
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/include/have_rocksdb.opt b/storage/rocksdb/mysql-test/rocksdb_sys_vars/include/have_rocksdb.opt
new file mode 100644
index 00000000..36d7dda1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/include/have_rocksdb.opt
@@ -0,0 +1,12 @@
+--loose-enable-rocksdb
+--loose-enable-rocksdb_global_info
+--loose-enable-rocksdb_ddl
+--loose-enable-rocksdb_cf_options
+--loose-enable_rocksdb_perf_context
+--loose-enable_rocksdb_perf_context_global
+--loose-enable-rocksdb_index_file_map
+--loose-enable-rocksdb_dbstats
+--loose-enable-rocksdb_cfstats
+--loose-enable-rocksdb_lock_info
+--loose-enable-rocksdb_trx
+--loose-enable-rocksdb_locks
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/include/rocksdb_sys_var.inc b/storage/rocksdb/mysql-test/rocksdb_sys_vars/include/rocksdb_sys_var.inc
new file mode 100644
index 00000000..db0abc57
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/include/rocksdb_sys_var.inc
@@ -0,0 +1,124 @@
+##
+# $sys_var name of the variable
+# $read_only - true if read-only
+# $session - true if this is session, false if global-only
+# $suppress_default_value - if true, don't check the default value
+# valid_values table should contain valid values
+# invalid_values
+##
+
+--eval SET @start_global_value = @@global.$sys_var
+if (!$suppress_default_value)
+{
+ --replace_regex /[a-f0-9]{40}/#/
+ SELECT @start_global_value;
+ if ($session)
+ {
+ --eval SET @start_session_value = @@session.$sys_var
+ SELECT @start_session_value;
+ }
+}
+
+if (!$read_only)
+{
+ --echo '# Setting to valid values in global scope#'
+
+ --let $i=1
+ --let $value=query_get_value(select value from valid_values, value, $i)
+ while ($value != 'No such row')
+ {
+ --echo "Trying to set variable @@global.$sys_var to $value"
+ --eval SET @@global.$sys_var = $value
+ --eval SELECT @@global.$sys_var
+ --let $v=`SELECT @@global.$sys_var`
+ --source include/correctboolvalue.inc
+ if (!$sticky)
+ {
+ if ($v != $int_value)
+ {
+ --echo Set @@global.$sys_var to $value but it remained set to $v
+ --die Wrong variable value
+ }
+ }
+
+ --echo "Setting the global scope variable back to default"
+ --eval SET @@global.$sys_var = DEFAULT
+ --eval SELECT @@global.$sys_var
+
+ --inc $i
+ --let $value=query_get_value(select value from valid_values, value, $i)
+ }
+
+ if ($session)
+ {
+ --echo '# Setting to valid values in session scope#'
+
+ --let $i=1
+ --let $value=query_get_value(select value from valid_values, value, $i)
+ while ($value != 'No such row')
+ {
+ --echo "Trying to set variable @@session.$sys_var to $value"
+ --eval SET @@session.$sys_var = $value
+ --eval SELECT @@session.$sys_var
+ --let $v=`SELECT @@session.$sys_var`
+ --source include/correctboolvalue.inc
+ if (!$sticky)
+ {
+ if ($v != $int_value)
+ {
+ --echo Set @@session.$sys_var to $value but it remained set to $v
+ --die Wrong variable value
+ }
+ }
+ --echo "Setting the session scope variable back to default"
+ --eval SET @@session.$sys_var = DEFAULT
+ --eval SELECT @@session.$sys_var
+
+ --inc $i
+ --let $value=query_get_value(select value from valid_values, value, $i)
+ }
+ }
+ if (!$session)
+ {
+ --echo "Trying to set variable @@session.$sys_var to 444. It should fail because it is not session."
+ --Error ER_GLOBAL_VARIABLE
+ --eval SET @@session.$sys_var = 444
+ }
+
+ --echo '# Testing with invalid values in global scope #'
+ ####################################################################
+ # Change the value of query_prealloc_size to an invalid value #
+ ####################################################################
+ --let $i=1
+ --let $value=query_get_value(select value from invalid_values, value, $i)
+ while ($value != 'No such row')
+ {
+ --echo "Trying to set variable @@global.$sys_var to $value"
+ --Error ER_WRONG_VALUE_FOR_VAR, ER_WRONG_TYPE_FOR_VAR
+ --eval SET @@global.$sys_var = $value
+ --eval SELECT @@global.$sys_var
+ --inc $i
+ --let $value=query_get_value(select value from invalid_values, value, $i)
+ }
+}
+
+if ($read_only)
+{
+ --echo "Trying to set variable @@global.$sys_var to 444. It should fail because it is readonly."
+ --Error ER_INCORRECT_GLOBAL_LOCAL_VAR
+ --eval SET @@global.$sys_var = 444
+}
+
+####################################
+# Restore initial value #
+####################################
+if (!$read_only)
+{
+ --eval SET @@global.$sys_var = @start_global_value
+ --eval SELECT @@global.$sys_var
+ if ($session)
+ {
+ --eval SET @@session.$sys_var = @start_session_value
+ --eval SELECT @@session.$sys_var
+ }
+}
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/my.cnf b/storage/rocksdb/mysql-test/rocksdb_sys_vars/my.cnf
new file mode 100644
index 00000000..f37bb45b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/my.cnf
@@ -0,0 +1,10 @@
+!include include/default_my.cnf
+
+[server]
+skip-innodb
+default-storage-engine=rocksdb
+
+sql-mode=NO_ENGINE_SUBSTITUTION
+explicit-defaults-for-timestamp=1
+loose-rocksdb_lock_wait_timeout=1
+loose-rocksdb_force_compute_memtable_stats_cachetime=0
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/all_vars.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/all_vars.result
new file mode 100644
index 00000000..159d6a98
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/all_vars.result
@@ -0,0 +1,13 @@
+create table t1 (test_name text) engine=MyISAM;
+create table t2 (variable_name text) engine=MyISAM;
+load data infile "MYSQLTEST_VARDIR/tmp/rocksdb_sys_vars.all_vars.txt" into table t1;
+insert into t2 select variable_name from information_schema.global_variables where variable_name like "rocksdb_%";
+insert into t2 select variable_name from information_schema.session_variables where variable_name like "rocksdb_%";
+select variable_name as `There should be *no* long test name listed below:` from t2
+where length(variable_name) > 50;
+There should be *no* long test name listed below:
+select variable_name as `There should be *no* variables listed below:` from t2
+left join t1 on variable_name=test_name where test_name is null ORDER BY variable_name;
+There should be *no* variables listed below:
+drop table t1;
+drop table t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_access_hint_on_compaction_start_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_access_hint_on_compaction_start_basic.result
new file mode 100644
index 00000000..4398563d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_access_hint_on_compaction_start_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_ACCESS_HINT_ON_COMPACTION_START;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_ACCESS_HINT_ON_COMPACTION_START to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_ACCESS_HINT_ON_COMPACTION_START = 444;
+ERROR HY000: Variable 'rocksdb_access_hint_on_compaction_start' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_advise_random_on_open_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_advise_random_on_open_basic.result
new file mode 100644
index 00000000..f7175fd9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_advise_random_on_open_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_ADVISE_RANDOM_ON_OPEN;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_ADVISE_RANDOM_ON_OPEN to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_ADVISE_RANDOM_ON_OPEN = 444;
+ERROR HY000: Variable 'rocksdb_advise_random_on_open' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_concurrent_memtable_write_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_concurrent_memtable_write_basic.result
new file mode 100644
index 00000000..3b174fbb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_concurrent_memtable_write_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_ALLOW_CONCURRENT_MEMTABLE_WRITE;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_ALLOW_CONCURRENT_MEMTABLE_WRITE to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_ALLOW_CONCURRENT_MEMTABLE_WRITE = 444;
+ERROR HY000: Variable 'rocksdb_allow_concurrent_memtable_write' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_mmap_reads_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_mmap_reads_basic.result
new file mode 100644
index 00000000..f0f1b077
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_mmap_reads_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_ALLOW_MMAP_READS;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_ALLOW_MMAP_READS to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_ALLOW_MMAP_READS = 444;
+ERROR HY000: Variable 'rocksdb_allow_mmap_reads' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_mmap_writes_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_mmap_writes_basic.result
new file mode 100644
index 00000000..3fa1f14e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_mmap_writes_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_ALLOW_MMAP_WRITES;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_ALLOW_MMAP_WRITES to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_ALLOW_MMAP_WRITES = 444;
+ERROR HY000: Variable 'rocksdb_allow_mmap_writes' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_to_start_after_corruption_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_to_start_after_corruption_basic.result
new file mode 100644
index 00000000..086010dc
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_allow_to_start_after_corruption_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_ALLOW_TO_START_AFTER_CORRUPTION;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_ALLOW_TO_START_AFTER_CORRUPTION to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_ALLOW_TO_START_AFTER_CORRUPTION = 444;
+ERROR HY000: Variable 'rocksdb_allow_to_start_after_corruption' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_blind_delete_primary_key_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_blind_delete_primary_key_basic.result
new file mode 100644
index 00000000..805ed233
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_blind_delete_primary_key_basic.result
@@ -0,0 +1,100 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY to 1"
+SET @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = 1;
+SELECT @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = DEFAULT;
+SELECT @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+0
+"Trying to set variable @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY to 0"
+SET @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = 0;
+SELECT @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = DEFAULT;
+SELECT @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+0
+"Trying to set variable @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY to on"
+SET @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = on;
+SELECT @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = DEFAULT;
+SELECT @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY to 1"
+SET @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = 1;
+SELECT @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = DEFAULT;
+SELECT @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+0
+"Trying to set variable @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY to 0"
+SET @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = 0;
+SELECT @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = DEFAULT;
+SELECT @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+0
+"Trying to set variable @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY to on"
+SET @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = on;
+SELECT @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = DEFAULT;
+SELECT @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY to 'aaa'"
+SET @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+0
+"Trying to set variable @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY to 'bbb'"
+SET @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+0
+SET @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = @start_global_value;
+SELECT @@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@global.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+0
+SET @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY = @start_session_value;
+SELECT @@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY;
+@@session.ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_cache_size_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_cache_size_basic.result
new file mode 100644
index 00000000..b319c39a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_cache_size_basic.result
@@ -0,0 +1,85 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(65536);
+INSERT INTO valid_values VALUES(1024);
+INSERT INTO valid_values VALUES(1*1024*1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+SET @start_global_value = @@global.ROCKSDB_BLOCK_CACHE_SIZE;
+SELECT @start_global_value;
+@start_global_value
+536870912
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_BLOCK_CACHE_SIZE to 65536"
+SET @@global.ROCKSDB_BLOCK_CACHE_SIZE = 65536;
+SELECT @@global.ROCKSDB_BLOCK_CACHE_SIZE;
+@@global.ROCKSDB_BLOCK_CACHE_SIZE
+65536
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BLOCK_CACHE_SIZE = DEFAULT;
+SELECT @@global.ROCKSDB_BLOCK_CACHE_SIZE;
+@@global.ROCKSDB_BLOCK_CACHE_SIZE
+536870912
+"Trying to set variable @@global.ROCKSDB_BLOCK_CACHE_SIZE to 1024"
+SET @@global.ROCKSDB_BLOCK_CACHE_SIZE = 1024;
+SELECT @@global.ROCKSDB_BLOCK_CACHE_SIZE;
+@@global.ROCKSDB_BLOCK_CACHE_SIZE
+1024
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BLOCK_CACHE_SIZE = DEFAULT;
+SELECT @@global.ROCKSDB_BLOCK_CACHE_SIZE;
+@@global.ROCKSDB_BLOCK_CACHE_SIZE
+536870912
+"Trying to set variable @@global.ROCKSDB_BLOCK_CACHE_SIZE to 1048576"
+SET @@global.ROCKSDB_BLOCK_CACHE_SIZE = 1048576;
+SELECT @@global.ROCKSDB_BLOCK_CACHE_SIZE;
+@@global.ROCKSDB_BLOCK_CACHE_SIZE
+1048576
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BLOCK_CACHE_SIZE = DEFAULT;
+SELECT @@global.ROCKSDB_BLOCK_CACHE_SIZE;
+@@global.ROCKSDB_BLOCK_CACHE_SIZE
+536870912
+"Trying to set variable @@session.ROCKSDB_BLOCK_CACHE_SIZE to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_BLOCK_CACHE_SIZE = 444;
+ERROR HY000: Variable 'rocksdb_block_cache_size' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_BLOCK_CACHE_SIZE to 'aaa'"
+SET @@global.ROCKSDB_BLOCK_CACHE_SIZE = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BLOCK_CACHE_SIZE;
+@@global.ROCKSDB_BLOCK_CACHE_SIZE
+536870912
+"Trying to set variable @@global.ROCKSDB_BLOCK_CACHE_SIZE to 'bbb'"
+SET @@global.ROCKSDB_BLOCK_CACHE_SIZE = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BLOCK_CACHE_SIZE;
+@@global.ROCKSDB_BLOCK_CACHE_SIZE
+536870912
+"Trying to set variable @@global.ROCKSDB_BLOCK_CACHE_SIZE to '-1'"
+SET @@global.ROCKSDB_BLOCK_CACHE_SIZE = '-1';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BLOCK_CACHE_SIZE;
+@@global.ROCKSDB_BLOCK_CACHE_SIZE
+536870912
+"Trying to set variable @@global.ROCKSDB_BLOCK_CACHE_SIZE to '101'"
+SET @@global.ROCKSDB_BLOCK_CACHE_SIZE = '101';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BLOCK_CACHE_SIZE;
+@@global.ROCKSDB_BLOCK_CACHE_SIZE
+536870912
+"Trying to set variable @@global.ROCKSDB_BLOCK_CACHE_SIZE to '484436'"
+SET @@global.ROCKSDB_BLOCK_CACHE_SIZE = '484436';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BLOCK_CACHE_SIZE;
+@@global.ROCKSDB_BLOCK_CACHE_SIZE
+536870912
+SET @@global.ROCKSDB_BLOCK_CACHE_SIZE = @start_global_value;
+SELECT @@global.ROCKSDB_BLOCK_CACHE_SIZE;
+@@global.ROCKSDB_BLOCK_CACHE_SIZE
+536870912
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_restart_interval_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_restart_interval_basic.result
new file mode 100644
index 00000000..4d02e197
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_restart_interval_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_BLOCK_RESTART_INTERVAL;
+SELECT @start_global_value;
+@start_global_value
+16
+"Trying to set variable @@global.ROCKSDB_BLOCK_RESTART_INTERVAL to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_BLOCK_RESTART_INTERVAL = 444;
+ERROR HY000: Variable 'rocksdb_block_restart_interval' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_size_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_size_basic.result
new file mode 100644
index 00000000..0382184f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_size_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_BLOCK_SIZE;
+SELECT @start_global_value;
+@start_global_value
+4096
+"Trying to set variable @@global.ROCKSDB_BLOCK_SIZE to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_BLOCK_SIZE = 444;
+ERROR HY000: Variable 'rocksdb_block_size' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_size_deviation_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_size_deviation_basic.result
new file mode 100644
index 00000000..83513f81
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_block_size_deviation_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_BLOCK_SIZE_DEVIATION;
+SELECT @start_global_value;
+@start_global_value
+10
+"Trying to set variable @@global.ROCKSDB_BLOCK_SIZE_DEVIATION to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_BLOCK_SIZE_DEVIATION = 444;
+ERROR HY000: Variable 'rocksdb_block_size_deviation' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_allow_sk_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_allow_sk_basic.result
new file mode 100644
index 00000000..c0d09d89
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_allow_sk_basic.result
@@ -0,0 +1,100 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_BULK_LOAD_ALLOW_SK;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_BULK_LOAD_ALLOW_SK;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD_ALLOW_SK to 1"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_SK = 1;
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_SK
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_SK = DEFAULT;
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_SK
+0
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD_ALLOW_SK to 0"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_SK = 0;
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_SK
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_SK = DEFAULT;
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_SK
+0
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD_ALLOW_SK to on"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_SK = on;
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_SK
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_SK = DEFAULT;
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_SK
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_BULK_LOAD_ALLOW_SK to 1"
+SET @@session.ROCKSDB_BULK_LOAD_ALLOW_SK = 1;
+SELECT @@session.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@session.ROCKSDB_BULK_LOAD_ALLOW_SK
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_BULK_LOAD_ALLOW_SK = DEFAULT;
+SELECT @@session.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@session.ROCKSDB_BULK_LOAD_ALLOW_SK
+0
+"Trying to set variable @@session.ROCKSDB_BULK_LOAD_ALLOW_SK to 0"
+SET @@session.ROCKSDB_BULK_LOAD_ALLOW_SK = 0;
+SELECT @@session.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@session.ROCKSDB_BULK_LOAD_ALLOW_SK
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_BULK_LOAD_ALLOW_SK = DEFAULT;
+SELECT @@session.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@session.ROCKSDB_BULK_LOAD_ALLOW_SK
+0
+"Trying to set variable @@session.ROCKSDB_BULK_LOAD_ALLOW_SK to on"
+SET @@session.ROCKSDB_BULK_LOAD_ALLOW_SK = on;
+SELECT @@session.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@session.ROCKSDB_BULK_LOAD_ALLOW_SK
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_BULK_LOAD_ALLOW_SK = DEFAULT;
+SELECT @@session.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@session.ROCKSDB_BULK_LOAD_ALLOW_SK
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD_ALLOW_SK to 'aaa'"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_SK = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_SK
+0
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD_ALLOW_SK to 'bbb'"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_SK = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_SK
+0
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_SK = @start_global_value;
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_SK
+0
+SET @@session.ROCKSDB_BULK_LOAD_ALLOW_SK = @start_session_value;
+SELECT @@session.ROCKSDB_BULK_LOAD_ALLOW_SK;
+@@session.ROCKSDB_BULK_LOAD_ALLOW_SK
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_allow_unsorted_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_allow_unsorted_basic.result
new file mode 100644
index 00000000..a59ba561
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_allow_unsorted_basic.result
@@ -0,0 +1,100 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED to 1"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = 1;
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = DEFAULT;
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+0
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED to 0"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = 0;
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = DEFAULT;
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+0
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED to on"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = on;
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = DEFAULT;
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED to 1"
+SET @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = 1;
+SELECT @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = DEFAULT;
+SELECT @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+0
+"Trying to set variable @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED to 0"
+SET @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = 0;
+SELECT @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = DEFAULT;
+SELECT @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+0
+"Trying to set variable @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED to on"
+SET @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = on;
+SELECT @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = DEFAULT;
+SELECT @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED to 'aaa'"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+0
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED to 'bbb'"
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+0
+SET @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = @start_global_value;
+SELECT @@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@global.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+0
+SET @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED = @start_session_value;
+SELECT @@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED;
+@@session.ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_basic.result
new file mode 100644
index 00000000..96b78cf6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_basic.result
@@ -0,0 +1,100 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_BULK_LOAD;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_BULK_LOAD;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD to 1"
+SET @@global.ROCKSDB_BULK_LOAD = 1;
+SELECT @@global.ROCKSDB_BULK_LOAD;
+@@global.ROCKSDB_BULK_LOAD
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BULK_LOAD = DEFAULT;
+SELECT @@global.ROCKSDB_BULK_LOAD;
+@@global.ROCKSDB_BULK_LOAD
+0
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD to 0"
+SET @@global.ROCKSDB_BULK_LOAD = 0;
+SELECT @@global.ROCKSDB_BULK_LOAD;
+@@global.ROCKSDB_BULK_LOAD
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BULK_LOAD = DEFAULT;
+SELECT @@global.ROCKSDB_BULK_LOAD;
+@@global.ROCKSDB_BULK_LOAD
+0
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD to on"
+SET @@global.ROCKSDB_BULK_LOAD = on;
+SELECT @@global.ROCKSDB_BULK_LOAD;
+@@global.ROCKSDB_BULK_LOAD
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BULK_LOAD = DEFAULT;
+SELECT @@global.ROCKSDB_BULK_LOAD;
+@@global.ROCKSDB_BULK_LOAD
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_BULK_LOAD to 1"
+SET @@session.ROCKSDB_BULK_LOAD = 1;
+SELECT @@session.ROCKSDB_BULK_LOAD;
+@@session.ROCKSDB_BULK_LOAD
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_BULK_LOAD = DEFAULT;
+SELECT @@session.ROCKSDB_BULK_LOAD;
+@@session.ROCKSDB_BULK_LOAD
+0
+"Trying to set variable @@session.ROCKSDB_BULK_LOAD to 0"
+SET @@session.ROCKSDB_BULK_LOAD = 0;
+SELECT @@session.ROCKSDB_BULK_LOAD;
+@@session.ROCKSDB_BULK_LOAD
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_BULK_LOAD = DEFAULT;
+SELECT @@session.ROCKSDB_BULK_LOAD;
+@@session.ROCKSDB_BULK_LOAD
+0
+"Trying to set variable @@session.ROCKSDB_BULK_LOAD to on"
+SET @@session.ROCKSDB_BULK_LOAD = on;
+SELECT @@session.ROCKSDB_BULK_LOAD;
+@@session.ROCKSDB_BULK_LOAD
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_BULK_LOAD = DEFAULT;
+SELECT @@session.ROCKSDB_BULK_LOAD;
+@@session.ROCKSDB_BULK_LOAD
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD to 'aaa'"
+SET @@global.ROCKSDB_BULK_LOAD = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BULK_LOAD;
+@@global.ROCKSDB_BULK_LOAD
+0
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD to 'bbb'"
+SET @@global.ROCKSDB_BULK_LOAD = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BULK_LOAD;
+@@global.ROCKSDB_BULK_LOAD
+0
+SET @@global.ROCKSDB_BULK_LOAD = @start_global_value;
+SELECT @@global.ROCKSDB_BULK_LOAD;
+@@global.ROCKSDB_BULK_LOAD
+0
+SET @@session.ROCKSDB_BULK_LOAD = @start_session_value;
+SELECT @@session.ROCKSDB_BULK_LOAD;
+@@session.ROCKSDB_BULK_LOAD
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_size_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_size_basic.result
new file mode 100644
index 00000000..40404d2f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bulk_load_size_basic.result
@@ -0,0 +1,72 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_BULK_LOAD_SIZE;
+SELECT @start_global_value;
+@start_global_value
+1000
+SET @start_session_value = @@session.ROCKSDB_BULK_LOAD_SIZE;
+SELECT @start_session_value;
+@start_session_value
+1000
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD_SIZE to 1"
+SET @@global.ROCKSDB_BULK_LOAD_SIZE = 1;
+SELECT @@global.ROCKSDB_BULK_LOAD_SIZE;
+@@global.ROCKSDB_BULK_LOAD_SIZE
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BULK_LOAD_SIZE = DEFAULT;
+SELECT @@global.ROCKSDB_BULK_LOAD_SIZE;
+@@global.ROCKSDB_BULK_LOAD_SIZE
+1000
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD_SIZE to 1024"
+SET @@global.ROCKSDB_BULK_LOAD_SIZE = 1024;
+SELECT @@global.ROCKSDB_BULK_LOAD_SIZE;
+@@global.ROCKSDB_BULK_LOAD_SIZE
+1024
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BULK_LOAD_SIZE = DEFAULT;
+SELECT @@global.ROCKSDB_BULK_LOAD_SIZE;
+@@global.ROCKSDB_BULK_LOAD_SIZE
+1000
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_BULK_LOAD_SIZE to 1"
+SET @@session.ROCKSDB_BULK_LOAD_SIZE = 1;
+SELECT @@session.ROCKSDB_BULK_LOAD_SIZE;
+@@session.ROCKSDB_BULK_LOAD_SIZE
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_BULK_LOAD_SIZE = DEFAULT;
+SELECT @@session.ROCKSDB_BULK_LOAD_SIZE;
+@@session.ROCKSDB_BULK_LOAD_SIZE
+1000
+"Trying to set variable @@session.ROCKSDB_BULK_LOAD_SIZE to 1024"
+SET @@session.ROCKSDB_BULK_LOAD_SIZE = 1024;
+SELECT @@session.ROCKSDB_BULK_LOAD_SIZE;
+@@session.ROCKSDB_BULK_LOAD_SIZE
+1024
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_BULK_LOAD_SIZE = DEFAULT;
+SELECT @@session.ROCKSDB_BULK_LOAD_SIZE;
+@@session.ROCKSDB_BULK_LOAD_SIZE
+1000
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_BULK_LOAD_SIZE to 'aaa'"
+SET @@global.ROCKSDB_BULK_LOAD_SIZE = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BULK_LOAD_SIZE;
+@@global.ROCKSDB_BULK_LOAD_SIZE
+1000
+SET @@global.ROCKSDB_BULK_LOAD_SIZE = @start_global_value;
+SELECT @@global.ROCKSDB_BULK_LOAD_SIZE;
+@@global.ROCKSDB_BULK_LOAD_SIZE
+1000
+SET @@session.ROCKSDB_BULK_LOAD_SIZE = @start_session_value;
+SELECT @@session.ROCKSDB_BULK_LOAD_SIZE;
+@@session.ROCKSDB_BULK_LOAD_SIZE
+1000
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bytes_per_sync_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bytes_per_sync_basic.result
new file mode 100644
index 00000000..9af4f730
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_bytes_per_sync_basic.result
@@ -0,0 +1,85 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+SET @start_global_value = @@global.ROCKSDB_BYTES_PER_SYNC;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_BYTES_PER_SYNC to 100"
+SET @@global.ROCKSDB_BYTES_PER_SYNC = 100;
+SELECT @@global.ROCKSDB_BYTES_PER_SYNC;
+@@global.ROCKSDB_BYTES_PER_SYNC
+100
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BYTES_PER_SYNC = DEFAULT;
+SELECT @@global.ROCKSDB_BYTES_PER_SYNC;
+@@global.ROCKSDB_BYTES_PER_SYNC
+0
+"Trying to set variable @@global.ROCKSDB_BYTES_PER_SYNC to 1"
+SET @@global.ROCKSDB_BYTES_PER_SYNC = 1;
+SELECT @@global.ROCKSDB_BYTES_PER_SYNC;
+@@global.ROCKSDB_BYTES_PER_SYNC
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BYTES_PER_SYNC = DEFAULT;
+SELECT @@global.ROCKSDB_BYTES_PER_SYNC;
+@@global.ROCKSDB_BYTES_PER_SYNC
+0
+"Trying to set variable @@global.ROCKSDB_BYTES_PER_SYNC to 0"
+SET @@global.ROCKSDB_BYTES_PER_SYNC = 0;
+SELECT @@global.ROCKSDB_BYTES_PER_SYNC;
+@@global.ROCKSDB_BYTES_PER_SYNC
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_BYTES_PER_SYNC = DEFAULT;
+SELECT @@global.ROCKSDB_BYTES_PER_SYNC;
+@@global.ROCKSDB_BYTES_PER_SYNC
+0
+"Trying to set variable @@session.ROCKSDB_BYTES_PER_SYNC to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_BYTES_PER_SYNC = 444;
+ERROR HY000: Variable 'rocksdb_bytes_per_sync' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_BYTES_PER_SYNC to 'aaa'"
+SET @@global.ROCKSDB_BYTES_PER_SYNC = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BYTES_PER_SYNC;
+@@global.ROCKSDB_BYTES_PER_SYNC
+0
+"Trying to set variable @@global.ROCKSDB_BYTES_PER_SYNC to 'bbb'"
+SET @@global.ROCKSDB_BYTES_PER_SYNC = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BYTES_PER_SYNC;
+@@global.ROCKSDB_BYTES_PER_SYNC
+0
+"Trying to set variable @@global.ROCKSDB_BYTES_PER_SYNC to '-1'"
+SET @@global.ROCKSDB_BYTES_PER_SYNC = '-1';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BYTES_PER_SYNC;
+@@global.ROCKSDB_BYTES_PER_SYNC
+0
+"Trying to set variable @@global.ROCKSDB_BYTES_PER_SYNC to '101'"
+SET @@global.ROCKSDB_BYTES_PER_SYNC = '101';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BYTES_PER_SYNC;
+@@global.ROCKSDB_BYTES_PER_SYNC
+0
+"Trying to set variable @@global.ROCKSDB_BYTES_PER_SYNC to '484436'"
+SET @@global.ROCKSDB_BYTES_PER_SYNC = '484436';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_BYTES_PER_SYNC;
+@@global.ROCKSDB_BYTES_PER_SYNC
+0
+SET @@global.ROCKSDB_BYTES_PER_SYNC = @start_global_value;
+SELECT @@global.ROCKSDB_BYTES_PER_SYNC;
+@@global.ROCKSDB_BYTES_PER_SYNC
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_dump_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_dump_basic.result
new file mode 100644
index 00000000..90fc99ef
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_dump_basic.result
@@ -0,0 +1,19 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+INSERT INTO valid_values VALUES('true');
+INSERT INTO valid_values VALUES('false');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_CACHE_DUMP;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_CACHE_DUMP to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_CACHE_DUMP = 444;
+ERROR HY000: Variable 'rocksdb_cache_dump' is a read only variable
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_high_pri_pool_ratio_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_high_pri_pool_ratio_basic.result
new file mode 100644
index 00000000..9d098385
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_high_pri_pool_ratio_basic.result
@@ -0,0 +1,22 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1.0);
+INSERT INTO valid_values VALUES(0.0);
+INSERT INTO valid_values VALUES(0.5);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES(2.0);
+INSERT INTO invalid_values VALUES(-0.5);
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+INSERT INTO invalid_values VALUES('\'0.5\'');
+SET @start_global_value = @@global.ROCKSDB_CACHE_HIGH_PRI_POOL_RATIO;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_CACHE_HIGH_PRI_POOL_RATIO to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_CACHE_HIGH_PRI_POOL_RATIO = 444;
+ERROR HY000: Variable 'rocksdb_cache_high_pri_pool_ratio' is a read only variable
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_index_and_filter_blocks_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_index_and_filter_blocks_basic.result
new file mode 100644
index 00000000..12c25ad6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_index_and_filter_blocks_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_CACHE_INDEX_AND_FILTER_BLOCKS;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_CACHE_INDEX_AND_FILTER_BLOCKS to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_CACHE_INDEX_AND_FILTER_BLOCKS = 444;
+ERROR HY000: Variable 'rocksdb_cache_index_and_filter_blocks' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_index_and_filter_with_high_priority_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_index_and_filter_with_high_priority_basic.result
new file mode 100644
index 00000000..819425c8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_cache_index_and_filter_with_high_priority_basic.result
@@ -0,0 +1,19 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+INSERT INTO valid_values VALUES('true');
+INSERT INTO valid_values VALUES('false');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_CACHE_INDEX_AND_FILTER_WITH_HIGH_PRIORITY;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_CACHE_INDEX_AND_FILTER_WITH_HIGH_PRIORITY to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_CACHE_INDEX_AND_FILTER_WITH_HIGH_PRIORITY = 444;
+ERROR HY000: Variable 'rocksdb_cache_index_and_filter_with_high_priority' is a read only variable
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_checksums_pct_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_checksums_pct_basic.result
new file mode 100644
index 00000000..694c9a4f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_checksums_pct_basic.result
@@ -0,0 +1,93 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(99);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_CHECKSUMS_PCT;
+SELECT @start_global_value;
+@start_global_value
+100
+SET @start_session_value = @@session.ROCKSDB_CHECKSUMS_PCT;
+SELECT @start_session_value;
+@start_session_value
+100
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_CHECKSUMS_PCT to 0"
+SET @@global.ROCKSDB_CHECKSUMS_PCT = 0;
+SELECT @@global.ROCKSDB_CHECKSUMS_PCT;
+@@global.ROCKSDB_CHECKSUMS_PCT
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_CHECKSUMS_PCT = DEFAULT;
+SELECT @@global.ROCKSDB_CHECKSUMS_PCT;
+@@global.ROCKSDB_CHECKSUMS_PCT
+100
+"Trying to set variable @@global.ROCKSDB_CHECKSUMS_PCT to 1"
+SET @@global.ROCKSDB_CHECKSUMS_PCT = 1;
+SELECT @@global.ROCKSDB_CHECKSUMS_PCT;
+@@global.ROCKSDB_CHECKSUMS_PCT
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_CHECKSUMS_PCT = DEFAULT;
+SELECT @@global.ROCKSDB_CHECKSUMS_PCT;
+@@global.ROCKSDB_CHECKSUMS_PCT
+100
+"Trying to set variable @@global.ROCKSDB_CHECKSUMS_PCT to 99"
+SET @@global.ROCKSDB_CHECKSUMS_PCT = 99;
+SELECT @@global.ROCKSDB_CHECKSUMS_PCT;
+@@global.ROCKSDB_CHECKSUMS_PCT
+99
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_CHECKSUMS_PCT = DEFAULT;
+SELECT @@global.ROCKSDB_CHECKSUMS_PCT;
+@@global.ROCKSDB_CHECKSUMS_PCT
+100
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_CHECKSUMS_PCT to 0"
+SET @@session.ROCKSDB_CHECKSUMS_PCT = 0;
+SELECT @@session.ROCKSDB_CHECKSUMS_PCT;
+@@session.ROCKSDB_CHECKSUMS_PCT
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_CHECKSUMS_PCT = DEFAULT;
+SELECT @@session.ROCKSDB_CHECKSUMS_PCT;
+@@session.ROCKSDB_CHECKSUMS_PCT
+100
+"Trying to set variable @@session.ROCKSDB_CHECKSUMS_PCT to 1"
+SET @@session.ROCKSDB_CHECKSUMS_PCT = 1;
+SELECT @@session.ROCKSDB_CHECKSUMS_PCT;
+@@session.ROCKSDB_CHECKSUMS_PCT
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_CHECKSUMS_PCT = DEFAULT;
+SELECT @@session.ROCKSDB_CHECKSUMS_PCT;
+@@session.ROCKSDB_CHECKSUMS_PCT
+100
+"Trying to set variable @@session.ROCKSDB_CHECKSUMS_PCT to 99"
+SET @@session.ROCKSDB_CHECKSUMS_PCT = 99;
+SELECT @@session.ROCKSDB_CHECKSUMS_PCT;
+@@session.ROCKSDB_CHECKSUMS_PCT
+99
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_CHECKSUMS_PCT = DEFAULT;
+SELECT @@session.ROCKSDB_CHECKSUMS_PCT;
+@@session.ROCKSDB_CHECKSUMS_PCT
+100
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_CHECKSUMS_PCT to 'aaa'"
+SET @@global.ROCKSDB_CHECKSUMS_PCT = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_CHECKSUMS_PCT;
+@@global.ROCKSDB_CHECKSUMS_PCT
+100
+SET @@global.ROCKSDB_CHECKSUMS_PCT = @start_global_value;
+SELECT @@global.ROCKSDB_CHECKSUMS_PCT;
+@@global.ROCKSDB_CHECKSUMS_PCT
+100
+SET @@session.ROCKSDB_CHECKSUMS_PCT = @start_session_value;
+SELECT @@session.ROCKSDB_CHECKSUMS_PCT;
+@@session.ROCKSDB_CHECKSUMS_PCT
+100
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_collect_sst_properties_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_collect_sst_properties_basic.result
new file mode 100644
index 00000000..2f101987
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_collect_sst_properties_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_COLLECT_SST_PROPERTIES;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_COLLECT_SST_PROPERTIES to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_COLLECT_SST_PROPERTIES = 444;
+ERROR HY000: Variable 'rocksdb_collect_sst_properties' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_commit_in_the_middle_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_commit_in_the_middle_basic.result
new file mode 100644
index 00000000..4664ccb2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_commit_in_the_middle_basic.result
@@ -0,0 +1,100 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE to 1"
+SET @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE = 1;
+SELECT @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@global.ROCKSDB_COMMIT_IN_THE_MIDDLE
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE = DEFAULT;
+SELECT @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@global.ROCKSDB_COMMIT_IN_THE_MIDDLE
+0
+"Trying to set variable @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE to 0"
+SET @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE = 0;
+SELECT @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@global.ROCKSDB_COMMIT_IN_THE_MIDDLE
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE = DEFAULT;
+SELECT @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@global.ROCKSDB_COMMIT_IN_THE_MIDDLE
+0
+"Trying to set variable @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE to on"
+SET @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE = on;
+SELECT @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@global.ROCKSDB_COMMIT_IN_THE_MIDDLE
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE = DEFAULT;
+SELECT @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@global.ROCKSDB_COMMIT_IN_THE_MIDDLE
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE to 1"
+SET @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE = 1;
+SELECT @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@session.ROCKSDB_COMMIT_IN_THE_MIDDLE
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE = DEFAULT;
+SELECT @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@session.ROCKSDB_COMMIT_IN_THE_MIDDLE
+0
+"Trying to set variable @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE to 0"
+SET @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE = 0;
+SELECT @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@session.ROCKSDB_COMMIT_IN_THE_MIDDLE
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE = DEFAULT;
+SELECT @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@session.ROCKSDB_COMMIT_IN_THE_MIDDLE
+0
+"Trying to set variable @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE to on"
+SET @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE = on;
+SELECT @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@session.ROCKSDB_COMMIT_IN_THE_MIDDLE
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE = DEFAULT;
+SELECT @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@session.ROCKSDB_COMMIT_IN_THE_MIDDLE
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE to 'aaa'"
+SET @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@global.ROCKSDB_COMMIT_IN_THE_MIDDLE
+0
+"Trying to set variable @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE to 'bbb'"
+SET @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@global.ROCKSDB_COMMIT_IN_THE_MIDDLE
+0
+SET @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE = @start_global_value;
+SELECT @@global.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@global.ROCKSDB_COMMIT_IN_THE_MIDDLE
+0
+SET @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE = @start_session_value;
+SELECT @@session.ROCKSDB_COMMIT_IN_THE_MIDDLE;
+@@session.ROCKSDB_COMMIT_IN_THE_MIDDLE
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_commit_time_batch_for_recovery_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_commit_time_batch_for_recovery_basic.result
new file mode 100644
index 00000000..8d3f4a6e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_commit_time_batch_for_recovery_basic.result
@@ -0,0 +1,121 @@
+CREATE TABLE valid_values (value varchar(255));
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+CREATE TABLE invalid_values (value varchar(255));
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+SELECT @start_global_value;
+@start_global_value
+1
+SET @start_session_value = @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+SELECT @start_session_value;
+@start_session_value
+1
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY to 1"
+SET @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = 1;
+SELECT @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = DEFAULT;
+SELECT @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+"Trying to set variable @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY to 0"
+SET @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = 0;
+SELECT @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = DEFAULT;
+SELECT @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+"Trying to set variable @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY to on"
+SET @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = on;
+SELECT @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = DEFAULT;
+SELECT @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+"Trying to set variable @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY to off"
+SET @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = off;
+SELECT @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = DEFAULT;
+SELECT @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY to 1"
+SET @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = 1;
+SELECT @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = DEFAULT;
+SELECT @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+"Trying to set variable @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY to 0"
+SET @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = 0;
+SELECT @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = DEFAULT;
+SELECT @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+"Trying to set variable @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY to on"
+SET @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = on;
+SELECT @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = DEFAULT;
+SELECT @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+"Trying to set variable @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY to off"
+SET @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = off;
+SELECT @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = DEFAULT;
+SELECT @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY to 'aaa'"
+SET @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+"Trying to set variable @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY to 'bbb'"
+SET @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+SET @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = @start_global_value;
+SELECT @@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@global.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+SET @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY = @start_session_value;
+SELECT @@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY;
+@@session.ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+1
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compact_cf_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compact_cf_basic.result
new file mode 100644
index 00000000..b65ef65c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compact_cf_basic.result
@@ -0,0 +1,40 @@
+call mtr.add_suppression(" Column family '[a-z]*' not found.");
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES('abc');
+INSERT INTO valid_values VALUES('def');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+SET @start_global_value = @@global.ROCKSDB_COMPACT_CF;
+SELECT @start_global_value;
+@start_global_value
+
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_COMPACT_CF to abc"
+SET @@global.ROCKSDB_COMPACT_CF = abc;
+SELECT @@global.ROCKSDB_COMPACT_CF;
+@@global.ROCKSDB_COMPACT_CF
+
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACT_CF = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACT_CF;
+@@global.ROCKSDB_COMPACT_CF
+
+"Trying to set variable @@global.ROCKSDB_COMPACT_CF to def"
+SET @@global.ROCKSDB_COMPACT_CF = def;
+SELECT @@global.ROCKSDB_COMPACT_CF;
+@@global.ROCKSDB_COMPACT_CF
+
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACT_CF = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACT_CF;
+@@global.ROCKSDB_COMPACT_CF
+
+"Trying to set variable @@session.ROCKSDB_COMPACT_CF to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_COMPACT_CF = 444;
+ERROR HY000: Variable 'rocksdb_compact_cf' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+SET @@global.ROCKSDB_COMPACT_CF = @start_global_value;
+SELECT @@global.ROCKSDB_COMPACT_CF;
+@@global.ROCKSDB_COMPACT_CF
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_readahead_size_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_readahead_size_basic.result
new file mode 100644
index 00000000..206cfa81
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_readahead_size_basic.result
@@ -0,0 +1,70 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(222333);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @@global.rocksdb_compaction_readahead_size = -1;
+Warnings:
+Warning 1292 Truncated incorrect rocksdb_compaction_readahead_... value: '-1'
+SELECT @@global.rocksdb_compaction_readahead_size;
+@@global.rocksdb_compaction_readahead_size
+0
+SET @start_global_value = @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE to 1"
+SET @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE = 1;
+SELECT @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE;
+@@global.ROCKSDB_COMPACTION_READAHEAD_SIZE
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE;
+@@global.ROCKSDB_COMPACTION_READAHEAD_SIZE
+0
+"Trying to set variable @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE to 0"
+SET @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE = 0;
+SELECT @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE;
+@@global.ROCKSDB_COMPACTION_READAHEAD_SIZE
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE;
+@@global.ROCKSDB_COMPACTION_READAHEAD_SIZE
+0
+"Trying to set variable @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE to 222333"
+SET @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE = 222333;
+SELECT @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE;
+@@global.ROCKSDB_COMPACTION_READAHEAD_SIZE
+222333
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE;
+@@global.ROCKSDB_COMPACTION_READAHEAD_SIZE
+0
+"Trying to set variable @@session.ROCKSDB_COMPACTION_READAHEAD_SIZE to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_COMPACTION_READAHEAD_SIZE = 444;
+ERROR HY000: Variable 'rocksdb_compaction_readahead_size' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE to 'aaa'"
+SET @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE;
+@@global.ROCKSDB_COMPACTION_READAHEAD_SIZE
+0
+"Trying to set variable @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE to 'bbb'"
+SET @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE;
+@@global.ROCKSDB_COMPACTION_READAHEAD_SIZE
+0
+SET @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE = @start_global_value;
+SELECT @@global.ROCKSDB_COMPACTION_READAHEAD_SIZE;
+@@global.ROCKSDB_COMPACTION_READAHEAD_SIZE
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_basic.result
new file mode 100644
index 00000000..311184a1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_basic.result
@@ -0,0 +1,64 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+INSERT INTO valid_values VALUES(2000000);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'2000001\'');
+SET @start_global_value = @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES to 1"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES = 1;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES
+0
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES to 1024"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES = 1024;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES
+1024
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES
+0
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES to 2000000"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES = 2000000;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES
+2000000
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES
+0
+"Trying to set variable @@session.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES = 444;
+ERROR HY000: Variable 'rocksdb_compaction_sequential_deletes' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES to 'aaa'"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES
+0
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES to '2000001'"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES = '2000001';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES
+0
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES = @start_global_value;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_count_sd_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_count_sd_basic.result
new file mode 100644
index 00000000..d4e7e28b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_count_sd_basic.result
@@ -0,0 +1,64 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD to 1"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD = 1;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD
+0
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD to 0"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD = 0;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD
+0
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD to on"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD = on;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD
+0
+"Trying to set variable @@session.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD = 444;
+ERROR HY000: Variable 'rocksdb_compaction_sequential_deletes_count_sd' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD to 'aaa'"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD
+0
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD to 'bbb'"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD
+0
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD = @start_global_value;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_file_size_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_file_size_basic.result
new file mode 100644
index 00000000..703e235e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_file_size_basic.result
@@ -0,0 +1,46 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE to 1"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE = 1;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE
+0
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE to 1024"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE = 1024;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE
+1024
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE
+0
+"Trying to set variable @@session.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE = 444;
+ERROR HY000: Variable 'rocksdb_compaction_sequential_deletes_file_size' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE to 'aaa'"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE
+0
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE = @start_global_value;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_window_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_window_basic.result
new file mode 100644
index 00000000..84436b65
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_compaction_sequential_deletes_window_basic.result
@@ -0,0 +1,64 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+INSERT INTO valid_values VALUES(2000000);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'2000001\'');
+SET @start_global_value = @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW to 1"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW = 1;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW
+0
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW to 1024"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW = 1024;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW
+1024
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW
+0
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW to 2000000"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW = 2000000;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW
+2000000
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW = DEFAULT;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW
+0
+"Trying to set variable @@session.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW = 444;
+ERROR HY000: Variable 'rocksdb_compaction_sequential_deletes_window' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW to 'aaa'"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW
+0
+"Trying to set variable @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW to '2000001'"
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW = '2000001';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW
+0
+SET @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW = @start_global_value;
+SELECT @@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW;
+@@global.ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_create_checkpoint_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_create_checkpoint_basic.result
new file mode 100644
index 00000000..630fa78e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_create_checkpoint_basic.result
@@ -0,0 +1,15 @@
+SET @start_value = @@global.ROCKSDB_CREATE_CHECKPOINT;
+SET @@global.ROCKSDB_CREATE_CHECKPOINT = 'TMP/abc';
+SELECT @@global.ROCKSDB_CREATE_CHECKPOINT;
+@@global.ROCKSDB_CREATE_CHECKPOINT
+
+SET @@global.ROCKSDB_CREATE_CHECKPOINT = DEFAULT;
+SET @@global.ROCKSDB_CREATE_CHECKPOINT = 'TMP/def';
+SELECT @@global.ROCKSDB_CREATE_CHECKPOINT;
+@@global.ROCKSDB_CREATE_CHECKPOINT
+
+SET @@global.ROCKSDB_CREATE_CHECKPOINT = DEFAULT;
+SET @@session.ROCKSDB_CREATE_CHECKPOINT = 444;
+ERROR HY000: Variable 'rocksdb_create_checkpoint' is a GLOBAL variable and should be set with SET GLOBAL
+SET @@global.ROCKSDB_CREATE_CHECKPOINT = @start_value;
+ERROR HY000: Got error 4 'Invalid argument: invalid checkpoint directory name' from ROCKSDB
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_create_if_missing_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_create_if_missing_basic.result
new file mode 100644
index 00000000..26dd14fb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_create_if_missing_basic.result
@@ -0,0 +1,14 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_CREATE_IF_MISSING;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_CREATE_IF_MISSING to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_CREATE_IF_MISSING = 444;
+ERROR HY000: Variable 'rocksdb_create_if_missing' is a read only variable
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_create_missing_column_families_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_create_missing_column_families_basic.result
new file mode 100644
index 00000000..7debadc2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_create_missing_column_families_basic.result
@@ -0,0 +1,14 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_CREATE_MISSING_COLUMN_FAMILIES;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_CREATE_MISSING_COLUMN_FAMILIES to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_CREATE_MISSING_COLUMN_FAMILIES = 444;
+ERROR HY000: Variable 'rocksdb_create_missing_column_families' is a read only variable
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_datadir_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_datadir_basic.result
new file mode 100644
index 00000000..3215624b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_datadir_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_DATADIR;
+SELECT @start_global_value;
+@start_global_value
+./#rocksdb
+"Trying to set variable @@global.ROCKSDB_DATADIR to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_DATADIR = 444;
+ERROR HY000: Variable 'rocksdb_datadir' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_db_write_buffer_size_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_db_write_buffer_size_basic.result
new file mode 100644
index 00000000..6c588b7e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_db_write_buffer_size_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_DB_WRITE_BUFFER_SIZE;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_DB_WRITE_BUFFER_SIZE to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_DB_WRITE_BUFFER_SIZE = 444;
+ERROR HY000: Variable 'rocksdb_db_write_buffer_size' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_deadlock_detect_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_deadlock_detect_basic.result
new file mode 100644
index 00000000..f200105b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_deadlock_detect_basic.result
@@ -0,0 +1,121 @@
+CREATE TABLE valid_values (value varchar(255));
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+CREATE TABLE invalid_values (value varchar(255));
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_DEADLOCK_DETECT;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_DEADLOCK_DETECT;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_DEADLOCK_DETECT to 1"
+SET @@global.ROCKSDB_DEADLOCK_DETECT = 1;
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT;
+@@global.ROCKSDB_DEADLOCK_DETECT
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEADLOCK_DETECT = DEFAULT;
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT;
+@@global.ROCKSDB_DEADLOCK_DETECT
+0
+"Trying to set variable @@global.ROCKSDB_DEADLOCK_DETECT to 0"
+SET @@global.ROCKSDB_DEADLOCK_DETECT = 0;
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT;
+@@global.ROCKSDB_DEADLOCK_DETECT
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEADLOCK_DETECT = DEFAULT;
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT;
+@@global.ROCKSDB_DEADLOCK_DETECT
+0
+"Trying to set variable @@global.ROCKSDB_DEADLOCK_DETECT to on"
+SET @@global.ROCKSDB_DEADLOCK_DETECT = on;
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT;
+@@global.ROCKSDB_DEADLOCK_DETECT
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEADLOCK_DETECT = DEFAULT;
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT;
+@@global.ROCKSDB_DEADLOCK_DETECT
+0
+"Trying to set variable @@global.ROCKSDB_DEADLOCK_DETECT to off"
+SET @@global.ROCKSDB_DEADLOCK_DETECT = off;
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT;
+@@global.ROCKSDB_DEADLOCK_DETECT
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEADLOCK_DETECT = DEFAULT;
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT;
+@@global.ROCKSDB_DEADLOCK_DETECT
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_DEADLOCK_DETECT to 1"
+SET @@session.ROCKSDB_DEADLOCK_DETECT = 1;
+SELECT @@session.ROCKSDB_DEADLOCK_DETECT;
+@@session.ROCKSDB_DEADLOCK_DETECT
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_DEADLOCK_DETECT = DEFAULT;
+SELECT @@session.ROCKSDB_DEADLOCK_DETECT;
+@@session.ROCKSDB_DEADLOCK_DETECT
+0
+"Trying to set variable @@session.ROCKSDB_DEADLOCK_DETECT to 0"
+SET @@session.ROCKSDB_DEADLOCK_DETECT = 0;
+SELECT @@session.ROCKSDB_DEADLOCK_DETECT;
+@@session.ROCKSDB_DEADLOCK_DETECT
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_DEADLOCK_DETECT = DEFAULT;
+SELECT @@session.ROCKSDB_DEADLOCK_DETECT;
+@@session.ROCKSDB_DEADLOCK_DETECT
+0
+"Trying to set variable @@session.ROCKSDB_DEADLOCK_DETECT to on"
+SET @@session.ROCKSDB_DEADLOCK_DETECT = on;
+SELECT @@session.ROCKSDB_DEADLOCK_DETECT;
+@@session.ROCKSDB_DEADLOCK_DETECT
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_DEADLOCK_DETECT = DEFAULT;
+SELECT @@session.ROCKSDB_DEADLOCK_DETECT;
+@@session.ROCKSDB_DEADLOCK_DETECT
+0
+"Trying to set variable @@session.ROCKSDB_DEADLOCK_DETECT to off"
+SET @@session.ROCKSDB_DEADLOCK_DETECT = off;
+SELECT @@session.ROCKSDB_DEADLOCK_DETECT;
+@@session.ROCKSDB_DEADLOCK_DETECT
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_DEADLOCK_DETECT = DEFAULT;
+SELECT @@session.ROCKSDB_DEADLOCK_DETECT;
+@@session.ROCKSDB_DEADLOCK_DETECT
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_DEADLOCK_DETECT to 'aaa'"
+SET @@global.ROCKSDB_DEADLOCK_DETECT = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT;
+@@global.ROCKSDB_DEADLOCK_DETECT
+0
+"Trying to set variable @@global.ROCKSDB_DEADLOCK_DETECT to 'bbb'"
+SET @@global.ROCKSDB_DEADLOCK_DETECT = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT;
+@@global.ROCKSDB_DEADLOCK_DETECT
+0
+SET @@global.ROCKSDB_DEADLOCK_DETECT = @start_global_value;
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT;
+@@global.ROCKSDB_DEADLOCK_DETECT
+0
+SET @@session.ROCKSDB_DEADLOCK_DETECT = @start_session_value;
+SELECT @@session.ROCKSDB_DEADLOCK_DETECT;
+@@session.ROCKSDB_DEADLOCK_DETECT
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_deadlock_detect_depth_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_deadlock_detect_depth_basic.result
new file mode 100644
index 00000000..6f052687
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_deadlock_detect_depth_basic.result
@@ -0,0 +1,79 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(2);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'123\'');
+SET @start_global_value = @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH;
+SELECT @start_global_value;
+@start_global_value
+50
+SET @start_session_value = @@session.ROCKSDB_DEADLOCK_DETECT_DEPTH;
+SELECT @start_session_value;
+@start_session_value
+50
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH to 100"
+SET @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH = 100;
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH;
+@@global.ROCKSDB_DEADLOCK_DETECT_DEPTH
+100
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH = DEFAULT;
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH;
+@@global.ROCKSDB_DEADLOCK_DETECT_DEPTH
+50
+"Trying to set variable @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH to 2"
+SET @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH = 2;
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH;
+@@global.ROCKSDB_DEADLOCK_DETECT_DEPTH
+2
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH = DEFAULT;
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH;
+@@global.ROCKSDB_DEADLOCK_DETECT_DEPTH
+50
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_DEADLOCK_DETECT_DEPTH to 100"
+SET @@session.ROCKSDB_DEADLOCK_DETECT_DEPTH = 100;
+SELECT @@session.ROCKSDB_DEADLOCK_DETECT_DEPTH;
+@@session.ROCKSDB_DEADLOCK_DETECT_DEPTH
+100
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_DEADLOCK_DETECT_DEPTH = DEFAULT;
+SELECT @@session.ROCKSDB_DEADLOCK_DETECT_DEPTH;
+@@session.ROCKSDB_DEADLOCK_DETECT_DEPTH
+50
+"Trying to set variable @@session.ROCKSDB_DEADLOCK_DETECT_DEPTH to 2"
+SET @@session.ROCKSDB_DEADLOCK_DETECT_DEPTH = 2;
+SELECT @@session.ROCKSDB_DEADLOCK_DETECT_DEPTH;
+@@session.ROCKSDB_DEADLOCK_DETECT_DEPTH
+2
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_DEADLOCK_DETECT_DEPTH = DEFAULT;
+SELECT @@session.ROCKSDB_DEADLOCK_DETECT_DEPTH;
+@@session.ROCKSDB_DEADLOCK_DETECT_DEPTH
+50
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH to 'aaa'"
+SET @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH;
+@@global.ROCKSDB_DEADLOCK_DETECT_DEPTH
+50
+"Trying to set variable @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH to '123'"
+SET @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH = '123';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH;
+@@global.ROCKSDB_DEADLOCK_DETECT_DEPTH
+50
+SET @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH = @start_global_value;
+SELECT @@global.ROCKSDB_DEADLOCK_DETECT_DEPTH;
+@@global.ROCKSDB_DEADLOCK_DETECT_DEPTH
+50
+SET @@session.ROCKSDB_DEADLOCK_DETECT_DEPTH = @start_session_value;
+SELECT @@session.ROCKSDB_DEADLOCK_DETECT_DEPTH;
+@@session.ROCKSDB_DEADLOCK_DETECT_DEPTH
+50
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_manual_compaction_delay_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_manual_compaction_delay_basic.result
new file mode 100644
index 00000000..6c5db015
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_manual_compaction_delay_basic.result
@@ -0,0 +1,46 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(2400);
+INSERT INTO valid_values VALUES(100000);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY to 2400"
+SET @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY = 2400;
+SELECT @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY;
+@@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY
+2400
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY = DEFAULT;
+SELECT @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY;
+@@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY
+0
+"Trying to set variable @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY to 100000"
+SET @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY = 100000;
+SELECT @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY;
+@@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY
+100000
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY = DEFAULT;
+SELECT @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY;
+@@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY
+0
+"Trying to set variable @@session.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY = 444;
+ERROR HY000: Variable 'rocksdb_debug_manual_compaction_delay' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY to 'aaa'"
+SET @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY;
+@@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY
+0
+SET @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY = @start_global_value;
+SELECT @@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY;
+@@global.ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_optimizer_no_zero_cardinality_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_optimizer_no_zero_cardinality_basic.result
new file mode 100644
index 00000000..5e64ccc6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_optimizer_no_zero_cardinality_basic.result
@@ -0,0 +1,64 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY;
+SELECT @start_global_value;
+@start_global_value
+1
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY to 1"
+SET @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY = 1;
+SELECT @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY;
+@@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY = DEFAULT;
+SELECT @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY;
+@@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY
+1
+"Trying to set variable @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY to 0"
+SET @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY = 0;
+SELECT @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY;
+@@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY = DEFAULT;
+SELECT @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY;
+@@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY
+1
+"Trying to set variable @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY to on"
+SET @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY = on;
+SELECT @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY;
+@@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY = DEFAULT;
+SELECT @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY;
+@@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY
+1
+"Trying to set variable @@session.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY = 444;
+ERROR HY000: Variable 'rocksdb_debug_optimizer_no_zero_cardinality' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY to 'aaa'"
+SET @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY;
+@@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY
+1
+"Trying to set variable @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY to 'bbb'"
+SET @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY;
+@@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY
+1
+SET @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY = @start_global_value;
+SELECT @@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY;
+@@global.ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY
+1
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_ignore_pk_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_ignore_pk_basic.result
new file mode 100644
index 00000000..1d8eb721
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_ignore_pk_basic.result
@@ -0,0 +1,64 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK to 1"
+SET @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK = 1;
+SELECT @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK;
+@@global.ROCKSDB_DEBUG_TTL_IGNORE_PK
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK = DEFAULT;
+SELECT @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK;
+@@global.ROCKSDB_DEBUG_TTL_IGNORE_PK
+0
+"Trying to set variable @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK to 0"
+SET @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK = 0;
+SELECT @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK;
+@@global.ROCKSDB_DEBUG_TTL_IGNORE_PK
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK = DEFAULT;
+SELECT @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK;
+@@global.ROCKSDB_DEBUG_TTL_IGNORE_PK
+0
+"Trying to set variable @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK to on"
+SET @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK = on;
+SELECT @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK;
+@@global.ROCKSDB_DEBUG_TTL_IGNORE_PK
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK = DEFAULT;
+SELECT @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK;
+@@global.ROCKSDB_DEBUG_TTL_IGNORE_PK
+0
+"Trying to set variable @@session.ROCKSDB_DEBUG_TTL_IGNORE_PK to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_DEBUG_TTL_IGNORE_PK = 444;
+ERROR HY000: Variable 'rocksdb_debug_ttl_ignore_pk' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK to 'aaa'"
+SET @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK;
+@@global.ROCKSDB_DEBUG_TTL_IGNORE_PK
+0
+"Trying to set variable @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK to 'bbb'"
+SET @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK;
+@@global.ROCKSDB_DEBUG_TTL_IGNORE_PK
+0
+SET @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK = @start_global_value;
+SELECT @@global.ROCKSDB_DEBUG_TTL_IGNORE_PK;
+@@global.ROCKSDB_DEBUG_TTL_IGNORE_PK
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_read_filter_ts_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_read_filter_ts_basic.result
new file mode 100644
index 00000000..bbc46001
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_read_filter_ts_basic.result
@@ -0,0 +1,46 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(2400);
+INSERT INTO valid_values VALUES(-2400);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS to 2400"
+SET @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS = 2400;
+SELECT @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS;
+@@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS
+2400
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS = DEFAULT;
+SELECT @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS;
+@@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS
+0
+"Trying to set variable @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS to -2400"
+SET @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS = -2400;
+SELECT @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS;
+@@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS
+-2400
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS = DEFAULT;
+SELECT @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS;
+@@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS
+0
+"Trying to set variable @@session.ROCKSDB_DEBUG_TTL_READ_FILTER_TS to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_DEBUG_TTL_READ_FILTER_TS = 444;
+ERROR HY000: Variable 'rocksdb_debug_ttl_read_filter_ts' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS to 'aaa'"
+SET @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS;
+@@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS
+0
+SET @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS = @start_global_value;
+SELECT @@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS;
+@@global.ROCKSDB_DEBUG_TTL_READ_FILTER_TS
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_rec_ts_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_rec_ts_basic.result
new file mode 100644
index 00000000..347ba9a0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_rec_ts_basic.result
@@ -0,0 +1,46 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(2400);
+INSERT INTO valid_values VALUES(-2400);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_DEBUG_TTL_REC_TS;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_DEBUG_TTL_REC_TS to 2400"
+SET @@global.ROCKSDB_DEBUG_TTL_REC_TS = 2400;
+SELECT @@global.ROCKSDB_DEBUG_TTL_REC_TS;
+@@global.ROCKSDB_DEBUG_TTL_REC_TS
+2400
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEBUG_TTL_REC_TS = DEFAULT;
+SELECT @@global.ROCKSDB_DEBUG_TTL_REC_TS;
+@@global.ROCKSDB_DEBUG_TTL_REC_TS
+0
+"Trying to set variable @@global.ROCKSDB_DEBUG_TTL_REC_TS to -2400"
+SET @@global.ROCKSDB_DEBUG_TTL_REC_TS = -2400;
+SELECT @@global.ROCKSDB_DEBUG_TTL_REC_TS;
+@@global.ROCKSDB_DEBUG_TTL_REC_TS
+-2400
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEBUG_TTL_REC_TS = DEFAULT;
+SELECT @@global.ROCKSDB_DEBUG_TTL_REC_TS;
+@@global.ROCKSDB_DEBUG_TTL_REC_TS
+0
+"Trying to set variable @@session.ROCKSDB_DEBUG_TTL_REC_TS to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_DEBUG_TTL_REC_TS = 444;
+ERROR HY000: Variable 'rocksdb_debug_ttl_rec_ts' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_DEBUG_TTL_REC_TS to 'aaa'"
+SET @@global.ROCKSDB_DEBUG_TTL_REC_TS = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DEBUG_TTL_REC_TS;
+@@global.ROCKSDB_DEBUG_TTL_REC_TS
+0
+SET @@global.ROCKSDB_DEBUG_TTL_REC_TS = @start_global_value;
+SELECT @@global.ROCKSDB_DEBUG_TTL_REC_TS;
+@@global.ROCKSDB_DEBUG_TTL_REC_TS
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_snapshot_ts_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_snapshot_ts_basic.result
new file mode 100644
index 00000000..03a937ef
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_debug_ttl_snapshot_ts_basic.result
@@ -0,0 +1,46 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(2400);
+INSERT INTO valid_values VALUES(-2400);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS to 2400"
+SET @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS = 2400;
+SELECT @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS;
+@@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS
+2400
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS = DEFAULT;
+SELECT @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS;
+@@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS
+0
+"Trying to set variable @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS to -2400"
+SET @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS = -2400;
+SELECT @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS;
+@@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS
+-2400
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS = DEFAULT;
+SELECT @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS;
+@@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS
+0
+"Trying to set variable @@session.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS = 444;
+ERROR HY000: Variable 'rocksdb_debug_ttl_snapshot_ts' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS to 'aaa'"
+SET @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS;
+@@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS
+0
+SET @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS = @start_global_value;
+SELECT @@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS;
+@@global.ROCKSDB_DEBUG_TTL_SNAPSHOT_TS
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_default_cf_options_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_default_cf_options_basic.result
new file mode 100644
index 00000000..b2b1c0e4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_default_cf_options_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_DEFAULT_CF_OPTIONS;
+SELECT @start_global_value;
+@start_global_value
+
+"Trying to set variable @@global.ROCKSDB_DEFAULT_CF_OPTIONS to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_DEFAULT_CF_OPTIONS = 444;
+ERROR HY000: Variable 'rocksdb_default_cf_options' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_delayed_write_rate_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_delayed_write_rate_basic.result
new file mode 100644
index 00000000..13749e1c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_delayed_write_rate_basic.result
@@ -0,0 +1,85 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+SET @start_global_value = @@global.ROCKSDB_DELAYED_WRITE_RATE;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_DELAYED_WRITE_RATE to 100"
+SET @@global.ROCKSDB_DELAYED_WRITE_RATE = 100;
+SELECT @@global.ROCKSDB_DELAYED_WRITE_RATE;
+@@global.ROCKSDB_DELAYED_WRITE_RATE
+100
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DELAYED_WRITE_RATE = DEFAULT;
+SELECT @@global.ROCKSDB_DELAYED_WRITE_RATE;
+@@global.ROCKSDB_DELAYED_WRITE_RATE
+0
+"Trying to set variable @@global.ROCKSDB_DELAYED_WRITE_RATE to 1"
+SET @@global.ROCKSDB_DELAYED_WRITE_RATE = 1;
+SELECT @@global.ROCKSDB_DELAYED_WRITE_RATE;
+@@global.ROCKSDB_DELAYED_WRITE_RATE
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DELAYED_WRITE_RATE = DEFAULT;
+SELECT @@global.ROCKSDB_DELAYED_WRITE_RATE;
+@@global.ROCKSDB_DELAYED_WRITE_RATE
+0
+"Trying to set variable @@global.ROCKSDB_DELAYED_WRITE_RATE to 0"
+SET @@global.ROCKSDB_DELAYED_WRITE_RATE = 0;
+SELECT @@global.ROCKSDB_DELAYED_WRITE_RATE;
+@@global.ROCKSDB_DELAYED_WRITE_RATE
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_DELAYED_WRITE_RATE = DEFAULT;
+SELECT @@global.ROCKSDB_DELAYED_WRITE_RATE;
+@@global.ROCKSDB_DELAYED_WRITE_RATE
+0
+"Trying to set variable @@session.ROCKSDB_DELAYED_WRITE_RATE to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_DELAYED_WRITE_RATE = 444;
+ERROR HY000: Variable 'rocksdb_delayed_write_rate' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_DELAYED_WRITE_RATE to 'aaa'"
+SET @@global.ROCKSDB_DELAYED_WRITE_RATE = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DELAYED_WRITE_RATE;
+@@global.ROCKSDB_DELAYED_WRITE_RATE
+0
+"Trying to set variable @@global.ROCKSDB_DELAYED_WRITE_RATE to 'bbb'"
+SET @@global.ROCKSDB_DELAYED_WRITE_RATE = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DELAYED_WRITE_RATE;
+@@global.ROCKSDB_DELAYED_WRITE_RATE
+0
+"Trying to set variable @@global.ROCKSDB_DELAYED_WRITE_RATE to '-1'"
+SET @@global.ROCKSDB_DELAYED_WRITE_RATE = '-1';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DELAYED_WRITE_RATE;
+@@global.ROCKSDB_DELAYED_WRITE_RATE
+0
+"Trying to set variable @@global.ROCKSDB_DELAYED_WRITE_RATE to '101'"
+SET @@global.ROCKSDB_DELAYED_WRITE_RATE = '101';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DELAYED_WRITE_RATE;
+@@global.ROCKSDB_DELAYED_WRITE_RATE
+0
+"Trying to set variable @@global.ROCKSDB_DELAYED_WRITE_RATE to '484436'"
+SET @@global.ROCKSDB_DELAYED_WRITE_RATE = '484436';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_DELAYED_WRITE_RATE;
+@@global.ROCKSDB_DELAYED_WRITE_RATE
+0
+SET @@global.ROCKSDB_DELAYED_WRITE_RATE = @start_global_value;
+SELECT @@global.ROCKSDB_DELAYED_WRITE_RATE;
+@@global.ROCKSDB_DELAYED_WRITE_RATE
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_delete_cf_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_delete_cf_basic.result
new file mode 100644
index 00000000..b840baf2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_delete_cf_basic.result
@@ -0,0 +1,6 @@
+SET @@global.ROCKSDB_DELETE_CF = 'nonexistent_cf';
+ERROR 42000: Variable 'rocksdb_delete_cf' can't be set to the value of 'nonexistent_cf'
+SET @@global.ROCKSDB_DELETE_CF = '__system__';
+ERROR 42000: Variable 'rocksdb_delete_cf' can't be set to the value of '__system__'
+SET @@global.ROCKSDB_DELETE_CF = 'default';
+ERROR 42000: Variable 'rocksdb_delete_cf' can't be set to the value of 'default'
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_delete_obsolete_files_period_micros_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_delete_obsolete_files_period_micros_basic.result
new file mode 100644
index 00000000..2dc220fb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_delete_obsolete_files_period_micros_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_DELETE_OBSOLETE_FILES_PERIOD_MICROS;
+SELECT @start_global_value;
+@start_global_value
+21600000000
+"Trying to set variable @@global.ROCKSDB_DELETE_OBSOLETE_FILES_PERIOD_MICROS to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_DELETE_OBSOLETE_FILES_PERIOD_MICROS = 444;
+ERROR HY000: Variable 'rocksdb_delete_obsolete_files_period_micros' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_2pc_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_2pc_basic.result
new file mode 100644
index 00000000..686f8bcd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_2pc_basic.result
@@ -0,0 +1,75 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_ENABLE_2PC;
+SELECT @start_global_value;
+@start_global_value
+1
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_ENABLE_2PC to 1"
+SET @@global.ROCKSDB_ENABLE_2PC = 1;
+SELECT @@global.ROCKSDB_ENABLE_2PC;
+@@global.ROCKSDB_ENABLE_2PC
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ENABLE_2PC = DEFAULT;
+SELECT @@global.ROCKSDB_ENABLE_2PC;
+@@global.ROCKSDB_ENABLE_2PC
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_2PC to 0"
+SET @@global.ROCKSDB_ENABLE_2PC = 0;
+SELECT @@global.ROCKSDB_ENABLE_2PC;
+@@global.ROCKSDB_ENABLE_2PC
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ENABLE_2PC = DEFAULT;
+SELECT @@global.ROCKSDB_ENABLE_2PC;
+@@global.ROCKSDB_ENABLE_2PC
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_2PC to on"
+SET @@global.ROCKSDB_ENABLE_2PC = on;
+SELECT @@global.ROCKSDB_ENABLE_2PC;
+@@global.ROCKSDB_ENABLE_2PC
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ENABLE_2PC = DEFAULT;
+SELECT @@global.ROCKSDB_ENABLE_2PC;
+@@global.ROCKSDB_ENABLE_2PC
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_2PC to off"
+SET @@global.ROCKSDB_ENABLE_2PC = off;
+SELECT @@global.ROCKSDB_ENABLE_2PC;
+@@global.ROCKSDB_ENABLE_2PC
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ENABLE_2PC = DEFAULT;
+SELECT @@global.ROCKSDB_ENABLE_2PC;
+@@global.ROCKSDB_ENABLE_2PC
+1
+"Trying to set variable @@session.ROCKSDB_ENABLE_2PC to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_ENABLE_2PC = 444;
+ERROR HY000: Variable 'rocksdb_enable_2pc' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_ENABLE_2PC to 'aaa'"
+SET @@global.ROCKSDB_ENABLE_2PC = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_ENABLE_2PC;
+@@global.ROCKSDB_ENABLE_2PC
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_2PC to 'bbb'"
+SET @@global.ROCKSDB_ENABLE_2PC = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_ENABLE_2PC;
+@@global.ROCKSDB_ENABLE_2PC
+1
+SET @@global.ROCKSDB_ENABLE_2PC = @start_global_value;
+SELECT @@global.ROCKSDB_ENABLE_2PC;
+@@global.ROCKSDB_ENABLE_2PC
+1
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_bulk_load_api_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_bulk_load_api_basic.result
new file mode 100644
index 00000000..2c0ff289
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_bulk_load_api_basic.result
@@ -0,0 +1,14 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_ENABLE_BULK_LOAD_API;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_BULK_LOAD_API to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_ENABLE_BULK_LOAD_API = 444;
+ERROR HY000: Variable 'rocksdb_enable_bulk_load_api' is a read only variable
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_insert_with_update_caching_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_insert_with_update_caching_basic.result
new file mode 100644
index 00000000..ede1690f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_insert_with_update_caching_basic.result
@@ -0,0 +1,75 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING;
+SELECT @start_global_value;
+@start_global_value
+1
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING to 1"
+SET @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING = 1;
+SELECT @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING;
+@@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING = DEFAULT;
+SELECT @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING;
+@@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING to 0"
+SET @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING = 0;
+SELECT @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING;
+@@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING = DEFAULT;
+SELECT @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING;
+@@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING to on"
+SET @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING = on;
+SELECT @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING;
+@@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING = DEFAULT;
+SELECT @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING;
+@@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING to off"
+SET @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING = off;
+SELECT @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING;
+@@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING = DEFAULT;
+SELECT @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING;
+@@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING
+1
+"Trying to set variable @@session.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING = 444;
+ERROR HY000: Variable 'rocksdb_enable_insert_with_update_caching' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING to 'aaa'"
+SET @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING;
+@@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING to 'bbb'"
+SET @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING;
+@@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING
+1
+SET @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING = @start_global_value;
+SELECT @@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING;
+@@global.ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING
+1
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_thread_tracking_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_thread_tracking_basic.result
new file mode 100644
index 00000000..a63383a4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_thread_tracking_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_ENABLE_THREAD_TRACKING;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_THREAD_TRACKING to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_ENABLE_THREAD_TRACKING = 444;
+ERROR HY000: Variable 'rocksdb_enable_thread_tracking' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_ttl_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_ttl_basic.result
new file mode 100644
index 00000000..1f569235
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_ttl_basic.result
@@ -0,0 +1,64 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_ENABLE_TTL;
+SELECT @start_global_value;
+@start_global_value
+1
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_ENABLE_TTL to 1"
+SET @@global.ROCKSDB_ENABLE_TTL = 1;
+SELECT @@global.ROCKSDB_ENABLE_TTL;
+@@global.ROCKSDB_ENABLE_TTL
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ENABLE_TTL = DEFAULT;
+SELECT @@global.ROCKSDB_ENABLE_TTL;
+@@global.ROCKSDB_ENABLE_TTL
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_TTL to 0"
+SET @@global.ROCKSDB_ENABLE_TTL = 0;
+SELECT @@global.ROCKSDB_ENABLE_TTL;
+@@global.ROCKSDB_ENABLE_TTL
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ENABLE_TTL = DEFAULT;
+SELECT @@global.ROCKSDB_ENABLE_TTL;
+@@global.ROCKSDB_ENABLE_TTL
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_TTL to on"
+SET @@global.ROCKSDB_ENABLE_TTL = on;
+SELECT @@global.ROCKSDB_ENABLE_TTL;
+@@global.ROCKSDB_ENABLE_TTL
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ENABLE_TTL = DEFAULT;
+SELECT @@global.ROCKSDB_ENABLE_TTL;
+@@global.ROCKSDB_ENABLE_TTL
+1
+"Trying to set variable @@session.ROCKSDB_ENABLE_TTL to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_ENABLE_TTL = 444;
+ERROR HY000: Variable 'rocksdb_enable_ttl' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_ENABLE_TTL to 'aaa'"
+SET @@global.ROCKSDB_ENABLE_TTL = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_ENABLE_TTL;
+@@global.ROCKSDB_ENABLE_TTL
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_TTL to 'bbb'"
+SET @@global.ROCKSDB_ENABLE_TTL = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_ENABLE_TTL;
+@@global.ROCKSDB_ENABLE_TTL
+1
+SET @@global.ROCKSDB_ENABLE_TTL = @start_global_value;
+SELECT @@global.ROCKSDB_ENABLE_TTL;
+@@global.ROCKSDB_ENABLE_TTL
+1
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_ttl_read_filtering_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_ttl_read_filtering_basic.result
new file mode 100644
index 00000000..005c15e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_ttl_read_filtering_basic.result
@@ -0,0 +1,64 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING;
+SELECT @start_global_value;
+@start_global_value
+1
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING to 1"
+SET @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING = 1;
+SELECT @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING;
+@@global.ROCKSDB_ENABLE_TTL_READ_FILTERING
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING = DEFAULT;
+SELECT @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING;
+@@global.ROCKSDB_ENABLE_TTL_READ_FILTERING
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING to 0"
+SET @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING = 0;
+SELECT @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING;
+@@global.ROCKSDB_ENABLE_TTL_READ_FILTERING
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING = DEFAULT;
+SELECT @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING;
+@@global.ROCKSDB_ENABLE_TTL_READ_FILTERING
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING to on"
+SET @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING = on;
+SELECT @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING;
+@@global.ROCKSDB_ENABLE_TTL_READ_FILTERING
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING = DEFAULT;
+SELECT @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING;
+@@global.ROCKSDB_ENABLE_TTL_READ_FILTERING
+1
+"Trying to set variable @@session.ROCKSDB_ENABLE_TTL_READ_FILTERING to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_ENABLE_TTL_READ_FILTERING = 444;
+ERROR HY000: Variable 'rocksdb_enable_ttl_read_filtering' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING to 'aaa'"
+SET @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING;
+@@global.ROCKSDB_ENABLE_TTL_READ_FILTERING
+1
+"Trying to set variable @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING to 'bbb'"
+SET @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING;
+@@global.ROCKSDB_ENABLE_TTL_READ_FILTERING
+1
+SET @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING = @start_global_value;
+SELECT @@global.ROCKSDB_ENABLE_TTL_READ_FILTERING;
+@@global.ROCKSDB_ENABLE_TTL_READ_FILTERING
+1
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_write_thread_adaptive_yield_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_write_thread_adaptive_yield_basic.result
new file mode 100644
index 00000000..37107be4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_enable_write_thread_adaptive_yield_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_ENABLE_WRITE_THREAD_ADAPTIVE_YIELD;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_ENABLE_WRITE_THREAD_ADAPTIVE_YIELD to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_ENABLE_WRITE_THREAD_ADAPTIVE_YIELD = 444;
+ERROR HY000: Variable 'rocksdb_enable_write_thread_adaptive_yield' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_error_if_exists_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_error_if_exists_basic.result
new file mode 100644
index 00000000..650e2956
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_error_if_exists_basic.result
@@ -0,0 +1,14 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_ERROR_IF_EXISTS;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_ERROR_IF_EXISTS to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_ERROR_IF_EXISTS = 444;
+ERROR HY000: Variable 'rocksdb_error_if_exists' is a read only variable
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_error_on_suboptimal_collation_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_error_on_suboptimal_collation_basic.result
new file mode 100644
index 00000000..e10583bf
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_error_on_suboptimal_collation_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_ERROR_ON_SUBOPTIMAL_COLLATION;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_ERROR_ON_SUBOPTIMAL_COLLATION to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_ERROR_ON_SUBOPTIMAL_COLLATION = 444;
+ERROR HY000: Variable 'rocksdb_error_on_suboptimal_collation' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_flush_log_at_trx_commit_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_flush_log_at_trx_commit_basic.result
new file mode 100644
index 00000000..b8fe837d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_flush_log_at_trx_commit_basic.result
@@ -0,0 +1,57 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(2);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT;
+SELECT @start_global_value;
+@start_global_value
+1
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT to 2"
+SET @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT = 2;
+SELECT @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT;
+@@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT
+2
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT = DEFAULT;
+SELECT @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT;
+@@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT
+1
+"Trying to set variable @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT to 1"
+SET @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT = 1;
+SELECT @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT;
+@@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT = DEFAULT;
+SELECT @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT;
+@@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT
+1
+"Trying to set variable @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT to 0"
+SET @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT = 0;
+SELECT @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT;
+@@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT = DEFAULT;
+SELECT @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT;
+@@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT
+1
+"Trying to set variable @@session.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT = 444;
+ERROR HY000: Variable 'rocksdb_flush_log_at_trx_commit' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT to 'aaa'"
+SET @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT;
+@@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT
+1
+SET @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT = @start_global_value;
+SELECT @@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT;
+@@global.ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT
+1
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_compute_memtable_stats_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_compute_memtable_stats_basic.result
new file mode 100644
index 00000000..90fd829e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_compute_memtable_stats_basic.result
@@ -0,0 +1,15 @@
+DROP TABLE IF EXISTS t;
+CREATE TABLE t (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t (a,b) VALUES (1,'bar'),(2,'foo');
+SET @ORIG_FORCE_COMPUTE_MEMTABLE_STATS = @@rocksdb_force_compute_memtable_stats;
+set global rocksdb_force_flush_memtable_now = true;
+INSERT INTO t (a,b) VALUES (3,'dead'),(4,'beef'),(5,'a'),(6,'bbb'),(7,'c'),(8,'d');
+set global rocksdb_force_compute_memtable_stats=0;
+SELECT TABLE_ROWS INTO @ROWS_EXCLUDE_MEMTABLE FROM information_schema.TABLES WHERE table_name = 't';
+set global rocksdb_force_compute_memtable_stats=1;
+SELECT TABLE_ROWS INTO @ROWS_INCLUDE_MEMTABLE FROM information_schema.TABLES WHERE table_name = 't';
+select case when @ROWS_INCLUDE_MEMTABLE-@ROWS_EXCLUDE_MEMTABLE > 0 then 'true' else 'false' end;
+case when @ROWS_INCLUDE_MEMTABLE-@ROWS_EXCLUDE_MEMTABLE > 0 then 'true' else 'false' end
+true
+DROP TABLE t;
+set global rocksdb_force_compute_memtable_stats = @ORIG_FORCE_COMPUTE_MEMTABLE_STATS;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_compute_memtable_stats_cachetime_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_compute_memtable_stats_cachetime_basic.result
new file mode 100644
index 00000000..50e06b5b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_compute_memtable_stats_cachetime_basic.result
@@ -0,0 +1,68 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+INSERT INTO valid_values VALUES(1024 * 1024 * 1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME to 0"
+SET @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME = 0;
+SELECT @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME;
+@@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME = DEFAULT;
+SELECT @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME;
+@@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME
+60000000
+"Trying to set variable @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME to 1"
+SET @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME = 1;
+SELECT @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME;
+@@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME = DEFAULT;
+SELECT @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME;
+@@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME
+60000000
+"Trying to set variable @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME to 1024"
+SET @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME = 1024;
+SELECT @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME;
+@@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME
+1024
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME = DEFAULT;
+SELECT @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME;
+@@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME
+60000000
+"Trying to set variable @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME to 1073741824"
+SET @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME = 1073741824;
+SELECT @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME;
+@@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME
+1073741824
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME = DEFAULT;
+SELECT @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME;
+@@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME
+60000000
+"Trying to set variable @@session.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME = 444;
+ERROR HY000: Variable 'rocksdb_force_compute_memtable_stats_cachetime' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME to 'aaa'"
+SET @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME;
+@@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME
+60000000
+SET @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME = @start_global_value;
+SELECT @@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME;
+@@global.ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_flush_memtable_and_lzero_now_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_flush_memtable_and_lzero_now_basic.result
new file mode 100644
index 00000000..68cfeb07
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_flush_memtable_and_lzero_now_basic.result
@@ -0,0 +1,50 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+SET @start_global_value = @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW to 1"
+SET @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW = 1;
+SELECT @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW;
+@@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW = DEFAULT;
+SELECT @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW;
+@@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW
+0
+"Trying to set variable @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW to 0"
+SET @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW = 0;
+SELECT @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW;
+@@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW = DEFAULT;
+SELECT @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW;
+@@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW
+0
+"Trying to set variable @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW to on"
+SET @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW = on;
+SELECT @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW;
+@@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW = DEFAULT;
+SELECT @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW;
+@@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW
+0
+"Trying to set variable @@session.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW = 444;
+ERROR HY000: Variable 'rocksdb_force_flush_memtable_and_lzero_now' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+SET @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW = @start_global_value;
+SELECT @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW;
+@@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_flush_memtable_now_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_flush_memtable_now_basic.result
new file mode 100644
index 00000000..30444e26
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_flush_memtable_now_basic.result
@@ -0,0 +1,50 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+SET @start_global_value = @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW to 1"
+SET @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW = 1;
+SELECT @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW;
+@@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW = DEFAULT;
+SELECT @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW;
+@@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW
+0
+"Trying to set variable @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW to 0"
+SET @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW = 0;
+SELECT @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW;
+@@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW = DEFAULT;
+SELECT @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW;
+@@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW
+0
+"Trying to set variable @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW to on"
+SET @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW = on;
+SELECT @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW;
+@@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW = DEFAULT;
+SELECT @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW;
+@@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW
+0
+"Trying to set variable @@session.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW = 444;
+ERROR HY000: Variable 'rocksdb_force_flush_memtable_now' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+SET @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW = @start_global_value;
+SELECT @@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW;
+@@global.ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_index_records_in_range_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_index_records_in_range_basic.result
new file mode 100644
index 00000000..d4768cfd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_force_index_records_in_range_basic.result
@@ -0,0 +1,106 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(222333);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @@session.rocksdb_force_index_records_in_range = -1;
+Warnings:
+Warning 1292 Truncated incorrect rocksdb_force_index_records_i... value: '-1'
+SELECT @@session.rocksdb_force_index_records_in_range;
+@@session.rocksdb_force_index_records_in_range
+0
+SET @start_global_value = @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE to 1"
+SET @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = 1;
+SELECT @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = DEFAULT;
+SELECT @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+0
+"Trying to set variable @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE to 0"
+SET @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = 0;
+SELECT @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = DEFAULT;
+SELECT @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+0
+"Trying to set variable @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE to 222333"
+SET @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = 222333;
+SELECT @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+222333
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = DEFAULT;
+SELECT @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE to 1"
+SET @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = 1;
+SELECT @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = DEFAULT;
+SELECT @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+0
+"Trying to set variable @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE to 0"
+SET @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = 0;
+SELECT @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = DEFAULT;
+SELECT @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+0
+"Trying to set variable @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE to 222333"
+SET @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = 222333;
+SELECT @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+222333
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = DEFAULT;
+SELECT @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE to 'aaa'"
+SET @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+0
+"Trying to set variable @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE to 'bbb'"
+SET @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+0
+SET @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = @start_global_value;
+SELECT @@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@global.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+0
+SET @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE = @start_session_value;
+SELECT @@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE;
+@@session.ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_git_hash_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_git_hash_basic.result
new file mode 100644
index 00000000..bbcfa141
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_git_hash_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_GIT_HASH;
+SELECT @start_global_value;
+@start_global_value
+#
+"Trying to set variable @@global.ROCKSDB_GIT_HASH to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_GIT_HASH = 444;
+ERROR HY000: Variable 'rocksdb_git_hash' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_hash_index_allow_collision_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_hash_index_allow_collision_basic.result
new file mode 100644
index 00000000..34deca6c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_hash_index_allow_collision_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_HASH_INDEX_ALLOW_COLLISION;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_HASH_INDEX_ALLOW_COLLISION to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_HASH_INDEX_ALLOW_COLLISION = 444;
+ERROR HY000: Variable 'rocksdb_hash_index_allow_collision' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_ignore_unknown_options_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_ignore_unknown_options_basic.result
new file mode 100644
index 00000000..621213cd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_ignore_unknown_options_basic.result
@@ -0,0 +1,14 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_IGNORE_UNKNOWN_OPTIONS;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_IGNORE_UNKNOWN_OPTIONS to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_IGNORE_UNKNOWN_OPTIONS = 444;
+ERROR HY000: Variable 'rocksdb_ignore_unknown_options' is a read only variable
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_index_type_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_index_type_basic.result
new file mode 100644
index 00000000..97c6ed84
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_index_type_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_INDEX_TYPE;
+SELECT @start_global_value;
+@start_global_value
+kBinarySearch
+"Trying to set variable @@global.ROCKSDB_INDEX_TYPE to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_INDEX_TYPE = 444;
+ERROR HY000: Variable 'rocksdb_index_type' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_info_log_level_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_info_log_level_basic.result
new file mode 100644
index 00000000..1509f9ae
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_info_log_level_basic.result
@@ -0,0 +1,93 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES('fatal_level');
+INSERT INTO valid_values VALUES('error_level');
+INSERT INTO valid_values VALUES('warn_level');
+INSERT INTO valid_values VALUES('info_level');
+INSERT INTO valid_values VALUES('debug_level');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES(5);
+INSERT INTO invalid_values VALUES(6);
+INSERT INTO invalid_values VALUES('foo');
+SET @start_global_value = @@global.ROCKSDB_INFO_LOG_LEVEL;
+SELECT @start_global_value;
+@start_global_value
+error_level
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_INFO_LOG_LEVEL to fatal_level"
+SET @@global.ROCKSDB_INFO_LOG_LEVEL = fatal_level;
+SELECT @@global.ROCKSDB_INFO_LOG_LEVEL;
+@@global.ROCKSDB_INFO_LOG_LEVEL
+fatal_level
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_INFO_LOG_LEVEL = DEFAULT;
+SELECT @@global.ROCKSDB_INFO_LOG_LEVEL;
+@@global.ROCKSDB_INFO_LOG_LEVEL
+error_level
+"Trying to set variable @@global.ROCKSDB_INFO_LOG_LEVEL to error_level"
+SET @@global.ROCKSDB_INFO_LOG_LEVEL = error_level;
+SELECT @@global.ROCKSDB_INFO_LOG_LEVEL;
+@@global.ROCKSDB_INFO_LOG_LEVEL
+error_level
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_INFO_LOG_LEVEL = DEFAULT;
+SELECT @@global.ROCKSDB_INFO_LOG_LEVEL;
+@@global.ROCKSDB_INFO_LOG_LEVEL
+error_level
+"Trying to set variable @@global.ROCKSDB_INFO_LOG_LEVEL to warn_level"
+SET @@global.ROCKSDB_INFO_LOG_LEVEL = warn_level;
+SELECT @@global.ROCKSDB_INFO_LOG_LEVEL;
+@@global.ROCKSDB_INFO_LOG_LEVEL
+warn_level
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_INFO_LOG_LEVEL = DEFAULT;
+SELECT @@global.ROCKSDB_INFO_LOG_LEVEL;
+@@global.ROCKSDB_INFO_LOG_LEVEL
+error_level
+"Trying to set variable @@global.ROCKSDB_INFO_LOG_LEVEL to info_level"
+SET @@global.ROCKSDB_INFO_LOG_LEVEL = info_level;
+SELECT @@global.ROCKSDB_INFO_LOG_LEVEL;
+@@global.ROCKSDB_INFO_LOG_LEVEL
+info_level
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_INFO_LOG_LEVEL = DEFAULT;
+SELECT @@global.ROCKSDB_INFO_LOG_LEVEL;
+@@global.ROCKSDB_INFO_LOG_LEVEL
+error_level
+"Trying to set variable @@global.ROCKSDB_INFO_LOG_LEVEL to debug_level"
+SET @@global.ROCKSDB_INFO_LOG_LEVEL = debug_level;
+SELECT @@global.ROCKSDB_INFO_LOG_LEVEL;
+@@global.ROCKSDB_INFO_LOG_LEVEL
+debug_level
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_INFO_LOG_LEVEL = DEFAULT;
+SELECT @@global.ROCKSDB_INFO_LOG_LEVEL;
+@@global.ROCKSDB_INFO_LOG_LEVEL
+error_level
+"Trying to set variable @@session.ROCKSDB_INFO_LOG_LEVEL to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_INFO_LOG_LEVEL = 444;
+ERROR HY000: Variable 'rocksdb_info_log_level' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_INFO_LOG_LEVEL to 5"
+SET @@global.ROCKSDB_INFO_LOG_LEVEL = 5;
+Got one of the listed errors
+SELECT @@global.ROCKSDB_INFO_LOG_LEVEL;
+@@global.ROCKSDB_INFO_LOG_LEVEL
+error_level
+"Trying to set variable @@global.ROCKSDB_INFO_LOG_LEVEL to 6"
+SET @@global.ROCKSDB_INFO_LOG_LEVEL = 6;
+Got one of the listed errors
+SELECT @@global.ROCKSDB_INFO_LOG_LEVEL;
+@@global.ROCKSDB_INFO_LOG_LEVEL
+error_level
+"Trying to set variable @@global.ROCKSDB_INFO_LOG_LEVEL to foo"
+SET @@global.ROCKSDB_INFO_LOG_LEVEL = foo;
+Got one of the listed errors
+SELECT @@global.ROCKSDB_INFO_LOG_LEVEL;
+@@global.ROCKSDB_INFO_LOG_LEVEL
+error_level
+SET @@global.ROCKSDB_INFO_LOG_LEVEL = @start_global_value;
+SELECT @@global.ROCKSDB_INFO_LOG_LEVEL;
+@@global.ROCKSDB_INFO_LOG_LEVEL
+error_level
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_io_write_timeout_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_io_write_timeout_basic.result
new file mode 100644
index 00000000..0917a397
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_io_write_timeout_basic.result
@@ -0,0 +1,86 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(10);
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(42);
+INSERT INTO valid_values VALUES(142);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_IO_WRITE_TIMEOUT;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_IO_WRITE_TIMEOUT to 10"
+SET @@global.ROCKSDB_IO_WRITE_TIMEOUT = 10;
+SELECT @@global.ROCKSDB_IO_WRITE_TIMEOUT;
+@@global.ROCKSDB_IO_WRITE_TIMEOUT
+10
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_IO_WRITE_TIMEOUT = DEFAULT;
+SELECT @@global.ROCKSDB_IO_WRITE_TIMEOUT;
+@@global.ROCKSDB_IO_WRITE_TIMEOUT
+0
+"Trying to set variable @@global.ROCKSDB_IO_WRITE_TIMEOUT to 100"
+SET @@global.ROCKSDB_IO_WRITE_TIMEOUT = 100;
+SELECT @@global.ROCKSDB_IO_WRITE_TIMEOUT;
+@@global.ROCKSDB_IO_WRITE_TIMEOUT
+100
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_IO_WRITE_TIMEOUT = DEFAULT;
+SELECT @@global.ROCKSDB_IO_WRITE_TIMEOUT;
+@@global.ROCKSDB_IO_WRITE_TIMEOUT
+0
+"Trying to set variable @@global.ROCKSDB_IO_WRITE_TIMEOUT to 0"
+SET @@global.ROCKSDB_IO_WRITE_TIMEOUT = 0;
+SELECT @@global.ROCKSDB_IO_WRITE_TIMEOUT;
+@@global.ROCKSDB_IO_WRITE_TIMEOUT
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_IO_WRITE_TIMEOUT = DEFAULT;
+SELECT @@global.ROCKSDB_IO_WRITE_TIMEOUT;
+@@global.ROCKSDB_IO_WRITE_TIMEOUT
+0
+"Trying to set variable @@global.ROCKSDB_IO_WRITE_TIMEOUT to 42"
+SET @@global.ROCKSDB_IO_WRITE_TIMEOUT = 42;
+SELECT @@global.ROCKSDB_IO_WRITE_TIMEOUT;
+@@global.ROCKSDB_IO_WRITE_TIMEOUT
+42
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_IO_WRITE_TIMEOUT = DEFAULT;
+SELECT @@global.ROCKSDB_IO_WRITE_TIMEOUT;
+@@global.ROCKSDB_IO_WRITE_TIMEOUT
+0
+"Trying to set variable @@global.ROCKSDB_IO_WRITE_TIMEOUT to 142"
+SET @@global.ROCKSDB_IO_WRITE_TIMEOUT = 142;
+SELECT @@global.ROCKSDB_IO_WRITE_TIMEOUT;
+@@global.ROCKSDB_IO_WRITE_TIMEOUT
+142
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_IO_WRITE_TIMEOUT = DEFAULT;
+SELECT @@global.ROCKSDB_IO_WRITE_TIMEOUT;
+@@global.ROCKSDB_IO_WRITE_TIMEOUT
+0
+"Trying to set variable @@session.ROCKSDB_IO_WRITE_TIMEOUT to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_IO_WRITE_TIMEOUT = 444;
+ERROR HY000: Variable 'rocksdb_io_write_timeout' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_IO_WRITE_TIMEOUT to 'aaa'"
+SET @@global.ROCKSDB_IO_WRITE_TIMEOUT = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_IO_WRITE_TIMEOUT;
+@@global.ROCKSDB_IO_WRITE_TIMEOUT
+0
+"Trying to set variable @@global.ROCKSDB_IO_WRITE_TIMEOUT to 'bbb'"
+SET @@global.ROCKSDB_IO_WRITE_TIMEOUT = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_IO_WRITE_TIMEOUT;
+@@global.ROCKSDB_IO_WRITE_TIMEOUT
+0
+SET @@global.ROCKSDB_IO_WRITE_TIMEOUT = @start_global_value;
+SELECT @@global.ROCKSDB_IO_WRITE_TIMEOUT;
+@@global.ROCKSDB_IO_WRITE_TIMEOUT
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_is_fd_close_on_exec_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_is_fd_close_on_exec_basic.result
new file mode 100644
index 00000000..87dd0e90
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_is_fd_close_on_exec_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_IS_FD_CLOSE_ON_EXEC;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_IS_FD_CLOSE_ON_EXEC to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_IS_FD_CLOSE_ON_EXEC = 444;
+ERROR HY000: Variable 'rocksdb_is_fd_close_on_exec' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_keep_log_file_num_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_keep_log_file_num_basic.result
new file mode 100644
index 00000000..3a0c5060
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_keep_log_file_num_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_KEEP_LOG_FILE_NUM;
+SELECT @start_global_value;
+@start_global_value
+1000
+"Trying to set variable @@global.ROCKSDB_KEEP_LOG_FILE_NUM to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_KEEP_LOG_FILE_NUM = 444;
+ERROR HY000: Variable 'rocksdb_keep_log_file_num' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_large_prefix_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_large_prefix_basic.result
new file mode 100644
index 00000000..89697683
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_large_prefix_basic.result
@@ -0,0 +1,64 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_LARGE_PREFIX;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_LARGE_PREFIX to 1"
+SET @@global.ROCKSDB_LARGE_PREFIX = 1;
+SELECT @@global.ROCKSDB_LARGE_PREFIX;
+@@global.ROCKSDB_LARGE_PREFIX
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_LARGE_PREFIX = DEFAULT;
+SELECT @@global.ROCKSDB_LARGE_PREFIX;
+@@global.ROCKSDB_LARGE_PREFIX
+0
+"Trying to set variable @@global.ROCKSDB_LARGE_PREFIX to 0"
+SET @@global.ROCKSDB_LARGE_PREFIX = 0;
+SELECT @@global.ROCKSDB_LARGE_PREFIX;
+@@global.ROCKSDB_LARGE_PREFIX
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_LARGE_PREFIX = DEFAULT;
+SELECT @@global.ROCKSDB_LARGE_PREFIX;
+@@global.ROCKSDB_LARGE_PREFIX
+0
+"Trying to set variable @@global.ROCKSDB_LARGE_PREFIX to on"
+SET @@global.ROCKSDB_LARGE_PREFIX = on;
+SELECT @@global.ROCKSDB_LARGE_PREFIX;
+@@global.ROCKSDB_LARGE_PREFIX
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_LARGE_PREFIX = DEFAULT;
+SELECT @@global.ROCKSDB_LARGE_PREFIX;
+@@global.ROCKSDB_LARGE_PREFIX
+0
+"Trying to set variable @@session.ROCKSDB_LARGE_PREFIX to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_LARGE_PREFIX = 444;
+ERROR HY000: Variable 'rocksdb_large_prefix' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_LARGE_PREFIX to 'aaa'"
+SET @@global.ROCKSDB_LARGE_PREFIX = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_LARGE_PREFIX;
+@@global.ROCKSDB_LARGE_PREFIX
+0
+"Trying to set variable @@global.ROCKSDB_LARGE_PREFIX to 'bbb'"
+SET @@global.ROCKSDB_LARGE_PREFIX = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_LARGE_PREFIX;
+@@global.ROCKSDB_LARGE_PREFIX
+0
+SET @@global.ROCKSDB_LARGE_PREFIX = @start_global_value;
+SELECT @@global.ROCKSDB_LARGE_PREFIX;
+@@global.ROCKSDB_LARGE_PREFIX
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_lock_scanned_rows_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_lock_scanned_rows_basic.result
new file mode 100644
index 00000000..eff9e619
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_lock_scanned_rows_basic.result
@@ -0,0 +1,170 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+INSERT INTO valid_values VALUES('true');
+INSERT INTO valid_values VALUES('false');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES(2);
+INSERT INTO invalid_values VALUES(1000);
+SET @start_global_value = @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_LOCK_SCANNED_ROWS;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_LOCK_SCANNED_ROWS to 1"
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = 1;
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = DEFAULT;
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Trying to set variable @@global.ROCKSDB_LOCK_SCANNED_ROWS to 0"
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = 0;
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = DEFAULT;
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Trying to set variable @@global.ROCKSDB_LOCK_SCANNED_ROWS to on"
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = on;
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = DEFAULT;
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Trying to set variable @@global.ROCKSDB_LOCK_SCANNED_ROWS to off"
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = off;
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = DEFAULT;
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Trying to set variable @@global.ROCKSDB_LOCK_SCANNED_ROWS to true"
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = true;
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = DEFAULT;
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Trying to set variable @@global.ROCKSDB_LOCK_SCANNED_ROWS to false"
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = false;
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = DEFAULT;
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_LOCK_SCANNED_ROWS to 1"
+SET @@session.ROCKSDB_LOCK_SCANNED_ROWS = 1;
+SELECT @@session.ROCKSDB_LOCK_SCANNED_ROWS;
+@@session.ROCKSDB_LOCK_SCANNED_ROWS
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_LOCK_SCANNED_ROWS = DEFAULT;
+SELECT @@session.ROCKSDB_LOCK_SCANNED_ROWS;
+@@session.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Trying to set variable @@session.ROCKSDB_LOCK_SCANNED_ROWS to 0"
+SET @@session.ROCKSDB_LOCK_SCANNED_ROWS = 0;
+SELECT @@session.ROCKSDB_LOCK_SCANNED_ROWS;
+@@session.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_LOCK_SCANNED_ROWS = DEFAULT;
+SELECT @@session.ROCKSDB_LOCK_SCANNED_ROWS;
+@@session.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Trying to set variable @@session.ROCKSDB_LOCK_SCANNED_ROWS to on"
+SET @@session.ROCKSDB_LOCK_SCANNED_ROWS = on;
+SELECT @@session.ROCKSDB_LOCK_SCANNED_ROWS;
+@@session.ROCKSDB_LOCK_SCANNED_ROWS
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_LOCK_SCANNED_ROWS = DEFAULT;
+SELECT @@session.ROCKSDB_LOCK_SCANNED_ROWS;
+@@session.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Trying to set variable @@session.ROCKSDB_LOCK_SCANNED_ROWS to off"
+SET @@session.ROCKSDB_LOCK_SCANNED_ROWS = off;
+SELECT @@session.ROCKSDB_LOCK_SCANNED_ROWS;
+@@session.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_LOCK_SCANNED_ROWS = DEFAULT;
+SELECT @@session.ROCKSDB_LOCK_SCANNED_ROWS;
+@@session.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Trying to set variable @@session.ROCKSDB_LOCK_SCANNED_ROWS to true"
+SET @@session.ROCKSDB_LOCK_SCANNED_ROWS = true;
+SELECT @@session.ROCKSDB_LOCK_SCANNED_ROWS;
+@@session.ROCKSDB_LOCK_SCANNED_ROWS
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_LOCK_SCANNED_ROWS = DEFAULT;
+SELECT @@session.ROCKSDB_LOCK_SCANNED_ROWS;
+@@session.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Trying to set variable @@session.ROCKSDB_LOCK_SCANNED_ROWS to false"
+SET @@session.ROCKSDB_LOCK_SCANNED_ROWS = false;
+SELECT @@session.ROCKSDB_LOCK_SCANNED_ROWS;
+@@session.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_LOCK_SCANNED_ROWS = DEFAULT;
+SELECT @@session.ROCKSDB_LOCK_SCANNED_ROWS;
+@@session.ROCKSDB_LOCK_SCANNED_ROWS
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_LOCK_SCANNED_ROWS to 'aaa'"
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Trying to set variable @@global.ROCKSDB_LOCK_SCANNED_ROWS to 2"
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = 2;
+Got one of the listed errors
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+0
+"Trying to set variable @@global.ROCKSDB_LOCK_SCANNED_ROWS to 1000"
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = 1000;
+Got one of the listed errors
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+0
+SET @@global.ROCKSDB_LOCK_SCANNED_ROWS = @start_global_value;
+SELECT @@global.ROCKSDB_LOCK_SCANNED_ROWS;
+@@global.ROCKSDB_LOCK_SCANNED_ROWS
+0
+SET @@session.ROCKSDB_LOCK_SCANNED_ROWS = @start_session_value;
+SELECT @@session.ROCKSDB_LOCK_SCANNED_ROWS;
+@@session.ROCKSDB_LOCK_SCANNED_ROWS
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_lock_wait_timeout_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_lock_wait_timeout_basic.result
new file mode 100644
index 00000000..38df5820
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_lock_wait_timeout_basic.result
@@ -0,0 +1,72 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_LOCK_WAIT_TIMEOUT;
+SELECT @start_global_value;
+@start_global_value
+1
+SET @start_session_value = @@session.ROCKSDB_LOCK_WAIT_TIMEOUT;
+SELECT @start_session_value;
+@start_session_value
+1
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_LOCK_WAIT_TIMEOUT to 1"
+SET @@global.ROCKSDB_LOCK_WAIT_TIMEOUT = 1;
+SELECT @@global.ROCKSDB_LOCK_WAIT_TIMEOUT;
+@@global.ROCKSDB_LOCK_WAIT_TIMEOUT
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_LOCK_WAIT_TIMEOUT = DEFAULT;
+SELECT @@global.ROCKSDB_LOCK_WAIT_TIMEOUT;
+@@global.ROCKSDB_LOCK_WAIT_TIMEOUT
+1
+"Trying to set variable @@global.ROCKSDB_LOCK_WAIT_TIMEOUT to 1024"
+SET @@global.ROCKSDB_LOCK_WAIT_TIMEOUT = 1024;
+SELECT @@global.ROCKSDB_LOCK_WAIT_TIMEOUT;
+@@global.ROCKSDB_LOCK_WAIT_TIMEOUT
+1024
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_LOCK_WAIT_TIMEOUT = DEFAULT;
+SELECT @@global.ROCKSDB_LOCK_WAIT_TIMEOUT;
+@@global.ROCKSDB_LOCK_WAIT_TIMEOUT
+1
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_LOCK_WAIT_TIMEOUT to 1"
+SET @@session.ROCKSDB_LOCK_WAIT_TIMEOUT = 1;
+SELECT @@session.ROCKSDB_LOCK_WAIT_TIMEOUT;
+@@session.ROCKSDB_LOCK_WAIT_TIMEOUT
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_LOCK_WAIT_TIMEOUT = DEFAULT;
+SELECT @@session.ROCKSDB_LOCK_WAIT_TIMEOUT;
+@@session.ROCKSDB_LOCK_WAIT_TIMEOUT
+1
+"Trying to set variable @@session.ROCKSDB_LOCK_WAIT_TIMEOUT to 1024"
+SET @@session.ROCKSDB_LOCK_WAIT_TIMEOUT = 1024;
+SELECT @@session.ROCKSDB_LOCK_WAIT_TIMEOUT;
+@@session.ROCKSDB_LOCK_WAIT_TIMEOUT
+1024
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_LOCK_WAIT_TIMEOUT = DEFAULT;
+SELECT @@session.ROCKSDB_LOCK_WAIT_TIMEOUT;
+@@session.ROCKSDB_LOCK_WAIT_TIMEOUT
+1
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_LOCK_WAIT_TIMEOUT to 'aaa'"
+SET @@global.ROCKSDB_LOCK_WAIT_TIMEOUT = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_LOCK_WAIT_TIMEOUT;
+@@global.ROCKSDB_LOCK_WAIT_TIMEOUT
+1
+SET @@global.ROCKSDB_LOCK_WAIT_TIMEOUT = @start_global_value;
+SELECT @@global.ROCKSDB_LOCK_WAIT_TIMEOUT;
+@@global.ROCKSDB_LOCK_WAIT_TIMEOUT
+1
+SET @@session.ROCKSDB_LOCK_WAIT_TIMEOUT = @start_session_value;
+SELECT @@session.ROCKSDB_LOCK_WAIT_TIMEOUT;
+@@session.ROCKSDB_LOCK_WAIT_TIMEOUT
+1
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_log_file_time_to_roll_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_log_file_time_to_roll_basic.result
new file mode 100644
index 00000000..24cff584
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_log_file_time_to_roll_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_LOG_FILE_TIME_TO_ROLL;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_LOG_FILE_TIME_TO_ROLL to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_LOG_FILE_TIME_TO_ROLL = 444;
+ERROR HY000: Variable 'rocksdb_log_file_time_to_roll' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_manifest_preallocation_size_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_manifest_preallocation_size_basic.result
new file mode 100644
index 00000000..dbb331d2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_manifest_preallocation_size_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_MANIFEST_PREALLOCATION_SIZE;
+SELECT @start_global_value;
+@start_global_value
+4194304
+"Trying to set variable @@global.ROCKSDB_MANIFEST_PREALLOCATION_SIZE to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_MANIFEST_PREALLOCATION_SIZE = 444;
+ERROR HY000: Variable 'rocksdb_manifest_preallocation_size' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_manual_compaction_threads_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_manual_compaction_threads_basic.result
new file mode 100644
index 00000000..3d599e17
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_manual_compaction_threads_basic.result
@@ -0,0 +1,93 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(99);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_MANUAL_COMPACTION_THREADS;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_MANUAL_COMPACTION_THREADS;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_MANUAL_COMPACTION_THREADS to 0"
+SET @@global.ROCKSDB_MANUAL_COMPACTION_THREADS = 0;
+SELECT @@global.ROCKSDB_MANUAL_COMPACTION_THREADS;
+@@global.ROCKSDB_MANUAL_COMPACTION_THREADS
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MANUAL_COMPACTION_THREADS = DEFAULT;
+SELECT @@global.ROCKSDB_MANUAL_COMPACTION_THREADS;
+@@global.ROCKSDB_MANUAL_COMPACTION_THREADS
+0
+"Trying to set variable @@global.ROCKSDB_MANUAL_COMPACTION_THREADS to 1"
+SET @@global.ROCKSDB_MANUAL_COMPACTION_THREADS = 1;
+SELECT @@global.ROCKSDB_MANUAL_COMPACTION_THREADS;
+@@global.ROCKSDB_MANUAL_COMPACTION_THREADS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MANUAL_COMPACTION_THREADS = DEFAULT;
+SELECT @@global.ROCKSDB_MANUAL_COMPACTION_THREADS;
+@@global.ROCKSDB_MANUAL_COMPACTION_THREADS
+0
+"Trying to set variable @@global.ROCKSDB_MANUAL_COMPACTION_THREADS to 99"
+SET @@global.ROCKSDB_MANUAL_COMPACTION_THREADS = 99;
+SELECT @@global.ROCKSDB_MANUAL_COMPACTION_THREADS;
+@@global.ROCKSDB_MANUAL_COMPACTION_THREADS
+99
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MANUAL_COMPACTION_THREADS = DEFAULT;
+SELECT @@global.ROCKSDB_MANUAL_COMPACTION_THREADS;
+@@global.ROCKSDB_MANUAL_COMPACTION_THREADS
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_MANUAL_COMPACTION_THREADS to 0"
+SET @@session.ROCKSDB_MANUAL_COMPACTION_THREADS = 0;
+SELECT @@session.ROCKSDB_MANUAL_COMPACTION_THREADS;
+@@session.ROCKSDB_MANUAL_COMPACTION_THREADS
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_MANUAL_COMPACTION_THREADS = DEFAULT;
+SELECT @@session.ROCKSDB_MANUAL_COMPACTION_THREADS;
+@@session.ROCKSDB_MANUAL_COMPACTION_THREADS
+0
+"Trying to set variable @@session.ROCKSDB_MANUAL_COMPACTION_THREADS to 1"
+SET @@session.ROCKSDB_MANUAL_COMPACTION_THREADS = 1;
+SELECT @@session.ROCKSDB_MANUAL_COMPACTION_THREADS;
+@@session.ROCKSDB_MANUAL_COMPACTION_THREADS
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_MANUAL_COMPACTION_THREADS = DEFAULT;
+SELECT @@session.ROCKSDB_MANUAL_COMPACTION_THREADS;
+@@session.ROCKSDB_MANUAL_COMPACTION_THREADS
+0
+"Trying to set variable @@session.ROCKSDB_MANUAL_COMPACTION_THREADS to 99"
+SET @@session.ROCKSDB_MANUAL_COMPACTION_THREADS = 99;
+SELECT @@session.ROCKSDB_MANUAL_COMPACTION_THREADS;
+@@session.ROCKSDB_MANUAL_COMPACTION_THREADS
+99
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_MANUAL_COMPACTION_THREADS = DEFAULT;
+SELECT @@session.ROCKSDB_MANUAL_COMPACTION_THREADS;
+@@session.ROCKSDB_MANUAL_COMPACTION_THREADS
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_MANUAL_COMPACTION_THREADS to 'aaa'"
+SET @@global.ROCKSDB_MANUAL_COMPACTION_THREADS = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_MANUAL_COMPACTION_THREADS;
+@@global.ROCKSDB_MANUAL_COMPACTION_THREADS
+0
+SET @@global.ROCKSDB_MANUAL_COMPACTION_THREADS = @start_global_value;
+SELECT @@global.ROCKSDB_MANUAL_COMPACTION_THREADS;
+@@global.ROCKSDB_MANUAL_COMPACTION_THREADS
+0
+SET @@session.ROCKSDB_MANUAL_COMPACTION_THREADS = @start_session_value;
+SELECT @@session.ROCKSDB_MANUAL_COMPACTION_THREADS;
+@@session.ROCKSDB_MANUAL_COMPACTION_THREADS
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_manual_wal_flush_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_manual_wal_flush_basic.result
new file mode 100644
index 00000000..9b176263
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_manual_wal_flush_basic.result
@@ -0,0 +1,14 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_MANUAL_WAL_FLUSH;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_MANUAL_WAL_FLUSH to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_MANUAL_WAL_FLUSH = 444;
+ERROR HY000: Variable 'rocksdb_manual_wal_flush' is a read only variable
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_master_skip_tx_api_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_master_skip_tx_api_basic.result
new file mode 100644
index 00000000..3f50772d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_master_skip_tx_api_basic.result
@@ -0,0 +1,100 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_MASTER_SKIP_TX_API;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_MASTER_SKIP_TX_API;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_MASTER_SKIP_TX_API to 1"
+SET @@global.ROCKSDB_MASTER_SKIP_TX_API = 1;
+SELECT @@global.ROCKSDB_MASTER_SKIP_TX_API;
+@@global.ROCKSDB_MASTER_SKIP_TX_API
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MASTER_SKIP_TX_API = DEFAULT;
+SELECT @@global.ROCKSDB_MASTER_SKIP_TX_API;
+@@global.ROCKSDB_MASTER_SKIP_TX_API
+0
+"Trying to set variable @@global.ROCKSDB_MASTER_SKIP_TX_API to 0"
+SET @@global.ROCKSDB_MASTER_SKIP_TX_API = 0;
+SELECT @@global.ROCKSDB_MASTER_SKIP_TX_API;
+@@global.ROCKSDB_MASTER_SKIP_TX_API
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MASTER_SKIP_TX_API = DEFAULT;
+SELECT @@global.ROCKSDB_MASTER_SKIP_TX_API;
+@@global.ROCKSDB_MASTER_SKIP_TX_API
+0
+"Trying to set variable @@global.ROCKSDB_MASTER_SKIP_TX_API to on"
+SET @@global.ROCKSDB_MASTER_SKIP_TX_API = on;
+SELECT @@global.ROCKSDB_MASTER_SKIP_TX_API;
+@@global.ROCKSDB_MASTER_SKIP_TX_API
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MASTER_SKIP_TX_API = DEFAULT;
+SELECT @@global.ROCKSDB_MASTER_SKIP_TX_API;
+@@global.ROCKSDB_MASTER_SKIP_TX_API
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_MASTER_SKIP_TX_API to 1"
+SET @@session.ROCKSDB_MASTER_SKIP_TX_API = 1;
+SELECT @@session.ROCKSDB_MASTER_SKIP_TX_API;
+@@session.ROCKSDB_MASTER_SKIP_TX_API
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_MASTER_SKIP_TX_API = DEFAULT;
+SELECT @@session.ROCKSDB_MASTER_SKIP_TX_API;
+@@session.ROCKSDB_MASTER_SKIP_TX_API
+0
+"Trying to set variable @@session.ROCKSDB_MASTER_SKIP_TX_API to 0"
+SET @@session.ROCKSDB_MASTER_SKIP_TX_API = 0;
+SELECT @@session.ROCKSDB_MASTER_SKIP_TX_API;
+@@session.ROCKSDB_MASTER_SKIP_TX_API
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_MASTER_SKIP_TX_API = DEFAULT;
+SELECT @@session.ROCKSDB_MASTER_SKIP_TX_API;
+@@session.ROCKSDB_MASTER_SKIP_TX_API
+0
+"Trying to set variable @@session.ROCKSDB_MASTER_SKIP_TX_API to on"
+SET @@session.ROCKSDB_MASTER_SKIP_TX_API = on;
+SELECT @@session.ROCKSDB_MASTER_SKIP_TX_API;
+@@session.ROCKSDB_MASTER_SKIP_TX_API
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_MASTER_SKIP_TX_API = DEFAULT;
+SELECT @@session.ROCKSDB_MASTER_SKIP_TX_API;
+@@session.ROCKSDB_MASTER_SKIP_TX_API
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_MASTER_SKIP_TX_API to 'aaa'"
+SET @@global.ROCKSDB_MASTER_SKIP_TX_API = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_MASTER_SKIP_TX_API;
+@@global.ROCKSDB_MASTER_SKIP_TX_API
+0
+"Trying to set variable @@global.ROCKSDB_MASTER_SKIP_TX_API to 'bbb'"
+SET @@global.ROCKSDB_MASTER_SKIP_TX_API = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_MASTER_SKIP_TX_API;
+@@global.ROCKSDB_MASTER_SKIP_TX_API
+0
+SET @@global.ROCKSDB_MASTER_SKIP_TX_API = @start_global_value;
+SELECT @@global.ROCKSDB_MASTER_SKIP_TX_API;
+@@global.ROCKSDB_MASTER_SKIP_TX_API
+0
+SET @@session.ROCKSDB_MASTER_SKIP_TX_API = @start_session_value;
+SELECT @@session.ROCKSDB_MASTER_SKIP_TX_API;
+@@session.ROCKSDB_MASTER_SKIP_TX_API
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_background_jobs_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_background_jobs_basic.result
new file mode 100644
index 00000000..88e6d21c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_background_jobs_basic.result
@@ -0,0 +1,46 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(64);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'abc\'');
+SET @start_global_value = @@global.ROCKSDB_MAX_BACKGROUND_JOBS;
+SELECT @start_global_value;
+@start_global_value
+2
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_MAX_BACKGROUND_JOBS to 1"
+SET @@global.ROCKSDB_MAX_BACKGROUND_JOBS = 1;
+SELECT @@global.ROCKSDB_MAX_BACKGROUND_JOBS;
+@@global.ROCKSDB_MAX_BACKGROUND_JOBS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MAX_BACKGROUND_JOBS = DEFAULT;
+SELECT @@global.ROCKSDB_MAX_BACKGROUND_JOBS;
+@@global.ROCKSDB_MAX_BACKGROUND_JOBS
+2
+"Trying to set variable @@global.ROCKSDB_MAX_BACKGROUND_JOBS to 64"
+SET @@global.ROCKSDB_MAX_BACKGROUND_JOBS = 64;
+SELECT @@global.ROCKSDB_MAX_BACKGROUND_JOBS;
+@@global.ROCKSDB_MAX_BACKGROUND_JOBS
+64
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MAX_BACKGROUND_JOBS = DEFAULT;
+SELECT @@global.ROCKSDB_MAX_BACKGROUND_JOBS;
+@@global.ROCKSDB_MAX_BACKGROUND_JOBS
+2
+"Trying to set variable @@session.ROCKSDB_MAX_BACKGROUND_JOBS to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_MAX_BACKGROUND_JOBS = 444;
+ERROR HY000: Variable 'rocksdb_max_background_jobs' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_MAX_BACKGROUND_JOBS to 'abc'"
+SET @@global.ROCKSDB_MAX_BACKGROUND_JOBS = 'abc';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_MAX_BACKGROUND_JOBS;
+@@global.ROCKSDB_MAX_BACKGROUND_JOBS
+2
+SET @@global.ROCKSDB_MAX_BACKGROUND_JOBS = @start_global_value;
+SELECT @@global.ROCKSDB_MAX_BACKGROUND_JOBS;
+@@global.ROCKSDB_MAX_BACKGROUND_JOBS
+2
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_latest_deadlocks_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_latest_deadlocks_basic.result
new file mode 100644
index 00000000..74dbdb42
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_latest_deadlocks_basic.result
@@ -0,0 +1,53 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(1);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'123\'');
+SET @start_global_value = @@global.ROCKSDB_MAX_LATEST_DEADLOCKS;
+SELECT @start_global_value;
+@start_global_value
+5
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_MAX_LATEST_DEADLOCKS to 100"
+SET @@global.ROCKSDB_MAX_LATEST_DEADLOCKS = 100;
+SELECT @@global.ROCKSDB_MAX_LATEST_DEADLOCKS;
+@@global.ROCKSDB_MAX_LATEST_DEADLOCKS
+100
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MAX_LATEST_DEADLOCKS = DEFAULT;
+SELECT @@global.ROCKSDB_MAX_LATEST_DEADLOCKS;
+@@global.ROCKSDB_MAX_LATEST_DEADLOCKS
+5
+"Trying to set variable @@global.ROCKSDB_MAX_LATEST_DEADLOCKS to 1"
+SET @@global.ROCKSDB_MAX_LATEST_DEADLOCKS = 1;
+SELECT @@global.ROCKSDB_MAX_LATEST_DEADLOCKS;
+@@global.ROCKSDB_MAX_LATEST_DEADLOCKS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MAX_LATEST_DEADLOCKS = DEFAULT;
+SELECT @@global.ROCKSDB_MAX_LATEST_DEADLOCKS;
+@@global.ROCKSDB_MAX_LATEST_DEADLOCKS
+5
+"Trying to set variable @@session.ROCKSDB_MAX_LATEST_DEADLOCKS to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_MAX_LATEST_DEADLOCKS = 444;
+ERROR HY000: Variable 'rocksdb_max_latest_deadlocks' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_MAX_LATEST_DEADLOCKS to 'aaa'"
+SET @@global.ROCKSDB_MAX_LATEST_DEADLOCKS = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_MAX_LATEST_DEADLOCKS;
+@@global.ROCKSDB_MAX_LATEST_DEADLOCKS
+5
+"Trying to set variable @@global.ROCKSDB_MAX_LATEST_DEADLOCKS to '123'"
+SET @@global.ROCKSDB_MAX_LATEST_DEADLOCKS = '123';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_MAX_LATEST_DEADLOCKS;
+@@global.ROCKSDB_MAX_LATEST_DEADLOCKS
+5
+SET @@global.ROCKSDB_MAX_LATEST_DEADLOCKS = @start_global_value;
+SELECT @@global.ROCKSDB_MAX_LATEST_DEADLOCKS;
+@@global.ROCKSDB_MAX_LATEST_DEADLOCKS
+5
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_log_file_size_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_log_file_size_basic.result
new file mode 100644
index 00000000..4359ee72
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_log_file_size_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_MAX_LOG_FILE_SIZE;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_MAX_LOG_FILE_SIZE to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_MAX_LOG_FILE_SIZE = 444;
+ERROR HY000: Variable 'rocksdb_max_log_file_size' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_manifest_file_size_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_manifest_file_size_basic.result
new file mode 100644
index 00000000..45330b82
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_manifest_file_size_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_MAX_MANIFEST_FILE_SIZE;
+SELECT @start_global_value;
+@start_global_value
+1073741824
+"Trying to set variable @@global.ROCKSDB_MAX_MANIFEST_FILE_SIZE to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_MAX_MANIFEST_FILE_SIZE = 444;
+ERROR HY000: Variable 'rocksdb_max_manifest_file_size' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_manual_compactions_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_manual_compactions_basic.result
new file mode 100644
index 00000000..815506cc
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_manual_compactions_basic.result
@@ -0,0 +1,57 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+INSERT INTO valid_values VALUES(512*1024*1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS;
+SELECT @start_global_value;
+@start_global_value
+10
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS to 1"
+SET @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS = 1;
+SELECT @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS;
+@@global.ROCKSDB_MAX_MANUAL_COMPACTIONS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS = DEFAULT;
+SELECT @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS;
+@@global.ROCKSDB_MAX_MANUAL_COMPACTIONS
+10
+"Trying to set variable @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS to 1024"
+SET @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS = 1024;
+SELECT @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS;
+@@global.ROCKSDB_MAX_MANUAL_COMPACTIONS
+1024
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS = DEFAULT;
+SELECT @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS;
+@@global.ROCKSDB_MAX_MANUAL_COMPACTIONS
+10
+"Trying to set variable @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS to 536870912"
+SET @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS = 536870912;
+SELECT @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS;
+@@global.ROCKSDB_MAX_MANUAL_COMPACTIONS
+536870912
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS = DEFAULT;
+SELECT @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS;
+@@global.ROCKSDB_MAX_MANUAL_COMPACTIONS
+10
+"Trying to set variable @@session.ROCKSDB_MAX_MANUAL_COMPACTIONS to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_MAX_MANUAL_COMPACTIONS = 444;
+ERROR HY000: Variable 'rocksdb_max_manual_compactions' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS to 'aaa'"
+SET @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS;
+@@global.ROCKSDB_MAX_MANUAL_COMPACTIONS
+10
+SET @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS = @start_global_value;
+SELECT @@global.ROCKSDB_MAX_MANUAL_COMPACTIONS;
+@@global.ROCKSDB_MAX_MANUAL_COMPACTIONS
+10
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_open_files_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_open_files_basic.result
new file mode 100644
index 00000000..60f50531
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_open_files_basic.result
@@ -0,0 +1,3 @@
+show variables like 'rocksdb_max_open_files';
+Variable_name Value
+rocksdb_max_open_files #
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_row_locks_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_row_locks_basic.result
new file mode 100644
index 00000000..b195df09
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_row_locks_basic.result
@@ -0,0 +1,93 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+INSERT INTO valid_values VALUES(512*1024*1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_MAX_ROW_LOCKS;
+SELECT @start_global_value;
+@start_global_value
+1048576
+SET @start_session_value = @@session.ROCKSDB_MAX_ROW_LOCKS;
+SELECT @start_session_value;
+@start_session_value
+1048576
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_MAX_ROW_LOCKS to 1"
+SET @@global.ROCKSDB_MAX_ROW_LOCKS = 1;
+SELECT @@global.ROCKSDB_MAX_ROW_LOCKS;
+@@global.ROCKSDB_MAX_ROW_LOCKS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MAX_ROW_LOCKS = DEFAULT;
+SELECT @@global.ROCKSDB_MAX_ROW_LOCKS;
+@@global.ROCKSDB_MAX_ROW_LOCKS
+1048576
+"Trying to set variable @@global.ROCKSDB_MAX_ROW_LOCKS to 1024"
+SET @@global.ROCKSDB_MAX_ROW_LOCKS = 1024;
+SELECT @@global.ROCKSDB_MAX_ROW_LOCKS;
+@@global.ROCKSDB_MAX_ROW_LOCKS
+1024
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MAX_ROW_LOCKS = DEFAULT;
+SELECT @@global.ROCKSDB_MAX_ROW_LOCKS;
+@@global.ROCKSDB_MAX_ROW_LOCKS
+1048576
+"Trying to set variable @@global.ROCKSDB_MAX_ROW_LOCKS to 536870912"
+SET @@global.ROCKSDB_MAX_ROW_LOCKS = 536870912;
+SELECT @@global.ROCKSDB_MAX_ROW_LOCKS;
+@@global.ROCKSDB_MAX_ROW_LOCKS
+536870912
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MAX_ROW_LOCKS = DEFAULT;
+SELECT @@global.ROCKSDB_MAX_ROW_LOCKS;
+@@global.ROCKSDB_MAX_ROW_LOCKS
+1048576
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_MAX_ROW_LOCKS to 1"
+SET @@session.ROCKSDB_MAX_ROW_LOCKS = 1;
+SELECT @@session.ROCKSDB_MAX_ROW_LOCKS;
+@@session.ROCKSDB_MAX_ROW_LOCKS
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_MAX_ROW_LOCKS = DEFAULT;
+SELECT @@session.ROCKSDB_MAX_ROW_LOCKS;
+@@session.ROCKSDB_MAX_ROW_LOCKS
+1048576
+"Trying to set variable @@session.ROCKSDB_MAX_ROW_LOCKS to 1024"
+SET @@session.ROCKSDB_MAX_ROW_LOCKS = 1024;
+SELECT @@session.ROCKSDB_MAX_ROW_LOCKS;
+@@session.ROCKSDB_MAX_ROW_LOCKS
+1024
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_MAX_ROW_LOCKS = DEFAULT;
+SELECT @@session.ROCKSDB_MAX_ROW_LOCKS;
+@@session.ROCKSDB_MAX_ROW_LOCKS
+1048576
+"Trying to set variable @@session.ROCKSDB_MAX_ROW_LOCKS to 536870912"
+SET @@session.ROCKSDB_MAX_ROW_LOCKS = 536870912;
+SELECT @@session.ROCKSDB_MAX_ROW_LOCKS;
+@@session.ROCKSDB_MAX_ROW_LOCKS
+536870912
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_MAX_ROW_LOCKS = DEFAULT;
+SELECT @@session.ROCKSDB_MAX_ROW_LOCKS;
+@@session.ROCKSDB_MAX_ROW_LOCKS
+1048576
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_MAX_ROW_LOCKS to 'aaa'"
+SET @@global.ROCKSDB_MAX_ROW_LOCKS = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_MAX_ROW_LOCKS;
+@@global.ROCKSDB_MAX_ROW_LOCKS
+1048576
+SET @@global.ROCKSDB_MAX_ROW_LOCKS = @start_global_value;
+SELECT @@global.ROCKSDB_MAX_ROW_LOCKS;
+@@global.ROCKSDB_MAX_ROW_LOCKS
+1048576
+SET @@session.ROCKSDB_MAX_ROW_LOCKS = @start_session_value;
+SELECT @@session.ROCKSDB_MAX_ROW_LOCKS;
+@@session.ROCKSDB_MAX_ROW_LOCKS
+1048576
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_subcompactions_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_subcompactions_basic.result
new file mode 100644
index 00000000..58452f58
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_subcompactions_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_MAX_SUBCOMPACTIONS;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_MAX_SUBCOMPACTIONS to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_MAX_SUBCOMPACTIONS = 444;
+ERROR HY000: Variable 'rocksdb_max_subcompactions' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_total_wal_size_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_total_wal_size_basic.result
new file mode 100644
index 00000000..22c17c24
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_max_total_wal_size_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_MAX_TOTAL_WAL_SIZE;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_MAX_TOTAL_WAL_SIZE to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_MAX_TOTAL_WAL_SIZE = 444;
+ERROR HY000: Variable 'rocksdb_max_total_wal_size' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_merge_buf_size_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_merge_buf_size_basic.result
new file mode 100644
index 00000000..5715b198
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_merge_buf_size_basic.result
@@ -0,0 +1,43 @@
+drop table if exists t1;
+set session rocksdb_merge_buf_size=250;
+set session rocksdb_merge_combine_read_size=1000;
+CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i)) ENGINE = ROCKSDB;
+ALTER TABLE t1 ADD INDEX kj(j), ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) NOT NULL,
+ `j` int(11) DEFAULT NULL,
+ PRIMARY KEY (`i`),
+ KEY `kj` (`j`),
+ KEY `kij` (`i`,`j`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+DROP INDEX kj on t1;
+DROP INDEX kij ON t1;
+ALTER TABLE t1 ADD INDEX kj(j), ADD INDEX kij(i,j), ADD INDEX kji(j,i), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) NOT NULL,
+ `j` int(11) DEFAULT NULL,
+ PRIMARY KEY (`i`),
+ KEY `kj` (`j`),
+ KEY `kij` (`i`,`j`),
+ KEY `kji` (`j`,`i`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=RocksDB;
+ALTER TABLE t1 ADD INDEX kb(b) comment 'rev:cf1', ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`),
+ KEY `kb` (`b`) COMMENT 'rev:cf1'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+SELECT COUNT(*) FROM t1 FORCE INDEX(kb);
+COUNT(*)
+100
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_merge_combine_read_size_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_merge_combine_read_size_basic.result
new file mode 100644
index 00000000..5b73305c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_merge_combine_read_size_basic.result
@@ -0,0 +1,29 @@
+drop table if exists t1;
+set session rocksdb_merge_buf_size=250;
+set session rocksdb_merge_combine_read_size=1000;
+CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i)) ENGINE = ROCKSDB;
+ALTER TABLE t1 ADD INDEX kj(j), ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) NOT NULL,
+ `j` int(11) DEFAULT NULL,
+ PRIMARY KEY (`i`),
+ KEY `kj` (`j`),
+ KEY `kij` (`i`,`j`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+DROP INDEX kj on t1;
+DROP INDEX kij ON t1;
+ALTER TABLE t1 ADD INDEX kj(j), ADD INDEX kij(i,j), ADD INDEX kji(j,i), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) NOT NULL,
+ `j` int(11) DEFAULT NULL,
+ PRIMARY KEY (`i`),
+ KEY `kj` (`j`),
+ KEY `kij` (`i`,`j`),
+ KEY `kji` (`j`,`i`)
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_merge_tmp_file_removal_delay_ms_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_merge_tmp_file_removal_delay_ms_basic.result
new file mode 100644
index 00000000..277de716
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_merge_tmp_file_removal_delay_ms_basic.result
@@ -0,0 +1,93 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('on');
+SET @start_global_value = @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS to 1"
+SET @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS = 1;
+SELECT @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS;
+@@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS = DEFAULT;
+SELECT @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS;
+@@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS
+0
+"Trying to set variable @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS to 0"
+SET @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS = 0;
+SELECT @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS;
+@@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS = DEFAULT;
+SELECT @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS;
+@@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS to 1"
+SET @@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS = 1;
+SELECT @@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS;
+@@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS = DEFAULT;
+SELECT @@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS;
+@@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS
+0
+"Trying to set variable @@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS to 0"
+SET @@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS = 0;
+SELECT @@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS;
+@@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS = DEFAULT;
+SELECT @@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS;
+@@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS to 'aaa'"
+SET @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS;
+@@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS
+0
+"Trying to set variable @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS to 'bbb'"
+SET @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS;
+@@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS
+0
+"Trying to set variable @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS to on"
+SET @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS = on;
+Got one of the listed errors
+SELECT @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS;
+@@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS
+0
+SET @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS = @start_global_value;
+SELECT @@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS;
+@@global.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS
+0
+SET @@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS = @start_session_value;
+SELECT @@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS;
+@@session.ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
+set session rocksdb_merge_buf_size=250;
+set session rocksdb_merge_combine_read_size=1000;
+set session rocksdb_merge_tmp_file_removal_delay_ms=1000;
+CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i)) ENGINE = ROCKSDB;
+ALTER TABLE t1 ADD INDEX kj(j), ALGORITHM=INPLACE;
+include/assert.inc [Alter should have taken at least 10 seconds]
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_new_table_reader_for_compaction_inputs_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_new_table_reader_for_compaction_inputs_basic.result
new file mode 100644
index 00000000..c2daec32
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_new_table_reader_for_compaction_inputs_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_NEW_TABLE_READER_FOR_COMPACTION_INPUTS;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_NEW_TABLE_READER_FOR_COMPACTION_INPUTS to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_NEW_TABLE_READER_FOR_COMPACTION_INPUTS = 444;
+ERROR HY000: Variable 'rocksdb_new_table_reader_for_compaction_inputs' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_no_block_cache_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_no_block_cache_basic.result
new file mode 100644
index 00000000..7bd32950
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_no_block_cache_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_NO_BLOCK_CACHE;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_NO_BLOCK_CACHE to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_NO_BLOCK_CACHE = 444;
+ERROR HY000: Variable 'rocksdb_no_block_cache' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_override_cf_options_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_override_cf_options_basic.result
new file mode 100644
index 00000000..59042124
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_override_cf_options_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_OVERRIDE_CF_OPTIONS;
+SELECT @start_global_value;
+@start_global_value
+
+"Trying to set variable @@global.ROCKSDB_OVERRIDE_CF_OPTIONS to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_OVERRIDE_CF_OPTIONS = 444;
+ERROR HY000: Variable 'rocksdb_override_cf_options' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_paranoid_checks_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_paranoid_checks_basic.result
new file mode 100644
index 00000000..102d4926
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_paranoid_checks_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_PARANOID_CHECKS;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_PARANOID_CHECKS to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_PARANOID_CHECKS = 444;
+ERROR HY000: Variable 'rocksdb_paranoid_checks' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_pause_background_work_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_pause_background_work_basic.result
new file mode 100644
index 00000000..5849fe09
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_pause_background_work_basic.result
@@ -0,0 +1,75 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_PAUSE_BACKGROUND_WORK;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_PAUSE_BACKGROUND_WORK to 1"
+SET @@global.ROCKSDB_PAUSE_BACKGROUND_WORK = 1;
+SELECT @@global.ROCKSDB_PAUSE_BACKGROUND_WORK;
+@@global.ROCKSDB_PAUSE_BACKGROUND_WORK
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_PAUSE_BACKGROUND_WORK = DEFAULT;
+SELECT @@global.ROCKSDB_PAUSE_BACKGROUND_WORK;
+@@global.ROCKSDB_PAUSE_BACKGROUND_WORK
+0
+"Trying to set variable @@global.ROCKSDB_PAUSE_BACKGROUND_WORK to 0"
+SET @@global.ROCKSDB_PAUSE_BACKGROUND_WORK = 0;
+SELECT @@global.ROCKSDB_PAUSE_BACKGROUND_WORK;
+@@global.ROCKSDB_PAUSE_BACKGROUND_WORK
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_PAUSE_BACKGROUND_WORK = DEFAULT;
+SELECT @@global.ROCKSDB_PAUSE_BACKGROUND_WORK;
+@@global.ROCKSDB_PAUSE_BACKGROUND_WORK
+0
+"Trying to set variable @@global.ROCKSDB_PAUSE_BACKGROUND_WORK to on"
+SET @@global.ROCKSDB_PAUSE_BACKGROUND_WORK = on;
+SELECT @@global.ROCKSDB_PAUSE_BACKGROUND_WORK;
+@@global.ROCKSDB_PAUSE_BACKGROUND_WORK
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_PAUSE_BACKGROUND_WORK = DEFAULT;
+SELECT @@global.ROCKSDB_PAUSE_BACKGROUND_WORK;
+@@global.ROCKSDB_PAUSE_BACKGROUND_WORK
+0
+"Trying to set variable @@global.ROCKSDB_PAUSE_BACKGROUND_WORK to off"
+SET @@global.ROCKSDB_PAUSE_BACKGROUND_WORK = off;
+SELECT @@global.ROCKSDB_PAUSE_BACKGROUND_WORK;
+@@global.ROCKSDB_PAUSE_BACKGROUND_WORK
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_PAUSE_BACKGROUND_WORK = DEFAULT;
+SELECT @@global.ROCKSDB_PAUSE_BACKGROUND_WORK;
+@@global.ROCKSDB_PAUSE_BACKGROUND_WORK
+0
+"Trying to set variable @@session.ROCKSDB_PAUSE_BACKGROUND_WORK to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_PAUSE_BACKGROUND_WORK = 444;
+ERROR HY000: Variable 'rocksdb_pause_background_work' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_PAUSE_BACKGROUND_WORK to 'aaa'"
+SET @@global.ROCKSDB_PAUSE_BACKGROUND_WORK = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_PAUSE_BACKGROUND_WORK;
+@@global.ROCKSDB_PAUSE_BACKGROUND_WORK
+0
+"Trying to set variable @@global.ROCKSDB_PAUSE_BACKGROUND_WORK to 'bbb'"
+SET @@global.ROCKSDB_PAUSE_BACKGROUND_WORK = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_PAUSE_BACKGROUND_WORK;
+@@global.ROCKSDB_PAUSE_BACKGROUND_WORK
+0
+SET @@global.ROCKSDB_PAUSE_BACKGROUND_WORK = @start_global_value;
+SELECT @@global.ROCKSDB_PAUSE_BACKGROUND_WORK;
+@@global.ROCKSDB_PAUSE_BACKGROUND_WORK
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_perf_context_level_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_perf_context_level_basic.result
new file mode 100644
index 00000000..292ba58a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_perf_context_level_basic.result
@@ -0,0 +1,114 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(2);
+INSERT INTO valid_values VALUES(3);
+INSERT INTO valid_values VALUES(4);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_PERF_CONTEXT_LEVEL;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_PERF_CONTEXT_LEVEL;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_PERF_CONTEXT_LEVEL to 1"
+SET @@global.ROCKSDB_PERF_CONTEXT_LEVEL = 1;
+SELECT @@global.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@global.ROCKSDB_PERF_CONTEXT_LEVEL
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_PERF_CONTEXT_LEVEL = DEFAULT;
+SELECT @@global.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@global.ROCKSDB_PERF_CONTEXT_LEVEL
+0
+"Trying to set variable @@global.ROCKSDB_PERF_CONTEXT_LEVEL to 2"
+SET @@global.ROCKSDB_PERF_CONTEXT_LEVEL = 2;
+SELECT @@global.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@global.ROCKSDB_PERF_CONTEXT_LEVEL
+2
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_PERF_CONTEXT_LEVEL = DEFAULT;
+SELECT @@global.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@global.ROCKSDB_PERF_CONTEXT_LEVEL
+0
+"Trying to set variable @@global.ROCKSDB_PERF_CONTEXT_LEVEL to 3"
+SET @@global.ROCKSDB_PERF_CONTEXT_LEVEL = 3;
+SELECT @@global.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@global.ROCKSDB_PERF_CONTEXT_LEVEL
+3
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_PERF_CONTEXT_LEVEL = DEFAULT;
+SELECT @@global.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@global.ROCKSDB_PERF_CONTEXT_LEVEL
+0
+"Trying to set variable @@global.ROCKSDB_PERF_CONTEXT_LEVEL to 4"
+SET @@global.ROCKSDB_PERF_CONTEXT_LEVEL = 4;
+SELECT @@global.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@global.ROCKSDB_PERF_CONTEXT_LEVEL
+4
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_PERF_CONTEXT_LEVEL = DEFAULT;
+SELECT @@global.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@global.ROCKSDB_PERF_CONTEXT_LEVEL
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_PERF_CONTEXT_LEVEL to 1"
+SET @@session.ROCKSDB_PERF_CONTEXT_LEVEL = 1;
+SELECT @@session.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@session.ROCKSDB_PERF_CONTEXT_LEVEL
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_PERF_CONTEXT_LEVEL = DEFAULT;
+SELECT @@session.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@session.ROCKSDB_PERF_CONTEXT_LEVEL
+0
+"Trying to set variable @@session.ROCKSDB_PERF_CONTEXT_LEVEL to 2"
+SET @@session.ROCKSDB_PERF_CONTEXT_LEVEL = 2;
+SELECT @@session.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@session.ROCKSDB_PERF_CONTEXT_LEVEL
+2
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_PERF_CONTEXT_LEVEL = DEFAULT;
+SELECT @@session.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@session.ROCKSDB_PERF_CONTEXT_LEVEL
+0
+"Trying to set variable @@session.ROCKSDB_PERF_CONTEXT_LEVEL to 3"
+SET @@session.ROCKSDB_PERF_CONTEXT_LEVEL = 3;
+SELECT @@session.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@session.ROCKSDB_PERF_CONTEXT_LEVEL
+3
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_PERF_CONTEXT_LEVEL = DEFAULT;
+SELECT @@session.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@session.ROCKSDB_PERF_CONTEXT_LEVEL
+0
+"Trying to set variable @@session.ROCKSDB_PERF_CONTEXT_LEVEL to 4"
+SET @@session.ROCKSDB_PERF_CONTEXT_LEVEL = 4;
+SELECT @@session.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@session.ROCKSDB_PERF_CONTEXT_LEVEL
+4
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_PERF_CONTEXT_LEVEL = DEFAULT;
+SELECT @@session.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@session.ROCKSDB_PERF_CONTEXT_LEVEL
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_PERF_CONTEXT_LEVEL to 'aaa'"
+SET @@global.ROCKSDB_PERF_CONTEXT_LEVEL = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@global.ROCKSDB_PERF_CONTEXT_LEVEL
+0
+SET @@global.ROCKSDB_PERF_CONTEXT_LEVEL = @start_global_value;
+SELECT @@global.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@global.ROCKSDB_PERF_CONTEXT_LEVEL
+0
+SET @@session.ROCKSDB_PERF_CONTEXT_LEVEL = @start_session_value;
+SELECT @@session.ROCKSDB_PERF_CONTEXT_LEVEL;
+@@session.ROCKSDB_PERF_CONTEXT_LEVEL
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_persistent_cache_path_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_persistent_cache_path_basic.result
new file mode 100644
index 00000000..10b187d4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_persistent_cache_path_basic.result
@@ -0,0 +1,13 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES('abc');
+INSERT INTO valid_values VALUES('def');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+SET @start_global_value = @@global.ROCKSDB_PERSISTENT_CACHE_PATH;
+SELECT @start_global_value;
+@start_global_value
+
+"Trying to set variable @@global.ROCKSDB_PERSISTENT_CACHE_PATH to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_PERSISTENT_CACHE_PATH = 444;
+ERROR HY000: Variable 'rocksdb_persistent_cache_path' is a read only variable
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_persistent_cache_size_mb_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_persistent_cache_size_mb_basic.result
new file mode 100644
index 00000000..d0971925
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_persistent_cache_size_mb_basic.result
@@ -0,0 +1,14 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_PERSISTENT_CACHE_SIZE_MB;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_PERSISTENT_CACHE_SIZE_MB to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_PERSISTENT_CACHE_SIZE_MB = 444;
+ERROR HY000: Variable 'rocksdb_persistent_cache_size_mb' is a read only variable
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_pin_l0_filter_and_index_blocks_in_cache_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_pin_l0_filter_and_index_blocks_in_cache_basic.result
new file mode 100644
index 00000000..c152ecf1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_pin_l0_filter_and_index_blocks_in_cache_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_PIN_L0_FILTER_AND_INDEX_BLOCKS_IN_CACHE;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_PIN_L0_FILTER_AND_INDEX_BLOCKS_IN_CACHE to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_PIN_L0_FILTER_AND_INDEX_BLOCKS_IN_CACHE = 444;
+ERROR HY000: Variable 'rocksdb_pin_l0_filter_and_index_blocks_in_cache' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_print_snapshot_conflict_queries_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_print_snapshot_conflict_queries_basic.result
new file mode 100644
index 00000000..02a4b404
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_print_snapshot_conflict_queries_basic.result
@@ -0,0 +1,64 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES to 1"
+SET @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES = 1;
+SELECT @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES;
+@@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES = DEFAULT;
+SELECT @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES;
+@@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES
+0
+"Trying to set variable @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES to 0"
+SET @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES = 0;
+SELECT @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES;
+@@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES = DEFAULT;
+SELECT @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES;
+@@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES
+0
+"Trying to set variable @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES to on"
+SET @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES = on;
+SELECT @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES;
+@@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES = DEFAULT;
+SELECT @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES;
+@@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES
+0
+"Trying to set variable @@session.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES = 444;
+ERROR HY000: Variable 'rocksdb_print_snapshot_conflict_queries' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES to 'aaa'"
+SET @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES;
+@@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES
+0
+"Trying to set variable @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES to 'bbb'"
+SET @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES;
+@@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES
+0
+SET @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES = @start_global_value;
+SELECT @@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES;
+@@global.ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_rate_limiter_bytes_per_sec_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_rate_limiter_bytes_per_sec_basic.result
new file mode 100644
index 00000000..9d194ad7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_rate_limiter_bytes_per_sec_basic.result
@@ -0,0 +1,101 @@
+SET @@global.rocksdb_rate_limiter_bytes_per_sec = 10000;
+Warnings:
+Warning 1210 RocksDB: rocksdb_rate_limiter_bytes_per_sec cannot be dynamically changed to or from 0. Do a clean shutdown if you want to change it from or to 0.
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1), (1000), (1000000), (1000000000), (1000000000000);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\''), (3.14);
+SET @start_global_value = @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC;
+SELECT @start_global_value;
+@start_global_value
+10000
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC to 1"
+SET @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC = 1;
+SELECT @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC;
+@@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC = DEFAULT;
+Warnings:
+Warning 1210 RocksDB: rocksdb_rate_limiter_bytes_per_sec cannot be dynamically changed to or from 0. Do a clean shutdown if you want to change it from or to 0.
+SELECT @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC;
+@@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC
+1
+"Trying to set variable @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC to 1000"
+SET @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC = 1000;
+SELECT @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC;
+@@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC
+1000
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC = DEFAULT;
+Warnings:
+Warning 1210 RocksDB: rocksdb_rate_limiter_bytes_per_sec cannot be dynamically changed to or from 0. Do a clean shutdown if you want to change it from or to 0.
+SELECT @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC;
+@@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC
+1000
+"Trying to set variable @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC to 1000000"
+SET @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC = 1000000;
+SELECT @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC;
+@@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC
+1000000
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC = DEFAULT;
+Warnings:
+Warning 1210 RocksDB: rocksdb_rate_limiter_bytes_per_sec cannot be dynamically changed to or from 0. Do a clean shutdown if you want to change it from or to 0.
+SELECT @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC;
+@@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC
+1000000
+"Trying to set variable @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC to 1000000000"
+SET @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC = 1000000000;
+SELECT @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC;
+@@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC
+1000000000
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC = DEFAULT;
+Warnings:
+Warning 1210 RocksDB: rocksdb_rate_limiter_bytes_per_sec cannot be dynamically changed to or from 0. Do a clean shutdown if you want to change it from or to 0.
+SELECT @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC;
+@@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC
+1000000000
+"Trying to set variable @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC to 1000000000000"
+SET @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC = 1000000000000;
+SELECT @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC;
+@@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC
+1000000000000
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC = DEFAULT;
+Warnings:
+Warning 1210 RocksDB: rocksdb_rate_limiter_bytes_per_sec cannot be dynamically changed to or from 0. Do a clean shutdown if you want to change it from or to 0.
+SELECT @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC;
+@@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC
+1000000000000
+"Trying to set variable @@session.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC = 444;
+ERROR HY000: Variable 'rocksdb_rate_limiter_bytes_per_sec' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC to 'aaa'"
+SET @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC;
+@@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC
+1000000000000
+"Trying to set variable @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC to 3.14"
+SET @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC = 3.14;
+Got one of the listed errors
+SELECT @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC;
+@@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC
+1000000000000
+SET @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC = @start_global_value;
+SELECT @@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC;
+@@global.ROCKSDB_RATE_LIMITER_BYTES_PER_SEC
+10000
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
+SET @@global.rocksdb_rate_limiter_bytes_per_sec = 0;
+Warnings:
+Warning 1210 RocksDB: rocksdb_rate_limiter_bytes_per_sec cannot be dynamically changed to or from 0. Do a clean shutdown if you want to change it from or to 0.
+SET @@global.rocksdb_rate_limiter_bytes_per_sec = -1;
+Warnings:
+Warning 1292 Truncated incorrect rocksdb_rate_limiter_bytes_pe... value: '-1'
+Warning 1210 RocksDB: rocksdb_rate_limiter_bytes_per_sec cannot be dynamically changed to or from 0. Do a clean shutdown if you want to change it from or to 0.
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_read_free_rpl_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_read_free_rpl_basic.result
new file mode 100644
index 00000000..78837992
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_read_free_rpl_basic.result
@@ -0,0 +1,58 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES('PK_SK');
+INSERT INTO valid_values VALUES('OFF');
+INSERT INTO valid_values VALUES('PK_ONLY');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('a');
+SET @start_global_value = @@global.ROCKSDB_READ_FREE_RPL;
+SELECT @start_global_value;
+@start_global_value
+OFF
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_READ_FREE_RPL to PK_SK"
+SET @@global.ROCKSDB_READ_FREE_RPL = PK_SK;
+SELECT @@global.ROCKSDB_READ_FREE_RPL;
+@@global.ROCKSDB_READ_FREE_RPL
+PK_SK
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_READ_FREE_RPL = DEFAULT;
+SELECT @@global.ROCKSDB_READ_FREE_RPL;
+@@global.ROCKSDB_READ_FREE_RPL
+OFF
+"Trying to set variable @@global.ROCKSDB_READ_FREE_RPL to OFF"
+SET @@global.ROCKSDB_READ_FREE_RPL = OFF;
+SELECT @@global.ROCKSDB_READ_FREE_RPL;
+@@global.ROCKSDB_READ_FREE_RPL
+OFF
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_READ_FREE_RPL = DEFAULT;
+SELECT @@global.ROCKSDB_READ_FREE_RPL;
+@@global.ROCKSDB_READ_FREE_RPL
+OFF
+"Trying to set variable @@global.ROCKSDB_READ_FREE_RPL to PK_ONLY"
+SET @@global.ROCKSDB_READ_FREE_RPL = PK_ONLY;
+SELECT @@global.ROCKSDB_READ_FREE_RPL;
+@@global.ROCKSDB_READ_FREE_RPL
+PK_ONLY
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_READ_FREE_RPL = DEFAULT;
+SELECT @@global.ROCKSDB_READ_FREE_RPL;
+@@global.ROCKSDB_READ_FREE_RPL
+OFF
+"Trying to set variable @@session.ROCKSDB_READ_FREE_RPL to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_READ_FREE_RPL = 444;
+ERROR HY000: Variable 'rocksdb_read_free_rpl' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_READ_FREE_RPL to a"
+SET @@global.ROCKSDB_READ_FREE_RPL = a;
+Got one of the listed errors
+SELECT @@global.ROCKSDB_READ_FREE_RPL;
+@@global.ROCKSDB_READ_FREE_RPL
+OFF
+SET @@global.ROCKSDB_READ_FREE_RPL = @start_global_value;
+SELECT @@global.ROCKSDB_READ_FREE_RPL;
+@@global.ROCKSDB_READ_FREE_RPL
+OFF
+SET GLOBAL ROCKSDB_READ_FREE_RPL=DEFAULT;
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_read_free_rpl_tables_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_read_free_rpl_tables_basic.result
new file mode 100644
index 00000000..2643eb08
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_read_free_rpl_tables_basic.result
@@ -0,0 +1,49 @@
+call mtr.add_suppression(".*Invalid pattern in rocksdb_read_free_rpl_tables.*");
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES('a');
+INSERT INTO valid_values VALUES('b');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'*\'');
+SET @start_global_value = @@global.ROCKSDB_READ_FREE_RPL_TABLES;
+SELECT @start_global_value;
+@start_global_value
+.*
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_READ_FREE_RPL_TABLES to a"
+SET @@global.ROCKSDB_READ_FREE_RPL_TABLES = a;
+SELECT @@global.ROCKSDB_READ_FREE_RPL_TABLES;
+@@global.ROCKSDB_READ_FREE_RPL_TABLES
+a
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_READ_FREE_RPL_TABLES = DEFAULT;
+SELECT @@global.ROCKSDB_READ_FREE_RPL_TABLES;
+@@global.ROCKSDB_READ_FREE_RPL_TABLES
+.*
+"Trying to set variable @@global.ROCKSDB_READ_FREE_RPL_TABLES to b"
+SET @@global.ROCKSDB_READ_FREE_RPL_TABLES = b;
+SELECT @@global.ROCKSDB_READ_FREE_RPL_TABLES;
+@@global.ROCKSDB_READ_FREE_RPL_TABLES
+b
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_READ_FREE_RPL_TABLES = DEFAULT;
+SELECT @@global.ROCKSDB_READ_FREE_RPL_TABLES;
+@@global.ROCKSDB_READ_FREE_RPL_TABLES
+.*
+"Trying to set variable @@session.ROCKSDB_READ_FREE_RPL_TABLES to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_READ_FREE_RPL_TABLES = 444;
+ERROR HY000: Variable 'rocksdb_read_free_rpl_tables' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_READ_FREE_RPL_TABLES to '*'"
+SET @@global.ROCKSDB_READ_FREE_RPL_TABLES = '*';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_READ_FREE_RPL_TABLES;
+@@global.ROCKSDB_READ_FREE_RPL_TABLES
+.*
+SET @@global.ROCKSDB_READ_FREE_RPL_TABLES = @start_global_value;
+SELECT @@global.ROCKSDB_READ_FREE_RPL_TABLES;
+@@global.ROCKSDB_READ_FREE_RPL_TABLES
+.*
+SET GLOBAL ROCKSDB_READ_FREE_RPL_TABLES=NULL;
+SET GLOBAL ROCKSDB_READ_FREE_RPL_TABLES=DEFAULT;
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_records_in_range_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_records_in_range_basic.result
new file mode 100644
index 00000000..e866787e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_records_in_range_basic.result
@@ -0,0 +1,100 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(222333);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_RECORDS_IN_RANGE;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_RECORDS_IN_RANGE;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_RECORDS_IN_RANGE to 1"
+SET @@global.ROCKSDB_RECORDS_IN_RANGE = 1;
+SELECT @@global.ROCKSDB_RECORDS_IN_RANGE;
+@@global.ROCKSDB_RECORDS_IN_RANGE
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_RECORDS_IN_RANGE = DEFAULT;
+SELECT @@global.ROCKSDB_RECORDS_IN_RANGE;
+@@global.ROCKSDB_RECORDS_IN_RANGE
+0
+"Trying to set variable @@global.ROCKSDB_RECORDS_IN_RANGE to 0"
+SET @@global.ROCKSDB_RECORDS_IN_RANGE = 0;
+SELECT @@global.ROCKSDB_RECORDS_IN_RANGE;
+@@global.ROCKSDB_RECORDS_IN_RANGE
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_RECORDS_IN_RANGE = DEFAULT;
+SELECT @@global.ROCKSDB_RECORDS_IN_RANGE;
+@@global.ROCKSDB_RECORDS_IN_RANGE
+0
+"Trying to set variable @@global.ROCKSDB_RECORDS_IN_RANGE to 222333"
+SET @@global.ROCKSDB_RECORDS_IN_RANGE = 222333;
+SELECT @@global.ROCKSDB_RECORDS_IN_RANGE;
+@@global.ROCKSDB_RECORDS_IN_RANGE
+222333
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_RECORDS_IN_RANGE = DEFAULT;
+SELECT @@global.ROCKSDB_RECORDS_IN_RANGE;
+@@global.ROCKSDB_RECORDS_IN_RANGE
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_RECORDS_IN_RANGE to 1"
+SET @@session.ROCKSDB_RECORDS_IN_RANGE = 1;
+SELECT @@session.ROCKSDB_RECORDS_IN_RANGE;
+@@session.ROCKSDB_RECORDS_IN_RANGE
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_RECORDS_IN_RANGE = DEFAULT;
+SELECT @@session.ROCKSDB_RECORDS_IN_RANGE;
+@@session.ROCKSDB_RECORDS_IN_RANGE
+0
+"Trying to set variable @@session.ROCKSDB_RECORDS_IN_RANGE to 0"
+SET @@session.ROCKSDB_RECORDS_IN_RANGE = 0;
+SELECT @@session.ROCKSDB_RECORDS_IN_RANGE;
+@@session.ROCKSDB_RECORDS_IN_RANGE
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_RECORDS_IN_RANGE = DEFAULT;
+SELECT @@session.ROCKSDB_RECORDS_IN_RANGE;
+@@session.ROCKSDB_RECORDS_IN_RANGE
+0
+"Trying to set variable @@session.ROCKSDB_RECORDS_IN_RANGE to 222333"
+SET @@session.ROCKSDB_RECORDS_IN_RANGE = 222333;
+SELECT @@session.ROCKSDB_RECORDS_IN_RANGE;
+@@session.ROCKSDB_RECORDS_IN_RANGE
+222333
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_RECORDS_IN_RANGE = DEFAULT;
+SELECT @@session.ROCKSDB_RECORDS_IN_RANGE;
+@@session.ROCKSDB_RECORDS_IN_RANGE
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_RECORDS_IN_RANGE to 'aaa'"
+SET @@global.ROCKSDB_RECORDS_IN_RANGE = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_RECORDS_IN_RANGE;
+@@global.ROCKSDB_RECORDS_IN_RANGE
+0
+"Trying to set variable @@global.ROCKSDB_RECORDS_IN_RANGE to 'bbb'"
+SET @@global.ROCKSDB_RECORDS_IN_RANGE = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_RECORDS_IN_RANGE;
+@@global.ROCKSDB_RECORDS_IN_RANGE
+0
+SET @@global.ROCKSDB_RECORDS_IN_RANGE = @start_global_value;
+SELECT @@global.ROCKSDB_RECORDS_IN_RANGE;
+@@global.ROCKSDB_RECORDS_IN_RANGE
+0
+SET @@session.ROCKSDB_RECORDS_IN_RANGE = @start_session_value;
+SELECT @@session.ROCKSDB_RECORDS_IN_RANGE;
+@@session.ROCKSDB_RECORDS_IN_RANGE
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_remove_mariabackup_checkpoint_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_remove_mariabackup_checkpoint_basic.result
new file mode 100644
index 00000000..01145cd2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_remove_mariabackup_checkpoint_basic.result
@@ -0,0 +1,4 @@
+SET GLOBAL rocksdb_create_checkpoint=CONCAT(@@rocksdb_datadir,'/mariabackup-checkpoint');
+SET GLOBAL rocksdb_remove_mariabackup_checkpoint=ON;
+SET GLOBAL rocksdb_create_checkpoint=CONCAT(@@rocksdb_datadir,'/mariabackup-checkpoint');
+SET GLOBAL rocksdb_remove_mariabackup_checkpoint=ON;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_reset_stats_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_reset_stats_basic.result
new file mode 100644
index 00000000..d585e734
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_reset_stats_basic.result
@@ -0,0 +1,97 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+INSERT INTO valid_values VALUES('true');
+INSERT INTO valid_values VALUES('false');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_RESET_STATS;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_RESET_STATS to 1"
+SET @@global.ROCKSDB_RESET_STATS = 1;
+SELECT @@global.ROCKSDB_RESET_STATS;
+@@global.ROCKSDB_RESET_STATS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_RESET_STATS = DEFAULT;
+SELECT @@global.ROCKSDB_RESET_STATS;
+@@global.ROCKSDB_RESET_STATS
+0
+"Trying to set variable @@global.ROCKSDB_RESET_STATS to 0"
+SET @@global.ROCKSDB_RESET_STATS = 0;
+SELECT @@global.ROCKSDB_RESET_STATS;
+@@global.ROCKSDB_RESET_STATS
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_RESET_STATS = DEFAULT;
+SELECT @@global.ROCKSDB_RESET_STATS;
+@@global.ROCKSDB_RESET_STATS
+0
+"Trying to set variable @@global.ROCKSDB_RESET_STATS to on"
+SET @@global.ROCKSDB_RESET_STATS = on;
+SELECT @@global.ROCKSDB_RESET_STATS;
+@@global.ROCKSDB_RESET_STATS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_RESET_STATS = DEFAULT;
+SELECT @@global.ROCKSDB_RESET_STATS;
+@@global.ROCKSDB_RESET_STATS
+0
+"Trying to set variable @@global.ROCKSDB_RESET_STATS to off"
+SET @@global.ROCKSDB_RESET_STATS = off;
+SELECT @@global.ROCKSDB_RESET_STATS;
+@@global.ROCKSDB_RESET_STATS
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_RESET_STATS = DEFAULT;
+SELECT @@global.ROCKSDB_RESET_STATS;
+@@global.ROCKSDB_RESET_STATS
+0
+"Trying to set variable @@global.ROCKSDB_RESET_STATS to true"
+SET @@global.ROCKSDB_RESET_STATS = true;
+SELECT @@global.ROCKSDB_RESET_STATS;
+@@global.ROCKSDB_RESET_STATS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_RESET_STATS = DEFAULT;
+SELECT @@global.ROCKSDB_RESET_STATS;
+@@global.ROCKSDB_RESET_STATS
+0
+"Trying to set variable @@global.ROCKSDB_RESET_STATS to false"
+SET @@global.ROCKSDB_RESET_STATS = false;
+SELECT @@global.ROCKSDB_RESET_STATS;
+@@global.ROCKSDB_RESET_STATS
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_RESET_STATS = DEFAULT;
+SELECT @@global.ROCKSDB_RESET_STATS;
+@@global.ROCKSDB_RESET_STATS
+0
+"Trying to set variable @@session.ROCKSDB_RESET_STATS to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_RESET_STATS = 444;
+ERROR HY000: Variable 'rocksdb_reset_stats' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_RESET_STATS to 'aaa'"
+SET @@global.ROCKSDB_RESET_STATS = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_RESET_STATS;
+@@global.ROCKSDB_RESET_STATS
+0
+"Trying to set variable @@global.ROCKSDB_RESET_STATS to 'bbb'"
+SET @@global.ROCKSDB_RESET_STATS = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_RESET_STATS;
+@@global.ROCKSDB_RESET_STATS
+0
+SET @@global.ROCKSDB_RESET_STATS = @start_global_value;
+SELECT @@global.ROCKSDB_RESET_STATS;
+@@global.ROCKSDB_RESET_STATS
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_rollback_on_timeout_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_rollback_on_timeout_basic.result
new file mode 100644
index 00000000..e51df4f6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_rollback_on_timeout_basic.result
@@ -0,0 +1,97 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+INSERT INTO valid_values VALUES('true');
+INSERT INTO valid_values VALUES('false');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT to 1"
+SET @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT = 1;
+SELECT @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+@@global.ROCKSDB_ROLLBACK_ON_TIMEOUT
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT = DEFAULT;
+SELECT @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+@@global.ROCKSDB_ROLLBACK_ON_TIMEOUT
+0
+"Trying to set variable @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT to 0"
+SET @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT = 0;
+SELECT @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+@@global.ROCKSDB_ROLLBACK_ON_TIMEOUT
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT = DEFAULT;
+SELECT @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+@@global.ROCKSDB_ROLLBACK_ON_TIMEOUT
+0
+"Trying to set variable @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT to on"
+SET @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT = on;
+SELECT @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+@@global.ROCKSDB_ROLLBACK_ON_TIMEOUT
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT = DEFAULT;
+SELECT @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+@@global.ROCKSDB_ROLLBACK_ON_TIMEOUT
+0
+"Trying to set variable @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT to off"
+SET @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT = off;
+SELECT @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+@@global.ROCKSDB_ROLLBACK_ON_TIMEOUT
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT = DEFAULT;
+SELECT @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+@@global.ROCKSDB_ROLLBACK_ON_TIMEOUT
+0
+"Trying to set variable @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT to true"
+SET @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT = true;
+SELECT @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+@@global.ROCKSDB_ROLLBACK_ON_TIMEOUT
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT = DEFAULT;
+SELECT @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+@@global.ROCKSDB_ROLLBACK_ON_TIMEOUT
+0
+"Trying to set variable @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT to false"
+SET @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT = false;
+SELECT @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+@@global.ROCKSDB_ROLLBACK_ON_TIMEOUT
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT = DEFAULT;
+SELECT @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+@@global.ROCKSDB_ROLLBACK_ON_TIMEOUT
+0
+"Trying to set variable @@session.ROCKSDB_ROLLBACK_ON_TIMEOUT to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_ROLLBACK_ON_TIMEOUT = 444;
+ERROR HY000: Variable 'rocksdb_rollback_on_timeout' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT to 'aaa'"
+SET @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+@@global.ROCKSDB_ROLLBACK_ON_TIMEOUT
+0
+"Trying to set variable @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT to 'bbb'"
+SET @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+@@global.ROCKSDB_ROLLBACK_ON_TIMEOUT
+0
+SET @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT = @start_global_value;
+SELECT @@global.ROCKSDB_ROLLBACK_ON_TIMEOUT;
+@@global.ROCKSDB_ROLLBACK_ON_TIMEOUT
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_seconds_between_stat_computes_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_seconds_between_stat_computes_basic.result
new file mode 100644
index 00000000..ea80d88f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_seconds_between_stat_computes_basic.result
@@ -0,0 +1,64 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES;
+SELECT @start_global_value;
+@start_global_value
+3600
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES to 1"
+SET @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES = 1;
+SELECT @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES;
+@@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES = DEFAULT;
+SELECT @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES;
+@@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES
+3600
+"Trying to set variable @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES to 0"
+SET @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES = 0;
+SELECT @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES;
+@@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES = DEFAULT;
+SELECT @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES;
+@@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES
+3600
+"Trying to set variable @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES to 1024"
+SET @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES = 1024;
+SELECT @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES;
+@@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES
+1024
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES = DEFAULT;
+SELECT @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES;
+@@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES
+3600
+"Trying to set variable @@session.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES = 444;
+ERROR HY000: Variable 'rocksdb_seconds_between_stat_computes' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES to 'aaa'"
+SET @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES;
+@@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES
+3600
+"Trying to set variable @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES to 'bbb'"
+SET @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES;
+@@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES
+3600
+SET @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES = @start_global_value;
+SELECT @@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES;
+@@global.ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES
+3600
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_signal_drop_index_thread_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_signal_drop_index_thread_basic.result
new file mode 100644
index 00000000..94a15275
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_signal_drop_index_thread_basic.result
@@ -0,0 +1,64 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD to 1"
+SET @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD = 1;
+SELECT @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD;
+@@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD = DEFAULT;
+SELECT @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD;
+@@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD
+0
+"Trying to set variable @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD to 0"
+SET @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD = 0;
+SELECT @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD;
+@@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD = DEFAULT;
+SELECT @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD;
+@@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD
+0
+"Trying to set variable @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD to on"
+SET @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD = on;
+SELECT @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD;
+@@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD = DEFAULT;
+SELECT @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD;
+@@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD
+0
+"Trying to set variable @@session.ROCKSDB_SIGNAL_DROP_INDEX_THREAD to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_SIGNAL_DROP_INDEX_THREAD = 444;
+ERROR HY000: Variable 'rocksdb_signal_drop_index_thread' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD to 'aaa'"
+SET @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD;
+@@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD
+0
+"Trying to set variable @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD to 'bbb'"
+SET @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD;
+@@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD
+0
+SET @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD = @start_global_value;
+SELECT @@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD;
+@@global.ROCKSDB_SIGNAL_DROP_INDEX_THREAD
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_sim_cache_size_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_sim_cache_size_basic.result
new file mode 100644
index 00000000..ef4c6194
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_sim_cache_size_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_SIM_CACHE_SIZE;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_SIM_CACHE_SIZE to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_SIM_CACHE_SIZE = 444;
+ERROR HY000: Variable 'rocksdb_sim_cache_size' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_skip_bloom_filter_on_read_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_skip_bloom_filter_on_read_basic.result
new file mode 100644
index 00000000..201bc500
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_skip_bloom_filter_on_read_basic.result
@@ -0,0 +1,100 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ to 1"
+SET @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = 1;
+SELECT @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = DEFAULT;
+SELECT @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+0
+"Trying to set variable @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ to 0"
+SET @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = 0;
+SELECT @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = DEFAULT;
+SELECT @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+0
+"Trying to set variable @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ to on"
+SET @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = on;
+SELECT @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = DEFAULT;
+SELECT @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ to 1"
+SET @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = 1;
+SELECT @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = DEFAULT;
+SELECT @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+0
+"Trying to set variable @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ to 0"
+SET @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = 0;
+SELECT @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = DEFAULT;
+SELECT @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+0
+"Trying to set variable @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ to on"
+SET @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = on;
+SELECT @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = DEFAULT;
+SELECT @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ to 'aaa'"
+SET @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+0
+"Trying to set variable @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ to 'bbb'"
+SET @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+0
+SET @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = @start_global_value;
+SELECT @@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@global.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+0
+SET @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ = @start_session_value;
+SELECT @@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ;
+@@session.ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_skip_fill_cache_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_skip_fill_cache_basic.result
new file mode 100644
index 00000000..a843851c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_skip_fill_cache_basic.result
@@ -0,0 +1,100 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_SKIP_FILL_CACHE;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_SKIP_FILL_CACHE;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_SKIP_FILL_CACHE to 1"
+SET @@global.ROCKSDB_SKIP_FILL_CACHE = 1;
+SELECT @@global.ROCKSDB_SKIP_FILL_CACHE;
+@@global.ROCKSDB_SKIP_FILL_CACHE
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SKIP_FILL_CACHE = DEFAULT;
+SELECT @@global.ROCKSDB_SKIP_FILL_CACHE;
+@@global.ROCKSDB_SKIP_FILL_CACHE
+0
+"Trying to set variable @@global.ROCKSDB_SKIP_FILL_CACHE to 0"
+SET @@global.ROCKSDB_SKIP_FILL_CACHE = 0;
+SELECT @@global.ROCKSDB_SKIP_FILL_CACHE;
+@@global.ROCKSDB_SKIP_FILL_CACHE
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SKIP_FILL_CACHE = DEFAULT;
+SELECT @@global.ROCKSDB_SKIP_FILL_CACHE;
+@@global.ROCKSDB_SKIP_FILL_CACHE
+0
+"Trying to set variable @@global.ROCKSDB_SKIP_FILL_CACHE to on"
+SET @@global.ROCKSDB_SKIP_FILL_CACHE = on;
+SELECT @@global.ROCKSDB_SKIP_FILL_CACHE;
+@@global.ROCKSDB_SKIP_FILL_CACHE
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SKIP_FILL_CACHE = DEFAULT;
+SELECT @@global.ROCKSDB_SKIP_FILL_CACHE;
+@@global.ROCKSDB_SKIP_FILL_CACHE
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_SKIP_FILL_CACHE to 1"
+SET @@session.ROCKSDB_SKIP_FILL_CACHE = 1;
+SELECT @@session.ROCKSDB_SKIP_FILL_CACHE;
+@@session.ROCKSDB_SKIP_FILL_CACHE
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_SKIP_FILL_CACHE = DEFAULT;
+SELECT @@session.ROCKSDB_SKIP_FILL_CACHE;
+@@session.ROCKSDB_SKIP_FILL_CACHE
+0
+"Trying to set variable @@session.ROCKSDB_SKIP_FILL_CACHE to 0"
+SET @@session.ROCKSDB_SKIP_FILL_CACHE = 0;
+SELECT @@session.ROCKSDB_SKIP_FILL_CACHE;
+@@session.ROCKSDB_SKIP_FILL_CACHE
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_SKIP_FILL_CACHE = DEFAULT;
+SELECT @@session.ROCKSDB_SKIP_FILL_CACHE;
+@@session.ROCKSDB_SKIP_FILL_CACHE
+0
+"Trying to set variable @@session.ROCKSDB_SKIP_FILL_CACHE to on"
+SET @@session.ROCKSDB_SKIP_FILL_CACHE = on;
+SELECT @@session.ROCKSDB_SKIP_FILL_CACHE;
+@@session.ROCKSDB_SKIP_FILL_CACHE
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_SKIP_FILL_CACHE = DEFAULT;
+SELECT @@session.ROCKSDB_SKIP_FILL_CACHE;
+@@session.ROCKSDB_SKIP_FILL_CACHE
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_SKIP_FILL_CACHE to 'aaa'"
+SET @@global.ROCKSDB_SKIP_FILL_CACHE = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_SKIP_FILL_CACHE;
+@@global.ROCKSDB_SKIP_FILL_CACHE
+0
+"Trying to set variable @@global.ROCKSDB_SKIP_FILL_CACHE to 'bbb'"
+SET @@global.ROCKSDB_SKIP_FILL_CACHE = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_SKIP_FILL_CACHE;
+@@global.ROCKSDB_SKIP_FILL_CACHE
+0
+SET @@global.ROCKSDB_SKIP_FILL_CACHE = @start_global_value;
+SELECT @@global.ROCKSDB_SKIP_FILL_CACHE;
+@@global.ROCKSDB_SKIP_FILL_CACHE
+0
+SET @@session.ROCKSDB_SKIP_FILL_CACHE = @start_session_value;
+SELECT @@session.ROCKSDB_SKIP_FILL_CACHE;
+@@session.ROCKSDB_SKIP_FILL_CACHE
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_skip_unique_check_tables_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_skip_unique_check_tables_basic.result
new file mode 100644
index 00000000..a3749b75
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_skip_unique_check_tables_basic.result
@@ -0,0 +1,67 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES("aaa");
+INSERT INTO valid_values VALUES("bbb");
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+SET @start_global_value = @@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES;
+SELECT @start_global_value;
+@start_global_value
+.*
+SET @start_session_value = @@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES;
+SELECT @start_session_value;
+@start_session_value
+.*
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES to aaa"
+SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES = aaa;
+SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES;
+@@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES
+aaa
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES = DEFAULT;
+SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES;
+@@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES
+.*
+"Trying to set variable @@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES to bbb"
+SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES = bbb;
+SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES;
+@@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES
+bbb
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES = DEFAULT;
+SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES;
+@@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES
+.*
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES to aaa"
+SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES = aaa;
+SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES;
+@@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES
+aaa
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES = DEFAULT;
+SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES;
+@@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES
+.*
+"Trying to set variable @@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES to bbb"
+SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES = bbb;
+SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES;
+@@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES
+bbb
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES = DEFAULT;
+SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES;
+@@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES
+.*
+'# Testing with invalid values in global scope #'
+SET @@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES = @start_global_value;
+SELECT @@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES;
+@@global.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES
+.*
+SET @@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES = @start_session_value;
+SELECT @@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES;
+@@session.ROCKSDB_SKIP_UNIQUE_CHECK_TABLES
+.*
+SET GLOBAL ROCKSDB_SKIP_UNIQUE_CHECK_TABLES=NULL;
+SET GLOBAL ROCKSDB_SKIP_UNIQUE_CHECK_TABLES=DEFAULT;
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_sst_mgr_rate_bytes_per_sec_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_sst_mgr_rate_bytes_per_sec_basic.result
new file mode 100644
index 00000000..a714f1c2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_sst_mgr_rate_bytes_per_sec_basic.result
@@ -0,0 +1,85 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+SET @start_global_value = @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC to 100"
+SET @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC = 100;
+SELECT @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC;
+@@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC
+100
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC = DEFAULT;
+SELECT @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC;
+@@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC
+0
+"Trying to set variable @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC to 1"
+SET @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC = 1;
+SELECT @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC;
+@@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC = DEFAULT;
+SELECT @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC;
+@@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC
+0
+"Trying to set variable @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC to 0"
+SET @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC = 0;
+SELECT @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC;
+@@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC = DEFAULT;
+SELECT @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC;
+@@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC
+0
+"Trying to set variable @@session.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC = 444;
+ERROR HY000: Variable 'rocksdb_sst_mgr_rate_bytes_per_sec' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC to 'aaa'"
+SET @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC;
+@@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC
+0
+"Trying to set variable @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC to 'bbb'"
+SET @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC;
+@@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC
+0
+"Trying to set variable @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC to '-1'"
+SET @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC = '-1';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC;
+@@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC
+0
+"Trying to set variable @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC to '101'"
+SET @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC = '101';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC;
+@@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC
+0
+"Trying to set variable @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC to '484436'"
+SET @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC = '484436';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC;
+@@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC
+0
+SET @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC = @start_global_value;
+SELECT @@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC;
+@@global.ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_stats_dump_period_sec_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_stats_dump_period_sec_basic.result
new file mode 100644
index 00000000..2dbf5a55
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_stats_dump_period_sec_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_STATS_DUMP_PERIOD_SEC;
+SELECT @start_global_value;
+@start_global_value
+600
+"Trying to set variable @@global.ROCKSDB_STATS_DUMP_PERIOD_SEC to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_STATS_DUMP_PERIOD_SEC = 444;
+ERROR HY000: Variable 'rocksdb_stats_dump_period_sec' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_stats_level_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_stats_level_basic.result
new file mode 100644
index 00000000..d8d218fe
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_stats_level_basic.result
@@ -0,0 +1,85 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(4);
+INSERT INTO valid_values VALUES(2);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+SET @start_global_value = @@global.ROCKSDB_STATS_LEVEL;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_STATS_LEVEL to 0"
+SET @@global.ROCKSDB_STATS_LEVEL = 0;
+SELECT @@global.ROCKSDB_STATS_LEVEL;
+@@global.ROCKSDB_STATS_LEVEL
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_STATS_LEVEL = DEFAULT;
+SELECT @@global.ROCKSDB_STATS_LEVEL;
+@@global.ROCKSDB_STATS_LEVEL
+0
+"Trying to set variable @@global.ROCKSDB_STATS_LEVEL to 4"
+SET @@global.ROCKSDB_STATS_LEVEL = 4;
+SELECT @@global.ROCKSDB_STATS_LEVEL;
+@@global.ROCKSDB_STATS_LEVEL
+4
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_STATS_LEVEL = DEFAULT;
+SELECT @@global.ROCKSDB_STATS_LEVEL;
+@@global.ROCKSDB_STATS_LEVEL
+0
+"Trying to set variable @@global.ROCKSDB_STATS_LEVEL to 2"
+SET @@global.ROCKSDB_STATS_LEVEL = 2;
+SELECT @@global.ROCKSDB_STATS_LEVEL;
+@@global.ROCKSDB_STATS_LEVEL
+2
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_STATS_LEVEL = DEFAULT;
+SELECT @@global.ROCKSDB_STATS_LEVEL;
+@@global.ROCKSDB_STATS_LEVEL
+0
+"Trying to set variable @@session.ROCKSDB_STATS_LEVEL to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_STATS_LEVEL = 444;
+ERROR HY000: Variable 'rocksdb_stats_level' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_STATS_LEVEL to 'aaa'"
+SET @@global.ROCKSDB_STATS_LEVEL = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_STATS_LEVEL;
+@@global.ROCKSDB_STATS_LEVEL
+0
+"Trying to set variable @@global.ROCKSDB_STATS_LEVEL to 'bbb'"
+SET @@global.ROCKSDB_STATS_LEVEL = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_STATS_LEVEL;
+@@global.ROCKSDB_STATS_LEVEL
+0
+"Trying to set variable @@global.ROCKSDB_STATS_LEVEL to '-1'"
+SET @@global.ROCKSDB_STATS_LEVEL = '-1';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_STATS_LEVEL;
+@@global.ROCKSDB_STATS_LEVEL
+0
+"Trying to set variable @@global.ROCKSDB_STATS_LEVEL to '101'"
+SET @@global.ROCKSDB_STATS_LEVEL = '101';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_STATS_LEVEL;
+@@global.ROCKSDB_STATS_LEVEL
+0
+"Trying to set variable @@global.ROCKSDB_STATS_LEVEL to '484436'"
+SET @@global.ROCKSDB_STATS_LEVEL = '484436';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_STATS_LEVEL;
+@@global.ROCKSDB_STATS_LEVEL
+0
+SET @@global.ROCKSDB_STATS_LEVEL = @start_global_value;
+SELECT @@global.ROCKSDB_STATS_LEVEL;
+@@global.ROCKSDB_STATS_LEVEL
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_stats_recalc_rate_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_stats_recalc_rate_basic.result
new file mode 100644
index 00000000..4f337b84
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_stats_recalc_rate_basic.result
@@ -0,0 +1,53 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(1);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'123\'');
+SET @start_global_value = @@global.ROCKSDB_STATS_RECALC_RATE;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_STATS_RECALC_RATE to 100"
+SET @@global.ROCKSDB_STATS_RECALC_RATE = 100;
+SELECT @@global.ROCKSDB_STATS_RECALC_RATE;
+@@global.ROCKSDB_STATS_RECALC_RATE
+100
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_STATS_RECALC_RATE = DEFAULT;
+SELECT @@global.ROCKSDB_STATS_RECALC_RATE;
+@@global.ROCKSDB_STATS_RECALC_RATE
+0
+"Trying to set variable @@global.ROCKSDB_STATS_RECALC_RATE to 1"
+SET @@global.ROCKSDB_STATS_RECALC_RATE = 1;
+SELECT @@global.ROCKSDB_STATS_RECALC_RATE;
+@@global.ROCKSDB_STATS_RECALC_RATE
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_STATS_RECALC_RATE = DEFAULT;
+SELECT @@global.ROCKSDB_STATS_RECALC_RATE;
+@@global.ROCKSDB_STATS_RECALC_RATE
+0
+"Trying to set variable @@session.ROCKSDB_STATS_RECALC_RATE to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_STATS_RECALC_RATE = 444;
+ERROR HY000: Variable 'rocksdb_stats_recalc_rate' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_STATS_RECALC_RATE to 'aaa'"
+SET @@global.ROCKSDB_STATS_RECALC_RATE = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_STATS_RECALC_RATE;
+@@global.ROCKSDB_STATS_RECALC_RATE
+0
+"Trying to set variable @@global.ROCKSDB_STATS_RECALC_RATE to '123'"
+SET @@global.ROCKSDB_STATS_RECALC_RATE = '123';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_STATS_RECALC_RATE;
+@@global.ROCKSDB_STATS_RECALC_RATE
+0
+SET @@global.ROCKSDB_STATS_RECALC_RATE = @start_global_value;
+SELECT @@global.ROCKSDB_STATS_RECALC_RATE;
+@@global.ROCKSDB_STATS_RECALC_RATE
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_store_row_debug_checksums_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_store_row_debug_checksums_basic.result
new file mode 100644
index 00000000..a838d660
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_store_row_debug_checksums_basic.result
@@ -0,0 +1,100 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS to 1"
+SET @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = 1;
+SELECT @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = DEFAULT;
+SELECT @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+0
+"Trying to set variable @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS to 0"
+SET @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = 0;
+SELECT @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = DEFAULT;
+SELECT @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+0
+"Trying to set variable @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS to on"
+SET @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = on;
+SELECT @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = DEFAULT;
+SELECT @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS to 1"
+SET @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = 1;
+SELECT @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = DEFAULT;
+SELECT @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+0
+"Trying to set variable @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS to 0"
+SET @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = 0;
+SELECT @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = DEFAULT;
+SELECT @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+0
+"Trying to set variable @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS to on"
+SET @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = on;
+SELECT @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = DEFAULT;
+SELECT @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS to 'aaa'"
+SET @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+0
+"Trying to set variable @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS to 'bbb'"
+SET @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+0
+SET @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = @start_global_value;
+SELECT @@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+0
+SET @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS = @start_session_value;
+SELECT @@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS;
+@@session.ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_strict_collation_check_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_strict_collation_check_basic.result
new file mode 100644
index 00000000..46d238d1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_strict_collation_check_basic.result
@@ -0,0 +1,75 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_STRICT_COLLATION_CHECK;
+SELECT @start_global_value;
+@start_global_value
+1
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_STRICT_COLLATION_CHECK to 1"
+SET @@global.ROCKSDB_STRICT_COLLATION_CHECK = 1;
+SELECT @@global.ROCKSDB_STRICT_COLLATION_CHECK;
+@@global.ROCKSDB_STRICT_COLLATION_CHECK
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_STRICT_COLLATION_CHECK = DEFAULT;
+SELECT @@global.ROCKSDB_STRICT_COLLATION_CHECK;
+@@global.ROCKSDB_STRICT_COLLATION_CHECK
+1
+"Trying to set variable @@global.ROCKSDB_STRICT_COLLATION_CHECK to 0"
+SET @@global.ROCKSDB_STRICT_COLLATION_CHECK = 0;
+SELECT @@global.ROCKSDB_STRICT_COLLATION_CHECK;
+@@global.ROCKSDB_STRICT_COLLATION_CHECK
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_STRICT_COLLATION_CHECK = DEFAULT;
+SELECT @@global.ROCKSDB_STRICT_COLLATION_CHECK;
+@@global.ROCKSDB_STRICT_COLLATION_CHECK
+1
+"Trying to set variable @@global.ROCKSDB_STRICT_COLLATION_CHECK to on"
+SET @@global.ROCKSDB_STRICT_COLLATION_CHECK = on;
+SELECT @@global.ROCKSDB_STRICT_COLLATION_CHECK;
+@@global.ROCKSDB_STRICT_COLLATION_CHECK
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_STRICT_COLLATION_CHECK = DEFAULT;
+SELECT @@global.ROCKSDB_STRICT_COLLATION_CHECK;
+@@global.ROCKSDB_STRICT_COLLATION_CHECK
+1
+"Trying to set variable @@global.ROCKSDB_STRICT_COLLATION_CHECK to off"
+SET @@global.ROCKSDB_STRICT_COLLATION_CHECK = off;
+SELECT @@global.ROCKSDB_STRICT_COLLATION_CHECK;
+@@global.ROCKSDB_STRICT_COLLATION_CHECK
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_STRICT_COLLATION_CHECK = DEFAULT;
+SELECT @@global.ROCKSDB_STRICT_COLLATION_CHECK;
+@@global.ROCKSDB_STRICT_COLLATION_CHECK
+1
+"Trying to set variable @@session.ROCKSDB_STRICT_COLLATION_CHECK to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_STRICT_COLLATION_CHECK = 444;
+ERROR HY000: Variable 'rocksdb_strict_collation_check' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_STRICT_COLLATION_CHECK to 'aaa'"
+SET @@global.ROCKSDB_STRICT_COLLATION_CHECK = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_STRICT_COLLATION_CHECK;
+@@global.ROCKSDB_STRICT_COLLATION_CHECK
+1
+"Trying to set variable @@global.ROCKSDB_STRICT_COLLATION_CHECK to 'bbb'"
+SET @@global.ROCKSDB_STRICT_COLLATION_CHECK = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_STRICT_COLLATION_CHECK;
+@@global.ROCKSDB_STRICT_COLLATION_CHECK
+1
+SET @@global.ROCKSDB_STRICT_COLLATION_CHECK = @start_global_value;
+SELECT @@global.ROCKSDB_STRICT_COLLATION_CHECK;
+@@global.ROCKSDB_STRICT_COLLATION_CHECK
+1
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_strict_collation_exceptions_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_strict_collation_exceptions_basic.result
new file mode 100644
index 00000000..5f748621
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_strict_collation_exceptions_basic.result
@@ -0,0 +1,36 @@
+SET @start_global_value = @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS;
+SELECT @start_global_value;
+@start_global_value
+
+"Trying to set @session.ROCKSDB_STRICT_COLLATION_EXCEPTIONS to simple table name."
+SET @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS = mytable;
+SELECT @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS;
+@@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS
+mytable
+"Trying to set @session.ROCKSDB_STRICT_COLLATION_EXCEPTIONS to regex table name(s)."
+SET @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS = "t.*";
+SELECT @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS;
+@@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS
+t.*
+"Trying to set @session.ROCKSDB_STRICT_COLLATION_EXCEPTIONS to multiple regex table names."
+SET @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS = "s.*,t.*";
+SELECT @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS;
+@@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS
+s.*,t.*
+"Trying to set @session.ROCKSDB_STRICT_COLLATION_EXCEPTIONS to empty."
+SET @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS = "";
+SELECT @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS;
+@@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS
+
+"Trying to set @session.ROCKSDB_STRICT_COLLATION_EXCEPTIONS to default."
+SET @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS = DEFAULT;
+SELECT @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS;
+@@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS
+
+"Trying to set @session.ROCKSDB_STRICT_COLLATION_EXCEPTIONS to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_STRICT_COLLATION_EXCEPTIONS = 444;
+ERROR HY000: Variable 'rocksdb_strict_collation_exceptions' is a GLOBAL variable and should be set with SET GLOBAL
+SET @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS = @start_global_value;
+SELECT @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS;
+@@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_supported_compression_types_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_supported_compression_types_basic.result
new file mode 100644
index 00000000..aa77d739
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_supported_compression_types_basic.result
@@ -0,0 +1,4 @@
+SET @start_global_value = @@global.ROCKSDB_SUPPORTED_COMPRESSION_TYPES;
+"Trying to set variable @@global.ROCKSDB_SUPPORTED_COMPRESSION_TYPES to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_SUPPORTED_COMPRESSION_TYPES = 444;
+ERROR HY000: Variable 'rocksdb_supported_compression_types' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_table_cache_numshardbits_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_table_cache_numshardbits_basic.result
new file mode 100644
index 00000000..0161a339
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_table_cache_numshardbits_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_TABLE_CACHE_NUMSHARDBITS;
+SELECT @start_global_value;
+@start_global_value
+6
+"Trying to set variable @@global.ROCKSDB_TABLE_CACHE_NUMSHARDBITS to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_TABLE_CACHE_NUMSHARDBITS = 444;
+ERROR HY000: Variable 'rocksdb_table_cache_numshardbits' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_table_stats_sampling_pct_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_table_stats_sampling_pct_basic.result
new file mode 100644
index 00000000..6ff47ab9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_table_stats_sampling_pct_basic.result
@@ -0,0 +1,85 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+SET @start_global_value = @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT;
+SELECT @start_global_value;
+@start_global_value
+10
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT to 100"
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = 100;
+SELECT @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT;
+@@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT
+100
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = DEFAULT;
+SELECT @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT;
+@@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT
+10
+"Trying to set variable @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT to 1"
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = 1;
+SELECT @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT;
+@@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = DEFAULT;
+SELECT @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT;
+@@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT
+10
+"Trying to set variable @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT to 0"
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = 0;
+SELECT @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT;
+@@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = DEFAULT;
+SELECT @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT;
+@@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT
+10
+"Trying to set variable @@session.ROCKSDB_TABLE_STATS_SAMPLING_PCT to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_TABLE_STATS_SAMPLING_PCT = 444;
+ERROR HY000: Variable 'rocksdb_table_stats_sampling_pct' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT to 'aaa'"
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT;
+@@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT
+10
+"Trying to set variable @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT to 'bbb'"
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT;
+@@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT
+10
+"Trying to set variable @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT to '-1'"
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = '-1';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT;
+@@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT
+10
+"Trying to set variable @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT to '101'"
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = '101';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT;
+@@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT
+10
+"Trying to set variable @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT to '484436'"
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = '484436';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT;
+@@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT
+10
+SET @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT = @start_global_value;
+SELECT @@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT;
+@@global.ROCKSDB_TABLE_STATS_SAMPLING_PCT
+10
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_tmpdir_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_tmpdir_basic.result
new file mode 100644
index 00000000..25b19ee5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_tmpdir_basic.result
@@ -0,0 +1,29 @@
+SET @start_global_value = @@global.rocksdb_tmpdir;
+SELECT @start_global_value;
+@start_global_value
+
+select @@session.rocksdb_tmpdir;
+@@session.rocksdb_tmpdir
+
+show global variables like 'rocksdb_tmpdir';
+Variable_name Value
+rocksdb_tmpdir
+show session variables like 'rocksdb_tmpdir';
+Variable_name Value
+rocksdb_tmpdir
+select * from information_schema.global_variables where variable_name='rocksdb_tmpdir';
+VARIABLE_NAME VARIABLE_VALUE
+ROCKSDB_TMPDIR
+select * from information_schema.session_variables where variable_name='rocksdb_tmpdir';
+VARIABLE_NAME VARIABLE_VALUE
+ROCKSDB_TMPDIR
+set global rocksdb_tmpdir='value';
+set session rocksdb_tmpdir='value';
+set global rocksdb_tmpdir=1.1;
+ERROR 42000: Incorrect argument type to variable 'rocksdb_tmpdir'
+set global rocksdb_tmpdir=1e1;
+ERROR 42000: Incorrect argument type to variable 'rocksdb_tmpdir'
+SET @@global.rocksdb_tmpdir = @start_global_value;
+SELECT @@global.rocksdb_tmpdir;
+@@global.rocksdb_tmpdir
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_trace_sst_api_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_trace_sst_api_basic.result
new file mode 100644
index 00000000..d4ffde80
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_trace_sst_api_basic.result
@@ -0,0 +1,100 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_TRACE_SST_API;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_TRACE_SST_API;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_TRACE_SST_API to 1"
+SET @@global.ROCKSDB_TRACE_SST_API = 1;
+SELECT @@global.ROCKSDB_TRACE_SST_API;
+@@global.ROCKSDB_TRACE_SST_API
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_TRACE_SST_API = DEFAULT;
+SELECT @@global.ROCKSDB_TRACE_SST_API;
+@@global.ROCKSDB_TRACE_SST_API
+0
+"Trying to set variable @@global.ROCKSDB_TRACE_SST_API to 0"
+SET @@global.ROCKSDB_TRACE_SST_API = 0;
+SELECT @@global.ROCKSDB_TRACE_SST_API;
+@@global.ROCKSDB_TRACE_SST_API
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_TRACE_SST_API = DEFAULT;
+SELECT @@global.ROCKSDB_TRACE_SST_API;
+@@global.ROCKSDB_TRACE_SST_API
+0
+"Trying to set variable @@global.ROCKSDB_TRACE_SST_API to on"
+SET @@global.ROCKSDB_TRACE_SST_API = on;
+SELECT @@global.ROCKSDB_TRACE_SST_API;
+@@global.ROCKSDB_TRACE_SST_API
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_TRACE_SST_API = DEFAULT;
+SELECT @@global.ROCKSDB_TRACE_SST_API;
+@@global.ROCKSDB_TRACE_SST_API
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_TRACE_SST_API to 1"
+SET @@session.ROCKSDB_TRACE_SST_API = 1;
+SELECT @@session.ROCKSDB_TRACE_SST_API;
+@@session.ROCKSDB_TRACE_SST_API
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_TRACE_SST_API = DEFAULT;
+SELECT @@session.ROCKSDB_TRACE_SST_API;
+@@session.ROCKSDB_TRACE_SST_API
+0
+"Trying to set variable @@session.ROCKSDB_TRACE_SST_API to 0"
+SET @@session.ROCKSDB_TRACE_SST_API = 0;
+SELECT @@session.ROCKSDB_TRACE_SST_API;
+@@session.ROCKSDB_TRACE_SST_API
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_TRACE_SST_API = DEFAULT;
+SELECT @@session.ROCKSDB_TRACE_SST_API;
+@@session.ROCKSDB_TRACE_SST_API
+0
+"Trying to set variable @@session.ROCKSDB_TRACE_SST_API to on"
+SET @@session.ROCKSDB_TRACE_SST_API = on;
+SELECT @@session.ROCKSDB_TRACE_SST_API;
+@@session.ROCKSDB_TRACE_SST_API
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_TRACE_SST_API = DEFAULT;
+SELECT @@session.ROCKSDB_TRACE_SST_API;
+@@session.ROCKSDB_TRACE_SST_API
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_TRACE_SST_API to 'aaa'"
+SET @@global.ROCKSDB_TRACE_SST_API = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_TRACE_SST_API;
+@@global.ROCKSDB_TRACE_SST_API
+0
+"Trying to set variable @@global.ROCKSDB_TRACE_SST_API to 'bbb'"
+SET @@global.ROCKSDB_TRACE_SST_API = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_TRACE_SST_API;
+@@global.ROCKSDB_TRACE_SST_API
+0
+SET @@global.ROCKSDB_TRACE_SST_API = @start_global_value;
+SELECT @@global.ROCKSDB_TRACE_SST_API;
+@@global.ROCKSDB_TRACE_SST_API
+0
+SET @@session.ROCKSDB_TRACE_SST_API = @start_session_value;
+SELECT @@session.ROCKSDB_TRACE_SST_API;
+@@session.ROCKSDB_TRACE_SST_API
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_two_write_queues_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_two_write_queues_basic.result
new file mode 100644
index 00000000..5a19016b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_two_write_queues_basic.result
@@ -0,0 +1,14 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_TWO_WRITE_QUEUES;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_TWO_WRITE_QUEUES to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_TWO_WRITE_QUEUES = 444;
+ERROR HY000: Variable 'rocksdb_two_write_queues' is a read only variable
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_unsafe_for_binlog_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_unsafe_for_binlog_basic.result
new file mode 100644
index 00000000..c9748cc6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_unsafe_for_binlog_basic.result
@@ -0,0 +1,100 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_UNSAFE_FOR_BINLOG;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_UNSAFE_FOR_BINLOG;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_UNSAFE_FOR_BINLOG to 1"
+SET @@global.ROCKSDB_UNSAFE_FOR_BINLOG = 1;
+SELECT @@global.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@global.ROCKSDB_UNSAFE_FOR_BINLOG
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_UNSAFE_FOR_BINLOG = DEFAULT;
+SELECT @@global.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@global.ROCKSDB_UNSAFE_FOR_BINLOG
+0
+"Trying to set variable @@global.ROCKSDB_UNSAFE_FOR_BINLOG to 0"
+SET @@global.ROCKSDB_UNSAFE_FOR_BINLOG = 0;
+SELECT @@global.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@global.ROCKSDB_UNSAFE_FOR_BINLOG
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_UNSAFE_FOR_BINLOG = DEFAULT;
+SELECT @@global.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@global.ROCKSDB_UNSAFE_FOR_BINLOG
+0
+"Trying to set variable @@global.ROCKSDB_UNSAFE_FOR_BINLOG to on"
+SET @@global.ROCKSDB_UNSAFE_FOR_BINLOG = on;
+SELECT @@global.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@global.ROCKSDB_UNSAFE_FOR_BINLOG
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_UNSAFE_FOR_BINLOG = DEFAULT;
+SELECT @@global.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@global.ROCKSDB_UNSAFE_FOR_BINLOG
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_UNSAFE_FOR_BINLOG to 1"
+SET @@session.ROCKSDB_UNSAFE_FOR_BINLOG = 1;
+SELECT @@session.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@session.ROCKSDB_UNSAFE_FOR_BINLOG
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_UNSAFE_FOR_BINLOG = DEFAULT;
+SELECT @@session.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@session.ROCKSDB_UNSAFE_FOR_BINLOG
+0
+"Trying to set variable @@session.ROCKSDB_UNSAFE_FOR_BINLOG to 0"
+SET @@session.ROCKSDB_UNSAFE_FOR_BINLOG = 0;
+SELECT @@session.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@session.ROCKSDB_UNSAFE_FOR_BINLOG
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_UNSAFE_FOR_BINLOG = DEFAULT;
+SELECT @@session.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@session.ROCKSDB_UNSAFE_FOR_BINLOG
+0
+"Trying to set variable @@session.ROCKSDB_UNSAFE_FOR_BINLOG to on"
+SET @@session.ROCKSDB_UNSAFE_FOR_BINLOG = on;
+SELECT @@session.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@session.ROCKSDB_UNSAFE_FOR_BINLOG
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_UNSAFE_FOR_BINLOG = DEFAULT;
+SELECT @@session.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@session.ROCKSDB_UNSAFE_FOR_BINLOG
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_UNSAFE_FOR_BINLOG to 'aaa'"
+SET @@global.ROCKSDB_UNSAFE_FOR_BINLOG = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@global.ROCKSDB_UNSAFE_FOR_BINLOG
+0
+"Trying to set variable @@global.ROCKSDB_UNSAFE_FOR_BINLOG to 'bbb'"
+SET @@global.ROCKSDB_UNSAFE_FOR_BINLOG = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@global.ROCKSDB_UNSAFE_FOR_BINLOG
+0
+SET @@global.ROCKSDB_UNSAFE_FOR_BINLOG = @start_global_value;
+SELECT @@global.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@global.ROCKSDB_UNSAFE_FOR_BINLOG
+0
+SET @@session.ROCKSDB_UNSAFE_FOR_BINLOG = @start_session_value;
+SELECT @@session.ROCKSDB_UNSAFE_FOR_BINLOG;
+@@session.ROCKSDB_UNSAFE_FOR_BINLOG
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_update_cf_options.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_update_cf_options.result
new file mode 100644
index 00000000..126b4cff
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_update_cf_options.result
@@ -0,0 +1,38 @@
+CREATE TABLE t1 (a INT, PRIMARY KEY (a) COMMENT 'update_cf1') ENGINE=ROCKSDB;
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS='update_cf1={write_buffer_size=8m;target_file_size_base=2m};';
+SELECT @@global.rocksdb_update_cf_options;
+@@global.rocksdb_update_cf_options
+update_cf1={write_buffer_size=8m;target_file_size_base=2m};
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=NULL;
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
+Variable_name Value
+rocksdb_update_cf_options
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=NULL;
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
+Variable_name Value
+rocksdb_update_cf_options
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS="";
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
+Variable_name Value
+rocksdb_update_cf_options
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=NULL;
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
+Variable_name Value
+rocksdb_update_cf_options
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS='update_cf1={write_buffer_size=8m;target_file_size_base=2m};';
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
+Variable_name Value
+rocksdb_update_cf_options update_cf1={write_buffer_size=8m;target_file_size_base=2m};
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS='update_cf2={write_buffer_size=8m;target_file_size_base=2m};';
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
+Variable_name Value
+rocksdb_update_cf_options update_cf2={write_buffer_size=8m;target_file_size_base=2m};
+DROP TABLE t1;
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS='update_cf1={write_buffer_size=8m;target_file_size_base=2m};';
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
+Variable_name Value
+rocksdb_update_cf_options update_cf1={write_buffer_size=8m;target_file_size_base=2m};
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=DEFAULT;
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
+Variable_name Value
+rocksdb_update_cf_options
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_update_cf_options_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_update_cf_options_basic.result
new file mode 100644
index 00000000..dcc7e1f6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_update_cf_options_basic.result
@@ -0,0 +1,126 @@
+call mtr.add_suppression("MyRocks: NULL is not a valid option for updates to column family settings.");
+call mtr.add_suppression("Invalid cf options, '=' expected *");
+call mtr.add_suppression("MyRocks: failed to parse the updated column family options = *");
+call mtr.add_suppression("Invalid cf config for default in override options *");
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note 1051 Unknown table 'test.t1'
+CREATE TABLE `t1` (
+`col1` bigint(20) NOT NULL,
+`col2` varbinary(64) NOT NULL,
+`col3` varbinary(256) NOT NULL,
+`col4` bigint(20) NOT NULL,
+`col5` mediumblob NOT NULL,
+PRIMARY KEY (`col1`,`col2`,`col3`) COMMENT 'custom_p0_cfname=cf1;custom_p1_cfname=cf2',
+UNIQUE KEY (`col2`, `col4`) COMMENT 'custom_p5_cfname=cf3'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+PARTITION BY LIST COLUMNS (`col2`) (
+PARTITION custom_p0 VALUES IN (0x12345),
+PARTITION custom_p1 VALUES IN (0x23456),
+PARTITION custom_p2 VALUES IN (0x34567),
+PARTITION custom_p3 VALUES IN (0x45678),
+PARTITION custom_p4 VALUES IN (0x56789),
+PARTITION custom_p5 VALUES IN (0x6789A),
+PARTITION custom_p6 VALUES IN (0x789AB),
+PARTITION custom_p7 VALUES IN (0x89ABC)
+);
+USE information_schema;
+SELECT @@global.rocksdb_update_cf_options;
+@@global.rocksdb_update_cf_options
+NULL
+SET @@global.rocksdb_update_cf_options = NULL;
+SELECT @@global.rocksdb_update_cf_options;
+@@global.rocksdb_update_cf_options
+NULL
+SET @@global.rocksdb_update_cf_options = NULL;
+SELECT @@global.rocksdb_update_cf_options;
+@@global.rocksdb_update_cf_options
+NULL
+SET @@global.rocksdb_update_cf_options = '';
+SELECT @@global.rocksdb_update_cf_options;
+@@global.rocksdb_update_cf_options
+
+SET @@global.rocksdb_update_cf_options = 'aaaaa';;
+ERROR 42000: Variable 'rocksdb_update_cf_options' can't be set to the value of 'aaaaa'
+SELECT @@global.rocksdb_update_cf_options;
+@@global.rocksdb_update_cf_options
+
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='default' AND OPTION_TYPE='WRITE_BUFFER_SIZE';
+CF_NAME OPTION_TYPE VALUE
+default WRITE_BUFFER_SIZE 67108864
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='default' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+CF_NAME OPTION_TYPE VALUE
+default TARGET_FILE_SIZE_BASE 67108864
+SET @@global.rocksdb_update_cf_options = 'default={write_buffer_size=8m;target_file_size_base=2m};';
+SELECT @@global.rocksdb_update_cf_options;
+@@global.rocksdb_update_cf_options
+default={write_buffer_size=8m;target_file_size_base=2m};
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='default' AND OPTION_TYPE='WRITE_BUFFER_SIZE';
+CF_NAME OPTION_TYPE VALUE
+default WRITE_BUFFER_SIZE 8388608
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='default' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+CF_NAME OPTION_TYPE VALUE
+default TARGET_FILE_SIZE_BASE 2097152
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf1' AND OPTION_TYPE='WRITE_BUFFER_SIZE';
+CF_NAME OPTION_TYPE VALUE
+cf1 WRITE_BUFFER_SIZE 67108864
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf1' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+CF_NAME OPTION_TYPE VALUE
+cf1 TARGET_FILE_SIZE_BASE 67108864
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf2' AND OPTION_TYPE='WRITE_BUFFER_SIZE';
+CF_NAME OPTION_TYPE VALUE
+cf2 WRITE_BUFFER_SIZE 67108864
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf2' AND OPTION_TYPE='MAX_BYTES_FOR_LEVEL_MULTIPLIER';
+CF_NAME OPTION_TYPE VALUE
+cf2 MAX_BYTES_FOR_LEVEL_MULTIPLIER 10.000000
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf3' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+CF_NAME OPTION_TYPE VALUE
+cf3 TARGET_FILE_SIZE_BASE 67108864
+SET @@global.rocksdb_update_cf_options = 'cf1={write_buffer_size=8m;target_file_size_base=2m};cf2={write_buffer_size=16m;max_bytes_for_level_multiplier=8};cf3={target_file_size_base=4m};';
+SELECT @@global.rocksdb_update_cf_options;
+@@global.rocksdb_update_cf_options
+cf1={write_buffer_size=8m;target_file_size_base=2m};cf2={write_buffer_size=16m;max_bytes_for_level_multiplier=8};cf3={target_file_size_base=4m};
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf1' AND OPTION_TYPE='WRITE_BUFFER_SIZE';
+CF_NAME OPTION_TYPE VALUE
+cf1 WRITE_BUFFER_SIZE 8388608
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf1' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+CF_NAME OPTION_TYPE VALUE
+cf1 TARGET_FILE_SIZE_BASE 2097152
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf2' AND OPTION_TYPE='WRITE_BUFFER_SIZE';
+CF_NAME OPTION_TYPE VALUE
+cf2 WRITE_BUFFER_SIZE 16777216
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf2' AND OPTION_TYPE='MAX_BYTES_FOR_LEVEL_MULTIPLIER';
+CF_NAME OPTION_TYPE VALUE
+cf2 MAX_BYTES_FOR_LEVEL_MULTIPLIER 8.000000
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf3' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+CF_NAME OPTION_TYPE VALUE
+cf3 TARGET_FILE_SIZE_BASE 4194304
+SET @@global.rocksdb_update_cf_options = 'cf3={target_file_size_base=24m};';
+SELECT @@global.rocksdb_update_cf_options;
+@@global.rocksdb_update_cf_options
+cf3={target_file_size_base=24m};
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf3' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+CF_NAME OPTION_TYPE VALUE
+cf3 TARGET_FILE_SIZE_BASE 25165824
+SET @@global.rocksdb_update_cf_options = 'cf1={target_file_size_base=24m};foo={max_bytes_for_level_multiplier=8};';
+SELECT @@global.rocksdb_update_cf_options;
+@@global.rocksdb_update_cf_options
+cf1={target_file_size_base=24m};foo={max_bytes_for_level_multiplier=8};
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf1' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+CF_NAME OPTION_TYPE VALUE
+cf1 TARGET_FILE_SIZE_BASE 25165824
+SET @@global.rocksdb_update_cf_options = 'default={foo=bar};';;
+ERROR 42000: Variable 'rocksdb_update_cf_options' can't be set to the value of 'default={foo=bar};'
+SELECT @@global.rocksdb_update_cf_options;
+@@global.rocksdb_update_cf_options
+cf1={target_file_size_base=24m};foo={max_bytes_for_level_multiplier=8};
+SET @@global.rocksdb_update_cf_options = 'default={write_buffer_size=67108864;target_file_size_base=67108864};';
+SET @@global.rocksdb_update_cf_options = 'cf1={write_buffer_size=67108864;target_file_size_base=67108864};';
+SET @@global.rocksdb_update_cf_options = 'cf2={write_buffer_size=67108864;target_file_size_base=67108864;max_bytes_for_level_multiplier=10.000000};';
+SET @@global.rocksdb_update_cf_options = 'cf3={write_buffer_size=67108864;target_file_size_base=67108864};';
+SET @@global.rocksdb_update_cf_options = NULL;
+SELECT @@global.rocksdb_update_cf_options;
+@@global.rocksdb_update_cf_options
+NULL
+USE test;
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_adaptive_mutex_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_adaptive_mutex_basic.result
new file mode 100644
index 00000000..ef4007c7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_adaptive_mutex_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_USE_ADAPTIVE_MUTEX;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_USE_ADAPTIVE_MUTEX to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_USE_ADAPTIVE_MUTEX = 444;
+ERROR HY000: Variable 'rocksdb_use_adaptive_mutex' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_clock_cache_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_clock_cache_basic.result
new file mode 100644
index 00000000..f23d1889
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_clock_cache_basic.result
@@ -0,0 +1,19 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+INSERT INTO valid_values VALUES('true');
+INSERT INTO valid_values VALUES('false');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_USE_CLOCK_CACHE;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_USE_CLOCK_CACHE to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_USE_CLOCK_CACHE = 444;
+ERROR HY000: Variable 'rocksdb_use_clock_cache' is a read only variable
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_direct_io_for_flush_and_compaction_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_direct_io_for_flush_and_compaction_basic.result
new file mode 100644
index 00000000..219cdb73
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_direct_io_for_flush_and_compaction_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_USE_DIRECT_IO_FOR_FLUSH_AND_COMPACTION;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_USE_DIRECT_IO_FOR_FLUSH_AND_COMPACTION to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_USE_DIRECT_IO_FOR_FLUSH_AND_COMPACTION = 444;
+ERROR HY000: Variable 'rocksdb_use_direct_io_for_flush_and_compaction' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_direct_reads_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_direct_reads_basic.result
new file mode 100644
index 00000000..ec36c309
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_direct_reads_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_USE_DIRECT_READS;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_USE_DIRECT_READS to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_USE_DIRECT_READS = 444;
+ERROR HY000: Variable 'rocksdb_use_direct_reads' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_fsync_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_fsync_basic.result
new file mode 100644
index 00000000..254cc2ce
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_use_fsync_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_USE_FSYNC;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_USE_FSYNC to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_USE_FSYNC = 444;
+ERROR HY000: Variable 'rocksdb_use_fsync' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_validate_tables_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_validate_tables_basic.result
new file mode 100644
index 00000000..c7b87487
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_validate_tables_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_VALIDATE_TABLES;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_VALIDATE_TABLES to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_VALIDATE_TABLES = 444;
+ERROR HY000: Variable 'rocksdb_validate_tables' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_verify_row_debug_checksums_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_verify_row_debug_checksums_basic.result
new file mode 100644
index 00000000..ad71c890
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_verify_row_debug_checksums_basic.result
@@ -0,0 +1,100 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS to 1"
+SET @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = 1;
+SELECT @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = DEFAULT;
+SELECT @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+0
+"Trying to set variable @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS to 0"
+SET @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = 0;
+SELECT @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = DEFAULT;
+SELECT @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+0
+"Trying to set variable @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS to on"
+SET @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = on;
+SELECT @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = DEFAULT;
+SELECT @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS to 1"
+SET @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = 1;
+SELECT @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = DEFAULT;
+SELECT @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+0
+"Trying to set variable @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS to 0"
+SET @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = 0;
+SELECT @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = DEFAULT;
+SELECT @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+0
+"Trying to set variable @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS to on"
+SET @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = on;
+SELECT @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = DEFAULT;
+SELECT @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS to 'aaa'"
+SET @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+0
+"Trying to set variable @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS to 'bbb'"
+SET @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+0
+SET @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = @start_global_value;
+SELECT @@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@global.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+0
+SET @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS = @start_session_value;
+SELECT @@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS;
+@@session.ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_bytes_per_sync_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_bytes_per_sync_basic.result
new file mode 100644
index 00000000..f432f1f7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_bytes_per_sync_basic.result
@@ -0,0 +1,85 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+SET @start_global_value = @@global.ROCKSDB_WAL_BYTES_PER_SYNC;
+SELECT @start_global_value;
+@start_global_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_WAL_BYTES_PER_SYNC to 100"
+SET @@global.ROCKSDB_WAL_BYTES_PER_SYNC = 100;
+SELECT @@global.ROCKSDB_WAL_BYTES_PER_SYNC;
+@@global.ROCKSDB_WAL_BYTES_PER_SYNC
+100
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_WAL_BYTES_PER_SYNC = DEFAULT;
+SELECT @@global.ROCKSDB_WAL_BYTES_PER_SYNC;
+@@global.ROCKSDB_WAL_BYTES_PER_SYNC
+0
+"Trying to set variable @@global.ROCKSDB_WAL_BYTES_PER_SYNC to 1"
+SET @@global.ROCKSDB_WAL_BYTES_PER_SYNC = 1;
+SELECT @@global.ROCKSDB_WAL_BYTES_PER_SYNC;
+@@global.ROCKSDB_WAL_BYTES_PER_SYNC
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_WAL_BYTES_PER_SYNC = DEFAULT;
+SELECT @@global.ROCKSDB_WAL_BYTES_PER_SYNC;
+@@global.ROCKSDB_WAL_BYTES_PER_SYNC
+0
+"Trying to set variable @@global.ROCKSDB_WAL_BYTES_PER_SYNC to 0"
+SET @@global.ROCKSDB_WAL_BYTES_PER_SYNC = 0;
+SELECT @@global.ROCKSDB_WAL_BYTES_PER_SYNC;
+@@global.ROCKSDB_WAL_BYTES_PER_SYNC
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_WAL_BYTES_PER_SYNC = DEFAULT;
+SELECT @@global.ROCKSDB_WAL_BYTES_PER_SYNC;
+@@global.ROCKSDB_WAL_BYTES_PER_SYNC
+0
+"Trying to set variable @@session.ROCKSDB_WAL_BYTES_PER_SYNC to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_WAL_BYTES_PER_SYNC = 444;
+ERROR HY000: Variable 'rocksdb_wal_bytes_per_sync' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_WAL_BYTES_PER_SYNC to 'aaa'"
+SET @@global.ROCKSDB_WAL_BYTES_PER_SYNC = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_WAL_BYTES_PER_SYNC;
+@@global.ROCKSDB_WAL_BYTES_PER_SYNC
+0
+"Trying to set variable @@global.ROCKSDB_WAL_BYTES_PER_SYNC to 'bbb'"
+SET @@global.ROCKSDB_WAL_BYTES_PER_SYNC = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_WAL_BYTES_PER_SYNC;
+@@global.ROCKSDB_WAL_BYTES_PER_SYNC
+0
+"Trying to set variable @@global.ROCKSDB_WAL_BYTES_PER_SYNC to '-1'"
+SET @@global.ROCKSDB_WAL_BYTES_PER_SYNC = '-1';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_WAL_BYTES_PER_SYNC;
+@@global.ROCKSDB_WAL_BYTES_PER_SYNC
+0
+"Trying to set variable @@global.ROCKSDB_WAL_BYTES_PER_SYNC to '101'"
+SET @@global.ROCKSDB_WAL_BYTES_PER_SYNC = '101';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_WAL_BYTES_PER_SYNC;
+@@global.ROCKSDB_WAL_BYTES_PER_SYNC
+0
+"Trying to set variable @@global.ROCKSDB_WAL_BYTES_PER_SYNC to '484436'"
+SET @@global.ROCKSDB_WAL_BYTES_PER_SYNC = '484436';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_WAL_BYTES_PER_SYNC;
+@@global.ROCKSDB_WAL_BYTES_PER_SYNC
+0
+SET @@global.ROCKSDB_WAL_BYTES_PER_SYNC = @start_global_value;
+SELECT @@global.ROCKSDB_WAL_BYTES_PER_SYNC;
+@@global.ROCKSDB_WAL_BYTES_PER_SYNC
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_dir_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_dir_basic.result
new file mode 100644
index 00000000..fd76a5ec
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_dir_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_WAL_DIR;
+SELECT @start_global_value;
+@start_global_value
+
+"Trying to set variable @@global.ROCKSDB_WAL_DIR to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_WAL_DIR = 444;
+ERROR HY000: Variable 'rocksdb_wal_dir' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_recovery_mode_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_recovery_mode_basic.result
new file mode 100644
index 00000000..9fec4a24
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_recovery_mode_basic.result
@@ -0,0 +1,46 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_WAL_RECOVERY_MODE;
+SELECT @start_global_value;
+@start_global_value
+1
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_WAL_RECOVERY_MODE to 1"
+SET @@global.ROCKSDB_WAL_RECOVERY_MODE = 1;
+SELECT @@global.ROCKSDB_WAL_RECOVERY_MODE;
+@@global.ROCKSDB_WAL_RECOVERY_MODE
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_WAL_RECOVERY_MODE = DEFAULT;
+SELECT @@global.ROCKSDB_WAL_RECOVERY_MODE;
+@@global.ROCKSDB_WAL_RECOVERY_MODE
+1
+"Trying to set variable @@global.ROCKSDB_WAL_RECOVERY_MODE to 0"
+SET @@global.ROCKSDB_WAL_RECOVERY_MODE = 0;
+SELECT @@global.ROCKSDB_WAL_RECOVERY_MODE;
+@@global.ROCKSDB_WAL_RECOVERY_MODE
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_WAL_RECOVERY_MODE = DEFAULT;
+SELECT @@global.ROCKSDB_WAL_RECOVERY_MODE;
+@@global.ROCKSDB_WAL_RECOVERY_MODE
+1
+"Trying to set variable @@session.ROCKSDB_WAL_RECOVERY_MODE to 444. It should fail because it is not session."
+SET @@session.ROCKSDB_WAL_RECOVERY_MODE = 444;
+ERROR HY000: Variable 'rocksdb_wal_recovery_mode' is a GLOBAL variable and should be set with SET GLOBAL
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_WAL_RECOVERY_MODE to 'aaa'"
+SET @@global.ROCKSDB_WAL_RECOVERY_MODE = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_WAL_RECOVERY_MODE;
+@@global.ROCKSDB_WAL_RECOVERY_MODE
+1
+SET @@global.ROCKSDB_WAL_RECOVERY_MODE = @start_global_value;
+SELECT @@global.ROCKSDB_WAL_RECOVERY_MODE;
+@@global.ROCKSDB_WAL_RECOVERY_MODE
+1
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_size_limit_mb_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_size_limit_mb_basic.result
new file mode 100644
index 00000000..5f03597d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_size_limit_mb_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_WAL_SIZE_LIMIT_MB;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_WAL_SIZE_LIMIT_MB to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_WAL_SIZE_LIMIT_MB = 444;
+ERROR HY000: Variable 'rocksdb_wal_size_limit_mb' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_ttl_seconds_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_ttl_seconds_basic.result
new file mode 100644
index 00000000..23f7fc81
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_wal_ttl_seconds_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_WAL_TTL_SECONDS;
+SELECT @start_global_value;
+@start_global_value
+0
+"Trying to set variable @@global.ROCKSDB_WAL_TTL_SECONDS to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_WAL_TTL_SECONDS = 444;
+ERROR HY000: Variable 'rocksdb_wal_ttl_seconds' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_whole_key_filtering_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_whole_key_filtering_basic.result
new file mode 100644
index 00000000..0d6f7216
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_whole_key_filtering_basic.result
@@ -0,0 +1,7 @@
+SET @start_global_value = @@global.ROCKSDB_WHOLE_KEY_FILTERING;
+SELECT @start_global_value;
+@start_global_value
+1
+"Trying to set variable @@global.ROCKSDB_WHOLE_KEY_FILTERING to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_WHOLE_KEY_FILTERING = 444;
+ERROR HY000: Variable 'rocksdb_whole_key_filtering' is a read only variable
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_batch_max_bytes_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_batch_max_bytes_basic.result
new file mode 100644
index 00000000..8f6d91b2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_batch_max_bytes_basic.result
@@ -0,0 +1,15 @@
+create table t (i int);
+insert into t values (1), (2), (3), (4), (5);
+set session rocksdb_write_batch_max_bytes = 1000;
+insert into t values (1), (2), (3), (4), (5);
+set session rocksdb_write_batch_max_bytes = 10;
+insert into t values (1), (2), (3), (4), (5);
+ERROR HY000: Got error 10 'Operation aborted: Memory limit reached' from ROCKSDB
+set session rocksdb_write_batch_max_bytes = 0;
+insert into t values (1), (2), (3), (4), (5);
+set session rocksdb_write_batch_max_bytes = 10;
+begin;
+insert into t values (1), (2), (3), (4), (5);
+ERROR HY000: Got error 10 'Operation aborted: Memory limit reached' from ROCKSDB
+rollback;
+drop table t;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_disable_wal_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_disable_wal_basic.result
new file mode 100644
index 00000000..b71ee7f9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_disable_wal_basic.result
@@ -0,0 +1,114 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_WRITE_DISABLE_WAL;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_WRITE_DISABLE_WAL;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_WRITE_DISABLE_WAL to 1"
+SET @@global.ROCKSDB_WRITE_DISABLE_WAL = 1;
+SELECT @@global.ROCKSDB_WRITE_DISABLE_WAL;
+@@global.ROCKSDB_WRITE_DISABLE_WAL
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_WRITE_DISABLE_WAL = DEFAULT;
+SELECT @@global.ROCKSDB_WRITE_DISABLE_WAL;
+@@global.ROCKSDB_WRITE_DISABLE_WAL
+0
+"Trying to set variable @@global.ROCKSDB_WRITE_DISABLE_WAL to 0"
+SET @@global.ROCKSDB_WRITE_DISABLE_WAL = 0;
+SELECT @@global.ROCKSDB_WRITE_DISABLE_WAL;
+@@global.ROCKSDB_WRITE_DISABLE_WAL
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_WRITE_DISABLE_WAL = DEFAULT;
+SELECT @@global.ROCKSDB_WRITE_DISABLE_WAL;
+@@global.ROCKSDB_WRITE_DISABLE_WAL
+0
+"Trying to set variable @@global.ROCKSDB_WRITE_DISABLE_WAL to on"
+SET @@global.ROCKSDB_WRITE_DISABLE_WAL = on;
+SELECT @@global.ROCKSDB_WRITE_DISABLE_WAL;
+@@global.ROCKSDB_WRITE_DISABLE_WAL
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_WRITE_DISABLE_WAL = DEFAULT;
+SELECT @@global.ROCKSDB_WRITE_DISABLE_WAL;
+@@global.ROCKSDB_WRITE_DISABLE_WAL
+0
+"Trying to set variable @@global.ROCKSDB_WRITE_DISABLE_WAL to off"
+SET @@global.ROCKSDB_WRITE_DISABLE_WAL = off;
+SELECT @@global.ROCKSDB_WRITE_DISABLE_WAL;
+@@global.ROCKSDB_WRITE_DISABLE_WAL
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_WRITE_DISABLE_WAL = DEFAULT;
+SELECT @@global.ROCKSDB_WRITE_DISABLE_WAL;
+@@global.ROCKSDB_WRITE_DISABLE_WAL
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_WRITE_DISABLE_WAL to 1"
+SET @@session.ROCKSDB_WRITE_DISABLE_WAL = 1;
+SELECT @@session.ROCKSDB_WRITE_DISABLE_WAL;
+@@session.ROCKSDB_WRITE_DISABLE_WAL
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_WRITE_DISABLE_WAL = DEFAULT;
+SELECT @@session.ROCKSDB_WRITE_DISABLE_WAL;
+@@session.ROCKSDB_WRITE_DISABLE_WAL
+0
+"Trying to set variable @@session.ROCKSDB_WRITE_DISABLE_WAL to 0"
+SET @@session.ROCKSDB_WRITE_DISABLE_WAL = 0;
+SELECT @@session.ROCKSDB_WRITE_DISABLE_WAL;
+@@session.ROCKSDB_WRITE_DISABLE_WAL
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_WRITE_DISABLE_WAL = DEFAULT;
+SELECT @@session.ROCKSDB_WRITE_DISABLE_WAL;
+@@session.ROCKSDB_WRITE_DISABLE_WAL
+0
+"Trying to set variable @@session.ROCKSDB_WRITE_DISABLE_WAL to on"
+SET @@session.ROCKSDB_WRITE_DISABLE_WAL = on;
+SELECT @@session.ROCKSDB_WRITE_DISABLE_WAL;
+@@session.ROCKSDB_WRITE_DISABLE_WAL
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_WRITE_DISABLE_WAL = DEFAULT;
+SELECT @@session.ROCKSDB_WRITE_DISABLE_WAL;
+@@session.ROCKSDB_WRITE_DISABLE_WAL
+0
+"Trying to set variable @@session.ROCKSDB_WRITE_DISABLE_WAL to off"
+SET @@session.ROCKSDB_WRITE_DISABLE_WAL = off;
+SELECT @@session.ROCKSDB_WRITE_DISABLE_WAL;
+@@session.ROCKSDB_WRITE_DISABLE_WAL
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_WRITE_DISABLE_WAL = DEFAULT;
+SELECT @@session.ROCKSDB_WRITE_DISABLE_WAL;
+@@session.ROCKSDB_WRITE_DISABLE_WAL
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_WRITE_DISABLE_WAL to 'aaa'"
+SET @@global.ROCKSDB_WRITE_DISABLE_WAL = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_WRITE_DISABLE_WAL;
+@@global.ROCKSDB_WRITE_DISABLE_WAL
+0
+SET @@global.ROCKSDB_WRITE_DISABLE_WAL = @start_global_value;
+SELECT @@global.ROCKSDB_WRITE_DISABLE_WAL;
+@@global.ROCKSDB_WRITE_DISABLE_WAL
+0
+SET @@session.ROCKSDB_WRITE_DISABLE_WAL = @start_session_value;
+SELECT @@session.ROCKSDB_WRITE_DISABLE_WAL;
+@@session.ROCKSDB_WRITE_DISABLE_WAL
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_ignore_missing_column_families_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_ignore_missing_column_families_basic.result
new file mode 100644
index 00000000..dbe46858
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_ignore_missing_column_families_basic.result
@@ -0,0 +1,100 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+SET @start_global_value = @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+SELECT @start_global_value;
+@start_global_value
+0
+SET @start_session_value = @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+SELECT @start_session_value;
+@start_session_value
+0
+'# Setting to valid values in global scope#'
+"Trying to set variable @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES to 1"
+SET @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = 1;
+SELECT @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = DEFAULT;
+SELECT @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+0
+"Trying to set variable @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES to 0"
+SET @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = 0;
+SELECT @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+0
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = DEFAULT;
+SELECT @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+0
+"Trying to set variable @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES to on"
+SET @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = on;
+SELECT @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+1
+"Setting the global scope variable back to default"
+SET @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = DEFAULT;
+SELECT @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+0
+'# Setting to valid values in session scope#'
+"Trying to set variable @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES to 1"
+SET @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = 1;
+SELECT @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = DEFAULT;
+SELECT @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+0
+"Trying to set variable @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES to 0"
+SET @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = 0;
+SELECT @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+0
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = DEFAULT;
+SELECT @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+0
+"Trying to set variable @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES to on"
+SET @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = on;
+SELECT @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+1
+"Setting the session scope variable back to default"
+SET @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = DEFAULT;
+SELECT @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+0
+'# Testing with invalid values in global scope #'
+"Trying to set variable @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES to 'aaa'"
+SET @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = 'aaa';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+0
+"Trying to set variable @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES to 'bbb'"
+SET @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = 'bbb';
+Got one of the listed errors
+SELECT @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+0
+SET @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = @start_global_value;
+SELECT @@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@global.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+0
+SET @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES = @start_session_value;
+SELECT @@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES;
+@@session.ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+0
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_policy_basic.result b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_policy_basic.result
new file mode 100644
index 00000000..58e040e0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/r/rocksdb_write_policy_basic.result
@@ -0,0 +1,15 @@
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES("write_committed");
+INSERT INTO valid_values VALUES("write_prepared");
+INSERT INTO valid_values VALUES("write_unprepared");
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+SET @start_global_value = @@global.ROCKSDB_WRITE_POLICY;
+SELECT @start_global_value;
+@start_global_value
+write_committed
+"Trying to set variable @@global.ROCKSDB_WRITE_POLICY to 444. It should fail because it is readonly."
+SET @@global.ROCKSDB_WRITE_POLICY = 444;
+ERROR HY000: Variable 'rocksdb_write_policy' is a read only variable
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/suite.opt b/storage/rocksdb/mysql-test/rocksdb_sys_vars/suite.opt
new file mode 100644
index 00000000..f6640ca5
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/suite.opt
@@ -0,0 +1 @@
+--ignore-db-dirs=#rocksdb --plugin-load=$HA_ROCKSDB_SO
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/suite.pm b/storage/rocksdb/mysql-test/rocksdb_sys_vars/suite.pm
new file mode 100644
index 00000000..5264d657
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/suite.pm
@@ -0,0 +1,21 @@
+package My::Suite::Rocksdb_sys_vars;
+
+#
+# Note: The below is copied from ../rocksdb/suite.pm
+#
+@ISA = qw(My::Suite);
+use My::Find;
+use File::Basename;
+use strict;
+
+#sub is_default { not $::opt_embedded_server }
+
+my $sst_dump=
+::mtr_exe_maybe_exists(
+ "$::bindir/storage/rocksdb$::opt_vs_config/sst_dump",
+ "$::path_client_bindir/sst_dump");
+return "RocksDB is not compiled, no sst_dump" unless $sst_dump;
+$ENV{MARIAROCKS_SST_DUMP}="$sst_dump";
+
+bless { };
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/all_vars.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/all_vars.test
new file mode 100644
index 00000000..7943d3e4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/all_vars.test
@@ -0,0 +1,39 @@
+--source include/have_rocksdb.inc
+--source include/not_embedded.inc
+
+# This test verifies that *all* MyRocks system variables are tested by the
+# rocksdb_sys_vars suite. For every MyRocks system variable there must be a
+# <variable_name>_basic.test file.
+#
+
+#
+# we can diff in perl or in sql, as it's my_SQL_test suite, do it in sql
+#
+
+perl;
+ use File::Basename;
+ my $dirname=dirname($ENV{MYSQLTEST_FILE});
+ my @all_tests=<$dirname/*_basic{,_32,_64}.test>;
+ open(F, '>', "$ENV{MYSQLTEST_VARDIR}/tmp/rocksdb_sys_vars.all_vars.txt") or die;
+ binmode F;
+ print F join "\n", sort map { s/_basic(_32|_64)?\.test$//; basename $_ } @all_tests;
+EOF
+
+create table t1 (test_name text) engine=MyISAM;
+create table t2 (variable_name text) engine=MyISAM;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval load data infile "$MYSQLTEST_VARDIR/tmp/rocksdb_sys_vars.all_vars.txt" into table t1;
+
+insert into t2 select variable_name from information_schema.global_variables where variable_name like "rocksdb_%";
+insert into t2 select variable_name from information_schema.session_variables where variable_name like "rocksdb_%";
+
+--sorted_result
+select variable_name as `There should be *no* long test name listed below:` from t2
+ where length(variable_name) > 50;
+
+--sorted_result
+select variable_name as `There should be *no* variables listed below:` from t2
+ left join t1 on variable_name=test_name where test_name is null ORDER BY variable_name;
+
+drop table t1;
+drop table t2;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/disabled.def
new file mode 100644
index 00000000..efa82ff6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/disabled.def
@@ -0,0 +1,5 @@
+# Disabled tests
+
+rocksdb_read_free_rpl_basic : MariaDB: Read-Free replication is not supported
+rocksdb_read_free_rpl_tables_basic : MariaDB: Read-Free replication is not supported
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_access_hint_on_compaction_start_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_access_hint_on_compaction_start_basic.test
new file mode 100644
index 00000000..51765574
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_access_hint_on_compaction_start_basic.test
@@ -0,0 +1,7 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_ACCESS_HINT_ON_COMPACTION_START
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_advise_random_on_open_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_advise_random_on_open_basic.test
new file mode 100644
index 00000000..06593363
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_advise_random_on_open_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_ADVISE_RANDOM_ON_OPEN
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_concurrent_memtable_write_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_concurrent_memtable_write_basic.test
new file mode 100644
index 00000000..5d4e3c05
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_concurrent_memtable_write_basic.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+--let $sys_var=ROCKSDB_ALLOW_CONCURRENT_MEMTABLE_WRITE
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_mmap_reads_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_mmap_reads_basic.test
new file mode 100644
index 00000000..72fed6b2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_mmap_reads_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_ALLOW_MMAP_READS
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_mmap_writes_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_mmap_writes_basic.test
new file mode 100644
index 00000000..8b8da14f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_mmap_writes_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_ALLOW_MMAP_WRITES
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_to_start_after_corruption_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_to_start_after_corruption_basic.test
new file mode 100644
index 00000000..64fb2458
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_allow_to_start_after_corruption_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_ALLOW_TO_START_AFTER_CORRUPTION
+--let $read_only=1
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_blind_delete_primary_key_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_blind_delete_primary_key_basic.test
new file mode 100644
index 00000000..da972ccc
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_blind_delete_primary_key_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_BLIND_DELETE_PRIMARY_KEY
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_cache_size_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_cache_size_basic.test
new file mode 100644
index 00000000..8d3bab4e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_cache_size_basic.test
@@ -0,0 +1,21 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(65536);
+INSERT INTO valid_values VALUES(1024);
+INSERT INTO valid_values VALUES(1*1024*1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+
+--let $sys_var=ROCKSDB_BLOCK_CACHE_SIZE
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_restart_interval_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_restart_interval_basic.test
new file mode 100644
index 00000000..0688ef73
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_restart_interval_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_BLOCK_RESTART_INTERVAL
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_size_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_size_basic.test
new file mode 100644
index 00000000..150c1e53
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_size_basic.test
@@ -0,0 +1,7 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_BLOCK_SIZE
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_size_deviation_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_size_deviation_basic.test
new file mode 100644
index 00000000..98d179c0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_block_size_deviation_basic.test
@@ -0,0 +1,7 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_BLOCK_SIZE_DEVIATION
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_allow_sk_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_allow_sk_basic.test
new file mode 100644
index 00000000..14e5f38b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_allow_sk_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_BULK_LOAD_ALLOW_SK
+--let $read_only=0
+--let $session=1
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_allow_unsorted_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_allow_unsorted_basic.test
new file mode 100644
index 00000000..e57396e0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_allow_unsorted_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_BULK_LOAD_ALLOW_UNSORTED
+--let $read_only=0
+--let $session=1
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_basic.test
new file mode 100644
index 00000000..dd55c849
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_BULK_LOAD
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_size_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_size_basic.test
new file mode 100644
index 00000000..70d1c448
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bulk_load_size_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_BULK_LOAD_SIZE
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bytes_per_sync_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bytes_per_sync_basic.test
new file mode 100644
index 00000000..bf78f578
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_bytes_per_sync_basic.test
@@ -0,0 +1,22 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+
+--let $sys_var=ROCKSDB_BYTES_PER_SYNC
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_dump_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_dump_basic.test
new file mode 100644
index 00000000..70557621
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_dump_basic.test
@@ -0,0 +1,21 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+INSERT INTO valid_values VALUES('true');
+INSERT INTO valid_values VALUES('false');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_CACHE_DUMP
+--let $read_only=1
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_high_pri_pool_ratio_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_high_pri_pool_ratio_basic.test
new file mode 100644
index 00000000..d97c4e20
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_high_pri_pool_ratio_basic.test
@@ -0,0 +1,24 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1.0);
+INSERT INTO valid_values VALUES(0.0);
+INSERT INTO valid_values VALUES(0.5);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES(2.0);
+INSERT INTO invalid_values VALUES(-0.5);
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+INSERT INTO invalid_values VALUES('\'0.5\'');
+
+--let $sys_var=ROCKSDB_CACHE_HIGH_PRI_POOL_RATIO
+--let $read_only=1
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_index_and_filter_blocks_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_index_and_filter_blocks_basic.test
new file mode 100644
index 00000000..27d0aa99
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_index_and_filter_blocks_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_CACHE_INDEX_AND_FILTER_BLOCKS
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_index_and_filter_with_high_priority_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_index_and_filter_with_high_priority_basic.test
new file mode 100644
index 00000000..5ed7927f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_cache_index_and_filter_with_high_priority_basic.test
@@ -0,0 +1,21 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+INSERT INTO valid_values VALUES('true');
+INSERT INTO valid_values VALUES('false');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_CACHE_INDEX_AND_FILTER_WITH_HIGH_PRIORITY
+--let $read_only=1
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_checksums_pct_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_checksums_pct_basic.test
new file mode 100644
index 00000000..b595cb62
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_checksums_pct_basic.test
@@ -0,0 +1,17 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(99);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_CHECKSUMS_PCT
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_collect_sst_properties_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_collect_sst_properties_basic.test
new file mode 100644
index 00000000..9c0e111d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_collect_sst_properties_basic.test
@@ -0,0 +1,8 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_COLLECT_SST_PROPERTIES
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_commit_in_the_middle_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_commit_in_the_middle_basic.test
new file mode 100644
index 00000000..ec860cfc
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_commit_in_the_middle_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_COMMIT_IN_THE_MIDDLE
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_commit_time_batch_for_recovery_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_commit_time_batch_for_recovery_basic.test
new file mode 100644
index 00000000..0d36e0a1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_commit_time_batch_for_recovery_basic.test
@@ -0,0 +1,20 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255));
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+
+CREATE TABLE invalid_values (value varchar(255));
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_COMMIT_TIME_BATCH_FOR_RECOVERY
+--let $read_only=0
+--let $session=1
+--let $sticky=1
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compact_cf_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compact_cf_basic.test
new file mode 100644
index 00000000..736f6754
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compact_cf_basic.test
@@ -0,0 +1,19 @@
+
+call mtr.add_suppression(" Column family '[a-z]*' not found.");
+
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES('abc');
+INSERT INTO valid_values VALUES('def');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+
+--let $sys_var=ROCKSDB_COMPACT_CF
+--let $read_only=0
+--let $session=0
+--let $sticky=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_readahead_size_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_readahead_size_basic.test
new file mode 100644
index 00000000..c0651a3a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_readahead_size_basic.test
@@ -0,0 +1,23 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(222333);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+# Attempt to set the value to -1 - this should first truncate to 0 and then generate a warning as
+# we can't set it to or from 0
+SET @@global.rocksdb_compaction_readahead_size = -1;
+SELECT @@global.rocksdb_compaction_readahead_size;
+
+--let $sys_var=ROCKSDB_COMPACTION_READAHEAD_SIZE
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_basic.test
new file mode 100644
index 00000000..24399c85
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+INSERT INTO valid_values VALUES(2000000);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'2000001\'');
+
+--let $sys_var=ROCKSDB_COMPACTION_SEQUENTIAL_DELETES
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_count_sd_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_count_sd_basic.test
new file mode 100644
index 00000000..b3a437d6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_count_sd_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_COUNT_SD
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_file_size_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_file_size_basic.test
new file mode 100644
index 00000000..aaf71179
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_file_size_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_FILE_SIZE
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_window_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_window_basic.test
new file mode 100644
index 00000000..d5be3469
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_compaction_sequential_deletes_window_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+INSERT INTO valid_values VALUES(2000000);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'2000001\'');
+
+--let $sys_var=ROCKSDB_COMPACTION_SEQUENTIAL_DELETES_WINDOW
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_create_checkpoint_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_create_checkpoint_basic.test
new file mode 100644
index 00000000..32d4a6a2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_create_checkpoint_basic.test
@@ -0,0 +1,29 @@
+--source include/have_rocksdb.inc
+
+--eval SET @start_value = @@global.ROCKSDB_CREATE_CHECKPOINT
+
+# Test using tmp/abc
+--replace_result $MYSQL_TMP_DIR TMP
+--eval SET @@global.ROCKSDB_CREATE_CHECKPOINT = '$MYSQL_TMP_DIR/abc'
+--eval SELECT @@global.ROCKSDB_CREATE_CHECKPOINT
+--eval SET @@global.ROCKSDB_CREATE_CHECKPOINT = DEFAULT
+
+# Test using tmp/def
+--replace_result $MYSQL_TMP_DIR TMP
+--eval SET @@global.ROCKSDB_CREATE_CHECKPOINT = '$MYSQL_TMP_DIR/def'
+--eval SELECT @@global.ROCKSDB_CREATE_CHECKPOINT
+--eval SET @@global.ROCKSDB_CREATE_CHECKPOINT = DEFAULT
+
+# Should fail because it is not a session
+--Error ER_GLOBAL_VARIABLE
+--eval SET @@session.ROCKSDB_CREATE_CHECKPOINT = 444
+
+# Set back to original value
+# validate that DEFAULT causes failure in creating checkpoint since
+# DEFAULT == ''
+--error ER_GET_ERRMSG
+--eval SET @@global.ROCKSDB_CREATE_CHECKPOINT = @start_value
+
+# clean up
+--exec rm -r $MYSQL_TMP_DIR/abc
+--exec rm -r $MYSQL_TMP_DIR/def
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_create_if_missing_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_create_if_missing_basic.test
new file mode 100644
index 00000000..ab92a0a0
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_create_if_missing_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_CREATE_IF_MISSING
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_create_missing_column_families_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_create_missing_column_families_basic.test
new file mode 100644
index 00000000..21c0f0ea
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_create_missing_column_families_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_CREATE_MISSING_COLUMN_FAMILIES
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_datadir_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_datadir_basic.test
new file mode 100644
index 00000000..fd3569c8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_datadir_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_DATADIR
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_db_write_buffer_size_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_db_write_buffer_size_basic.test
new file mode 100644
index 00000000..df6a2490
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_db_write_buffer_size_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_DB_WRITE_BUFFER_SIZE
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_deadlock_detect_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_deadlock_detect_basic.test
new file mode 100644
index 00000000..980be0f3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_deadlock_detect_basic.test
@@ -0,0 +1,20 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255));
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+
+CREATE TABLE invalid_values (value varchar(255));
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_DEADLOCK_DETECT
+--let $read_only=0
+--let $session=1
+--let $sticky=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_deadlock_detect_depth_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_deadlock_detect_depth_basic.test
new file mode 100644
index 00000000..cab72a11
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_deadlock_detect_depth_basic.test
@@ -0,0 +1,17 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(2);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'123\'');
+
+--let $sys_var=ROCKSDB_DEADLOCK_DETECT_DEPTH
+--let $read_only=0
+--let $session=1
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_manual_compaction_delay_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_manual_compaction_delay_basic.test
new file mode 100644
index 00000000..518c284c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_manual_compaction_delay_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(2400);
+INSERT INTO valid_values VALUES(100000);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_DEBUG_MANUAL_COMPACTION_DELAY
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_optimizer_no_zero_cardinality_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_optimizer_no_zero_cardinality_basic.test
new file mode 100644
index 00000000..41c4ae63
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_optimizer_no_zero_cardinality_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_DEBUG_OPTIMIZER_NO_ZERO_CARDINALITY
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_ignore_pk_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_ignore_pk_basic.test
new file mode 100644
index 00000000..8ad071e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_ignore_pk_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_DEBUG_TTL_IGNORE_PK
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_read_filter_ts_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_read_filter_ts_basic.test
new file mode 100644
index 00000000..c3837ff1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_read_filter_ts_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(2400);
+INSERT INTO valid_values VALUES(-2400);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_DEBUG_TTL_READ_FILTER_TS
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_rec_ts_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_rec_ts_basic.test
new file mode 100644
index 00000000..14c3e3d3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_rec_ts_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(2400);
+INSERT INTO valid_values VALUES(-2400);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_DEBUG_TTL_REC_TS
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_snapshot_ts_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_snapshot_ts_basic.test
new file mode 100644
index 00000000..af507fbe
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_debug_ttl_snapshot_ts_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(2400);
+INSERT INTO valid_values VALUES(-2400);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_DEBUG_TTL_SNAPSHOT_TS
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_default_cf_options_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_default_cf_options_basic.test
new file mode 100644
index 00000000..1febc6db
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_default_cf_options_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_DEFAULT_CF_OPTIONS
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delayed_write_rate_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delayed_write_rate_basic.test
new file mode 100644
index 00000000..8068b6b8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delayed_write_rate_basic.test
@@ -0,0 +1,22 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+
+--let $sys_var=ROCKSDB_DELAYED_WRITE_RATE
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delete_cf_basic-master.opt b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delete_cf_basic-master.opt
new file mode 100644
index 00000000..ae43ab33
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delete_cf_basic-master.opt
@@ -0,0 +1 @@
+--loose-rocksdb-dummy-option-instead-of-force-restart
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delete_cf_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delete_cf_basic.test
new file mode 100644
index 00000000..0875e492
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delete_cf_basic.test
@@ -0,0 +1,75 @@
+--disable_query_log
+call mtr.add_suppression("Failed to drop column family");
+call mtr.add_suppression("Column family '[a-z_]+' not found");
+--enable_query_log
+
+--source include/have_rocksdb.inc
+
+# should fail for not existing CF
+--error ER_WRONG_VALUE_FOR_VAR
+--eval SET @@global.ROCKSDB_DELETE_CF = 'nonexistent_cf'
+
+# should fail for default system cf
+--error ER_WRONG_VALUE_FOR_VAR
+--eval SET @@global.ROCKSDB_DELETE_CF = '__system__'
+
+# should fail for default cf
+--error ER_WRONG_VALUE_FOR_VAR
+--eval SET @@global.ROCKSDB_DELETE_CF = 'default'
+
+--disable_parsing
+# should succeed for not existing CF
+--eval SET @@global.ROCKSDB_DELETE_CF = 'nonexistent_cf'
+
+# should fail for default system cf
+--error ER_WRONG_VALUE_FOR_VAR
+--eval SET @@global.ROCKSDB_DELETE_CF = '__system__'
+
+alter table mysql.slave_worker_info engine = MyISAM;
+alter table mysql.slave_relay_log_info engine = MyISAM;
+alter table mysql.slave_gtid_info engine = MyISAM;
+alter table mysql.slave_master_info engine = MyISAM;
+
+select count(*) from information_schema.rocksdb_ddl where cf = 'default';
+
+# should fail for default cf
+--error ER_GET_ERRMSG
+--eval SET @@global.ROCKSDB_DELETE_CF = 'default'
+
+CREATE TABLE cf_deletion_test_table1 (
+ id1 int(10) unsigned NOT NULL DEFAULT '0',
+ id2 int(10) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (id1) COMMENT 'cf_primary_key',
+ KEY `sec_key` (id2) COMMENT 'cf_secondary_key'
+) ENGINE=ROCKSDB;
+
+# should fail, CFs are still in use
+--error ER_WRONG_VALUE_FOR_VAR
+--eval SET @@global.ROCKSDB_DELETE_CF = 'cf_primary_key'
+--error ER_WRONG_VALUE_FOR_VAR
+--eval SET @@global.ROCKSDB_DELETE_CF = 'cf_secondary_key'
+
+CREATE TABLE cf_deletion_test_table2 (
+ id1 int(10) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (id1) COMMENT 'cf_primary_key'
+) ENGINE=ROCKSDB;
+
+DROP TABLE cf_deletion_test_table1;
+
+# should fail, still used by second table
+--error ER_WRONG_VALUE_FOR_VAR
+--eval SET @@global.ROCKSDB_DELETE_CF = 'cf_primary_key'
+
+# should succeed, no one is using it anymore
+--eval SET @@global.ROCKSDB_DELETE_CF = 'cf_secondary_key'
+
+DROP TABLE cf_deletion_test_table2;
+
+# should succeed now
+--eval SET @@global.ROCKSDB_DELETE_CF = 'cf_primary_key'
+
+alter table mysql.slave_worker_info engine = ROCKSDB;
+alter table mysql.slave_relay_log_info engine = ROCKSDB;
+alter table mysql.slave_gtid_info engine = ROCKSDB;
+alter table mysql.slave_master_info engine = ROCKSDB;
+--enable_parsing
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delete_obsolete_files_period_micros_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delete_obsolete_files_period_micros_basic.test
new file mode 100644
index 00000000..3c2cd2db
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_delete_obsolete_files_period_micros_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_DELETE_OBSOLETE_FILES_PERIOD_MICROS
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_2pc_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_2pc_basic.test
new file mode 100644
index 00000000..0a38895c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_2pc_basic.test
@@ -0,0 +1,20 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_ENABLE_2PC
+--let $read_only=0
+--let $session=0
+--let $sticky=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_bulk_load_api_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_bulk_load_api_basic.test
new file mode 100644
index 00000000..52313ffb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_bulk_load_api_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_ENABLE_BULK_LOAD_API
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_insert_with_update_caching_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_insert_with_update_caching_basic.test
new file mode 100644
index 00000000..cd643cfe
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_insert_with_update_caching_basic.test
@@ -0,0 +1,21 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_ENABLE_INSERT_WITH_UPDATE_CACHING
+--let $read_only=0
+--let $session=0
+--let $sticky=1
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_thread_tracking_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_thread_tracking_basic.test
new file mode 100644
index 00000000..566d5656
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_thread_tracking_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_ENABLE_THREAD_TRACKING
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_ttl_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_ttl_basic.test
new file mode 100644
index 00000000..209530bd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_ttl_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_ENABLE_TTL
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_ttl_read_filtering_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_ttl_read_filtering_basic.test
new file mode 100644
index 00000000..cc034ed4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_ttl_read_filtering_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_ENABLE_TTL_READ_FILTERING
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_write_thread_adaptive_yield_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_write_thread_adaptive_yield_basic.test
new file mode 100644
index 00000000..b5c844a9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_enable_write_thread_adaptive_yield_basic.test
@@ -0,0 +1,5 @@
+--source include/have_rocksdb.inc
+--let $sys_var=ROCKSDB_ENABLE_WRITE_THREAD_ADAPTIVE_YIELD
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_error_if_exists_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_error_if_exists_basic.test
new file mode 100644
index 00000000..933642a7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_error_if_exists_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_ERROR_IF_EXISTS
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_error_on_suboptimal_collation_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_error_on_suboptimal_collation_basic.test
new file mode 100644
index 00000000..9278fa31
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_error_on_suboptimal_collation_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_ERROR_ON_SUBOPTIMAL_COLLATION
+--let $read_only=1
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_flush_log_at_trx_commit_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_flush_log_at_trx_commit_basic.test
new file mode 100644
index 00000000..02c533dc
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_flush_log_at_trx_commit_basic.test
@@ -0,0 +1,17 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(2);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_FLUSH_LOG_AT_TRX_COMMIT
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_compute_memtable_stats_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_compute_memtable_stats_basic.test
new file mode 100644
index 00000000..318ae1ee
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_compute_memtable_stats_basic.test
@@ -0,0 +1,23 @@
+--source include/have_rocksdb.inc
+--disable_warnings
+DROP TABLE IF EXISTS t;
+--enable_warnings
+
+CREATE TABLE t (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
+INSERT INTO t (a,b) VALUES (1,'bar'),(2,'foo');
+
+SET @ORIG_FORCE_COMPUTE_MEMTABLE_STATS = @@rocksdb_force_compute_memtable_stats;
+set global rocksdb_force_flush_memtable_now = true;
+
+INSERT INTO t (a,b) VALUES (3,'dead'),(4,'beef'),(5,'a'),(6,'bbb'),(7,'c'),(8,'d');
+
+set global rocksdb_force_compute_memtable_stats=0;
+SELECT TABLE_ROWS INTO @ROWS_EXCLUDE_MEMTABLE FROM information_schema.TABLES WHERE table_name = 't';
+
+set global rocksdb_force_compute_memtable_stats=1;
+SELECT TABLE_ROWS INTO @ROWS_INCLUDE_MEMTABLE FROM information_schema.TABLES WHERE table_name = 't';
+
+select case when @ROWS_INCLUDE_MEMTABLE-@ROWS_EXCLUDE_MEMTABLE > 0 then 'true' else 'false' end;
+
+DROP TABLE t;
+set global rocksdb_force_compute_memtable_stats = @ORIG_FORCE_COMPUTE_MEMTABLE_STATS;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_compute_memtable_stats_cachetime_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_compute_memtable_stats_cachetime_basic.test
new file mode 100644
index 00000000..20180ec1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_compute_memtable_stats_cachetime_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+INSERT INTO valid_values VALUES(1024 * 1024 * 1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_FORCE_COMPUTE_MEMTABLE_STATS_CACHETIME
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_flush_memtable_and_lzero_now_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_flush_memtable_and_lzero_now_basic.test
new file mode 100644
index 00000000..5eeac501
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_flush_memtable_and_lzero_now_basic.test
@@ -0,0 +1,17 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+
+--let $sys_var=ROCKSDB_FORCE_FLUSH_MEMTABLE_AND_LZERO_NOW
+--let $read_only=0
+--let $session=0
+--let $sticky=1
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_flush_memtable_now_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_flush_memtable_now_basic.test
new file mode 100644
index 00000000..4386af1e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_flush_memtable_now_basic.test
@@ -0,0 +1,17 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+
+--let $sys_var=ROCKSDB_FORCE_FLUSH_MEMTABLE_NOW
+--let $read_only=0
+--let $session=0
+--let $sticky=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_index_records_in_range_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_index_records_in_range_basic.test
new file mode 100644
index 00000000..30263ea4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_force_index_records_in_range_basic.test
@@ -0,0 +1,23 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(222333);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+# Attempt to set the value to -1 - this should first truncate to 0 and then generate a warning as
+# we can't set it to or from 0
+SET @@session.rocksdb_force_index_records_in_range = -1;
+SELECT @@session.rocksdb_force_index_records_in_range;
+
+--let $sys_var=ROCKSDB_FORCE_INDEX_RECORDS_IN_RANGE
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_git_hash_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_git_hash_basic.test
new file mode 100644
index 00000000..7b314e47
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_git_hash_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_GIT_HASH
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_hash_index_allow_collision_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_hash_index_allow_collision_basic.test
new file mode 100644
index 00000000..e787dd33
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_hash_index_allow_collision_basic.test
@@ -0,0 +1,7 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_HASH_INDEX_ALLOW_COLLISION
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_ignore_unknown_options_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_ignore_unknown_options_basic.test
new file mode 100644
index 00000000..f10ff2c6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_ignore_unknown_options_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_IGNORE_UNKNOWN_OPTIONS
+--let $read_only=1
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_index_type_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_index_type_basic.test
new file mode 100644
index 00000000..49369ffd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_index_type_basic.test
@@ -0,0 +1,7 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_INDEX_TYPE
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_info_log_level_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_info_log_level_basic.test
new file mode 100644
index 00000000..fb2ce5e7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_info_log_level_basic.test
@@ -0,0 +1,21 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES('fatal_level');
+INSERT INTO valid_values VALUES('error_level');
+INSERT INTO valid_values VALUES('warn_level');
+INSERT INTO valid_values VALUES('info_level');
+INSERT INTO valid_values VALUES('debug_level');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES(5);
+INSERT INTO invalid_values VALUES(6);
+INSERT INTO invalid_values VALUES('foo');
+
+--let $sys_var=ROCKSDB_INFO_LOG_LEVEL
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_io_write_timeout_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_io_write_timeout_basic.test
new file mode 100644
index 00000000..4433eb26
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_io_write_timeout_basic.test
@@ -0,0 +1,20 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(10);
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(42);
+INSERT INTO valid_values VALUES(142);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_IO_WRITE_TIMEOUT
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_is_fd_close_on_exec_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_is_fd_close_on_exec_basic.test
new file mode 100644
index 00000000..4d39c2a3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_is_fd_close_on_exec_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_IS_FD_CLOSE_ON_EXEC
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_keep_log_file_num_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_keep_log_file_num_basic.test
new file mode 100644
index 00000000..0eff718c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_keep_log_file_num_basic.test
@@ -0,0 +1,7 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_KEEP_LOG_FILE_NUM
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_large_prefix_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_large_prefix_basic.test
new file mode 100644
index 00000000..5ed3c741
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_large_prefix_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_LARGE_PREFIX
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_lock_scanned_rows_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_lock_scanned_rows_basic.test
new file mode 100644
index 00000000..35b4128c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_lock_scanned_rows_basic.test
@@ -0,0 +1,22 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+INSERT INTO valid_values VALUES('true');
+INSERT INTO valid_values VALUES('false');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES(2);
+INSERT INTO invalid_values VALUES(1000);
+
+--let $sys_var=ROCKSDB_LOCK_SCANNED_ROWS
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_lock_wait_timeout_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_lock_wait_timeout_basic.test
new file mode 100644
index 00000000..24096677
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_lock_wait_timeout_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_LOCK_WAIT_TIMEOUT
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_log_file_time_to_roll_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_log_file_time_to_roll_basic.test
new file mode 100644
index 00000000..63a7c5fe
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_log_file_time_to_roll_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_LOG_FILE_TIME_TO_ROLL
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_manifest_preallocation_size_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_manifest_preallocation_size_basic.test
new file mode 100644
index 00000000..6f248ece
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_manifest_preallocation_size_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_MANIFEST_PREALLOCATION_SIZE
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_manual_compaction_threads_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_manual_compaction_threads_basic.test
new file mode 100644
index 00000000..4f166a9c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_manual_compaction_threads_basic.test
@@ -0,0 +1,17 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(99);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_MANUAL_COMPACTION_THREADS
+--let $read_only=0
+--let $session=1
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_manual_wal_flush_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_manual_wal_flush_basic.test
new file mode 100644
index 00000000..3e01722d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_manual_wal_flush_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_MANUAL_WAL_FLUSH
+--let $read_only=1
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_master_skip_tx_api_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_master_skip_tx_api_basic.test
new file mode 100644
index 00000000..e0d5925c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_master_skip_tx_api_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_MASTER_SKIP_TX_API
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_background_jobs_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_background_jobs_basic.test
new file mode 100644
index 00000000..375a4fdd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_background_jobs_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(64);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'abc\'');
+
+--let $sys_var=ROCKSDB_MAX_BACKGROUND_JOBS
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_latest_deadlocks_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_latest_deadlocks_basic.test
new file mode 100644
index 00000000..9917ec31
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_latest_deadlocks_basic.test
@@ -0,0 +1,17 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(1);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'123\'');
+
+--let $sys_var=ROCKSDB_MAX_LATEST_DEADLOCKS
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_log_file_size_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_log_file_size_basic.test
new file mode 100644
index 00000000..cbe5d925
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_log_file_size_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_MAX_LOG_FILE_SIZE
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_manifest_file_size_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_manifest_file_size_basic.test
new file mode 100644
index 00000000..f399b296
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_manifest_file_size_basic.test
@@ -0,0 +1,7 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_MAX_MANIFEST_FILE_SIZE
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_manual_compactions_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_manual_compactions_basic.test
new file mode 100644
index 00000000..1c663168
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_manual_compactions_basic.test
@@ -0,0 +1,17 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+INSERT INTO valid_values VALUES(512*1024*1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_MAX_MANUAL_COMPACTIONS
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_open_files_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_open_files_basic.test
new file mode 100644
index 00000000..36996761
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_open_files_basic.test
@@ -0,0 +1,8 @@
+--source include/have_rocksdb.inc
+
+# We can not use rocksdb_sys_var.inc here as this is a global, read only option
+# whose value is dependent on the servers open_files_limit. It is more fully
+# tested in the rocksdb.max_open_files test.
+
+--replace_column 2 #
+show variables like 'rocksdb_max_open_files';
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_row_locks_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_row_locks_basic.test
new file mode 100644
index 00000000..8a26ae91
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_row_locks_basic.test
@@ -0,0 +1,17 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+INSERT INTO valid_values VALUES(512*1024*1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_MAX_ROW_LOCKS
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_subcompactions_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_subcompactions_basic.test
new file mode 100644
index 00000000..a4494dd8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_subcompactions_basic.test
@@ -0,0 +1,7 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_MAX_SUBCOMPACTIONS
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_total_wal_size_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_total_wal_size_basic.test
new file mode 100644
index 00000000..35ba859c
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_max_total_wal_size_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_MAX_TOTAL_WAL_SIZE
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_merge_buf_size_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_merge_buf_size_basic.test
new file mode 100644
index 00000000..8e2dda64
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_merge_buf_size_basic.test
@@ -0,0 +1,50 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+set session rocksdb_merge_buf_size=250;
+set session rocksdb_merge_combine_read_size=1000;
+
+CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i)) ENGINE = ROCKSDB;
+
+--disable_query_log
+let $max = 100;
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO t1 VALUES ($i, FLOOR(RAND() * 100));
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+ALTER TABLE t1 ADD INDEX kj(j), ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+
+DROP INDEX kj on t1;
+DROP INDEX kij ON t1;
+
+ALTER TABLE t1 ADD INDEX kj(j), ADD INDEX kij(i,j), ADD INDEX kji(j,i), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+# Reverse CF testing, needs to be added to SSTFileWriter in reverse order
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=RocksDB;
+--disable_query_log
+let $max = 100;
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO t1 VALUES ($i, FLOOR(RAND() * 100));
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+ALTER TABLE t1 ADD INDEX kb(b) comment 'rev:cf1', ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+SELECT COUNT(*) FROM t1 FORCE INDEX(kb);
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_merge_combine_read_size_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_merge_combine_read_size_basic.test
new file mode 100644
index 00000000..48e89137
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_merge_combine_read_size_basic.test
@@ -0,0 +1,32 @@
+--source include/have_rocksdb.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+set session rocksdb_merge_buf_size=250;
+set session rocksdb_merge_combine_read_size=1000;
+
+CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i)) ENGINE = ROCKSDB;
+
+--disable_query_log
+let $max = 100;
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO t1 VALUES ($i, $i);
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+ALTER TABLE t1 ADD INDEX kj(j), ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD INDEX kij(i,j), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+
+DROP INDEX kj on t1;
+DROP INDEX kij ON t1;
+
+ALTER TABLE t1 ADD INDEX kj(j), ADD INDEX kij(i,j), ADD INDEX kji(j,i), ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_merge_tmp_file_removal_delay_ms_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_merge_tmp_file_removal_delay_ms_basic.test
new file mode 100644
index 00000000..03cc0b11
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_merge_tmp_file_removal_delay_ms_basic.test
@@ -0,0 +1,49 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('on');
+
+--let $sys_var=ROCKSDB_MERGE_TMP_FILE_REMOVAL_DELAY_MS
+--let $read_only=0
+--let $session=1
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
+
+set session rocksdb_merge_buf_size=250;
+set session rocksdb_merge_combine_read_size=1000;
+set session rocksdb_merge_tmp_file_removal_delay_ms=1000;
+
+CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i)) ENGINE = ROCKSDB;
+
+--disable_query_log
+let $max = 100;
+let $i = 1;
+while ($i <= $max) {
+ let $insert = INSERT INTO t1 VALUES ($i, FLOOR(RAND() * 100));
+ inc $i;
+ eval $insert;
+}
+--enable_query_log
+
+let $start= `SELECT UNIX_TIMESTAMP()`;
+# this should take a lot longer than normal because each deleted merge file
+# will sleep for 1 secs. There should be about 13 buffers.
+# So it should take at least 13 secs
+ALTER TABLE t1 ADD INDEX kj(j), ALGORITHM=INPLACE;
+let $stop_exec= `SELECT UNIX_TIMESTAMP()`;
+
+let $time_diff= `SELECT ($stop_exec - $start)`;
+let $assert_text= Alter should have taken at least 10 seconds;
+let $assert_cond= $time_diff >= 10;
+source include/assert.inc;
+
+DROP TABLE t1;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_new_table_reader_for_compaction_inputs_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_new_table_reader_for_compaction_inputs_basic.test
new file mode 100644
index 00000000..1d2ea6e6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_new_table_reader_for_compaction_inputs_basic.test
@@ -0,0 +1,7 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_NEW_TABLE_READER_FOR_COMPACTION_INPUTS
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_no_block_cache_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_no_block_cache_basic.test
new file mode 100644
index 00000000..be1e3e88
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_no_block_cache_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_NO_BLOCK_CACHE
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_override_cf_options_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_override_cf_options_basic.test
new file mode 100644
index 00000000..1f4325b8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_override_cf_options_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_OVERRIDE_CF_OPTIONS
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_paranoid_checks_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_paranoid_checks_basic.test
new file mode 100644
index 00000000..5bdd9d3d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_paranoid_checks_basic.test
@@ -0,0 +1,7 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_PARANOID_CHECKS
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_pause_background_work_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_pause_background_work_basic.test
new file mode 100644
index 00000000..3f2f6bc7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_pause_background_work_basic.test
@@ -0,0 +1,20 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_PAUSE_BACKGROUND_WORK
+--let $read_only=0
+--let $session=0
+--let $sticky=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_perf_context_level_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_perf_context_level_basic.test
new file mode 100644
index 00000000..46f74578
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_perf_context_level_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(2);
+INSERT INTO valid_values VALUES(3);
+INSERT INTO valid_values VALUES(4);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_PERF_CONTEXT_LEVEL
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_persistent_cache_path_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_persistent_cache_path_basic.test
new file mode 100644
index 00000000..1a1146a1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_persistent_cache_path_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES('abc');
+INSERT INTO valid_values VALUES('def');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+
+--let $sys_var=ROCKSDB_PERSISTENT_CACHE_PATH
+--let $read_only=1
+--let $session=0
+--let $sticky=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_persistent_cache_size_mb_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_persistent_cache_size_mb_basic.test
new file mode 100644
index 00000000..7f21d96f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_persistent_cache_size_mb_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_PERSISTENT_CACHE_SIZE_MB
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_pin_l0_filter_and_index_blocks_in_cache_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_pin_l0_filter_and_index_blocks_in_cache_basic.test
new file mode 100644
index 00000000..d2513106
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_pin_l0_filter_and_index_blocks_in_cache_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_PIN_L0_FILTER_AND_INDEX_BLOCKS_IN_CACHE
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_print_snapshot_conflict_queries_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_print_snapshot_conflict_queries_basic.test
new file mode 100644
index 00000000..24d2f182
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_print_snapshot_conflict_queries_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_PRINT_SNAPSHOT_CONFLICT_QUERIES
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rate_limiter_bytes_per_sec_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rate_limiter_bytes_per_sec_basic.test
new file mode 100644
index 00000000..743f942a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rate_limiter_bytes_per_sec_basic.test
@@ -0,0 +1,63 @@
+--source include/have_rocksdb.inc
+
+# Attempt to set the value - this should generate a warning as we can't set it to or from 0
+SET @@global.rocksdb_rate_limiter_bytes_per_sec = 10000;
+
+# Now shut down and come back up with the rate limiter enabled and retest setting the variable
+
+# Write file to make mysql-test-run.pl expect the "crash", but don't restart the
+# server until it is told to
+--let $_server_id= `SELECT @@server_id`
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
+--exec echo "wait" >$_expect_file_name
+
+# Send shutdown to the connected server and give it 10 seconds to die before
+# zapping it
+shutdown_server;
+
+# Attempt to restart the server with the rate limiter on
+--exec echo "restart:--rocksdb_rate_limiter_bytes_per_sec=10000" >$_expect_file_name
+--sleep 5
+
+# Wait for reconnect
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+
+# The valid_values table lists the values that we want to make sure that the system will allow
+# us to set for rocksdb_rate_limiter_bytes_per_sec
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1), (1000), (1000000), (1000000000), (1000000000000);
+
+# The invalid_values table lists the values that we don't want to allow for the variable
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\''), (3.14);
+
+# Test all the valid and invalid values
+--let $sys_var=ROCKSDB_RATE_LIMITER_BYTES_PER_SEC
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
+
+# Zero is an invalid value if the rate limiter is turned on, but it won't be rejected by the
+# SET command but will generate a warning.
+
+# Attempt to set the value to 0 - this should generate a warning as we can't set it to or from 0
+SET @@global.rocksdb_rate_limiter_bytes_per_sec = 0;
+
+# Attempt to set the value to -1 - this should first truncate to 0 and then generate a warning as
+# we can't set it to or from 0
+SET @@global.rocksdb_rate_limiter_bytes_per_sec = -1;
+
+# Restart the server without the rate limiter
+--exec echo "wait" >$_expect_file_name
+shutdown_server;
+--exec echo "restart" >$_expect_file_name
+--sleep 5
+
+# Wait for reconnect
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_read_free_rpl_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_read_free_rpl_basic.test
new file mode 100644
index 00000000..f37f75b4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_read_free_rpl_basic.test
@@ -0,0 +1,19 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES('PK_SK');
+INSERT INTO valid_values VALUES('OFF');
+INSERT INTO valid_values VALUES('PK_ONLY');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('a');
+
+--let $sys_var=ROCKSDB_READ_FREE_RPL
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+SET GLOBAL ROCKSDB_READ_FREE_RPL=DEFAULT;
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_read_free_rpl_tables_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_read_free_rpl_tables_basic.test
new file mode 100644
index 00000000..a2c900c9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_read_free_rpl_tables_basic.test
@@ -0,0 +1,20 @@
+--source include/have_rocksdb.inc
+
+call mtr.add_suppression(".*Invalid pattern in rocksdb_read_free_rpl_tables.*");
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES('a');
+INSERT INTO valid_values VALUES('b');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'*\'');
+
+--let $sys_var=ROCKSDB_READ_FREE_RPL_TABLES
+--let $read_only=0
+--source include/rocksdb_sys_var.inc
+
+SET GLOBAL ROCKSDB_READ_FREE_RPL_TABLES=NULL;
+SET GLOBAL ROCKSDB_READ_FREE_RPL_TABLES=DEFAULT;
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_records_in_range_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_records_in_range_basic.test
new file mode 100644
index 00000000..21503475
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_records_in_range_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(222333);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_RECORDS_IN_RANGE
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_remove_mariabackup_checkpoint_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_remove_mariabackup_checkpoint_basic.test
new file mode 100644
index 00000000..30f38283
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_remove_mariabackup_checkpoint_basic.test
@@ -0,0 +1,5 @@
+# Simulate creating and removing mariabackup checkpoint twice
+SET GLOBAL rocksdb_create_checkpoint=CONCAT(@@rocksdb_datadir,'/mariabackup-checkpoint');
+SET GLOBAL rocksdb_remove_mariabackup_checkpoint=ON;
+SET GLOBAL rocksdb_create_checkpoint=CONCAT(@@rocksdb_datadir,'/mariabackup-checkpoint');
+SET GLOBAL rocksdb_remove_mariabackup_checkpoint=ON;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_reset_stats_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_reset_stats_basic.test
new file mode 100644
index 00000000..62f75a3b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_reset_stats_basic.test
@@ -0,0 +1,21 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+INSERT INTO valid_values VALUES('true');
+INSERT INTO valid_values VALUES('false');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_RESET_STATS
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rollback_on_timeout_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rollback_on_timeout_basic.test
new file mode 100644
index 00000000..793b7752
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rollback_on_timeout_basic.test
@@ -0,0 +1,21 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+INSERT INTO valid_values VALUES('true');
+INSERT INTO valid_values VALUES('false');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_ROLLBACK_ON_TIMEOUT
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_seconds_between_stat_computes_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_seconds_between_stat_computes_basic.test
new file mode 100644
index 00000000..53c2e6e6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_seconds_between_stat_computes_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_SECONDS_BETWEEN_STAT_COMPUTES
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_signal_drop_index_thread_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_signal_drop_index_thread_basic.test
new file mode 100644
index 00000000..ea90c7b7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_signal_drop_index_thread_basic.test
@@ -0,0 +1,19 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_SIGNAL_DROP_INDEX_THREAD
+--let $read_only=0
+--let $session=0
+--let $sticky=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_sim_cache_size_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_sim_cache_size_basic.test
new file mode 100644
index 00000000..a82d50e1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_sim_cache_size_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_SIM_CACHE_SIZE
+--let $read_only=1
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_skip_bloom_filter_on_read_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_skip_bloom_filter_on_read_basic.test
new file mode 100644
index 00000000..82b56e0b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_skip_bloom_filter_on_read_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_SKIP_BLOOM_FILTER_ON_READ
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_skip_fill_cache_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_skip_fill_cache_basic.test
new file mode 100644
index 00000000..cc1b608b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_skip_fill_cache_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_SKIP_FILL_CACHE
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_skip_unique_check_tables_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_skip_unique_check_tables_basic.test
new file mode 100644
index 00000000..50c2354d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_skip_unique_check_tables_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES("aaa");
+INSERT INTO valid_values VALUES("bbb");
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+
+--let $sys_var=ROCKSDB_SKIP_UNIQUE_CHECK_TABLES
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+SET GLOBAL ROCKSDB_SKIP_UNIQUE_CHECK_TABLES=NULL;
+SET GLOBAL ROCKSDB_SKIP_UNIQUE_CHECK_TABLES=DEFAULT;
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_sst_mgr_rate_bytes_per_sec_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_sst_mgr_rate_bytes_per_sec_basic.test
new file mode 100644
index 00000000..3492596d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_sst_mgr_rate_bytes_per_sec_basic.test
@@ -0,0 +1,22 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+
+--let $sys_var=ROCKSDB_SST_MGR_RATE_BYTES_PER_SEC
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_stats_dump_period_sec_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_stats_dump_period_sec_basic.test
new file mode 100644
index 00000000..2fbb0c6e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_stats_dump_period_sec_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_STATS_DUMP_PERIOD_SEC
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_stats_level_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_stats_level_basic.test
new file mode 100644
index 00000000..89b0878f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_stats_level_basic.test
@@ -0,0 +1,21 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES(4);
+INSERT INTO valid_values VALUES(2);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+
+--let $sys_var=ROCKSDB_STATS_LEVEL
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_stats_recalc_rate_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_stats_recalc_rate_basic.test
new file mode 100644
index 00000000..a3b9059b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_stats_recalc_rate_basic.test
@@ -0,0 +1,17 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(1);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'123\'');
+
+--let $sys_var=ROCKSDB_STATS_RECALC_RATE
+--let $read_only=0
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_store_row_debug_checksums_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_store_row_debug_checksums_basic.test
new file mode 100644
index 00000000..e3faca86
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_store_row_debug_checksums_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_STORE_ROW_DEBUG_CHECKSUMS
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_strict_collation_check_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_strict_collation_check_basic.test
new file mode 100644
index 00000000..17aa63b8
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_strict_collation_check_basic.test
@@ -0,0 +1,19 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_STRICT_COLLATION_CHECK
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_strict_collation_exceptions_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_strict_collation_exceptions_basic.test
new file mode 100644
index 00000000..4eb96488
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_strict_collation_exceptions_basic.test
@@ -0,0 +1,35 @@
+--source include/have_rocksdb.inc
+
+# We cannot use the rocskdb_sys_var.inc script as some of the strings we set
+# need to be quoted and that doesn't work with this script. Run through
+# valid options by hand.
+
+SET @start_global_value = @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS;
+SELECT @start_global_value;
+
+--echo "Trying to set @session.ROCKSDB_STRICT_COLLATION_EXCEPTIONS to simple table name."
+SET @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS = mytable;
+SELECT @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS;
+
+--echo "Trying to set @session.ROCKSDB_STRICT_COLLATION_EXCEPTIONS to regex table name(s)."
+SET @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS = "t.*";
+SELECT @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS;
+
+--echo "Trying to set @session.ROCKSDB_STRICT_COLLATION_EXCEPTIONS to multiple regex table names."
+SET @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS = "s.*,t.*";
+SELECT @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS;
+
+--echo "Trying to set @session.ROCKSDB_STRICT_COLLATION_EXCEPTIONS to empty."
+SET @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS = "";
+SELECT @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS;
+
+--echo "Trying to set @session.ROCKSDB_STRICT_COLLATION_EXCEPTIONS to default."
+SET @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS = DEFAULT;
+SELECT @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS;
+
+--echo "Trying to set @session.ROCKSDB_STRICT_COLLATION_EXCEPTIONS to 444. It should fail because it is not session."
+--Error ER_GLOBAL_VARIABLE
+SET @@session.ROCKSDB_STRICT_COLLATION_EXCEPTIONS = 444;
+
+SET @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS = @start_global_value;
+SELECT @@global.ROCKSDB_STRICT_COLLATION_EXCEPTIONS;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_supported_compression_types_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_supported_compression_types_basic.test
new file mode 100644
index 00000000..52bf63c2
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_supported_compression_types_basic.test
@@ -0,0 +1,7 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_SUPPORTED_COMPRESSION_TYPES
+--let $read_only=1
+--let $session=0
+--let $suppress_default_value=1
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_table_cache_numshardbits_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_table_cache_numshardbits_basic.test
new file mode 100644
index 00000000..11bdd6ab
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_table_cache_numshardbits_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_TABLE_CACHE_NUMSHARDBITS
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_table_stats_sampling_pct_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_table_stats_sampling_pct_basic.test
new file mode 100644
index 00000000..3bed5e6e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_table_stats_sampling_pct_basic.test
@@ -0,0 +1,22 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+
+--let $sys_var=ROCKSDB_TABLE_STATS_SAMPLING_PCT
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_tmpdir_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_tmpdir_basic.test
new file mode 100644
index 00000000..8865914d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_tmpdir_basic.test
@@ -0,0 +1,38 @@
+--source include/have_rocksdb.inc
+
+SET @start_global_value = @@global.rocksdb_tmpdir;
+SELECT @start_global_value;
+
+#
+# exists as global and session
+#
+select @@session.rocksdb_tmpdir;
+
+show global variables like 'rocksdb_tmpdir';
+show session variables like 'rocksdb_tmpdir';
+
+select * from information_schema.global_variables where variable_name='rocksdb_tmpdir';
+select * from information_schema.session_variables where variable_name='rocksdb_tmpdir';
+
+#
+# Show that it is writable
+#
+
+set global rocksdb_tmpdir='value';
+set session rocksdb_tmpdir='value';
+
+#
+# incorrect types
+#
+--error ER_WRONG_TYPE_FOR_VAR
+set global rocksdb_tmpdir=1.1;
+--error ER_WRONG_TYPE_FOR_VAR
+set global rocksdb_tmpdir=1e1;
+
+#
+# Cleanup
+#
+
+SET @@global.rocksdb_tmpdir = @start_global_value;
+SELECT @@global.rocksdb_tmpdir;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_trace_sst_api_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_trace_sst_api_basic.test
new file mode 100644
index 00000000..259021d3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_trace_sst_api_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_TRACE_SST_API
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_two_write_queues_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_two_write_queues_basic.test
new file mode 100644
index 00000000..43579fab
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_two_write_queues_basic.test
@@ -0,0 +1,16 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(1024);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_TWO_WRITE_QUEUES
+--let $read_only=1
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_unsafe_for_binlog_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_unsafe_for_binlog_basic.test
new file mode 100644
index 00000000..f5f4536d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_unsafe_for_binlog_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_UNSAFE_FOR_BINLOG
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_update_cf_options.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_update_cf_options.test
new file mode 100644
index 00000000..03626260
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_update_cf_options.test
@@ -0,0 +1,22 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE t1 (a INT, PRIMARY KEY (a) COMMENT 'update_cf1') ENGINE=ROCKSDB;
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS='update_cf1={write_buffer_size=8m;target_file_size_base=2m};';
+SELECT @@global.rocksdb_update_cf_options;
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=NULL;
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=NULL;
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS="";
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=NULL;
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS='update_cf1={write_buffer_size=8m;target_file_size_base=2m};';
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS='update_cf2={write_buffer_size=8m;target_file_size_base=2m};';
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
+DROP TABLE t1;
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS='update_cf1={write_buffer_size=8m;target_file_size_base=2m};';
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
+SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=DEFAULT;
+SHOW GLOBAL VARIABLES LIKE 'rocksdb_update_cf_options';
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_update_cf_options_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_update_cf_options_basic.test
new file mode 100644
index 00000000..9462e40a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_update_cf_options_basic.test
@@ -0,0 +1,119 @@
+--source include/have_rocksdb.inc
+--source include/have_partition.inc
+
+call mtr.add_suppression("MyRocks: NULL is not a valid option for updates to column family settings.");
+call mtr.add_suppression("Invalid cf options, '=' expected *");
+call mtr.add_suppression("MyRocks: failed to parse the updated column family options = *");
+call mtr.add_suppression("Invalid cf config for default in override options *");
+
+DROP TABLE IF EXISTS t1;
+
+# Need a table which has multiple partitions and column families associated
+# with them to make sure that we're testing the valid scenario.
+CREATE TABLE `t1` (
+ `col1` bigint(20) NOT NULL,
+ `col2` varbinary(64) NOT NULL,
+ `col3` varbinary(256) NOT NULL,
+ `col4` bigint(20) NOT NULL,
+ `col5` mediumblob NOT NULL,
+ PRIMARY KEY (`col1`,`col2`,`col3`) COMMENT 'custom_p0_cfname=cf1;custom_p1_cfname=cf2',
+ UNIQUE KEY (`col2`, `col4`) COMMENT 'custom_p5_cfname=cf3'
+) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
+ PARTITION BY LIST COLUMNS (`col2`) (
+ PARTITION custom_p0 VALUES IN (0x12345),
+ PARTITION custom_p1 VALUES IN (0x23456),
+ PARTITION custom_p2 VALUES IN (0x34567),
+ PARTITION custom_p3 VALUES IN (0x45678),
+ PARTITION custom_p4 VALUES IN (0x56789),
+ PARTITION custom_p5 VALUES IN (0x6789A),
+ PARTITION custom_p6 VALUES IN (0x789AB),
+ PARTITION custom_p7 VALUES IN (0x89ABC)
+);
+
+USE information_schema;
+
+# We should start with NULL.
+SELECT @@global.rocksdb_update_cf_options;
+
+# ... and we should be able to handle NULL and issue a reasonable warning.
+SET @@global.rocksdb_update_cf_options = NULL;
+SELECT @@global.rocksdb_update_cf_options;
+
+# Make sure that we do not double free the NULL string
+SET @@global.rocksdb_update_cf_options = NULL;
+SELECT @@global.rocksdb_update_cf_options;
+
+# Attempt setting an empty string
+SET @@global.rocksdb_update_cf_options = '';
+SELECT @@global.rocksdb_update_cf_options;
+
+# Will fail to parse. Value not updated.
+--Error ER_WRONG_VALUE_FOR_VAR
+--eval SET @@global.rocksdb_update_cf_options = 'aaaaa';
+SELECT @@global.rocksdb_update_cf_options;
+
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='default' AND OPTION_TYPE='WRITE_BUFFER_SIZE';
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='default' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+
+# Save these off to reset later
+--let $ORIG_WRITE_BUFFER_SIZE=`SELECT VALUE FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='default' AND OPTION_TYPE='WRITE_BUFFER_SIZE'`
+--let $ORIG_TARGET_FILE_SIZE_BASE=`SELECT VALUE FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='default' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE'`
+--let $ORIG_MAX_BYTES_FOR_LEVEL_MULTIPLIER=`SELECT VALUE FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='default' AND OPTION_TYPE='MAX_BYTES_FOR_LEVEL_MULTIPLIER'`
+
+# All good. Use default CF.
+SET @@global.rocksdb_update_cf_options = 'default={write_buffer_size=8m;target_file_size_base=2m};';
+SELECT @@global.rocksdb_update_cf_options;
+
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='default' AND OPTION_TYPE='WRITE_BUFFER_SIZE';
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='default' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf1' AND OPTION_TYPE='WRITE_BUFFER_SIZE';
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf1' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf2' AND OPTION_TYPE='WRITE_BUFFER_SIZE';
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf2' AND OPTION_TYPE='MAX_BYTES_FOR_LEVEL_MULTIPLIER';
+
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf3' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+
+# All good. Use multiple valid CF-s.
+SET @@global.rocksdb_update_cf_options = 'cf1={write_buffer_size=8m;target_file_size_base=2m};cf2={write_buffer_size=16m;max_bytes_for_level_multiplier=8};cf3={target_file_size_base=4m};';
+SELECT @@global.rocksdb_update_cf_options;
+
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf1' AND OPTION_TYPE='WRITE_BUFFER_SIZE';
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf1' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf2' AND OPTION_TYPE='WRITE_BUFFER_SIZE';
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf2' AND OPTION_TYPE='MAX_BYTES_FOR_LEVEL_MULTIPLIER';
+
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf3' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+
+# All good. Use a single valid CF.
+SET @@global.rocksdb_update_cf_options = 'cf3={target_file_size_base=24m};';
+SELECT @@global.rocksdb_update_cf_options;
+
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf3' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+
+# Some parts are good. Value still updated.
+SET @@global.rocksdb_update_cf_options = 'cf1={target_file_size_base=24m};foo={max_bytes_for_level_multiplier=8};';
+SELECT @@global.rocksdb_update_cf_options;
+
+SELECT * FROM ROCKSDB_CF_OPTIONS WHERE CF_NAME='cf1' AND OPTION_TYPE='TARGET_FILE_SIZE_BASE';
+
+# Will fail to parse. No valid assignments included. Value not updated and
+# reset to NULL.
+--Error ER_WRONG_VALUE_FOR_VAR
+--eval SET @@global.rocksdb_update_cf_options = 'default={foo=bar};';
+SELECT @@global.rocksdb_update_cf_options;
+
+# Reset the cf options so the test passes with --repeat=2
+--eval SET @@global.rocksdb_update_cf_options = 'default={write_buffer_size=$ORIG_WRITE_BUFFER_SIZE;target_file_size_base=$ORIG_TARGET_FILE_SIZE_BASE};'
+--eval SET @@global.rocksdb_update_cf_options = 'cf1={write_buffer_size=$ORIG_WRITE_BUFFER_SIZE;target_file_size_base=$ORIG_TARGET_FILE_SIZE_BASE};'
+--eval SET @@global.rocksdb_update_cf_options = 'cf2={write_buffer_size=$ORIG_WRITE_BUFFER_SIZE;target_file_size_base=$ORIG_TARGET_FILE_SIZE_BASE;max_bytes_for_level_multiplier=$ORIG_MAX_BYTES_FOR_LEVEL_MULTIPLIER};'
+--eval SET @@global.rocksdb_update_cf_options = 'cf3={write_buffer_size=$ORIG_WRITE_BUFFER_SIZE;target_file_size_base=$ORIG_TARGET_FILE_SIZE_BASE};'
+
+SET @@global.rocksdb_update_cf_options = NULL;
+SELECT @@global.rocksdb_update_cf_options;
+
+USE test;
+
+DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_adaptive_mutex_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_adaptive_mutex_basic.test
new file mode 100644
index 00000000..7ce7bec1
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_adaptive_mutex_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_USE_ADAPTIVE_MUTEX
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_clock_cache_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_clock_cache_basic.test
new file mode 100644
index 00000000..d3e7b652
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_clock_cache_basic.test
@@ -0,0 +1,21 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+INSERT INTO valid_values VALUES('true');
+INSERT INTO valid_values VALUES('false');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_USE_CLOCK_CACHE
+--let $read_only=1
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_direct_io_for_flush_and_compaction_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_direct_io_for_flush_and_compaction_basic.test
new file mode 100644
index 00000000..f5dde2aa
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_direct_io_for_flush_and_compaction_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_USE_DIRECT_IO_FOR_FLUSH_AND_COMPACTION
+--let $read_only=1
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_direct_reads_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_direct_reads_basic.test
new file mode 100644
index 00000000..323b517f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_direct_reads_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_USE_DIRECT_READS
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_fsync_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_fsync_basic.test
new file mode 100644
index 00000000..90b41c4a
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_use_fsync_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_USE_FSYNC
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_validate_tables_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_validate_tables_basic.test
new file mode 100644
index 00000000..ed12b319
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_validate_tables_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_VALIDATE_TABLES
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_verify_row_debug_checksums_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_verify_row_debug_checksums_basic.test
new file mode 100644
index 00000000..352bc9d9
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_verify_row_debug_checksums_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_VERIFY_ROW_DEBUG_CHECKSUMS
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_bytes_per_sync_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_bytes_per_sync_basic.test
new file mode 100644
index 00000000..9c2a1f4f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_bytes_per_sync_basic.test
@@ -0,0 +1,22 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(100);
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+INSERT INTO invalid_values VALUES('\'-1\'');
+INSERT INTO invalid_values VALUES('\'101\'');
+INSERT INTO invalid_values VALUES('\'484436\'');
+
+--let $sys_var=ROCKSDB_WAL_BYTES_PER_SYNC
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_dir_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_dir_basic.test
new file mode 100644
index 00000000..a40c7766
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_dir_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_WAL_DIR
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_recovery_mode_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_recovery_mode_basic.test
new file mode 100644
index 00000000..ce202f2e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_recovery_mode_basic.test
@@ -0,0 +1,17 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_WAL_RECOVERY_MODE
+--let $read_only=0
+--let $session=0
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
+
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_size_limit_mb_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_size_limit_mb_basic.test
new file mode 100644
index 00000000..95880ea3
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_size_limit_mb_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_WAL_SIZE_LIMIT_MB
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_ttl_seconds_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_ttl_seconds_basic.test
new file mode 100644
index 00000000..e65d3851
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_wal_ttl_seconds_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_WAL_TTL_SECONDS
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_whole_key_filtering_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_whole_key_filtering_basic.test
new file mode 100644
index 00000000..83e8e238
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_whole_key_filtering_basic.test
@@ -0,0 +1,6 @@
+--source include/have_rocksdb.inc
+
+--let $sys_var=ROCKSDB_WHOLE_KEY_FILTERING
+--let $read_only=1
+--let $session=0
+--source include/rocksdb_sys_var.inc
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_batch_max_bytes_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_batch_max_bytes_basic.test
new file mode 100644
index 00000000..40d22373
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_batch_max_bytes_basic.test
@@ -0,0 +1,26 @@
+--source include/have_rocksdb.inc
+
+create table t (i int);
+
+insert into t values (1), (2), (3), (4), (5);
+
+set session rocksdb_write_batch_max_bytes = 1000;
+
+insert into t values (1), (2), (3), (4), (5);
+
+set session rocksdb_write_batch_max_bytes = 10;
+
+--error ER_GET_ERRMSG
+insert into t values (1), (2), (3), (4), (5);
+
+set session rocksdb_write_batch_max_bytes = 0;
+
+insert into t values (1), (2), (3), (4), (5);
+
+set session rocksdb_write_batch_max_bytes = 10;
+begin;
+--error ER_GET_ERRMSG
+insert into t values (1), (2), (3), (4), (5);
+rollback;
+
+drop table t;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_disable_wal_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_disable_wal_basic.test
new file mode 100644
index 00000000..d732beba
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_disable_wal_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+INSERT INTO valid_values VALUES('off');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_WRITE_DISABLE_WAL
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_ignore_missing_column_families_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_ignore_missing_column_families_basic.test
new file mode 100644
index 00000000..f38b7c96
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_ignore_missing_column_families_basic.test
@@ -0,0 +1,18 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES(1);
+INSERT INTO valid_values VALUES(0);
+INSERT INTO valid_values VALUES('on');
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+INSERT INTO invalid_values VALUES('\'bbb\'');
+
+--let $sys_var=ROCKSDB_WRITE_IGNORE_MISSING_COLUMN_FAMILIES
+--let $read_only=0
+--let $session=1
+--source include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_policy_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_policy_basic.test
new file mode 100644
index 00000000..720b9d67
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_write_policy_basic.test
@@ -0,0 +1,17 @@
+--source include/have_rocksdb.inc
+
+CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO valid_values VALUES("write_committed");
+INSERT INTO valid_values VALUES("write_prepared");
+INSERT INTO valid_values VALUES("write_unprepared");
+
+CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
+INSERT INTO invalid_values VALUES('\'aaa\'');
+
+--let $sys_var=ROCKSDB_WRITE_POLICY
+--let $read_only=1
+--let $session=0
+--source ../include/rocksdb_sys_var.inc
+
+DROP TABLE valid_values;
+DROP TABLE invalid_values;
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 00000000..76e7705e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/cache_index.rdiff
@@ -0,0 +1,71 @@
+--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/cache_index.result 2017-06-22 00:33:46.419995639 +0300
++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/cache_index.reject 2017-06-22 01:11:22.479981459 +0300
+@@ -12,31 +12,31 @@
+ SET GLOBAL <CACHE_NAME>.key_buffer_size=128*1024;
+ CACHE INDEX t1 INDEX (a), t2 IN <CACHE_NAME>;
+ Table Op Msg_type Msg_text
+-test.t1 assign_to_keycache status OK
+-test.t2 assign_to_keycache status OK
++test.t1 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache
++test.t2 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache
+ LOAD INDEX INTO CACHE t1, t2;
+ Table Op Msg_type Msg_text
+-test.t1 preload_keys status OK
+-test.t2 preload_keys status OK
++test.t1 preload_keys note The storage engine for the table doesn't support preload_keys
++test.t2 preload_keys note The storage engine for the table doesn't support preload_keys
+ INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d');
+ SET GLOBAL <CACHE_NAME>.key_buffer_size=8*1024;
+ LOAD INDEX INTO CACHE t1, t2 IGNORE LEAVES;
+ Table Op Msg_type Msg_text
+-test.t1 preload_keys status OK
+-test.t2 preload_keys status OK
++test.t1 preload_keys note The storage engine for the table doesn't support preload_keys
++test.t2 preload_keys note The storage engine for the table doesn't support preload_keys
+ SET GLOBAL <CACHE_NAME>.key_cache_age_threshold = 100, <CACHE_NAME>.key_cache_block_size = 512, <CACHE_NAME>.key_cache_division_limit = 1, <CACHE_NAME>.key_cache_segments=2;
+ INSERT INTO t1 (a,b) VALUES (5,'e'),(6,'f');
+ LOAD INDEX INTO CACHE t1;
+ Table Op Msg_type Msg_text
+-test.t1 preload_keys status OK
++test.t1 preload_keys note The storage engine for the table doesn't support preload_keys
+ SET GLOBAL new_<CACHE_NAME>.key_buffer_size=128*1024;
+ CACHE INDEX t1 IN new_<CACHE_NAME>;
+ Table Op Msg_type Msg_text
+-test.t1 assign_to_keycache status OK
++test.t1 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache
+ INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
+ LOAD INDEX INTO CACHE t1 IGNORE LEAVES;
+ Table Op Msg_type Msg_text
+-test.t1 preload_keys status OK
++test.t1 preload_keys note The storage engine for the table doesn't support preload_keys
+ INSERT INTO t1 (a,b) VALUES (9,'i');
+ DROP TABLE t2;
+ DROP TABLE t1;
+@@ -47,11 +47,11 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ CACHE INDEX t1 IN <CACHE_NAME>;
+ Table Op Msg_type Msg_text
+-test.t1 assign_to_keycache status OK
++test.t1 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+ LOAD INDEX INTO CACHE t1;
+ Table Op Msg_type Msg_text
+-test.t1 preload_keys status OK
++test.t1 preload_keys note The storage engine for the table doesn't support preload_keys
+ DROP TABLE t1;
+ CREATE TABLE t1 (a <INT_COLUMN>,
+ b <CHAR_COLUMN>,
+@@ -59,11 +59,11 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ CACHE INDEX t1 IN <CACHE_NAME>;
+ Table Op Msg_type Msg_text
+-test.t1 assign_to_keycache status OK
++test.t1 assign_to_keycache note The storage engine for the table doesn't support assign_to_keycache
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+ LOAD INDEX INTO CACHE t1;
+ Table Op Msg_type Msg_text
+-test.t1 preload_keys status OK
++test.t1 preload_keys note The storage engine for the table doesn't support preload_keys
+ DROP TABLE t1;
+ SET GLOBAL <CACHE_NAME>.key_buffer_size=0;
+ SET GLOBAL new_<CACHE_NAME>.key_buffer_size=0;
diff --git a/storage/rocksdb/mysql-test/storage_engine/checksum_table_live.rdiff b/storage/rocksdb/mysql-test/storage_engine/checksum_table_live.rdiff
new file mode 100644
index 00000000..094136ee
--- /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 00000000..e6fe915e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/cleanup_engine.inc
@@ -0,0 +1,25 @@
+###########################################
+#
+# This is a stub of the include file cleanup_engine.inc which
+# should be placed in storage/<engine>/mysql-test/storage_engine folder.
+#
+################################
+#
+# Here you can add whatever is needed to cleanup
+# in case your define_engine.inc created any artefacts,
+# e.g. an additional schema and/or tables.
+
+--let $datadir= `SELECT @@datadir`
+
+--error 0,1
+--file_exists $datadir/\#rocksdb/*
+if (!$mysql_errno)
+{
+ --enable_reconnect
+ --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+ --shutdown_server
+ --source include/wait_until_disconnected.inc
+ --rmdir $datadir/\#rocksdb
+ --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+ --source include/wait_until_connected_again.inc
+}
diff --git a/storage/rocksdb/mysql-test/storage_engine/define_engine.inc b/storage/rocksdb/mysql-test/storage_engine/define_engine.inc
new file mode 100644
index 00000000..1c77a6b6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/define_engine.inc
@@ -0,0 +1,45 @@
+###########################################
+#
+# This is a template of the include file define_engine.inc which
+# should be placed in storage/<engine>/mysql-test/storage_engine folder.
+#
+################################
+#
+# The name of the engine under test must be defined in $ENGINE variable.
+# You can set it either here (uncomment and edit) or in your environment.
+#
+let $ENGINE = RocksDB;
+#
+################################
+#
+# The following three variables define specific options for columns and tables.
+# Normally there should be none needed, but for some engines it can be different.
+# If the engine requires specific column option for all or indexed columns,
+# set them inside the comment, e.g. /*!NOT NULL*/.
+# Do the same for table options if needed, e.g. /*!INSERT_METHOD=LAST*/
+
+let $default_col_opts = /*!*/;
+let $default_col_indexed_opts = /*!*/;
+let $default_tbl_opts = /*!*/;
+
+# INDEX, UNIQUE INDEX, PRIMARY KEY, special index type - choose the fist that the engine allows,
+# or set it to /*!*/ if none is supported
+
+let $default_index = /*!INDEX*/;
+
+# If the engine does not support the following types, replace them with the closest possible
+
+let $default_int_type = INT(11);
+let $default_char_type = CHAR(8);
+
+################################
+
+--disable_query_log
+--disable_result_log
+
+# Here you can place your custom MTR code which needs to be executed before each test,
+# e.g. creation of an additional schema or table, etc.
+# The cleanup part should be defined in cleanup_engine.inc
+
+--enable_query_log
+--enable_result_log
diff --git a/storage/rocksdb/mysql-test/storage_engine/disabled.def b/storage/rocksdb/mysql-test/storage_engine/disabled.def
new file mode 100644
index 00000000..7ed4fac6
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/disabled.def
@@ -0,0 +1,27 @@
+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_engine : SHOW ENGINE produces different number of lines depending on previous tests
+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_binary_indexes : MDEV-16387 - Wrong execution plan
+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 00000000..76d6c6dd
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/index.rdiff
@@ -0,0 +1,60 @@
+--- suite/storage_engine/index.result 2017-03-12 04:57:07.169911845 +0200
++++ suite/storage_engine/index.reject 2017-08-14 22:41:06.548555663 +0300
+@@ -4,7 +4,7 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SHOW KEYS IN t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 1 a 1 a # # NULL NULL # BTREE
++t1 1 a 1 a # # NULL NULL # LSMTREE
+ DROP TABLE t1;
+ CREATE TABLE t1 (a <INT_COLUMN>,
+ b <CHAR_COLUMN>,
+@@ -12,8 +12,8 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SHOW KEYS IN t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 1 a_b 1 a # # NULL NULL # BTREE a_b index
+-t1 1 a_b 2 b # # NULL NULL # BTREE a_b index
++t1 1 a_b 1 a # # NULL NULL # LSMTREE a_b index
++t1 1 a_b 2 b # # NULL NULL # LSMTREE a_b index
+ DROP TABLE t1;
+ CREATE TABLE t1 (a <INT_COLUMN>,
+ b <CHAR_COLUMN>,
+@@ -22,8 +22,8 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SHOW KEYS IN t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 1 a 1 a # # NULL NULL # BTREE
+-t1 1 b 1 b # # NULL NULL # BTREE
++t1 1 a 1 a # # NULL NULL # LSMTREE
++t1 1 b 1 b # # NULL NULL # LSMTREE
+ DROP TABLE t1;
+ CREATE TABLE t1 (a <INT_COLUMN>,
+ b <CHAR_COLUMN>,
+@@ -31,7 +31,7 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SHOW KEYS IN t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 0 a 1 a # # NULL NULL # BTREE
++t1 0 a 1 a # # NULL NULL # LSMTREE
+ 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'
+@@ -43,7 +43,7 @@
+ ALTER TABLE t1 ADD <CUSTOM_INDEX> (a) COMMENT 'simple index on a';
+ SHOW INDEX FROM t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 1 a 1 a # # NULL NULL # BTREE simple index on a
++t1 1 a 1 a # # NULL NULL # LSMTREE simple index on a
+ ALTER TABLE t1 DROP KEY a;
+ DROP TABLE t1;
+ CREATE TABLE t1 (a <INT_COLUMN>,
+@@ -52,7 +52,7 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SHOW KEYS IN t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 0 a 1 a # # NULL NULL # BTREE
++t1 0 a 1 a # # NULL NULL # LSMTREE
+ 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'
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 00000000..5fcffbea
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/index_type_btree.rdiff
@@ -0,0 +1,60 @@
+--- suite/storage_engine/index_type_btree.result 2017-03-12 04:57:07.169911845 +0200
++++ suite/storage_engine/index_type_btree.reject 2017-08-14 22:50:47.264555216 +0300
+@@ -4,7 +4,7 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SHOW KEYS IN t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 1 a 1 a # # NULL NULL # BTREE
++t1 1 a 1 a # # NULL NULL # LSMTREE
+ DROP TABLE t1;
+ CREATE TABLE t1 (a <INT_COLUMN>,
+ b <CHAR_COLUMN>,
+@@ -12,8 +12,8 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SHOW KEYS IN t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 1 a_b 1 a # # NULL NULL # BTREE a_b index
+-t1 1 a_b 2 b # # NULL NULL # BTREE a_b index
++t1 1 a_b 1 a # # NULL NULL # LSMTREE a_b index
++t1 1 a_b 2 b # # NULL NULL # LSMTREE a_b index
+ DROP TABLE t1;
+ CREATE TABLE t1 (a <INT_COLUMN>,
+ b <CHAR_COLUMN>,
+@@ -22,8 +22,8 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SHOW KEYS IN t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 1 a 1 a # # NULL NULL # BTREE
+-t1 1 b 1 b # # NULL NULL # BTREE
++t1 1 a 1 a # # NULL NULL # LSMTREE
++t1 1 b 1 b # # NULL NULL # LSMTREE
+ DROP TABLE t1;
+ CREATE TABLE t1 (a <INT_COLUMN>,
+ b <CHAR_COLUMN>,
+@@ -31,7 +31,7 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SHOW KEYS IN t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 0 a 1 a # # NULL NULL # BTREE
++t1 0 a 1 a # # NULL NULL # LSMTREE
+ 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'
+@@ -43,7 +43,7 @@
+ ALTER TABLE t1 ADD <CUSTOM_INDEX> (a) USING BTREE COMMENT 'simple index on a';
+ SHOW INDEX FROM t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 1 a 1 a # # NULL NULL # BTREE simple index on a
++t1 1 a 1 a # # NULL NULL # LSMTREE simple index on a
+ ALTER TABLE t1 DROP KEY a;
+ DROP TABLE t1;
+ CREATE TABLE t1 (a <INT_COLUMN>,
+@@ -52,7 +52,7 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SHOW KEYS IN t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 0 a 1 a # # NULL NULL # BTREE
++t1 0 a 1 a # # NULL NULL # LSMTREE
+ 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'
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 00000000..815b2983
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/index_type_hash.rdiff
@@ -0,0 +1,60 @@
+--- suite/storage_engine/index_type_hash.result 2017-03-12 04:57:07.169911845 +0200
++++ suite/storage_engine/index_type_hash.reject 2017-08-14 22:51:55.644555163 +0300
+@@ -4,7 +4,7 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SHOW KEYS IN t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 1 a 1 a # # NULL NULL # HASH
++t1 1 a 1 a # # NULL NULL # LSMTREE
+ DROP TABLE t1;
+ CREATE TABLE t1 (a <INT_COLUMN>,
+ b <CHAR_COLUMN>,
+@@ -12,8 +12,8 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SHOW KEYS IN t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 1 a_b 1 a # # NULL NULL # HASH a_b index
+-t1 1 a_b 2 b # # NULL NULL # HASH a_b index
++t1 1 a_b 1 a # # NULL NULL # LSMTREE a_b index
++t1 1 a_b 2 b # # NULL NULL # LSMTREE a_b index
+ DROP TABLE t1;
+ CREATE TABLE t1 (a <INT_COLUMN>,
+ b <CHAR_COLUMN>,
+@@ -22,8 +22,8 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SHOW KEYS IN t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 1 a 1 a # # NULL NULL # HASH
+-t1 1 b 1 b # # NULL NULL # HASH
++t1 1 a 1 a # # NULL NULL # LSMTREE
++t1 1 b 1 b # # NULL NULL # LSMTREE
+ DROP TABLE t1;
+ CREATE TABLE t1 (a <INT_COLUMN>,
+ b <CHAR_COLUMN>,
+@@ -31,7 +31,7 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SHOW KEYS IN t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 0 a 1 a # # NULL NULL # HASH
++t1 0 a 1 a # # NULL NULL # LSMTREE
+ 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'
+@@ -43,7 +43,7 @@
+ ALTER TABLE t1 ADD <CUSTOM_INDEX> (a) USING HASH COMMENT 'simple index on a';
+ SHOW INDEX FROM t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 1 a 1 a # # NULL NULL # HASH simple index on a
++t1 1 a 1 a # # NULL NULL # LSMTREE simple index on a
+ ALTER TABLE t1 DROP KEY a;
+ DROP TABLE t1;
+ CREATE TABLE t1 (a <INT_COLUMN>,
+@@ -52,7 +52,7 @@
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SHOW KEYS IN t1;
+ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+-t1 0 a 1 a # # NULL NULL # HASH
++t1 0 a 1 a # # NULL NULL # LSMTREE
+ 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'
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 00000000..fc6cd02e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/mask_engine.inc
@@ -0,0 +1,15 @@
+#
+# This include file just replaces the storage engine under test by the generic string <STORAGE_ENGINE>
+# in the next statement. More masks can be added by defining $add_regex, e.g.
+# let $add_regex = /$data_dir/<DATA_DIR>/ /$index_dir/<INDEX_DIR>/
+#
+
+--let $regex = /$storage_engine/<STORAGE_ENGINE>/i / COLLATE[= ]latin1_bin//
+if ($add_regex)
+{
+ --let $regex = $regex $add_regex
+}
+
+--let $add_regex =
+--replace_regex $regex
+
diff --git a/storage/rocksdb/mysql-test/storage_engine/misc.rdiff b/storage/rocksdb/mysql-test/storage_engine/misc.rdiff
new file mode 100644
index 00000000..cdbad003
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/misc.rdiff
@@ -0,0 +1,34 @@
+--- suite/storage_engine/misc.result 2018-02-23 03:01:49.673249912 +0200
++++ suite/storage_engine/misc.reject 2018-02-23 03:02:05.669249564 +0200
+@@ -28,6 +28,10 @@
+ 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'
++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 +62,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
+@@ -94,7 +92,5 @@
+ time_zone_transition Transition_time NULL NULL
+ time_zone_transition_type Time_zone_id NULL NULL
+ time_zone_transition_type Transition_type_id NULL NULL
+-transaction_registry commit_id NULL NULL
+-transaction_registry transaction_id NULL NULL
+ user Host NULL NULL
+ user User 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 00000000..bf3347a4
--- /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 00000000..b2cb47a0
--- /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 00000000..ef8ad5b3
--- /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 00000000..d77a8227
--- /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 --loose-rocksdb_flush_log_at_trx_commit=0
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 00000000..15a9bb6f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/show_engine.rdiff
@@ -0,0 +1,15 @@
+--- suite/storage_engine/show_engine.result 2017-03-12 04:57:07.169911845 +0200
++++ suite/storage_engine/show_engine.reject 2017-08-14 22:58:15.508554871 +0300
+@@ -4,7 +4,11 @@
+ # volatile data (timestamps, memory info, etc.)
+ SHOW ENGINE <STORAGE_ENGINE> STATUS;
+ Type Name Status
+-<STORAGE_ENGINE> ### Engine status, can be long and changeable ###
++STATISTICS <STORAGE_ENGINE> ### Engine status, can be long and changeable ###
++DBSTATS <STORAGE_ENGINE> ### Engine status, can be long and changeable ###
++CF_COMPACTION __system__ ### Engine status, can be long and changeable ###
++CF_COMPACTION default ### Engine status, can be long and changeable ###
++MEMORY_STATS <STORAGE_ENGINE> ### Engine status, can be long and changeable ###
+ # For SHOW MUTEX even the number of lines is volatile, so the result logging is disabled,
+ # the test only checks that the command does not produce any errors
+ SHOW ENGINE <STORAGE_ENGINE> MUTEX;
diff --git a/storage/rocksdb/mysql-test/storage_engine/show_table_status.rdiff b/storage/rocksdb/mysql-test/storage_engine/show_table_status.rdiff
new file mode 100644
index 00000000..d7252eb5
--- /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 00000000..e6122c7e
--- /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 --loose-rocksdb_flush_log_at_trx_commit=0
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 00000000..20f594fb
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/tbl_opt_insert_method.rdiff
@@ -0,0 +1,11 @@
+--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/tbl_opt_insert_method.result 2017-06-22 00:33:46.423995639 +0300
++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/tbl_opt_insert_method.reject 2017-06-22 02:39:45.243948128 +0300
+@@ -5,7 +5,7 @@
+ t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+-) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 INSERT_METHOD=FIRST
++) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ ALTER TABLE t1 INSERT_METHOD=NO;
+ SHOW CREATE TABLE t1;
+ Table Create Table
diff --git a/storage/rocksdb/mysql-test/storage_engine/tbl_opt_union.rdiff b/storage/rocksdb/mysql-test/storage_engine/tbl_opt_union.rdiff
new file mode 100644
index 00000000..0d65ad07
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/tbl_opt_union.rdiff
@@ -0,0 +1,16 @@
+--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/tbl_opt_union.result 2017-06-22 00:33:46.423995639 +0300
++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/tbl_opt_union.reject 2017-06-22 02:41:02.719947641 +0300
+@@ -4,11 +4,11 @@
+ Table Create Table
+ t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+-) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 UNION=(`child1`)
++) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ ALTER TABLE t1 UNION = (child1,child2);
+ SHOW CREATE TABLE t1;
+ Table Create Table
+ t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+-) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 UNION=(`child1`,`child2`)
++) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ DROP TABLE t1, child1, child2;
diff --git a/storage/rocksdb/mysql-test/storage_engine/tbl_temporary.rdiff b/storage/rocksdb/mysql-test/storage_engine/tbl_temporary.rdiff
new file mode 100644
index 00000000..d24806e7
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/tbl_temporary.rdiff
@@ -0,0 +1,24 @@
+--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/tbl_temporary.result 2017-06-22 00:33:46.423995639 +0300
++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/tbl_temporary.reject 2017-06-22 15:27:50.643658456 +0300
+@@ -1,11 +1,14 @@
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1 (c CHAR(1)) ENGINE=MyISAM;
+ CREATE TEMPORARY TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+-SHOW CREATE TABLE t1;
+-Table Create Table
+-t1 CREATE TEMPORARY TABLE `t1` (
+- `a` int(11) DEFAULT NULL,
+- `b` char(8) DEFAULT NULL
+-) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+-DROP TEMPORARY TABLE t1;
++ERROR HY000: Table storage engine 'ROCKSDB' does not support the create option 'TEMPORARY'
++# ERROR: Statement ended with errno 1478, errname ER_ILLEGAL_HA_CREATE_OPTION (expected to succeed)
++# ------------ UNEXPECTED RESULT ------------
++# [ CREATE TEMPORARY TABLE t1 (a INT(11) /*!*/ /*Custom column options*/, b CHAR(8) /*!*/ /*Custom column options*/) ENGINE=RocksDB /*!*/ /*Custom table options*/ ]
++# The statement|command finished with ER_ILLEGAL_HA_CREATE_OPTION.
++# Temporary tables or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors.
++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def.
++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped.
++# Also, this problem may cause a chain effect (more errors of different kinds in the test).
++# -------------------------------------------
+ DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/storage_engine/truncate_table.rdiff b/storage/rocksdb/mysql-test/storage_engine/truncate_table.rdiff
new file mode 100644
index 00000000..9ca7861d
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/truncate_table.rdiff
@@ -0,0 +1,24 @@
+--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/truncate_table.result 2017-06-22 00:33:46.423995639 +0300
++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/truncate_table.reject 2017-06-22 02:43:27.183946733 +0300
+@@ -29,13 +29,12 @@
+ CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
+ HANDLER t1 OPEN AS h1;
+-HANDLER h1 READ FIRST;
+-a b
+-1 a
+-TRUNCATE TABLE t1;
+-HANDLER h1 READ NEXT;
+-ERROR 42S02: Unknown table 'h1' in HANDLER
+-HANDLER t1 OPEN AS h2;
+-HANDLER h2 READ FIRST;
+-a b
++ERROR HY000: Storage engine ROCKSDB of the table `test`.`t1` doesn't have this option
++# ------------ UNEXPECTED RESULT ------------
++# The statement|command finished with ER_ILLEGAL_HA.
++# HANDLER or the syntax or the mix could be unsupported.
++# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def.
++# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped.
++# Also, this problem may cause a chain effect (more errors of different kinds in the test).
++# -------------------------------------------
+ DROP TABLE t1;
diff --git a/storage/rocksdb/mysql-test/storage_engine/trx/delete.rdiff b/storage/rocksdb/mysql-test/storage_engine/trx/delete.rdiff
new file mode 100644
index 00000000..dac23b83
--- /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 00000000..4e227c10
--- /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 00000000..36a71076
--- /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 00000000..6b9e4a3f
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/trx/level_read_committed.rdiff
@@ -0,0 +1,10 @@
+--- /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/trx/level_read_committed.result 2017-06-22 00:33:46.423995639 +0300
++++ /data/src/bb-10.2-mdev12528/mysql-test/suite/storage_engine/trx/level_read_committed.reject 2017-06-22 19:29:41.459567247 +0300
+@@ -77,6 +77,7 @@
+ CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+ START TRANSACTION WITH CONSISTENT SNAPSHOT;
++ERROR HY000: Only REPEATABLE READ isolation level is supported for START TRANSACTION WITH CONSISTENT SNAPSHOT in RocksDB Storage Engine.
+ connection con2;
+ INSERT INTO t1 (a) VALUES (1);
+ connection con1;
diff --git a/storage/rocksdb/mysql-test/storage_engine/trx/level_repeatable_read.rdiff b/storage/rocksdb/mysql-test/storage_engine/trx/level_repeatable_read.rdiff
new file mode 100644
index 00000000..cf770755
--- /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 00000000..d77a8227
--- /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 --loose-rocksdb_flush_log_at_trx_commit=0
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 00000000..ab181947
--- /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 00000000..5eec9d24
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/type_binary_indexes.rdiff
@@ -0,0 +1,11 @@
+--- suite/storage_engine/type_binary_indexes.result 2017-03-12 04:57:07.173911845 +0200
++++ suite/storage_engine/type_binary_indexes.reject 2017-08-14 22:54:02.144555066 +0300
+@@ -91,7 +91,7 @@
+ INSERT INTO t1 (b,b20,v16,v128) SELECT b,b20,v16,v128 FROM 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 00000000..e53a33b4
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/type_bit_indexes.rdiff
@@ -0,0 +1,20 @@
+--- suite/storage_engine/type_bit_indexes.result 2017-12-12 20:34:34.000000000 +0200
++++ suite/storage_engine/type_bit_indexes.reject 2017-12-12 20:35:24.539330056 +0200
+@@ -69,7 +69,7 @@
+ (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 # # # #
++# # # # # NULL # # # #
+ SELECT HEX(b+c) FROM t1 WHERE c > 1 OR HEX(b) < 0xFFFFFF;
+ HEX(b+c)
+ 10
+@@ -98,7 +98,7 @@
+ (1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF);
+ EXPLAIN SELECT DISTINCT a+0 FROM t1 ORDER BY a;
+ id select_type table type possible_keys key key_len ref rows Extra
+-# # # # # a # # # #
++# # # # # NULL # # # #
+ SELECT DISTINCT a+0 FROM t1 ORDER BY a;
+ a+0
+ 0
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 00000000..be83fb6e
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/type_enum_indexes.rdiff
@@ -0,0 +1,11 @@
+--- suite/storage_engine/type_enum_indexes.result 2017-03-12 04:38:50.000000000 +0200
++++ suite/storage_engine/type_enum_indexes.reject 2017-12-12 20:36:47.455331726 +0200
+@@ -30,7 +30,7 @@
+ 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 # # # #
++# # # # # NULL # # # #
+ SELECT a FROM t1 WHERE b > 'test2' ORDER BY a;
+ a
+ Africa
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 00000000..2703e81b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/storage_engine/type_set_indexes.rdiff
@@ -0,0 +1,20 @@
+--- suite/storage_engine/type_set_indexes.result 2017-03-12 04:38:50.000000000 +0200
++++ suite/storage_engine/type_set_indexes.reject 2017-12-12 20:37:16.187332305 +0200
+@@ -97,7 +97,7 @@
+ Warning 1265 Data truncated for column 'b' at row 7
+ EXPLAIN SELECT a FROM t1 WHERE FIND_IN_SET('Europe',a) > 0;
+ id select_type table type possible_keys key key_len ref rows Extra
+-# # # # # a # # # #
++# # # # # NULL # # # #
+ SELECT a FROM t1 WHERE FIND_IN_SET('Europe',a) > 0;
+ a
+ Africa,Europe,Asia
+@@ -124,7 +124,7 @@
+ 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 # # # #
++# # # # # NULL # # # #
+ SELECT DISTINCT a, b FROM t1 ORDER BY b DESC, a;
+ a b
+ test1,test3