From 26971c9aea67a62f348cd105348a8dc4407bcf4a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 9 Jan 2018 19:06:21 +0100 Subject: [PATCH] SQL: versioning info in INFORMATION_SCHEMA * show SYSTEM VERSIONED in INFORMATION_SCHEMA.TABLES * show ROW START/ROW END columns in INFORMATION_SCHEMA.COLUMNS --- mysql-test/suite/versioning/r/create.result | 64 +++++++++++++++++++++ mysql-test/suite/versioning/t/create.test | 3 + sql/sql_show.cc | 14 ++++- 3 files changed, 80 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/versioning/r/create.result b/mysql-test/suite/versioning/r/create.result index 8026668e3e0..3cf159ac3d0 100644 --- a/mysql-test/suite/versioning/r/create.result +++ b/mysql-test/suite/versioning/r/create.result @@ -13,6 +13,70 @@ t1 CREATE TABLE `t1` ( `Sys_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END INVISIBLE COMMENT 'end', PERIOD FOR SYSTEM_TIME (`Sys_start`, `Sys_end`) ) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +select table_catalog,table_schema,table_name,table_type,version,table_rows,avg_row_length,data_free,auto_increment,check_time,table_collation,checksum,create_options,table_comment from information_schema.tables where table_name='t1'; +table_catalog def +table_schema test +table_name t1 +table_type SYSTEM VERSIONED +version 10 +table_rows 0 +avg_row_length 0 +data_free 0 +auto_increment NULL +check_time NULL +table_collation latin1_swedish_ci +checksum NULL +create_options +table_comment +select table_catalog,table_schema,table_name,column_name,ordinal_position,column_default,character_maximum_length,character_octet_length,character_set_name,collation_name,column_key,extra,privileges,column_comment,is_generated,generation_expression from information_schema.columns where table_name='t1'; +table_catalog def +table_schema test +table_name t1 +column_name x1 +ordinal_position 1 +column_default NULL +character_maximum_length NULL +character_octet_length NULL +character_set_name NULL +collation_name NULL +column_key +extra +privileges select,insert,update,references +column_comment +is_generated NEVER +generation_expression NULL +table_catalog def +table_schema test +table_name t1 +column_name Sys_start +ordinal_position 2 +column_default NULL +character_maximum_length NULL +character_octet_length NULL +character_set_name NULL +collation_name NULL +column_key +extra INVISIBLE +privileges select,insert,update,references +column_comment start +is_generated ALWAYS +generation_expression ROW START +table_catalog def +table_schema test +table_name t1 +column_name Sys_end +ordinal_position 3 +column_default NULL +character_maximum_length NULL +character_octet_length NULL +character_set_name NULL +collation_name NULL +column_key +extra INVISIBLE +privileges select,insert,update,references +column_comment end +is_generated ALWAYS +generation_expression ROW END # Implicit fields test create or replace table t1 ( x2 int unsigned diff --git a/mysql-test/suite/versioning/t/create.test b/mysql-test/suite/versioning/t/create.test index 70a7fb9f7d8..f1ffd7fcf68 100644 --- a/mysql-test/suite/versioning/t/create.test +++ b/mysql-test/suite/versioning/t/create.test @@ -15,6 +15,9 @@ eval create table t1 ( --replace_result $default_engine DEFAULT_ENGINE $sys_datatype_expl SYS_DATATYPE show create table t1; +--query_vertical select table_catalog,table_schema,table_name,table_type,version,table_rows,avg_row_length,data_free,auto_increment,check_time,table_collation,checksum,create_options,table_comment from information_schema.tables where table_name='t1' +--query_vertical select table_catalog,table_schema,table_name,column_name,ordinal_position,column_default,character_maximum_length,character_octet_length,character_set_name,collation_name,column_key,extra,privileges,column_comment,is_generated,generation_expression from information_schema.columns where table_name='t1' + --echo # Implicit fields test create or replace table t1 ( x2 int unsigned diff --git a/sql/sql_show.cc b/sql/sql_show.cc index b82a57a84eb..41cf8556e87 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -5459,7 +5459,10 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, else { DBUG_ASSERT(share->tmp_table == NO_TMP_TABLE); - table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs); + if (share->versioned) + table->field[3]->store(STRING_WITH_LEN("SYSTEM VERSIONED"), cs); + else + table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs); } for (int i= 4; i < 20; i++) @@ -5948,6 +5951,15 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, else buf.set(STRING_WITH_LEN("VIRTUAL GENERATED"), cs); } + else if (field->flags & VERS_SYSTEM_FIELD) + { + if (field->flags & VERS_SYS_START_FLAG) + table->field[21]->store(STRING_WITH_LEN("ROW START"), cs); + else + table->field[21]->store(STRING_WITH_LEN("ROW END"), cs); + table->field[21]->set_notnull(); + table->field[20]->store(STRING_WITH_LEN("ALWAYS"), cs); + } else table->field[20]->store(STRING_WITH_LEN("NEVER"), cs); /*Invisible can coexist with auto_increment and virtual */