summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rwxr-xr-xdebian/autobake-deb.sh3
-rw-r--r--extra/mariabackup/xtrabackup.cc2
-rw-r--r--include/mysql/service_wsrep.h3
-rw-r--r--mysql-test/main/create_drop_role.result9
-rw-r--r--mysql-test/main/create_drop_role.test11
-rw-r--r--mysql-test/main/derived_split_innodb.result41
-rw-r--r--mysql-test/main/derived_split_innodb.test29
-rw-r--r--mysql-test/main/loaddata.result50
-rw-r--r--mysql-test/main/loaddata.test45
-rw-r--r--mysql-test/main/log_slow.result37
-rw-r--r--mysql-test/main/log_slow.test40
-rw-r--r--mysql-test/main/sp.result33
-rw-r--r--mysql-test/main/sp.test41
-rw-r--r--mysql-test/main/union.result37
-rw-r--r--mysql-test/main/union.test30
-rw-r--r--mysql-test/main/view.result22
-rw-r--r--mysql-test/main/view.test23
-rw-r--r--mysql-test/suite/encryption/r/innodb-checksum-algorithm,32k.rdiff18
-rw-r--r--mysql-test/suite/encryption/r/innodb-checksum-algorithm,64k.rdiff18
-rw-r--r--mysql-test/suite/encryption/r/innodb-checksum-algorithm.result18
-rw-r--r--mysql-test/suite/encryption/r/innodb-compressed-blob.result2
-rw-r--r--mysql-test/suite/encryption/r/innodb-encryption-alter.result33
-rw-r--r--mysql-test/suite/encryption/t/innodb-encryption-alter.test13
-rw-r--r--mysql-test/suite/galera/disabled.def8
-rw-r--r--mysql-test/suite/galera/r/MW-336.result94
-rw-r--r--mysql-test/suite/galera/r/MW-86-wait1.result2
-rw-r--r--mysql-test/suite/galera/r/MW-86-wait8.result2
-rw-r--r--mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result44
-rw-r--r--mysql-test/suite/galera/r/galera_mdl_race.result16
-rw-r--r--mysql-test/suite/galera/r/galera_query_cache_sync_wait.result24
-rw-r--r--mysql-test/suite/galera/t/MW-336.test82
-rw-r--r--mysql-test/suite/galera/t/MW-388.test3
-rw-r--r--mysql-test/suite/galera/t/MW-86-wait1.test3
-rw-r--r--mysql-test/suite/galera/t/MW-86-wait8.test3
-rw-r--r--mysql-test/suite/galera/t/galera_mdl_race.test17
-rw-r--r--mysql-test/suite/galera/t/galera_query_cache_sync_wait.test13
-rw-r--r--mysql-test/suite/innodb/r/alter_table.result31
-rw-r--r--mysql-test/suite/innodb/r/innodb-alter-nullable.result154
-rw-r--r--mysql-test/suite/innodb/r/innodb-alter-timestamp.result5
-rw-r--r--mysql-test/suite/innodb/r/innodb-table-online.result7
-rw-r--r--mysql-test/suite/innodb/r/instant_alter_debug.result2
-rw-r--r--mysql-test/suite/innodb/t/alter_table.test37
-rw-r--r--mysql-test/suite/innodb/t/innodb-alter-nullable.test103
-rw-r--r--mysql-test/suite/innodb/t/innodb-alter-timestamp.test12
-rw-r--r--mysql-test/suite/innodb/t/innodb-table-online.test13
-rw-r--r--mysql-test/suite/innodb/t/instant_alter_debug.test2
-rw-r--r--mysql-test/suite/parts/r/partition_auto_increment_max.result7
-rw-r--r--mysql-test/suite/parts/t/partition_auto_increment_max.test12
-rw-r--r--mysql-test/suite/vcol/r/vcol_keys_myisam.result8
-rw-r--r--mysql-test/suite/vcol/t/vcol_keys_myisam.test10
-rw-r--r--sql/field.h45
-rw-r--r--sql/ha_partition.cc44
-rw-r--r--sql/handler.cc54
-rw-r--r--sql/mysqld.cc18
-rw-r--r--sql/opt_split.cc13
-rw-r--r--sql/sql_acl.cc12
-rw-r--r--sql/sql_admin.cc4
-rw-r--r--sql/sql_admin.h8
-rw-r--r--sql/sql_alter.h2
-rw-r--r--sql/sql_class.h10
-rw-r--r--sql/sql_cmd.h13
-rw-r--r--sql/sql_delete.cc8
-rw-r--r--sql/sql_derived.cc31
-rw-r--r--sql/sql_derived.h1
-rw-r--r--sql/sql_insert.cc5
-rw-r--r--sql/sql_lex.cc36
-rw-r--r--sql/sql_lex.h32
-rw-r--r--sql/sql_load.cc10
-rw-r--r--sql/sql_parse.cc58
-rw-r--r--sql/sql_plugin_services.ic1
-rw-r--r--sql/sql_prepare.cc22
-rw-r--r--sql/sql_select.cc7
-rw-r--r--sql/sql_select.h3
-rw-r--r--sql/sql_table.cc3
-rw-r--r--sql/sql_union.cc5
-rw-r--r--sql/sys_vars.cc93
-rw-r--r--sql/wsrep_dummy.cc8
-rw-r--r--sql/wsrep_thd.cc18
-rw-r--r--storage/innobase/btr/btr0cur.cc7
-rw-r--r--storage/innobase/buf/buf0buf.cc26
-rw-r--r--storage/innobase/fsp/fsp0fsp.cc3
-rw-r--r--storage/innobase/handler/ha_innodb.cc208
-rw-r--r--storage/innobase/handler/handler0alter.cc45
-rw-r--r--storage/innobase/include/ut0wqueue.h13
-rw-r--r--storage/innobase/ut/ut0wqueue.cc19
-rw-r--r--storage/myisam/ha_myisam.cc10
-rw-r--r--support-files/wsrep.cnf.sh4
-rw-r--r--win/packaging/create_msi.cmake5
89 files changed, 1632 insertions, 546 deletions
diff --git a/.gitignore b/.gitignore
index ec97b0c8ce5..fb0857c8c24 100644
--- a/.gitignore
+++ b/.gitignore
@@ -196,8 +196,8 @@ storage/rocksdb/ldb
storage/rocksdb/myrocks_hotbackup
storage/rocksdb/mysql_ldb
storage/rocksdb/myrocks_hotbackup
-storage/rocksdb/sst_dump
storage/rocksdb/rdb_source_revision.h
+storage/rocksdb/sst_dump
storage/tokudb/PerconaFT/buildheader/db.h
storage/tokudb/PerconaFT/buildheader/make_tdb
storage/tokudb/PerconaFT/buildheader/runcat.sh
diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh
index 6ef0cb33553..7d2301c7369 100755
--- a/debian/autobake-deb.sh
+++ b/debian/autobake-deb.sh
@@ -97,6 +97,9 @@ then
sed '/Package: mariadb-plugin-rocksdb/,/^$/d' -i debian/control
fi
+# Always remove aws plugin, see -DNOT_FOR_DISTRIBUTION in CMakeLists.txt
+sed '/Package: mariadb-plugin-aws-key-management-10.2/,/^$/d' -i debian/control
+
# Don't build cassandra package if thrift is not installed
if [[ ! -f /usr/local/include/thrift/Thrift.h && ! -f /usr/include/thrift/Thrift.h ]]
then
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index 00a9c4678f4..6213558bcb2 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -1583,7 +1583,7 @@ static const char *xb_server_default_groups[]={
static void print_version(void)
{
- msg("%s based on MariaDB server %s %s (%s)",
+ fprintf(stderr, "%s based on MariaDB server %s %s (%s)\n",
my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
}
diff --git a/include/mysql/service_wsrep.h b/include/mysql/service_wsrep.h
index 2df497ec149..c8b19587e9e 100644
--- a/include/mysql/service_wsrep.h
+++ b/include/mysql/service_wsrep.h
@@ -62,6 +62,7 @@ extern struct wsrep_service_st {
int (*wsrep_thd_retry_counter_func)(const MYSQL_THD thd);
bool (*wsrep_thd_ignore_table_func)(MYSQL_THD thd);
long long (*wsrep_thd_trx_seqno_func)(const MYSQL_THD thd);
+ void (*wsrep_thd_auto_increment_variables_func)(THD *thd, unsigned long long *offset, unsigned long long *increment);
my_bool (*wsrep_thd_is_aborting_func)(const MYSQL_THD thd);
void (*wsrep_set_data_home_dir_func)(const char *data_dir);
my_bool (*wsrep_thd_is_BF_func)(const MYSQL_THD thd, my_bool sync);
@@ -102,6 +103,7 @@ extern struct wsrep_service_st {
#define wsrep_thd_retry_counter(T) wsrep_service->wsrep_thd_retry_counter_func(T)
#define wsrep_thd_ignore_table(T) wsrep_service->wsrep_thd_ignore_table_func(T)
#define wsrep_thd_trx_seqno(T) wsrep_service->wsrep_thd_trx_seqno_func(T)
+#define wsrep_thd_auto_increment_variables(T,O,I) wsrep_service->wsrep_thd_auto_increment_variables_func(T,O,I)
#define wsrep_set_data_home_dir(A) wsrep_service->wsrep_set_data_home_dir_func(A)
#define wsrep_thd_is_BF(T,S) wsrep_service->wsrep_thd_is_BF_func(T,S)
#define wsrep_thd_is_aborting(T) wsrep_service->wsrep_thd_is_aborting_func(T)
@@ -138,6 +140,7 @@ extern "C" long long wsrep_xid_seqno(const struct xid_t* xid);
const unsigned char* wsrep_xid_uuid(const struct xid_t* xid);
extern "C" long long wsrep_thd_trx_seqno(const MYSQL_THD thd);
my_bool get_wsrep_recovery();
+void wsrep_thd_auto_increment_variables(THD *thd, unsigned long long *offset, unsigned long long *increment);
bool wsrep_thd_ignore_table(MYSQL_THD thd);
void wsrep_set_data_home_dir(const char *data_dir);
diff --git a/mysql-test/main/create_drop_role.result b/mysql-test/main/create_drop_role.result
index 498dd4c1c02..886dcfd0e72 100644
--- a/mysql-test/main/create_drop_role.result
+++ b/mysql-test/main/create_drop_role.result
@@ -77,3 +77,12 @@ Note 1976 Can't drop role 'role_1'; it doesn't exist
DROP ROLE role_1;
ERROR HY000: Operation DROP ROLE failed for 'role_1'
DROP USER u1@localhost;
+CREATE ROLE r;
+GRANT SHOW DATABASES ON *.* TO r;
+CREATE USER foo;
+CREATE USER bar;
+GRANT r TO foo;
+CREATE OR REPLACE USER foo IDENTIFIED WITH non_existing_plugin;
+ERROR HY000: Plugin 'non_existing_plugin' is not loaded
+DROP ROLE r;
+DROP USER bar;
diff --git a/mysql-test/main/create_drop_role.test b/mysql-test/main/create_drop_role.test
index be33083e6c4..11bc832c6e9 100644
--- a/mysql-test/main/create_drop_role.test
+++ b/mysql-test/main/create_drop_role.test
@@ -54,3 +54,14 @@ DROP ROLE IF EXISTS role_1;
DROP ROLE role_1;
DROP USER u1@localhost;
+
+# MDEV-17942
+CREATE ROLE r;
+GRANT SHOW DATABASES ON *.* TO r;
+CREATE USER foo;
+CREATE USER bar;
+GRANT r TO foo;
+--error ER_PLUGIN_IS_NOT_LOADED
+CREATE OR REPLACE USER foo IDENTIFIED WITH non_existing_plugin;
+DROP ROLE r;
+DROP USER bar;
diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result
index 5073aa84c13..e8f9df5f80d 100644
--- a/mysql-test/main/derived_split_innodb.result
+++ b/mysql-test/main/derived_split_innodb.result
@@ -100,3 +100,44 @@ id select_type table type possible_keys key key_len ref rows Extra
2 LATERAL DERIVED t1 eq_ref PRIMARY PRIMARY 4 test.t2.id 1
set join_cache_level=default;
DROP TABLE t1,t2;
+#
+# Bug mdev-18467: join of grouping view and a base table as inner operand
+# of left join with on condition containing impossible range
+#
+create table t1 (f1 int, f2 int, key(f2)) engine=InnoDB;
+insert into t1 values (3,33), (7,77), (1,11);
+create table t2 (f1 int, f2 int, primary key (f1)) engine=InnoDB;
+insert into t2 values (3,33), (9,99), (1,11);
+create view v1 as
+select f1, max(f2) as f2 from t2 group by f1;
+select t.f2
+from t1
+left join
+(v1 join t1 as t on v1.f1=t.f1 and t.f2 = null)
+on t1.f1=t.f1;
+f2
+NULL
+NULL
+NULL
+explain select t.f2
+from t1
+left join
+(v1 join t1 as t on v1.f1=t.f1 and t.f2 = null)
+on t1.f1=t.f1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t const f2 NULL NULL NULL 1 Impossible ON condition
+1 PRIMARY <derived2> const key1 NULL NULL NULL 1 Impossible ON condition
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3
+2 DERIVED t2 ALL PRIMARY NULL NULL NULL 3 Using temporary; Using filesort
+set statement optimizer_switch='split_materialized=off' for explain select t.f2
+from t1
+left join
+(v1 join t1 as t on v1.f1=t.f1 and t.f2 = null)
+on t1.f1=t.f1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t const f2 NULL NULL NULL 1 Impossible ON condition
+1 PRIMARY <derived3> const key1 NULL NULL NULL 1 Impossible ON condition
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3
+3 DERIVED t2 index NULL PRIMARY 4 NULL 3
+drop view v1;
+drop table t1,t2;
diff --git a/mysql-test/main/derived_split_innodb.test b/mysql-test/main/derived_split_innodb.test
index c3b3bcabede..1bf70cd8114 100644
--- a/mysql-test/main/derived_split_innodb.test
+++ b/mysql-test/main/derived_split_innodb.test
@@ -94,3 +94,32 @@ eval EXPLAIN $q;
set join_cache_level=default;
DROP TABLE t1,t2;
+
+--echo #
+--echo # Bug mdev-18467: join of grouping view and a base table as inner operand
+--echo # of left join with on condition containing impossible range
+--echo #
+
+create table t1 (f1 int, f2 int, key(f2)) engine=InnoDB;
+insert into t1 values (3,33), (7,77), (1,11);
+
+create table t2 (f1 int, f2 int, primary key (f1)) engine=InnoDB;
+insert into t2 values (3,33), (9,99), (1,11);
+
+create view v1 as
+ select f1, max(f2) as f2 from t2 group by f1;
+
+let $q=
+select t.f2
+ from t1
+ left join
+ (v1 join t1 as t on v1.f1=t.f1 and t.f2 = null)
+ on t1.f1=t.f1;
+
+eval $q;
+eval explain $q;
+eval set statement optimizer_switch='split_materialized=off' for explain $q;
+
+drop view v1;
+
+drop table t1,t2;
diff --git a/mysql-test/main/loaddata.result b/mysql-test/main/loaddata.result
index 4c5cee0aa25..b7d51a13c85 100644
--- a/mysql-test/main/loaddata.result
+++ b/mysql-test/main/loaddata.result
@@ -581,6 +581,56 @@ HEX(a)
C3A4
DROP TABLE t1;
#
+# MDEV-15744: Assertion `derived->table' failed in mysql_derived_merge_for_insert
+#
+create table t1 (a int, b int);
+CREATE OR REPLACE VIEW t2 AS SELECT * FROM t1;
+CREATE VIEW v2 AS SELECT * FROM t2;
+LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2
+FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
+select * from v2;
+a b
+2 2
+3 3
+4 4
+5 5
+6 6
+select * from t2;
+a b
+2 2
+3 3
+4 4
+5 5
+6 6
+DROP VIEW IF EXISTS v2,t2;
+DROP TABLE IF EXISTS t1;
+#
+# MDEV-15950: LOAD DATA INTO compex_view crashed
+#
+create table t1 (a int, b int);
+create table t0 (x int, y int);
+CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1,t0;
+CREATE VIEW v2 AS SELECT * FROM v1;
+LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v1
+FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
+ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD
+LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2
+FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
+ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD
+DROP VIEW IF EXISTS v2,v1;
+DROP TABLE IF EXISTS t1,t0;
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE(b));
+INSERT INTO t1 VALUES (1,1);
+CREATE TABLE t2 (c INT);
+CREATE VIEW v AS SELECT t1.* FROM t1 JOIN t2;
+SELECT a, b INTO OUTFILE '15645.data' FROM t1;
+LOAD DATA INFILE '15645.data' IGNORE INTO TABLE v (a,b);
+ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD
+LOAD DATA INFILE '15645.data' REPLACE INTO TABLE v (a,b);
+ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD
+drop table t1,t2;
+drop view v;
+#
# MDEV-15497 Wrong empty value in a GEOMETRY column on LOAD DATA
#
SET sql_mode='';
diff --git a/mysql-test/main/loaddata.test b/mysql-test/main/loaddata.test
index a283e64d473..8fb1877bbc5 100644
--- a/mysql-test/main/loaddata.test
+++ b/mysql-test/main/loaddata.test
@@ -677,6 +677,51 @@ LOAD DATA INFILE '../../std_data/loaddata/mdev-11631.txt' INTO TABLE t1 CHARACTE
SELECT HEX(a) FROM t1;
DROP TABLE t1;
+--echo #
+--echo # MDEV-15744: Assertion `derived->table' failed in mysql_derived_merge_for_insert
+--echo #
+
+create table t1 (a int, b int);
+CREATE OR REPLACE VIEW t2 AS SELECT * FROM t1;
+CREATE VIEW v2 AS SELECT * FROM t2;
+LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2
+ FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
+select * from v2;
+select * from t2;
+DROP VIEW IF EXISTS v2,t2;
+DROP TABLE IF EXISTS t1;
+
+--echo #
+--echo # MDEV-15950: LOAD DATA INTO compex_view crashed
+--echo #
+create table t1 (a int, b int);
+create table t0 (x int, y int);
+CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1,t0;
+CREATE VIEW v2 AS SELECT * FROM v1;
+
+--error ER_WRONG_USAGE
+LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v1
+FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
+
+--error ER_WRONG_USAGE
+LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2
+FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
+
+DROP VIEW IF EXISTS v2,v1;
+DROP TABLE IF EXISTS t1,t0;
+
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE(b));
+INSERT INTO t1 VALUES (1,1);
+CREATE TABLE t2 (c INT);
+CREATE VIEW v AS SELECT t1.* FROM t1 JOIN t2;
+SELECT a, b INTO OUTFILE '15645.data' FROM t1;
+--error ER_WRONG_USAGE
+LOAD DATA INFILE '15645.data' IGNORE INTO TABLE v (a,b);
+--error ER_WRONG_USAGE
+LOAD DATA INFILE '15645.data' REPLACE INTO TABLE v (a,b);
+drop table t1,t2;
+drop view v;
+
--echo #
--echo # MDEV-15497 Wrong empty value in a GEOMETRY column on LOAD DATA
diff --git a/mysql-test/main/log_slow.result b/mysql-test/main/log_slow.result
index 59149633b99..74a77e3f11d 100644
--- a/mysql-test/main/log_slow.result
+++ b/mysql-test/main/log_slow.result
@@ -77,3 +77,40 @@ set @@log_slow_filter=default;
set @@log_slow_verbosity=default;
set global log_output= default;
truncate mysql.slow_log;
+#
+# MDEV-18333 Slow_queries count doesn't increase when slow_query_log is turned off
+#
+SET SESSION slow_query_log=OFF;
+SET GLOBAL slow_query_log=OFF;
+SET long_query_time=0.1;
+# Although this query is disallowed by slow_query_log, it should still increment Slow_queries
+SELECT VARIABLE_VALUE INTO @global_slow_queries
+FROM INFORMATION_SCHEMA.GLOBAL_STATUS
+WHERE VARIABLE_NAME='SLOW_QUERIES';
+SELECT sleep(0.2) INTO @tmp FROM DUAL;
+SELECT
+CAST(VARIABLE_VALUE AS UNSIGNED)-@global_slow_queries AS Slow_queries_increment
+FROM
+INFORMATION_SCHEMA.GLOBAL_STATUS
+WHERE
+VARIABLE_NAME='SLOW_QUERIES';
+Slow_queries_increment
+0
+# Although this query is disallowed by log_slow_filter, it should still increment Slow_queries
+SET log_slow_filter=filesort;
+SELECT sleep(0.2) INTO @tmp FROM DUAL;
+SELECT VARIABLE_VALUE INTO @global_slow_queries
+FROM INFORMATION_SCHEMA.GLOBAL_STATUS
+WHERE VARIABLE_NAME='SLOW_QUERIES';
+SELECT sleep(0.2) INTO @tmp FROM DUAL;
+SELECT
+CAST(VARIABLE_VALUE AS UNSIGNED)-@global_slow_queries AS Slow_queries_increment
+FROM
+INFORMATION_SCHEMA.GLOBAL_STATUS
+WHERE
+VARIABLE_NAME='SLOW_QUERIES';
+Slow_queries_increment
+0
+SET log_slow_filter=DEFAULT;
+SET @@long_query_time=default;
+SET GLOBAL slow_query_log= @org_slow_query_log;
diff --git a/mysql-test/main/log_slow.test b/mysql-test/main/log_slow.test
index 56e35bd5a20..edb1865b5ae 100644
--- a/mysql-test/main/log_slow.test
+++ b/mysql-test/main/log_slow.test
@@ -58,3 +58,43 @@ set @@log_slow_filter=default;
set @@log_slow_verbosity=default;
set global log_output= default;
truncate mysql.slow_log;
+
+--echo #
+--echo # MDEV-18333 Slow_queries count doesn't increase when slow_query_log is turned off
+--echo #
+
+SET SESSION slow_query_log=OFF;
+SET GLOBAL slow_query_log=OFF;
+SET long_query_time=0.1;
+
+--echo # Although this query is disallowed by slow_query_log, it should still increment Slow_queries
+
+SELECT VARIABLE_VALUE INTO @global_slow_queries
+ FROM INFORMATION_SCHEMA.GLOBAL_STATUS
+ WHERE VARIABLE_NAME='SLOW_QUERIES';
+SELECT sleep(0.2) INTO @tmp FROM DUAL;
+SELECT
+ CAST(VARIABLE_VALUE AS UNSIGNED)-@global_slow_queries AS Slow_queries_increment
+ FROM
+ INFORMATION_SCHEMA.GLOBAL_STATUS
+ WHERE
+ VARIABLE_NAME='SLOW_QUERIES';
+
+--echo # Although this query is disallowed by log_slow_filter, it should still increment Slow_queries
+
+SET log_slow_filter=filesort;
+SELECT sleep(0.2) INTO @tmp FROM DUAL;
+SELECT VARIABLE_VALUE INTO @global_slow_queries
+ FROM INFORMATION_SCHEMA.GLOBAL_STATUS
+ WHERE VARIABLE_NAME='SLOW_QUERIES';
+SELECT sleep(0.2) INTO @tmp FROM DUAL;
+SELECT
+ CAST(VARIABLE_VALUE AS UNSIGNED)-@global_slow_queries AS Slow_queries_increment
+ FROM
+ INFORMATION_SCHEMA.GLOBAL_STATUS
+ WHERE
+ VARIABLE_NAME='SLOW_QUERIES';
+SET log_slow_filter=DEFAULT;
+
+SET @@long_query_time=default;
+SET GLOBAL slow_query_log= @org_slow_query_log;
diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result
index 39bc09e21d6..62663c7e91b 100644
--- a/mysql-test/main/sp.result
+++ b/mysql-test/main/sp.result
@@ -7906,6 +7906,39 @@ CALL sp;
c a b a b
DROP PROCEDURE sp;
DROP TABLE t1;
+#
+# MDEV-17055: Server crashes in find_order_in_list upon
+# 2nd (3rd) execution of SP with UPDATE
+#
+CREATE TABLE t1 (a INT);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (c INT);
+CREATE PROCEDURE sp() UPDATE v1 SET a = 1 ORDER BY a, b LIMIT 1;
+LOCK TABLE t2 READ;
+CALL sp;
+ERROR HY000: Table 'v1' was not locked with LOCK TABLES
+UNLOCK TABLES;
+CALL sp;
+ERROR 42S22: Unknown column 'b' in 'order clause'
+CALL sp;
+ERROR 42S22: Unknown column 'b' in 'order clause'
+CALL sp;
+ERROR 42S22: Unknown column 'b' in 'order clause'
+DROP PROCEDURE sp;
+CREATE PROCEDURE sp() UPDATE v1 SET a = 1 WHERE a=1 and b=2;
+LOCK TABLE t2 READ;
+CALL sp;
+ERROR HY000: Table 'v1' was not locked with LOCK TABLES
+UNLOCK TABLES;
+CALL sp;
+ERROR 42S22: Unknown column 'b' in 'where clause'
+CALL sp;
+ERROR 42S22: Unknown column 'b' in 'where clause'
+CALL sp;
+ERROR 42S22: Unknown column 'b' in 'where clause'
+DROP PROCEDURE sp;
+DROP VIEW v1;
+DROP TABLE t1, t2;
# End of 5.5 test
#
# MDEV-7040: Crash in field_conv, memcpy_field_possible, part#2
diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test
index 230e9c8bb18..1000f172931 100644
--- a/mysql-test/main/sp.test
+++ b/mysql-test/main/sp.test
@@ -9352,6 +9352,47 @@ CALL sp;
DROP PROCEDURE sp;
DROP TABLE t1;
+--echo #
+--echo # MDEV-17055: Server crashes in find_order_in_list upon
+--echo # 2nd (3rd) execution of SP with UPDATE
+--echo #
+
+CREATE TABLE t1 (a INT);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (c INT);
+
+CREATE PROCEDURE sp() UPDATE v1 SET a = 1 ORDER BY a, b LIMIT 1;
+LOCK TABLE t2 READ;
+--error ER_TABLE_NOT_LOCKED
+CALL sp;
+UNLOCK TABLES;
+--error ER_BAD_FIELD_ERROR
+CALL sp;
+--error ER_BAD_FIELD_ERROR
+CALL sp;
+--error ER_BAD_FIELD_ERROR
+CALL sp;
+
+# Cleanup
+DROP PROCEDURE sp;
+
+CREATE PROCEDURE sp() UPDATE v1 SET a = 1 WHERE a=1 and b=2;
+LOCK TABLE t2 READ;
+--error ER_TABLE_NOT_LOCKED
+CALL sp;
+UNLOCK TABLES;
+--error ER_BAD_FIELD_ERROR
+CALL sp;
+--error ER_BAD_FIELD_ERROR
+CALL sp;
+--error ER_BAD_FIELD_ERROR
+CALL sp;
+
+# Cleanup
+DROP PROCEDURE sp;
+
+DROP VIEW v1;
+DROP TABLE t1, t2;
--echo # End of 5.5 test
diff --git a/mysql-test/main/union.result b/mysql-test/main/union.result
index e975e0f8591..ce14b68ae2d 100644
--- a/mysql-test/main/union.result
+++ b/mysql-test/main/union.result
@@ -2583,5 +2583,42 @@ c1
-10
drop table t1,t2;
#
+# MDEV-18700: EXPLAIN EXTENDED for query with UNION ALL
+# after INTERSECT/EXCEPT operations
+#
+create table t1 (a int);
+insert into t1 values (3), (1), (7), (3), (2), (7), (4);
+create table t2 (a int);
+insert into t2 values (4), (5), (9), (1), (8), (9);
+create table t3 (a int);
+insert into t3 values (8), (1), (8), (2), (3), (7), (2);
+explain extended
+select * from t2 where a < 5
+intersect
+select * from t3 where a < 5
+union all
+select * from t1 where a > 4;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where
+2 INTERSECT t3 ALL NULL NULL NULL NULL 7 100.00 Using where
+3 UNION t1 ALL NULL NULL NULL NULL 7 100.00 Using where
+NULL UNIT RESULT <unit1,2,3> ALL NULL NULL NULL NULL NULL NULL
+Warnings:
+Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where `test`.`t2`.`a` < 5 intersect /* select#2 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` where `test`.`t3`.`a` < 5 union all /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` > 4
+explain extended
+select * from t2 where a < 5
+except
+select * from t3 where a < 5
+union all
+select * from t1 where a > 4;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where
+2 EXCEPT t3 ALL NULL NULL NULL NULL 7 100.00 Using where
+3 UNION t1 ALL NULL NULL NULL NULL 7 100.00 Using where
+NULL UNIT RESULT <unit1,2,3> ALL NULL NULL NULL NULL NULL NULL
+Warnings:
+Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where `test`.`t2`.`a` < 5 except /* select#2 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` where `test`.`t3`.`a` < 5 union all /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` > 4
+drop table t1,t2,t3;
+#
# End of 10.3 tests
#
diff --git a/mysql-test/main/union.test b/mysql-test/main/union.test
index dc9a4617fb3..9d25708611e 100644
--- a/mysql-test/main/union.test
+++ b/mysql-test/main/union.test
@@ -1822,5 +1822,35 @@ SELECT c1 FROM t1 UNION SELECT - @a FROM t2;
drop table t1,t2;
--echo #
+--echo # MDEV-18700: EXPLAIN EXTENDED for query with UNION ALL
+--echo # after INTERSECT/EXCEPT operations
+--echo #
+
+create table t1 (a int);
+insert into t1 values (3), (1), (7), (3), (2), (7), (4);
+
+create table t2 (a int);
+insert into t2 values (4), (5), (9), (1), (8), (9);
+
+create table t3 (a int);
+insert into t3 values (8), (1), (8), (2), (3), (7), (2);
+
+explain extended
+select * from t2 where a < 5
+intersect
+select * from t3 where a < 5
+union all
+select * from t1 where a > 4;
+
+explain extended
+select * from t2 where a < 5
+except
+select * from t3 where a < 5
+union all
+select * from t1 where a > 4;
+
+drop table t1,t2,t3;
+
+--echo #
--echo # End of 10.3 tests
--echo #
diff --git a/mysql-test/main/view.result b/mysql-test/main/view.result
index bbe1d9b69d7..fccec1a5ef3 100644
--- a/mysql-test/main/view.result
+++ b/mysql-test/main/view.result
@@ -6717,5 +6717,27 @@ drop table t1;
ALTER VIEW IF NOT EXISTS v1 AS SELECT 1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'IF NOT EXISTS v1 AS SELECT 1' at line 1
#
+# MDEV-18605: Loss of column aliases by using view and group
+#
+CREATE TABLE t1 (id int, foo int);
+CREATE VIEW v1 AS SELECT id, IFNULL(foo,'') AS foo FROM t1;
+INSERT INTO t1 (id, foo) VALUES (1,1),(2,2);
+SELECT v.id, v.foo AS bar FROM v1 v
+WHERE id = 2;
+id bar
+2 2
+SELECT v.id, v.foo AS bar FROM v1 v
+GROUP BY v.id;
+id bar
+1 1
+2 2
+SELECT v.id, v.foo AS bar FROM v1 v
+WHERE id = 2
+GROUP BY v.id;
+id bar
+2 2
+Drop View v1;
+Drop table t1;
+#
# End of 10.3 tests
#
diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test
index f5590e01639..94036273ce1 100644
--- a/mysql-test/main/view.test
+++ b/mysql-test/main/view.test
@@ -6416,5 +6416,28 @@ drop table t1;
ALTER VIEW IF NOT EXISTS v1 AS SELECT 1;
--echo #
+--echo # MDEV-18605: Loss of column aliases by using view and group
+--echo #
+
+CREATE TABLE t1 (id int, foo int);
+CREATE VIEW v1 AS SELECT id, IFNULL(foo,'') AS foo FROM t1;
+
+INSERT INTO t1 (id, foo) VALUES (1,1),(2,2);
+
+SELECT v.id, v.foo AS bar FROM v1 v
+ WHERE id = 2;
+
+SELECT v.id, v.foo AS bar FROM v1 v
+ GROUP BY v.id;
+
+SELECT v.id, v.foo AS bar FROM v1 v
+ WHERE id = 2
+ GROUP BY v.id;
+
+#Cleanup
+Drop View v1;
+Drop table t1;
+
+--echo #
--echo # End of 10.3 tests
--echo #
diff --git a/mysql-test/suite/encryption/r/innodb-checksum-algorithm,32k.rdiff b/mysql-test/suite/encryption/r/innodb-checksum-algorithm,32k.rdiff
index cd66df7440b..d963cde132a 100644
--- a/mysql-test/suite/encryption/r/innodb-checksum-algorithm,32k.rdiff
+++ b/mysql-test/suite/encryption/r/innodb-checksum-algorithm,32k.rdiff
@@ -1,5 +1,5 @@
--- suite/encryption/r/innodb-checksum-algorithm.result
-+++ suite/encryption/r/innodb-checksum-algorithm,32k.reject
++++ suite/encryption/r/innodb-checksum-algorithm.result
@@ -13,9 +13,9 @@
SET GLOBAL innodb_default_encryption_key_id=4;
SET GLOBAL innodb_checksum_algorithm=crc32;
@@ -9,10 +9,10 @@
create table tc_crc32(a serial, b blob, index(b(10))) engine=innodb
-ROW_FORMAT=COMPRESSED encrypted=no;
+ROW_FORMAT=DYNAMIC encrypted=no;
+ Warnings:
+ Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_crc32(a serial, b blob, index(b(10))) engine=innodb
- encrypted=yes;
- create table t_crc32(a serial, b blob, index(b(10))) engine=innodb
-@@ -222,9 +222,9 @@
+@@ -153,9 +153,9 @@
t_crc32, tpe_crc32, tp_crc32;
SET GLOBAL innodb_checksum_algorithm=innodb;
create table tce_innodb(a serial, b blob, index(b(10))) engine=innodb
@@ -21,10 +21,10 @@
create table tc_innodb(a serial, b blob, index(b(10))) engine=innodb
-ROW_FORMAT=COMPRESSED encrypted=no;
+ROW_FORMAT=DYNAMIC encrypted=no;
+ Warnings:
+ Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_innodb(a serial, b blob, index(b(10))) engine=innodb
- encrypted=yes;
- create table t_innodb(a serial, b blob, index(b(10))) engine=innodb
-@@ -431,9 +431,9 @@
+@@ -293,9 +293,9 @@
t_innodb, tpe_innodb, tp_innodb;
SET GLOBAL innodb_checksum_algorithm=none;
create table tce_none(a serial, b blob, index(b(10))) engine=innodb
@@ -33,6 +33,6 @@
create table tc_none(a serial, b blob, index(b(10))) engine=innodb
-ROW_FORMAT=COMPRESSED encrypted=no;
+ROW_FORMAT=DYNAMIC encrypted=no;
+ Warnings:
+ Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_none(a serial, b blob, index(b(10))) engine=innodb
- encrypted=yes;
- create table t_none(a serial, b blob, index(b(10))) engine=innodb
diff --git a/mysql-test/suite/encryption/r/innodb-checksum-algorithm,64k.rdiff b/mysql-test/suite/encryption/r/innodb-checksum-algorithm,64k.rdiff
index 523074297da..d963cde132a 100644
--- a/mysql-test/suite/encryption/r/innodb-checksum-algorithm,64k.rdiff
+++ b/mysql-test/suite/encryption/r/innodb-checksum-algorithm,64k.rdiff
@@ -1,5 +1,5 @@
--- suite/encryption/r/innodb-checksum-algorithm.result
-+++ suite/encryption/r/innodb-checksum-algorithm,64k.reject
++++ suite/encryption/r/innodb-checksum-algorithm.result
@@ -13,9 +13,9 @@
SET GLOBAL innodb_default_encryption_key_id=4;
SET GLOBAL innodb_checksum_algorithm=crc32;
@@ -9,10 +9,10 @@
create table tc_crc32(a serial, b blob, index(b(10))) engine=innodb
-ROW_FORMAT=COMPRESSED encrypted=no;
+ROW_FORMAT=DYNAMIC encrypted=no;
+ Warnings:
+ Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_crc32(a serial, b blob, index(b(10))) engine=innodb
- encrypted=yes;
- create table t_crc32(a serial, b blob, index(b(10))) engine=innodb
-@@ -222,9 +222,9 @@
+@@ -153,9 +153,9 @@
t_crc32, tpe_crc32, tp_crc32;
SET GLOBAL innodb_checksum_algorithm=innodb;
create table tce_innodb(a serial, b blob, index(b(10))) engine=innodb
@@ -21,10 +21,10 @@
create table tc_innodb(a serial, b blob, index(b(10))) engine=innodb
-ROW_FORMAT=COMPRESSED encrypted=no;
+ROW_FORMAT=DYNAMIC encrypted=no;
+ Warnings:
+ Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_innodb(a serial, b blob, index(b(10))) engine=innodb
- encrypted=yes;
- create table t_innodb(a serial, b blob, index(b(10))) engine=innodb
-@@ -431,9 +431,9 @@
+@@ -293,9 +293,9 @@
t_innodb, tpe_innodb, tp_innodb;
SET GLOBAL innodb_checksum_algorithm=none;
create table tce_none(a serial, b blob, index(b(10))) engine=innodb
@@ -33,6 +33,6 @@
create table tc_none(a serial, b blob, index(b(10))) engine=innodb
-ROW_FORMAT=COMPRESSED encrypted=no;
+ROW_FORMAT=DYNAMIC encrypted=no;
+ Warnings:
+ Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_none(a serial, b blob, index(b(10))) engine=innodb
- encrypted=yes;
- create table t_none(a serial, b blob, index(b(10))) engine=innodb
diff --git a/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result b/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result
index afb79dbad8a..ff42e975b8d 100644
--- a/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result
+++ b/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result
@@ -14,14 +14,20 @@ create table tce_crc32(a serial, b blob, index(b(10))) engine=innodb
ROW_FORMAT=COMPRESSED encrypted=yes;
create table tc_crc32(a serial, b blob, index(b(10))) engine=innodb
ROW_FORMAT=COMPRESSED encrypted=no;
+Warnings:
+Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_crc32(a serial, b blob, index(b(10))) engine=innodb
encrypted=yes;
create table t_crc32(a serial, b blob, index(b(10))) engine=innodb
encrypted=no;
+Warnings:
+Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table tpe_crc32(a serial, b blob, index(b(10))) engine=innodb
page_compressed=yes encrypted=yes;
create table tp_crc32(a serial, b blob, index(b(10))) engine=innodb
page_compressed=yes encrypted=no;
+Warnings:
+Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
begin;
insert into tce_crc32(b) values (repeat('secret',20));
insert into tc_crc32(b) values (repeat('secret',20));
@@ -149,14 +155,20 @@ create table tce_innodb(a serial, b blob, index(b(10))) engine=innodb
ROW_FORMAT=COMPRESSED encrypted=yes;
create table tc_innodb(a serial, b blob, index(b(10))) engine=innodb
ROW_FORMAT=COMPRESSED encrypted=no;
+Warnings:
+Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_innodb(a serial, b blob, index(b(10))) engine=innodb
encrypted=yes;
create table t_innodb(a serial, b blob, index(b(10))) engine=innodb
encrypted=no;
+Warnings:
+Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table tpe_innodb(a serial, b blob, index(b(10))) engine=innodb
page_compressed=yes encrypted=yes;
create table tp_innodb(a serial, b blob, index(b(10))) engine=innodb
page_compressed=yes encrypted=no;
+Warnings:
+Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
begin;
insert into tce_innodb(b) values (repeat('secret',20));
insert into tc_innodb(b) values (repeat('secret',20));
@@ -284,14 +296,20 @@ create table tce_none(a serial, b blob, index(b(10))) engine=innodb
ROW_FORMAT=COMPRESSED encrypted=yes;
create table tc_none(a serial, b blob, index(b(10))) engine=innodb
ROW_FORMAT=COMPRESSED encrypted=no;
+Warnings:
+Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_none(a serial, b blob, index(b(10))) engine=innodb
encrypted=yes;
create table t_none(a serial, b blob, index(b(10))) engine=innodb
encrypted=no;
+Warnings:
+Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table tpe_none(a serial, b blob, index(b(10))) engine=innodb
page_compressed=yes encrypted=yes;
create table tp_none(a serial, b blob, index(b(10))) engine=innodb
page_compressed=yes encrypted=no;
+Warnings:
+Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
begin;
insert into tce_none(b) values (repeat('secret',20));
insert into tc_none(b) values (repeat('secret',20));
diff --git a/mysql-test/suite/encryption/r/innodb-compressed-blob.result b/mysql-test/suite/encryption/r/innodb-compressed-blob.result
index e156266edc6..f163f6141dd 100644
--- a/mysql-test/suite/encryption/r/innodb-compressed-blob.result
+++ b/mysql-test/suite/encryption/r/innodb-compressed-blob.result
@@ -7,6 +7,8 @@ set GLOBAL innodb_default_encryption_key_id=4;
create table t1(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed;
create table t2(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed encrypted=yes;
create table t3(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed encrypted=no;
+Warnings:
+Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
insert into t1 values (1, repeat('secret',6000));
insert into t2 values (1, repeat('secret',6000));
insert into t3 values (1, repeat('secret',6000));
diff --git a/mysql-test/suite/encryption/r/innodb-encryption-alter.result b/mysql-test/suite/encryption/r/innodb-encryption-alter.result
index 2c6372e1c61..934f0607958 100644
--- a/mysql-test/suite/encryption/r/innodb-encryption-alter.result
+++ b/mysql-test/suite/encryption/r/innodb-encryption-alter.result
@@ -2,9 +2,16 @@ SET GLOBAL innodb_encrypt_tables = ON;
SET GLOBAL innodb_encryption_threads = 4;
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=4;
Warnings:
-Warning 140 InnoDB: Ignored ENCRYPTION_KEY_ID 4 when encryption is disabled
+Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
DROP TABLE t1;
+set @save_global = @@GLOBAL.innodb_default_encryption_key_id;
set innodb_default_encryption_key_id = 99;
+Warnings:
+Warning 1210 innodb_default_encryption_key=99 is not available
+set global innodb_default_encryption_key_id = 99;
+Warnings:
+Warning 1210 innodb_default_encryption_key=99 is not available
+set global innodb_default_encryption_key_id = @save_global;
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB;
ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
SHOW WARNINGS;
@@ -38,8 +45,6 @@ t1 CREATE TABLE `t1` (
PRIMARY KEY (`pk`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `ENCRYPTION_KEY_ID`=4
CREATE TABLE t2 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=1;
-Warnings:
-Warning 140 InnoDB: Ignored ENCRYPTION_KEY_ID 1 when encryption is disabled
ALTER TABLE t1 ENCRYPTION_KEY_ID=99;
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID'
SHOW WARNINGS;
@@ -51,38 +56,32 @@ drop table t1,t2;
SET GLOBAL innodb_encrypt_tables=OFF;
CREATE TABLE t1 (a int not null primary key) engine=innodb;
ALTER TABLE t1 ENCRYPTION_KEY_ID=4;
-ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID'
-SHOW WARNINGS;
-Level Code Message
-Warning 140 InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1
-Error 1478 Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID'
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 `ENCRYPTION_KEY_ID`=4
DROP TABLE t1;
CREATE TABLE t2 (a int not null primary key) engine=innodb;
ALTER TABLE t2 ENCRYPTION_KEY_ID=4, ALGORITHM=COPY;
-ERROR HY000: Can't create table `test`.`t2` (errno: 140 "Wrong create options")
SHOW WARNINGS;
Level Code Message
-Warning 140 InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1
-Error 1005 Can't create table `test`.`t2` (errno: 140 "Wrong create options")
-Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 `ENCRYPTION_KEY_ID`=4
CREATE TABLE t3 (a int not null primary key) engine=innodb ENCRYPTION_KEY_ID=4;
-ERROR HY000: Can't create table `test`.`t3` (errno: 140 "Wrong create options")
+DROP TABLE t3;
+SET GLOBAL innodb_encrypt_tables='FORCE';
+CREATE TABLE t1 (a int primary key) engine=innodb encrypted=no;
+ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
SHOW WARNINGS;
Level Code Message
-Warning 140 InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1
-Error 1005 Can't create table `test`.`t3` (errno: 140 "Wrong create options")
+Warning 140 InnoDB: ENCRYPTED=NO cannot be used with innodb_encrypt_tables=FORCE
+Error 1005 Can't create table `test`.`t1` (errno: 140 "Wrong create options")
Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB
FLUSH TABLES;
create table t1(f1 int not null, f2 int not null)engine=innodb encrypted=yes;
diff --git a/mysql-test/suite/encryption/t/innodb-encryption-alter.test b/mysql-test/suite/encryption/t/innodb-encryption-alter.test
index bc7c3b3f13d..d9a0e4e95cd 100644
--- a/mysql-test/suite/encryption/t/innodb-encryption-alter.test
+++ b/mysql-test/suite/encryption/t/innodb-encryption-alter.test
@@ -12,7 +12,10 @@ SET GLOBAL innodb_encryption_threads = 4;
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=4;
DROP TABLE t1;
+set @save_global = @@GLOBAL.innodb_default_encryption_key_id;
set innodb_default_encryption_key_id = 99;
+set global innodb_default_encryption_key_id = 99;
+set global innodb_default_encryption_key_id = @save_global;
--error 1005
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB;
SHOW WARNINGS;
@@ -83,22 +86,24 @@ drop table t1,t2;
#
# MDEV-17230: encryption_key_id from alter is ignored by encryption threads
#
+--enable_warnings
SET GLOBAL innodb_encrypt_tables=OFF;
CREATE TABLE t1 (a int not null primary key) engine=innodb;
---error ER_ILLEGAL_HA_CREATE_OPTION
ALTER TABLE t1 ENCRYPTION_KEY_ID=4;
-SHOW WARNINGS;
SHOW CREATE TABLE t1;
DROP TABLE t1;
CREATE TABLE t2 (a int not null primary key) engine=innodb;
---error ER_CANT_CREATE_TABLE
ALTER TABLE t2 ENCRYPTION_KEY_ID=4, ALGORITHM=COPY;
SHOW WARNINGS;
SHOW CREATE TABLE t2;
---error ER_CANT_CREATE_TABLE
CREATE TABLE t3 (a int not null primary key) engine=innodb ENCRYPTION_KEY_ID=4;
+DROP TABLE t3;
+
+SET GLOBAL innodb_encrypt_tables='FORCE';
+--error ER_CANT_CREATE_TABLE
+CREATE TABLE t1 (a int primary key) engine=innodb encrypted=no;
SHOW WARNINGS;
FLUSH TABLES;
diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def
index 0ad0327f6fc..930229fc6da 100644
--- a/mysql-test/suite/galera/disabled.def
+++ b/mysql-test/suite/galera/disabled.def
@@ -23,22 +23,16 @@ galera_var_notify_cmd : MDEV-13549 Galera test failures
galera_as_slave_replication_bundle : MDEV-13549 Galera test failures
galera_ssl_upgrade : MDEV-13549 Galera test failures
MW-329 : wsrep_local_replays not stable
+MW-336 : MDEV-13549 incorrect wait_condition for wsrep_slave_threads changes
MW-416 : MDEV-13549 Galera test failures
-MW-388 : MDEV-13549 Galera test failures
MW-44 : MDEV-15809 Test failure on galera.MW-44
galera_pc_ignore_sb : MDEV-15811 Test failure on galera_pc_ignore_sb
galera_kill_applier : race condition at the start of the test
galera_ist_progress: MDEV-15236 galera_ist_progress fails when trying to read transfer status
pxc-421: Lock timeout exceeded
galera_sst_mysqldump_with_key : MDEV-16890 Galera test failure
-galera_gcs_fc_limit : Timeouts
-pool_of_threads: WSREP has not yet prepared node for application use
-galera_var_innodb_disallow_writes : Timeout
-MW-336 : nondeterministic wsrep_thread_count
-galera_binlog_stmt_autoinc : MDEV-17106 Test failure on galera.galera_binlog_stmt_autoinc
galera_kill_ddl : MDEV-17108 Test failure on galera.galera_kill_ddl
galera_var_node_address : MDEV-17151 Galera test failure on galera.galera_var_node_address
-galera_binlog_stmt_autoinc: MDEV-17106 Test failure on galera.galera_binlog_stmt_autoinc
galera_gc_fc_limit : MDEV-17061 Test failure on galera.galera_gc_fc_limit
galera_as_slave_replication_budle : MDEV-15785 Test case galera_as_slave_replication_bundle caused debug assertion
galera_wan : MDEV-17259: Test failure on galera.galera_wan
diff --git a/mysql-test/suite/galera/r/MW-336.result b/mysql-test/suite/galera/r/MW-336.result
index 5961d1f3e24..d344775648f 100644
--- a/mysql-test/suite/galera/r/MW-336.result
+++ b/mysql-test/suite/galera/r/MW-336.result
@@ -5,30 +5,9 @@ INSERT INTO t1 values(0);
connection node_1;
SET GLOBAL wsrep_slave_threads = 10;
SET GLOBAL wsrep_slave_threads = 1;
-<<<<<<< HEAD
-SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
-COUNT(*)
-11
-SHOW STATUS LIKE 'wsrep_thread_count';
-Variable_name Value
-wsrep_thread_count 11
-connection node_2;
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-=======
# Wait 10 slave threads to start 1
connection node_2;
# Generate 12 replication events
->>>>>>> 10.2
connection node_1;
SELECT COUNT(*) FROM t1;
COUNT(*)
@@ -40,90 +19,18 @@ SET GLOBAL wsrep_slave_threads = 20;
# Wait 20 slave threads to start 3
SET GLOBAL wsrep_slave_threads = 1;
connection node_2;
-<<<<<<< HEAD
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-=======
# Generate 40 replication events
connection node_1;
SELECT COUNT(*) FROM t1;
COUNT(*)
53
# Wait 10 slave threads to exit 3
->>>>>>> 10.2
SET GLOBAL wsrep_slave_threads = 10;
SET GLOBAL wsrep_slave_threads = 0;
Warnings:
Warning 1292 Truncated incorrect wsrep_slave_threads value: '0'
# Wait 10 slave threads to start 3
connection node_2;
-<<<<<<< HEAD
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-connection node_1;
-SET GLOBAL wsrep_slave_threads = 1;
-connection node_2;
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-INSERT INTO t1 VALUES (1);
-connection node_1;
-=======
# Generate 12 replication events
connection node_1;
SELECT COUNT(*) FROM t1;
@@ -131,5 +38,4 @@ COUNT(*)
65
# Wait 10 slave threads to exit 4
connection node_1;
->>>>>>> 10.2
DROP TABLE t1;
diff --git a/mysql-test/suite/galera/r/MW-86-wait1.result b/mysql-test/suite/galera/r/MW-86-wait1.result
index 36cbfadf302..8ad9c8bf181 100644
--- a/mysql-test/suite/galera/r/MW-86-wait1.result
+++ b/mysql-test/suite/galera/r/MW-86-wait1.result
@@ -1,6 +1,6 @@
connection node_2;
connection node_1;
-SET @orig_debug=@@debug;
+SET @orig_debug=@@debug_dbug;
connection node_2;
SELECT @@debug_sync;
@@debug_sync
diff --git a/mysql-test/suite/galera/r/MW-86-wait8.result b/mysql-test/suite/galera/r/MW-86-wait8.result
index 6ac2c5f5e1f..07e59ebbe0a 100644
--- a/mysql-test/suite/galera/r/MW-86-wait8.result
+++ b/mysql-test/suite/galera/r/MW-86-wait8.result
@@ -1,6 +1,6 @@
connection node_2;
connection node_1;
-SET @orig_debug=@@debug;
+SET @orig_debug=@@debug_dbug;
connection node_2;
SELECT @@debug_sync;
@@debug_sync
diff --git a/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result b/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result
index 8e8b79b168f..a09ad6b97b9 100644
--- a/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result
+++ b/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result
@@ -1,4 +1,10 @@
+connection node_2;
+connection node_1;
+connection node_1;
+connection node_2;
+connection node_2;
SET GLOBAL wsrep_forced_binlog_format='STATEMENT';
+connection node_1;
SET GLOBAL wsrep_forced_binlog_format='STATEMENT';
CREATE TABLE t1 (
i int(11) NOT NULL AUTO_INCREMENT,
@@ -8,21 +14,23 @@ PRIMARY KEY (i)
insert into t1(i) values(null);
select * from t1;
i c
-3 dummy_text
+1 dummy_text
insert into t1(i) values(null), (null), (null);
select * from t1;
i c
+1 dummy_text
3 dummy_text
5 dummy_text
7 dummy_text
-9 dummy_text
+connection node_2;
select * from t1;
i c
+1 dummy_text
3 dummy_text
5 dummy_text
7 dummy_text
-9 dummy_text
SET GLOBAL wsrep_forced_binlog_format='none';
+connection node_1;
SET GLOBAL wsrep_forced_binlog_format='none';
drop table t1;
SET SESSION binlog_format='STATEMENT';
@@ -40,20 +48,22 @@ PRIMARY KEY (i)
insert into t1(i) values(null);
select * from t1;
i c
-4 dummy_text
+1 dummy_text
insert into t1(i) values(null), (null), (null);
select * from t1;
i c
+1 dummy_text
4 dummy_text
7 dummy_text
10 dummy_text
-13 dummy_text
+connection node_2;
select * from t1;
i c
+1 dummy_text
4 dummy_text
7 dummy_text
10 dummy_text
-13 dummy_text
+connection node_1;
SET GLOBAL wsrep_auto_increment_control='ON';
SET SESSION binlog_format='ROW';
show variables like 'binlog_format';
@@ -67,12 +77,14 @@ wsrep_auto_increment_control ON
SET GLOBAL wsrep_auto_increment_control='OFF';
show variables like '%auto_increment%';
Variable_name Value
-auto_increment_increment 2
+auto_increment_increment 3
auto_increment_offset 1
wsrep_auto_increment_control OFF
SET GLOBAL wsrep_auto_increment_control='ON';
drop table t1;
+connection node_2;
SET GLOBAL wsrep_forced_binlog_format='ROW';
+connection node_1;
SET GLOBAL wsrep_forced_binlog_format='ROW';
CREATE TABLE t1 (
i int(11) NOT NULL AUTO_INCREMENT,
@@ -82,21 +94,23 @@ PRIMARY KEY (i)
insert into t1(i) values(null);
select * from t1;
i c
-3 dummy_text
+1 dummy_text
insert into t1(i) values(null), (null), (null);
select * from t1;
i c
+1 dummy_text
3 dummy_text
5 dummy_text
7 dummy_text
-9 dummy_text
+connection node_2;
select * from t1;
i c
+1 dummy_text
3 dummy_text
5 dummy_text
7 dummy_text
-9 dummy_text
SET GLOBAL wsrep_forced_binlog_format='none';
+connection node_1;
SET GLOBAL wsrep_forced_binlog_format='none';
drop table t1;
SET SESSION binlog_format='ROW';
@@ -114,20 +128,22 @@ PRIMARY KEY (i)
insert into t1(i) values(null);
select * from t1;
i c
-4 dummy_text
+1 dummy_text
insert into t1(i) values(null), (null), (null);
select * from t1;
i c
+1 dummy_text
4 dummy_text
7 dummy_text
10 dummy_text
-13 dummy_text
+connection node_2;
select * from t1;
i c
+1 dummy_text
4 dummy_text
7 dummy_text
10 dummy_text
-13 dummy_text
+connection node_1;
SET GLOBAL wsrep_auto_increment_control='ON';
show variables like 'binlog_format';
Variable_name Value
@@ -140,7 +156,7 @@ wsrep_auto_increment_control ON
SET GLOBAL wsrep_auto_increment_control='OFF';
show variables like '%auto_increment%';
Variable_name Value
-auto_increment_increment 2
+auto_increment_increment 3
auto_increment_offset 1
wsrep_auto_increment_control OFF
SET GLOBAL wsrep_auto_increment_control='ON';
diff --git a/mysql-test/suite/galera/r/galera_mdl_race.result b/mysql-test/suite/galera/r/galera_mdl_race.result
index e05c1493322..cf747ed8efb 100644
--- a/mysql-test/suite/galera/r/galera_mdl_race.result
+++ b/mysql-test/suite/galera/r/galera_mdl_race.result
@@ -1,7 +1,7 @@
connection node_2;
connection node_1;
-CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
-CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)) engine=innodb;
+CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)) engine=innodb;
INSERT INTO t1 VALUES (1, 'a');
INSERT INTO t1 VALUES (2, 'a');
connection node_1;
@@ -12,20 +12,14 @@ connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
connection node_1a;
LOCK TABLE t2 WRITE;
connection node_1;
-SET GLOBAL DEBUG = "d,sync.wsrep_before_mdl_wait";
-Warnings:
-Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
+SET @@debug_dbug = "d,sync.wsrep_before_mdl_wait";
SELECT * FROM t2;;
connection node_1a;
-SET GLOBAL DEBUG = "d,sync.wsrep_after_BF_victim_lock";
-Warnings:
-Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
+SET @@debug_dbug = "d,sync.wsrep_after_BF_victim_lock";
connection node_2;
UPDATE t1 SET f2 = 'c' WHERE f1 = 1;
connection node_1a;
-SET GLOBAL DEBUG = "";
-Warnings:
-Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
+SET @@debug_dbug = "";
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_before_mdl_wait";
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_after_BF_victim_lock";
UNLOCK TABLES;
diff --git a/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result b/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result
index 4ee910f9169..0f2f61ea97f 100644
--- a/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result
+++ b/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result
@@ -4,9 +4,7 @@ CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
connection node_2;
SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S";
-SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb";
-Warnings:
-Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
+SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb";
SELECT MAX(id) FROM t1;
MAX(id)
1
@@ -15,23 +13,17 @@ INSERT INTO t1 VALUES (2);
connection node_2;
SELECT MAX(id) FROM t1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-SET GLOBAL DEBUG = "";
-Warnings:
-Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
+SET GLOBAL debug_dbug = "";
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
FLUSH QUERY CACHE;
-SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb";
-Warnings:
-Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
+SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb";
SET DEBUG_SYNC = "RESET";
connection node_1;
INSERT INTO t1 VALUES (3);
connection node_2;
SELECT MAX(id) FROM t1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-SET GLOBAL DEBUG = "";
-Warnings:
-Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
+SET GLOBAL debug_dbug = "";
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
connection node_1;
INSERT INTO t1 VALUES (4);
@@ -46,18 +38,14 @@ MAX(id)
SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits';
VARIABLE_VALUE = 1
1
-SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb";
-Warnings:
-Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
+SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb";
connection node_1;
INSERT INTO t1 VALUES (5);
connection node_2;
SELECT MAX(id) FROM t1 ;
connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2;
connection node_2a;
-SET GLOBAL DEBUG = "";
-Warnings:
-Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
+SET GLOBAL debug_dbug = "";
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
connection node_2;
MAX(id)
diff --git a/mysql-test/suite/galera/t/MW-336.test b/mysql-test/suite/galera/t/MW-336.test
index 67715c24992..6549ecfe6ea 100644
--- a/mysql-test/suite/galera/t/MW-336.test
+++ b/mysql-test/suite/galera/t/MW-336.test
@@ -6,74 +6,118 @@
--source include/have_innodb.inc
CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB;
+INSERT INTO t1 values(0);
--connection node_1
SET GLOBAL wsrep_slave_threads = 10;
SET GLOBAL wsrep_slave_threads = 1;
+
+--echo # Wait 10 slave threads to start 1
--let $wait_timeout=600
--let $wait_condition = SELECT COUNT(*) = 12 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
--source include/wait_condition.inc
-SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
-SHOW STATUS LIKE 'wsrep_thread_count';
-
--connection node_2
-# Generate 11 replication events
---let $count = 11
+# Wait until inserts are replicated
+--let $wait_condition = SELECT COUNT(*) = 1 FROM t1;
+--source include/wait_condition.inc
+--echo # Generate 12 replication events
+--disable_query_log
+--disable_result_log
+--let $count = 12
while ($count)
{
INSERT INTO t1 VALUES (1);
--dec $count
}
+--enable_result_log
+--enable_query_log
--connection node_1
+# Wait until inserts are replicated
+--let $wait_condition = SELECT COUNT(*) = 13 FROM t1;
+--source include/wait_condition.inc
+
+SELECT COUNT(*) FROM t1;
+
+--echo # Wait 9 slave threads to exit 1
+# Wait until appliers exit
+--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
+--source include/wait_condition.inc
SET GLOBAL wsrep_slave_threads = 10;
+
+--echo # Wait 10 slave threads to start 2
--let $wait_condition = SELECT COUNT(*) = 12 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
--source include/wait_condition.inc
SET GLOBAL wsrep_slave_threads = 20;
+
+--echo # Wait 20 slave threads to start 3
--let $wait_condition = SELECT COUNT(*) = 22 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
--source include/wait_condition.inc
SET GLOBAL wsrep_slave_threads = 1;
--connection node_2
-# Generate 21 replication events
---let $count = 21
+--echo # Generate 40 replication events
+--disable_query_log
+--disable_result_log
+--let $count = 40
while ($count)
{
INSERT INTO t1 VALUES (1);
--dec $count
}
+--enable_query_log
+--enable_result_log
+
+--connection node_1
+
+# Wait until inserts are replicated
+--let $wait_condition = SELECT COUNT(*) = 53 FROM t1;
+--source include/wait_condition.inc
+
+SELECT COUNT(*) FROM t1;
+
+--echo # Wait 10 slave threads to exit 3
+# Wait until appliers exit
+--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
+--source include/wait_condition.inc
SET GLOBAL wsrep_slave_threads = 10;
SET GLOBAL wsrep_slave_threads = 0;
+--echo # Wait 10 slave threads to start 3
+--let $wait_timeout=600
+--let $wait_condition = SELECT COUNT(*) = 11 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
+--source include/wait_condition.inc
+
--connection node_2
-# Generate 21 replication events
---let $count = 21
+--echo # Generate 12 replication events
+--disable_query_log
+--disable_result_log
+--let $count = 12
while ($count)
{
INSERT INTO t1 VALUES (1);
--dec $count
}
+--enable_result_log
+--enable_query_log
--connection node_1
---let $wait_condition = SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
+# Wait until inserts are replicated
+--let $wait_condition = SELECT COUNT(*) = 65 FROM t1;
--source include/wait_condition.inc
-SET GLOBAL wsrep_slave_threads = 1;
+SELECT COUNT(*) FROM t1;
---connection node_2
-# Generate 21 replication events
---let $count = 21
-while ($count)
-{
- INSERT INTO t1 VALUES (1);
- --dec $count
-}
+--echo # Wait 10 slave threads to exit 4
+# Wait until appliers exit
+--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE IS NULL OR STATE NOT LIKE 'InnoDB%');
+--source include/wait_condition.inc
--connection node_1
DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/MW-388.test b/mysql-test/suite/galera/t/MW-388.test
index 9cf176434ba..4df1fc1a03f 100644
--- a/mysql-test/suite/galera/t/MW-388.test
+++ b/mysql-test/suite/galera/t/MW-388.test
@@ -1,6 +1,4 @@
--source include/galera_cluster.inc
---source include/have_innodb.inc
---source include/have_debug.inc
--source include/have_debug_sync.inc
--connection node_1
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(255)) Engine=InnoDB;
@@ -28,6 +26,7 @@ DELIMITER ;|
# that of the INSERT. Because there is only one slave thread,
# commit cut is not processed and therefore does not advance
# local monitor, and our INSERT remains stuck there.
+
SET GLOBAL wsrep_slave_threads = 2;
SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb";
diff --git a/mysql-test/suite/galera/t/MW-86-wait1.test b/mysql-test/suite/galera/t/MW-86-wait1.test
index aee5a0b2486..9fe863bf340 100644
--- a/mysql-test/suite/galera/t/MW-86-wait1.test
+++ b/mysql-test/suite/galera/t/MW-86-wait1.test
@@ -6,7 +6,7 @@
--source include/galera_cluster.inc
--source include/have_binlog_format_row.inc
--source include/have_debug_sync.inc
-SET @orig_debug=@@debug;
+SET @orig_debug=@@debug_dbug;
--connection node_2
# Make sure no signals have been leftover from previous tests to surprise us.
@@ -92,7 +92,6 @@ SHOW WARNINGS;
--enable_result_log
# Unblock the background INSERT and remove the sync point.
-#SET GLOBAL debug_dbug = "-d,sync.wsrep_apply_cb";
SET GLOBAL debug_dbug = @orig_debug;
SET SESSION debug_sync = "now SIGNAL signal.wsrep_apply_cb";
diff --git a/mysql-test/suite/galera/t/MW-86-wait8.test b/mysql-test/suite/galera/t/MW-86-wait8.test
index c40cd8b77c7..7d9e54a16ba 100644
--- a/mysql-test/suite/galera/t/MW-86-wait8.test
+++ b/mysql-test/suite/galera/t/MW-86-wait8.test
@@ -4,7 +4,7 @@
--source include/galera_cluster.inc
--source include/have_binlog_format_row.inc
--source include/have_debug_sync.inc
-SET @orig_debug=@@debug;
+SET @orig_debug=@@debug_dbug;
--connection node_2
# Make sure no signals have been leftover from previous tests to surprise us.
@@ -113,7 +113,6 @@ SHOW WARNINGS;
--enable_query_log
# Unblock the background INSERT and remove the sync point.
-#SET GLOBAL debug = "-d,sync.wsrep_apply_cb";
SET GLOBAL debug_dbug = @orig_debug;
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
diff --git a/mysql-test/suite/galera/t/galera_mdl_race.test b/mysql-test/suite/galera/t/galera_mdl_race.test
index 508b85add4b..ad6770f9991 100644
--- a/mysql-test/suite/galera/t/galera_mdl_race.test
+++ b/mysql-test/suite/galera/t/galera_mdl_race.test
@@ -3,11 +3,10 @@
#
--source include/galera_cluster.inc
---source include/have_innodb.inc
--source include/have_debug_sync.inc
-CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
-CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
+CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)) engine=innodb;
+CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)) engine=innodb;
INSERT INTO t1 VALUES (1, 'a');
INSERT INTO t1 VALUES (2, 'a');
@@ -24,7 +23,7 @@ LOCK TABLE t2 WRITE;
# Block before MLD lock wait
--connection node_1
- SET GLOBAL DEBUG = "d,sync.wsrep_before_mdl_wait";
+ SET @@debug_dbug = "d,sync.wsrep_before_mdl_wait";
--send SELECT * FROM t2;
# Wait for SELECT to be blocked
@@ -35,27 +34,21 @@ LOCK TABLE t2 WRITE;
#--source include/wait_condition.inc
# block applier to wait after BF victim is locked
-SET GLOBAL DEBUG = "d,sync.wsrep_after_BF_victim_lock";
+SET @@debug_dbug = "d,sync.wsrep_after_BF_victim_lock";
# Issue a conflicting update on node #2
--connection node_2
UPDATE t1 SET f2 = 'c' WHERE f1 = 1;
---sleep 3
-
# Unblock the SELECT, to enter wsrep_thd_is_BF
--connection node_1a
-SET GLOBAL DEBUG = "";
+SET @@debug_dbug = "";
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_before_mdl_wait";
---sleep 3
-
# unblock applier to try to BF the SELECT
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_after_BF_victim_lock";
-
# table lock is not needed anymore
---sleep 3
UNLOCK TABLES;
# SELECT succeeds
diff --git a/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test b/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test
index 87afc2d7bb2..e13e7f1f748 100644
--- a/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test
+++ b/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test
@@ -1,5 +1,4 @@
--source include/galera_cluster.inc
---source include/have_innodb.inc
--source include/have_debug_sync.inc
--source include/have_query_cache.inc
@@ -9,7 +8,7 @@ INSERT INTO t1 VALUES (1);
--connection node_2
--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options`
SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S";
-SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb";
+SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb";
SELECT MAX(id) FROM t1; # first lookup miss
#
@@ -22,11 +21,11 @@ INSERT INTO t1 VALUES (2);
--connection node_2
--error ER_LOCK_WAIT_TIMEOUT
SELECT MAX(id) FROM t1;
-SET GLOBAL DEBUG = "";
+SET GLOBAL debug_dbug = "";
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
FLUSH QUERY CACHE;
-SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb";
+SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb";
SET DEBUG_SYNC = "RESET";
#
@@ -39,7 +38,7 @@ INSERT INTO t1 VALUES (3);
--connection node_2
--error ER_LOCK_WAIT_TIMEOUT
SELECT MAX(id) FROM t1;
-SET GLOBAL DEBUG = "";
+SET GLOBAL debug_dbug = "";
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
#
@@ -59,7 +58,7 @@ SELECT MAX(id) FROM t1;
FLUSH STATUS;
SELECT MAX(id) FROM t1;
SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits';
-SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb";
+SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb";
#
# Query cache invalidated
@@ -73,7 +72,7 @@ INSERT INTO t1 VALUES (5);
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
--connection node_2a
-SET GLOBAL DEBUG = "";
+SET GLOBAL debug_dbug = "";
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
--connection node_2
diff --git a/mysql-test/suite/innodb/r/alter_table.result b/mysql-test/suite/innodb/r/alter_table.result
index 3a765a61dd2..0cfd3096f3f 100644
--- a/mysql-test/suite/innodb/r/alter_table.result
+++ b/mysql-test/suite/innodb/r/alter_table.result
@@ -22,6 +22,37 @@ alter table t1 change column id2 id4 varchar(100) not null;
select * from t1 where id4 like 'a';
id1 id4 id3
drop table t1;
+#
+# MDEV-17725 Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed in Diagnostics_area::set_ok_status upon ALTER failing due to error from engine
+#
+SET sql_mode=STRICT_ALL_TABLES;
+CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB;
+ALTER TABLE t1 ORDER BY a;
+Warnings:
+Warning 1105 ORDER BY ignored as there is a user-defined clustered index in the table 't1'
+DROP TABLE t1;
+SET sql_mode='';
+CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB;
+ALTER TABLE t1 ORDER BY a;
+Warnings:
+Warning 1105 ORDER BY ignored as there is a user-defined clustered index in the table 't1'
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+#
+# MDEV-18775 Server crashes in dict_table_t::instant_column
+# upon ADD COLUMN
+#
+CREATE TABLE tx (pk INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t1 (pk INT, a INT, PRIMARY KEY (pk), KEY (a), FOREIGN KEY (a) REFERENCES tx (pk)) ENGINE=InnoDB;
+SET FOREIGN_KEY_CHECKS=OFF;
+ALTER TABLE t1 DROP a;
+ERROR HY000: Cannot drop column 'a': needed in a foreign key constraint 'test/t1_ibfk_1'
+SET FOREIGN_KEY_CHECKS=ON;
+ALTER TABLE t1 ADD b INT;
+ALTER TABLE t1 DROP a;
+ERROR HY000: Cannot drop index 'a': needed in a foreign key constraint
+ALTER TABLE t1 ADD c INT;
+DROP TABLE t1, tx;
create table t1 (a int) transactional=1 engine=aria;
create table t2 (a int) transactional=1 engine=innodb;
show create table t1;
diff --git a/mysql-test/suite/innodb/r/innodb-alter-nullable.result b/mysql-test/suite/innodb/r/innodb-alter-nullable.result
index 632f7885b8e..68ad6762335 100644
--- a/mysql-test/suite/innodb/r/innodb-alter-nullable.result
+++ b/mysql-test/suite/innodb/r/innodb-alter-nullable.result
@@ -3,12 +3,9 @@ INSERT INTO t VALUES (1,2,3),(4,5,6),(7,8,9);
ALTER TABLE t CHANGE c1 c1 INT NULL FIRST, ALGORITHM=INPLACE;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
-set @old_sql_mode = @@sql_mode;
-set @@sql_mode = 'STRICT_TRANS_TABLES';
ALTER TABLE t MODIFY c3 INT NOT NULL, ALGORITHM=INPLACE;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
-set @@sql_mode = @old_sql_mode;
ALTER TABLE t CHANGE c2 c2 INT, CHANGE c2 c2 INT NOT NULL;
ERROR 42S22: Unknown column 'c2' in 't'
ALTER TABLE t MODIFY c2 INT, MODIFY c2 INT NOT NULL;
@@ -24,8 +21,6 @@ ALTER TABLE t MODIFY c2 INT NOT NULL;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
connect con1,localhost,root,,;
-connection con1;
-SET SQL_MODE='STRICT_ALL_TABLES';
UPDATE t SET c2=NULL;
ERROR 23000: Column 'c2' cannot be null
SELECT * FROM t;
@@ -61,3 +56,152 @@ CREATE TABLE t1(c1 INT) ENGINE=InnoDB;
ALTER TABLE t1 ADD CONSTRAINT UNIQUE KEY i1(c1);
ALTER TABLE t1 CHANGE c1 c1 INT NOT NULL,ADD KEY(c1);
DROP TABLE t1;
+#
+# MDEV-18732 InnoDB: ALTER IGNORE returns error for NULL
+#
+CREATE TABLE t1(c INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL);
+ALTER IGNORE TABLE t1 MODIFY c INT NOT NULL;
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 1
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+INSERT INTO t1 VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT * FROM t1;
+c
+0
+DROP TABLE t1;
+CREATE TABLE t1(c INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL),(1),(1);
+ALTER IGNORE TABLE t1 ADD UNIQUE(c);
+affected rows: 3
+info: Records: 3 Duplicates: 1 Warnings: 0
+ALTER IGNORE TABLE t1 ADD PRIMARY KEY(c);
+affected rows: 2
+info: Records: 2 Duplicates: 0 Warnings: 1
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT * FROM t1;
+c
+0
+1
+DROP TABLE t1;
+CREATE TABLE t1(c INT, g INT AS (c) PERSISTENT) ENGINE=InnoDB;
+CREATE TABLE t2(c INT, v INT AS (c) VIRTUAL) ENGINE=InnoDB;
+CREATE TABLE t3(c INT, v INT AS (c) VIRTUAL, INDEX(v)) ENGINE=InnoDB;
+INSERT INTO t1 SET c=NULL;
+INSERT INTO t2 SET c=NULL;
+INSERT INTO t3 SET c=NULL;
+SET @old_sql_mode = @@sql_mode;
+SET sql_mode = '';
+ALTER TABLE t1 MODIFY c INT NOT NULL;
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 1
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+ALTER TABLE t2 MODIFY c INT NOT NULL;
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 1
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+ALTER TABLE t3 MODIFY c INT NOT NULL;
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 1
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+SET sql_mode = @old_sql_mode;
+# MDEV-18819 FIXME: Wrong result g=NULL
+SELECT * FROM t1;
+c g
+0 NULL
+SELECT * FROM t2;
+c v
+0 0
+SELECT * FROM t3;
+c v
+0 0
+SELECT v FROM t3 FORCE INDEX(v);
+v
+0
+CHECK TABLE t1,t2,t3;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+test.t2 check status OK
+test.t3 check status OK
+DROP TABLE t1,t2,t3;
+CREATE TABLE t1(c INT, g INT AS (c) PERSISTENT) ENGINE=InnoDB;
+CREATE TABLE t2(c INT, v INT AS (c) VIRTUAL) ENGINE=InnoDB;
+CREATE TABLE t3(c INT, v INT AS (c) VIRTUAL, INDEX(v)) ENGINE=InnoDB;
+INSERT INTO t1 SET c=NULL;
+INSERT INTO t2 SET c=NULL;
+INSERT INTO t3 SET c=NULL;
+ALTER IGNORE TABLE t1 MODIFY c INT NOT NULL;
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 1
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+ALTER IGNORE TABLE t2 MODIFY c INT NOT NULL;
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 1
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+ALTER IGNORE TABLE t3 MODIFY c INT NOT NULL;
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 1
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+# MDEV-18819 FIXME: Wrong result g=NULL
+SELECT * FROM t1;
+c g
+0 NULL
+SELECT * FROM t2;
+c v
+0 0
+SELECT * FROM t3;
+c v
+0 0
+SELECT v FROM t3 FORCE INDEX(v);
+v
+0
+CHECK TABLE t1,t2,t3;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+test.t2 check status OK
+test.t3 check status OK
+DROP TABLE t1,t2,t3;
+CREATE TABLE t1(c INT, g INT AS (c) PERSISTENT) ENGINE=InnoDB;
+CREATE TABLE t2(c INT, v INT AS (c) VIRTUAL) ENGINE=InnoDB;
+CREATE TABLE t3(c INT, v INT AS (c) VIRTUAL, INDEX(v)) ENGINE=InnoDB;
+INSERT INTO t1 SET c=NULL;
+INSERT INTO t2 SET c=NULL;
+INSERT INTO t3 SET c=NULL;
+ALTER TABLE t1 MODIFY c INT NOT NULL;
+ERROR 01000: Data truncated for column 'c' at row 1
+ALTER TABLE t2 MODIFY c INT NOT NULL;
+ERROR 01000: Data truncated for column 'c' at row 1
+ALTER TABLE t3 MODIFY c INT NOT NULL;
+ERROR 01000: Data truncated for column 'c' at row 1
+UPDATE t1 SET c=0;
+UPDATE t2 SET c=0;
+UPDATE t3 SET c=0;
+ALTER TABLE t1 MODIFY c INT NOT NULL;
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0
+ALTER TABLE t2 MODIFY c INT NOT NULL;
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0
+# MDEV-18819 FIXME: This should not require ALGORITHM=COPY.
+ALTER TABLE t3 MODIFY c INT NOT NULL;
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 0
+SELECT * FROM t1;
+c g
+0 0
+SELECT * FROM t2;
+c v
+0 0
+SELECT * FROM t3;
+c v
+0 0
+DROP TABLE t1,t2,t3;
diff --git a/mysql-test/suite/innodb/r/innodb-alter-timestamp.result b/mysql-test/suite/innodb/r/innodb-alter-timestamp.result
index d4c0aa6a50e..516ac333a87 100644
--- a/mysql-test/suite/innodb/r/innodb-alter-timestamp.result
+++ b/mysql-test/suite/innodb/r/innodb-alter-timestamp.result
@@ -10,10 +10,15 @@ ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT,
ADD PRIMARY KEY(id), ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
ALTER IGNORE TABLE t1 ADD PRIMARY KEY(i1), ALGORITHM=INPLACE;
+ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Creating unique indexes with IGNORE requires COPY algorithm to remove duplicate rows. Try ALGORITHM=COPY
+SET @old_sql_mode = @@sql_mode;
+SET sql_mode = '';
+ALTER TABLE t1 ADD PRIMARY KEY(i1), ALGORITHM=INPLACE;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 1
Warnings:
Warning 1265 Data truncated for column 'i1' at row 1
+SET sql_mode = @old_sql_mode;
ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
diff --git a/mysql-test/suite/innodb/r/innodb-table-online.result b/mysql-test/suite/innodb/r/innodb-table-online.result
index 363ca07e1bc..7872332a4a8 100644
--- a/mysql-test/suite/innodb/r/innodb-table-online.result
+++ b/mysql-test/suite/innodb/r/innodb-table-online.result
@@ -397,15 +397,11 @@ UPDATE t1 SET c3 = NULL WHERE c3 = '';
SET lock_wait_timeout = 1;
ALTER TABLE t1 DROP COLUMN c22f, ADD PRIMARY KEY c3p5(c3(5));
ERROR 42000: Key column 'c22f' doesn't exist in table
-SET @old_sql_mode = @@sql_mode;
-SET @@sql_mode = 'STRICT_TRANS_TABLES';
ALTER IGNORE TABLE t1 DROP COLUMN c22f, DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)),
ALGORITHM = INPLACE;
-ERROR 23000: Duplicate entry '' for key 'PRIMARY'
-SET @@sql_mode = @old_sql_mode;
+ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Creating unique indexes with IGNORE requires COPY algorithm to remove duplicate rows. Try ALGORITHM=COPY
UPDATE t1 SET c3=LEFT(CONCAT(c1,REPEAT('foo',c1)),255) WHERE c3 IS NULL;
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created0 WAIT_FOR ins_done0';
-SET @@sql_mode = 'STRICT_TRANS_TABLES';
ALTER TABLE t1 MODIFY c3 CHAR(255) NOT NULL, DROP COLUMN c22f,
DROP PRIMARY KEY, ADD PRIMARY KEY(c1,c4(5)),
ADD COLUMN c5 CHAR(5) DEFAULT 'tired' FIRST;
@@ -419,7 +415,6 @@ SET DEBUG_SYNC = 'now SIGNAL ins_done0';
# session con1
connection con1;
ERROR 01000: Data truncated for column 'c3' at row 323
-SET @@sql_mode = @old_sql_mode;
# session default
connection default;
ROLLBACK;
diff --git a/mysql-test/suite/innodb/r/instant_alter_debug.result b/mysql-test/suite/innodb/r/instant_alter_debug.result
index 4989c801738..866aeb48f67 100644
--- a/mysql-test/suite/innodb/r/instant_alter_debug.result
+++ b/mysql-test/suite/innodb/r/instant_alter_debug.result
@@ -246,7 +246,7 @@ ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=INSTANT;
UPDATE t1 SET d=1;
connection ddl;
SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL copied WAIT_FOR logged';
-ALTER IGNORE TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (a,d);
+ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (a,d);
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR copied';
BEGIN;
diff --git a/mysql-test/suite/innodb/t/alter_table.test b/mysql-test/suite/innodb/t/alter_table.test
index 1a43016a38e..a8b52732c91 100644
--- a/mysql-test/suite/innodb/t/alter_table.test
+++ b/mysql-test/suite/innodb/t/alter_table.test
@@ -23,6 +23,43 @@ alter table t1 change column id2 id4 varchar(100) not null;
select * from t1 where id4 like 'a';
drop table t1;
+--echo #
+--echo # MDEV-17725 Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed in Diagnostics_area::set_ok_status upon ALTER failing due to error from engine
+--echo #
+
+SET sql_mode=STRICT_ALL_TABLES;
+CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB;
+ALTER TABLE t1 ORDER BY a;
+DROP TABLE t1;
+
+SET sql_mode='';
+CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB;
+ALTER TABLE t1 ORDER BY a;
+DROP TABLE t1;
+
+SET sql_mode=DEFAULT;
+
+--echo #
+--echo # MDEV-18775 Server crashes in dict_table_t::instant_column
+--echo # upon ADD COLUMN
+--echo #
+
+CREATE TABLE tx (pk INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t1 (pk INT, a INT, PRIMARY KEY (pk), KEY (a), FOREIGN KEY (a) REFERENCES tx (pk)) ENGINE=InnoDB;
+
+SET FOREIGN_KEY_CHECKS=OFF;
+
+--error ER_FK_COLUMN_CANNOT_DROP
+ALTER TABLE t1 DROP a;
+
+SET FOREIGN_KEY_CHECKS=ON;
+
+ALTER TABLE t1 ADD b INT;
+--error ER_DROP_INDEX_FK
+ALTER TABLE t1 DROP a;
+ALTER TABLE t1 ADD c INT;
+DROP TABLE t1, tx;
+
#
# Check that innodb supports transactional=1
#
diff --git a/mysql-test/suite/innodb/t/innodb-alter-nullable.test b/mysql-test/suite/innodb/t/innodb-alter-nullable.test
index d039459f91f..9e6f5df2bc9 100644
--- a/mysql-test/suite/innodb/t/innodb-alter-nullable.test
+++ b/mysql-test/suite/innodb/t/innodb-alter-nullable.test
@@ -13,14 +13,7 @@ INSERT INTO t VALUES (1,2,3),(4,5,6),(7,8,9);
ALTER TABLE t CHANGE c1 c1 INT NULL FIRST, ALGORITHM=INPLACE;
# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on.
---disable_info
-set @old_sql_mode = @@sql_mode;
-set @@sql_mode = 'STRICT_TRANS_TABLES';
---enable_info
ALTER TABLE t MODIFY c3 INT NOT NULL, ALGORITHM=INPLACE;
---disable_info
-set @@sql_mode = @old_sql_mode;
---enable_info
# Request some conflicting changes for a single column.
--error ER_BAD_FIELD_ERROR
@@ -38,9 +31,6 @@ ALTER TABLE t MODIFY c2 INT NOT NULL;
--disable_info
connect (con1,localhost,root,,);
-connection con1;
-
-SET SQL_MODE='STRICT_ALL_TABLES';
--error ER_BAD_NULL_ERROR
UPDATE t SET c2=NULL;
@@ -76,6 +66,99 @@ ALTER TABLE t1 ADD CONSTRAINT UNIQUE KEY i1(c1);
ALTER TABLE t1 CHANGE c1 c1 INT NOT NULL,ADD KEY(c1);
DROP TABLE t1;
+--echo #
+--echo # MDEV-18732 InnoDB: ALTER IGNORE returns error for NULL
+--echo #
+
+CREATE TABLE t1(c INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL);
+--enable_info
+ALTER IGNORE TABLE t1 MODIFY c INT NOT NULL;
+--disable_info
+--error ER_BAD_NULL_ERROR
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1(c INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL),(1),(1);
+--enable_info
+ALTER IGNORE TABLE t1 ADD UNIQUE(c);
+ALTER IGNORE TABLE t1 ADD PRIMARY KEY(c);
+--disable_info
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1(c INT, g INT AS (c) PERSISTENT) ENGINE=InnoDB;
+CREATE TABLE t2(c INT, v INT AS (c) VIRTUAL) ENGINE=InnoDB;
+CREATE TABLE t3(c INT, v INT AS (c) VIRTUAL, INDEX(v)) ENGINE=InnoDB;
+INSERT INTO t1 SET c=NULL;
+INSERT INTO t2 SET c=NULL;
+INSERT INTO t3 SET c=NULL;
+SET @old_sql_mode = @@sql_mode;
+# Allow lossy conversions of data
+SET sql_mode = '';
+--enable_info
+ALTER TABLE t1 MODIFY c INT NOT NULL;
+ALTER TABLE t2 MODIFY c INT NOT NULL;
+ALTER TABLE t3 MODIFY c INT NOT NULL;
+--disable_info
+SET sql_mode = @old_sql_mode;
+--echo # MDEV-18819 FIXME: Wrong result g=NULL
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+SELECT v FROM t3 FORCE INDEX(v);
+CHECK TABLE t1,t2,t3;
+DROP TABLE t1,t2,t3;
+
+CREATE TABLE t1(c INT, g INT AS (c) PERSISTENT) ENGINE=InnoDB;
+CREATE TABLE t2(c INT, v INT AS (c) VIRTUAL) ENGINE=InnoDB;
+CREATE TABLE t3(c INT, v INT AS (c) VIRTUAL, INDEX(v)) ENGINE=InnoDB;
+INSERT INTO t1 SET c=NULL;
+INSERT INTO t2 SET c=NULL;
+INSERT INTO t3 SET c=NULL;
+--enable_info
+ALTER IGNORE TABLE t1 MODIFY c INT NOT NULL;
+ALTER IGNORE TABLE t2 MODIFY c INT NOT NULL;
+ALTER IGNORE TABLE t3 MODIFY c INT NOT NULL;
+--disable_info
+--echo # MDEV-18819 FIXME: Wrong result g=NULL
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+SELECT v FROM t3 FORCE INDEX(v);
+CHECK TABLE t1,t2,t3;
+DROP TABLE t1,t2,t3;
+
+CREATE TABLE t1(c INT, g INT AS (c) PERSISTENT) ENGINE=InnoDB;
+CREATE TABLE t2(c INT, v INT AS (c) VIRTUAL) ENGINE=InnoDB;
+CREATE TABLE t3(c INT, v INT AS (c) VIRTUAL, INDEX(v)) ENGINE=InnoDB;
+INSERT INTO t1 SET c=NULL;
+INSERT INTO t2 SET c=NULL;
+INSERT INTO t3 SET c=NULL;
+--enable_info
+--error WARN_DATA_TRUNCATED
+ALTER TABLE t1 MODIFY c INT NOT NULL;
+--error WARN_DATA_TRUNCATED
+ALTER TABLE t2 MODIFY c INT NOT NULL;
+--error WARN_DATA_TRUNCATED
+ALTER TABLE t3 MODIFY c INT NOT NULL;
+--disable_info
+UPDATE t1 SET c=0;
+UPDATE t2 SET c=0;
+UPDATE t3 SET c=0;
+--enable_info
+ALTER TABLE t1 MODIFY c INT NOT NULL;
+ALTER TABLE t2 MODIFY c INT NOT NULL;
+--echo # MDEV-18819 FIXME: This should not require ALGORITHM=COPY.
+ALTER TABLE t3 MODIFY c INT NOT NULL;
+--disable_info
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+DROP TABLE t1,t2,t3;
+
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/innodb/t/innodb-alter-timestamp.test b/mysql-test/suite/innodb/t/innodb-alter-timestamp.test
index 8b56fb5be5d..1fabdc8f24d 100644
--- a/mysql-test/suite/innodb/t/innodb-alter-timestamp.test
+++ b/mysql-test/suite/innodb/t/innodb-alter-timestamp.test
@@ -12,7 +12,19 @@ ALGORITHM=COPY;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT,
ADD PRIMARY KEY(id), ALGORITHM=INPLACE;
+
+# ALTER IGNORE cannot create unique or primary key with ALGORITHM=INPLACE.
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER IGNORE TABLE t1 ADD PRIMARY KEY(i1), ALGORITHM=INPLACE;
+# Try the same with ALTER TABLE, using non-strict sql_mode.
+--disable_info
+SET @old_sql_mode = @@sql_mode;
+SET sql_mode = '';
+--enable_info
+ALTER TABLE t1 ADD PRIMARY KEY(i1), ALGORITHM=INPLACE;
+--disable_info
+SET sql_mode = @old_sql_mode;
+--enable_info
ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT;
--disable_info
SELECT * FROM t1;
diff --git a/mysql-test/suite/innodb/t/innodb-table-online.test b/mysql-test/suite/innodb/t/innodb-table-online.test
index 2b3879bc707..ce014b0aa00 100644
--- a/mysql-test/suite/innodb/t/innodb-table-online.test
+++ b/mysql-test/suite/innodb/t/innodb-table-online.test
@@ -350,20 +350,16 @@ UPDATE t1 SET c3 = NULL WHERE c3 = '';
SET lock_wait_timeout = 1;
--error ER_KEY_COLUMN_DOES_NOT_EXITS
ALTER TABLE t1 DROP COLUMN c22f, ADD PRIMARY KEY c3p5(c3(5));
-SET @old_sql_mode = @@sql_mode;
-# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on.
-# And adding a PRIMARY KEY will also add NOT NULL implicitly!
-SET @@sql_mode = 'STRICT_TRANS_TABLES';
---error ER_DUP_ENTRY
+# NULL -> NOT NULL is only allowed INPLACE without IGNORE.
+# Adding a PRIMARY KEY will add NOT NULL implicitly!
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER IGNORE TABLE t1 DROP COLUMN c22f, DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)),
ALGORITHM = INPLACE;
-SET @@sql_mode = @old_sql_mode;
UPDATE t1 SET c3=LEFT(CONCAT(c1,REPEAT('foo',c1)),255) WHERE c3 IS NULL;
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created0 WAIT_FOR ins_done0';
-# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on.
-SET @@sql_mode = 'STRICT_TRANS_TABLES';
+# NULL -> NOT NULL is allowed INPLACE.
--send
ALTER TABLE t1 MODIFY c3 CHAR(255) NOT NULL, DROP COLUMN c22f,
DROP PRIMARY KEY, ADD PRIMARY KEY(c1,c4(5)),
@@ -382,7 +378,6 @@ SET DEBUG_SYNC = 'now SIGNAL ins_done0';
connection con1;
--error WARN_DATA_TRUNCATED
reap;
-SET @@sql_mode = @old_sql_mode;
--echo # session default
connection default;
diff --git a/mysql-test/suite/innodb/t/instant_alter_debug.test b/mysql-test/suite/innodb/t/instant_alter_debug.test
index fcccbd9a750..73a222cb23c 100644
--- a/mysql-test/suite/innodb/t/instant_alter_debug.test
+++ b/mysql-test/suite/innodb/t/instant_alter_debug.test
@@ -281,7 +281,7 @@ UPDATE t1 SET d=1;
connection ddl;
SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL copied WAIT_FOR logged';
-send ALTER IGNORE TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (a,d);
+send ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (a,d);
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR copied';
diff --git a/mysql-test/suite/parts/r/partition_auto_increment_max.result b/mysql-test/suite/parts/r/partition_auto_increment_max.result
new file mode 100644
index 00000000000..65a3900e8e6
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_auto_increment_max.result
@@ -0,0 +1,7 @@
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY) PARTITION BY KEY (pk) PARTITIONS 2;
+INSERT INTO t1 VALUES (NULL),(NULL);
+UPDATE t1 SET pk = 2147483647;
+ERROR 23000: Duplicate entry '2147483647' for key 'PRIMARY'
+REPLACE INTO t1 VALUES (NULL);
+ERROR 22003: Out of range value for column 'pk' at row 1
+DROP TABLE t1;
diff --git a/mysql-test/suite/parts/t/partition_auto_increment_max.test b/mysql-test/suite/parts/t/partition_auto_increment_max.test
new file mode 100644
index 00000000000..74e6139131d
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_auto_increment_max.test
@@ -0,0 +1,12 @@
+--source include/have_partition.inc
+--source include/have_log_bin.inc
+
+CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY) PARTITION BY KEY (pk) PARTITIONS 2;
+INSERT INTO t1 VALUES (NULL),(NULL);
+
+--error ER_DUP_ENTRY
+UPDATE t1 SET pk = 2147483647;
+--error HA_ERR_AUTOINC_ERANGE
+REPLACE INTO t1 VALUES (NULL);
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/vcol/r/vcol_keys_myisam.result b/mysql-test/suite/vcol/r/vcol_keys_myisam.result
index 0b257d12ca0..a2613e0dfa1 100644
--- a/mysql-test/suite/vcol/r/vcol_keys_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_keys_myisam.result
@@ -376,3 +376,11 @@ repair table t1 extended;
Table Op Msg_type Msg_text
test.t1 repair status OK
drop table t1;
+create table t1 ( id int primary key,
+hexid varchar(10) generated always as (hex(id)) stored,
+key (hexid)) engine=myisam;
+insert into t1 (id) select 100;
+select * from t1;
+id hexid
+100 64
+drop table t1;
diff --git a/mysql-test/suite/vcol/t/vcol_keys_myisam.test b/mysql-test/suite/vcol/t/vcol_keys_myisam.test
index 337d14c3074..3269979fc9e 100644
--- a/mysql-test/suite/vcol/t/vcol_keys_myisam.test
+++ b/mysql-test/suite/vcol/t/vcol_keys_myisam.test
@@ -262,3 +262,13 @@ create table t1 (
insert into t1 values (null, 0);
repair table t1 extended;
drop table t1;
+
+#
+# MDEV-18486 Database crash on a table with indexed virtual column
+#
+create table t1 ( id int primary key,
+ hexid varchar(10) generated always as (hex(id)) stored,
+ key (hexid)) engine=myisam;
+insert into t1 (id) select 100;
+select * from t1;
+drop table t1;
diff --git a/sql/field.h b/sql/field.h
index aad96adcd40..475b6907346 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1577,6 +1577,17 @@ public:
/* Hash value */
virtual void hash(ulong *nr, ulong *nr2);
+ /**
+ Get the upper limit of the MySQL integral and floating-point type.
+
+ @return maximum allowed value for the field
+ */
+ virtual ulonglong get_max_int_value() const
+ {
+ DBUG_ASSERT(false);
+ return 0ULL;
+ }
+
/**
Checks whether a string field is part of write_set.
@@ -2232,6 +2243,10 @@ public:
*to= *from;
return from + 1;
}
+ virtual ulonglong get_max_int_value() const
+ {
+ return unsigned_flag ? 0xFFULL : 0x7FULL;
+ }
};
@@ -2276,6 +2291,10 @@ public:
virtual const uchar *unpack(uchar* to, const uchar *from,
const uchar *from_end, uint param_data)
{ return unpack_int16(to, from, from_end); }
+ virtual ulonglong get_max_int_value() const
+ {
+ return unsigned_flag ? 0xFFFFULL : 0x7FFFULL;
+ }
};
class Field_medium :public Field_int
@@ -2311,6 +2330,10 @@ public:
{
return Field::pack(to, from, max_length);
}
+ virtual ulonglong get_max_int_value() const
+ {
+ return unsigned_flag ? 0xFFFFFFULL : 0x7FFFFFULL;
+ }
};
@@ -2360,6 +2383,10 @@ public:
{
return unpack_int32(to, from, from_end);
}
+ virtual ulonglong get_max_int_value() const
+ {
+ return unsigned_flag ? 0xFFFFFFFFULL : 0x7FFFFFFFULL;
+ }
};
@@ -2414,6 +2441,10 @@ public:
}
void set_max();
bool is_max();
+ virtual ulonglong get_max_int_value() const
+ {
+ return unsigned_flag ? 0xFFFFFFFFFFFFFFFFULL : 0x7FFFFFFFFFFFFFFFULL;
+ }
};
@@ -2496,6 +2527,13 @@ public:
uint32 pack_length() const { return sizeof(float); }
uint row_pack_length() const { return pack_length(); }
void sql_type(String &str) const;
+ virtual ulonglong get_max_int_value() const
+ {
+ /*
+ We use the maximum as per IEEE754-2008 standard, 2^24
+ */
+ return 0x1000000ULL;
+ }
private:
int save_field_metadata(uchar *first_byte);
};
@@ -2554,6 +2592,13 @@ public:
uint32 pack_length() const { return sizeof(double); }
uint row_pack_length() const { return pack_length(); }
void sql_type(String &str) const;
+ virtual ulonglong get_max_int_value() const
+ {
+ /*
+ We use the maximum as per IEEE754-2008 standard, 2^53
+ */
+ return 0x20000000000000ULL;
+ }
private:
int save_field_metadata(uchar *first_byte);
};
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index c13b26cdb86..aea1796e776 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -10547,31 +10547,37 @@ void ha_partition::release_auto_increment()
m_file[i]->ha_release_auto_increment();
}
}
- else if (next_insert_id)
+ else
{
- ulonglong next_auto_inc_val;
lock_auto_increment();
- next_auto_inc_val= part_share->next_auto_inc_val;
- /*
- If the current auto_increment values is lower than the reserved
- value, and the reserved value was reserved by this thread,
- we can lower the reserved value.
- */
- if (next_insert_id < next_auto_inc_val &&
- auto_inc_interval_for_cur_row.maximum() >= next_auto_inc_val)
+ if (next_insert_id)
{
- THD *thd= ha_thd();
+ ulonglong next_auto_inc_val= part_share->next_auto_inc_val;
/*
- Check that we do not lower the value because of a failed insert
- with SET INSERT_ID, i.e. forced/non generated values.
+ If the current auto_increment values is lower than the reserved
+ value, and the reserved value was reserved by this thread,
+ we can lower the reserved value.
*/
- if (thd->auto_inc_intervals_forced.maximum() < next_insert_id)
- part_share->next_auto_inc_val= next_insert_id;
+ if (next_insert_id < next_auto_inc_val &&
+ auto_inc_interval_for_cur_row.maximum() >= next_auto_inc_val)
+ {
+ THD *thd= ha_thd();
+ /*
+ Check that we do not lower the value because of a failed insert
+ with SET INSERT_ID, i.e. forced/non generated values.
+ */
+ if (thd->auto_inc_intervals_forced.maximum() < next_insert_id)
+ part_share->next_auto_inc_val= next_insert_id;
+ }
+ DBUG_PRINT("info", ("part_share->next_auto_inc_val: %lu",
+ (ulong) part_share->next_auto_inc_val));
}
- DBUG_PRINT("info", ("part_share->next_auto_inc_val: %lu",
- (ulong) part_share->next_auto_inc_val));
-
- /* Unlock the multi row statement lock taken in get_auto_increment */
+ /*
+ Unlock the multi-row statement lock taken in get_auto_increment.
+ These actions must be performed even if the next_insert_id field
+ contains zero, otherwise if the update_auto_increment fails then
+ an unnecessary lock will remain:
+ */
if (auto_increment_safe_stmt_log_lock)
{
auto_increment_safe_stmt_log_lock= FALSE;
diff --git a/sql/handler.cc b/sql/handler.cc
index 58731fdcda7..0746f8a81fc 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -3265,11 +3265,17 @@ compute_next_insert_id(ulonglong nr,struct system_variables *variables)
nr= nr + 1; // optimization of the formula below
else
{
- nr= (((nr+ variables->auto_increment_increment -
- variables->auto_increment_offset)) /
- (ulonglong) variables->auto_increment_increment);
- nr= (nr* (ulonglong) variables->auto_increment_increment +
- variables->auto_increment_offset);
+ /*
+ Calculating the number of complete auto_increment_increment extents:
+ */
+ nr= (nr + variables->auto_increment_increment -
+ variables->auto_increment_offset) /
+ (ulonglong) variables->auto_increment_increment;
+ /*
+ Adding an offset to the auto_increment_increment extent boundary:
+ */
+ nr= nr * (ulonglong) variables->auto_increment_increment +
+ variables->auto_increment_offset;
}
if (unlikely(nr <= save_nr))
@@ -3323,8 +3329,14 @@ prev_insert_id(ulonglong nr, struct system_variables *variables)
}
if (variables->auto_increment_increment == 1)
return nr; // optimization of the formula below
- nr= (((nr - variables->auto_increment_offset)) /
- (ulonglong) variables->auto_increment_increment);
+ /*
+ Calculating the number of complete auto_increment_increment extents:
+ */
+ nr= (nr - variables->auto_increment_offset) /
+ (ulonglong) variables->auto_increment_increment;
+ /*
+ Adding an offset to the auto_increment_increment extent boundary:
+ */
return (nr * (ulonglong) variables->auto_increment_increment +
variables->auto_increment_offset);
}
@@ -3566,10 +3578,32 @@ int handler::update_auto_increment()
if (unlikely(tmp)) // Out of range value in store
{
/*
- It's better to return an error here than getting a confusing
- 'duplicate key error' later.
+ First, test if the query was aborted due to strict mode constraints
+ or new field value greater than maximum integer value:
*/
- result= HA_ERR_AUTOINC_ERANGE;
+ if (thd->killed == KILL_BAD_DATA ||
+ nr > table->next_number_field->get_max_int_value())
+ {
+ /*
+ It's better to return an error here than getting a confusing
+ 'duplicate key error' later.
+ */
+ result= HA_ERR_AUTOINC_ERANGE;
+ }
+ else
+ {
+ /*
+ Field refused this value (overflow) and truncated it, use the result
+ of the truncation (which is going to be inserted); however we try to
+ decrease it to honour auto_increment_* variables.
+ That will shift the left bound of the reserved interval, we don't
+ bother shifting the right bound (anyway any other value from this
+ interval will cause a duplicate key).
+ */
+ nr= prev_insert_id(table->next_number_field->val_int(), variables);
+ if (unlikely(table->next_number_field->store((longlong)nr, TRUE)))
+ nr= table->next_number_field->val_int();
+ }
}
if (append)
{
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 24993a045ac..4bb0e0cad88 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
- Copyright (c) 2008, 2017, MariaDB Corporation.
+ Copyright (c) 2008, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -3985,6 +3985,8 @@ static int init_common_variables()
if (IS_SYSVAR_AUTOSIZE(&server_version_ptr))
set_server_version(server_version, sizeof(server_version));
+ mysql_real_data_home_len= uint(strlen(mysql_real_data_home));
+
if (!opt_abort)
{
if (IS_SYSVAR_AUTOSIZE(&server_version_ptr))
@@ -4378,6 +4380,20 @@ static int init_common_variables()
global_system_variables.in_subquery_conversion_threshold= IN_SUBQUERY_CONVERSION_THRESHOLD;
+#ifdef WITH_WSREP
+ /*
+ We need to initialize auxiliary variables, that will be
+ further keep the original values of auto-increment options
+ as they set by the user. These variables used to restore
+ user-defined values of the auto-increment options after
+ setting of the wsrep_auto_increment_control to 'OFF'.
+ */
+ global_system_variables.saved_auto_increment_increment=
+ global_system_variables.auto_increment_increment;
+ global_system_variables.saved_auto_increment_offset=
+ global_system_variables.auto_increment_offset;
+#endif /* WITH_WSREP */
+
return 0;
}
diff --git a/sql/opt_split.cc b/sql/opt_split.cc
index fc3f08464f4..cfac0c93544 100644
--- a/sql/opt_split.cc
+++ b/sql/opt_split.cc
@@ -1078,6 +1078,7 @@ bool JOIN::inject_best_splitting_cond(table_map remaining_tables)
@param
spl_plan info on the splitting plan chosen for the splittable table T
remaining_tables the table T is joined just before these tables
+ is_const_table the table T is a constant table
@details
If in the final query plan the optimizer has chosen a splitting plan
@@ -1091,12 +1092,13 @@ bool JOIN::inject_best_splitting_cond(table_map remaining_tables)
*/
bool JOIN_TAB::fix_splitting(SplM_plan_info *spl_plan,
- table_map remaining_tables)
+ table_map remaining_tables,
+ bool is_const_table)
{
SplM_opt_info *spl_opt_info= table->spl_opt_info;
DBUG_ASSERT(table->spl_opt_info != 0);
JOIN *md_join= spl_opt_info->join;
- if (spl_plan)
+ if (spl_plan && !is_const_table)
{
memcpy((char *) md_join->best_positions,
(char *) spl_plan->best_positions,
@@ -1113,7 +1115,7 @@ bool JOIN_TAB::fix_splitting(SplM_plan_info *spl_plan,
remaining_tables,
true);
}
- else
+ else if (md_join->save_qep)
{
md_join->restore_query_plan(md_join->save_qep);
}
@@ -1143,10 +1145,11 @@ bool JOIN::fix_all_splittings_in_plan()
{
POSITION *cur_pos= &best_positions[tablenr];
JOIN_TAB *tab= cur_pos->table;
- if (tablenr >= const_tables && tab->table->is_splittable())
+ if (tab->table->is_splittable())
{
SplM_plan_info *spl_plan= cur_pos->spl_plan;
- if (tab->fix_splitting(spl_plan, all_tables & ~prev_tables))
+ if (tab->fix_splitting(spl_plan, all_tables & ~prev_tables,
+ tablenr < const_tables ))
return true;
}
prev_tables|= tab->table->map;
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index b441356df26..6fef2927938 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -10521,6 +10521,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list, bool handle_as_role)
LEX_USER *user_name;
List_iterator <LEX_USER> user_list(list);
bool binlog= false;
+ bool some_users_dropped= false;
DBUG_ENTER("mysql_create_user");
DBUG_PRINT("entry", ("Handle as %s", handle_as_role ? "role" : "user"));
@@ -10580,6 +10581,8 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list, bool handle_as_role)
result= true;
continue;
}
+ else
+ some_users_dropped= true;
// Proceed with the creation
}
else if (thd->lex->create_info.if_not_exists())
@@ -10648,12 +10651,21 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list, bool handle_as_role)
}
}
+ if (result && some_users_dropped && !handle_as_role)
+ {
+ /* Rebuild in-memory structs, since 'acl_users' has been modified */
+ rebuild_check_host();
+ rebuild_role_grants();
+ }
+
mysql_mutex_unlock(&acl_cache->lock);
if (result)
+ {
my_error(ER_CANNOT_USER, MYF(0),
(handle_as_role) ? "CREATE ROLE" : "CREATE USER",
wrong_users.c_ptr_safe());
+ }
if (binlog)
result |= write_bin_log(thd, FALSE, thd->query(), thd->query_length());
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index b39103e382a..795d4c2611b 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates.
- Copyright (c) 2011, 2018, MariaDB
+ Copyright (c) 2011, 2019, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1402,8 +1402,6 @@ bool Sql_cmd_repair_table::execute(THD *thd)
if (check_table_access(thd, SELECT_ACL | INSERT_ACL, first_table,
FALSE, UINT_MAX, FALSE))
goto error; /* purecov: inspected */
- thd->enable_slow_log&= !MY_TEST(thd->variables.log_slow_disabled_statements &
- LOG_SLOW_DISABLE_ADMIN);
WSREP_TO_ISOLATION_BEGIN_WRTCHK(NULL, NULL, first_table);
res= mysql_admin_table(thd, first_table, &m_lex->check_opt, "repair",
TL_WRITE, 1,
diff --git a/sql/sql_admin.h b/sql/sql_admin.h
index e7f4086540a..dea835c2de9 100644
--- a/sql/sql_admin.h
+++ b/sql/sql_admin.h
@@ -28,7 +28,7 @@ int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache,
/**
Sql_cmd_analyze_table represents the ANALYZE TABLE statement.
*/
-class Sql_cmd_analyze_table : public Sql_cmd
+class Sql_cmd_analyze_table : public Sql_cmd_admin
{
public:
/**
@@ -53,7 +53,7 @@ public:
/**
Sql_cmd_check_table represents the CHECK TABLE statement.
*/
-class Sql_cmd_check_table : public Sql_cmd
+class Sql_cmd_check_table : public Sql_cmd_admin
{
public:
/**
@@ -77,7 +77,7 @@ public:
/**
Sql_cmd_optimize_table represents the OPTIMIZE TABLE statement.
*/
-class Sql_cmd_optimize_table : public Sql_cmd
+class Sql_cmd_optimize_table : public Sql_cmd_admin
{
public:
/**
@@ -102,7 +102,7 @@ public:
/**
Sql_cmd_repair_table represents the REPAIR TABLE statement.
*/
-class Sql_cmd_repair_table : public Sql_cmd
+class Sql_cmd_repair_table : public Sql_cmd_admin
{
public:
/**
diff --git a/sql/sql_alter.h b/sql/sql_alter.h
index 14242015bd2..e2e7abe2a1c 100644
--- a/sql/sql_alter.h
+++ b/sql/sql_alter.h
@@ -333,7 +333,7 @@ private:
statements.
@todo move Alter_info and other ALTER generic structures from Lex here.
*/
-class Sql_cmd_common_alter_table : public Sql_cmd
+class Sql_cmd_common_alter_table : public Sql_cmd_admin
{
protected:
/**
diff --git a/sql/sql_class.h b/sql/sql_class.h
index bac5807677c..56ebe7f805f 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -599,6 +599,16 @@ typedef struct system_variables
ha_rows max_join_size;
ha_rows expensive_subquery_limit;
ulong auto_increment_increment, auto_increment_offset;
+#ifdef WITH_WSREP
+ /*
+ Stored values of the auto_increment_increment and auto_increment_offset
+ that are will be restored when wsrep_auto_increment_control will be set
+ to 'OFF', because the setting it to 'ON' leads to overwriting of the
+ original values (which are set by the user) by calculated ones (which
+ are based on the cluster size):
+ */
+ ulong saved_auto_increment_increment, saved_auto_increment_offset;
+#endif /* WITH_WSREP */
uint eq_range_index_dive_limit;
ulong column_compression_zlib_strategy;
ulong lock_wait_timeout;
diff --git a/sql/sql_cmd.h b/sql/sql_cmd.h
index 973e159c0cb..cbd7513e29f 100644
--- a/sql/sql_cmd.h
+++ b/sql/sql_cmd.h
@@ -161,6 +161,8 @@ public:
*/
virtual bool execute(THD *thd) = 0;
+ virtual bool log_slow_enabled_statement(const THD *thd) const;
+
protected:
Sql_cmd()
{}
@@ -178,6 +180,17 @@ protected:
};
+class Sql_cmd_admin: public Sql_cmd
+{
+public:
+ Sql_cmd_admin()
+ {}
+ ~Sql_cmd_admin()
+ {}
+ bool log_slow_enabled_statement(const THD *thd) const;
+};
+
+
/**
Sql_cmd_call represents the CALL statement.
*/
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index abfcf0865fe..d02d35a7dd8 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2010, Oracle and/or its affiliates.
- Copyright (c) 2010, 2015, MariaDB
+ Copyright (c) 2010, 2019, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -41,7 +41,7 @@
#include "records.h" // init_read_record,
#include "filesort.h"
#include "uniques.h"
-#include "sql_derived.h" // mysql_handle_list_of_derived
+#include "sql_derived.h" // mysql_handle_derived
// end_read_record
#include "sql_partition.h" // make_used_partitions_str
@@ -393,9 +393,9 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
DBUG_RETURN(true);
}
- if (mysql_handle_list_of_derived(thd->lex, table_list, DT_MERGE_FOR_INSERT))
+ if (thd->lex->handle_list_of_derived(table_list, DT_MERGE_FOR_INSERT))
DBUG_RETURN(TRUE);
- if (mysql_handle_list_of_derived(thd->lex, table_list, DT_PREPARE))
+ if (thd->lex->handle_list_of_derived(table_list, DT_PREPARE))
DBUG_RETURN(TRUE);
if (!table_list->single_table_updatable())
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 9919c30af6d..bce70e63603 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -96,6 +96,7 @@ mysql_handle_derived(LEX *lex, uint phases)
sl= sl->next_select_in_list())
{
TABLE_LIST *cursor= sl->get_table_list();
+ sl->changed_elements|= TOUCHED_SEL_DERIVED;
/*
DT_MERGE_FOR_INSERT is not needed for views/derived tables inside
subqueries. Views and derived tables of subqueries should be
@@ -208,36 +209,6 @@ mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases)
/**
- Run specified phases for derived tables/views in the given list
-
- @param lex LEX for this thread
- @param table_list list of derived tables/view to handle
- @param phase_map phases to process tables/views through
-
- @details
- This function runs phases specified by the 'phases_map' on derived
- tables/views found in the 'dt_list' with help of the
- TABLE_LIST::handle_derived function.
- 'lex' is passed as an argument to the TABLE_LIST::handle_derived.
-
- @return FALSE ok
- @return TRUE error
-*/
-
-bool
-mysql_handle_list_of_derived(LEX *lex, TABLE_LIST *table_list, uint phases)
-{
- for (TABLE_LIST *tl= table_list; tl; tl= tl->next_local)
- {
- if (tl->is_view_or_derived() &&
- tl->handle_derived(lex, phases))
- return TRUE;
- }
- return FALSE;
-}
-
-
-/**
Merge a derived table/view into the embedding select
@param thd thread handle
diff --git a/sql/sql_derived.h b/sql/sql_derived.h
index f098cf39083..621a6e9ec24 100644
--- a/sql/sql_derived.h
+++ b/sql/sql_derived.h
@@ -22,7 +22,6 @@ struct LEX;
bool mysql_handle_derived(LEX *lex, uint phases);
bool mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases);
-bool mysql_handle_list_of_derived(LEX *lex, TABLE_LIST *dt_list, uint phases);
bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived);
/**
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 90170f5a132..b18553ee586 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1497,7 +1497,7 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
DBUG_RETURN(TRUE);
if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
DBUG_RETURN(TRUE);
- if (mysql_handle_list_of_derived(thd->lex, table_list, DT_PREPARE))
+ if (thd->lex->handle_list_of_derived(table_list, DT_PREPARE))
DBUG_RETURN(TRUE);
/*
For subqueries in VALUES() we should not see the table in which we are
@@ -1590,7 +1590,6 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
DBUG_RETURN(TRUE);
}
select_lex->fix_prepare_information(thd, &fake_conds, &fake_conds);
- select_lex->first_execution= 0;
}
/*
Only call prepare_for_posistion() if we are not performing a DELAYED
@@ -1956,7 +1955,6 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
}
else
error= 0; // error was HA_ERR_RECORD_IS_THE_SAME
- thd->record_first_successful_insert_id_in_cur_stmt(table->file->insert_id_for_cur_row);
/*
Since we pretend that we have done insert we should call
its after triggers.
@@ -2012,7 +2010,6 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
if (table->file->insert_id_for_cur_row == 0)
table->file->insert_id_for_cur_row= insert_id_for_cur_row;
- thd->record_first_successful_insert_id_in_cur_stmt(table->file->insert_id_for_cur_row);
/*
Restore column maps if they where replaced during an duplicate key
problem.
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index fb9eb5c1ea6..792a196c5a8 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates.
- Copyright (c) 2009, 2018, MariaDB Corporation
+ Copyright (c) 2009, 2019, MariaDB Corporation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -2377,7 +2377,7 @@ void st_select_lex::init_query()
hidden_bit_fields= 0;
subquery_in_having= explicit_limit= 0;
is_item_list_lookup= 0;
- first_execution= 1;
+ changed_elements= 0;
first_natural_join_processing= 1;
first_cond_optimization= 1;
parsing_place= NO_MATTER;
@@ -2973,8 +2973,6 @@ void st_select_lex_unit::print(String *str, enum_query_type query_type)
str->append(STRING_WITH_LEN(" union "));
if (union_all)
str->append(STRING_WITH_LEN("all "));
- else if (union_distinct == sl)
- union_all= TRUE;
break;
case INTERSECT_TYPE:
str->append(STRING_WITH_LEN(" intersect "));
@@ -2983,6 +2981,8 @@ void st_select_lex_unit::print(String *str, enum_query_type query_type)
str->append(STRING_WITH_LEN(" except "));
break;
}
+ if (sl == union_distinct)
+ union_all= TRUE;
}
if (sl->braces)
str->append('(');
@@ -3950,10 +3950,11 @@ void st_select_lex::fix_prepare_information(THD *thd, Item **conds,
Item **having_conds)
{
DBUG_ENTER("st_select_lex::fix_prepare_information");
- if (!thd->stmt_arena->is_conventional() && first_execution)
+ if (!thd->stmt_arena->is_conventional() &&
+ !(changed_elements & TOUCHED_SEL_COND))
{
Query_arena_stmt on_stmt_arena(thd);
- first_execution= 0;
+ changed_elements|= TOUCHED_SEL_COND;
if (group_list.first)
{
if (!group_list_ptrs)
@@ -4204,14 +4205,7 @@ bool st_select_lex::optimize_unflattened_subqueries(bool const_only)
bool st_select_lex::handle_derived(LEX *lex, uint phases)
{
- for (TABLE_LIST *cursor= (TABLE_LIST*) table_list.first;
- cursor;
- cursor= cursor->next_local)
- {
- if (cursor->is_view_or_derived() && cursor->handle_derived(lex, phases))
- return TRUE;
- }
- return FALSE;
+ return lex->handle_list_of_derived(table_list.first, phases);
}
@@ -5222,6 +5216,20 @@ bool LEX::is_partition_management() const
}
+bool Sql_cmd::log_slow_enabled_statement(const THD *thd) const
+{
+ return global_system_variables.sql_log_slow && thd->variables.sql_log_slow;
+}
+
+
+bool Sql_cmd_admin::log_slow_enabled_statement(const THD *thd) const
+{
+ return !MY_TEST(thd->variables.log_slow_disabled_statements &
+ LOG_SLOW_DISABLE_ADMIN) &&
+ Sql_cmd::log_slow_enabled_statement(thd);
+}
+
+
/**
Exclude last added SELECT_LEX (current) in the UNIT and return pointer in it
(previous become currect)
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 4f60f89ff36..ca72770e13b 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -1029,6 +1029,10 @@ Field_pair *get_corresponding_field_pair(Item *item,
Field_pair *find_matching_field_pair(Item *item, List<Field_pair> pair_list);
+#define TOUCHED_SEL_COND 1/* WHERE/HAVING/ON should be reinited before use */
+#define TOUCHED_SEL_DERIVED (1<<1)/* derived should be reinited before use */
+
+
/*
SELECT_LEX - store information of parsed SELECT statment
*/
@@ -1234,7 +1238,8 @@ public:
subquery. Prepared statements work OK in that regard, as in
case of an error during prepare the PS is not created.
*/
- bool first_execution;
+ uint8 changed_elements; // see TOUCHED_SEL_*
+ /* TODO: add foloowing first_* to bitmap above */
bool first_natural_join_processing;
bool first_cond_optimization;
/* do not wrap view fields with Item_ref */
@@ -4310,6 +4315,31 @@ public:
bool tmp_table() const { return create_info.tmp_table(); }
bool if_exists() const { return create_info.if_exists(); }
+ /*
+ Run specified phases for derived tables/views in the given list
+
+ @param table_list - list of derived tables/view to handle
+ @param phase - phases to process tables/views through
+
+ @details
+ This method runs phases specified by the 'phases' on derived
+ tables/views found in the 'table_list' with help of the
+ TABLE_LIST::handle_derived function.
+ 'this' is passed as an argument to the TABLE_LIST::handle_derived.
+
+ @return false - ok
+ @return true - error
+ */
+ bool handle_list_of_derived(TABLE_LIST *table_list, uint phases)
+ {
+ for (TABLE_LIST *tl= table_list; tl; tl= tl->next_local)
+ {
+ if (tl->is_view_or_derived() && tl->handle_derived(this, phases))
+ return true;
+ }
+ return false;
+ }
+
SELECT_LEX *exclude_last_select();
SELECT_LEX *exclude_not_first_select(SELECT_LEX *exclude);
void check_automatic_up(enum sub_select_type type);
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index da5356ffb4b..0228bf62708 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -387,8 +387,9 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
if (open_and_lock_tables(thd, table_list, TRUE, 0))
DBUG_RETURN(TRUE);
- if (mysql_handle_single_derived(thd->lex, table_list, DT_MERGE_FOR_INSERT) ||
- mysql_handle_single_derived(thd->lex, table_list, DT_PREPARE))
+ if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
+ DBUG_RETURN(TRUE);
+ if (thd->lex->handle_list_of_derived(table_list, DT_PREPARE))
DBUG_RETURN(TRUE);
if (setup_tables_and_check_access(thd,
&thd->lex->first_select_lex()->context,
@@ -407,6 +408,11 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "LOAD");
DBUG_RETURN(TRUE);
}
+ if (table_list->is_multitable())
+ {
+ my_error(ER_WRONG_USAGE, MYF(0), "Multi-table VIEW", "LOAD");
+ DBUG_RETURN(TRUE);
+ }
if (table_list->prepare_where(thd, 0, TRUE) ||
table_list->prepare_check_option(thd))
{
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index fecd889381c..10417601345 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1575,7 +1575,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->variables.log_slow_disabled_statements defines which statements
are logged to slow log
*/
- thd->enable_slow_log= thd->variables.sql_log_slow;
+ thd->enable_slow_log= true;
thd->query_plan_flags= QPLAN_INIT;
thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */
thd->reset_kill_query();
@@ -2478,6 +2478,32 @@ dispatch_end:
}
+static bool log_slow_enabled_statement(const THD *thd)
+{
+ /*
+ TODO-10.4: Add classes Sql_cmd_create_index and Sql_cmd_drop_index
+ for symmetry with other admin commands, so these statements can be
+ handled by this command:
+ */
+ if (thd->lex->m_sql_cmd)
+ return thd->lex->m_sql_cmd->log_slow_enabled_statement(thd);
+
+ /*
+ Currently CREATE INDEX or DROP INDEX cause a full table rebuild
+ and thus classify as slow administrative statements just like
+ ALTER TABLE.
+ */
+ if ((thd->lex->sql_command == SQLCOM_CREATE_INDEX ||
+ thd->lex->sql_command == SQLCOM_DROP_INDEX) &&
+ MY_TEST(thd->variables.log_slow_disabled_statements &
+ LOG_SLOW_DISABLE_ADMIN))
+ return true;
+
+ return global_system_variables.sql_log_slow &&
+ thd->variables.sql_log_slow;
+}
+
+
/*
Log query to slow queries, if it passes filtering
@@ -2496,8 +2522,17 @@ void log_slow_statement(THD *thd)
*/
if (unlikely(thd->in_sub_stmt))
goto end; // Don't set time for sub stmt
- if (!thd->enable_slow_log || !global_system_variables.sql_log_slow)
- goto end;
+ /*
+ Skip both long_query_count increment and logging if the current
+ statement forces slow log suppression (e.g. an SP statement).
+
+ Note, we don't check for global_system_variables.sql_log_slow here.
+ According to the manual, the "Slow_queries" status variable does not require
+ sql_log_slow to be ON. So even if sql_log_slow is OFF, we still need to
+ continue and increment long_query_count (and skip only logging, see below):
+ */
+ if (!thd->enable_slow_log)
+ goto end; // E.g. SP statement
if ((thd->server_status &
(SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
@@ -2510,15 +2545,14 @@ void log_slow_statement(THD *thd)
thd->server_status|= SERVER_QUERY_WAS_SLOW;
}
- /* Follow the slow log filter configuration. */
- if (thd->variables.log_slow_filter &&
- !(thd->variables.log_slow_filter & thd->query_plan_flags))
- goto end;
-
if ((thd->server_status & SERVER_QUERY_WAS_SLOW) &&
thd->get_examined_row_count() >= thd->variables.min_examined_row_limit)
{
thd->status_var.long_query_count++;
+
+ if (!log_slow_enabled_statement(thd))
+ goto end;
+
/*
If rate limiting of slow log writes is enabled, decide whether to log
this query to the log or not.
@@ -2527,6 +2561,14 @@ void log_slow_statement(THD *thd)
(global_query_id % thd->variables.log_slow_rate_limit) != 0)
goto end;
+ /*
+ Follow the slow log filter configuration:
+ skip logging if the current statement matches the filter.
+ */
+ if (thd->variables.log_slow_filter &&
+ !(thd->variables.log_slow_filter & thd->query_plan_flags))
+ goto end;
+
THD_STAGE_INFO(thd, stage_logging_slow_query);
slow_log_print(thd, thd->query(), thd->query_length(),
thd->utime_after_query);
diff --git a/sql/sql_plugin_services.ic b/sql/sql_plugin_services.ic
index 8893ea361e3..adb20c0eb92 100644
--- a/sql/sql_plugin_services.ic
+++ b/sql/sql_plugin_services.ic
@@ -155,6 +155,7 @@ static struct wsrep_service_st wsrep_handler = {
wsrep_thd_retry_counter,
wsrep_thd_ignore_table,
wsrep_thd_trx_seqno,
+ wsrep_thd_auto_increment_variables,
wsrep_thd_is_aborting,
wsrep_set_data_home_dir,
wsrep_thd_is_BF,
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index cbabdd4221b..3967b4d57a9 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2002, 2015, Oracle and/or its affiliates.
- Copyright (c) 2008, 2017, MariaDB
+ Copyright (c) 2008, 2019, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -2946,7 +2946,7 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
}
for (; sl; sl= sl->next_select_in_list())
{
- if (!sl->first_execution)
+ if (sl->changed_elements & TOUCHED_SEL_COND)
{
/* remove option which was put by mysql_explain_union() */
sl->options&= ~SELECT_DESCRIBE;
@@ -2993,8 +2993,13 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
order->next= sl->group_list_ptrs->at(ix+1);
}
}
+ }
+ { // no harm to do it (item_ptr set on parsing)
+ ORDER *order;
for (order= sl->group_list.first; order; order= order->next)
+ {
order->item= &order->item_ptr;
+ }
/* Fix ORDER list */
for (order= sl->order_list.first; order; order= order->next)
order->item= &order->item_ptr;
@@ -3008,15 +3013,16 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
for (order= win_spec->order_list->first; order; order= order->next)
order->item= &order->item_ptr;
}
-
- {
+ }
+ if (sl->changed_elements & TOUCHED_SEL_DERIVED)
+ {
#ifdef DBUG_ASSERT_EXISTS
- bool res=
+ bool res=
#endif
- sl->handle_derived(lex, DT_REINIT);
- DBUG_ASSERT(res == 0);
- }
+ sl->handle_derived(lex, DT_REINIT);
+ DBUG_ASSERT(res == 0);
}
+
{
SELECT_LEX_UNIT *unit= sl->master_unit();
unit->unclean();
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 211898f46d0..cbf136b9b8b 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2016 Oracle and/or its affiliates.
- Copyright (c) 2009, 2018 MariaDB Corporation
+ Copyright (c) 2009, 2019 MariaDB Corporation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1270,7 +1270,7 @@ JOIN::prepare(TABLE_LIST *tables_init,
select_lex->check_unrestricted_recursive(
thd->variables.only_standard_compliant_cte))
DBUG_RETURN(-1);
- if (select_lex->first_execution)
+ if (!(select_lex->changed_elements & TOUCHED_SEL_COND))
select_lex->check_subqueries_with_recursive_references();
int res= check_and_do_in_subquery_rewrites(this);
@@ -7062,6 +7062,7 @@ void set_position(JOIN *join,uint idx,JOIN_TAB *table,KEYUSE *key)
next=tmp;
}
join->best_ref[idx]=table;
+ join->positions[idx].spl_plan= 0;
}
@@ -24536,7 +24537,9 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
real_pos->type() == Item::COND_ITEM) &&
!real_pos->with_sum_func())
{ // Save for send fields
+ LEX_CSTRING real_name= pos->name;
pos= real_pos;
+ pos->name= real_name;
/* TODO:
In most cases this result will be sent to the user.
This should be changed to use copy_int or copy_real depending
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 3bb2710d3a1..dcf95f04702 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -676,7 +676,8 @@ typedef struct st_join_table {
void add_keyuses_for_splitting();
SplM_plan_info *choose_best_splitting(double record_count,
table_map remaining_tables);
- bool fix_splitting(SplM_plan_info *spl_plan, table_map remaining_tables);
+ bool fix_splitting(SplM_plan_info *spl_plan, table_map remaining_tables,
+ bool is_const_table);
} JOIN_TAB;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index cdf418a7cab..b2212fe0ab0 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -10508,11 +10508,14 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
to->file->ha_table_flags() & HA_TABLE_SCAN_ON_INDEX)
{
char warn_buff[MYSQL_ERRMSG_SIZE];
+ bool save_abort_on_warning= thd->abort_on_warning;
+ thd->abort_on_warning= false;
my_snprintf(warn_buff, sizeof(warn_buff),
"ORDER BY ignored as there is a user-defined clustered index"
" in the table '%-.192s'", from->s->table_name.str);
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
warn_buff);
+ thd->abort_on_warning= save_abort_on_warning;
}
else
{
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index ca8a5e7a8b3..a1d86959218 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -611,8 +611,9 @@ st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg,
called at the first execution of the statement, while first_execution
shows whether this is called at the first execution of the union that
may form just a subselect.
- */
- if (!fake_select_lex->first_execution && first_execution)
+ */
+ if ((fake_select_lex->changed_elements & TOUCHED_SEL_COND) &&
+ first_execution)
{
for (ORDER *order= global_parameters()->order_list.first;
order;
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 5e88c4e7544..5626fc5bdaf 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -350,6 +350,25 @@ static Sys_var_long Sys_pfs_connect_attrs_size(
#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
+#ifdef WITH_WSREP
+
+/*
+ We need to keep the original values set by the user, as they will
+ be lost if wsrep_auto_increment_control set to 'ON':
+*/
+static bool update_auto_increment_increment (sys_var *self, THD *thd, enum_var_type type)
+{
+ if (type == OPT_GLOBAL)
+ global_system_variables.saved_auto_increment_increment=
+ global_system_variables.auto_increment_increment;
+ else
+ thd->variables.saved_auto_increment_increment=
+ thd->variables.auto_increment_increment;
+ return false;
+}
+
+#endif /* WITH_WSREP */
+
static Sys_var_double Sys_analyze_sample_percentage(
"analyze_sample_percentage",
"Percentage of rows from the table ANALYZE TABLE will sample "
@@ -365,7 +384,31 @@ static Sys_var_ulong Sys_auto_increment_increment(
SESSION_VAR(auto_increment_increment),
CMD_LINE(OPT_ARG),
VALID_RANGE(1, 65535), DEFAULT(1), BLOCK_SIZE(1),
+#ifdef WITH_WSREP
+ NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0),
+ ON_UPDATE(update_auto_increment_increment));
+#else
NO_MUTEX_GUARD, IN_BINLOG);
+#endif /* WITH_WSREP */
+
+#ifdef WITH_WSREP
+
+/*
+ We need to keep the original values set by the user, as they will
+ be lost if wsrep_auto_increment_control set to 'ON':
+*/
+static bool update_auto_increment_offset (sys_var *self, THD *thd, enum_var_type type)
+{
+ if (type == OPT_GLOBAL)
+ global_system_variables.saved_auto_increment_offset=
+ global_system_variables.auto_increment_offset;
+ else
+ thd->variables.saved_auto_increment_offset=
+ thd->variables.auto_increment_offset;
+ return false;
+}
+
+#endif /* WITH_WSREP */
static Sys_var_ulong Sys_auto_increment_offset(
"auto_increment_offset",
@@ -374,7 +417,12 @@ static Sys_var_ulong Sys_auto_increment_offset(
SESSION_VAR(auto_increment_offset),
CMD_LINE(OPT_ARG),
VALID_RANGE(1, 65535), DEFAULT(1), BLOCK_SIZE(1),
+#ifdef WITH_WSREP
+ NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0),
+ ON_UPDATE(update_auto_increment_offset));
+#else
NO_MUTEX_GUARD, IN_BINLOG);
+#endif /* WITH_WSREP */
static Sys_var_mybool Sys_automatic_sp_privileges(
"automatic_sp_privileges",
@@ -5414,11 +5462,54 @@ static Sys_var_ulong Sys_wsrep_retry_autocommit(
SESSION_VAR(wsrep_retry_autocommit), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, 10000), DEFAULT(1), BLOCK_SIZE(1));
+static bool update_wsrep_auto_increment_control (sys_var *self, THD *thd, enum_var_type type)
+{
+ if (wsrep_auto_increment_control)
+ {
+ /*
+ The variables that control auto increment shall be calculated
+ automaticaly based on the size of the cluster. This usually done
+ within the wsrep_view_handler_cb callback. However, if the user
+ manually sets the value of wsrep_auto_increment_control to 'ON',
+ then we should to re-calculate these variables again (because
+ these values may be required before wsrep_view_handler_cb will
+ be re-invoked, which is rarely invoked if the cluster stays in
+ the stable state):
+ */
+ global_system_variables.auto_increment_increment=
+ wsrep_cluster_size ? wsrep_cluster_size : 1;
+ global_system_variables.auto_increment_offset=
+ wsrep_local_index >= 0 ? wsrep_local_index + 1 : 1;
+ thd->variables.auto_increment_increment=
+ global_system_variables.auto_increment_increment;
+ thd->variables.auto_increment_offset=
+ global_system_variables.auto_increment_offset;
+ }
+ else
+ {
+ /*
+ We must restore the last values of the variables that
+ are explicitly specified by the user:
+ */
+ global_system_variables.auto_increment_increment=
+ global_system_variables.saved_auto_increment_increment;
+ global_system_variables.auto_increment_offset=
+ global_system_variables.saved_auto_increment_offset;
+ thd->variables.auto_increment_increment=
+ thd->variables.saved_auto_increment_increment;
+ thd->variables.auto_increment_offset=
+ thd->variables.saved_auto_increment_offset;
+ }
+ return false;
+}
+
static Sys_var_mybool Sys_wsrep_auto_increment_control(
"wsrep_auto_increment_control", "To automatically control the "
"assignment of autoincrement variables",
GLOBAL_VAR(wsrep_auto_increment_control),
- CMD_LINE(OPT_ARG), DEFAULT(TRUE));
+ CMD_LINE(OPT_ARG), DEFAULT(TRUE),
+ NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
+ ON_UPDATE(update_wsrep_auto_increment_control));
static Sys_var_mybool Sys_wsrep_drupal_282555_workaround(
"wsrep_drupal_282555_workaround", "Enable a workaround to handle the "
diff --git a/sql/wsrep_dummy.cc b/sql/wsrep_dummy.cc
index 916788483ab..f021054bf4c 100644
--- a/sql/wsrep_dummy.cc
+++ b/sql/wsrep_dummy.cc
@@ -101,6 +101,14 @@ const char* wsrep_thd_client_state_str(const THD*)
const char* wsrep_thd_client_mode_str(const THD*)
{ return 0; }
+void wsrep_thd_auto_increment_variables(THD *thd,
+ unsigned long long *offset,
+ unsigned long long *increment)
+{
+ *offset= thd->variables.auto_increment_offset;
+ *increment= thd->variables.auto_increment_increment;
+}
+
const char* wsrep_thd_transaction_state_str(const THD*)
{ return 0; }
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index 556163ad03d..b849bc256cb 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -397,3 +397,21 @@ bool wsrep_bf_abort(const THD* bf_thd, THD* victim_thd)
return ret;
}
+/*
+ Get auto increment variables for THD. Use global settings for
+ applier threads.
+ */
+void wsrep_thd_auto_increment_variables(THD* thd,
+ unsigned long long* offset,
+ unsigned long long* increment)
+{
+ if (wsrep_thd_is_applying(thd) &&
+ thd->wsrep_trx().state() != wsrep::transaction::s_replaying)
+ {
+ *offset= global_system_variables.auto_increment_offset;
+ *increment= global_system_variables.auto_increment_increment;
+ return;
+ }
+ *offset= thd->variables.auto_increment_offset;
+ *increment= thd->variables.auto_increment_increment;
+}
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index 59704201c4e..40bcbd33ec9 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -767,11 +767,7 @@ btr_cur_optimistic_latch_leaves(
file, line, mtr)) {
if (btr_page_get_prev(buf_block_get_frame(block), mtr)
== left_page_no) {
- /* adjust buf_fix_count */
- buf_page_mutex_enter(block);
buf_block_buf_fix_dec(block);
- buf_page_mutex_exit(block);
-
*latch_mode = mode;
return(true);
} else {
@@ -787,10 +783,7 @@ btr_cur_optimistic_latch_leaves(
}
unpin_failed:
/* unpin the block */
- buf_page_mutex_enter(block);
buf_block_buf_fix_dec(block);
- buf_page_mutex_exit(block);
-
return(false);
default:
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 35fa8edc497..b1f158525af 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -3827,18 +3827,10 @@ err_exit:
ut_ad(!buf_pool_watch_is_sentinel(buf_pool, bpage));
switch (buf_page_get_state(bpage)) {
- case BUF_BLOCK_POOL_WATCH:
- case BUF_BLOCK_NOT_USED:
- case BUF_BLOCK_READY_FOR_USE:
- case BUF_BLOCK_MEMORY:
- case BUF_BLOCK_REMOVE_HASH:
- ut_error;
-
case BUF_BLOCK_ZIP_PAGE:
case BUF_BLOCK_ZIP_DIRTY:
bpage->fix();
block_mutex = &buf_pool->zip_mutex;
- mutex_enter(block_mutex);
goto got_block;
case BUF_BLOCK_FILE_PAGE:
/* Discard the uncompressed page frame if possible. */
@@ -3853,16 +3845,16 @@ err_exit:
__FILE__, __LINE__);
block_mutex = &((buf_block_t*) bpage)->mutex;
-
- mutex_enter(block_mutex);
-
goto got_block;
+ default:
+ break;
}
ut_error;
goto err_exit;
got_block:
+ mutex_enter(block_mutex);
must_read = buf_page_get_io_fix(bpage) == BUF_IO_READ;
rw_lock_s_unlock(hash_lock);
@@ -4965,10 +4957,7 @@ buf_page_optimistic_get(
}
if (!success) {
- buf_page_mutex_enter(block);
buf_block_buf_fix_dec(block);
- buf_page_mutex_exit(block);
-
return(FALSE);
}
@@ -4982,10 +4971,7 @@ buf_page_optimistic_get(
rw_lock_x_unlock(&block->lock);
}
- buf_page_mutex_enter(block);
buf_block_buf_fix_dec(block);
- buf_page_mutex_exit(block);
-
return(FALSE);
}
@@ -5088,10 +5074,7 @@ buf_page_get_known_nowait(
}
if (!success) {
- buf_page_mutex_enter(block);
buf_block_buf_fix_dec(block);
- buf_page_mutex_exit(block);
-
return(FALSE);
}
@@ -5185,10 +5168,7 @@ buf_page_try_get_func(
}
if (!success) {
- buf_page_mutex_enter(block);
buf_block_buf_fix_dec(block);
- buf_page_mutex_exit(block);
-
return(NULL);
}
diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc
index 3250cccb643..d43b2352a58 100644
--- a/storage/innobase/fsp/fsp0fsp.cc
+++ b/storage/innobase/fsp/fsp0fsp.cc
@@ -1234,11 +1234,8 @@ fsp_page_create(
} else {
rw_lock_sx_lock(&block->lock);
}
- mutex_enter(&block->mutex);
buf_block_buf_fix_inc(block, __FILE__, __LINE__);
-
- mutex_exit(&block->mutex);
mtr_memo_push(init_mtr, block, rw_latch == RW_X_LATCH
? MTR_MEMO_PAGE_X_FIX : MTR_MEMO_PAGE_SX_FIX);
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 76aa9046f1c..4a98109aca7 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -700,9 +700,25 @@ static MYSQL_THDVAR_BOOL(compression_default, PLUGIN_VAR_OPCMDARG,
"Is compression the default for new tables",
NULL, NULL, FALSE);
+/** Update callback for SET [SESSION] innodb_default_encryption_key_id */
+static void
+innodb_default_encryption_key_id_update(THD* thd, st_mysql_sys_var* var,
+ void* var_ptr, const void *save)
+{
+ uint key_id = *static_cast<const uint*>(save);
+ if (key_id != FIL_DEFAULT_ENCRYPTION_KEY
+ && !encryption_key_id_exists(key_id)) {
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
+ ER_WRONG_ARGUMENTS,
+ "innodb_default_encryption_key=%u"
+ " is not available", key_id);
+ }
+ *static_cast<uint*>(var_ptr) = key_id;
+}
+
static MYSQL_THDVAR_UINT(default_encryption_key_id, PLUGIN_VAR_RQCMDARG,
"Default encryption key id used for table encryption.",
- NULL, NULL,
+ NULL, innodb_default_encryption_key_id_update,
FIL_DEFAULT_ENCRYPTION_KEY, 1, UINT_MAX32, 0);
/**
@@ -8102,8 +8118,8 @@ ha_innobase::write_row(
/* We need the upper limit of the col type to check for
whether we update the table autoinc counter or not. */
- col_max_value = innobase_get_int_col_max_value(
- table->next_number_field);
+ col_max_value =
+ table->next_number_field->get_max_int_value();
/* Get the value that MySQL attempted to store in the table.*/
auto_inc = table->next_number_field->val_uint();
@@ -8178,15 +8194,30 @@ set_max_autoinc:
/* This should filter out the negative
values set explicitly by the user. */
if (auto_inc <= col_max_value) {
- ut_a(m_prebuilt->autoinc_increment > 0);
ulonglong offset;
ulonglong increment;
dberr_t err;
-
- offset = m_prebuilt->autoinc_offset;
- increment = m_prebuilt->autoinc_increment;
-
+#ifdef WITH_WSREP
+ /* Applier threads which are processing
+ ROW events and don't go through server
+ level autoinc processing, therefore
+ m_prebuilt autoinc values don't get
+ properly assigned. Fetch values from
+ server side. */
+ if (wsrep_on(m_user_thd) &&
+ wsrep_thd_is_applying(m_user_thd))
+ {
+ wsrep_thd_auto_increment_variables(
+ m_user_thd, &offset, &increment);
+ }
+ else
+#endif /* WITH_WSREP */
+ {
+ ut_a(m_prebuilt->autoinc_increment > 0);
+ offset = m_prebuilt->autoinc_offset;
+ increment = m_prebuilt->autoinc_increment;
+ }
auto_inc = innobase_next_autoinc(
auto_inc,
1, increment, offset,
@@ -8877,12 +8908,27 @@ ha_innobase::update_row(
/* A value for an AUTO_INCREMENT column
was specified in the UPDATE statement. */
+ ulonglong offset;
+ ulonglong increment;
+#ifdef WITH_WSREP
+ /* Applier threads which are processing
+ ROW events and don't go through server
+ level autoinc processing, therefore
+ m_prebuilt autoinc values don't get
+ properly assigned. Fetch values from
+ server side. */
+ if (wsrep_on(m_user_thd) &&
+ wsrep_thd_is_applying(m_user_thd))
+ wsrep_thd_auto_increment_variables(
+ m_user_thd, &offset, &increment);
+ else
+#endif /* WITH_WSREP */
+ offset = m_prebuilt->autoinc_offset,
+ increment = m_prebuilt->autoinc_increment;
+
autoinc = innobase_next_autoinc(
- autoinc, 1,
- m_prebuilt->autoinc_increment,
- m_prebuilt->autoinc_offset,
- innobase_get_int_col_max_value(
- table->found_next_number_field));
+ autoinc, 1, increment, offset,
+ table->found_next_number_field->get_max_int_value());
error = innobase_set_max_autoinc(autoinc);
@@ -11139,8 +11185,8 @@ err_col:
if (err == DB_SUCCESS) {
err = row_create_table_for_mysql(
table, m_trx,
- (fil_encryption_t)options->encryption,
- (uint32_t)options->encryption_key_id);
+ fil_encryption_t(options->encryption),
+ uint32_t(options->encryption_key_id));
m_drop_before_rollback = (err == DB_SUCCESS);
}
@@ -11559,42 +11605,72 @@ const char*
create_table_info_t::check_table_options()
{
enum row_type row_format = m_create_info->row_type;
- ha_table_option_struct *options= m_form->s->option_struct;
- fil_encryption_t encrypt = (fil_encryption_t)options->encryption;
- bool should_encrypt = (encrypt == FIL_ENCRYPTION_ON);
-
- /* Currently we do not support encryption for
- spatial indexes thus do not allow creating table with forced
- encryption */
- for(ulint i = 0; i < m_form->s->keys; i++) {
- const KEY* key = m_form->key_info + i;
- if (key->flags & HA_SPATIAL && should_encrypt
- && (options->page_compressed
- || srv_checksum_algorithm
- < SRV_CHECKSUM_ALGORITHM_FULL_CRC32)) {
- push_warning_printf(m_thd, Sql_condition::WARN_LEVEL_WARN,
- HA_ERR_UNSUPPORTED,
- "InnoDB: ENCRYPTED=ON not supported for table because "
- "it contains spatial index.");
- return "ENCRYPTED";
- }
- }
-
- if (encrypt != FIL_ENCRYPTION_DEFAULT && !m_allow_file_per_table) {
+ const ha_table_option_struct *options= m_form->s->option_struct;
+
+ switch (options->encryption) {
+ case FIL_ENCRYPTION_OFF:
+ if (options->encryption_key_id != FIL_DEFAULT_ENCRYPTION_KEY) {
+ push_warning(
+ m_thd, Sql_condition::WARN_LEVEL_WARN,
+ HA_WRONG_CREATE_OPTION,
+ "InnoDB: ENCRYPTED=NO implies"
+ " ENCRYPTION_KEY_ID=1");
+ compile_time_assert(FIL_DEFAULT_ENCRYPTION_KEY == 1);
+ }
+ if (srv_encrypt_tables != 2) {
+ break;
+ }
push_warning(
m_thd, Sql_condition::WARN_LEVEL_WARN,
HA_WRONG_CREATE_OPTION,
- "InnoDB: ENCRYPTED requires innodb_file_per_table");
+ "InnoDB: ENCRYPTED=NO cannot be used with"
+ " innodb_encrypt_tables=FORCE");
return "ENCRYPTED";
- }
+ case FIL_ENCRYPTION_DEFAULT:
+ if (!srv_encrypt_tables) {
+ break;
+ }
+ /* fall through */
+ case FIL_ENCRYPTION_ON:
+ const uint32_t key_id = uint32_t(options->encryption_key_id);
+ if (!encryption_key_id_exists(key_id)) {
+ push_warning_printf(
+ m_thd, Sql_condition::WARN_LEVEL_WARN,
+ HA_WRONG_CREATE_OPTION,
+ "InnoDB: ENCRYPTION_KEY_ID %u not available",
+ key_id);
+ return "ENCRYPTION_KEY_ID";
+ }
+
+ /* We do not support encryption for spatial indexes,
+ except if innodb_checksum_algorithm=full_crc32.
+ Do not allow ENCRYPTED=YES if any SPATIAL INDEX exists. */
+ if (options->encryption != FIL_ENCRYPTION_ON
+ || (!options->page_compressed
+ && srv_checksum_algorithm
+ >= SRV_CHECKSUM_ALGORITHM_FULL_CRC32)) {
+ break;
+ }
+ for (ulint i = 0; i < m_form->s->keys; i++) {
+ if (m_form->key_info[i].flags & HA_SPATIAL) {
+ push_warning(m_thd,
+ Sql_condition::WARN_LEVEL_WARN,
+ HA_ERR_UNSUPPORTED,
+ "InnoDB: ENCRYPTED=YES is not"
+ " supported for SPATIAL INDEX");
+ return "ENCRYPTED";
+ }
+ }
+ }
- if (encrypt == FIL_ENCRYPTION_OFF && srv_encrypt_tables == 2) {
+ if (!m_allow_file_per_table
+ && options->encryption != FIL_ENCRYPTION_DEFAULT) {
push_warning(
m_thd, Sql_condition::WARN_LEVEL_WARN,
HA_WRONG_CREATE_OPTION,
- "InnoDB: ENCRYPTED=OFF cannot be used when innodb_encrypt_tables=FORCE");
+ "InnoDB: ENCRYPTED requires innodb_file_per_table");
return "ENCRYPTED";
- }
+ }
/* Check page compression requirements */
if (options->page_compressed) {
@@ -11668,46 +11744,6 @@ create_table_info_t::check_table_options()
}
}
- /* If encryption is set up make sure that used key_id is found */
- if (encrypt == FIL_ENCRYPTION_ON ||
- (encrypt == FIL_ENCRYPTION_DEFAULT && srv_encrypt_tables)) {
- if (!encryption_key_id_exists((unsigned int)options->encryption_key_id)) {
- push_warning_printf(
- m_thd, Sql_condition::WARN_LEVEL_WARN,
- HA_WRONG_CREATE_OPTION,
- "InnoDB: ENCRYPTION_KEY_ID %u not available",
- (uint)options->encryption_key_id
- );
- return "ENCRYPTION_KEY_ID";
- }
- }
-
- /* Ignore nondefault key_id if encryption is set off */
- if (encrypt == FIL_ENCRYPTION_OFF &&
- options->encryption_key_id != THDVAR(m_thd, default_encryption_key_id)) {
- push_warning_printf(
- m_thd, Sql_condition::WARN_LEVEL_WARN,
- HA_WRONG_CREATE_OPTION,
- "InnoDB: Ignored ENCRYPTION_KEY_ID %u when encryption is disabled",
- (uint)options->encryption_key_id
- );
- options->encryption_key_id = FIL_DEFAULT_ENCRYPTION_KEY;
- }
-
- /* If default encryption is used and encryption is disabled, you may
- not use nondefault encryption_key_id as it is not stored anywhere. */
- if (encrypt == FIL_ENCRYPTION_DEFAULT
- && !srv_encrypt_tables
- && options->encryption_key_id != FIL_DEFAULT_ENCRYPTION_KEY) {
- compile_time_assert(FIL_DEFAULT_ENCRYPTION_KEY == 1);
- push_warning_printf(
- m_thd, Sql_condition::WARN_LEVEL_WARN,
- HA_WRONG_CREATE_OPTION,
- "InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1"
- );
- return "ENCRYPTION_KEY_ID";
- }
-
return NULL;
}
@@ -16522,7 +16558,8 @@ ha_innobase::get_auto_increment(
/* We need the upper limit of the col type to check for
whether we update the table autoinc counter or not. */
- ulonglong col_max_value = innobase_get_int_col_max_value(table->next_number_field);
+ ulonglong col_max_value =
+ table->next_number_field->get_max_int_value();
/** The following logic is needed to avoid duplicate key error
for autoincrement column.
@@ -16603,11 +16640,10 @@ ha_innobase::get_auto_increment(
if (!wsrep_on(m_user_thd)) {
current = autoinc
- m_prebuilt->autoinc_increment;
+ current = innobase_next_autoinc(
+ current, 1, increment, offset, col_max_value);
}
- current = innobase_next_autoinc(
- current, 1, increment, offset, col_max_value);
-
dict_table_autoinc_initialize(
m_prebuilt->table, current);
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 8102060414b..57ebde11ece 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -1834,6 +1834,17 @@ ha_innobase::check_if_supported_inplace_alter(
DBUG_RETURN(HA_ALTER_INPLACE_INSTANT);
}
+ /* InnoDB cannot IGNORE when creating unique indexes. IGNORE
+ should silently delete some duplicate rows. Our inplace_alter
+ code will not delete anything from existing indexes. */
+ if (ha_alter_info->ignore
+ && (ha_alter_info->handler_flags
+ & (ALTER_ADD_PK_INDEX | ALTER_ADD_UNIQUE_INDEX))) {
+ ha_alter_info->unsupported_reason = my_get_err_msg(
+ ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_IGNORE);
+ DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
+ }
+
/* DROP PRIMARY KEY is only allowed in combination with ADD
PRIMARY KEY. */
if ((ha_alter_info->handler_flags
@@ -1844,15 +1855,16 @@ ha_innobase::check_if_supported_inplace_alter(
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
}
- /* If a column change from NOT NULL to NULL,
- and there's a implict pk on this column. the
- table should be rebuild. The change should
- only go through the "Copy" method. */
- if ((ha_alter_info->handler_flags
- & ALTER_COLUMN_NULLABLE)) {
+ if (ha_alter_info->handler_flags & ALTER_COLUMN_NULLABLE) {
+ /* If a NOT NULL attribute is going to be removed and
+ a UNIQUE INDEX on the column had been promoted to an
+ implicit PRIMARY KEY, the table should be rebuilt by
+ ALGORITHM=COPY. (Theoretically, we could support
+ rebuilding by ALGORITHM=INPLACE if a PRIMARY KEY is
+ going to be added, either explicitly or by promoting
+ another UNIQUE KEY.) */
const uint my_primary_key = altered_table->s->primary_key;
- /* See if MYSQL table has no pk but we do. */
if (UNIV_UNLIKELY(my_primary_key >= MAX_KEY)
&& !dict_index_is_auto_gen_clust(
dict_table_get_first_index(m_prebuilt->table))) {
@@ -2138,8 +2150,15 @@ ha_innobase::check_if_supported_inplace_alter(
& ALTER_ADD_COLUMN));
if (const Field* f = cf->field) {
- /* This could be changing an existing column
+ if (!f->real_maybe_null() || (*af)->real_maybe_null())
+ goto next_column;
+ /* We are changing an existing column
from NULL to NOT NULL. */
+ DBUG_ASSERT(ha_alter_info->handler_flags
+ & ALTER_COLUMN_NOT_NULLABLE);
+ /* Virtual columns are never NOT NULL. */
+ DBUG_ASSERT(f->stored_in_db());
+
switch ((*af)->type()) {
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_TIMESTAMP2:
@@ -2148,20 +2167,12 @@ ha_innobase::check_if_supported_inplace_alter(
replaced. Ensure that the DEFAULT
expression is not changing during
ALTER TABLE. */
- if (!f->real_maybe_null()
- || (*af)->real_maybe_null()) {
- /* The column was NOT NULL, or it
- will allow NULL after ALTER TABLE. */
- goto next_column;
- }
-
if (!(*af)->default_value
&& (*af)->is_real_null()) {
/* No DEFAULT value is
specified. We can report
errors for any NULL values for
the TIMESTAMP. */
-
goto next_column;
}
break;
@@ -6957,14 +6968,12 @@ error_handled:
ut_ad(!user_table->drop_aborted);
err_exit:
-#ifdef UNIV_DEBUG
/* Clear the to_be_dropped flag in the data dictionary cache. */
for (ulint i = 0; i < ctx->num_to_drop_index; i++) {
DBUG_ASSERT(ctx->drop_index[i]->is_committed());
DBUG_ASSERT(ctx->drop_index[i]->to_be_dropped);
ctx->drop_index[i]->to_be_dropped = 0;
}
-#endif /* UNIV_DEBUG */
if (ctx->trx) {
row_mysql_unlock_data_dictionary(ctx->trx);
diff --git a/storage/innobase/include/ut0wqueue.h b/storage/innobase/include/ut0wqueue.h
index 771d8d6ae5c..3a96d7d4059 100644
--- a/storage/innobase/include/ut0wqueue.h
+++ b/storage/innobase/include/ut0wqueue.h
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2006, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -63,14 +64,10 @@ ib_wqueue_add(
mem_heap_t* heap); /*!< in: memory heap to use for
allocating the list node */
-/********************************************************************
-Check if queue is empty. */
-ibool
-ib_wqueue_is_empty(
-/*===============*/
- /* out: TRUE if queue empty
- else FALSE */
- const ib_wqueue_t* wq); /* in: work queue */
+/** Check if queue is empty.
+@param wq wait queue
+@return whether the queue is empty */
+bool ib_wqueue_is_empty(ib_wqueue_t* wq);
/****************************************************************//**
Wait for a work item to appear in the queue.
diff --git a/storage/innobase/ut/ut0wqueue.cc b/storage/innobase/ut/ut0wqueue.cc
index ccd5c10555c..35f14fd20fe 100644
--- a/storage/innobase/ut/ut0wqueue.cc
+++ b/storage/innobase/ut/ut0wqueue.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2006, 2015, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -201,16 +201,15 @@ ib_wqueue_nowait(
return (node ? node->data : NULL);
}
-/********************************************************************
-Check if queue is empty. */
-ibool
-ib_wqueue_is_empty(
-/*===============*/
- /* out: TRUE if queue empty
- else FALSE */
- const ib_wqueue_t* wq) /* in: work queue */
+/** Check if queue is empty.
+@param wq wait queue
+@return whether the queue is empty */
+bool ib_wqueue_is_empty(ib_wqueue_t* wq)
{
- return(ib_list_is_empty(wq->items));
+ mutex_enter(&wq->mutex);
+ bool is_empty = ib_list_is_empty(wq->items);
+ mutex_exit(&wq->mutex);
+ return is_empty;
}
/********************************************************************
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 012691ef2da..2db068acbcb 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -960,14 +960,18 @@ void ha_myisam::setup_vcols_for_repair(HA_CHECK *param)
ulong new_vreclength= file->s->vreclength;
for (Field **vf= table->vfield; *vf; vf++)
{
- uint vf_end= (*vf)->offset(table->record[0]) + (*vf)->pack_length_in_rec();
- set_if_bigger(new_vreclength, vf_end);
- indexed_vcols|= ((*vf)->flags & PART_KEY_FLAG) != 0;
+ if (!(*vf)->stored_in_db())
+ {
+ uint vf_end= (*vf)->offset(table->record[0]) + (*vf)->pack_length_in_rec();
+ set_if_bigger(new_vreclength, vf_end);
+ indexed_vcols|= ((*vf)->flags & PART_KEY_FLAG) != 0;
+ }
}
if (!indexed_vcols)
return;
file->s->vreclength= new_vreclength;
}
+ DBUG_ASSERT(file->s->base.reclength < file->s->vreclength);
param->fix_record= compute_vcols;
table->use_all_columns();
}
diff --git a/support-files/wsrep.cnf.sh b/support-files/wsrep.cnf.sh
index 51ce3dca2dd..7242fff9f7a 100644
--- a/support-files/wsrep.cnf.sh
+++ b/support-files/wsrep.cnf.sh
@@ -67,10 +67,10 @@ wsrep_slave_threads=1
wsrep_certify_nonPK=1
# Maximum number of rows in write set
-wsrep_max_ws_rows=131072
+wsrep_max_ws_rows=0
# Maximum size of write set
-wsrep_max_ws_size=1073741824
+wsrep_max_ws_size=2147483647
# to enable debug level logging, set this to 1
wsrep_debug=0
diff --git a/win/packaging/create_msi.cmake b/win/packaging/create_msi.cmake
index 01bb6505b3f..ad935803a1e 100644
--- a/win/packaging/create_msi.cmake
+++ b/win/packaging/create_msi.cmake
@@ -367,9 +367,10 @@ IF("$ENV{EXTRA_LIGHT_ARGS}")
ENDIF()
FILE(REMOVE mysql_server.wixobj extra.wixobj)
+STRING(REPLACE " " ";" EXTRA_WIX_PREPROCESSOR_FLAGS_LIST ${EXTRA_WIX_PREPROCESSOR_FLAGS})
EXECUTE_PROCESS(
COMMAND ${CANDLE_EXECUTABLE}
- ${EXTRA_WIX_PREPROCESSOR_FLAGS}
+ ${EXTRA_WIX_PREPROCESSOR_FLAGS_LIST}
${CANDLE_ARCH}
-ext WixUtilExtension
-ext WixFirewallExtension
@@ -379,7 +380,7 @@ EXECUTE_PROCESS(
EXECUTE_PROCESS(
COMMAND ${CANDLE_EXECUTABLE} ${CANDLE_ARCH}
- ${EXTRA_WIX_PREPROCESSOR_FLAGS}
+ ${EXTRA_WIX_PREPROCESSOR_FLAGS_LIST}
-ext WixUtilExtension
-ext WixFirewallExtension
${CMAKE_CURRENT_BINARY_DIR}/extra.wxs