Skip to content

Commit f566889

Browse files
committed
Merge branch '10.3' into 10.4
2 parents ec40980 + 9c6fec8 commit f566889

File tree

5 files changed

+60
-13
lines changed

5 files changed

+60
-13
lines changed

storage/rocksdb/ha_rocksdb.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,7 +3010,7 @@ class Rdb_transaction {
30103010
time_t tm;
30113011
tm = time(nullptr);
30123012
for (auto &it : modified_tables) {
3013-
it->update_time = tm;
3013+
it->m_update_time = tm;
30143014
}
30153015
modified_tables.clear();
30163016
}
@@ -11044,11 +11044,11 @@ int ha_rocksdb::info(uint flag) {
1104411044
}
1104511045
}
1104611046

11047-
stats.create_time = m_tbl_def->get_creation_time();
11047+
stats.create_time = m_tbl_def->get_create_time();
1104811048
}
1104911049

1105011050
if (flag & HA_STATUS_TIME) {
11051-
stats.update_time = m_tbl_def->update_time;
11051+
stats.update_time = m_tbl_def->m_update_time;
1105211052
}
1105311053

1105411054
if (flag & HA_STATUS_ERRKEY) {

storage/rocksdb/mysql-test/rocksdb/r/show_table_status.result

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,25 @@ select create_time, update_time into @create_tm, @update_tm
7575
from information_schema.tables
7676
where table_schema=database() and table_name='t1';
7777
# Then, an in-place ALTER TABLE:
78+
select sleep(2);
79+
sleep(2) 0
7880
alter table t1 add key (a);
81+
# create_time will change as .frm file is rewritten:
82+
select
83+
create_time=@create_tm,
84+
update_time
85+
from information_schema.tables
86+
where table_schema=database() and table_name='t1';
87+
create_time=@create_tm 0
88+
update_time NULL
89+
# Check TRUNCATE TABLE
90+
insert into t1 values (10,10);
91+
select create_time, update_time into @create_tm, @update_tm
92+
from information_schema.tables
93+
where table_schema=database() and table_name='t1';
94+
select sleep(2);
95+
sleep(2) 0
96+
truncate table t1;
7997
select
8098
create_time=@create_tm /* should not change */,
8199
update_time
@@ -86,13 +104,18 @@ update_time NULL
86104
#
87105
# Check what is left after server restart
88106
#
107+
drop table t1;
108+
create table t1 (a int);
109+
insert into t1 values (1);
89110
# Save t1's creation time
90111
create table t2 as
91112
select create_time
92113
from information_schema.tables
93114
where table_schema=database() and table_name='t1';
115+
select sleep(2);
116+
sleep(2) 0
94117
select
95-
create_time=(select create_time from t2) /* should change */,
118+
create_time=(select create_time from t2) /* should not change */,
96119
update_time
97120
from information_schema.tables
98121
where table_schema=database() and table_name='t1';

storage/rocksdb/mysql-test/rocksdb/t/show_table_status.test

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,26 +114,49 @@ from information_schema.tables
114114
where table_schema=database() and table_name='t1';
115115

116116
--echo # Then, an in-place ALTER TABLE:
117+
select sleep(2);
117118
alter table t1 add key (a);
118119

120+
--echo # create_time will change as .frm file is rewritten:
121+
select
122+
create_time=@create_tm,
123+
update_time
124+
from information_schema.tables
125+
where table_schema=database() and table_name='t1';
126+
127+
--echo # Check TRUNCATE TABLE
128+
insert into t1 values (10,10);
129+
select create_time, update_time into @create_tm, @update_tm
130+
from information_schema.tables
131+
where table_schema=database() and table_name='t1';
132+
133+
select sleep(2);
134+
truncate table t1;
135+
119136
select
120137
create_time=@create_tm /* should not change */,
121138
update_time
122139
from information_schema.tables
123140
where table_schema=database() and table_name='t1';
124141

142+
125143
--echo #
126144
--echo # Check what is left after server restart
127145
--echo #
128-
146+
drop table t1;
147+
create table t1 (a int);
148+
insert into t1 values (1);
129149
--echo # Save t1's creation time
130150
create table t2 as
131151
select create_time
132152
from information_schema.tables
133153
where table_schema=database() and table_name='t1';
134154

155+
select sleep(2);
156+
--source include/restart_mysqld.inc
157+
135158
select
136-
create_time=(select create_time from t2) /* should change */,
159+
create_time=(select create_time from t2) /* should not change */,
137160
update_time
138161
from information_schema.tables
139162
where table_schema=database() and table_name='t1';

storage/rocksdb/rdb_datadic.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3592,7 +3592,7 @@ bool Rdb_tbl_def::put_dict(Rdb_dict_manager *const dict,
35923592
return false;
35933593
}
35943594

3595-
time_t Rdb_tbl_def::get_creation_time() {
3595+
time_t Rdb_tbl_def::get_create_time() {
35963596
time_t create_time = m_create_time;
35973597

35983598
if (create_time == CREATE_TIME_UNKNOWN) {

storage/rocksdb/rdb_datadic.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,27 +1093,24 @@ class Rdb_tbl_def {
10931093

10941094
explicit Rdb_tbl_def(const std::string &name)
10951095
: m_key_descr_arr(nullptr), m_hidden_pk_val(0), m_auto_incr_val(0),
1096-
m_create_time(CREATE_TIME_UNKNOWN) {
1096+
m_update_time(0), m_create_time(CREATE_TIME_UNKNOWN) {
10971097
set_name(name);
10981098
}
10991099

11001100
Rdb_tbl_def(const char *const name, const size_t len)
11011101
: m_key_descr_arr(nullptr), m_hidden_pk_val(0), m_auto_incr_val(0),
1102-
m_create_time(CREATE_TIME_UNKNOWN) {
1102+
m_update_time(0), m_create_time(CREATE_TIME_UNKNOWN) {
11031103
set_name(std::string(name, len));
11041104
}
11051105

11061106
explicit Rdb_tbl_def(const rocksdb::Slice &slice, const size_t pos = 0)
11071107
: m_key_descr_arr(nullptr), m_hidden_pk_val(0), m_auto_incr_val(0),
1108-
m_create_time(CREATE_TIME_UNKNOWN) {
1108+
m_update_time(0), m_create_time(CREATE_TIME_UNKNOWN) {
11091109
set_name(std::string(slice.data() + pos, slice.size() - pos));
11101110
}
11111111

11121112
~Rdb_tbl_def();
11131113

1114-
time_t get_creation_time();
1115-
time_t update_time = 0; // in-memory only value, maintained right here
1116-
11171114
void check_and_set_read_free_rpl_table();
11181115

11191116
/* Number of indexes */
@@ -1139,6 +1136,10 @@ class Rdb_tbl_def {
11391136
const std::string &base_tablename() const { return m_tablename; }
11401137
const std::string &base_partition() const { return m_partition; }
11411138
GL_INDEX_ID get_autoincr_gl_index_id();
1139+
1140+
time_t get_create_time();
1141+
std::atomic<time_t> m_update_time; // in-memory only value
1142+
11421143
private:
11431144
const time_t CREATE_TIME_UNKNOWN= 1;
11441145
// CREATE_TIME_UNKNOWN means "didn't try to read, yet"

0 commit comments

Comments
 (0)