Commit 232d8bbd authored by aditya's avatar aditya

Bug #17299181 CREATE_TIME AND UPDATE_TIME ARE WRONG FOR PARTITIONED TABLES

PROBLEM

Create time is calculated as last status change time of .frm file.
The first problem was that innodb was passing file name as
"table_name#po#p0.frm" to the stat() call which calculates the create time.
Since there is no frm file with this name create_time will be stored as NULL.
The second problem is ha_partition::info() updates stats for create time
when HA_STATUS_CONST flag was set ,where as innodb calculates this statistic
when HA_STATUS_TIME is set,which causes create_time to be set as NULL.

Fix
Pass proper .frm name to stat() call and calculate create time when
HA_STATUS_CONST flag is set.
parent c01d13b1
......@@ -365,33 +365,33 @@ DROP TABLE t1;
create table t1 (a int) engine=innodb partition by hash(a) ;
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 InnoDB 10 Compact 2 8192 16384 0 0 # NULL NULL NULL NULL latin1_swedish_ci NULL partitioned
t1 InnoDB 10 Compact 2 8192 16384 0 0 # NULL # NULL NULL latin1_swedish_ci NULL partitioned
drop table t1;
create table t1 (a int)
engine = innodb
partition by key (a);
show table status;
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 InnoDB 10 Compact 2 8192 16384 0 0 # NULL NULL NULL NULL latin1_swedish_ci NULL partitioned
t1 InnoDB 10 Compact 2 8192 16384 0 0 # NULL # NULL NULL latin1_swedish_ci NULL partitioned
insert into t1 values (0), (1), (2), (3);
show table status;
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 InnoDB 10 Compact 4 4096 16384 0 0 # NULL NULL NULL NULL latin1_swedish_ci NULL partitioned
t1 InnoDB 10 Compact 4 4096 16384 0 0 # NULL # NULL NULL latin1_swedish_ci NULL partitioned
drop table t1;
create table t1 (a int auto_increment primary key)
engine = innodb
partition by key (a);
show table status;
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 InnoDB 10 Compact 2 8192 16384 0 0 # 1 NULL NULL NULL latin1_swedish_ci NULL partitioned
t1 InnoDB 10 Compact 2 8192 16384 0 0 # 1 # NULL NULL latin1_swedish_ci NULL partitioned
insert into t1 values (NULL), (NULL), (NULL), (NULL);
show table status;
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 InnoDB 10 Compact 4 4096 16384 0 0 # 5 NULL NULL NULL latin1_swedish_ci NULL partitioned
t1 InnoDB 10 Compact 4 4096 16384 0 0 # 5 # NULL NULL latin1_swedish_ci NULL partitioned
insert into t1 values (NULL), (NULL), (NULL), (NULL);
show table status;
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 InnoDB 10 Compact 8 2048 16384 0 0 # 9 NULL NULL NULL latin1_swedish_ci NULL partitioned
t1 InnoDB 10 Compact 8 2048 16384 0 0 # 9 # NULL NULL latin1_swedish_ci NULL partitioned
drop table t1;
create table t1 (a int)
partition by key (a)
......@@ -572,3 +572,14 @@ a b
1 2
0 1
DROP TABLE t1;
#
# Bug #17299181 CREATE_TIME AND UPDATE_TIME ARE
# WRONG FOR PARTITIONED TABLES
#
CREATE TABLE t1 (a int, PRIMARY KEY (a)) ENGINE=InnoDB
PARTITION BY HASH (a) PARTITIONS 2;
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE
CREATE_TIME IS NOT NULL AND TABLE_NAME='t1';
COUNT(*)
1
DROP TABLE t1;
......@@ -387,7 +387,7 @@ DROP TABLE t1;
create table t1 (a int) engine=innodb partition by hash(a) ;
# Data_free for InnoDB tablespace varies depending on which
# tests have been run before this one
--replace_column 10 #
--replace_column 10 # 12 #
show table status like 't1';
drop table t1;
......@@ -399,12 +399,12 @@ engine = innodb
partition by key (a);
# Data_free for InnoDB tablespace varies depending on which
# tests have been run before this one
--replace_column 10 #
--replace_column 10 # 12 #
show table status;
insert into t1 values (0), (1), (2), (3);
# Data_free for InnoDB tablespace varies depending on which
# tests have been run before this one
--replace_column 10 #
--replace_column 10 # 12 #
show table status;
drop table t1;
......@@ -413,17 +413,17 @@ engine = innodb
partition by key (a);
# Data_free for InnoDB tablespace varies depending on which
# tests have been run before this one
--replace_column 10 #
--replace_column 10 # 12 #
show table status;
insert into t1 values (NULL), (NULL), (NULL), (NULL);
# Data_free for InnoDB tablespace varies depending on which
# tests have been run before this one
--replace_column 10 #
--replace_column 10 # 12 #
show table status;
insert into t1 values (NULL), (NULL), (NULL), (NULL);
# Data_free for InnoDB tablespace varies depending on which
# tests have been run before this one
--replace_column 10 #
--replace_column 10 # 12 #
show table status;
drop table t1;
......@@ -660,3 +660,15 @@ ALTER TABLE t1 ADD UNIQUE KEY (b);
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # Bug #17299181 CREATE_TIME AND UPDATE_TIME ARE
--echo # WRONG FOR PARTITIONED TABLES
--echo #
CREATE TABLE t1 (a int, PRIMARY KEY (a)) ENGINE=InnoDB
PARTITION BY HASH (a) PARTITIONS 2;
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE
CREATE_TIME IS NOT NULL AND TABLE_NAME='t1';
DROP TABLE t1;
......@@ -8172,17 +8172,6 @@ ha_innobase::info_low(
prebuilt->trx->op_info = "returning various info to MySQL";
}
my_snprintf(path, sizeof(path), "%s/%s%s",
mysql_data_home, ib_table->name, reg_ext);
unpack_filename(path,path);
/* Note that we do not know the access time of the table,
nor the CHECK TABLE time, nor the UPDATE or INSERT time. */
if (os_file_get_status(path,&stat_info)) {
stats.create_time = (ulong) stat_info.ctime;
}
}
if (flag & HA_STATUS_VARIABLE) {
......@@ -8379,6 +8368,20 @@ ha_innobase::info_low(
}
dict_table_stats_unlock(ib_table, RW_S_LATCH);
my_snprintf(path, sizeof(path), "%s/%s%s",
mysql_data_home,
table->s->normalized_path.str,
reg_ext);
unpack_filename(path,path);
/* Note that we do not know the access time of the table,
nor the CHECK TABLE time, nor the UPDATE or INSERT time. */
if (os_file_get_status(path,&stat_info)) {
stats.create_time = (ulong) stat_info.ctime;
}
}
if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment