From aa27a7858e199ae8d0adbacb2871af800b4c930c Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Thu, 24 Jun 2004 18:46:41 +0500 Subject: [PATCH] "Version" column in SHOW TABLE STATUS. --- mysql-test/r/show_check.result | 58 +++++++++++++++++----------------- mysql-test/t/show_check.test | 14 ++++---- sql/sql_show.cc | 3 ++ sql/table.cc | 1 + sql/table.h | 1 + 5 files changed, 41 insertions(+), 36 deletions(-) diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index 653a8e7302e..87691e864c5 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -43,7 +43,7 @@ wait_timeout 28800 show variables like "this_doesn't_exists%"; Variable_name Value show table status from test like "this_doesn't_exists%"; -Name Engine 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 show databases; Database mysql @@ -309,58 +309,58 @@ insert into t1 values (1),(2); insert into t2 values (1),(2); insert into t3 values (1,1),(2,2); show table status; -Name Engine 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 HEAP Fixed 2 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 HEAP Fixed 2 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 HEAP Fixed 2 9 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +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 HEAP 9 Fixed 2 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t2 HEAP 9 Fixed 2 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t3 HEAP 9 Fixed 2 9 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL insert into t1 values (3),(4); insert into t2 values (3),(4); insert into t3 values (3,3),(4,4); show table status; -Name Engine 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 HEAP Fixed 4 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 HEAP Fixed 4 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 HEAP Fixed 4 9 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +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 HEAP 9 Fixed 4 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t2 HEAP 9 Fixed 4 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t3 HEAP 9 Fixed 4 9 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL insert into t1 values (5); insert into t2 values (5); insert into t3 values (5,5); show table status; -Name Engine 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 HEAP Fixed 5 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 HEAP Fixed 5 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 HEAP Fixed 5 9 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +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 HEAP 9 Fixed 5 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t2 HEAP 9 Fixed 5 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t3 HEAP 9 Fixed 5 9 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL delete from t1 where a=3; delete from t2 where b=3; delete from t3 where a=3; show table status; -Name Engine 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 HEAP Fixed 4 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 HEAP Fixed 4 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 HEAP Fixed 4 9 # # # 9 NULL NULL NULL NULL latin1_swedish_ci NULL +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 HEAP 9 Fixed 4 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL +t2 HEAP 9 Fixed 4 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL +t3 HEAP 9 Fixed 4 9 # # # 9 NULL NULL NULL NULL latin1_swedish_ci NULL delete from t1; delete from t2; delete from t3; show table status; -Name Engine 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 HEAP Fixed 0 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 HEAP Fixed 0 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 HEAP Fixed 0 9 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +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 HEAP 9 Fixed 0 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t2 HEAP 9 Fixed 0 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t3 HEAP 9 Fixed 0 9 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL insert into t1 values (5); insert into t2 values (5); insert into t3 values (5,5); show table status; -Name Engine 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 HEAP Fixed 1 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 HEAP Fixed 1 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 HEAP Fixed 1 9 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +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 HEAP 9 Fixed 1 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t2 HEAP 9 Fixed 1 5 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t3 HEAP 9 Fixed 1 9 # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL delete from t1 where a=5; delete from t2 where b=5; delete from t3 where a=5; show table status; -Name Engine 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 HEAP Fixed 0 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 HEAP Fixed 0 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 HEAP Fixed 0 9 # # # 9 NULL NULL NULL NULL latin1_swedish_ci NULL +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 HEAP 9 Fixed 0 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL +t2 HEAP 9 Fixed 0 5 # # # 5 NULL NULL NULL NULL latin1_swedish_ci NULL +t3 HEAP 9 Fixed 0 9 # # # 9 NULL NULL NULL NULL latin1_swedish_ci NULL drop table t1, t2, t3; create database test_$1; show create database test_$1; diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index deb95af9168..3ff2605cff4 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -222,37 +222,37 @@ CREATE TABLE t3 ( insert into t1 values (1),(2); insert into t2 values (1),(2); insert into t3 values (1,1),(2,2); ---replace_column 6 # 7 # 8 # +--replace_column 7 # 8 # 9 # show table status; insert into t1 values (3),(4); insert into t2 values (3),(4); insert into t3 values (3,3),(4,4); ---replace_column 6 # 7 # 8 # +--replace_column 7 # 8 # 9 # show table status; insert into t1 values (5); insert into t2 values (5); insert into t3 values (5,5); ---replace_column 6 # 7 # 8 # +--replace_column 7 # 8 # 9 # show table status; delete from t1 where a=3; delete from t2 where b=3; delete from t3 where a=3; ---replace_column 6 # 7 # 8 # +--replace_column 7 # 8 # 9 # show table status; delete from t1; delete from t2; delete from t3; ---replace_column 6 # 7 # 8 # +--replace_column 7 # 8 # 9 # show table status; insert into t1 values (5); insert into t2 values (5); insert into t3 values (5,5); ---replace_column 6 # 7 # 8 # +--replace_column 7 # 8 # 9 # show table status; delete from t1 where a=5; delete from t2 where b=5; delete from t3 where a=5; ---replace_column 6 # 7 # 8 # +--replace_column 7 # 8 # 9 # show table status; drop table t1, t2, t3; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 4642abfcfc4..823552be3a4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -473,6 +473,8 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) field_list.push_back(item=new Item_empty_string("Name",NAME_LEN)); field_list.push_back(item=new Item_empty_string("Engine",10)); item->maybe_null=1; + field_list.push_back(item=new Item_int("Version", (longlong) 0, 21)); + item->maybe_null=1; field_list.push_back(item=new Item_empty_string("Row_format",10)); item->maybe_null=1; field_list.push_back(item=new Item_int("Rows",(longlong) 1,21)); @@ -533,6 +535,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) handler *file=table->file; file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_NO_LOCK); protocol->store(file->table_type(), system_charset_info); + protocol->store((ulonglong) table->frm_version); str= ((table->db_options_in_use & HA_OPTION_COMPRESS_RECORD) ? "Compressed" : (table->db_options_in_use & HA_OPTION_PACK_RECORD) ? diff --git a/sql/table.cc b/sql/table.cc index e053eba7b6c..d0759c8d415 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -126,6 +126,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, goto err_not_open; /* purecov: inspected */ *fn_ext(index_file)='\0'; // Remove .frm extension + outparam->frm_version= head[2]; outparam->db_type=ha_checktype((enum db_type) (uint) *(head+3)); outparam->db_create_options=db_create_options=uint2korr(head+30); outparam->db_options_in_use=outparam->db_create_options; diff --git a/sql/table.h b/sql/table.h index b558436de1d..f111377bc85 100644 --- a/sql/table.h +++ b/sql/table.h @@ -156,6 +156,7 @@ struct st_table { uint quick_key_parts[MAX_KEY]; key_part_map const_key_parts[MAX_KEY]; ulong query_id; + uchar frm_version; union /* Temporary variables */ {