summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/vcol/t
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/suite/vcol/t')
-rw-r--r--mysql-test/suite/vcol/t/alter_inplace-9045.test32
-rw-r--r--mysql-test/suite/vcol/t/binlog.test83
-rw-r--r--mysql-test/suite/vcol/t/charsets.test19
-rw-r--r--mysql-test/suite/vcol/t/cross_db.test12
-rw-r--r--mysql-test/suite/vcol/t/delayed.test5
-rw-r--r--mysql-test/suite/vcol/t/index.test97
-rw-r--r--mysql-test/suite/vcol/t/innodb_autoinc_vcol.test9
-rw-r--r--mysql-test/suite/vcol/t/innodb_virtual_fk.test115
-rw-r--r--mysql-test/suite/vcol/t/load_data.test15
-rw-r--r--mysql-test/suite/vcol/t/mrr.test13
-rw-r--r--mysql-test/suite/vcol/t/myisam_repair_prefix_varchar.test131
-rw-r--r--mysql-test/suite/vcol/t/not_supported.test66
-rw-r--r--mysql-test/suite/vcol/t/partition.test80
-rw-r--r--mysql-test/suite/vcol/t/races.test22
-rw-r--r--mysql-test/suite/vcol/t/range.test10
-rw-r--r--mysql-test/suite/vcol/t/rpl_vcol.test70
-rw-r--r--mysql-test/suite/vcol/t/update.test129
-rw-r--r--mysql-test/suite/vcol/t/update_binlog.test14
-rw-r--r--mysql-test/suite/vcol/t/upgrade.test28
-rw-r--r--mysql-test/suite/vcol/t/vcol_archive.test49
-rw-r--r--mysql-test/suite/vcol/t/vcol_blackhole.test49
-rw-r--r--mysql-test/suite/vcol/t/vcol_blocked_sql_funcs.test49
-rw-r--r--mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_main.inc359
-rw-r--r--mysql-test/suite/vcol/t/vcol_column_def_options_innodb.test51
-rw-r--r--mysql-test/suite/vcol/t/vcol_column_def_options_myisam.test50
-rw-r--r--mysql-test/suite/vcol/t/vcol_csv.test48
-rw-r--r--mysql-test/suite/vcol/t/vcol_handler_aria.test52
-rw-r--r--mysql-test/suite/vcol/t/vcol_handler_innodb.test51
-rw-r--r--mysql-test/suite/vcol/t/vcol_handler_myisam.test50
-rw-r--r--mysql-test/suite/vcol/t/vcol_ins_upd_innodb.test51
-rw-r--r--mysql-test/suite/vcol/t/vcol_ins_upd_myisam.test50
-rw-r--r--mysql-test/suite/vcol/t/vcol_keys_aria.test3
-rw-r--r--mysql-test/suite/vcol/t/vcol_keys_innodb.opt1
-rw-r--r--mysql-test/suite/vcol/t/vcol_keys_innodb.test137
-rw-r--r--mysql-test/suite/vcol/t/vcol_keys_myisam.test315
-rw-r--r--mysql-test/suite/vcol/t/vcol_memory.test48
-rw-r--r--mysql-test/suite/vcol/t/vcol_merge.test57
-rw-r--r--mysql-test/suite/vcol/t/vcol_misc.opt1
-rw-r--r--mysql-test/suite/vcol/t/vcol_misc.test543
-rw-r--r--mysql-test/suite/vcol/t/vcol_non_stored_columns_innodb.test53
-rw-r--r--mysql-test/suite/vcol/t/vcol_non_stored_columns_myisam.test52
-rw-r--r--mysql-test/suite/vcol/t/vcol_partition_innodb.test51
-rw-r--r--mysql-test/suite/vcol/t/vcol_partition_myisam.test51
-rw-r--r--mysql-test/suite/vcol/t/vcol_select_innodb.test56
-rw-r--r--mysql-test/suite/vcol/t/vcol_select_myisam.test132
-rw-r--r--mysql-test/suite/vcol/t/vcol_sql_mode.test322
-rw-r--r--mysql-test/suite/vcol/t/vcol_sql_mode_datetime.test134
-rw-r--r--mysql-test/suite/vcol/t/vcol_sql_mode_time.test135
-rw-r--r--mysql-test/suite/vcol/t/vcol_sql_mode_timestamp.test122
-rw-r--r--mysql-test/suite/vcol/t/vcol_sql_mode_upgrade.test193
-rw-r--r--mysql-test/suite/vcol/t/vcol_supported_sql_funcs.test49
-rw-r--r--mysql-test/suite/vcol/t/vcol_supported_sql_funcs_main.inc1223
-rw-r--r--mysql-test/suite/vcol/t/vcol_syntax.test189
-rw-r--r--mysql-test/suite/vcol/t/vcol_trigger_sp_innodb.test52
-rw-r--r--mysql-test/suite/vcol/t/vcol_trigger_sp_myisam.test51
-rw-r--r--mysql-test/suite/vcol/t/vcol_view_innodb.test55
-rw-r--r--mysql-test/suite/vcol/t/vcol_view_myisam.test50
-rw-r--r--mysql-test/suite/vcol/t/wrong_arena.test66
58 files changed, 6000 insertions, 0 deletions
diff --git a/mysql-test/suite/vcol/t/alter_inplace-9045.test b/mysql-test/suite/vcol/t/alter_inplace-9045.test
new file mode 100644
index 00000000..57723e6f
--- /dev/null
+++ b/mysql-test/suite/vcol/t/alter_inplace-9045.test
@@ -0,0 +1,32 @@
+#
+# MDEV-9045 Inconsistent handling of "ALGORITHM=INPLACE" with PERSISTENT generated columns
+#
+--source include/have_innodb.inc
+
+create table t1(id int auto_increment primary key, handle int, data bigint not null default 0) engine = innodb;
+insert into t1(handle) values(12),(54),(NULL);
+select *, md5(handle) from t1;
+alter table t1 add index handle(handle), algorithm=inplace;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+alter table t1 add column hash varchar(32) as (md5(handle)) persistent, algorithm=inplace;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+alter table t1 add column hash varchar(32) as (md5(handle)) persistent, add unique index hash(hash), algorithm=inplace;
+alter table t1 add column hash varchar(32) as (md5(handle)) persistent, add unique index hash(hash), algorithm=copy;
+select * from t1;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+alter table t1 modify column hash varchar(32) as (md5(handle+1)) persistent, algorithm=inplace;
+alter table t1 modify column hash varchar(32) as (md5(handle+1)) persistent, algorithm=copy;
+select * from t1;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+alter table t1 modify column handle int not null, algorithm=inplace;
+SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
+alter table t1 modify column handle int not null, algorithm=copy;
+select * from t1;
+alter table t1 drop index handle, algorithm=inplace;
+create index data on t1(data) algorithm=inplace;
+alter table t1 drop column data, algorithm=inplace;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+alter table t1 add column sha varchar(32) as (sha1(handle)) persistent, algorithm=inplace;
+alter table t1 add column sha varchar(32), algorithm=inplace;
+alter table t1 drop column hash, algorithm=inplace;
+drop table t1;
diff --git a/mysql-test/suite/vcol/t/binlog.test b/mysql-test/suite/vcol/t/binlog.test
new file mode 100644
index 00000000..edf0a895
--- /dev/null
+++ b/mysql-test/suite/vcol/t/binlog.test
@@ -0,0 +1,83 @@
+--source include/have_innodb.inc
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+
+#
+# MDEV-15243
+# Server crashes in in Field_blob::pack upon REPLACE into view with virtual
+# columns with binlog enabled
+#
+
+CREATE TABLE t1 (
+ pk SERIAL,
+ vcol_date DATE AS (col_date) PERSISTENT,
+ vcol_int INT AS (col_int) VIRTUAL,
+ vcol_year YEAR AS (col_year) PERSISTENT,
+ vcol_blob BLOB AS (col_blob) VIRTUAL,
+ col_date DATE,
+ col_int INT NULL,
+ col_blob BLOB NULL,
+ col_year YEAR,
+ PRIMARY KEY(pk)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 (col_date,col_int,col_blob,col_year) VALUES ('2010-04-24',5,'foo',1981);
+SET SQL_MODE='';
+
+set binlog_row_image="FULL";
+CREATE VIEW v1 AS SELECT * FROM t1;
+REPLACE INTO v1 SELECT pk, vcol_date, vcol_int, vcol_year, vcol_blob, col_date, col_int, col_blob, 1982 FROM t1;
+select col_date,col_int,col_blob,col_year from v1;
+sync_slave_with_master;
+select col_date,col_int,col_blob,col_year from v1;
+connection master;
+DROP VIEW v1;
+set binlog_row_image="MINIMAL";
+CREATE VIEW v1 AS SELECT * FROM t1;
+REPLACE INTO v1 SELECT pk, vcol_date, vcol_int, vcol_year, vcol_blob, col_date, col_int, col_blob, 1983 FROM t1;
+select col_date,col_int,col_blob,col_year from v1;
+sync_slave_with_master;
+select col_date,col_int,col_blob,col_year from v1;
+connection master;
+DROP VIEW v1;
+set @@binlog_row_image="NOBLOB";
+CREATE VIEW v1 AS SELECT * FROM t1;
+REPLACE INTO v1 SELECT pk, vcol_date, vcol_int, vcol_year, vcol_blob, col_date, col_int, col_blob, 1984 FROM t1;
+select col_date,col_int,col_blob,col_year from v1;
+sync_slave_with_master;
+select col_date,col_int,col_blob,col_year from v1;
+connection master;
+DROP VIEW v1;
+set @@binlog_row_image=default;
+
+DROP TABLE t1;
+SET SQL_MODE=default;
+
+# MDEV-24782
+# ASAN use-after-poison in Field::pack_int / THD::binlog_update_row
+
+CREATE TABLE t1 (pk INT, a VARCHAR(3), b VARCHAR(1) AS (a) VIRTUAL, PRIMARY KEY (pk));
+INSERT IGNORE INTO t1 (pk, a) VALUES (1,'foo'),(2,'bar');
+--error ER_DATA_TOO_LONG
+REPLACE INTO t1 (pk) VALUES (2);
+UPDATE IGNORE t1 SET a = NULL;
+
+# Cleanup
+DROP TABLE t1;
+
+
+--echo #
+--echo # MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+--echo #
+
+SET SESSION binlog_row_image= noblob;
+CREATE TEMPORARY TABLE t1 SELECT UUID();
+show create table t1;
+CREATE TABLE t2 (a INT PRIMARY KEY, b TEXT, c INT GENERATED ALWAYS AS(b));
+INSERT INTO t2 (a,b) VALUES (1,1);
+
+SET SESSION binlog_row_image= default;
+DROP TABLE t2;
+
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/vcol/t/charsets.test b/mysql-test/suite/vcol/t/charsets.test
new file mode 100644
index 00000000..72f9b7a3
--- /dev/null
+++ b/mysql-test/suite/vcol/t/charsets.test
@@ -0,0 +1,19 @@
+#
+# vcol definition, table charset, current connection charset
+#
+set names utf8;
+create table t1 (
+ a int,
+ b varchar(100) as (if(a,collation('й'),hex('ю')))
+) character set koi8r;
+insert t1 (a) values (0),(1);
+select * from t1;
+set names latin1;
+select * from t1;
+flush tables;
+select * from t1;
+set names koi8r;
+select * from t1;
+flush tables;
+select * from t1;
+drop table t1;
diff --git a/mysql-test/suite/vcol/t/cross_db.test b/mysql-test/suite/vcol/t/cross_db.test
new file mode 100644
index 00000000..5a8ee547
--- /dev/null
+++ b/mysql-test/suite/vcol/t/cross_db.test
@@ -0,0 +1,12 @@
+--source include/default_charset.inc
+
+#
+# MDEV-13209 Cross-database operation with virtual columns fails
+#
+
+create database mysqltest1;
+create table mysqltest1.t1 (i int, j int as (i) persistent);
+show create table mysqltest1.t1;
+alter table mysqltest1.t1 add index (i);
+show create table mysqltest1.t1;
+drop database mysqltest1;
diff --git a/mysql-test/suite/vcol/t/delayed.test b/mysql-test/suite/vcol/t/delayed.test
new file mode 100644
index 00000000..62065abd
--- /dev/null
+++ b/mysql-test/suite/vcol/t/delayed.test
@@ -0,0 +1,5 @@
+create table t (a int primary key, b int, c int as (b), index (c));
+insert t (a,b) values (10,1);
+replace delayed t (a,b) values (10,5);
+check table t;
+drop table t;
diff --git a/mysql-test/suite/vcol/t/index.test b/mysql-test/suite/vcol/t/index.test
new file mode 100644
index 00000000..b93c337f
--- /dev/null
+++ b/mysql-test/suite/vcol/t/index.test
@@ -0,0 +1,97 @@
+--source include/have_innodb.inc
+--source include/have_log_bin.inc
+
+--echo #
+--echo # Test table with a key that consists of indirect virtual fields
+--echo #
+
+CREATE TABLE t1 (a int, b int as (a+1) virtual, c int as (b+1) virtual, index(c)) engine=myisam;
+insert into t1 (a) values (1),(2),(3);
+update t1 set a=5 where a=3;
+delete from t1 where a=1;
+select * from t1;
+select * from t1 where c=7;
+check table t1;
+select * from t1;
+drop table t1;
+
+CREATE TABLE t1 (a int, b int as (a+1) virtual, c int as (b+1) virtual, index(c)) engine=innodb;
+insert into t1 (a) values (1),(2),(3);
+update t1 set a=5 where a=3;
+delete from t1 where a=1;
+select * from t1;
+select * from t1 where c=7;
+check table t1;
+select * from t1;
+drop table t1;
+
+--echo #
+--echo # MDEV-15114
+--echo # ASAN heap-use-after-free in mem_heap_dup or
+--echo # dfield_data_is_binary_equal
+--echo #
+
+CREATE TABLE t1 (
+ pk INT,
+ extra tinyint,
+ c TEXT,
+ vc LONGTEXT AS (c) VIRTUAL,
+ i INT,
+ PRIMARY KEY(pk),
+ UNIQUE(i),
+ INDEX(vc(64))
+) ENGINE=InnoDB;
+
+INSERT INTO t1 (pk,extra, c, i) VALUES (1, 10, REPEAT('foo ',15000),0);
+REPLACE INTO t1 (pk,extra, c,i) SELECT pk,extra+10, c,i FROM t1;
+select pk, extra, left(c, 10), length(c), left(vc,10), length(vc), extra from t1;
+DROP TABLE t1;
+
+--echo #
+--echo # Update of deleted row with binary logging enabled
+--echo #
+
+SET BINLOG_FORMAT=row;
+
+CREATE TABLE t1 (
+ pk INT,
+ c TEXT,
+ vc LONGTEXT AS (c) VIRTUAL,
+ i INT,
+ PRIMARY KEY(pk),
+ UNIQUE(i),
+ INDEX(vc(64))
+) ENGINE=InnoDB;
+
+INSERT INTO t1 (pk,c,i) VALUES (1,REPEAT('foo ',15000),10);
+INSERT INTO t1 (pk,c,i) VALUES (2,REPEAT('bar ',15000),11);
+
+--connect (c1,localhost,root,,)
+--connection c1
+begin;
+DELETE from t1 WHERE pk=1;
+--connection default
+--send update t1 set pk=1 where pk=2
+--connection c1
+commit;
+--connection default
+--reap
+select pk, left(c, 10), length(c), i from t1;
+drop table t1;
+disconnect c1;
+
+#
+# MDEV-16961 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed upon concurrent DELETE and DDL with virtual blob column
+#
+
+CREATE TABLE t1 (b BLOB, vb TEXT AS (b) PERSISTENT, KEY(vb(64))) ENGINE=InnoDB;
+INSERT INTO t1 (b) VALUES ('foo');
+--connect (con1,localhost,root,,test)
+--send CREATE TABLE t2 LIKE t1
+--connection default
+DELETE FROM t1;
+--connection con1
+--reap
+--disconnect con1
+--connection default
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/vcol/t/innodb_autoinc_vcol.test b/mysql-test/suite/vcol/t/innodb_autoinc_vcol.test
new file mode 100644
index 00000000..d499a06c
--- /dev/null
+++ b/mysql-test/suite/vcol/t/innodb_autoinc_vcol.test
@@ -0,0 +1,9 @@
+--source include/have_innodb.inc
+
+create table t1 (c2 int as (1+1), c1 int primary key auto_increment) engine=innodb;
+insert into t1(c1) values (null),(null),(null);
+select * from t1;
+alter table t1 auto_increment = 3;
+show create table t1;
+drop table t1;
+
diff --git a/mysql-test/suite/vcol/t/innodb_virtual_fk.test b/mysql-test/suite/vcol/t/innodb_virtual_fk.test
new file mode 100644
index 00000000..cab43914
--- /dev/null
+++ b/mysql-test/suite/vcol/t/innodb_virtual_fk.test
@@ -0,0 +1,115 @@
+source include/have_innodb.inc;
+set default_storage_engine=innodb;
+
+#
+# MDEV-13708 Crash with indexed virtual columns and FK cascading deletes
+#
+
+create table t1 (id int primary key, id2 int as (id) virtual, key id2 (id2));
+create table t2 (id int key, constraint fk_id foreign key (id) references t1 (id) on delete cascade);
+insert into t1 (id) values (1), (2);
+insert into t2 (id) values (1), (2);
+delete from t1;
+select * from t1;
+select * from t2;
+drop table t2;
+drop table t1;
+
+--echo #
+--echo # End of 10.2 tests
+--echo #
+
+--echo #
+--echo # MDEV-18114 Foreign Key Constraint actions don't affect Virtual Column
+--echo #
+create table t1 (id int primary key);
+
+# note that RESTRICT, NO ACTION, and DELETE CASCADE are fine
+# because they don't change values of referenced columns
+
+# virtual indexed
+create or replace table t2 (id int, id2 int as (id) virtual, key(id2), foreign key (id) references t1 (id) on update restrict);
+create or replace table t2 (id int, id2 int as (id) virtual, key(id2), foreign key (id) references t1 (id) on update no action);
+create or replace table t2 (id int, id2 int as (id) virtual, key(id2), foreign key (id) references t1 (id) on delete cascade);
+create or replace table t2 (id int, id2 int as (id) virtual, key(id2), foreign key (id) references t1 (id) on update cascade);
+create or replace table t2 (id int, id2 int as (id) virtual, key(id2), foreign key (id) references t1 (id) on delete set null);
+create or replace table t2 (id int, id2 int as (id) virtual, key(id2), foreign key (id) references t1 (id) on update set null);
+
+# stored
+create or replace table t2 (id int, id2 int as (id) stored, foreign key (id) references t1 (id) on update restrict);
+create or replace table t2 (id int, id2 int as (id) stored, foreign key (id) references t1 (id) on update no action);
+create or replace table t2 (id int, id2 int as (id) stored, foreign key (id) references t1 (id) on delete cascade);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (id int, id2 int as (id) stored, foreign key (id) references t1 (id) on update cascade);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (id int, id2 int as (id) stored, foreign key (id) references t1 (id) on delete set null);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (id int, id2 int as (id) stored, foreign key (id) references t1 (id) on update set null);
+
+# stored indirect
+create or replace table t2 (id int, id2 int as (id) virtual, id3 int as (id2) stored, foreign key (id) references t1 (id) on update restrict);
+create or replace table t2 (id int, id2 int as (id) virtual, id3 int as (id2) stored, foreign key (id) references t1 (id) on update no action);
+create or replace table t2 (id int, id2 int as (id) virtual, id3 int as (id2) stored, foreign key (id) references t1 (id) on delete cascade);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (id int, id2 int as (id) virtual, id3 int as (id2) stored, foreign key (id) references t1 (id) on update cascade);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (id int, id2 int as (id) virtual, id3 int as (id2) stored, foreign key (id) references t1 (id) on delete set null);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (id int, id2 int as (id) virtual, id3 int as (id2) stored, foreign key (id) references t1 (id) on update set null);
+
+# default
+create or replace table t2 (id int, id2 int default (id), foreign key (id) references t1 (id) on update restrict);
+create or replace table t2 (id int, id2 int default (id), foreign key (id) references t1 (id) on update no action);
+create or replace table t2 (id int, id2 int default (id), foreign key (id) references t1 (id) on delete cascade);
+create or replace table t2 (id int, id2 int default (id), foreign key (id) references t1 (id) on update cascade);
+create or replace table t2 (id int, id2 int default (id), foreign key (id) references t1 (id) on delete set null);
+create or replace table t2 (id int, id2 int default (id), foreign key (id) references t1 (id) on update set null);
+
+# field check
+create or replace table t2 (id int, id2 int check (id), foreign key (id) references t1 (id) on update restrict);
+create or replace table t2 (id int, id2 int check (id), foreign key (id) references t1 (id) on update no action);
+create or replace table t2 (id int, id2 int check (id), foreign key (id) references t1 (id) on delete cascade);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (id int, id2 int check (id), foreign key (id) references t1 (id) on update cascade);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (id int, id2 int check (id), foreign key (id) references t1 (id) on delete set null);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (id int, id2 int check (id), foreign key (id) references t1 (id) on update set null);
+
+# table check
+create or replace table t2 (id int, id2 int, check (id), foreign key (id) references t1 (id) on update restrict);
+create or replace table t2 (id int, id2 int, check (id), foreign key (id) references t1 (id) on update no action);
+create or replace table t2 (id int, id2 int, check (id), foreign key (id) references t1 (id) on delete cascade);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (id int, id2 int, check (id), foreign key (id) references t1 (id) on update cascade);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (id int, id2 int, check (id), foreign key (id) references t1 (id) on delete set null);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (id int, id2 int, check (id), foreign key (id) references t1 (id) on update set null);
+
+# table check indirect
+create or replace table t2 (id int, id2 int as (id) virtual, check (id2), foreign key (id) references t1 (id) on update restrict);
+create or replace table t2 (id int, id2 int as (id) virtual, check (id2), foreign key (id) references t1 (id) on update no action);
+create or replace table t2 (id int, id2 int as (id) virtual, check (id2), foreign key (id) references t1 (id) on delete cascade);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (id int, id2 int as (id) virtual, check (id2), foreign key (id) references t1 (id) on update cascade);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (id int, id2 int as (id) virtual, check (id2), foreign key (id) references t1 (id) on delete set null);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (id int, id2 int as (id) virtual, check (id2), foreign key (id) references t1 (id) on update set null);
+
+drop table if exists t2, t1;
+
+--echo #
+--echo # MDEV-31853 Assertion failure in Column_definition::check_vcol_for_key upon adding FK
+--echo #
+create table t (a int, b int, c int generated always as (a), key(b), key(c));
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table t add foreign key (a) references t (b) on update set null, algorithm=nocopy;
+alter table t add foreign key (a) references t (b);
+show create table t;
+drop table t;
+
+--echo #
+--echo # End of 10.5 tests
+--echo #
diff --git a/mysql-test/suite/vcol/t/load_data.test b/mysql-test/suite/vcol/t/load_data.test
new file mode 100644
index 00000000..1b662818
--- /dev/null
+++ b/mysql-test/suite/vcol/t/load_data.test
@@ -0,0 +1,15 @@
+#
+# MDEV-7968 Virtual column set to NULL using load data infile
+#
+create table t1 ( c1 varchar(10), c2 varchar(10), c3 int );
+insert into t1 values ("a" , "b", 1), ("a" , "b", 2);
+create table t2 like t1 ;
+alter table t2 add column c4 bigint unsigned as (CONV(LEFT(MD5(concat(c1,c2,c3)), 16), 16, 10)) persistent unique key;
+--disable_ps2_protocol
+select * into outfile 't1.csv' from t1;
+--enable_ps2_protocol
+load data infile 't1.csv' ignore into table t2 ;
+select * from t2;
+insert into t2 (c1,c2,c3) values ("a" , "b", 4);
+select * from t2;
+drop table t1, t2;
diff --git a/mysql-test/suite/vcol/t/mrr.test b/mysql-test/suite/vcol/t/mrr.test
new file mode 100644
index 00000000..d7772ba5
--- /dev/null
+++ b/mysql-test/suite/vcol/t/mrr.test
@@ -0,0 +1,13 @@
+CREATE TABLE t1 (
+ pk INT AUTO_INCREMENT PRIMARY KEY,
+ col_int_nokey INT NULL,
+ col_int_key INT AS (col_int_nokey) VIRTUAL,
+ KEY (col_int_key)
+);
+INSERT INTO t1 (col_int_nokey)
+VALUES (0), (5), (4), (3), (7), (42), (5), (0), (3);
+SELECT * FROM t1 WHERE col_int_key IN (3, 4) AND col_int_key <= 83 ORDER BY 1;
+set optimizer_switch='index_condition_pushdown=off';
+SELECT * FROM t1 WHERE col_int_key IN (3, 4) ORDER BY 1;
+SELECT * FROM t1 WHERE col_int_key IN (3, 4) AND col_int_key <= 83 ORDER BY 1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/vcol/t/myisam_repair_prefix_varchar.test b/mysql-test/suite/vcol/t/myisam_repair_prefix_varchar.test
new file mode 100644
index 00000000..f35512c5
--- /dev/null
+++ b/mysql-test/suite/vcol/t/myisam_repair_prefix_varchar.test
@@ -0,0 +1,131 @@
+#
+# MDEV-11605 Assertion `(longlong) thd->status_var.local_memory_used >= 0 || !debug_assert_on_not_freed_memory' failed in my_malloc_size_cb_func
+#
+create table t4 (
+ pk bigint auto_increment,
+ col_int smallint(48) not null default 0,
+ col_datetime datetime(6) null,
+ col_enum set('','a','b','c','d','e','f','foo','bar') null,
+ col_dec decimal(65,38) unsigned zerofill null,
+ col_bit bit(26) null,
+ col_year year null,
+ col_datetime2 datetime(6) null,
+ col_date date null,
+ col_char binary(242) not null default '',
+ col_time time(1) null,
+ col_blob tinytext null,
+ col_varchar varchar(1855) not null default '',
+ vcol_varchar varchar(2116) as (col_varchar) virtual,
+ vvcol_varchar varchar(2116) as (vcol_varchar) virtual,
+ primary key(pk)
+ ) engine=myisam;
+
+insert into t4 (col_int,col_datetime,col_enum,col_dec,col_bit,col_year,col_datetime2,col_date,col_char,col_time,col_blob,col_varchar) values
+ (9,NULL,'',0.2,b'10100001',2026,NULL,'1988-08-27','bar','14:20:46.009603','bar','bar'),
+ (6,'2013-06-27 15:21:27.016500','',0.1,b'01000100',1983,'2014-03-26 03:00:53.052916','2000-09-04','','22:30:46.061648','bar','bar'),
+ (156,'2017-04-04 00:00:00','',0.8,NULL,1992,'1991-10-18 17:41:54.030689',NULL,'f','16:58:37.037585','z','a'),
+ (7,'1979-05-14 19:13:18.060777',NULL,0.4,b'0',1994,'1900-01-01 00:00:00','2030-01-06','bar','03:24:01.010412','bar','bar'),
+ (5,'1975-08-06 00:00:02.061160','',0.7,b'01',1996,'1982-06-10 13:09:15.005717','2008-04-23','bar',NULL,'bar','bar'),
+ (14,'2029-05-19 07:56:57.028948','',0.0,NULL,1973,'1900-01-01 00:00:00','2006-03-01','p','20:58:23.064148','v','a'),
+ (23,NULL,'',NULL,b'011111111000',2014,'2004-06-19 17:20:37.029214','1974-06-26','bar','14:55:15.000814','m','bar'),
+ (6,NULL,'',0.6,b'1100100011011101001111',1986,'2014-07-01 03:01:16.043826','2020-01-15','z','04:57:32.018208','bar','g'),
+ (2,'1987-03-12 05:18:40.006865','',0.6,b'001001001011000011001',2012,NULL,'2020-04-21','','20:45:31.021923','k','t'),
+ (1,'1993-05-23 10:37:22.054985','',0.4,b'01001',NULL,'1997-08-16 02:35:53.002484','2001-12-09','bar','07:36:35.044493','','s'),
+ (9,'2020-11-17 01:09:54.053312','',0.7,b'0',2022,'1900-01-01 00:00:00','2026-05-12','bar','21:41:10.040515','bar','bar'),
+ (1,'2025-04-21 16:08:16.033559','',0.4,b'0000',1991,'2013-03-14 09:03:02.016013',NULL,'bar','23:22:08.056231','c','bar'),
+ (4,NULL,'',0.5,b'101000000',2023,'1900-01-01 00:00:00','1991-05-26','bar','08:23:51.037917','bar',''),
+ (5,'2035-09-13 00:00:00','',0.4,b'1110100001001111',2027,'2001-01-13 19:20:36.044577','2019-04-03','foo','08:18:11.001097','','bar'),
+ (6,'1975-08-15 21:42:22.049174','',0.3,b'010010010101',2032,NULL,'2023-01-21','bar','22:08:23.001364','bar','bar'),
+ (4,'2013-05-01 00:00:00','',0.3,b'011101010000110000',2021,'2030-07-16 00:00:00','2027-12-07','e','10:09:49.061627','bar','bar'),
+ (2,'2035-06-20 22:55:45.008894','',0.8,b'11000',2034,'1983-12-20 07:27:43.035034','1986-09-12','bar','19:02:29.013068','bar','foo'),
+ (0,NULL,'',0.1,b'01111010100011',2029,'1978-01-08 00:00:00','1974-12-16','','03:44:02.034839','bar','foo'),
+ (1,'1983-11-04 19:04:57.035319','',0.8,b'100001110100110001010',2001,NULL,'1981-05-05','f','00:00:00','bar','bar'),
+ (5,NULL,'',0.7,b'0011110001101',NULL,NULL,'1999-07-28','bar','20:33:42.039257','x','r'),
+ (3,NULL,'',0.9,b'00110110111',2019,'2008-12-27 00:00:00','2012-03-14','bar','19:12:32.062124','bar','bar'),
+ (8,NULL,'',0.9,b'001011001111',1977,'1995-02-20 00:00:00','1985-02-04','bar','23:08:10.014396','bar','bar'),
+ (0,NULL,NULL,0.9,b'01',2001,'2011-03-16 22:54:22.026461',NULL,'foo','07:07:55.017714','z','m'),
+ (8,'2027-08-03 00:00:00','',0.2,b'110001',2035,'2011-06-24 15:58:37.049649','2028-11-21','qux','16:37:54.001939','d','f'),
+ (2,'1900-01-01 00:00:00','',0.1,b'10',2015,'1973-11-22 15:34:01.047131','2010-08-18','foo','17:43:20.056086','bar','b'),
+ (7,NULL,'',0.7,b'00100100',1974,'1983-04-16 15:00:17.003592',NULL,'qux','00:00:00','bar','foo'),
+ (7,'1980-05-10 20:47:46.049712','',0.0,NULL,2010,'1900-01-01 00:00:00','1974-06-01','foo','08:34:02.056752','bar','qux'),
+ (0,'2029-01-10 19:49:58.002777',NULL,0.4,b'1100',2026,'2007-11-24 04:06:32.038008','1980-02-20','foo','06:01:30.019582','qux','bar'),
+ (8,'2010-01-04 12:54:59.003789','',0.8,b'01001110111010111',1971,'2010-01-17 06:56:30.006700','2007-09-21','u','13:31:53.061759','bar','foo'),
+ (1,'1976-11-17 00:00:00','',0.0,b'00010001011101',2034,'1976-11-08 21:18:21.053929','2029-04-19','','00:38:43.046200','qux','bar'),
+ (4,'1991-06-12 16:01:19.007026','',0.4,b'110111010100101111011001',1997,'2004-03-07 18:06:41.050645',NULL,'','17:23:17.056960','o',''),
+ (4,'2021-12-14 20:59:31.062969',NULL,0.8,b'01100001010111011101000101',NULL,'2034-04-17 02:55:45.046064',NULL,'bar','10:28:15.003445','n','foo'),
+ (85,'1998-09-24 21:01:37.043422','',0.3,b'1001001001111010',1997,'2033-03-23 12:54:48.043906','2030-10-10','r','08:12:29.026018','d','foo'),
+ (5,'2031-11-20 00:00:00','',0.1,b'11010011111',2011,'1989-07-07 16:45:29.060242',NULL,'qux','05:12:14.002326','foo','bar'),
+ (9,'1900-01-01 00:00:00','',0.3,b'0100010',2035,'1900-01-01 00:00:00','1982-12-04','bar',NULL,NULL,'qux'),
+ (8,'2024-11-03 23:31:40.058574','',0.2,b'11001101110101100100001011',2027,'1977-12-18 00:00:00','1972-01-13','tqvbj','16:27:36.004472','qux','f'),
+ (1,'1976-01-06 23:32:58.038263','',0.6,NULL,2020,'2029-03-08 18:36:33.010902','1900-01-01','qux','19:36:37.015269','e','bar'),
+ (9,'1900-01-01 00:00:00','',0.1,b'010010111101111110000',1993,'2000-10-27 16:52:51.015854','1974-12-22','qux','05:46:08.055789','i','bar'),
+ (6,'1900-01-01 00:00:00','',0.0,b'00',2010,'2009-06-09 18:30:10.054617',NULL,'qux','01:36:44.033940','bar',''),
+ (6,'2006-04-13 05:21:03.061942','',0.0,b'0000101101100011010000111',1971,'2032-04-05 16:01:44.056007',NULL,'r','01:08:36.007948',NULL,'bar'),
+ (8,'2001-03-27 10:39:48.064273','',0.2,b'1000111100100100110',2021,'2016-11-21 07:09:28.035220','2020-01-08','qux','21:33:51.036722','','bar'),
+ (6,'2009-11-26 00:00:00','',0.0,b'0000110010001010110111',2009,'2034-02-16 11:01:29.027539','2009-04-12','q','12:01:56.032072','bar','qux'),
+ (2,'1990-03-12 07:26:22.053357','',0.7,b'0110',2002,'1975-12-13 03:14:35.064214','2015-05-04','foo','18:17:43.065361','qux','bar'),
+ (3,'1900-01-01 00:00:00','',0.8,b'0',1990,'2004-03-24 17:19:30.055335','2005-01-21','bar','07:08:14.014929','b','b'),
+ (7,'2012-12-18 00:00:00','',0.5,NULL,1981,'1981-02-17 15:47:55.041049','1989-09-26','bar','09:00:19.031063','t','foo'),
+ (3,'1981-12-09 10:10:34.008107','',0.8,NULL,1976,NULL,'1980-01-20','foo','00:00:00','qux','bar'),
+ (2,'2006-06-05 03:56:10.030366','',0.5,b'001000101000100000100',1996,'1998-08-17 00:00:00','1994-02-11','bar','20:55:21.044208',NULL,'foo'),
+ (4,'1900-01-01 00:00:00',NULL,0.4,b'00111000011000001010000',1980,NULL,NULL,'e','09:37:44.034108','','k'),
+ (2,'2018-03-01 21:14:08.062101','',0.2,b'00001101011101000',1985,'2022-06-09 17:17:31.039498','1900-01-01','bar','00:00:00','j','qux'),
+ (1,'2018-05-06 20:12:14.043515',NULL,NULL,b'1100100000100001101011',NULL,'2020-12-20 11:46:57.017685','1973-04-20','qux','00:00:00','','bar'),
+ (8,'1985-07-12 02:16:53.034909',NULL,0.3,b'10111000100110110101',1997,'1985-11-07 23:07:06.015091','2007-01-08','z','04:14:58.038324','bar','x'),
+ (5,'2027-09-21 16:28:36.016865','',0.9,NULL,1986,'2013-11-16 07:22:14.009509','1900-01-01','qux','16:19:03.023217','bar','d'),
+ (1,'1900-01-01 00:00:00','',0.5,b'010101',2007,'1987-03-23 01:34:02.040253','2004-01-24','bar','00:00:00','qux','t'),
+ (0,NULL,'',0.3,b'10111010001110111011',2030,NULL,'2007-11-17','qux','14:16:15.008674','bar','foo'),
+ (5,'1900-01-01 00:00:00','',0.3,b'1',2004,'1978-03-06 00:00:00','2003-07-08','','09:33:46.000325','','bar'),
+ (207,'2019-10-05 19:24:40.063253','',NULL,b'1010111000110110110000',1977,'1992-01-07 15:50:41.043085','2003-10-24','d','12:50:19.026611','qux','bar'),
+ (1,'2012-07-01 23:30:29.042644','',0.8,b'01111010111001001101',1974,'1976-03-16 00:00:00','2006-01-09','qux','22:22:44.040748','','bar'),
+ (2,'1995-06-21 00:00:00','',0.9,b'000101001100100',2022,'2006-09-23 00:00:00',NULL,'bar','06:13:27.061694','v','qux'),
+ (1,'1900-01-01 00:00:00',NULL,0.8,b'000000001000',2027,'2028-03-20 08:34:05.027629','1999-09-28','bar','01:39:33.047138','foo','qux'),
+ (5,'1996-06-01 05:23:35.020694','',0.9,b'1111001111001110001011001',1996,'1973-12-13 05:51:14.039856','1993-04-13','','20:24:00.040657','foo','bar'),
+ (8,'2000-02-18 12:32:03.020086','',0.3,b'0000111010',2010,'1972-09-12 01:43:50.058850',NULL,'qux','23:12:01.017030','bar','x'),
+ (8,'1992-05-27 02:39:01.058236','',0.7,b'011101110',2032,NULL,'1998-04-03','h','12:22:12.041362','p','bar'),
+ (7,'1900-01-01 00:00:00','',0.3,b'10111111110011010111',1989,'1998-06-08 00:00:00','1993-02-10','qux','12:44:43.060254','h','bar'),
+ (164,'2034-08-09 10:48:51.053786',NULL,0.0,b'00100111',1973,'2026-01-13 19:29:43.039915','2022-03-01','bar','11:51:54.036462','','qux'),
+ (0,'2030-02-22 18:02:11.043075','',0.8,b'011000111111011111111100',2001,'2030-02-09 15:46:56.055798','2026-03-20','bar','10:31:58.002654','q','qux'),
+ (7,'2009-11-19 06:26:11.008028','',0.8,NULL,2004,'2009-07-05 00:00:00','2014-04-22','t','05:45:36.023615',NULL,'u'),
+ (1,'1987-04-17 04:16:29.007028','',0.5,b'00',1976,'1900-01-01 00:00:00','2023-12-07','foo','22:25:07.010419','qux','bar'),
+ (6,NULL,'',0.6,b'0',2003,'2025-04-15 11:19:34.034736','2010-06-20','qux','00:00:00','bar','foo'),
+ (2,'2025-03-26 07:09:22.012297','',0.5,b'00110000001110111110',2033,'1974-03-16 18:35:58.062140','1982-04-07','qux','18:50:57.025695',NULL,'z'),
+ (4,'2032-12-08 13:05:51.020675','',0.4,b'11001001100011',NULL,'1983-08-26 11:47:49.027635','2019-07-08','qux','00:00:00','','x'),
+ (0,'1972-12-10 00:00:00','',NULL,b'00000100010110100000',1978,'1990-12-28 15:20:43.027572','2008-02-23','r','17:48:05.030363','foo','bar'),
+ (6,'1900-01-01 00:00:00',NULL,0.9,b'111000001101010',2026,'1997-08-09 00:00:00','1900-01-01','c','00:00:00','','qux'),
+ (6,NULL,'',0.5,b'011110001001',2010,'1900-01-01 00:00:00','2018-01-11','foo','00:00:00','qux','bar'),
+ (9,'2000-11-10 06:31:29.024423','',0.7,NULL,2004,'1900-01-01 00:00:00','1972-04-10','qux','22:50:18.046302','foo','bar'),
+ (0,'2008-02-11 00:00:00','',0.3,b'111010011',NULL,'1976-10-02 06:40:56.017017','1900-01-01','q','12:50:11.001180',NULL,'foo'),
+ (6,'2032-01-13 00:00:00',NULL,0.7,b'0101110010010110011001000',2006,NULL,'2015-06-08','bar','00:27:52.030995','qux','foo'),
+ (5,NULL,'',0.2,b'101100101000',1993,'2008-03-26 00:00:00','2023-03-25','bar','17:51:32.035040','foo','qux'),
+ (0,NULL,NULL,NULL,b'01110000111011010101',2020,'1988-02-20 19:30:16.015815','2027-02-07','bar','11:18:36.020832','qux','foo'),
+ (8,'1990-02-04 11:52:45.035803','',0.2,b'1',2034,'2014-06-28 16:58:27.046952','2020-12-05','bar','08:36:43.060728','','qux'),
+ (1,NULL,'',0.7,b'110010010111110100110001',2002,'2019-06-19 03:39:03.040619','2001-08-28','bar','01:59:24.036052','foo','qux'),
+ (6,'2003-09-12 14:34:37.035049','',0.3,b'110010',2029,NULL,'2025-11-09','bar','18:51:11.041328','d',''),
+ (9,NULL,'',NULL,b'00010',2005,'2027-07-12 23:36:51.053942','2000-06-04','qux','13:46:39.062130','bar',''),
+ (5,'2035-12-19 04:59:44.044122','',0.8,b'110011011010010101101100',2000,'1980-06-16 02:14:18.040078','1900-01-01','j',NULL,'qux','c'),
+ (4,'1978-06-11 18:53:14.037991','',0.4,b'00000',NULL,'2018-03-13 18:56:39.056433','2020-12-07','foo','17:58:15.029684','bar','y'),
+ (2,NULL,'',0.2,b'100101110010101',1976,'2017-06-12 18:40:22.011803','2021-11-01','qux','15:16:59.059052','foo','bar'),
+ (5,'2017-08-07 01:53:34.056737','',0.1,b'1110101100',1979,'1900-01-01 00:00:00','1900-01-01','foo','03:13:31.046205','bar',REPEAT('a',1693)),
+ (7,'2022-09-25 03:36:08.040842','',0.7,b'11010111110001010',2026,NULL,'2018-04-15','bar','16:08:47.004044','','qux'),
+ (5,'1988-04-05 07:40:37.041464','',0.6,b'101110100110110',NULL,'2011-08-08 02:23:59.013723','2020-01-28','qux','00:00:00','foo','y'),
+ (6,NULL,NULL,0.7,b'1100001',1995,NULL,'2026-02-01','',NULL,'o','qux'),
+ (9,'1985-05-13 00:00:00','',0.5,b'1110101011010100101110',1973,'1975-04-08 00:00:00','2006-09-22','qux','13:43:19.008905','foo','bar'),
+ (7,'2032-07-23 00:00:00','',0.6,b'10100100011110110100',1985,'1997-02-22 02:04:16.040238','1971-05-24','y','10:27:41.006741','i','qux'),
+ (1,'1900-01-01 00:00:00','',0.5,NULL,2013,'2002-09-28 00:00:00','2025-03-17','o','13:27:32.040813','','y'),
+ (8,'2014-08-03 10:02:33.055574','',0.0,b'1',1992,NULL,'1978-12-27','x','10:58:03.022898','foo',''),
+ (9,'2011-05-25 00:00:00','',0.8,b'11001001000011100',2019,NULL,'2003-10-06','qux','00:00:00',NULL,'bar'),
+ (8,'1900-01-01 00:00:00','',0.0,b'101101000010100011011111',2000,'2005-05-18 00:00:00','1995-07-13','bar','13:19:40.057958','foo',''),
+ (4,NULL,'',0.8,b'011011',1972,NULL,'2008-04-16','b','00:00:00','bar','foo'),
+ (8,'2005-07-21 07:54:38.040060','',0.5,b'100',2003,'1900-01-01 00:00:00','1994-09-03','qux','02:36:25.048212','','b'),
+ (7,'2002-07-03 01:08:02.012450','',0.5,b'101100010001101101',1990,'1974-04-15 02:53:22.018939','2002-02-12','','10:40:14.031253','w','c'),
+ (174,'2029-09-28 01:08:52.004131','',NULL,b'001001000011',1976,'2034-12-11 02:11:04.035857','2005-07-18','qux','00:00:00','xd','bar'),
+ (255,'2004-02-02 06:53:55.023459',NULL,NULL,b'111010100',1982,'1983-12-17 00:00:00','2003-12-20','bar','01:23:47.001055','t','qux');
+
+alter table t4 add index(vcol_varchar(64));
+repair table t4;
+repair table t4 extended;
+alter table t4 add index(vvcol_varchar(32));
+repair table t4;
+repair table t4 extended;
+drop table t4;
diff --git a/mysql-test/suite/vcol/t/not_supported.test b/mysql-test/suite/vcol/t/not_supported.test
new file mode 100644
index 00000000..d58b207a
--- /dev/null
+++ b/mysql-test/suite/vcol/t/not_supported.test
@@ -0,0 +1,66 @@
+#
+# MDEV-7113 difference between check_vcol_func_processor and check_partition_func_processor
+#
+
+# the following functions must not be supported in persistent columns.
+# but for compatibility reasons it won't be done in a GA version,
+# we'll only fix most critical issues (inconsistent results, crashes)
+
+connect (con1, localhost, root);
+
+set lc_time_names = 'es_MX';
+set time_zone='+10:00';
+set div_precision_increment=20;
+
+create table t1 (a int, b int, v decimal(20,19) as (a/3));
+create table t2 (a int, b int, v int as (a+@a)); drop table t2;
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+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));
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create table t3 (a int, b int, v int as (a+@@error_count) PERSISTENT);
+create table t4 (a int, b int, v int as (@a:=a)); drop table t4;
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+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)));
+
+insert t1 (a,b) values (1,2);
+insert t8 (a,b) values (1234567890,2);
+
+select * from t1;
+select * from t8;
+
+disconnect con1;
+connection default;
+set time_zone='+1:00';
+flush tables;
+
+select * from t1;
+select * from t8;
+
+drop table t1, t3_ok, t8;
+
+--echo #
+--echo # Bug#33141966 - INCONSISTENT BEHAVIOR IF A COLUMN OF TYPE SERIAL IS SET AS GENERATED
+--echo #
+--error ER_PARSE_ERROR
+create table t1 (a int, b serial as (a+1));
+
+--echo #
+--echo # End of 10.2 tests
+--echo #
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create table t1 (a int, b real as (rand()), c real as (b) stored);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create table t1 (a int, b real as (rand()), c real as (b) unique);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create table t1 (a int auto_increment primary key,
+ b int as (a+1), c int as (b+1) stored);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create table t1 (a int auto_increment primary key,
+ b int as (a+1), c int as (b+1) unique);
+
+--echo #
+--echo # End of 10.3 tests
+--echo #
diff --git a/mysql-test/suite/vcol/t/partition.test b/mysql-test/suite/vcol/t/partition.test
new file mode 100644
index 00000000..408990b2
--- /dev/null
+++ b/mysql-test/suite/vcol/t/partition.test
@@ -0,0 +1,80 @@
+#
+# test keyread on an indexed vcol
+#
+--source include/have_partition.inc
+
+CREATE TABLE t1 (
+ id INT NOT NULL,
+ store_id INT NOT NULL,
+ x INT GENERATED ALWAYS AS (id + store_id)
+)
+PARTITION BY RANGE (store_id) (
+ PARTITION p0 VALUES LESS THAN (6),
+ PARTITION p1 VALUES LESS THAN (11),
+ PARTITION p2 VALUES LESS THAN (16),
+ PARTITION p3 VALUES LESS THAN (21)
+);
+INSERT t1 (id, store_id) VALUES(1, 2), (3, 4), (3, 12), (4, 18);
+CREATE INDEX idx ON t1(x);
+SELECT x FROM t1;
+DROP TABLE t1;
+
+#
+# MDEV-15626 Assertion on update virtual column in partitioned table
+#
+create table t1 (i int, v int as (i) virtual)
+partition by range columns (i)
+subpartition by hash(v) subpartitions 3 (
+ partition p1 values less than (3),
+ partition pn values less than (maxvalue));
+insert t1 set i= 0;
+set statement sql_mode= '' for update t1 set i= 1, v= 2;
+drop table t1;
+
+--echo #
+--echo # MDEV-18734 ASAN heap-use-after-free in my_strnxfrm_simple_internal upon update on versioned partitioned table
+--echo #
+--echo # Cover queue_fix() in ha_partition::handle_ordered_index_scan()
+create or replace table t1 (
+ x int auto_increment primary key,
+ b text, v mediumtext as (b) virtual,
+ index (v(10))
+) partition by range columns (x) (
+ partition p1 values less than (3),
+ partition p2 values less than (6),
+ partition p3 values less than (9),
+ partition p4 values less than (12),
+ partition p5 values less than (15),
+ partition p6 values less than (17),
+ partition p7 values less than (19),
+ partition p8 values less than (21),
+ partition p9 values less than (23),
+ partition p10 values less than (25),
+ partition p11 values less than (27),
+ partition p12 values less than (29),
+ partition p13 values less than (31),
+ partition p14 values less than (33),
+ partition p15 values less than (35),
+ partition pn values less than (maxvalue));
+insert into t1 (b) values
+(repeat('q', 8192)), (repeat('z', 8192)), (repeat('a', 8192)), (repeat('b', 8192)),
+(repeat('x', 8192)), (repeat('y', 8192));
+
+insert t1 (b) select b from t1;
+insert t1 (b) select b from t1;
+insert t1 (b) select b from t1;
+insert t1 (b) select b from t1;
+
+select x, left(b, 10), left(v, 10) from t1 where x > 30 and x < 60 order by v;
+update t1 set b= 'bar' where v > 'a' limit 20;
+
+drop table t1;
+
+--echo # Cover return_top_record() in ha_partition::handle_ordered_index_scan()
+create table t1 (x int primary key, b tinytext, v text as (b) virtual)
+partition by range columns (x) (
+ partition p1 values less than (4),
+ partition pn values less than (maxvalue));
+insert into t1 (x, b) values (1, ''), (2, ''), (3, 'a'), (4, 'b');
+update t1 set b= 'bar' where x > 0 order by v limit 2;
+drop table t1;
diff --git a/mysql-test/suite/vcol/t/races.test b/mysql-test/suite/vcol/t/races.test
new file mode 100644
index 00000000..1bf4e43d
--- /dev/null
+++ b/mysql-test/suite/vcol/t/races.test
@@ -0,0 +1,22 @@
+#
+# MDEV-17349 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed on concurrent SELECT and DELETE after RENAME from table with index on virtual column
+#
+source include/have_innodb.inc;
+source include/have_debug_sync.inc;
+create table t1 (f text, vf tinytext as (f), key (vf(64))) engine=innodb;
+insert t1 (f) values ('foo');
+flush tables;
+connect con1,localhost,root,,test;
+set debug_sync='TABLE_after_field_clone WAIT_FOR go';
+send delete from t1;
+connection default;
+let $wait_condition= select state like 'debug sync point%' from information_schema.processlist;
+source include/wait_condition.inc;
+select * from t1;
+set debug_sync='now SIGNAL go';
+connection con1;
+reap;
+disconnect con1;
+connection default;
+drop table t1;
+set debug_sync='reset';
diff --git a/mysql-test/suite/vcol/t/range.test b/mysql-test/suite/vcol/t/range.test
new file mode 100644
index 00000000..a4593d8b
--- /dev/null
+++ b/mysql-test/suite/vcol/t/range.test
@@ -0,0 +1,10 @@
+#
+# MDEV-11518 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed in Field_long::val_int()
+#
+create table t1 (pk int, i int, v int as (i*2) virtual, primary key (pk), key (v)) engine=myisam;
+insert into t1 (pk,i) values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8);
+create table t2 (a int, b int) engine=myisam;
+insert into t2 values (1,2),(2,4);
+select * from t1 inner join t2 on ( t2.b = t1.v or t2.a = t1.pk );
+drop table t1, t2;
+
diff --git a/mysql-test/suite/vcol/t/rpl_vcol.test b/mysql-test/suite/vcol/t/rpl_vcol.test
new file mode 100644
index 00000000..d893ebac
--- /dev/null
+++ b/mysql-test/suite/vcol/t/rpl_vcol.test
@@ -0,0 +1,70 @@
+################################################################################
+# t/vcol_rpl.test #
+# #
+# Purpose: #
+# Test replication of tables with virtual columns. #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04
+# Change Author: Oleksandr Byelkin (Monty program Ab)
+# Date: 2009-03-24
+# Change: Syntax changed
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+--source include/have_innodb.inc
+SET @@session.default_storage_engine = 'InnoDB';
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source include/master-slave.inc
+
+connection master;
+create table t1 (a int, b int as (a+1));
+show create table t1;
+insert into t1 values (1,default);
+insert into t1 values (2,default);
+select * from t1;
+save_master_pos;
+
+connection slave;
+sync_with_master;
+select * from t1;
+
+connection master;
+drop table t1;
+save_master_pos;
+
+connection slave;
+sync_with_master;
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/vcol/t/update.test b/mysql-test/suite/vcol/t/update.test
new file mode 100644
index 00000000..6065f926
--- /dev/null
+++ b/mysql-test/suite/vcol/t/update.test
@@ -0,0 +1,129 @@
+#
+# Test how UPDATE detects what columns need to be read (or generated) in a row
+#
+# stored column depends on virtual column depends on updated column.
+# this tests TABLE::mark_virtual_columns_for_write()
+#
+create table t1 (a int, b int as (a+1), c int as (b+1) stored);
+insert t1 set a=1;
+select * from t1;
+update t1 set a=2;
+select * from t1;
+drop table t1;
+#
+# one keypart is virtual, the other keypart is updated
+# this tests TABLE::mark_columns_needed_for_update()
+#
+create table t1 (a int, c int as(a), p varchar(20) as(rtrim(y)), y char(20), index (p,c));
+show create table t1;
+insert into t1 (a,y) values(1, "yyy");
+update t1 set a = 100 where a = 1;
+check table t1;
+drop table t1;
+
+#
+# note: prefix keys below
+#
+create table t1 (
+ a varchar(10000),
+ b varchar(3000),
+ c varchar(14000) generated always as (concat(a,b)) virtual,
+ d varchar(5000) generated always as (b) virtual,
+ e int(11) generated always as (10) virtual,
+ h int(11) not null primary key,
+ index(c(100), d(20)));
+insert t1 (a,b,h) values (repeat('g', 10000), repeat('x', 2800), 1);
+update t1 set a = repeat(cast(1 as char), 2000);
+drop table t1;
+
+create table t1 (
+ a varchar(10000),
+ b varchar(3000),
+ c varchar(14000) generated always as (concat(a,b)) virtual,
+ i varchar(5000) generated always as (b) virtual,
+ d varchar(5000) generated always as (i) virtual,
+ e int(11) generated always as (10) virtual,
+ h int(11) not null primary key,
+ index(c(100), d(20)));
+insert t1 (a,b,h) values (repeat('g', 10000), repeat('x', 2800), 1);
+update t1 set a = repeat(cast(1 as char), 2000);
+drop table t1;
+#
+# UPDATE disguised as INSERT
+#
+create table t1(a blob not null, b int, c varbinary (10) generated always as (a) virtual, unique (c(9)));
+insert t1 (a,b) values ('a', 1);
+replace t1 set a = 'a',b =1;
+insert t1 (a,b) values ('a', 1) on duplicate key update a='b', b=2;
+select * from t1;
+drop table t1;
+
+#
+# multi-UPDATE and const tables
+#
+create table t (a int primary key, b int, c int as (b), index (c));
+insert t (a,b) values (9,0);
+create table t2 select * from t;
+update t, t2 set t.b=10 where t.a=t2.a;
+check table t; select * from t;
+drop table t, t2;
+
+#
+# blobs
+# This tests BLOB_VALUE_ORPHANAGE
+#
+create table t1 (a int, b int, c int, d int, e int);
+insert t1 values (1,2,3,4,5), (1,2,3,4,5);
+SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
+create table t (a int primary key,
+ b int, c blob as (b), index (c(57)),
+ d blob, e blob as (d), index (e(57)))
+ replace select * from t1;
+check table t; select * from t;
+update t set a=10, b=1, d=1;
+check table t; select * from t;
+replace t (a,b,d) values (10,2,2);
+check table t; select * from t;
+--error ER_WRONG_VALUE_COUNT_ON_ROW
+insert t(a,b,d) values (10) on duplicate key update b=3;
+insert t(a,b,d) values (10,2,2) on duplicate key update b=3, d=3;
+check table t; select * from t;
+replace t (a,b,d) select 10,4,4;
+check table t; select * from t;
+insert t(a,b,d) select 10,4,4 on duplicate key update b=5, d=5;
+check table t; select * from t;
+replace delayed t (a,b,d) values (10,6,6);
+flush tables t;
+check table t; select * from t;
+insert delayed t(a,b,d) values (10,6,6) on duplicate key update b=7, d=7;
+flush tables t;
+check table t; select * from t;
+--write_file $MYSQLTEST_VARDIR/tmp/vblobs.txt
+10 8 foo 8 foo
+EOF
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval load data infile '$MYSQLTEST_VARDIR/tmp/vblobs.txt' replace into table t
+--remove_file $MYSQLTEST_VARDIR/tmp/vblobs.txt
+check table t; select * from t;
+update t set a=11, b=9, d=9 where a>5;
+check table t; select * from t;
+create table t2 select * from t;
+update t, t2 set t.b=10, t.d=10 where t.a=t2.a;
+check table t; select * from t;
+update t, t tt set t.b=11, tt.d=11 where t.a=tt.a;
+check table t; select * from t;
+drop table t, t1, t2;
+
+#
+# MDEV-13623 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed in virtual longlong Field_long::val_int
+#
+create table t (f1 int, f2 int, f3 int as (f1*2) virtual, key(f3,f2));
+insert into t (f1,f2) values (1,1),(2,2);
+create view v as
+ select a2.f1, a2.f2, a1.f3
+ from t a1, t a2
+ where a2.f3 <> 0
+ with local check option;
+update v set f3 = 52;
+drop view v;
+drop table t;
diff --git a/mysql-test/suite/vcol/t/update_binlog.test b/mysql-test/suite/vcol/t/update_binlog.test
new file mode 100644
index 00000000..458aac48
--- /dev/null
+++ b/mysql-test/suite/vcol/t/update_binlog.test
@@ -0,0 +1,14 @@
+#
+# Check that vcol update works with binlog enabled
+#
+
+--source include/have_binlog_format_row.inc
+
+set binlog_row_image="FULL";
+set @@default_storage_engine="myisam";
+
+--source update.test
+
+set binlog_row_image="MINIMAL";
+
+--source update.test
diff --git a/mysql-test/suite/vcol/t/upgrade.test b/mysql-test/suite/vcol/t/upgrade.test
new file mode 100644
index 00000000..146495d8
--- /dev/null
+++ b/mysql-test/suite/vcol/t/upgrade.test
@@ -0,0 +1,28 @@
+#
+# MDEV-12936 upgrade to 10.2.6 failed upon tables with virtual columns
+#
+let $datadir=`select @@datadir`;
+copy_file std_data/vcol_autoinc.frm $datadir/test/vcol_autoinc.frm;
+copy_file std_data/vcol_autoinc.MYD $datadir/test/vcol_autoinc.MYD;
+copy_file std_data/vcol_autoinc.MYI $datadir/test/vcol_autoinc.MYI;
+check table vcol_autoinc for upgrade;
+show create table vcol_autoinc;
+select * from vcol_autoinc;
+insert vcol_autoinc (pk) values (1);
+select * from vcol_autoinc;
+drop table vcol_autoinc;
+
+#
+# MDEV-17909 Problem by MariaDB Update 10.1.32 -> 10.2.19 (Incorrect information in file: .frm)
+#
+source include/have_partition.inc;
+copy_file std_data/mdev17909#P#p20181029.MYD $datadir/test/t1#P#p20181029.MYD;
+copy_file std_data/mdev17909#P#p20181029.MYI $datadir/test/t1#P#p20181029.MYI;
+copy_file std_data/mdev17909#P#p20181128.MYD $datadir/test/t1#P#p20181128.MYD;
+copy_file std_data/mdev17909#P#p20181128.MYI $datadir/test/t1#P#p20181128.MYI;
+copy_file std_data/mdev17909.frm $datadir/test/t1.frm;
+copy_file std_data/mdev17909.par $datadir/test/t1.par;
+check table t1 for upgrade;
+flush tables;
+show create table t1;
+drop table t1;
diff --git a/mysql-test/suite/vcol/t/vcol_archive.test b/mysql-test/suite/vcol/t/vcol_archive.test
new file mode 100644
index 00000000..b708b3a4
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_archive.test
@@ -0,0 +1,49 @@
+################################################################################
+# t/vcol_archive.test #
+# #
+# Purpose: #
+# ARCHIVE branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-02 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+--source include/have_archive.inc
+SET @@session.default_storage_engine = 'archive';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+--source suite/vcol/inc/vcol_unsupported_storage_engines.inc
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_blackhole.test b/mysql-test/suite/vcol/t/vcol_blackhole.test
new file mode 100644
index 00000000..6cbc68a9
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_blackhole.test
@@ -0,0 +1,49 @@
+################################################################################
+# t/vcol_blackhole.test #
+# #
+# Purpose: #
+# BLACKHOLE branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-02 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+--source include/have_blackhole.inc
+SET @@session.default_storage_engine = 'blackhole';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+--source suite/vcol/inc/vcol_unsupported_storage_engines.inc
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_blocked_sql_funcs.test b/mysql-test/suite/vcol/t/vcol_blocked_sql_funcs.test
new file mode 100644
index 00000000..d00ab827
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_blocked_sql_funcs.test
@@ -0,0 +1,49 @@
+################################################################################
+# t/vcol_supported_sql_funcs.test #
+# #
+# Purpose: #
+# Test SQL functions not allowed for virtual columns #
+# MyISAM branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-08-31 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+eval SET @@session.default_storage_engine = 'MyISAM';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source vcol_blocked_sql_funcs_main.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_main.inc b/mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_main.inc
new file mode 100644
index 00000000..52324176
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_main.inc
@@ -0,0 +1,359 @@
+################################################################################
+# inc/vcol_blocked_sql_funcs_main.inc #
+# #
+# Purpose: #
+# Tests around sql functions #
+# #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-08-31 #
+# Change Author: Oleksandr Byelkin (Monty program Ab)
+# Date: 2009-03-24
+# Change: Syntax changed
+################################################################################
+
+#
+# NOTE: All SQL functions should be rejected, otherwise BUG.
+# As PERSISTANT has higher level checks than VIRTUAL, we use VIRTUAL
+# to check for things that should not work for either VIRTUAL or PERSISTENT
+#
+
+--echo # RAND()
+create or replace table t1 (b double as (rand()));
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (b double as (rand()) PERSISTENT);
+
+--echo # LOAD_FILE()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(64), b varchar(1024) as (load_file(a)));
+
+--echo # CURDATE()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime as (curdate()) PERSISTENT);
+
+--echo # CURRENT_DATE(), CURRENT_DATE
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime as (current_date) PERSISTENT);
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime as (current_date()) PERSISTENT);
+
+--echo # CURRENT_TIME(), CURRENT_TIME
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime as (current_time) PERSISTENT);
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime as (current_time()) PERSISTENT);
+
+--echo # CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime as (current_timestamp()) PERSISTENT);
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime as (current_timestamp) PERSISTENT);
+
+--echo # CURTIME()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime as (curtime()) PERSISTENT);
+
+--echo # LOCALTIME(), LOCALTIME
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime, b varchar(10) as (localtime()) PERSISTENT);
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime, b varchar(10) as (localtime) PERSISTENT);
+
+--echo # LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6)
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime, b varchar(10) as (localtimestamp()) PERSISTENT);
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime, b varchar(10) as (localtimestamp) PERSISTENT);
+
+--echo # NOW()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime, b varchar(10) as (now()) PERSISTENT);
+
+--echo # SYSDATE()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b varchar(10) as (sysdate()) PERSISTENT);
+
+--echo # UNIX_TIMESTAMP()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime, b datetime as (unix_timestamp()) PERSISTENT);
+
+--echo # UTC_DATE()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime, b datetime as (utc_date()) PERSISTENT);
+
+--echo # UTC_TIME()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime, b datetime as (utc_time()) PERSISTENT);
+
+--echo # UTC_TIMESTAMP()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime, b datetime as (utc_timestamp()) PERSISTENT);
+
+--echo # WEEK() - one argument version
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a datetime, b datetime as (week(a)) PERSISTENT);
+
+--echo # MATCH()
+--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);
+
+--echo # BENCHMARK()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3)));
+
+--echo # CHARSET()
+create or replace table t1 (a varchar(64), b varchar(64) as (charset(a)) PERSISTENT);
+
+--echo # COERCIBILITY()
+create or replace table t1 (a varchar(64), b int as (coercibility(a)) PERSISTENT);
+
+--echo # COLLATION()
+create or replace table t1 (a varchar(64), b varchar(64) as (collation(a)) PERSISTENT);
+
+--echo # CONNECTION_ID()
+create or replace table t1 (a int as (connection_id()));
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int as (connection_id()) PERSISTENT);
+
+--echo # DATABASE()
+create or replace table t1 (a varchar(32) as (database()));
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(1024), b varchar(1024) as (database()) PERSISTENT);
+
+--echo # FOUND_ROWS()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(1024), b varchar(1024) as (found_rows()));
+
+--echo # GET_LOCK()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10)));
+
+--echo # IS_FREE_LOCK()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a)));
+
+--echo # IS_USED_LOCK()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a)));
+
+--echo # LAST_INSERT_ID()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int as (last_insert_id()));
+
+--echo # MASTER_POS_WAIT()
+-- 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)));
+
+--echo # NAME_CONST()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(32) as (name_const('test',1)));
+
+--echo # RELEASE_LOCK()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(32), b int as (release_lock(a)));
+
+--echo # ROW_COUNT()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int as (row_count()));
+
+--echo # SCHEMA()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(32) as (schema()) PERSISTENT);
+
+--echo # SESSION_USER()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(32) as (session_user()) PERSISTENT);
+
+--echo # SLEEP()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (sleep(a)));
+
+--echo # SYSTEM_USER()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(32) as (system_user()) PERSISTENT);
+
+--echo # USER()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(1024), b varchar(1024) as (user()) PERSISTENT);
+
+--echo # UUID_SHORT()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(1024) as (uuid_short()) PERSISTENT);
+
+--echo # UUID()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(1024) as (uuid()) PERSISTENT);
+
+--echo # VALUES()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(1024), b varchar(1024) as (value(a)));
+
+--echo # VERSION()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(1024), b varchar(1024) as (version()) PERSISTENT);
+
+--echo # ENCRYPT()
+create or replace table t1 (a varchar(1024), b varchar(1024) as (encrypt(a)) PERSISTENT);
+
+--echo # Stored procedures
+
+delimiter //;
+create procedure p1()
+begin
+ select current_user();
+end //
+
+create function f1()
+returns int
+begin
+ return 1;
+end //
+
+delimiter ;//
+
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int as (p1()) PERSISTENT);
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int as (f1()) PERSISTENT);
+
+drop procedure p1;
+drop function f1;
+
+--echo # Unknown functions
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int as (f1()) PERSISTENT);
+
+--echo #
+--echo # GROUP BY FUNCTIONS
+--echo #
+
+--echo # AVG()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (avg(a)));
+
+--echo # BIT_AND()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (bit_and(a)));
+
+--echo # BIT_OR()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (bit_or(a)));
+
+--echo # BIT_XOR()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (bit_xor(a)));
+
+--echo # COUNT(DISTINCT)
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (count(distinct a)));
+
+--echo # COUNT()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (count(a)));
+
+--echo # GROUP_CONCAT()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a varchar(32), b int as (group_concat(a,'')));
+
+--echo # MAX()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (max(a)));
+
+--echo # MIN()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (min(a)));
+
+--echo # STD()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (std(a)));
+
+--echo # STDDEV_POP()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (stddev_pop(a)));
+
+--echo # STDDEV_SAMP()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (stddev_samp(a)));
+
+--echo # STDDEV()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (stddev(a)));
+
+--echo # SUM()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (sum(a)));
+
+--echo # VAR_POP()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (var_pop(a)));
+
+--echo # VAR_SAMP()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (var_samp(a)));
+
+--echo # VARIANCE()
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (variance(a)));
+
+--echo #
+--echo # XML FUNCTIONS
+--echo #
+
+--echo # ExtractValue()
+create or replace table t1 (a varchar(1024), b varchar(1024) as (ExtractValue(a,'//b[$@j]')) PERSISTENT);
+
+--echo # UpdateXML()
+create or replace table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a','<e>fff</e>')) PERSISTENT);
+
+--echo #
+--echo # Sub-selects
+--echo #
+
+create or replace table t1 (a int);
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t2 (a int, b int as (select count(*) from t1));
+drop table t1;
+
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as ((select 1)));
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (a+(select 1)));
+
+--echo #
+--echo # SP functions
+--echo #
+
+--disable_warnings
+drop function if exists sub1;
+--enable_warnings
+create function sub1(i int) returns int deterministic
+ return i+1;
+select sub1(1);
+-- error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create or replace table t1 (a int, b int as (a+sub3(1)));
+drop function sub1;
+
+--echo #
+--echo # Long expression
+
+let $tmp_long_string = `SELECT repeat('a',240)`;
+eval create or replace table t1 (a int, b varchar(300) as (concat(a,'$tmp_long_string')));
+drop table t1;
+let $tmp_long_string = `SELECT repeat('a',243)`;
+eval create or replace table t1 (a int, b varchar(16384) as (concat(a,'$tmp_long_string')));
+
+--disable_query_log
+let $tmp_long_string = `SELECT repeat('a',65535)`;
+--error ER_EXPRESSION_IS_TOO_BIG
+eval create or replace table t1 (a int, b varchar(16384) as (concat(a,'$tmp_long_string')));
+--enable_query_log
+
+--echo #
+--echo # Constant expression
+create or replace table t1 (a int as (PI()) PERSISTENT);
+
+drop table if exists t1;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create table t1 (a timestamp, b varchar(255) as (date_format(a, '%w %a %m %b')) stored);
diff --git a/mysql-test/suite/vcol/t/vcol_column_def_options_innodb.test b/mysql-test/suite/vcol/t/vcol_column_def_options_innodb.test
new file mode 100644
index 00000000..6fb6a504
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_column_def_options_innodb.test
@@ -0,0 +1,51 @@
+################################################################################
+# t/vcol_column_def_options_innodb.test #
+# #
+# Purpose: #
+# Testing different optional parameters of virtual columns. #
+# #
+# InnoDB branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-02 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+--source include/have_innodb.inc
+eval SET @@session.default_storage_engine = 'InnoDB';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_column_def_options.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_column_def_options_myisam.test b/mysql-test/suite/vcol/t/vcol_column_def_options_myisam.test
new file mode 100644
index 00000000..63081429
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_column_def_options_myisam.test
@@ -0,0 +1,50 @@
+################################################################################
+# t/vcol_column_def_options_myisam.test #
+# #
+# Purpose: #
+# Testing different optional parameters of virtual columns. #
+# #
+# MyISAM branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-02 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+eval SET @@session.default_storage_engine = 'MyISAM';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_column_def_options.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_csv.test b/mysql-test/suite/vcol/t/vcol_csv.test
new file mode 100644
index 00000000..0c218df6
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_csv.test
@@ -0,0 +1,48 @@
+################################################################################
+# t/vcol_csv.test #
+# #
+# Purpose: #
+# CSV branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-02 #
+# Change Author: Oleksandr Byelkin (Monty program Ab)
+# Date: 2009-03-24
+# Change: Syntax changed
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+--source include/have_csv.inc
+SET @@session.default_storage_engine = 'CSV';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+
+#------------------------------------------------------------------------------#
+--source suite/vcol/inc/vcol_unsupported_storage_engines.inc
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_handler_aria.test b/mysql-test/suite/vcol/t/vcol_handler_aria.test
new file mode 100644
index 00000000..0787321e
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_handler_aria.test
@@ -0,0 +1,52 @@
+################################################################################
+# t/vcol_handler_maria.test #
+# #
+# Purpose: #
+# Testing HANDLER.
+# #
+# Maria branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--source include/have_maria.inc
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MARIA SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+eval SET @@session.default_storage_engine = 'maria';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_handler.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_handler_innodb.test b/mysql-test/suite/vcol/t/vcol_handler_innodb.test
new file mode 100644
index 00000000..c86cbd0d
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_handler_innodb.test
@@ -0,0 +1,51 @@
+################################################################################
+# t/vcol_handler_innodb.test #
+# #
+# Purpose: #
+# Testing HANDLER.
+# #
+# InnoDB branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+--source include/have_innodb.inc
+eval SET @@session.default_storage_engine = 'InnoDB';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_handler.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_handler_myisam.test b/mysql-test/suite/vcol/t/vcol_handler_myisam.test
new file mode 100644
index 00000000..424752d9
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_handler_myisam.test
@@ -0,0 +1,50 @@
+################################################################################
+# t/vcol_handler_myisam.test #
+# #
+# Purpose: #
+# Testing HANDLER.
+# #
+# MyISAM branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+eval SET @@session.default_storage_engine = 'MyISAM';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_handler.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_ins_upd_innodb.test b/mysql-test/suite/vcol/t/vcol_ins_upd_innodb.test
new file mode 100644
index 00000000..fd1af0ab
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_ins_upd_innodb.test
@@ -0,0 +1,51 @@
+################################################################################
+# t/vcol_ins_upd_innodb.test #
+# #
+# Purpose: #
+# Testing DDL operations such as INSERT, UPDATE, REPLACE and DELETE. #
+# #
+# InnoDB branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+--source include/have_innodb.inc
+eval SET @@session.default_storage_engine = 'InnoDB';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_ins_upd.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_ins_upd_myisam.test b/mysql-test/suite/vcol/t/vcol_ins_upd_myisam.test
new file mode 100644
index 00000000..d73d0aa6
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_ins_upd_myisam.test
@@ -0,0 +1,50 @@
+################################################################################
+# t/vcol_ins_upd_myisam.test #
+# #
+# Purpose: #
+# Testing DDL operations such as INSERT, UPDATE, REPLACE and DELETE. #
+# #
+# MyISAM branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+eval SET @@session.default_storage_engine = 'MyISAM';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_ins_upd.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_keys_aria.test b/mysql-test/suite/vcol/t/vcol_keys_aria.test
new file mode 100644
index 00000000..b7ac0d26
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_keys_aria.test
@@ -0,0 +1,3 @@
+--source include/have_maria.inc
+--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
+create table t1 (a int, b int as (a+1), c int, index(b)) engine=aria;
diff --git a/mysql-test/suite/vcol/t/vcol_keys_innodb.opt b/mysql-test/suite/vcol/t/vcol_keys_innodb.opt
new file mode 100644
index 00000000..778b4443
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_keys_innodb.opt
@@ -0,0 +1 @@
+--innodb-sort-buffer-size=64k
diff --git a/mysql-test/suite/vcol/t/vcol_keys_innodb.test b/mysql-test/suite/vcol/t/vcol_keys_innodb.test
new file mode 100644
index 00000000..488a2b93
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_keys_innodb.test
@@ -0,0 +1,137 @@
+###############################################################################
+# t/vcol_keys_innodb.test #
+# #
+# Purpose: #
+# Testing keys, indexes defined upon virtual columns. #
+# #
+# InnoDB branch #
+# #
+#-----------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04 #
+# Change Author: #
+# Change Date: #
+# Change: #
+###############################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#-----------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#-----------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#-----------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+--source include/have_innodb.inc
+SET @@session.default_storage_engine = 'InnoDB';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#-----------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+let $with_foreign_keys = 1;
+--source suite/vcol/inc/vcol_keys.inc
+
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#-----------------------------------------------------------------------------#
+# Execute storage engine specific tests
+#-----------------------------------------------------------------------------#
+
+--echo #
+--echo # MDEV-11737 Failing assertion: block->magic_n == MEM_BLOCK_MAGIC_N
+--echo #
+
+CREATE TABLE t1 (i INT PRIMARY KEY, vi INT AS (i*2) VIRTUAL UNIQUE)
+ENGINE=InnoDB;
+CREATE TABLE t2 (i INT) ENGINE=InnoDB;
+ALTER TABLE t1 ADD COLUMN col INT;
+SELECT * FROM t1 WHERE vi < 2;
+DROP TABLE t1, t2;
+
+
+#
+# MDEV-11604 Assertion `!check_datetime_range(ltime)' failed in TIME_to_longlong_datetime_packed
+#
+create table t1 (
+ pk int auto_increment,
+ col_varchar varchar(847) not null default '',
+ col_int bigint(15) unsigned zerofill,
+ col_datetime datetime(3) not null default '1900-01-01 00:00:00',
+ col_time time(5) not null default '00:00:00',
+ col_blob text,
+ col_bit bit(34),
+ col_year year,
+ col_char char(10),
+ col_dec decimal(18,9) not null default 0,
+ col_enum enum('','a','b','c','d','e','f','foo','bar') not null default '',
+ col_date date not null default '1900-01-01',
+ col_timestamp timestamp(3) not null default '1971-01-01 00:00:00',
+ vcol_datetime datetime as (truncate(col_datetime,0)) virtual,
+ vcol_dec decimal(18,9) zerofill as (col_dec) virtual,
+ vcol_bit bit(63) as (col_bit) virtual,
+ vcol_char binary(51) as (col_char) virtual,
+ vcol_timestamp timestamp(5) as (col_timestamp) virtual,
+ vcol_enum enum('','a','b','c','d','e','f','foo','bar') as (col_enum) virtual,
+ vcol_int tinyint(48) zerofill as (col_int) virtual,
+ vcol_time time(4) as (col_time) virtual,
+ vcol_varchar varbinary(3873) as (col_varchar) virtual,
+ vcol_year year as (col_year) virtual,
+ vcol_date date as (col_date) virtual,
+ vcol_blob longtext as (col_blob) virtual,
+ primary key(pk)
+ ) engine=innodb;
+
+insert into t1 (col_varchar,col_int,col_datetime,col_time,col_blob,col_bit,col_year,col_char,col_dec,col_enum,col_date,col_timestamp) values
+ ('foo',1,'2010-05-08 13:08:12.034783','18:32:14','foo',b'0111110101001001',1992,'f',0.2,'','1994-12-26','2019-01-11 00:00:00'),
+ ('bar',6,'1900-01-01 00:00:00','00:00:00','bar',b'10011000001101011000101',1985,'b',0.7,'','2028-04-06','1971-01-01 00:00:00');
+
+alter table t1 add index(vcol_datetime);
+drop table t1;
+
+
+#
+# MDEV-11704 InnoDB: Failing assertion: dfield_is_null(dfield2) || dfield2->data
+#
+create table t1 (
+ pk int,
+ col_blob mediumtext not null default '',
+ vcol_blob tinyblob as (col_blob) virtual,
+ col_char char(22) null,
+ primary key(pk),
+ index(col_char,vcol_blob(64))
+ ) engine=innodb;
+insert ignore into t1 (pk) values (1),(2);
+update t1 set col_char = 'foo' where pk = 1;
+drop table t1;
+
+#
+# MDEV-20799 DROP Virtual Column crashes MariaDB
+#
+--source include/have_sequence.inc
+create table t1 (
+ id int not null primary key,
+ a varchar(200),
+ b varchar(200),
+ c int,
+ va char(200) generated always as (ucase(a)) virtual,
+ vb char(200) generated always as (ucase(b)) virtual,
+ key (c,va,vb)
+) engine=innodb;
+insert t1 (id,a,c) select seq,seq,seq from seq_1_to_330;
+select IF(@@innodb_sort_buffer_size < count(*)*200, 'GOOD', 'WRONG SIZE') from t1;
+alter table t1 drop column va;
+drop table t1;
diff --git a/mysql-test/suite/vcol/t/vcol_keys_myisam.test b/mysql-test/suite/vcol/t/vcol_keys_myisam.test
new file mode 100644
index 00000000..ab75703f
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_keys_myisam.test
@@ -0,0 +1,315 @@
+--source include/have_sequence.inc
+--let $datadir= `select @@datadir`
+###############################################################################
+# t/vcol_keys_myisam.test #
+# #
+# Purpose: #
+# Testing keys, indexes defined upon virtual columns. #
+# #
+# MyISAM branch #
+# #
+#-----------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04 #
+# Change Author: #
+# Change Date: #
+# Change: #
+###############################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+SET @@session.default_storage_engine = 'MyISAM';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_keys.inc
+
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#-----------------------------------------------------------------------------#
+# Execute storage engine specific test
+#-----------------------------------------------------------------------------#
+
+--echo #
+--echo # Original test
+--echo #
+
+create table t1 (a int, b int as (a+1), c int, index(b));
+insert t1 (a,c) values (0x7890abcd, 0x76543210);
+insert t1 (a,c) select seq, sin(seq)*10000 from seq_1_to_1000;
+explain select * from t1 where b=10;
+select * from t1 where b=10;
+--replace_result $datadir datadir
+--exec $MYISAMCHK -d $datadir/test/t1
+update t1 set a=20 where b=10;
+select * from t1 where b=10;
+select * from t1 where b=21;
+delete from t1 where b=21;
+select * from t1 where b=21;
+alter table t1 add column d char(20) as (concat(a,c));
+select * from t1 where b=11;
+create index i on t1 (d);
+check table t1;
+select * from t1 where b=11;
+check table t1 quick;
+select * from t1 where b=11;
+check table t1 medium;
+select * from t1 where b=11;
+check table t1 extended;
+show keys from t1;
+select * from t1 where b=11;
+delete from t1 where b=12;
+analyze table t1;
+show keys from t1;
+select * from t1 where b=11;
+optimize table t1;
+show keys from t1;
+select * from t1 where b=11;
+repair table t1;
+select * from t1 where b=11;
+repair table t1 quick;
+select * from t1 where b=11;
+repair table t1 extended;
+select * from t1 where b=11;
+repair table t1 use_frm;
+select * from t1 where b=11;
+update t1 set a=30 where b=11;
+select * from t1 where b=11;
+select * from t1 where b=31;
+
+--error 1
+--exec $MYISAMCHK $datadir/test/t1
+--error 1
+--exec $MYISAMCHK -r $datadir/test/t1
+drop table t1;
+
+--echo #
+--echo # MDEV-11606 Server crashes in mi_make_key / sort_key_read
+--echo #
+
+CREATE TABLE t1 (
+ pk BIGINT AUTO_INCREMENT,
+ col_date DATE NULL,
+ col_datetime DATETIME(1) NULL,
+ col_int TINYINT(13) UNSIGNED ZEROFILL NULL,
+ col_varchar VARBINARY(2222) NULL,
+ col_timestamp TIMESTAMP(2) NULL,
+ col_bit BIT(64) NOT NULL DEFAULT 0,
+ col_blob MEDIUMBLOB NULL,
+ col_dec DECIMAL(10,9) ZEROFILL NOT NULL DEFAULT 0,
+ col_time TIME(4) NULL,
+ col_year YEAR NOT NULL DEFAULT '1970',
+ col_char CHAR(129) NULL,
+ col_enum SET('','a','b','c','d','e','f','foo','bar') NULL,
+ vcol_dec DECIMAL(50,18) ZEROFILL AS (col_dec) VIRTUAL,
+ vcol_bit BIT(48) AS (col_bit) VIRTUAL,
+ vcol_char CHAR(224) AS (col_char) VIRTUAL,
+ vcol_datetime DATETIME(4) AS (col_datetime) VIRTUAL,
+ vcol_year YEAR AS (col_year) VIRTUAL,
+ vcol_varchar VARBINARY(356) AS (col_varchar) VIRTUAL,
+ vcol_blob MEDIUMBLOB AS (col_blob) VIRTUAL,
+ vcol_timestamp TIMESTAMP(5) AS (col_timestamp) VIRTUAL,
+ vcol_int BIGINT(46) AS (col_int) VIRTUAL,
+ vcol_time TIME(1) AS (col_time) VIRTUAL,
+ vcol_date DATE AS (col_date) VIRTUAL,
+ vcol_enum SET('','a','b','c','d','e','f','foo','bar') AS (col_enum) VIRTUAL,
+ UNIQUE(pk),
+ PRIMARY KEY(pk)
+ ) ENGINE=MyISAM;
+
+--disable_query_log
+INSERT INTO t1 (col_date,col_datetime,col_int,col_varchar,col_timestamp,col_bit,col_blob,col_dec,col_time,col_year,col_char,col_enum) VALUES
+ (NULL,'2011-04-17 15:46:11.056462',6,'rsprn','1980-01-01 00:00:00',b'0001011111000111001110000110100110010101101','spr',0.0,'00:00:00',1988,'p',''),
+ ('2007-05-18',NULL,5,'rnwg','2009-07-07 23:46:32.052699',b'01010','n',0.6,'04:35:56.018027',1995,'wgrpq',''),
+ ('1994-03-16','2006-03-15 22:48:25.013225',7,'grpquarw','2034-05-17 10:51:23.048265',b'0001011101001011000111101','rp',0.3,'15:13:22.043368',2004,'pq',''),
+ ('1980-01-01','1987-06-01 04:14:04.027480',1,'qu','1989-07-05 09:46:16.038513',b'001111011000100011100111010100101010000100010100101','uar',0.6,'11:56:35.031314',1986,'',''),
+ ('2014-08-16','2021-01-08 20:59:16.041252',0,'arw','2022-12-20 22:48:53.014627',b'110110101100001011001110110100','m',0.6,'17:26:26.039855',2008,'rw',''),
+ ('1981-12-02','1992-02-10 09:29:41.028674',6,'wk','2017-09-25 10:37:25.043516',b'010101001110111010101001101000101010',NULL,0.7,'00:00:00',2035,'kaz',''),
+ ('2022-11-11','2029-03-07 17:24:19.043489',122,'a','1980-01-01 00:00:00',b'0001100111011','z',0.0,'10:23:45.050733',2018,'a',''),
+ ('2004-03-12','1979-02-18 00:00:00',0,'zjeiwvd','1998-07-03 16:09:05.053954',b'0000110101111001001110100100111001111111100001110','',0.4,'07:43:46.015324',2028,'je',''),
+ ('2016-08-08','1986-03-10 00:00:00',3,'eiwv','2025-08-07 12:24:53.040869',b'010001101110100111111','iw',0.3,'02:48:45.058781',2020,'',''),
+ ('1979-02-25',NULL,2,'wvd','1980-01-01 00:00:00',b'010','vdm',0.1,'13:35:24.021296',1995,'dmd',''),
+ ('2012-04-19','2034-10-06 23:29:21.057367',9,'mdiv','2022-05-16 05:28:40.005808',b'110111111101000010011011001','divj',0.3,'11:24:50.017885',1997,'iv',''),
+ ('2009-10-13','1997-01-21 13:04:34.011524',1,'vjqs','1980-01-01 00:00:00',b'11110011100101011100001110110000101001100010000011110110011','j',0.7,'00:00:00',2008,'qsxmh',''),
+ ('2012-01-01','2011-06-23 06:11:33.014723',9,'r','2022-04-27 05:29:32.023395',b'1001011010101100100111','',0.5,'03:34:01.048002',1976,'sx',''),
+ ('2007-08-24','2012-01-24 22:16:53.014811',2,'fpp','2005-10-11 08:58:32.021273',b'011011111011',NULL,0.4,'18:11:17.036115',2026,'m',''),
+ (NULL,'1985-05-28 00:00:00',7,'hjw','2030-06-10 10:15:54.061818',b'0011110101001100011011000101010','',0.5,'02:03:21.020237',1994,'z',''),
+ ('2006-09-09','2002-11-10 06:16:27.008631',0,'jw','2030-07-16 00:00:00',b'11101110111101000010101110000010001110110001001101110100','wa',0.8,'00:00:00',1974,'',''),
+ ('1993-04-22','1980-01-01 00:00:00',3,'a','2020-02-06 08:11:00.051515',b'001110110010','gew',0.4,'11:59:05.013933',1998,NULL,''),
+ ('1985-11-05','2019-12-24 04:13:43.062741',7,'foo','1986-07-02 00:00:00',b'10100110001010100011111111101011011101001110010110101100110000','',0.5,'17:32:55.060182',1978,'w',''),
+ ('2007-02-20','2033-10-16 18:47:42.006517',1,'clc','1971-10-14 00:00:00',b'100001010','',0.1,'20:38:42.062598',2004,'lcfy',''),
+ ('1979-12-10','1972-08-04 00:00:00',8,'','2021-12-24 04:51:09.011443',b'011010010010010010011101000010110011110110110010100010','e',0.1,'23:08:10.014396',2026,'cfykywl',''),
+ ('2002-07-04',NULL,NULL,'fyky','1980-11-02 00:00:00',b'10000010111010000110','f',0.6,'13:07:14.014203',1979,'ykywl',''),
+ ('2019-02-15','2004-08-28 10:16:46.053753',8,'kywl','2004-12-01 00:00:00',b'010111010110001110110011000010110111011','ywlcne',0.2,'09:10:39.028897',2031,'wlcnemiuaab',''),
+ ('1989-05-15','1973-09-04 00:00:00',2,'lcne',NULL,b'100001100101110110000011110','',0.9,'19:22:16.015548',2013,'cnemiuaa',''),
+ ('2023-04-20','2018-12-04 04:19:46.040664',8,NULL,'1985-04-18 05:32:12.013509',b'111011011111100100000001','nem',0.1,'23:18:05.007794',2026,'emiua',''),
+ (NULL,'2024-08-10 03:52:31.047182',2,'miua','2035-09-03 06:07:22.008308',b'000111','',0.1,'03:58:02.003946',1988,'iua',''),
+ ('1977-09-01','1987-02-01 03:44:00.061840',5,'u','1997-11-27 04:02:13.014551',b'111110001001100101101000100010001011101000011',NULL,0.3,'00:00:00',1985,'aab',''),
+ (NULL,'1980-01-01 00:00:00',6,'a','1989-03-02 09:07:11.058643',b'10101001011110110010111010010100001010000110000110010',NULL,0.8,'17:41:15.057101',1975,'br',''),
+ ('1980-01-01','2019-02-10 20:56:51.063985',NULL,'rr','2000-02-28 01:38:27.004468',b'0101001011110001010001','rifnhu',0.5,'20:55:57.029281',1973,'if',''),
+ (NULL,'2019-04-15 02:13:03.019581',7,'fnhu','2000-03-25 18:48:46.063113',b'011000110','nhuu',0.0,'00:00:00',2030,'h',''),
+ ('1997-04-01',NULL,3,NULL,'1976-05-22 04:48:42.013754',b'101110101010000111101',NULL,0.1,'12:09:48.030076',2031,'u',''),
+ (NULL,'1993-10-10 15:11:03.021823',NULL,'ufzasunkrcpvasdqkxbwptigbpnesqigwegcnfeuvrgnecpthm','1986-06-12 04:29:01.017855',b'11110','fza',0.9,NULL,1994,'zasun',''),
+ ('1997-02-13','2001-04-08 02:01:53.018388',0,'as','1975-09-18 00:00:00',b'00111000101001001101001000100100010101110011010111000001011011','su',0.3,'15:15:31.011102',1972,'unk',''),
+ ('1975-07-26','2022-12-24 00:00:00',0,'foo','1986-01-22 21:27:38.024505',b'1111110000000001000010111','krc',0.9,'05:46:08.055789',1996,'rcp',''),
+ ('2000-08-04','1980-01-01 00:00:00',48,'foo','2015-12-21 17:04:06.008790',b'0100001110011001011101011101110110100010000101101100011010','g',0.7,'18:31:50.046211',2025,'pvasdq',''),
+ ('2001-03-26','2032-03-19 13:15:13.063368',NULL,'foo','2026-09-05 02:46:10.026919',b'11','a',0.3,'03:12:20.039599',2019,'sdqkx',''),
+ ('2035-01-14','1987-09-15 05:46:00.041527',4,'p','1980-01-01 00:00:00',b'1111100111','dqkxbwpt',0.0,'09:57:41.059145',1995,'q',''),
+ ('2035-07-13','2011-04-13 04:05:14.025091',212,'kxbw','1985-02-14 11:58:32.002055',b'1010100011110101011111111011010','x',0.2,'19:35:02.024655',1975,'bwptig',''),
+ ('2026-02-08','2015-05-04 09:31:22.017074',4,'wpt','2024-01-26 11:06:03.057899',b'011000010000100000011000011011000100101111001100000111011010','ptig',0.0,'00:00:00',1977,'tig',''),
+ ('1981-05-11',NULL,NULL,'foo','1981-12-09 10:10:34.008107',b'01000100100100110011111','gbp',0.0,'13:05:42.035253',2019,'bpn',''),
+ ('1977-05-16',NULL,9,'pne',NULL,b'001101100111001110110010111001110100','s',0.0,'15:09:37.063819',1998,'ne',''),
+ ('1980-01-01','2018-12-02 00:27:35.056455',2,'','1981-07-07 23:39:32.028644',b'0000101001010111010001101000','es',0.3,'15:43:30.016638',2013,NULL,''),
+ ('2027-09-05','1998-05-14 04:15:42.009728',1,'s','2015-07-16 00:00:00',b'01011101101010000110011010000111001000001000011','',0.6,'08:39:24.041879',2035,'qigweg',''),
+ ('2005-02-04',NULL,2,'i','1974-01-11 11:02:16.024653',b'01001101110001001101101010011001001101010010000','gw',0.6,'03:28:30.012172',1978,'weg',''),
+ (NULL,'1976-06-21 00:00:00',5,NULL,'2023-11-25 15:49:52.021725',b'101011010001100','e',0.1,'00:00:00',1977,'gcn',''),
+ ('1989-07-13',NULL,1,'c','1978-02-22 02:55:14.047104',b'01101010100001100110111011101000111011101101110011','f',0.8,NULL,1987,'nfeu',''),
+ ('2004-04-27','2019-06-28 08:04:35.039213',0,'f','1990-01-09 14:22:27.065127',b'00101001011','eu',0.0,'13:33:09.039791',2007,'uvrgne',''),
+ ('2008-09-08','1990-11-05 00:00:00',1,'w','2026-12-23 00:00:00',b'0001101','vrgnec',0.3,'19:13:14.037732',1983,'d',''),
+ ('2026-08-12','2026-11-23 11:18:35.012315',4,'rgnec','1988-09-06 07:11:55.057710',b'11010111001001101100100010110011100001000100001011000000000010','',0.9,NULL,1982,'gnecpth',''),
+ ('1992-12-03','2033-08-18 04:47:11.033829',65,'n','1989-11-21 17:42:13.012747',b'11011011110000000',NULL,0.9,'10:08:34.006377',1971,'ecpth',''),
+ ('1976-10-11','1975-05-18 00:00:00',3,'c','2017-11-06 03:33:38.002741',b'0111100010000111000111111100111100111000101100111111100','p',0.7,'03:28:07.039921',2014,'thmhf',''),
+ ('2014-04-19','2023-08-07 16:18:59.024013',0,'','2006-05-04 23:01:46.019351',b'0101101011011101101011101110000001001000110100101000011001110','h',0.5,'00:00:00',1995,'m',''),
+ ('1990-07-16','1980-01-01 00:00:00',8,'hffqbythjwpukqubzpomntrddrwhzjtqvb','1985-08-04 05:33:20.030471',b'001101111111100110101111000011100','ff',0.0,'00:00:00',2002,'fqbythj',''),
+ (NULL,'2019-01-12 00:00:00',0,NULL,'2009-01-25 00:00:00',b'100111111010000110010011100100000011101001010101111','qb',0.4,'20:35:33.059895',1981,'byt',''),
+ ('1991-10-07',NULL,2,'yt','2027-04-19 06:38:46.020191',b'001','t',0.4,'10:02:06.014126',2004,'h',''),
+ (NULL,'2009-07-05 00:00:00',241,'j','1981-06-26 12:35:20.061910',b'10101110001101001000011010010111000','wpukqu',0.5,'00:00:00',1973,'pukqu',''),
+ ('2001-05-26','2007-01-06 00:57:02.048605',0,'u',NULL,b'111100','k',0.7,'03:19:10.052988',2026,'q',NULL),
+ ('2008-03-15','1990-09-11 00:00:00',5,'ubz','1980-01-01 00:00:00',b'11010111011110001101111000000011000111101100111','b',0.5,'00:34:27.006616',2013,NULL,''),
+ ('1984-08-01','2000-09-20 09:35:47.025609',3,'zp','2016-11-22 19:38:52.053299',b'00000010','po',0.7,'19:47:19.014687',1996,'o',''),
+ ('1978-02-05','1978-05-08 04:30:57.023271',7,'foo','2000-04-06 08:42:13.019650',b'11000110111100101010001110111101111000001101','n',0.8,NULL,1980,'trdd',''),
+ ('2017-04-11','2002-09-26 12:59:43.051659',8,'rd','1972-03-27 13:09:07.017459',b'00011110001001001000000100110100101010','ddrwh',0.7,'00:00:00',2021,'drwhzj',''),
+ ('1980-01-01','1986-05-04 05:15:19.008418',0,'r','2005-10-04 09:21:09.020131',b'1101100010101001010011010001011101001111110010101111011','wh',0.0,'00:00:00',1975,'hzjtqv',''),
+ ('2035-12-12','1980-01-01 00:00:00',0,'x',NULL,b'0010000101010110111100000110000010001000100001000110111000010110','zjt',0.4,'15:51:12.040679',1984,'jtqvbji',''),
+ ('1993-05-12','2000-11-11 20:54:49.053753',0,'tqvb','2022-02-26 14:26:36.004981',b'110000101110000111011','qv',0.7,'00:00:00',1972,'v',''),
+ ('1971-08-22','2029-02-15 16:39:35.007278',2,NULL,'2033-09-22 08:28:19.057517',b'11111101011101110111100011011111001','bji',0.8,'08:34:37.000701',2000,'o',''),
+ (NULL,NULL,5,'foo','1982-02-24 00:00:00',b'00111111000111111111010111010111011101','iklce',0.8,'01:23:11.014485',2021,'klcek',''),
+ (NULL,NULL,8,'lce','1988-07-28 11:48:23.011427',b'101101000101010000000100000001011','',0.3,'17:15:34.034697',1991,'cekxqy',''),
+ ('2029-12-07','1993-12-24 00:45:29.060155',3,'ekx','1980-01-01 00:00:00',b'01001010110110000100100100111010110000000101001011111110001100','q',0.7,'10:39:47.004022',2006,'foo',''),
+ ('2015-10-20','1980-01-01 00:00:00',189,'xqy','2028-12-19 00:00:00',b'101001011011100101110010101000101110100110','qy',0.5,'15:16:59.059052',1993,'foo',''),
+ ('1998-08-07','2017-08-07 01:53:34.056737',5,'oxsolbx',NULL,b'1000111010110010110','xsolbxth',0.3,'22:56:09.003450',2014,'s',''),
+ ('2016-01-25','2000-09-14 22:35:41.048328',6,'foo','2004-10-11 00:00:00',b'001','olbxt',0.0,'14:15:54.033066',1983,'lbxt',''),
+ ('1979-09-02','2027-01-19 09:34:15.034597',4,'bxth','1989-10-23 09:11:09.055445',b'011011001110000011011011',NULL,0.8,'05:31:31.006489',1978,'xthdc',''),
+ ('1980-01-01',NULL,8,'th','2012-02-07 00:00:00',b'00101011001100111001101011010110','hdc',0.0,'22:09:17.054381',2013,'dcprs',''),
+ (NULL,'2018-08-03 17:37:14.049040',2,'cprswpj','1990-07-28 07:56:50.026324',b'0000010111011110100100010010011011010010001111011010000010011101','',0.1,NULL,1971,'prswpjx',''),
+ ('1984-05-07','2012-05-07 00:00:00',1,'rswp','2030-05-09 07:42:25.003848',b'1001','swp',0.4,'13:27:32.040813',1997,'wpj',''),
+ (NULL,'2030-03-22 14:03:46.000742',7,'pjxixm','2022-05-11 00:00:00',b'00111110011001010010001111010001111110010010000111','j',0.8,'00:00:00',1996,'x',NULL),
+ ('2000-12-03','2020-08-13 16:03:09.041436',8,'ix','1985-05-19 11:28:09.002728',b'11011010000101000110111111010111','xmvfwm',0.9,'19:06:00.002417',1976,'m',''),
+ ('1990-03-13','2035-09-08 21:29:04.011731',5,'vfwmsys','2029-11-03 04:28:54.058532',b'0110001011001010100','fw',0.6,'20:30:32.032224',1994,'wmsys',''),
+ ('2035-06-04','2027-06-07 11:27:21.038934',8,'ms','1987-09-02 00:00:00',b'001101101101111110010110110011','syse',0.1,'01:10:53.060943',2027,'yse',''),
+ (NULL,'1993-06-06 07:29:56.029103',NULL,'','1971-06-08 23:51:55.054403',b'11001110001111111001001010101110111011000100111010','se',0.2,'10:24:53.013058',1995,'eb',''),
+ ('2018-06-12','2020-08-06 23:47:35.060301',5,NULL,NULL,b'110011110111010111','blwc',0.6,NULL,1971,'lwc',''),
+ ('2005-02-03','2016-10-11 00:00:00',0,'w','2005-03-25 00:00:00',b'0101001001001','',0.2,'21:56:26.025743',1971,'c',''),
+ ('2025-10-10',NULL,1,'vumvyv','2034-05-06 18:17:26.004829',b'10110101101100100001000011001111100100111101100','um',0.3,'19:42:29.005509',1992,'m',''),
+ ('2014-01-27','1980-01-01 00:00:00',2,'vyvb','1975-04-08 10:13:06.052060',b'111011110111111010011111011011101111','yv',0.4,'15:13:32.059509',2011,NULL,''),
+ ('2016-08-04','2008-12-03 01:55:41.030042',6,'vb','1993-09-08 00:01:40.016566',b'000101110101100111001101010110','b',0.5,'08:39:05.055786',1993,'it',''),
+ ('1980-01-01','1980-01-01 00:00:00',9,'tx','1991-07-19 05:37:43.056696',b'110110111010111101010001100010111100110011111010100100100','k',0.9,'00:00:00',1999,'h',''),
+ (NULL,'2007-06-14 15:47:29.017306',9,'foo',NULL,b'0100111000001011111000111010000011011000011000101010','qjxdzd',0.3,'13:52:31.035851',2001,'jxdzd',''),
+ (NULL,'2022-04-28 18:27:19.060240',4,'foo','2018-02-28 02:49:16.013066',b'10000100000000110011011110101110100001100011101110011011100','d',0.0,'15:01:48.022368',1987,'zdytun',''),
+ ('1987-10-10','1975-06-02 02:47:57.012240',9,'dy','1980-06-10 00:00:00',b'110000111','',0.7,'08:13:44.003967',1981,'',''),
+ ('2015-09-28',NULL,4,'d','2005-08-09 08:35:04.039832',b'00','b',0.1,'00:47:43.048164',1973,'yt',''),
+ ('2030-01-18','2011-12-09 00:00:00',6,NULL,'1982-05-13 00:00:00',b'111110100001000010001110110010111100001011010','v',0.2,'00:39:24.001557',2027,'tun',''),
+ ('1980-06-28','2016-04-07 00:00:00',8,'y','1980-01-01 00:00:00',b'01011100100001010110101110111110110','unq',0.7,'00:00:00',2016,'foo',''),
+ ('2018-09-16','1975-01-03 00:00:00',NULL,'qv','2028-05-10 00:00:00',b'0001100101001011100110','vv',0.0,'23:54:42.064230',2000,'vr',''),
+ ('2033-12-11','2021-07-23 12:20:17.025201',3,'rm','1996-07-16 00:00:00',b'1011001110','mpyx',0.7,'04:04:01.055956',2009,'pyx',''),
+ ('1982-12-18','1996-09-16 00:00:00',9,'yx','2003-10-14 03:54:44.012072',b'11001011011000001111011000101111101110100101','x',0.9,NULL,1981,'rencqh',''),
+ ('1980-01-01','2009-01-17 12:11:34.030449',7,'encqh','1980-01-01 00:00:00',b'1101001101001000101010001100100100','ncq',0.4,'23:44:22.012217',2030,'b',''),
+ ('2015-05-03','1987-03-19 17:37:53.053429',6,'','2012-08-03 00:00:00',b'0','cq',0.0,'17:16:43.030750',2035,'qh',NULL),
+ (NULL,'1980-01-01 00:00:00',1,'huyr','2012-02-11 14:15:13.004778',b'110011001100010100001101011001011110010000011001110101','',0.7,'09:33:00.034425',2024,'uyr',''),
+ ('2019-06-05','2020-08-05 23:53:07.028129',1,'yr',NULL,b'1001011110101010001111101000011001011111100','rflu',0.3,NULL,2016,'fluezqe',''),
+ ('1980-01-10','2025-05-12 08:22:39.039097',1,'lu','1975-07-24 00:00:00',b'10100111001111101001110000110011','',0.1,'23:58:28.031575',2005,NULL,''),
+ ('2008-03-17','1982-05-27 11:44:53.038339',NULL,'uezqe','2024-10-12 02:16:04.063095',b'1001010110101101000101011011000011','e',0.9,'19:37:29.063243',1987,'zqekmq','')
+;
+--enable_query_log
+--disable_warnings
+SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
+ALTER TABLE t1 ADD INDEX(col_enum,vcol_int);
+SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
+ALTER TABLE t1 ADD INDEX(col_year);
+--enable_warnings
+DROP TABLE t1;
+
+#
+# MDEV-11750 Assertion `vfield' failed in TABLE::update_virtual_fields after crash recovery on corrupted MyISAM table
+#
+create table t1 (
+ pk int primary key auto_increment,
+ b bit default null,
+ key(b)
+) engine=myisam;
+
+insert into t1 values (null, 0);
+repair table t1 extended;
+drop table t1;
+
+#
+# MDEV-18486 Database crash on a table with indexed virtual column
+#
+create table t1 ( id int primary key,
+ hexid varchar(10) generated always as (hex(id)) stored,
+ key (hexid)) engine=myisam;
+insert into t1 (id) select 100;
+select * from t1;
+drop table t1;
+
+
+--echo #
+--echo # MDEV-15881 Assertion `is_valid_value_slow()' failed in Datetime::Datetime or corrupt data after ALTER with indexed persistent column
+--echo #
+
+CREATE TABLE t1 (i INT, d1 DATE, d2 DATE NOT NULL, t TIMESTAMP, KEY(t)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,'2023-03-16','2023-03-15','2012-12-12 12:12:12');
+ALTER TABLE t1 MODIFY t FLOAT AS (i) PERSISTENT;
+--disable_ps2_protocol
+SELECT i, d1, d2 INTO OUTFILE 'load_t1' FROM t1;
+--enable_ps2_protocol
+DELETE FROM t1;
+LOAD DATA INFILE 'load_t1' INTO TABLE t1 (i,d1,d2);
+SELECT * FROM t1 WHERE d2 < d1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ i INT DEFAULT NULL,
+ d1 DATE DEFAULT NULL,
+ d2 DATE NOT NULL,
+ t FLOAT GENERATED ALWAYS AS (i) STORED,
+ KEY (t)
+) ENGINE=MyISAM;
+LOAD DATA INFILE 'load_t1' INTO TABLE t1 (i,d1,d2);
+SELECT * FROM t1 WHERE d2 < d1;
+DROP TABLE t1;
+# Cleanup
+--let $datadir= `SELECT @@datadir`
+--remove_file $datadir/test/load_t1
+
+
+--echo #
+--echo # MDEV-20015 Assertion `!in_use->is_error()' failed in TABLE::update_virtual_field
+--echo #
+create or replace table t1 (a int);
+insert into t1 (a) values (1), (1);
+create or replace table t2 (pk int, b int, c int as (b) virtual, primary key (pk), key(c));
+--error ER_DUP_ENTRY
+insert into t2 (pk) select a from t1;
+drop tables t1, t2;
diff --git a/mysql-test/suite/vcol/t/vcol_memory.test b/mysql-test/suite/vcol/t/vcol_memory.test
new file mode 100644
index 00000000..b78850ed
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_memory.test
@@ -0,0 +1,48 @@
+################################################################################
+# t/vcol_memory.test #
+# #
+# Purpose: #
+# MEMORY branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-02 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+SET @@session.default_storage_engine = 'memory';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+--source suite/vcol/inc/vcol_unsupported_storage_engines.inc
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_merge.test b/mysql-test/suite/vcol/t/vcol_merge.test
new file mode 100644
index 00000000..ee1511ee
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_merge.test
@@ -0,0 +1,57 @@
+################################################################################
+# t/vcol_merge.test #
+# #
+# Purpose: #
+# MERGE branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-03 #
+# Change Author: Oleksandr Byelkin (Monty program Ab)
+# Date: 2009-03-24
+# Change: Syntax changed
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+--disable_warnings
+drop table if exists t1, t2, t3;
+--enable_warnings
+
+create table t1 (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 t2 values (2,default);
+--error ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS
+create table t3 (a int, b int as (a % 10)) engine=MERGE UNION=(t1,t2);
+drop table t1,t2;
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_misc.opt b/mysql-test/suite/vcol/t/vcol_misc.opt
new file mode 100644
index 00000000..fd1faea4
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_misc.opt
@@ -0,0 +1 @@
+--character-sets-dir=$MYSQL_TEST_DIR/std_data/ldml/
diff --git a/mysql-test/suite/vcol/t/vcol_misc.test b/mysql-test/suite/vcol/t/vcol_misc.test
new file mode 100644
index 00000000..83a06e83
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_misc.test
@@ -0,0 +1,543 @@
+--source include/have_ucs2.inc
+--source include/have_debug.inc
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+
+#
+# Bug#601164: DELETE/UPDATE with ORDER BY index and LIMIT
+#
+
+create table t1 (a int, b int, v int as (a+1), index idx(b));
+insert into t1(a, b) values
+ (4, 40), (3, 30), (5, 50), (7, 70), (8, 80), (2, 20), (1, 10);
+
+select * from t1 order by b;
+
+delete from t1 where v > 6 order by b limit 1;
+select * from t1 order by b;
+
+update t1 set a=v order by b limit 1;
+select * from t1 order by b;
+
+drop table t1;
+
+#
+# Bug#604549: Expression for virtual column returns row
+#
+
+-- error ER_OPERAND_COLUMNS
+CREATE TABLE t1 (
+ a int NOT NULL DEFAULT '0',
+ v double AS ((1, a)) VIRTUAL
+);
+
+#
+# Bug#603654: Virtual column in ORDER BY, no other references of table columns
+#
+
+CREATE TABLE t1 (
+ a CHAR(255) BINARY NOT NULL DEFAULT 0,
+ b CHAR(255) BINARY NOT NULL DEFAULT 0,
+ v CHAR(255) BINARY AS (CONCAT(a,b)) VIRTUAL );
+INSERT INTO t1(a,b) VALUES ('4','7'), ('4','6');
+SELECT 1 AS C FROM t1 ORDER BY v;
+
+DROP TABLE t1;
+
+#
+# Bug#603186: Insert into a table with stored vurtual columns
+#
+
+CREATE TABLE t1(a int, b int DEFAULT 0, v INT AS (b+10) PERSISTENT);
+INSERT INTO t1(a) VALUES (1);
+SELECT b, v FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1(a int DEFAULT 100, v int AS (a+1) PERSISTENT);
+INSERT INTO t1 () VALUES ();
+CREATE TABLE t2(a int DEFAULT 100 , v int AS (a+1));
+INSERT INTO t2 () VALUES ();
+
+SELECT a, v FROM t1;
+SELECT a, v FROM t2;
+
+DROP TABLE t1,t2;
+
+#
+# Bug#604503: Virtual column expression with datetime comparison
+#
+
+CREATE TABLE t1 (
+ a datetime NOT NULL DEFAULT '2000-01-01',
+ v boolean AS (a < '2001-01-01')
+);
+INSERT INTO t1(a) VALUES ('2002-02-15');
+INSERT INTO t1(a) VALUES ('2000-10-15');
+
+SELECT a, v FROM t1;
+SELECT a, v FROM t1;
+
+CREATE TABLE t2 (
+ a datetime NOT NULL DEFAULT '2000-01-01',
+ v boolean AS (a < '2001-01-01') PERSISTENT
+);
+INSERT INTO t2(a) VALUES ('2002-02-15');
+INSERT INTO t2(a) VALUES ('2000-10-15');
+
+SELECT * FROM t2;
+
+DROP TABLE t1, t2;
+
+#
+# Bug#607566: Virtual column in the select list of SELECT with ORDER BY
+#
+
+CREATE TABLE t1 (
+ a char(255), b char(255), c char(255), d char(255),
+ v char(255) AS (CONCAT(c,d) ) VIRTUAL
+);
+
+INSERT INTO t1(a,b,c,d) VALUES ('w','x','y','z'), ('W','X','Y','Z');
+
+SELECT v FROM t1 ORDER BY CONCAT(a,b);
+
+DROP TABLE t1;
+
+#
+# Bug#607168: CREATE TABLE AS SELECT that returns virtual columns
+#
+
+CREATE TABLE t1 (f1 INTEGER, v1 INTEGER AS (f1) VIRTUAL);
+CREATE TABLE t2 AS SELECT v1 FROM t1;
+SHOW CREATE TABLE t2;
+
+DROP TABLE t1,t2;
+
+#
+# Bug#607177: ROUND function in the expression for a virtual function
+#
+
+CREATE TABLE t1 (p int, a double NOT NULL, v double AS (ROUND(a,p)) VIRTUAL);
+INSERT IGNORE INTO t1 VALUES (0,1,0);
+INSERT IGNORE INTO t1 VALUES (NULL,0,0);
+SELECT a, p, v, ROUND(a,p), ROUND(a,p+NULL) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (p int, a double NOT NULL);
+INSERT INTO t1(p,a) VALUES (0,1);
+INSERT INTO t1(p,a) VALUES (NULL,0);
+SELECT a, p, ROUND(a,p), ROUND(a,p+NULL) FROM t1;
+DROP TABLE t1;
+
+#
+# Bug#610890: SHOW CREATE TABLE with a virtual column
+#
+
+CREATE TABLE t1 (a char(32), v char(32) CHARACTER SET ucs2 AS (a) VIRTUAL);
+
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+#
+# Bug#930814: no info in information schema for tables with virtual columns
+#
+
+CREATE TABLE t1 (a int, b int);
+CREATE TABLE t2 (a int, b int as (a+1) VIRTUAL);
+
+SELECT table_schema, table_name, column_name, column_type, extra
+ FROM information_schema.columns WHERE table_name = 't1';
+SELECT table_schema, table_name, column_name, column_type, extra
+ FROM information_schema.columns WHERE table_name = 't2';
+
+DROP TABLE t1,t2;
+
+#
+# Bug mdev-354: virtual columns of ENUM and SET types
+#
+
+create table t1 (
+ a int not null, b char(2) not null,
+ c enum('Y','N') as (case when b = 'aa' then 'Y' else 'N' end) persistent
+);
+show create table t1;
+insert into t1(a,b) values (1,'bb'), (2,'aa'), (3,'cc');
+select * from t1;
+
+create table t2 (
+ a int, b int,
+ c set("y","n")
+ as (if(a=0,if(b=0,('n,n'),('n,y')),if(b=0,('y,n'),('y,y')))) persistent
+);
+show create table t2;
+insert into t2(a,b) values (7,0), (2,3), (0,1);
+select * from t2;
+
+drop table t1,t2;
+
+#
+# Bug mdev-3938: INSERT DELAYED for a table with virtual columns
+#
+
+SET @old_debug= @@global.debug;
+SET @old_debug= @@global.debug;
+SET GLOBAL debug_dbug= "+d,write_delay_wakeup";
+CREATE TABLE t1 (a int,
+ ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ tsv TIMESTAMP AS (ADDDATE(ts, INTERVAL 1 DAY)) VIRTUAL
+) ENGINE=MyISAM;
+
+--echo # First test FLUSH TABLES
+INSERT INTO t1 (a,tsv) VALUES (1,DEFAULT);
+INSERT DELAYED INTO t1 (a,tsv) VALUES (2,DEFAULT);
+FLUSH TABLES;
+# Count may be 1 or 2, depending on FLUSH happened before or after delayed
+SELECT COUNT(*) > 0 FROM t1;
+
+--echo # Then test FLUSH TABLES t1;
+INSERT INTO t1 (a,tsv) VALUES (3,DEFAULT);
+INSERT DELAYED INTO t1 (a,tsv) VALUES (4,DEFAULT);
+FLUSH TABLES t1;
+SELECT COUNT(*) FROM t1;
+
+--echo # Then test FLUSH TABLES WITH READ LOCK;
+
+INSERT INTO t1 (a,tsv) VALUES (5,DEFAULT);
+INSERT DELAYED INTO t1 (a,tsv) VALUES (6,DEFAULT);
+FLUSH TABLES WITH READ LOCK;
+SELECT COUNT(*) FROM t1;
+set GLOBAL debug_dbug= @old_debug;
+unlock tables;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-4823 Server crashes in Item_func_not::fix_fields on
+--echo # creating a table with a virtual column using NOT
+--echo #
+CREATE TABLE t1 ( f1 INT, v4 INT AS ( NOT f1 ) VIRTUAL );
+drop table t1;
+
+--echo # end of 5.2 tests
+
+#
+# SELECT that uses a virtual column and executed with BKA
+#
+
+create table t1 (a int, b int);
+insert into t1 values (3, 30), (4, 20), (1, 20);
+create table t2 (c int, d int, v int as (d+1), index idx(c));
+insert into t2(c,d) values
+ (20, 100), (20, 300), (30, 100), (30, 200), (40, 500),
+ (70, 100), (40, 300), (60, 100), (40, 100), (70, 100);
+insert into t2(c,d) values
+ (120, 100), (150, 300), (130, 100), (130, 200), (140, 500),
+ (170, 100), (180, 300), (160, 100), (40, 100), (170, 100);
+
+set join_cache_level=6;
+explain
+select * from t1,t2 where t1.b=t2.c and d <= 100;
+
+select * from t1,t2 where t1.b=t2.c and d <= 100;
+set join_cache_level=default;
+
+drop table t1, t2;
+
+#
+# Test crashes when using convert_const_item()
+#
+create table t1 (a bigint, b bigint as (a > '2'));
+show create table t1;
+insert into t1 (a) values (1),(3);
+select * from t1;
+select * from t1;
+drop table t1;
+create table t1 (a bigint, b bigint as (a between 0 and 2));
+show create table t1;
+insert into t1 (a) values (1),(3);
+select * from t1;
+select * from t1;
+drop table t1;
+create table t1 (a char(10), b char(10) as (a between 0 and 2));
+show create table t1;
+insert into t1 (a) values (1),(3);
+select * from t1;
+select * from t1;
+drop table t1;
+
+#
+# Test output of show columns
+#
+
+CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` varchar(32) DEFAULT NULL,
+ `c` int(11) AS (a MOD 10) VIRTUAL,
+ `d` varchar(5) AS (LEFT(b,5)) PERSISTENT
+) ENGINE=MyISAM;
+show create table t1;
+show columns from t1;
+--replace_column 8 #
+show full columns from t1;
+INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,NULL);
+UPDATE IGNORE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a';
+INSERT IGNORE INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a');
+set sql_mode='strict_all_tables';
+--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';
+--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
+INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a');
+drop table t1;
+
+--echo #
+--echo # MDEV-5611: self-referencing virtual column
+--echo #
+
+--error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD
+create table t1 (a int, b int as (b is null) virtual);
+
+create table t1 (a int as (1+1), b int as (a is null) virtual);
+drop table t1;
+
+--echo # end of 5.3 tests
+
+#
+# MDEV-7655 SHOW CREATE TABLE returns invalid DDL when using virtual columns along with a table collation
+#
+create table t1 (v1 varchar(255) as (c1) persistent, c1 varchar(50)) collate=latin1_general_ci;
+show create table t1;
+drop table t1;
+
+#
+# MDEV-11527 Virtual columns do not get along well with NO_ZERO_DATE
+#
+set sql_mode='no_zero_date';
+create table t1 (
+ ts timestamp not null default current_timestamp,
+ tsv timestamp as (adddate(ts, interval 1 day)) virtual
+);
+drop table t1;
+set sql_mode=default;
+
+--echo #
+--echo # MDEV-11819 NO_ZERO_IN_DATE: Incorrect generated column value
+--echo #
+
+SET sql_mode='NO_ZERO_IN_DATE';
+CREATE TABLE t1
+(
+ a datetime DEFAULT NULL,
+ b datetime DEFAULT NULL,
+ c time GENERATED ALWAYS AS (timediff(`a`,`b`)) VIRTUAL
+);
+INSERT INTO t1 VALUES ('2008-12-31 23:59:59.000001','2008-12-30 01:01:01.000002',DEFAULT);
+SELECT * FROM t1;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+
+--echo #
+--echo # MDEV-15834 The code in TABLE_SHARE::init_from_binary_frm_image() is not safe
+--echo #
+
+--copy_file std_data/frm/t1.frm $MYSQLD_DATADIR/test/t1.frm
+SHOW TABLES;
+--replace_result $MYSQLD_DATADIR ./
+--error ER_NOT_FORM_FILE
+SHOW CREATE TABLE t1;
+--replace_result $MYSQLD_DATADIR ./
+--error ER_NOT_FORM_FILE
+ALTER TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.frm
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
+
+--echo #
+--echo # End of 10.0 tests
+--echo #
+
+--echo #
+--echo # MDEV-8441 Bad SHOW CREATE TABLE output for a table with a virtual column
+--echo #
+CREATE TABLE t1 (a DATETIME, b TIMESTAMP AS (TIMESTAMP(a)));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+# Make sure that if the first TIMESTAMP column appears to be virtual,
+# then no further promotion is done, so the next TIMESTAMP column "c" does not
+# get the "DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" attributes.
+CREATE TABLE t1 (a DATETIME, b TIMESTAMP AS (TIMESTAMP(a)),c TIMESTAMP);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-8839 COLUMN_GET() produces warnings with no data
+--echo #
+SET @aaa= COLUMN_CREATE('price', _binary 0xF0F1F2F3F4F5F6F7);
+SELECT COLUMN_GET(@aaa, 'price' AS DECIMAL) aaa;
+SELECT COLUMN_GET(@aaa, 'price' AS INT) aaa;
+SELECT COLUMN_GET(@aaa, 'price' AS DOUBLE) aaa;
+
+
+--echo #
+--echo # MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column
+--echo #
+
+SET sql_mode=STRICT_ALL_TABLES;
+CREATE OR REPLACE TABLE t1 (
+ a INT NOT NULL DEFAULT 10,
+ b INT AS (a+1) VIRTUAL
+) ENGINE=MyISAM;
+
+# Testing with a column list
+
+--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
+INSERT INTO t1 (b) VALUES (10);
+--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
+INSERT INTO t1 (b) VALUES (DEFAULT(a));
+INSERT INTO t1 (b) VALUES (DEFAULT);
+
+# Testing without a column list
+--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
+INSERT INTO t1 VALUES (10,10);
+--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
+INSERT INTO t1 VALUES (10,DEFAULT(a));
+INSERT INTO t1 VALUES (10, DEFAULT);
+
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+
+--echo #
+--echo # End of 10.1 tests
+--echo #
+
+--echo #
+--echo # MDEV-16518 MYSQL57_GENERATED_FIELD: The code in TABLE_SHARE::init_from_binary_frm_image() is not safe
+--echo #
+
+--copy_file std_data/frm/mdev16518.frm $MYSQLD_DATADIR/test/t1.frm
+SHOW TABLES;
+--replace_result $MYSQLD_DATADIR ./
+--error ER_NOT_FORM_FILE
+SHOW CREATE TABLE t1;
+--replace_result $MYSQLD_DATADIR ./
+--error ER_NOT_FORM_FILE
+ALTER TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.frm
+
+--echo #
+--echo # MDEV-19771 REPLACE on table with virtual_field can cause crash in set_ok_status()
+--echo
+
+create or replace table t1 (pk int primary key, col_bit bit(15) default null,
+ vcol_bit bit(10) GENERATED ALWAYS AS (`col_bit`) VIRTUAL);
+replace INTO `t1` (`pk`,col_bit) VALUES (99,1000);
+select pk, col_bit+0, vcol_bit+0 from t1;
+replace INTO `t1` (`pk`,col_bit) VALUES (99,10000);
+select pk, col_bit+0, vcol_bit+0 from t1;
+--error ER_DATA_TOO_LONG
+REPLACE LOW_PRIORITY INTO `t1` (`pk`) VALUES (99);
+drop table t1;
+
+--echo #
+--echo # MDEV-17837 REPLACE on table with virtual_field can cause crash in set_ok_status()
+--echo #
+
+SET @old_sql_mode=@@sql_mode;
+SET sql_mode= STRICT_ALL_TABLES;
+
+CREATE TABLE t1 (
+ pk INT,
+ i TINYINT,
+ vi TINYINT AS (i+1) PERSISTENT,
+ PRIMARY KEY(pk)
+);
+
+INSERT INTO t1 (pk,i) VALUES (1,1);
+TRUNCATE TABLE t1;
+INSERT IGNORE INTO t1 (pk,i) VALUES (1,127);
+--error ER_WARN_DATA_OUT_OF_RANGE
+REPLACE INTO t1 (pk,i) VALUES (1,2);
+DROP TABLE t1;
+SET @sql_mode=@old_sql_mode;
+
+--echo #
+--echo # MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column
+--echo # 10.2+ specific part
+--echo #
+
+SET sql_mode=STRICT_ALL_TABLES;
+CREATE OR REPLACE TABLE t1 (
+ a INT NOT NULL DEFAULT 10,
+ b INT AS (a+1) VIRTUAL
+) ENGINE=MyISAM;
+
+# Testing with column list
+
+EXECUTE IMMEDIATE 'INSERT INTO t1 (b) VALUES(?)' USING DEFAULT;
+EXECUTE IMMEDIATE 'INSERT INTO t1 (b) VALUES(?)' USING IGNORE;
+INSERT INTO t1 (b) VALUES (DEFAULT);
+INSERT INTO t1 (b) VALUES (IGNORE);
+SELECT * FROM t1;
+DELETE FROM t1;
+
+# Testing without column list
+
+EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES(10,?)' USING DEFAULT;
+EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES(11,?)' USING IGNORE;
+INSERT INTO t1 VALUES (12,DEFAULT);
+INSERT INTO t1 VALUES (13,IGNORE);
+SELECT * FROM t1;
+
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+--echo #
+--echo # CONTEXT_ANALYSIS_ONLY_VCOL_EXPR
+--echo #
+
+--source include/have_ucs2.inc
+call mtr.add_suppression("Charset id.*trying to replace");
+create table t1 (c1 char(1) character set ucs2 collate ucs2_test_ci,
+ v1 char(1) character set ucs2 collate ucs2_test_ci as (c1),
+ v2 int as (c1 = 'b'),
+ v3 int as (v1 = 'b'));
+insert into t1 (c1) values ('a');
+select * from t1 where v1 = 'b';
+show create table t1;
+drop table t1;
+
+--echo #
+--echo # End of 10.2 tests
+--echo #
+
+--echo #
+--echo # RAND is session func
+--echo #
+create table t1 (a int, b float default rand(1));
+insert into t1 (a) values (1);
+insert into t1 (a) values (2);
+insert into t1 (a) values (3);
+select * from t1;
+drop table t1;
+
+--echo #
+--echo # End of 10.3 tests
+--echo #
+
+--echo #
+--echo # MDEV-31112 vcol circular references lead to stack overflow
+--echo #
+create table t (a int, c int as (a));
+alter table t alter column c drop default;
+--error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD
+alter table t modify column a int as (c) stored;
+drop table t;
+
+--echo #
+--echo # End of 10.4 tests
+--echo #
diff --git a/mysql-test/suite/vcol/t/vcol_non_stored_columns_innodb.test b/mysql-test/suite/vcol/t/vcol_non_stored_columns_innodb.test
new file mode 100644
index 00000000..8f7a4671
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_non_stored_columns_innodb.test
@@ -0,0 +1,53 @@
+################################################################################
+# t/vcol_non_stored_columns_innodb.test #
+# #
+# Purpose: #
+# Ensure that MySQL behaviour is consistent irrelevant of #
+# - the place of a non-stored column among other columns, #
+# - the total number of non-stored fields. #
+# #
+# InnoDB branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+--source include/have_innodb.inc
+eval SET @@session.default_storage_engine = 'InnoDB';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_non_stored_columns.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_non_stored_columns_myisam.test b/mysql-test/suite/vcol/t/vcol_non_stored_columns_myisam.test
new file mode 100644
index 00000000..74c11ba8
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_non_stored_columns_myisam.test
@@ -0,0 +1,52 @@
+################################################################################
+# t/vcol_non_stored_columns_myisam.test #
+# #
+# Purpose: #
+# Ensure that MySQL behaviour is consistent irrelevant of #
+# - the place of a non-stored column among other columns, #
+# - the total number of non-stored fields. #
+# #
+# MyISAM branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+eval SET @@session.default_storage_engine = 'MyISAM';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_non_stored_columns.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_partition_innodb.test b/mysql-test/suite/vcol/t/vcol_partition_innodb.test
new file mode 100644
index 00000000..7b8e8de2
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_partition_innodb.test
@@ -0,0 +1,51 @@
+################################################################################
+# t/vcol_partition_innodb.test #
+# #
+# Purpose: #
+# Testing partitioning tables with virtual columns. #
+# #
+# InnoDB branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+--source include/have_innodb.inc
+eval SET @@session.default_storage_engine = 'InnoDB';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source inc/vcol_partition.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_partition_myisam.test b/mysql-test/suite/vcol/t/vcol_partition_myisam.test
new file mode 100644
index 00000000..b41a2482
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_partition_myisam.test
@@ -0,0 +1,51 @@
+################################################################################
+# t/vcol_partition_myisam.test #
+# #
+# Purpose: #
+# Testing partitioning tables with virtual columns. #
+# #
+# MyISAM branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+--source include/have_partition.inc
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+eval SET @@session.default_storage_engine = 'MyISAM';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_partition.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_select_innodb.test b/mysql-test/suite/vcol/t/vcol_select_innodb.test
new file mode 100644
index 00000000..5b04096a
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_select_innodb.test
@@ -0,0 +1,56 @@
+################################################################################
+# t/vcol_select_innodb.test #
+# #
+# Purpose: #
+# Testing different SELECTs. #
+# #
+# InnoDB branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-18 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source include/default_optimizer_switch.inc
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+--source include/have_innodb.inc
+eval SET @@session.default_storage_engine = 'InnoDB';
+SET @save_stats_persistent=@@GLOBAL.innodb_stats_persistent;
+SET GLOBAL innodb_stats_persistent=0;
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_select.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+SET GLOBAL innodb_stats_persistent=@save_stats_persistent;
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_select_myisam.test b/mysql-test/suite/vcol/t/vcol_select_myisam.test
new file mode 100644
index 00000000..1e1adf29
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_select_myisam.test
@@ -0,0 +1,132 @@
+###############################################################################
+# t/vcol_select.test #
+# #
+# Purpose: #
+# Testing different SELECTs. #
+# #
+# MyISAM branch #
+# #
+#-----------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-18 #
+# Change Author: #
+# Change Date: #
+# Change: #
+###############################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#-----------------------------------------------------------------------------#
+# Cleanup
+--source include/default_optimizer_switch.inc
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#-----------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#-----------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+eval SET @@session.default_storage_engine = 'MyISAM';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#-----------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_select.inc
+
+#-----------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#-----------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+--echo #
+--echo # Bug #806057: join with USING over a virtual column
+--echo #
+
+CREATE TABLE t1 (b int);
+INSERT INTO t1 VALUES (NULL),( 78), (185), (0), (154);
+
+CREATE TABLE t2 (a int, b int AS (a) VIRTUAL);
+INSERT IGNORE INTO t2 VALUES (187,187), (9,9), (187,187);
+
+EXPLAIN EXTENDED
+SELECT * FROM t1 JOIN t2 USING (b);
+SELECT * FROM t1 JOIN t2 USING (b);
+
+EXPLAIN EXTENDED
+SELECT * FROM t1 NATURAL JOIN t2;
+SELECT * FROM t1 NATURAL JOIN t2;
+
+DROP TABLE t1,t2;
+
+#
+# MDEV-11525 Assertion `cp + len <= buff + buff_size' failed in JOIN_CACHE::write_record_data
+#
+
+create table t1 (
+ pk integer auto_increment,
+ bi integer not null,
+ vi integer generated always as (bi) persistent,
+ bc varchar(1) not null,
+ vc varchar(2) generated always as (concat(bc, bc)) persistent,
+ primary key (pk),
+ key (vi, vc));
+insert t1 (bi, bc) values (0, 'x'), (0, 'n'), (1, 'w'), (7, 's'), (0, 'a'), (4, 'd'), (1, 'w'), (1, 'j'), (1, 'm'), (4, 'k'), (7, 't'), (4, 'k'), (2, 'e'), (0, 'i'), (1, 't'), (6, 'z'), (3, 'c'), (6, 'i'), (8, 'v');
+create table t2 (
+ pk integer auto_increment,
+ bi integer not null,
+ vi integer generated always as (bi) persistent,
+ bc varchar(257) not null,
+ vc varchar(2) generated always as (concat(bc, bc)) persistent,
+ primary key (pk),
+ key (vi, vc));
+insert t2 (bi, bc) values (1, 'c'), (8, 'm'), (9, 'd'), (6, 'y'), (1, 't'), (6, 'd'), (2, 's'), (4, 'r'), (8, 'm'), (4, 'b'), (4, 'x'), (7, 'g'), (4, 'p'), (1, 'q'), (9, 'w'), (4, 'd'), (8, 'e'), (4, 'b'), (8, 'y');
+explain # should be using join buffer
+select t2.vi from (t2 as t3 right join (t2 left join t1 on (t1.bi = t2.vi)) on (t1.vc = t2.vc));
+--sorted_result
+select t2.vi from (t2 as t3 right join (t2 left join t1 on (t1.bi = t2.vi)) on (t1.vc = t2.vc));
+drop table t2,t1;
+
+#
+# End of 5.5 tests
+#
+
+#
+# MDEV-11640 gcol.gcol_select_myisam fails in buildbot on Power
+# (same as MDEV-11525 above, but for virtual columns)
+#
+
+create table t1 (
+ pk integer auto_increment,
+ bi integer not null,
+ vi integer generated always as (bi) virtual,
+ bc varchar(1) not null,
+ vc varchar(2) generated always as (concat(bc, bc)),
+ primary key (pk),
+ key (vi, vc));
+insert t1 (bi, bc) values (0, 'x'), (0, 'n'), (1, 'w'), (7, 's'), (0, 'a'), (4, 'd'), (1, 'w'), (1, 'j'), (1, 'm'), (4, 'k'), (7, 't'), (4, 'k'), (2, 'e'), (0, 'i'), (1, 't'), (6, 'z'), (3, 'c'), (6, 'i'), (8, 'v');
+create table t2 (
+ pk integer auto_increment,
+ bi integer not null,
+ vi integer generated always as (bi) virtual,
+ bc varchar(257) not null,
+ vc varchar(2) generated always as (concat(bc, bc)),
+ primary key (pk),
+ key (vi, vc));
+insert t2 (bi, bc) values (1, 'c'), (8, 'm'), (9, 'd'), (6, 'y'), (1, 't'), (6, 'd'), (2, 's'), (4, 'r'), (8, 'm'), (4, 'b'), (4, 'x'), (7, 'g'), (4, 'p'), (1, 'q'), (9, 'w'), (4, 'd'), (8, 'e'), (4, 'b'), (8, 'y');
+explain # should be using join buffer
+select t2.vi from (t2 as t3 right join (t2 left join t1 on (t1.bi = t2.vi)) on (t1.vc = t2.vc));
+--sorted_result
+select t2.vi from (t2 as t3 right join (t2 left join t1 on (t1.bi = t2.vi)) on (t1.vc = t2.vc));
+drop table t2,t1;
diff --git a/mysql-test/suite/vcol/t/vcol_sql_mode.test b/mysql-test/suite/vcol/t/vcol_sql_mode.test
new file mode 100644
index 00000000..f52345c7
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_sql_mode.test
@@ -0,0 +1,322 @@
+--echo #
+--echo # Start of 10.2 tests
+--echo #
+
+--echo #
+--echo # MDEV-18156 Assertion `0' failed or `btr_validate_index(index, 0, false)' in row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with PAD_CHAR_TO_FULL_LENGTH
+--echo #
+
+--echo #
+--echo # PAD_CHAR_TO_FULL_LENGTH + various virtual column data types
+--echo #
+
+CREATE TABLE t1 (a CHAR(5), v CHAR(5) AS (a) VIRTUAL, KEY(v));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(5), v INT AS (a) VIRTUAL, KEY(v));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a CHAR(5), v TIME AS (a) VIRTUAL, KEY(v));
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (c CHAR(8), v BINARY(8) AS (c), KEY(v));
+SHOW WARNINGS;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a CHAR(5), v BIT(64) AS (a) VIRTUAL, KEY(v));
+SHOW WARNINGS;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (a) VIRTUAL, KEY(v));
+SHOW WARNINGS;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a CHAR(5), v TEXT AS (a) VIRTUAL, KEY(v(100)));
+SHOW WARNINGS;
+
+
+--echo # PAD_CHAR_TO_FULL_LENGTH + TRIM resolving dependency
+
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (RTRIM(a)) VIRTUAL, KEY(v));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(5), v TEXT AS (RTRIM(a)) VIRTUAL, KEY(v(100)));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(TRAILING ' ' FROM a)) VIRTUAL, KEY(v));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(5), v TEXT AS (TRIM(TRAILING ' ' FROM a)) VIRTUAL, KEY(v(100)));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(BOTH ' ' FROM a)) VIRTUAL, KEY(v));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(5), v TEXT AS (TRIM(BOTH ' ' FROM a)) VIRTUAL, KEY(v(100)));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(TRAILING NULL FROM a)) VIRTUAL, KEY(v));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(BOTH NULL FROM a)) VIRTUAL, KEY(v));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo # PAD_CHAR_TO_FULL_LENGTH + TRIM not resolving dependency
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(LEADING ' ' FROM a)) VIRTUAL, KEY(v));
+SHOW WARNINGS;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a CHAR(5), v TEXT AS (TRIM(LEADING ' ' FROM a)) VIRTUAL, KEY(v(100)));
+SHOW WARNINGS;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(TRAILING '' FROM a)) VIRTUAL, KEY(v));
+SHOW WARNINGS;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(BOTH '' FROM a)) VIRTUAL, KEY(v));
+SHOW WARNINGS;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(TRAILING 'x' FROM a)) VIRTUAL, KEY(v));
+SHOW WARNINGS;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(BOTH 'x' FROM a)) VIRTUAL, KEY(v));
+SHOW WARNINGS;
+
+# more than one space
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ a CHAR(5),
+ v VARCHAR(5) AS (TRIM(TRAILING ' ' FROM a)) VIRTUAL, KEY(v));
+SHOW WARNINGS;
+
+# more than one space
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ a CHAR(5),
+ v VARCHAR(5) AS (TRIM(BOTH ' ' FROM a)) VIRTUAL, KEY(v));
+SHOW WARNINGS;
+
+
+--echo # PAD_CHAR_TO_FULL_LENGTH + TRIM(... non_constant FROM a)
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ a CHAR(5),
+ b CHAR(5),
+ v TEXT AS (TRIM(TRAILING b FROM a)) VIRTUAL, KEY(v(100)));
+SHOW WARNINGS;
+
+
+--echo # PAD_CHAR_TO_FULL_LENGTH + RPAD resolving dependency
+
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (RPAD(a,5,' ')) VIRTUAL, KEY(v));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (RPAD(a,6,' ')) VIRTUAL, KEY(v));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (RPAD(a,6,NULL)) VIRTUAL, KEY(v));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (RPAD(a,NULL,' ')) VIRTUAL, KEY(v));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo # PAD_CHAR_TO_FULL_LENGTH + RPAD not resolving dependency
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (RPAD(a,4,' ')) VIRTUAL, KEY(v));
+SHOW WARNINGS;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ a CHAR(5),
+ b CHAR(5),
+ v VARCHAR(5) AS (RPAD(a,NULL,b)) VIRTUAL,
+ KEY(v)
+);
+SHOW WARNINGS;
+
+
+--echo # PAD_CHAR_TO_FULL_LENGTH + comparison
+
+CREATE TABLE t1 (a CHAR(5), v INT AS (a='a') VIRTUAL, KEY(v));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ a CHAR(5) CHARACTER SET latin1 COLLATE latin1_nopad_bin,
+ v INT AS (a='a') VIRTUAL, KEY(v)
+);
+SHOW WARNINGS;
+
+
+--echo # PAD_CHAR_TO_FULL_LENGTH + LIKE
+
+CREATE TABLE t1 (a CHAR(5), v INT AS (a LIKE 'a%') VIRTUAL, KEY(v));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(5), v INT AS (a LIKE NULL) VIRTUAL, KEY(v));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a CHAR(5), v INT AS (a LIKE 'a') VIRTUAL, KEY(v));
+SHOW WARNINGS;
+
+
+--echo # PAD_CHAR_TO_FULL_LENGTH + LENGTH(char_column) = hard dependency
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a CHAR(5), v INT AS (LENGTH(a)) VIRTUAL, KEY(v));
+SHOW WARNINGS;
+
+
+--echo #
+--echo # Testing NO_UNSIGNED_SUBTRACTION
+--echo #
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ a INT UNSIGNED,
+ b INT UNSIGNED,
+ c INT GENERATED ALWAYS AS (a-b) VIRTUAL,
+ KEY (c)
+);
+SHOW WARNINGS;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ a INT UNSIGNED,
+ b INT UNSIGNED,
+ c INT GENERATED ALWAYS AS (CAST(a AS SIGNED)-b) VIRTUAL,
+ KEY (c)
+);
+SHOW WARNINGS;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ a INT UNSIGNED,
+ b INT UNSIGNED,
+ c INT GENERATED ALWAYS AS (a-CAST(b AS SIGNED)) VIRTUAL,
+ KEY (c)
+);
+SHOW WARNINGS;
+
+CREATE TABLE t1 (
+ a INT UNSIGNED,
+ b INT UNSIGNED,
+ c INT GENERATED ALWAYS AS (CAST(a AS SIGNED)-CAST(b AS SIGNED)) VIRTUAL,
+ KEY (c)
+);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+# 'CAST(signed AS DECIMAL)' does not copy 'unsigned_flag' from the argument.
+# So the below is safe.
+CREATE TABLE t1 (
+ a INT UNSIGNED,
+ b INT UNSIGNED,
+ c INT GENERATED ALWAYS AS (CAST(a AS DECIMAL(20,0))-CAST(b AS DECIMAL(20,0))) VIRTUAL,
+ KEY (c)
+);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Comnination: PAD_CHAR_TO_FULL_LENGTH + NO_UNSIGNED_SUBTRACTION
+--echo #
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ a INT UNSIGNED,
+ b INT UNSIGNED,
+ c CHAR(5),
+ v VARCHAR(5) GENERATED ALWAYS AS (RPAD(c,a-b,' ')) VIRTUAL,
+ KEY (v)
+);
+SHOW WARNINGS;
+
+
+# The below solves the dependency on NO_UNSIGNED_SUBTRACTION
+# but does not solve the dependency on PAD_CHAR_TO_FULL_LENGTH,
+# because the 'length' argument to RPAD() is not a constant.
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ a INT UNSIGNED,
+ b INT UNSIGNED,
+ c CHAR(5),
+ v VARCHAR(5) GENERATED ALWAYS AS (RPAD(c,CAST(a AS DECIMAL(20,1))-b,' ')) VIRTUAL,
+ KEY (v)
+);
+SHOW WARNINGS;
+
+
+
+--echo # ALTER TABLE ADD KEY(vcol_depending_on_sql_mode) --> error
+
+# This makes sure that QT_ITEM_IDENT_SKIP_DB_NAMES and
+# QT_ITEM_IDENT_SKIP_TABLE_NAMES are passed to print()
+# to avoid temporary table names like `test`.`#sql-50a6_4`.`c`
+# in the error message.
+#
+
+CREATE TABLE t1 (
+ a INT UNSIGNED,
+ b INT UNSIGNED,
+ c CHAR(5),
+ v VARCHAR(5) GENERATED ALWAYS AS (c) VIRTUAL
+);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+ALTER TABLE t1 ADD KEY(v);
+SHOW WARNINGS;
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE INDEX v ON t1 (v);
+SHOW WARNINGS;
+DROP TABLE t1;
+
+
+--echo # A virtual column on the second position in an index - cannot depend on sql_mode
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (id int, a CHAR(5), v TEXT AS (a) VIRTUAL, KEY(id, v(100)));
+SHOW WARNINGS;
+
+
+--echo # A persisten virtual column cannot depend on sql_mode
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (a) PERSISTENT);
+SHOW WARNINGS;
+
+CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (RTRIM(a)) PERSISTENT);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--echo #
+--echo # End of 10.2 tests
+--echo #
diff --git a/mysql-test/suite/vcol/t/vcol_sql_mode_datetime.test b/mysql-test/suite/vcol/t/vcol_sql_mode_datetime.test
new file mode 100644
index 00000000..19ebd964
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_sql_mode_datetime.test
@@ -0,0 +1,134 @@
+--echo #
+--echo # Start of 10.4 tests
+--echo #
+
+--echo #
+--echo # MDEV-18153 Assertion `0' or Assertion `btr_validate_index(index, 0)' failed in row_upd_sec_index_entry or error code 126: Index is corrupted upon UPDATE with TIME_ROUND_FRACTIONAL
+--echo #
+
+SET sql_mode=DEFAULT;
+
+--echo # OK: same FSP + virtual index
+
+CREATE TABLE t1 (
+ t DATETIME(4),
+ d DATETIME,
+ v DATETIME(4) AS (t) VIRTUAL,
+ KEY(v,d)
+);
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ t DATETIME(4),
+ d DATETIME,
+ v DATETIME(4) AS ('2001-01-01 10:20:30.1234') VIRTUAL,
+ KEY(v,d)
+);
+DROP TABLE t1;
+
+
+--echo # OK: lower FSP + no virtual index
+
+CREATE TABLE t1 (
+ t DATETIME(4),
+ d DATETIME,
+ v DATETIME(3) AS (t) VIRTUAL
+);
+DROP TABLE t1;
+
+
+CREATE TABLE t1 (
+ t DATETIME(4),
+ d DATETIME,
+ v DATETIME(3) AS ('2001-01-01 10:20:30.1234') VIRTUAL
+);
+DROP TABLE t1;
+
+
+--echo # NOT OK: lower FSP + virtual index
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ t DATETIME(4),
+ d DATETIME,
+ v DATETIME(3) AS (t) VIRTUAL,
+ KEY(v,d)
+);
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ t DATETIME(4),
+ d DATETIME,
+ v DATETIME(3) AS (COALESCE(t)) VIRTUAL,
+ KEY(v,d)
+);
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ t DATETIME(4),
+ d DATETIME,
+ v DATETIME(3) AS ('2001-01-01 10:20:30.1234') VIRTUAL,
+ KEY(v,d)
+);
+
+
+--echo # OK: lower FSP + ROUND + virtual index
+SET sql_mode=DEFAULT;
+CREATE TABLE t1 (
+ t DATETIME(4),
+ d DATETIME,
+ v DATETIME(3) AS (ROUND(t,3)) VIRTUAL,
+ KEY(v,d)
+);
+INSERT IGNORE INTO t1 (t,d) VALUES ('2006-03-01 12:44:34.0496','2029-10-10 21:27:53');
+SELECT * FROM t1;
+SET SQL_MODE= 'TIME_ROUND_FRACTIONAL';
+UPDATE IGNORE t1 SET d = NOW();
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+
+--echo # OK: lower FSP + TRUNCATE + virtual index
+SET sql_mode=DEFAULT;
+CREATE TABLE t1 (
+ t DATETIME(4),
+ d DATETIME,
+ v DATETIME(3) AS (TRUNCATE(t,3)) VIRTUAL,
+ KEY(v,d)
+);
+INSERT IGNORE INTO t1 (t,d) VALUES ('2006-03-01 12:44:34.0496','2029-10-10 21:27:53');
+SELECT * FROM t1;
+SET SQL_MODE= 'TIME_ROUND_FRACTIONAL';
+UPDATE IGNORE t1 SET d = NOW();
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+--echo #
+--echo # MDEV-20423 Assertion `0' failed or `btr_validate_index(index, 0, false)' in row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with TIME_ROUND_FRACTIONAL
+--echo #
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ a DATETIME(6),
+ v VARCHAR(30) GENERATED ALWAYS AS (CAST(a AS DATETIME(3))) VIRTUAL,
+ KEY (v)
+);
+
+CREATE TABLE t1 (
+ a DATETIME(6),
+ v VARCHAR(30) GENERATED ALWAYS AS (TRUNCATE(a,3)) VIRTUAL,
+ KEY (v)
+);
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ a DATETIME(6),
+ v VARCHAR(30) GENERATED ALWAYS AS (ROUND(a,3)) VIRTUAL,
+ KEY (v)
+);
+DROP TABLE t1;
+
+
+--echo #
+--echo # End of 10.4 tests
+--echo #
diff --git a/mysql-test/suite/vcol/t/vcol_sql_mode_time.test b/mysql-test/suite/vcol/t/vcol_sql_mode_time.test
new file mode 100644
index 00000000..2ce2a9eb
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_sql_mode_time.test
@@ -0,0 +1,135 @@
+--echo #
+--echo # Start of 10.4 tests
+--echo #
+
+--echo #
+--echo # MDEV-18153 Assertion `0' or Assertion `btr_validate_index(index, 0)' failed in row_upd_sec_index_entry or error code 126: Index is corrupted upon UPDATE with TIME_ROUND_FRACTIONAL
+--echo #
+
+SET sql_mode=DEFAULT;
+
+--echo # OK: same FSP + virtual index
+
+CREATE TABLE t1 (
+ t TIME(4),
+ d TIME,
+ v TIME(4) AS (t) VIRTUAL,
+ KEY(v,d)
+);
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ t TIME(4),
+ d TIME,
+ v TIME(4) AS ('10:20:30.1234') VIRTUAL,
+ KEY(v,d)
+);
+DROP TABLE t1;
+
+
+--echo # OK: lower FSP + no virtual index
+
+CREATE TABLE t1 (
+ t TIME(4),
+ d TIME,
+ v TIME(3) AS (t) VIRTUAL
+);
+DROP TABLE t1;
+
+
+CREATE TABLE t1 (
+ t TIME(4),
+ d TIME,
+ v TIME(3) AS ('2001-01-01 10:20:30.1234') VIRTUAL
+);
+DROP TABLE t1;
+
+
+--echo # NOT OK: lower FSP + virtual index
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ t TIME(4),
+ d TIME,
+ v TIME(3) AS (t) VIRTUAL,
+ KEY(v,d)
+);
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ t TIME(4),
+ d TIME,
+ v TIME(3) AS (COALESCE(t)) VIRTUAL,
+ KEY(v,d)
+);
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ t TIME(4),
+ d TIME,
+ v TIME(3) AS ('2001-01-01 10:20:30.1234') VIRTUAL,
+ KEY(v,d)
+);
+
+
+--echo # OK: lower FSP + ROUND + virtual index
+SET sql_mode=DEFAULT;
+CREATE TABLE t1 (
+ t TIME(4),
+ d TIME,
+ v TIME(3) AS (ROUND(t,3)) VIRTUAL,
+ KEY(v,d)
+);
+INSERT IGNORE INTO t1 (t,d) VALUES ('12:44:34.0496','21:27:53');
+SELECT * FROM t1;
+SET SQL_MODE= 'TIME_ROUND_FRACTIONAL';
+UPDATE IGNORE t1 SET d = CURRENT_TIME;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+
+--echo # OK: lower FSP + TRUNCATE + virtual index
+SET sql_mode=DEFAULT;
+CREATE TABLE t1 (
+ t TIME(4),
+ d TIME,
+ v TIME(3) AS (TRUNCATE(t,3)) VIRTUAL,
+ KEY(v,d)
+);
+INSERT IGNORE INTO t1 (t,d) VALUES ('12:44:34.0496','21:27:53');
+SELECT * FROM t1;
+SET SQL_MODE= 'TIME_ROUND_FRACTIONAL';
+UPDATE IGNORE t1 SET d = CURRENT_TIME;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+
+--echo #
+--echo # MDEV-20423 Assertion `0' failed or `btr_validate_index(index, 0, false)' in row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with TIME_ROUND_FRACTIONAL
+--echo #
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ a TIME(6),
+ v VARCHAR(30) GENERATED ALWAYS AS (CAST(a AS TIME(3))) VIRTUAL,
+ KEY (v)
+);
+
+CREATE TABLE t1 (
+ a TIME(6),
+ v VARCHAR(30) GENERATED ALWAYS AS (TRUNCATE(a,3)) VIRTUAL,
+ KEY (v)
+);
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ a TIME(6),
+ v VARCHAR(30) GENERATED ALWAYS AS (ROUND(a,3)) VIRTUAL,
+ KEY (v)
+);
+DROP TABLE t1;
+
+
+--echo #
+--echo # End of 10.4 tests
+--echo #
diff --git a/mysql-test/suite/vcol/t/vcol_sql_mode_timestamp.test b/mysql-test/suite/vcol/t/vcol_sql_mode_timestamp.test
new file mode 100644
index 00000000..e3dee582
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_sql_mode_timestamp.test
@@ -0,0 +1,122 @@
+--echo #
+--echo # Start of 10.4 tests
+--echo #
+
+--echo #
+--echo # MDEV-18153 Assertion `0' or Assertion `btr_validate_index(index, 0)' failed in row_upd_sec_index_entry or error code 126: Index is corrupted upon UPDATE with TIME_ROUND_FRACTIONAL
+--echo #
+
+SET sql_mode=DEFAULT;
+
+--echo # OK: same FSP + virtual index
+
+CREATE TABLE t1 (
+ t TIMESTAMP(4),
+ d DATETIME,
+ v TIMESTAMP(4) AS (t) VIRTUAL,
+ KEY(v,d)
+);
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ t TIMESTAMP(4),
+ d DATETIME,
+ v TIMESTAMP(4) AS ('2001-01-01 10:20:30.1234') VIRTUAL,
+ KEY(v,d)
+);
+DROP TABLE t1;
+
+
+--echo # OK: lower FSP + no virtual index
+
+CREATE TABLE t1 (
+ t TIMESTAMP(4),
+ d DATETIME,
+ v TIMESTAMP(3) AS (t) VIRTUAL
+);
+DROP TABLE t1;
+
+
+CREATE TABLE t1 (
+ t TIMESTAMP(4),
+ d DATETIME,
+ v TIMESTAMP(3) AS ('2001-01-01 10:20:30.1234') VIRTUAL
+);
+DROP TABLE t1;
+
+
+--echo # NOT OK: lower FSP + virtual index
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ t TIMESTAMP(4),
+ d DATETIME,
+ v TIMESTAMP(3) AS (t) VIRTUAL,
+ KEY(v,d)
+);
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ t TIMESTAMP(4),
+ d DATETIME,
+ v TIMESTAMP(3) AS (COALESCE(t)) VIRTUAL,
+ KEY(v,d)
+);
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (
+ t TIMESTAMP(4),
+ d DATETIME,
+ v TIMESTAMP(3) AS ('2001-01-01 10:20:30.1234') VIRTUAL,
+ KEY(v,d)
+);
+
+
+--echo # OK: lower FSP + ROUND + virtual index
+SET sql_mode=DEFAULT;
+CREATE TABLE t1 (
+ t TIMESTAMP(4),
+ d DATETIME,
+ v TIMESTAMP(3) AS (ROUND(t,3)) VIRTUAL,
+ KEY(v,d)
+);
+INSERT IGNORE INTO t1 (t,d) VALUES ('2006-03-01 12:44:34.0496','2029-10-10 21:27:53');
+SELECT * FROM t1;
+SET SQL_MODE= 'TIME_ROUND_FRACTIONAL';
+UPDATE IGNORE t1 SET d = NOW();
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+
+--echo # OK: lower FSP + TRUNCATE + virtual index
+SET sql_mode=DEFAULT;
+CREATE TABLE t1 (
+ t TIMESTAMP(4),
+ d DATETIME,
+ v TIMESTAMP(3) AS (TRUNCATE(t,3)) VIRTUAL,
+ KEY(v,d)
+);
+INSERT IGNORE INTO t1 (t,d) VALUES ('2006-03-01 12:44:34.0496','2029-10-10 21:27:53');
+SELECT * FROM t1;
+SET SQL_MODE= 'TIME_ROUND_FRACTIONAL';
+UPDATE IGNORE t1 SET d = NOW();
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+--echo #
+--echo # MDEV-20639 ASAN SEGV in get_prefix upon modifying base column type with existing indexed virtual column
+--echo #
+
+CREATE TABLE t1 (
+ a TIMESTAMP,
+ b TIMESTAMP AS (a) VIRTUAL,
+ KEY (b)
+);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+ALTER TABLE t1 MODIFY a BLOB FIRST;
+SHOW WARNINGS;
+DROP TABLE t1;
+
+--echo #
+--echo # End of 10.4 tests
+--echo #
diff --git a/mysql-test/suite/vcol/t/vcol_sql_mode_upgrade.test b/mysql-test/suite/vcol/t/vcol_sql_mode_upgrade.test
new file mode 100644
index 00000000..71e34231
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_sql_mode_upgrade.test
@@ -0,0 +1,193 @@
+-- source include/mysql_upgrade_preparation.inc
+call mtr.add_suppression("Table rebuild required");
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+
+--enable_prepare_warnings
+
+--echo #
+--echo # Opening a Maria-10.2.26 table with a stored VARCHAR column
+--echo #
+
+--echo # Copying maria100226_char_to_vchar_stored.* to MYSQLD_DATADIR
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYD $MYSQLD_DATADIR/test/t1.MYD
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYI $MYSQLD_DATADIR/test/t1.MYI
+
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t1;
+FLUSH TABLES;
+SHOW CREATE TABLE t1;
+
+FLUSH TABLES;
+SELECT * FROM t1;
+SELECT * FROM t1;
+FLUSH TABLES;
+SELECT * FROM t1;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t2 LIKE t1;
+FLUSH TABLES;
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t2 LIKE t1;
+
+SHOW CREATE TABLE t1;
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+ALTER TABLE t1 ADD b INT DEFAULT a;
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+FLUSH TABLES;
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+ALTER TABLE t1 ADD c INT DEFAULT a;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Fixing a Maria-10.2.26 table with a stored VARCHAR column
+--echo #
+
+--echo # Fixing by dropping the generated stored column
+--echo # Copying maria100226_char_to_vchar_stored.* to MYSQLD_DATADIR
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYD $MYSQLD_DATADIR/test/t1.MYD
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYI $MYSQLD_DATADIR/test/t1.MYI
+
+ALTER TABLE t1 DROP v;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo # Fixing by altering the generation expression of the stored column
+--echo # Copying maria100226_char_to_vchar_stored.* to MYSQLD_DATADIR
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYD $MYSQLD_DATADIR/test/t1.MYD
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYI $MYSQLD_DATADIR/test/t1.MYI
+
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 MODIFY v VARCHAR(5) AS (RTRIM(a)) PERSISTENT;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+
+--echo #
+--echo # Opening a Maria-10.2.26 table with a virtual VARCHAR column
+--echo #
+
+--echo # Copying maria100226_char_to_vchar_virtual.* to MYSQLD_DATADIR
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYD $MYSQLD_DATADIR/test/t1.MYD
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYI $MYSQLD_DATADIR/test/t1.MYI
+
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t1;
+FLUSH TABLES;
+SHOW CREATE TABLE t1;
+
+FLUSH TABLES;
+SELECT * FROM t1;
+SELECT * FROM t1;
+FLUSH TABLES;
+SELECT * FROM t1;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t2 LIKE t1;
+FLUSH TABLES;
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t2 LIKE t1;
+
+
+SHOW CREATE TABLE t1;
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+ALTER TABLE t1 ADD b INT DEFAULT a;
+FLUSH TABLES;
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+ALTER TABLE t1 ADD c INT DEFAULT a;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Fixing a Maria-10.2.26 table with a virtual VARCHAR column
+--echo #
+
+--echo # Fixing by dropping the virtual column
+--echo # Copying maria100226_char_to_vchar_virtual.* to MYSQLD_DATADIR
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYD $MYSQLD_DATADIR/test/t1.MYD
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYI $MYSQLD_DATADIR/test/t1.MYI
+
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 DROP v;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo # Fixing by dropping a key on a virtual column, using ALTER TABLE
+--echo # Copying maria100226_char_to_vchar_virtual.* to MYSQLD_DATADIR
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYD $MYSQLD_DATADIR/test/t1.MYD
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYI $MYSQLD_DATADIR/test/t1.MYI
+
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 DROP KEY v;
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+--echo # Fixing by dropping a key on a virtual column, using DROP INDEX
+--echo # Copying maria100226_char_to_vchar_virtual.* to MYSQLD_DATADIR
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYD $MYSQLD_DATADIR/test/t1.MYD
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYI $MYSQLD_DATADIR/test/t1.MYI
+
+DROP INDEX v ON t1;
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+--echo # Fixing by altering the generation expression of a virtual column
+--echo # Copying maria100226_char_to_vchar_virtual.* to MYSQLD_DATADIR
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYD $MYSQLD_DATADIR/test/t1.MYD
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYI $MYSQLD_DATADIR/test/t1.MYI
+
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 MODIFY v VARCHAR(5) AS(RTRIM(a)) VIRTUAL;
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+CREATE TABLE t2 LIKE t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Upgrading a Maria-10.2.26 table with a stored column
+--echo #
+
+--echo # Copying maria100226_char_to_varchar.* to MYSQLD_DATADIR
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYD $MYSQLD_DATADIR/test/t1.MYD
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYI $MYSQLD_DATADIR/test/t1.MYI
+
+CHECK TABLE t1 FOR UPGRADE;
+FLUSH TABLES;
+CHECK TABLE t1 FOR UPGRADE;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Upgrading a Maria-10.2.26 table with a virtual column
+--echo #
+
+--echo # Copying maria100226_char_to_varchar.* to MYSQLD_DATADIR
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYD $MYSQLD_DATADIR/test/t1.MYD
+--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYI $MYSQLD_DATADIR/test/t1.MYI
+
+CHECK TABLE t1 FOR UPGRADE;
+FLUSH TABLES;
+CHECK TABLE t1 FOR UPGRADE;
+DROP TABLE t1;
diff --git a/mysql-test/suite/vcol/t/vcol_supported_sql_funcs.test b/mysql-test/suite/vcol/t/vcol_supported_sql_funcs.test
new file mode 100644
index 00000000..36c1ba09
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_supported_sql_funcs.test
@@ -0,0 +1,49 @@
+################################################################################
+# t/vcol_supported_sql_funcs.test #
+# #
+# Purpose: #
+# Test SQL functions allowed for virtual columns #
+# MyISAM branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-08-31 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+eval SET @@session.default_storage_engine = 'MyISAM';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source vcol_supported_sql_funcs_main.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_supported_sql_funcs_main.inc b/mysql-test/suite/vcol/t/vcol_supported_sql_funcs_main.inc
new file mode 100644
index 00000000..fa2162e5
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_supported_sql_funcs_main.inc
@@ -0,0 +1,1223 @@
+################################################################################
+# inc/vcol_supported_sql_funcs_main.inc #
+# #
+# Purpose: #
+# Tests frame for allowed sql functions #
+# #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-08-31 #
+# Change Author: Oleksandr Byelkin (Monty program Ab)
+# Date: 2009-03-24
+# Change: Syntax changed
+################################################################################
+
+--echo #
+--echo # NUMERIC FUNCTIONS
+--echo #
+
+--echo # ABS()
+let $cols = a int, b int as (abs(a));
+let $values1 = -1, default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # ACOS()
+let $cols = a double, b double as (format(acos(a),6));
+let $values1 = 1, default;
+let $values2 = 1.0001,default;
+let $values3 = 0,default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # ASIN()
+let $cols = a double, b double as (format(asin(a),6));
+let $values1 = 0.2, default;
+let $values2 = 1.0001,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo #ATAN
+let $cols = a double, b double, c double as (format(atan(a,b),6));
+let $values1 = -2,2,default;
+let $values2 = format(PI(),6),0,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+let $cols = a double, c double as (format(atan(a),6));
+let $values1 = -2,default;
+let $values2 = format(PI(),6),default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # ATAN2
+let $cols = a double, b double, c double as (format(atan2(a,b),6));
+let $values1 = -2,2,default;
+let $values2 = format(PI(),6),0,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # CEIL()
+let $cols = a double, b int as (ceil(a));
+let $values1 = 1.23,default;
+let $values2 = -1.23,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # CONV()
+let $cols = a varchar(10), b int, c int, d varchar(10) as (conv(a,b,c));
+let $values1 = 'a',16,2,default;
+let $values2 = '6e',18,8,default;
+let $values3 = -17,10,-18,default;
+let $values4 = 10+'10'+'10'+0xa,10,10,default;
+let $rows = 4;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # COS()
+let $cols = a double, b double as (format(cos(a),6));
+let $values1 = format(PI(),6),default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # COT()
+let $cols = a double, b double as (format(cot(a),6));
+let $values1 = 12,default;
+let $values2 = 1,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # CRC32()
+let $cols = a varchar(10), b long as (crc32(a));
+let $values1 = 'MySQL',default;
+let $values2 = 'mysql',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # DEGREES()
+let $cols = a double, b double as (format(degrees(a),6));
+let $values1 = format(PI(),6),default;
+let $values2 = format(PI()/2,6),default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # /
+let $cols = a double, b double as (a/2);
+let $values1 = 2,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # EXP()
+let $cols = a double, b double as (format(exp(a),6));
+let $values1 = 2,default;
+let $values2 = -2,default;
+let $values3 = 0,default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # FLOOR()
+let $cols = a double, b long as (floor(a));
+let $values1 = 1.23,default;
+let $values2 = -1.23,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # LN()
+let $cols = a double, b double as (format(ln(a),6));
+let $values1 = 2,default;
+let $values2 = -2,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # LOG()
+let $cols = a double, b double, c double as (format(log(a,b),6));
+let $values1 = 2,65536,default;
+let $values2 = 10,100,default;
+let $values3 = 1,100,default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+let $cols = a double, b double as (format(log(a),6));
+let $values1 = 2,default;
+let $values2 = -2,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # LOG2()
+let $cols = a double, b double as (format(log2(a),6));
+let $values1 = 65536,default;
+let $values2 = -100,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # LOG10()
+let $cols = a double, b double as (format(log10(a),6));
+let $values1 = 2,default;
+let $values2 = 100,default;
+let $values3 = -100,default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # -
+let $cols = a double, b double as (a-1);
+let $values1 = 2,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # MOD()
+let $cols = a int, b int as (mod(a,10));
+let $values1 = 1,default;
+let $values2 = 11,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # %
+let $cols = a int, b int as (a % 10);
+let $values1 = 1,default;
+let $values2 = 11,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # OCT()
+let $cols = a double, b varchar(10) as (oct(a));
+let $values1 = 12,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # PI()
+let $cols = a double, b double as (format(PI()*a*a,6));
+let $values1 = 1,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # +
+let $cols = a int, b int as (a+1);
+let $values1 = 1,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # POW, POWER
+let $cols = a int, b int as (pow(a,2)), c int as (power(a,2));
+let $values1 = 1,default,default;
+let $values2 = 2,default,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # RADIANS()
+let $cols = a double, b double as (format(radians(a),6));
+let $values1 = 90,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # ROUND()
+let $cols = a double, b int as (round(a));
+let $values1 = -1.23,default;
+let $values2 = -1.58,default;
+let $values3 = 1.58,default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+let $cols = a double, b double, c int as (round(a,b));
+let $values1 = 1.298,1,default;
+let $values2 = 1.298,0,default;
+let $values3 = 23.298,-1,default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # SIGN()
+let $cols = a double, b int as (sign(a));
+let $values1 = -32,default;
+let $values2 = 0,default;
+let $values3 = 234,default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # SIN()
+let $cols = a double, b double as (format(sin(a),6));
+let $values1 = format(PI()/2,6),default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # SQRT()
+let $cols = a double, b double as (format(sqrt(a),6));
+let $values1 = 4,default;
+let $values2 = 20,default;
+let $values3 = -16,default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # TAN()
+let $cols = a double, b double as (format(tan(a),6));
+let $values1 = format(PI(),6),default;
+let $values2 = format(PI()+1,6),default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # *
+let $cols = a double, b double as (a*3);
+let $values1 = 0,default;
+let $values2 = 1,default;
+let $values3 = 2,default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # TRUNCATE()
+let $cols = a double, b double as (truncate(a,4));
+let $values1 = 1.223,default;
+let $values2 = 1.999,default;
+let $values3 = 1.999,default;
+let $values4 = 122,default;
+let $rows = 4;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # Unary -
+let $cols = a double, b double as (-a);
+let $values1 = 1,default;
+let $values2 = -1,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo #
+--echo # STRING FUNCTIONS
+--echo #
+
+--echo # ASCII()
+let $cols = a char(2), b int as (ascii(a));
+let $values1 = '2',default;
+let $values2 = 2,default;
+let $values3 = 'dx',default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # BIN()
+let $cols = a int, b varchar(10) as (bin(a));
+let $values1 = 12,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # BIT_LENGTH()
+let $cols = a varchar(10), b long as (bit_length(a));
+let $values1 = 'text',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # CHAR_LENGTH()
+let $cols = a varchar(10), b long as (char_length(a));
+let $values1 = 'text',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # CHAR()
+let $cols = a int, b int, c varbinary(10) as (char(a,b));
+let $values1 = 77,121,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # CHARACTER_LENGTH()
+let $cols = a varchar(10), b long as (character_length(a));
+let $values1 = 'text',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # CONCAT_WS()
+let $cols = a varchar(10), b varchar(10), c varchar(20) as (concat_ws(',',a,b));
+let $values1 = 'value1','value2',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # CONCAT()
+let $cols = a varchar(10), b varchar(10), c varchar(20) as (concat(a,',',b));
+let $values1 = 'value1','value2',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # ELT()
+let $cols = a varchar(10), b varchar(10), c int, d varchar(10) as (elt(c,a,b));
+let $values1 = 'value1','value2',1,default;
+let $values2 = 'value1','value2',2,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # EXPORT_SET()
+let $cols = a int, b varchar(10) as (export_set(a,'1','0','',10));
+let $values1 = 6,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # FIELD()
+let $cols = a varchar(10), b varchar(10), c int as (field('aa',a,b));
+let $values1 = 'aa','bb',default;
+let $values2 = 'bb','aa',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # FIND_IN_SET()
+let $cols = a varchar(10), b varchar(10), c int as (find_in_set(a,b));
+let $values1 = 'aa','aa,bb,cc',default;
+let $values2 = 'aa','bb,aa,cc',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # FORMAT()
+let $cols = a double, b varchar(20) as (format(a,2));
+let $values1 = 12332.123456,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # HEX()
+let $cols = a int, b varchar(10) as (hex(a));
+let $values1 = 17,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+let $cols = a varchar(10), b varchar(10) as (hex(a));
+let $values1 = 'abc',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # INSERT()
+let $cols = a varchar(10), b varchar(10), c varchar(20) as (insert(a,length(a),length(b),b));
+let $values1 = 'start,','end',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # INSTR()
+let $cols = a varchar(10), b varchar(10), c int as (instr(a,b));
+let $values1 = 'foobarbar,','bar',default;
+let $values2 = 'xbar,','foobar',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # LCASE()
+let $cols = a varchar(10), b varchar(10) as (lcase(a));
+let $values1 = 'MySQL',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # LEFT()
+let $cols = a varchar(10), b varchar(5) as (left(a,5));
+let $values1 = 'foobarbar',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # LENGTH()
+let $cols = a varchar(10), b int as (length(a));
+let $values1 = 'text',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # LIKE
+let $cols = a varchar(10), b bool as (a like 'H%!o' escape '!');
+let $values1 = 'Hello',default;
+let $values2 = 'MySQL',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # LOCATE()
+let $cols = a varchar(10), b varchar(10) as (locate('bar',a));
+let $values1 = 'foobarbar',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # LOWER()
+let $cols = a varchar(10), b varchar(10) as (lower(a));
+let $values1 = 'MySQL',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # LPAD()
+let $cols = a varchar(10), b varchar(10) as (lpad(a,4,' '));
+let $values1 = 'MySQL',default;
+let $values2 = 'M',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # LTRIM()
+let $cols = a varchar(10), b varchar(10) as (ltrim(a));
+let $values1 = ' MySQL',default;
+let $values2 = 'MySQL',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # MAKE_SET()
+let $cols = a varchar(10), b varchar(10), c int, d varchar(30) as (make_set(c,a,b));
+let $values1 = 'a','b',1,default;
+let $values2 = 'a','b',3,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # MID()
+let $cols = a varchar(10), b varchar(10) as (mid(a,1,2));
+let $values1 = 'foobarbar',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # NOT LIKE
+let $cols = a varchar(10), b bool as (a not like 'H%o');
+let $values1 = 'Hello',default;
+let $values2 = 'MySQL',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # NOT REGEXP
+let $cols = a varchar(10), b bool as (a not regexp 'H.+o');
+let $values1 = 'Hello',default;
+let $values2 = 'hello',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # OCTET_LENGTH()
+let $cols = a varchar(10), b int as (octet_length(a));
+let $values1 = 'text',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # ORD()
+let $cols = a varchar(10), b long as (ord(a));
+let $values1 = '2',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # POSITION()
+let $cols = a varchar(10), b varchar(10) as (position('bar' in a));
+let $values1 = 'foobarbar',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # QUOTE()
+let $cols = a varchar(10), b varchar(10) as (quote(a));
+let $values1 = 'Don\'t',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # REGEXP()
+let $cols = a varchar(10), b bool as (a regexp 'H.+o');
+let $values1 = 'Hello',default;
+let $values2 = 'hello',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # REPEAT()
+let $cols = a varchar(10), b varchar(30) as (repeat(a,3));
+let $values1 = 'MySQL',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # REPLACE()
+let $cols = a varchar(10), b varchar(30) as (replace(a,'aa','bb'));
+let $values1 = 'maa',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # REVERSE()
+let $cols = a varchar(10), b varchar(30) as (reverse(a));
+let $values1 = 'maa',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # RIGHT()
+let $cols = a varchar(10), b varchar(10) as (right(a,4));
+let $values1 = 'foobarbar',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # RLIKE()
+let $cols = a varchar(10), b bool as (a rlike 'H.+o');
+let $values1 = 'Hello',default;
+let $values2 = 'MySQL',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # RPAD()
+let $cols = a varchar(10), b varchar(10) as (rpad(a,4,'??'));
+let $values1 = 'He',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # RTRIM();
+let $cols = a varchar(10), b varchar(10) as (rtrim(a));
+let $values1 = 'Hello ',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # SOUNDEX()
+let $cols = a varchar(10), b varchar(20) as (soundex(a));
+let $values1 = 'Hello',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # SOUNDS LIKE
+let $cols = a varchar(10), b varchar(10), c bool as (a sounds like b);
+let $values1 = 'Hello','Hello',default;
+let $values2 = 'Hello','MySQL',default;
+let $values3 = 'Hello','hello',default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # SPACE()
+let $cols = a varchar(5), b varchar(10) as (concat(a,space(5)));
+let $values1 = 'Hello', default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # STRCMP()
+let $cols = a varchar(9), b varchar(9), c tinyint(1) as (strcmp(a,b));
+let $values1 = 'Hello','Hello', default;
+let $values2 = 'Hello','Hello1', default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # SUBSTR()
+let $cols = a varchar(5), b varchar(10) as (substr(a,2));
+let $values1 = 'Hello',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # SUBSTRING_INDEX()
+let $cols = a varchar(15), b varchar(10) as (substring_index(a,'.',2));
+let $values1 = 'www.mysql.com',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # SUBSTRING()
+let $cols = a varchar(5), b varchar(10) as (substring(a from 2 for 2));
+let $values1 = 'Hello',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # TRIM()
+let $cols = a varchar(15), b varchar(10) as (trim(a));
+let $values1 = ' aa ',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # UCASE()
+let $cols = a varchar(5), b varchar(10) as (ucase(a));
+let $values1 = 'MySQL',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # UNHEX()
+let $cols = a varchar(15), b varchar(10) as (unhex(a));
+let $values1 = '4D7953514C',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # UPPER()
+let $cols = a varchar(5), b varchar(10) as (upper(a));
+let $values1 = 'MySQL',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo #
+--echo # CONTROL FLOW FUNCTIONS
+--echo #
+
+--echo # CASE
+let $cols = a varchar(10), b varchar(16) as (case a when NULL then 'asd' when 'b' then 'B' else a end);
+let $values1 = NULL,default;
+let $values2 = 'b',default;
+let $values3 = 'c',default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # IF
+let $cols = a int, b int, c int as (if(a=1,a,b));
+let $values1 = 1,2,default;
+let $values2 = 3,4,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # IFNULL
+let $cols = a varchar(10), b varchar(10), c varchar(10) as (ifnull(a,'DEFAULT'));
+let $values1 = NULL,'adf',default;
+let $values2 = 'a','adf',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # NULLIF
+let $cols = a varchar(10), b varchar(10) as (nullif(a,'DEFAULT'));
+let $values1 = 'DEFAULT',default;
+let $values2 = 'a',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo #
+--echo # OPERATORS
+--echo #
+
+--echo # AND, &&
+let $cols = a int, b bool as (a>0 && a<2);
+let $values1 = -1,default;
+let $values2 = 1,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # BETWEEN ... AND ...
+let $cols = a int, b bool as (a between 0 and 2);
+let $values1 = -1,default;
+let $values2 = 1,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # BINARY
+let $cols = a varchar(10), b varbinary(10) as (binary a);
+let $values1 = '11',default;
+let $values2 = 1,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # &
+let $cols = a int, b int as (a & 5);
+let $values1 = 1,default;
+let $values2 = 0,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # ~
+let $cols = a int, b int as (~a);
+let $values1 = 1,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # |
+let $cols = a int, b int as (a | 5);
+let $values1 = 1,default;
+let $values2 = 0,default;
+let $values3 = 2,default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # ^
+let $cols = a int, b int as (a ^ 5);
+let $values1 = 1,default;
+let $values2 = 0,default;
+let $values3 = 2,default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # DIV
+let $cols = a int, b int as (a div 5);
+let $values1 = 1,default;
+let $values2 = 7,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # <=>
+let $cols = a int, b int, c bool as (a <=> b);
+let $values1 = 1,1,default;
+let $values2 = NULL,NULL,default;
+let $values3 = 1,NULL,default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # =
+let $cols = a varchar(10), b varchar(10), c bool as (a=b);
+let $values1 = 'a','b',default;
+let $values2 = 'a','a',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # >=
+let $cols = a varchar(10), b varchar(10), c bool as (a >= b);
+let $values1 = 'a','b',default;
+let $values2 = 'a','a',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # >
+let $cols = a varchar(10), b varchar(10), c bool as (a > b);
+let $values1 = 'a','b',default;
+let $values2 = 'a','a',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # IS NOT NULL
+let $cols = a int, b bool as (a is not null);
+let $values1 = 1,default;
+let $values2 = NULL,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # IS NULL
+let $cols = a int, b bool as (a is null);
+let $values1 = 1,default;
+let $values2 = NULL,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # <<
+let $cols = a int, b int as (a << 2);
+let $values1 = 1,default;
+let $values2 = 3,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # <=
+let $cols = a varchar(10), b varchar(10), c bool as (a <= b);
+let $values1 = 'b','a',default;
+let $values2 = 'b','b',default;
+let $values3 = 'b','c',default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # <
+let $cols = a varchar(10), b varchar(10), c bool as (a < b);
+let $values1 = 'b','a',default;
+let $values2 = 'b','b',default;
+let $values3 = 'b','c',default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # NOT BETWEEN ... AND ...
+let $cols = a int, b bool as (a not between 0 and 2);
+let $values1 = -1,default;
+let $values2 = 1,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # <>
+let $cols = a varchar(10), b varchar(10), c bool as (a <> b);
+let $values1 = 'b','a',default;
+let $values2 = 'b','b',default;
+let $values3 = 'b','c',default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # !=
+let $cols = a varchar(10), b varchar(10), c bool as (a != b);
+let $values1 = 'b','a',default;
+let $values2 = 'b','b',default;
+let $values3 = 'b','c',default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # ||, OR
+let $cols = a int, b int as (a>5 || a<3);
+let $values1 = 1,default;
+let $values2 = 4,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # >>
+let $cols = a int, b int as (a >> 2);
+let $values1 = 8,default;
+let $values2 = 3,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # XOR
+let $cols = a int, b int as (a xor 5);
+let $values1 = 0,default;
+let $values2 = 1,default;
+let $values3 = 2,default;
+let $rows = 3;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo #
+--echo # DATE AND TIME FUNCTIONS
+--echo #
+
+--echo # ADDDATE()
+let $cols = a datetime, b datetime as (adddate(a,interval 1 month));
+let $values1 = '2008-08-31',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # ADDTIME()
+let $cols = a datetime, b datetime as (addtime(a,'02:00:00'));
+let $values1 = '2008-08-31',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # CONVERT_TZ()
+let $cols = a datetime, b datetime as (convert_tz(a,'MET','UTC'));
+let $values1 = '2008-08-31',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # DATE_ADD()
+let $cols = a datetime, b datetime as (date_add(a,interval 1 month));
+let $values1 = '2008-08-31',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # DATE_SUB()
+let $cols = a datetime, b datetime as (date_sub(a,interval 1 month));
+let $values1 = '2008-08-31',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # DATE()
+let $cols = a datetime, b datetime as (date(a));
+let $values1 = '2008-08-31 02:00:00',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # DATEDIFF()
+let $cols = a datetime, b long as (datediff(a,'2000-01-01'));
+let $values1 = '2008-08-31',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # DAY()
+let $cols = a datetime, b int as (day(a));
+let $values1 = '2008-08-31',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # DAYOFMONTH()
+let $cols = a datetime, b int as (dayofmonth(a));
+let $values1 = '2008-08-31',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # DAYOFWEEK()
+let $cols = a datetime, b int as (dayofweek(a));
+let $values1 = '2008-08-31',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # DAYOFYEAR()
+let $cols = a datetime, b int as (dayofyear(a));
+let $values1 = '2008-08-31',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # EXTRACT
+let $cols = a datetime, b int as (extract(year from a));
+let $values1 = '2008-08-31',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # FROM_DAYS()
+let $cols = a long, b datetime as (from_days(a));
+let $values1 = 730669,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # FROM_UNIXTIME()
+let $cols = a long, b datetime as (from_unixtime(a));
+let $values1 = 1196440219,default;
+let $rows = 1;
+set time_zone='UTC';
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # HOUR()
+let $cols = a time, b long as (hour(a));
+let $values1 = '10:05:03',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # LAST_DAY()
+let $cols = a datetime, b datetime as (last_day(a));
+let $values1 = '2003-02-05',default;
+let $values2 = '2003-02-32',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # MAKEDATE()
+let $cols = a int, b datetime as (makedate(a,1));
+let $values1 = 2001,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # MAKETIME()
+let $cols = a int, b time as (maketime(a,1,3));
+let $values1 = 12,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # MICROSECOND()
+let $cols = a datetime, b long as (microsecond(a));
+let $values1 = '2009-12-31 12:00:00.123456',default;
+let $values2 = '2009-12-31 23:59:59.000010',default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # MINUTE()
+let $cols = a datetime, b int as (minute(a));
+let $values1 = '2009-12-31 23:59:59.000010',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # MONTH()
+let $cols = a datetime, b int as (month(a));
+let $values1 = '2009-12-31 23:59:59.000010',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # PERIOD_ADD()
+let $cols = a int, b int as (period_add(a,2));
+let $values1 = 200801,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # PERIOD_DIFF()
+let $cols = a int, b int, c int as (period_diff(a,b));
+let $values1 = 200802,200703,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # QUARTER()
+let $cols = a datetime, b int as (quarter(a));
+let $values1 = '2008-08-31',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # SEC_TO_TIME()
+let $cols = a long, b time as (sec_to_time(a));
+let $values1 = 2378,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # SECOND()
+let $cols = a datetime, b int as (second(a));
+let $values1 = '10:05:03',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # STR_TO_DATE()
+let $cols = a varchar(64), b datetime as (str_to_date(a,'%m/%d/%Y'));
+let $values1 = '04/30/2004',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # SUBDATE()
+let $cols = a datetime, b datetime as (subdate(a,interval 1 month));
+let $values1 = '2008-08-31',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # SUBTIME()
+let $cols = a datetime, b datetime as (subtime(a,'02:00:00'));
+let $values1 = '2008-08-31',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # TIME_TO_SEC()
+let $cols = a time, b long as (time_to_sec(a));
+let $values1 = '22:23:00',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # TIME()
+let $cols = a datetime, b time as (time(a));
+let $values1 = '2008-08-31 02:03:04',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # TIMEDIFF()
+let $cols = a datetime, b datetime, c long as (timediff(a,b));
+let $values1 = '2008-12-31 23:59:59.000001','2008-12-30 01:01:01.000002',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # TIMESTAMP()
+let $cols = a datetime, b timestamp as (timestamp(a));
+let $values1 = '2008-12-31',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # TIMESTAMPADD()
+let $cols = a datetime, b timestamp as (timestampadd(minute,1,a));
+let $values1 = '2003-01-02',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # TIMESTAMPDIFF()
+let $cols = a timestamp, b timestamp, c long as (timestampdiff(MONTH, a,b));
+let $values1 = '2003-02-01','2003-05-01',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # TO_DAYS()
+let $cols = a datetime, b long as (to_days(a));
+let $values1 = '2007-10-07',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # WEEK()
+let $cols = a datetime, b int as (week(a,0));
+let $values1 = '2008-09-01',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # WEEKDAY()
+let $cols = a datetime, b int as (weekday(a));
+let $values1 = '2008-09-01',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # WEEKOFYEAR()
+let $cols = a datetime, b int as (weekofyear(a));
+let $values1 = '2008-09-01',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # YEAR()
+let $cols = a datetime, b int as (year(a));
+let $values1 = '2008-09-01',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # YEARWEEK()
+let $cols = a datetime, b int as (yearweek(a));
+let $values1 = '2008-09-01',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo #
+--echo # FULL TEXT SEARCH FUNCTIONS
+--echo #
+--echo # None.
+
+--echo #
+--echo # CAST FUNCTIONS AND OPERATORS
+--echo #
+
+--echo # CAST()
+let $cols = a int, b long as (cast(a as unsigned));
+let $values1 = 1,default;
+let $values2 = -1,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # Convert()
+let $cols = a int, b long as (convert(a,unsigned));
+let $values1 = 1,default;
+let $values2 = -1,default;
+let $rows = 2;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo #
+--echo # XML FUNCTIONS
+--echo #
+--echo # None.
+
+
+--echo #
+--echo # OTHER FUNCTIONS
+--echo #
+
+--echo # AES_DECRYPT(), AES_ENCRYPT()
+let $cols = a varchar(1024), b varchar(1024) as (aes_encrypt(aes_decrypt(a,'adf'),'adf'));
+let $values1 = 'MySQL',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # BIT_COUNT()
+let $cols = a int, b int as (bit_count(a));
+let $values1 = 5,default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # COMPRESS(), UNCOMPRESS()
+let $cols = a varchar(1024), b varchar(1024) as (uncompress(compress(a)));
+let $values1 = 'MySQL',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # ENCODE(), DECODE()
+let $cols = a varchar(1024), b varchar(1024) as (decode(encode(a,'abc'),'abc'));
+let $values1 = 'MySQL',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # DEFAULT()
+let $cols = a varchar(1024) default 'aaa', b varchar(1024) as (ifnull(a,default(a)));
+let $values1 = 'any value',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+#--echo # DES_ENCRYPT(), DES_DECRYPT()
+#--source include/have_ssl_communication.inc
+#let $cols = a varchar(1024), b varchar(1024) as (des_encrypt(des_decrypt(a,'adf'),'adf'));
+#let $values1 = 'MySQL',default;
+#let $rows = 1;
+#--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # INET_ATON(), INET_NTOA()
+let $cols = a varchar(1024), b varchar(1024) as (inet_ntoa(inet_aton(a)));
+let $values1 = '127.0.0.1',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # MD5()
+let $cols = a varchar(1024), b varbinary(32) as (md5(a));
+let $values1 = 'testing',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # OLD_PASSWORD()
+let $cols = a varchar(1024), b varchar(1024) as (old_password(a));
+let $values1 = 'badpwd',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # PASSWORD()
+let $cols = a varchar(1024), b varchar(1024) as (password(a));
+let $values1 = 'badpwd',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # SHA1()
+let $cols = a varchar(1024), b varchar(1024) as (sha1(a));
+let $values1 = 'abc',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # SHA()
+let $cols = a varchar(1024), b varchar(1024) as (sha(a));
+let $values1 = 'abc',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # UNCOMPRESSED_LENGTH()
+let $cols = a char, b varchar(1024) as (uncompressed_length(compress(repeat(a,30))));
+let $values1 = 'a',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # MONTHNAME()
+let $cols = a date, b varchar(100) as (monthname(a));
+let $values1 = '2010-10-10',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # DAYNAME()
+let $cols = a date, b varchar(100) as (dayname(a));
+let $values1 = '2011-11-11',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # DATE_FORMAT()
+let $cols = a date, b varchar(100) as (date_format(a, '%W %a %M %b'));
+let $values1 = '2012-12-12',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # DATE_FORMAT() STORED
+let $cols = a date, b varchar(100) as (date_format(a, '%W %a %M %b', 'de_DE')) STORED;
+let $values1 = '2012-12-12',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # CURRENT_USER()
+let $cols = a char, b varchar(32) as (current_user());
+let $values1 = 'a', default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # TIME_FORMAT()
+let $cols = a datetime, b varchar(10) as (time_format(a,"%H.%i.%S"));
+let $values1 = '2001-01-01 02:03:04',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
+--echo # TIME_FORMAT() STORED
+let $cols = a datetime, b varchar(10) as (time_format(a,"%H.%i.%S")) STORED;
+let $values1 = '2001-01-01 02:03:04',default;
+let $rows = 1;
+--source suite/vcol/inc/vcol_supported_sql_funcs.inc
+
diff --git a/mysql-test/suite/vcol/t/vcol_syntax.test b/mysql-test/suite/vcol/t/vcol_syntax.test
new file mode 100644
index 00000000..c26c4897
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_syntax.test
@@ -0,0 +1,189 @@
+#
+# test syntax
+#
+set @OLD_SQL_MODE=@@SESSION.SQL_MODE;
+create table t1 (a int, b int generated always as (a+1));
+show create table t1;
+drop table t1;
+create table t1 (a int, b int as (a+1) virtual);
+show create table t1;
+drop table t1;
+create table t1 (a int, b int generated always as (a+1) persistent);
+show create table t1;
+drop table t1;
+
+set session sql_mode='ORACLE';
+create table t1 (a int, b int as (a+1));
+show create table t1;
+drop table t1;
+create table t1 (a int, b int generated always as (a+1) virtual);
+show create table t1;
+drop table t1;
+create table t1 (a int, b int as (a+1) persistent);
+show create table t1;
+drop table t1;
+set session sql_mode=@OLD_SQL_MODE;
+
+--echo #
+--echo # MDEV-25091 CREATE TABLE: field references qualified by a wrong table name succeed
+--echo #
+create table t2 (x int);
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create table t1 (x int, y int generated always as (t2.x));
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create table t1 (x int, y int check (y > t2.x));
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create table t1 (x int, y int default t2.x);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create table t1 (x int, check (t2.x > 0));
+
+create table t1 (x int);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+alter table t1 add column y int generated always as (t2.x);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+alter table t1 add column y int check (z > t2.x);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+alter table t1 add column y int default t2.x;
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+alter table t1 add constraint check (t2.x > 0);
+
+create or replace table t1 (x int, y int generated always as (t1.x));
+create or replace table t1 (x int, y int check (y > t1.x));
+create or replace table t1 (x int, y int default t1.x);
+create or replace table t1 (x int, check (t1.x > 0));
+
+create or replace table t1 (x int, y int generated always as (test.t1.x));
+create or replace table t1 (x int, y int check (y > test.t1.x));
+create or replace table t1 (x int, y int default test.t1.x);
+create or replace table t1 (x int, check (test.t1.x > 0));
+
+drop tables t1, t2;
+
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create table t1 (x int, y int generated always as (test2.t1.x));
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create table t1 (x int, y int check (y > test2.t1.x));
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create table t1 (x int, y int default test2.t1.x);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+create table t1 (x int, check (test2.t1.x > 0));
+
+--echo #
+--echo # MDEV-25672 table alias from previous statement interferes later commands
+--echo #
+create table t1 (a int, v_a int generated always as (a));
+update t1 as x set a = 1;
+alter table t1 force;
+drop table t1;
+
+create table t1 (
+ id int not null auto_increment primary key,
+ order_date_time datetime not null,
+ order_date date generated always as (convert(order_date_time, date)),
+ language_id binary(16) null
+);
+
+update t1 as tx set order_date= null;
+alter table t1 modify column language_id binary(16) not null;
+# Cleanup
+drop table t1;
+
+--echo #
+--echo # MDEV-24176 Server crashes after insert in the table with virtual column generated using date_format() and if()
+--echo #
+create table t1 (d1 date not null, d2 date not null,
+ gd text as (concat(d1,if(d1 <> d2, date_format(d2, 'to %y-%m-%d '), ''))) );
+
+insert into t1(d1,d2) values
+ ('2020-09-01','2020-09-01'),('2020-05-01','2020-09-01');
+select * from t1;
+
+drop table t1;
+
+--echo # MDEV-25772 (duplicate) and LOCK TABLES case
+create table t1 (d1 datetime , v_d1 tinyint(1) as (d1 < curdate()));
+insert into t1 (d1) values ('2021-09-11 08:38:23'), ('2021-09-01 08:38:23');
+
+lock tables t1 write;
+select * from t1 where v_d1=1;
+select * from t1;
+unlock tables;
+
+drop table t1;
+
+--echo # MDEV-26432 (duplicate)
+create table t1 (v2 int, v1 int as ((user() like 'x'))) ;
+select 1 from t1 where v1=1 ;
+select * from t1;
+
+drop table t1;
+
+create table t1 (v2 int as ( user () like 'x'));
+select 1 from t1 order by v2 ;
+alter table t1 add i int;
+drop table t1;
+
+--echo # MDEV-26437 (duplicate)
+create table v0 (v2 int not null,
+ v1 bigint as (case 'x' when current_user() then v2 end));
+
+select v2 as v3 from v0 where v1 like 'x' escape 'x';
+insert into v0 (v2) values (-128);
+
+drop table v0;
+
+create table t1 (vi int as (case 'x' when current_user() then 1 end));
+select 1 from t1 where vi=1;
+show create table t1;
+
+drop table t1;
+
+create table t1 (vi int as (case 'x' when current_user() then 1 end));
+select 1 from t1 where vi=1;
+select 1 from t1 where vi=1;
+
+drop table t1;
+
+--echo # MDEV-28092 (duplicate)
+create table t1 (b timestamp, a int as (1 in (dayofmonth (b between 'x' and current_user) = b)));
+insert into t1(b) values ('2022-03-17 14:55:37');
+
+select 1 from t1 x natural join t1;
+drop table t1;
+
+--echo # MDEV-28089 (duplicate)
+create table t1 (a int , b date as (1 in ('x' ,(database () = 'x' is null) ))) ;
+select b from t1;
+select a from t1 order by 'x' = b;
+drop table t1;
+
+create table t1 (a int , b date as (1 in ('x' ,(database ()) ))) ;
+select b from t1;
+select a from t1 order by 'x' = b;
+drop table t1;
+
+--echo #
+--echo # MDEV-31319 Assertion const_item_cache == true failed in Item_func::fix_fields
+--echo #
+create table t (f1 int, f2 int, fv int generated always as (case user() when 'foo' or 'bar' then f1 else f2 end) virtual);
+select * from t;
+insert into t (f1,f2) values(1,1);
+select * from t;
+create table tmp as select * from information_schema.tables where table_name = 't';
+select * from t;
+
+# cleanup
+drop table t, tmp;
+
+--echo #
+--echo # MDEV-29357 Assertion (fixed) in Item_func_dayname on INSERT
+--echo #
+set sql_mode='';
+create table t (c1 blob ,c2 int,c3 char(10) as (dayname (c2)));
+create trigger tr before insert on t for each row set new.c2=0;
+insert into t values (0, 0, 0);
+insert into t values (1, 1, 1);
+
+drop trigger tr;
+drop table t;
diff --git a/mysql-test/suite/vcol/t/vcol_trigger_sp_innodb.test b/mysql-test/suite/vcol/t/vcol_trigger_sp_innodb.test
new file mode 100644
index 00000000..c35a1279
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_trigger_sp_innodb.test
@@ -0,0 +1,52 @@
+################################################################################
+# t/vcol_trigger_sp_innodb.test #
+# #
+# Purpose: #
+# Testing triggers, stored procedures and functions #
+# defined on tables with virtual columns. #
+# #
+# InnoDB branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+--source include/have_innodb.inc
+eval SET @@session.default_storage_engine = 'InnoDB';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_trigger_sp.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_trigger_sp_myisam.test b/mysql-test/suite/vcol/t/vcol_trigger_sp_myisam.test
new file mode 100644
index 00000000..d5f36d80
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_trigger_sp_myisam.test
@@ -0,0 +1,51 @@
+################################################################################
+# t/vcol_trigger_sp_myisam.test #
+# #
+# Purpose: #
+# Testing triggers, stored procedures and functions #
+# defined on tables with virtual columns. #
+# #
+# MyISAM branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+eval SET @@session.default_storage_engine = 'MyISAM';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_trigger_sp.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_view_innodb.test b/mysql-test/suite/vcol/t/vcol_view_innodb.test
new file mode 100644
index 00000000..3b869425
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_view_innodb.test
@@ -0,0 +1,55 @@
+################################################################################
+# t/vcol_view_innodb.test #
+# #
+# Purpose: #
+# Testing views defined on tables with virtual columns. #
+# #
+# InnoDB branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+--source include/have_innodb.inc
+eval SET @@session.default_storage_engine = 'InnoDB';
+SET @save_innodb_stats_persistent=@@GLOBAL.innodb_stats_persistent;
+SET GLOBAL innodb_stats_persistent=0;
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_view.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent;
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/vcol_view_myisam.test b/mysql-test/suite/vcol/t/vcol_view_myisam.test
new file mode 100644
index 00000000..1b4a387a
--- /dev/null
+++ b/mysql-test/suite/vcol/t/vcol_view_myisam.test
@@ -0,0 +1,50 @@
+################################################################################
+# t/vcol_view_myisam.test #
+# #
+# Purpose: #
+# Testing views defined on tables with virtual columns. #
+# #
+# MyISAM branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: Andrey Zhakov #
+# Original Date: 2008-09-04 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+--source suite/vcol/inc/vcol_init_vars.pre
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+# Set the session storage engine
+eval SET @@session.default_storage_engine = 'MyISAM';
+
+##### Workarounds for known open engine specific bugs
+# none
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/vcol/inc/vcol_view.inc
+
+#------------------------------------------------------------------------------#
+# Execute storage engine specific tests
+
+#------------------------------------------------------------------------------#
+# Cleanup
+--source suite/vcol/inc/vcol_cleanup.inc
diff --git a/mysql-test/suite/vcol/t/wrong_arena.test b/mysql-test/suite/vcol/t/wrong_arena.test
new file mode 100644
index 00000000..4b6f9415
--- /dev/null
+++ b/mysql-test/suite/vcol/t/wrong_arena.test
@@ -0,0 +1,66 @@
+#
+# This tests various issues when vcol items allocate memory (e.g. more items)
+# not in the TABLE::expr_arena.
+#
+
+--echo #
+--echo # MDEV-9690 concurrent queries with virtual columns crash in temporal code
+--echo #
+create table t1 (a datetime,
+ # get_datetime_value
+ b int as (a > 1), # Arg_comparator
+ c int as (a in (1,2,3)), # in_datetime
+ d int as ((a,a) in ((1,1),(2,1),(NULL,1))), # cmp_item_datetime
+ # other issues
+ e int as ((a,1) in ((1,1),(2,1),(NULL,1))) # cmp_item_row::alloc_comparators()
+);
+enable_prepare_warnings;
+show create table t1;
+disable_prepare_warnings;
+connect con1, localhost, root;
+disable_warnings;
+insert t1 (a) values ('2010-10-10 10:10:10');
+enable_warnings;
+#Enable after fix MDEV-31359
+--disable_ps2_protocol
+select * from t1;
+--enable_ps2_protocol
+disconnect con1;
+connection default;
+disable_warnings;
+select * from t1;
+enable_warnings;
+drop table t1;
+
+connect con1, localhost, root;
+create table t1 (a datetime,
+ b datetime as (least(a,1)) # Item_func_min_max::get_date
+);
+insert t1 (a) values ('2010-10-10 10:10:10');
+select * from t1;
+disconnect con1;
+connection default;
+select * from t1;
+drop table t1;
+
+--echo #
+--echo # MDEV-13435 Crash when selecting virtual columns generated using JSON functions
+--echo #
+create table t1 (
+ id int not null ,
+ js varchar(1000) not null,
+ t time AS (cast(json_value(json_extract(js,concat('$.singleDay."', dayname(curdate()),'"')),'$.start') as time)) virtual);
+insert into t1(id,js) values (0, '{"default" : {"start": "00:00:00", "end":"23:59:50"}}');
+select * from t1;
+drop table t1;
+
+--echo #
+--echo # MDEV-26281 ASAN use-after-poison when complex conversion is involved in blob
+--echo #
+create table t1 (v2 blob as ('a' is null), a1 int, a char(1) as (cast(a1 in (0,current_user() is null) as char(16777216) )));
+insert ignore into t1 values ('x','x',v2) ;
+drop table t1;
+
+--echo #
+--echo # End of 10.2 tests
+--echo #