summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-05-27 17:10:39 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-05-27 17:10:39 +0300
commitdad7a8ee7dab99c0ba3d98ac12d0235462f3029e (patch)
treebdfa61bfebb73cf1c5c06a1e3931dd7d2d4b0d77 /mysql-test
parent7476e8c7cdd73d60294126a2840baee97e7644b6 (diff)
parent5139cfabb3bfc62be38e651ff176580e0aba09b8 (diff)
downloadmariadb-git-dad7a8ee7dab99c0ba3d98ac12d0235462f3029e.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/main/partition_alter.result53
-rw-r--r--mysql-test/main/partition_alter.test54
-rw-r--r--mysql-test/main/processlist_notembedded.result3
-rw-r--r--mysql-test/main/processlist_notembedded.test3
-rw-r--r--mysql-test/main/selectivity.result15
-rw-r--r--mysql-test/main/selectivity.test12
-rw-r--r--mysql-test/main/selectivity_innodb.result15
-rw-r--r--mysql-test/suite/maria/bulk_insert_crash.opt2
-rw-r--r--mysql-test/suite/maria/bulk_insert_crash.result13
-rw-r--r--mysql-test/suite/maria/bulk_insert_crash.test36
-rw-r--r--mysql-test/suite/rpl/r/rpl_parallel_optimistic_until.result291
-rw-r--r--mysql-test/suite/rpl/t/rpl_parallel_optimistic_until.test465
-rw-r--r--mysql-test/suite/vcol/r/vcol_keys_myisam.result9
-rw-r--r--mysql-test/suite/vcol/t/vcol_keys_myisam.test11
14 files changed, 975 insertions, 7 deletions
diff --git a/mysql-test/main/partition_alter.result b/mysql-test/main/partition_alter.result
index d946f2b8822..997a5cf97fa 100644
--- a/mysql-test/main/partition_alter.result
+++ b/mysql-test/main/partition_alter.result
@@ -122,7 +122,55 @@ t1 CREATE TABLE `t1` (
PARTITION `p02` ENGINE = MyISAM,
PARTITION `p03` ENGINE = MyISAM)
drop table t1;
-create or replace table t1 (x int) partition by hash (x) (partition p1, partition p2);
+#
+# MDEV-19751 Wrong partitioning by KEY() after key dropped
+#
+create or replace table t1 (pk int, x timestamp(6), primary key (pk, x)) engine innodb
+partition by key() partitions 2;
+insert into t1 (pk, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+# Inplace for DROP PRIMARY KEY when partitioned by default field list is denied
+alter table t1 drop primary key, drop column x, add primary key (pk), algorithm=inplace;
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
+alter table t1 drop primary key, drop column x, add primary key (pk);
+select * from t1 partition (p0);
+pk
+1
+drop table t1;
+create or replace table t1 (pk int not null, x timestamp(6), unique u(pk, x)) engine innodb
+partition by key() partitions 2;
+insert into t1 (pk, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+# Same for NOT NULL UNIQUE KEY as this is actually primary key
+alter table t1 drop key u, drop column x, add unique (pk), algorithm=inplace;
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
+alter table t1 drop key u, drop column x, add unique (pk);
+select * from t1 partition (p0);
+pk
+1
+drop table t1;
+create or replace table t1 (pk int, x timestamp(6), primary key (pk)) engine innodb
+partition by key(pk) partitions 2;
+insert into t1 (pk, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+# Inplace for DROP PRIMARY KEY when partitioned by explicit field list is allowed
+alter table t1 drop primary key, add primary key (pk, x), algorithm=inplace;
+select * from t1 partition (p0);
+pk x
+1 2000-01-01 00:00:00.000000
+drop table t1;
+create or replace table t1 (k int, x timestamp(6), unique key u (x, k)) engine innodb
+partition by key(k) partitions 2;
+insert into t1 (k, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+# Inplace for DROP KEY is allowed
+alter table t1 drop key u, algorithm=inplace;
+select * from t1 partition (p0);
+k x
+1 2000-01-01 00:00:00.000000
+drop table t1;
+# End of 10.2 tests
+#
+# MDEV-14817 Server crashes in prep_alter_part_table()
+# after table lock and multiple add partition
+#
+create table t1 (x int) partition by hash (x) (partition p1, partition p2);
lock table t1 write;
alter table t1 add partition (partition p1);
ERROR HY000: Duplicate partition name p1
@@ -134,7 +182,7 @@ drop table t1;
# ha_partition::update_row or `part_id == m_last_part' in
# ha_partition::delete_row upon UPDATE/DELETE after dropping versioning
#
-create or replace table t1 (pk int, f int, primary key(pk, f)) engine=innodb
+create table t1 (pk int, f int, primary key(pk, f)) engine=innodb
partition by key() partitions 2;
insert into t1 values (1,10),(2,11);
# expected to hit same partition
@@ -152,3 +200,4 @@ pk
2
delete from t1;
drop table t1;
+# End of 10.3 tests
diff --git a/mysql-test/main/partition_alter.test b/mysql-test/main/partition_alter.test
index dbe7802b5fb..804b43dc3c2 100644
--- a/mysql-test/main/partition_alter.test
+++ b/mysql-test/main/partition_alter.test
@@ -113,10 +113,52 @@ alter online table t1 delay_key_write=1;
show create table t1;
drop table t1;
-#
-# MDEV-14817 Server crashes in prep_alter_part_table() after table lock and multiple add partition
-#
-create or replace table t1 (x int) partition by hash (x) (partition p1, partition p2);
+--echo #
+--echo # MDEV-19751 Wrong partitioning by KEY() after key dropped
+--echo #
+create or replace table t1 (pk int, x timestamp(6), primary key (pk, x)) engine innodb
+partition by key() partitions 2;
+insert into t1 (pk, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+--echo # Inplace for DROP PRIMARY KEY when partitioned by default field list is denied
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+alter table t1 drop primary key, drop column x, add primary key (pk), algorithm=inplace;
+alter table t1 drop primary key, drop column x, add primary key (pk);
+select * from t1 partition (p0);
+drop table t1;
+
+create or replace table t1 (pk int not null, x timestamp(6), unique u(pk, x)) engine innodb
+partition by key() partitions 2;
+insert into t1 (pk, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+--echo # Same for NOT NULL UNIQUE KEY as this is actually primary key
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+alter table t1 drop key u, drop column x, add unique (pk), algorithm=inplace;
+alter table t1 drop key u, drop column x, add unique (pk);
+select * from t1 partition (p0);
+drop table t1;
+
+create or replace table t1 (pk int, x timestamp(6), primary key (pk)) engine innodb
+partition by key(pk) partitions 2;
+insert into t1 (pk, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+--echo # Inplace for DROP PRIMARY KEY when partitioned by explicit field list is allowed
+alter table t1 drop primary key, add primary key (pk, x), algorithm=inplace;
+select * from t1 partition (p0);
+drop table t1;
+
+create or replace table t1 (k int, x timestamp(6), unique key u (x, k)) engine innodb
+partition by key(k) partitions 2;
+insert into t1 (k, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+--echo # Inplace for DROP KEY is allowed
+alter table t1 drop key u, algorithm=inplace;
+select * from t1 partition (p0);
+drop table t1;
+
+--echo # End of 10.2 tests
+
+--echo #
+--echo # MDEV-14817 Server crashes in prep_alter_part_table()
+--echo # after table lock and multiple add partition
+--echo #
+create table t1 (x int) partition by hash (x) (partition p1, partition p2);
lock table t1 write;
--error ER_SAME_NAME_PARTITION
alter table t1 add partition (partition p1);
@@ -129,7 +171,7 @@ drop table t1;
--echo # ha_partition::update_row or `part_id == m_last_part' in
--echo # ha_partition::delete_row upon UPDATE/DELETE after dropping versioning
--echo #
-create or replace table t1 (pk int, f int, primary key(pk, f)) engine=innodb
+create table t1 (pk int, f int, primary key(pk, f)) engine=innodb
partition by key() partitions 2;
insert into t1 values (1,10),(2,11);
@@ -142,3 +184,5 @@ select * from t1 partition(p0);
select * from t1 partition(p1);
delete from t1;
drop table t1;
+
+--echo # End of 10.3 tests
diff --git a/mysql-test/main/processlist_notembedded.result b/mysql-test/main/processlist_notembedded.result
index e663c407a1b..6231abb6550 100644
--- a/mysql-test/main/processlist_notembedded.result
+++ b/mysql-test/main/processlist_notembedded.result
@@ -8,6 +8,9 @@ connection default;
SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
FOUND 1 /sleep/ in MDEV-20466.text
SET DEBUG_SYNC= 'now SIGNAL go';
+connection con1;
+user
disconnect con1;
+connection default;
SET DEBUG_SYNC = 'RESET';
End of 5.5 tests
diff --git a/mysql-test/main/processlist_notembedded.test b/mysql-test/main/processlist_notembedded.test
index 4979e40a85a..6f269a816fc 100644
--- a/mysql-test/main/processlist_notembedded.test
+++ b/mysql-test/main/processlist_notembedded.test
@@ -30,7 +30,10 @@ remove_file $MYSQLTEST_VARDIR/tmp/MDEV-20466.text;
SET DEBUG_SYNC= 'now SIGNAL go';
+connection con1;
+reap;
disconnect con1;
+connection default;
SET DEBUG_SYNC = 'RESET';
diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result
index 64058f45cfa..b446c3591b9 100644
--- a/mysql-test/main/selectivity.result
+++ b/mysql-test/main/selectivity.result
@@ -1871,5 +1871,20 @@ id select_type table type possible_keys key key_len ref rows Extra
set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2;
+#
+# MDEV-21495: Conditional jump or move depends on uninitialised value in sel_arg_range_seq_next
+#
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 SELECT seq, seq from seq_1_to_100;
+set optimizer_use_condition_selectivity=4;
+ANALYZE TABLE t1 PERSISTENT FOR ALL;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+SELECT * from t1 WHERE a = 5 and b = 5;
+a b
+5 5
+set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+drop table t1;
# End of 10.1 tests
set @@global.histogram_size=@save_histogram_size;
diff --git a/mysql-test/main/selectivity.test b/mysql-test/main/selectivity.test
index c9e1bea1f12..a31573edb8e 100644
--- a/mysql-test/main/selectivity.test
+++ b/mysql-test/main/selectivity.test
@@ -1272,6 +1272,18 @@ set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2;
+--echo #
+--echo # MDEV-21495: Conditional jump or move depends on uninitialised value in sel_arg_range_seq_next
+--echo #
+
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 SELECT seq, seq from seq_1_to_100;
+set optimizer_use_condition_selectivity=4;
+ANALYZE TABLE t1 PERSISTENT FOR ALL;
+SELECT * from t1 WHERE a = 5 and b = 5;
+set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+drop table t1;
+
--echo # End of 10.1 tests
#
diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result
index ad0034d60e3..9cf65d1f950 100644
--- a/mysql-test/main/selectivity_innodb.result
+++ b/mysql-test/main/selectivity_innodb.result
@@ -1881,6 +1881,21 @@ id select_type table type possible_keys key key_len ref rows Extra
set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2;
+#
+# MDEV-21495: Conditional jump or move depends on uninitialised value in sel_arg_range_seq_next
+#
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 SELECT seq, seq from seq_1_to_100;
+set optimizer_use_condition_selectivity=4;
+ANALYZE TABLE t1 PERSISTENT FOR ALL;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+SELECT * from t1 WHERE a = 5 and b = 5;
+a b
+5 5
+set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+drop table t1;
# End of 10.1 tests
set @@global.histogram_size=@save_histogram_size;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
diff --git a/mysql-test/suite/maria/bulk_insert_crash.opt b/mysql-test/suite/maria/bulk_insert_crash.opt
new file mode 100644
index 00000000000..f85a8d9c973
--- /dev/null
+++ b/mysql-test/suite/maria/bulk_insert_crash.opt
@@ -0,0 +1,2 @@
+--skip-stack-trace --skip-core-file
+--default-storage-engine=Aria
diff --git a/mysql-test/suite/maria/bulk_insert_crash.result b/mysql-test/suite/maria/bulk_insert_crash.result
new file mode 100644
index 00000000000..fc28bf325ba
--- /dev/null
+++ b/mysql-test/suite/maria/bulk_insert_crash.result
@@ -0,0 +1,13 @@
+create table t1 (a int primary key, b int, c int, unique key(b), key(c)) engine=aria transactional=1;
+insert into t1 values (1000,1000,1000);
+insert into t1 select seq,seq+100, seq+200 from seq_1_to_10;
+SET GLOBAL debug_dbug="+d,crash_end_bulk_insert";
+REPLACE into t1 select seq+20,seq+95, seq + 300 from seq_1_to_10;
+ERROR HY000: Lost connection to MySQL server during query
+check table t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+select sum(a),sum(b),sum(c) from t1;
+sum(a) sum(b) sum(c)
+1055 2055 3055
+drop table t1;
diff --git a/mysql-test/suite/maria/bulk_insert_crash.test b/mysql-test/suite/maria/bulk_insert_crash.test
new file mode 100644
index 00000000000..d9167c3f0d7
--- /dev/null
+++ b/mysql-test/suite/maria/bulk_insert_crash.test
@@ -0,0 +1,36 @@
+--source include/not_embedded.inc
+--source include/not_valgrind.inc
+# Avoid CrashReporter popup on Mac
+--source include/not_crashrep.inc
+# Binary must be compiled with debug for crash to occur
+--source include/have_debug.inc
+--source include/have_sequence.inc
+
+#
+# MDEV-20578 Got error 126 when executing undo undo_key_delete upon Aria crash
+# recovery
+#
+
+# Write file to make mysql-test-run.pl expect crash and restart
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+
+create table t1 (a int primary key, b int, c int, unique key(b), key(c)) engine=aria transactional=1;
+insert into t1 values (1000,1000,1000);
+insert into t1 select seq,seq+100, seq+200 from seq_1_to_10;
+
+# Insert into t1 with batch insert where we get a rows replaced after
+# a few sucessful inserts
+
+SET GLOBAL debug_dbug="+d,crash_end_bulk_insert";
+
+--error 2013
+REPLACE into t1 select seq+20,seq+95, seq + 300 from seq_1_to_10;
+
+# Wait until restarted
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+
+check table t1;
+select sum(a),sum(b),sum(c) from t1;
+drop table t1;
diff --git a/mysql-test/suite/rpl/r/rpl_parallel_optimistic_until.result b/mysql-test/suite/rpl/r/rpl_parallel_optimistic_until.result
new file mode 100644
index 00000000000..a83a9b61b9f
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_parallel_optimistic_until.result
@@ -0,0 +1,291 @@
+include/master-slave.inc
+[connection master]
+connection slave;
+include/stop_slave.inc
+RESET MASTER;
+RESET SLAVE;
+connection master;
+RESET MASTER;
+CREATE TABLE t1 (a int primary key, b text) ENGINE=InnoDB;
+INSERT INTO t1 SET a=25, b='trx0';
+connection slave;
+include/start_slave.inc
+connection master;
+connection slave;
+include/stop_slave.inc
+ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
+SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
+SET GLOBAL slave_parallel_threads=2;
+SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode;
+SET GLOBAL slave_parallel_mode='optimistic';
+connection slave;
+SET @old_max_relay_log_size = @@global.max_relay_log_size;
+SET @@global.max_relay_log_size=4096;
+connection master;
+BEGIN;
+INSERT INTO t1 SET a=1, b='trx1';
+INSERT INTO t1 SET a=2, b='trx1';
+INSERT INTO t1 SET a=3, b='trx1';
+INSERT INTO t1 SET a=4, b='trx1';
+INSERT INTO t1 SET a=5, b='trx1';
+INSERT INTO t1 SET a=6, b='trx1';
+INSERT INTO t1 SET a=7, b='trx1';
+INSERT INTO t1 SET a=8, b='trx1';
+INSERT INTO t1 SET a=9, b='trx1';
+INSERT INTO t1 SET a=10, b='trx1';
+INSERT INTO t1 SET a=11, b='trx1';
+INSERT INTO t1 SET a=12, b='trx1';
+INSERT INTO t1 SET a=13, b='trx1';
+INSERT INTO t1 SET a=14, b='trx1';
+INSERT INTO t1 SET a=15, b='trx1';
+INSERT INTO t1 SET a=16, b='trx1';
+INSERT INTO t1 SET a=17, b='trx1';
+INSERT INTO t1 SET a=18, b='trx1';
+INSERT INTO t1 SET a=19, b='trx1';
+INSERT INTO t1 SET a=20, b='trx1';
+INSERT INTO t1 SET a=21, b='trx1';
+INSERT INTO t1 SET a=22, b='trx1';
+INSERT INTO t1 SET a=23, b='trx1';
+INSERT INTO t1 SET a=24, b='trx1';
+COMMIT;
+FLUSH LOGS;
+BEGIN;
+UPDATE t1 SET b='trx2_0' WHERE a = 25;
+UPDATE t1 SET b='trx2' WHERE a = 25;
+COMMIT;
+INSERT INTO t1 SET a=26,b='trx3';
+*** case 1 UNTIL inside trx2
+connection slave1;
+BEGIN;
+INSERT INTO t1 SET a= 1;
+connection slave;
+SELECT <pos_0> <= <pos_until> AND <pos_until> < <pos_trx2> as "pos_until < trx0 and is within trx2";
+pos_until < trx0 and is within trx2
+1
+CHANGE MASTER TO MASTER_USE_GTID=no;
+START SLAVE UNTIL MASTER_LOG_FILE = 'file_2', MASTER_LOG_POS = <pos_until>;
+connection slave1;
+ROLLBACK;
+Proof 1: Correct stop
+connection slave;
+include/wait_for_slave_sql_to_stop.inc
+SELECT count(*) = 1 as 'trx2 is committed' FROM t1 WHERE b = 'trx2';
+trx2 is committed
+1
+SELECT count(*) = 0 as 'trx3 is not committed' FROM t1 WHERE b = 'trx3';
+trx3 is not committed
+1
+Proof 2: Resume works out
+include/start_slave.inc
+connection master;
+connection slave;
+*** case 2 UNTIL inside trx2
+connection slave;
+DELETE FROM t1 WHERE a <> 25;
+UPDATE t1 SET b='trx0' WHERE a = 25;
+connection slave1;
+BEGIN;
+INSERT INTO t1 SET a= 1;
+connection slave;
+include/stop_slave.inc
+SELECT <pos_0> <= <pos_until> AND <pos_until> < <pos_trx2> as "pos_until >= trx0 and is within trx2";
+pos_until >= trx0 and is within trx2
+1
+CHANGE MASTER TO MASTER_LOG_FILE = 'file_1', MASTER_LOG_POS = <pos_trx0>, MASTER_USE_GTID=no;
+START SLAVE UNTIL MASTER_LOG_FILE = 'file_2', MASTER_LOG_POS = <pos_until>;
+connection slave1;
+ROLLBACK;
+Proof 1: Correct stop
+connection slave;
+include/wait_for_slave_sql_to_stop.inc
+SELECT count(*) = 1 as 'trx2 is committed' FROM t1 WHERE b = 'trx2';
+trx2 is committed
+1
+SELECT count(*) = 0 as 'trx3 is not committed' FROM t1 WHERE b = 'trx3';
+trx3 is not committed
+1
+Proof 2: Resume works out
+include/start_slave.inc
+connection master;
+connection slave;
+*** case 3 UNTIL inside trx1
+connection slave;
+DELETE FROM t1 WHERE a <> 25;
+UPDATE t1 SET b='trx0' WHERE a = 25;
+connection slave1;
+BEGIN;
+INSERT INTO t1 SET a= 1; # block trx1;
+connection slave;
+include/stop_slave.inc
+SELECT <pos_until> < <pos_0> as "pos_until before trx2 start position";
+pos_until before trx2 start position
+1
+CHANGE MASTER TO MASTER_LOG_FILE = 'file_1', MASTER_LOG_POS = <pos_trx0>, MASTER_USE_GTID=no;
+START SLAVE UNTIL MASTER_LOG_FILE = 'file_2', MASTER_LOG_POS = <pos_until>;
+connection slave1;
+ROLLBACK;
+Proof 1: Correct stop
+connection slave;
+include/wait_for_slave_sql_to_stop.inc
+SELECT count(*) = 25-1 as 'trx1 is committed' FROM t1 WHERE b = 'trx1';
+trx1 is committed
+1
+SELECT count(*) = 0 as 'trx2 is not committed' FROM t1 WHERE b = 'trx2';
+trx2 is not committed
+1
+Proof 2: Resume works out
+include/start_slave.inc
+connection master;
+connection slave;
+*** case 4 Relay-log UNTIL inside trx1
+connection slave;
+DELETE FROM t1 WHERE a <> 25;
+UPDATE t1 SET b='trx0' WHERE a = 25;
+connection slave1;
+BEGIN;
+INSERT INTO t1 SET a= 1; # block trx1;
+connection slave;
+include/stop_slave.inc
+CHANGE MASTER TO MASTER_LOG_FILE = 'file_1', MASTER_LOG_POS = <pos_trx0>, MASTER_USE_GTID=no;
+START SLAVE IO_THREAD;
+include/wait_for_slave_io_to_start.inc
+START SLAVE UNTIL RELAY_LOG_FILE = 'file_2', RELAY_LOG_POS = <pos_until>;
+connection slave1;
+ROLLBACK;
+Proof 1: Correct stop
+connection slave;
+include/wait_for_slave_sql_to_stop.inc
+SELECT count(*) = 25-1 as 'trx1 is committed' FROM t1 WHERE b = 'trx1';
+trx1 is committed
+1
+SELECT count(*) = 0 as 'trx2 is not committed' FROM t1 WHERE b = 'trx2';
+trx2 is not committed
+1
+Proof 2: Resume works out
+include/start_slave.inc
+connection master;
+connection slave;
+*** case 5 Relay-log UNTIL inside a "big" trx that spawns few relay logs
+connection master;
+CREATE TABLE t2 (a TEXT) ENGINE=InnoDB;
+FLUSH LOGS;
+connection slave;
+connection slave;
+include/stop_slave.inc
+connection master;
+BEGIN;
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+COMMIT;
+INSERT INTO t2 SET a='a';
+connection slave;
+START SLAVE IO_THREAD;
+include/wait_for_slave_io_to_start.inc
+START SLAVE UNTIL RELAY_LOG_FILE = 'file_2', RELAY_LOG_POS = <pos_until>;
+Proof 1: Correct stop
+connection slave;
+include/wait_for_slave_sql_to_stop.inc
+Proof 2: Resume works out
+include/start_slave.inc
+connection master;
+connection slave;
+include/diff_tables.inc [master:t2,slave:t2]
+*** case 6 Relay-log UNTIL inside a small trx inside a sequence of relay logs
+connection slave;
+include/stop_slave.inc
+connection master;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+COMMIT;
+connection slave;
+START SLAVE IO_THREAD;
+include/wait_for_slave_io_to_start.inc
+connection master;
+include/sync_slave_io_with_master.inc
+connection slave;
+START SLAVE UNTIL RELAY_LOG_FILE = 'file_2', RELAY_LOG_POS = <pos_until>;
+Proof 1: Correct stop
+connection slave;
+include/wait_for_slave_sql_to_stop.inc
+Proof 2: Resume works out
+include/start_slave.inc
+connection master;
+connection slave;
+include/diff_tables.inc [master:t2,slave:t2]
+connection slave;
+include/stop_slave.inc
+SET GLOBAL max_relay_log_size=@old_max_relay_log_size;
+SET GLOBAL slave_parallel_mode=@old_parallel_mode;
+SET GLOBAL slave_parallel_threads=@old_parallel_threads;
+include/start_slave.inc
+connection master;
+DROP TABLE t1, t2;
+connection slave;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_parallel_optimistic_until.test b/mysql-test/suite/rpl/t/rpl_parallel_optimistic_until.test
new file mode 100644
index 00000000000..508213c9075
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_parallel_optimistic_until.test
@@ -0,0 +1,465 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+--source include/master-slave.inc
+# Format is restricted because the test expects a specific result of
+# relay-logging that splits a transaction into two different files.
+--source include/have_binlog_format_row.inc
+
+#
+# MDEV-15152 Optimistic parallel slave doesn't cope well with START SLAVE UNTIL
+#
+--connection slave
+--source include/stop_slave.inc
+RESET MASTER;
+RESET SLAVE;
+
+--connection master
+RESET MASTER;
+CREATE TABLE t1 (a int primary key, b text) ENGINE=InnoDB;
+--let $a0 = 25
+--eval INSERT INTO t1 SET a=$a0, b='trx0'
+# Memorize the position for replication restart from it
+--let $pos_trx0 = query_get_value(SHOW MASTER STATUS, Position, 1)
+
+--connection slave
+--source include/start_slave.inc
+
+--connection master
+# --connection slave
+--sync_slave_with_master
+--source include/stop_slave.inc
+ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
+SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
+SET GLOBAL slave_parallel_threads=2;
+SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode;
+SET GLOBAL slave_parallel_mode='optimistic';
+
+# Run the slave in the following modes one by one.
+#
+# 1. the until position is set in the middle of trx2
+# below $pos_trx0 of the last exec position in the first file
+# 2. and above $pos_trx0
+# In either case trx2 must commit before slave stops.
+# 3. the until postion is inside trx1
+# 4. RELAY log until inside trx1
+# 5. RELAY log until inside a "big" trx
+# 6. RELAY log until inside a trx within a sequence of relay logs
+#
+# Execution flaw for Until_Master_Pos cases follows as:
+# create the transaction trx1, trx2
+# logged at the beginning of two subsequent binlog files.
+# Set the until position to at the middle of the 2rd transaction.
+# Engage the optimistic scheduler while having trx1 execution blocked.
+# Lift the block after trx2 has reached waiting its order to commit.
+# *Proof 1*
+# Observe that the slave applier stops at a correct position.
+# In the bug condition it would stop prematurely having the stop position
+# in the first file, therefore trx2 not committed.
+# Specifically, an internal transaction position until makes the applier to run
+# beyond it to commit commit the current transaction.
+# *Proof 2*
+# Observe the following START SLAVE resumes OK.
+#
+# Auxiliary third trx3 on master is just for triggering the actual stop
+# (whihc is a legacy UNTIL's property).
+# trx0 is to produce a specific value of the last executed binlog file:pos
+# to emulate the bug condition.
+#
+# Intermediate checks via SELECT are supposed to succeed
+# with putting out value 1.
+#
+# NOTE: Relay log until tests have to use explicit log names and position
+# which may require to adjust with future changes to event formats etc.
+#
+
+--connection slave
+SET @old_max_relay_log_size = @@global.max_relay_log_size;
+SET @@global.max_relay_log_size=4096;
+
+--connection master
+# trx1
+--let $a=1
+BEGIN;
+while (`SELECT $a < $a0`)
+{
+ --eval INSERT INTO t1 SET a=$a, b='trx1'
+--inc $a
+}
+COMMIT;
+--let $fil_1 = query_get_value(SHOW MASTER STATUS, File, 1)
+--let $pos_trx1 = query_get_value(SHOW MASTER STATUS, Position, 1)
+
+FLUSH LOGS;
+
+# $pos_0 the offset of the first event of trx2 in new file
+--let $pos_0=query_get_value(SHOW MASTER STATUS, Position, 1)
+# trx2
+--let $a=$a0
+BEGIN;
+--eval UPDATE t1 SET b='trx2_0' WHERE a = $a
+--eval UPDATE t1 SET b='trx2' WHERE a = $a
+COMMIT;
+--let $fil_2=query_get_value(SHOW MASTER STATUS, File, 1)
+--let $pos_trx2=query_get_value(SHOW MASTER STATUS, Position, 1)
+
+# trx3
+--let $a=$a0
+--inc $a
+--eval INSERT INTO t1 SET a=$a,b='trx3'
+--let $pos_trx3=query_get_value(SHOW MASTER STATUS, Position, 1)
+--let $a=
+
+
+--echo *** case 1 UNTIL inside trx2
+
+--connection slave1
+# Blocker to hold off EXEC_MASTER_LOG_POS advance
+BEGIN;
+ --eval INSERT INTO t1 SET a= 1
+--connection slave
+--let $pos_until=`SELECT $pos_trx0 - 1`
+--replace_result $pos_0 <pos_0> $pos_until <pos_until> $pos_trx2 <pos_trx2>
+--eval SELECT $pos_0 <= $pos_until AND $pos_until < $pos_trx2 as "pos_until < trx0 and is within trx2"
+CHANGE MASTER TO MASTER_USE_GTID=no;
+--replace_result $fil_2 file_2 $pos_until <pos_until>
+--eval START SLAVE UNTIL MASTER_LOG_FILE = '$fil_2', MASTER_LOG_POS = $pos_until
+
+--let $wait_condition= SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state = "Waiting for prior transaction to commit"
+--source include/wait_condition.inc
+
+--connection slave1
+# unblock to see the slave applier stops at $until
+ROLLBACK;
+
+--echo Proof 1: Correct stop
+--connection slave
+--source include/wait_for_slave_sql_to_stop.inc
+--let $file_stop= query_get_value(SHOW SLAVE STATUS, Relay_Master_Log_File, 1)
+--let $pos_stop= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
+if (`SELECT "$file_stop" != "$fil_2" OR $pos_stop < $pos_until`)
+{
+ --echo *** ERROR: Slave stopped at $file_stop:$pos_stop which is not $fil_2:$pos_until.
+ --die
+}
+--eval SELECT count(*) = 1 as 'trx2 is committed' FROM t1 WHERE b = 'trx2'
+--eval SELECT count(*) = 0 as 'trx3 is not committed' FROM t1 WHERE b = 'trx3'
+
+--echo Proof 2: Resume works out
+--source include/start_slave.inc
+--connection master
+--sync_slave_with_master
+
+
+--echo *** case 2 UNTIL inside trx2
+
+--connection slave
+--eval DELETE FROM t1 WHERE a <> $a0
+--eval UPDATE t1 SET b='trx0' WHERE a = $a0
+
+--connection slave1
+# Blocker to hold off EXEC_MASTER_LOG_POS advance
+BEGIN;
+ --eval INSERT INTO t1 SET a= 1
+
+--connection slave
+--source include/stop_slave.inc
+
+--let $pos_until=`SELECT $pos_trx2 - 1`
+--replace_result $pos_trx0 <pos_0> $pos_until <pos_until> $pos_trx2 <pos_trx2>
+--eval SELECT $pos_trx0 <= $pos_until AND $pos_until < $pos_trx2 as "pos_until >= trx0 and is within trx2"
+--replace_result $fil_1 file_1 $pos_trx0 <pos_trx0>
+--eval CHANGE MASTER TO MASTER_LOG_FILE = '$fil_1', MASTER_LOG_POS = $pos_trx0, MASTER_USE_GTID=no
+--replace_result $fil_2 file_2 $pos_until <pos_until>
+--eval START SLAVE UNTIL MASTER_LOG_FILE = '$fil_2', MASTER_LOG_POS = $pos_until
+
+--let $wait_condition= SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state = "Waiting for prior transaction to commit"
+--source include/wait_condition.inc
+
+--connection slave1
+# unblock to see the slave applier stops at $until
+ROLLBACK;
+
+--echo Proof 1: Correct stop
+--connection slave
+--source include/wait_for_slave_sql_to_stop.inc
+--let $file_stop= query_get_value(SHOW SLAVE STATUS, Relay_Master_Log_File, 1)
+--let $pos_stop= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
+if (`SELECT "$file_stop" != "$fil_2" OR $pos_stop < $pos_until`)
+{
+ --echo *** ERROR: Slave stopped at $file_stop:$pos_stop which is not $fil_2:$pos_until.
+ --die
+}
+--eval SELECT count(*) = 1 as 'trx2 is committed' FROM t1 WHERE b = 'trx2'
+--eval SELECT count(*) = 0 as 'trx3 is not committed' FROM t1 WHERE b = 'trx3'
+
+--echo Proof 2: Resume works out
+--source include/start_slave.inc
+--connection master
+--sync_slave_with_master
+
+
+--echo *** case 3 UNTIL inside trx1
+
+--connection slave
+--eval DELETE FROM t1 WHERE a <> $a0
+--eval UPDATE t1 SET b='trx0' WHERE a = $a0
+
+
+--connection slave1
+# Blocker to hold off EXEC_MASTER_LOG_POS advance
+BEGIN;
+ --eval INSERT INTO t1 SET a= 1; # block trx1
+
+--connection slave
+--source include/stop_slave.inc
+
+--let $pos_until=`SELECT $pos_0 - 1`
+--replace_result $pos_0 <pos_0> $pos_until <pos_until> $pos_trx2 <pos_trx2>
+--eval SELECT $pos_until < $pos_0 as "pos_until before trx2 start position"
+--replace_result $fil_1 file_1 $pos_trx0 <pos_trx0>
+--eval CHANGE MASTER TO MASTER_LOG_FILE = '$fil_1', MASTER_LOG_POS = $pos_trx0, MASTER_USE_GTID=no
+--replace_result $fil_2 file_2 $pos_until <pos_until>
+--eval START SLAVE UNTIL MASTER_LOG_FILE = '$fil_2', MASTER_LOG_POS = $pos_until
+
+--connection slave1
+# unblock to see the slave applier stops at $until
+ROLLBACK;
+
+--echo Proof 1: Correct stop
+--connection slave
+--source include/wait_for_slave_sql_to_stop.inc
+--let $file_stop= query_get_value(SHOW SLAVE STATUS, Relay_Master_Log_File, 1)
+--let $pos_stop= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
+if (`SELECT "$file_stop" != "$fil_2" OR $pos_stop < $pos_until`)
+{
+ --echo *** ERROR: Slave stopped at $file_stop:$pos_stop which is not $fil_2:$pos_until.
+ --die
+}
+--eval SELECT count(*) = $a0-1 as 'trx1 is committed' FROM t1 WHERE b = 'trx1'
+--eval SELECT count(*) = 0 as 'trx2 is not committed' FROM t1 WHERE b = 'trx2'
+
+--echo Proof 2: Resume works out
+--source include/start_slave.inc
+--connection master
+--sync_slave_with_master
+
+
+--echo *** case 4 Relay-log UNTIL inside trx1
+
+--connection slave
+--eval DELETE FROM t1 WHERE a <> $a0
+--eval UPDATE t1 SET b='trx0' WHERE a = $a0
+
+--connection slave1
+# Blocker to hold off EXEC_MASTER_LOG_POS advance
+BEGIN;
+ --eval INSERT INTO t1 SET a= 1; # block trx1
+
+--connection slave
+--source include/stop_slave.inc
+--replace_result $fil_1 file_1 $pos_trx0 <pos_trx0>
+--eval CHANGE MASTER TO MASTER_LOG_FILE = '$fil_1', MASTER_LOG_POS = $pos_trx0, MASTER_USE_GTID=no
+START SLAVE IO_THREAD;
+--source include/wait_for_slave_io_to_start.inc
+
+# The following test sets the stop coordinate is set to inside the first event
+# of a relay log that holds events of a transaction started in an earlier log.
+# Peek the stop position in the middle of trx1, not even on a event boundary.
+--let $pos_until=255
+--let $file_rl=slave-relay-bin.000003
+--let $binlog_file=$file_rl
+
+--let $pos_xid=508
+--let $info= query_get_value(SHOW RELAYLOG EVENTS IN '$file_rl' FROM $pos_xid LIMIT 1, Info, 1)
+
+if (`SELECT "$info" NOT LIKE "COMMIT /* xid=% */" OR $pos_xid < $pos_until`)
+{
+ --echo *** Unexpected offset. Refine it to point to the correct XID event!
+ --die
+}
+
+--replace_result $file_rl file_2 $pos_until <pos_until>
+--eval START SLAVE UNTIL RELAY_LOG_FILE = '$file_rl', RELAY_LOG_POS = $pos_until
+
+--connection slave1
+# unblock to see the slave applier stops at $until
+ROLLBACK;
+
+--echo Proof 1: Correct stop
+--connection slave
+--source include/wait_for_slave_sql_to_stop.inc
+--let $file_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
+--let $pos_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1)
+if (`SELECT strcmp("$file_rl","$file_stop") > -1`)
+{
+ --echo *** ERROR: Slave stopped at $file_stop:$pos_stop which is not $file_rl:$pos_until.
+ --die
+}
+
+--eval SELECT count(*) = $a0-1 as 'trx1 is committed' FROM t1 WHERE b = 'trx1'
+--eval SELECT count(*) = 0 as 'trx2 is not committed' FROM t1 WHERE b = 'trx2'
+
+--echo Proof 2: Resume works out
+--source include/start_slave.inc
+--connection master
+--sync_slave_with_master
+
+
+
+--echo *** case 5 Relay-log UNTIL inside a "big" trx that spawns few relay logs
+
+--connection master
+CREATE TABLE t2 (a TEXT) ENGINE=InnoDB;
+FLUSH LOGS;
+
+--sync_slave_with_master
+--let $file_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
+--let $pos_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1)
+--let $records=`SELECT floor(4*@@global.max_relay_log_size / 1024) + 1`
+
+--connection slave
+--source include/stop_slave.inc
+
+--connection master
+# trx4
+BEGIN;
+--let $i=$records
+while ($i)
+{
+ INSERT INTO t2 SET a=repeat('a',1024);
+
+--dec $i
+}
+COMMIT;
+
+# slave will stop there:
+--let $file_trx4 = query_get_value(SHOW MASTER STATUS, File, 1)
+--let $pos_trx4 = query_get_value(SHOW MASTER STATUS, Position, 1)
+
+# trx5
+INSERT INTO t2 SET a='a';
+--let $pos_trx5 = query_get_value(SHOW MASTER STATUS, Position, 1)
+
+--connection slave
+START SLAVE IO_THREAD;
+--source include/wait_for_slave_io_to_start.inc
+
+# Set position inside the transaction though the value
+# specified is beyond that relay log file.
+# The coordianate may point to in a different event in future changes
+# but should not move away from inside this big group of events.
+# So we don't test which event in the transaction it points to.
+--let $pos_until= 4500
+--let $file_rl= slave-relay-bin.000010
+
+--replace_result $file_rl file_2 $pos_until <pos_until>
+--eval START SLAVE UNTIL RELAY_LOG_FILE = '$file_rl', RELAY_LOG_POS = $pos_until
+
+--echo Proof 1: Correct stop
+--connection slave
+--source include/wait_for_slave_sql_to_stop.inc
+--let $file_stop= query_get_value(SHOW SLAVE STATUS, Relay_Master_Log_File, 1)
+--let $pos_stop= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
+# It's showed the actual stop occurred before trx5
+if (`SELECT strcmp("$file_trx4", "$file_stop") <> 0 OR $pos_stop >= $pos_trx5 OR count(*) <> $records FROM t2`)
+{
+ --echo *** ERROR: Slave stopped at *binlog* $file_stop:$pos_stop which is not $file_trx4:$pos_trx4.
+ --die
+}
+
+--echo Proof 2: Resume works out
+--source include/start_slave.inc
+--connection master
+--sync_slave_with_master
+
+--let $diff_tables=master:t2,slave:t2
+--source include/diff_tables.inc
+
+
+
+--echo *** case 6 Relay-log UNTIL inside a small trx inside a sequence of relay logs
+
+--connection slave
+--source include/stop_slave.inc
+
+--connection master
+# trx6
+--let $records=`SELECT count(*) FROM t2`
+while ($records)
+{
+ BEGIN;
+ DELETE FROM t2 LIMIT 1;
+ COMMIT;
+--dec $records
+}
+COMMIT;
+
+--connection slave
+START SLAVE IO_THREAD;
+--source include/wait_for_slave_io_to_start.inc
+
+--connection master
+--source include/sync_slave_io_with_master.inc
+
+--connection slave
+# The relay-log coordinate is not at an event boundary and
+# also may change across the server version.
+# The test makes its best to check its coherance.
+--let $pos_until= 3130
+--let $file_rl= slave-relay-bin.000018
+
+--let $pos_gtid = 2987
+--let $info= query_get_value(SHOW RELAYLOG EVENTS IN '$file_rl' FROM $pos_gtid LIMIT 1, Info, 1)
+
+if (`SELECT "$info" != "BEGIN GTID 0-1-23"`)
+{
+ --echo *** Unexpected offset. Refine it to point to the correct GTID!
+ --die
+}
+--let $pos_event = 3120
+--let $type= query_get_value(SHOW RELAYLOG EVENTS IN '$file_rl' FROM $pos_event LIMIT 1, Event_type, 1)
+if (`SELECT "$type" != "Delete_rows_v1"`)
+{
+ --echo *** Unexpected offset. Refine it to point to the expected event!
+ --die
+}
+
+--replace_result $file_rl file_2 $pos_until <pos_until>
+--eval START SLAVE UNTIL RELAY_LOG_FILE = '$file_rl', RELAY_LOG_POS = $pos_until
+
+--echo Proof 1: Correct stop
+--connection slave
+--source include/wait_for_slave_sql_to_stop.inc
+--let $file_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
+--let $pos_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1)
+if (`SELECT strcmp("$file_stop", "$file_rl") = -1 OR
+ strcmp("$file_stop", "$file_rl") = 0 AND $pos_stop < $pos_until`)
+{
+ --echo *** ERROR: Slave stopped at *relay* $file_stop:$pos_stop which is not $file_rl:$pos_until.
+ --die
+}
+
+--echo Proof 2: Resume works out
+--source include/start_slave.inc
+--connection master
+--sync_slave_with_master
+
+--let $diff_tables=master:t2,slave:t2
+--source include/diff_tables.inc
+
+#
+# Clean up.
+#
+--connection slave
+--source include/stop_slave.inc
+SET GLOBAL max_relay_log_size=@old_max_relay_log_size;
+SET GLOBAL slave_parallel_mode=@old_parallel_mode;
+SET GLOBAL slave_parallel_threads=@old_parallel_threads;
+--source include/start_slave.inc
+
+--connection master
+DROP TABLE t1, t2;
+
+--sync_slave_with_master
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/vcol/r/vcol_keys_myisam.result b/mysql-test/suite/vcol/r/vcol_keys_myisam.result
index b7086600ab1..dd6e4c414f0 100644
--- a/mysql-test/suite/vcol/r/vcol_keys_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_keys_myisam.result
@@ -408,3 +408,12 @@ SELECT * FROM t1 WHERE d2 < d1;
i d1 d2 t
1 2023-03-16 2023-03-15 1
DROP TABLE t1;
+#
+# MDEV-20015 Assertion `!in_use->is_error()' failed in TABLE::update_virtual_field
+#
+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));
+insert into t2 (pk) select a from t1;
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+drop tables t1, t2;
diff --git a/mysql-test/suite/vcol/t/vcol_keys_myisam.test b/mysql-test/suite/vcol/t/vcol_keys_myisam.test
index 99b1c9a444b..24612f4d55f 100644
--- a/mysql-test/suite/vcol/t/vcol_keys_myisam.test
+++ b/mysql-test/suite/vcol/t/vcol_keys_myisam.test
@@ -300,3 +300,14 @@ 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;