1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-11066 use MySQL terminology for "virtual columns"

This commit is contained in:
Sergei Golubchik
2016-11-24 09:49:12 +01:00
parent 6eaa5fd210
commit 1db438c833
67 changed files with 1116 additions and 1110 deletions

View File

@ -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 */

View File

@ -804,7 +804,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` char(5) AS ((cast('a' as char(10) charset latin1) + `a`)) VIRTUAL `b` char(5) GENERATED ALWAYS AS ((cast('a' as char(10) charset latin1) + `a`)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
select collation(cast("a" as char(10) binary)); select collation(cast("a" as char(10) binary));

View File

@ -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;
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;

View File

@ -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;
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;
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;

View File

@ -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 //
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);
--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);
--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;
--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;

View File

@ -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)
{ {
--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));
--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;
--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;
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:

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -1,9 +1,9 @@
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;

View File

@ -1,9 +1,9 @@
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;

View File

@ -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
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;

View File

@ -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;
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;
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;
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;
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;
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);
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;
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;
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;
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;
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;
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;
# #
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
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
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
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

View File

@ -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;
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;
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;
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;
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;
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);
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;
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;
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;
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;
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;
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;
# #
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
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
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
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

View File

@ -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
# 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
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
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

View File

@ -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
# 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
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
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

View File

@ -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;
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;
# 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));

View File

@ -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;
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;
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;
# 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;
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:

View File

@ -1,9 +1,9 @@
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;

View File

@ -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;

View File

@ -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;
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;
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
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;

View File

@ -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;
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;
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
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;

View File

@ -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
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` (
`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;
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
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
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
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;
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;
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
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
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
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
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
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`),

View File

@ -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
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
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`)

View File

@ -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
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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;
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;
--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));

View File

@ -30,7 +30,7 @@ grad_degree CREATE TABLE `grad_degree` (
`plan` varchar(10) NOT NULL, `plan` varchar(10) NOT NULL,
`admit_term` char(4) NOT NULL, `admit_term` char(4) NOT NULL,
`wdraw_rsn` varchar(4) NOT NULL DEFAULT '', `wdraw_rsn` varchar(4) NOT NULL DEFAULT '',
`ofis_deg_status` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed' else 'Not Completed' end)) VIRTUAL, `ofis_deg_status` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed' else 'Not Completed' end)) VIRTUAL,
`deg_start_term` char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginning of the data', `deg_start_term` char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginning of the data',
`deg_as_of_term` char(4) NOT NULL COMMENT 'In most cases also end term', `deg_as_of_term` char(4) NOT NULL COMMENT 'In most cases also end term',
PRIMARY KEY (`student_id`,`plan`,`admit_term`) PRIMARY KEY (`student_id`,`plan`,`admit_term`)
@ -136,14 +136,14 @@ grad_degree CREATE TABLE `grad_degree` (
`plan` varchar(10) NOT NULL, `plan` varchar(10) NOT NULL,
`admit_term` char(4) NOT NULL, `admit_term` char(4) NOT NULL,
`wdraw_rsn` varchar(4) NOT NULL DEFAULT '', `wdraw_rsn` varchar(4) NOT NULL DEFAULT '',
`ofis_deg_status` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed' else 'Not Completed' end)) VIRTUAL, `ofis_deg_status` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed' else 'Not Completed' end)) VIRTUAL,
`ofis_deg_status2` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress2' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed2' else 'Not Completed2' end)) VIRTUAL, `ofis_deg_status2` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress2' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed2' else 'Not Completed2' end)) VIRTUAL,
`ofis_deg_status3` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress3' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed3' else 'Not Completed3' end)) VIRTUAL, `ofis_deg_status3` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress3' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed3' else 'Not Completed3' end)) VIRTUAL,
`ofis_deg_status4` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress4' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed4' else 'Not Completed4' end)) VIRTUAL, `ofis_deg_status4` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress4' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed4' else 'Not Completed4' end)) VIRTUAL,
`ofis_deg_status5` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress5' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed5' else 'Not Completed5' end)) VIRTUAL, `ofis_deg_status5` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress5' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed5' else 'Not Completed5' end)) VIRTUAL,
`ofis_deg_status6` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress6' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed6' else 'Not Completed6' end)) VIRTUAL, `ofis_deg_status6` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress6' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed6' else 'Not Completed6' end)) VIRTUAL,
`ofis_deg_status7` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress7' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed7' else 'Not Completed7' end)) VIRTUAL, `ofis_deg_status7` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress7' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed7' else 'Not Completed7' end)) VIRTUAL,
`ofis_deg_status8` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress8' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed8' else 'Not Completed8' end)) VIRTUAL, `ofis_deg_status8` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress8' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed8' else 'Not Completed8' end)) VIRTUAL,
`deg_start_term` char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginning of the data', `deg_start_term` char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginning of the data',
`deg_as_of_term` char(4) NOT NULL COMMENT 'In most cases also end term', `deg_as_of_term` char(4) NOT NULL COMMENT 'In most cases also end term',
PRIMARY KEY (`student_id`,`plan`,`admit_term`) PRIMARY KEY (`student_id`,`plan`,`admit_term`)
@ -193,14 +193,14 @@ grad_degree CREATE TABLE `grad_degree` (
`plan` varchar(10) NOT NULL, `plan` varchar(10) NOT NULL,
`admit_term` char(4) NOT NULL, `admit_term` char(4) NOT NULL,
`wdraw_rsn` varchar(4) NOT NULL DEFAULT '', `wdraw_rsn` varchar(4) NOT NULL DEFAULT '',
`ofis_deg_status` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed' else 'Not Completed' end)) VIRTUAL, `ofis_deg_status` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed' else 'Not Completed' end)) VIRTUAL,
`ofis_deg_status2` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress2' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed2' else 'Not Completed2' end)) VIRTUAL, `ofis_deg_status2` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress2' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed2' else 'Not Completed2' end)) VIRTUAL,
`ofis_deg_status3` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress3' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed3' else 'Not Completed3' end)) VIRTUAL, `ofis_deg_status3` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress3' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed3' else 'Not Completed3' end)) VIRTUAL,
`ofis_deg_status4` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress4' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed4' else 'Not Completed4' end)) VIRTUAL, `ofis_deg_status4` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress4' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed4' else 'Not Completed4' end)) VIRTUAL,
`ofis_deg_status5` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress5' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed5' else 'Not Completed5' end)) VIRTUAL, `ofis_deg_status5` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress5' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed5' else 'Not Completed5' end)) VIRTUAL,
`ofis_deg_status6` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress6' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed6' else 'Not Completed6' end)) VIRTUAL, `ofis_deg_status6` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress6' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed6' else 'Not Completed6' end)) VIRTUAL,
`ofis_deg_status7` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress7' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed7' else 'Not Completed7' end)) VIRTUAL, `ofis_deg_status7` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress7' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed7' else 'Not Completed7' end)) VIRTUAL,
`ofis_deg_status8` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress8' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed8' else 'Not Completed8' end)) VIRTUAL, `ofis_deg_status8` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress8' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed8' else 'Not Completed8' end)) VIRTUAL,
`deg_as_of_term` char(4) NOT NULL COMMENT 'In most cases also end term', `deg_as_of_term` char(4) NOT NULL COMMENT 'In most cases also end term',
PRIMARY KEY (`student_id`,`plan`,`admit_term`), PRIMARY KEY (`student_id`,`plan`,`admit_term`),
KEY `grad_degree_as_of_term_ndx` (`deg_as_of_term`) KEY `grad_degree_as_of_term_ndx` (`deg_as_of_term`)
@ -270,14 +270,14 @@ grad_degree CREATE TABLE `grad_degree` (
`plan` varchar(10) NOT NULL, `plan` varchar(10) NOT NULL,
`admit_term` char(4) NOT NULL, `admit_term` char(4) NOT NULL,
`wdraw_rsn` varchar(4) NOT NULL DEFAULT '', `wdraw_rsn` varchar(4) NOT NULL DEFAULT '',
`ofis_deg_status` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed' else 'Not Completed' end)) VIRTUAL, `ofis_deg_status` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed' else 'Not Completed' end)) VIRTUAL,
`ofis_deg_status2` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress2' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed2' else 'Not Completed2' end)) VIRTUAL, `ofis_deg_status2` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress2' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed2' else 'Not Completed2' end)) VIRTUAL,
`ofis_deg_status3` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress3' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed3' else 'Not Completed3' end)) VIRTUAL, `ofis_deg_status3` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress3' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed3' else 'Not Completed3' end)) VIRTUAL,
`ofis_deg_status4` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress4' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed4' else 'Not Completed4' end)) VIRTUAL, `ofis_deg_status4` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress4' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed4' else 'Not Completed4' end)) VIRTUAL,
`ofis_deg_status5` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress5' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed5' else 'Not Completed5' end)) VIRTUAL, `ofis_deg_status5` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress5' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed5' else 'Not Completed5' end)) VIRTUAL,
`ofis_deg_status6` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress6' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed6' else 'Not Completed6' end)) VIRTUAL, `ofis_deg_status6` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress6' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed6' else 'Not Completed6' end)) VIRTUAL,
`ofis_deg_status7` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress7' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed7' else 'Not Completed7' end)) VIRTUAL, `ofis_deg_status7` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress7' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed7' else 'Not Completed7' end)) VIRTUAL,
`ofis_deg_status8` varchar(15) AS ((case when (`wdraw_rsn` = '') then 'In progress8' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed8' else 'Not Completed8' end)) VIRTUAL, `ofis_deg_status8` varchar(15) GENERATED ALWAYS AS ((case when (`wdraw_rsn` = '') then 'In progress8' when ((`wdraw_rsn` = 'DCMP') or (`wdraw_rsn` = 'TRDC')) then 'Completed8' else 'Not Completed8' end)) VIRTUAL,
`deg_start_term` char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginning of the data', `deg_start_term` char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginning of the data',
`deg_as_of_term` char(4) NOT NULL COMMENT 'In most cases also end term', `deg_as_of_term` char(4) NOT NULL COMMENT 'In most cases also end term',
PRIMARY KEY (`student_id`,`plan`,`admit_term`) PRIMARY KEY (`student_id`,`plan`,`admit_term`)

View File

@ -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 #

View File

@ -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;
# 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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -1,7 +1,7 @@
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;

View File

@ -1,7 +1,7 @@
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;

View File

@ -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;
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;
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;
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;
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;
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;

View File

@ -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;
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;
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;
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;
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;
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;

View File

@ -1,7 +1,7 @@
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;

View File

@ -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
# 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
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
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
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
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

View File

@ -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
# 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
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
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
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
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

View File

@ -13,13 +13,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)) 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 as (a*2), unique key (b)); create table t1 (a int, b int as (a*2), unique key (b));
drop table t1; drop table t1;
@ -28,13 +28,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)) 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 as (a*2)); create table t1 (a int, b int as (a*2));
alter table t1 add unique key (b); alter table t1 add unique key (b);
@ -57,26 +57,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 as (a*2) persistent, index (a,b)); create table t1 (a int, b int as (a*2) persistent, 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 as (a*2)); create table t1 (a int, b int as (a*2));
alter table t1 add index (b); alter table t1 add index (b);
@ -107,20 +107,20 @@ drop table t1;
# Rejected FK options. # Rejected FK options.
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 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 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 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 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);
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 as (a+1) persistent); create table t1 (a int, b int as (a+1) persistent);
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;
create table t1 (a int, b int as (a+1), foreign key (b) references t2(a)); create table t1 (a int, b int as (a+1), foreign key (b) references t2(a));
ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed") ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed")

View File

@ -129,13 +129,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)) 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 as (a*2), unique key (b)); create table t1 (a int, b int as (a*2), unique key (b));
drop table t1; drop table t1;
@ -144,13 +144,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)) 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 as (a*2)); create table t1 (a int, b int as (a*2));
alter table t1 add unique key (b); alter table t1 add unique key (b);
@ -173,26 +173,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 as (a*2) persistent, index (a,b)); create table t1 (a int, b int as (a*2) persistent, 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 as (a*2)); create table t1 (a int, b int as (a*2));
alter table t1 add index (b); alter table t1 add index (b);
@ -223,20 +223,20 @@ drop table t1;
# Rejected FK options. # Rejected FK options.
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 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 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 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 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);
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 as (a+1) persistent); create table t1 (a int, b int as (a+1) persistent);
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));

View File

@ -1,7 +1,7 @@
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;

View File

@ -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;

View File

@ -108,10 +108,10 @@ DROP TABLE t1,t2;
CREATE TABLE t1 (p int, a double NOT NULL, v double AS (ROUND(a,p)) VIRTUAL); CREATE TABLE t1 (p int, a double NOT NULL, v double AS (ROUND(a,p)) VIRTUAL);
INSERT INTO t1 VALUES (0,1,0); INSERT INTO t1 VALUES (0,1,0);
Warnings: Warnings:
Warning 1906 The value specified for computed column 'v' in table 't1' ignored Warning 1906 The value specified for generated column 'v' in table 't1' ignored
INSERT INTO t1 VALUES (NULL,0,0); INSERT INTO t1 VALUES (NULL,0,0);
Warnings: Warnings:
Warning 1906 The value specified for computed column 'v' in table 't1' ignored Warning 1906 The value specified for generated column 'v' in table 't1' ignored
SELECT a, p, v, ROUND(a,p), ROUND(a,p+NULL) FROM t1; SELECT a, p, v, ROUND(a,p), ROUND(a,p+NULL) FROM t1;
a p v ROUND(a,p) ROUND(a,p+NULL) a p v ROUND(a,p) ROUND(a,p+NULL)
1 0 1 1 NULL 1 0 1 1 NULL
@ -130,7 +130,7 @@ SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` char(32) DEFAULT NULL, `a` char(32) DEFAULT NULL,
`v` char(32) CHARACTER SET ucs2 AS (`a`) VIRTUAL `v` char(32) CHARACTER SET ucs2 GENERATED ALWAYS AS (`a`) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a int, b int); CREATE TABLE t1 (a int, b int);
@ -144,7 +144,7 @@ SELECT table_schema, table_name, column_name, column_type, extra
FROM information_schema.columns WHERE table_name = 't2'; FROM information_schema.columns WHERE table_name = 't2';
table_schema table_name column_name column_type extra table_schema table_name column_name column_type extra
test t2 a int(11) test t2 a int(11)
test t2 b int(11) VIRTUAL test t2 b int(11) VIRTUAL GENERATED
DROP TABLE t1,t2; DROP TABLE t1,t2;
create table t1 ( create table t1 (
a int not null, b char(2) not null, a int not null, b char(2) not null,
@ -155,7 +155,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL, `a` int(11) NOT NULL,
`b` char(2) NOT NULL, `b` char(2) NOT NULL,
`c` enum('Y','N') AS ((case when (`b` = 'aa') then 'Y' else 'N' end)) PERSISTENT `c` enum('Y','N') GENERATED ALWAYS AS ((case when (`b` = 'aa') then 'Y' else 'N' end)) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1(a,b) values (1,'bb'), (2,'aa'), (3,'cc'); insert into t1(a,b) values (1,'bb'), (2,'aa'), (3,'cc');
select * from t1; select * from t1;
@ -173,7 +173,7 @@ Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL,
`c` set('y','n') AS (if((`a` = 0),if((`b` = 0),'n,n','n,y'),if((`b` = 0),'y,n','y,y'))) PERSISTENT `c` set('y','n') GENERATED ALWAYS AS (if((`a` = 0),if((`b` = 0),'n,n','n,y'),if((`b` = 0),'y,n','y,y'))) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t2(a,b) values (7,0), (2,3), (0,1); insert into t2(a,b) values (7,0), (2,3), (0,1);
select * from t2; select * from t2;
@ -227,7 +227,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` bigint(20) DEFAULT NULL, `a` bigint(20) DEFAULT NULL,
`b` bigint(20) AS ((`a` > '2')) VIRTUAL `b` bigint(20) GENERATED ALWAYS AS ((`a` > '2')) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 (a) values (1),(3); insert into t1 (a) values (1),(3);
select * from t1; select * from t1;
@ -244,7 +244,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` bigint(20) DEFAULT NULL, `a` bigint(20) DEFAULT NULL,
`b` bigint(20) AS ((`a` between 0 and 2)) VIRTUAL `b` bigint(20) GENERATED ALWAYS AS ((`a` between 0 and 2)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 (a) values (1),(3); insert into t1 (a) values (1),(3);
select * from t1; select * from t1;
@ -261,7 +261,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` char(10) DEFAULT NULL, `a` char(10) DEFAULT NULL,
`b` char(10) AS ((`a` between 0 and 2)) VIRTUAL `b` char(10) GENERATED ALWAYS AS ((`a` between 0 and 2)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 (a) values (1),(3); insert into t1 (a) values (1),(3);
select * from t1; select * from t1;
@ -284,33 +284,33 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL, `a` int(11) NOT NULL,
`b` varchar(32) DEFAULT NULL, `b` varchar(32) DEFAULT NULL,
`c` int(11) AS ((`a` % 10)) VIRTUAL, `c` int(11) GENERATED ALWAYS AS ((`a` % 10)) VIRTUAL,
`d` varchar(5) AS (left(`b`,5)) PERSISTENT `d` varchar(5) GENERATED ALWAYS AS (left(`b`,5)) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
show columns from t1; show columns from t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) NO NULL a int(11) NO NULL
b varchar(32) YES NULL b varchar(32) YES NULL
c int(11) YES NULL VIRTUAL c int(11) YES NULL VIRTUAL GENERATED
d varchar(5) YES NULL PERSISTENT d varchar(5) YES NULL STORED GENERATED
show full columns from t1; show full columns from t1;
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
a int(11) NULL NO NULL # a int(11) NULL NO NULL #
b varchar(32) latin1_swedish_ci YES NULL # b varchar(32) latin1_swedish_ci YES NULL #
c int(11) NULL YES NULL VIRTUAL # c int(11) NULL YES NULL VIRTUAL GENERATED #
d varchar(5) latin1_swedish_ci YES NULL PERSISTENT # d varchar(5) latin1_swedish_ci YES NULL STORED GENERATED #
INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,NULL); INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,NULL);
UPDATE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a'; UPDATE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a';
Warnings: Warnings:
Warning 1906 The value specified for computed column 'd' in table 't1' ignored Warning 1906 The value specified for generated column 'd' in table 't1' ignored
INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a'); INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a');
Warnings: Warnings:
Warning 1906 The value specified for computed column 'd' in table 't1' ignored Warning 1906 The value specified for generated column 'd' in table 't1' ignored
set sql_mode='strict_all_tables'; set sql_mode='strict_all_tables';
UPDATE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a'; UPDATE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a';
ERROR HY000: The value specified for computed column 'd' in table 't1' ignored ERROR HY000: The value specified for generated column 'd' in table 't1' ignored
INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a'); INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a');
ERROR HY000: The value specified for computed column 'd' in table 't1' ignored ERROR HY000: The value specified for generated column 'd' in table 't1' ignored
drop table t1; drop table t1;
# #
# MDEV-5611: self-referencing virtual column # MDEV-5611: self-referencing virtual column
@ -324,7 +324,7 @@ create table t1 (v1 varchar(255) as (c1) persistent, c1 varchar(50)) collate=lat
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`v1` varchar(255) AS (`c1`) PERSISTENT, `v1` varchar(255) GENERATED ALWAYS AS (`c1`) STORED,
`c1` varchar(50) COLLATE latin1_general_ci DEFAULT NULL `c1` varchar(50) COLLATE latin1_general_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
drop table t1; drop table t1;
@ -339,7 +339,7 @@ SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` datetime DEFAULT NULL, `a` datetime DEFAULT NULL,
`b` timestamp AS (cast(`a` as datetime)) VIRTUAL `b` timestamp GENERATED ALWAYS AS (cast(`a` as datetime)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a DATETIME, b TIMESTAMP AS (TIMESTAMP(a)),c TIMESTAMP); CREATE TABLE t1 (a DATETIME, b TIMESTAMP AS (TIMESTAMP(a)),c TIMESTAMP);
@ -347,7 +347,7 @@ SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` datetime DEFAULT NULL, `a` datetime DEFAULT NULL,
`b` timestamp AS (cast(`a` as datetime)) VIRTUAL, `b` timestamp GENERATED ALWAYS AS (cast(`a` as datetime)) VIRTUAL,
`c` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' `c` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;

View File

@ -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;
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;
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
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
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;
# #

View File

@ -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=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 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=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM 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;
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;
@ -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=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
@ -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=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM 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
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;
# #

View File

@ -273,9 +273,9 @@ INSERT INTO t1 VALUES (NULL),( 78), (185), (0), (154);
CREATE TABLE t2 (a int, b int AS (a) VIRTUAL); CREATE TABLE t2 (a int, b int AS (a) VIRTUAL);
INSERT INTO t2 VALUES (187,187), (9,9), (187,187); INSERT INTO t2 VALUES (187,187), (9,9), (187,187);
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
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
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT * FROM t1 JOIN t2 USING (b); SELECT * FROM t1 JOIN t2 USING (b);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,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
drop table t1; drop table t1;
create table t1 (a int, b int as (a+1) virtual); create table t1 (a int, b int as (a+1) virtual);
@ -13,7 +13,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
drop table t1; drop table t1;
create table t1 (a int, b int generated always as (a+1) persistent); create table t1 (a int, b int generated always as (a+1) persistent);
@ -21,7 +21,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
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
set session sql_mode='ORACLE'; set session sql_mode='ORACLE';
@ -30,7 +30,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
) )
drop table t1; drop table t1;
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);
@ -38,7 +38,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
) )
drop table t1; drop table t1;
create table t1 (a int, b int as (a+1) persistent); create table t1 (a int, b int as (a+1) persistent);
@ -46,7 +46,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
) )
drop table t1; drop table t1;
set session sql_mode=@OLD_SQL_MODE; set session sql_mode=@OLD_SQL_MODE;

View File

@ -13,16 +13,16 @@ set time_zone='+10:00';
set div_precision_increment=20; set div_precision_increment=20;
create table t1 (a int, b int, v decimal(20,19) as (a/3)); create table t1 (a int, b int, v decimal(20,19) as (a/3));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t2 (a int, b int, v int as (a+@a)); create table t2 (a int, b int, v int as (a+@a));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t2 (a int, b int, v int as (a+@a) PERSISTENT); create table t2 (a int, b int, v int as (a+@a) PERSISTENT);
create table t3_ok (a int, b int, v int as (a+@@error_count)); create table t3_ok (a int, b int, v int as (a+@@error_count));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t3 (a int, b int, v int as (a+@@error_count) PERSISTENT); create table t3 (a int, b int, v int as (a+@@error_count) PERSISTENT);
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t4 (a int, b int, v int as (@a:=a)); create table t4 (a int, b int, v int as (@a:=a));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t4 (a int, b int, v int as (@a:=a) PERSISTENT); create table t4 (a int, b int, v int as (@a:=a) PERSISTENT);
create table t8 (a int, b int, v varchar(100) as (from_unixtime(a))); create table t8 (a int, b int, v varchar(100) as (from_unixtime(a)));

View File

@ -21,85 +21,85 @@
--echo # RAND() --echo # RAND()
create or replace table t1 (b double as (rand())); create or replace table t1 (b double as (rand()));
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (b double as (rand()) PERSISTENT); create or replace table t1 (b double as (rand()) PERSISTENT);
--echo # LOAD_FILE() --echo # LOAD_FILE()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(64), b varchar(1024) as (load_file(a))); create or replace table t1 (a varchar(64), b varchar(1024) as (load_file(a)));
--echo # CURDATE() --echo # CURDATE()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime as (curdate()) PERSISTENT); create or replace table t1 (a datetime as (curdate()) PERSISTENT);
--echo # CURRENT_DATE(), CURRENT_DATE --echo # CURRENT_DATE(), CURRENT_DATE
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime as (current_date) PERSISTENT); create or replace table t1 (a datetime as (current_date) PERSISTENT);
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime as (current_date()) PERSISTENT); create or replace table t1 (a datetime as (current_date()) PERSISTENT);
--echo # CURRENT_TIME(), CURRENT_TIME --echo # CURRENT_TIME(), CURRENT_TIME
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime as (current_time) PERSISTENT); create or replace table t1 (a datetime as (current_time) PERSISTENT);
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime as (current_time()) PERSISTENT); create or replace table t1 (a datetime as (current_time()) PERSISTENT);
--echo # CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP --echo # CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime as (current_timestamp()) PERSISTENT); create or replace table t1 (a datetime as (current_timestamp()) PERSISTENT);
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime as (current_timestamp) PERSISTENT); create or replace table t1 (a datetime as (current_timestamp) PERSISTENT);
--echo # CURTIME() --echo # CURTIME()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime as (curtime()) PERSISTENT); create or replace table t1 (a datetime as (curtime()) PERSISTENT);
--echo # LOCALTIME(), LOCALTIME --echo # LOCALTIME(), LOCALTIME
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime, b varchar(10) as (localtime()) PERSISTENT); create or replace table t1 (a datetime, b varchar(10) as (localtime()) PERSISTENT);
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime, b varchar(10) as (localtime) PERSISTENT); create or replace table t1 (a datetime, b varchar(10) as (localtime) PERSISTENT);
--echo # LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6) --echo # LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6)
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime, b varchar(10) as (localtimestamp()) PERSISTENT); create or replace table t1 (a datetime, b varchar(10) as (localtimestamp()) PERSISTENT);
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime, b varchar(10) as (localtimestamp) PERSISTENT); create or replace table t1 (a datetime, b varchar(10) as (localtimestamp) PERSISTENT);
--echo # NOW() --echo # NOW()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime, b varchar(10) as (now()) PERSISTENT); create or replace table t1 (a datetime, b varchar(10) as (now()) PERSISTENT);
--echo # SYSDATE() --echo # SYSDATE()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b varchar(10) as (sysdate()) PERSISTENT); create or replace table t1 (a int, b varchar(10) as (sysdate()) PERSISTENT);
--echo # UNIX_TIMESTAMP() --echo # UNIX_TIMESTAMP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime, b datetime as (unix_timestamp()) PERSISTENT); create or replace table t1 (a datetime, b datetime as (unix_timestamp()) PERSISTENT);
--echo # UTC_DATE() --echo # UTC_DATE()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime, b datetime as (utc_date()) PERSISTENT); create or replace table t1 (a datetime, b datetime as (utc_date()) PERSISTENT);
--echo # UTC_TIME() --echo # UTC_TIME()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime, b datetime as (utc_time()) PERSISTENT); create or replace table t1 (a datetime, b datetime as (utc_time()) PERSISTENT);
--echo # UTC_TIMESTAMP() --echo # UTC_TIMESTAMP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime, b datetime as (utc_timestamp()) PERSISTENT); create or replace table t1 (a datetime, b datetime as (utc_timestamp()) PERSISTENT);
--echo # WEEK() - one argument version --echo # WEEK() - one argument version
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a datetime, b datetime as (week(a)) PERSISTENT); create or replace table t1 (a datetime, b datetime as (week(a)) PERSISTENT);
--echo # MATCH() --echo # MATCH()
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(32), b bool as (match a against ('sample text')) PERSISTENT); create or replace table t1 (a varchar(32), b bool as (match a against ('sample text')) PERSISTENT);
--echo # BENCHMARK() --echo # BENCHMARK()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3))); create or replace table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3)));
--echo # CHARSET() --echo # CHARSET()
@ -113,84 +113,84 @@ create or replace table t1 (a varchar(64), b varchar(64) as (collation(a)) PERSI
--echo # CONNECTION_ID() --echo # CONNECTION_ID()
create or replace table t1 (a int as (connection_id())); create or replace table t1 (a int as (connection_id()));
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int as (connection_id()) PERSISTENT); create or replace table t1 (a int as (connection_id()) PERSISTENT);
--echo # DATABASE() --echo # DATABASE()
create or replace table t1 (a varchar(32) as (database())); create or replace table t1 (a varchar(32) as (database()));
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(1024), b varchar(1024) as (database()) PERSISTENT); create or replace table t1 (a varchar(1024), b varchar(1024) as (database()) PERSISTENT);
--echo # FOUND_ROWS() --echo # FOUND_ROWS()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(1024), b varchar(1024) as (found_rows())); create or replace table t1 (a varchar(1024), b varchar(1024) as (found_rows()));
--echo # GET_LOCK() --echo # GET_LOCK()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10))); create or replace table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10)));
--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 or replace table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a))); create or replace table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a)));
--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 or replace table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a))); create or replace table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a)));
--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 or replace table t1 (a int as (last_insert_id())); create or replace table t1 (a int as (last_insert_id()));
--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 or replace table t1 (a varchar(32), b int as (master_pos_wait(a,0,2))); create or replace table t1 (a varchar(32), b int as (master_pos_wait(a,0,2)));
--echo # NAME_CONST() --echo # NAME_CONST()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(32) as (name_const('test',1))); create or replace table t1 (a varchar(32) as (name_const('test',1)));
--echo # RELEASE_LOCK() --echo # RELEASE_LOCK()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(32), b int as (release_lock(a))); create or replace table t1 (a varchar(32), b int as (release_lock(a)));
--echo # ROW_COUNT() --echo # ROW_COUNT()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int as (row_count())); create or replace table t1 (a int as (row_count()));
--echo # SCHEMA() --echo # SCHEMA()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(32) as (schema()) PERSISTENT); create or replace table t1 (a varchar(32) as (schema()) PERSISTENT);
--echo # SESSION_USER() --echo # SESSION_USER()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(32) as (session_user()) PERSISTENT); create or replace table t1 (a varchar(32) as (session_user()) PERSISTENT);
--echo # SLEEP() --echo # SLEEP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (sleep(a))); create or replace table t1 (a int, b int as (sleep(a)));
--echo # SYSTEM_USER() --echo # SYSTEM_USER()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(32) as (system_user()) PERSISTENT); create or replace table t1 (a varchar(32) as (system_user()) PERSISTENT);
--echo # USER() --echo # USER()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(1024), b varchar(1024) as (user()) PERSISTENT); create or replace table t1 (a varchar(1024), b varchar(1024) as (user()) PERSISTENT);
--echo # UUID_SHORT() --echo # UUID_SHORT()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(1024) as (uuid_short()) PERSISTENT); create or replace table t1 (a varchar(1024) as (uuid_short()) PERSISTENT);
--echo # UUID() --echo # UUID()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(1024) as (uuid()) PERSISTENT); create or replace table t1 (a varchar(1024) as (uuid()) PERSISTENT);
--echo # VALUES() --echo # VALUES()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(1024), b varchar(1024) as (values(a))); create or replace table t1 (a varchar(1024), b varchar(1024) as (values(a)));
--echo # VERSION() --echo # VERSION()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(1024), b varchar(1024) as (version()) PERSISTENT); create or replace table t1 (a varchar(1024), b varchar(1024) as (version()) PERSISTENT);
--echo # ENCRYPT() --echo # ENCRYPT()
@ -212,16 +212,16 @@ end //
delimiter ;// delimiter ;//
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int as (p1()) PERSISTENT); create or replace table t1 (a int as (p1()) PERSISTENT);
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int as (f1()) PERSISTENT); create or replace table t1 (a int as (f1()) PERSISTENT);
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 or replace table t1 (a int as (f1()) PERSISTENT); create or replace table t1 (a int as (f1()) PERSISTENT);
--echo # --echo #
@ -229,71 +229,71 @@ create or replace table t1 (a int as (f1()) PERSISTENT);
--echo # --echo #
--echo # AVG() --echo # AVG()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (avg(a))); create or replace table t1 (a int, b int as (avg(a)));
--echo # BIT_AND() --echo # BIT_AND()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (bit_and(a))); create or replace table t1 (a int, b int as (bit_and(a)));
--echo # BIT_OR() --echo # BIT_OR()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (bit_or(a))); create or replace table t1 (a int, b int as (bit_or(a)));
--echo # BIT_XOR() --echo # BIT_XOR()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (bit_xor(a))); create or replace table t1 (a int, b int as (bit_xor(a)));
--echo # COUNT(DISTINCT) --echo # COUNT(DISTINCT)
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (count(distinct a))); create or replace table t1 (a int, b int as (count(distinct a)));
--echo # COUNT() --echo # COUNT()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (count(a))); create or replace table t1 (a int, b int as (count(a)));
--echo # GROUP_CONCAT() --echo # GROUP_CONCAT()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a varchar(32), b int as (group_concat(a,''))); create or replace table t1 (a varchar(32), b int as (group_concat(a,'')));
--echo # MAX() --echo # MAX()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (max(a))); create or replace table t1 (a int, b int as (max(a)));
--echo # MIN() --echo # MIN()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (min(a))); create or replace table t1 (a int, b int as (min(a)));
--echo # STD() --echo # STD()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (std(a))); create or replace table t1 (a int, b int as (std(a)));
--echo # STDDEV_POP() --echo # STDDEV_POP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (stddev_pop(a))); create or replace table t1 (a int, b int as (stddev_pop(a)));
--echo # STDDEV_SAMP() --echo # STDDEV_SAMP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (stddev_samp(a))); create or replace table t1 (a int, b int as (stddev_samp(a)));
--echo # STDDEV() --echo # STDDEV()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (stddev(a))); create or replace table t1 (a int, b int as (stddev(a)));
--echo # SUM() --echo # SUM()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (sum(a))); create or replace table t1 (a int, b int as (sum(a)));
--echo # VAR_POP() --echo # VAR_POP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (var_pop(a))); create or replace table t1 (a int, b int as (var_pop(a)));
--echo # VAR_SAMP() --echo # VAR_SAMP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (var_samp(a))); create or replace table t1 (a int, b int as (var_samp(a)));
--echo # VARIANCE() --echo # VARIANCE()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (variance(a))); create or replace table t1 (a int, b int as (variance(a)));
--echo # --echo #
@ -311,13 +311,13 @@ create or replace table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a
--echo # --echo #
create or replace table t1 (a int); create or replace table t1 (a int);
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t2 (a int, b int as (select count(*) from t1)); create or replace table t2 (a int, b int as (select count(*) from t1));
drop table t1; drop table t1;
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as ((select 1))); create or replace table t1 (a int, b int as ((select 1)));
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (a+(select 1))); create or replace table t1 (a int, b int as (a+(select 1)));
--echo # --echo #
@ -330,7 +330,7 @@ drop function if exists sub1;
create function sub1(i int) returns int deterministic create function sub1(i int) returns int deterministic
return i+1; return i+1;
select sub1(1); select sub1(1);
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED -- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a int, b int as (a+sub3(1))); create or replace table t1 (a int, b int as (a+sub3(1)));
drop function sub1; drop function sub1;

View File

@ -48,7 +48,7 @@ create table t1 (a int, b int as (a % 10));
create table t2 (a int, b int as (a % 10)); 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);
--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS --error ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS
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);
drop table t1,t2; drop table t1,t2;

View File

@ -269,9 +269,9 @@ INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,NULL);
UPDATE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a'; UPDATE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a';
INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a'); INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a');
set sql_mode='strict_all_tables'; set sql_mode='strict_all_tables';
--error ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN --error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
UPDATE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a'; UPDATE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a';
--error ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN --error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a'); INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a');
drop table t1; drop table t1;

View File

@ -321,9 +321,9 @@ drop table t1;
--echo # Error handling --echo # Error handling
--echo # --echo #
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a bigint default xxx()); create or replace table t1 (a bigint default xxx());
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create or replace table t1 (a bigint default (select (1))); create or replace table t1 (a bigint default (select (1)));
--error ER_OPERAND_COLUMNS --error ER_OPERAND_COLUMNS
create or replace table t1 (a bigint default (1,2,3)); create or replace table t1 (a bigint default (1,2,3));
@ -338,13 +338,13 @@ CREATE TABLE t1 (a INT, b INT DEFAULT -a);
--echo # Invalid DEFAULT expressions --echo # Invalid DEFAULT expressions
--echo # --echo #
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT ((SELECT 1))); CREATE TABLE t1 (a INT DEFAULT ((SELECT 1)));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT (EXISTS (SELECT 1))); CREATE TABLE t1 (a INT DEFAULT (EXISTS (SELECT 1)));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT (1=ANY (SELECT 1))); CREATE TABLE t1 (a INT DEFAULT (1=ANY (SELECT 1)));
--error ER_OPERAND_COLUMNS --error ER_OPERAND_COLUMNS
@ -364,39 +364,39 @@ CREATE TABLE t1 (a INT DEFAULT(?));
--error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD --error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD
CREATE TABLE t1 (a INT DEFAULT (b), b INT DEFAULT(a)); CREATE TABLE t1 (a INT DEFAULT (b), b INT DEFAULT(a));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT @v); CREATE TABLE t1 (a INT DEFAULT @v);
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT @v:=1); CREATE TABLE t1 (a INT DEFAULT @v:=1);
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT(NAME_CONST('xxx', 'yyy')); CREATE TABLE t1 (a INT DEFAULT(NAME_CONST('xxx', 'yyy'));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT COUNT(*)); CREATE TABLE t1 (a INT DEFAULT COUNT(*));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT COUNT(1)); CREATE TABLE t1 (a INT DEFAULT COUNT(1));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT AVG(1)); CREATE TABLE t1 (a INT DEFAULT AVG(1));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT MIN(1)); CREATE TABLE t1 (a INT DEFAULT MIN(1));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT GROUP_CONCAT(1)); CREATE TABLE t1 (a INT DEFAULT GROUP_CONCAT(1));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT ROW_NUMBER() OVER ()); CREATE TABLE t1 (a INT DEFAULT ROW_NUMBER() OVER ());
CREATE FUNCTION f1() RETURNS INT RETURN 1; CREATE FUNCTION f1() RETURNS INT RETURN 1;
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT f1()); CREATE TABLE t1 (a INT DEFAULT f1());
DROP FUNCTION f1; DROP FUNCTION f1;
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE PROCEDURE p1(par INT) CREATE TABLE t1 (a INT DEFAULT par); CREATE PROCEDURE p1(par INT) CREATE TABLE t1 (a INT DEFAULT par);
--error ER_BAD_FIELD_ERROR --error ER_BAD_FIELD_ERROR
@ -407,18 +407,18 @@ CREATE PROCEDURE p1() CREATE TABLE t1 (a INT DEFAULT par);
CALL p1; CALL p1;
DROP PROCEDURE p1; DROP PROCEDURE p1;
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT VALUES(a)); CREATE TABLE t1 (a INT DEFAULT VALUES(a));
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
# "Explicit or implicit commit is not allowed in stored function or trigger # "Explicit or implicit commit is not allowed in stored function or trigger
# because the entire CREATE TABLE is actually not allowed in triggers! # because the entire CREATE TABLE is actually not allowed in triggers!
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CREATE TABLE t2 (a INT DEFAULT NEW.a); CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CREATE TABLE t2 (a INT DEFAULT NEW.a);
# This is OK to return Function or expression is not allowed for 'DEFAULT' # This is OK to return Function or expression is not allowed for 'DEFAULT'
# because CREATE TEMPORARY TABLE is allowed in triggers # because CREATE TEMPORARY TABLE is allowed in triggers
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CREATE TEMPORARY TABLE t2 (a INT DEFAULT NEW.a); CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CREATE TEMPORARY TABLE t2 (a INT DEFAULT NEW.a);
DROP TABLE t1; DROP TABLE t1;
@ -930,37 +930,37 @@ INSERT INTO t1 VALUES ();
SELECT a>0 FROM t1; SELECT a>0 FROM t1;
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 DEFAULT BENCHMARK(1,1)); CREATE TABLE t1 (a INT DEFAULT BENCHMARK(1,1));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT GET_LOCK('a',1)); CREATE TABLE t1 (a INT DEFAULT GET_LOCK('a',1));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT RELEASE_LOCK('a')); CREATE TABLE t1 (a INT DEFAULT RELEASE_LOCK('a'));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT IS_USED_LOCK('a')); CREATE TABLE t1 (a INT DEFAULT IS_USED_LOCK('a'));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT IS_FREE_LOCK('a')); CREATE TABLE t1 (a INT DEFAULT IS_FREE_LOCK('a'));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT SLEEP(1)); CREATE TABLE t1 (a INT DEFAULT SLEEP(1));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT ROW_COUNT()); CREATE TABLE t1 (a INT DEFAULT ROW_COUNT());
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT FOUND_ROWS()); CREATE TABLE t1 (a INT DEFAULT FOUND_ROWS());
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT MASTER_POS_WAIT('test',100)); CREATE TABLE t1 (a INT DEFAULT MASTER_POS_WAIT('test',100));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT MASTER_GTID_WAIT('test')); CREATE TABLE t1 (a INT DEFAULT MASTER_GTID_WAIT('test'));
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a VARCHAR(30), b DOUBLE DEFAULT MATCH (a) AGAINST('bbbb' IN BOOLEAN MODE)); CREATE TABLE t1 (a VARCHAR(30), b DOUBLE DEFAULT MATCH (a) AGAINST('bbbb' IN BOOLEAN MODE));
--echo # --echo #
@ -1594,7 +1594,7 @@ INSERT INTO t1 VALUES (0x50006,'Y','N','',64,DEFAULT);
SELECT * FROM t1; SELECT * FROM t1;
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 VARCHAR(30), b BLOB DEFAULT LOAD_FILE(a)); CREATE TABLE t1 (a VARCHAR(30), b BLOB DEFAULT LOAD_FILE(a));
--echo # --echo #
@ -1722,7 +1722,7 @@ DROP TABLE t1;
--echo # --echo #
# QQ: LAST_INSERT_ID() should probably be allowed # QQ: LAST_INSERT_ID() should probably be allowed
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 CREATE TABLE t1
( (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,

View File

@ -14,7 +14,7 @@ SET @tmp=ST_GIS_DEBUG(1);
--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 INT DEFAULT ST_GIS_DEBUG(1)); CREATE TABLE t1 (a INT DEFAULT ST_GIS_DEBUG(1));
--echo # --echo #

View File

@ -9797,7 +9797,7 @@ bool check_expression(Virtual_column_info *vcol, const char *name,
if (ret || (res.errors & filter)) if (ret || (res.errors & filter))
{ {
my_error(ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0), res.name, my_error(ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0), res.name,
vcol_type_name(type), name); vcol_type_name(type), name);
return TRUE; return TRUE;
} }

View File

@ -6965,28 +6965,28 @@ ER_LAST_MYSQL_ERROR_MESSAGE
# MariaDB error numbers starts from 1900 # MariaDB error numbers starts from 1900
start-error-number 1900 start-error-number 1900
ER_VCOL_BASED_ON_VCOL ER_UNUSED_18
eng "A computed column cannot be based on a computed column" eng ""
ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
eng "Function or expression '%s' cannot be used in the %s clause of %`s" eng "Function or expression '%s' cannot be used in the %s clause of %`s"
ER_DATA_CONVERSION_ERROR_FOR_VIRTUAL_COLUMN ER_UNUSED_19
eng "Generated value for computed column '%s' cannot be converted to type '%s'" eng ""
ER_PRIMARY_KEY_BASED_ON_VIRTUAL_COLUMN ER_PRIMARY_KEY_BASED_ON_GENERATED_COLUMN
eng "Primary key cannot be defined upon a computed column" eng "Primary key cannot be defined upon a generated column"
ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
eng "Key/Index cannot be defined on a non-stored computed column" eng "Key/Index cannot be defined on a virtual generated column"
ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
eng "Cannot define foreign key with %s clause on a computed column" eng "Cannot define foreign key with %s clause on a generated column"
ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
eng "The value specified for computed column '%s' in table '%s' ignored" eng "The value specified for generated column '%s' in table '%s' ignored"
ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
eng "This is not yet supported for computed columns" eng "This is not yet supported for generated columns"
ER_CONST_EXPR_IN_VCOL ER_UNUSED_20
eng "Constant expression in computed column function is not allowed" eng ""
ER_ROW_EXPR_FOR_VCOL ER_UNUSED_21
eng "Expression for computed column cannot return a row" eng ""
ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS
eng "%s storage engine does not support computed columns" eng "%s storage engine does not support generated columns"
ER_UNKNOWN_OPTION ER_UNKNOWN_OPTION
eng "Unknown option '%-.64s'" eng "Unknown option '%-.64s'"
ER_BAD_OPTION_VALUE ER_BAD_OPTION_VALUE

View File

@ -1913,11 +1913,11 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
{ {
StringBuffer<MAX_FIELD_WIDTH> str(&my_charset_utf8mb4_general_ci); StringBuffer<MAX_FIELD_WIDTH> str(&my_charset_utf8mb4_general_ci);
field->vcol_info->print(&str); field->vcol_info->print(&str);
packet->append(STRING_WITH_LEN(" AS (")); packet->append(STRING_WITH_LEN(" GENERATED ALWAYS AS ("));
packet->append(str); packet->append(str);
packet->append(STRING_WITH_LEN(")")); packet->append(STRING_WITH_LEN(")"));
if (field->vcol_info->stored_in_db) if (field->vcol_info->stored_in_db)
packet->append(STRING_WITH_LEN(" PERSISTENT")); packet->append(STRING_WITH_LEN(" STORED"));
else else
packet->append(STRING_WITH_LEN(" VIRTUAL")); packet->append(STRING_WITH_LEN(" VIRTUAL"));
} }
@ -5508,9 +5508,9 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
if (field->vcol_info) if (field->vcol_info)
{ {
if (field->vcol_info->stored_in_db) if (field->vcol_info->stored_in_db)
table->field[17]->store(STRING_WITH_LEN("PERSISTENT"), cs); table->field[17]->store(STRING_WITH_LEN("STORED GENERATED"), cs);
else else
table->field[17]->store(STRING_WITH_LEN("VIRTUAL"), cs); table->field[17]->store(STRING_WITH_LEN("VIRTUAL GENERATED"), cs);
} }
table->field[19]->store(field->comment.str, field->comment.length, cs); table->field[19]->store(field->comment.str, field->comment.length, cs);
if (schema_table_store_record(thd, table)) if (schema_table_store_record(thd, table))

View File

@ -3881,7 +3881,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
{ {
if (key->type == Key::PRIMARY) if (key->type == Key::PRIMARY)
{ {
my_error(ER_PRIMARY_KEY_BASED_ON_VIRTUAL_COLUMN, MYF(0)); my_error(ER_PRIMARY_KEY_BASED_ON_GENERATED_COLUMN, MYF(0));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
if (sql_field->vcol_info->flags & VCOL_NOT_STRICTLY_DETERMINISTIC) if (sql_field->vcol_info->flags & VCOL_NOT_STRICTLY_DETERMINISTIC)
@ -7625,7 +7625,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
new_create_list.push_back(def, thd->mem_root); new_create_list.push_back(def, thd->mem_root);
if (field->stored_in_db() != def->stored_in_db()) if (field->stored_in_db() != def->stored_in_db())
{ {
my_error(ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN, MYF(0)); my_error(ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN, MYF(0));
goto err; goto err;
} }
if (!def->after) if (!def->after)

View File

@ -13953,7 +13953,7 @@ create_table_info_t::gcols_in_fulltext_or_spatial()
/* We do not support special (Fulltext or /* We do not support special (Fulltext or
Spatial) index on virtual columns */ Spatial) index on virtual columns */
if (innobase_is_v_fld(key_part->field)) { if (innobase_is_v_fld(key_part->field)) {
my_error(ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN, MYF(0)); my_error(ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN, MYF(0));
return true; return true;
} }
} }