summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2021-08-02 10:11:41 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2021-08-02 10:11:41 +0200
commit6efb5e9f5e3cd3ec811ae832a67e1878c14f0dea (patch)
treeb7c1a18b8bbc638ee12951d1d04db6d21bebcaed /mysql-test
parent07674e6a741a82d2e30f9798f699209a6c34dfef (diff)
parentec8882b9ddbba2f9fc3571a1ac2ade0dabf412d9 (diff)
downloadmariadb-git-6efb5e9f5e3cd3ec811ae832a67e1878c14f0dea.tar.gz
Merge branch '10.5' into 10.6
Diffstat (limited to 'mysql-test')
-rwxr-xr-xmysql-test/dgcov.pl38
-rw-r--r--mysql-test/include/wait_until_disconnected.inc2
-rw-r--r--mysql-test/lib/My/SafeProcess.pm18
-rw-r--r--mysql-test/lib/mtr_process.pl8
-rw-r--r--mysql-test/main/cte_nonrecursive.result67
-rw-r--r--mysql-test/main/cte_nonrecursive.test50
-rw-r--r--mysql-test/main/cte_recursive.result95
-rw-r--r--mysql-test/main/cte_recursive.test83
-rw-r--r--mysql-test/main/func_str.result13
-rw-r--r--mysql-test/main/func_str.test18
-rw-r--r--mysql-test/main/grant5.result21
-rw-r--r--mysql-test/main/grant5.test14
-rw-r--r--mysql-test/main/insert_returning.result41
-rw-r--r--mysql-test/main/insert_returning.test20
-rw-r--r--mysql-test/main/lock_multi_bug38499.test3
-rw-r--r--mysql-test/main/lock_multi_bug38691.test2
-rw-r--r--mysql-test/main/my_print_defaults.result51
-rw-r--r--mysql-test/main/my_print_defaults.test106
-rw-r--r--mysql-test/main/mysql_client_test.result5
-rw-r--r--mysql-test/main/mysql_client_test.test4
-rw-r--r--mysql-test/main/mysql_upgrade.result2
-rw-r--r--mysql-test/main/mysqldump.result1
-rw-r--r--mysql-test/main/order_by_innodb.result52
-rw-r--r--mysql-test/main/order_by_innodb.test51
-rw-r--r--mysql-test/main/prepare.result14
-rw-r--r--mysql-test/main/prepare.test12
-rw-r--r--mysql-test/main/ps.result14
-rw-r--r--mysql-test/main/ps.test16
-rw-r--r--mysql-test/main/replace_returning.result122
-rw-r--r--mysql-test/main/replace_returning.test99
-rw-r--r--mysql-test/main/selectivity_innodb.result51
-rw-r--r--mysql-test/main/selectivity_innodb.test55
-rw-r--r--mysql-test/main/selectivity_no_engine.result20
-rw-r--r--mysql-test/main/selectivity_no_engine.test21
-rw-r--r--mysql-test/main/shutdown_not_windows.combinations5
-rw-r--r--mysql-test/main/shutdown_not_windows.result8
-rw-r--r--mysql-test/main/shutdown_not_windows.test14
-rw-r--r--mysql-test/main/skip_name_resolve.result22
-rw-r--r--mysql-test/main/skip_name_resolve.test26
-rw-r--r--mysql-test/main/ssl_cipher.opt1
-rw-r--r--mysql-test/main/table_value_constr.result38
-rw-r--r--mysql-test/main/table_value_constr.test22
-rw-r--r--mysql-test/main/union.result31
-rw-r--r--mysql-test/main/union.test25
-rw-r--r--mysql-test/main/win.result287
-rw-r--r--mysql-test/main/win.test147
-rwxr-xr-xmysql-test/mariadb-test-run.pl113
-rw-r--r--mysql-test/suite/binlog/include/binlog.test18
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_binlog.result23
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_binlog.result24
-rw-r--r--mysql-test/suite/binlog_encryption/encrypted_master.test3
-rw-r--r--mysql-test/suite/encryption/r/tempfiles_encrypted.result287
-rw-r--r--mysql-test/suite/encryption/t/innodb-page_encryption.test3
-rw-r--r--mysql-test/suite/galera/r/MDEV-22051.result6
-rw-r--r--mysql-test/suite/galera/r/MDEV-22421.result7
-rw-r--r--mysql-test/suite/galera/r/MDEV-25740.result9
-rw-r--r--mysql-test/suite/galera/r/galera_backup_stage.result78
-rw-r--r--mysql-test/suite/galera/r/galera_fk_lock_wait.result54
-rw-r--r--mysql-test/suite/galera/suite.pm1
-rw-r--r--mysql-test/suite/galera/t/MDEV-22421.test12
-rw-r--r--mysql-test/suite/galera/t/MDEV-25740.test14
-rw-r--r--mysql-test/suite/galera/t/galera_backup_stage.test120
-rw-r--r--mysql-test/suite/galera/t/galera_fk_lock_wait.test40
-rw-r--r--mysql-test/suite/gcol/inc/gcol_ins_upd.inc74
-rw-r--r--mysql-test/suite/gcol/inc/gcol_keys.inc2
-rw-r--r--mysql-test/suite/gcol/inc/gcol_partition.inc16
-rw-r--r--mysql-test/suite/gcol/inc/gcol_view.inc55
-rw-r--r--mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result221
-rw-r--r--mysql-test/suite/gcol/r/gcol_ins_upd_myisam.result70
-rw-r--r--mysql-test/suite/gcol/r/gcol_keys_innodb.result2
-rw-r--r--mysql-test/suite/gcol/r/gcol_keys_myisam.result2
-rw-r--r--mysql-test/suite/gcol/r/gcol_partition_innodb.result15
-rw-r--r--mysql-test/suite/gcol/r/gcol_partition_myisam.result15
-rw-r--r--mysql-test/suite/gcol/r/gcol_view_innodb.result41
-rw-r--r--mysql-test/suite/gcol/r/gcol_view_myisam.result41
-rw-r--r--mysql-test/suite/gcol/r/innodb_virtual_fk.result3
-rw-r--r--mysql-test/suite/gcol/t/gcol_ins_upd_innodb.test2
-rw-r--r--mysql-test/suite/gcol/t/innodb_virtual_fk.test3
-rw-r--r--mysql-test/suite/innodb/r/alter_table.result10
-rw-r--r--mysql-test/suite/innodb/r/default_row_format_alter.result17
-rw-r--r--mysql-test/suite/innodb/r/import_bugs.result12
-rw-r--r--mysql-test/suite/innodb/t/alter_table.test11
-rw-r--r--mysql-test/suite/innodb/t/default_row_format_alter.test33
-rw-r--r--mysql-test/suite/innodb/t/import_bugs.test20
-rw-r--r--mysql-test/suite/innodb/t/innodb-page_compression_lz4.test2
-rw-r--r--mysql-test/suite/innodb_zip/r/innochecksum_3.result8
-rw-r--r--mysql-test/suite/innodb_zip/t/innochecksum_3.test5
-rw-r--r--mysql-test/suite/roles/set_default_role_clear.result2
-rw-r--r--mysql-test/suite/roles/set_default_role_for.result8
-rw-r--r--mysql-test/suite/roles/set_default_role_invalid.result12
-rw-r--r--mysql-test/suite/roles/set_default_role_new_connection.result4
-rw-r--r--mysql-test/suite/roles/set_role-recursive.result2
-rw-r--r--mysql-test/suite/rpl/r/create_or_replace_mix.result2
-rw-r--r--mysql-test/suite/rpl/r/create_or_replace_row.result3
-rw-r--r--mysql-test/suite/rpl/r/create_or_replace_statement.result2
-rw-r--r--mysql-test/suite/rpl/t/rpl_trunc_temp.test2
-rw-r--r--mysql-test/suite/s3/my.cnf1
-rw-r--r--mysql-test/suite/s3/slave.cnf1
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_server_embedded.result2
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result2
-rw-r--r--mysql-test/suite/sys_vars/t/innodb_fatal_semaphore_wait_threshold.test2
-rw-r--r--mysql-test/suite/vcol/r/binlog.result14
-rw-r--r--mysql-test/suite/vcol/t/binlog.test14
-rw-r--r--mysql-test/suite/versioning/r/create.result19
-rw-r--r--mysql-test/suite/versioning/r/partition.result21
-rw-r--r--mysql-test/suite/versioning/r/sysvars-notembedded.result30
-rw-r--r--mysql-test/suite/versioning/r/sysvars.result108
-rw-r--r--mysql-test/suite/versioning/t/create.test12
-rw-r--r--mysql-test/suite/versioning/t/partition.test21
-rw-r--r--mysql-test/suite/versioning/t/sysvars-notembedded.test31
-rw-r--r--mysql-test/suite/versioning/t/sysvars.test71
-rw-r--r--mysql-test/suite/wsrep/r/variables.result1
-rw-r--r--mysql-test/suite/wsrep/r/variables_debug.result1
-rw-r--r--mysql-test/suite/wsrep/t/variables.test2
-rw-r--r--mysql-test/suite/wsrep/t/variables_debug.test2
115 files changed, 3507 insertions, 192 deletions
diff --git a/mysql-test/dgcov.pl b/mysql-test/dgcov.pl
index 525db191efa..639f3a5b72a 100755
--- a/mysql-test/dgcov.pl
+++ b/mysql-test/dgcov.pl
@@ -155,7 +155,7 @@ END
sub gcov_one_file {
return unless /\.gcda$/;
unless ($opt_skip_gcov) {
- $cmd= "gcov -i '$_' 2>/dev/null >/dev/null";
+ $cmd= "gcov -il '$_' 2>/dev/null >/dev/null";
print STDERR ++$file_no,"\r" if not $opt_verbose and -t STDERR;
logv "Running: $cmd";
system($cmd)==0 or die "system($cmd): $? $!";
@@ -167,25 +167,27 @@ sub gcov_one_file {
{
return;
}
- open FH, '<', "$gcov_file_path" or die "open(<$gcov_file_path): $!";
- my $fname;
- while (<FH>) {
- chomp;
- if (/^function:/) {
- next;
- }
- if (/^file:/) {
- $fname=realpath($');
- next;
- }
- next if /^lcount:\d+,-\d+/; # whatever that means
- unless (/^lcount:(\d+),(\d+)/ and $fname) {
- warn "unknown line '$_' after running '$cmd'";
- next;
+ for my $gcov_file (<$_*.gcov>) {
+ open FH, '<', "$gcov_file_path" or die "open(<$gcov_file_path): $!";
+ my $fname;
+ while (<FH>) {
+ chomp;
+ if (/^function:/) {
+ next;
+ }
+ if (/^file:/) {
+ $fname=realpath(-f $' ? $' : $root.$');
+ next;
+ }
+ next if /^lcount:\d+,-\d+/; # whatever that means
+ unless (/^lcount:(\d+),(\d+)/ and $fname) {
+ warn "unknown line '$_' in $gcov_file";
+ next;
+ }
+ $cov{$fname}->{$1}+=$2;
}
- $cov{$fname}->{$1}+=$2;
+ close(FH);
}
- close(FH);
}
sub write_coverage {
diff --git a/mysql-test/include/wait_until_disconnected.inc b/mysql-test/include/wait_until_disconnected.inc
index 15bc6474995..93ada7f11ce 100644
--- a/mysql-test/include/wait_until_disconnected.inc
+++ b/mysql-test/include/wait_until_disconnected.inc
@@ -15,7 +15,7 @@ while (!$mysql_errno)
dec $counter;
if (!$counter)
{
- --die Server failed to dissapear
+ --die Server failed to disappear
}
--real_sleep 0.1
}
diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm
index b5a7660ed3e..69033649b46 100644
--- a/mysql-test/lib/My/SafeProcess.pm
+++ b/mysql-test/lib/My/SafeProcess.pm
@@ -389,10 +389,10 @@ sub _collect {
# 1 Still running
#
sub wait_one {
- my ($self, $timeout)= @_;
- croak "usage: \$safe_proc->wait_one([timeout])" unless ref $self;
+ my ($self, $timeout, $keep)= @_;
+ croak "usage: \$safe_proc->wait_one([timeout] [, keep])" unless ref $self;
- _verbose("wait_one $self, $timeout");
+ _verbose("wait_one $self, $timeout, $keep");
if ( ! defined($self->{SAFE_PID}) ) {
# No pid => not running
@@ -466,16 +466,16 @@ sub wait_one {
return 1;
}
- if ( not $blocking and $retpid == -1 ) {
- # still running
- _verbose("still running");
- return 1;
- }
+ #if ( not $blocking and $retpid == -1 ) {
+ # # still running
+ # _verbose("still running");
+ # return 1;
+ #}
#warn "wait_one: expected pid $pid but got $retpid"
# unless( $retpid == $pid );
- $self->_collect($exit_code);
+ $self->_collect($exit_code) unless $keep;
return 0;
}
diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl
index 4c64a546f65..a384aa584c4 100644
--- a/mysql-test/lib/mtr_process.pl
+++ b/mysql-test/lib/mtr_process.pl
@@ -40,7 +40,7 @@ BEGIN
eval 'sub USE_NETPING { $use_netping }';
}
-sub sleep_until_file_created ($$$$);
+sub sleep_until_file_created ($$$$$);
sub mtr_ping_port ($);
sub mtr_ping_port ($) {
@@ -102,8 +102,9 @@ sub mtr_ping_port ($) {
# FIXME check that the pidfile contains the expected pid!
-sub sleep_until_file_created ($$$$) {
+sub sleep_until_file_created ($$$$$) {
my $pidfile= shift;
+ my $expectfile = shift;
my $timeout= shift;
my $proc= shift;
my $warn_seconds = shift;
@@ -121,8 +122,9 @@ sub sleep_until_file_created ($$$$) {
my $seconds= ($loop * $sleeptime) / 1000;
# Check if it died after the fork() was successful
- if ( defined $proc and ! $proc->wait_one(0) )
+ if ( defined $proc and ! $proc->wait_one(0, 1) )
{
+ return 1 if -r $expectfile;
mtr_warning("Process $proc died after mysql-test-run waited $seconds " .
"seconds for $pidfile to be created.");
return 0;
diff --git a/mysql-test/main/cte_nonrecursive.result b/mysql-test/main/cte_nonrecursive.result
index f1eb1dc1268..17c73f74a49 100644
--- a/mysql-test/main/cte_nonrecursive.result
+++ b/mysql-test/main/cte_nonrecursive.result
@@ -2019,6 +2019,73 @@ drop procedure sp1;
drop procedure sp2;
drop procedure sp3;
drop table t1;
+#
+# MDEV-26095: missing RECURSIVE for the recursive definition of CTE
+# embedded into another CTE definition
+#
+create table t1 (a int);
+insert into t1 values (5), (7);
+with cte_e as (
+with recursive cte_r as (
+select a from t1 union select a+1 as a from cte_r r where a < 10
+) select * from cte_r
+) select * from cte_e;
+a
+5
+7
+6
+8
+9
+10
+with cte_e as (
+with cte_r as (
+select a from t1 union select a+1 as a from cte_r r where a < 10
+) select * from cte_r
+) select * from cte_e;
+ERROR 42S02: Table 'test.cte_r' doesn't exist
+drop table t1;
+#
+# MDEV-26025: query with two usage of a CTE executing via PS /SP
+#
+create table t1 (a int, b int);
+insert into t1 value (1,3), (3,2), (1,3), (4,1);
+prepare stmt from "with
+cte1 as ( select a,b from t1 where a = 1 AND b = 3 ),
+cte2 as ( select a,b from cte1 ),
+cte3 as ( select a,b from cte2 )
+select * from cte3, cte2";
+execute stmt;
+a b a b
+1 3 1 3
+1 3 1 3
+1 3 1 3
+1 3 1 3
+execute stmt;
+a b a b
+1 3 1 3
+1 3 1 3
+1 3 1 3
+1 3 1 3
+deallocate prepare stmt;
+create procedure sp() with
+cte1 as ( select a,b from t1 where a = 1 AND b = 3 ),
+cte2 as ( select a,b from cte1 ),
+cte3 as ( select a,b from cte2 )
+select * from cte3, cte2;
+call sp();
+a b a b
+1 3 1 3
+1 3 1 3
+1 3 1 3
+1 3 1 3
+call sp();
+a b a b
+1 3 1 3
+1 3 1 3
+1 3 1 3
+1 3 1 3
+drop procedure sp;
+drop table t1;
# End of 10.2 tests
#
# MDEV-21673: several references to CTE that uses
diff --git a/mysql-test/main/cte_nonrecursive.test b/mysql-test/main/cte_nonrecursive.test
index ad03b25ceb6..8ab3bddc410 100644
--- a/mysql-test/main/cte_nonrecursive.test
+++ b/mysql-test/main/cte_nonrecursive.test
@@ -1504,6 +1504,56 @@ drop procedure sp3;
drop table t1;
+--echo #
+--echo # MDEV-26095: missing RECURSIVE for the recursive definition of CTE
+--echo # embedded into another CTE definition
+--echo #
+
+create table t1 (a int);
+insert into t1 values (5), (7);
+
+with cte_e as (
+ with recursive cte_r as (
+ select a from t1 union select a+1 as a from cte_r r where a < 10
+ ) select * from cte_r
+) select * from cte_e;
+
+--ERROR ER_NO_SUCH_TABLE
+with cte_e as (
+ with cte_r as (
+ select a from t1 union select a+1 as a from cte_r r where a < 10
+ ) select * from cte_r
+) select * from cte_e;
+
+drop table t1;
+
+--echo #
+--echo # MDEV-26025: query with two usage of a CTE executing via PS /SP
+--echo #
+
+create table t1 (a int, b int);
+insert into t1 value (1,3), (3,2), (1,3), (4,1);
+
+let $q=
+with
+ cte1 as ( select a,b from t1 where a = 1 AND b = 3 ),
+ cte2 as ( select a,b from cte1 ),
+ cte3 as ( select a,b from cte2 )
+select * from cte3, cte2;
+
+eval prepare stmt from "$q";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+eval create procedure sp() $q;
+
+call sp();
+call sp();
+
+drop procedure sp;
+drop table t1;
+
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result
index 805352307ba..478bd9a92a5 100644
--- a/mysql-test/main/cte_recursive.result
+++ b/mysql-test/main/cte_recursive.result
@@ -3735,7 +3735,7 @@ select * from t1 as t;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t ALL NULL NULL NULL NULL 4 100.00
Warnings:
-Note 1003 with recursive cte as (/* select#2 */ select `*` AS `*` from `test`.`t1` where `a` = 1 union /* select#3 */ select `a` + 1 AS `a+1` from `cte` where `a` < 3)/* select#1 */ select `test`.`t`.`a` AS `a` from `test`.`t1` `t`
+Note 1003 with recursive cte as (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 1 union /* select#3 */ select `cte`.`a` + 1 AS `a+1` from `cte` where `cte`.`a` < 3)/* select#1 */ select `test`.`t`.`a` AS `a` from `test`.`t1` `t`
with recursive cte as
(select * from t1 where a=1 union select a+1 from cte where a<3)
select * from t1 as t;
@@ -3748,10 +3748,10 @@ create table t2 ( i1 int, i2 int);
insert into t2 values (1,1),(2,2);
explain
with recursive cte as
-( select * from t1 union select s1.* from t1 as s1, cte where s1.i1 = cte.i2 )
-select * from t1 as t;
+( select * from t2 union select s1.* from t2 as s1, cte where s1.i1 = cte.i2 )
+select * from t2 as t;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t ALL NULL NULL NULL NULL 4
+1 PRIMARY t ALL NULL NULL NULL NULL 2
drop table t1,t2;
#
# MDEV-22042: ANALYZE of query using stored function and recursive CTE
@@ -4499,6 +4499,93 @@ set big_tables=@save_big_tables;
Warnings:
Warning 1287 '@@big_tables' is deprecated and will be removed in a future release
#
+# MDEV-26135: execution of PS for query with hanging recursive CTE
+#
+create table t1 (a int);
+insert into t1 values (5), (7);
+create table t2 (b int);
+insert into t2 values (3), (7), (1);
+with recursive r as (select a from t1 union select a+1 from r where a < 10)
+select * from t2;
+b
+3
+7
+1
+prepare stmt from "with recursive r as (select a from t1 union select a+1 from r where a < 10)
+select * from t2";
+execute stmt;
+b
+3
+7
+1
+execute stmt;
+b
+3
+7
+1
+deallocate prepare stmt;
+drop table t1,t2;
+#
+# MDEV-26189: Unknown column reference within hanging recursive CTE
+#
+create table t1 (a int);
+insert into t1 values (3), (7), (1);
+with recursive
+r as (select * from t1 union select s1.* from t1 as s1, r where s1.a = r.b)
+select * from t1 as t;
+ERROR 42S22: Unknown column 'r.b' in 'where clause'
+explain with recursive
+r as (select * from t1 union select s1.* from t1 as s1, r where s1.a = r.b)
+select * from t1 as t;
+ERROR 42S22: Unknown column 'r.b' in 'where clause'
+create procedure sp1() with recursive
+r as (select * from t1 union select s1.* from t1 as s1, r where s1.a = r.b)
+select * from t1 as t;
+call sp1();
+ERROR 42S22: Unknown column 'r.b' in 'where clause'
+call sp1();
+ERROR 42S22: Unknown column 'r.b' in 'where clause'
+with recursive
+r as (select * from t1 union select s1.* from t1 as s1, r where s1.b = r.a)
+select * from t1 as t;
+ERROR 42S22: Unknown column 's1.b' in 'where clause'
+explain with recursive
+r as (select * from t1 union select s1.* from t1 as s1, r where s1.b = r.a)
+select * from t1 as t;
+ERROR 42S22: Unknown column 's1.b' in 'where clause'
+create procedure sp2() with recursive
+r as (select * from t1 union select s1.* from t1 as s1, r where s1.b = r.a)
+select * from t1 as t;
+call sp2();
+ERROR 42S22: Unknown column 's1.b' in 'where clause'
+call sp2();
+ERROR 42S22: Unknown column 's1.b' in 'where clause'
+drop procedure sp1;
+drop procedure sp2;
+drop table t1;
+#
+# MDEV-26202: Recursive CTE used indirectly twice
+# (fixed by the patch forMDEV-26025)
+#
+with recursive
+rcte as ( SELECT 1 AS a
+UNION ALL
+SELECT cast(a + 1 as unsigned int) FROM rcte WHERE a < 3),
+cte1 AS (SELECT a FROM rcte),
+cte2 AS (SELECT a FROM cte1),
+cte3 AS ( SELECT a FROM cte2)
+SELECT * FROM cte2, cte3;
+a a
+1 1
+2 1
+3 1
+1 2
+2 2
+3 2
+1 3
+2 3
+3 3
+#
# End of 10.2 tests
#
#
diff --git a/mysql-test/main/cte_recursive.test b/mysql-test/main/cte_recursive.test
index eb9150ec86f..dae227dfd9e 100644
--- a/mysql-test/main/cte_recursive.test
+++ b/mysql-test/main/cte_recursive.test
@@ -2594,8 +2594,8 @@ insert into t2 values (1,1),(2,2);
explain
with recursive cte as
- ( select * from t1 union select s1.* from t1 as s1, cte where s1.i1 = cte.i2 )
-select * from t1 as t;
+ ( select * from t2 union select s1.* from t2 as s1, cte where s1.i1 = cte.i2 )
+select * from t2 as t;
drop table t1,t2;
@@ -2859,6 +2859,85 @@ drop table folks;
set big_tables=@save_big_tables;
--echo #
+--echo # MDEV-26135: execution of PS for query with hanging recursive CTE
+--echo #
+
+create table t1 (a int);
+insert into t1 values (5), (7);
+create table t2 (b int);
+insert into t2 values (3), (7), (1);
+
+let $q=
+with recursive r as (select a from t1 union select a+1 from r where a < 10)
+select * from t2;
+
+eval $q;
+eval prepare stmt from "$q";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+drop table t1,t2;
+
+--echo #
+--echo # MDEV-26189: Unknown column reference within hanging recursive CTE
+--echo #
+
+create table t1 (a int);
+insert into t1 values (3), (7), (1);
+
+let $q1=
+with recursive
+ r as (select * from t1 union select s1.* from t1 as s1, r where s1.a = r.b)
+select * from t1 as t;
+
+--ERROR ER_BAD_FIELD_ERROR
+eval $q1;
+--ERROR ER_BAD_FIELD_ERROR
+eval explain $q1;
+
+eval create procedure sp1() $q1;
+--ERROR ER_BAD_FIELD_ERROR
+call sp1();
+--ERROR ER_BAD_FIELD_ERROR
+call sp1();
+
+let $q2=
+with recursive
+ r as (select * from t1 union select s1.* from t1 as s1, r where s1.b = r.a)
+select * from t1 as t;
+
+--ERROR ER_BAD_FIELD_ERROR
+eval $q2;
+--ERROR ER_BAD_FIELD_ERROR
+eval explain $q2;
+
+eval create procedure sp2() $q2;
+--ERROR ER_BAD_FIELD_ERROR
+call sp2();
+--ERROR ER_BAD_FIELD_ERROR
+call sp2();
+
+drop procedure sp1;
+drop procedure sp2;
+
+drop table t1;
+
+--echo #
+--echo # MDEV-26202: Recursive CTE used indirectly twice
+--echo # (fixed by the patch forMDEV-26025)
+--echo #
+
+with recursive
+ rcte as ( SELECT 1 AS a
+ UNION ALL
+ SELECT cast(a + 1 as unsigned int) FROM rcte WHERE a < 3),
+ cte1 AS (SELECT a FROM rcte),
+ cte2 AS (SELECT a FROM cte1),
+ cte3 AS ( SELECT a FROM cte2)
+SELECT * FROM cte2, cte3;
+
+--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/main/func_str.result b/mysql-test/main/func_str.result
index dc787219b73..f6f8db95f98 100644
--- a/mysql-test/main/func_str.result
+++ b/mysql-test/main/func_str.result
@@ -5158,6 +5158,19 @@ c1
42
DROP TABLE t1, t2;
#
+# MDEV-25560 Creating table with certain generated column crashes server
+#
+CREATE TABLE t1 (i int, b int AS (RPAD(123,1)) stored);
+# Original case from the reporter
+CREATE TABLE crash_test_2 (
+DATA_VALUE CHAR(10) NULL,
+HAS_DATA BIT NOT NULL,
+TEST_COLUMN CHAR(10) AS (RPAD(CASE WHEN HAS_DATA = 1
+THEN DATA_VALUE ELSE NULL END, 10)) STORED);
+ERROR HY000: Function or expression 'rpad(case when `HAS_DATA` = 1 then `DATA_VALUE` else NULL end,10)' cannot be used in the GENERATED ALWAYS AS clause of `TEST_COLUMN`
+# Cleanup
+DROP TABLE t1;
+#
# End of 10.3 tests
#
#
diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test
index 59ef8b0a805..4df473fa0f6 100644
--- a/mysql-test/main/func_str.test
+++ b/mysql-test/main/func_str.test
@@ -2094,6 +2094,24 @@ DROP TABLE t1, t2;
--echo #
+--echo # MDEV-25560 Creating table with certain generated column crashes server
+--echo #
+
+CREATE TABLE t1 (i int, b int AS (RPAD(123,1)) stored);
+
+--echo # Original case from the reporter
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE crash_test_2 (
+ DATA_VALUE CHAR(10) NULL,
+ HAS_DATA BIT NOT NULL,
+ TEST_COLUMN CHAR(10) AS (RPAD(CASE WHEN HAS_DATA = 1
+ THEN DATA_VALUE ELSE NULL END, 10)) STORED);
+
+--echo # Cleanup
+DROP TABLE t1;
+
+
+--echo #
--echo # End of 10.3 tests
--echo #
diff --git a/mysql-test/main/grant5.result b/mysql-test/main/grant5.result
index 9f6eb583e91..fa5a952a9c1 100644
--- a/mysql-test/main/grant5.result
+++ b/mysql-test/main/grant5.result
@@ -49,7 +49,7 @@ SHOW GRANTS FOR test_user;
Grants for test_user@%
GRANT `test_role` TO `test_user`@`%`
GRANT USAGE ON *.* TO `test_user`@`%`
-SET DEFAULT ROLE test_role FOR 'test_user'@'%'
+SET DEFAULT ROLE `test_role` FOR `test_user`@`%`
SET DEFAULT ROLE NONE for test_user;
SHOW GRANTS FOR test_user;
Grants for test_user@%
@@ -63,7 +63,7 @@ Grants for test_user@%
GRANT `test_role` TO `test_user`@`%`
GRANT USAGE ON *.* TO `test_user`@`%`
GRANT USAGE ON *.* TO `test_role`
-SET DEFAULT ROLE test_role FOR 'test_user'@'%'
+SET DEFAULT ROLE `test_role` FOR `test_user`@`%`
SET DEFAULT ROLE NONE;
SHOW GRANTS;
Grants for test_user@%
@@ -168,6 +168,23 @@ drop user 'user1'@'localhost';
drop user 'fetch'@'localhost';
drop user 'user-1'@'localhost';
drop user 'O\'Brien'@'localhost';
+#
+# MDEV-26080 SHOW GRANTS does not quote role names properly for DEFAULT ROLE
+#
+CREATE USER 'test-user';
+CREATE ROLE `r``o'l"e`;
+select user from mysql.user where is_role='Y';
+User
+r`o'l"e
+GRANT `r``o'l"e` TO 'test-user';
+SET DEFAULT ROLE `r``o'l"e` FOR 'test-user';
+SHOW GRANTS FOR 'test-user';
+Grants for test-user@%
+GRANT `r``o'l"e` TO `test-user`@`%`
+GRANT USAGE ON *.* TO `test-user`@`%`
+SET DEFAULT ROLE `r``o'l"e` FOR `test-user`@`%`
+DROP ROLE `r``o'l"e`;
+DROP USER 'test-user';
# End of 10.3 tests
create user u1@h identified with 'mysql_native_password' using 'pwd';
ERROR HY000: Password hash should be a 41-digit hexadecimal number
diff --git a/mysql-test/main/grant5.test b/mysql-test/main/grant5.test
index 9c3f20396c4..0b4a63ab075 100644
--- a/mysql-test/main/grant5.test
+++ b/mysql-test/main/grant5.test
@@ -124,6 +124,20 @@ drop user 'fetch'@'localhost';
drop user 'user-1'@'localhost';
drop user 'O\'Brien'@'localhost';
+--echo #
+--echo # MDEV-26080 SHOW GRANTS does not quote role names properly for DEFAULT ROLE
+--echo #
+
+CREATE USER 'test-user';
+CREATE ROLE `r``o'l"e`;
+select user from mysql.user where is_role='Y';
+GRANT `r``o'l"e` TO 'test-user';
+SET DEFAULT ROLE `r``o'l"e` FOR 'test-user';
+# it is expected that quotes won't be shown correctly
+SHOW GRANTS FOR 'test-user';
+DROP ROLE `r``o'l"e`;
+DROP USER 'test-user';
+
--echo # End of 10.3 tests
#
diff --git a/mysql-test/main/insert_returning.result b/mysql-test/main/insert_returning.result
index e664e02bedc..a3cde7b1270 100644
--- a/mysql-test/main/insert_returning.result
+++ b/mysql-test/main/insert_returning.result
@@ -89,6 +89,9 @@ total val1 id1 && id1 id1 UPPER(val1) f(id1)
ANALYZE INSERT INTO t1(id1,val1) VALUES(13,'l') RETURNING *;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL 100.00 100.00 NULL
+INSERT INTO t1(id1,val1) VALUES(14,'m') RETURNING t1.*;
+id1 val1
+14 m
TRUNCATE TABLE t1;
#
# Multiple values in one insert statement...RETURNING
@@ -182,6 +185,9 @@ id val1 id1 && id1 id1|id1 UPPER(val1) f(id1)
ANALYZE INSERT INTO t1 VALUES(25,'a'),(26,'b') RETURNING *;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL 100.00 100.00 NULL
+ANALYZE INSERT INTO t1 VALUES(27,'c'),(28,'d') RETURNING t1.*;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL 100.00 100.00 NULL
#
# INSERT...ON DUPLICATE KEY UPDATE...RETURNING
#
@@ -250,10 +256,14 @@ ANALYZE INSERT INTO ins_duplicate(id,val) VALUES(2,'b') ON DUPLICATE KEY UPDATE
val='k' RETURNING *;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 INSERT ins_duplicate ALL NULL NULL NULL NULL NULL NULL 100.00 100.00 NULL
+INSERT INTO ins_duplicate(id,val) VALUES(2,'b') ON DUPLICATE KEY UPDATE
+val='l' RETURNING ins_duplicate.*;
+id val
+2 l
SELECT * FROM ins_duplicate;
id val
1 a
-2 k
+2 l
3 c
4 d
#
@@ -327,6 +337,9 @@ total val1 id1 && id1 id1|id1 UPPER(val1) f(id1)
ANALYZE INSERT INTO t1 SET id1=12, val1='l' RETURNING *;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL 100.00 100.00 NULL
+INSERT INTO t1 SET id1= 13, val1= 'm' RETURNING t1.*;
+id1 val1
+13 m
SELECT * FROM t1;
id1 val1
1 a
@@ -339,6 +352,7 @@ id1 val1
8 n
26 Z
12 l
+13 m
#
# INSERT...SELECT...RETURNING
#
@@ -372,6 +386,7 @@ id1 val1
8 n
26 Z
12 l
+13 m
EXECUTE stmt;
(SELECT id1 FROM t1 WHERE val1='b')
2
@@ -407,6 +422,7 @@ id2 val2
5 e
26 Z
12 l
+13 m
Warnings:
Warning 1062 Duplicate entry '1' for key 'PRIMARY'
Warning 1062 Duplicate entry '2' for key 'PRIMARY'
@@ -430,6 +446,18 @@ id2 val2
5 e
26 Z
12 l
+13 m
+TRUNCATE TABLE t2;
+INSERT INTO t2 SELECT * FROM t1 WHERE id1=1 RETURNING t2.*;
+id2 val2
+1 a
+INSERT INTO t2 SELECT t1.* FROM t1 WHERE id1=2 RETURNING t2.*;
+id2 val2
+2 b
+SELECT * FROM t2;
+id2 val2
+1 a
+2 b
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE ins_duplicate;
@@ -460,6 +488,8 @@ t1 WHERE id1=1)
5 6
INSERT INTO t2(id2,val2) VALUES(5,'f') RETURNING (SELECT id2 FROM t2);
ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
+INSERT INTO t2 (id2, val2) VALUES (6,'f') RETURNING t1.*;
+ERROR 42S02: Unknown table 'test.t1'
#
# Multiple rows in single insert statement
#
@@ -481,6 +511,8 @@ t1 WHERE id1=1)
12 13
INSERT INTO t2 VALUES(13,'f'),(14,'g') RETURNING (SELECT id2 FROM t2);
ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
+INSERT INTO t2 VALUES(13,'f'),(14,'g') RETURNING t1.*;
+ERROR 42S02: Unknown table 'test.t1'
#
# INSERT ... SET
#
@@ -501,6 +533,8 @@ WHERE id1=1)
5 6
INSERT INTO t2 SET id2=5, val2='f' RETURNING (SELECT id2 FROM t2);
ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
+INSERT INTO t2 SET id2=5, val2='f' RETURNING t1.*;
+ERROR 42S02: Unknown table 'test.t1'
#
# INSERT...ON DUPLICATE KEY UPDATE
#
@@ -525,6 +559,9 @@ ERROR 42S22: Unknown column 'id2' in 'field list'
INSERT INTO ins_duplicate VALUES(2,'b') ON DUPLICATE KEY UPDATE val='b'
RETURNING (SELECT id FROM ins_duplicate);
ERROR HY000: Table 'ins_duplicate' is specified twice, both as a target for 'INSERT' and as a separate source for data
+INSERT INTO ins_duplicate VALUES(2,'b') ON DUPLICATE KEY UPDATE val='b'
+RETURNING t1.*;
+ERROR 42S02: Unknown table 'test.t1'
#
# INSERT...SELECT
#
@@ -544,6 +581,8 @@ ERROR 21000: Operand should contain 1 column(s)
INSERT INTO t2(id2,val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT
id2 FROM t2);
ERROR 21000: Subquery returns more than 1 row
+INSERT INTO t2(id2,val2) SELECT t1.* FROM t1 WHERE id1=2 RETURNING t1.*;
+ERROR 42S02: Unknown table 'test.t1'
#
# TRIGGER
#
diff --git a/mysql-test/main/insert_returning.test b/mysql-test/main/insert_returning.test
index b4fc75c28bb..6c8e71a4617 100644
--- a/mysql-test/main/insert_returning.test
+++ b/mysql-test/main/insert_returning.test
@@ -41,6 +41,7 @@ SELECT * FROM t1;
INSERT INTO v1(id1, val1) VALUES (12, 'a') RETURNING id1+id1 as total,val1,
id1 && id1, id1 id1, UPPER(val1),f(id1);
ANALYZE INSERT INTO t1(id1,val1) VALUES(13,'l') RETURNING *;
+INSERT INTO t1(id1,val1) VALUES(14,'m') RETURNING t1.*;
TRUNCATE TABLE t1;
--echo #
@@ -68,6 +69,7 @@ SELECT * FROM t1;
INSERT INTO v1 VALUES(23,'y'),(24,'z') RETURNING id1 as id,val1,
id1 && id1, id1|id1, UPPER(val1),f(id1);
ANALYZE INSERT INTO t1 VALUES(25,'a'),(26,'b') RETURNING *;
+ANALYZE INSERT INTO t1 VALUES(27,'c'),(28,'d') RETURNING t1.*;
--echo #
--echo # INSERT...ON DUPLICATE KEY UPDATE...RETURNING
@@ -101,6 +103,8 @@ val1='d' RETURNING id1+id1 AS total, val1, id1 && id1, id1|id1, UPPER(val1),
f(id1);
ANALYZE INSERT INTO ins_duplicate(id,val) VALUES(2,'b') ON DUPLICATE KEY UPDATE
val='k' RETURNING *;
+INSERT INTO ins_duplicate(id,val) VALUES(2,'b') ON DUPLICATE KEY UPDATE
+val='l' RETURNING ins_duplicate.*;
SELECT * FROM ins_duplicate;
--echo #
@@ -130,6 +134,7 @@ EXPLAIN FORMAT="json" INSERT INTO t1 SET id1=11, val1='k' RETURNING val1;
INSERT INTO v1 SET id1=26, val1='Z' RETURNING id1+id1 AS total,val1,
id1 && id1, id1|id1, UPPER(val1),f(id1);
ANALYZE INSERT INTO t1 SET id1=12, val1='l' RETURNING *;
+INSERT INTO t1 SET id1= 13, val1= 'm' RETURNING t1.*;
SELECT * FROM t1;
--echo #
@@ -158,6 +163,10 @@ INSERT IGNORE INTO t2 SELECT * FROM t1 WHERE id1=8 RETURNING *;
INSERT IGNORE INTO v2 SELECT * FROM v1 RETURNING *;
ANALYZE INSERT INTO t2 SELECT * FROM t1 WHERE id1=11 RETURNING *;
SELECT * FROM t2;
+TRUNCATE TABLE t2;
+INSERT INTO t2 SELECT * FROM t1 WHERE id1=1 RETURNING t2.*;
+INSERT INTO t2 SELECT t1.* FROM t1 WHERE id1=2 RETURNING t2.*;
+SELECT * FROM t2;
DROP TABLE t1;
DROP TABLE t2;
@@ -190,6 +199,8 @@ INSERT INTO t2(id2,val2) VALUES(5,'e') RETURNING id2, (SELECT id1+id2 FROM
t1 WHERE id1=1);
--error ER_UPDATE_TABLE_USED
INSERT INTO t2(id2,val2) VALUES(5,'f') RETURNING (SELECT id2 FROM t2);
+--error ER_BAD_TABLE_ERROR
+INSERT INTO t2 (id2, val2) VALUES (6,'f') RETURNING t1.*;
--echo #
--echo # Multiple rows in single insert statement
@@ -208,6 +219,8 @@ INSERT INTO t2 VALUES(11,'e'),(12,'f') RETURNING id2, (SELECT id1+id2 FROM
t1 WHERE id1=1);
--error ER_UPDATE_TABLE_USED
INSERT INTO t2 VALUES(13,'f'),(14,'g') RETURNING (SELECT id2 FROM t2);
+--error ER_BAD_TABLE_ERROR
+INSERT INTO t2 VALUES(13,'f'),(14,'g') RETURNING t1.*;
--echo #
--echo # INSERT ... SET
@@ -226,6 +239,8 @@ INSERT INTO t2 SET id2=5, val2='e' RETURNING id2, (SELECT id1+id2 FROM t1
WHERE id1=1);
--error ER_UPDATE_TABLE_USED
INSERT INTO t2 SET id2=5, val2='f' RETURNING (SELECT id2 FROM t2);
+--error ER_BAD_TABLE_ERROR
+INSERT INTO t2 SET id2=5, val2='f' RETURNING t1.*;
--echo #
--echo # INSERT...ON DUPLICATE KEY UPDATE
@@ -251,6 +266,9 @@ RETURNING id2, (SELECT id1+id FROM t1 WHERE id1=1);
--error ER_UPDATE_TABLE_USED
INSERT INTO ins_duplicate VALUES(2,'b') ON DUPLICATE KEY UPDATE val='b'
RETURNING (SELECT id FROM ins_duplicate);
+--error ER_BAD_TABLE_ERROR
+INSERT INTO ins_duplicate VALUES(2,'b') ON DUPLICATE KEY UPDATE val='b'
+RETURNING t1.*;
--echo #
--echo # INSERT...SELECT
@@ -271,6 +289,8 @@ INSERT INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING(SELECT
--error ER_SUBQUERY_NO_1_ROW
INSERT INTO t2(id2,val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT
id2 FROM t2);
+--error ER_BAD_TABLE_ERROR
+INSERT INTO t2(id2,val2) SELECT t1.* FROM t1 WHERE id1=2 RETURNING t1.*;
--echo #
--echo # TRIGGER
diff --git a/mysql-test/main/lock_multi_bug38499.test b/mysql-test/main/lock_multi_bug38499.test
index b812984e516..c489712e5d8 100644
--- a/mysql-test/main/lock_multi_bug38499.test
+++ b/mysql-test/main/lock_multi_bug38499.test
@@ -2,6 +2,9 @@
# MySQL >= 5.0
#
+# The test can take hours with valgrind
+--source include/not_valgrind.inc
+
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
diff --git a/mysql-test/main/lock_multi_bug38691.test b/mysql-test/main/lock_multi_bug38691.test
index 881a0d8e502..9760c1a873a 100644
--- a/mysql-test/main/lock_multi_bug38691.test
+++ b/mysql-test/main/lock_multi_bug38691.test
@@ -4,6 +4,8 @@
# MySQL >= 5.0
#
+# The test can take hours with valgrind
+--source include/not_valgrind.inc
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
diff --git a/mysql-test/main/my_print_defaults.result b/mysql-test/main/my_print_defaults.result
new file mode 100644
index 00000000000..64aa7b45ca8
--- /dev/null
+++ b/mysql-test/main/my_print_defaults.result
@@ -0,0 +1,51 @@
+# MDEV-24248: my_print_defaults is not taking all the values when using
+# -e option which is called from mysql.server (extra_args).
+#
+# checking for mysql.server
+--key_buffer_size=20M
+--max_allowed_packet=250M
+--table_open_cache=1000
+--table_definition_cache=2000
+--read_buffer_size=1M
+--thread_cache_size=8
+--max_connections=1024
+--long_query_time=60
+--slow_query_log=1
+#
+# MDEV-25908: -e does not work for my_print_defaults
+#
+# Testing -e
+--key_buffer_size=20M
+--max_allowed_packet=250M
+--table_open_cache=1000
+#Testing --defaults-extra-file
+--key_buffer_size=20M
+--max_allowed_packet=250M
+--table_open_cache=1000
+#
+# Testing other options
+#
+# Testing -c option
+--key_buffer_size=20M
+--max_allowed_packet=250M
+--table_open_cache=1000
+# Testing --defaults-file
+--key_buffer_size=20M
+--max_allowed_packet=250M
+--table_open_cache=1000
+# Testing -g option
+--key_buffer_size=20M
+--max_allowed_packet=250M
+--table_open_cache=1000
+--table_definition_cache=2000
+--read_buffer_size=1M
+--thread_cache_size=8
+# Testing --defaults-group-suffix
+--key_buffer_size=20M
+--max_allowed_packet=250M
+--table_open_cache=1000
+--table_definition_cache=2000
+--read_buffer_size=1M
+--thread_cache_size=8
+# Testing --no-defaults
+# End of 10.5 Test
diff --git a/mysql-test/main/my_print_defaults.test b/mysql-test/main/my_print_defaults.test
new file mode 100644
index 00000000000..bfd4e563826
--- /dev/null
+++ b/mysql-test/main/my_print_defaults.test
@@ -0,0 +1,106 @@
+--echo # MDEV-24248: my_print_defaults is not taking all the values when using
+--echo # -e option which is called from mysql.server (extra_args).
+--echo #
+
+--echo # checking for mysql.server
+
+--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
+[mariadb]
+key_buffer_size=20M
+max_allowed_packet=250M
+table_open_cache=1000
+table_definition_cache=2000
+read_buffer_size=1M
+thread_cache_size=8
+max_connections=1024
+long_query_time=60
+slow_query_log=1
+EOF
+
+--write_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
+[mariadb]
+key_buffer_size=20M
+max_allowed_packet=250M
+table_open_cache=1000
+table_definition_cache=2000
+read_buffer_size=1M
+thread_cache_size=8
+max_connections=1024
+long_query_time=60
+slow_query_log=1
+EOF
+
+--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server
+--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
+--remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
+
+
+--echo #
+--echo # MDEV-25908: -e does not work for my_print_defaults
+--echo #
+
+--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
+
+[mariadb]
+key_buffer_size=20M
+max_allowed_packet=250M
+table_open_cache=1000
+EOF
+
+--write_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
+
+[mariadb]
+key_buffer_size=20M
+max_allowed_packet=250M
+table_open_cache=1000
+EOF
+
+--echo # Testing -e
+--exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQLTEST_VARDIR/tmp/tmp1.cnf -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server
+--echo #Testing --defaults-extra-file
+--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server
+
+--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
+--remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
+
+--echo #
+--echo # Testing other options
+--echo #
+
+
+--write_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
+[mariadb]
+key_buffer_size=20M
+max_allowed_packet=250M
+table_open_cache=1000
+EOF
+
+--write_file $MYSQLTEST_VARDIR/tmp/tmp3.cnf
+[mariadb]
+key_buffer_size=20M
+max_allowed_packet=250M
+table_open_cache=1000
+
+[mariadb.1]
+table_definition_cache=2000
+read_buffer_size=1M
+thread_cache_size=8
+EOF
+
+--echo # Testing -c option
+--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server
+--echo # Testing --defaults-file
+--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server
+
+--echo # Testing -g option
+--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp3.cnf --mysqld mysql.server -g .1
+--echo # Testing --defaults-group-suffix
+--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp3.cnf --mysqld mysql.server --defaults-group-suffix=.1
+
+--echo # Testing --no-defaults
+--exec $MYSQL_MY_PRINT_DEFAULTS --no-defaults
+
+--remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
+--remove_file $MYSQLTEST_VARDIR/tmp/tmp3.cnf
+
+--echo # End of 10.5 Test
diff --git a/mysql-test/main/mysql_client_test.result b/mysql-test/main/mysql_client_test.result
index 420e2fc8e3c..dbc1feaa23b 100644
--- a/mysql-test/main/mysql_client_test.result
+++ b/mysql-test/main/mysql_client_test.result
@@ -127,6 +127,11 @@ Data:
EOF
mysql_stmt_next_result(): 0; field_count: 0
# ------------------------------------
+# cat MYSQL_TMP_DIR/test_mdev26145.out.log
+# ------------------------------------
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def MAX(a) MAX(a) 3 11 0 Y 32768 0 63
+# ------------------------------------
# cat MYSQL_TMP_DIR/test_explain_meta.out.log
diff --git a/mysql-test/main/mysql_client_test.test b/mysql-test/main/mysql_client_test.test
index 7885dc5c0d7..9fb7bcd81c9 100644
--- a/mysql-test/main/mysql_client_test.test
+++ b/mysql-test/main/mysql_client_test.test
@@ -36,6 +36,10 @@ echo ok;
--echo # ------------------------------------
--cat_file $MYSQL_TMP_DIR/test_wl4435.out.log
--echo # ------------------------------------
+--echo # cat MYSQL_TMP_DIR/test_mdev26145.out.log
+--echo # ------------------------------------
+--cat_file $MYSQL_TMP_DIR/test_mdev26145.out.log
+--echo # ------------------------------------
--echo
--echo
diff --git a/mysql-test/main/mysql_upgrade.result b/mysql-test/main/mysql_upgrade.result
index 2f7d968a8bd..347d942be5e 100644
--- a/mysql-test/main/mysql_upgrade.result
+++ b/mysql-test/main/mysql_upgrade.result
@@ -1880,7 +1880,7 @@ GRANT `aRole` TO `root`@`localhost` WITH ADMIN OPTION
GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` WITH GRANT OPTION
GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION
GRANT USAGE ON *.* TO `aRole`
-SET DEFAULT ROLE aRole FOR 'root'@'localhost'
+SET DEFAULT ROLE `aRole` FOR `root`@`localhost`
SET DEFAULT ROLE NONE;
SHOW GRANTS;
Grants for root@localhost
diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result
index b4bea9d3686..0de2c5a111b 100644
--- a/mysql-test/main/mysqldump.result
+++ b/mysql-test/main/mysqldump.result
@@ -2688,6 +2688,7 @@ DROP TABLE t1, t2;
# (Problems with --defaults-extra-file option)
#
--port=1234
+--port=1234
#
# Test of fix to Bug#12597 mysqldump dumps triggers wrongly
#
diff --git a/mysql-test/main/order_by_innodb.result b/mysql-test/main/order_by_innodb.result
index 9cdf9800cee..14b9b861a14 100644
--- a/mysql-test/main/order_by_innodb.result
+++ b/mysql-test/main/order_by_innodb.result
@@ -147,4 +147,56 @@ i n
656 eight
set optimizer_switch= @save_optimizer_switch;
DROP TABLE t1,t2,t3;
+#
+# MDEV-25858: Query results are incorrect when indexes are added
+#
+CREATE TABLE t1 (id int NOT NULL PRIMARY KEY) engine=innodb;
+insert into t1 values (1),(2),(3);
+CREATE TABLE t2 (
+id int NOT NULL PRIMARY KEY,
+id2 int NOT NULL,
+d1 datetime,
+d2 timestamp NOT NULL,
+KEY id2 (id2)
+) engine=innodb;
+insert into t2 values
+(1,2,'2019-03-05 00:00:00','2019-03-06 00:00:00'),
+(2,3,'2019-03-05 00:00:00','2019-03-06 00:00:00'),
+(3,3,'2019-03-06 00:00:00','2019-03-05 00:00:00');
+select
+t1.id,t2.id
+from
+t1 left join
+t2 on t2.id2 = t1.id and
+t2.id = (select dd.id
+from t2 dd
+where
+dd.id2 = t1.id and
+d1 > '2019-02-06 00:00:00'
+ order by
+dd.d1 desc, dd.d2 desc, dd.id desc limit 1
+);
+id id
+1 NULL
+2 1
+3 3
+create index for_latest_sort on t2 (d1 desc, d2 desc, id desc);
+select
+t1.id,t2.id
+from
+t1 left join
+t2 on t2.id2 = t1.id and
+t2.id = (select dd.id
+from t2 dd
+where
+dd.id2 = t1.id and
+d1 > '2019-02-06 00:00:00'
+ order by
+dd.d1 desc, dd.d2 desc, dd.id desc limit 1
+);
+id id
+1 NULL
+2 1
+3 3
+drop table t1,t2;
# End of 10.2 tests
diff --git a/mysql-test/main/order_by_innodb.test b/mysql-test/main/order_by_innodb.test
index f4c738263ae..97c043b8dbc 100644
--- a/mysql-test/main/order_by_innodb.test
+++ b/mysql-test/main/order_by_innodb.test
@@ -135,4 +135,55 @@ set optimizer_switch= @save_optimizer_switch;
DROP TABLE t1,t2,t3;
+--echo #
+--echo # MDEV-25858: Query results are incorrect when indexes are added
+--echo #
+
+CREATE TABLE t1 (id int NOT NULL PRIMARY KEY) engine=innodb;
+insert into t1 values (1),(2),(3);
+
+CREATE TABLE t2 (
+ id int NOT NULL PRIMARY KEY,
+ id2 int NOT NULL,
+ d1 datetime,
+ d2 timestamp NOT NULL,
+ KEY id2 (id2)
+) engine=innodb;
+
+insert into t2 values
+ (1,2,'2019-03-05 00:00:00','2019-03-06 00:00:00'),
+ (2,3,'2019-03-05 00:00:00','2019-03-06 00:00:00'),
+ (3,3,'2019-03-06 00:00:00','2019-03-05 00:00:00');
+
+select
+ t1.id,t2.id
+from
+ t1 left join
+ t2 on t2.id2 = t1.id and
+ t2.id = (select dd.id
+ from t2 dd
+ where
+ dd.id2 = t1.id and
+ d1 > '2019-02-06 00:00:00'
+ order by
+ dd.d1 desc, dd.d2 desc, dd.id desc limit 1
+ );
+
+create index for_latest_sort on t2 (d1 desc, d2 desc, id desc);
+
+select
+ t1.id,t2.id
+from
+ t1 left join
+ t2 on t2.id2 = t1.id and
+ t2.id = (select dd.id
+ from t2 dd
+ where
+ dd.id2 = t1.id and
+ d1 > '2019-02-06 00:00:00'
+ order by
+ dd.d1 desc, dd.d2 desc, dd.id desc limit 1
+ );
+drop table t1,t2;
+
--echo # End of 10.2 tests
diff --git a/mysql-test/main/prepare.result b/mysql-test/main/prepare.result
index c1a2969212b..cfe6603dbbe 100644
--- a/mysql-test/main/prepare.result
+++ b/mysql-test/main/prepare.result
@@ -50,3 +50,17 @@ t1_first
deallocate prepare stmt1;
deallocate prepare stmt2;
drop table t1;
+#
+# MDEV-25808 PREPARE/EXECUTE makes signed integer out of unsigned
+#
+prepare p1 from 'select concat(?)';
+execute p1 using 17864960750176564435;
+concat(?)
+17864960750176564435
+prepare p1 from 'select SQRT(?) is not null';
+execute p1 using 17864960750176564435;
+SQRT(?) is not null
+1
+#
+# End of 10.3 tests
+#
diff --git a/mysql-test/main/prepare.test b/mysql-test/main/prepare.test
index eaab376a5a2..4d1573eb0c8 100644
--- a/mysql-test/main/prepare.test
+++ b/mysql-test/main/prepare.test
@@ -40,3 +40,15 @@ execute stmt2;
deallocate prepare stmt1;
deallocate prepare stmt2;
drop table t1;
+
+--echo #
+--echo # MDEV-25808 PREPARE/EXECUTE makes signed integer out of unsigned
+--echo #
+prepare p1 from 'select concat(?)';
+execute p1 using 17864960750176564435;
+prepare p1 from 'select SQRT(?) is not null';
+execute p1 using 17864960750176564435;
+
+--echo #
+--echo # End of 10.3 tests
+--echo #
diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result
index eb17def9a4b..e595b6f8c21 100644
--- a/mysql-test/main/ps.result
+++ b/mysql-test/main/ps.result
@@ -5566,6 +5566,20 @@ DROP TABLE t1, t2, t3;
# End of 10.2 tests
#
#
+# MDEV-26147: The test main.sp-row fails in case it is run in PS mode
+#
+CREATE PROCEDURE p1(a ROW(a INT,b INT))
+BEGIN
+SELECT a.a, a.b;
+END;
+$$
+PREPARE stmt FROM 'CALL p1(ROW(10, 20))';
+EXECUTE stmt;
+a.a a.b
+10 20
+DEALLOCATE PREPARE stmt;
+DROP PROCEDURE p1;
+#
# MDEV-19263: Server crashes in mysql_handle_single_derived
# upon 2nd execution of PS
#
diff --git a/mysql-test/main/ps.test b/mysql-test/main/ps.test
index e5285022efd..fa184ab8250 100644
--- a/mysql-test/main/ps.test
+++ b/mysql-test/main/ps.test
@@ -4995,6 +4995,22 @@ DROP TABLE t1, t2, t3;
--echo #
--echo #
+--echo # MDEV-26147: The test main.sp-row fails in case it is run in PS mode
+--echo #
+DELIMITER $$;
+CREATE PROCEDURE p1(a ROW(a INT,b INT))
+BEGIN
+ SELECT a.a, a.b;
+END;
+$$
+DELIMITER ;$$
+PREPARE stmt FROM 'CALL p1(ROW(10, 20))';
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+
+DROP PROCEDURE p1;
+
+--echo #
--echo # MDEV-19263: Server crashes in mysql_handle_single_derived
--echo # upon 2nd execution of PS
--echo #
diff --git a/mysql-test/main/replace_returning.result b/mysql-test/main/replace_returning.result
index 628b70abad1..1bc9bbd4cc5 100644
--- a/mysql-test/main/replace_returning.result
+++ b/mysql-test/main/replace_returning.result
@@ -33,9 +33,12 @@ EXECUTE stmt;
id1 (SELECT id2 FROM t2 WHERE val2='b')
1 2
DEALLOCATE PREPARE stmt;
+REPLACE INTO t1 (id1, val1) VALUES (1, 'g') RETURNING t1.*;
+id1 val1
+1 g
SELECT * FROM t1;
id1 val1
-1 f
+1 g
TRUNCATE TABLE t1;
#
# Multiple values in one replace statement...RETURNING
@@ -69,10 +72,14 @@ id1 (SELECT id2 FROM t2 WHERE val2='b')
1 2
2 2
DEALLOCATE PREPARE stmt;
+REPLACE INTO t1 VALUES (1,'u'),(2,'v') RETURNING t1.*;
+id1 val1
+1 u
+2 v
SELECT * FROM t1;
id1 val1
-1 s
-2 t
+1 u
+2 v
TRUNCATE TABLE t1;
#
# REPLACE...SET...RETURNING
@@ -101,9 +108,12 @@ EXECUTE stmt;
id1 (SELECT id2 FROM t2 WHERE val2='b')
3 2
DEALLOCATE PREPARE stmt;
+REPLACE INTO t1 SET id1=1, val1 = 'o' RETURNING t1.*;
+id1 val1
+1 o
SELECT * FROM t1;
id1 val1
-1 i
+1 o
2 j
3 k
#
@@ -113,7 +123,7 @@ TRUNCATE TABLE t2;
REPLACE INTO t2(id2,val2) SELECT * FROM t1;
REPLACE INTO t2 SELECT * FROM t1 WHERE id1=1 RETURNING *;
id2 val2
-1 i
+1 o
REPLACE INTO t2 SELECT * FROM t1 WHERE id1=2 RETURNING id2+id2 AS total,
id2&&id2, id2|id2,UPPER(val2),f(id2);
total id2&&id2 id2|id2 UPPER(val2) f(id2)
@@ -122,7 +132,7 @@ REPLACE INTO t2 SELECT * FROM t1 WHERE id1=3 RETURNING (SELECT
GROUP_CONCAT(val1) FROM t1 WHERE id1=1);
(SELECT
GROUP_CONCAT(val1) FROM t1 WHERE id1=1)
-i
+o
REPLACE INTO t2 SELECT * FROM t1 WHERE id1=1 RETURNING (SELECT
GROUP_CONCAT(val1) FROM t1 GROUP BY id1 HAVING id1=id1+1);
(SELECT
@@ -144,11 +154,109 @@ FROM t2 WHERE id2=0);
(SELECT id1+id2
FROM t2 WHERE id2=0)
NULL
+REPLACE INTO t2 SELECT * FROM t1 WHERE id1=2 RETURNING t2.*;
+id2 val2
+2 j
SELECT * FROM t2;
id2 val2
-1 i
+1 o
2 j
3 k
DROP TABLE t1;
DROP TABLE t2;
DROP FUNCTION f;
+#
+# checking errors
+#
+CREATE TABLE t1(id1 INT,val1 VARCHAR(1));
+CREATE TABLE t2(id2 INT,val2 VARCHAR(1));
+REPLACE INTO t1 VALUES(1,'a'),(2,'b'),(3,'c');
+#
+# SIMLPE REPLACE STATEMENT
+#
+REPLACE INTO t2(id2,val2) VALUES(1,'a') RETURNING id1;
+ERROR 42S22: Unknown column 'id1' in 'field list'
+REPLACE INTO t2(id2,val2) values(2,'b') RETURNING SUM(id2);
+ERROR HY000: Invalid use of group function
+REPLACE INTO t2(id2,val2) VALUES(3,'c') RETURNING (SELECT id1 FROM t1);
+ERROR 21000: Subquery returns more than 1 row
+REPLACE INTO t2(id2,val2) VALUES(4,'d') RETURNING (SELECT * FROM t1);
+ERROR 21000: Operand should contain 1 column(s)
+REPLACE INTO t2(id2,val2) VALUES(4,'d') RETURNING (SELECT * FROM t2);
+ERROR 21000: Operand should contain 1 column(s)
+REPLACE INTO t2(id2,val2) VALUES(5,'e') RETURNING id2, (SELECT id1+id2 FROM
+t1 WHERE id1=1);
+id2 (SELECT id1+id2 FROM
+t1 WHERE id1=1)
+5 6
+REPLACE INTO t2(id2,val2) VALUES(5,'f') RETURNING (SELECT id2 FROM t2);
+ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
+REPLACE INTO t2 (id2, val2) VALUES (6,'f') RETURNING t1.*;
+ERROR 42S02: Unknown table 'test.t1'
+#
+# Multiple rows in single insert statement
+#
+REPLACE INTO t2 VALUES(1,'a'),(2,'b') RETURNING id1;
+ERROR 42S22: Unknown column 'id1' in 'field list'
+REPLACE INTO t2 VALUES(3,'c'),(4,'d') RETURNING MAX(id2);
+ERROR HY000: Invalid use of group function
+REPLACE INTO t2 VALUES(5,'c'),(6,'f') RETURNING (SELECT id1 FROM t1);
+ERROR 21000: Subquery returns more than 1 row
+REPLACE INTO t2 VALUES(7,'g'),(8,'h') RETURNING (SELECT * FROM t1);
+ERROR 21000: Operand should contain 1 column(s)
+REPLACE INTO t2 VALUES(9,'g'),(10,'h') RETURNING (SELECT * FROM t2);
+ERROR 21000: Operand should contain 1 column(s)
+REPLACE INTO t2 VALUES(11,'e'),(12,'f') RETURNING id2, (SELECT id1+id2 FROM
+t1 WHERE id1=1);
+id2 (SELECT id1+id2 FROM
+t1 WHERE id1=1)
+11 12
+12 13
+REPLACE INTO t2 VALUES(13,'f'),(14,'g') RETURNING (SELECT id2 FROM t2);
+ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
+REPLACE INTO t2 VALUES(13,'f'),(14,'g') RETURNING t1.*;
+ERROR 42S02: Unknown table 'test.t1'
+#
+# REPLACE ... SET
+#
+REPLACE INTO t2 SET id2=1, val2='a' RETURNING id1;
+ERROR 42S22: Unknown column 'id1' in 'field list'
+REPLACE INTO t2 SET id2=2, val2='b' RETURNING COUNT(id2);
+ERROR HY000: Invalid use of group function
+REPLACE INTO t2 SET id2=3, val2='c' RETURNING (SELECT id1 FROM t1);
+ERROR 21000: Subquery returns more than 1 row
+REPLACE INTO t2 SET id2=4, val2='d' RETURNING (SELECT * FROM t1);
+ERROR 21000: Operand should contain 1 column(s)
+REPLACE INTO t2 SET id2=4, val2='d' RETURNING (SELECT * FROM t2);
+ERROR 21000: Operand should contain 1 column(s)
+REPLACE INTO t2 SET id2=5, val2='e' RETURNING id2, (SELECT id1+id2 FROM t1
+WHERE id1=1);
+id2 (SELECT id1+id2 FROM t1
+WHERE id1=1)
+5 6
+REPLACE INTO t2 SET id2=5, val2='f' RETURNING (SELECT id2 FROM t2);
+ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
+REPLACE INTO t2 SET id2=5, val2='f' RETURNING t1.*;
+ERROR 42S02: Unknown table 'test.t1'
+#
+# REPLACE...SELECT
+#
+REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=1 RETURNING id1;
+ERROR 42S22: Unknown column 'id1' in 'field list'
+REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING MAX(id2);
+ERROR HY000: Invalid use of group function
+REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT
+id1 FROM t1);
+ERROR 21000: Subquery returns more than 1 row
+REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT
+* FROM t1);
+ERROR 21000: Operand should contain 1 column(s)
+REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING(SELECT
+* FROM t2);
+ERROR 21000: Operand should contain 1 column(s)
+REPLACE INTO t2(id2,val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT
+id2 FROM t2);
+ERROR 21000: Subquery returns more than 1 row
+REPLACE INTO t2(id2,val2) SELECT t1.* FROM t1 WHERE id1=2 RETURNING t1.*;
+ERROR 42S02: Unknown table 'test.t1'
+DROP TABLE t1,t2;
diff --git a/mysql-test/main/replace_returning.test b/mysql-test/main/replace_returning.test
index b2681585d31..8b8a1c24e3e 100644
--- a/mysql-test/main/replace_returning.test
+++ b/mysql-test/main/replace_returning.test
@@ -28,6 +28,7 @@ PREPARE stmt FROM "REPLACE INTO t1 (id1,val1) VALUES (1,'f') RETURNING
id1,(SELECT id2 FROM t2 WHERE val2='b')";
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
+REPLACE INTO t1 (id1, val1) VALUES (1, 'g') RETURNING t1.*;
SELECT * FROM t1;
TRUNCATE TABLE t1;
@@ -46,6 +47,7 @@ PREPARE stmt FROM "REPLACE INTO t1 VALUES (1,'s'),(2,'t') RETURNING id1,
(SELECT id2 FROM t2 WHERE val2='b')";
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
+REPLACE INTO t1 VALUES (1,'u'),(2,'v') RETURNING t1.*;
SELECT * FROM t1;
TRUNCATE TABLE t1;
@@ -64,6 +66,8 @@ PREPARE stmt FROM "REPLACE INTO t1 SET id1=3, val1='k' RETURNING id1,
(SELECT id2 FROM t2 WHERE val2='b')";
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
+REPLACE INTO t1 SET id1=1, val1 = 'o' RETURNING t1.*;
+
SELECT * FROM t1;
--echo #
@@ -86,8 +90,103 @@ REPLACE INTO t2 SELECT * FROM t1 WHERE id1=3 RETURNING (SELECT id1+id2
FROM t1 WHERE id1=1);
REPLACE INTO t2 SELECT * FROM t1 WHERE id1=1 RETURNING (SELECT id1+id2
FROM t2 WHERE id2=0);
+REPLACE INTO t2 SELECT * FROM t1 WHERE id1=2 RETURNING t2.*;
SELECT * FROM t2;
DROP TABLE t1;
DROP TABLE t2;
DROP FUNCTION f;
+
+--echo #
+--echo # checking errors
+--echo #
+
+CREATE TABLE t1(id1 INT,val1 VARCHAR(1));
+CREATE TABLE t2(id2 INT,val2 VARCHAR(1));
+
+REPLACE INTO t1 VALUES(1,'a'),(2,'b'),(3,'c');
+
+--echo #
+--echo # SIMLPE REPLACE STATEMENT
+--echo #
+--error ER_BAD_FIELD_ERROR
+REPLACE INTO t2(id2,val2) VALUES(1,'a') RETURNING id1;
+--error ER_INVALID_GROUP_FUNC_USE
+REPLACE INTO t2(id2,val2) values(2,'b') RETURNING SUM(id2);
+--error ER_SUBQUERY_NO_1_ROW
+REPLACE INTO t2(id2,val2) VALUES(3,'c') RETURNING (SELECT id1 FROM t1);
+--error ER_OPERAND_COLUMNS
+REPLACE INTO t2(id2,val2) VALUES(4,'d') RETURNING (SELECT * FROM t1);
+--error ER_OPERAND_COLUMNS
+REPLACE INTO t2(id2,val2) VALUES(4,'d') RETURNING (SELECT * FROM t2);
+REPLACE INTO t2(id2,val2) VALUES(5,'e') RETURNING id2, (SELECT id1+id2 FROM
+t1 WHERE id1=1);
+--error ER_UPDATE_TABLE_USED
+REPLACE INTO t2(id2,val2) VALUES(5,'f') RETURNING (SELECT id2 FROM t2);
+--error ER_BAD_TABLE_ERROR
+REPLACE INTO t2 (id2, val2) VALUES (6,'f') RETURNING t1.*;
+
+--echo #
+--echo # Multiple rows in single insert statement
+--echo #
+--error ER_BAD_FIELD_ERROR
+REPLACE INTO t2 VALUES(1,'a'),(2,'b') RETURNING id1;
+--error ER_INVALID_GROUP_FUNC_USE
+REPLACE INTO t2 VALUES(3,'c'),(4,'d') RETURNING MAX(id2);
+--error ER_SUBQUERY_NO_1_ROW
+REPLACE INTO t2 VALUES(5,'c'),(6,'f') RETURNING (SELECT id1 FROM t1);
+--error ER_OPERAND_COLUMNS
+REPLACE INTO t2 VALUES(7,'g'),(8,'h') RETURNING (SELECT * FROM t1);
+--error ER_OPERAND_COLUMNS
+REPLACE INTO t2 VALUES(9,'g'),(10,'h') RETURNING (SELECT * FROM t2);
+REPLACE INTO t2 VALUES(11,'e'),(12,'f') RETURNING id2, (SELECT id1+id2 FROM
+t1 WHERE id1=1);
+--error ER_UPDATE_TABLE_USED
+REPLACE INTO t2 VALUES(13,'f'),(14,'g') RETURNING (SELECT id2 FROM t2);
+--error ER_BAD_TABLE_ERROR
+REPLACE INTO t2 VALUES(13,'f'),(14,'g') RETURNING t1.*;
+
+--echo #
+--echo # REPLACE ... SET
+--echo #
+--error ER_BAD_FIELD_ERROR
+REPLACE INTO t2 SET id2=1, val2='a' RETURNING id1;
+--error ER_INVALID_GROUP_FUNC_USE
+REPLACE INTO t2 SET id2=2, val2='b' RETURNING COUNT(id2);
+--error ER_SUBQUERY_NO_1_ROW
+REPLACE INTO t2 SET id2=3, val2='c' RETURNING (SELECT id1 FROM t1);
+--error ER_OPERAND_COLUMNS
+REPLACE INTO t2 SET id2=4, val2='d' RETURNING (SELECT * FROM t1);
+--error ER_OPERAND_COLUMNS
+REPLACE INTO t2 SET id2=4, val2='d' RETURNING (SELECT * FROM t2);
+REPLACE INTO t2 SET id2=5, val2='e' RETURNING id2, (SELECT id1+id2 FROM t1
+WHERE id1=1);
+--error ER_UPDATE_TABLE_USED
+REPLACE INTO t2 SET id2=5, val2='f' RETURNING (SELECT id2 FROM t2);
+--error ER_BAD_TABLE_ERROR
+REPLACE INTO t2 SET id2=5, val2='f' RETURNING t1.*;
+
+--echo #
+--echo # REPLACE...SELECT
+--echo #
+--error ER_BAD_FIELD_ERROR
+REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=1 RETURNING id1;
+--error ER_INVALID_GROUP_FUNC_USE
+REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING MAX(id2);
+--error ER_SUBQUERY_NO_1_ROW
+REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT
+id1 FROM t1);
+--error ER_OPERAND_COLUMNS
+REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT
+* FROM t1);
+--error ER_OPERAND_COLUMNS
+REPLACE INTO t2(id2, val2) SELECT * FROM t1 WHERE id1=2 RETURNING(SELECT
+* FROM t2);
+--error ER_SUBQUERY_NO_1_ROW
+REPLACE INTO t2(id2,val2) SELECT * FROM t1 WHERE id1=2 RETURNING (SELECT
+id2 FROM t2);
+--error ER_BAD_TABLE_ERROR
+REPLACE INTO t2(id2,val2) SELECT t1.* FROM t1 WHERE id1=2 RETURNING t1.*;
+
+
+DROP TABLE t1,t2;
diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result
index dc377aa5b6c..a1d227a9baa 100644
--- a/mysql-test/main/selectivity_innodb.result
+++ b/mysql-test/main/selectivity_innodb.result
@@ -2098,6 +2098,57 @@ drop view v1;
#
# End of 10.1 tests
#
+#
+# MDEV-17783: AddressSanitizer: stack-buffer-overflow in table_cond_selectivity
+#
+set
+@tmp_jcl=@@join_cache_level,
+@tmp_sel=@@optimizer_use_condition_selectivity;
+set
+join_cache_level=3,
+optimizer_use_condition_selectivity=2;
+CREATE TABLE t1 (
+c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, c8 int, c9 int, c10 int,
+c11 int, c12 int, c13 int, c14 int, c15 int, c16 int, c17 int, c18 int, c19 int,
+c20 int, c21 int, c22 int, c23 int, c24 int, c25 int, c26 int, c27 int, c28 int,
+c29 int, c30 int, c31 int, c32 int, c33 int, c34 int
+) ENGINE=InnoDB;
+SELECT * FROM t1
+WHERE
+(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10,
+c11, c12, c13, c14, c15, c16, c17, c18, c19,
+c20, c21, c22, c23, c24, c25, c26, c27, c28, c29,
+c30, c31, c32, c33, c34) IN (SELECT * FROM t1) ;
+c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34
+set
+join_cache_level=@tmp_jcl,
+optimizer_use_condition_selectivity=@tmp_sel;
+drop table t1;
+#
+# MDEV-25013: SIGSEGV in best_extension_by_limited_search | SIGSEGV in restore_prev_nj_state
+#
+SET join_cache_level=3;
+CREATE TABLE t1 (
+TEXT1 TEXT, TEXT2 TEXT, TEXT3 TEXT, TEXT4 TEXT, TEXT5 TEXT,
+TEXT6 TEXT, TEXT7 TEXT, TEXT8 TEXT, TEXT9 TEXT, TEXT10 TEXT,
+TEXT11 TEXT, TEXT12 TEXT,TEXT13 TEXT,TEXT14 TEXT,TEXT15 TEXT,
+TEXT16 TEXT,TEXT17 TEXT,TEXT18 TEXT,TEXT19 TEXT,TEXT20 TEXT,
+TEXT21 TEXT,TEXT22 TEXT,TEXT23 TEXT,TEXT24 TEXT,TEXT25 TEXT,
+TEXT26 TEXT,TEXT27 TEXT,TEXT28 TEXT,TEXT29 TEXT,TEXT30 TEXT,
+TEXT31 TEXT,TEXT32 TEXT,TEXT33 TEXT,TEXT34 TEXT,TEXT35 TEXT,
+TEXT36 TEXT,TEXT37 TEXT,TEXT38 TEXT,TEXT39 TEXT,TEXT40 TEXT,
+TEXT41 TEXT,TEXT42 TEXT,TEXT43 TEXT,TEXT44 TEXT,TEXT45 TEXT,
+TEXT46 TEXT,TEXT47 TEXT,TEXT48 TEXT,TEXT49 TEXT,TEXT50 TEXT
+) ENGINE=InnoDB;
+EXPLAIN SELECT 1 FROM t1 NATURAL JOIN t1 AS t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where
+1 SIMPLE t2 hash_ALL NULL #hash#$hj 150 test.t1.TEXT1,test.t1.TEXT2,test.t1.TEXT3,test.t1.TEXT4,test.t1.TEXT5,test.t1.TEXT6,test.t1.TEXT7,test.t1.TEXT8,test.t1.TEXT9,test.t1.TEXT10,test.t1.TEXT11,test.t1.TEXT12,test.t1.TEXT13,test.t1.TEXT14,test.t1.TEXT15,test.t1.TEXT16,test.t1.TEXT17,test.t1.TEXT18,test.t1.TEXT19,test.t1.TEXT20,test.t1.TEXT21,test.t1.TEXT22,test.t1.TEXT23,test.t1.TEXT24,test.t1.TEXT25,test.t1.TEXT26,test.t1.TEXT27,test.t1.TEXT28,test.t1.TEXT29,test.t1.TEXT30,test.t1.TEXT31,test.t1.TEXT32,test.t1.TEXT33,test.t1.TEXT34,test.t1.TEXT35,test.t1.TEXT36,test.t1.TEXT37,test.t1.TEXT38,test.t1.TEXT39,test.t1.TEXT40,test.t1.TEXT41,test.t1.TEXT42,test.t1.TEXT43,test.t1.TEXT44,test.t1.TEXT45,test.t1.TEXT46,test.t1.TEXT47,test.t1.TEXT48,test.t1.TEXT49,test.t1.TEXT50 1 Using where; Using join buffer (flat, BNLH join)
+set join_cache_level=@tmp_jcl;
+drop table t1;
+#
+# End of 10.1 tests
+#
set use_stat_tables= @tmp_ust;
set optimizer_use_condition_selectivity= @tmp_oucs;
set @@global.histogram_size=@save_histogram_size;
diff --git a/mysql-test/main/selectivity_innodb.test b/mysql-test/main/selectivity_innodb.test
index b98b5342183..4bcdb5d6ec9 100644
--- a/mysql-test/main/selectivity_innodb.test
+++ b/mysql-test/main/selectivity_innodb.test
@@ -174,6 +174,61 @@ drop view v1;
--echo # End of 10.1 tests
--echo #
+--echo #
+--echo # MDEV-17783: AddressSanitizer: stack-buffer-overflow in table_cond_selectivity
+--echo #
+
+set
+ @tmp_jcl=@@join_cache_level,
+ @tmp_sel=@@optimizer_use_condition_selectivity;
+set
+ join_cache_level=3,
+ optimizer_use_condition_selectivity=2;
+
+CREATE TABLE t1 (
+ c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, c8 int, c9 int, c10 int,
+ c11 int, c12 int, c13 int, c14 int, c15 int, c16 int, c17 int, c18 int, c19 int,
+ c20 int, c21 int, c22 int, c23 int, c24 int, c25 int, c26 int, c27 int, c28 int,
+ c29 int, c30 int, c31 int, c32 int, c33 int, c34 int
+) ENGINE=InnoDB;
+
+SELECT * FROM t1
+WHERE
+ (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10,
+ c11, c12, c13, c14, c15, c16, c17, c18, c19,
+ c20, c21, c22, c23, c24, c25, c26, c27, c28, c29,
+ c30, c31, c32, c33, c34) IN (SELECT * FROM t1) ;
+
+set
+ join_cache_level=@tmp_jcl,
+ optimizer_use_condition_selectivity=@tmp_sel;
+drop table t1;
+
+--echo #
+--echo # MDEV-25013: SIGSEGV in best_extension_by_limited_search | SIGSEGV in restore_prev_nj_state
+--echo #
+
+SET join_cache_level=3;
+CREATE TABLE t1 (
+ TEXT1 TEXT, TEXT2 TEXT, TEXT3 TEXT, TEXT4 TEXT, TEXT5 TEXT,
+ TEXT6 TEXT, TEXT7 TEXT, TEXT8 TEXT, TEXT9 TEXT, TEXT10 TEXT,
+ TEXT11 TEXT, TEXT12 TEXT,TEXT13 TEXT,TEXT14 TEXT,TEXT15 TEXT,
+ TEXT16 TEXT,TEXT17 TEXT,TEXT18 TEXT,TEXT19 TEXT,TEXT20 TEXT,
+ TEXT21 TEXT,TEXT22 TEXT,TEXT23 TEXT,TEXT24 TEXT,TEXT25 TEXT,
+ TEXT26 TEXT,TEXT27 TEXT,TEXT28 TEXT,TEXT29 TEXT,TEXT30 TEXT,
+ TEXT31 TEXT,TEXT32 TEXT,TEXT33 TEXT,TEXT34 TEXT,TEXT35 TEXT,
+ TEXT36 TEXT,TEXT37 TEXT,TEXT38 TEXT,TEXT39 TEXT,TEXT40 TEXT,
+ TEXT41 TEXT,TEXT42 TEXT,TEXT43 TEXT,TEXT44 TEXT,TEXT45 TEXT,
+ TEXT46 TEXT,TEXT47 TEXT,TEXT48 TEXT,TEXT49 TEXT,TEXT50 TEXT
+) ENGINE=InnoDB;
+EXPLAIN SELECT 1 FROM t1 NATURAL JOIN t1 AS t2;
+
+set join_cache_level=@tmp_jcl;
+drop table t1;
+--echo #
+--echo # End of 10.1 tests
+--echo #
+
set use_stat_tables= @tmp_ust;
set optimizer_use_condition_selectivity= @tmp_oucs;
set @@global.histogram_size=@save_histogram_size;
diff --git a/mysql-test/main/selectivity_no_engine.result b/mysql-test/main/selectivity_no_engine.result
index 743dcd04695..3811b12a1be 100644
--- a/mysql-test/main/selectivity_no_engine.result
+++ b/mysql-test/main/selectivity_no_engine.result
@@ -294,6 +294,26 @@ SELECT * FROM t1 WHERE t1.d = 0 AND t1.p = '1' AND t1.i != '-1' AND t1.n = 'some
i n d p
set optimizer_use_condition_selectivity= @tmp_mdev8779;
DROP TABLE t1;
+#
+# MDEV-23937: SIGSEGV in looped best_extension_by_limited_search from greedy_search
+# (Testcase only)
+#
+set
+@tmp_jcl= @@join_cache_level,
+@tmp_ucs= @@optimizer_use_condition_selectivity;
+set
+join_cache_level=3,
+optimizer_use_condition_selectivity=2;
+CREATE TABLE t1 AS SELECT * FROM mysql.user;
+CREATE TABLE t3 (b VARCHAR (1));
+CREATE TABLE t2 (c2 INT);
+INSERT INTO t2 VALUES (1);
+EXPLAIN
+SELECT * FROM t1 AS a NATURAL JOIN t1 AS b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE a ALL NULL NULL NULL NULL 5 Using where
+1 SIMPLE b hash_ALL NULL #hash#$hj 1341 test.a.Host,test.a.User,test.a.Password,test.a.Select_priv,test.a.Insert_priv,test.a.Update_priv,test.a.Delete_priv,test.a.Create_priv,test.a.Drop_priv,test.a.Reload_priv,test.a.Shutdown_priv,test.a.Process_priv,test.a.File_priv,test.a.Grant_priv,test.a.References_priv,test.a.Index_priv,test.a.Alter_priv,test.a.Show_db_priv,test.a.Super_priv,test.a.Create_tmp_table_priv,test.a.Lock_tables_priv,test.a.Execute_priv,test.a.Repl_slave_priv,test.a.Repl_client_priv,test.a.Create_view_priv,test.a.Show_view_priv,test.a.Create_routine_priv,test.a.Alter_routine_priv,test.a.Create_user_priv,test.a.Event_priv,test.a.Trigger_priv,test.a.Create_tablespace_priv,test.a.Delete_history_priv,test.a.ssl_type,test.a.ssl_cipher,test.a.x509_issuer,test.a.x509_subject,test.a.max_questions,test.a.max_updates,test.a.max_connections,test.a.max_user_connections,test.a.plugin,test.a.authentication_string,test.a.password_expired,test.a.is_role,test.a.default_role,test.a.max_statement_time 5 Using where; Using join buffer (flat, BNLH join)
+DROP TABLE t1,t2,t3;
#
# End of the test file
#
diff --git a/mysql-test/main/selectivity_no_engine.test b/mysql-test/main/selectivity_no_engine.test
index c0f41ca7fb2..5bc78e03781 100644
--- a/mysql-test/main/selectivity_no_engine.test
+++ b/mysql-test/main/selectivity_no_engine.test
@@ -229,6 +229,27 @@ SELECT * FROM t1 WHERE t1.d = 0 AND t1.p = '1' AND t1.i != '-1' AND t1.n = 'some
set optimizer_use_condition_selectivity= @tmp_mdev8779;
DROP TABLE t1;
+--echo #
+--echo # MDEV-23937: SIGSEGV in looped best_extension_by_limited_search from greedy_search
+--echo # (Testcase only)
+--echo #
+set
+ @tmp_jcl= @@join_cache_level,
+ @tmp_ucs= @@optimizer_use_condition_selectivity;
+set
+ join_cache_level=3,
+ optimizer_use_condition_selectivity=2;
+
+CREATE TABLE t1 AS SELECT * FROM mysql.user;
+CREATE TABLE t3 (b VARCHAR (1));
+CREATE TABLE t2 (c2 INT);
+INSERT INTO t2 VALUES (1);
+
+EXPLAIN
+SELECT * FROM t1 AS a NATURAL JOIN t1 AS b;
+
+DROP TABLE t1,t2,t3;
+
--echo #
--echo # End of the test file
--echo #
diff --git a/mysql-test/main/shutdown_not_windows.combinations b/mysql-test/main/shutdown_not_windows.combinations
new file mode 100644
index 00000000000..684d4cfd61d
--- /dev/null
+++ b/mysql-test/main/shutdown_not_windows.combinations
@@ -0,0 +1,5 @@
+[1tpc]
+--thread-handling=one-thread-per-connection
+
+[pot]
+--thread-handling=pool-of-threads
diff --git a/mysql-test/main/shutdown_not_windows.result b/mysql-test/main/shutdown_not_windows.result
new file mode 100644
index 00000000000..524cdf20fa2
--- /dev/null
+++ b/mysql-test/main/shutdown_not_windows.result
@@ -0,0 +1,8 @@
+#
+# MDEV-18353 Shutdown may miss to wait for connection thread
+#
+call mtr.add_suppression('Thread .* did not exit');
+set @old_dbug=@@global.debug_dbug;
+set global debug_dbug='+d,CONNECT_wait';
+select variable_value into @cons from information_schema.global_status where variable_name='connections';
+# restart
diff --git a/mysql-test/main/shutdown_not_windows.test b/mysql-test/main/shutdown_not_windows.test
new file mode 100644
index 00000000000..e93867e2227
--- /dev/null
+++ b/mysql-test/main/shutdown_not_windows.test
@@ -0,0 +1,14 @@
+source include/not_windows.inc;
+source include/not_embedded.inc;
+source include/have_debug.inc;
+--echo #
+--echo # MDEV-18353 Shutdown may miss to wait for connection thread
+--echo #
+call mtr.add_suppression('Thread .* did not exit');
+set @old_dbug=@@global.debug_dbug;
+set global debug_dbug='+d,CONNECT_wait';
+select variable_value into @cons from information_schema.global_status where variable_name='connections';
+exec $MYSQL -e 'select sleep(3600)' >/dev/null 2>&1 &;
+let $wait_condition= select variable_value>@cons from information_schema.global_status where variable_name='connections';
+source include/wait_condition.inc;
+source include/restart_mysqld.inc;
diff --git a/mysql-test/main/skip_name_resolve.result b/mysql-test/main/skip_name_resolve.result
index 9a903ebf472..fe71b714cbc 100644
--- a/mysql-test/main/skip_name_resolve.result
+++ b/mysql-test/main/skip_name_resolve.result
@@ -39,4 +39,24 @@ SET @@LOCAL.skip_name_resolve=0;
ERROR HY000: Variable 'skip_name_resolve' is a read only variable
SET @@GLOBAL.skip_name_resolve=0;
ERROR HY000: Variable 'skip_name_resolve' is a read only variable
-End of 5.1 tests
+#
+# End of 5.1 tests
+#
+#
+# MDEV-26081 set role crashes when a hostname cannot be resolved
+#
+create user u1@`%`;
+create role r1;
+create role r2;
+grant r2 to r1;
+grant r1 to u1@`%`;
+connect u1,127.0.0.1,u1,,,$MASTER_MYPORT;
+set role r2;
+ERROR OP000: User `u1`@`%` has not been granted role `r2`
+disconnect u1;
+connection default;
+drop user u1@`%`;
+drop role r1, r2;
+#
+# End of 10.2 tests
+#
diff --git a/mysql-test/main/skip_name_resolve.test b/mysql-test/main/skip_name_resolve.test
index b0c5118f970..0ff19092b82 100644
--- a/mysql-test/main/skip_name_resolve.test
+++ b/mysql-test/main/skip_name_resolve.test
@@ -50,4 +50,28 @@ SET @@LOCAL.skip_name_resolve=0;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@GLOBAL.skip_name_resolve=0;
---echo End of 5.1 tests
+--echo #
+--echo # End of 5.1 tests
+--echo #
+
+--echo #
+--echo # MDEV-26081 set role crashes when a hostname cannot be resolved
+--echo #
+
+create user u1@`%`;
+create role r1;
+create role r2;
+grant r2 to r1;
+grant r1 to u1@`%`;
+
+connect u1,127.0.0.1,u1,,,$MASTER_MYPORT;
+error ER_INVALID_ROLE;
+set role r2;
+disconnect u1;
+connection default;
+drop user u1@`%`;
+drop role r1, r2;
+
+--echo #
+--echo # End of 10.2 tests
+--echo #
diff --git a/mysql-test/main/ssl_cipher.opt b/mysql-test/main/ssl_cipher.opt
new file mode 100644
index 00000000000..6545e04ba5f
--- /dev/null
+++ b/mysql-test/main/ssl_cipher.opt
@@ -0,0 +1 @@
+--loose-tls-version=TLSv1.0,TLSv1.1,TLSv1.2
diff --git a/mysql-test/main/table_value_constr.result b/mysql-test/main/table_value_constr.result
index 1b41a6bab96..8b5df420269 100644
--- a/mysql-test/main/table_value_constr.result
+++ b/mysql-test/main/table_value_constr.result
@@ -3060,6 +3060,44 @@ a
2
3
drop table t1;
+#
+# MDEV-25484: Derived table using TVC with LIMIT and ORDER BY
+#
+create table t1 (a int);
+insert into t1 values (3), (7), (1);
+select * from ( (select * from t1 limit 2) order by 1 desc) as dt;
+a
+3
+7
+(values (3), (7), (1) limit 2) order by 1 desc;
+3
+7
+3
+select * from ( (values (3), (7), (1) limit 2) order by 1 desc) as dt;
+3
+3
+7
+select * from ( select * from t1 order by 1 limit 2 ) as dt;
+a
+1
+3
+values (3),(7),(1) order by 1 limit 2;
+3
+1
+3
+select * from ( values (3),(7),(1) order by 1 limit 2 ) as dt;
+3
+1
+3
+values (3),(7),(1) union values (2),(4) order by 1 limit 2;
+3
+1
+2
+select * from (values (3),(7),(1) union values (2),(4) order by 1 limit 2) as dt;
+3
+1
+2
+drop table t1;
End of 10.3 tests
#
# MDEV-22610 Crash in INSERT INTO t1 (VALUES (DEFAULT) UNION VALUES (DEFAULT))
diff --git a/mysql-test/main/table_value_constr.test b/mysql-test/main/table_value_constr.test
index 9f06be800e6..cbad7706ca5 100644
--- a/mysql-test/main/table_value_constr.test
+++ b/mysql-test/main/table_value_constr.test
@@ -1630,6 +1630,28 @@ select * from t1;
drop table t1;
+
+--echo #
+--echo # MDEV-25484: Derived table using TVC with LIMIT and ORDER BY
+--echo #
+
+create table t1 (a int);
+insert into t1 values (3), (7), (1);
+
+select * from ( (select * from t1 limit 2) order by 1 desc) as dt;
+(values (3), (7), (1) limit 2) order by 1 desc;
+select * from ( (values (3), (7), (1) limit 2) order by 1 desc) as dt;
+
+
+select * from ( select * from t1 order by 1 limit 2 ) as dt;
+values (3),(7),(1) order by 1 limit 2;
+select * from ( values (3),(7),(1) order by 1 limit 2 ) as dt;
+
+values (3),(7),(1) union values (2),(4) order by 1 limit 2;
+select * from (values (3),(7),(1) union values (2),(4) order by 1 limit 2) as dt;
+
+drop table t1;
+
--echo End of 10.3 tests
--echo #
diff --git a/mysql-test/main/union.result b/mysql-test/main/union.result
index ea1a55464d5..c0a45a2ac14 100644
--- a/mysql-test/main/union.result
+++ b/mysql-test/main/union.result
@@ -1612,7 +1612,7 @@ NULL binary(0) YES NULL
CREATE TABLE t5 SELECT NULL UNION SELECT NULL;
DESC t5;
Field Type Null Key Default Extra
-NULL null YES NULL
+NULL binary(0) YES NULL
CREATE TABLE t6
SELECT * FROM (SELECT * FROM (SELECT NULL)a) b UNION SELECT a FROM t1;
DESC t6;
@@ -2650,5 +2650,34 @@ CAST(1 AS UNSIGNED)
1
1
#
+# MDEV-24511 null field is created with CREATE..SELECT
+#
+set @save_default_storage_engine=@@default_storage_engine;
+SET @@default_storage_engine=MEMORY;
+CREATE TABLE t1 SELECT NULL UNION SELECT NULL;
+ALTER TABLE t1 ADD INDEX (`PRIMARY`);
+ERROR 42000: Key column 'PRIMARY' doesn't exist in table
+CREATE TABLE t2 SELECT NULL;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `NULL` binary(0) DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+CREATE TABLE t3 SELECT NULL UNION SELECT NULL;
+SHOW CREATE TABLE t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `NULL` binary(0) DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+CREATE OR REPLACE TABLE t4 SELECT NULL UNION SELECT NULL;
+SHOW CREATE TABLE t4;
+Table Create Table
+t4 CREATE TABLE `t4` (
+ `NULL` binary(0) DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1
+ALTER TABLE t4 ADD INDEX (`NULL`);
+DROP TABLE t1, t2, t3, t4;
+set @@default_storage_engine=@save_default_storage_engine;
+#
# End of 10.3 tests
#
diff --git a/mysql-test/main/union.test b/mysql-test/main/union.test
index 7e0147cd337..a34e76591ec 100644
--- a/mysql-test/main/union.test
+++ b/mysql-test/main/union.test
@@ -1889,5 +1889,30 @@ SELECT CAST(1 AS UNSIGNED) UNION ALL SELECT CAST(1 AS SIGNED);
--enable_ps_protocol
--echo #
+--echo # MDEV-24511 null field is created with CREATE..SELECT
+--echo #
+
+set @save_default_storage_engine=@@default_storage_engine;
+SET @@default_storage_engine=MEMORY;
+
+CREATE TABLE t1 SELECT NULL UNION SELECT NULL;
+--error ER_KEY_COLUMN_DOES_NOT_EXITS
+ALTER TABLE t1 ADD INDEX (`PRIMARY`);
+
+CREATE TABLE t2 SELECT NULL;
+SHOW CREATE TABLE t2;
+
+CREATE TABLE t3 SELECT NULL UNION SELECT NULL;
+SHOW CREATE TABLE t3;
+
+CREATE OR REPLACE TABLE t4 SELECT NULL UNION SELECT NULL;
+SHOW CREATE TABLE t4;
+ALTER TABLE t4 ADD INDEX (`NULL`);
+
+DROP TABLE t1, t2, t3, t4;
+
+set @@default_storage_engine=@save_default_storage_engine;
+
+--echo #
--echo # End of 10.3 tests
--echo #
diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result
index c2b3c30011f..095936f8b82 100644
--- a/mysql-test/main/win.result
+++ b/mysql-test/main/win.result
@@ -3912,6 +3912,293 @@ sum(i) over () IN ( SELECT 1 FROM t1 a)
0
DROP TABLE t1;
#
+# MDEV-25565: 2-nd call of SP with SELECT from view / derived table / CTE
+# returning the result of calculation of 2 window
+# functions that use the same window specification
+#
+create table t1 (a int);
+insert into t1 values (3), (7), (1), (7), (1), (1), (3), (1), (5);
+create view v2 as select a from t1 group by a;
+create view v1 as select * from v2;
+create procedure sp1() select v1.a,
+sum(v1.a) over (partition by v1.a order by v1.a) as k,
+avg(v1.a) over (partition by v1.a order by v1.a) as m
+from v1;
+call sp1();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp1();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "select v1.a,
+sum(v1.a) over (partition by v1.a order by v1.a) as k,
+avg(v1.a) over (partition by v1.a order by v1.a) as m
+from v1";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp2() select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from (select * from v2) as dt1
+) as dt;
+call sp2();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp2();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from (select * from v2) as dt1
+) as dt";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp3() select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from ( select * from (select * from t1 group by a) as dt2 ) as dt1
+) as dt;
+call sp3();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp3();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from ( select * from (select * from t1 group by a) as dt2 ) as dt1
+) as dt";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp4() with cte1 as (select * from (select * from t1 group by a) as dt2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp4();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp4();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with cte1 as (select * from (select * from t1 group by a) as dt2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp5() with cte1 as (select * from v2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp5();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp5();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with cte1 as (select * from v2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp6() with
+cte1 as (with cte2 as (select * from t1 group by a) select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp6();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp6();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with
+cte1 as (with cte2 as (select * from t1 group by a) select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp7() with
+cte2 as (select * from v1),
+cte1 as (select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp7();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp7();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with
+cte2 as (select * from v1),
+cte1 as (select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+drop procedure sp1;
+drop procedure sp2;
+drop procedure sp3;
+drop procedure sp4;
+drop procedure sp5;
+drop procedure sp6;
+drop procedure sp7;
+drop view v1,v2;
+drop table t1;
+#
# End of 10.2 tests
#
#
diff --git a/mysql-test/main/win.test b/mysql-test/main/win.test
index 778c685b680..43133386461 100644
--- a/mysql-test/main/win.test
+++ b/mysql-test/main/win.test
@@ -2556,6 +2556,153 @@ SELECT sum(i) over () IN ( SELECT 1 FROM t1 a) FROM t1;
DROP TABLE t1;
--echo #
+--echo # MDEV-25565: 2-nd call of SP with SELECT from view / derived table / CTE
+--echo # returning the result of calculation of 2 window
+--echo # functions that use the same window specification
+--echo #
+
+create table t1 (a int);
+insert into t1 values (3), (7), (1), (7), (1), (1), (3), (1), (5);
+
+create view v2 as select a from t1 group by a;
+create view v1 as select * from v2;
+
+let $q1=
+select v1.a,
+ sum(v1.a) over (partition by v1.a order by v1.a) as k,
+ avg(v1.a) over (partition by v1.a order by v1.a) as m
+from v1;
+
+eval create procedure sp1() $q1;
+call sp1();
+call sp1();
+
+eval prepare stmt from "$q1";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+let $q2=
+select * from
+ ( select dt1.a,
+ sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+ avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+ from (select * from v2) as dt1
+ ) as dt;
+
+eval create procedure sp2() $q2;
+call sp2();
+call sp2();
+
+eval prepare stmt from "$q2";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+let $q3=
+select * from
+ ( select dt1.a,
+ sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+ avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+ from ( select * from (select * from t1 group by a) as dt2 ) as dt1
+ ) as dt;
+
+eval create procedure sp3() $q3;
+call sp3();
+call sp3();
+
+eval prepare stmt from "$q3";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+let $q4=
+with cte1 as (select * from (select * from t1 group by a) as dt2),
+ cte as
+ ( select cte1.a,
+ sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+ avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+ from cte1 )
+select * from cte;
+
+eval create procedure sp4() $q4;
+call sp4();
+call sp4();
+
+eval prepare stmt from "$q4";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+let $q5=
+with cte1 as (select * from v2),
+ cte as
+ ( select cte1.a,
+ sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+ avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+ from cte1 )
+select * from cte;
+
+eval create procedure sp5() $q5;
+call sp5();
+call sp5();
+
+eval prepare stmt from "$q5";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+let $q6=
+with
+cte1 as (with cte2 as (select * from t1 group by a) select * from cte2),
+ cte as
+ ( select cte1.a,
+ sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+ avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+ from cte1 )
+select * from cte;
+
+eval create procedure sp6() $q6;
+call sp6();
+call sp6();
+
+eval prepare stmt from "$q6";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+let $q7=
+with
+ cte2 as (select * from v1),
+ cte1 as (select * from cte2),
+ cte as
+ ( select cte1.a,
+ sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+ avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+ from cte1 )
+select * from cte;
+
+eval create procedure sp7() $q7;
+call sp7();
+call sp7();
+
+eval prepare stmt from "$q7";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+
+drop procedure sp1;
+drop procedure sp2;
+drop procedure sp3;
+drop procedure sp4;
+drop procedure sp5;
+drop procedure sp6;
+drop procedure sp7;
+drop view v1,v2;
+drop table t1;
+
+--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/mariadb-test-run.pl b/mysql-test/mariadb-test-run.pl
index 7b9422565ab..6dcd25a9c86 100755
--- a/mysql-test/mariadb-test-run.pl
+++ b/mysql-test/mariadb-test-run.pl
@@ -2737,7 +2737,9 @@ sub mysql_server_start($) {
if (!$opt_embedded_server)
{
- mysqld_start($mysqld,$extra_opts);
+ mysqld_start($mysqld, $extra_opts) or
+ mtr_error("Failed to start mysqld ".$mysqld->name()." with command "
+ . $ENV{MYSQLD_LAST_CMD});
# Save this test case information, so next can examine it
$mysqld->{'started_tinfo'}= $tinfo;
@@ -2760,10 +2762,10 @@ sub mysql_server_start($) {
sub mysql_server_wait {
my ($mysqld, $tinfo) = @_;
+ my $expect_file= "$opt_vardir/tmp/".$mysqld->name().".expect";
- if (!sleep_until_file_created($mysqld->value('pid-file'),
- $opt_start_timeout,
- $mysqld->{'proc'},
+ if (!sleep_until_file_created($mysqld->value('pid-file'), $expect_file,
+ $opt_start_timeout, $mysqld->{'proc'},
$warn_seconds))
{
$tinfo->{comment}= "Failed to start ".$mysqld->name() . "\n";
@@ -4080,9 +4082,12 @@ sub run_testcase ($$) {
# ----------------------------------------------------
# Check if it was an expected crash
# ----------------------------------------------------
- my $check_crash = check_expected_crash_and_restart($wait_for_proc);
+ my @mysqld = grep($wait_for_proc eq $_->{proc}, mysqlds());
+ goto SRVDIED unless @mysqld;
+ my $check_crash = check_expected_crash_and_restart($mysqld[0]);
if ($check_crash == 0) # unexpected exit/crash of $wait_for_proc
{
+ $proc= $mysqld[0]->{proc};
goto SRVDIED;
}
elsif ($check_crash == 1) # $wait_for_proc was started again by check_expected_crash_and_restart()
@@ -4653,61 +4658,52 @@ sub check_warnings_post_shutdown {
}
#
-# Loop through our list of processes and look for and entry
-# with the provided pid, if found check for the file indicating
-# expected crash and restart it.
+# Check for the file indicating expected crash and restart it.
#
sub check_expected_crash_and_restart {
- my ($proc)= @_;
+ my $mysqld = shift;
- foreach my $mysqld ( mysqlds() )
+ # Check if crash expected by looking at the .expect file
+ # in var/tmp
+ my $expect_file= "$opt_vardir/tmp/".$mysqld->name().".expect";
+ if ( -f $expect_file )
{
- next unless ( $mysqld->{proc} and $mysqld->{proc} eq $proc );
+ mtr_verbose("Crash was expected, file '$expect_file' exists");
- # Check if crash expected by looking at the .expect file
- # in var/tmp
- my $expect_file= "$opt_vardir/tmp/".$mysqld->name().".expect";
- if ( -f $expect_file )
+ for (my $waits = 0; $waits < 50; mtr_milli_sleep(100), $waits++)
{
- mtr_verbose("Crash was expected, file '$expect_file' exists");
-
- for (my $waits = 0; $waits < 50; mtr_milli_sleep(100), $waits++)
+ # Race condition seen on Windows: try again until file not empty
+ next if -z $expect_file;
+ # If last line in expect file starts with "wait"
+ # sleep a little and try again, thus allowing the
+ # test script to control when the server should start
+ # up again. Keep trying for up to 5s at a time.
+ my $last_line= mtr_lastlinesfromfile($expect_file, 1);
+ if ($last_line =~ /^wait/ )
{
- # Race condition seen on Windows: try again until file not empty
- next if -z $expect_file;
- # If last line in expect file starts with "wait"
- # sleep a little and try again, thus allowing the
- # test script to control when the server should start
- # up again. Keep trying for up to 5s at a time.
- my $last_line= mtr_lastlinesfromfile($expect_file, 1);
- if ($last_line =~ /^wait/ )
- {
- mtr_verbose("Test says wait before restart") if $waits == 0;
- next;
- }
-
- # Ignore any partial or unknown command
- next unless $last_line =~ /^restart/;
- # If last line begins "restart:", the rest of the line is read as
- # extra command line options to add to the restarted mysqld.
- # Anything other than 'wait' or 'restart:' (with a colon) will
- # result in a restart with original mysqld options.
- if ($last_line =~ /restart:(.+)/) {
- my @rest_opt= split(' ', $1);
- $mysqld->{'restart_opts'}= \@rest_opt;
- } else {
- delete $mysqld->{'restart_opts'};
- }
- unlink($expect_file);
-
- # Start server with same settings as last time
- mysqld_start($mysqld, $mysqld->{'started_opts'});
+ mtr_verbose("Test says wait before restart") if $waits == 0;
+ next;
+ }
- return 1;
+ # Ignore any partial or unknown command
+ next unless $last_line =~ /^restart/;
+ # If last line begins "restart:", the rest of the line is read as
+ # extra command line options to add to the restarted mysqld.
+ # Anything other than 'wait' or 'restart:' (with a colon) will
+ # result in a restart with original mysqld options.
+ if ($last_line =~ /restart:(.+)/) {
+ my @rest_opt= split(' ', $1);
+ $mysqld->{'restart_opts'}= \@rest_opt;
+ } else {
+ delete $mysqld->{'restart_opts'};
}
- # Loop ran through: we should keep waiting after a re-check
- return 2;
+ unlink($expect_file);
+
+ # Start server with same settings as last time
+ return mysqld_start($mysqld, $mysqld->{'started_opts'});
}
+ # Loop ran through: we should keep waiting after a re-check
+ return 2;
}
# Not an expected crash
@@ -5064,6 +5060,7 @@ sub mysqld_start ($$) {
if ( defined $exe )
{
+ mtr_tofile($output, "\$ $exe @$args\n");
pre_write_errorlog($output);
$mysqld->{'proc'}= My::SafeProcess->new
(
@@ -5082,10 +5079,13 @@ sub mysqld_start ($$) {
mtr_verbose("Started $mysqld->{proc}");
}
- if (!sleep_until_file_created($mysqld->value('pid-file'),
- $opt_start_timeout, $mysqld->{'proc'}, $warn_seconds))
+ $mysqld->{'started_opts'}= $extra_opts;
+
+ my $expect_file= "$opt_vardir/tmp/".$mysqld->name().".expect";
+ my $rc= sleep_until_file_created($mysqld->value('pid-file'), $expect_file,
+ $opt_start_timeout, $mysqld->{'proc'}, $warn_seconds);
+ if (!$rc)
{
- my $mname= $mysqld->name();
# Report failure about the last test case before exit
my $test_name= mtr_grab_file($path_current_testlog);
$test_name =~ s/^CURRENT_TEST:\s//;
@@ -5095,13 +5095,8 @@ sub mysqld_start ($$) {
$tinfo->{logfile}=get_log_from_proc($mysqld->{'proc'}, $tinfo->{name});
report_option('verbose', 1);
mtr_report_test($tinfo);
- mtr_error("Failed to start mysqld $mname with command $exe @$args");
}
-
- # Remember options used when starting
- $mysqld->{'started_opts'}= $extra_opts;
-
- return;
+ return $rc;
}
diff --git a/mysql-test/suite/binlog/include/binlog.test b/mysql-test/suite/binlog/include/binlog.test
index 368dcebc5f1..9f3288b52f0 100644
--- a/mysql-test/suite/binlog/include/binlog.test
+++ b/mysql-test/suite/binlog/include/binlog.test
@@ -406,4 +406,22 @@ SHOW SESSION VARIABLES LIKE "unique_checks";
DROP TABLE t1;
disconnect fresh;
+connection default;
+--echo #
+--echo # MDEV-25595 DROP part of failed CREATE OR REPLACE is not written into binary log
+--echo #
+reset master;
+--error ER_DUP_FIELDNAME
+create table t as select 1 as b, 2 as b;
+create table t (old_table_field int);
+--error ER_DUP_FIELDNAME
+create or replace table t as select 1 as b, 2 as b;
+--error ER_DUP_FIELDNAME
+create or replace temporary table t as select 1 as b, 2 as b;
+create table t (new_table_field int);
+
+--source include/show_binlog_events.inc
+
+# cleanup
+drop table t;
diff --git a/mysql-test/suite/binlog/r/binlog_row_binlog.result b/mysql-test/suite/binlog/r/binlog_row_binlog.result
index 09dff6503aa..fa111106cd6 100644
--- a/mysql-test/suite/binlog/r/binlog_row_binlog.result
+++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result
@@ -1073,3 +1073,26 @@ Variable_name Value
unique_checks OFF
DROP TABLE t1;
disconnect fresh;
+connection default;
+#
+# MDEV-25595 DROP part of failed CREATE OR REPLACE is not written into binary log
+#
+reset master;
+create table t as select 1 as b, 2 as b;
+ERROR 42S21: Duplicate column name 'b'
+create table t (old_table_field int);
+create or replace table t as select 1 as b, 2 as b;
+ERROR 42S21: Duplicate column name 'b'
+create or replace temporary table t as select 1 as b, 2 as b;
+ERROR 42S21: Duplicate column name 'b'
+create table t (new_table_field int);
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; create table t (old_table_field int)
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */
+master-bin.000001 # Query # # ROLLBACK
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; create table t (new_table_field int)
+drop table t;
diff --git a/mysql-test/suite/binlog/r/binlog_stm_binlog.result b/mysql-test/suite/binlog/r/binlog_stm_binlog.result
index bd980540411..f48b624ec21 100644
--- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result
@@ -670,3 +670,27 @@ Variable_name Value
unique_checks OFF
DROP TABLE t1;
disconnect fresh;
+connection default;
+#
+# MDEV-25595 DROP part of failed CREATE OR REPLACE is not written into binary log
+#
+reset master;
+create table t as select 1 as b, 2 as b;
+ERROR 42S21: Duplicate column name 'b'
+create table t (old_table_field int);
+create or replace table t as select 1 as b, 2 as b;
+ERROR 42S21: Duplicate column name 'b'
+create or replace temporary table t as select 1 as b, 2 as b;
+ERROR 42S21: Duplicate column name 'b'
+create table t (new_table_field int);
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; create table t (old_table_field int)
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # DROP TEMPORARY TABLE IF EXISTS `test`.`t`/* Generated to handle failed CREATE OR REPLACE */
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; create table t (new_table_field int)
+drop table t;
diff --git a/mysql-test/suite/binlog_encryption/encrypted_master.test b/mysql-test/suite/binlog_encryption/encrypted_master.test
index f67e93ce815..f6fc172c79e 100644
--- a/mysql-test/suite/binlog_encryption/encrypted_master.test
+++ b/mysql-test/suite/binlog_encryption/encrypted_master.test
@@ -18,6 +18,9 @@
# - with annotated events, default checksums and minimal binlog row image
#
+# The test can take very long time with valgrind
+--source include/not_valgrind.inc
+
--source include/have_partition.inc
--source encryption_algorithms.inc
--source include/have_innodb.inc
diff --git a/mysql-test/suite/encryption/r/tempfiles_encrypted.result b/mysql-test/suite/encryption/r/tempfiles_encrypted.result
index 977bb0101fd..4cf31200ee2 100644
--- a/mysql-test/suite/encryption/r/tempfiles_encrypted.result
+++ b/mysql-test/suite/encryption/r/tempfiles_encrypted.result
@@ -3918,6 +3918,293 @@ sum(i) over () IN ( SELECT 1 FROM t1 a)
0
DROP TABLE t1;
#
+# MDEV-25565: 2-nd call of SP with SELECT from view / derived table / CTE
+# returning the result of calculation of 2 window
+# functions that use the same window specification
+#
+create table t1 (a int);
+insert into t1 values (3), (7), (1), (7), (1), (1), (3), (1), (5);
+create view v2 as select a from t1 group by a;
+create view v1 as select * from v2;
+create procedure sp1() select v1.a,
+sum(v1.a) over (partition by v1.a order by v1.a) as k,
+avg(v1.a) over (partition by v1.a order by v1.a) as m
+from v1;
+call sp1();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp1();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "select v1.a,
+sum(v1.a) over (partition by v1.a order by v1.a) as k,
+avg(v1.a) over (partition by v1.a order by v1.a) as m
+from v1";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp2() select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from (select * from v2) as dt1
+) as dt;
+call sp2();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp2();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from (select * from v2) as dt1
+) as dt";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp3() select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from ( select * from (select * from t1 group by a) as dt2 ) as dt1
+) as dt;
+call sp3();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp3();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "select * from
+( select dt1.a,
+sum(dt1.a) over (partition by dt1.a order by dt1.a) as k,
+avg(dt1.a) over (partition by dt1.a order by dt1.a) as m
+from ( select * from (select * from t1 group by a) as dt2 ) as dt1
+) as dt";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp4() with cte1 as (select * from (select * from t1 group by a) as dt2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp4();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp4();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with cte1 as (select * from (select * from t1 group by a) as dt2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp5() with cte1 as (select * from v2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp5();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp5();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with cte1 as (select * from v2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp6() with
+cte1 as (with cte2 as (select * from t1 group by a) select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp6();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp6();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with
+cte1 as (with cte2 as (select * from t1 group by a) select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+create procedure sp7() with
+cte2 as (select * from v1),
+cte1 as (select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte;
+call sp7();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+call sp7();
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+prepare stmt from "with
+cte2 as (select * from v1),
+cte1 as (select * from cte2),
+cte as
+( select cte1.a,
+sum(cte1.a) over (partition by cte1.a order by cte1.a) as k,
+avg(cte1.a) over (partition by cte1.a order by cte1.a) as m
+from cte1 )
+select * from cte";
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+execute stmt;
+a k m
+1 1 1.0000
+3 3 3.0000
+5 5 5.0000
+7 7 7.0000
+deallocate prepare stmt;
+drop procedure sp1;
+drop procedure sp2;
+drop procedure sp3;
+drop procedure sp4;
+drop procedure sp5;
+drop procedure sp6;
+drop procedure sp7;
+drop view v1,v2;
+drop table t1;
+#
# End of 10.2 tests
#
#
diff --git a/mysql-test/suite/encryption/t/innodb-page_encryption.test b/mysql-test/suite/encryption/t/innodb-page_encryption.test
index df2d1d52aaa..d756f07aea0 100644
--- a/mysql-test/suite/encryption/t/innodb-page_encryption.test
+++ b/mysql-test/suite/encryption/t/innodb-page_encryption.test
@@ -1,6 +1,9 @@
-- source include/have_innodb.inc
-- source include/have_file_key_management_plugin.inc
+# The test can take very long time with valgrind
+--source include/not_valgrind.inc
+
create table innodb_normal(c1 bigint not null, b char(200)) engine=innodb;
show warnings;
create table innodb_compact(c1 bigint not null, b char(200)) engine=innodb row_format=compact encrypted=yes encryption_key_id=1;
diff --git a/mysql-test/suite/galera/r/MDEV-22051.result b/mysql-test/suite/galera/r/MDEV-22051.result
index 9f5394637c2..0e9756dd20e 100644
--- a/mysql-test/suite/galera/r/MDEV-22051.result
+++ b/mysql-test/suite/galera/r/MDEV-22051.result
@@ -2,14 +2,14 @@ connection node_2;
connection node_1;
FLUSH TABLES WITH READ LOCK;
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
-ERROR 08S01: Aborting TOI: Global Read-Lock (FTWRL) in place.
+ERROR 08S01: Aborting TOI: Replication paused on node for FTWRL/BACKUP STAGE.
SET wsrep_OSU_method=RSU;
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
-ERROR 08S01: Aborting TOI: Global Read-Lock (FTWRL) in place.
+ERROR 08S01: Aborting TOI: Replication paused on node for FTWRL/BACKUP STAGE.
SET wsrep_OSU_method=TOI;
connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
-ERROR 08S01: Aborting TOI: Global Read-Lock (FTWRL) in place.
+ERROR 08S01: Aborting TOI: Replication paused on node for FTWRL/BACKUP STAGE.
connection node_1;
UNLOCK TABLES;
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
diff --git a/mysql-test/suite/galera/r/MDEV-22421.result b/mysql-test/suite/galera/r/MDEV-22421.result
new file mode 100644
index 00000000000..33dc3e449ae
--- /dev/null
+++ b/mysql-test/suite/galera/r/MDEV-22421.result
@@ -0,0 +1,7 @@
+connection node_2;
+connection node_1;
+SET @@local.sql_mode='no_field_options';
+CREATE TABLE t1 (f1 INT, ROW_START BIGINT UNSIGNED AS ROW START INVISIBLE, ROW_END BIGINT UNSIGNED AS ROW END INVISIBLE, PERIOD FOR SYSTEM_TIME(ROW_START, ROW_END)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+UPDATE t1 SET f1 = 1 WHERE f1 = 1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/MDEV-25740.result b/mysql-test/suite/galera/r/MDEV-25740.result
new file mode 100644
index 00000000000..5a4318a7f19
--- /dev/null
+++ b/mysql-test/suite/galera/r/MDEV-25740.result
@@ -0,0 +1,9 @@
+connection node_2;
+connection node_1;
+SET AUTOCOMMIT = OFF;
+SET completion_type = CHAIN;
+CREATE TABLE t1(f1 INT) ENGINE=InnoDB;
+BEGIN;
+INSERT INTO t1 VALUES (1);
+ROLLBACK;
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/galera_backup_stage.result b/mysql-test/suite/galera/r/galera_backup_stage.result
new file mode 100644
index 00000000000..6fb7d1643cd
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_backup_stage.result
@@ -0,0 +1,78 @@
+connection node_2;
+connection node_1;
+connection node_1;
+CREATE TABLE t1 (f1 varchar(10)) ENGINE=InnoDB;
+BACKUP STAGE START;
+BACKUP STAGE FLUSH;
+BACKUP STAGE END;
+BACKUP STAGE START;
+BACKUP STAGE FLUSH;
+connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+connection node_1a;
+SET SESSION wsrep_sync_wait=0;
+SET SESSION wsrep_retry_autocommit=0;
+INSERT INTO t1 (f1) values ("node1_1");
+ALTER TABLE t1 ADD COLUMN (f2 int(10));
+connection node_2;
+INSERT INTO t1 (f1) values ("node2_1");
+ALTER TABLE t1 ADD COLUMN (f3 int(10));
+connection node_1;
+BACKUP STAGE BLOCK_DDL;
+connect node_1c, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+connection node_1c;
+SET SESSION wsrep_sync_wait=0;
+connection node_2;
+INSERT INTO t1 (f1) values("node2_2");
+ALTER TABLE t1 ADD COLUMN (f5 int(10));
+connection node_1a;
+ALTER TABLE t1 ADD COLUMN (f4 int(10));
+ERROR 08S01: Aborting TOI: Replication paused on node for FTWRL/BACKUP STAGE.
+INSERT INTO t1 (f1) values("node1a");;
+connection node_1c;
+connection node_1;
+BACKUP STAGE BLOCK_COMMIT;
+connection node_1c;
+SELECT variable_value="Donor/Desynced" FROM information_schema.global_status WHERE variable_name="wsrep_local_state_comment";
+variable_value="Donor/Desynced"
+1
+connection node_2;
+INSERT INTO t1 (f1) values("node2_3");
+ALTER TABLE t1 ADD COLUMN (f6 int(10));
+connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+connection node_1b;
+SET SESSION wsrep_sync_wait=0;
+SET SESSION wsrep_retry_autocommit=0;
+ALTER TABLE t1 ADD COLUMN (f4 int(10));
+ERROR 08S01: Aborting TOI: Replication paused on node for FTWRL/BACKUP STAGE.
+INSERT INTO t1 (f1) values("node1b");;
+connection node_1c;
+SELECT COUNT(*)=2 FROM t1;
+COUNT(*)=2
+1
+SELECT COUNT(*)=3 FROM information_schema.columns WHERE table_name = 't1';
+COUNT(*)=3
+1
+connection node_1;
+BACKUP STAGE END;
+connection node_1a;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+connection node_1b;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+connection node_1;
+SELECT COUNT(*)=4 FROM t1;
+COUNT(*)=4
+1
+SELECT COUNT(*)=5 FROM information_schema.columns WHERE table_name = 't1';
+COUNT(*)=5
+1
+connection node_2;
+SELECT COUNT(*)=4 FROM t1;
+COUNT(*)=4
+1
+SELECT COUNT(*)=5 FROM information_schema.columns WHERE table_name = 't1';
+COUNT(*)=5
+1
+connection node_1;
+DROP TABLE t1;
+call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
+call mtr.add_suppression("greater than drain seqno");
diff --git a/mysql-test/suite/galera/r/galera_fk_lock_wait.result b/mysql-test/suite/galera/r/galera_fk_lock_wait.result
new file mode 100644
index 00000000000..0d87aa2aa57
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_fk_lock_wait.result
@@ -0,0 +1,54 @@
+connection node_2;
+connection node_1;
+CREATE TABLE parent(parent_id int not null AUTO_INCREMENT PRIMARY KEY,
+parent_name varchar(80)) ENGINE=InnoDB;
+CREATE TABLE child(child_id int not null AUTO_INCREMENT PRIMARY KEY,
+child_name varchar(80),
+child_parent_id int not null,
+CONSTRAINT `fk_child_parent`
+ FOREIGN KEY (child_parent_id) REFERENCES parent (parent_id)
+ON DELETE CASCADE
+ON UPDATE CASCADE) ENGINE=InnoDB;
+INSERT INTO parent VALUES (1, 'first'),(2,'second'),(3,'foo'),(4,'tmp');
+INSERT INTO child VALUES (NULL,'first_child',1);
+INSERT INTO child VALUES (NULL,'second_child',1);
+INSERT INTO child VALUES (NULL,'first_child2',2);
+INSERT INTO child VALUES (NULL,'first_child3',2);
+INSERT INTO child VALUES (NULL,'first_child4',3);
+BEGIN;
+UPDATE parent SET parent_name = 'bar' WHERE parent_id = 2;
+connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+SET SESSION innodb_lock_wait_timeout=2;
+UPDATE child SET child_parent_id = 5 where child_parent_id = 2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection node_1;
+COMMIT;
+SELECT * FROM parent;
+parent_id parent_name
+1 first
+2 bar
+3 foo
+4 tmp
+SELECT * FROM child;
+child_id child_name child_parent_id
+1 first_child 1
+3 second_child 1
+5 first_child2 2
+7 first_child3 2
+9 first_child4 3
+connection node_2;
+SELECT * FROM parent;
+parent_id parent_name
+1 first
+2 bar
+3 foo
+4 tmp
+SELECT * FROM child;
+child_id child_name child_parent_id
+1 first_child 1
+3 second_child 1
+5 first_child2 2
+7 first_child3 2
+9 first_child4 3
+DROP TABLE child, parent;
+disconnect node_1a;
diff --git a/mysql-test/suite/galera/suite.pm b/mysql-test/suite/galera/suite.pm
index 027100fdb30..2ef45b247b2 100644
--- a/mysql-test/suite/galera/suite.pm
+++ b/mysql-test/suite/galera/suite.pm
@@ -65,6 +65,7 @@ push @::global_suppressions,
qr|WSREP: Sending JOIN failed: -107 \(Transport endpoint is not connected\). Will retry in new primary component.|,
qr|WSREP: Trying to continue unpaused monitor|,
qr|WSREP: Wait for gtid returned error 3 while waiting for prior transactions to commit before setting position|,
+ qr|WSREP: Failed to report last committed|,
);
sub which($) { return `sh -c "command -v $_[0]"` }
diff --git a/mysql-test/suite/galera/t/MDEV-22421.test b/mysql-test/suite/galera/t/MDEV-22421.test
new file mode 100644
index 00000000000..369e56384a0
--- /dev/null
+++ b/mysql-test/suite/galera/t/MDEV-22421.test
@@ -0,0 +1,12 @@
+#
+# Tables with system versioning should not append keys to wsrep.
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+SET @@local.sql_mode='no_field_options';
+CREATE TABLE t1 (f1 INT, ROW_START BIGINT UNSIGNED AS ROW START INVISIBLE, ROW_END BIGINT UNSIGNED AS ROW END INVISIBLE, PERIOD FOR SYSTEM_TIME(ROW_START, ROW_END)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1);
+UPDATE t1 SET f1 = 1 WHERE f1 = 1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/MDEV-25740.test b/mysql-test/suite/galera/t/MDEV-25740.test
new file mode 100644
index 00000000000..0ea8d5f55c0
--- /dev/null
+++ b/mysql-test/suite/galera/t/MDEV-25740.test
@@ -0,0 +1,14 @@
+#
+# When `completion_type = CHAIN` is used, transaction started should not have previous writeset.
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+SET AUTOCOMMIT = OFF;
+SET completion_type = CHAIN;
+CREATE TABLE t1(f1 INT) ENGINE=InnoDB;
+BEGIN;
+INSERT INTO t1 VALUES (1);
+ROLLBACK;
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/galera_backup_stage.test b/mysql-test/suite/galera/t/galera_backup_stage.test
new file mode 100644
index 00000000000..31d76816355
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_backup_stage.test
@@ -0,0 +1,120 @@
+#
+# Check that BACKUP STAGE BLOCK_DDL desyncs and pauses the node until BACKUP STAGE END:
+# - Local DDLs will fail immediately
+# - Local DMLs will block until resync
+# - Remote txns will be applied after resync (STAGE END).
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+--source include/have_metadata_lock_info.inc
+
+--connection node_1
+CREATE TABLE t1 (f1 varchar(10)) ENGINE=InnoDB;
+
+# First, check that BACKUP STAGE END skipping desyncing stages is fine
+BACKUP STAGE START;
+BACKUP STAGE FLUSH;
+BACKUP STAGE END;
+
+BACKUP STAGE START;
+BACKUP STAGE FLUSH;
+
+--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connection node_1a
+SET SESSION wsrep_sync_wait=0;
+SET SESSION wsrep_retry_autocommit=0;
+INSERT INTO t1 (f1) values ("node1_1");
+ALTER TABLE t1 ADD COLUMN (f2 int(10));
+
+--connection node_2
+INSERT INTO t1 (f1) values ("node2_1");
+ALTER TABLE t1 ADD COLUMN (f3 int(10));
+
+# BLOCK_DDL desyncs and pauses the node
+--connection node_1
+BACKUP STAGE BLOCK_DDL;
+
+--connect node_1c, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connection node_1c
+SET SESSION wsrep_sync_wait=0;
+--let $wait_condition = SELECT variable_value="Donor/Desynced" FROM information_schema.global_status WHERE variable_name="wsrep_local_state_comment"
+--source include/wait_condition.inc
+
+--connection node_2
+INSERT INTO t1 (f1) values("node2_2");
+ALTER TABLE t1 ADD COLUMN (f5 int(10));
+
+--connection node_1a
+--error ER_UNKNOWN_COM_ERROR
+ALTER TABLE t1 ADD COLUMN (f4 int(10));
+--let $insert_id = `SELECT CONNECTION_ID()`
+--send INSERT INTO t1 (f1) values("node1a");
+
+# the insert will block during commit inside the provider, in certify. We can't
+# check for sure it is blocked there, so we wait for the thread to at least
+# reach commit stage. In the unlikely case the interleaving is different, the
+# result of the test should not change.
+--connection node_1c
+--let $wait_condition = SELECT COUNT(*)=1 FROM information_schema.processlist WHERE State='Commit' AND ID=$insert_id
+--source include/wait_condition.inc
+--let $wait_condition = SELECT COUNT(*)=1 FROM information_schema.metadata_lock_info WHERE TABLE_NAME='t1' AND THREAD_ID=$insert_id
+--source include/wait_condition.inc
+
+--connection node_1
+BACKUP STAGE BLOCK_COMMIT;
+
+# node only resumes/resyncs upon STAGE END
+--connection node_1c
+SELECT variable_value="Donor/Desynced" FROM information_schema.global_status WHERE variable_name="wsrep_local_state_comment";
+
+--connection node_2
+INSERT INTO t1 (f1) values("node2_3");
+ALTER TABLE t1 ADD COLUMN (f6 int(10));
+
+--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1
+--connection node_1b
+SET SESSION wsrep_sync_wait=0;
+SET SESSION wsrep_retry_autocommit=0;
+--error ER_UNKNOWN_COM_ERROR
+ALTER TABLE t1 ADD COLUMN (f4 int(10));
+--let $insert_id = `SELECT CONNECTION_ID()`
+--send INSERT INTO t1 (f1) values("node1b");
+
+# wait for insert to get blocked
+--connection node_1c
+--let $wait_condition = SELECT COUNT(*)=1 FROM information_schema.processlist WHERE State='Commit' AND ID=$insert_id
+--source include/wait_condition.inc
+--let $wait_condition = SELECT COUNT(*)=1 FROM information_schema.metadata_lock_info WHERE TABLE_NAME='t1' AND THREAD_ID=$insert_id
+--source include/wait_condition.inc
+--let $wait_condition = SELECT COUNT(*)=2 FROM information_schema.processlist WHERE Info like 'INSERT INTO t1 (f1) values("node1%")' AND State = 'Commit'
+--source include/wait_condition.inc
+
+# nothing after BLOCK_DDL is applied
+SELECT COUNT(*)=2 FROM t1;
+SELECT COUNT(*)=3 FROM information_schema.columns WHERE table_name = 't1';
+
+# STAGE END resumes and resyncs the node
+--connection node_1
+BACKUP STAGE END;
+
+# Upon resume, blocked inserts will continue but conflict with the applying alters
+--connection node_1a
+--error ER_LOCK_DEADLOCK
+--reap
+--connection node_1b
+--error ER_LOCK_DEADLOCK
+--reap
+
+--connection node_1
+SELECT COUNT(*)=4 FROM t1;
+SELECT COUNT(*)=5 FROM information_schema.columns WHERE table_name = 't1';
+
+--connection node_2
+SELECT COUNT(*)=4 FROM t1;
+SELECT COUNT(*)=5 FROM information_schema.columns WHERE table_name = 't1';
+
+--connection node_1
+DROP TABLE t1;
+call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
+call mtr.add_suppression("greater than drain seqno");
diff --git a/mysql-test/suite/galera/t/galera_fk_lock_wait.test b/mysql-test/suite/galera/t/galera_fk_lock_wait.test
new file mode 100644
index 00000000000..150c7397f7e
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_fk_lock_wait.test
@@ -0,0 +1,40 @@
+--source include/galera_cluster.inc
+
+CREATE TABLE parent(parent_id int not null AUTO_INCREMENT PRIMARY KEY,
+parent_name varchar(80)) ENGINE=InnoDB;
+
+CREATE TABLE child(child_id int not null AUTO_INCREMENT PRIMARY KEY,
+child_name varchar(80),
+child_parent_id int not null,
+CONSTRAINT `fk_child_parent`
+ FOREIGN KEY (child_parent_id) REFERENCES parent (parent_id)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE) ENGINE=InnoDB;
+
+INSERT INTO parent VALUES (1, 'first'),(2,'second'),(3,'foo'),(4,'tmp');
+INSERT INTO child VALUES (NULL,'first_child',1);
+INSERT INTO child VALUES (NULL,'second_child',1);
+INSERT INTO child VALUES (NULL,'first_child2',2);
+INSERT INTO child VALUES (NULL,'first_child3',2);
+INSERT INTO child VALUES (NULL,'first_child4',3);
+
+BEGIN;
+UPDATE parent SET parent_name = 'bar' WHERE parent_id = 2;
+
+--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
+SET SESSION innodb_lock_wait_timeout=2;
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE child SET child_parent_id = 5 where child_parent_id = 2;
+
+--connection node_1
+COMMIT;
+SELECT * FROM parent;
+SELECT * FROM child;
+
+--connection node_2
+
+SELECT * FROM parent;
+SELECT * FROM child;
+DROP TABLE child, parent;
+
+--disconnect node_1a
diff --git a/mysql-test/suite/gcol/inc/gcol_ins_upd.inc b/mysql-test/suite/gcol/inc/gcol_ins_upd.inc
index 8c00bde7fca..68c0a0e30c9 100644
--- a/mysql-test/suite/gcol/inc/gcol_ins_upd.inc
+++ b/mysql-test/suite/gcol/inc/gcol_ins_upd.inc
@@ -613,4 +613,78 @@ DELETE FROM t1;
DROP TEMPORARY TABLE t1;
+--echo #
+--echo # Original test case from MDEV-17890
+--echo #
+
+CREATE TABLE t1 (
+ pk BIGINT AUTO_INCREMENT,
+ b BIT(15),
+ v BIT(10) AS (b) VIRTUAL,
+ PRIMARY KEY(pk),
+ UNIQUE(v)
+);
+
+INSERT IGNORE INTO t1 (b) VALUES (b'101110001110100'),(b'011101');
+SELECT pk, b INTO OUTFILE 'load.data' FROM t1;
+--error ER_DATA_TOO_LONG
+LOAD DATA INFILE 'load.data' REPLACE INTO TABLE t1 (pk, b);
+
+# Cleanup
+DROP TABLE t1;
+--let $datadir= `SELECT @@datadir`
+--remove_file $datadir/test/load.data
+
+
+--echo #
+--echo # MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+--echo #
+
+CREATE TABLE t1 (
+ id INT NOT NULL AUTO_INCREMENT,
+ f ENUM('a','b','c'),
+ v ENUM('a','b','c') AS (f),
+ KEY(v,id)
+) ENGINE=MyISAM;
+INSERT INTO t1 (f) VALUES ('a'),('b');
+INSERT IGNORE INTO t1 SELECT * FROM t1;
+
+# Cleanup
+DROP TABLE t1;
+
+
+CREATE TABLE t1 (
+ id INT NOT NULL AUTO_INCREMENT,
+ f ENUM('a','b','c'),
+ v ENUM('a','b','c') AS (f),
+ KEY(v,id)
+) ENGINE=MyISAM;
+INSERT INTO t1 (f) VALUES ('a'),('b');
+INSERT IGNORE INTO t1 SELECT * FROM t1;
+
+# Cleanup
+DROP TABLE t1;
+
}
+
+--echo #
+--echo # MDEV-23597 Assertion `marked_for_read()' failed while evaluating DEFAULT
+--echo #
+
+CREATE TABLE t1 (a INT UNIQUE, b INT DEFAULT (c+1), c int);
+INSERT INTO t1 VALUES (1,1,1);
+UPDATE t1 SET b=DEFAULT;
+SELECT * from t1;
+
+REPLACE t1 VALUES(1,1,1);
+INSERT INTO t1 VALUES (1,1,1) ON DUPLICATE KEY UPDATE b= DEFAULT;
+SELECT * from t1;
+
+REPLACE t1 VALUES(1,1,1);
+CREATE TABLE t2 (a INT, b INT DEFAULT (c+1), c int);
+INSERT INTO t2 VALUES (5,5,5);
+UPDATE t1 join t2 set t1.b= DEFAULT, t2.b= DEFAULT;
+SELECT * from t1, t2;
+
+DROP TABLE t1, t2;
+
diff --git a/mysql-test/suite/gcol/inc/gcol_keys.inc b/mysql-test/suite/gcol/inc/gcol_keys.inc
index e5f7f976120..cf0612b0d0c 100644
--- a/mysql-test/suite/gcol/inc/gcol_keys.inc
+++ b/mysql-test/suite/gcol/inc/gcol_keys.inc
@@ -812,7 +812,7 @@ DROP TABLE t1;
--echo # MDEV-19011 Assertion `file->s->base.reclength < file->s->vreclength'
--echo # failed in ha_myisam::setup_vcols_for_repair
-CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL) ENGINE=MyISAM;
+CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL);
ALTER TABLE t1 ADD KEY (a);
DROP TABLE t1;
diff --git a/mysql-test/suite/gcol/inc/gcol_partition.inc b/mysql-test/suite/gcol/inc/gcol_partition.inc
index df199e86c68..4e4af4f0023 100644
--- a/mysql-test/suite/gcol/inc/gcol_partition.inc
+++ b/mysql-test/suite/gcol/inc/gcol_partition.inc
@@ -153,3 +153,19 @@ CHECK TABLE t EXTENDED;
FLUSH TABLES;
CHECK TABLE t EXTENDED;
DROP TABLE t;
+
+--echo #
+--echo # MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+--echo #
+CREATE TABLE t1 (
+ a INT,
+ b INT,
+ c BIT(4) NOT NULL DEFAULT b'0',
+ pk INTEGER AUTO_INCREMENT,
+ d BIT(4) AS (c) VIRTUAL,
+ PRIMARY KEY(pk),
+ KEY (b,d)
+) PARTITION BY HASH(pk);
+INSERT INTO t1 () VALUES (),();
+UPDATE t1 SET a = 0 WHERE b IS NULL ORDER BY pk;
+DROP TABLE t1;
diff --git a/mysql-test/suite/gcol/inc/gcol_view.inc b/mysql-test/suite/gcol/inc/gcol_view.inc
index 51cb9b5d725..6f9ce673199 100644
--- a/mysql-test/suite/gcol/inc/gcol_view.inc
+++ b/mysql-test/suite/gcol/inc/gcol_view.inc
@@ -221,3 +221,58 @@ select * from t1;
drop view v1;
drop table t1;
+
+--echo #
+--echo # MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+--echo #
+
+CREATE TABLE t1 (d DATETIME(3), v DATETIME(2) AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+
+INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),
+ ('1985-12-24 10:15:08.456');
+DELETE FROM v1 ORDER BY v LIMIT 4;
+
+# Cleanup
+DROP VIEW v1;
+DROP TABLE t1;
+
+--echo #
+--echo # [duplicate] MDEV-19306 Assertion `marked_for_read()' failed in
+--echo # Field_blob::val_str with virtual columns and views
+--echo #
+
+CREATE TABLE t1 (a BLOB, b TEXT AS (a) VIRTUAL);
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (a) VALUES ('foo'),('bar');
+DELETE FROM v1 ORDER BY b LIMIT 2;
+
+# Cleanup
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (d INT, v TINYINT AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004'),('1985') ;
+DELETE FROM v1 ORDER BY v LIMIT 4;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+
+CREATE TABLE t1 (d VARCHAR(64), v VARCHAR(63) AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),('1985-12-24 10:15:08.456') ;
+DELETE FROM v1 ORDER BY v LIMIT 4;
+
+DROP TABLE t1;
+DROP VIEW v1;
+
+
+--echo #
+--echo # MDEV-18249 ASSERT_COLUMN_MARKED_FOR_READ failed in ANALYZE TABLE
+--echo #
+
+create table t1 (c varchar(3) not null, v varchar(4) as (c) virtual);
+insert into t1 (c) values ('a'),('b');
+analyze table t1 persistent for columns (v) indexes ();
+
diff --git a/mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result b/mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result
index 3024b58da54..193ef064da8 100644
--- a/mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result
+++ b/mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result
@@ -435,6 +435,26 @@ UPDATE t1 SET col1 = 2;
UPDATE t1 SET col7 = DEFAULT;
UPDATE t1 SET col8 = DEFAULT;
DROP TABLE t1;
+Bug#20797344: WL#8149: ALLOCATED SPACE FOR INDEXED BLOB VGC CAN BE
+OVERWRITTEN FOR UPDATE
+#
+CREATE TABLE t (a varchar(100), b blob,
+c blob GENERATED ALWAYS AS (concat(a,b)) VIRTUAL,
+d blob GENERATED ALWAYS AS (b) VIRTUAL,
+e int(11) GENERATED ALWAYS AS (10) VIRTUAL,
+h int(11) NOT NULL, PRIMARY KEY (h), key(c(20)));
+INSERT INTO t(a,b,h) VALUES('aaaaaaa','1111111', 11);
+INSERT INTO t(a,b,h) VALUES('bbbbbbb','2222222', 22);
+SELECT c FROM t;
+c
+aaaaaaa1111111
+bbbbbbb2222222
+UPDATE t SET a='ccccccc';
+SELECT c FROM t;
+c
+ccccccc1111111
+ccccccc2222222
+DROP TABLE t;
# Bug#21081742: ASSERTION !TABLE || (!TABLE->WRITE_SET ||
# BITMAP_IS_SET(TABLE->WRITE_SET
#
@@ -491,6 +511,21 @@ SELECT * FROM t;
x y gc
2 1 3
DROP TABLE t;
+CREATE TABLE t (
+x INT, y INT, gc INT GENERATED ALWAYS AS (x+1), KEY (x,gc)
+);
+INSERT INTO t VALUES ();
+UPDATE t t1, t t2 SET t1.x = 1, t2.y = 2;
+SELECT * FROM t;
+x y gc
+1 2 2
+SELECT gc FROM t;
+gc
+2
+CHECK TABLE t;
+Table Op Msg_type Msg_text
+test.t check status OK
+DROP TABLE t;
# stored
CREATE TABLE C (
col_varchar_nokey VARCHAR(1),
@@ -552,6 +587,100 @@ SELECT * from C;
col_varchar_nokey col_varchar_key
a aa
DROP TABLE C;
+# virtual, indexed
+CREATE TABLE C (
+col_varchar_nokey VARCHAR(1),
+col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
+(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL,
+KEY (col_varchar_key, col_varchar_nokey)
+);
+INSERT INTO C (col_varchar_nokey) VALUES ('c');
+EXPLAIN UPDATE C AS OUTR1, C AS OUTR2
+SET OUTR1.`col_varchar_nokey` = 'f',
+OUTR2.`col_varchar_nokey` = "a";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE OUTR1 ALL NULL NULL NULL NULL 1
+1 SIMPLE OUTR2 ALL NULL NULL NULL NULL 1
+UPDATE C AS OUTR1, C AS OUTR2
+SET OUTR1.`col_varchar_nokey` = 'f',
+OUTR2.`col_varchar_nokey` = "a";
+SELECT * from C;
+col_varchar_nokey col_varchar_key
+a aa
+DROP TABLE C;
+#
+# Bug #21530366 CRASH/ASSERTION, CORRUPTION WITH INDEXES +
+# VIRTUAL COLUMNS, BLOB
+#
+CREATE TABLE t (
+a INTEGER,
+b BLOB GENERATED ALWAYS AS (a) VIRTUAL,
+INDEX (b(57))
+);
+INSERT INTO t (a) VALUES (9);
+UPDATE t SET a = 10;
+DELETE FROM t WHERE a = 10;
+DROP TABLE t;
+# Bug#21807818: Generated columns not updated with empty insert list
+CREATE TABLE t (
+a BLOB GENERATED ALWAYS AS ('') VIRTUAL,
+b TIMESTAMP(4) GENERATED ALWAYS AS ('') VIRTUAL,
+KEY (a(183),b)
+);
+ERROR HY000: Function or expression '''' cannot be used in the GENERATED ALWAYS AS clause of `b`
+CREATE TABLE t (
+a BLOB GENERATED ALWAYS AS ('') VIRTUAL,
+b TIMESTAMP(4) GENERATED ALWAYS AS ('') VIRTUAL
+);
+INSERT IGNORE INTO t VALUES(), (), ();
+DELETE IGNORE FROM t;
+DROP TABLE t;
+#
+# Bug#22195458:GCOLS: ASSERTION 0 AND CORRUPTION...
+#
+CREATE TABLE t (
+a INT,
+b YEAR GENERATED ALWAYS AS ('a') VIRTUAL,
+c YEAR GENERATED ALWAYS AS ('aaaa') VIRTUAL,
+b1 YEAR GENERATED ALWAYS AS ('a') STORED,
+c1 YEAR GENERATED ALWAYS AS ('aaaa') STORED,
+UNIQUE(b),
+UNIQUE(b1)
+);
+INSERT IGNORE INTO t VALUES();
+SELECT b from t;
+b
+0000
+SELECT b1 from t;
+b1
+0000
+SELECT * from t;
+a b c b1 c1
+NULL 0000 0000 0000 0000
+DELETE FROM t;
+CHECK TABLE t EXTENDED;
+Table Op Msg_type Msg_text
+test.t check status OK
+DROP TABLE t;
+# Bug#22195364:GCOLS: FAILING ASSERTION:
+# DFIELD_IS_NULL(DFIELD2) || DFIELD2->DATA
+CREATE TABLE t (
+a INT,
+c BLOB GENERATED ALWAYS AS ('') VIRTUAL,
+UNIQUE KEY(c(1),a)
+);
+INSERT INTO t(a) VALUES(1) ON DUPLICATE KEY UPDATE a=2;
+SELECT * FROM t;
+a c
+1
+INSERT INTO t(a) VALUES(1) ON DUPLICATE KEY UPDATE a=2;
+SELECT * FROM t;
+a c
+2
+SELECT GROUP_CONCAT(c ORDER BY c) FROM t;
+GROUP_CONCAT(c ORDER BY c)
+
+DROP TABLE t;
#Bug#21929967:GCOLS:GCOL VALUE CHANGES WHEN SESSION CHANGES SQL_MODE
CREATE TABLE t(c1 INT GENERATED ALWAYS AS (1) VIRTUAL,
c2 INT GENERATED ALWAYS AS(2) STORED);
@@ -593,6 +722,98 @@ i1 i2
5 10
5 10
DROP TABLE t1,t2;
+#
+# Bug#22070021 GCOL:ASSERTION `!TABLE || (!TABLE->WRITE_SET ||
+# BITMAP_IS_SET(TABLE->WRITE_SET,
+#
+CREATE TABLE t1(
+c1 INT,
+c2 INT GENERATED ALWAYS AS (c1 + c1) VIRTUAL,
+KEY(c2)
+);
+INSERT INTO t1(c1) VALUES(0);
+DELETE O1.* FROM t1 AS O1, t1 AS O2;
+SELECT * FROM t1;
+c1 c2
+DROP TABLE t1;
+#
+# Bug#21944199 SIMPLE DELETE QUERY CAUSES INNODB: FAILING ASSERTION: 0
+# & DATA CORRUPTION
+#
+CREATE TEMPORARY TABLE t1 (
+a INTEGER NOT NULL,
+b INTEGER GENERATED ALWAYS AS (a+1) VIRTUAL
+);
+INSERT INTO t1 (a) VALUES (0), (0), (0);
+ALTER TABLE t1 ADD INDEX idx (b);
+DELETE FROM t1;
+DROP TEMPORARY TABLE t1;
+#
+# Original test case from MDEV-17890
+#
+CREATE TABLE t1 (
+pk BIGINT AUTO_INCREMENT,
+b BIT(15),
+v BIT(10) AS (b) VIRTUAL,
+PRIMARY KEY(pk),
+UNIQUE(v)
+);
+INSERT IGNORE INTO t1 (b) VALUES (b'101110001110100'),(b'011101');
+Warnings:
+Warning 1264 Out of range value for column 'v' at row 1
+SELECT pk, b INTO OUTFILE 'load.data' FROM t1;
+LOAD DATA INFILE 'load.data' REPLACE INTO TABLE t1 (pk, b);
+ERROR 22001: Data too long for column 'v' at row 1
+DROP TABLE t1;
+#
+# MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+#
+CREATE TABLE t1 (
+id INT NOT NULL AUTO_INCREMENT,
+f ENUM('a','b','c'),
+v ENUM('a','b','c') AS (f),
+KEY(v,id)
+) ENGINE=MyISAM;
+INSERT INTO t1 (f) VALUES ('a'),('b');
+INSERT IGNORE INTO t1 SELECT * FROM t1;
+Warnings:
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+DROP TABLE t1;
+CREATE TABLE t1 (
+id INT NOT NULL AUTO_INCREMENT,
+f ENUM('a','b','c'),
+v ENUM('a','b','c') AS (f),
+KEY(v,id)
+) ENGINE=MyISAM;
+INSERT INTO t1 (f) VALUES ('a'),('b');
+INSERT IGNORE INTO t1 SELECT * FROM t1;
+Warnings:
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+DROP TABLE t1;
+#
+# MDEV-23597 Assertion `marked_for_read()' failed while evaluating DEFAULT
+#
+CREATE TABLE t1 (a INT UNIQUE, b INT DEFAULT (c+1), c int);
+INSERT INTO t1 VALUES (1,1,1);
+UPDATE t1 SET b=DEFAULT;
+SELECT * from t1;
+a b c
+1 2 1
+REPLACE t1 VALUES(1,1,1);
+INSERT INTO t1 VALUES (1,1,1) ON DUPLICATE KEY UPDATE b= DEFAULT;
+SELECT * from t1;
+a b c
+1 2 1
+REPLACE t1 VALUES(1,1,1);
+CREATE TABLE t2 (a INT, b INT DEFAULT (c+1), c int);
+INSERT INTO t2 VALUES (5,5,5);
+UPDATE t1 join t2 set t1.b= DEFAULT, t2.b= DEFAULT;
+SELECT * from t1, t2;
+a b c a b c
+1 2 1 5 6 5
+DROP TABLE t1, t2;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
diff --git a/mysql-test/suite/gcol/r/gcol_ins_upd_myisam.result b/mysql-test/suite/gcol/r/gcol_ins_upd_myisam.result
index e5f512d5029..98db88abf4b 100644
--- a/mysql-test/suite/gcol/r/gcol_ins_upd_myisam.result
+++ b/mysql-test/suite/gcol/r/gcol_ins_upd_myisam.result
@@ -572,13 +572,13 @@ UNIQUE(b1)
INSERT IGNORE INTO t VALUES();
SELECT b from t;
b
-2000
+0000
SELECT b1 from t;
b1
0000
SELECT * from t;
a b c b1 c1
-NULL 2000 0000 0000 0000
+NULL 0000 0000 0000 0000
DELETE FROM t;
CHECK TABLE t EXTENDED;
Table Op Msg_type Msg_text
@@ -670,6 +670,72 @@ INSERT INTO t1 (a) VALUES (0), (0), (0);
ALTER TABLE t1 ADD INDEX idx (b);
DELETE FROM t1;
DROP TEMPORARY TABLE t1;
+#
+# Original test case from MDEV-17890
+#
+CREATE TABLE t1 (
+pk BIGINT AUTO_INCREMENT,
+b BIT(15),
+v BIT(10) AS (b) VIRTUAL,
+PRIMARY KEY(pk),
+UNIQUE(v)
+);
+INSERT IGNORE INTO t1 (b) VALUES (b'101110001110100'),(b'011101');
+Warnings:
+Warning 1264 Out of range value for column 'v' at row 1
+SELECT pk, b INTO OUTFILE 'load.data' FROM t1;
+LOAD DATA INFILE 'load.data' REPLACE INTO TABLE t1 (pk, b);
+ERROR 22001: Data too long for column 'v' at row 1
+DROP TABLE t1;
+#
+# MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+#
+CREATE TABLE t1 (
+id INT NOT NULL AUTO_INCREMENT,
+f ENUM('a','b','c'),
+v ENUM('a','b','c') AS (f),
+KEY(v,id)
+) ENGINE=MyISAM;
+INSERT INTO t1 (f) VALUES ('a'),('b');
+INSERT IGNORE INTO t1 SELECT * FROM t1;
+Warnings:
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+DROP TABLE t1;
+CREATE TABLE t1 (
+id INT NOT NULL AUTO_INCREMENT,
+f ENUM('a','b','c'),
+v ENUM('a','b','c') AS (f),
+KEY(v,id)
+) ENGINE=MyISAM;
+INSERT INTO t1 (f) VALUES ('a'),('b');
+INSERT IGNORE INTO t1 SELECT * FROM t1;
+Warnings:
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+Warning 1906 The value specified for generated column 'v' in table 't1' has been ignored
+DROP TABLE t1;
+#
+# MDEV-23597 Assertion `marked_for_read()' failed while evaluating DEFAULT
+#
+CREATE TABLE t1 (a INT UNIQUE, b INT DEFAULT (c+1), c int);
+INSERT INTO t1 VALUES (1,1,1);
+UPDATE t1 SET b=DEFAULT;
+SELECT * from t1;
+a b c
+1 2 1
+REPLACE t1 VALUES(1,1,1);
+INSERT INTO t1 VALUES (1,1,1) ON DUPLICATE KEY UPDATE b= DEFAULT;
+SELECT * from t1;
+a b c
+1 2 1
+REPLACE t1 VALUES(1,1,1);
+CREATE TABLE t2 (a INT, b INT DEFAULT (c+1), c int);
+INSERT INTO t2 VALUES (5,5,5);
+UPDATE t1 join t2 set t1.b= DEFAULT, t2.b= DEFAULT;
+SELECT * from t1, t2;
+a b c a b c
+1 2 1 5 6 5
+DROP TABLE t1, t2;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
diff --git a/mysql-test/suite/gcol/r/gcol_keys_innodb.result b/mysql-test/suite/gcol/r/gcol_keys_innodb.result
index 0ee6654f3a7..196ceb5459e 100644
--- a/mysql-test/suite/gcol/r/gcol_keys_innodb.result
+++ b/mysql-test/suite/gcol/r/gcol_keys_innodb.result
@@ -885,7 +885,7 @@ ERROR 22003: Out of range value for column 'vi' at row 1
DROP TABLE t1;
# MDEV-19011 Assertion `file->s->base.reclength < file->s->vreclength'
# failed in ha_myisam::setup_vcols_for_repair
-CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL) ENGINE=MyISAM;
+CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL);
ALTER TABLE t1 ADD KEY (a);
DROP TABLE t1;
#
diff --git a/mysql-test/suite/gcol/r/gcol_keys_myisam.result b/mysql-test/suite/gcol/r/gcol_keys_myisam.result
index 48e11cbe222..c3cb35416ef 100644
--- a/mysql-test/suite/gcol/r/gcol_keys_myisam.result
+++ b/mysql-test/suite/gcol/r/gcol_keys_myisam.result
@@ -885,7 +885,7 @@ ERROR 22003: Out of range value for column 'vi' at row 1
DROP TABLE t1;
# MDEV-19011 Assertion `file->s->base.reclength < file->s->vreclength'
# failed in ha_myisam::setup_vcols_for_repair
-CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL) ENGINE=MyISAM;
+CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL);
ALTER TABLE t1 ADD KEY (a);
DROP TABLE t1;
DROP VIEW IF EXISTS v1,v2;
diff --git a/mysql-test/suite/gcol/r/gcol_partition_innodb.result b/mysql-test/suite/gcol/r/gcol_partition_innodb.result
index e5a68cdb177..d3f211c9b9a 100644
--- a/mysql-test/suite/gcol/r/gcol_partition_innodb.result
+++ b/mysql-test/suite/gcol/r/gcol_partition_innodb.result
@@ -89,6 +89,21 @@ Table Op Msg_type Msg_text
test.t check status OK
DROP TABLE t;
#
+# MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+#
+CREATE TABLE t1 (
+a INT,
+b INT,
+c BIT(4) NOT NULL DEFAULT b'0',
+pk INTEGER AUTO_INCREMENT,
+d BIT(4) AS (c) VIRTUAL,
+PRIMARY KEY(pk),
+KEY (b,d)
+) PARTITION BY HASH(pk);
+INSERT INTO t1 () VALUES (),();
+UPDATE t1 SET a = 0 WHERE b IS NULL ORDER BY pk;
+DROP TABLE t1;
+#
# MDEV-16980 Wrongly set tablename len while opening the
# table for purge thread
#
diff --git a/mysql-test/suite/gcol/r/gcol_partition_myisam.result b/mysql-test/suite/gcol/r/gcol_partition_myisam.result
index 81324da6fcd..75e216f903b 100644
--- a/mysql-test/suite/gcol/r/gcol_partition_myisam.result
+++ b/mysql-test/suite/gcol/r/gcol_partition_myisam.result
@@ -86,6 +86,21 @@ CHECK TABLE t EXTENDED;
Table Op Msg_type Msg_text
test.t check status OK
DROP TABLE t;
+#
+# MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+#
+CREATE TABLE t1 (
+a INT,
+b INT,
+c BIT(4) NOT NULL DEFAULT b'0',
+pk INTEGER AUTO_INCREMENT,
+d BIT(4) AS (c) VIRTUAL,
+PRIMARY KEY(pk),
+KEY (b,d)
+) PARTITION BY HASH(pk);
+INSERT INTO t1 () VALUES (),();
+UPDATE t1 SET a = 0 WHERE b IS NULL ORDER BY pk;
+DROP TABLE t1;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
diff --git a/mysql-test/suite/gcol/r/gcol_view_innodb.result b/mysql-test/suite/gcol/r/gcol_view_innodb.result
index b23dbfc4bff..ac23d64bcee 100644
--- a/mysql-test/suite/gcol/r/gcol_view_innodb.result
+++ b/mysql-test/suite/gcol/r/gcol_view_innodb.result
@@ -272,6 +272,47 @@ a b c
1 -1 -1
drop view v1;
drop table t1;
+#
+# MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+#
+CREATE TABLE t1 (d DATETIME(3), v DATETIME(2) AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),
+('1985-12-24 10:15:08.456');
+DELETE FROM v1 ORDER BY v LIMIT 4;
+DROP VIEW v1;
+DROP TABLE t1;
+#
+# [duplicate] MDEV-19306 Assertion `marked_for_read()' failed in
+# Field_blob::val_str with virtual columns and views
+#
+CREATE TABLE t1 (a BLOB, b TEXT AS (a) VIRTUAL);
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (a) VALUES ('foo'),('bar');
+DELETE FROM v1 ORDER BY b LIMIT 2;
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (d INT, v TINYINT AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004'),('1985') ;
+DELETE FROM v1 ORDER BY v LIMIT 4;
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (d VARCHAR(64), v VARCHAR(63) AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),('1985-12-24 10:15:08.456') ;
+DELETE FROM v1 ORDER BY v LIMIT 4;
+DROP TABLE t1;
+DROP VIEW v1;
+#
+# MDEV-18249 ASSERT_COLUMN_MARKED_FOR_READ failed in ANALYZE TABLE
+#
+create table t1 (c varchar(3) not null, v varchar(4) as (c) virtual);
+insert into t1 (c) values ('a'),('b');
+analyze table t1 persistent for columns (v) indexes ();
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
diff --git a/mysql-test/suite/gcol/r/gcol_view_myisam.result b/mysql-test/suite/gcol/r/gcol_view_myisam.result
index 264bd904c30..ddbbf44222c 100644
--- a/mysql-test/suite/gcol/r/gcol_view_myisam.result
+++ b/mysql-test/suite/gcol/r/gcol_view_myisam.result
@@ -272,6 +272,47 @@ a b c
1 -1 -1
drop view v1;
drop table t1;
+#
+# MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+#
+CREATE TABLE t1 (d DATETIME(3), v DATETIME(2) AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),
+('1985-12-24 10:15:08.456');
+DELETE FROM v1 ORDER BY v LIMIT 4;
+DROP VIEW v1;
+DROP TABLE t1;
+#
+# [duplicate] MDEV-19306 Assertion `marked_for_read()' failed in
+# Field_blob::val_str with virtual columns and views
+#
+CREATE TABLE t1 (a BLOB, b TEXT AS (a) VIRTUAL);
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (a) VALUES ('foo'),('bar');
+DELETE FROM v1 ORDER BY b LIMIT 2;
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (d INT, v TINYINT AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004'),('1985') ;
+DELETE FROM v1 ORDER BY v LIMIT 4;
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (d VARCHAR(64), v VARCHAR(63) AS (d));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),('1985-12-24 10:15:08.456') ;
+DELETE FROM v1 ORDER BY v LIMIT 4;
+DROP TABLE t1;
+DROP VIEW v1;
+#
+# MDEV-18249 ASSERT_COLUMN_MARKED_FOR_READ failed in ANALYZE TABLE
+#
+create table t1 (c varchar(3) not null, v varchar(4) as (c) virtual);
+insert into t1 (c) values ('a'),('b');
+analyze table t1 persistent for columns (v) indexes ();
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
diff --git a/mysql-test/suite/gcol/r/innodb_virtual_fk.result b/mysql-test/suite/gcol/r/innodb_virtual_fk.result
index 252274f3e0a..367ed1223f7 100644
--- a/mysql-test/suite/gcol/r/innodb_virtual_fk.result
+++ b/mysql-test/suite/gcol/r/innodb_virtual_fk.result
@@ -809,15 +809,18 @@ generated_email_id int as (email_id),
PRIMARY KEY (id),
KEY mautic_generated_sent_date_email_id (generated_email_id),
FOREIGN KEY (email_id) REFERENCES emails (id) ON DELETE SET NULL
+ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE emails_metadata (
email_id int,
PRIMARY KEY (email_id),
CONSTRAINT FK FOREIGN KEY (email_id) REFERENCES emails (id) ON DELETE CASCADE
+ON UPDATE CASCADE
) ENGINE=InnoDB;
INSERT INTO emails VALUES (1);
INSERT INTO email_stats (id, email_id, date_sent) VALUES (1,1,'Jan');
INSERT INTO emails_metadata VALUES (1);
+UPDATE emails SET id=2;
DELETE FROM emails;
DROP TABLE email_stats;
DROP TABLE emails_metadata;
diff --git a/mysql-test/suite/gcol/t/gcol_ins_upd_innodb.test b/mysql-test/suite/gcol/t/gcol_ins_upd_innodb.test
index 23d97a797e0..15a0db29615 100644
--- a/mysql-test/suite/gcol/t/gcol_ins_upd_innodb.test
+++ b/mysql-test/suite/gcol/t/gcol_ins_upd_innodb.test
@@ -36,7 +36,7 @@ eval SET @@session.default_storage_engine = 'InnoDB';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
-let $support_virtual_index= 0;
+let $support_virtual_index= 1;
--source suite/gcol/inc/gcol_ins_upd.inc
#------------------------------------------------------------------------------#
diff --git a/mysql-test/suite/gcol/t/innodb_virtual_fk.test b/mysql-test/suite/gcol/t/innodb_virtual_fk.test
index 24b6a4631e6..c99259531b3 100644
--- a/mysql-test/suite/gcol/t/innodb_virtual_fk.test
+++ b/mysql-test/suite/gcol/t/innodb_virtual_fk.test
@@ -670,6 +670,7 @@ CREATE TABLE email_stats (
PRIMARY KEY (id),
KEY mautic_generated_sent_date_email_id (generated_email_id),
FOREIGN KEY (email_id) REFERENCES emails (id) ON DELETE SET NULL
+ ON UPDATE CASCADE
) ENGINE=InnoDB;
@@ -677,6 +678,7 @@ CREATE TABLE emails_metadata (
email_id int,
PRIMARY KEY (email_id),
CONSTRAINT FK FOREIGN KEY (email_id) REFERENCES emails (id) ON DELETE CASCADE
+ ON UPDATE CASCADE
) ENGINE=InnoDB;
@@ -684,6 +686,7 @@ INSERT INTO emails VALUES (1);
INSERT INTO email_stats (id, email_id, date_sent) VALUES (1,1,'Jan');
INSERT INTO emails_metadata VALUES (1);
+UPDATE emails SET id=2;
DELETE FROM emails;
DROP TABLE email_stats;
diff --git a/mysql-test/suite/innodb/r/alter_table.result b/mysql-test/suite/innodb/r/alter_table.result
index aec2964121b..3b0d3b0659d 100644
--- a/mysql-test/suite/innodb/r/alter_table.result
+++ b/mysql-test/suite/innodb/r/alter_table.result
@@ -107,6 +107,16 @@ alter table t1 engine=innodb;
alter table t1 add column b int;
drop table t1,t2;
#
+# MDEV-19272 Assertion unireg_check...Field::NEXT_NUMBER failed
+#
+CREATE TABLE t1 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB;
+ALTER TABLE t1 MODIFY c INT NOT NULL, ALGORITHM=INPLACE;
+DROP TABLE t1;
+CREATE TABLE t1 (c TIMESTAMP AUTO_INCREMENT UNIQUE) ENGINE=InnoDB;
+ERROR 42000: Incorrect column specifier for column 'c'
+CREATE TABLE t1 (c DATETIME AUTO_INCREMENT UNIQUE) ENGINE=InnoDB;
+ERROR 42000: Incorrect column specifier for column 'c'
+#
# End of 10.4 tests
#
#
diff --git a/mysql-test/suite/innodb/r/default_row_format_alter.result b/mysql-test/suite/innodb/r/default_row_format_alter.result
index fa5adb32fb0..42cbab8a5f2 100644
--- a/mysql-test/suite/innodb/r/default_row_format_alter.result
+++ b/mysql-test/suite/innodb/r/default_row_format_alter.result
@@ -23,6 +23,7 @@ INSERT INTO t1 VALUES (1, 'abc');
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 InnoDB # Compact # # # # # # NULL # # NULL latin1_swedish_ci NULL 0 N
+CREATE TABLE t2 (b VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL) ENGINE=InnoDB;
SET GLOBAL innodb_default_row_format = DYNAMIC;
ALTER TABLE t1 DROP PRIMARY KEY, ADD COLUMN c INT PRIMARY KEY;
# Here we expect DYNAMIC because there is no explicit ROW_FORMAT and the
@@ -31,6 +32,10 @@ SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 InnoDB # Dynamic # # # # # # NULL # # NULL latin1_swedish_ci NULL 0 N
DROP TABLE t1;
+ALTER TABLE t2 ADD INDEX(b);
+ERROR HY000: Index column size too large. The maximum column size is 767 bytes
+ALTER TABLE t2 FORCE, ADD INDEX(b);
+DROP TABLE t2;
####################################
# Check the row_format effect on ALTER, ALGORITHM=COPY
SET GLOBAL innodb_default_row_format = REDUNDANT;
@@ -39,6 +44,7 @@ INSERT INTO t1 VALUES (1, REPEAT('abc',1000));
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 InnoDB # Redundant # # # # # # NULL # # NULL latin1_swedish_ci NULL 0 N
+CREATE TABLE t2 (b VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL) ENGINE=InnoDB;
SET GLOBAL innoDB_default_row_format = COMPACT;
ALTER TABLE t1 ADD COLUMN c2 BLOB, ALGORITHM=COPY;
# Because of ALGORITHM=COPY, there is TABLE REBUILD and the table isn't
@@ -47,9 +53,18 @@ SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 InnoDB # Compact # # # # # # NULL # # NULL latin1_swedish_ci NULL 0 N
DROP TABLE t1;
+ALTER TABLE t2 ADD INDEX(b);
+ERROR HY000: Index column size too large. The maximum column size is 767 bytes
+ALTER TABLE t2 FORCE, ADD INDEX(b);
+ERROR HY000: Index column size too large. The maximum column size is 767 bytes
+SET GLOBAL innodb_default_row_format = DYNAMIC;
+ALTER TABLE t2 ADD INDEX(b);
+ERROR HY000: Index column size too large. The maximum column size is 767 bytes
+ALTER TABLE t2 FORCE, ADD INDEX(b);
+DROP TABLE t2;
###################################
-# Check the row_format effect on ALTER, ALGORITH=COPY on
+# Check the row_format effect on ALTER, ALGORITHM=COPY on
# create table with explicit row_format
CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=INNODB;
INSERT INTO t1 VALUES (1, REPEAT('abc',1000));
diff --git a/mysql-test/suite/innodb/r/import_bugs.result b/mysql-test/suite/innodb/r/import_bugs.result
new file mode 100644
index 00000000000..a52fe6abbd6
--- /dev/null
+++ b/mysql-test/suite/innodb/r/import_bugs.result
@@ -0,0 +1,12 @@
+call mtr.add_suppression("Index for table 'imp_t1' is corrupt; try to repair it");
+SET @save_innodb_checksum_algorithm=@@GLOBAL.innodb_checksum_algorithm;
+SET GLOBAL innodb_checksum_algorithm=full_crc32;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
+CREATE TABLE imp_t1 (a INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+ALTER TABLE imp_t1 DISCARD TABLESPACE ;
+FLUSH TABLES t1 FOR EXPORT;
+UNLOCK TABLES;
+ALTER TABLE imp_t1 IMPORT TABLESPACE;
+ERROR HY000: Schema mismatch (ROW_FORMAT mismatch)
+DROP TABLE imp_t1, t1;
+SET GLOBAL innodb_checksum_algorithm=@save_innodb_checksum_algorithm;
diff --git a/mysql-test/suite/innodb/t/alter_table.test b/mysql-test/suite/innodb/t/alter_table.test
index 53a9dbfea03..67ada081d46 100644
--- a/mysql-test/suite/innodb/t/alter_table.test
+++ b/mysql-test/suite/innodb/t/alter_table.test
@@ -110,6 +110,17 @@ alter table t1 add column b int;
drop table t1,t2;
--echo #
+--echo # MDEV-19272 Assertion unireg_check...Field::NEXT_NUMBER failed
+--echo #
+CREATE TABLE t1 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB;
+ALTER TABLE t1 MODIFY c INT NOT NULL, ALGORITHM=INPLACE;
+DROP TABLE t1;
+--error ER_WRONG_FIELD_SPEC
+CREATE TABLE t1 (c TIMESTAMP AUTO_INCREMENT UNIQUE) ENGINE=InnoDB;
+--error ER_WRONG_FIELD_SPEC
+CREATE TABLE t1 (c DATETIME AUTO_INCREMENT UNIQUE) ENGINE=InnoDB;
+
+--echo #
--echo # End of 10.4 tests
--echo #
diff --git a/mysql-test/suite/innodb/t/default_row_format_alter.test b/mysql-test/suite/innodb/t/default_row_format_alter.test
index 7cd4d672858..f5dd246efb5 100644
--- a/mysql-test/suite/innodb/t/default_row_format_alter.test
+++ b/mysql-test/suite/innodb/t/default_row_format_alter.test
@@ -6,7 +6,7 @@ SET @row_format = @@GLOBAL.innodb_default_row_format;
--echo ####################################
--echo # Check if table rebuilding alter isn't affect if table is created
--echo # with explicit row_format
-eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=INNODB;
+CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=INNODB;
INSERT INTO t1 VALUES (1, 'abc');
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
@@ -23,12 +23,14 @@ DROP TABLE t1;
--echo # Check if table rebuilding alter is affected when there is no
--echo # row_format specified at CREATE TABLE.
SET GLOBAL innodb_default_row_format = COMPACT;
-eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB;
+CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB;
INSERT INTO t1 VALUES (1, 'abc');
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
+CREATE TABLE t2 (b VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL) ENGINE=InnoDB;
+
SET GLOBAL innodb_default_row_format = DYNAMIC;
ALTER TABLE t1 DROP PRIMARY KEY, ADD COLUMN c INT PRIMARY KEY;
@@ -38,15 +40,22 @@ ALTER TABLE t1 DROP PRIMARY KEY, ADD COLUMN c INT PRIMARY KEY;
SHOW TABLE STATUS LIKE 't1';
DROP TABLE t1;
+--error ER_INDEX_COLUMN_TOO_LONG
+ALTER TABLE t2 ADD INDEX(b);
+ALTER TABLE t2 FORCE, ADD INDEX(b);
+DROP TABLE t2;
+
--echo ####################################
--echo # Check the row_format effect on ALTER, ALGORITHM=COPY
SET GLOBAL innodb_default_row_format = REDUNDANT;
-eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB;
+CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB;
INSERT INTO t1 VALUES (1, REPEAT('abc',1000));
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
+CREATE TABLE t2 (b VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL) ENGINE=InnoDB;
+
SET GLOBAL innoDB_default_row_format = COMPACT;
ALTER TABLE t1 ADD COLUMN c2 BLOB, ALGORITHM=COPY;
@@ -56,11 +65,23 @@ ALTER TABLE t1 ADD COLUMN c2 BLOB, ALGORITHM=COPY;
SHOW TABLE STATUS LIKE 't1';
DROP TABLE t1;
+--error ER_INDEX_COLUMN_TOO_LONG
+ALTER TABLE t2 ADD INDEX(b);
+--error ER_INDEX_COLUMN_TOO_LONG
+ALTER TABLE t2 FORCE, ADD INDEX(b);
+
+SET GLOBAL innodb_default_row_format = DYNAMIC;
+--error ER_INDEX_COLUMN_TOO_LONG
+ALTER TABLE t2 ADD INDEX(b);
+ALTER TABLE t2 FORCE, ADD INDEX(b);
+
+DROP TABLE t2;
+
--echo
--echo ###################################
---echo # Check the row_format effect on ALTER, ALGORITH=COPY on
+--echo # Check the row_format effect on ALTER, ALGORITHM=COPY on
--echo # create table with explicit row_format
-eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=INNODB;
+CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=INNODB;
INSERT INTO t1 VALUES (1, REPEAT('abc',1000));
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
@@ -81,7 +102,7 @@ DROP TABLE t1;
--echo # Check row_format on ALTER ALGORITHM=INPLACE
SET GLOBAL innodb_default_row_format=COMPACT;
-eval CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT, KEY k1(b(10))) ENGINE=INNODB;
+CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT, KEY k1(b(10))) ENGINE=INNODB;
INSERT INTO t1 VALUES (1, REPEAT('abc',1000));
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
diff --git a/mysql-test/suite/innodb/t/import_bugs.test b/mysql-test/suite/innodb/t/import_bugs.test
new file mode 100644
index 00000000000..4b5c04e3056
--- /dev/null
+++ b/mysql-test/suite/innodb/t/import_bugs.test
@@ -0,0 +1,20 @@
+--source include/have_innodb.inc
+
+call mtr.add_suppression("Index for table 'imp_t1' is corrupt; try to repair it");
+
+SET @save_innodb_checksum_algorithm=@@GLOBAL.innodb_checksum_algorithm;
+SET GLOBAL innodb_checksum_algorithm=full_crc32;
+
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
+CREATE TABLE imp_t1 (a INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
+ALTER TABLE imp_t1 DISCARD TABLESPACE ;
+FLUSH TABLES t1 FOR EXPORT;
+let $datadir=`select @@datadir`;
+--copy_file $datadir/test/t1.ibd $datadir/test/imp_t1.ibd
+UNLOCK TABLES;
+--error ER_TABLE_SCHEMA_MISMATCH
+ALTER TABLE imp_t1 IMPORT TABLESPACE;
+DROP TABLE imp_t1, t1;
+--remove_file $datadir/test/imp_t1.ibd
+
+SET GLOBAL innodb_checksum_algorithm=@save_innodb_checksum_algorithm;
diff --git a/mysql-test/suite/innodb/t/innodb-page_compression_lz4.test b/mysql-test/suite/innodb/t/innodb-page_compression_lz4.test
index 828fc978a29..a091eb6ac31 100644
--- a/mysql-test/suite/innodb/t/innodb-page_compression_lz4.test
+++ b/mysql-test/suite/innodb/t/innodb-page_compression_lz4.test
@@ -1,6 +1,8 @@
-- source include/have_innodb.inc
-- source include/have_innodb_lz4.inc
-- source include/not_embedded.inc
+# The test can take very long time with valgrind
+--source include/not_valgrind.inc
# lz4
set global innodb_compression_algorithm = 2;
diff --git a/mysql-test/suite/innodb_zip/r/innochecksum_3.result b/mysql-test/suite/innodb_zip/r/innochecksum_3.result
index da9c3bbc343..280528f4200 100644
--- a/mysql-test/suite/innodb_zip/r/innochecksum_3.result
+++ b/mysql-test/suite/innodb_zip/r/innochecksum_3.result
@@ -158,10 +158,10 @@ Filename::tab#.ibd
# allow-mismatches,page,start-page,end-page
[9]: check the both short and long options "page" and "start-page" when
# seek value is larger than file size.
-FOUND 1 /Error: Unable to seek to necessary offset: Invalid argument/ in my_restart.err
-FOUND 1 /Error: Unable to seek to necessary offset: Invalid argument/ in my_restart.err
-FOUND 1 /Error: Unable to seek to necessary offset: Invalid argument/ in my_restart.err
-FOUND 1 /Error: Unable to seek to necessary offset: Invalid argument/ in my_restart.err
+FOUND 1 /Error: Unable to seek to necessary offset/ in my_restart.err
+FOUND 1 /Error: Unable to seek to necessary offset/ in my_restart.err
+FOUND 1 /Error: Unable to seek to necessary offset/ in my_restart.err
+FOUND 1 /Error: Unable to seek to necessary offset/ in my_restart.err
[34]: check the invalid upper bound values for options, allow-mismatches, end-page, start-page and page.
# innochecksum will fail with error code: 1
NOT FOUND /Incorrect unsigned integer value: '18446744073709551616'/ in my_restart.err
diff --git a/mysql-test/suite/innodb_zip/t/innochecksum_3.test b/mysql-test/suite/innodb_zip/t/innochecksum_3.test
index 88898aea521..ef6d82253f4 100644
--- a/mysql-test/suite/innodb_zip/t/innochecksum_3.test
+++ b/mysql-test/suite/innodb_zip/t/innochecksum_3.test
@@ -206,22 +206,19 @@ cat_file $MYSQLTEST_VARDIR/tmp/dump.txt;
--echo # seek value is larger than file size.
--error 1
--exec $INNOCHECKSUM --page=18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
-let SEARCH_PATTERN= Error: Unable to seek to necessary offset: Invalid argument;
+let SEARCH_PATTERN= Error: Unable to seek to necessary offset;
--source include/search_pattern_in_file.inc
--error 1
--exec $INNOCHECKSUM -p 18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
-let SEARCH_PATTERN= Error: Unable to seek to necessary offset: Invalid argument;
--source include/search_pattern_in_file.inc
--error 1
--exec $INNOCHECKSUM --start-page=18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
-let SEARCH_PATTERN= Error: Unable to seek to necessary offset: Invalid argument;
--source include/search_pattern_in_file.inc
--error 1
--exec $INNOCHECKSUM -s 18446744073709551615 $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
-let SEARCH_PATTERN= Error: Unable to seek to necessary offset: Invalid argument;
--source include/search_pattern_in_file.inc
--echo [34]: check the invalid upper bound values for options, allow-mismatches, end-page, start-page and page.
diff --git a/mysql-test/suite/roles/set_default_role_clear.result b/mysql-test/suite/roles/set_default_role_clear.result
index 281ed7e45ea..d8508f5d0d6 100644
--- a/mysql-test/suite/roles/set_default_role_clear.result
+++ b/mysql-test/suite/roles/set_default_role_clear.result
@@ -17,7 +17,7 @@ Grants for test_user@localhost
GRANT `test_role` TO `test_user`@`localhost`
GRANT USAGE ON *.* TO `test_user`@`localhost`
GRANT SELECT ON *.* TO `test_role`
-SET DEFAULT ROLE test_role FOR 'test_user'@'localhost'
+SET DEFAULT ROLE `test_role` FOR `test_user`@`localhost`
select user, host, default_role from mysql.user where user='test_user';
User Host default_role
test_user localhost test_role
diff --git a/mysql-test/suite/roles/set_default_role_for.result b/mysql-test/suite/roles/set_default_role_for.result
index fec43b8e763..3ddf48eb416 100644
--- a/mysql-test/suite/roles/set_default_role_for.result
+++ b/mysql-test/suite/roles/set_default_role_for.result
@@ -14,14 +14,14 @@ set default role role_a for user_a@localhost;
set default role invalid_role for user_a@localhost;
ERROR OP000: Invalid role specification `invalid_role`
set default role role_b for user_a@localhost;
-ERROR OP000: User `user_a@localhost` has not been granted role `role_b`
+ERROR OP000: User `root`@`localhost` has not been granted role `role_b`
set default role role_b for user_b@localhost;
show grants;
Grants for user_a@localhost
GRANT `role_a` TO `user_a`@`localhost`
GRANT USAGE ON *.* TO `user_a`@`localhost`
GRANT SELECT ON *.* TO `role_a`
-SET DEFAULT ROLE role_a FOR 'user_a'@'localhost'
+SET DEFAULT ROLE `role_a` FOR `user_a`@`localhost`
select user, host, default_role from mysql.user where user like 'user_%';
User Host default_role
user_a localhost role_a
@@ -37,13 +37,13 @@ User Host default_role
user_a localhost role_a
user_b localhost role_b
set default role role_b for current_user;
-ERROR OP000: User `user_a@localhost` has not been granted role `role_b`
+ERROR OP000: User `user_a`@`localhost` has not been granted role `role_b`
show grants;
Grants for user_b@localhost
GRANT `role_b` TO `user_b`@`localhost`
GRANT USAGE ON *.* TO `user_b`@`localhost`
GRANT INSERT, UPDATE ON *.* TO `role_b`
-SET DEFAULT ROLE role_b FOR 'user_b'@'localhost'
+SET DEFAULT ROLE `role_b` FOR `user_b`@`localhost`
select user, host, default_role from mysql.user where user like 'user_%';
ERROR 42000: SELECT command denied to user 'user_b'@'localhost' for table 'user'
set default role NONE for user_a@localhost;
diff --git a/mysql-test/suite/roles/set_default_role_invalid.result b/mysql-test/suite/roles/set_default_role_invalid.result
index 08087acc51f..eb3924dc617 100644
--- a/mysql-test/suite/roles/set_default_role_invalid.result
+++ b/mysql-test/suite/roles/set_default_role_invalid.result
@@ -24,7 +24,7 @@ Grants for test_user@localhost
GRANT `test_role` TO `test_user`@`localhost`
GRANT USAGE ON *.* TO `test_user`@`localhost`
GRANT SELECT ON *.* TO `test_role`
-SET DEFAULT ROLE test_role FOR 'test_user'@'localhost'
+SET DEFAULT ROLE `test_role` FOR `test_user`@`localhost`
select user, host, default_role from mysql.user where user='test_user';
User Host default_role
test_user localhost test_role
@@ -48,7 +48,7 @@ CREATE USER b;
CREATE ROLE r1;
CREATE ROLE r2;
SET DEFAULT ROLE r1 FOR a;
-ERROR OP000: User `a@%` has not been granted role `r1`
+ERROR OP000: User `root`@`localhost` has not been granted role `r1`
GRANT r1 TO b;
GRANT r2 TO b;
SET DEFAULT ROLE r1 FOR b;
@@ -72,7 +72,7 @@ GRANT `r1` TO `b`@`%`
GRANT `r2` TO `b`@`%`
GRANT USAGE ON *.* TO `b`@`%`
GRANT SELECT ON `mysql`.* TO `b`@`%`
-SET DEFAULT ROLE r2 FOR 'b'@'%'
+SET DEFAULT ROLE `r2` FOR `b`@`%`
SET DEFAULT ROLE r1 FOR a;
ERROR 42000: Access denied for user 'b'@'%' to database 'mysql'
SELECT CURRENT_ROLE;
@@ -98,9 +98,9 @@ GRANT `r1` TO `b`@`%`
GRANT `r2` TO `b`@`%`
GRANT USAGE ON *.* TO `b`@`%`
GRANT SELECT, UPDATE ON `mysql`.* TO `b`@`%`
-SET DEFAULT ROLE r2 FOR 'b'@'%'
+SET DEFAULT ROLE `r2` FOR `b`@`%`
SET DEFAULT ROLE r1 FOR a;
-ERROR OP000: User `a@%` has not been granted role `r1`
+ERROR OP000: User `b`@`%` has not been granted role `r1`
SET DEFAULT ROLE invalid_role;
ERROR OP000: Invalid role specification `invalid_role`
SET DEFAULT ROLE invalid_role FOR a;
@@ -117,7 +117,7 @@ SET DEFAULT ROLE None;
# Change user b (session 3: role granted to user a)
SET DEFAULT ROLE r1 FOR a;
SET DEFAULT ROLE r2 FOR a;
-ERROR OP000: User `a@%` has not been granted role `r2`
+ERROR OP000: User `b`@`%` has not been granted role `r2`
SET DEFAULT ROLE invalid_role;
ERROR OP000: Invalid role specification `invalid_role`
SET DEFAULT ROLE invalid_role FOR a;
diff --git a/mysql-test/suite/roles/set_default_role_new_connection.result b/mysql-test/suite/roles/set_default_role_new_connection.result
index 71035737f99..5c51b782ab7 100644
--- a/mysql-test/suite/roles/set_default_role_new_connection.result
+++ b/mysql-test/suite/roles/set_default_role_new_connection.result
@@ -23,7 +23,7 @@ Grants for test_user@localhost
GRANT `test_role` TO `test_user`@`localhost`
GRANT USAGE ON *.* TO `test_user`@`localhost`
GRANT SELECT ON *.* TO `test_role`
-SET DEFAULT ROLE test_role FOR 'test_user'@'localhost'
+SET DEFAULT ROLE `test_role` FOR `test_user`@`localhost`
select user, host, default_role from mysql.user where user = 'test_user';
User Host default_role
test_user localhost test_role
@@ -52,7 +52,7 @@ Grants for test_user@localhost
GRANT `test_role` TO `test_user`@`localhost`
GRANT USAGE ON *.* TO `test_user`@`localhost`
GRANT SELECT ON *.* TO `test_role`
-SET DEFAULT ROLE test_role FOR 'test_user'@'localhost'
+SET DEFAULT ROLE `test_role` FOR `test_user`@`localhost`
select user, host, default_role from mysql.user where user = 'test_user';
User Host default_role
test_user localhost test_role
diff --git a/mysql-test/suite/roles/set_role-recursive.result b/mysql-test/suite/roles/set_role-recursive.result
index be11728ad4e..102ee392581 100644
--- a/mysql-test/suite/roles/set_role-recursive.result
+++ b/mysql-test/suite/roles/set_role-recursive.result
@@ -67,7 +67,7 @@ Grants for test_user@localhost
GRANT USAGE ON *.* TO `test_user`@`localhost`
GRANT `test_role1` TO `test_user`@`localhost`
set role test_role2;
-ERROR OP000: User `test_user@localhost` has not been granted role `test_role2`
+ERROR OP000: User `test_user`@`localhost` has not been granted role `test_role2`
select current_user(), current_role();
current_user() current_role()
test_user@localhost NULL
diff --git a/mysql-test/suite/rpl/r/create_or_replace_mix.result b/mysql-test/suite/rpl/r/create_or_replace_mix.result
index 6c83d27eef9..9036ab425ae 100644
--- a/mysql-test/suite/rpl/r/create_or_replace_mix.result
+++ b/mysql-test/suite/rpl/r/create_or_replace_mix.result
@@ -103,6 +103,8 @@ include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; create table t1 (a int)
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */
drop table if exists t1,t2;
Warnings:
Note 1051 Unknown table 'test.t1'
diff --git a/mysql-test/suite/rpl/r/create_or_replace_row.result b/mysql-test/suite/rpl/r/create_or_replace_row.result
index c45daefd671..16f92b5e4b6 100644
--- a/mysql-test/suite/rpl/r/create_or_replace_row.result
+++ b/mysql-test/suite/rpl/r/create_or_replace_row.result
@@ -128,6 +128,9 @@ include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; create table t1 (a int)
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */
+master-bin.000001 # Query # # ROLLBACK
drop table if exists t1,t2;
Warnings:
Note 1051 Unknown table 'test.t1'
diff --git a/mysql-test/suite/rpl/r/create_or_replace_statement.result b/mysql-test/suite/rpl/r/create_or_replace_statement.result
index 6c83d27eef9..9036ab425ae 100644
--- a/mysql-test/suite/rpl/r/create_or_replace_statement.result
+++ b/mysql-test/suite/rpl/r/create_or_replace_statement.result
@@ -103,6 +103,8 @@ include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; create table t1 (a int)
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `test`.`t1`/* Generated to handle failed CREATE OR REPLACE */
drop table if exists t1,t2;
Warnings:
Note 1051 Unknown table 'test.t1'
diff --git a/mysql-test/suite/rpl/t/rpl_trunc_temp.test b/mysql-test/suite/rpl/t/rpl_trunc_temp.test
index 0e7d5483f62..1ef0fcedd1d 100644
--- a/mysql-test/suite/rpl/t/rpl_trunc_temp.test
+++ b/mysql-test/suite/rpl/t/rpl_trunc_temp.test
@@ -42,7 +42,7 @@ truncate t1;
sync_slave_with_master;
show status like 'Slave_open_temp_tables';
-# Disconnect the master, temp table on slave should dissapear
+# Disconnect the master, temp table on slave should disappear
disconnect master;
connection slave;
diff --git a/mysql-test/suite/s3/my.cnf b/mysql-test/suite/s3/my.cnf
index 487aa65230f..f851aa18d6d 100644
--- a/mysql-test/suite/s3/my.cnf
+++ b/mysql-test/suite/s3/my.cnf
@@ -2,7 +2,6 @@
!include include/default_client.cnf
[mysqld.1]
-plugin-maturity = gamma
plugin-load-add=@ENV.HA_S3_SO
s3=ON
s3-host-name=@ENV.S3_HOST_NAME
diff --git a/mysql-test/suite/s3/slave.cnf b/mysql-test/suite/s3/slave.cnf
index 28dc8572b30..4f4d3d39ac7 100644
--- a/mysql-test/suite/s3/slave.cnf
+++ b/mysql-test/suite/s3/slave.cnf
@@ -1,5 +1,4 @@
[mysqld.2]
-plugin-maturity = gamma
plugin-load-add=@ENV.HA_S3_SO
s3=ON
s3-slave-ignore-updates=1
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
index b28f3c567ff..b1d2a6595b3 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
@@ -3479,7 +3479,7 @@ VARIABLE_COMMENT Default value for the FOR SYSTEM_TIME AS OF clause
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
-ENUM_VALUE_LIST DEFAULT
+ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT NULL
VARIABLE_NAME TABLE_DEFINITION_CACHE
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
index bb3378139f2..7b811a011ff 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
@@ -4169,7 +4169,7 @@ VARIABLE_COMMENT Default value for the FOR SYSTEM_TIME AS OF clause
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
-ENUM_VALUE_LIST DEFAULT
+ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT NULL
VARIABLE_NAME TABLE_DEFINITION_CACHE
diff --git a/mysql-test/suite/sys_vars/t/innodb_fatal_semaphore_wait_threshold.test b/mysql-test/suite/sys_vars/t/innodb_fatal_semaphore_wait_threshold.test
index 124b0c8563a..9cff94ed5bc 100644
--- a/mysql-test/suite/sys_vars/t/innodb_fatal_semaphore_wait_threshold.test
+++ b/mysql-test/suite/sys_vars/t/innodb_fatal_semaphore_wait_threshold.test
@@ -50,7 +50,7 @@ while (!$mysql_errno)
if (!$counter)
{
# This will fail this test.
- --die Server failed to dissapear
+ --die Server failed to disappear
}
--sleep 1
}
diff --git a/mysql-test/suite/vcol/r/binlog.result b/mysql-test/suite/vcol/r/binlog.result
index d4893b7ed3c..519877e9bc0 100644
--- a/mysql-test/suite/vcol/r/binlog.result
+++ b/mysql-test/suite/vcol/r/binlog.result
@@ -80,4 +80,18 @@ Warnings:
Warning 1265 Data truncated for column 'b' at row 1
Warning 1265 Data truncated for column 'b' at row 2
DROP TABLE t1;
+#
+# MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols
+#
+SET SESSION binlog_row_image= noblob;
+CREATE TEMPORARY TABLE t1 SELECT UUID();
+show create table t1;
+Table Create Table
+t1 CREATE TEMPORARY TABLE `t1` (
+ `UUID()` varchar(36) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+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;
include/rpl_end.inc
diff --git a/mysql-test/suite/vcol/t/binlog.test b/mysql-test/suite/vcol/t/binlog.test
index aa939086f12..edf0a8957b9 100644
--- a/mysql-test/suite/vcol/t/binlog.test
+++ b/mysql-test/suite/vcol/t/binlog.test
@@ -66,4 +66,18 @@ UPDATE IGNORE t1 SET a = NULL;
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/versioning/r/create.result b/mysql-test/suite/versioning/r/create.result
index 5badb4b4a22..1017db78a4b 100644
--- a/mysql-test/suite/versioning/r/create.result
+++ b/mysql-test/suite/versioning/r/create.result
@@ -592,3 +592,22 @@ t2 CREATE TEMPORARY TABLE `t2` (
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1
drop temporary table t2;
drop table t1;
+#
+# MDEV-16857 system-invisible row_end is displayed in SHOW INDEX
+#
+create or replace table t1 (id int primary key, x int) with system versioning;
+select table_schema, table_name, non_unique, index_schema, index_name, seq_in_index, column_name
+from information_schema.statistics where table_name = 't1';
+table_schema table_name non_unique index_schema index_name seq_in_index column_name
+test t1 0 test PRIMARY 1 id
+show index from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored
+t1 0 PRIMARY 1 id # # # # # # NO
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL,
+ `x` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
+drop table t1;
diff --git a/mysql-test/suite/versioning/r/partition.result b/mysql-test/suite/versioning/r/partition.result
index 2a277b1c2ea..d6e6d827ddc 100644
--- a/mysql-test/suite/versioning/r/partition.result
+++ b/mysql-test/suite/versioning/r/partition.result
@@ -1119,6 +1119,27 @@ create or replace table t1 (a int) with system versioning;
alter table t1 partition by system_time (partition pn current);
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
drop table t1;
+#
+# MDEV-22247 History partition overflow leads to wrong SELECT result
+#
+set timestamp= unix_timestamp('2000-01-01 00:00:00');
+create or replace table t1 (x int) with system versioning
+partition by system_time interval 1 hour
+(partition p0 history, partition p1 history, partition pn current);
+insert into t1 values (0);
+update t1 set x= x + 1;
+set timestamp= unix_timestamp('2000-01-01 02:00:01');
+update t1 set x= x + 1;
+select *, row_start, row_end from t1 for system_time as of '2000-01-01 02:00:00';
+x row_start row_end
+1 2000-01-01 00:00:00.000000 2000-01-01 02:00:01.000000
+explain partitions select * from t1 for system_time as of '2000-01-01 02:00:00';
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p1,pn ALL NULL NULL NULL NULL # Using where
+explain partitions select * from t1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 pn # NULL NULL NULL NULL # #
+drop table t1;
# End of 10.3 tests
#
# MDEV-22283 Server crashes in key_copy or unexpected error 156: The table already existed in the storage engine
diff --git a/mysql-test/suite/versioning/r/sysvars-notembedded.result b/mysql-test/suite/versioning/r/sysvars-notembedded.result
new file mode 100644
index 00000000000..8b1ad6cfc58
--- /dev/null
+++ b/mysql-test/suite/versioning/r/sysvars-notembedded.result
@@ -0,0 +1,30 @@
+create table t (a int) with system versioning;
+set @before= UNIX_TIMESTAMP(now(6));
+insert into t values (1);
+set @after= UNIX_TIMESTAMP(now(6));
+update t set a= 2;
+set global system_versioning_asof= FROM_UNIXTIME(@after);
+set system_versioning_asof= FROM_UNIXTIME(@after);
+select * from t as nonempty;
+a
+1
+connect subcon,127.0.0.1,root,,,$SERVER_MYPORT_1;
+connection subcon;
+select * from t as nonempty;
+a
+1
+disconnect subcon;
+connection default;
+set global system_versioning_asof= FROM_UNIXTIME(@before);
+select * from t as nonempty;
+a
+1
+connect subcon,127.0.0.1,root,,,$SERVER_MYPORT_1;
+connection subcon;
+select * from t as empty;
+a
+disconnect subcon;
+connection default;
+drop table t;
+set global system_versioning_asof= DEFAULT;
+set system_versioning_asof= DEFAULT;
diff --git a/mysql-test/suite/versioning/r/sysvars.result b/mysql-test/suite/versioning/r/sysvars.result
index 66513741631..a5a3f79990c 100644
--- a/mysql-test/suite/versioning/r/sysvars.result
+++ b/mysql-test/suite/versioning/r/sysvars.result
@@ -1,5 +1,7 @@
create table t (a int) with system versioning;
+set @before= UNIX_TIMESTAMP(now(6));
insert into t values (1);
+set @after= UNIX_TIMESTAMP(now(6));
update t set a= 2;
show global variables like 'system_versioning_asof';
Variable_name Value
@@ -56,65 +58,71 @@ ERROR 42000: Variable 'system_versioning_asof' can't be set to the value of '201
set system_versioning_asof= '0000-00-00 00:00';
ERROR 42000: Variable 'system_versioning_asof' can't be set to the value of '0000-00-00 00:00'
# GLOBAL @@system_versioning_asof
-set global system_versioning_asof= '1911-11-11 11:11:11.1111119';
+set global system_versioning_asof= '1991-11-11 11:11:11.1111119';
Warnings:
-Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
-Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
+Note 1292 Truncated incorrect datetime value: '1991-11-11 11:11:11.1111119'
show global variables like 'system_versioning_asof';
Variable_name Value
-system_versioning_asof 1911-11-11 11:11:11.111111
-set global system_versioning_asof= '1900-01-01 00:00:00';
+system_versioning_asof 1991-11-11 11:11:11.111111
+set global system_versioning_asof= '1990-01-01 00:00:00';
show global variables like 'system_versioning_asof';
Variable_name Value
-system_versioning_asof 1900-01-01 00:00:00.000000
-set global system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119';
+system_versioning_asof 1990-01-01 00:00:00.000000
+set global system_versioning_asof= timestamp'1991-11-11 11:11:11.1111119';
Warnings:
-Note 1292 Truncated incorrect DATETIME value: '1911-11-11 11:11:11.1111119'
+Note 1292 Truncated incorrect DATETIME value: '1991-11-11 11:11:11.1111119'
show global variables like 'system_versioning_asof';
Variable_name Value
-system_versioning_asof 1911-11-11 11:11:11.111111
-set @ts= timestamp'1900-01-01 00:00:00';
+system_versioning_asof 1991-11-11 11:11:11.111111
+set @ts= timestamp'1990-01-01 00:00:00';
set global system_versioning_asof= @ts;
show global variables like 'system_versioning_asof';
Variable_name Value
-system_versioning_asof 1900-01-01 00:00:00.000000
+system_versioning_asof 1990-01-01 00:00:00.000000
set global system_versioning_asof= default;
select @@global.system_versioning_asof;
@@global.system_versioning_asof
DEFAULT
# SESSION @@system_versioning_asof
-set system_versioning_asof= '1911-11-11 11:11:11.1111119';
+set system_versioning_asof= '1991-11-11 11:11:11.1111119';
Warnings:
-Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
-Note 1292 Truncated incorrect datetime value: '1911-11-11 11:11:11.1111119'
+Note 1292 Truncated incorrect datetime value: '1991-11-11 11:11:11.1111119'
show variables like 'system_versioning_asof';
Variable_name Value
-system_versioning_asof 1911-11-11 11:11:11.111111
-set system_versioning_asof= '1900-01-01 00:00:00';
+system_versioning_asof 1991-11-11 11:11:11.111111
+set system_versioning_asof= '1990-01-01 00:00:00';
show variables like 'system_versioning_asof';
Variable_name Value
-system_versioning_asof 1900-01-01 00:00:00.000000
-set system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119';
+system_versioning_asof 1990-01-01 00:00:00.000000
+set system_versioning_asof= timestamp'1991-11-11 11:11:11.1111119';
Warnings:
-Note 1292 Truncated incorrect DATETIME value: '1911-11-11 11:11:11.1111119'
+Note 1292 Truncated incorrect DATETIME value: '1991-11-11 11:11:11.1111119'
show variables like 'system_versioning_asof';
Variable_name Value
-system_versioning_asof 1911-11-11 11:11:11.111111
-set @ts= timestamp'1900-01-01 00:00:00';
+system_versioning_asof 1991-11-11 11:11:11.111111
+set @ts= timestamp'1990-01-01 00:00:00';
set system_versioning_asof= @ts;
show variables like 'system_versioning_asof';
Variable_name Value
-system_versioning_asof 1900-01-01 00:00:00.000000
+system_versioning_asof 1990-01-01 00:00:00.000000
# DEFAULT: value is copied from GLOBAL to SESSION
-set global system_versioning_asof= timestamp'1911-11-11 11:11:11.111111';
-set system_versioning_asof= '1900-01-01 00:00:00';
+set global time_zone= "+03:00";
+set time_zone= "+10:00";
+set global system_versioning_asof= timestamp'1991-11-11 11:11:11.111111';
+set system_versioning_asof= '1990-01-01 00:00:00';
select @@global.system_versioning_asof != @@system_versioning_asof as different;
different
1
set system_versioning_asof= default;
+select @@global.system_versioning_asof != @@system_versioning_asof as different;
+different
+1
+set global system_versioning_asof= default;
select @@global.system_versioning_asof = @@system_versioning_asof as equal;
equal
1
+set global time_zone= DEFAULT;
+set time_zone= DEFAULT;
set global system_versioning_asof= DEFAULT;
set system_versioning_asof= DEFAULT;
select @@global.system_versioning_asof, @@system_versioning_asof;
@@ -142,6 +150,56 @@ select * from t for system_time between '1970-01-01 00:00' and current_timestamp
a
2
1
+# MDEV-16026: Global system_versioning_asof must not be used if client sessions can have non-default time zone
+# changing time zone should not abuse `system_versioning_asof`
+set session time_zone = '+10:00';
+set global system_versioning_asof = '1999-09-08 00:00:00.000000';
+show global variables like 'system_versioning_asof';
+Variable_name Value
+system_versioning_asof 1999-09-08 00:00:00.000000
+set session time_zone = '+03:00';
+show global variables like 'system_versioning_asof';
+Variable_name Value
+system_versioning_asof 1999-09-07 17:00:00.000000
+set session time_zone = '+03:00';
+set session system_versioning_asof = '2000-09-08 00:00:00.000000';
+show session variables like 'system_versioning_asof';
+Variable_name Value
+system_versioning_asof 2000-09-08 00:00:00.000000
+set session time_zone = '+10:00';
+show session variables like 'system_versioning_asof';
+Variable_name Value
+system_versioning_asof 2000-09-08 07:00:00.000000
+# global and local time zones should not interfere
+show global variables like 'system_versioning_asof';
+Variable_name Value
+system_versioning_asof 1999-09-08 00:00:00.000000
+set time_zone= "+10:00";
+set system_versioning_asof= FROM_UNIXTIME(@before);
+select * from t as empty;
+a
+set system_versioning_asof= FROM_UNIXTIME(@after);
+select * from t as nonempty;
+a
+1
+set time_zone= "+03:00";
+set system_versioning_asof= FROM_UNIXTIME(@before);
+select * from t as empty;
+a
+set system_versioning_asof= FROM_UNIXTIME(@after);
+select * from t as nonempty;
+a
+1
+# MDEV-16481: set global system_versioning_asof=sf() crashes in specific case
+# Using global variable inside a stored function should not crash
+create or replace function now_global() returns timestamp
+return CONVERT_TZ(now(), @@session.time_zone, @@global.time_zone);
+set global system_versioning_asof= now_global();
+drop function now_global;
+set global time_zone= "SYSTEM";
+set time_zone= "SYSTEM";
+set global system_versioning_asof= default;
+set system_versioning_asof= default;
show status like "Feature_system_versioning";
Variable_name Value
Feature_system_versioning 2
@@ -153,7 +211,7 @@ create or replace table t1 (x int) with system versioning;
create or replace table t2 (y int);
insert into t1 values (1);
insert into t2 values (1);
-set system_versioning_asof= '1970-01-01 00:00:00';
+set system_versioning_asof= '1970-01-02 00:00:00';
delete t1, t2 from t1 join t2 where t1.x = t2.y;
select * from t1 for system_time as of timestamp now(6);
x
diff --git a/mysql-test/suite/versioning/t/create.test b/mysql-test/suite/versioning/t/create.test
index 62f09b255f2..9e20aff1dc7 100644
--- a/mysql-test/suite/versioning/t/create.test
+++ b/mysql-test/suite/versioning/t/create.test
@@ -442,3 +442,15 @@ show create table t2;
drop temporary table t2;
drop table t1;
--disable_prepare_warnings
+
+--echo #
+--echo # MDEV-16857 system-invisible row_end is displayed in SHOW INDEX
+--echo #
+create or replace table t1 (id int primary key, x int) with system versioning;
+select table_schema, table_name, non_unique, index_schema, index_name, seq_in_index, column_name
+from information_schema.statistics where table_name = 't1';
+--replace_column 6 # 7 # 8 # 9 # 10 # 11 #
+show index from t1;
+--replace_result $default_engine DEFAULT_ENGINE
+show create table t1;
+drop table t1;
diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test
index 006a65e1a16..61cfe702f8a 100644
--- a/mysql-test/suite/versioning/t/partition.test
+++ b/mysql-test/suite/versioning/t/partition.test
@@ -995,6 +995,27 @@ alter table t1 partition by system_time (partition pn current);
# Cleanup
drop table t1;
+--echo #
+--echo # MDEV-22247 History partition overflow leads to wrong SELECT result
+--echo #
+set timestamp= unix_timestamp('2000-01-01 00:00:00');
+create or replace table t1 (x int) with system versioning
+partition by system_time interval 1 hour
+(partition p0 history, partition p1 history, partition pn current);
+
+insert into t1 values (0);
+update t1 set x= x + 1;
+
+set timestamp= unix_timestamp('2000-01-01 02:00:01');
+update t1 set x= x + 1;
+
+select *, row_start, row_end from t1 for system_time as of '2000-01-01 02:00:00';
+--replace_column 10 #
+explain partitions select * from t1 for system_time as of '2000-01-01 02:00:00';
+--replace_column 5 # 10 # 11 #
+explain partitions select * from t1;
+drop table t1;
+
--echo # End of 10.3 tests
--echo #
diff --git a/mysql-test/suite/versioning/t/sysvars-notembedded.test b/mysql-test/suite/versioning/t/sysvars-notembedded.test
new file mode 100644
index 00000000000..314972bc375
--- /dev/null
+++ b/mysql-test/suite/versioning/t/sysvars-notembedded.test
@@ -0,0 +1,31 @@
+source include/not_embedded.inc;
+
+create table t (a int) with system versioning;
+set @before= UNIX_TIMESTAMP(now(6));
+insert into t values (1);
+set @after= UNIX_TIMESTAMP(now(6));
+update t set a= 2;
+
+set global system_versioning_asof= FROM_UNIXTIME(@after);
+set system_versioning_asof= FROM_UNIXTIME(@after);
+select * from t as nonempty;
+
+--connect (subcon,127.0.0.1,root,,,$SERVER_MYPORT_1)
+--connection subcon
+select * from t as nonempty;
+--disconnect subcon
+--connection default
+
+set global system_versioning_asof= FROM_UNIXTIME(@before);
+select * from t as nonempty;
+
+--connect (subcon,127.0.0.1,root,,,$SERVER_MYPORT_1)
+--connection subcon
+select * from t as empty;
+--disconnect subcon
+--connection default
+
+drop table t;
+
+set global system_versioning_asof= DEFAULT;
+set system_versioning_asof= DEFAULT;
diff --git a/mysql-test/suite/versioning/t/sysvars.test b/mysql-test/suite/versioning/t/sysvars.test
index 34c98c48ff7..91dd278a2e1 100644
--- a/mysql-test/suite/versioning/t/sysvars.test
+++ b/mysql-test/suite/versioning/t/sysvars.test
@@ -1,5 +1,7 @@
create table t (a int) with system versioning;
+set @before= UNIX_TIMESTAMP(now(6));
insert into t values (1);
+set @after= UNIX_TIMESTAMP(now(6));
update t set a= 2;
show global variables like 'system_versioning_asof';
@@ -51,18 +53,18 @@ set system_versioning_asof= '2011-00-28 00:00';
set system_versioning_asof= '0000-00-00 00:00';
--echo # GLOBAL @@system_versioning_asof
-set global system_versioning_asof= '1911-11-11 11:11:11.1111119';
+set global system_versioning_asof= '1991-11-11 11:11:11.1111119';
show global variables like 'system_versioning_asof';
-set global system_versioning_asof= '1900-01-01 00:00:00';
+set global system_versioning_asof= '1990-01-01 00:00:00';
show global variables like 'system_versioning_asof';
--enable_prepare_warnings
-set global system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119';
+set global system_versioning_asof= timestamp'1991-11-11 11:11:11.1111119';
--disable_prepare_warnings
show global variables like 'system_versioning_asof';
-set @ts= timestamp'1900-01-01 00:00:00';
+set @ts= timestamp'1990-01-01 00:00:00';
set global system_versioning_asof= @ts;
show global variables like 'system_versioning_asof';
@@ -70,28 +72,34 @@ set global system_versioning_asof= default;
select @@global.system_versioning_asof;
--echo # SESSION @@system_versioning_asof
-set system_versioning_asof= '1911-11-11 11:11:11.1111119';
+set system_versioning_asof= '1991-11-11 11:11:11.1111119';
show variables like 'system_versioning_asof';
-set system_versioning_asof= '1900-01-01 00:00:00';
+set system_versioning_asof= '1990-01-01 00:00:00';
show variables like 'system_versioning_asof';
--enable_prepare_warnings
-set system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119';
+set system_versioning_asof= timestamp'1991-11-11 11:11:11.1111119';
--disable_prepare_warnings
show variables like 'system_versioning_asof';
-set @ts= timestamp'1900-01-01 00:00:00';
+set @ts= timestamp'1990-01-01 00:00:00';
set system_versioning_asof= @ts;
show variables like 'system_versioning_asof';
--echo # DEFAULT: value is copied from GLOBAL to SESSION
-set global system_versioning_asof= timestamp'1911-11-11 11:11:11.111111';
-set system_versioning_asof= '1900-01-01 00:00:00';
+set global time_zone= "+03:00";
+set time_zone= "+10:00";
+set global system_versioning_asof= timestamp'1991-11-11 11:11:11.111111';
+set system_versioning_asof= '1990-01-01 00:00:00';
select @@global.system_versioning_asof != @@system_versioning_asof as different;
set system_versioning_asof= default;
+select @@global.system_versioning_asof != @@system_versioning_asof as different;
+set global system_versioning_asof= default;
select @@global.system_versioning_asof = @@system_versioning_asof as equal;
+set global time_zone= DEFAULT;
+set time_zone= DEFAULT;
set global system_versioning_asof= DEFAULT;
set system_versioning_asof= DEFAULT;
select @@global.system_versioning_asof, @@system_versioning_asof;
@@ -104,6 +112,47 @@ select * from t for system_time all;
select * from t for system_time from '1970-01-01 00:00' to current_timestamp(6);
select * from t for system_time between '1970-01-01 00:00' and current_timestamp(6);
+-- echo # MDEV-16026: Global system_versioning_asof must not be used if client sessions can have non-default time zone
+-- echo # changing time zone should not abuse `system_versioning_asof`
+
+set session time_zone = '+10:00';
+set global system_versioning_asof = '1999-09-08 00:00:00.000000';
+show global variables like 'system_versioning_asof';
+set session time_zone = '+03:00';
+show global variables like 'system_versioning_asof';
+
+set session time_zone = '+03:00';
+set session system_versioning_asof = '2000-09-08 00:00:00.000000';
+show session variables like 'system_versioning_asof';
+set session time_zone = '+10:00';
+show session variables like 'system_versioning_asof';
+-- echo # global and local time zones should not interfere
+show global variables like 'system_versioning_asof';
+
+set time_zone= "+10:00";
+set system_versioning_asof= FROM_UNIXTIME(@before);
+select * from t as empty;
+set system_versioning_asof= FROM_UNIXTIME(@after);
+select * from t as nonempty;
+
+set time_zone= "+03:00";
+set system_versioning_asof= FROM_UNIXTIME(@before);
+select * from t as empty;
+set system_versioning_asof= FROM_UNIXTIME(@after);
+select * from t as nonempty;
+
+--echo # MDEV-16481: set global system_versioning_asof=sf() crashes in specific case
+--echo # Using global variable inside a stored function should not crash
+create or replace function now_global() returns timestamp
+ return CONVERT_TZ(now(), @@session.time_zone, @@global.time_zone);
+set global system_versioning_asof= now_global();
+drop function now_global;
+
+set global time_zone= "SYSTEM";
+set time_zone= "SYSTEM";
+set global system_versioning_asof= default;
+set system_versioning_asof= default;
+
show status like "Feature_system_versioning";
drop table t;
@@ -115,7 +164,7 @@ create or replace table t1 (x int) with system versioning;
create or replace table t2 (y int);
insert into t1 values (1);
insert into t2 values (1);
-set system_versioning_asof= '1970-01-01 00:00:00';
+set system_versioning_asof= '1970-01-02 00:00:00';
delete t1, t2 from t1 join t2 where t1.x = t2.y;
select * from t1 for system_time as of timestamp now(6);
diff --git a/mysql-test/suite/wsrep/r/variables.result b/mysql-test/suite/wsrep/r/variables.result
index 73bb18bd214..82c480917f1 100644
--- a/mysql-test/suite/wsrep/r/variables.result
+++ b/mysql-test/suite/wsrep/r/variables.result
@@ -34,6 +34,7 @@ wsrep_cert_deps_distance #
wsrep_apply_oooe #
wsrep_apply_oool #
wsrep_apply_window #
+wsrep_apply_waits #
wsrep_commit_oooe #
wsrep_commit_oool #
wsrep_commit_window #
diff --git a/mysql-test/suite/wsrep/r/variables_debug.result b/mysql-test/suite/wsrep/r/variables_debug.result
index 921f262c59c..fe2bffb3f08 100644
--- a/mysql-test/suite/wsrep/r/variables_debug.result
+++ b/mysql-test/suite/wsrep/r/variables_debug.result
@@ -34,6 +34,7 @@ wsrep_cert_deps_distance #
wsrep_apply_oooe #
wsrep_apply_oool #
wsrep_apply_window #
+wsrep_apply_waits #
wsrep_commit_oooe #
wsrep_commit_oool #
wsrep_commit_window #
diff --git a/mysql-test/suite/wsrep/t/variables.test b/mysql-test/suite/wsrep/t/variables.test
index 249fba48d44..e40ac7b8772 100644
--- a/mysql-test/suite/wsrep/t/variables.test
+++ b/mysql-test/suite/wsrep/t/variables.test
@@ -3,7 +3,7 @@
--source include/have_innodb.inc
--source include/galera_no_debug_sync.inc
---let $galera_version=26.4.8
+--let $galera_version=26.4.9
source include/check_galera_version.inc;
source include/galera_variables_ok.inc;
diff --git a/mysql-test/suite/wsrep/t/variables_debug.test b/mysql-test/suite/wsrep/t/variables_debug.test
index c48c2d895b9..29747e48f18 100644
--- a/mysql-test/suite/wsrep/t/variables_debug.test
+++ b/mysql-test/suite/wsrep/t/variables_debug.test
@@ -5,7 +5,7 @@
--source include/have_debug_sync.inc
--source include/galera_have_debug_sync.inc
---let $galera_version=26.4.8
+--let $galera_version=26.4.9
source include/check_galera_version.inc;
source include/galera_variables_ok.inc;