summaryrefslogtreecommitdiff
path: root/storage/rocksdb/rdb_datadic.h
diff options
context:
space:
mode:
Diffstat (limited to 'storage/rocksdb/rdb_datadic.h')
-rw-r--r--storage/rocksdb/rdb_datadic.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/storage/rocksdb/rdb_datadic.h b/storage/rocksdb/rdb_datadic.h
index 0a3a747c633..ab67c839153 100644
--- a/storage/rocksdb/rdb_datadic.h
+++ b/storage/rocksdb/rdb_datadic.h
@@ -201,6 +201,7 @@ const size_t RDB_SIZEOF_INDEX_TYPE = sizeof(uchar);
const size_t RDB_SIZEOF_KV_VERSION = sizeof(uint16);
const size_t RDB_SIZEOF_INDEX_FLAGS = sizeof(uint32);
const size_t RDB_SIZEOF_AUTO_INCREMENT_VERSION = sizeof(uint16);
+const size_t RDB_SIZEOF_TABLE_CREATION_TS_VERSION = sizeof(uint16);
// Possible return values for rdb_index_field_unpack_t functions.
enum {
@@ -504,6 +505,7 @@ class Rdb_key_def {
MAX_INDEX_ID = 7,
DDL_CREATE_INDEX_ONGOING = 8,
AUTO_INC = 9,
+ TABLE_CREATION_TS = 10,
END_DICT_INDEX_ID = 255
};
@@ -517,6 +519,7 @@ class Rdb_key_def {
MAX_INDEX_ID_VERSION = 1,
DDL_CREATE_INDEX_ONGOING_VERSION = 1,
AUTO_INCREMENT_VERSION = 1,
+ TABLE_CREATION_TS_VERSION = 1
// Version for index stats is stored in IndexStats struct
};
@@ -1108,6 +1111,13 @@ class Rdb_tbl_def {
~Rdb_tbl_def();
+ // time values are shown in SHOW TABLE STATUS
+ void put_creation_time(Rdb_dict_manager *dict_manager,
+ rocksdb::WriteBatchBase *batch, time_t timeval);
+ time_t get_creation_time(Rdb_dict_manager *dict_manager);
+
+ time_t update_time = 0; // in-memory only value, maintained right here
+
void check_and_set_read_free_rpl_table();
/* Number of indexes */
@@ -1133,6 +1143,12 @@ 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();
+
+ private:
+ const time_t CREATE_TIME_UNKNOWN= 1;
+ // CREATE_TIME_UNKNOWN means "didn't try to read, yet"
+ // 0 means "no data available" (and SQL layer shares this)
+ time_t create_time = CREATE_TIME_UNKNOWN;
};
/*
@@ -1347,6 +1363,10 @@ class Rdb_binlog_manager {
value: version, {max auto_increment so far}
max auto_increment is 8 bytes
+ 10. Table creation timestamp
+ key: Rdb_key_def::TABLE_CREATION_TIMESTAMP + cf_id + index_id
+ value: timestamp
+
Data dictionary operations are atomic inside RocksDB. For example,
when creating a table with two indexes, it is necessary to call Put
three times. They have to be atomic. Rdb_dict_manager has a wrapper function
@@ -1505,6 +1525,11 @@ class Rdb_dict_manager {
bool overwrite = false) const;
bool get_auto_incr_val(const GL_INDEX_ID &gl_index_id,
ulonglong *new_val) const;
+ rocksdb::Status put_creation_time(rocksdb::WriteBatchBase *batch,
+ const GL_INDEX_ID &gl_index_id,
+ time_t timeval_arg) const;
+ bool get_creation_time(const GL_INDEX_ID &gl_index_id,
+ time_t *new_val) const;
};
struct Rdb_index_info {