Commit 1db438c8 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-11066 use MySQL terminology for "virtual columns"

parent 6eaa5fd2
...@@ -138,6 +138,12 @@ typedef unsigned long long my_ulonglong; ...@@ -138,6 +138,12 @@ typedef unsigned long long my_ulonglong;
#define ER_WARN_DATA_TRUNCATED WARN_DATA_TRUNCATED #define ER_WARN_DATA_TRUNCATED WARN_DATA_TRUNCATED
#define WARN_PLUGIN_DELETE_BUILTIN ER_PLUGIN_DELETE_BUILTIN #define WARN_PLUGIN_DELETE_BUILTIN ER_PLUGIN_DELETE_BUILTIN
#define ER_FK_DUP_NAME ER_DUP_CONSTRAINT_NAME #define ER_FK_DUP_NAME ER_DUP_CONSTRAINT_NAME
#define ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#define ER_PRIMARY_KEY_BASED_ON_VIRTUAL_COLUMN ER_PRIMARY_KEY_BASED_ON_GENERATED_COLUMN
#define ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
#define ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
#define ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
#define ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS
typedef struct st_mysql_rows { typedef struct st_mysql_rows {
struct st_mysql_rows *next; /* list of rows */ struct st_mysql_rows *next; /* list of rows */
......
...@@ -1866,8 +1866,8 @@ Thinkpad Laptop black ttt ...@@ -1866,8 +1866,8 @@ Thinkpad Laptop black ttt
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`color` char(32) AS (column_get(`dynamic_cols`,1 as char charset latin1)) PERSISTENT, `color` char(32) GENERATED ALWAYS AS (column_get(`dynamic_cols`,1 as char charset latin1)) STORED,
`cl` char(32) AS (column_get(column_add(column_create(1,'blue' AS char charset latin1 ),2,'ttt'),`i` as char charset latin1)) PERSISTENT, `cl` char(32) GENERATED ALWAYS AS (column_get(column_add(column_create(1,'blue' AS char charset latin1 ),2,'ttt'),`i` as char charset latin1)) STORED,
`item_name` varchar(32) NOT NULL, `item_name` varchar(32) NOT NULL,
`i` int(11) DEFAULT NULL, `i` int(11) DEFAULT NULL,
`dynamic_cols` blob DEFAULT NULL, `dynamic_cols` blob DEFAULT NULL,
...@@ -1888,7 +1888,7 @@ show create table t1; ...@@ -1888,7 +1888,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`n` int(11) DEFAULT NULL, `n` int(11) DEFAULT NULL,
`c` char(32) AS (cast(cast(`n` as char charset latin1) as char charset latin1)) PERSISTENT `c` char(32) GENERATED ALWAYS AS (cast(cast(`n` as char charset latin1) as char charset latin1)) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
set @@session.collation_server=filename; set @@session.collation_server=filename;
......
...@@ -5,8 +5,8 @@ SHOW CREATE TABLE mysql57_virtual; ...@@ -5,8 +5,8 @@ SHOW CREATE TABLE mysql57_virtual;
Table Create Table Table Create Table
mysql57_virtual CREATE TABLE `mysql57_virtual` ( mysql57_virtual CREATE TABLE `mysql57_virtual` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` + 1)) VIRTUAL, `b` int(11) GENERATED ALWAYS AS ((`a` + 1)) VIRTUAL,
`c` int(11) AS ((`a` + 3)) PERSISTENT `c` int(11) GENERATED ALWAYS AS ((`a` + 3)) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into mysql57_virtual (a) values (1),(2); insert into mysql57_virtual (a) values (1),(2);
select * from mysql57_virtual; select * from mysql57_virtual;
...@@ -20,8 +20,8 @@ SHOW CREATE TABLE mysql57_virtual; ...@@ -20,8 +20,8 @@ SHOW CREATE TABLE mysql57_virtual;
Table Create Table Table Create Table
mysql57_virtual CREATE TABLE `mysql57_virtual` ( mysql57_virtual CREATE TABLE `mysql57_virtual` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` + 1)) VIRTUAL, `b` int(11) GENERATED ALWAYS AS ((`a` + 1)) VIRTUAL,
`c` int(11) AS ((`a` + 3)) PERSISTENT `c` int(11) GENERATED ALWAYS AS ((`a` + 3)) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='I am now a MariaDB table' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='I am now a MariaDB table'
DROP TABLE mysql57_virtual; DROP TABLE mysql57_virtual;
# #
...@@ -32,7 +32,7 @@ show create table t1; ...@@ -32,7 +32,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` + 1)) PERSISTENT, `b` int(11) GENERATED ALWAYS AS ((`a` + 1)) STORED,
`c` int(11) AS ((`a` + 2)) VIRTUAL `c` int(11) GENERATED ALWAYS AS ((`a` + 2)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
...@@ -55,62 +55,62 @@ drop table t1; ...@@ -55,62 +55,62 @@ drop table t1;
# #
--echo # LOAD_FILE() --echo # LOAD_FILE()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(64), b varchar(1024) generated always as (load_file(a)) virtual); create table t1 (a varchar(64), b varchar(1024) generated always as (load_file(a)) virtual);
--echo # MATCH() --echo # MATCH()
if (!$skip_full_text_check) if (!$skip_full_text_check)
{ {
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(32), b bool generated always as (match a against ('sample text')) virtual); create table t1 (a varchar(32), b bool generated always as (match a against ('sample text')) virtual);
} }
--echo # BENCHMARK() --echo # BENCHMARK()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) generated always as (benchmark(a,3)) virtual); create table t1 (a varchar(1024), b varchar(1024) generated always as (benchmark(a,3)) virtual);
--echo # FOUND_ROWS() --echo # FOUND_ROWS()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) generated always as (found_rows()) virtual); create table t1 (a varchar(1024), b varchar(1024) generated always as (found_rows()) virtual);
--echo # GET_LOCK() --echo # GET_LOCK()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) generated always as (get_lock(a,10)) virtual); create table t1 (a varchar(1024), b varchar(1024) generated always as (get_lock(a,10)) virtual);
--echo # IS_FREE_LOCK() --echo # IS_FREE_LOCK()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) generated always as (is_free_lock(a)) virtual); create table t1 (a varchar(1024), b varchar(1024) generated always as (is_free_lock(a)) virtual);
--echo # IS_USED_LOCK() --echo # IS_USED_LOCK()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) generated always as (is_used_lock(a)) virtual); create table t1 (a varchar(1024), b varchar(1024) generated always as (is_used_lock(a)) virtual);
--echo # LAST_INSERT_ID() --echo # LAST_INSERT_ID()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int generated always as (last_insert_id()) virtual); create table t1 (a int generated always as (last_insert_id()) virtual);
--echo # MASTER_POS_WAIT() --echo # MASTER_POS_WAIT()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(32), b int generated always as (master_pos_wait(a,0,2)) virtual); create table t1 (a varchar(32), b int generated always as (master_pos_wait(a,0,2)) virtual);
--echo # NAME_CONST() --echo # NAME_CONST()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(32) generated always as (name_const('test',1)) virtual); create table t1 (a varchar(32) generated always as (name_const('test',1)) virtual);
--echo # RELEASE_LOCK() --echo # RELEASE_LOCK()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(32), b int generated always as (release_lock(a)) virtual); create table t1 (a varchar(32), b int generated always as (release_lock(a)) virtual);
--echo # ROW_COUNT() --echo # ROW_COUNT()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int generated always as (row_count()) virtual); create table t1 (a int generated always as (row_count()) virtual);
--echo # SLEEP() --echo # SLEEP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (sleep(a)) virtual); create table t1 (a int, b int generated always as (sleep(a)) virtual);
--echo # VALUES() --echo # VALUES()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) generated always as (values(a)) virtual); create table t1 (a varchar(1024), b varchar(1024) generated always as (values(a)) virtual);
--echo # Stored procedures --echo # Stored procedures
...@@ -129,16 +129,16 @@ end // ...@@ -129,16 +129,16 @@ end //
delimiter ;// delimiter ;//
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int generated always as (p1()) virtual); create table t1 (a int generated always as (p1()) virtual);
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int generated always as (f1()) virtual); create table t1 (a int generated always as (f1()) virtual);
drop procedure p1; drop procedure p1;
drop function f1; drop function f1;
--echo # Unknown functions --echo # Unknown functions
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int generated always as (f1()) virtual); create table t1 (a int generated always as (f1()) virtual);
--echo # --echo #
...@@ -146,71 +146,71 @@ create table t1 (a int generated always as (f1()) virtual); ...@@ -146,71 +146,71 @@ create table t1 (a int generated always as (f1()) virtual);
--echo # --echo #
--echo # AVG() --echo # AVG()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (avg(a)) virtual); create table t1 (a int, b int generated always as (avg(a)) virtual);
--echo # BIT_AND() --echo # BIT_AND()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (bit_and(a)) virtual); create table t1 (a int, b int generated always as (bit_and(a)) virtual);
--echo # BIT_OR() --echo # BIT_OR()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (bit_or(a)) virtual); create table t1 (a int, b int generated always as (bit_or(a)) virtual);
--echo # BIT_XOR() --echo # BIT_XOR()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (bit_xor(a)) virtual); create table t1 (a int, b int generated always as (bit_xor(a)) virtual);
--echo # COUNT(DISTINCT) --echo # COUNT(DISTINCT)
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (count(distinct a)) virtual); create table t1 (a int, b int generated always as (count(distinct a)) virtual);
--echo # COUNT() --echo # COUNT()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (count(a)) virtual); create table t1 (a int, b int generated always as (count(a)) virtual);
--echo # GROUP_CONCAT() --echo # GROUP_CONCAT()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(32), b int generated always as (group_concat(a,'')) virtual); create table t1 (a varchar(32), b int generated always as (group_concat(a,'')) virtual);
--echo # MAX() --echo # MAX()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (max(a)) virtual); create table t1 (a int, b int generated always as (max(a)) virtual);
--echo # MIN() --echo # MIN()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (min(a)) virtual); create table t1 (a int, b int generated always as (min(a)) virtual);
--echo # STD() --echo # STD()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (std(a)) virtual); create table t1 (a int, b int generated always as (std(a)) virtual);
--echo # STDDEV_POP() --echo # STDDEV_POP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (stddev_pop(a)) virtual); create table t1 (a int, b int generated always as (stddev_pop(a)) virtual);
--echo # STDDEV_SAMP() --echo # STDDEV_SAMP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (stddev_samp(a)) virtual); create table t1 (a int, b int generated always as (stddev_samp(a)) virtual);
--echo # STDDEV() --echo # STDDEV()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (stddev(a)) virtual); create table t1 (a int, b int generated always as (stddev(a)) virtual);
--echo # SUM() --echo # SUM()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (sum(a)) virtual); create table t1 (a int, b int generated always as (sum(a)) virtual);
--echo # VAR_POP() --echo # VAR_POP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (var_pop(a)) virtual); create table t1 (a int, b int generated always as (var_pop(a)) virtual);
--echo # VAR_SAMP() --echo # VAR_SAMP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (var_samp(a)) virtual); create table t1 (a int, b int generated always as (var_samp(a)) virtual);
--echo # VARIANCE() --echo # VARIANCE()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int generated always as (variance(a)) virtual); create table t1 (a int, b int generated always as (variance(a)) virtual);
--echo # --echo #
...@@ -218,7 +218,7 @@ create table t1 (a int, b int generated always as (variance(a)) virtual); ...@@ -218,7 +218,7 @@ create table t1 (a int, b int generated always as (variance(a)) virtual);
--echo # --echo #
create table t1 (a int); create table t1 (a int);
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t2 (a int, b int generated always as (select count(*) virtual from t1)); create table t2 (a int, b int generated always as (select count(*) virtual from t1));
drop table t1; drop table t1;
...@@ -243,7 +243,7 @@ drop table t1; ...@@ -243,7 +243,7 @@ drop table t1;
--echo # ASSERTION FAILED: TR && TR->TABLE->FILE --echo # ASSERTION FAILED: TR && TR->TABLE->FILE
--echo # --echo #
create table t1 (a int); create table t1 (a int);
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
alter table t1 add column r blob generated always alter table t1 add column r blob generated always
as (match(a) against ('' in boolean mode)) virtual; as (match(a) against ('' in boolean mode)) virtual;
drop table t1; drop table t1;
...@@ -154,11 +154,11 @@ if ($support_virtual_foreign) ...@@ -154,11 +154,11 @@ if ($support_virtual_foreign)
--error ER_CANT_CREATE_TABLE --error ER_CANT_CREATE_TABLE
alter table t1 add constraint foreign key fk(b) references t2(a); alter table t1 add constraint foreign key fk(b) references t2(a);
} }
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN --error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
alter table t1 add constraint foreign key fk(c) references t2(a) on delete set null; alter table t1 add constraint foreign key fk(c) references t2(a) on delete set null;
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN --error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
alter table t1 add constraint foreign key fk(c) references t2(a) on update set null; alter table t1 add constraint foreign key fk(c) references t2(a) on update set null;
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN --error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
alter table t1 add constraint foreign key fk(c) references t2(a) on update cascade; alter table t1 add constraint foreign key fk(c) references t2(a) on update cascade;
drop table t1; drop table t1;
drop table t2; drop table t2;
...@@ -213,7 +213,7 @@ if (!$support_virtual_index) ...@@ -213,7 +213,7 @@ if (!$support_virtual_index)
{ {
--echo # Bug#20769299: INCORRECT KEY ERROR WHEN TRYING TO CREATE INDEX ON --echo # Bug#20769299: INCORRECT KEY ERROR WHEN TRYING TO CREATE INDEX ON
--echo # VIRTUAL GC FOR MYISAM --echo # VIRTUAL GC FOR MYISAM
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN --error ER_KEY_BASED_ON_GENERATED_GENERATED_COLUMN
CREATE TABLE A ( CREATE TABLE A (
pk INTEGER, pk INTEGER,
col_int_nokey INTEGER, col_int_nokey INTEGER,
...@@ -231,7 +231,7 @@ CREATE TABLE t1(a bigint AS (a between 1 and 1)); ...@@ -231,7 +231,7 @@ CREATE TABLE t1(a bigint AS (a between 1 and 1));
--echo # IN FIND_FIELD_IN_TABLE --echo # IN FIND_FIELD_IN_TABLE
--echo # --echo #
CREATE TABLE t1(a int); CREATE TABLE t1(a int);
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
ALTER TABLE t1 ADD COLUMN z int GENERATED ALWAYS AS ALTER TABLE t1 ADD COLUMN z int GENERATED ALWAYS AS
( 1 NOT IN (SELECT 1 FROM t1 WHERE c0006) ) virtual; ( 1 NOT IN (SELECT 1 FROM t1 WHERE c0006) ) virtual;
DROP TABLE t1; DROP TABLE t1;
...@@ -318,12 +318,12 @@ DROP TABLE t1; ...@@ -318,12 +318,12 @@ DROP TABLE t1;
--echo # IN FIND_FIELD_IN_TABLE --echo # IN FIND_FIELD_IN_TABLE
--echo # --echo #
CREATE TABLE t1(a int); CREATE TABLE t1(a int);
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
ALTER TABLE t1 ADD COLUMN z int GENERATED ALWAYS AS ALTER TABLE t1 ADD COLUMN z int GENERATED ALWAYS AS
( 1 NOT IN (SELECT 1 FROM t1 WHERE c0006) ) virtual; ( 1 NOT IN (SELECT 1 FROM t1 WHERE c0006) ) virtual;
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t2(a int, b int as (1 NOT IN (SELECT 1 FROM t1 WHERE not_exist_col))); CREATE TABLE t2(a int, b int as (1 NOT IN (SELECT 1 FROM t1 WHERE not_exist_col)));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t2(a int, b int as (1 NOT IN (SELECT 1 FROM dual))); CREATE TABLE t2(a int, b int as (1 NOT IN (SELECT 1 FROM dual)));
DROP TABLE t1; DROP TABLE t1;
...@@ -482,11 +482,11 @@ SELECT * FROM t1 order by col1; ...@@ -482,11 +482,11 @@ SELECT * FROM t1 order by col1;
SELECT sgc1 FROM t1 order by sgc1; SELECT sgc1 FROM t1 order by sgc1;
# Change virtual generated column to become stored # Change virtual generated column to become stored
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN --error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) STORED; ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) STORED;
# Change stored generated column to become virtual # Change stored generated column to become virtual
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN --error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) VIRTUAL; ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) VIRTUAL;
# Change base column to become stored generated column: # Change base column to become stored generated column:
......
...@@ -130,22 +130,22 @@ if (!$skip_spatial_index_check) ...@@ -130,22 +130,22 @@ if (!$skip_spatial_index_check)
--echo # FOREIGN KEY --echo # FOREIGN KEY
--echo # Rejected FK options. --echo # Rejected FK options.
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN --error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
create table t1 (a int, b int generated always as (a+1) stored, create table t1 (a int, b int generated always as (a+1) stored,
foreign key (b) references t2(a) on update set null); foreign key (b) references t2(a) on update set null);
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN --error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
create table t1 (a int, b int generated always as (a+1) stored, create table t1 (a int, b int generated always as (a+1) stored,
foreign key (b) references t2(a) on update cascade); foreign key (b) references t2(a) on update cascade);
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN --error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
create table t1 (a int, b int generated always as (a+1) stored, create table t1 (a int, b int generated always as (a+1) stored,
foreign key (b) references t2(a) on delete set null); foreign key (b) references t2(a) on delete set null);
create table t1 (a int, b int generated always as (a+1) stored); create table t1 (a int, b int generated always as (a+1) stored);
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN --error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
alter table t1 add foreign key (b) references t2(a) on update set null; alter table t1 add foreign key (b) references t2(a) on update set null;
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN --error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
alter table t1 add foreign key (b) references t2(a) on update cascade; alter table t1 add foreign key (b) references t2(a) on update cascade;
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN --error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
alter table t1 add foreign key (b) references t2(a) on delete set null; alter table t1 add foreign key (b) references t2(a) on delete set null;
drop table t1; drop table t1;
......
...@@ -74,14 +74,14 @@ drop table t1; ...@@ -74,14 +74,14 @@ drop table t1;
--echo # Case 7. ALTER. Modify virtual stored -> virtual non-stored --echo # Case 7. ALTER. Modify virtual stored -> virtual non-stored
eval create $opt_tmp table t1 (a int, b int generated always as (a % 2) stored); eval create $opt_tmp table t1 (a int, b int generated always as (a % 2) stored);
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN --error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
alter table t1 modify b int generated always as (a % 2) virtual; alter table t1 modify b int generated always as (a % 2) virtual;
show create table t1; show create table t1;
drop table t1; drop table t1;
--echo # Case 8. ALTER. Modify virtual non-stored -> virtual stored --echo # Case 8. ALTER. Modify virtual non-stored -> virtual stored
eval create $opt_tmp table t1 (a int, b int generated always as (a % 2) virtual); eval create $opt_tmp table t1 (a int, b int generated always as (a % 2) virtual);
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN --error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
alter table t1 modify b int generated always as (a % 2) stored; alter table t1 modify b int generated always as (a % 2) stored;
show create table t1; show create table t1;
drop table t1; drop table t1;
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
# Change: # # Change: #
################################################################################ ################################################################################
--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS --error ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS
create table t1 (a int, b int generated always as (a+1) virtual); create table t1 (a int, b int generated always as (a+1) virtual);
create table t1 (a int); create table t1 (a int);
--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS --error ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS
alter table t1 add column b int generated always as (a+1) virtual; alter table t1 add column b int generated always as (a+1) virtual;
drop table t1; drop table t1;
SET @@session.default_storage_engine = 'archive'; SET @@session.default_storage_engine = 'archive';
create table t1 (a int, b int generated always as (a+1) virtual); create table t1 (a int, b int generated always as (a+1) virtual);
ERROR HY000: ARCHIVE storage engine does not support computed columns ERROR HY000: ARCHIVE storage engine does not support generated columns
create table t1 (a int); create table t1 (a int);
alter table t1 add column b int generated always as (a+1) virtual; alter table t1 add column b int generated always as (a+1) virtual;
ERROR HY000: ARCHIVE storage engine does not support computed columns ERROR HY000: ARCHIVE storage engine does not support generated columns
drop table t1; drop table t1;
DROP VIEW IF EXISTS v1,v2; DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3; DROP TABLE IF EXISTS t1,t2,t3;
......
SET @@session.default_storage_engine = 'blackhole'; SET @@session.default_storage_engine = 'blackhole';
create table t1 (a int, b int generated always as (a+1) virtual); create table t1 (a int, b int generated always as (a+1) virtual);
ERROR HY000: BLACKHOLE storage engine does not support computed columns ERROR HY000: BLACKHOLE storage engine does not support generated columns
create table t1 (a int); create table t1 (a int);
alter table t1 add column b int generated always as (a+1) virtual; alter table t1 add column b int generated always as (a+1) virtual;
ERROR HY000: BLACKHOLE storage engine does not support computed columns ERROR HY000: BLACKHOLE storage engine does not support generated columns
drop table t1; drop table t1;
DROP VIEW IF EXISTS v1,v2; DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3; DROP TABLE IF EXISTS t1,t2,t3;
......
...@@ -486,7 +486,7 @@ Table Create Table ...@@ -486,7 +486,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` char(1) DEFAULT NULL, `a` char(1) DEFAULT NULL,
`b` char(1) DEFAULT NULL, `b` char(1) DEFAULT NULL,
`c` char(2) AS (((`a` <> 0) or (`b` <> 0))) VIRTUAL `c` char(2) GENERATED ALWAYS AS (((`a` <> 0) or (`b` <> 0))) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 (a,b) VALUES('1','1'); INSERT INTO t1 (a,b) VALUES('1','1');
SELECT * FROM t1; SELECT * FROM t1;
...@@ -507,7 +507,7 @@ Table Create Table ...@@ -507,7 +507,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` char(1) DEFAULT NULL, `a` char(1) DEFAULT NULL,
`b` char(1) DEFAULT NULL, `b` char(1) DEFAULT NULL,
`c` char(2) AS (concat(`a`,`b`)) VIRTUAL `c` char(2) GENERATED ALWAYS AS (concat(`a`,`b`)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 (a,b) VALUES('1','1'); INSERT INTO t1 (a,b) VALUES('1','1');
SELECT * FROM t1; SELECT * FROM t1;
......
...@@ -81,12 +81,12 @@ show create table t1; ...@@ -81,12 +81,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL COMMENT 'my comment' `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL COMMENT 'my comment'
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a % 2) virtual); create table t1 (a int, b int generated always as (a % 2) virtual);
alter table t1 modify b int generated always as (a % 2) virtual comment 'my comment'; alter table t1 modify b int generated always as (a % 2) virtual comment 'my comment';
...@@ -94,12 +94,12 @@ show create table t1; ...@@ -94,12 +94,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL COMMENT 'my comment' `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL COMMENT 'my comment'
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
insert into t1 (a) values (1); insert into t1 (a) values (1);
select * from t1; select * from t1;
a b a b
...@@ -114,12 +114,12 @@ show create table t2; ...@@ -114,12 +114,12 @@ show create table t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL COMMENT 'my comment' `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL COMMENT 'my comment'
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t2; describe t2;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
insert into t2 (a) values (1); insert into t2 (a) values (1);
select * from t2; select * from t2;
a b a b
...@@ -136,12 +136,12 @@ show create table t1; ...@@ -136,12 +136,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) PERSISTENT `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) STORED
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL PERSISTENT b int(11) YES NULL STORED GENERATED
insert into t1 (a) values (1); insert into t1 (a) values (1);
select * from t1; select * from t1;
a b a b
...@@ -158,7 +158,7 @@ show create table t1; ...@@ -158,7 +158,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) PERSISTENT `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) STORED
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a % 2) virtual); create table t1 (a int, b int generated always as (a % 2) virtual);
...@@ -168,7 +168,7 @@ show create table t1; ...@@ -168,7 +168,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1; drop table t1;
drop table t2; drop table t2;
...@@ -178,11 +178,11 @@ create table t2 (a int); ...@@ -178,11 +178,11 @@ create table t2 (a int);
alter table t1 add constraint foreign key fk(d) references t2(a); alter table t1 add constraint foreign key fk(d) references t2(a);
ERROR 42000: Key column 'd' doesn't exist in table ERROR 42000: Key column 'd' doesn't exist in table
alter table t1 add constraint foreign key fk(c) references t2(a) on delete set null; alter table t1 add constraint foreign key fk(c) references t2(a) on delete set null;
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a generated column
alter table t1 add constraint foreign key fk(c) references t2(a) on update set null; alter table t1 add constraint foreign key fk(c) references t2(a) on update set null;
ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a generated column
alter table t1 add constraint foreign key fk(c) references t2(a) on update cascade; alter table t1 add constraint foreign key fk(c) references t2(a) on update cascade;
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a generated column
drop table t1; drop table t1;
drop table t2; drop table t2;
Generated always is optional Generated always is optional
...@@ -191,24 +191,24 @@ show create table t1; ...@@ -191,24 +191,24 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int as (a % 2) stored); create table t1 (a int, b int as (a % 2) stored);
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) PERSISTENT `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) STORED
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL PERSISTENT b int(11) YES NULL STORED GENERATED
drop table t1; drop table t1;
Default should be non-stored column Default should be non-stored column
create table t1 (a int, b int as (a % 2)); create table t1 (a int, b int as (a % 2));
...@@ -216,12 +216,12 @@ show create table t1; ...@@ -216,12 +216,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
drop table t1; drop table t1;
Expression can be constant Expression can be constant
create table t1 (a int, b int as (5 * 2)); create table t1 (a int, b int as (5 * 2));
...@@ -229,12 +229,12 @@ show create table t1; ...@@ -229,12 +229,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((5 * 2)) VIRTUAL `b` int(11) GENERATED ALWAYS AS ((5 * 2)) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
drop table t1; drop table t1;
Test generated columns referencing other generated columns Test generated columns referencing other generated columns
create table t1 (a int unique, b int generated always as(-a) virtual, c int generated always as (b + 1) virtual); create table t1 (a int unique, b int generated always as(-a) virtual, c int generated always as (b + 1) virtual);
...@@ -294,9 +294,9 @@ SHOW CREATE TABLE t1; ...@@ -294,9 +294,9 @@ SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` + 1)) VIRTUAL, `b` int(11) GENERATED ALWAYS AS ((`a` + 1)) VIRTUAL,
`c` varchar(12) AS ('aaaabb') PERSISTENT, `c` varchar(12) GENERATED ALWAYS AS ('aaaabb') STORED,
`d` blob AS (`c`) VIRTUAL `d` blob GENERATED ALWAYS AS (`c`) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * FROM t1 order by a; SELECT * FROM t1 order by a;
a b c d a b c d
...@@ -307,9 +307,9 @@ SHOW CREATE TABLE t2; ...@@ -307,9 +307,9 @@ SHOW CREATE TABLE t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` + 1)) VIRTUAL, `b` int(11) GENERATED ALWAYS AS ((`a` + 1)) VIRTUAL,
`c` varchar(12) AS ('aaaabb') PERSISTENT, `c` varchar(12) GENERATED ALWAYS AS ('aaaabb') STORED,
`d` blob AS (`c`) VIRTUAL `d` blob GENERATED ALWAYS AS (`c`) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
CREATE TABLE t3 AS SELECT * FROM t1; CREATE TABLE t3 AS SELECT * FROM t1;
SHOW CREATE TABLE t3; SHOW CREATE TABLE t3;
...@@ -356,13 +356,13 @@ DROP TABLE t1; ...@@ -356,13 +356,13 @@ DROP TABLE t1;
# #
CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, 5 AS c2; CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, 5 AS c2;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'c2' in table 't1' ignored Warning 1906 The value specified for generated column 'c2' in table 't1' ignored
CREATE TABLE t2 (a int); CREATE TABLE t2 (a int);
INSERT INTO t2 values(1); INSERT INTO t2 values(1);
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, a AS c2 from t2; CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, a AS c2 from t2;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'c2' in table 't1' ignored Warning 1906 The value specified for generated column 'c2' in table 't1' ignored
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, 5; CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, 5;
SELECT * FROM t1; SELECT * FROM t1;
...@@ -572,9 +572,9 @@ sgc1 ...@@ -572,9 +572,9 @@ sgc1
1000 1000
4000 4000
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) STORED; ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) STORED;
ERROR HY000: This is not yet supported for computed columns ERROR HY000: This is not yet supported for generated columns
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) VIRTUAL; ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) VIRTUAL;
ERROR HY000: This is not yet supported for computed columns ERROR HY000: This is not yet supported for generated columns
ALTER TABLE t1 MODIFY COLUMN col4 INTEGER AS (col1 + col2 + col3) STORED; ALTER TABLE t1 MODIFY COLUMN col4 INTEGER AS (col1 + col2 + col3) STORED;
SELECT * FROM t1 order by col1; SELECT * FROM t1 order by col1;
col1 col2 col3 col4 vgc1 sgc1 col1 col2 col3 col4 vgc1 sgc1
...@@ -604,7 +604,7 @@ Table Create Table ...@@ -604,7 +604,7 @@ Table Create Table
t1 CREATE TABLE "t1" ( t1 CREATE TABLE "t1" (
"a" int(11) NOT NULL, "a" int(11) NOT NULL,
"b" varchar(10) DEFAULT NULL, "b" varchar(10) DEFAULT NULL,
"c" char(3) AS (substr("b",1,3)) VIRTUAL, "c" char(3) GENERATED ALWAYS AS (substr("b",1,3)) VIRTUAL,
PRIMARY KEY ("a"), PRIMARY KEY ("a"),
KEY "c" ("c") KEY "c" ("c")
) )
...@@ -619,7 +619,7 @@ Table Create Table ...@@ -619,7 +619,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL, `a` int(11) NOT NULL,
`b` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL,
`c` char(3) AS (substr(`b`,1,3)) VIRTUAL, `c` char(3) GENERATED ALWAYS AS (substr(`b`,1,3)) VIRTUAL,
PRIMARY KEY (`a`), PRIMARY KEY (`a`),
KEY `c` (`c`) KEY `c` (`c`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
......
...@@ -81,12 +81,12 @@ show create table t1; ...@@ -81,12 +81,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL COMMENT 'my comment' `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL COMMENT 'my comment'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a % 2) virtual); create table t1 (a int, b int generated always as (a % 2) virtual);
alter table t1 modify b int generated always as (a % 2) virtual comment 'my comment'; alter table t1 modify b int generated always as (a % 2) virtual comment 'my comment';
...@@ -94,12 +94,12 @@ show create table t1; ...@@ -94,12 +94,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL COMMENT 'my comment' `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL COMMENT 'my comment'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
insert into t1 (a) values (1); insert into t1 (a) values (1);
select * from t1; select * from t1;
a b a b
...@@ -114,12 +114,12 @@ show create table t2; ...@@ -114,12 +114,12 @@ show create table t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL COMMENT 'my comment' `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL COMMENT 'my comment'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t2; describe t2;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
insert into t2 (a) values (1); insert into t2 (a) values (1);
select * from t2; select * from t2;
a b a b
...@@ -136,12 +136,12 @@ show create table t1; ...@@ -136,12 +136,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) PERSISTENT `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL PERSISTENT b int(11) YES NULL STORED GENERATED
insert into t1 (a) values (1); insert into t1 (a) values (1);
select * from t1; select * from t1;
a b a b
...@@ -158,7 +158,7 @@ show create table t1; ...@@ -158,7 +158,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) PERSISTENT `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a % 2) virtual); create table t1 (a int, b int generated always as (a % 2) virtual);
...@@ -168,7 +168,7 @@ show create table t1; ...@@ -168,7 +168,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
drop table t2; drop table t2;
...@@ -178,11 +178,11 @@ create table t2 (a int); ...@@ -178,11 +178,11 @@ create table t2 (a int);
alter table t1 add constraint foreign key fk(d) references t2(a); alter table t1 add constraint foreign key fk(d) references t2(a);
ERROR 42000: Key column 'd' doesn't exist in table ERROR 42000: Key column 'd' doesn't exist in table
alter table t1 add constraint foreign key fk(c) references t2(a) on delete set null; alter table t1 add constraint foreign key fk(c) references t2(a) on delete set null;
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a generated column
alter table t1 add constraint foreign key fk(c) references t2(a) on update set null; alter table t1 add constraint foreign key fk(c) references t2(a) on update set null;
ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a generated column
alter table t1 add constraint foreign key fk(c) references t2(a) on update cascade; alter table t1 add constraint foreign key fk(c) references t2(a) on update cascade;
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a generated column
drop table t1; drop table t1;
drop table t2; drop table t2;
Generated always is optional Generated always is optional
...@@ -191,24 +191,24 @@ show create table t1; ...@@ -191,24 +191,24 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int as (a % 2) stored); create table t1 (a int, b int as (a % 2) stored);
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) PERSISTENT `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL PERSISTENT b int(11) YES NULL STORED GENERATED
drop table t1; drop table t1;
Default should be non-stored column Default should be non-stored column
create table t1 (a int, b int as (a % 2)); create table t1 (a int, b int as (a % 2));
...@@ -216,12 +216,12 @@ show create table t1; ...@@ -216,12 +216,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
drop table t1; drop table t1;
Expression can be constant Expression can be constant
create table t1 (a int, b int as (5 * 2)); create table t1 (a int, b int as (5 * 2));
...@@ -229,12 +229,12 @@ show create table t1; ...@@ -229,12 +229,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((5 * 2)) VIRTUAL `b` int(11) GENERATED ALWAYS AS ((5 * 2)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
drop table t1; drop table t1;
Test generated columns referencing other generated columns Test generated columns referencing other generated columns
create table t1 (a int unique, b int generated always as(-a) virtual, c int generated always as (b + 1) virtual); create table t1 (a int unique, b int generated always as(-a) virtual, c int generated always as (b + 1) virtual);
...@@ -294,9 +294,9 @@ SHOW CREATE TABLE t1; ...@@ -294,9 +294,9 @@ SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` + 1)) VIRTUAL, `b` int(11) GENERATED ALWAYS AS ((`a` + 1)) VIRTUAL,
`c` varchar(12) AS ('aaaabb') PERSISTENT, `c` varchar(12) GENERATED ALWAYS AS ('aaaabb') STORED,
`d` blob AS (`c`) VIRTUAL `d` blob GENERATED ALWAYS AS (`c`) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t1 order by a; SELECT * FROM t1 order by a;
a b c d a b c d
...@@ -307,9 +307,9 @@ SHOW CREATE TABLE t2; ...@@ -307,9 +307,9 @@ SHOW CREATE TABLE t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` + 1)) VIRTUAL, `b` int(11) GENERATED ALWAYS AS ((`a` + 1)) VIRTUAL,
`c` varchar(12) AS ('aaaabb') PERSISTENT, `c` varchar(12) GENERATED ALWAYS AS ('aaaabb') STORED,
`d` blob AS (`c`) VIRTUAL `d` blob GENERATED ALWAYS AS (`c`) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
CREATE TABLE t3 AS SELECT * FROM t1; CREATE TABLE t3 AS SELECT * FROM t1;
SHOW CREATE TABLE t3; SHOW CREATE TABLE t3;
...@@ -356,13 +356,13 @@ DROP TABLE t1; ...@@ -356,13 +356,13 @@ DROP TABLE t1;
# #
CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, 5 AS c2; CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, 5 AS c2;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'c2' in table 't1' ignored Warning 1906 The value specified for generated column 'c2' in table 't1' ignored
CREATE TABLE t2 (a int); CREATE TABLE t2 (a int);
INSERT INTO t2 values(1); INSERT INTO t2 values(1);
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, a AS c2 from t2; CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, a AS c2 from t2;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'c2' in table 't1' ignored Warning 1906 The value specified for generated column 'c2' in table 't1' ignored
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, 5; CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, 5;
SELECT * FROM t1; SELECT * FROM t1;
...@@ -572,9 +572,9 @@ sgc1 ...@@ -572,9 +572,9 @@ sgc1
1000 1000
4000 4000
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) STORED; ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) STORED;
ERROR HY000: This is not yet supported for computed columns ERROR HY000: This is not yet supported for generated columns
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) VIRTUAL; ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) VIRTUAL;
ERROR HY000: This is not yet supported for computed columns ERROR HY000: This is not yet supported for generated columns
ALTER TABLE t1 MODIFY COLUMN col4 INTEGER AS (col1 + col2 + col3) STORED; ALTER TABLE t1 MODIFY COLUMN col4 INTEGER AS (col1 + col2 + col3) STORED;
SELECT * FROM t1 order by col1; SELECT * FROM t1 order by col1;
col1 col2 col3 col4 vgc1 sgc1 col1 col2 col3 col4 vgc1 sgc1
...@@ -604,7 +604,7 @@ Table Create Table ...@@ -604,7 +604,7 @@ Table Create Table
t1 CREATE TABLE "t1" ( t1 CREATE TABLE "t1" (
"a" int(11) NOT NULL, "a" int(11) NOT NULL,
"b" varchar(10) DEFAULT NULL, "b" varchar(10) DEFAULT NULL,
"c" char(3) AS (substr("b",1,3)) VIRTUAL, "c" char(3) GENERATED ALWAYS AS (substr("b",1,3)) VIRTUAL,
PRIMARY KEY ("a"), PRIMARY KEY ("a"),
KEY "c" ("c") KEY "c" ("c")
) )
...@@ -619,7 +619,7 @@ Table Create Table ...@@ -619,7 +619,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL, `a` int(11) NOT NULL,
`b` varchar(10) DEFAULT NULL, `b` varchar(10) DEFAULT NULL,
`c` char(3) AS (substr(`b`,1,3)) VIRTUAL, `c` char(3) GENERATED ALWAYS AS (substr(`b`,1,3)) VIRTUAL,
PRIMARY KEY (`a`), PRIMARY KEY (`a`),
KEY `c` (`c`) KEY `c` (`c`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
......
...@@ -25,8 +25,8 @@ a b c ...@@ -25,8 +25,8 @@ a b c
# INSERT INTO tbl_name VALUES... a non-NULL value is specified against gcols # INSERT INTO tbl_name VALUES... a non-NULL value is specified against gcols
insert into t1 values (1,2,3); insert into t1 values (1,2,3);
Warnings: Warnings:
Warning 1906 The value specified for computed column 'b' in table 't1' ignored Warning 1906 The value specified for generated column 'b' in table 't1' ignored
Warning 1906 The value specified for computed column 'c' in table 't1' ignored Warning 1906 The value specified for generated column 'c' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -65,8 +65,8 @@ a b c ...@@ -65,8 +65,8 @@ a b c
# against gcols # against gcols
insert into t1 (a,b) values (1,3), (2,4); insert into t1 (a,b) values (1,3), (2,4);
Warnings: Warnings:
Warning 1906 The value specified for computed column 'b' in table 't1' ignored Warning 1906 The value specified for generated column 'b' in table 't1' ignored
Warning 1906 The value specified for computed column 'b' in table 't1' ignored Warning 1906 The value specified for generated column 'b' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -153,7 +153,7 @@ a b c ...@@ -153,7 +153,7 @@ a b c
2 -2 -2 2 -2 -2
update t1 set c=3 where a=2; update t1 set c=3 where a=2;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'c' in table 't1' ignored Warning 1906 The value specified for generated column 'c' in table 't1' ignored
select * from t1 order by a; select * from t1 order by a;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -183,7 +183,7 @@ a b c ...@@ -183,7 +183,7 @@ a b c
2 -2 -2 2 -2 -2
update t1 set c=3 where b=-2; update t1 set c=3 where b=-2;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'c' in table 't1' ignored Warning 1906 The value specified for generated column 'c' in table 't1' ignored
select * from t1 order by a; select * from t1 order by a;
a b c a b c
1 -1 -1 1 -1 -1
......
...@@ -25,8 +25,8 @@ a b c ...@@ -25,8 +25,8 @@ a b c
# INSERT INTO tbl_name VALUES... a non-NULL value is specified against gcols # INSERT INTO tbl_name VALUES... a non-NULL value is specified against gcols
insert into t1 values (1,2,3); insert into t1 values (1,2,3);
Warnings: Warnings:
Warning 1906 The value specified for computed column 'b' in table 't1' ignored Warning 1906 The value specified for generated column 'b' in table 't1' ignored
Warning 1906 The value specified for computed column 'c' in table 't1' ignored Warning 1906 The value specified for generated column 'c' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -65,8 +65,8 @@ a b c ...@@ -65,8 +65,8 @@ a b c
# against gcols # against gcols
insert into t1 (a,b) values (1,3), (2,4); insert into t1 (a,b) values (1,3), (2,4);
Warnings: Warnings:
Warning 1906 The value specified for computed column 'b' in table 't1' ignored Warning 1906 The value specified for generated column 'b' in table 't1' ignored
Warning 1906 The value specified for computed column 'b' in table 't1' ignored Warning 1906 The value specified for generated column 'b' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -153,7 +153,7 @@ a b c ...@@ -153,7 +153,7 @@ a b c
2 -2 -2 2 -2 -2
update t1 set c=3 where a=2; update t1 set c=3 where a=2;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'c' in table 't1' ignored Warning 1906 The value specified for generated column 'c' in table 't1' ignored
select * from t1 order by a; select * from t1 order by a;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -183,7 +183,7 @@ a b c ...@@ -183,7 +183,7 @@ a b c
2 -2 -2 2 -2 -2
update t1 set c=3 where b=-2; update t1 set c=3 where b=-2;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'c' in table 't1' ignored Warning 1906 The value specified for generated column 'c' in table 't1' ignored
select * from t1 order by a; select * from t1 order by a;
a b c a b c
1 -1 -1 1 -1 -1
......
...@@ -11,26 +11,26 @@ show create table t1; ...@@ -11,26 +11,26 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` * 2)) PERSISTENT, `b` int(11) GENERATED ALWAYS AS ((`a` * 2)) STORED,
UNIQUE KEY `b` (`b`) UNIQUE KEY `b` (`b`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES UNI NULL PERSISTENT b int(11) YES UNI NULL STORED GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a*2) stored, unique (b)); create table t1 (a int, b int generated always as (a*2) stored, unique (b));
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` * 2)) PERSISTENT, `b` int(11) GENERATED ALWAYS AS ((`a` * 2)) STORED,
UNIQUE KEY `b` (`b`) UNIQUE KEY `b` (`b`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES UNI NULL PERSISTENT b int(11) YES UNI NULL STORED GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a*2) stored); create table t1 (a int, b int generated always as (a*2) stored);
alter table t1 add unique key (b); alter table t1 add unique key (b);
...@@ -46,26 +46,26 @@ show create table t1; ...@@ -46,26 +46,26 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` * 2)) PERSISTENT, `b` int(11) GENERATED ALWAYS AS ((`a` * 2)) STORED,
KEY `b` (`b`) KEY `b` (`b`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES MUL NULL PERSISTENT b int(11) YES MUL NULL STORED GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a*2) stored, index (a,b)); create table t1 (a int, b int generated always as (a*2) stored, index (a,b));
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` * 2)) PERSISTENT, `b` int(11) GENERATED ALWAYS AS ((`a` * 2)) STORED,
KEY `a` (`a`,`b`) KEY `a` (`a`,`b`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES MUL NULL a int(11) YES MUL NULL
b int(11) YES NULL PERSISTENT b int(11) YES NULL STORED GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a*2) stored); create table t1 (a int, b int generated always as (a*2) stored);
alter table t1 add index (b); alter table t1 add index (b);
...@@ -85,20 +85,20 @@ drop table t1; ...@@ -85,20 +85,20 @@ drop table t1;
# Rejected FK options. # Rejected FK options.
create table t1 (a int, b int generated always as (a+1) stored, create table t1 (a int, b int generated always as (a+1) stored,
foreign key (b) references t2(a) on update set null); foreign key (b) references t2(a) on update set null);
ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a generated column
create table t1 (a int, b int generated always as (a+1) stored, create table t1 (a int, b int generated always as (a+1) stored,
foreign key (b) references t2(a) on update cascade); foreign key (b) references t2(a) on update cascade);
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a generated column
create table t1 (a int, b int generated always as (a+1) stored, create table t1 (a int, b int generated always as (a+1) stored,
foreign key (b) references t2(a) on delete set null); foreign key (b) references t2(a) on delete set null);
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a generated column
create table t1 (a int, b int generated always as (a+1) stored); create table t1 (a int, b int generated always as (a+1) stored);
alter table t1 add foreign key (b) references t2(a) on update set null; alter table t1 add foreign key (b) references t2(a) on update set null;
ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a generated column
alter table t1 add foreign key (b) references t2(a) on update cascade; alter table t1 add foreign key (b) references t2(a) on update cascade;
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a generated column
alter table t1 add foreign key (b) references t2(a) on delete set null; alter table t1 add foreign key (b) references t2(a) on delete set null;
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a generated column
drop table t1; drop table t1;
# Allowed FK options. # Allowed FK options.
create table t2 (a int primary key, b char(5)); create table t2 (a int primary key, b char(5));
......
...@@ -11,52 +11,52 @@ show create table t1; ...@@ -11,52 +11,52 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` * 2)) VIRTUAL, `b` int(11) GENERATED ALWAYS AS ((`a` * 2)) VIRTUAL,
UNIQUE KEY `b` (`b`) UNIQUE KEY `b` (`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES UNI NULL VIRTUAL b int(11) YES UNI NULL VIRTUAL GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a*2) stored unique); create table t1 (a int, b int generated always as (a*2) stored unique);
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` * 2)) PERSISTENT, `b` int(11) GENERATED ALWAYS AS ((`a` * 2)) STORED,
UNIQUE KEY `b` (`b`) UNIQUE KEY `b` (`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES UNI NULL PERSISTENT b int(11) YES UNI NULL STORED GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a*2) virtual, unique key (b)); create table t1 (a int, b int generated always as (a*2) virtual, unique key (b));
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` * 2)) VIRTUAL, `b` int(11) GENERATED ALWAYS AS ((`a` * 2)) VIRTUAL,
UNIQUE KEY `b` (`b`) UNIQUE KEY `b` (`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES UNI NULL VIRTUAL b int(11) YES UNI NULL VIRTUAL GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a*2) stored, unique (b)); create table t1 (a int, b int generated always as (a*2) stored, unique (b));
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` * 2)) PERSISTENT, `b` int(11) GENERATED ALWAYS AS ((`a` * 2)) STORED,
UNIQUE KEY `b` (`b`) UNIQUE KEY `b` (`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES UNI NULL PERSISTENT b int(11) YES UNI NULL STORED GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a*2) virtual); create table t1 (a int, b int generated always as (a*2) virtual);
alter table t1 add unique key (b); alter table t1 add unique key (b);
...@@ -75,13 +75,13 @@ show create table t1; ...@@ -75,13 +75,13 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` * 2)) VIRTUAL, `b` int(11) GENERATED ALWAYS AS ((`a` * 2)) VIRTUAL,
KEY `b` (`b`) KEY `b` (`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES MUL NULL VIRTUAL b int(11) YES MUL NULL VIRTUAL GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a*2) virtual, index (a,b)); create table t1 (a int, b int generated always as (a*2) virtual, index (a,b));
drop table t1; drop table t1;
...@@ -90,26 +90,26 @@ show create table t1; ...@@ -90,26 +90,26 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` * 2)) PERSISTENT, `b` int(11) GENERATED ALWAYS AS ((`a` * 2)) STORED,
KEY `b` (`b`) KEY `b` (`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES MUL NULL PERSISTENT b int(11) YES MUL NULL STORED GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a*2) stored, index (a,b)); create table t1 (a int, b int generated always as (a*2) stored, index (a,b));
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` * 2)) PERSISTENT, `b` int(11) GENERATED ALWAYS AS ((`a` * 2)) STORED,
KEY `a` (`a`,`b`) KEY `a` (`a`,`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES MUL NULL a int(11) YES MUL NULL
b int(11) YES NULL PERSISTENT b int(11) YES NULL STORED GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a*2) virtual); create table t1 (a int, b int generated always as (a*2) virtual);
alter table t1 add index (b); alter table t1 add index (b);
...@@ -140,20 +140,20 @@ drop table t1; ...@@ -140,20 +140,20 @@ drop table t1;
# Rejected FK options. # Rejected FK options.
create table t1 (a int, b int generated always as (a+1) stored, create table t1 (a int, b int generated always as (a+1) stored,
foreign key (b) references t2(a) on update set null); foreign key (b) references t2(a) on update set null);
ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a generated column
create table t1 (a int, b int generated always as (a+1) stored, create table t1 (a int, b int generated always as (a+1) stored,
foreign key (b) references t2(a) on update cascade); foreign key (b) references t2(a) on update cascade);
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a generated column
create table t1 (a int, b int generated always as (a+1) stored, create table t1 (a int, b int generated always as (a+1) stored,
foreign key (b) references t2(a) on delete set null); foreign key (b) references t2(a) on delete set null);
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a generated column
create table t1 (a int, b int generated always as (a+1) stored); create table t1 (a int, b int generated always as (a+1) stored);
alter table t1 add foreign key (b) references t2(a) on update set null; alter table t1 add foreign key (b) references t2(a) on update set null;
ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a generated column
alter table t1 add foreign key (b) references t2(a) on update cascade; alter table t1 add foreign key (b) references t2(a) on update cascade;
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a generated column
alter table t1 add foreign key (b) references t2(a) on delete set null; alter table t1 add foreign key (b) references t2(a) on delete set null;
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a generated column
drop table t1; drop table t1;
# Allowed FK options. # Allowed FK options.
create table t2 (a int primary key, b char(5)); create table t2 (a int primary key, b char(5));
...@@ -300,7 +300,7 @@ DESC t1; ...@@ -300,7 +300,7 @@ DESC t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
pk int(11) NO PRI NULL pk int(11) NO PRI NULL
col_int_nokey int(11) YES NULL col_int_nokey int(11) YES NULL
col_int_key int(11) YES UNI NULL VIRTUAL col_int_key int(11) YES UNI NULL VIRTUAL GENERATED
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#21346132: WL8149:INNODB: FAILING ASSERTION: # Bug#21346132: WL8149:INNODB: FAILING ASSERTION:
......
SET @@session.default_storage_engine = 'memory'; SET @@session.default_storage_engine = 'memory';
create table t1 (a int, b int generated always as (a+1) virtual); create table t1 (a int, b int generated always as (a+1) virtual);
ERROR HY000: MEMORY storage engine does not support computed columns ERROR HY000: MEMORY storage engine does not support generated columns
create table t1 (a int); create table t1 (a int);
alter table t1 add column b int generated always as (a+1) virtual; alter table t1 add column b int generated always as (a+1) virtual;
ERROR HY000: MEMORY storage engine does not support computed columns ERROR HY000: MEMORY storage engine does not support generated columns
drop table t1; drop table t1;
DROP VIEW IF EXISTS v1,v2; DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3; DROP TABLE IF EXISTS t1,t2,t3;
......
...@@ -4,7 +4,7 @@ create table t2 (a int, b int generated always as (a % 10) virtual); ...@@ -4,7 +4,7 @@ create table t2 (a int, b int generated always as (a % 10) virtual);
insert into t1 values (1,default); insert into t1 values (1,default);
insert into t2 values (2,default); insert into t2 values (2,default);
create table t3 (a int, b int generated always as (a % 10) virtual) engine=MERGE UNION=(t1,t2); create table t3 (a int, b int generated always as (a % 10) virtual) engine=MERGE UNION=(t1,t2);
ERROR HY000: MRG_MyISAM storage engine does not support computed columns ERROR HY000: MRG_MyISAM storage engine does not support generated columns
drop table t1,t2; drop table t1,t2;
DROP VIEW IF EXISTS v1,v2; DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3; DROP TABLE IF EXISTS t1,t2,t3;
......
...@@ -85,23 +85,23 @@ drop table t1; ...@@ -85,23 +85,23 @@ drop table t1;
# Case 7. ALTER. Modify virtual stored -> virtual non-stored # Case 7. ALTER. Modify virtual stored -> virtual non-stored
create table t1 (a int, b int generated always as (a % 2) stored); create table t1 (a int, b int generated always as (a % 2) stored);
alter table t1 modify b int generated always as (a % 2) virtual; alter table t1 modify b int generated always as (a % 2) virtual;
ERROR HY000: This is not yet supported for computed columns ERROR HY000: This is not yet supported for generated columns
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) PERSISTENT `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) STORED
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1; drop table t1;
# Case 8. ALTER. Modify virtual non-stored -> virtual stored # Case 8. ALTER. Modify virtual non-stored -> virtual stored
create table t1 (a int, b int generated always as (a % 2) virtual); create table t1 (a int, b int generated always as (a % 2) virtual);
alter table t1 modify b int generated always as (a % 2) stored; alter table t1 modify b int generated always as (a % 2) stored;
ERROR HY000: This is not yet supported for computed columns ERROR HY000: This is not yet supported for generated columns
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1; drop table t1;
# Case 9. CREATE LIKE # Case 9. CREATE LIKE
...@@ -182,7 +182,7 @@ show create table t1; ...@@ -182,7 +182,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`c` int(11) AS (dayofyear(`b`)) VIRTUAL, `c` int(11) GENERATED ALWAYS AS (dayofyear(`b`)) VIRTUAL,
`b` datetime DEFAULT NULL `b` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1; drop table t1;
...@@ -203,7 +203,7 @@ show create table t1; ...@@ -203,7 +203,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`c` int(11) AS (dayofyear(`b`)) PERSISTENT, `c` int(11) GENERATED ALWAYS AS (dayofyear(`b`)) STORED,
`b` datetime DEFAULT NULL `b` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1; drop table t1;
...@@ -225,7 +225,7 @@ Table Create Table ...@@ -225,7 +225,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` datetime DEFAULT NULL, `b` datetime DEFAULT NULL,
`c` int(11) AS (week(`b`,1)) VIRTUAL `c` int(11) GENERATED ALWAYS AS (week(`b`,1)) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1; drop table t1;
DROP VIEW IF EXISTS v1,v2; DROP VIEW IF EXISTS v1,v2;
......
...@@ -85,23 +85,23 @@ drop table t1; ...@@ -85,23 +85,23 @@ drop table t1;
# Case 7. ALTER. Modify virtual stored -> virtual non-stored # Case 7. ALTER. Modify virtual stored -> virtual non-stored
create table t1 (a int, b int generated always as (a % 2) stored); create table t1 (a int, b int generated always as (a % 2) stored);
alter table t1 modify b int generated always as (a % 2) virtual; alter table t1 modify b int generated always as (a % 2) virtual;
ERROR HY000: This is not yet supported for computed columns ERROR HY000: This is not yet supported for generated columns
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) PERSISTENT `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
# Case 8. ALTER. Modify virtual non-stored -> virtual stored # Case 8. ALTER. Modify virtual non-stored -> virtual stored
create table t1 (a int, b int generated always as (a % 2) virtual); create table t1 (a int, b int generated always as (a % 2) virtual);
alter table t1 modify b int generated always as (a % 2) stored; alter table t1 modify b int generated always as (a % 2) stored;
ERROR HY000: This is not yet supported for computed columns ERROR HY000: This is not yet supported for generated columns
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
# Case 9. CREATE LIKE # Case 9. CREATE LIKE
...@@ -182,7 +182,7 @@ show create table t1; ...@@ -182,7 +182,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`c` int(11) AS (dayofyear(`b`)) VIRTUAL, `c` int(11) GENERATED ALWAYS AS (dayofyear(`b`)) VIRTUAL,
`b` datetime DEFAULT NULL `b` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
...@@ -203,7 +203,7 @@ show create table t1; ...@@ -203,7 +203,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`c` int(11) AS (dayofyear(`b`)) PERSISTENT, `c` int(11) GENERATED ALWAYS AS (dayofyear(`b`)) STORED,
`b` datetime DEFAULT NULL `b` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
...@@ -225,7 +225,7 @@ Table Create Table ...@@ -225,7 +225,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` datetime DEFAULT NULL, `b` datetime DEFAULT NULL,
`c` int(11) AS (week(`b`,1)) VIRTUAL `c` int(11) GENERATED ALWAYS AS (week(`b`,1)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
DROP VIEW IF EXISTS v1,v2; DROP VIEW IF EXISTS v1,v2;
......
...@@ -222,10 +222,10 @@ pos base_pos ...@@ -222,10 +222,10 @@ pos base_pos
65537 0 65537 0
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t (a TEXT, b TEXT GENERATED ALWAYS AS (a), fulltext INDEX idx (b)); CREATE TABLE t (a TEXT, b TEXT GENERATED ALWAYS AS (a), fulltext INDEX idx (b));
ERROR HY000: This is not yet supported for computed columns ERROR HY000: This is not yet supported for generated columns
CREATE TABLE t (a TEXT, b TEXT GENERATED ALWAYS AS (a)); CREATE TABLE t (a TEXT, b TEXT GENERATED ALWAYS AS (a));
ALTER TABLE t ADD FULLTEXT INDEX (b); ALTER TABLE t ADD FULLTEXT INDEX (b);
ERROR HY000: This is not yet supported for computed columns ERROR HY000: This is not yet supported for generated columns
DROP TABLE t; DROP TABLE t;
CREATE TABLE t (a geometry not null, b geometry GENERATED ALWAYS AS (a), spatial INDEX idx (b)); CREATE TABLE t (a geometry not null, b geometry GENERATED ALWAYS AS (a), spatial INDEX idx (b));
ERROR 42000: All parts of a SPATIAL index must be NOT NULL ERROR 42000: All parts of a SPATIAL index must be NOT NULL
...@@ -386,9 +386,9 @@ Table Create Table ...@@ -386,9 +386,9 @@ Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`a` varchar(10000) DEFAULT NULL, `a` varchar(10000) DEFAULT NULL,
`b` varchar(3000) DEFAULT NULL, `b` varchar(3000) DEFAULT NULL,
`c` varchar(14000) AS (concat(`a`,`b`)) VIRTUAL, `c` varchar(14000) GENERATED ALWAYS AS (concat(`a`,`b`)) VIRTUAL,
`d` varchar(5000) AS (`b`) VIRTUAL, `d` varchar(5000) GENERATED ALWAYS AS (`b`) VIRTUAL,
`e` int(11) AS (10) VIRTUAL, `e` int(11) GENERATED ALWAYS AS (10) VIRTUAL,
`h` int(11) NOT NULL, `h` int(11) NOT NULL,
PRIMARY KEY (`h`) PRIMARY KEY (`h`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
...@@ -546,9 +546,9 @@ t1 CREATE TABLE `t1` ( ...@@ -546,9 +546,9 @@ t1 CREATE TABLE `t1` (
`col2` int(11) NOT NULL, `col2` int(11) NOT NULL,
`col3` int(11) NOT NULL, `col3` int(11) NOT NULL,
`col4` int(11) DEFAULT NULL, `col4` int(11) DEFAULT NULL,
`col5` int(11) AS ((`col2` % `col3`)) VIRTUAL, `col5` int(11) GENERATED ALWAYS AS ((`col2` % `col3`)) VIRTUAL,
`col7` int(11) AS ((`col5` * `col5`)) VIRTUAL, `col7` int(11) GENERATED ALWAYS AS ((`col5` * `col5`)) VIRTUAL,
`col8` int(11) AS ((`col5` % `col5`)) VIRTUAL, `col8` int(11) GENERATED ALWAYS AS ((`col5` % `col5`)) VIRTUAL,
`col9` text DEFAULT NULL, `col9` text DEFAULT NULL,
`col6` int(11) DEFAULT NULL, `col6` int(11) DEFAULT NULL,
UNIQUE KEY `uidx` (`col5`) UNIQUE KEY `uidx` (`col5`)
...@@ -557,7 +557,7 @@ DROP TABLE t1; ...@@ -557,7 +557,7 @@ DROP TABLE t1;
CREATE TABLE t (a INT, b INT GENERATED ALWAYS AS (a), c point, d point GENERATED ALWAYS AS (c), spatial index idx (d)); CREATE TABLE t (a INT, b INT GENERATED ALWAYS AS (a), c point, d point GENERATED ALWAYS AS (c), spatial index idx (d));
ERROR 42000: All parts of a SPATIAL index must be NOT NULL ERROR 42000: All parts of a SPATIAL index must be NOT NULL
CREATE TABLE t (a INT, b INT GENERATED ALWAYS AS (a), c CHAR(10), d char(20) GENERATED ALWAYS AS (c), fulltext index idx (d)); CREATE TABLE t (a INT, b INT GENERATED ALWAYS AS (a), c CHAR(10), d char(20) GENERATED ALWAYS AS (c), fulltext index idx (d));
ERROR HY000: This is not yet supported for computed columns ERROR HY000: This is not yet supported for generated columns
CREATE TABLE t (a INT, b INT, c INT GENERATED ALWAYS AS(a+b), h VARCHAR(10), j INT, m INT GENERATED ALWAYS AS(b + j), n VARCHAR(10), p VARCHAR(20) GENERATED ALWAYS AS(CONCAT(n, h)), INDEX idx1(c), INDEX idx2 (m), INDEX idx3(p)); CREATE TABLE t (a INT, b INT, c INT GENERATED ALWAYS AS(a+b), h VARCHAR(10), j INT, m INT GENERATED ALWAYS AS(b + j), n VARCHAR(10), p VARCHAR(20) GENERATED ALWAYS AS(CONCAT(n, h)), INDEX idx1(c), INDEX idx2 (m), INDEX idx3(p));
INSERT INTO t VALUES(11, 22, DEFAULT, "AAA", 8, DEFAULT, "XXX", DEFAULT); INSERT INTO t VALUES(11, 22, DEFAULT, "AAA", 8, DEFAULT, "XXX", DEFAULT);
INSERT INTO t VALUES(1, 2, DEFAULT, "uuu", 9, DEFAULT, "uu", DEFAULT); INSERT INTO t VALUES(1, 2, DEFAULT, "uuu", 9, DEFAULT, "uu", DEFAULT);
...@@ -757,9 +757,9 @@ Table Create Table ...@@ -757,9 +757,9 @@ Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`a` varchar(10000) DEFAULT NULL, `a` varchar(10000) DEFAULT NULL,
`b` varchar(3000) DEFAULT NULL, `b` varchar(3000) DEFAULT NULL,
`c` varchar(14000) AS (concat(`a`,`b`)) VIRTUAL, `c` varchar(14000) GENERATED ALWAYS AS (concat(`a`,`b`)) VIRTUAL,
`d` varchar(5000) AS (`b`) VIRTUAL, `d` varchar(5000) GENERATED ALWAYS AS (`b`) VIRTUAL,
`e` int(11) AS (10) VIRTUAL, `e` int(11) GENERATED ALWAYS AS (10) VIRTUAL,
`h` int(11) NOT NULL, `h` int(11) NOT NULL,
PRIMARY KEY (`h`) PRIMARY KEY (`h`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
...@@ -806,9 +806,9 @@ Table Create Table ...@@ -806,9 +806,9 @@ Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`a` varchar(10000) DEFAULT NULL, `a` varchar(10000) DEFAULT NULL,
`b` varchar(3000) DEFAULT NULL, `b` varchar(3000) DEFAULT NULL,
`c` varchar(14000) AS (concat(`a`,`b`)) VIRTUAL, `c` varchar(14000) GENERATED ALWAYS AS (concat(`a`,`b`)) VIRTUAL,
`d` varchar(5000) AS (`b`) VIRTUAL, `d` varchar(5000) GENERATED ALWAYS AS (`b`) VIRTUAL,
`e` int(11) AS (10) VIRTUAL, `e` int(11) GENERATED ALWAYS AS (10) VIRTUAL,
`h` int(11) NOT NULL, `h` int(11) NOT NULL,
PRIMARY KEY (`h`) PRIMARY KEY (`h`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT
...@@ -855,9 +855,9 @@ Table Create Table ...@@ -855,9 +855,9 @@ Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`a` varchar(10000) DEFAULT NULL, `a` varchar(10000) DEFAULT NULL,
`b` varchar(3000) DEFAULT NULL, `b` varchar(3000) DEFAULT NULL,
`c` varchar(14000) AS (concat(`a`,`b`)) VIRTUAL, `c` varchar(14000) GENERATED ALWAYS AS (concat(`a`,`b`)) VIRTUAL,
`d` varchar(5000) AS (`b`) VIRTUAL, `d` varchar(5000) GENERATED ALWAYS AS (`b`) VIRTUAL,
`e` int(11) AS (10) VIRTUAL, `e` int(11) GENERATED ALWAYS AS (10) VIRTUAL,
`h` int(11) NOT NULL, `h` int(11) NOT NULL,
PRIMARY KEY (`h`) PRIMARY KEY (`h`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED
...@@ -968,20 +968,20 @@ SHOW CREATE TABLE t; ...@@ -968,20 +968,20 @@ SHOW CREATE TABLE t;
Table Create Table Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`col_int_nokey` int(11) DEFAULT NULL, `col_int_nokey` int(11) DEFAULT NULL,
`col_int` int(11) AS ((`col_int_nokey` + `col_int_nokey`)) PERSISTENT, `col_int` int(11) GENERATED ALWAYS AS ((`col_int_nokey` + `col_int_nokey`)) STORED,
`col_int_key` int(11) AS ((`col_int` + `col_int_nokey`)) VIRTUAL, `col_int_key` int(11) GENERATED ALWAYS AS ((`col_int` + `col_int_nokey`)) VIRTUAL,
`col_date_nokey` date DEFAULT NULL, `col_date_nokey` date DEFAULT NULL,
`col_date` date AS ((`col_date_nokey` + interval 30 day)) PERSISTENT, `col_date` date GENERATED ALWAYS AS ((`col_date_nokey` + interval 30 day)) STORED,
`col_date_key` date AS ((`col_date` + interval 30 day)) VIRTUAL, `col_date_key` date GENERATED ALWAYS AS ((`col_date` + interval 30 day)) VIRTUAL,
`col_datetime_nokey` datetime DEFAULT NULL, `col_datetime_nokey` datetime DEFAULT NULL,
`col_time_nokey` time DEFAULT NULL, `col_time_nokey` time DEFAULT NULL,
`col_datetime` datetime AS (addtime(`col_datetime_nokey`,`col_time_nokey`)) PERSISTENT, `col_datetime` datetime GENERATED ALWAYS AS (addtime(`col_datetime_nokey`,`col_time_nokey`)) STORED,
`col_time` time AS (addtime(`col_datetime_nokey`,`col_time_nokey`)) PERSISTENT, `col_time` time GENERATED ALWAYS AS (addtime(`col_datetime_nokey`,`col_time_nokey`)) STORED,
`col_datetime_key` datetime AS (addtime(`col_datetime`,`col_time_nokey`)) VIRTUAL, `col_datetime_key` datetime GENERATED ALWAYS AS (addtime(`col_datetime`,`col_time_nokey`)) VIRTUAL,
`col_time_key` time AS (addtime(`col_datetime_nokey`,`col_time`)) VIRTUAL, `col_time_key` time GENERATED ALWAYS AS (addtime(`col_datetime_nokey`,`col_time`)) VIRTUAL,
`col_varchar_nokey` varchar(1) DEFAULT NULL, `col_varchar_nokey` varchar(1) DEFAULT NULL,
`col_varchar` varchar(2) AS (concat(`col_varchar_nokey`,`col_varchar_nokey`)) PERSISTENT, `col_varchar` varchar(2) GENERATED ALWAYS AS (concat(`col_varchar_nokey`,`col_varchar_nokey`)) STORED,
`col_varchar_key` varchar(2) AS (concat(`col_varchar`,'x')) VIRTUAL, `col_varchar_key` varchar(2) GENERATED ALWAYS AS (concat(`col_varchar`,'x')) VIRTUAL,
UNIQUE KEY `pk` (`col_int_key`), UNIQUE KEY `pk` (`col_int_key`),
UNIQUE KEY `col_int_key` (`col_int_key`), UNIQUE KEY `col_int_key` (`col_int_key`),
UNIQUE KEY `col_int_key_2` (`col_int_key`,`col_varchar_key`), UNIQUE KEY `col_int_key_2` (`col_int_key`,`col_varchar_key`),
...@@ -1058,10 +1058,10 @@ ALTER TABLE t1 CHANGE d d INT GENERATED ALWAYS AS(a+b) FIRST; ...@@ -1058,10 +1058,10 @@ ALTER TABLE t1 CHANGE d d INT GENERATED ALWAYS AS(a+b) FIRST;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`d` int(11) AS ((`a` + `b`)) VIRTUAL, `d` int(11) GENERATED ALWAYS AS ((`a` + `b`)) VIRTUAL,
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL,
`c` int(11) AS ((`a` + `b`)) VIRTUAL, `c` int(11) GENERATED ALWAYS AS ((`a` + `b`)) VIRTUAL,
`h` varchar(10) DEFAULT NULL `h` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
...@@ -1366,8 +1366,8 @@ Table Create Table ...@@ -1366,8 +1366,8 @@ Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL,
`d` int(11) AS (((`a` + `b`) + `b`)) VIRTUAL, `d` int(11) GENERATED ALWAYS AS (((`a` + `b`) + `b`)) VIRTUAL,
`e` int(11) AS (`a`) VIRTUAL, `e` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL,
`h` varchar(10) DEFAULT NULL, `h` varchar(10) DEFAULT NULL,
KEY `idx` (`d`), KEY `idx` (`d`),
KEY `idx2` (`e`,`d`) KEY `idx2` (`e`,`d`)
...@@ -1382,9 +1382,9 @@ Table Create Table ...@@ -1382,9 +1382,9 @@ Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL,
`e` int(11) AS (`a`) VIRTUAL, `e` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL,
`h` varchar(10) DEFAULT NULL, `h` varchar(10) DEFAULT NULL,
`c` int(11) AS ((`a` + `b`)) VIRTUAL, `c` int(11) GENERATED ALWAYS AS ((`a` + `b`)) VIRTUAL,
KEY `idx2` (`e`), KEY `idx2` (`e`),
KEY `idx` (`e`) KEY `idx` (`e`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
...@@ -1394,10 +1394,10 @@ Table Create Table ...@@ -1394,10 +1394,10 @@ Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL,
`e` int(11) AS (`a`) VIRTUAL, `e` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL,
`h` varchar(10) DEFAULT NULL, `h` varchar(10) DEFAULT NULL,
`c` int(11) AS ((`a` + `b`)) VIRTUAL, `c` int(11) GENERATED ALWAYS AS ((`a` + `b`)) VIRTUAL,
`x` varchar(10) AS (`h`) VIRTUAL, `x` varchar(10) GENERATED ALWAYS AS (`h`) VIRTUAL,
KEY `idx2` (`e`), KEY `idx2` (`e`),
KEY `idx4` (`c`,`e`) KEY `idx4` (`c`,`e`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
...@@ -1409,10 +1409,10 @@ Table Create Table ...@@ -1409,10 +1409,10 @@ Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL,
`e` int(11) AS (`a`) VIRTUAL, `e` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL,
`h` varchar(10) DEFAULT NULL, `h` varchar(10) DEFAULT NULL,
`c` int(11) AS ((`a` + `b`)) VIRTUAL, `c` int(11) GENERATED ALWAYS AS ((`a` + `b`)) VIRTUAL,
`x` varchar(10) AS (`h`) VIRTUAL, `x` varchar(10) GENERATED ALWAYS AS (`h`) VIRTUAL,
`j` int(11) DEFAULT NULL, `j` int(11) DEFAULT NULL,
KEY `idx2` (`e`), KEY `idx2` (`e`),
KEY `idx4` (`c`,`e`), KEY `idx4` (`c`,`e`),
...@@ -1426,12 +1426,12 @@ Table Create Table ...@@ -1426,12 +1426,12 @@ Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL,
`e` int(11) AS (`a`) VIRTUAL, `e` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL,
`h` varchar(10) DEFAULT NULL, `h` varchar(10) DEFAULT NULL,
`c` int(11) AS ((`a` + `b`)) VIRTUAL, `c` int(11) GENERATED ALWAYS AS ((`a` + `b`)) VIRTUAL,
`x` varchar(10) AS (`h`) VIRTUAL, `x` varchar(10) GENERATED ALWAYS AS (`h`) VIRTUAL,
`j` int(11) DEFAULT NULL, `j` int(11) DEFAULT NULL,
`i` int(11) AS (((`a` + `a`) + `b`)) VIRTUAL, `i` int(11) GENERATED ALWAYS AS (((`a` + `a`) + `b`)) VIRTUAL,
KEY `idx2` (`e`), KEY `idx2` (`e`),
KEY `idx4` (`c`,`e`), KEY `idx4` (`c`,`e`),
KEY `x` (`x`), KEY `x` (`x`),
......
...@@ -43,7 +43,7 @@ Table Create Table ...@@ -43,7 +43,7 @@ Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL,
`c` int(11) AS ((`a` + `b`)) VIRTUAL, `c` int(11) GENERATED ALWAYS AS ((`a` + `b`)) VIRTUAL,
`h` varchar(10) DEFAULT NULL, `h` varchar(10) DEFAULT NULL,
KEY `idx` (`c`) KEY `idx` (`c`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
...@@ -112,7 +112,7 @@ Table Create Table ...@@ -112,7 +112,7 @@ Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL,
`c` int(11) AS ((`a` + `b`)) VIRTUAL, `c` int(11) GENERATED ALWAYS AS ((`a` + `b`)) VIRTUAL,
`h` varchar(10) DEFAULT NULL, `h` varchar(10) DEFAULT NULL,
KEY `idx_1` (`c`) KEY `idx_1` (`c`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
...@@ -158,9 +158,9 @@ c ...@@ -158,9 +158,9 @@ c
SHOW CREATE TABLE t; SHOW CREATE TABLE t;
Table Create Table Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`a` int(11) AS (1) VIRTUAL, `a` int(11) GENERATED ALWAYS AS (1) VIRTUAL,
`b` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL,
`c` int(11) AS (1) VIRTUAL, `c` int(11) GENERATED ALWAYS AS (1) VIRTUAL,
UNIQUE KEY `b` (`b`), UNIQUE KEY `b` (`b`),
UNIQUE KEY `c` (`c`), UNIQUE KEY `c` (`c`),
KEY `a` (`a`) KEY `a` (`a`)
......
...@@ -89,7 +89,7 @@ Table Create Table ...@@ -89,7 +89,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL,
`c` int(11) AS ((`a` + `b`)) VIRTUAL, `c` int(11) GENERATED ALWAYS AS ((`a` + `b`)) VIRTUAL,
KEY `idx` (`c`) KEY `idx` (`c`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * FROM t1; SELECT * FROM t1;
...@@ -128,7 +128,7 @@ Table Create Table ...@@ -128,7 +128,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL,
`c` int(11) AS ((`a` + `b`)) VIRTUAL, `c` int(11) GENERATED ALWAYS AS ((`a` + `b`)) VIRTUAL,
KEY `idx` (`c`) KEY `idx` (`c`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * FROM t1; SELECT * FROM t1;
......
...@@ -7,7 +7,7 @@ show create table t1; ...@@ -7,7 +7,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` + 1)) VIRTUAL `b` int(11) GENERATED ALWAYS AS ((`a` + 1)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values (1,default); insert into t1 values (1,default);
insert into t1 values (2,default); insert into t1 values (2,default);
......
...@@ -305,7 +305,7 @@ DROP TABLE t1; ...@@ -305,7 +305,7 @@ DROP TABLE t1;
CREATE TABLE t(a int); CREATE TABLE t(a int);
ALTER TABLE t ADD COLUMN b int GENERATED ALWAYS AS ( ALTER TABLE t ADD COLUMN b int GENERATED ALWAYS AS (
date_sub(a,interval a month)) VIRTUAL; date_sub(a,interval a month)) VIRTUAL;
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
ALTER TABLE t ADD COLUMN c int GENERATED ALWAYS AS (sum(a)); ALTER TABLE t ADD COLUMN c int GENERATED ALWAYS AS (sum(a));
DROP TABLE t; DROP TABLE t;
......
...@@ -43,7 +43,7 @@ create table t1 (a int, b int generated always as (a % 10) virtual); ...@@ -43,7 +43,7 @@ create table t1 (a int, b int generated always as (a % 10) virtual);
create table t2 (a int, b int generated always as (a % 10) virtual); create table t2 (a int, b int generated always as (a % 10) virtual);
insert into t1 values (1,default); insert into t1 values (1,default);
insert into t2 values (2,default); insert into t2 values (2,default);
--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS --error ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS
create table t3 (a int, b int generated always as (a % 10) virtual) engine=MERGE UNION=(t1,t2); create table t3 (a int, b int generated always as (a % 10) virtual) engine=MERGE UNION=(t1,t2);
drop table t1,t2; drop table t1,t2;
......
...@@ -181,7 +181,7 @@ ALTER TABLE t1 add COLUMN (d INT generated always as (a+1) virtual, e INT as(5) ...@@ -181,7 +181,7 @@ ALTER TABLE t1 add COLUMN (d INT generated always as (a+1) virtual, e INT as(5)
SELECT pos, base_pos FROM informatiON_schema.innodb_sys_virtual; SELECT pos, base_pos FROM informatiON_schema.innodb_sys_virtual;
#--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN #--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
ALTER TABLE t1 add COLUMN (f INT generated always as (a+1) virtual, g INT as(5) virtual), DROP COLUMN e; ALTER TABLE t1 add COLUMN (f INT generated always as (a+1) virtual, g INT as(5) virtual), DROP COLUMN e;
SELECT pos, base_pos FROM informatiON_schema.innodb_sys_virtual; SELECT pos, base_pos FROM informatiON_schema.innodb_sys_virtual;
...@@ -226,10 +226,10 @@ SELECT pos, base_pos FROM informatiON_schema.innodb_sys_virtual; ...@@ -226,10 +226,10 @@ SELECT pos, base_pos FROM informatiON_schema.innodb_sys_virtual;
DROP TABLE t1; DROP TABLE t1;
# We do not support Fulltext or Spatial INDEX ON Virtual Columns # We do not support Fulltext or Spatial INDEX ON Virtual Columns
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN --error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
CREATE TABLE t (a TEXT, b TEXT GENERATED ALWAYS AS (a), fulltext INDEX idx (b)); CREATE TABLE t (a TEXT, b TEXT GENERATED ALWAYS AS (a), fulltext INDEX idx (b));
CREATE TABLE t (a TEXT, b TEXT GENERATED ALWAYS AS (a)); CREATE TABLE t (a TEXT, b TEXT GENERATED ALWAYS AS (a));
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN --error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
ALTER TABLE t ADD FULLTEXT INDEX (b); ALTER TABLE t ADD FULLTEXT INDEX (b);
DROP TABLE t; DROP TABLE t;
...@@ -528,7 +528,7 @@ DROP TABLE t1; ...@@ -528,7 +528,7 @@ DROP TABLE t1;
--error ER_SPATIAL_CANT_HAVE_NULL --error ER_SPATIAL_CANT_HAVE_NULL
CREATE TABLE t (a INT, b INT GENERATED ALWAYS AS (a), c point, d point GENERATED ALWAYS AS (c), spatial index idx (d)); CREATE TABLE t (a INT, b INT GENERATED ALWAYS AS (a), c point, d point GENERATED ALWAYS AS (c), spatial index idx (d));
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN --error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
CREATE TABLE t (a INT, b INT GENERATED ALWAYS AS (a), c CHAR(10), d char(20) GENERATED ALWAYS AS (c), fulltext index idx (d)); CREATE TABLE t (a INT, b INT GENERATED ALWAYS AS (a), c CHAR(10), d char(20) GENERATED ALWAYS AS (c), fulltext index idx (d));
CREATE TABLE t (a INT, b INT, c INT GENERATED ALWAYS AS(a+b), h VARCHAR(10), j INT, m INT GENERATED ALWAYS AS(b + j), n VARCHAR(10), p VARCHAR(20) GENERATED ALWAYS AS(CONCAT(n, h)), INDEX idx1(c), INDEX idx2 (m), INDEX idx3(p)); CREATE TABLE t (a INT, b INT, c INT GENERATED ALWAYS AS(a+b), h VARCHAR(10), j INT, m INT GENERATED ALWAYS AS(b + j), n VARCHAR(10), p VARCHAR(20) GENERATED ALWAYS AS(CONCAT(n, h)), INDEX idx1(c), INDEX idx2 (m), INDEX idx3(p));
......
...@@ -569,7 +569,7 @@ DROP TABLE t1; ...@@ -569,7 +569,7 @@ DROP TABLE t1;
--echo # MDEV-10134 Add full support for DEFAULT --echo # MDEV-10134 Add full support for DEFAULT
--echo # --echo #
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a VARCHAR(100) DEFAULT BINLOG_GTID_POS("master-bin.000001", 600)); CREATE TABLE t1 (a VARCHAR(100) DEFAULT BINLOG_GTID_POS("master-bin.000001", 600));
--echo # --echo #
......
...@@ -103,22 +103,22 @@ if (!$skip_spatial_index_check) ...@@ -103,22 +103,22 @@ if (!$skip_spatial_index_check)
--echo # FOREIGN KEY --echo # FOREIGN KEY
--echo # Rejected FK options. --echo # Rejected FK options.
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN --error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
create table t1 (a int, b int as (a+1) persistent, create table t1 (a int, b int as (a+1) persistent,
foreign key (b) references t2(a) on update set null); foreign key (b) references t2(a) on update set null);
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN --error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
create table t1 (a int, b int as (a+1) persistent, create table t1 (a int, b int as (a+1) persistent,
foreign key (b) references t2(a) on update cascade); foreign key (b) references t2(a) on update cascade);
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN --error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
create table t1 (a int, b int as (a+1) persistent, create table t1 (a int, b int as (a+1) persistent,
foreign key (b) references t2(a) on delete set null); foreign key (b) references t2(a) on delete set null);
create table t1 (a int, b int as (a+1) persistent); create table t1 (a int, b int as (a+1) persistent);
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN --error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
alter table t1 add foreign key (b) references t2(a) on update set null; alter table t1 add foreign key (b) references t2(a) on update set null;
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN --error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
alter table t1 add foreign key (b) references t2(a) on update cascade; alter table t1 add foreign key (b) references t2(a) on update cascade;
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN --error ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
alter table t1 add foreign key (b) references t2(a) on delete set null; alter table t1 add foreign key (b) references t2(a) on delete set null;
drop table t1; drop table t1;
...@@ -161,23 +161,23 @@ drop table t1; ...@@ -161,23 +161,23 @@ drop table t1;
# Restrictions when indexed: # Restrictions when indexed:
# #
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b timestamp as (now()), key (b)); create table t1 (a int, b timestamp as (now()), key (b));
create table t1 (a int, b timestamp as (now())); create table t1 (a int, b timestamp as (now()));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
alter table t1 add index (b); alter table t1 add index (b);
drop table t1; drop table t1;
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b varchar(100) as (user()), key (b)); create table t1 (a int, b varchar(100) as (user()), key (b));
create table t1 (a int, b varchar(100) as (user())); create table t1 (a int, b varchar(100) as (user()));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
alter table t1 add index (b); alter table t1 add index (b);
drop table t1; drop table t1;
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b double as (rand()), key (b)); create table t1 (a int, b double as (rand()), key (b));
create table t1 (a int, b double as (rand())); create table t1 (a int, b double as (rand()));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
alter table t1 add index (b); alter table t1 add index (b);
drop table t1; drop table t1;
...@@ -71,14 +71,14 @@ drop table t1; ...@@ -71,14 +71,14 @@ drop table t1;
--echo # Case 7. ALTER. Modify virtual stored -> virtual non-stored --echo # Case 7. ALTER. Modify virtual stored -> virtual non-stored
create table t1 (a int, b int as (a % 2) persistent); create table t1 (a int, b int as (a % 2) persistent);
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN --error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
alter table t1 modify b int as (a % 2); alter table t1 modify b int as (a % 2);
show create table t1; show create table t1;
drop table t1; drop table t1;
--echo # Case 8. ALTER. Modify virtual non-stored -> virtual stored --echo # Case 8. ALTER. Modify virtual non-stored -> virtual stored
create table t1 (a int, b int as (a % 2)); create table t1 (a int, b int as (a % 2));
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN --error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
alter table t1 modify b int as (a % 2) persistent; alter table t1 modify b int as (a % 2) persistent;
show create table t1; show create table t1;
drop table t1; drop table t1;
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
# Change: Syntax changed # Change: Syntax changed
################################################################################ ################################################################################
--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS --error ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS
create table t1 (a int, b int as (a+1)); create table t1 (a int, b int as (a+1));
create table t1 (a int not null); create table t1 (a int not null);
--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS --error ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS
alter table t1 add column b int as (a+1); alter table t1 add column b int as (a+1);
drop table t1; drop table t1;
...@@ -9,7 +9,7 @@ alter table t1 auto_increment = 3; ...@@ -9,7 +9,7 @@ alter table t1 auto_increment = 3;
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c2` int(11) AS ((1 + 1)) VIRTUAL, `c2` int(11) GENERATED ALWAYS AS ((1 + 1)) VIRTUAL,
`c1` int(11) NOT NULL AUTO_INCREMENT, `c1` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`c1`) PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
......
...@@ -7,7 +7,7 @@ show create table t1; ...@@ -7,7 +7,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` + 1)) VIRTUAL `b` int(11) GENERATED ALWAYS AS ((`a` + 1)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values (1,default); insert into t1 values (1,default);
insert into t1 values (2,default); insert into t1 values (2,default);
......
...@@ -61,10 +61,10 @@ b int, c blob as (b), index (c(57)), ...@@ -61,10 +61,10 @@ b int, c blob as (b), index (c(57)),
d blob, e blob as (d), index (e(57))) d blob, e blob as (d), index (e(57)))
replace select * from t1; replace select * from t1;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'c' in table 't' ignored Warning 1906 The value specified for generated column 'c' in table 't' ignored
Warning 1906 The value specified for computed column 'e' in table 't' ignored Warning 1906 The value specified for generated column 'e' in table 't' ignored
Warning 1906 The value specified for computed column 'c' in table 't' ignored Warning 1906 The value specified for generated column 'c' in table 't' ignored
Warning 1906 The value specified for computed column 'e' in table 't' ignored Warning 1906 The value specified for generated column 'e' in table 't' ignored
check table t; check table t;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t check status OK test.t check status OK
......
SET @@session.storage_engine = 'archive'; SET @@session.storage_engine = 'archive';
create table t1 (a int, b int as (a+1)); create table t1 (a int, b int as (a+1));
ERROR HY000: ARCHIVE storage engine does not support computed columns ERROR HY000: ARCHIVE storage engine does not support generated columns
create table t1 (a int not null); create table t1 (a int not null);
alter table t1 add column b int as (a+1); alter table t1 add column b int as (a+1);
ERROR HY000: ARCHIVE storage engine does not support computed columns ERROR HY000: ARCHIVE storage engine does not support generated columns
drop table t1; drop table t1;
SET @@session.storage_engine = 'blackhole'; SET @@session.storage_engine = 'blackhole';
create table t1 (a int, b int as (a+1)); create table t1 (a int, b int as (a+1));
ERROR HY000: BLACKHOLE storage engine does not support computed columns ERROR HY000: BLACKHOLE storage engine does not support generated columns
create table t1 (a int not null); create table t1 (a int not null);
alter table t1 add column b int as (a+1); alter table t1 add column b int as (a+1);
ERROR HY000: BLACKHOLE storage engine does not support computed columns ERROR HY000: BLACKHOLE storage engine does not support generated columns
drop table t1; drop table t1;
...@@ -54,12 +54,12 @@ show create table t1; ...@@ -54,12 +54,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL COMMENT 'my comment' `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL COMMENT 'my comment'
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int as (a % 2)); create table t1 (a int, b int as (a % 2));
alter table t1 modify b int as (a % 2) comment 'my comment'; alter table t1 modify b int as (a % 2) comment 'my comment';
...@@ -67,12 +67,12 @@ show create table t1; ...@@ -67,12 +67,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL COMMENT 'my comment' `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL COMMENT 'my comment'
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
insert into t1 (a) values (1); insert into t1 (a) values (1);
select * from t1; select * from t1;
a b a b
...@@ -87,12 +87,12 @@ show create table t2; ...@@ -87,12 +87,12 @@ show create table t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL COMMENT 'my comment' `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL COMMENT 'my comment'
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t2; describe t2;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
insert into t2 (a) values (1); insert into t2 (a) values (1);
select * from t2; select * from t2;
a b a b
...@@ -109,12 +109,12 @@ show create table t1; ...@@ -109,12 +109,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) PERSISTENT `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) STORED
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL PERSISTENT b int(11) YES NULL STORED GENERATED
insert into t1 (a) values (1); insert into t1 (a) values (1);
select * from t1; select * from t1;
a b a b
...@@ -131,7 +131,7 @@ show create table t1; ...@@ -131,7 +131,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) PERSISTENT `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) STORED
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1; drop table t1;
create table t1 (a int, b int as (a % 2)); create table t1 (a int, b int as (a % 2));
...@@ -141,6 +141,6 @@ show create table t1; ...@@ -141,6 +141,6 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1; drop table t1;
...@@ -54,12 +54,12 @@ show create table t1; ...@@ -54,12 +54,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL COMMENT 'my comment' `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL COMMENT 'my comment'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
drop table t1; drop table t1;
create table t1 (a int, b int as (a % 2)); create table t1 (a int, b int as (a % 2));
alter table t1 modify b int as (a % 2) comment 'my comment'; alter table t1 modify b int as (a % 2) comment 'my comment';
...@@ -67,12 +67,12 @@ show create table t1; ...@@ -67,12 +67,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL COMMENT 'my comment' `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL COMMENT 'my comment'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
insert into t1 (a) values (1); insert into t1 (a) values (1);
select * from t1; select * from t1;
a b a b
...@@ -87,12 +87,12 @@ show create table t2; ...@@ -87,12 +87,12 @@ show create table t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL COMMENT 'my comment' `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL COMMENT 'my comment'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t2; describe t2;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL VIRTUAL b int(11) YES NULL VIRTUAL GENERATED
insert into t2 (a) values (1); insert into t2 (a) values (1);
select * from t2; select * from t2;
a b a b
...@@ -109,12 +109,12 @@ show create table t1; ...@@ -109,12 +109,12 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) PERSISTENT `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
describe t1; describe t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b int(11) YES NULL PERSISTENT b int(11) YES NULL STORED GENERATED
insert into t1 (a) values (1); insert into t1 (a) values (1);
select * from t1; select * from t1;
a b a b
...@@ -131,7 +131,7 @@ show create table t1; ...@@ -131,7 +131,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) PERSISTENT `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
create table t1 (a int, b int as (a % 2)); create table t1 (a int, b int as (a % 2));
...@@ -141,6 +141,6 @@ show create table t1; ...@@ -141,6 +141,6 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
SET @@session.storage_engine = 'CSV'; SET @@session.storage_engine = 'CSV';
create table t1 (a int, b int as (a+1)); create table t1 (a int, b int as (a+1));
ERROR HY000: CSV storage engine does not support computed columns ERROR HY000: CSV storage engine does not support generated columns
create table t1 (a int not null); create table t1 (a int not null);
alter table t1 add column b int as (a+1); alter table t1 add column b int as (a+1);
ERROR HY000: CSV storage engine does not support computed columns ERROR HY000: CSV storage engine does not support generated columns
drop table t1; drop table t1;
...@@ -25,8 +25,8 @@ a b c ...@@ -25,8 +25,8 @@ a b c
# INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols # INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols
insert into t1 values (1,2,3); insert into t1 values (1,2,3);
Warnings: Warnings:
Warning 1906 The value specified for computed column 'b' in table 't1' ignored Warning 1906 The value specified for generated column 'b' in table 't1' ignored
Warning 1906 The value specified for computed column 'c' in table 't1' ignored Warning 1906 The value specified for generated column 'c' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -65,8 +65,8 @@ a b c ...@@ -65,8 +65,8 @@ a b c
# against vcols # against vcols
insert into t1 (a,b) values (1,3), (2,4); insert into t1 (a,b) values (1,3), (2,4);
Warnings: Warnings:
Warning 1906 The value specified for computed column 'b' in table 't1' ignored Warning 1906 The value specified for generated column 'b' in table 't1' ignored
Warning 1906 The value specified for computed column 'b' in table 't1' ignored Warning 1906 The value specified for generated column 'b' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -107,8 +107,8 @@ a b c ...@@ -107,8 +107,8 @@ a b c
create table t2 like t1; create table t2 like t1;
insert into t2 select * from t1; insert into t2 select * from t1;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'b' in table 't2' ignored Warning 1906 The value specified for generated column 'b' in table 't2' ignored
Warning 1906 The value specified for computed column 'c' in table 't2' ignored Warning 1906 The value specified for generated column 'c' in table 't2' ignored
select * from t1; select * from t1;
a b c a b c
2 -2 -2 2 -2 -2
...@@ -123,8 +123,8 @@ a b c ...@@ -123,8 +123,8 @@ a b c
create table t2 like t1; create table t2 like t1;
insert into t2 (a,b) select a,b from t1; insert into t2 (a,b) select a,b from t1;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'b' in table 't2' ignored Warning 1906 The value specified for generated column 'b' in table 't2' ignored
Warning 1906 The value specified for computed column 'b' in table 't2' ignored Warning 1906 The value specified for generated column 'b' in table 't2' ignored
select * from t2; select * from t2;
a b c a b c
2 -2 -2 2 -2 -2
...@@ -159,7 +159,7 @@ a b c ...@@ -159,7 +159,7 @@ a b c
2 -2 -2 2 -2 -2
update t1 set c=3 where a=2; update t1 set c=3 where a=2;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'c' in table 't1' ignored Warning 1906 The value specified for generated column 'c' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -189,7 +189,7 @@ a b c ...@@ -189,7 +189,7 @@ a b c
2 -2 -2 2 -2 -2
update t1 set c=3 where b=-2; update t1 set c=3 where b=-2;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'c' in table 't1' ignored Warning 1906 The value specified for generated column 'c' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
......
...@@ -25,8 +25,8 @@ a b c ...@@ -25,8 +25,8 @@ a b c
# INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols # INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols
insert into t1 values (1,2,3); insert into t1 values (1,2,3);
Warnings: Warnings:
Warning 1906 The value specified for computed column 'b' in table 't1' ignored Warning 1906 The value specified for generated column 'b' in table 't1' ignored
Warning 1906 The value specified for computed column 'c' in table 't1' ignored Warning 1906 The value specified for generated column 'c' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -65,8 +65,8 @@ a b c ...@@ -65,8 +65,8 @@ a b c
# against vcols # against vcols
insert into t1 (a,b) values (1,3), (2,4); insert into t1 (a,b) values (1,3), (2,4);
Warnings: Warnings:
Warning 1906 The value specified for computed column 'b' in table 't1' ignored Warning 1906 The value specified for generated column 'b' in table 't1' ignored
Warning 1906 The value specified for computed column 'b' in table 't1' ignored Warning 1906 The value specified for generated column 'b' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -107,8 +107,8 @@ a b c ...@@ -107,8 +107,8 @@ a b c
create table t2 like t1; create table t2 like t1;
insert into t2 select * from t1; insert into t2 select * from t1;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'b' in table 't2' ignored Warning 1906 The value specified for generated column 'b' in table 't2' ignored
Warning 1906 The value specified for computed column 'c' in table 't2' ignored Warning 1906 The value specified for generated column 'c' in table 't2' ignored
select * from t1; select * from t1;
a b c a b c
2 -2 -2 2 -2 -2
...@@ -123,8 +123,8 @@ a b c ...@@ -123,8 +123,8 @@ a b c
create table t2 like t1; create table t2 like t1;
insert into t2 (a,b) select a,b from t1; insert into t2 (a,b) select a,b from t1;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'b' in table 't2' ignored Warning 1906 The value specified for generated column 'b' in table 't2' ignored
Warning 1906 The value specified for computed column 'b' in table 't2' ignored Warning 1906 The value specified for generated column 'b' in table 't2' ignored
select * from t2; select * from t2;
a b c a b c
2 -2 -2 2 -2 -2
...@@ -159,7 +159,7 @@ a b c ...@@ -159,7 +159,7 @@ a b c
2 -2 -2 2 -2 -2
update t1 set c=3 where a=2; update t1 set c=3 where a=2;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'c' in table 't1' ignored Warning 1906 The value specified for generated column 'c' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -189,7 +189,7 @@ a b c ...@@ -189,7 +189,7 @@ a b c
2 -2 -2 2 -2 -2
update t1 set c=3 where b=-2; update t1 set c=3 where b=-2;
Warnings: Warnings:
Warning 1906 The value specified for computed column 'c' in table 't1' ignored Warning 1906 The value specified for generated column 'c' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
......
SET @@session.storage_engine = 'memory'; SET @@session.storage_engine = 'memory';
create table t1 (a int, b int as (a+1)); create table t1 (a int, b int as (a+1));
ERROR HY000: MEMORY storage engine does not support computed columns ERROR HY000: MEMORY storage engine does not support generated columns
create table t1 (a int not null); create table t1 (a int not null);
alter table t1 add column b int as (a+1); alter table t1 add column b int as (a+1);
ERROR HY000: MEMORY storage engine does not support computed columns ERROR HY000: MEMORY storage engine does not support generated columns
drop table t1; drop table t1;
...@@ -4,5 +4,5 @@ create table t2 (a int, b int as (a % 10)); ...@@ -4,5 +4,5 @@ create table t2 (a int, b int as (a % 10));
insert into t1 values (1,default); insert into t1 values (1,default);
insert into t2 values (2,default); insert into t2 values (2,default);
create table t3 (a int, b int as (a % 10)) engine=MERGE UNION=(t1,t2); create table t3 (a int, b int as (a % 10)) engine=MERGE UNION=(t1,t2);
ERROR HY000: MRG_MyISAM storage engine does not support computed columns ERROR HY000: MRG_MyISAM storage engine does not support generated columns
drop table t1,t2; drop table t1,t2;
This diff is collapsed.
...@@ -76,23 +76,23 @@ drop table t1; ...@@ -76,23 +76,23 @@ drop table t1;
# Case 7. ALTER. Modify virtual stored -> virtual non-stored # Case 7. ALTER. Modify virtual stored -> virtual non-stored
create table t1 (a int, b int as (a % 2) persistent); create table t1 (a int, b int as (a % 2) persistent);
alter table t1 modify b int as (a % 2); alter table t1 modify b int as (a % 2);
ERROR HY000: This is not yet supported for computed columns ERROR HY000: This is not yet supported for generated columns
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) PERSISTENT `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) STORED
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1; drop table t1;
# Case 8. ALTER. Modify virtual non-stored -> virtual stored # Case 8. ALTER. Modify virtual non-stored -> virtual stored
create table t1 (a int, b int as (a % 2)); create table t1 (a int, b int as (a % 2));
alter table t1 modify b int as (a % 2) persistent; alter table t1 modify b int as (a % 2) persistent;
ERROR HY000: This is not yet supported for computed columns ERROR HY000: This is not yet supported for generated columns
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` % 2)) VIRTUAL `b` int(11) GENERATED ALWAYS AS ((`a` % 2)) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1; drop table t1;
# Case 9. CREATE LIKE # Case 9. CREATE LIKE
...@@ -173,7 +173,7 @@ show create table t1; ...@@ -173,7 +173,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`c` int(11) AS (dayofyear(`b`)) VIRTUAL, `c` int(11) GENERATED ALWAYS AS (dayofyear(`b`)) VIRTUAL,
`b` datetime DEFAULT NULL `b` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1; drop table t1;
...@@ -194,7 +194,7 @@ show create table t1; ...@@ -194,7 +194,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`c` int(11) AS (dayofyear(`b`)) PERSISTENT, `c` int(11) GENERATED ALWAYS AS (dayofyear(`b`)) STORED,
`b` datetime DEFAULT NULL `b` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1; drop table t1;
...@@ -216,7 +216,7 @@ Table Create Table ...@@ -216,7 +216,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` datetime DEFAULT NULL, `b` datetime DEFAULT NULL,
`c` int(11) AS (week(`b`,1)) PERSISTENT `c` int(11) GENERATED ALWAYS AS (week(`b`,1)) STORED
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1; drop table t1;
# Case 15. ALTER. Changing the expression of a virtual non-stored column. # Case 15. ALTER. Changing the expression of a virtual non-stored column.
...@@ -237,7 +237,7 @@ Table Create Table ...@@ -237,7 +237,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` datetime DEFAULT NULL, `b` datetime DEFAULT NULL,
`c` int(11) AS (week(`b`,1)) VIRTUAL `c` int(11) GENERATED ALWAYS AS (week(`b`,1)) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1; drop table t1;
# #
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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