summaryrefslogtreecommitdiff
path: root/mysql-test/suite/s3
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/suite/s3')
-rw-r--r--mysql-test/suite/s3/alter.result122
-rw-r--r--mysql-test/suite/s3/alter.test96
-rw-r--r--mysql-test/suite/s3/alter2.result22
-rw-r--r--mysql-test/suite/s3/alter2.test32
-rw-r--r--mysql-test/suite/s3/amazon.result7
-rw-r--r--mysql-test/suite/s3/amazon.test27
-rw-r--r--mysql-test/suite/s3/arguments.result58
-rw-r--r--mysql-test/suite/s3/arguments.test54
-rw-r--r--mysql-test/suite/s3/backup.result18
-rw-r--r--mysql-test/suite/s3/backup.test33
-rw-r--r--mysql-test/suite/s3/basic.result106
-rw-r--r--mysql-test/suite/s3/basic.test55
-rw-r--r--mysql-test/suite/s3/create_database.inc10
-rw-r--r--mysql-test/suite/s3/discovery.result57
-rw-r--r--mysql-test/suite/s3/discovery.test84
-rw-r--r--mysql-test/suite/s3/drop_database.inc9
-rw-r--r--mysql-test/suite/s3/encryption.opt4
-rw-r--r--mysql-test/suite/s3/encryption.result23
-rw-r--r--mysql-test/suite/s3/encryption.test36
-rw-r--r--mysql-test/suite/s3/innodb.result31
-rw-r--r--mysql-test/suite/s3/innodb.test35
-rw-r--r--mysql-test/suite/s3/my.cnf11
-rw-r--r--mysql-test/suite/s3/mysqldump.result60
-rw-r--r--mysql-test/suite/s3/mysqldump.test33
-rw-r--r--mysql-test/suite/s3/no_s3-master.opt1
-rw-r--r--mysql-test/suite/s3/no_s3.result13
-rw-r--r--mysql-test/suite/s3/no_s3.test25
-rw-r--r--mysql-test/suite/s3/partitions-master.opt1
-rw-r--r--mysql-test/suite/s3/partitions.result128
-rw-r--r--mysql-test/suite/s3/partitions.test113
-rw-r--r--mysql-test/suite/s3/select.result8
-rw-r--r--mysql-test/suite/s3/select.test17
-rw-r--r--mysql-test/suite/s3/suite.pm8
-rw-r--r--mysql-test/suite/s3/unsupported.result8
-rw-r--r--mysql-test/suite/s3/unsupported.test31
35 files changed, 1376 insertions, 0 deletions
diff --git a/mysql-test/suite/s3/alter.result b/mysql-test/suite/s3/alter.result
new file mode 100644
index 00000000000..0764d661468
--- /dev/null
+++ b/mysql-test/suite/s3/alter.result
@@ -0,0 +1,122 @@
+drop table if exists t1,t2,t3;
+#
+# Test ALTER TABLE to and from s3
+#
+create table t1 (a int, b int) engine=aria;
+insert into t1 select seq,seq+10 from seq_1_to_1000;
+alter table t1 engine=s3;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=S3 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+alter table t1 comment="hello";
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=S3 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 COMMENT='hello'
+alter table t1 engine=aria;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 COMMENT='hello'
+select count(*), sum(a), sum(b) from t1;
+count(*) sum(a) sum(b)
+1000 500500 510500
+drop table t1;
+#
+# Test ALTER TABLE to and from s3 with rename
+#
+create table t1 (a int, b int) engine=aria select seq as a,seq+10 as b from seq_1_to_10;
+alter table t1 rename to t2, engine=s3;
+select count(*), sum(a), sum(b) from t2;
+count(*) sum(a) sum(b)
+10 55 155
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=S3 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+alter table t2 rename to t3, engine=aria;
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+select count(*), sum(a), sum(b) from t3;
+count(*) sum(a) sum(b)
+10 55 155
+drop table t3;
+#
+# Test changing options for a s3 table
+#
+create table t1 (a int, b int) engine=aria select seq as a,seq+10 as b from seq_1_to_1000;
+alter table t1 engine=s3;
+alter table t1 engine=s3, compression_algorithm="zlib";
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=S3 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 `compression_algorithm`='zlib'
+select count(*), sum(a), sum(b) from t1;
+count(*) sum(a) sum(b)
+1000 500500 510500
+drop table t1;
+#
+# Test ALTER TABLE for S3
+#
+create table t1 (a int, b int) engine=aria select seq as a,seq+10 as b from seq_1_to_10;
+alter table t1 add column c int, engine=s3;
+alter table t1 add column d int;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ `d` int(11) DEFAULT NULL
+) ENGINE=S3 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+select count(*), sum(a), sum(b), sum(c), sum(d) from t1;
+count(*) sum(a) sum(b) sum(c) sum(d)
+10 55 155 NULL NULL
+drop table t1;
+#
+# Test ALTER TABLE with locked table for S3
+#
+create table t1 (a int, b int) engine=aria select seq as a,seq+10 as b from seq_1_to_10;
+lock table t1 write;
+alter table t1 add column c int, engine=s3;
+ERROR HY000: Table 't1' is read only
+unlock tables;
+select count(*), sum(a), sum(b), sum(c) from t1;
+count(*) sum(a) sum(b) sum(c)
+10 55 155 NULL
+lock table t1 write;
+ERROR HY000: Table 't1' is read only
+lock table t1 read;
+select count(*), sum(a), sum(b), sum(c) from t1;
+count(*) sum(a) sum(b) sum(c)
+10 55 155 NULL
+unlock tables;
+drop table t1;
+#
+# Test RENAME TABLE
+#
+create table t1 (a int, b int) engine=aria select seq as a, seq+10 as b from seq_1_to_10;
+alter table t1 engine=s3;
+rename table t1 to t3;
+alter table t3 rename t2;
+select count(*), sum(a), sum(b) from t2;
+count(*) sum(a) sum(b)
+10 55 155
+select count(*), sum(a), sum(b) from t1;
+ERROR 42S02: Table 'database.t1' doesn't exist
+drop table t2;
diff --git a/mysql-test/suite/s3/alter.test b/mysql-test/suite/s3/alter.test
new file mode 100644
index 00000000000..791d7750cb1
--- /dev/null
+++ b/mysql-test/suite/s3/alter.test
@@ -0,0 +1,96 @@
+--source include/have_s3.inc
+--source include/have_sequence.inc
+
+#
+# Create unique database for running the tests
+#
+--source create_database.inc
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
+--echo #
+--echo # Test ALTER TABLE to and from s3
+--echo #
+
+create table t1 (a int, b int) engine=aria;
+insert into t1 select seq,seq+10 from seq_1_to_1000;
+alter table t1 engine=s3;
+show create table t1;
+alter table t1 comment="hello";
+show create table t1;
+alter table t1 engine=aria;
+show create table t1;
+select count(*), sum(a), sum(b) from t1;
+drop table t1;
+
+--echo #
+--echo # Test ALTER TABLE to and from s3 with rename
+--echo #
+
+create table t1 (a int, b int) engine=aria select seq as a,seq+10 as b from seq_1_to_10;
+alter table t1 rename to t2, engine=s3;
+select count(*), sum(a), sum(b) from t2;
+show create table t2;
+alter table t2 rename to t3, engine=aria;
+show create table t3;
+select count(*), sum(a), sum(b) from t3;
+drop table t3;
+
+--echo #
+--echo # Test changing options for a s3 table
+--echo #
+
+create table t1 (a int, b int) engine=aria select seq as a,seq+10 as b from seq_1_to_1000;
+alter table t1 engine=s3;
+alter table t1 engine=s3, compression_algorithm="zlib";
+show create table t1;
+select count(*), sum(a), sum(b) from t1;
+drop table t1;
+
+--echo #
+--echo # Test ALTER TABLE for S3
+--echo #
+
+create table t1 (a int, b int) engine=aria select seq as a,seq+10 as b from seq_1_to_10;
+alter table t1 add column c int, engine=s3;
+alter table t1 add column d int;
+show create table t1;
+select count(*), sum(a), sum(b), sum(c), sum(d) from t1;
+drop table t1;
+
+--echo #
+--echo # Test ALTER TABLE with locked table for S3
+--echo #
+
+create table t1 (a int, b int) engine=aria select seq as a,seq+10 as b from seq_1_to_10;
+lock table t1 write;
+--error ER_OPEN_AS_READONLY
+alter table t1 add column c int, engine=s3;
+unlock tables;
+select count(*), sum(a), sum(b), sum(c) from t1;
+--error ER_OPEN_AS_READONLY
+lock table t1 write;
+lock table t1 read;
+select count(*), sum(a), sum(b), sum(c) from t1;
+unlock tables;
+drop table t1;
+
+--echo #
+--echo # Test RENAME TABLE
+--echo #
+
+create table t1 (a int, b int) engine=aria select seq as a, seq+10 as b from seq_1_to_10;
+alter table t1 engine=s3;
+rename table t1 to t3;
+alter table t3 rename t2;
+select count(*), sum(a), sum(b) from t2;
+--replace_result $database database
+--error ER_NO_SUCH_TABLE
+select count(*), sum(a), sum(b) from t1;
+drop table t2;
+
+#
+# clean up
+#
+--source drop_database.inc
diff --git a/mysql-test/suite/s3/alter2.result b/mysql-test/suite/s3/alter2.result
new file mode 100644
index 00000000000..d2849905c67
--- /dev/null
+++ b/mysql-test/suite/s3/alter2.result
@@ -0,0 +1,22 @@
+#
+# MDEV-19575 Assertion `page_st == 1' failed upon SELECT from S3
+# table which is being converted into Aria
+#
+CREATE TABLE t1 (f INT);
+insert into t1 values (1),(2);
+ALTER TABLE t1 ENGINE=S3;
+select * from t1;
+f
+1
+2
+connect con1,localhost,root,,$database;
+ALTER TABLE t1 ENGINE=Aria;
+connection default;
+SELECT * FROM t1;
+f
+1
+2
+connection con1;
+disconnect con1;
+connection default;
+DROP TABLE t1;
diff --git a/mysql-test/suite/s3/alter2.test b/mysql-test/suite/s3/alter2.test
new file mode 100644
index 00000000000..de2bc001298
--- /dev/null
+++ b/mysql-test/suite/s3/alter2.test
@@ -0,0 +1,32 @@
+--source include/have_s3.inc
+--source create_database.inc
+
+--echo #
+--echo # MDEV-19575 Assertion `page_st == 1' failed upon SELECT from S3
+--echo # table which is being converted into Aria
+--echo #
+
+CREATE TABLE t1 (f INT);
+insert into t1 values (1),(2);
+
+ALTER TABLE t1 ENGINE=S3;
+select * from t1;
+--connect (con1,localhost,root,,$database)
+--send
+ ALTER TABLE t1 ENGINE=Aria;
+
+--connection default
+SELECT * FROM t1;
+
+# Cleanup
+
+--connection con1
+--reap
+--disconnect con1
+--connection default
+DROP TABLE t1;
+
+#
+# clean up
+#
+--source drop_database.inc
diff --git a/mysql-test/suite/s3/amazon.result b/mysql-test/suite/s3/amazon.result
new file mode 100644
index 00000000000..29075118a63
--- /dev/null
+++ b/mysql-test/suite/s3/amazon.result
@@ -0,0 +1,7 @@
+set @save_s3_protocol_version=@@global.s3_protocol_version;
+set @@global.s3_protocol_version="Original";
+create table t1 (pk int primary key, a int);
+insert into t1 values (1,1),(2,2),(3,3),(4,4);
+alter table t1 engine=S3;
+drop table t1;
+set @@global.s3_protocol_version=@save_s3_protocol_version;
diff --git a/mysql-test/suite/s3/amazon.test b/mysql-test/suite/s3/amazon.test
new file mode 100644
index 00000000000..3c64cc2841b
--- /dev/null
+++ b/mysql-test/suite/s3/amazon.test
@@ -0,0 +1,27 @@
+--source include/have_s3.inc
+
+if (`SELECT @@s3_host_name <> "s3.amazonaws.com"`)
+{
+ skip Not connected to AWS;
+}
+
+--source create_database.inc
+
+#
+# Check options against amazon
+#
+
+set @save_s3_protocol_version=@@global.s3_protocol_version;
+set @@global.s3_protocol_version="Original";
+
+create table t1 (pk int primary key, a int);
+insert into t1 values (1,1),(2,2),(3,3),(4,4);
+--replace_result $database database
+alter table t1 engine=S3;
+drop table t1;
+
+#
+# clean up
+#
+set @@global.s3_protocol_version=@save_s3_protocol_version;
+--source drop_database.inc
diff --git a/mysql-test/suite/s3/arguments.result b/mysql-test/suite/s3/arguments.result
new file mode 100644
index 00000000000..4a371aabc9b
--- /dev/null
+++ b/mysql-test/suite/s3/arguments.result
@@ -0,0 +1,58 @@
+drop table if exists t1;
+#
+# Test options
+#
+create or replace table t1 (a int, b int, key(a)) engine=aria;
+insert into t1 select seq,seq+10 from seq_1_to_10;
+alter table t1 engine=s3, s3_block_size=819200, compression_algorithm="zlib";
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY `a` (`a`)
+) ENGINE=S3 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 `s3_block_size`=819200 `compression_algorithm`='zlib'
+alter table t1 engine=s3, s3_block_size=8192;
+ERROR HY000: Incorrect value '8192' for option 's3_block_size'
+alter table t1 engine=s3, s3_block_size=65536;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY `a` (`a`)
+) ENGINE=S3 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 `compression_algorithm`='zlib' `s3_block_size`=65536
+alter table t1 engine=s3, s3_block_size=100000;
+ERROR HY000: Incorrect value '100000' for option 's3_block_size'
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY `a` (`a`)
+) ENGINE=S3 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 `compression_algorithm`='zlib' `s3_block_size`=65536
+alter table t1 engine=s3, compression_algorithm="wss";
+ERROR HY000: Incorrect value 'wss' for option 'compression_algorithm'
+drop table t1;
+# Check that key variables are not shown to the end user
+show variables like "s3%key";
+Variable_name Value
+s3_access_key *****
+s3_secret_key *****
+# Show some "static" s3 variables
+set @tmp= @@global.s3_block_size;
+show variables like "s3_block_size";
+Variable_name Value
+s3_block_size 4194304
+set @@global.s3_block_size=65536;
+show variables like "s3_block_size";
+Variable_name Value
+s3_block_size 65536
+set @@global.s3_block_size= @tmp;
+set @@s3_block_size=65536;
+ERROR HY000: Variable 's3_block_size' is a GLOBAL variable and should be set with SET GLOBAL
+# Check s3 variables that can't be changed by end user
+set @@s3_access_key="abc";
+ERROR HY000: Variable 's3_access_key' is a read only variable
+set @@s3_secret_key="abc";
+ERROR HY000: Variable 's3_secret_key' is a read only variable
diff --git a/mysql-test/suite/s3/arguments.test b/mysql-test/suite/s3/arguments.test
new file mode 100644
index 00000000000..76ef4c960dd
--- /dev/null
+++ b/mysql-test/suite/s3/arguments.test
@@ -0,0 +1,54 @@
+--source include/have_s3.inc
+--source include/have_sequence.inc
+
+#
+# Create unique database for running the tests
+#
+--source create_database.inc
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+--echo #
+--echo # Test options
+--echo #
+
+create or replace table t1 (a int, b int, key(a)) engine=aria;
+insert into t1 select seq,seq+10 from seq_1_to_10;
+alter table t1 engine=s3, s3_block_size=819200, compression_algorithm="zlib";
+show create table t1;
+--error ER_BAD_OPTION_VALUE
+alter table t1 engine=s3, s3_block_size=8192;
+alter table t1 engine=s3, s3_block_size=65536;
+show create table t1;
+--error ER_BAD_OPTION_VALUE
+alter table t1 engine=s3, s3_block_size=100000;
+show create table t1;
+--error ER_BAD_OPTION_VALUE
+alter table t1 engine=s3, compression_algorithm="wss";
+drop table t1;
+
+--echo # Check that key variables are not shown to the end user
+
+show variables like "s3%key";
+
+--echo # Show some "static" s3 variables
+set @tmp= @@global.s3_block_size;
+show variables like "s3_block_size";
+set @@global.s3_block_size=65536;
+show variables like "s3_block_size";
+set @@global.s3_block_size= @tmp;
+--error ER_GLOBAL_VARIABLE
+set @@s3_block_size=65536;
+
+--echo # Check s3 variables that can't be changed by end user
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+set @@s3_access_key="abc";
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+set @@s3_secret_key="abc";
+
+#
+# clean up
+#
+--source drop_database.inc
diff --git a/mysql-test/suite/s3/backup.result b/mysql-test/suite/s3/backup.result
new file mode 100644
index 00000000000..55065d7baa8
--- /dev/null
+++ b/mysql-test/suite/s3/backup.result
@@ -0,0 +1,18 @@
+#
+# MDEV-19585 Assertion `!is_set() || (m_status == DA_OK_BULK &&
+# is_bulk_op())' failed upon SELECT from S3 table with concurrent
+# BACKUP stage
+#
+CREATE TABLE t1 (a INT);
+ALTER TABLE t1 ENGINE=S3;
+connect con1,localhost,root,,test;
+BACKUP STAGE START;
+connection default;
+SELECT * FROM t1;
+connection con1;
+BACKUP STAGE BLOCK_COMMIT;
+BACKUP STAGE END;
+disconnect con1;
+connection default;
+a
+DROP TABLE t1;
diff --git a/mysql-test/suite/s3/backup.test b/mysql-test/suite/s3/backup.test
new file mode 100644
index 00000000000..06f61429707
--- /dev/null
+++ b/mysql-test/suite/s3/backup.test
@@ -0,0 +1,33 @@
+--source include/have_s3.inc
+--source create_database.inc
+
+--echo #
+--echo # MDEV-19585 Assertion `!is_set() || (m_status == DA_OK_BULK &&
+--echo # is_bulk_op())' failed upon SELECT from S3 table with concurrent
+--echo # BACKUP stage
+--echo #
+
+CREATE TABLE t1 (a INT);
+ALTER TABLE t1 ENGINE=S3;
+
+--connect (con1,localhost,root,,test)
+BACKUP STAGE START;
+
+--connection default
+--send
+SELECT * FROM t1;
+
+--connection con1
+BACKUP STAGE BLOCK_COMMIT;
+
+# Cleanup
+BACKUP STAGE END;
+--disconnect con1
+--connection default
+--reap
+DROP TABLE t1;
+
+#
+# clean up
+#
+--source drop_database.inc
diff --git a/mysql-test/suite/s3/basic.result b/mysql-test/suite/s3/basic.result
new file mode 100644
index 00000000000..94fe14ab989
--- /dev/null
+++ b/mysql-test/suite/s3/basic.result
@@ -0,0 +1,106 @@
+drop table if exists t1;
+#
+# Test simple create of s3 table
+#
+create or replace table t1 (a int, b int, key (a)) engine=aria;
+insert into t1 select seq,seq+10 from seq_1_to_10000;
+alter table t1 engine=s3;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY `a` (`a`)
+) ENGINE=S3 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+select * from information_schema.tables where table_schema="database" and table_name="t1";;
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT MAX_INDEX_LENGTH TEMPORARY
+def # t1 BASE TABLE S3 10 Page 10000 33 335872 # 122880 0 NULL # # # latin1_swedish_ci NULL page_checksum=1 9007199254732800 #
+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 S3 10 Page 10000 33 335872 # 122880 0 NULL # # # latin1_swedish_ci NULL page_checksum=1 # N
+select * from t1 limit 10;
+a b
+1 11
+2 12
+3 13
+4 14
+5 15
+6 16
+7 17
+8 18
+9 19
+10 20
+select count(*) from t1;
+count(*)
+10000
+select * from t1 where a between 10 and 20;
+a b
+10 20
+11 21
+12 22
+13 23
+14 24
+15 25
+16 26
+17 27
+18 28
+19 29
+20 30
+explain select * from t1 where a between 10 and 20;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL # Using index condition
+insert into t1 values (1,1);
+ERROR HY000: Table 't1' is read only
+update t1 set b=100 where a=1;
+ERROR HY000: Table 't1' is read only
+delete from t1 where a>10;
+ERROR HY000: Table 't1' is read only
+alter table t1 engine=aria;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY `a` (`a`)
+) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+select * from t1 limit 10;
+a b
+1 11
+2 12
+3 13
+4 14
+5 15
+6 16
+7 17
+8 18
+9 19
+10 20
+select count(*) from t1;
+count(*)
+10000
+delete from t1 where a=1;
+drop table t1;
+#
+# status
+#
+show variables like "s3%";
+Variable_name Value
+s3_access_key X
+s3_block_size X
+s3_bucket X
+s3_debug X
+s3_host_name X
+s3_pagecache_age_threshold X
+s3_pagecache_buffer_size X
+s3_pagecache_division_limit X
+s3_pagecache_file_hash_size X
+s3_protocol_version X
+s3_region X
+s3_secret_key X
+show status like "s3%";
+Variable_name Value
+S3_pagecache_blocks_not_flushed X
+S3_pagecache_blocks_unused X
+S3_pagecache_blocks_used X
+S3_pagecache_read_requests X
+S3_pagecache_reads X
diff --git a/mysql-test/suite/s3/basic.test b/mysql-test/suite/s3/basic.test
new file mode 100644
index 00000000000..f3f53a55a1c
--- /dev/null
+++ b/mysql-test/suite/s3/basic.test
@@ -0,0 +1,55 @@
+--source include/have_s3.inc
+--source include/have_sequence.inc
+
+#
+# Create unique database for running the tests
+#
+--source create_database.inc
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+--echo #
+--echo # Test simple create of s3 table
+--echo #
+
+create or replace table t1 (a int, b int, key (a)) engine=aria;
+insert into t1 select seq,seq+10 from seq_1_to_10000;
+alter table t1 engine=s3;
+show create table t1;
+
+--replace_column 2 # 11 # 15 # 16 # 17 # 23 #
+--replace_result $database database
+--eval select * from information_schema.tables where table_schema="$database" and table_name="t1";
+--replace_column 8 # 12 # 13 # 14 # 19 #
+show table status like "t1";
+select * from t1 limit 10;
+select count(*) from t1;
+select * from t1 where a between 10 and 20;
+--replace_column 9 #
+explain select * from t1 where a between 10 and 20;
+--error ER_OPEN_AS_READONLY
+insert into t1 values (1,1);
+--error ER_OPEN_AS_READONLY
+update t1 set b=100 where a=1;
+--error ER_OPEN_AS_READONLY
+delete from t1 where a>10;
+alter table t1 engine=aria;
+show create table t1;
+select * from t1 limit 10;
+select count(*) from t1;
+delete from t1 where a=1;
+drop table t1;
+
+--echo #
+--echo # status
+--echo #
+
+--replace_column 2 X
+show variables like "s3%";
+--replace_column 2 X
+show status like "s3%";
+#
+# clean up
+#
+--source drop_database.inc
diff --git a/mysql-test/suite/s3/create_database.inc b/mysql-test/suite/s3/create_database.inc
new file mode 100644
index 00000000000..880cdd3a8d5
--- /dev/null
+++ b/mysql-test/suite/s3/create_database.inc
@@ -0,0 +1,10 @@
+#
+# Create unique database to not conflict with concurrently running tests as
+# the s3 database is shared
+#
+
+let $database=`select concat("s3_test_",replace(uuid(),"-",""))`;
+--disable_query_log
+--eval create database $database;
+--eval use $database;
+--enable_query_log
diff --git a/mysql-test/suite/s3/discovery.result b/mysql-test/suite/s3/discovery.result
new file mode 100644
index 00000000000..abc97867e89
--- /dev/null
+++ b/mysql-test/suite/s3/discovery.result
@@ -0,0 +1,57 @@
+drop table if exists t1,t2;
+#
+# Test discovery of s3
+#
+create table t1 (a int, b int) engine=aria select seq as a, seq+10 as b from seq_1_to_10;
+alter table t1 engine=s3;
+#
+# Check discovery by select
+#
+flush tables;
+select * from t1 limit 1;
+a b
+1 11
+#
+# Check if changes to .frm is copied to S3
+#
+alter table t1 change column b c int not null;
+flush tables;
+select * from t1 limit 1;
+a c
+1 11
+#
+# Check if SHOW TABLES finds the S3 tables
+#
+create table t2 (a int, b int) engine=aria select seq as a, seq+10 as b from seq_1_to_10;
+alter table t2 engine=s3;
+flush tables;
+SHOW TABLES;
+Tables_in_database
+t1
+t2
+drop table t2;
+#
+# Check if DROP TABLE works with discovery
+#
+select count(*) from t1;
+count(*)
+10
+flush tables;
+drop table t1;
+select count(*), sum(a) from t1;
+ERROR 42S02: Table 'database.t1' doesn't exist
+#
+# Check if S3 detects that the .frm is too old
+#
+create table t1 (a int, b int) engine=aria select seq as a, seq+10 as b from seq_1_to_10;
+alter table t1 engine=s3;
+alter table t1 add column c int, engine=s3;
+flush tables;
+select * from t1 limit 1;
+a b c
+1 11 NULL
+flush tables;
+select * from t1 limit 1;
+a b c
+1 11 NULL
+drop table t1;
diff --git a/mysql-test/suite/s3/discovery.test b/mysql-test/suite/s3/discovery.test
new file mode 100644
index 00000000000..b85776acac5
--- /dev/null
+++ b/mysql-test/suite/s3/discovery.test
@@ -0,0 +1,84 @@
+--source include/have_s3.inc
+--source include/have_sequence.inc
+
+#
+# Create unique database for running the tests
+#
+--source create_database.inc
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+let $datadir=`select @@datadir`;
+
+--echo #
+--echo # Test discovery of s3
+--echo #
+
+create table t1 (a int, b int) engine=aria select seq as a, seq+10 as b from seq_1_to_10;
+alter table t1 engine=s3;
+
+--echo #
+--echo # Check discovery by select
+--echo #
+
+--remove_file $datadir/$database/t1.frm
+flush tables;
+select * from t1 limit 1;
+
+--echo #
+--echo # Check if changes to .frm is copied to S3
+--echo #
+
+alter table t1 change column b c int not null;
+flush tables;
+--remove_file $datadir/$database/t1.frm
+select * from t1 limit 1;
+
+--echo #
+--echo # Check if SHOW TABLES finds the S3 tables
+--echo #
+
+create table t2 (a int, b int) engine=aria select seq as a, seq+10 as b from seq_1_to_10;
+alter table t2 engine=s3;
+
+flush tables;
+--remove_file $datadir/$database/t1.frm
+--replace_result $database database
+SHOW TABLES;
+drop table t2;
+
+--echo #
+--echo # Check if DROP TABLE works with discovery
+--echo #
+
+select count(*) from t1;
+flush tables;
+--remove_file $datadir/$database/t1.frm
+drop table t1;
+--replace_result $database database
+--error ER_NO_SUCH_TABLE
+select count(*), sum(a) from t1;
+
+--echo #
+--echo # Check if S3 detects that the .frm is too old
+--echo #
+
+create table t1 (a int, b int) engine=aria select seq as a, seq+10 as b from seq_1_to_10;
+alter table t1 engine=s3;
+--copy_file $datadir/$database/t1.frm $datadir/$database/t1.frm-old
+alter table t1 add column c int, engine=s3;
+flush tables;
+--remove_file $datadir/$database/t1.frm
+--copy_file $datadir/$database/t1.frm-old $datadir/$database/t1.frm
+--remove_file $datadir/$database/t1.frm-old
+select * from t1 limit 1;
+flush tables;
+--remove_file $datadir/$database/t1.frm
+select * from t1 limit 1;
+drop table t1;
+
+#
+# clean up
+#
+--source drop_database.inc
diff --git a/mysql-test/suite/s3/drop_database.inc b/mysql-test/suite/s3/drop_database.inc
new file mode 100644
index 00000000000..a5425f4ed47
--- /dev/null
+++ b/mysql-test/suite/s3/drop_database.inc
@@ -0,0 +1,9 @@
+
+#
+# Drop database created by the s3 tests
+#
+
+--disable_query_log
+use test;
+--eval drop database $database;
+--enable_query_log
diff --git a/mysql-test/suite/s3/encryption.opt b/mysql-test/suite/s3/encryption.opt
new file mode 100644
index 00000000000..8f13b08c5c4
--- /dev/null
+++ b/mysql-test/suite/s3/encryption.opt
@@ -0,0 +1,4 @@
+--plugin-load-add=$FILE_KEY_MANAGEMENT_SO
+--aria-encrypt-tables=1
+--loose-file-key-management
+--loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys.txt
diff --git a/mysql-test/suite/s3/encryption.result b/mysql-test/suite/s3/encryption.result
new file mode 100644
index 00000000000..c60490d342a
--- /dev/null
+++ b/mysql-test/suite/s3/encryption.result
@@ -0,0 +1,23 @@
+#
+# MDEV-20306
+# Assertion `!(end_of_data > info->scan.dir_end)' failed in
+# _ma_scan_block_record upon converting table from S3 to Aria
+# with encryption enabled
+#
+drop table if exists t1;
+CREATE TABLE t1 (a INT) ENGINE=Aria;
+INSERT INTO t1 VALUES (1);
+ALTER TABLE t1 ENGINE=S3;
+select * from t1;
+a
+1
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=S3 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+ALTER TABLE t1 ENGINE=Aria;
+select * from t1;
+a
+1
+DROP TABLE t1;
diff --git a/mysql-test/suite/s3/encryption.test b/mysql-test/suite/s3/encryption.test
new file mode 100644
index 00000000000..82434627309
--- /dev/null
+++ b/mysql-test/suite/s3/encryption.test
@@ -0,0 +1,36 @@
+--source include/have_s3.inc
+
+if (`SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'file_key_management' AND PLUGIN_STATUS='ACTIVE'`)
+{
+ --skip Test requires file_key_management plugin
+}
+
+#
+# Create unique database for running the tests
+#
+--source create_database.inc
+
+--echo #
+--echo # MDEV-20306
+--echo # Assertion `!(end_of_data > info->scan.dir_end)' failed in
+--echo # _ma_scan_block_record upon converting table from S3 to Aria
+--echo # with encryption enabled
+--echo #
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT) ENGINE=Aria;
+INSERT INTO t1 VALUES (1);
+ALTER TABLE t1 ENGINE=S3;
+select * from t1;
+show create table t1;
+ALTER TABLE t1 ENGINE=Aria;
+select * from t1;
+DROP TABLE t1;
+
+#
+# clean up
+#
+--source drop_database.inc
diff --git a/mysql-test/suite/s3/innodb.result b/mysql-test/suite/s3/innodb.result
new file mode 100644
index 00000000000..eaa9cf93c86
--- /dev/null
+++ b/mysql-test/suite/s3/innodb.result
@@ -0,0 +1,31 @@
+drop table if exists t1,t2,t3;
+#
+# Test ALTER TABLE to and from s3
+#
+create table t1 (a int, b int) engine=innodb;
+insert into t1 select seq,seq+10 from seq_1_to_1000;
+alter table t1 engine=s3;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=S3 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+alter table t1 comment="hello";
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=S3 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 COMMENT='hello'
+alter table t1 engine=innodb;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 COMMENT='hello'
+select count(*), sum(a), sum(b) from t1;
+count(*) sum(a) sum(b)
+1000 500500 510500
+drop table t1;
diff --git a/mysql-test/suite/s3/innodb.test b/mysql-test/suite/s3/innodb.test
new file mode 100644
index 00000000000..e2687064bdb
--- /dev/null
+++ b/mysql-test/suite/s3/innodb.test
@@ -0,0 +1,35 @@
+--source include/have_s3.inc
+--source include/have_sequence.inc
+--source include/have_innodb.inc
+
+#
+# Testing converting InnoDB tables to S3
+#
+
+#
+# Create unique database for running the tests
+#
+--source create_database.inc
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
+--echo #
+--echo # Test ALTER TABLE to and from s3
+--echo #
+
+create table t1 (a int, b int) engine=innodb;
+insert into t1 select seq,seq+10 from seq_1_to_1000;
+alter table t1 engine=s3;
+show create table t1;
+alter table t1 comment="hello";
+show create table t1;
+alter table t1 engine=innodb;
+show create table t1;
+select count(*), sum(a), sum(b) from t1;
+drop table t1;
+
+#
+# clean up
+#
+--source drop_database.inc
diff --git a/mysql-test/suite/s3/my.cnf b/mysql-test/suite/s3/my.cnf
new file mode 100644
index 00000000000..1958a04343f
--- /dev/null
+++ b/mysql-test/suite/s3/my.cnf
@@ -0,0 +1,11 @@
+!include include/default_mysqld.cnf
+!include include/default_client.cnf
+
+[mysqld.1]
+s3=ON
+#s3-host-name=s3.amazonaws.com
+#s3-protocol-version=Amazon
+#s3-bucket=MariaDB
+#s3-access-key=...
+#s3-secret-key=...
+#s3-region=eu-north-1
diff --git a/mysql-test/suite/s3/mysqldump.result b/mysql-test/suite/s3/mysqldump.result
new file mode 100644
index 00000000000..995cbf5bc63
--- /dev/null
+++ b/mysql-test/suite/s3/mysqldump.result
@@ -0,0 +1,60 @@
+create table t1 (pk int primary key, a int);
+insert into t1 values (1,1),(2,2),(3,3),(4,4);
+alter table t1 engine=S3;
+#####
+# mysqldump with --copy-s3-tables=0 (by default)
+###
+#####
+# mysqldump with --copy-s3-tables=0 (by default) XML
+###
+<?xml version="1.0"?>
+<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<database name="database">
+</database>
+</mysqldump>
+#####
+# mysqldump with --copy-s3-tables=1
+###
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `t1` (
+ `pk` int(11) NOT NULL,
+ `a` int(11) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+INSERT INTO `t1` VALUES (1,1),(2,2),(3,3),(4,4);
+ATER TABLE `t1` ENGINE=S3;
+#####
+# mysqldump with --copy-s3-tables=1 XML
+###
+<?xml version="1.0"?>
+<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<database name="database">
+ <table_structure name="t1">
+ <field Field="pk" Type="int(11)" Null="NO" Key="PRI" Extra="" Comment="" />
+ <field Field="a" Type="int(11)" Null="YES" Key="" Default="NULL" Extra="" Comment="" />
+ <key Table="t1" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="pk" Collation="A" Cardinality="4" Null="" Index_type="BTREE" Comment="" Index_comment="" />
+ <options Name="t1" Engine="Aria" Version="10" Row_format="Page" Rows="4" Avg_row_length="4096" Data_length="16384" Max_data_length="17592186011648" Index_length="16384" Data_free="0" Create_time="--TIME--" Collation="latin1_swedish_ci" Create_options="" Comment="" Max_index_length="9007199254732800" Temporary="N" />
+ </table_structure>
+ <table_data name="t1">
+ <row>
+ <field name="pk">1</field>
+ <field name="a">1</field>
+ </row>
+ <row>
+ <field name="pk">2</field>
+ <field name="a">2</field>
+ </row>
+ <row>
+ <field name="pk">3</field>
+ <field name="a">3</field>
+ </row>
+ <row>
+ <field name="pk">4</field>
+ <field name="a">4</field>
+ </row>
+ </table_data>
+</database>
+</mysqldump>
+drop table t1;
diff --git a/mysql-test/suite/s3/mysqldump.test b/mysql-test/suite/s3/mysqldump.test
new file mode 100644
index 00000000000..83d2310d636
--- /dev/null
+++ b/mysql-test/suite/s3/mysqldump.test
@@ -0,0 +1,33 @@
+--source include/have_s3.inc
+--source create_database.inc
+
+create table t1 (pk int primary key, a int);
+insert into t1 values (1,1),(2,2),(3,3),(4,4);
+alter table t1 engine=S3;
+
+--echo #####
+--echo # mysqldump with --copy-s3-tables=0 (by default)
+--echo ###
+--exec $MYSQL_DUMP --compact $database
+--echo #####
+--echo # mysqldump with --copy-s3-tables=0 (by default) XML
+--echo ###
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.[0-9]{2})*/--TIME--/
+--replace_result $database database
+--exec $MYSQL_DUMP --compact -X $database
+--echo #####
+--echo # mysqldump with --copy-s3-tables=1
+--echo ###
+--exec $MYSQL_DUMP --compact --copy-s3-tables=1 $database
+--echo #####
+--echo # mysqldump with --copy-s3-tables=1 XML
+--echo ###
+--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.[0-9]{2})*/--TIME--/
+--replace_result $database database
+--exec $MYSQL_DUMP --compact --copy-s3-tables=1 -X $database
+
+drop table t1;
+#
+# clean up
+#
+--source drop_database.inc
diff --git a/mysql-test/suite/s3/no_s3-master.opt b/mysql-test/suite/s3/no_s3-master.opt
new file mode 100644
index 00000000000..ad13d335ae9
--- /dev/null
+++ b/mysql-test/suite/s3/no_s3-master.opt
@@ -0,0 +1 @@
+--s3-bucket=storage-engine --s3-access-key="" --s3-secret-key="" --s3-region=eu-north-1
diff --git a/mysql-test/suite/s3/no_s3.result b/mysql-test/suite/s3/no_s3.result
new file mode 100644
index 00000000000..89ab3ea97a1
--- /dev/null
+++ b/mysql-test/suite/s3/no_s3.result
@@ -0,0 +1,13 @@
+create table t1 (a int, b int) engine=aria select seq,seq+10 from seq_1_to_2;
+alter table t1 engine=s3;
+ERROR HY000: Can't create table `test`.`t1` (errno: 138 "Unsupported extension used for table")
+drop table t1;
+select * from s3_unique_table;
+ERROR 42000: Table 's3_unique_table' uses an extension that doesn't exist in this MariaDB version
+truncate table s3_unique_table;
+ERROR 42000: Table 's3_unique_table' uses an extension that doesn't exist in this MariaDB version
+rename table s3_unique_table to t1;
+ERROR HY000: Error on rename of './test/s3_unique_table' to './test/t1' (errno: 138 "Unsupported extension used for table")
+drop table s3_unique_table;
+Warnings:
+Warning 1112 Table 's3_unique_table' uses an extension that doesn't exist in this MariaDB version
diff --git a/mysql-test/suite/s3/no_s3.test b/mysql-test/suite/s3/no_s3.test
new file mode 100644
index 00000000000..6c5df76bfa3
--- /dev/null
+++ b/mysql-test/suite/s3/no_s3.test
@@ -0,0 +1,25 @@
+--source include/have_sequence.inc
+
+let $datadir=`select @@datadir`;
+
+if (`select @@global.s3_secret_key <> "" or @@global.s3_access_key <> ""`)
+{
+ skip S3 engine options given (probably from command line);
+}
+
+#
+# Test what happens when we don't have s3 enabled
+#
+create table t1 (a int, b int) engine=aria select seq,seq+10 from seq_1_to_2;
+--error ER_CANT_CREATE_TABLE
+alter table t1 engine=s3;
+drop table t1;
+
+--copy_file std_data/s3_unique_table.frm $datadir/test/s3_unique_table.frm
+--error ER_UNSUPPORTED_EXTENSION
+select * from s3_unique_table;
+--error ER_UNSUPPORTED_EXTENSION
+truncate table s3_unique_table;
+--error ER_ERROR_ON_RENAME
+rename table s3_unique_table to t1;
+drop table s3_unique_table;
diff --git a/mysql-test/suite/s3/partitions-master.opt b/mysql-test/suite/s3/partitions-master.opt
new file mode 100644
index 00000000000..bbb6d7f9ff4
--- /dev/null
+++ b/mysql-test/suite/s3/partitions-master.opt
@@ -0,0 +1 @@
+--loose-partition
diff --git a/mysql-test/suite/s3/partitions.result b/mysql-test/suite/s3/partitions.result
new file mode 100644
index 00000000000..c7f9a9d8cc7
--- /dev/null
+++ b/mysql-test/suite/s3/partitions.result
@@ -0,0 +1,128 @@
+# Test for COALESCE PARTITION, ALTER TABLE and ADD PARTITIONS
+# for tables with HASH partitions
+CREATE TABLE t1 (
+c1 INT DEFAULT NULL
+) ENGINE=Aria
+PARTITION BY HASH (c1)
+PARTITIONS 3;
+INSERT INTO t1 VALUE (1), (2), (101), (102), (201), (202);
+ALTER TABLE t1 ENGINE=S3;
+SELECT count(*) FROM t1;
+count(*)
+6
+ALTER TABLE t1 COALESCE PARTITION 2;
+ERROR HY000: Storage engine S3 of the table `s3`.`t1` doesn't have this option
+ALTER TABLE t1 ADD PARTITION PARTITIONS 6;
+ERROR HY000: Storage engine S3 of the table `s3`.`t1` doesn't have this option
+SELECT count(*) FROM t1;
+count(*)
+6
+ALTER TABLE t1 ADD COLUMN c INT;
+SELECT count(*) FROM t1;
+count(*)
+6
+DROP TABLE t1;
+# Test for simple change engine to S3
+CREATE TABLE t1 (
+c1 int DEFAULT NULL,
+c2 int DEFAULT NULL
+) ENGINE=Aria
+PARTITION BY RANGE (c1)
+SUBPARTITION BY HASH(c2)
+SUBPARTITIONS 2
+(PARTITION p0 VALUES LESS THAN (100),
+PARTITION p1 VALUES LESS THAN (200),
+PARTITION p3 VALUES LESS THAN (300));
+INSERT INTO t1 VALUE (1,1), (2,2), (101,101), (102,102), (201,201), (202,202);
+ALTER TABLE t1 ENGINE=S3;
+SELECT count(*) FROM t1;
+count(*)
+6
+# Test for rename table
+RENAME TABLE t1 TO t2;
+SELECT count(*) FROM t2;
+count(*)
+6
+# Test for TRUNCATE, ANALYZE, CHECK, REBUILD, OPTIMIZE, REPAIR,
+# ADD, DROP, REORGANIZE partition
+ALTER TABLE t2 TRUNCATE PARTITION p3;
+ERROR HY000: Table 't2' is read only
+ALTER TABLE t2 ANALYZE PARTITION p3;
+Table Op Msg_type Msg_text
+s3.t2 analyze error Table 's3.t2' is read only
+SELECT count(*) FROM t2;
+count(*)
+6
+ALTER TABLE t2 CHECK PARTITION p3;
+Table Op Msg_type Msg_text
+s3.t2 check error Subpartition p3sp0 returned error
+s3.t2 check error Unknown - internal error 131 during operation
+SELECT count(*) FROM t2;
+count(*)
+6
+ALTER TABLE t2 REBUILD PARTITION p0, p1;
+ERROR HY000: Storage engine S3 of the table `s3`.`t2` doesn't have this option
+ALTER TABLE t2 OPTIMIZE PARTITION p0, p1;
+Table Op Msg_type Msg_text
+s3.t2 optimize Error Table 't2' is read only
+s3.t2 optimize status Operation failed
+SELECT count(*) FROM t2;
+count(*)
+6
+ALTER TABLE t2 REPAIR PARTITION p0, p1;
+Table Op Msg_type Msg_text
+s3.t2 repair Error Table 't2' is read only
+s3.t2 repair status Operation failed
+SELECT count(*) FROM t2;
+count(*)
+6
+ALTER TABLE t2 ADD PARTITION (PARTITION p4 VALUES LESS THAN (400));
+ERROR HY000: Storage engine S3 of the table `s3`.`t2` doesn't have this option
+ALTER TABLE t2
+REORGANIZE PARTITION p3 INTO (
+PARTITION n0 VALUES LESS THAN (500),
+PARTITION n1 VALUES LESS THAN (600)
+);
+ERROR HY000: Storage engine S3 of the table `s3`.`t2` doesn't have this option
+ALTER TABLE t2 DROP PARTITION p3;
+SELECT count(*) from t2;
+count(*)
+4
+# Test for ALTER TABLE
+ALTER TABLE t2 ADD COLUMN c INT;
+SELECT count(*) FROM t2;
+count(*)
+4
+ALTER TABLE t2 DROP COLUMN c;
+SELECT count(*) FROM t2;
+count(*)
+4
+# Test for REMOVE PARTITIONING
+ALTER TABLE t2 REMOVE PARTITIONING;
+SELECT count(*) FROM t2;
+count(*)
+4
+DROP TABLE t2;
+# Test for EXCHANGE PARTITION
+CREATE TABLE t1 (
+c1 int DEFAULT NULL
+) ENGINE=Aria
+PARTITION BY RANGE (c1)
+(PARTITION p0 VALUES LESS THAN (100),
+PARTITION p1 VALUES LESS THAN (200));
+INSERT INTO t1 VALUE (1), (2), (101), (102);
+ALTER TABLE t1 ENGINE=S3;
+CREATE TABLE t_part (
+c1 int DEFAULT NULL
+) ENGINE=Aria;
+INSERT INTO t_part VALUE (120), (130), (140);
+ALTER TABLE t_part ENGINE=S3;
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t_part;
+SELECT count(*) FROM t_part;
+count(*)
+2
+SELECT count(*) FROM t1;
+count(*)
+5
+DROP TABLE t1;
+DROP TABLE t_part;
diff --git a/mysql-test/suite/s3/partitions.test b/mysql-test/suite/s3/partitions.test
new file mode 100644
index 00000000000..196a72e2826
--- /dev/null
+++ b/mysql-test/suite/s3/partitions.test
@@ -0,0 +1,113 @@
+--source include/have_partition.inc
+--source include/have_s3.inc
+--source create_database.inc
+
+
+--echo # Test for COALESCE PARTITION, ALTER TABLE and ADD PARTITIONS
+--echo # for tables with HASH partitions
+CREATE TABLE t1 (
+ c1 INT DEFAULT NULL
+) ENGINE=Aria
+ PARTITION BY HASH (c1)
+ PARTITIONS 3;
+INSERT INTO t1 VALUE (1), (2), (101), (102), (201), (202);
+ALTER TABLE t1 ENGINE=S3;
+SELECT count(*) FROM t1;
+--replace_result $database s3
+--error ER_ILLEGAL_HA
+ALTER TABLE t1 COALESCE PARTITION 2;
+--replace_result $database s3
+--error ER_ILLEGAL_HA
+ALTER TABLE t1 ADD PARTITION PARTITIONS 6;
+SELECT count(*) FROM t1;
+ALTER TABLE t1 ADD COLUMN c INT;
+SELECT count(*) FROM t1;
+DROP TABLE t1;
+
+--echo # Test for simple change engine to S3
+CREATE TABLE t1 (
+ c1 int DEFAULT NULL,
+ c2 int DEFAULT NULL
+) ENGINE=Aria
+ PARTITION BY RANGE (c1)
+ SUBPARTITION BY HASH(c2)
+ SUBPARTITIONS 2
+ (PARTITION p0 VALUES LESS THAN (100),
+ PARTITION p1 VALUES LESS THAN (200),
+ PARTITION p3 VALUES LESS THAN (300));
+
+INSERT INTO t1 VALUE (1,1), (2,2), (101,101), (102,102), (201,201), (202,202);
+ALTER TABLE t1 ENGINE=S3;
+SELECT count(*) FROM t1;
+
+--echo # Test for rename table
+RENAME TABLE t1 TO t2;
+SELECT count(*) FROM t2;
+
+--echo # Test for TRUNCATE, ANALYZE, CHECK, REBUILD, OPTIMIZE, REPAIR,
+--echo # ADD, DROP, REORGANIZE partition
+--error ER_OPEN_AS_READONLY
+ALTER TABLE t2 TRUNCATE PARTITION p3;
+--replace_result $database s3
+ALTER TABLE t2 ANALYZE PARTITION p3;
+SELECT count(*) FROM t2;
+--replace_result $database s3
+ALTER TABLE t2 CHECK PARTITION p3;
+SELECT count(*) FROM t2;
+--replace_result $database s3
+--error ER_ILLEGAL_HA
+ALTER TABLE t2 REBUILD PARTITION p0, p1;
+--replace_result $database s3
+ALTER TABLE t2 OPTIMIZE PARTITION p0, p1;
+SELECT count(*) FROM t2;
+--replace_result $database s3
+ALTER TABLE t2 REPAIR PARTITION p0, p1;
+SELECT count(*) FROM t2;
+--replace_result $database s3
+--error ER_ILLEGAL_HA
+ALTER TABLE t2 ADD PARTITION (PARTITION p4 VALUES LESS THAN (400));
+--replace_result $database s3
+--error ER_ILLEGAL_HA
+ALTER TABLE t2
+ REORGANIZE PARTITION p3 INTO (
+ PARTITION n0 VALUES LESS THAN (500),
+ PARTITION n1 VALUES LESS THAN (600)
+);
+ALTER TABLE t2 DROP PARTITION p3;
+SELECT count(*) from t2;
+
+--echo # Test for ALTER TABLE
+ALTER TABLE t2 ADD COLUMN c INT;
+SELECT count(*) FROM t2;
+ALTER TABLE t2 DROP COLUMN c;
+SELECT count(*) FROM t2;
+
+--echo # Test for REMOVE PARTITIONING
+ALTER TABLE t2 REMOVE PARTITIONING;
+SELECT count(*) FROM t2;
+DROP TABLE t2;
+
+--echo # Test for EXCHANGE PARTITION
+CREATE TABLE t1 (
+ c1 int DEFAULT NULL
+) ENGINE=Aria
+ PARTITION BY RANGE (c1)
+ (PARTITION p0 VALUES LESS THAN (100),
+ PARTITION p1 VALUES LESS THAN (200));
+INSERT INTO t1 VALUE (1), (2), (101), (102);
+ALTER TABLE t1 ENGINE=S3;
+CREATE TABLE t_part (
+ c1 int DEFAULT NULL
+) ENGINE=Aria;
+INSERT INTO t_part VALUE (120), (130), (140);
+ALTER TABLE t_part ENGINE=S3;
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t_part;
+SELECT count(*) FROM t_part;
+SELECT count(*) FROM t1;
+DROP TABLE t1;
+DROP TABLE t_part;
+
+#
+# clean up
+#
+--source drop_database.inc
diff --git a/mysql-test/suite/s3/select.result b/mysql-test/suite/s3/select.result
new file mode 100644
index 00000000000..94a6fdf12d6
--- /dev/null
+++ b/mysql-test/suite/s3/select.result
@@ -0,0 +1,8 @@
+create table t1 (pk int primary key, a int);
+insert into t1 values (1,1),(2,2),(3,3),(4,4);
+alter table t1 engine=S3;
+select a from t1 where pk in (2, 3);
+a
+2
+3
+drop table t1;
diff --git a/mysql-test/suite/s3/select.test b/mysql-test/suite/s3/select.test
new file mode 100644
index 00000000000..223311cb32b
--- /dev/null
+++ b/mysql-test/suite/s3/select.test
@@ -0,0 +1,17 @@
+--source include/have_s3.inc
+--source create_database.inc
+
+#
+# MDEV-19465 Server crashes in s3_block_read upon IN quer
+#
+
+create table t1 (pk int primary key, a int);
+insert into t1 values (1,1),(2,2),(3,3),(4,4);
+alter table t1 engine=S3;
+select a from t1 where pk in (2, 3);
+drop table t1;
+
+#
+# clean up
+#
+--source drop_database.inc
diff --git a/mysql-test/suite/s3/suite.pm b/mysql-test/suite/s3/suite.pm
new file mode 100644
index 00000000000..5bf1559ae97
--- /dev/null
+++ b/mysql-test/suite/s3/suite.pm
@@ -0,0 +1,8 @@
+package My::Suite::S3;
+
+@ISA = qw(My::Suite);
+
+return "Need S3 engine" unless $::mysqld_variables{'s3'} eq "ON";
+
+bless { };
+
diff --git a/mysql-test/suite/s3/unsupported.result b/mysql-test/suite/s3/unsupported.result
new file mode 100644
index 00000000000..4ced713f73f
--- /dev/null
+++ b/mysql-test/suite/s3/unsupported.result
@@ -0,0 +1,8 @@
+create sequence s1;
+alter table s1 engine=s3;
+ERROR HY000: Can't create table `database`.`s1` (errno: 138 "Unsupported extension used for table")
+drop sequence s1;
+create temporary table t1 (a int);
+alter table t1 engine=S3;
+ERROR HY000: Can't create table `database`.`t1` (errno: 131 "Command not supported by the engine")
+drop temporary table t1;
diff --git a/mysql-test/suite/s3/unsupported.test b/mysql-test/suite/s3/unsupported.test
new file mode 100644
index 00000000000..c2b2a89e424
--- /dev/null
+++ b/mysql-test/suite/s3/unsupported.test
@@ -0,0 +1,31 @@
+--source include/have_s3.inc
+--source create_database.inc
+
+#
+# Test unsupported features in S3
+#
+#
+
+#
+# MDEV-19463 Altering sequence to S3 leaves unremovable garbage behind
+#
+
+create sequence s1;
+--replace_result $database database
+--error ER_CANT_CREATE_TABLE
+alter table s1 engine=s3;
+drop sequence s1;
+
+#
+# MDEV-19461 Assertion failure upon altering temporary S3 table
+#
+
+create temporary table t1 (a int);
+--replace_result $database database
+--error ER_CANT_CREATE_TABLE
+alter table t1 engine=S3;
+drop temporary table t1;
+
+# clean up
+#
+--source drop_database.inc