Commit 2e73561c authored by Aleksey Midenkov's avatar Aleksey Midenkov Committed by Sergei Golubchik

MDEV-16804 SYSTEM VERSIONING columns not showing as GENERATED

Closes #830
parent 4a3d51c7
......@@ -54,7 +54,7 @@ character_octet_length NULL
character_set_name NULL
collation_name NULL
column_key
extra INVISIBLE
extra STORED GENERATED, INVISIBLE
column_comment start
is_generated ALWAYS
generation_expression ROW START
......@@ -69,7 +69,7 @@ character_octet_length NULL
character_set_name NULL
collation_name NULL
column_key
extra INVISIBLE
extra STORED GENERATED, INVISIBLE
column_comment end
is_generated ALWAYS
generation_expression ROW END
......
......@@ -71,3 +71,135 @@ and d.dept_id = e.dept_id;
emp_id dept_id name salary dept_id name
1 10 bill 2000 10 accounting
drop table emp, dept;
create table t1 (
a timestamp(6),
b timestamp(6) generated always as (a + interval 1 day),
c timestamp(6) generated always as (a + interval 1 month) stored,
d timestamp(6) generated always as row start,
e timestamp(6) generated always as row end,
period for system_time(d,e)
) with system versioning;
show columns from t1;
Field Type Null Key Default Extra
a timestamp(6) NO current_timestamp(6) on update current_timestamp(6)
b timestamp(6) YES NULL VIRTUAL GENERATED
c timestamp(6) YES NULL STORED GENERATED
d timestamp(6) NO NULL STORED GENERATED
e timestamp(6) NO NULL STORED GENERATED
select *,'---' from information_schema.columns where table_name='t1';
TABLE_CATALOG def
TABLE_SCHEMA test
TABLE_NAME t1
COLUMN_NAME a
ORDINAL_POSITION 1
COLUMN_DEFAULT current_timestamp(6)
IS_NULLABLE NO
DATA_TYPE timestamp
CHARACTER_MAXIMUM_LENGTH NULL
CHARACTER_OCTET_LENGTH NULL
NUMERIC_PRECISION NULL
NUMERIC_SCALE NULL
DATETIME_PRECISION 6
CHARACTER_SET_NAME NULL
COLLATION_NAME NULL
COLUMN_TYPE timestamp(6)
COLUMN_KEY
EXTRA on update current_timestamp(6)
PRIVILEGES select,insert,update,references
COLUMN_COMMENT
IS_GENERATED NEVER
GENERATION_EXPRESSION NULL
--- ---
TABLE_CATALOG def
TABLE_SCHEMA test
TABLE_NAME t1
COLUMN_NAME b
ORDINAL_POSITION 2
COLUMN_DEFAULT NULL
IS_NULLABLE YES
DATA_TYPE timestamp
CHARACTER_MAXIMUM_LENGTH NULL
CHARACTER_OCTET_LENGTH NULL
NUMERIC_PRECISION NULL
NUMERIC_SCALE NULL
DATETIME_PRECISION 6
CHARACTER_SET_NAME NULL
COLLATION_NAME NULL
COLUMN_TYPE timestamp(6)
COLUMN_KEY
EXTRA VIRTUAL GENERATED
PRIVILEGES select,insert,update,references
COLUMN_COMMENT
IS_GENERATED ALWAYS
GENERATION_EXPRESSION `a` + interval 1 day
--- ---
TABLE_CATALOG def
TABLE_SCHEMA test
TABLE_NAME t1
COLUMN_NAME c
ORDINAL_POSITION 3
COLUMN_DEFAULT NULL
IS_NULLABLE YES
DATA_TYPE timestamp
CHARACTER_MAXIMUM_LENGTH NULL
CHARACTER_OCTET_LENGTH NULL
NUMERIC_PRECISION NULL
NUMERIC_SCALE NULL
DATETIME_PRECISION 6
CHARACTER_SET_NAME NULL
COLLATION_NAME NULL
COLUMN_TYPE timestamp(6)
COLUMN_KEY
EXTRA STORED GENERATED
PRIVILEGES select,insert,update,references
COLUMN_COMMENT
IS_GENERATED ALWAYS
GENERATION_EXPRESSION `a` + interval 1 month
--- ---
TABLE_CATALOG def
TABLE_SCHEMA test
TABLE_NAME t1
COLUMN_NAME d
ORDINAL_POSITION 4
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE timestamp
CHARACTER_MAXIMUM_LENGTH NULL
CHARACTER_OCTET_LENGTH NULL
NUMERIC_PRECISION NULL
NUMERIC_SCALE NULL
DATETIME_PRECISION 6
CHARACTER_SET_NAME NULL
COLLATION_NAME NULL
COLUMN_TYPE timestamp(6)
COLUMN_KEY
EXTRA STORED GENERATED
PRIVILEGES select,insert,update,references
COLUMN_COMMENT
IS_GENERATED ALWAYS
GENERATION_EXPRESSION ROW START
--- ---
TABLE_CATALOG def
TABLE_SCHEMA test
TABLE_NAME t1
COLUMN_NAME e
ORDINAL_POSITION 5
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE timestamp
CHARACTER_MAXIMUM_LENGTH NULL
CHARACTER_OCTET_LENGTH NULL
NUMERIC_PRECISION NULL
NUMERIC_SCALE NULL
DATETIME_PRECISION 6
CHARACTER_SET_NAME NULL
COLLATION_NAME NULL
COLUMN_TYPE timestamp(6)
COLUMN_KEY
EXTRA STORED GENERATED
PRIVILEGES select,insert,update,references
COLUMN_COMMENT
IS_GENERATED ALWAYS
GENERATION_EXPRESSION ROW END
--- ---
drop table t1;
......@@ -71,3 +71,19 @@ where d.dept_id = 10
and d.dept_id = e.dept_id;
drop table emp, dept;
#
# MDEV-16804 SYSTEM VERSIONING columns not showing as GENERATED
#
create table t1 (
a timestamp(6),
b timestamp(6) generated always as (a + interval 1 day),
c timestamp(6) generated always as (a + interval 1 month) stored,
d timestamp(6) generated always as row start,
e timestamp(6) generated always as row end,
period for system_time(d,e)
) with system versioning;
show columns from t1;
query_vertical select *,'---' from information_schema.columns where table_name='t1';
drop table t1;
......@@ -6001,9 +6001,15 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
else if (field->flags & VERS_SYSTEM_FIELD)
{
if (field->flags & VERS_SYS_START_FLAG)
{
table->field[21]->store(STRING_WITH_LEN("ROW START"), cs);
buf.set(STRING_WITH_LEN("STORED GENERATED"), cs);
}
else
{
table->field[21]->store(STRING_WITH_LEN("ROW END"), cs);
buf.set(STRING_WITH_LEN("STORED GENERATED"), cs);
}
table->field[21]->set_notnull();
table->field[20]->store(STRING_WITH_LEN("ALWAYS"), cs);
}
......
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