Commit d8c68db1 authored by Ashish Agarwal's avatar Ashish Agarwal

BUG#11759349 - 51655: CREATE TABLE IN MEMORY ENGINE DOESN'T STORE

                      CREATE_TIME IN INFORMATION_SC

It was impossible to determine MEMORY table creation time,
since it wasn't stored/exposed.

With this patch creation time is saved and it is available via
I_S.TABLES.CREATE_TIME.

Note: it was decided that additional analysis is required before
implementing UPDATE_TIME. Thus this patch doesn't store UPDATE_TIME.
parent 3f5c0cc7
...@@ -50,6 +50,7 @@ typedef struct st_heapinfo /* Struct from heap_info */ ...@@ -50,6 +50,7 @@ typedef struct st_heapinfo /* Struct from heap_info */
uint reclength; /* Length of one record */ uint reclength; /* Length of one record */
int errkey; int errkey;
ulonglong auto_increment; ulonglong auto_increment;
time_t create_time;
} HEAPINFO; } HEAPINFO;
...@@ -146,6 +147,7 @@ typedef struct st_heap_share ...@@ -146,6 +147,7 @@ typedef struct st_heap_share
uint open_count; uint open_count;
uchar *del_link; /* Link to next block with del. rec */ uchar *del_link; /* Link to next block with del. rec */
char * name; /* Name of "memory-file" */ char * name; /* Name of "memory-file" */
time_t create_time;
#ifdef THREAD #ifdef THREAD
THR_LOCK lock; THR_LOCK lock;
pthread_mutex_t intern_lock; /* Locking for use with _locking */ pthread_mutex_t intern_lock; /* Locking for use with _locking */
......
...@@ -715,8 +715,8 @@ create table t1 (c char(10)) engine=memory; ...@@ -715,8 +715,8 @@ create table t1 (c char(10)) engine=memory;
create table t2 (c varchar(10)) engine=memory; create table t2 (c varchar(10)) engine=memory;
show table status like 't_'; show table status 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 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 MEMORY 10 Fixed 0 11 0 # 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL t1 MEMORY 10 Fixed 0 11 0 # 0 0 NULL # NULL NULL latin1_swedish_ci NULL
t2 MEMORY 10 Fixed 0 12 0 # 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL t2 MEMORY 10 Fixed 0 12 0 # 0 0 NULL # NULL NULL latin1_swedish_ci NULL
drop table t1, t2; drop table t1, t2;
CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256), CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY; KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY;
......
...@@ -458,57 +458,57 @@ insert into t2 values (1),(2); ...@@ -458,57 +458,57 @@ insert into t2 values (1),(2);
insert into t3 values (1,1),(2,2); insert into t3 values (1,1),(2,2);
show table status; 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 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 MEMORY 10 Fixed 2 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL t1 MEMORY 10 Fixed 2 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL
t2 MEMORY 10 Fixed 2 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL t2 MEMORY 10 Fixed 2 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL
t3 MEMORY 10 Fixed 2 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL t3 MEMORY 10 Fixed 2 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL
insert into t1 values (3),(4); insert into t1 values (3),(4);
insert into t2 values (3),(4); insert into t2 values (3),(4);
insert into t3 values (3,3),(4,4); insert into t3 values (3,3),(4,4);
show table status; 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 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 MEMORY 10 Fixed 4 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL t1 MEMORY 10 Fixed 4 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL
t2 MEMORY 10 Fixed 4 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL t2 MEMORY 10 Fixed 4 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL
t3 MEMORY 10 Fixed 4 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL t3 MEMORY 10 Fixed 4 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL
insert into t1 values (5); insert into t1 values (5);
insert into t2 values (5); insert into t2 values (5);
insert into t3 values (5,5); insert into t3 values (5,5);
show table status; 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 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 MEMORY 10 Fixed 5 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL t1 MEMORY 10 Fixed 5 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL
t2 MEMORY 10 Fixed 5 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL t2 MEMORY 10 Fixed 5 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL
t3 MEMORY 10 Fixed 5 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL t3 MEMORY 10 Fixed 5 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL
delete from t1 where a=3; delete from t1 where a=3;
delete from t2 where b=3; delete from t2 where b=3;
delete from t3 where a=3; delete from t3 where a=3;
show table status; 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 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 MEMORY 10 Fixed 4 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL t1 MEMORY 10 Fixed 4 # # # # # NULL # NULL NULL latin1_swedish_ci NULL
t2 MEMORY 10 Fixed 4 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL t2 MEMORY 10 Fixed 4 # # # # # NULL # NULL NULL latin1_swedish_ci NULL
t3 MEMORY 10 Fixed 4 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL t3 MEMORY 10 Fixed 4 # # # # # NULL # NULL NULL latin1_swedish_ci NULL
truncate table t1; truncate table t1;
truncate table t2; truncate table t2;
truncate table t3; truncate table t3;
show table status; 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 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 MEMORY 10 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL t1 MEMORY 10 Fixed 0 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL
t2 MEMORY 10 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL t2 MEMORY 10 Fixed 0 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL
t3 MEMORY 10 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL t3 MEMORY 10 Fixed 0 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL
insert into t1 values (5); insert into t1 values (5);
insert into t2 values (5); insert into t2 values (5);
insert into t3 values (5,5); insert into t3 values (5,5);
show table status; 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 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 MEMORY 10 Fixed 1 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL t1 MEMORY 10 Fixed 1 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL
t2 MEMORY 10 Fixed 1 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL t2 MEMORY 10 Fixed 1 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL
t3 MEMORY 10 Fixed 1 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL t3 MEMORY 10 Fixed 1 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL
delete from t1 where a=5; delete from t1 where a=5;
delete from t2 where b=5; delete from t2 where b=5;
delete from t3 where a=5; delete from t3 where a=5;
show table status; 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 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 MEMORY 10 Fixed 0 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL t1 MEMORY 10 Fixed 0 # # # # # NULL # NULL NULL latin1_swedish_ci NULL
t2 MEMORY 10 Fixed 0 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL t2 MEMORY 10 Fixed 0 # # # # # NULL # NULL NULL latin1_swedish_ci NULL
t3 MEMORY 10 Fixed 0 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL t3 MEMORY 10 Fixed 0 # # # # # NULL # NULL NULL latin1_swedish_ci NULL
drop table t1, t2, t3; drop table t1, t2, t3;
create database mysqltest; create database mysqltest;
show create database mysqltest; show create database mysqltest;
...@@ -659,7 +659,7 @@ DROP TABLE t1; ...@@ -659,7 +659,7 @@ DROP TABLE t1;
flush tables; flush tables;
SHOW TABLE STATUS like '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 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 NULL NULL NULL NULL # # # # NULL NULL NULL NULL NULL NULL NULL NULL Incorrect information in file: './test/t1.frm' t1 NULL NULL NULL NULL # # # # NULL NULL # NULL NULL NULL NULL NULL Incorrect information in file: './test/t1.frm'
Warnings: Warnings:
Warning 1033 Incorrect information in file: './test/t1.frm' Warning 1033 Incorrect information in file: './test/t1.frm'
show create table t1; show create table t1;
......
...@@ -454,7 +454,7 @@ drop table t1; ...@@ -454,7 +454,7 @@ drop table t1;
# #
create table t1 (c char(10)) engine=memory; create table t1 (c char(10)) engine=memory;
create table t2 (c varchar(10)) engine=memory; create table t2 (c varchar(10)) engine=memory;
--replace_column 8 # --replace_column 8 # 12 #
show table status like 't_'; show table status like 't_';
drop table t1, t2; drop table t1, t2;
......
...@@ -230,7 +230,7 @@ DROP TABLE """a"; ...@@ -230,7 +230,7 @@ DROP TABLE """a";
#set names latin1; #set names latin1;
#create database ``; #create database ``;
#create table ``.`` (a int) engine=heap; #create table ``.`` (a int) engine=heap;
#--replace_column 7 # 8 # 9 # #--replace_column 7 # 8 # 9 # 12 #
#show table status from `` LIKE ''; #show table status from `` LIKE '';
#drop database ``; #drop database ``;
...@@ -276,37 +276,37 @@ CREATE TABLE t3 ( ...@@ -276,37 +276,37 @@ CREATE TABLE t3 (
insert into t1 values (1),(2); insert into t1 values (1),(2);
insert into t2 values (1),(2); insert into t2 values (1),(2);
insert into t3 values (1,1),(2,2); insert into t3 values (1,1),(2,2);
--replace_column 6 # 7 # 8 # 9 # --replace_column 6 # 7 # 8 # 9 # 12 #
show table status; show table status;
insert into t1 values (3),(4); insert into t1 values (3),(4);
insert into t2 values (3),(4); insert into t2 values (3),(4);
insert into t3 values (3,3),(4,4); insert into t3 values (3,3),(4,4);
--replace_column 6 # 7 # 8 # 9 # --replace_column 6 # 7 # 8 # 9 # 12 #
show table status; show table status;
insert into t1 values (5); insert into t1 values (5);
insert into t2 values (5); insert into t2 values (5);
insert into t3 values (5,5); insert into t3 values (5,5);
--replace_column 6 # 7 # 8 # 9 # --replace_column 6 # 7 # 8 # 9 # 12 #
show table status; show table status;
delete from t1 where a=3; delete from t1 where a=3;
delete from t2 where b=3; delete from t2 where b=3;
delete from t3 where a=3; delete from t3 where a=3;
--replace_column 6 # 7 # 8 # 9 # 10 # --replace_column 6 # 7 # 8 # 9 # 10 # 12 #
show table status; show table status;
truncate table t1; truncate table t1;
truncate table t2; truncate table t2;
truncate table t3; truncate table t3;
--replace_column 6 # 7 # 8 # 9 # --replace_column 6 # 7 # 8 # 9 # 12 #
show table status; show table status;
insert into t1 values (5); insert into t1 values (5);
insert into t2 values (5); insert into t2 values (5);
insert into t3 values (5,5); insert into t3 values (5,5);
--replace_column 6 # 7 # 8 # 9 # --replace_column 6 # 7 # 8 # 9 # 12 #
show table status; show table status;
delete from t1 where a=5; delete from t1 where a=5;
delete from t2 where b=5; delete from t2 where b=5;
delete from t3 where a=5; delete from t3 where a=5;
--replace_column 6 # 7 # 8 # 9 # 10 # --replace_column 6 # 7 # 8 # 9 # 10 # 12 #
show table status; show table status;
drop table t1, t2, t3; drop table t1, t2, t3;
...@@ -367,7 +367,7 @@ flush privileges; ...@@ -367,7 +367,7 @@ flush privileges;
#set names latin1; #set names latin1;
#create database ``; #create database ``;
#create table ``.`` (a int) engine=heap; #create table ``.`` (a int) engine=heap;
#--replace_column 7 # 8 # 9 # #--replace_column 7 # 8 # 9 # 12 #
#show table status from `` LIKE ''; #show table status from `` LIKE '';
#drop database ``; #drop database ``;
...@@ -430,7 +430,7 @@ flush tables; ...@@ -430,7 +430,7 @@ flush tables;
# Create a junk frm file on disk # Create a junk frm file on disk
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
system echo "this is a junk file for test" >> $MYSQLD_DATADIR/test/t1.frm ; system echo "this is a junk file for test" >> $MYSQLD_DATADIR/test/t1.frm ;
--replace_column 6 # 7 # 8 # 9 # --replace_column 6 # 7 # 8 # 9 # 12 #
SHOW TABLE STATUS like 't1'; SHOW TABLE STATUS like 't1';
--error ER_NOT_FORM_FILE --error ER_NOT_FORM_FILE
show create table t1; show create table t1;
......
...@@ -382,6 +382,7 @@ int ha_heap::info(uint flag) ...@@ -382,6 +382,7 @@ int ha_heap::info(uint flag)
stats.index_file_length= hp_info.index_length; stats.index_file_length= hp_info.index_length;
stats.max_data_file_length= hp_info.max_records * hp_info.reclength; stats.max_data_file_length= hp_info.max_records * hp_info.reclength;
stats.delete_length= hp_info.deleted * hp_info.reclength; stats.delete_length= hp_info.deleted * hp_info.reclength;
stats.create_time= (ulong) hp_info.create_time;
if (flag & HA_STATUS_AUTO) if (flag & HA_STATUS_AUTO)
stats.auto_increment_value= hp_info.auto_increment; stats.auto_increment_value= hp_info.auto_increment;
/* /*
......
...@@ -186,6 +186,7 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, ...@@ -186,6 +186,7 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
share->auto_key= create_info->auto_key; share->auto_key= create_info->auto_key;
share->auto_key_type= create_info->auto_key_type; share->auto_key_type= create_info->auto_key_type;
share->auto_increment= create_info->auto_increment; share->auto_increment= create_info->auto_increment;
share->create_time= (long) time((time_t*) 0);
/* Must be allocated separately for rename to work */ /* Must be allocated separately for rename to work */
if (!(share->name= my_strdup(name,MYF(0)))) if (!(share->name= my_strdup(name,MYF(0))))
{ {
......
...@@ -53,6 +53,7 @@ int heap_info(reg1 HP_INFO *info,reg2 HEAPINFO *x, int flag ) ...@@ -53,6 +53,7 @@ int heap_info(reg1 HP_INFO *info,reg2 HEAPINFO *x, int flag )
x->index_length = info->s->index_length; x->index_length = info->s->index_length;
x->max_records = info->s->max_records; x->max_records = info->s->max_records;
x->errkey = info->errkey; x->errkey = info->errkey;
x->create_time = info->s->create_time;
if (flag & HA_STATUS_AUTO) if (flag & HA_STATUS_AUTO)
x->auto_increment= info->s->auto_increment + 1; x->auto_increment= info->s->auto_increment + 1;
DBUG_RETURN(0); DBUG_RETURN(0);
......
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