SQL: removed VERS_HIDDEN_FLAG [closes ]

This commit is contained in:
Aleksey Midenkov 2017-12-19 16:12:56 +03:00
parent 8ba06032ae
commit ee68d019d1
38 changed files with 406 additions and 491 deletions

View file

@ -202,7 +202,6 @@ enum enum_indicator_type
#define VERS_UPDATE_UNVERSIONED_FLAG (1 << 29) /* column that doesn't support
system versioning when table
itself supports it*/
#define VERS_HIDDEN_FLAG (1 << 31) /* hide from SELECT * */
#define REFRESH_GRANT (1ULL << 0) /* Refresh grant tables */
#define REFRESH_LOG (1ULL << 1) /* Start on new log file */

View file

@ -15,10 +15,7 @@ alter table t add system versioning;
show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t add column y int;
ERROR HY000: Not allowed for system-versioned `test`.`t`. Change @@system_versioning_alter_history to proceed with ALTER.
@ -32,35 +29,35 @@ t CREATE TABLE `t` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
set system_versioning_alter_history= keep;
alter table t
add column trx_start bigint(20) unsigned generated always as row start,
add column trx_end bigint(20) unsigned generated always as row end,
add column trx_start bigint(20) unsigned as row start invisible,
add column trx_end bigint(20) unsigned as row end invisible,
add period for system_time(trx_start, trx_end),
add system versioning;
ERROR HY000: `trx_start` must be of type TIMESTAMP(6) for system-versioned table `t`
alter table t
add column trx_start timestamp generated always as row start,
add column trx_end timestamp generated always as row end,
add column trx_start timestamp as row start invisible,
add column trx_end timestamp as row end invisible,
add period for system_time(trx_start, trx_end),
add system versioning;
ERROR HY000: `trx_start` must be of type TIMESTAMP(6) for system-versioned table `t`
alter table t
add column trx_start timestamp(6) not null generated always as row start,
add column trx_end timestamp(6) not null generated always as row end,
add column trx_start timestamp(6) not null as row start invisible,
add column trx_end timestamp(6) not null as row end invisible,
add period for system_time(trx_start, trx_end),
add system versioning;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'generated always as row start,
add column trx_end timestamp(6) not null generate' at line 2
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'as row start invisible,
add column trx_end timestamp(6) not null as row end invi' at line 2
alter table t
add column trx_start timestamp(6) generated always as row start,
add column trx_end timestamp(6) generated always as row end,
add column trx_start timestamp(6) as row start invisible,
add column trx_end timestamp(6) as row end invisible,
add period for system_time(trx_start, trx_end),
add system versioning;
show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`trx_start` timestamp(6) GENERATED ALWAYS AS ROW START INVISIBLE,
`trx_end` timestamp(6) GENERATED ALWAYS AS ROW END INVISIBLE,
PERIOD FOR SYSTEM_TIME (`trx_start`, `trx_end`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t drop column trx_start, drop column trx_end;
@ -74,31 +71,22 @@ alter table t add system versioning;
show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t add column b int;
show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t add column c int;
show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t add column d int first;
show create table t;
@ -106,11 +94,8 @@ Table Create Table
t CREATE TABLE `t` (
`d` int(11) DEFAULT NULL,
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t add column e int after d;
show create table t;
@ -119,11 +104,8 @@ t CREATE TABLE `t` (
`d` int(11) DEFAULT NULL,
`e` int(11) DEFAULT NULL,
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t drop column a;
show create table t;
@ -131,20 +113,17 @@ Table Create Table
t CREATE TABLE `t` (
`d` int(11) DEFAULT NULL,
`e` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t (
a int,
sys_trx_start timestamp(6) generated always as row start,
sys_trx_end timestamp(6) generated always as row end,
sys_trx_start timestamp(6) as row start invisible,
sys_trx_end timestamp(6) as row end invisible,
period for system_time(sys_trx_start, sys_trx_end))
with system versioning;
select * from t for system_time all;
a sys_trx_start sys_trx_end
a
alter table t drop column sys_trx_start;
alter table t drop column sys_trx_end;
select * from t for system_time all;
@ -155,12 +134,12 @@ alter table t drop column sys_trx_end;
ERROR 42000: Can't DROP COLUMN `sys_trx_end`; check that it exists
create or replace table t (
a int,
sys_trx_start timestamp(6) generated always as row start,
sys_trx_end timestamp(6) generated always as row end,
sys_trx_start timestamp(6) as row start invisible,
sys_trx_end timestamp(6) as row end invisible,
period for system_time(sys_trx_start, sys_trx_end))
with system versioning;
select * from t for system_time all;
a sys_trx_start sys_trx_end
a
alter table t drop column sys_trx_start, drop column sys_trx_end;
select * from t for system_time all;
a
@ -172,10 +151,7 @@ alter table t add system versioning;
show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
insert into t values(2);
select * from t for system_time all;
@ -205,10 +181,7 @@ show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
select * from t;
a b
@ -240,35 +213,29 @@ show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
`b` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t modify a int with system versioning;
show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t(
a int
) engine=innodb;
alter table t
add column trx_start timestamp(6) as row start,
add column trx_end timestamp(6) as row end,
add column trx_start timestamp(6) as row start invisible,
add column trx_end timestamp(6) as row end invisible,
add period for system_time(trx_start, trx_end),
add system versioning;
show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`trx_start` timestamp(6) GENERATED ALWAYS AS ROW START INVISIBLE,
`trx_end` timestamp(6) GENERATED ALWAYS AS ROW END INVISIBLE,
PERIOD FOR SYSTEM_TIME (`trx_start`, `trx_end`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
# Issue #211: drop of system columns required before drop system versioning
@ -276,18 +243,15 @@ alter table t drop column trx_start, drop column trx_end;
show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`trx_start`, `trx_end`)
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t drop system versioning;
insert into t values(1);
call verify_vtq;
No A B C D
alter table t
add column trx_start bigint(20) unsigned as row start,
add column trx_end bigint(20) unsigned as row end,
add column trx_start bigint(20) unsigned as row start invisible,
add column trx_end bigint(20) unsigned as row end invisible,
add period for system_time(trx_start, trx_end),
add system versioning;
call verify_vtq;
@ -296,8 +260,8 @@ show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
`trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
`trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START INVISIBLE,
`trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END INVISIBLE,
PERIOD FOR SYSTEM_TIME (`trx_start`, `trx_end`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t(
@ -310,10 +274,7 @@ No A B C D
show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
update t set a= 2;
select * from t for system_time all;
@ -325,10 +286,7 @@ show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
`b` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`b` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
select * from t;
a b
@ -339,10 +297,7 @@ alter table t drop column b, algorithm=copy;
show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
select * from t for system_time all;
a
@ -420,33 +375,33 @@ a b
4 2
create or replace table t (
a int,
sys_trx_start bigint(20) unsigned generated always as row start,
sys_trx_end bigint(20) unsigned generated always as row end,
sys_trx_start bigint(20) unsigned as row start invisible,
sys_trx_end bigint(20) unsigned as row end invisible,
period for system_time(sys_trx_start, sys_trx_end)
) with system versioning engine innodb;
alter table t change column sys_trx_start asdf bigint unsigned;
ERROR HY000: Can not change system versioning field `sys_trx_start`
create or replace table t (
a int,
sys_trx_start timestamp(6) generated always as row start,
sys_trx_end timestamp(6) generated always as row end,
sys_trx_start timestamp(6) as row start invisible,
sys_trx_end timestamp(6) as row end invisible,
period for system_time(sys_trx_start, sys_trx_end)
) with system versioning engine myisam;
alter table t change column sys_trx_start asdf timestamp(6);
ERROR HY000: Can not change system versioning field `sys_trx_start`
create or replace table t (
a int,
sys_trx_start timestamp(6) generated always as row start,
sys_trx_end timestamp(6) generated always as row end,
sys_trx_start timestamp(6) as row start invisible,
sys_trx_end timestamp(6) as row end invisible,
period for system_time(sys_trx_start, sys_trx_end)
) with system versioning;
select * from t;
a sys_trx_start sys_trx_end
a
alter table t drop system versioning;
ERROR HY000: System versioning field `sys_trx_start` is not hidden
alter table t drop column sys_trx_start;
select * from t;
a sys_trx_end
a
alter table t drop system versioning;
ERROR HY000: System versioning field `sys_trx_end` is not hidden
alter table t drop column sys_trx_end;

View file

@ -8,8 +8,8 @@ set @str= concat('
id int unsigned auto_increment primary key,
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);

View file

@ -1,7 +1,7 @@
create table t1(
id int auto_increment primary key,
sys_trx_start bigint unsigned generated always as row start,
sys_trx_end bigint unsigned generated always as row end,
sys_trx_start bigint unsigned as row start invisible,
sys_trx_end bigint unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
)
with system versioning

View file

@ -1,16 +1,16 @@
drop table if exists t1;
create table t1 (
x1 int unsigned,
Sys_start SYS_DATATYPE generated always as row start comment 'start',
Sys_end SYS_DATATYPE generated always as row end comment 'end',
Sys_start SYS_DATATYPE as row start invisible comment 'start',
Sys_end SYS_DATATYPE as row end invisible comment 'end',
period for system_time (Sys_start, Sys_end)
) with system versioning;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x1` int(10) unsigned DEFAULT NULL,
`Sys_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START COMMENT 'start',
`Sys_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END COMMENT 'end',
`Sys_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START INVISIBLE COMMENT 'start',
`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
# Implicit fields test
@ -20,29 +20,26 @@ x2 int unsigned
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x2` int(10) unsigned DEFAULT NULL,
`sys_trx_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`sys_trx_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`x2` int(10) unsigned DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
x3 int unsigned,
Sys_start SYS_DATATYPE generated always as row start,
Sys_end SYS_DATATYPE generated always as row end,
Sys_start SYS_DATATYPE as row start invisible,
Sys_end SYS_DATATYPE as row end invisible,
period for system_time (x, Sys_end)
) with system versioning;
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start` and `Sys_end`
create or replace table t1 (
x4 int unsigned,
Sys_start SYS_DATATYPE generated always as row start,
Sys_end2 SYS_DATATYPE generated always as row end,
Sys_start SYS_DATATYPE as row start invisible,
Sys_end2 SYS_DATATYPE as row end invisible,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start` and `Sys_end2`
create or replace table t1 (
x5 int unsigned,
Sys_start SYS_DATATYPE generated always as row start,
Sys_end SYS_DATATYPE generated always as row end,
Sys_start SYS_DATATYPE as row start invisible,
Sys_end SYS_DATATYPE as row end invisible,
period for system_time (Sys_start, x)
) with system versioning;
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start` and `Sys_end`
@ -53,57 +50,57 @@ period for system_time (Sys_start, Sys_end)
ERROR HY000: Wrong parameters for `t1`: missing 'AS ROW START'
create or replace table t1 (
x7 int unsigned,
Sys_start SYS_DATATYPE generated always as row start,
Sys_end SYS_DATATYPE generated always as row end,
Sys_start SYS_DATATYPE as row start invisible,
Sys_end SYS_DATATYPE as row end invisible,
period for system_time (Sys_start, Sys_end)
);
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
create or replace table t1 (
x8 int unsigned,
Sys_start SYS_DATATYPE generated always as row start,
Sys_end SYS_DATATYPE generated always as row end,
Sys_start SYS_DATATYPE as row start invisible,
Sys_end SYS_DATATYPE as row end invisible,
period for system_time (sys_insert, sys_remove)
) with system versioning;
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start` and `Sys_end`
create or replace table t1 (
x9 int unsigned,
Sys_start SYS_DATATYPE generated always as row start,
Sys_end SYS_DATATYPE generated always as row end,
Sys_start SYS_DATATYPE as row start invisible,
Sys_end SYS_DATATYPE as row end invisible,
period for system_time (Sys_start, Sys_end)
);
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
create or replace table t1 (
x10 int unsigned,
Sys_start SYS_DATATYPE generated always as row start,
Sys_end SYS_DATATYPE generated always as row end,
Sys_start SYS_DATATYPE as row start invisible,
Sys_end SYS_DATATYPE as row end invisible,
period for system_time (Sys_start, Sys_start)
);
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
create or replace table t1 (
x11 int unsigned,
Sys_start bigint unsigned generated always as row start,
Sys_end timestamp(6) generated always as row end,
Sys_start bigint unsigned as row start invisible,
Sys_end timestamp(6) as row end invisible,
period for system_time (Sys_start, Sys_end)
) with system versioning;
Got one of the listed errors
create or replace table t1 (
x12 int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end bigint unsigned generated always as row end,
Sys_start timestamp(6) as row start invisible,
Sys_end bigint unsigned as row end invisible,
period for system_time (Sys_start, Sys_end)
) with system versioning;
Got one of the listed errors
create or replace table t1 (
x13 int unsigned,
Sys_start bigint generated always as row start,
Sys_end bigint unsigned generated always as row end,
Sys_start bigint as row start invisible,
Sys_end bigint unsigned as row end invisible,
period for system_time (Sys_start, Sys_end)
) with system versioning engine innodb;
ERROR HY000: `Sys_start` must be of type TIMESTAMP(6) for system-versioned table `t1`
create or replace table t1 (
x14 int unsigned,
Sys_start bigint unsigned generated always as row start,
Sys_end bigint generated always as row end,
Sys_start bigint unsigned as row start invisible,
Sys_end bigint as row end invisible,
period for system_time (Sys_start, Sys_end)
) with system versioning engine innodb;
ERROR HY000: `Sys_end` must be of type BIGINT(20) UNSIGNED for system-versioned table `t1`
@ -115,10 +112,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x15` int(11) DEFAULT NULL,
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
`sys_trx_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`sys_trx_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
x16 int with system versioning,
@ -128,10 +122,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x16` int(11) DEFAULT NULL,
`B` int(11) DEFAULT NULL,
`sys_trx_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`sys_trx_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`B` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
x17 int,
@ -145,10 +136,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x18` int(11) DEFAULT NULL,
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
`sys_trx_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`sys_trx_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
x19 int with system versioning,
@ -158,10 +146,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x19` int(11) DEFAULT NULL,
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
`sys_trx_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`sys_trx_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
x20 int with system versioning,
@ -171,10 +156,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x20` int(11) DEFAULT NULL,
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
`sys_trx_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`sys_trx_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
x21 int without system versioning
@ -188,10 +170,7 @@ create table tt1 like t1;
show create table tt1;
Table Create Table
tt1 CREATE TABLE `tt1` (
`a` int(11) DEFAULT NULL,
`sys_trx_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`sys_trx_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`a` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
drop table tt1;
create temporary table tt1 like t1;
@ -207,8 +186,8 @@ tt1 CREATE TEMPORARY TABLE `tt1` (
create or replace table t1 (x23 int) with system versioning;
create or replace table t0(
y int,
st SYS_DATATYPE generated always as row start,
en SYS_DATATYPE generated always as row end,
st SYS_DATATYPE as row start,
en SYS_DATATYPE as row end,
period for system_time (st, en)
) with system versioning;
## For non-versioned table:
@ -233,17 +212,14 @@ t3 CREATE TABLE `t3` (
## For versioned table
insert into t1 values (1);
select sys_trx_start from t1 into @sys_trx_start;
insert into t0 values (2);
insert into t0 (y) values (2);
select st from t0 into @st;
### 1. implicit system fields are included as implicit
create or replace table t2 with system versioning as select * from t1;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`x23` int(11) DEFAULT NULL,
`sys_trx_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`sys_trx_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`x23` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
#### sys_trx_start, sys_trx_end are copied; wildcard not expanded
select * from t2 where sys_trx_start = @sys_trx_start;
@ -256,10 +232,7 @@ Table Create Table
t3 CREATE TABLE `t3` (
`y` int(11) DEFAULT NULL,
`st` SYS_DATATYPE,
`en` SYS_DATATYPE,
`sys_trx_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`sys_trx_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`en` SYS_DATATYPE
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
#### st, en are plain fields now
select * from t3 where y > 2;
@ -269,16 +242,16 @@ y
2
### 3. explicit system fields are kept as system
create or replace table t3 (
st SYS_DATATYPE generated always as row start,
en SYS_DATATYPE generated always as row end,
st SYS_DATATYPE as row start invisible,
en SYS_DATATYPE as row end invisible,
period for system_time (st, en)
) with system versioning as select * from t0;
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`y` int(11) DEFAULT NULL,
`st` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`en` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
`st` SYS_DATATYPE GENERATED ALWAYS AS ROW START INVISIBLE,
`en` SYS_DATATYPE GENERATED ALWAYS AS ROW END INVISIBLE,
PERIOD FOR SYSTEM_TIME (`st`, `en`)
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
select y from t3 where st = @st;
@ -289,10 +262,7 @@ create or replace table t3 with system versioning select x23 from t1;
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`x23` int(11) DEFAULT NULL,
`sys_trx_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`sys_trx_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`x23` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
select * from t3;
x23
@ -314,16 +284,13 @@ show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`x23` int(11) DEFAULT NULL,
`sys_trx_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`sys_trx_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
`y` int(11) DEFAULT NULL,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`y` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
select * from t3 for system_time all where sys_trx_start = @sys_trx_start and sys_trx_end = @sys_trx_end;
x23 y
1 3
create or replace table t2 like t0;
insert into t2 values (1), (2);
insert into t2 (y) values (1), (2);
delete from t2 where y = 2;
create or replace table t3 select * from t2 for system_time all;
select st, en from t3 where y = 1 into @st, @en;
@ -341,24 +308,19 @@ as select x25, sys_trx_start, sys_trx_end from t1 for system_time all;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`x25` int(11) DEFAULT NULL,
`sys_trx_start` SYS_DATATYPE,
`sys_trx_end` SYS_DATATYPE
`x25` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1
create or replace table t2 with system versioning
as select x25, sys_trx_start, sys_trx_end from t1;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`x25` int(11) DEFAULT NULL,
`sys_trx_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`sys_trx_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`x25` int(11) DEFAULT NULL
) ENGINE=NON_DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
x26 int,
st bigint unsigned generated always as row start,
en bigint unsigned generated always as row end,
st bigint unsigned as row start invisible,
en bigint unsigned as row end invisible,
period for system_time (st, en)
) with system versioning engine innodb;
create or replace table t2 with system versioning engine myisam
@ -372,10 +334,7 @@ show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`b` int(11) DEFAULT NULL,
`x27` int(11) DEFAULT NULL,
`sys_trx_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`sys_trx_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`x27` int(11) DEFAULT NULL
) ENGINE=NON_DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
## Errors
create or replace table t (sys_trx_start int);
@ -388,9 +347,9 @@ create or replace temporary table t (x28 int) with system versioning;
ERROR HY000: Incorrect usage of TEMPORARY and WITH SYSTEM VERSIONING
create or replace table t1 (
x29 int unsigned,
Sys_start0 timestamp(6) generated always as row start,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
Sys_start0 timestamp(6) as row start invisible,
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Duplicate ROW START column `Sys_start`
@ -398,8 +357,8 @@ ERROR HY000: Duplicate ROW START column `Sys_start`
create or replace table t1 (x30 int) with system versioning;
create or replace table t2 (
y int,
st SYS_DATATYPE generated always as row start,
en SYS_DATATYPE generated always as row end,
st SYS_DATATYPE as row start invisible,
en SYS_DATATYPE as row end invisible,
period for system_time (st, en)
) with system versioning;
create or replace table t3
@ -409,15 +368,13 @@ Table Create Table
t3 CREATE TABLE `t3` (
`x30` int(11) DEFAULT NULL,
`y` int(11) DEFAULT NULL,
`sys_trx_start` SYS_DATATYPE,
`sys_trx_end` SYS_DATATYPE,
`st` SYS_DATATYPE,
`en` SYS_DATATYPE
`st` SYS_DATATYPE NOT NULL INVISIBLE DEFAULT '0000-00-00 00:00:00.000000',
`en` SYS_DATATYPE NOT NULL INVISIBLE DEFAULT '0000-00-00 00:00:00.000000'
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1
create or replace table t3 (
y int,
st SYS_DATATYPE generated always as row start,
en SYS_DATATYPE generated always as row end,
st SYS_DATATYPE as row start invisible,
en SYS_DATATYPE as row end invisible,
period for system_time (st, en)
) with system versioning
as select x30, y, sys_trx_start, sys_trx_end, st, en from t1, t2;
@ -426,10 +383,8 @@ Table Create Table
t3 CREATE TABLE `t3` (
`x30` int(11) DEFAULT NULL,
`y` int(11) DEFAULT NULL,
`sys_trx_start` SYS_DATATYPE,
`sys_trx_end` SYS_DATATYPE,
`st` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`en` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
`st` SYS_DATATYPE GENERATED ALWAYS AS ROW START INVISIBLE,
`en` SYS_DATATYPE GENERATED ALWAYS AS ROW END INVISIBLE,
PERIOD FOR SYSTEM_TIME (`st`, `en`)
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
drop database test;

View file

@ -6,8 +6,8 @@ begin
set @str= concat('
create or replace table t1(
XNo int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
@ -52,8 +52,8 @@ fields varchar(255))
begin
set @str= concat('create or replace table t1 (
x int,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
@ -74,8 +74,8 @@ begin
set @str0= concat('(
x int,
y int,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
@ -239,11 +239,11 @@ No A B C D
14 1 1 1 1
# Check sys_start, sys_end
call test_02('timestamp(6)', 'myisam', 'sys_end');
x sys_start sys_end
x
A B C
1 1 1
call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
x sys_start sys_end
x
A B C
1 1 1
call verify_vtq;

View file

@ -7,8 +7,8 @@ set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
@ -30,8 +30,8 @@ set @str= concat('
id int unsigned auto_increment primary key,
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
@ -52,8 +52,8 @@ set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
@ -94,8 +94,8 @@ begin
set @str= concat('(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
@ -265,8 +265,8 @@ No A B C D
16 1 1 1 1
create table t1(
x int unsigned,
sys_start bigint unsigned generated always as row start,
sys_end bigint unsigned generated always as row end,
sys_start bigint unsigned as row start invisible,
sys_end bigint unsigned as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning engine=innodb;
create table t2(x int unsigned) engine=innodb;
@ -294,8 +294,8 @@ Warning 4145 Transaction-based system versioning is EXPERIMENTAL and is subject
create or replace table t1 (
x int,
y int as (x) virtual,
sys_trx_start bigint unsigned as row start,
sys_trx_end bigint unsigned as row end,
sys_trx_start bigint unsigned as row start invisible,
sys_trx_end bigint unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) engine=innodb with system versioning;
insert into t1 values (1, null);

View file

@ -89,10 +89,7 @@ Warning 4115 Maybe missing parameters: no rotation condition for multiple HISTOR
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) DEFAULT NULL,
`sys_trx_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`sys_trx_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`x` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME
(PARTITION `p0` HISTORY ENGINE = DEFAULT_ENGINE,
@ -215,10 +212,7 @@ partition pn current);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) DEFAULT NULL,
`sys_trx_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START,
`sys_trx_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
`x` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME LIMIT 2
(PARTITION `p0` HISTORY ENGINE = DEFAULT_ENGINE,

View file

@ -1,8 +1,8 @@
create or replace table t1 (
x int unsigned,
y int unsigned,
sys_trx_start SYS_DATATYPE generated always as row start,
sys_trx_end SYS_DATATYPE generated always as row end,
sys_trx_start SYS_DATATYPE as row start invisible,
sys_trx_end SYS_DATATYPE as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning;
insert into t1 (x, y) values
@ -313,8 +313,8 @@ select * from t1 for system_time as of transaction 1;
ERROR HY000: Transaction system versioning for `t1` is not supported
create or replace table t1 (
x int,
sys_trx_start bigint unsigned generated always as row start,
sys_trx_end bigint unsigned generated always as row end,
sys_trx_start bigint unsigned as row start invisible,
sys_trx_end bigint unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning engine innodb;
insert into t1 values (1);

View file

@ -6,8 +6,8 @@ set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
@ -58,8 +58,8 @@ declare sys_type varchar(255) default sys_datatype(default_engine());
set @str0= concat('(
x int,
y int,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);

View file

@ -118,8 +118,8 @@ a sys_trx_start sys_trx_end
set system_versioning_hide= FULL;
create or replace table t (
x int,
st timestamp(6) generated always as row start,
en timestamp(6) generated always as row end,
st timestamp(6) as row start invisible,
en timestamp(6) as row end invisible,
period for system_time (st, en))
with system versioning;
show create table t;

View file

@ -3,8 +3,8 @@ select @@system_versioning_transaction_registry;
0
create or replace table t1 (
x int,
sys_trx_start bigint(20) unsigned generated always as row start,
sys_trx_end bigint(20) unsigned generated always as row end,
sys_trx_start bigint(20) unsigned as row start invisible,
sys_trx_end bigint(20) unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning engine innodb;
ERROR HY000: Temporal operation requires `mysql.transaction_registry` (@@system_versioning_transaction_registry).
@ -13,8 +13,8 @@ Warnings:
Warning 4145 Transaction-based system versioning is EXPERIMENTAL and is subject to change in future.
create or replace table t1 (
x int,
sys_trx_start bigint(20) unsigned generated always as row start,
sys_trx_end bigint(20) unsigned generated always as row end,
sys_trx_start bigint(20) unsigned as row start invisible,
sys_trx_end bigint(20) unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning engine innodb;
insert into t1 (x) values (1);

View file

@ -7,8 +7,8 @@ set @str= concat('
create table t1(
x int unsigned,
y int unsigned,
sys_trx_start ', sys_type, ' generated always as row start,
sys_trx_end ', sys_type, ' generated always as row end,
sys_trx_start ', sys_type, ' as row start invisible,
sys_trx_end ', sys_type, ' as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);
@ -41,8 +41,8 @@ set @str= concat('
id bigint primary key,
x int,
y int without system versioning,
sys_trx_start ', sys_type, ' as row start,
sys_trx_end ', sys_type, ' as row end,
sys_trx_start ', sys_type, ' as row start invisible,
sys_trx_end ', sys_type, ' as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);
@ -66,8 +66,8 @@ set @str= concat('
create table t1 (
x int,
y int,
sys_trx_start bigint unsigned as row start,
sys_trx_end bigint unsigned as row end,
sys_trx_start bigint unsigned as row start invisible,
sys_trx_end bigint unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning
engine ', engine);
@ -92,8 +92,8 @@ set @str= concat('
create table t1 (
id int primary key auto_increment,
x int,
sys_trx_start ', sys_type, ' as row start,
sys_trx_end ', sys_type, ' as row end,
sys_trx_start ', sys_type, ' as row start invisible,
sys_trx_end ', sys_type, ' as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);
@ -118,8 +118,8 @@ begin
set @str= concat('
create table t1(
x int unsigned,
sys_trx_end ', sys_type, ' generated always as row end,
sys_trx_start ', sys_type, ' generated always as row start,
sys_trx_end ', sys_type, ' as row end invisible,
sys_trx_start ', sys_type, ' as row start invisible,
y int unsigned,
period for system_time (sys_trx_start, sys_trx_end),
primary key(x, y))
@ -145,8 +145,8 @@ begin
set @str= concat('(
x int unsigned,
y int unsigned,
sys_trx_start ', sys_type, ' generated always as row start,
sys_trx_end ', sys_type, ' generated always as row end,
sys_trx_start ', sys_type, ' as row start invisible,
sys_trx_end ', sys_type, ' as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);
@ -191,8 +191,8 @@ set @str= concat('(
id bigint primary key without system versioning,
name varchar(128),
salary bigint without system versioning,
sys_trx_start ', sys_type, ' as row start,
sys_trx_end ', sys_type, ' as row end,
sys_trx_start ', sys_type, ' as row start invisible,
sys_trx_end ', sys_type, ' as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);

View file

@ -22,28 +22,28 @@ set system_versioning_alter_history= keep;
--error ER_VERS_FIELD_WRONG_TYPE
alter table t
add column trx_start bigint(20) unsigned generated always as row start,
add column trx_end bigint(20) unsigned generated always as row end,
add column trx_start bigint(20) unsigned as row start invisible,
add column trx_end bigint(20) unsigned as row end invisible,
add period for system_time(trx_start, trx_end),
add system versioning;
--error ER_VERS_FIELD_WRONG_TYPE
alter table t
add column trx_start timestamp generated always as row start,
add column trx_end timestamp generated always as row end,
add column trx_start timestamp as row start invisible,
add column trx_end timestamp as row end invisible,
add period for system_time(trx_start, trx_end),
add system versioning;
--error ER_PARSE_ERROR
alter table t
add column trx_start timestamp(6) not null generated always as row start,
add column trx_end timestamp(6) not null generated always as row end,
add column trx_start timestamp(6) not null as row start invisible,
add column trx_end timestamp(6) not null as row end invisible,
add period for system_time(trx_start, trx_end),
add system versioning;
alter table t
add column trx_start timestamp(6) generated always as row start,
add column trx_end timestamp(6) generated always as row end,
add column trx_start timestamp(6) as row start invisible,
add column trx_end timestamp(6) as row end invisible,
add period for system_time(trx_start, trx_end),
add system versioning;
show create table t;
@ -72,8 +72,8 @@ show create table t;
create or replace table t (
a int,
sys_trx_start timestamp(6) generated always as row start,
sys_trx_end timestamp(6) generated always as row end,
sys_trx_start timestamp(6) as row start invisible,
sys_trx_end timestamp(6) as row end invisible,
period for system_time(sys_trx_start, sys_trx_end))
with system versioning;
@ -89,8 +89,8 @@ alter table t drop column sys_trx_end;
create or replace table t (
a int,
sys_trx_start timestamp(6) generated always as row start,
sys_trx_end timestamp(6) generated always as row end,
sys_trx_start timestamp(6) as row start invisible,
sys_trx_end timestamp(6) as row end invisible,
period for system_time(sys_trx_start, sys_trx_end))
with system versioning;
@ -142,8 +142,8 @@ create or replace table t(
) engine=innodb;
alter table t
add column trx_start timestamp(6) as row start,
add column trx_end timestamp(6) as row end,
add column trx_start timestamp(6) as row start invisible,
add column trx_end timestamp(6) as row end invisible,
add period for system_time(trx_start, trx_end),
add system versioning;
@ -158,8 +158,8 @@ insert into t values(1);
call verify_vtq;
alter table t
add column trx_start bigint(20) unsigned as row start,
add column trx_end bigint(20) unsigned as row end,
add column trx_start bigint(20) unsigned as row start invisible,
add column trx_end bigint(20) unsigned as row end invisible,
add period for system_time(trx_start, trx_end),
add system versioning;
call verify_vtq;
@ -262,8 +262,8 @@ select * from t for system_time all;
create or replace table t (
a int,
sys_trx_start bigint(20) unsigned generated always as row start,
sys_trx_end bigint(20) unsigned generated always as row end,
sys_trx_start bigint(20) unsigned as row start invisible,
sys_trx_end bigint(20) unsigned as row end invisible,
period for system_time(sys_trx_start, sys_trx_end)
) with system versioning engine innodb;
--error ER_VERS_ALTER_SYSTEM_FIELD
@ -271,8 +271,8 @@ alter table t change column sys_trx_start asdf bigint unsigned;
create or replace table t (
a int,
sys_trx_start timestamp(6) generated always as row start,
sys_trx_end timestamp(6) generated always as row end,
sys_trx_start timestamp(6) as row start invisible,
sys_trx_end timestamp(6) as row end invisible,
period for system_time(sys_trx_start, sys_trx_end)
) with system versioning engine myisam;
--error ER_VERS_ALTER_SYSTEM_FIELD
@ -280,8 +280,8 @@ alter table t change column sys_trx_start asdf timestamp(6);
create or replace table t (
a int,
sys_trx_start timestamp(6) generated always as row start,
sys_trx_end timestamp(6) generated always as row end,
sys_trx_start timestamp(6) as row start invisible,
sys_trx_end timestamp(6) as row end invisible,
period for system_time(sys_trx_start, sys_trx_end)
) with system versioning;
select * from t;
@ -333,10 +333,10 @@ insert into non_empty values (1, 100, 200);
--error ER_VERS_GENERATED_ALWAYS_NOT_EMPTY
alter table non_empty
change column sys_trx_start sys_trx_start bigint(20) unsigned generated always as row start;
change column sys_trx_start sys_trx_start bigint(20) unsigned as row start invisible;
--error ER_VERS_GENERATED_ALWAYS_NOT_EMPTY
alter table non_empty
change column sys_trx_end sys_trx_end bigint(20) unsigned generated always as row end;
change column sys_trx_end sys_trx_end bigint(20) unsigned as row end invisible;
drop table non_empty;
create or replace table t (a int primary key) with system versioning;

View file

@ -11,8 +11,8 @@ begin
id int unsigned auto_increment primary key,
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);

View file

@ -2,8 +2,8 @@
create table t1(
id int auto_increment primary key,
sys_trx_start bigint unsigned generated always as row start,
sys_trx_end bigint unsigned generated always as row end,
sys_trx_start bigint unsigned as row start invisible,
sys_trx_end bigint unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
)
with system versioning

View file

@ -8,8 +8,8 @@ drop table if exists t1;
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE NULL ''
eval create table t1 (
x1 int unsigned,
Sys_start $sys_datatype generated always as row start comment 'start',
Sys_end $sys_datatype generated always as row end comment 'end',
Sys_start $sys_datatype as row start invisible comment 'start',
Sys_end $sys_datatype as row end invisible comment 'end',
period for system_time (Sys_start, Sys_end)
) with system versioning;
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
@ -26,8 +26,8 @@ show create table t1;
--error ER_VERS_PERIOD_COLUMNS
eval create or replace table t1 (
x3 int unsigned,
Sys_start $sys_datatype generated always as row start,
Sys_end $sys_datatype generated always as row end,
Sys_start $sys_datatype as row start invisible,
Sys_end $sys_datatype as row end invisible,
period for system_time (x, Sys_end)
) with system versioning;
@ -35,8 +35,8 @@ eval create or replace table t1 (
--error ER_VERS_PERIOD_COLUMNS
eval create or replace table t1 (
x4 int unsigned,
Sys_start $sys_datatype generated always as row start,
Sys_end2 $sys_datatype generated always as row end,
Sys_start $sys_datatype as row start invisible,
Sys_end2 $sys_datatype as row end invisible,
period for system_time (Sys_start, Sys_end)
) with system versioning;
@ -44,8 +44,8 @@ eval create or replace table t1 (
--error ER_VERS_PERIOD_COLUMNS
eval create or replace table t1 (
x5 int unsigned,
Sys_start $sys_datatype generated always as row start,
Sys_end $sys_datatype generated always as row end,
Sys_start $sys_datatype as row start invisible,
Sys_end $sys_datatype as row end invisible,
period for system_time (Sys_start, x)
) with system versioning;
@ -59,8 +59,8 @@ create or replace table t1 (
--error ER_MISSING
eval create or replace table t1 (
x7 int unsigned,
Sys_start $sys_datatype generated always as row start,
Sys_end $sys_datatype generated always as row end,
Sys_start $sys_datatype as row start invisible,
Sys_end $sys_datatype as row end invisible,
period for system_time (Sys_start, Sys_end)
);
@ -68,8 +68,8 @@ eval create or replace table t1 (
--error ER_VERS_PERIOD_COLUMNS
eval create or replace table t1 (
x8 int unsigned,
Sys_start $sys_datatype generated always as row start,
Sys_end $sys_datatype generated always as row end,
Sys_start $sys_datatype as row start invisible,
Sys_end $sys_datatype as row end invisible,
period for system_time (sys_insert, sys_remove)
) with system versioning;
@ -77,8 +77,8 @@ eval create or replace table t1 (
--error ER_MISSING
eval create or replace table t1 (
x9 int unsigned,
Sys_start $sys_datatype generated always as row start,
Sys_end $sys_datatype generated always as row end,
Sys_start $sys_datatype as row start invisible,
Sys_end $sys_datatype as row end invisible,
period for system_time (Sys_start, Sys_end)
);
@ -86,40 +86,40 @@ eval create or replace table t1 (
--error ER_MISSING
eval create or replace table t1 (
x10 int unsigned,
Sys_start $sys_datatype generated always as row start,
Sys_end $sys_datatype generated always as row end,
Sys_start $sys_datatype as row start invisible,
Sys_end $sys_datatype as row end invisible,
period for system_time (Sys_start, Sys_start)
);
--error ER_VERS_FIELD_WRONG_TYPE, ER_VERS_FIELD_WRONG_TYPE
create or replace table t1 (
x11 int unsigned,
Sys_start bigint unsigned generated always as row start,
Sys_end timestamp(6) generated always as row end,
Sys_start bigint unsigned as row start invisible,
Sys_end timestamp(6) as row end invisible,
period for system_time (Sys_start, Sys_end)
) with system versioning;
--error ER_VERS_FIELD_WRONG_TYPE, ER_VERS_FIELD_WRONG_TYPE
create or replace table t1 (
x12 int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end bigint unsigned generated always as row end,
Sys_start timestamp(6) as row start invisible,
Sys_end bigint unsigned as row end invisible,
period for system_time (Sys_start, Sys_end)
) with system versioning;
--error ER_VERS_FIELD_WRONG_TYPE
create or replace table t1 (
x13 int unsigned,
Sys_start bigint generated always as row start,
Sys_end bigint unsigned generated always as row end,
Sys_start bigint as row start invisible,
Sys_end bigint unsigned as row end invisible,
period for system_time (Sys_start, Sys_end)
) with system versioning engine innodb;
--error ER_VERS_FIELD_WRONG_TYPE
create or replace table t1 (
x14 int unsigned,
Sys_start bigint unsigned generated always as row start,
Sys_end bigint generated always as row end,
Sys_start bigint unsigned as row start invisible,
Sys_end bigint as row end invisible,
period for system_time (Sys_start, Sys_end)
) with system versioning engine innodb;
@ -190,8 +190,8 @@ create or replace table t1 (x23 int) with system versioning;
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
eval create or replace table t0(
y int,
st $sys_datatype generated always as row start,
en $sys_datatype generated always as row end,
st $sys_datatype as row start,
en $sys_datatype as row end,
period for system_time (st, en)
) with system versioning;
@ -210,7 +210,7 @@ show create table t3;
--echo ## For versioned table
insert into t1 values (1);
select sys_trx_start from t1 into @sys_trx_start;
insert into t0 values (2);
insert into t0 (y) values (2);
select st from t0 into @st;
--echo ### 1. implicit system fields are included as implicit
@ -231,8 +231,8 @@ select y from t3 where st = @st and sys_trx_start > @st;
--echo ### 3. explicit system fields are kept as system
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
eval create or replace table t3 (
st $sys_datatype generated always as row start,
en $sys_datatype generated always as row end,
st $sys_datatype as row start invisible,
en $sys_datatype as row end invisible,
period for system_time (st, en)
) with system versioning as select * from t0;
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE $sys_datatype_null SYS_DATATYPE $sys_datatype_not_null SYS_DATATYPE $sys_datatype_default_null SYS_DATATYPE
@ -264,7 +264,7 @@ show create table t3;
select * from t3 for system_time all where sys_trx_start = @sys_trx_start and sys_trx_end = @sys_trx_end;
create or replace table t2 like t0;
insert into t2 values (1), (2);
insert into t2 (y) values (1), (2);
delete from t2 where y = 2;
create or replace table t3 select * from t2 for system_time all;
@ -288,8 +288,8 @@ show create table t2;
create or replace table t1 (
x26 int,
st bigint unsigned generated always as row start,
en bigint unsigned generated always as row end,
st bigint unsigned as row start invisible,
en bigint unsigned as row end invisible,
period for system_time (st, en)
) with system versioning engine innodb;
--error ER_VERS_FIELD_WRONG_TYPE
@ -319,9 +319,9 @@ create or replace temporary table t (x28 int) with system versioning;
--error ER_VERS_DUPLICATE_ROW_START_END
create or replace table t1 (
x29 int unsigned,
Sys_start0 timestamp(6) generated always as row start,
Sys_start timestamp(6) generated always as row start,
Sys_end timestamp(6) generated always as row end,
Sys_start0 timestamp(6) as row start invisible,
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
period for system_time (Sys_start, Sys_end)
) with system versioning;
@ -330,8 +330,8 @@ create or replace table t1 (x30 int) with system versioning;
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
eval create or replace table t2 (
y int,
st $sys_datatype generated always as row start,
en $sys_datatype generated always as row end,
st $sys_datatype as row start invisible,
en $sys_datatype as row end invisible,
period for system_time (st, en)
) with system versioning;
@ -343,8 +343,8 @@ show create table t3;
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
eval create or replace table t3 (
y int,
st $sys_datatype generated always as row start,
en $sys_datatype generated always as row end,
st $sys_datatype as row start invisible,
en $sys_datatype as row end invisible,
period for system_time (st, en)
) with system versioning
as select x30, y, sys_trx_start, sys_trx_end, st, en from t1, t2;

View file

@ -9,8 +9,8 @@ begin
set @str= concat('
create or replace table t1(
XNo int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
@ -56,8 +56,8 @@ create or replace procedure test_02(
begin
set @str= concat('create or replace table t1 (
x int,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
@ -79,8 +79,8 @@ begin
set @str0= concat('(
x int,
y int,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);

View file

@ -10,8 +10,8 @@ begin
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
@ -34,8 +34,8 @@ begin
id int unsigned auto_increment primary key,
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
@ -57,8 +57,8 @@ begin
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
@ -101,8 +101,8 @@ begin
set @str= concat('(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
@ -168,8 +168,8 @@ call verify_vtq;
create table t1(
x int unsigned,
sys_start bigint unsigned generated always as row start,
sys_end bigint unsigned generated always as row end,
sys_start bigint unsigned as row start invisible,
sys_end bigint unsigned as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning engine=innodb;
@ -198,8 +198,8 @@ set global system_versioning_transaction_registry= on;
create or replace table t1 (
x int,
y int as (x) virtual,
sys_trx_start bigint unsigned as row start,
sys_trx_end bigint unsigned as row end,
sys_trx_start bigint unsigned as row start invisible,
sys_trx_end bigint unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) engine=innodb with system versioning;
insert into t1 values (1, null);

View file

@ -7,8 +7,8 @@
eval create or replace table t1 (
x int unsigned,
y int unsigned,
sys_trx_start $sys_datatype_expl generated always as row start,
sys_trx_end $sys_datatype_expl generated always as row end,
sys_trx_start $sys_datatype_expl as row start invisible,
sys_trx_end $sys_datatype_expl as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning;
@ -203,8 +203,8 @@ select * from t1 for system_time as of transaction 1;
create or replace table t1 (
x int,
sys_trx_start bigint unsigned generated always as row start,
sys_trx_end bigint unsigned generated always as row end,
sys_trx_start bigint unsigned as row start invisible,
sys_trx_end bigint unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning engine innodb;
insert into t1 values (1);

View file

@ -11,8 +11,8 @@ begin
create table t1(
x int unsigned,
y int unsigned,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);
@ -70,8 +70,8 @@ begin
set @str0= concat('(
x int,
y int,
sys_start ', sys_type, ' generated always as row start,
sys_end ', sys_type, ' generated always as row end,
sys_start ', sys_type, ' as row start invisible,
sys_end ', sys_type, ' as row end invisible,
period for system_time (sys_start, sys_end))
with system versioning
engine ', engine);

View file

@ -85,8 +85,8 @@ select * from t;
set system_versioning_hide= FULL;
create or replace table t (
x int,
st timestamp(6) generated always as row start,
en timestamp(6) generated always as row end,
st timestamp(6) as row start invisible,
en timestamp(6) as row end invisible,
period for system_time (st, en))
with system versioning;

View file

@ -5,8 +5,8 @@ select @@system_versioning_transaction_registry;
--error ER_VERS_TRT_IS_DISABLED
create or replace table t1 (
x int,
sys_trx_start bigint(20) unsigned generated always as row start,
sys_trx_end bigint(20) unsigned generated always as row end,
sys_trx_start bigint(20) unsigned as row start invisible,
sys_trx_end bigint(20) unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning engine innodb;
@ -14,8 +14,8 @@ set global system_versioning_transaction_registry= 1;
create or replace table t1 (
x int,
sys_trx_start bigint(20) unsigned generated always as row start,
sys_trx_end bigint(20) unsigned generated always as row end,
sys_trx_start bigint(20) unsigned as row start invisible,
sys_trx_end bigint(20) unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning engine innodb;

View file

@ -10,8 +10,8 @@ begin
create table t1(
x int unsigned,
y int unsigned,
sys_trx_start ', sys_type, ' generated always as row start,
sys_trx_end ', sys_type, ' generated always as row end,
sys_trx_start ', sys_type, ' as row start invisible,
sys_trx_end ', sys_type, ' as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);
@ -45,8 +45,8 @@ begin
id bigint primary key,
x int,
y int without system versioning,
sys_trx_start ', sys_type, ' as row start,
sys_trx_end ', sys_type, ' as row end,
sys_trx_start ', sys_type, ' as row start invisible,
sys_trx_end ', sys_type, ' as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);
@ -73,8 +73,8 @@ begin
create table t1 (
x int,
y int,
sys_trx_start bigint unsigned as row start,
sys_trx_end bigint unsigned as row end,
sys_trx_start bigint unsigned as row start invisible,
sys_trx_end bigint unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning
engine ', engine);
@ -104,8 +104,8 @@ begin
create table t1 (
id int primary key auto_increment,
x int,
sys_trx_start ', sys_type, ' as row start,
sys_trx_end ', sys_type, ' as row end,
sys_trx_start ', sys_type, ' as row start invisible,
sys_trx_end ', sys_type, ' as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);
@ -134,8 +134,8 @@ begin
set @str= concat('
create table t1(
x int unsigned,
sys_trx_end ', sys_type, ' generated always as row end,
sys_trx_start ', sys_type, ' generated always as row start,
sys_trx_end ', sys_type, ' as row end invisible,
sys_trx_start ', sys_type, ' as row start invisible,
y int unsigned,
period for system_time (sys_trx_start, sys_trx_end),
primary key(x, y))
@ -162,8 +162,8 @@ begin
set @str= concat('(
x int unsigned,
y int unsigned,
sys_trx_start ', sys_type, ' generated always as row start,
sys_trx_end ', sys_type, ' generated always as row end,
sys_trx_start ', sys_type, ' as row start invisible,
sys_trx_end ', sys_type, ' as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);
@ -209,8 +209,8 @@ begin
id bigint primary key without system versioning,
name varchar(128),
salary bigint without system versioning,
sys_trx_start ', sys_type, ' as row start,
sys_trx_end ', sys_type, ' as row end,
sys_trx_start ', sys_type, ' as row start invisible,
sys_trx_end ', sys_type, ' as row end invisible,
period for system_time (sys_trx_start, sys_trx_end))
with system versioning
engine ', engine);

View file

@ -1603,7 +1603,7 @@ String *Field::val_int_as_str(String *val_buffer, bool unsigned_val)
Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
uchar null_bit_arg,
utype unireg_check_arg, const LEX_CSTRING *field_name_arg)
:ptr(ptr_arg), field_visibility(NOT_INVISIBLE),
:ptr(ptr_arg), invisible(VISIBLE),
null_ptr(null_ptr_arg), table(0), orig_table(0),
table_name(0), field_name(*field_name_arg), option_list(0),
option_struct(0), key_start(0), part_of_key(0),
@ -2238,9 +2238,9 @@ Field *Field::make_new_field(MEM_ROOT *root, TABLE *new_table,
tmp->flags&= (NOT_NULL_FLAG | BLOB_FLAG | UNSIGNED_FLAG |
ZEROFILL_FLAG | BINARY_FLAG | ENUM_FLAG | SET_FLAG |
VERS_SYS_START_FLAG | VERS_SYS_END_FLAG |
VERS_UPDATE_UNVERSIONED_FLAG | VERS_HIDDEN_FLAG);
VERS_UPDATE_UNVERSIONED_FLAG);
tmp->reset_fields();
tmp->field_visibility= NOT_INVISIBLE;
tmp->invisible= VISIBLE;
return tmp;
}
@ -10750,7 +10750,7 @@ Column_definition::Column_definition(THD *thd, Field *old_field,
pack_flag= 0;
compression_method_ptr= 0;
versioning= VERSIONING_NOT_SET;
field_visibility= old_field->field_visibility;
invisible= old_field->invisible;
if (orig_field)
{
@ -10888,7 +10888,7 @@ Column_definition::redefine_stage1_common(const Column_definition *dup_field,
flags= dup_field->flags;
interval= dup_field->interval;
vcol_info= dup_field->vcol_info;
field_visibility= dup_field->field_visibility;
invisible= dup_field->invisible;
}

View file

@ -683,7 +683,7 @@ public:
uchar *ptr; // Position to field in record
field_visible_type field_visibility;
field_visibility_t invisible;
/**
Byte where the @c NULL bit is stored inside a record. If this Field is a
@c NOT @c NULL field, this member is @c NULL.
@ -1468,6 +1468,8 @@ public:
return flags & VERS_UPDATE_UNVERSIONED_FLAG;
}
bool vers_sys_invisible(THD *thd) const;
virtual bool vers_trx_id() const
{
return false;
@ -4142,7 +4144,7 @@ public:
max number of characters.
*/
ulonglong length;
field_visible_type field_visibility;
field_visibility_t invisible;
/*
The value of `length' as set by parser: is the number of characters
for most of the types, or of bytes for BLOBs or numeric types.
@ -4175,7 +4177,7 @@ public:
:Type_handler_hybrid_field_type(&type_handler_null),
compression_method_ptr(0),
comment(null_clex_str),
on_update(NULL), length(0),field_visibility(NOT_INVISIBLE), decimals(0),
on_update(NULL), length(0), invisible(VISIBLE), decimals(0),
flags(0), pack_length(0), key_length(0), unireg_check(Field::NONE),
interval(0), charset(&my_charset_bin),
srid(0), geom_type(Field::GEOM_GEOMETRY),
@ -4654,7 +4656,7 @@ bool check_expression(Virtual_column_info *vcol, LEX_CSTRING *name,
#define f_no_default(x) ((x) & FIELDFLAG_NO_DEFAULT)
#define f_bit_as_char(x) ((x) & FIELDFLAG_TREAT_BIT_AS_CHAR)
#define f_is_hex_escape(x) ((x) & FIELDFLAG_HEX_ESCAPE)
#define f_visibility(x) (static_cast<field_visible_type> ((x) & MAX_BITS_INVISIBLE))
#define f_visibility(x) (static_cast<field_visibility_t> ((x) & INVISIBLE_MAX_BITS))
inline
ulonglong TABLE::vers_end_id() const

View file

@ -6771,9 +6771,10 @@ static Create_field *vers_init_sys_field(THD *thd, const char *field_name,
f->field_name.str= field_name;
f->field_name.length= strlen(field_name);
f->charset= system_charset_info;
f->flags= flags | VERS_HIDDEN_FLAG;
f->flags= flags;
f->set_handler(&type_handler_timestamp2);
f->length= MAX_DATETIME_PRECISION;
f->invisible= INVISIBLE_SYSTEM;
if (f->check(thd))
return NULL;
@ -7120,13 +7121,13 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
return true;
}
if (!(share->vers_start_field()->flags & VERS_HIDDEN_FLAG))
if (share->vers_start_field()->invisible < INVISIBLE_SYSTEM)
{
my_error(ER_VERS_SYS_FIELD_NOT_HIDDEN, MYF(0),
share->vers_start_field()->field_name.str);
return true;
}
if (!(share->vers_end_field()->flags & VERS_HIDDEN_FLAG))
if (share->vers_end_field()->invisible < INVISIBLE_SYSTEM)
{
my_error(ER_VERS_SYS_FIELD_NOT_HIDDEN, MYF(0),
share->vers_end_field()->field_name.str);
@ -7255,7 +7256,7 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
}
else
continue;
if (f->flags & VERS_HIDDEN_FLAG)
if (f->invisible > INVISIBLE_USER)
{
my_error(ER_CANT_DROP_FIELD_OR_KEY, MYF(0), d->type_name(), name);
return true;

View file

@ -5528,7 +5528,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
if (field_ptr && *field_ptr)
{
if ((*field_ptr)->field_visibility == COMPLETELY_INVISIBLE &&
if ((*field_ptr)->invisible == INVISIBLE_FULL &&
DBUG_EVALUATE_IF("test_completely_invisible", 0, 1))
DBUG_RETURN((Field*)0);
@ -7492,6 +7492,29 @@ bool get_key_map_from_key_list(key_map *map, TABLE *table,
}
inline
bool Field::vers_sys_invisible(THD *thd) const
{
DBUG_ASSERT(vers_sys_field());
enum_sql_command sql_command= thd->lex->sql_command;
SELECT_LEX *slex= thd->lex->current_select;
ulong vers_hide= thd->variables.vers_hide;
DBUG_ASSERT(table);
DBUG_ASSERT(table->pos_in_table_list);
TABLE_LIST *tl= table->pos_in_table_list;
vers_system_time_t vers_type= tl->vers_conditions.type;
return (sql_command == SQLCOM_CREATE_VIEW ||
slex->nest_level > 0 ||
vers_hide == VERS_HIDE_FULL ||
(invisible && (
vers_hide == VERS_HIDE_IMPLICIT ||
(vers_hide == VERS_HIDE_AUTO && (
vers_type == SYSTEM_TIME_UNSPECIFIED ||
vers_type == SYSTEM_TIME_AS_OF)))));
}
/*
Drops in all fields instead of current '*' field
@ -7518,7 +7541,6 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
Field_iterator_table_ref field_iterator;
bool found;
char name_buff[SAFE_NAME_LEN+1];
ulong vers_hide= thd->variables.vers_hide;
DBUG_ENTER("insert_fields");
DBUG_PRINT("arena", ("stmt arena: %p",thd->stmt_arena));
@ -7623,45 +7645,21 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
But view fields can never be invisible.
*/
if ((field= field_iterator.field()) &&
field->field_visibility != NOT_INVISIBLE)
(field->vers_sys_field() ?
field->vers_sys_invisible(thd) :
field->invisible))
{
if (thd->lex->sql_command != SQLCOM_CREATE_TABLE ||
!(thd->lex->create_info.options & HA_VERSIONED_TABLE))
continue;
}
Item *item;
if (!(item= field_iterator.create_item(thd)))
DBUG_RETURN(TRUE);
if (item->type() == Item::FIELD_ITEM)
{
Item_field *f= static_cast<Item_field *>(item);
DBUG_ASSERT(f->field);
uint32 fl= f->field->flags;
bool sys_field= fl & (VERS_SYS_START_FLAG | VERS_SYS_END_FLAG);
SELECT_LEX *slex= thd->lex->current_select;
TABLE *table= f->field->table;
DBUG_ASSERT(table && table->pos_in_table_list);
TABLE_LIST *tl= table->pos_in_table_list;
vers_system_time_t vers_type= tl->vers_conditions.type;
enum_sql_command sql_command= thd->lex->sql_command;
unsigned int create_options= thd->lex->create_info.options;
if (sys_field ?
(sql_command == SQLCOM_CREATE_VIEW ||
slex->nest_level > 0 ||
vers_hide == VERS_HIDE_FULL ||
((fl & VERS_HIDDEN_FLAG) && (
vers_hide == VERS_HIDE_IMPLICIT ||
(vers_hide == VERS_HIDE_AUTO && (
vers_type == SYSTEM_TIME_UNSPECIFIED ||
vers_type == SYSTEM_TIME_AS_OF))))) :
(fl & VERS_HIDDEN_FLAG))
{
if (sql_command != SQLCOM_CREATE_TABLE ||
!(create_options & HA_VERSIONED_TABLE))
continue;
}
}
else if (item->type() == Item::REF_ITEM)
if (item->type() == Item::REF_ITEM)
{
Item *i= item;
while (i->type() == Item::REF_ITEM)
@ -7670,7 +7668,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
{
Item_field *f= (Item_field *)i;
DBUG_ASSERT(f->field);
if (f->field->flags & VERS_HIDDEN_FLAG)
if (f->field->vers_sys_field() && f->field->vers_sys_invisible(thd))
continue;
}
}
@ -8307,14 +8305,18 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
/* Ensure that all fields are from the same table */
DBUG_ASSERT(field->table == table);
if (table->versioned() && field->vers_sys_field() && !ignore_errors)
bool vers_sys_field= table->versioned() && field->vers_sys_field();
if (vers_sys_field && !ignore_errors)
{
my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), field->field_name.str);
goto err;
}
if (field->field_visibility != NOT_INVISIBLE)
if (field->invisible && !vers_sys_field)
{
continue;
}
else
value=v++;
if (field->field_index == autoinc_index)

View file

@ -222,7 +222,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
table_list->view_db.str, table_list->view_name.str);
DBUG_RETURN(-1);
}
if (values.elements != table->vers_user_fields())
if (values.elements != table->s->visible_fields)
{
my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), 1L);
DBUG_RETURN(-1);

View file

@ -16865,7 +16865,6 @@ Field *create_tmp_field_from_field(THD *thd, Field *org_field,
new_field->field_name= *name;
new_field->flags|= (org_field->flags & (
NO_DEFAULT_VALUE_FLAG |
VERS_HIDDEN_FLAG |
VERS_SYS_START_FLAG |
VERS_SYS_END_FLAG |
VERS_UPDATE_UNVERSIONED_FLAG));
@ -17128,6 +17127,10 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
modify_item ? field :
NULL);
}
if (field->field->vers_sys_field())
result->invisible= field->field->invisible;
if (orig_type == Item::REF_ITEM && orig_modify)
((Item_ref*)orig_item)->set_result_field(result);
/*
@ -17715,8 +17718,10 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
if (sys_trx_start && sys_trx_end)
{
DBUG_ASSERT(versioned);
sys_trx_start->flags|= VERS_SYS_START_FLAG | VERS_HIDDEN_FLAG;
sys_trx_end->flags|= VERS_SYS_END_FLAG | VERS_HIDDEN_FLAG;
sys_trx_start->flags|= VERS_SYS_START_FLAG;
sys_trx_end->flags|= VERS_SYS_END_FLAG;
sys_trx_start->invisible= INVISIBLE_SYSTEM;
sys_trx_end->invisible= INVISIBLE_SYSTEM;
share->versioned= versioned;
share->field= table->field;
share->row_start_field= sys_trx_start->field_index;

View file

@ -2189,12 +2189,17 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
uint flags = field->flags;
if (vers_hide == VERS_HIDE_FULL &&
(flags & (VERS_SYS_START_FLAG | VERS_SYS_END_FLAG)))
continue;
if (field->field_visibility > USER_DEFINED_INVISIBLE)
if (field->vers_sys_field())
{
if (vers_hide == VERS_HIDE_FULL || (vers_hide != VERS_HIDE_NEVER &&
field->invisible > INVISIBLE_USER))
{
continue;
}
}
else if (field->invisible > INVISIBLE_USER)
continue;
if (not_the_first_field)
packet->append(STRING_WITH_LEN(",\n"));
@ -2259,7 +2264,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
packet->append(STRING_WITH_LEN(" NULL"));
}
if (field->field_visibility == USER_DEFINED_INVISIBLE)
if (field->invisible == INVISIBLE_USER)
{
packet->append(STRING_WITH_LEN(" INVISIBLE"));
}
@ -2343,8 +2348,8 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
Field *field= key_part->field;
if (field && field->vers_sys_field())
{
if (vers_hide == VERS_HIDE_FULL /*|| ((field->flags & HIDDEN_FLAG) &&
vers_hide != VERS_HIDE_NEVER)*/)
if (vers_hide == VERS_HIDE_FULL || (field->invisible &&
vers_hide != VERS_HIDE_NEVER))
continue;
}
@ -2380,11 +2385,17 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
{
const Field *fs = table->vers_start_field();
const Field *fe = table->vers_end_field();
packet->append(STRING_WITH_LEN(",\n PERIOD FOR SYSTEM_TIME ("));
append_identifier(thd,packet,fs->field_name.str, fs->field_name.length);
packet->append(STRING_WITH_LEN(", "));
append_identifier(thd,packet,fe->field_name.str, fe->field_name.length);
packet->append(STRING_WITH_LEN(")"));
DBUG_ASSERT(fs);
DBUG_ASSERT(fe);
DBUG_ASSERT(!fs->invisible || fe->invisible);
if (fe->invisible < INVISIBLE_SYSTEM || vers_hide == VERS_HIDE_NEVER)
{
packet->append(STRING_WITH_LEN(",\n PERIOD FOR SYSTEM_TIME ("));
append_identifier(thd,packet,fs->field_name.str, fs->field_name.length);
packet->append(STRING_WITH_LEN(", "));
append_identifier(thd,packet,fe->field_name.str, fe->field_name.length);
packet->append(STRING_WITH_LEN(")"));
}
}
/*
@ -5847,7 +5858,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
for (; (field= *ptr) ; ptr++)
{
if(field->field_visibility > USER_DEFINED_INVISIBLE)
if(field->invisible > INVISIBLE_USER)
continue;
uchar *pos;
char tmp[MAX_FIELD_WIDTH];
@ -5928,7 +5939,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
else
table->field[20]->store(STRING_WITH_LEN("NEVER"), cs);
/*Invisible can coexist with auto_increment and virtual */
if (field->field_visibility == USER_DEFINED_INVISIBLE)
if (field->invisible == INVISIBLE_USER)
{
if (buf.length())
buf.append(STRING_WITH_LEN(", "));

View file

@ -3316,22 +3316,22 @@ bool Column_definition::prepare_stage1_check_typelib_default()
field_list list of all table fields
field_name name/prefix of invisible field
( Prefix in the case when it is
*COMPLETELY_INVISIBLE*
*INVISIBLE_FULL*
and given name is duplicate)
type_handler field data type
field_visibility
invisible
default value
RETURN VALUE
Create_field pointer
*/
int mysql_add_invisible_field(THD *thd, List<Create_field> * field_list,
const char *field_name, Type_handler *type_handler,
field_visible_type field_visibility, Item* default_value)
field_visibility_t invisible, Item* default_value)
{
Create_field *fld= new(thd->mem_root)Create_field();
const char *new_name= NULL;
/* Get unique field name if field_visibility == COMPLETELY_INVISIBLE */
if (field_visibility == COMPLETELY_INVISIBLE)
/* Get unique field name if invisible == INVISIBLE_FULL */
if (invisible == INVISIBLE_FULL)
{
if ((new_name= make_unique_invisible_field_name(thd, field_name,
field_list)))
@ -3348,7 +3348,7 @@ int mysql_add_invisible_field(THD *thd, List<Create_field> * field_list,
fld->field_name.length= strlen(field_name);
}
fld->set_handler(type_handler);
fld->field_visibility= field_visibility;
fld->invisible= invisible;
if (default_value)
{
Virtual_column_info *v= new (thd->mem_root) Virtual_column_info();
@ -3421,12 +3421,12 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
DBUG_EXECUTE_IF("test_pseudo_invisible",{
mysql_add_invisible_field(thd, &alter_info->create_list,
"invisible", &type_handler_long, SYSTEM_INVISIBLE,
"invisible", &type_handler_long, INVISIBLE_SYSTEM,
new (thd->mem_root)Item_int(thd, 9));
});
DBUG_EXECUTE_IF("test_completely_invisible",{
mysql_add_invisible_field(thd, &alter_info->create_list,
"invisible", &type_handler_long, COMPLETELY_INVISIBLE,
"invisible", &type_handler_long, INVISIBLE_FULL,
new (thd->mem_root)Item_int(thd, 9));
});
DBUG_EXECUTE_IF("test_invisible_index",{
@ -3584,7 +3584,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
*/
if (sql_field->stored_in_db())
record_offset+= sql_field->pack_length;
if (sql_field->field_visibility == USER_DEFINED_INVISIBLE &&
if (sql_field->invisible == INVISIBLE_USER &&
sql_field->flags & NOT_NULL_FLAG &&
sql_field->flags & NO_DEFAULT_VALUE_FLAG)
{
@ -3604,7 +3604,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
sql_field->offset= record_offset;
record_offset+= sql_field->pack_length;
}
if (sql_field->field_visibility == NOT_INVISIBLE)
if (sql_field->invisible == VISIBLE)
is_all_invisible= false;
}
if (is_all_invisible)
@ -3862,15 +3862,15 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
&sql_field->field_name))
field++;
/*
Either field is not present or field visibility is >
USER_DEFINED_INVISIBLE
Either field is not present or field visibility is > INVISIBLE_USER
*/
if (!sql_field)
{
my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name.str);
DBUG_RETURN(TRUE);
}
if (sql_field->field_visibility > USER_DEFINED_INVISIBLE &&
if (sql_field->invisible > INVISIBLE_USER &&
!(sql_field->flags & VERS_SYSTEM_FIELD) &&
!key->invisible && DBUG_EVALUATE_IF("test_invisible_index", 0, 1))
{
my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name.str);
@ -5343,11 +5343,11 @@ static void make_unique_constraint_name(THD *thd, LEX_CSTRING *name,
}
/**
COMPLETELY_INVISIBLE are internally created. They are completely invisible
INVISIBLE_FULL are internally created. They are completely invisible
to Alter command (Opposite of SYSTEM_INVISIBLE which throws an
error when same name column is added by Alter). So in the case of when
user added a same column name as of COMPLETELY_INVISIBLE , we change
COMPLETELY_INVISIBLE column name.
user added a same column name as of INVISIBLE_FULL , we change
INVISIBLE_FULL column name.
*/
static const
char * make_unique_invisible_field_name(THD *thd, const char *field_name,
@ -7889,7 +7889,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
bitmap_clear_all(&table->tmp_set);
for (f_ptr=table->field ; (field= *f_ptr) ; f_ptr++)
{
if (field->field_visibility == COMPLETELY_INVISIBLE)
if (field->invisible == INVISIBLE_FULL)
continue;
Alter_drop *drop;
if (field->type() == MYSQL_TYPE_VARCHAR)
@ -7902,7 +7902,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
!my_strcasecmp(system_charset_info,field->field_name.str, drop->name))
break;
}
if (drop && field->field_visibility < SYSTEM_INVISIBLE)
if (drop && (field->invisible < INVISIBLE_SYSTEM || field->vers_sys_field()))
{
/* Reset auto_increment value if it was dropped */
if (MTYP_TYPENR(field->unireg_check) == Field::NEXT_NUMBER &&
@ -7927,7 +7927,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
&def->change))
break;
}
if (def && field->field_visibility < SYSTEM_INVISIBLE)
if (def && (field->invisible < INVISIBLE_SYSTEM || field->vers_sys_field()))
{ // Field is changed
def->field=field;
/*

View file

@ -6649,7 +6649,7 @@ vcol_attribute:
| COMMENT_SYM TEXT_STRING_sys { Lex->last_field->comment= $2; }
| INVISIBLE_SYM
{
Lex->last_field->field_visibility= USER_DEFINED_INVISIBLE;
Lex->last_field->invisible= INVISIBLE_USER;
}
;

View file

@ -6135,7 +6135,7 @@ vcol_attribute:
| COMMENT_SYM TEXT_STRING_sys { Lex->last_field->comment= $2; }
| INVISIBLE_SYM
{
Lex->last_field->field_visibility= USER_DEFINED_INVISIBLE;
Lex->last_field->invisible= INVISIBLE_USER;
}
;

View file

@ -2076,14 +2076,12 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
uchar flags= *extra2_field_flags++;
if (flags & VERS_OPTIMIZED_UPDATE)
reg_field->flags|= VERS_UPDATE_UNVERSIONED_FLAG;
if (flags & VERS_HIDDEN)
reg_field->flags|= VERS_HIDDEN_FLAG;
reg_field->field_visibility= f_visibility(flags);
reg_field->invisible= f_visibility(flags);
}
if (reg_field->field_visibility == USER_DEFINED_INVISIBLE)
if (reg_field->invisible == INVISIBLE_USER)
status_var_increment(thd->status_var.feature_invisible_columns);
if (reg_field->field_visibility == NOT_INVISIBLE)
if (!reg_field->invisible)
share->visible_fields++;
if (field_type == MYSQL_TYPE_BIT && !f_bit_as_char(pack_flag))
{
@ -2336,7 +2334,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
field= key_part->field= share->field[key_part->fieldnr-1];
key_part->type= field->key_type();
if (field->field_visibility > USER_DEFINED_INVISIBLE)
if (field->invisible > INVISIBLE_USER && !field->vers_sys_field())
keyinfo->flags |= HA_INVISIBLE_KEY;
if (field->null_ptr)
{

View file

@ -337,16 +337,18 @@ enum enum_vcol_update_mode
/* Field visibility enums */
enum field_visible_type{
NOT_INVISIBLE= 0,
USER_DEFINED_INVISIBLE,
enum field_visibility_t {
VISIBLE= 0,
INVISIBLE_USER,
/* automatically added by the server. Can be queried explicitly
in SELECT, otherwise invisible from anything" */
SYSTEM_INVISIBLE,
COMPLETELY_INVISIBLE,
MAX_BITS_INVISIBLE= 3
INVISIBLE_SYSTEM,
INVISIBLE_FULL
};
#define INVISIBLE_MAX_BITS 3
/**
Category of table found in the table share.
*/
@ -1561,13 +1563,6 @@ public:
/** Number of additional fields used in versioned tables */
#define VERSIONING_FIELDS 2
uint vers_user_fields() const
{
return s->versioned ?
s->visible_fields - VERSIONING_FIELDS :
s->visible_fields;
}
};

View file

@ -98,11 +98,9 @@ static uchar *extra2_write_field_properties(uchar *pos,
pos= extra2_write_len(pos, create_fields.elements);
while (Create_field *cf= it++)
{
uchar flags= cf->field_visibility;
uchar flags= cf->invisible;
if (cf->flags & VERS_UPDATE_UNVERSIONED_FLAG)
flags|= VERS_OPTIMIZED_UPDATE;
if (cf->flags & VERS_HIDDEN_FLAG)
flags|= VERS_HIDDEN;
*pos++= flags;
}
return pos;
@ -143,9 +141,9 @@ bool has_extra2_field_flags(List<Create_field> &create_fields)
List_iterator<Create_field> it(create_fields);
while (Create_field *f= it++)
{
if (f->field_visibility != NOT_INVISIBLE)
if (f->invisible)
return true;
if (f->flags & (VERS_UPDATE_UNVERSIONED_FLAG | VERS_HIDDEN_FLAG))
if (f->flags & VERS_UPDATE_UNVERSIONED_FLAG)
return true;
}
return false;

View file

@ -182,8 +182,8 @@ enum extra2_frm_value_type {
};
enum extra2_field_flags {
VERS_OPTIMIZED_UPDATE= 1 << MAX_BITS_INVISIBLE,
VERS_HIDDEN= 1 << (MAX_BITS_INVISIBLE + 1),
VERS_OPTIMIZED_UPDATE= 1 << INVISIBLE_MAX_BITS,
VERS_HIDDEN= 1 << (INVISIBLE_MAX_BITS + 1),
};
int rea_create_table(THD *thd, LEX_CUSTRING *frm,