lists.mariadb.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

commits

Thread Start a new thread
Threads by month
  • ----- 2025 -----
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
commits@lists.mariadb.org

  • 14605 discussions
[Commits] 86167e908fe: MDEV-20611: MRR scan over partitioned InnoDB table produces "Out of memory" error
by psergey 15 Nov '19

15 Nov '19
revision-id: 86167e908fe5de6f6e9f5076b4ea8041514d0820 (mariadb-10.3.20-9-g86167e908fe) parent(s): 3d4a80153345209bad736235d4f66dcaa51a9d51 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2019-11-15 23:37:28 +0300 message: MDEV-20611: MRR scan over partitioned InnoDB table produces "Out of memory" error Fix partitioning and DS-MRR to work together - In ha_partition::index_end(): take into account that ha_innobase (and other engines using DS-MRR) will have inited=RND when initialized for DS-MRR scan. - In ha_partition::multi_range_read_next(): if the MRR scan is using HA_MRR_NO_ASSOCIATION mode, it is not guaranteed that the partition's handler will store anything into *range_info. - In DsMrr_impl::choose_mrr_impl(): ha_partition will inquire partitions about how much memory their MRR implementation needs by passing *buffer_size=0. DS-MRR code didn't know about this (actually it used uint for buffer size calculation and would have an under-flow). Returning *buffer_size=0 made ha_partition assume that partitions do not need MRR memory and pass the same buffer to each of them. Now, this is fixed. If DS-MRR gets *buffer_size=0, it will return the amount of buffer space needed, but not more than about @@mrr_buffer_size. * Fix ha_{innobase,maria,myisam}::clone. If ha_partition uses MRR on its partitions, and partition use DS-MRR, the code will call handler->clone with TABLE (*NOT partition*) name as an argument. DS-MRR has no way of knowing the partition name, so the solution was to have the ::clone() function for the affected storage engine to ignore the name argument and get it elsewhere. --- mysql-test/include/partition_mrr.inc | 46 +++++++++++++++++ mysql-test/main/partition_mrr_aria.result | 79 +++++++++++++++++++++++++++++ mysql-test/main/partition_mrr_aria.test | 2 + mysql-test/main/partition_mrr_innodb.result | 79 +++++++++++++++++++++++++++++ mysql-test/main/partition_mrr_innodb.test | 4 ++ mysql-test/main/partition_mrr_myisam.result | 79 +++++++++++++++++++++++++++++ mysql-test/main/partition_mrr_myisam.test | 3 ++ sql/ha_partition.cc | 14 ++++- sql/multi_range_read.cc | 33 +++++++++--- sql/multi_range_read.h | 5 +- storage/innobase/handler/ha_innodb.cc | 2 +- storage/maria/ha_maria.cc | 8 +-- storage/myisam/ha_myisam.cc | 7 +-- 13 files changed, 343 insertions(+), 18 deletions(-) diff --git a/mysql-test/include/partition_mrr.inc b/mysql-test/include/partition_mrr.inc new file mode 100644 index 00000000000..4c285791ec7 --- /dev/null +++ b/mysql-test/include/partition_mrr.inc @@ -0,0 +1,46 @@ +--source include/have_partition.inc + +--disable_warnings +drop table if exists t1,t3; +--enable_warnings + +--echo # +--echo # MDEV-20611: MRR scan over partitioned InnoDB table produces "Out of memory" error +--echo # +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +set @tmp=@@storage_engine; +eval set storage_engine=$engine_type; + +create table t3 ( + ID bigint(20) NOT NULL AUTO_INCREMENT, + part_id int, + key_col int, + col2 int, + key(key_col), + PRIMARY KEY (ID,part_id) +) PARTITION BY RANGE (part_id) +(PARTITION p1 VALUES LESS THAN (3), + PARTITION p2 VALUES LESS THAN (7), + PARTITION p3 VALUES LESS THAN (10) +); + +show create table t3; +set storage_engine= @tmp; + +insert into t3 select + A.a+10*B.a, + A.a, + B.a, + 123456 +from t1 A, t1 B; + +set optimizer_switch='mrr=on'; +--replace_column 9 # +explain +select * from t3 force index (key_col) where key_col < 3; +select * from t3 force index (key_col) where key_col < 3; + +drop table t1,t3; + diff --git a/mysql-test/main/partition_mrr_aria.result b/mysql-test/main/partition_mrr_aria.result new file mode 100644 index 00000000000..7a0c35a309e --- /dev/null +++ b/mysql-test/main/partition_mrr_aria.result @@ -0,0 +1,79 @@ +drop table if exists t1,t3; +# +# MDEV-20611: MRR scan over partitioned InnoDB table produces "Out of memory" error +# +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +set @tmp=@@storage_engine; +set storage_engine=Aria; +create table t3 ( +ID bigint(20) NOT NULL AUTO_INCREMENT, +part_id int, +key_col int, +col2 int, +key(key_col), +PRIMARY KEY (ID,part_id) +) PARTITION BY RANGE (part_id) +(PARTITION p1 VALUES LESS THAN (3), +PARTITION p2 VALUES LESS THAN (7), +PARTITION p3 VALUES LESS THAN (10) +); +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `ID` bigint(20) NOT NULL AUTO_INCREMENT, + `part_id` int(11) NOT NULL, + `key_col` int(11) DEFAULT NULL, + `col2` int(11) DEFAULT NULL, + PRIMARY KEY (`ID`,`part_id`), + KEY `key_col` (`key_col`) +) ENGINE=Aria DEFAULT CHARSET=latin1 + PARTITION BY RANGE (`part_id`) +(PARTITION `p1` VALUES LESS THAN (3) ENGINE = Aria, + PARTITION `p2` VALUES LESS THAN (7) ENGINE = Aria, + PARTITION `p3` VALUES LESS THAN (10) ENGINE = Aria) +set storage_engine= @tmp; +insert into t3 select +A.a+10*B.a, +A.a, +B.a, +123456 +from t1 A, t1 B; +set optimizer_switch='mrr=on'; +explain +select * from t3 force index (key_col) where key_col < 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range key_col key_col 5 NULL # Using where; Rowid-ordered scan +select * from t3 force index (key_col) where key_col < 3; +ID part_id key_col col2 +1 0 0 123456 +1 1 0 123456 +2 2 0 123456 +10 0 1 123456 +11 1 1 123456 +12 2 1 123456 +20 0 2 123456 +21 1 2 123456 +22 2 2 123456 +3 3 0 123456 +4 4 0 123456 +5 5 0 123456 +6 6 0 123456 +13 3 1 123456 +14 4 1 123456 +15 5 1 123456 +16 6 1 123456 +23 3 2 123456 +24 4 2 123456 +25 5 2 123456 +26 6 2 123456 +7 7 0 123456 +8 8 0 123456 +9 9 0 123456 +17 7 1 123456 +18 8 1 123456 +19 9 1 123456 +27 7 2 123456 +28 8 2 123456 +29 9 2 123456 +drop table t1,t3; diff --git a/mysql-test/main/partition_mrr_aria.test b/mysql-test/main/partition_mrr_aria.test new file mode 100644 index 00000000000..e3dfe8cd9b5 --- /dev/null +++ b/mysql-test/main/partition_mrr_aria.test @@ -0,0 +1,2 @@ +let $engine_type= Aria; +--source include/partition_mrr.inc diff --git a/mysql-test/main/partition_mrr_innodb.result b/mysql-test/main/partition_mrr_innodb.result new file mode 100644 index 00000000000..c188f7e9929 --- /dev/null +++ b/mysql-test/main/partition_mrr_innodb.result @@ -0,0 +1,79 @@ +drop table if exists t1,t3; +# +# MDEV-20611: MRR scan over partitioned InnoDB table produces "Out of memory" error +# +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +set @tmp=@@storage_engine; +set storage_engine=InnoDB; +create table t3 ( +ID bigint(20) NOT NULL AUTO_INCREMENT, +part_id int, +key_col int, +col2 int, +key(key_col), +PRIMARY KEY (ID,part_id) +) PARTITION BY RANGE (part_id) +(PARTITION p1 VALUES LESS THAN (3), +PARTITION p2 VALUES LESS THAN (7), +PARTITION p3 VALUES LESS THAN (10) +); +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `ID` bigint(20) NOT NULL AUTO_INCREMENT, + `part_id` int(11) NOT NULL, + `key_col` int(11) DEFAULT NULL, + `col2` int(11) DEFAULT NULL, + PRIMARY KEY (`ID`,`part_id`), + KEY `key_col` (`key_col`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 + PARTITION BY RANGE (`part_id`) +(PARTITION `p1` VALUES LESS THAN (3) ENGINE = InnoDB, + PARTITION `p2` VALUES LESS THAN (7) ENGINE = InnoDB, + PARTITION `p3` VALUES LESS THAN (10) ENGINE = InnoDB) +set storage_engine= @tmp; +insert into t3 select +A.a+10*B.a, +A.a, +B.a, +123456 +from t1 A, t1 B; +set optimizer_switch='mrr=on'; +explain +select * from t3 force index (key_col) where key_col < 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range key_col key_col 5 NULL # Using where; Rowid-ordered scan +select * from t3 force index (key_col) where key_col < 3; +ID part_id key_col col2 +1 0 0 123456 +1 1 0 123456 +2 2 0 123456 +10 0 1 123456 +11 1 1 123456 +12 2 1 123456 +20 0 2 123456 +21 1 2 123456 +22 2 2 123456 +3 3 0 123456 +4 4 0 123456 +5 5 0 123456 +6 6 0 123456 +13 3 1 123456 +14 4 1 123456 +15 5 1 123456 +16 6 1 123456 +23 3 2 123456 +24 4 2 123456 +25 5 2 123456 +26 6 2 123456 +7 7 0 123456 +8 8 0 123456 +9 9 0 123456 +17 7 1 123456 +18 8 1 123456 +19 9 1 123456 +27 7 2 123456 +28 8 2 123456 +29 9 2 123456 +drop table t1,t3; diff --git a/mysql-test/main/partition_mrr_innodb.test b/mysql-test/main/partition_mrr_innodb.test new file mode 100644 index 00000000000..1eccf070e5c --- /dev/null +++ b/mysql-test/main/partition_mrr_innodb.test @@ -0,0 +1,4 @@ +--source include/have_innodb.inc +let $engine_type= InnoDB; + +--source include/partition_mrr.inc diff --git a/mysql-test/main/partition_mrr_myisam.result b/mysql-test/main/partition_mrr_myisam.result new file mode 100644 index 00000000000..1f1cea8e9d6 --- /dev/null +++ b/mysql-test/main/partition_mrr_myisam.result @@ -0,0 +1,79 @@ +drop table if exists t1,t3; +# +# MDEV-20611: MRR scan over partitioned InnoDB table produces "Out of memory" error +# +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +set @tmp=@@storage_engine; +set storage_engine=myisam; +create table t3 ( +ID bigint(20) NOT NULL AUTO_INCREMENT, +part_id int, +key_col int, +col2 int, +key(key_col), +PRIMARY KEY (ID,part_id) +) PARTITION BY RANGE (part_id) +(PARTITION p1 VALUES LESS THAN (3), +PARTITION p2 VALUES LESS THAN (7), +PARTITION p3 VALUES LESS THAN (10) +); +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `ID` bigint(20) NOT NULL AUTO_INCREMENT, + `part_id` int(11) NOT NULL, + `key_col` int(11) DEFAULT NULL, + `col2` int(11) DEFAULT NULL, + PRIMARY KEY (`ID`,`part_id`), + KEY `key_col` (`key_col`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 + PARTITION BY RANGE (`part_id`) +(PARTITION `p1` VALUES LESS THAN (3) ENGINE = MyISAM, + PARTITION `p2` VALUES LESS THAN (7) ENGINE = MyISAM, + PARTITION `p3` VALUES LESS THAN (10) ENGINE = MyISAM) +set storage_engine= @tmp; +insert into t3 select +A.a+10*B.a, +A.a, +B.a, +123456 +from t1 A, t1 B; +set optimizer_switch='mrr=on'; +explain +select * from t3 force index (key_col) where key_col < 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range key_col key_col 5 NULL # Using where; Rowid-ordered scan +select * from t3 force index (key_col) where key_col < 3; +ID part_id key_col col2 +1 0 0 123456 +1 1 0 123456 +2 2 0 123456 +10 0 1 123456 +11 1 1 123456 +12 2 1 123456 +20 0 2 123456 +21 1 2 123456 +22 2 2 123456 +3 3 0 123456 +4 4 0 123456 +5 5 0 123456 +6 6 0 123456 +13 3 1 123456 +14 4 1 123456 +15 5 1 123456 +16 6 1 123456 +23 3 2 123456 +24 4 2 123456 +25 5 2 123456 +26 6 2 123456 +7 7 0 123456 +8 8 0 123456 +9 9 0 123456 +17 7 1 123456 +18 8 1 123456 +19 9 1 123456 +27 7 2 123456 +28 8 2 123456 +29 9 2 123456 +drop table t1,t3; diff --git a/mysql-test/main/partition_mrr_myisam.test b/mysql-test/main/partition_mrr_myisam.test new file mode 100644 index 00000000000..d67a37ab3d2 --- /dev/null +++ b/mysql-test/main/partition_mrr_myisam.test @@ -0,0 +1,3 @@ +let $engine_type= myisam; + +--source include/partition_mrr.inc diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index ccda01de6b7..09664deb458 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -5478,6 +5478,13 @@ int ha_partition::index_end() if ((tmp= (*file)->ha_index_end())) error= tmp; } + else if ((*file)->inited == RND) + { + // Possible due to MRR + int tmp; + if ((tmp= (*file)->ha_rnd_end())) + error= tmp; + } } while (*(++file)); destroy_record_priority_queue(); DBUG_RETURN(error); @@ -6519,8 +6526,11 @@ int ha_partition::multi_range_read_next(range_id_t *range_info) else if (unlikely((error= handle_unordered_next(table->record[0], FALSE)))) DBUG_RETURN(error); - *range_info= - ((PARTITION_KEY_MULTI_RANGE *) m_range_info[m_last_part])->ptr; + if (!(m_mrr_mode & HA_MRR_NO_ASSOCIATION)) + { + *range_info= + ((PARTITION_KEY_MULTI_RANGE *) m_range_info[m_last_part])->ptr; + } } DBUG_RETURN(0); } diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index f40c8d0fbd8..6d62ea07dfa 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -1589,11 +1589,10 @@ bool DsMrr_impl::choose_mrr_impl(uint keyno, ha_rows rows, uint *flags, } uint add_len= share->key_info[keyno].key_length + primary_file->ref_length; - *bufsz -= add_len; - if (get_disk_sweep_mrr_cost(keyno, rows, *flags, bufsz, &dsmrr_cost)) + if (get_disk_sweep_mrr_cost(keyno, rows, *flags, bufsz, add_len, + &dsmrr_cost)) return TRUE; - *bufsz += add_len; - + bool force_dsmrr; /* If mrr_cost_based flag is not set, then set cost of DS-MRR to be minimum of @@ -1682,6 +1681,11 @@ static void get_sort_and_sweep_cost(TABLE *table, ha_rows nrows, Cost_estimate * @param rows E(Number of rows to be scanned) @param flags Scan parameters (HA_MRR_* flags) @param buffer_size INOUT Buffer size + IN: Buffer of size 0 means the function + will determine the best size and return it. + @param extra_mem_overhead Extra memory overhead of the MRR implementation + (the function assumes this many bytes of buffer + space will not be usable by DS-MRR) @param cost OUT The cost @retval FALSE OK @@ -1690,7 +1694,9 @@ static void get_sort_and_sweep_cost(TABLE *table, ha_rows nrows, Cost_estimate * */ bool DsMrr_impl::get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags, - uint *buffer_size, Cost_estimate *cost) + uint *buffer_size, + uint extra_mem_overhead, + Cost_estimate *cost) { ulong max_buff_entries, elem_size; ha_rows rows_in_full_step; @@ -1700,11 +1706,24 @@ bool DsMrr_impl::get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags, elem_size= primary_file->ref_length + sizeof(void*) * (!MY_TEST(flags & HA_MRR_NO_ASSOCIATION)); - max_buff_entries = *buffer_size / elem_size; - if (!max_buff_entries) + if (!*buffer_size) + { + /* + We are requested to determine how much memory we need. + Request memory to finish the scan in one pass but do not request + more than @@mrr_buff_size. + */ + *buffer_size = MY_MIN(extra_mem_overhead + rows*elem_size, + MY_MAX(table->in_use->variables.mrr_buff_size, + extra_mem_overhead)); + } + + if (elem_size + extra_mem_overhead > *buffer_size) return TRUE; /* Buffer has not enough space for even 1 rowid */ + max_buff_entries = (*buffer_size - extra_mem_overhead) / elem_size; + /* Number of iterations we'll make with full buffer */ n_full_steps= (uint)floor(rows2double(rows) / max_buff_entries); diff --git a/sql/multi_range_read.h b/sql/multi_range_read.h index 85578aa312c..0473fef04ae 100644 --- a/sql/multi_range_read.h +++ b/sql/multi_range_read.h @@ -631,8 +631,9 @@ class DsMrr_impl bool choose_mrr_impl(uint keyno, ha_rows rows, uint *flags, uint *bufsz, Cost_estimate *cost); - bool get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags, - uint *buffer_size, Cost_estimate *cost); + bool get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags, + uint *buffer_size, uint extra_mem_overhead, + Cost_estimate *cost); bool check_cpk_scan(THD *thd, TABLE_SHARE *share, uint keyno, uint mrr_flags); bool setup_buffer_sharing(uint key_size_in_keybuf, key_part_map key_tuple_map); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 29f29544f29..eecc72ad1f6 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -6466,7 +6466,7 @@ ha_innobase::clone( DBUG_ENTER("ha_innobase::clone"); ha_innobase* new_handler = static_cast<ha_innobase*>( - handler::clone(name, mem_root)); + handler::clone(m_prebuilt->table->name.m_name, mem_root)); if (new_handler != NULL) { DBUG_ASSERT(new_handler->m_prebuilt != NULL); diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 57537a69082..71456666fbe 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1000,10 +1000,12 @@ can_enable_indexes(1), bulk_insert_single_undo(BULK_INSERT_NONE) {} -handler *ha_maria::clone(const char *name, MEM_ROOT *mem_root) +handler *ha_maria::clone(const char *name __attribute__((unused)), + MEM_ROOT *mem_root) { - ha_maria *new_handler= static_cast <ha_maria *>(handler::clone(name, - mem_root)); + ha_maria *new_handler= + static_cast <ha_maria *>(handler::clone(file->s->open_file_name.str, + mem_root)); if (new_handler) { new_handler->file->state= file->state; diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 40c8ea61ddc..9b4dff68683 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -702,10 +702,11 @@ ha_myisam::ha_myisam(handlerton *hton, TABLE_SHARE *table_arg) can_enable_indexes(1) {} -handler *ha_myisam::clone(const char *name, MEM_ROOT *mem_root) +handler *ha_myisam::clone(const char *name __attribute__((unused)), + MEM_ROOT *mem_root) { - ha_myisam *new_handler= static_cast <ha_myisam *>(handler::clone(name, - mem_root)); + ha_myisam *new_handler= + static_cast <ha_myisam *>(handler::clone(file->filename, mem_root)); if (new_handler) new_handler->file->state= file->state; return new_handler;
1 0
0 0
[Commits] b46e58ffb82: MDEV-21044: Wrong result when using a smaller size for sort buffer
by Varun 15 Nov '19

15 Nov '19
revision-id: b46e58ffb828e90c83e3b1ee536b0e6d345570c6 (mariadb-10.1.41-92-gb46e58ffb82) parent(s): 214023aa0e6ec00dcac386167a2b2cf9394b6c7e author: Varun Gupta committer: Varun Gupta timestamp: 2019-11-15 12:33:32 +0530 message: MDEV-21044: Wrong result when using a smaller size for sort buffer Make sure that the sort buffers can store atleast one sort key. This is needed to make sure that all merge buffers are read else with no sort keys some merge buffers are skipped because the code makes a conclusion there is no data to be read. --- mysql-test/r/order_by.result | 30 ++++++++++++++++++++++++++++++ mysql-test/t/order_by.test | 16 ++++++++++++++++ sql/filesort.cc | 1 + 3 files changed, 47 insertions(+) diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 4cd9aebdf49..380687554d7 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -3207,3 +3207,33 @@ pk 2 3 DROP TABLE t1; +# +# MDEV-21044: Wrong result when using a smaller size for sort buffer +# +create table t1(a varchar(765),b int); +insert into t1 values ("a",1),("b",2),("c",3),("e",4); +insert into t1 values ("d",5),("f",6),("g",7),("h",8); +insert into t1 values ("k",11),("l",12),("i",9),("j",10); +insert into t1 values ("m",13),("n",14),("o",15),("p",16); +set @save_sort_buffer_size= @@sort_buffer_size; +set sort_buffer_size=1024; +select * from t1 order by b; +a b +a 1 +b 2 +c 3 +e 4 +d 5 +f 6 +g 7 +h 8 +i 9 +j 10 +k 11 +l 12 +m 13 +n 14 +o 15 +p 16 +set @@sort_buffer_size= @save_sort_buffer_size; +drop table t1; diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 1ca258d1d48..999c7314139 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -2141,3 +2141,19 @@ INSERT INTO t1 VALUES (1),(2),(3); SELECT DISTINCT pk FROM t1 GROUP BY 'foo'; SELECT DISTINCT pk FROM t1; DROP TABLE t1; + +--echo # +--echo # MDEV-21044: Wrong result when using a smaller size for sort buffer +--echo # + +create table t1(a varchar(765),b int); +insert into t1 values ("a",1),("b",2),("c",3),("e",4); +insert into t1 values ("d",5),("f",6),("g",7),("h",8); +insert into t1 values ("k",11),("l",12),("i",9),("j",10); +insert into t1 values ("m",13),("n",14),("o",15),("p",16); +set @save_sort_buffer_size= @@sort_buffer_size; +set sort_buffer_size=1024; +select * from t1 order by b; +set @@sort_buffer_size= @save_sort_buffer_size; +drop table t1; + diff --git a/sql/filesort.cc b/sql/filesort.cc index 4f195f68059..bb3e73343ad 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -343,6 +343,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, param.max_keys_per_buffer=((param.max_keys_per_buffer * (param.rec_length + sizeof(char*))) / param.rec_length - 1); + set_if_bigger(param.max_keys_per_buffer, 1); maxbuffer--; // Offset from 0 if (merge_many_buff(&param, (uchar*) table_sort.get_sort_keys(),
1 0
0 0
[Commits] 5f051e2c2cb: Support Create_time and Update_time in MyRocks table status
by psergey 14 Nov '19

14 Nov '19
revision-id: 5f051e2c2cbfa652c6e149d2bdd78b7f122963ba (fb-prod201903-144-g5f051e2c2cb) parent(s): d97c0c628e5dc60abd725f6a7120a8d87b09321e author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2019-11-14 20:46:20 +0300 message: Support Create_time and Update_time in MyRocks table status (Variant #7 of the patch) The implementation follows InnoDB: - Create_time is taken from the .frm file creation timestamp - Update_time is maintained in memory only and is set NULL on server restart --- mysql-test/suite/rocksdb/include/bulk_load.inc | 4 +- .../suite/rocksdb/include/bulk_load_unsorted.inc | 4 +- mysql-test/suite/rocksdb/r/bulk_load.result | 12 +-- mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result | 12 +-- .../rocksdb/r/bulk_load_rev_cf_and_data.result | 12 +-- .../suite/rocksdb/r/bulk_load_rev_data.result | 12 +-- .../suite/rocksdb/r/bulk_load_unsorted.result | 12 +-- .../suite/rocksdb/r/bulk_load_unsorted_rev.result | 12 +-- mysql-test/suite/rocksdb/r/issue255.result | 16 +-- mysql-test/suite/rocksdb/r/rocksdb.result | 6 +- .../suite/rocksdb/r/show_table_status.result | 117 ++++++++++++++++++++- mysql-test/suite/rocksdb/r/truncate_table.result | 8 +- mysql-test/suite/rocksdb/t/issue255.test | 17 +-- mysql-test/suite/rocksdb/t/rocksdb.test | 4 +- mysql-test/suite/rocksdb/t/show_table_status.test | 116 +++++++++++++++++++- mysql-test/suite/rocksdb/t/truncate_table.test | 8 +- storage/rocksdb/ha_rocksdb.cc | 38 ++++++- storage/rocksdb/rdb_datadic.cc | 20 ++++ storage/rocksdb/rdb_datadic.h | 20 +++- 19 files changed, 371 insertions(+), 79 deletions(-) diff --git a/mysql-test/suite/rocksdb/include/bulk_load.inc b/mysql-test/suite/rocksdb/include/bulk_load.inc index 1b79825e507..7e163602202 100644 --- a/mysql-test/suite/rocksdb/include/bulk_load.inc +++ b/mysql-test/suite/rocksdb/include/bulk_load.inc @@ -121,12 +121,12 @@ set rocksdb_bulk_load=0; --remove_file $file # Make sure row count index stats are correct ---replace_column 6 # 7 # 8 # 9 # +--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 # +--replace_column 6 # 7 # 8 # 9 # 12 # 13 # SHOW TABLE STATUS WHERE name LIKE 't%'; # Make sure all the data is there. diff --git a/mysql-test/suite/rocksdb/include/bulk_load_unsorted.inc b/mysql-test/suite/rocksdb/include/bulk_load_unsorted.inc index 5cdc76a32d4..812af0401aa 100644 --- a/mysql-test/suite/rocksdb/include/bulk_load_unsorted.inc +++ b/mysql-test/suite/rocksdb/include/bulk_load_unsorted.inc @@ -119,12 +119,12 @@ set rocksdb_bulk_load=0; --remove_file $file # Make sure row count index stats are correct ---replace_column 6 # 7 # 8 # 9 # +--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 # +--replace_column 6 # 7 # 8 # 9 # 12 # 13 # SHOW TABLE STATUS WHERE name LIKE 't%'; # Make sure all the data is there. diff --git a/mysql-test/suite/rocksdb/r/bulk_load.result b/mysql-test/suite/rocksdb/r/bulk_load.result index a36f99a7619..76db28e66bd 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load.result +++ b/mysql-test/suite/rocksdb/r/bulk_load.result @@ -38,9 +38,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,9 +48,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned select count(pk) from t1; count(pk) 5000000 diff --git a/mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result b/mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result index b5d3e252c5d..ae363f7ec0c 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result +++ b/mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result @@ -38,9 +38,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,9 +48,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned select count(pk) from t1; count(pk) 5000000 diff --git a/mysql-test/suite/rocksdb/r/bulk_load_rev_cf_and_data.result b/mysql-test/suite/rocksdb/r/bulk_load_rev_cf_and_data.result index f46acd41080..dd8dd7e60a8 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load_rev_cf_and_data.result +++ b/mysql-test/suite/rocksdb/r/bulk_load_rev_cf_and_data.result @@ -38,9 +38,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,9 +48,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned select count(pk) from t1; count(pk) 5000000 diff --git a/mysql-test/suite/rocksdb/r/bulk_load_rev_data.result b/mysql-test/suite/rocksdb/r/bulk_load_rev_data.result index 3389968ef37..96738ae62e2 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load_rev_data.result +++ b/mysql-test/suite/rocksdb/r/bulk_load_rev_data.result @@ -38,9 +38,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,9 +48,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned select count(pk) from t1; count(pk) 5000000 diff --git a/mysql-test/suite/rocksdb/r/bulk_load_unsorted.result b/mysql-test/suite/rocksdb/r/bulk_load_unsorted.result index 924032549ac..87fc63af2da 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load_unsorted.result +++ b/mysql-test/suite/rocksdb/r/bulk_load_unsorted.result @@ -70,9 +70,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -80,9 +80,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned select count(a) from t1; count(a) 5000000 diff --git a/mysql-test/suite/rocksdb/r/bulk_load_unsorted_rev.result b/mysql-test/suite/rocksdb/r/bulk_load_unsorted_rev.result index 3cc9fb8e459..8e0914f0159 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load_unsorted_rev.result +++ b/mysql-test/suite/rocksdb/r/bulk_load_unsorted_rev.result @@ -70,9 +70,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -80,9 +80,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned select count(a) from t1; count(a) 5000000 diff --git a/mysql-test/suite/rocksdb/r/issue255.result b/mysql-test/suite/rocksdb/r/issue255.result index c1ce3be2276..b45b3b5afc7 100644 --- a/mysql-test/suite/rocksdb/r/issue255.result +++ b/mysql-test/suite/rocksdb/r/issue255.result @@ -2,7 +2,7 @@ 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 -t1 ROCKSDB # Fixed # # # # # # 6 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 6 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES ('538647864786478647864'); Warnings: Warning 1264 Out of range value for column 'pk' at row 1 @@ -12,7 +12,7 @@ pk 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 -t1 ROCKSDB 10 Fixed 2 22 44 0 0 0 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed 2 22 44 0 0 0 9223372036854775807 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES (); ERROR 23000: Duplicate entry '9223372036854775807' for key 'PRIMARY' SELECT * FROM t1; @@ -21,7 +21,7 @@ pk 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 -t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES (); ERROR 23000: Duplicate entry '9223372036854775807' for key 'PRIMARY' SELECT * FROM t1; @@ -30,13 +30,13 @@ pk 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 -t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 # # NULL latin1_swedish_ci NULL 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 -t1 ROCKSDB # Fixed # # # # # # 6 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 6 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES (1000); Warnings: Warning 1264 Out of range value for column 'pk' at row 1 @@ -46,7 +46,7 @@ pk 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 -t1 ROCKSDB # Fixed # # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 127 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES (); ERROR 23000: Duplicate entry '127' for key 'PRIMARY' SELECT * FROM t1; @@ -55,7 +55,7 @@ pk 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 -t1 ROCKSDB # Fixed # # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 127 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES (); ERROR 23000: Duplicate entry '127' for key 'PRIMARY' SELECT * FROM t1; @@ -64,5 +64,5 @@ pk 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 -t1 ROCKSDB # Fixed # # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 127 # # NULL latin1_swedish_ci NULL DROP TABLE t1; diff --git a/mysql-test/suite/rocksdb/r/rocksdb.result b/mysql-test/suite/rocksdb/r/rocksdb.result index 088eb050f6f..a631d58ac69 100644 --- a/mysql-test/suite/rocksdb/r/rocksdb.result +++ b/mysql-test/suite/rocksdb/r/rocksdb.result @@ -1417,7 +1417,7 @@ 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 -t1 ROCKSDB 10 Fixed 1000 0 # 0 0 0 3 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed 1000 0 # 0 0 0 3 # # NULL latin1_swedish_ci NULL drop table t1; # # Fix Issue #4: Crash when using pseudo-unique keys @@ -2612,7 +2612,7 @@ 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 -t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 3 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 3 # # NULL latin1_swedish_ci NULL SELECT * FROM t1; a -1 @@ -2623,7 +2623,7 @@ 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 -t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 12 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 12 # # NULL latin1_swedish_ci NULL SELECT * FROM t1; a 1 diff --git a/mysql-test/suite/rocksdb/r/show_table_status.result b/mysql-test/suite/rocksdb/r/show_table_status.result index 29140f045e4..cb6a9ca5984 100644 --- a/mysql-test/suite/rocksdb/r/show_table_status.result +++ b/mysql-test/suite/rocksdb/r/show_table_status.result @@ -7,12 +7,12 @@ 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 -t1 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL utf8_general_ci NULL +t1 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL utf8_general_ci NULL 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 -t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL latin1_swedish_ci NULL DROP TABLE t1, t2, t3; CREATE DATABASE `db_new..............................................end`; USE `db_new..............................................end`; @@ -22,3 +22,112 @@ SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.table_statistics WHERE T 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 sleep(2); +sleep(2) 0 +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'; +select sleep(2); +sleep(2) 0 +# Then, an in-place ALTER TABLE: +alter table t1 add key (a); +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 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 +# +# 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 +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/mysql-test/suite/rocksdb/r/truncate_table.result b/mysql-test/suite/rocksdb/r/truncate_table.result index 1544256f194..79b266a2453 100644 --- a/mysql-test/suite/rocksdb/r/truncate_table.result +++ b/mysql-test/suite/rocksdb/r/truncate_table.result @@ -9,19 +9,19 @@ 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 -t1 ROCKSDB 10 Fixed # # # 0 0 0 1 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed # # # 0 0 0 1 # # NULL latin1_swedish_ci NULL 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 -t1 ROCKSDB 10 Fixed # # # 0 0 0 4 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed # # # 0 0 0 4 # # NULL latin1_swedish_ci NULL 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 -t1 ROCKSDB 10 Fixed # # # 0 0 0 1 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed # # # 0 0 0 1 # # NULL latin1_swedish_ci NULL 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 -t1 ROCKSDB 10 Fixed # # # 0 0 0 2 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed # # # 0 0 0 2 # # NULL latin1_swedish_ci NULL SELECT a,c FROM t1; a c 1 d diff --git a/mysql-test/suite/rocksdb/t/issue255.test b/mysql-test/suite/rocksdb/t/issue255.test index 370dece0c6c..686f45b4056 100644 --- a/mysql-test/suite/rocksdb/t/issue255.test +++ b/mysql-test/suite/rocksdb/t/issue255.test @@ -3,24 +3,25 @@ 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 # +--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 # +--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 # +--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 # +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # SHOW TABLE STATUS LIKE 't1'; DROP TABLE t1; @@ -28,24 +29,24 @@ 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 # +--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 # +--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 # +--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 # +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # SHOW TABLE STATUS LIKE 't1'; DROP TABLE t1; diff --git a/mysql-test/suite/rocksdb/t/rocksdb.test b/mysql-test/suite/rocksdb/t/rocksdb.test index 5eff0fbf38f..7dcae569c92 100644 --- a/mysql-test/suite/rocksdb/t/rocksdb.test +++ b/mysql-test/suite/rocksdb/t/rocksdb.test @@ -1198,7 +1198,7 @@ drop table t1; create table t1 (i int primary key auto_increment) engine=RocksDB; insert into t1 values (null),(null); ---replace_column 7 # +--replace_column 7 # 12 # 13 # show table status like 't1'; drop table t1; @@ -1903,11 +1903,13 @@ DROP TABLE t1; # 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; diff --git a/mysql-test/suite/rocksdb/t/show_table_status.test b/mysql-test/suite/rocksdb/t/show_table_status.test index 29cc2ccfb5e..011302dab8b 100644 --- a/mysql-test/suite/rocksdb/t/show_table_status.test +++ b/mysql-test/suite/rocksdb/t/show_table_status.test @@ -1,5 +1,5 @@ --source include/have_rocksdb.inc - +--source include/have_partition.inc # # SHOW TABLE STATUS statement # @@ -24,7 +24,7 @@ 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 # +--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 @@ -48,7 +48,7 @@ set global rocksdb_force_flush_memtable_now = true; # 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 # +--replace_column 6 # 7 # 12 # 13 # SHOW TABLE STATUS WHERE name LIKE 't2'; DROP TABLE t1, t2, t3; @@ -62,3 +62,113 @@ CREATE TABLE `t1_new..............................................end`(a int) en 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 sleep(2); + +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'; + +select sleep(2); +--echo # Then, an in-place ALTER TABLE: +alter table t1 add key (a); + +select + create_time=@create_tm /* should not change */, + 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 # + +--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'; + +--source include/restart_mysqld.inc + +select sleep(2); +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/mysql-test/suite/rocksdb/t/truncate_table.test b/mysql-test/suite/rocksdb/t/truncate_table.test index a61488654a3..1001eeb6cde 100644 --- a/mysql-test/suite/rocksdb/t/truncate_table.test +++ b/mysql-test/suite/rocksdb/t/truncate_table.test @@ -29,22 +29,22 @@ DROP TABLE t1; 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 # +--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 # +--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 # +--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 # +--replace_column 5 # 6 # 7 # 12 # 13 # SHOW TABLE STATUS LIKE 't1'; --sorted_result diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index d6c89087bea..8e5ce292620 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -2456,6 +2456,8 @@ class Rdb_transaction { bool m_is_delayed_snapshot = false; bool m_is_two_phase = false; + std::unordered_set<Rdb_tbl_def*> modified_tables; + private: /* Number of write operations this transaction had when we took the last @@ -3139,6 +3141,25 @@ class Rdb_transaction { virtual void start_tx() = 0; virtual void start_stmt() = 0; + protected: + // Non-virtual functions with actions to be done on transaction start and + // commit. + void on_commit() { + time_t tm; + tm = time(nullptr); + for (auto &it : modified_tables) { + it->m_update_time = tm; + } + modified_tables.clear(); + } + void on_rollback() { + modified_tables.clear(); + } + public: + void log_table_write_op(Rdb_tbl_def *tbl) { + modified_tables.insert(tbl); + } + void set_initial_savepoint() { /* Set the initial savepoint. If the first statement in the transaction @@ -3322,7 +3343,9 @@ class Rdb_transaction_impl : public Rdb_transaction { goto error; } + on_commit(); error: + on_rollback(); /* Save the transaction object to be reused */ release_tx(); @@ -3338,6 +3361,7 @@ class Rdb_transaction_impl : public Rdb_transaction { public: void rollback() override { + on_rollback(); m_write_count = 0; m_insert_count = 0; m_update_count = 0; @@ -3659,7 +3683,9 @@ class Rdb_writebatch_impl : public Rdb_transaction { res = true; goto error; } + on_commit(); error: + on_rollback(); reset(); m_write_count = 0; @@ -3691,6 +3717,7 @@ class Rdb_writebatch_impl : public Rdb_transaction { } void rollback() override { + on_rollback(); m_write_count = 0; m_insert_count = 0; m_update_count = 0; @@ -7549,6 +7576,7 @@ int ha_rocksdb::create_table(const std::string &table_name, /* Create table/key descriptions and put them into the data dictionary */ m_tbl_def = new Rdb_tbl_def(table_name); + //m_tbl_def->set_create_time(time(nullptr)); uint n_keys = table_arg->s->keys; @@ -7696,7 +7724,6 @@ int ha_rocksdb::create(const char *const name, TABLE *const table_arg, DBUG_RETURN(HA_ERR_ROCKSDB_CORRUPT_DATA); } } - DBUG_RETURN(create_table(str, table_arg, create_info->auto_increment_value)); } @@ -10177,6 +10204,8 @@ int ha_rocksdb::update_write_row(const uchar *const old_data, row_info.tx->incr_insert_count(); } + row_info.tx->log_table_write_op(m_tbl_def); + if (do_bulk_commit(row_info.tx)) { DBUG_RETURN(HA_ERR_ROCKSDB_BULK_LOAD); } @@ -10648,6 +10677,7 @@ int ha_rocksdb::delete_row(const uchar *const buf) { } tx->incr_delete_count(); + tx->log_table_write_op(m_tbl_def); if (do_bulk_commit(tx)) { DBUG_RETURN(HA_ERR_ROCKSDB_BULK_LOAD); @@ -10802,6 +10832,12 @@ int ha_rocksdb::info(uint flag) { k->rec_per_key[j] = x; } } + + stats.create_time = m_tbl_def->get_create_time(); + } + + if (flag & HA_STATUS_TIME) { + stats.update_time = m_tbl_def->m_update_time; } if (flag & HA_STATUS_ERRKEY) { diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc index c0741a1ce9b..166b22c62ff 100644 --- a/storage/rocksdb/rdb_datadic.cc +++ b/storage/rocksdb/rdb_datadic.cc @@ -3563,6 +3563,26 @@ bool Rdb_tbl_def::put_dict(Rdb_dict_manager *const dict, return false; } +time_t Rdb_tbl_def::get_create_time() { + time_t create_time = m_create_time; + + if (create_time == CREATE_TIME_UNKNOWN) { + // Read it from the .frm file. It's not a problem if several threads do this + // concurrently + char path[FN_REFLEN]; + snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home, + m_dbname.c_str(), m_tablename.c_str(), reg_ext); + unpack_filename(path,path); + MY_STAT f_stat; + if (my_stat(path, &f_stat, MYF(0))) + create_time = f_stat.st_ctime; + else + create_time = 0; // will be shown as SQL NULL + m_create_time = create_time; + } + return create_time; +} + // Length that each index flag takes inside the record. // Each index in the array maps to the enum INDEX_FLAG static const std::array<uint, 1> index_flag_lengths = { diff --git a/storage/rocksdb/rdb_datadic.h b/storage/rocksdb/rdb_datadic.h index 416857cad38..0bf1372410f 100644 --- a/storage/rocksdb/rdb_datadic.h +++ b/storage/rocksdb/rdb_datadic.h @@ -1094,7 +1094,9 @@ class Rdb_tbl_def { : m_key_descr_arr(nullptr), m_hidden_pk_val(0), m_auto_incr_val(0), - m_tbl_stats() { + m_tbl_stats(), + m_update_time(0), + m_create_time(CREATE_TIME_UNKNOWN) { set_name(name); } @@ -1102,7 +1104,9 @@ class Rdb_tbl_def { : m_key_descr_arr(nullptr), m_hidden_pk_val(0), m_auto_incr_val(0), - m_tbl_stats() { + m_tbl_stats(), + m_update_time(0), + m_create_time(CREATE_TIME_UNKNOWN) { set_name(std::string(name, len)); } @@ -1110,7 +1114,9 @@ class Rdb_tbl_def { : m_key_descr_arr(nullptr), m_hidden_pk_val(0), m_auto_incr_val(0), - m_tbl_stats() { + m_tbl_stats(), + m_update_time(0), + m_create_time(CREATE_TIME_UNKNOWN) { set_name(std::string(slice.data() + pos, slice.size() - pos)); } @@ -1161,6 +1167,14 @@ class Rdb_tbl_def { const std::string &base_tablename() const { return m_tablename; } const std::string &base_partition() const { return m_partition; } GL_INDEX_ID get_autoincr_gl_index_id(); + + time_t get_create_time(); + std::atomic<time_t> m_update_time; // in-memory only value + private: + const time_t CREATE_TIME_UNKNOWN = 1; + // CREATE_TIME_UNKNOWN means "didn't try to read, yet" + // 0 means "no data available" + std::atomic<time_t> m_create_time; }; /*
1 0
0 0
[Commits] d4edb0510ec: MDEV-20646: 10.3.18 is slower than 10.3.17
by psergey 13 Nov '19

13 Nov '19
revision-id: d4edb0510ec1189f65850bb47977e94ed98b1f71 (mariadb-10.3.20-5-gd4edb0510ec) parent(s): 5098d708a07f90484c9e13fe3ab58113a8a10191 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2019-11-13 18:53:59 +0300 message: MDEV-20646: 10.3.18 is slower than 10.3.17 Fix incorrect change introduced in the fix for MDEV-20109. The patch tried to compute a more precise estimate for the record_count value in SJ-Materialization-Scan strategy (in Sj_materialization_picker::check_qep). However the new formula is worse as it produces extremely optimistic results in common cases where SJ-Materialization-Scan should be used) The old formula produces pessimistic results in cases when Sj-Materialization- Scan is unlikely to be a good choice anyway. So, the old behavior is better. --- mysql-test/main/subselect_sj2_mat.result | 14 +++++++------- mysql-test/main/subselect_sj_jcl6.result | 8 ++++---- sql/opt_subselect.cc | 17 ++++++++++++++++- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/mysql-test/main/subselect_sj2_mat.result b/mysql-test/main/subselect_sj2_mat.result index dd9f560aeed..ab3e4652deb 100644 --- a/mysql-test/main/subselect_sj2_mat.result +++ b/mysql-test/main/subselect_sj2_mat.result @@ -1855,18 +1855,18 @@ AND t3.id_product IN (SELECT id_product FROM t2 t2_3 WHERE t2_3.id_t2 = 18 OR t2 AND t3.id_product IN (SELECT id_product FROM t2 t2_4 WHERE t2_4.id_t2 = 34 OR t2_4.id_t2 = 23) AND t3.id_product IN (SELECT id_product FROM t2 t2_5 WHERE t2_5.id_t2 = 29 OR t2_5.id_t2 = 28 OR t2_5.id_t2 = 26); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 12 -1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t2_2.id_product 1 Using where; Using index +1 PRIMARY t1 index NULL PRIMARY 8 NULL 73 Using index +1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t1.id_product 1 Using index 1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 4 func 1 Using where 1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 4 func 1 Using where -1 PRIMARY <subquery6> eq_ref distinct_key distinct_key 4 func 1 Using where +1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 Using where 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 Using where +1 PRIMARY t4 eq_ref PRIMARY PRIMARY 8 test.t1.id_product,const 1 Using where; Using index +1 PRIMARY <subquery6> eq_ref distinct_key distinct_key 4 func 1 Using where 1 PRIMARY t5 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) -1 PRIMARY t4 eq_ref PRIMARY PRIMARY 8 test.t3.id_product,const 1 Using where; Using index -1 PRIMARY t1 index NULL PRIMARY 8 NULL 73 Using where; Using index; Using join buffer (flat, BNL join) -3 MATERIALIZED t2_2 ref id_t2,id_product id_t2 5 const 12 Using where 5 MATERIALIZED t2_4 range id_t2,id_product id_t2 5 NULL 18 Using index condition; Using where 4 MATERIALIZED t2_3 range id_t2,id_product id_t2 5 NULL 32 Using index condition; Using where -6 MATERIALIZED t2_5 range id_t2,id_product id_t2 5 NULL 30 Using index condition; Using where +3 MATERIALIZED t2_2 ref id_t2,id_product id_t2 5 const 12 2 MATERIALIZED t2_1 ref id_t2,id_product id_t2 5 const 50 +6 MATERIALIZED t2_5 range id_t2,id_product id_t2 5 NULL 30 Using index condition; Using where drop table t1,t2,t3,t4,t5; diff --git a/mysql-test/main/subselect_sj_jcl6.result b/mysql-test/main/subselect_sj_jcl6.result index 6278b5a0cf5..e9a19b2a1c3 100644 --- a/mysql-test/main/subselect_sj_jcl6.result +++ b/mysql-test/main/subselect_sj_jcl6.result @@ -3527,8 +3527,8 @@ EXPLAIN SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a) GROUP BY a HAVING a != 'z'; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 Using temporary; Using filesort -1 PRIMARY t ref idx_a idx_a 4 test.t2.b 2 Using index +1 PRIMARY t index idx_a idx_a 4 NULL 3 Using index +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where 2 MATERIALIZED t1 ref idx_a idx_a 4 test.t2.b 2 Using index SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a) @@ -3541,8 +3541,8 @@ EXPLAIN SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a) GROUP BY a HAVING a != 'z'; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 Using temporary; Using filesort -1 PRIMARY t ref idx_a idx_a 4 test.t2.b 2 Using index +1 PRIMARY t index idx_a idx_a 4 NULL 3 Using index +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where 2 MATERIALIZED t1 ref idx_a idx_a 4 test.t2.b 2 Using index SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a) diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index aeafc13998a..a8afd952a4d 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -3029,7 +3029,22 @@ bool Sj_materialization_picker::check_qep(JOIN *join, *strategy= SJ_OPT_MATERIALIZE_SCAN; *read_time= prefix_cost; - *record_count= prefix_rec_count / mat_info->rows_with_duplicates; + /* + Note: the next line means we did not remove the subquery's fanout from + *record_count. It needs to be removed, as the join prefix is + + ntX SJM-SCAN(it1 ... itN) | (ot1 ... otN) ... + + here, the SJM-SCAN may have introduced subquery's fanout (duplicate rows, + rows that don't have matches in ot1_i). All this fanout is gone after + table otN (or earlier) but taking it into account is hard. + + Some consolation here is that SJM-Scan strategy is applicable when the + subquery is smaller than tables otX. If the subquery has large cardinality, + we can greatly overestimate *record_count here, but it doesn't matter as + SJ-Materialization-Lookup is a better strategy anyway. + */ + *record_count= prefix_rec_count; *handled_fanout= mat_nest->sj_inner_tables; return TRUE; }
1 0
0 0
f72427f463d: MDEV-20923:UBSAN: member access within address … which does not point to an object of type 'xid_count_per_binlog'
by sujatha 12 Nov '19

12 Nov '19
revision-id: f72427f463d316a54ebf87c2e84c73947e3c5fe4 (mariadb-10.1.43-5-gf72427f463d) parent(s): 13db50fc03e7312e6c01b06c7e4af69f69ba5382 author: Sujatha committer: Sujatha timestamp: 2019-11-12 16:11:16 +0530 message: MDEV-20923:UBSAN: member access within address … which does not point to an object of type 'xid_count_per_binlog' Problem: ------- Accessing a member within 'xid_count_per_binlog' structure results in following error when 'UBSAN' is enabled. member access within address 0xXXX which does not point to an object of type 'xid_count_per_binlog' Analysis: --------- The problem appears to be that no constructor for 'xid_count_per_binlog' is being called, and thus the vtable will not be initialized. Fix: --- Defined a parameterized constructor for 'xid_count_per_binlog' class. --- sql/log.cc | 28 ++++++++++++++-------------- sql/log.h | 9 ++++++++- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index acf1f8f8a9c..2b8b67febef 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -3216,7 +3216,7 @@ void MYSQL_BIN_LOG::cleanup() DBUG_ASSERT(!binlog_xid_count_list.head()); WSREP_XID_LIST_ENTRY("MYSQL_BIN_LOG::cleanup(): Removing xid_list_entry " "for %s (%lu)", b); - my_free(b); + delete b; } mysql_mutex_destroy(&LOCK_log); @@ -3580,17 +3580,17 @@ bool MYSQL_BIN_LOG::open(const char *log_name, */ uint off= dirname_length(log_file_name); uint len= strlen(log_file_name) - off; - char *entry_mem, *name_mem; - if (!(new_xid_list_entry = (xid_count_per_binlog *) - my_multi_malloc(MYF(MY_WME), - &entry_mem, sizeof(xid_count_per_binlog), - &name_mem, len, - NULL))) + char *name_mem; + name_mem= (char *) my_malloc(len, MYF(MY_ZEROFILL)); + if (!name_mem) goto err; memcpy(name_mem, log_file_name+off, len); - new_xid_list_entry->binlog_name= name_mem; - new_xid_list_entry->binlog_name_len= len; - new_xid_list_entry->xid_count= 0; + new_xid_list_entry= new xid_count_per_binlog(name_mem, (int)len); + if (!new_xid_list_entry) + { + my_free(name_mem); + goto err; + } /* Find the name for the Initial binlog checkpoint. @@ -3711,7 +3711,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name, { WSREP_XID_LIST_ENTRY("MYSQL_BIN_LOG::open(): Removing xid_list_entry for " "%s (%lu)", b); - my_free(binlog_xid_count_list.get()); + delete binlog_xid_count_list.get(); } mysql_cond_broadcast(&COND_xid_list); WSREP_XID_LIST_ENTRY("MYSQL_BIN_LOG::open(): Adding new xid_list_entry for " @@ -3758,7 +3758,7 @@ Turning logging off for the whole duration of the MySQL server process. \ To turn it on again: fix the cause, \ shutdown the MySQL server and restart it.", name, errno); if (new_xid_list_entry) - my_free(new_xid_list_entry); + delete new_xid_list_entry; if (file >= 0) mysql_file_close(file, MYF(0)); close(LOG_CLOSE_INDEX); @@ -4252,7 +4252,7 @@ bool MYSQL_BIN_LOG::reset_logs(THD *thd, bool create_new_log, DBUG_ASSERT(b->xid_count == 0); WSREP_XID_LIST_ENTRY("MYSQL_BIN_LOG::reset_logs(): Removing " "xid_list_entry for %s (%lu)", b); - my_free(binlog_xid_count_list.get()); + delete binlog_xid_count_list.get(); } mysql_cond_broadcast(&COND_xid_list); reset_master_pending--; @@ -9736,7 +9736,7 @@ TC_LOG_BINLOG::mark_xid_done(ulong binlog_id, bool write_checkpoint) break; WSREP_XID_LIST_ENTRY("TC_LOG_BINLOG::mark_xid_done(): Removing " "xid_list_entry for %s (%lu)", b); - my_free(binlog_xid_count_list.get()); + delete binlog_xid_count_list.get(); } mysql_mutex_unlock(&LOCK_xid_list); diff --git a/sql/log.h b/sql/log.h index b4c9b24a3a9..30a55e577a4 100644 --- a/sql/log.h +++ b/sql/log.h @@ -587,7 +587,14 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG long xid_count; /* For linking in requests to the binlog background thread. */ xid_count_per_binlog *next_in_queue; - xid_count_per_binlog(); /* Give link error if constructor used. */ + xid_count_per_binlog(char *log_file_name, uint log_file_name_len) + :binlog_name(log_file_name), binlog_name_len(log_file_name_len), + binlog_id(0), xid_count(0) + {} + ~xid_count_per_binlog() + { + my_free(binlog_name); + } }; I_List<xid_count_per_binlog> binlog_xid_count_list; mysql_mutex_t LOCK_binlog_background_thread;
1 0
0 0
[Commits] 9769baf3fc0: MDEV-20922: Adding an order by changes the query results
by Varun 08 Nov '19

08 Nov '19
revision-id: 9769baf3fc0ad550bb8c2175c206a33e4c635299 (mariadb-10.1.41-86-g9769baf3fc0) parent(s): 4e99e67c4e8a04bd03cb0e7efc2ce0129af60c34 author: Varun Gupta committer: Varun Gupta timestamp: 2019-11-08 13:51:34 +0530 message: MDEV-20922: Adding an order by changes the query results In the case of sorting the first non-const table, sort key should be made by the items referring to the base table and not to the temporary table. --- mysql-test/r/derived.result | 31 +++++++++++++++++++++++++++++++ mysql-test/t/derived.test | 25 +++++++++++++++++++++++++ sql/filesort.cc | 4 ++-- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index be241c0e928..9f825ffa993 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -1164,5 +1164,36 @@ a 5 DROP TABLE t1; # +# MDEV-20922: Adding an order by changes the query results +# +CREATE TABLE t1(a int, b int); +INSERT INTO t1 values (1, 1), (2, 2), (3, 1), (4, 2); +explain SELECT q.x, COUNT(DISTINCT q.a) AS y +FROM (select b+1 as x, a FROM t1)q +GROUP BY x ORDER BY y; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort +SELECT q.x, COUNT(DISTINCT q.a) AS y +FROM (select b+1 as x, a FROM t1)q +GROUP BY x ORDER BY y; +x y +2 2 +3 2 +set optimizer_switch='derived_merge=off'; +explain SELECT q.x, COUNT(DISTINCT q.a) AS y +FROM (select b+1 as x, a FROM t1)q +GROUP BY x ORDER BY y; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 Using temporary; Using filesort +2 DERIVED t1 ALL NULL NULL NULL NULL 4 +SELECT q.x, COUNT(DISTINCT q.a) AS y +FROM (select b+1 as x, a FROM t1)q +GROUP BY x ORDER BY y; +x y +2 2 +3 2 +set optimizer_switch= @save_derived_optimizer_switch; +drop table t1; +# # End of 10.1 tests # diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 470060d83db..87c332df01a 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -990,6 +990,31 @@ SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a=1; SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a='5' AND a=1; DROP TABLE t1; +--echo # +--echo # MDEV-20922: Adding an order by changes the query results +--echo # + +CREATE TABLE t1(a int, b int); +INSERT INTO t1 values (1, 1), (2, 2), (3, 1), (4, 2); + +let $query= SELECT q.x, COUNT(DISTINCT q.a) AS y + FROM (select b+1 as x, a FROM t1)q + GROUP BY x ORDER BY y; + +eval explain $query; +eval $query; + +set optimizer_switch='derived_merge=off'; +let $query= SELECT q.x, COUNT(DISTINCT q.a) AS y + FROM (select b+1 as x, a FROM t1)q + GROUP BY x ORDER BY y; + +eval explain $query; +eval $query; + +set optimizer_switch= @save_derived_optimizer_switch; +drop table t1; + --echo # --echo # End of 10.1 tests --echo # diff --git a/sql/filesort.cc b/sql/filesort.cc index 4f195f68059..648e1d58747 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -987,8 +987,8 @@ static void make_sortkey(Sort_param *param, } else { // Item - Item *item=sort_field->item; - maybe_null= item->maybe_null; + Item *item=sort_field->item->real_item(); + maybe_null= sort_field->item->maybe_null; switch (sort_field->result_type) { case STRING_RESULT: {
1 0
0 0
[Commits] 92cedc1a081: MDEV-20953: binlog_encryption.rpl_corruption failed in buildbot due to wrong error code
by sujatha 05 Nov '19

05 Nov '19
revision-id: 92cedc1a081fe08b0390baceb742b8bee4ae1c81 (mariadb-10.1.41-83-g92cedc1a081) parent(s): dc771113a6b7a3256672e72842a657c8e27f35a8 author: Sujatha committer: Sujatha timestamp: 2019-11-05 15:01:29 +0530 message: MDEV-20953: binlog_encryption.rpl_corruption failed in buildbot due to wrong error code Problem: ======== CURRENT_TEST: binlog_encryption.rpl_corruption mysqltest: In included file "./include/wait_for_slave_io_error.inc": ... At line 72: Slave stopped with wrong error code **** Slave stopped with wrong error code: 1743 (expected 1595,1913) **** Analysis: ======== The test emulates the corruption at the various stages of replication for example in binlog file, in network and in relay log etc. It verifies that all corruption cases are handled through appropriate error messages. The test cases which emulate network failure expect following errors. --ER_SLAVE_RELAY_LOG_WRITE_FAILURE (1595) --ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE (1743) Ideally test should expect error codes as 1595 and 1743. But the test actually waits on incorrect error code 1595,1913 Fix: === Added appropriate error code for 'ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE'. Replaced 1913 with 1743. --- mysql-test/extra/rpl_tests/rpl_corruption.inc | 8 ++++---- mysql-test/suite/binlog_encryption/rpl_corruption.result | 4 ++-- mysql-test/suite/rpl/r/rpl_corruption.result | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mysql-test/extra/rpl_tests/rpl_corruption.inc b/mysql-test/extra/rpl_tests/rpl_corruption.inc index 048a9d74249..1726ee4ba2f 100644 --- a/mysql-test/extra/rpl_tests/rpl_corruption.inc +++ b/mysql-test/extra/rpl_tests/rpl_corruption.inc @@ -122,11 +122,11 @@ SET GLOBAL master_verify_checksum=0; SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set"; --connection slave START SLAVE IO_THREAD; -# When the checksum error is detected, the slave sets error code 1913 +# When the checksum error is detected, the slave sets error code 1743 # (ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE) in queue_event(), then immediately # sets error 1595 (ER_SLAVE_RELAY_LOG_WRITE_FAILURE) in handle_slave_io(). -# So we usually get 1595, but it is occasionally possible to get 1913. -let $slave_io_errno= 1595,1913; +# So we usually get 1595, but it is occasionally possible to get 1743. +let $slave_io_errno= 1595,1743; # ER_SLAVE_RELAY_LOG_WRITE_FAILURE, ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE --source include/wait_for_slave_io_error.inc --connection master SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; @@ -138,7 +138,7 @@ SET GLOBAL master_verify_checksum=1; --connection slave SET GLOBAL debug_dbug="+d,corrupt_queue_event"; START SLAVE IO_THREAD; -let $slave_io_errno= 1595,1913; +let $slave_io_errno= 1595,1743; # ER_SLAVE_RELAY_LOG_WRITE_FAILURE, ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE --source include/wait_for_slave_io_error.inc SET GLOBAL debug_dbug="-d,corrupt_queue_event"; diff --git a/mysql-test/suite/binlog_encryption/rpl_corruption.result b/mysql-test/suite/binlog_encryption/rpl_corruption.result index 51c2c6261b8..05db91bf058 100644 --- a/mysql-test/suite/binlog_encryption/rpl_corruption.result +++ b/mysql-test/suite/binlog_encryption/rpl_corruption.result @@ -25,14 +25,14 @@ SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; SET GLOBAL master_verify_checksum=0; SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set"; START SLAVE IO_THREAD; -include/wait_for_slave_io_error.inc [errno=1595,1913] +include/wait_for_slave_io_error.inc [errno=1595,1743] SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; SET GLOBAL debug_dbug= ""; SET GLOBAL master_verify_checksum=1; # 5. Slave. Corruption in network SET GLOBAL debug_dbug="+d,corrupt_queue_event"; START SLAVE IO_THREAD; -include/wait_for_slave_io_error.inc [errno=1595,1913] +include/wait_for_slave_io_error.inc [errno=1595,1743] SET GLOBAL debug_dbug="-d,corrupt_queue_event"; # 6. Slave. Corruption in relay log SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char"; diff --git a/mysql-test/suite/rpl/r/rpl_corruption.result b/mysql-test/suite/rpl/r/rpl_corruption.result index 51c2c6261b8..05db91bf058 100644 --- a/mysql-test/suite/rpl/r/rpl_corruption.result +++ b/mysql-test/suite/rpl/r/rpl_corruption.result @@ -25,14 +25,14 @@ SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; SET GLOBAL master_verify_checksum=0; SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set"; START SLAVE IO_THREAD; -include/wait_for_slave_io_error.inc [errno=1595,1913] +include/wait_for_slave_io_error.inc [errno=1595,1743] SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; SET GLOBAL debug_dbug= ""; SET GLOBAL master_verify_checksum=1; # 5. Slave. Corruption in network SET GLOBAL debug_dbug="+d,corrupt_queue_event"; START SLAVE IO_THREAD; -include/wait_for_slave_io_error.inc [errno=1595,1913] +include/wait_for_slave_io_error.inc [errno=1595,1743] SET GLOBAL debug_dbug="-d,corrupt_queue_event"; # 6. Slave. Corruption in relay log SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char";
1 0
0 0
[Commits] 44a9d52471b: Support Create_time and Update_time in MyRocks table status
by psergey 04 Nov '19

04 Nov '19
revision-id: 44a9d52471b8b73c5a0728f90d2654c9a641cdb9 (fb-prod201903-144-g44a9d52471b) parent(s): d97c0c628e5dc60abd725f6a7120a8d87b09321e author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2019-11-04 15:51:41 +0300 message: Support Create_time and Update_time in MyRocks table status (Variant #7 of the patch) The implementation follows InnoDB: - Create_time is taken from the .frm file creation timestamp - Update_time is maintained in memory only and is set NULL on server restart --- mysql-test/suite/rocksdb/include/bulk_load.inc | 4 +- .../suite/rocksdb/include/bulk_load_unsorted.inc | 4 +- mysql-test/suite/rocksdb/r/bulk_load.result | 12 +-- mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result | 12 +-- .../rocksdb/r/bulk_load_rev_cf_and_data.result | 12 +-- .../suite/rocksdb/r/bulk_load_rev_data.result | 12 +-- .../suite/rocksdb/r/bulk_load_unsorted.result | 12 +-- .../suite/rocksdb/r/bulk_load_unsorted_rev.result | 12 +-- mysql-test/suite/rocksdb/r/issue255.result | 16 +-- mysql-test/suite/rocksdb/r/rocksdb.result | 6 +- .../suite/rocksdb/r/show_table_status.result | 117 ++++++++++++++++++++- mysql-test/suite/rocksdb/r/truncate_table.result | 8 +- mysql-test/suite/rocksdb/t/issue255.test | 17 +-- mysql-test/suite/rocksdb/t/rocksdb.test | 4 +- mysql-test/suite/rocksdb/t/show_table_status.test | 116 +++++++++++++++++++- mysql-test/suite/rocksdb/t/truncate_table.test | 8 +- storage/rocksdb/ha_rocksdb.cc | 45 +++++++- storage/rocksdb/rdb_datadic.cc | 20 ++++ storage/rocksdb/rdb_datadic.h | 20 +++- 19 files changed, 377 insertions(+), 80 deletions(-) diff --git a/mysql-test/suite/rocksdb/include/bulk_load.inc b/mysql-test/suite/rocksdb/include/bulk_load.inc index 1b79825e507..7e163602202 100644 --- a/mysql-test/suite/rocksdb/include/bulk_load.inc +++ b/mysql-test/suite/rocksdb/include/bulk_load.inc @@ -121,12 +121,12 @@ set rocksdb_bulk_load=0; --remove_file $file # Make sure row count index stats are correct ---replace_column 6 # 7 # 8 # 9 # +--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 # +--replace_column 6 # 7 # 8 # 9 # 12 # 13 # SHOW TABLE STATUS WHERE name LIKE 't%'; # Make sure all the data is there. diff --git a/mysql-test/suite/rocksdb/include/bulk_load_unsorted.inc b/mysql-test/suite/rocksdb/include/bulk_load_unsorted.inc index 5cdc76a32d4..812af0401aa 100644 --- a/mysql-test/suite/rocksdb/include/bulk_load_unsorted.inc +++ b/mysql-test/suite/rocksdb/include/bulk_load_unsorted.inc @@ -119,12 +119,12 @@ set rocksdb_bulk_load=0; --remove_file $file # Make sure row count index stats are correct ---replace_column 6 # 7 # 8 # 9 # +--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 # +--replace_column 6 # 7 # 8 # 9 # 12 # 13 # SHOW TABLE STATUS WHERE name LIKE 't%'; # Make sure all the data is there. diff --git a/mysql-test/suite/rocksdb/r/bulk_load.result b/mysql-test/suite/rocksdb/r/bulk_load.result index a36f99a7619..76db28e66bd 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load.result +++ b/mysql-test/suite/rocksdb/r/bulk_load.result @@ -38,9 +38,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,9 +48,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned select count(pk) from t1; count(pk) 5000000 diff --git a/mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result b/mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result index b5d3e252c5d..ae363f7ec0c 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result +++ b/mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result @@ -38,9 +38,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,9 +48,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned select count(pk) from t1; count(pk) 5000000 diff --git a/mysql-test/suite/rocksdb/r/bulk_load_rev_cf_and_data.result b/mysql-test/suite/rocksdb/r/bulk_load_rev_cf_and_data.result index f46acd41080..dd8dd7e60a8 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load_rev_cf_and_data.result +++ b/mysql-test/suite/rocksdb/r/bulk_load_rev_cf_and_data.result @@ -38,9 +38,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,9 +48,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned select count(pk) from t1; count(pk) 5000000 diff --git a/mysql-test/suite/rocksdb/r/bulk_load_rev_data.result b/mysql-test/suite/rocksdb/r/bulk_load_rev_data.result index 3389968ef37..96738ae62e2 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load_rev_data.result +++ b/mysql-test/suite/rocksdb/r/bulk_load_rev_data.result @@ -38,9 +38,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,9 +48,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned select count(pk) from t1; count(pk) 5000000 diff --git a/mysql-test/suite/rocksdb/r/bulk_load_unsorted.result b/mysql-test/suite/rocksdb/r/bulk_load_unsorted.result index 924032549ac..87fc63af2da 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load_unsorted.result +++ b/mysql-test/suite/rocksdb/r/bulk_load_unsorted.result @@ -70,9 +70,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -80,9 +80,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned select count(a) from t1; count(a) 5000000 diff --git a/mysql-test/suite/rocksdb/r/bulk_load_unsorted_rev.result b/mysql-test/suite/rocksdb/r/bulk_load_unsorted_rev.result index 3cc9fb8e459..8e0914f0159 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load_unsorted_rev.result +++ b/mysql-test/suite/rocksdb/r/bulk_load_unsorted_rev.result @@ -70,9 +70,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -80,9 +80,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned select count(a) from t1; count(a) 5000000 diff --git a/mysql-test/suite/rocksdb/r/issue255.result b/mysql-test/suite/rocksdb/r/issue255.result index c1ce3be2276..b45b3b5afc7 100644 --- a/mysql-test/suite/rocksdb/r/issue255.result +++ b/mysql-test/suite/rocksdb/r/issue255.result @@ -2,7 +2,7 @@ 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 -t1 ROCKSDB # Fixed # # # # # # 6 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 6 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES ('538647864786478647864'); Warnings: Warning 1264 Out of range value for column 'pk' at row 1 @@ -12,7 +12,7 @@ pk 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 -t1 ROCKSDB 10 Fixed 2 22 44 0 0 0 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed 2 22 44 0 0 0 9223372036854775807 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES (); ERROR 23000: Duplicate entry '9223372036854775807' for key 'PRIMARY' SELECT * FROM t1; @@ -21,7 +21,7 @@ pk 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 -t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES (); ERROR 23000: Duplicate entry '9223372036854775807' for key 'PRIMARY' SELECT * FROM t1; @@ -30,13 +30,13 @@ pk 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 -t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 # # NULL latin1_swedish_ci NULL 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 -t1 ROCKSDB # Fixed # # # # # # 6 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 6 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES (1000); Warnings: Warning 1264 Out of range value for column 'pk' at row 1 @@ -46,7 +46,7 @@ pk 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 -t1 ROCKSDB # Fixed # # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 127 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES (); ERROR 23000: Duplicate entry '127' for key 'PRIMARY' SELECT * FROM t1; @@ -55,7 +55,7 @@ pk 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 -t1 ROCKSDB # Fixed # # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 127 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES (); ERROR 23000: Duplicate entry '127' for key 'PRIMARY' SELECT * FROM t1; @@ -64,5 +64,5 @@ pk 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 -t1 ROCKSDB # Fixed # # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 127 # # NULL latin1_swedish_ci NULL DROP TABLE t1; diff --git a/mysql-test/suite/rocksdb/r/rocksdb.result b/mysql-test/suite/rocksdb/r/rocksdb.result index 088eb050f6f..a631d58ac69 100644 --- a/mysql-test/suite/rocksdb/r/rocksdb.result +++ b/mysql-test/suite/rocksdb/r/rocksdb.result @@ -1417,7 +1417,7 @@ 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 -t1 ROCKSDB 10 Fixed 1000 0 # 0 0 0 3 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed 1000 0 # 0 0 0 3 # # NULL latin1_swedish_ci NULL drop table t1; # # Fix Issue #4: Crash when using pseudo-unique keys @@ -2612,7 +2612,7 @@ 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 -t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 3 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 3 # # NULL latin1_swedish_ci NULL SELECT * FROM t1; a -1 @@ -2623,7 +2623,7 @@ 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 -t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 12 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 12 # # NULL latin1_swedish_ci NULL SELECT * FROM t1; a 1 diff --git a/mysql-test/suite/rocksdb/r/show_table_status.result b/mysql-test/suite/rocksdb/r/show_table_status.result index 29140f045e4..cb6a9ca5984 100644 --- a/mysql-test/suite/rocksdb/r/show_table_status.result +++ b/mysql-test/suite/rocksdb/r/show_table_status.result @@ -7,12 +7,12 @@ 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 -t1 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL utf8_general_ci NULL +t1 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL utf8_general_ci NULL 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 -t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL latin1_swedish_ci NULL DROP TABLE t1, t2, t3; CREATE DATABASE `db_new..............................................end`; USE `db_new..............................................end`; @@ -22,3 +22,112 @@ SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.table_statistics WHERE T 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 sleep(2); +sleep(2) 0 +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'; +select sleep(2); +sleep(2) 0 +# Then, an in-place ALTER TABLE: +alter table t1 add key (a); +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 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 +# +# 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 +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/mysql-test/suite/rocksdb/r/truncate_table.result b/mysql-test/suite/rocksdb/r/truncate_table.result index 1544256f194..79b266a2453 100644 --- a/mysql-test/suite/rocksdb/r/truncate_table.result +++ b/mysql-test/suite/rocksdb/r/truncate_table.result @@ -9,19 +9,19 @@ 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 -t1 ROCKSDB 10 Fixed # # # 0 0 0 1 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed # # # 0 0 0 1 # # NULL latin1_swedish_ci NULL 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 -t1 ROCKSDB 10 Fixed # # # 0 0 0 4 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed # # # 0 0 0 4 # # NULL latin1_swedish_ci NULL 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 -t1 ROCKSDB 10 Fixed # # # 0 0 0 1 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed # # # 0 0 0 1 # # NULL latin1_swedish_ci NULL 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 -t1 ROCKSDB 10 Fixed # # # 0 0 0 2 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed # # # 0 0 0 2 # # NULL latin1_swedish_ci NULL SELECT a,c FROM t1; a c 1 d diff --git a/mysql-test/suite/rocksdb/t/issue255.test b/mysql-test/suite/rocksdb/t/issue255.test index 370dece0c6c..686f45b4056 100644 --- a/mysql-test/suite/rocksdb/t/issue255.test +++ b/mysql-test/suite/rocksdb/t/issue255.test @@ -3,24 +3,25 @@ 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 # +--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 # +--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 # +--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 # +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # SHOW TABLE STATUS LIKE 't1'; DROP TABLE t1; @@ -28,24 +29,24 @@ 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 # +--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 # +--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 # +--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 # +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # SHOW TABLE STATUS LIKE 't1'; DROP TABLE t1; diff --git a/mysql-test/suite/rocksdb/t/rocksdb.test b/mysql-test/suite/rocksdb/t/rocksdb.test index 5eff0fbf38f..7dcae569c92 100644 --- a/mysql-test/suite/rocksdb/t/rocksdb.test +++ b/mysql-test/suite/rocksdb/t/rocksdb.test @@ -1198,7 +1198,7 @@ drop table t1; create table t1 (i int primary key auto_increment) engine=RocksDB; insert into t1 values (null),(null); ---replace_column 7 # +--replace_column 7 # 12 # 13 # show table status like 't1'; drop table t1; @@ -1903,11 +1903,13 @@ DROP TABLE t1; # 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; diff --git a/mysql-test/suite/rocksdb/t/show_table_status.test b/mysql-test/suite/rocksdb/t/show_table_status.test index 29cc2ccfb5e..011302dab8b 100644 --- a/mysql-test/suite/rocksdb/t/show_table_status.test +++ b/mysql-test/suite/rocksdb/t/show_table_status.test @@ -1,5 +1,5 @@ --source include/have_rocksdb.inc - +--source include/have_partition.inc # # SHOW TABLE STATUS statement # @@ -24,7 +24,7 @@ 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 # +--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 @@ -48,7 +48,7 @@ set global rocksdb_force_flush_memtable_now = true; # 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 # +--replace_column 6 # 7 # 12 # 13 # SHOW TABLE STATUS WHERE name LIKE 't2'; DROP TABLE t1, t2, t3; @@ -62,3 +62,113 @@ CREATE TABLE `t1_new..............................................end`(a int) en 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 sleep(2); + +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'; + +select sleep(2); +--echo # Then, an in-place ALTER TABLE: +alter table t1 add key (a); + +select + create_time=@create_tm /* should not change */, + 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 # + +--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'; + +--source include/restart_mysqld.inc + +select sleep(2); +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/mysql-test/suite/rocksdb/t/truncate_table.test b/mysql-test/suite/rocksdb/t/truncate_table.test index a61488654a3..1001eeb6cde 100644 --- a/mysql-test/suite/rocksdb/t/truncate_table.test +++ b/mysql-test/suite/rocksdb/t/truncate_table.test @@ -29,22 +29,22 @@ DROP TABLE t1; 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 # +--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 # +--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 # +--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 # +--replace_column 5 # 6 # 7 # 12 # 13 # SHOW TABLE STATUS LIKE 't1'; --sorted_result diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index d6c89087bea..d90233f2d24 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -2456,6 +2456,8 @@ class Rdb_transaction { bool m_is_delayed_snapshot = false; bool m_is_two_phase = false; + std::unordered_set<Rdb_tbl_def*> modified_tables; + private: /* Number of write operations this transaction had when we took the last @@ -3139,6 +3141,25 @@ class Rdb_transaction { virtual void start_tx() = 0; virtual void start_stmt() = 0; + protected: + // Non-virtual functions with actions to be done on transaction start and + // commit. + void on_commit() { + time_t tm; + tm = time(nullptr); + for (auto &it : modified_tables) { + it->m_update_time = tm; + } + modified_tables.clear(); + } + void on_rollback() { + modified_tables.clear(); + } + public: + void log_table_write_op(Rdb_tbl_def *tbl) { + modified_tables.insert(tbl); + } + void set_initial_savepoint() { /* Set the initial savepoint. If the first statement in the transaction @@ -3322,7 +3343,9 @@ class Rdb_transaction_impl : public Rdb_transaction { goto error; } + on_commit(); error: + on_rollback(); /* Save the transaction object to be reused */ release_tx(); @@ -3338,6 +3361,7 @@ class Rdb_transaction_impl : public Rdb_transaction { public: void rollback() override { + on_rollback(); m_write_count = 0; m_insert_count = 0; m_update_count = 0; @@ -3659,7 +3683,9 @@ class Rdb_writebatch_impl : public Rdb_transaction { res = true; goto error; } + on_commit(); error: + on_rollback(); reset(); m_write_count = 0; @@ -3691,6 +3717,7 @@ class Rdb_writebatch_impl : public Rdb_transaction { } void rollback() override { + on_rollback(); m_write_count = 0; m_insert_count = 0; m_update_count = 0; @@ -7549,6 +7576,7 @@ int ha_rocksdb::create_table(const std::string &table_name, /* Create table/key descriptions and put them into the data dictionary */ m_tbl_def = new Rdb_tbl_def(table_name); + //m_tbl_def->set_create_time(time(nullptr)); uint n_keys = table_arg->s->keys; @@ -7684,9 +7712,11 @@ int ha_rocksdb::create(const char *const name, TABLE *const table_arg, } // Check whether Data Dictionary contain information + //time_t saved_time = 0; Rdb_tbl_def *tbl = ddl_manager.find(str); if (tbl != nullptr) { if (thd->lex->sql_command == SQLCOM_TRUNCATE) { + // saved_time = tbl->get_create_time(); err = delete_table(tbl); if (err != HA_EXIT_SUCCESS) { DBUG_RETURN(err); @@ -7696,8 +7726,9 @@ int ha_rocksdb::create(const char *const name, TABLE *const table_arg, DBUG_RETURN(HA_ERR_ROCKSDB_CORRUPT_DATA); } } - - DBUG_RETURN(create_table(str, table_arg, create_info->auto_increment_value)); + int rc = create_table(str, table_arg, create_info->auto_increment_value); + //if (!rc && saved_time) m_tbl_def->set_create_time(saved_time); + DBUG_RETURN(rc); } /** @@ -10177,6 +10208,8 @@ int ha_rocksdb::update_write_row(const uchar *const old_data, row_info.tx->incr_insert_count(); } + row_info.tx->log_table_write_op(m_tbl_def); + if (do_bulk_commit(row_info.tx)) { DBUG_RETURN(HA_ERR_ROCKSDB_BULK_LOAD); } @@ -10648,6 +10681,7 @@ int ha_rocksdb::delete_row(const uchar *const buf) { } tx->incr_delete_count(); + tx->log_table_write_op(m_tbl_def); if (do_bulk_commit(tx)) { DBUG_RETURN(HA_ERR_ROCKSDB_BULK_LOAD); @@ -10802,6 +10836,12 @@ int ha_rocksdb::info(uint flag) { k->rec_per_key[j] = x; } } + + stats.create_time = m_tbl_def->get_create_time(); + } + + if (flag & HA_STATUS_TIME) { + stats.update_time = m_tbl_def->m_update_time; } if (flag & HA_STATUS_ERRKEY) { @@ -12603,6 +12643,7 @@ bool ha_rocksdb::prepare_inplace_alter_table( m_tbl_def->m_auto_incr_val.load(std::memory_order_relaxed); new_tdef->m_hidden_pk_val = m_tbl_def->m_hidden_pk_val.load(std::memory_order_relaxed); + //new_tdef->set_create_time(m_tbl_def->get_create_time()); if (create_key_defs(altered_table, new_tdef, table, m_tbl_def)) { /* Delete the new key descriptors */ diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc index c0741a1ce9b..166b22c62ff 100644 --- a/storage/rocksdb/rdb_datadic.cc +++ b/storage/rocksdb/rdb_datadic.cc @@ -3563,6 +3563,26 @@ bool Rdb_tbl_def::put_dict(Rdb_dict_manager *const dict, return false; } +time_t Rdb_tbl_def::get_create_time() { + time_t create_time = m_create_time; + + if (create_time == CREATE_TIME_UNKNOWN) { + // Read it from the .frm file. It's not a problem if several threads do this + // concurrently + char path[FN_REFLEN]; + snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home, + m_dbname.c_str(), m_tablename.c_str(), reg_ext); + unpack_filename(path,path); + MY_STAT f_stat; + if (my_stat(path, &f_stat, MYF(0))) + create_time = f_stat.st_ctime; + else + create_time = 0; // will be shown as SQL NULL + m_create_time = create_time; + } + return create_time; +} + // Length that each index flag takes inside the record. // Each index in the array maps to the enum INDEX_FLAG static const std::array<uint, 1> index_flag_lengths = { diff --git a/storage/rocksdb/rdb_datadic.h b/storage/rocksdb/rdb_datadic.h index 416857cad38..0bf1372410f 100644 --- a/storage/rocksdb/rdb_datadic.h +++ b/storage/rocksdb/rdb_datadic.h @@ -1094,7 +1094,9 @@ class Rdb_tbl_def { : m_key_descr_arr(nullptr), m_hidden_pk_val(0), m_auto_incr_val(0), - m_tbl_stats() { + m_tbl_stats(), + m_update_time(0), + m_create_time(CREATE_TIME_UNKNOWN) { set_name(name); } @@ -1102,7 +1104,9 @@ class Rdb_tbl_def { : m_key_descr_arr(nullptr), m_hidden_pk_val(0), m_auto_incr_val(0), - m_tbl_stats() { + m_tbl_stats(), + m_update_time(0), + m_create_time(CREATE_TIME_UNKNOWN) { set_name(std::string(name, len)); } @@ -1110,7 +1114,9 @@ class Rdb_tbl_def { : m_key_descr_arr(nullptr), m_hidden_pk_val(0), m_auto_incr_val(0), - m_tbl_stats() { + m_tbl_stats(), + m_update_time(0), + m_create_time(CREATE_TIME_UNKNOWN) { set_name(std::string(slice.data() + pos, slice.size() - pos)); } @@ -1161,6 +1167,14 @@ class Rdb_tbl_def { const std::string &base_tablename() const { return m_tablename; } const std::string &base_partition() const { return m_partition; } GL_INDEX_ID get_autoincr_gl_index_id(); + + time_t get_create_time(); + std::atomic<time_t> m_update_time; // in-memory only value + private: + const time_t CREATE_TIME_UNKNOWN = 1; + // CREATE_TIME_UNKNOWN means "didn't try to read, yet" + // 0 means "no data available" + std::atomic<time_t> m_create_time; }; /*
1 0
0 0
[Commits] 9c6fec88b10: MDEV-17171: RocksDB Tables do not have "Creation Date"
by psergey 01 Nov '19

01 Nov '19
revision-id: 9c6fec88b10bfe51d87f63e6a6ea474cd18d1952 (mariadb-10.3.18-74-g9c6fec88b10) parent(s): 9c72963d2aef783cae652b5b8ac01f7aa2bcb43a author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2019-11-01 21:40:10 +0300 message: MDEV-17171: RocksDB Tables do not have "Creation Date" - Add SLEEP() calls to the testcase to make it really test that the time doesn't change. - Always use .frm file creation time as a creation timestamp (attempts to re-use older create_time when the table DDL changes are not good because then create_time will change after server restart) - Use the same method names as the upstream patch does - Use std::atomic for m_update_time --- storage/rocksdb/ha_rocksdb.cc | 6 ++--- .../mysql-test/rocksdb/r/show_table_status.result | 25 +++++++++++++++++++- .../mysql-test/rocksdb/t/show_table_status.test | 27 ++++++++++++++++++++-- storage/rocksdb/rdb_datadic.cc | 2 +- storage/rocksdb/rdb_datadic.h | 13 ++++++----- 5 files changed, 60 insertions(+), 13 deletions(-) diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index f063d76f49c..d7d1b1665f7 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -3010,7 +3010,7 @@ class Rdb_transaction { time_t tm; tm = time(nullptr); for (auto &it : modified_tables) { - it->update_time = tm; + it->m_update_time = tm; } modified_tables.clear(); } @@ -11040,11 +11040,11 @@ int ha_rocksdb::info(uint flag) { } } - stats.create_time = m_tbl_def->get_creation_time(); + stats.create_time = m_tbl_def->get_create_time(); } if (flag & HA_STATUS_TIME) { - stats.update_time = m_tbl_def->update_time; + stats.update_time = m_tbl_def->m_update_time; } if (flag & HA_STATUS_ERRKEY) { diff --git a/storage/rocksdb/mysql-test/rocksdb/r/show_table_status.result b/storage/rocksdb/mysql-test/rocksdb/r/show_table_status.result index ca373112c1c..d95549be4c1 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/show_table_status.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/show_table_status.result @@ -75,7 +75,25 @@ 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 @@ -86,13 +104,18 @@ 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 select -create_time=(select create_time from t2) /* should change */, +create_time=(select create_time from t2) /* should not change */, update_time from information_schema.tables where table_schema=database() and table_name='t1'; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/show_table_status.test b/storage/rocksdb/mysql-test/rocksdb/t/show_table_status.test index 109301a8879..55854710c31 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/show_table_status.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/show_table_status.test @@ -114,26 +114,49 @@ 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 change */, + create_time=(select create_time from t2) /* should not change */, update_time from information_schema.tables where table_schema=database() and table_name='t1'; diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc index 0cefed77ac8..0d43d4da5c4 100644 --- a/storage/rocksdb/rdb_datadic.cc +++ b/storage/rocksdb/rdb_datadic.cc @@ -3592,7 +3592,7 @@ bool Rdb_tbl_def::put_dict(Rdb_dict_manager *const dict, return false; } -time_t Rdb_tbl_def::get_creation_time() { +time_t Rdb_tbl_def::get_create_time() { time_t create_time = m_create_time; if (create_time == CREATE_TIME_UNKNOWN) { diff --git a/storage/rocksdb/rdb_datadic.h b/storage/rocksdb/rdb_datadic.h index d6cb242bd35..7bcc45d3f62 100644 --- a/storage/rocksdb/rdb_datadic.h +++ b/storage/rocksdb/rdb_datadic.h @@ -1093,27 +1093,24 @@ class Rdb_tbl_def { explicit Rdb_tbl_def(const std::string &name) : m_key_descr_arr(nullptr), m_hidden_pk_val(0), m_auto_incr_val(0), - m_create_time(CREATE_TIME_UNKNOWN) { + m_update_time(0), m_create_time(CREATE_TIME_UNKNOWN) { set_name(name); } Rdb_tbl_def(const char *const name, const size_t len) : m_key_descr_arr(nullptr), m_hidden_pk_val(0), m_auto_incr_val(0), - m_create_time(CREATE_TIME_UNKNOWN) { + m_update_time(0), m_create_time(CREATE_TIME_UNKNOWN) { set_name(std::string(name, len)); } explicit Rdb_tbl_def(const rocksdb::Slice &slice, const size_t pos = 0) : m_key_descr_arr(nullptr), m_hidden_pk_val(0), m_auto_incr_val(0), - m_create_time(CREATE_TIME_UNKNOWN) { + m_update_time(0), m_create_time(CREATE_TIME_UNKNOWN) { set_name(std::string(slice.data() + pos, slice.size() - pos)); } ~Rdb_tbl_def(); - time_t get_creation_time(); - time_t update_time = 0; // in-memory only value, maintained right here - void check_and_set_read_free_rpl_table(); /* Number of indexes */ @@ -1139,6 +1136,10 @@ class Rdb_tbl_def { const std::string &base_tablename() const { return m_tablename; } const std::string &base_partition() const { return m_partition; } GL_INDEX_ID get_autoincr_gl_index_id(); + + time_t get_create_time(); + std::atomic<time_t> m_update_time; // in-memory only value + private: const time_t CREATE_TIME_UNKNOWN= 1; // CREATE_TIME_UNKNOWN means "didn't try to read, yet"
1 0
0 0
[Commits] 19ed8ad6bcf: Support Create_time and Update_time in MyRocks table status
by psergey 31 Oct '19

31 Oct '19
revision-id: 19ed8ad6bcfd455787b24bbd5ddc93f248575170 (fb-prod201903-144-g19ed8ad6bcf) parent(s): d97c0c628e5dc60abd725f6a7120a8d87b09321e author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2019-10-31 23:43:18 +0300 message: Support Create_time and Update_time in MyRocks table status (Variant #6 of the patch) The implementation follows InnoDB: - Create_time is taken from the .frm file creation timestamp - Update_time is maintained in memory only and is set NULL on server restart - Create_time is maintained across in-place ALTER TABLE and TRUNCATE TABLE --- mysql-test/suite/rocksdb/include/bulk_load.inc | 4 +- .../suite/rocksdb/include/bulk_load_unsorted.inc | 4 +- mysql-test/suite/rocksdb/r/bulk_load.result | 12 +-- mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result | 12 +-- .../rocksdb/r/bulk_load_rev_cf_and_data.result | 12 +-- .../suite/rocksdb/r/bulk_load_rev_data.result | 12 +-- .../suite/rocksdb/r/bulk_load_unsorted.result | 12 +-- .../suite/rocksdb/r/bulk_load_unsorted_rev.result | 12 +-- mysql-test/suite/rocksdb/r/issue255.result | 16 +-- mysql-test/suite/rocksdb/r/rocksdb.result | 6 +- .../suite/rocksdb/r/show_table_status.result | 115 ++++++++++++++++++++- mysql-test/suite/rocksdb/r/truncate_table.result | 8 +- mysql-test/suite/rocksdb/t/issue255.test | 17 +-- mysql-test/suite/rocksdb/t/rocksdb.test | 4 +- mysql-test/suite/rocksdb/t/show_table_status.test | 114 +++++++++++++++++++- mysql-test/suite/rocksdb/t/truncate_table.test | 8 +- storage/rocksdb/ha_rocksdb.cc | 45 +++++++- storage/rocksdb/rdb_datadic.cc | 21 ++++ storage/rocksdb/rdb_datadic.h | 23 ++++- 19 files changed, 377 insertions(+), 80 deletions(-) diff --git a/mysql-test/suite/rocksdb/include/bulk_load.inc b/mysql-test/suite/rocksdb/include/bulk_load.inc index 1b79825e507..7e163602202 100644 --- a/mysql-test/suite/rocksdb/include/bulk_load.inc +++ b/mysql-test/suite/rocksdb/include/bulk_load.inc @@ -121,12 +121,12 @@ set rocksdb_bulk_load=0; --remove_file $file # Make sure row count index stats are correct ---replace_column 6 # 7 # 8 # 9 # +--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 # +--replace_column 6 # 7 # 8 # 9 # 12 # 13 # SHOW TABLE STATUS WHERE name LIKE 't%'; # Make sure all the data is there. diff --git a/mysql-test/suite/rocksdb/include/bulk_load_unsorted.inc b/mysql-test/suite/rocksdb/include/bulk_load_unsorted.inc index 5cdc76a32d4..812af0401aa 100644 --- a/mysql-test/suite/rocksdb/include/bulk_load_unsorted.inc +++ b/mysql-test/suite/rocksdb/include/bulk_load_unsorted.inc @@ -119,12 +119,12 @@ set rocksdb_bulk_load=0; --remove_file $file # Make sure row count index stats are correct ---replace_column 6 # 7 # 8 # 9 # +--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 # +--replace_column 6 # 7 # 8 # 9 # 12 # 13 # SHOW TABLE STATUS WHERE name LIKE 't%'; # Make sure all the data is there. diff --git a/mysql-test/suite/rocksdb/r/bulk_load.result b/mysql-test/suite/rocksdb/r/bulk_load.result index a36f99a7619..76db28e66bd 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load.result +++ b/mysql-test/suite/rocksdb/r/bulk_load.result @@ -38,9 +38,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,9 +48,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned select count(pk) from t1; count(pk) 5000000 diff --git a/mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result b/mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result index b5d3e252c5d..ae363f7ec0c 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result +++ b/mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result @@ -38,9 +38,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,9 +48,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned select count(pk) from t1; count(pk) 5000000 diff --git a/mysql-test/suite/rocksdb/r/bulk_load_rev_cf_and_data.result b/mysql-test/suite/rocksdb/r/bulk_load_rev_cf_and_data.result index f46acd41080..dd8dd7e60a8 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load_rev_cf_and_data.result +++ b/mysql-test/suite/rocksdb/r/bulk_load_rev_cf_and_data.result @@ -38,9 +38,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,9 +48,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned select count(pk) from t1; count(pk) 5000000 diff --git a/mysql-test/suite/rocksdb/r/bulk_load_rev_data.result b/mysql-test/suite/rocksdb/r/bulk_load_rev_data.result index 3389968ef37..96738ae62e2 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load_rev_data.result +++ b/mysql-test/suite/rocksdb/r/bulk_load_rev_data.result @@ -38,9 +38,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,9 +48,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned select count(pk) from t1; count(pk) 5000000 diff --git a/mysql-test/suite/rocksdb/r/bulk_load_unsorted.result b/mysql-test/suite/rocksdb/r/bulk_load_unsorted.result index 924032549ac..87fc63af2da 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load_unsorted.result +++ b/mysql-test/suite/rocksdb/r/bulk_load_unsorted.result @@ -70,9 +70,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -80,9 +80,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned select count(a) from t1; count(a) 5000000 diff --git a/mysql-test/suite/rocksdb/r/bulk_load_unsorted_rev.result b/mysql-test/suite/rocksdb/r/bulk_load_unsorted_rev.result index 3cc9fb8e459..8e0914f0159 100644 --- a/mysql-test/suite/rocksdb/r/bulk_load_unsorted_rev.result +++ b/mysql-test/suite/rocksdb/r/bulk_load_unsorted_rev.result @@ -70,9 +70,9 @@ 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -80,9 +80,9 @@ test.t2 analyze status OK 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 -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned select count(a) from t1; count(a) 5000000 diff --git a/mysql-test/suite/rocksdb/r/issue255.result b/mysql-test/suite/rocksdb/r/issue255.result index c1ce3be2276..b45b3b5afc7 100644 --- a/mysql-test/suite/rocksdb/r/issue255.result +++ b/mysql-test/suite/rocksdb/r/issue255.result @@ -2,7 +2,7 @@ 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 -t1 ROCKSDB # Fixed # # # # # # 6 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 6 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES ('538647864786478647864'); Warnings: Warning 1264 Out of range value for column 'pk' at row 1 @@ -12,7 +12,7 @@ pk 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 -t1 ROCKSDB 10 Fixed 2 22 44 0 0 0 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed 2 22 44 0 0 0 9223372036854775807 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES (); ERROR 23000: Duplicate entry '9223372036854775807' for key 'PRIMARY' SELECT * FROM t1; @@ -21,7 +21,7 @@ pk 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 -t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES (); ERROR 23000: Duplicate entry '9223372036854775807' for key 'PRIMARY' SELECT * FROM t1; @@ -30,13 +30,13 @@ pk 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 -t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 # # NULL latin1_swedish_ci NULL 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 -t1 ROCKSDB # Fixed # # # # # # 6 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 6 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES (1000); Warnings: Warning 1264 Out of range value for column 'pk' at row 1 @@ -46,7 +46,7 @@ pk 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 -t1 ROCKSDB # Fixed # # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 127 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES (); ERROR 23000: Duplicate entry '127' for key 'PRIMARY' SELECT * FROM t1; @@ -55,7 +55,7 @@ pk 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 -t1 ROCKSDB # Fixed # # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 127 # # NULL latin1_swedish_ci NULL INSERT INTO t1 VALUES (); ERROR 23000: Duplicate entry '127' for key 'PRIMARY' SELECT * FROM t1; @@ -64,5 +64,5 @@ pk 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 -t1 ROCKSDB # Fixed # # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB # Fixed # # # # # # 127 # # NULL latin1_swedish_ci NULL DROP TABLE t1; diff --git a/mysql-test/suite/rocksdb/r/rocksdb.result b/mysql-test/suite/rocksdb/r/rocksdb.result index 088eb050f6f..a631d58ac69 100644 --- a/mysql-test/suite/rocksdb/r/rocksdb.result +++ b/mysql-test/suite/rocksdb/r/rocksdb.result @@ -1417,7 +1417,7 @@ 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 -t1 ROCKSDB 10 Fixed 1000 0 # 0 0 0 3 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed 1000 0 # 0 0 0 3 # # NULL latin1_swedish_ci NULL drop table t1; # # Fix Issue #4: Crash when using pseudo-unique keys @@ -2612,7 +2612,7 @@ 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 -t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 3 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 3 # # NULL latin1_swedish_ci NULL SELECT * FROM t1; a -1 @@ -2623,7 +2623,7 @@ 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 -t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 12 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 12 # # NULL latin1_swedish_ci NULL SELECT * FROM t1; a 1 diff --git a/mysql-test/suite/rocksdb/r/show_table_status.result b/mysql-test/suite/rocksdb/r/show_table_status.result index 29140f045e4..53180cb47d9 100644 --- a/mysql-test/suite/rocksdb/r/show_table_status.result +++ b/mysql-test/suite/rocksdb/r/show_table_status.result @@ -7,12 +7,12 @@ 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 -t1 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL utf8_general_ci NULL +t1 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL utf8_general_ci NULL 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 -t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL latin1_swedish_ci NULL DROP TABLE t1, t2, t3; CREATE DATABASE `db_new..............................................end`; USE `db_new..............................................end`; @@ -22,3 +22,110 @@ SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.table_statistics WHERE T 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: +alter table t1 add key (a); +select sleep(2); +sleep(2) 0 +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 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'; +truncate table t1; +select sleep(2); +sleep(2) 0 +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 +# +# 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 +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/mysql-test/suite/rocksdb/r/truncate_table.result b/mysql-test/suite/rocksdb/r/truncate_table.result index 1544256f194..79b266a2453 100644 --- a/mysql-test/suite/rocksdb/r/truncate_table.result +++ b/mysql-test/suite/rocksdb/r/truncate_table.result @@ -9,19 +9,19 @@ 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 -t1 ROCKSDB 10 Fixed # # # 0 0 0 1 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed # # # 0 0 0 1 # # NULL latin1_swedish_ci NULL 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 -t1 ROCKSDB 10 Fixed # # # 0 0 0 4 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed # # # 0 0 0 4 # # NULL latin1_swedish_ci NULL 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 -t1 ROCKSDB 10 Fixed # # # 0 0 0 1 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed # # # 0 0 0 1 # # NULL latin1_swedish_ci NULL 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 -t1 ROCKSDB 10 Fixed # # # 0 0 0 2 NULL NULL NULL latin1_swedish_ci NULL +t1 ROCKSDB 10 Fixed # # # 0 0 0 2 # # NULL latin1_swedish_ci NULL SELECT a,c FROM t1; a c 1 d diff --git a/mysql-test/suite/rocksdb/t/issue255.test b/mysql-test/suite/rocksdb/t/issue255.test index 370dece0c6c..686f45b4056 100644 --- a/mysql-test/suite/rocksdb/t/issue255.test +++ b/mysql-test/suite/rocksdb/t/issue255.test @@ -3,24 +3,25 @@ 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 # +--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 # +--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 # +--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 # +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # SHOW TABLE STATUS LIKE 't1'; DROP TABLE t1; @@ -28,24 +29,24 @@ 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 # +--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 # +--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 # +--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 # +--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # SHOW TABLE STATUS LIKE 't1'; DROP TABLE t1; diff --git a/mysql-test/suite/rocksdb/t/rocksdb.test b/mysql-test/suite/rocksdb/t/rocksdb.test index 5eff0fbf38f..7dcae569c92 100644 --- a/mysql-test/suite/rocksdb/t/rocksdb.test +++ b/mysql-test/suite/rocksdb/t/rocksdb.test @@ -1198,7 +1198,7 @@ drop table t1; create table t1 (i int primary key auto_increment) engine=RocksDB; insert into t1 values (null),(null); ---replace_column 7 # +--replace_column 7 # 12 # 13 # show table status like 't1'; drop table t1; @@ -1903,11 +1903,13 @@ DROP TABLE t1; # 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; diff --git a/mysql-test/suite/rocksdb/t/show_table_status.test b/mysql-test/suite/rocksdb/t/show_table_status.test index 29cc2ccfb5e..dcc51f275f9 100644 --- a/mysql-test/suite/rocksdb/t/show_table_status.test +++ b/mysql-test/suite/rocksdb/t/show_table_status.test @@ -1,5 +1,5 @@ --source include/have_rocksdb.inc - +--source include/have_partition.inc # # SHOW TABLE STATUS statement # @@ -24,7 +24,7 @@ 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 # +--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 @@ -48,7 +48,7 @@ set global rocksdb_force_flush_memtable_now = true; # 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 # +--replace_column 6 # 7 # 12 # 13 # SHOW TABLE STATUS WHERE name LIKE 't2'; DROP TABLE t1, t2, t3; @@ -62,3 +62,111 @@ CREATE TABLE `t1_new..............................................end`(a int) en 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: +alter table t1 add key (a); +select sleep(2); + +select + create_time=@create_tm /* should not change */, + 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'; + +truncate table t1; +select sleep(2); + +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 # + +--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'; + +--source include/restart_mysqld.inc + +select sleep(2); +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/mysql-test/suite/rocksdb/t/truncate_table.test b/mysql-test/suite/rocksdb/t/truncate_table.test index a61488654a3..1001eeb6cde 100644 --- a/mysql-test/suite/rocksdb/t/truncate_table.test +++ b/mysql-test/suite/rocksdb/t/truncate_table.test @@ -29,22 +29,22 @@ DROP TABLE t1; 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 # +--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 # +--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 # +--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 # +--replace_column 5 # 6 # 7 # 12 # 13 # SHOW TABLE STATUS LIKE 't1'; --sorted_result diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index d6c89087bea..22a1a2b78cd 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -2456,6 +2456,8 @@ class Rdb_transaction { bool m_is_delayed_snapshot = false; bool m_is_two_phase = false; + std::unordered_set<Rdb_tbl_def*> modified_tables; + private: /* Number of write operations this transaction had when we took the last @@ -3139,6 +3141,25 @@ class Rdb_transaction { virtual void start_tx() = 0; virtual void start_stmt() = 0; + protected: + // Non-virtual functions with actions to be done on transaction start and + // commit. + void on_commit() { + time_t tm; + tm = time(nullptr); + for (auto &it : modified_tables) { + it->m_update_time = tm; + } + modified_tables.clear(); + } + void on_rollback() { + modified_tables.clear(); + } + public: + void log_table_write_op(Rdb_tbl_def *tbl) { + modified_tables.insert(tbl); + } + void set_initial_savepoint() { /* Set the initial savepoint. If the first statement in the transaction @@ -3322,7 +3343,9 @@ class Rdb_transaction_impl : public Rdb_transaction { goto error; } + on_commit(); error: + on_rollback(); /* Save the transaction object to be reused */ release_tx(); @@ -3338,6 +3361,7 @@ class Rdb_transaction_impl : public Rdb_transaction { public: void rollback() override { + on_rollback(); m_write_count = 0; m_insert_count = 0; m_update_count = 0; @@ -3659,7 +3683,9 @@ class Rdb_writebatch_impl : public Rdb_transaction { res = true; goto error; } + on_commit(); error: + on_rollback(); reset(); m_write_count = 0; @@ -3691,6 +3717,7 @@ class Rdb_writebatch_impl : public Rdb_transaction { } void rollback() override { + on_rollback(); m_write_count = 0; m_insert_count = 0; m_update_count = 0; @@ -7549,6 +7576,7 @@ int ha_rocksdb::create_table(const std::string &table_name, /* Create table/key descriptions and put them into the data dictionary */ m_tbl_def = new Rdb_tbl_def(table_name); + m_tbl_def->set_create_time(time(nullptr)); uint n_keys = table_arg->s->keys; @@ -7684,9 +7712,11 @@ int ha_rocksdb::create(const char *const name, TABLE *const table_arg, } // Check whether Data Dictionary contain information + time_t saved_time = 0; Rdb_tbl_def *tbl = ddl_manager.find(str); if (tbl != nullptr) { if (thd->lex->sql_command == SQLCOM_TRUNCATE) { + saved_time = tbl->get_create_time(); err = delete_table(tbl); if (err != HA_EXIT_SUCCESS) { DBUG_RETURN(err); @@ -7696,8 +7726,9 @@ int ha_rocksdb::create(const char *const name, TABLE *const table_arg, DBUG_RETURN(HA_ERR_ROCKSDB_CORRUPT_DATA); } } - - DBUG_RETURN(create_table(str, table_arg, create_info->auto_increment_value)); + int rc = create_table(str, table_arg, create_info->auto_increment_value); + if (!rc && saved_time) m_tbl_def->set_create_time(saved_time); + DBUG_RETURN(rc); } /** @@ -10177,6 +10208,8 @@ int ha_rocksdb::update_write_row(const uchar *const old_data, row_info.tx->incr_insert_count(); } + row_info.tx->log_table_write_op(m_tbl_def); + if (do_bulk_commit(row_info.tx)) { DBUG_RETURN(HA_ERR_ROCKSDB_BULK_LOAD); } @@ -10648,6 +10681,7 @@ int ha_rocksdb::delete_row(const uchar *const buf) { } tx->incr_delete_count(); + tx->log_table_write_op(m_tbl_def); if (do_bulk_commit(tx)) { DBUG_RETURN(HA_ERR_ROCKSDB_BULK_LOAD); @@ -10802,6 +10836,12 @@ int ha_rocksdb::info(uint flag) { k->rec_per_key[j] = x; } } + + stats.create_time = m_tbl_def->get_create_time(); + } + + if (flag & HA_STATUS_TIME) { + stats.update_time = m_tbl_def->m_update_time; } if (flag & HA_STATUS_ERRKEY) { @@ -12603,6 +12643,7 @@ bool ha_rocksdb::prepare_inplace_alter_table( m_tbl_def->m_auto_incr_val.load(std::memory_order_relaxed); new_tdef->m_hidden_pk_val = m_tbl_def->m_hidden_pk_val.load(std::memory_order_relaxed); + new_tdef->set_create_time(m_tbl_def->get_create_time()); if (create_key_defs(altered_table, new_tdef, table, m_tbl_def)) { /* Delete the new key descriptors */ diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc index c0741a1ce9b..4c8e4e1161e 100644 --- a/storage/rocksdb/rdb_datadic.cc +++ b/storage/rocksdb/rdb_datadic.cc @@ -3563,6 +3563,26 @@ bool Rdb_tbl_def::put_dict(Rdb_dict_manager *const dict, return false; } +time_t Rdb_tbl_def::get_create_time() { + time_t create_time = m_create_time; + + if (create_time == CREATE_TIME_UNKNOWN) { + // Read it from the .frm file. It's not a problem if several threads do this + // concurrently + char path[FN_REFLEN]; + snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home, + m_dbname.c_str(), m_tablename.c_str(), reg_ext); + unpack_filename(path,path); + MY_STAT f_stat; + if (my_stat(path, &f_stat, MYF(0))) + create_time = f_stat.st_ctime; + else + create_time = 0; // will be shown as SQL NULL + m_create_time = create_time; + } + return create_time; +} + // Length that each index flag takes inside the record. // Each index in the array maps to the enum INDEX_FLAG static const std::array<uint, 1> index_flag_lengths = { @@ -4471,6 +4491,7 @@ bool Rdb_ddl_manager::rename(const std::string &from, const std::string &to, rec->m_hidden_pk_val.load(std::memory_order_relaxed); new_rec->m_tbl_stats = rec->m_tbl_stats; + new_rec->set_create_time(rec->get_create_time()); // so that it's not free'd when deleting the old rec rec->m_key_descr_arr = nullptr; diff --git a/storage/rocksdb/rdb_datadic.h b/storage/rocksdb/rdb_datadic.h index 416857cad38..5102a1d43cc 100644 --- a/storage/rocksdb/rdb_datadic.h +++ b/storage/rocksdb/rdb_datadic.h @@ -1094,7 +1094,9 @@ class Rdb_tbl_def { : m_key_descr_arr(nullptr), m_hidden_pk_val(0), m_auto_incr_val(0), - m_tbl_stats() { + m_tbl_stats(), + m_update_time(0), + m_create_time(CREATE_TIME_UNKNOWN) { set_name(name); } @@ -1102,7 +1104,9 @@ class Rdb_tbl_def { : m_key_descr_arr(nullptr), m_hidden_pk_val(0), m_auto_incr_val(0), - m_tbl_stats() { + m_tbl_stats(), + m_update_time(0), + m_create_time(CREATE_TIME_UNKNOWN) { set_name(std::string(name, len)); } @@ -1110,7 +1114,9 @@ class Rdb_tbl_def { : m_key_descr_arr(nullptr), m_hidden_pk_val(0), m_auto_incr_val(0), - m_tbl_stats() { + m_tbl_stats(), + m_update_time(0), + m_create_time(CREATE_TIME_UNKNOWN) { set_name(std::string(slice.data() + pos, slice.size() - pos)); } @@ -1161,6 +1167,17 @@ class Rdb_tbl_def { const std::string &base_tablename() const { return m_tablename; } const std::string &base_partition() const { return m_partition; } GL_INDEX_ID get_autoincr_gl_index_id(); + + // time values are shown in SHOW TABLE STATUS + void set_create_time(time_t val) { m_create_time = val; } + time_t get_create_time(); + + std::atomic<time_t> m_update_time; // in-memory only value + private: + const time_t CREATE_TIME_UNKNOWN= 1; + // CREATE_TIME_UNKNOWN means "didn't try to read, yet" + // 0 means "no data available" + std::atomic<time_t> m_create_time; }; /*
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • ...
  • 1461
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.