summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2019-12-30 13:56:19 +0200
committerMonty <monty@mariadb.org>2020-03-24 21:00:02 +0200
commit6a9e24d0465fb0e67ba7bbc333263437e7227d8c (patch)
tree02bdd98c5cd807e55c185a6827558ddd6c9993b4
parente5de1e26e723525aaab1cebc5c958c748eb36d9e (diff)
downloadmariadb-git-6a9e24d0465fb0e67ba7bbc333263437e7227d8c.tar.gz
Added support for replication for S3
MDEV-19964 S3 replication support Added new configure options: s3_slave_ignore_updates "If the slave has shares same S3 storage as the master" s3_replicate_alter_as_create_select "When converting S3 table to local table, log all rows in binary log" This allows on to configure slaves to have the S3 storage shared or independent from the master. Other thing: Added new session variable '@@sql_if_exists' to force IF_EXIST to DDL's.
-rw-r--r--libmysqld/libmysql.c116
-rw-r--r--mysql-test/include/show_events.inc6
-rw-r--r--mysql-test/main/drop.result17
-rw-r--r--mysql-test/main/drop.test14
-rw-r--r--mysql-test/main/mysqlbinlog-innodb.result4
-rw-r--r--mysql-test/main/mysqlbinlog.result36
-rw-r--r--mysql-test/main/mysqlbinlog_row_compressed.result2
-rw-r--r--mysql-test/main/mysqlbinlog_row_minimal.result4
-rw-r--r--mysql-test/main/mysqlbinlog_stmt_compressed.result2
-rw-r--r--mysql-test/main/user_var-binlog.result2
-rw-r--r--mysql-test/suite/binlog/r/binlog_base64_flag.result2
-rw-r--r--mysql-test/suite/binlog/r/binlog_mysqlbinlog2.result70
-rw-r--r--mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result2
-rw-r--r--mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result8
-rw-r--r--mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result8
-rw-r--r--mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result2
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_annotate.result12
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result4
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result4
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result4
-rw-r--r--mysql-test/suite/binlog/r/flashback.result4
-rw-r--r--mysql-test/suite/binlog/r/foreign_key.result34
-rw-r--r--mysql-test/suite/binlog_encryption/binlog_row_annotate.result6
-rw-r--r--mysql-test/suite/galera/r/galera_gra_log.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_blackhole_row_annotate.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_hrtime.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_mariadb_slave_capability.result8
-rw-r--r--mysql-test/suite/rpl/r/rpl_mdev382.result6
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result8
-rw-r--r--mysql-test/suite/rpl/r/rpl_sp.result2
-rw-r--r--mysql-test/suite/s3/basic.result8
-rw-r--r--mysql-test/suite/s3/basic.test4
-rw-r--r--mysql-test/suite/s3/my.cnf9
-rw-r--r--mysql-test/suite/s3/replication.inc179
-rw-r--r--mysql-test/suite/s3/replication_mixed.cnf2
-rw-r--r--mysql-test/suite/s3/replication_mixed.result261
-rw-r--r--mysql-test/suite/s3/replication_mixed.test11
-rw-r--r--mysql-test/suite/s3/replication_stmt.cnf2
-rw-r--r--mysql-test/suite/s3/replication_stmt.result261
-rw-r--r--mysql-test/suite/s3/replication_stmt.test11
-rw-r--r--mysql-test/suite/s3/unsupported.result7
-rw-r--r--mysql-test/suite/s3/unsupported.test12
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_server_embedded.result10
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result10
-rw-r--r--sql/handler.cc96
-rw-r--r--sql/handler.h17
-rw-r--r--sql/log.cc2
-rw-r--r--sql/log_event.h4
-rw-r--r--sql/log_event_client.cc2
-rw-r--r--sql/log_event_server.cc18
-rw-r--r--sql/share/errmsg-utf8.txt7
-rw-r--r--sql/sql_alter.cc3
-rw-r--r--sql/sql_class.h3
-rw-r--r--sql/sql_insert.cc91
-rw-r--r--sql/sql_insert.h2
-rw-r--r--sql/sql_lex.h4
-rw-r--r--sql/sql_parse.cc32
-rw-r--r--sql/sql_priv.h4
-rw-r--r--sql/sql_rename.cc23
-rw-r--r--sql/sql_table.cc251
-rw-r--r--sql/sql_table.h6
-rw-r--r--sql/sql_union.cc4
-rw-r--r--sql/sys_vars.cc5
-rw-r--r--storage/maria/CMakeLists.txt2
-rw-r--r--storage/maria/aria_s3_copy.cc2
-rw-r--r--storage/maria/ha_s3.cc56
-rw-r--r--storage/maria/ha_s3.h2
-rw-r--r--storage/maria/maria_def.h7
-rw-r--r--storage/maria/s3_func.c24
-rw-r--r--storage/maria/s3_func.h2
70 files changed, 1499 insertions, 350 deletions
diff --git a/libmysqld/libmysql.c b/libmysqld/libmysql.c
index 476630d77bc..bc39ea9e569 100644
--- a/libmysqld/libmysql.c
+++ b/libmysqld/libmysql.c
@@ -4954,119 +4954,3 @@ ulong STDCALL mysql_net_field_length(uchar **packet)
{
return net_field_length(packet);
}
-
-/********************************************************************
- Dummy functions to avoid linking with libmarias3 / libcurl
-*********************************************************************/
-
-#if defined(WITH_S3_STORAGE_ENGINE) || !defined(FIX_BEFORE_RELESE)
-C_MODE_START
-
-#include <stdint.h>
-struct ms3_st;
-typedef struct ms3_st ms3_st;
-struct ms3_list_st;
-typedef struct ms3_list_st ms3_list_st;
-struct ms3_status_st;
-typedef struct ms3_status_st ms3_status_st;
-enum ms3_set_option_t
-{
- SOME_OPTIONS
-};
-typedef enum ms3_set_option_t ms3_set_option_t;
-typedef void *(*ms3_malloc_callback)(size_t size);
-typedef void (*ms3_free_callback)(void *ptr);
-typedef void *(*ms3_realloc_callback)(void *ptr, size_t size);
-typedef char *(*ms3_strdup_callback)(const char *str);
-typedef void *(*ms3_calloc_callback)(size_t nmemb, size_t size);
-
-
-uint8_t ms3_library_init_malloc(ms3_malloc_callback m,
- ms3_free_callback f, ms3_realloc_callback r,
- ms3_strdup_callback s, ms3_calloc_callback c)
-{
- return 1;
-}
-void ms3_library_deinit(void)
-{
-}
-
-ms3_st *ms3_init(const char *s3key, const char *s3secret,
- const char *region,
- const char *base_domain)
-{
- return 0;
-}
-
-uint8_t ms3_set_option(ms3_st *ms3, ms3_set_option_t option, void *value)
-{
- return 0;
-}
-
-void ms3_deinit(ms3_st *ms3)
-{}
-
-const char *ms3_server_error(ms3_st *ms3)
-{
- return 0;
-}
-const char *ms3_error(uint8_t errcode)
-{
- return 0;
-}
-
-uint8_t ms3_list(ms3_st *ms3, const char *bucket, const char *prefix,
- ms3_list_st **list)
-{
- return 0;
-}
-
-uint8_t ms3_list_dir(ms3_st *ms3, const char *bucket, const char *prefix,
- ms3_list_st **list)
-{
- return 0;
-}
-
-void ms3_list_free(ms3_list_st *list)
-{}
-
-uint8_t ms3_put(ms3_st *ms3, const char *bucket, const char *key,
- const uint8_t *data, size_t length)
-{
- return 1;
-}
-
-uint8_t ms3_get(ms3_st *ms3, const char *bucket, const char *key,
- uint8_t **data, size_t *length)
-{
- return 1;
-}
-
-
-void ms3_free(uint8_t *data)
-{}
-
-uint8_t ms3_delete(ms3_st *ms3, const char *bucket, const char *key)
-{
- return 1;
-}
-
-
-uint8_t ms3_status(ms3_st *ms3, const char *bucket, const char *key,
- ms3_status_st *status)
-{
- return 1;
-}
-
-uint8_t ms3_move(ms3_st *ms3, const char *source_bucket, const char *source_key,
- const char *dest_bucket, const char *dest_key)
-{
- return 1;
-}
-
-void ms3_debug()
-{
-}
-
-C_MODE_END
-#endif /* WITH_S3_STORAGE_ENGINE */
diff --git a/mysql-test/include/show_events.inc b/mysql-test/include/show_events.inc
index 9ee01f73999..453cde39ed5 100644
--- a/mysql-test/include/show_events.inc
+++ b/mysql-test/include/show_events.inc
@@ -80,6 +80,11 @@ if ($binlog_limit != '')
--let $statement= $statement limit $binlog_limit
}
+if (!$binlog_database)
+{
+ --let $binlog_database="database"
+}
+
# Execute the statement and write to $output_file
--let $output_file= GENERATE
--source include/write_result_to_file.inc
@@ -102,6 +107,7 @@ let $script=
s{((?:master|slave|slave-relay)-bin\.[0-9]{6};pos=)[0-9]+DOLLAR}{DOLLAR1POS};
s{SONAME ".*"}{SONAME "LIB"};
s{DOLLARmysqltest_vardir}{MYSQLTEST_VARDIR}g;
+ s{$binlog_database}{database};
||
--let $pre_script= my DOLLARmysqltest_vardir = DOLLARENV{'MYSQLTEST_VARDIR'};
diff --git a/mysql-test/main/drop.result b/mysql-test/main/drop.result
index 88e070af88c..6bbaba950bf 100644
--- a/mysql-test/main/drop.result
+++ b/mysql-test/main/drop.result
@@ -230,3 +230,20 @@ DROP TABLE table1,table2;
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.db(id INT);
DROP DATABASE mysqltest;
+#
+# Verify sql_if_exists
+#
+DROP DATABASE mysqltest;
+ERROR HY000: Can't drop database 'mysqltest'; database doesn't exist
+CREATE DATABASE mysqltest;
+drop table mysqltest.does_not_exists;
+ERROR 42S02: Unknown table 'mysqltest.does_not_exists'
+set @@session.sql_if_exists=1;
+drop table mysqltest.does_not_exists;
+Warnings:
+Note 1051 Unknown table 'mysqltest.does_not_exists'
+drop database mysqltest;
+drop database mysqltest;
+Warnings:
+Note 1008 Can't drop database 'mysqltest'; database doesn't exist
+set @@session.sql_if_exists=0;
diff --git a/mysql-test/main/drop.test b/mysql-test/main/drop.test
index fe8d39c0d7e..923ec676d18 100644
--- a/mysql-test/main/drop.test
+++ b/mysql-test/main/drop.test
@@ -322,3 +322,17 @@ CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.db(id INT);
DROP DATABASE mysqltest;
+--echo #
+--echo # Verify sql_if_exists
+--echo #
+
+--error ER_DB_DROP_EXISTS
+DROP DATABASE mysqltest;
+CREATE DATABASE mysqltest;
+--error ER_BAD_TABLE_ERROR
+drop table mysqltest.does_not_exists;
+set @@session.sql_if_exists=1;
+drop table mysqltest.does_not_exists;
+drop database mysqltest;
+drop database mysqltest;
+set @@session.sql_if_exists=0;
diff --git a/mysql-test/main/mysqlbinlog-innodb.result b/mysql-test/main/mysqlbinlog-innodb.result
index f9f48299f41..342cd7cbd82 100644
--- a/mysql-test/main/mysqlbinlog-innodb.result
+++ b/mysql-test/main/mysqlbinlog-innodb.result
@@ -29,7 +29,7 @@ BEGIN
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -60,7 +60,7 @@ BEGIN
use `foo`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/main/mysqlbinlog.result b/mysql-test/main/mysqlbinlog.result
index decd095bbdf..e514c951284 100644
--- a/mysql-test/main/mysqlbinlog.result
+++ b/mysql-test/main/mysqlbinlog.result
@@ -22,7 +22,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -102,7 +102,7 @@ BEGIN
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -138,7 +138,7 @@ BEGIN
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -189,7 +189,7 @@ BEGIN
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -216,7 +216,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -296,7 +296,7 @@ BEGIN
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -332,7 +332,7 @@ BEGIN
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -383,7 +383,7 @@ BEGIN
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -492,7 +492,7 @@ DELIMITER /*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -544,7 +544,7 @@ DELIMITER /*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -724,7 +724,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1253783037/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -778,7 +778,7 @@ DELIMITER /*!*/;
ROLLBACK/*!*/;
SET TIMESTAMP=1253783037/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -813,7 +813,7 @@ ROLLBACK /* added by mysqlbinlog */;
DELIMITER /*!*/;
SET TIMESTAMP=1266652094/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -855,7 +855,7 @@ ROLLBACK /* added by mysqlbinlog */;
DELIMITER /*!*/;
SET TIMESTAMP=1266652094/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -962,7 +962,7 @@ AAAAAAAAAAAAAAAAAAAgrgJSFzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
# Event: Query thread_id=1 exec_time=0 error_code=0
SET TIMESTAMP=1375907364/*!*/;
SET @@session.pseudo_thread_id=1/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1045,7 +1045,7 @@ AAAAAAAAAAAAAAAAAAA/rQJSGzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
# Event: Query thread_id=1 exec_time=1 error_code=0
SET TIMESTAMP=1375907141/*!*/;
SET @@session.pseudo_thread_id=1/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1128,7 +1128,7 @@ AAAAAAAAAAAAAAAAAAAnrAJSHzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
# Event: Query thread_id=1 exec_time=0 error_code=0
SET TIMESTAMP=1375906879/*!*/;
SET @@session.pseudo_thread_id=1/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1211,7 +1211,7 @@ AAAAAAAAAAAAAAAAAABbsAJSEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
# Event: Query thread_id=1 exec_time=0 error_code=0
SET TIMESTAMP=1375907933/*!*/;
SET @@session.pseudo_thread_id=1/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/main/mysqlbinlog_row_compressed.result b/mysql-test/main/mysqlbinlog_row_compressed.result
index 94125352654..d32c2c21b28 100644
--- a/mysql-test/main/mysqlbinlog_row_compressed.result
+++ b/mysql-test/main/mysqlbinlog_row_compressed.result
@@ -33,7 +33,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=X/*!*/;
SET @@session.pseudo_thread_id=5/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/main/mysqlbinlog_row_minimal.result b/mysql-test/main/mysqlbinlog_row_minimal.result
index 6f3dbab55a8..7133381420a 100644
--- a/mysql-test/main/mysqlbinlog_row_minimal.result
+++ b/mysql-test/main/mysqlbinlog_row_minimal.result
@@ -31,7 +31,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=X/*!*/;
SET @@session.pseudo_thread_id=5/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -379,7 +379,7 @@ BEGIN
#<date> server id 1 end_log_pos 725 CRC32 XXX Query thread_id=5 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
SET @@session.pseudo_thread_id=5/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/main/mysqlbinlog_stmt_compressed.result b/mysql-test/main/mysqlbinlog_stmt_compressed.result
index 42717bccd01..82f36f42fcb 100644
--- a/mysql-test/main/mysqlbinlog_stmt_compressed.result
+++ b/mysql-test/main/mysqlbinlog_stmt_compressed.result
@@ -33,7 +33,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=X/*!*/;
SET @@session.pseudo_thread_id=5/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=#/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/main/user_var-binlog.result b/mysql-test/main/user_var-binlog.result
index 0d8732399c7..9021fcc9628 100644
--- a/mysql-test/main/user_var-binlog.result
+++ b/mysql-test/main/user_var-binlog.result
@@ -29,7 +29,7 @@ SET @`a b`:=_latin1 X'68656C6C6F' COLLATE `latin1_swedish_ci`/*!*/;
use `test`/*!*/;
SET TIMESTAMP=10000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/suite/binlog/r/binlog_base64_flag.result b/mysql-test/suite/binlog/r/binlog_base64_flag.result
index 114272329de..a12e0d8eb31 100644
--- a/mysql-test/suite/binlog/r/binlog_base64_flag.result
+++ b/mysql-test/suite/binlog/r/binlog_base64_flag.result
@@ -57,7 +57,7 @@ ROLLBACK/*!*/;
<#>
use `test`/*!*/;
SET TIMESTAMP=1196959712/*!*/;
-<#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+<#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog2.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog2.result
index 8ecd4d37b1f..a6378f4e094 100644
--- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog2.result
+++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog2.result
@@ -25,7 +25,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -97,7 +97,7 @@ SET INSERT_ID=1/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -163,7 +163,7 @@ SET INSERT_ID=3/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773144/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -208,7 +208,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -253,7 +253,7 @@ SET INSERT_ID=3/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773144/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -280,7 +280,7 @@ SET INSERT_ID=3/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773144/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -325,7 +325,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -368,7 +368,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -430,7 +430,7 @@ SET INSERT_ID=6/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773143/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -460,7 +460,7 @@ SET INSERT_ID=1/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -516,7 +516,7 @@ SET INSERT_ID=6/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773143/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -546,7 +546,7 @@ SET INSERT_ID=3/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773144/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -584,7 +584,7 @@ SET INSERT_ID=6/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773143/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -611,7 +611,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -687,7 +687,7 @@ SET INSERT_ID=3/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773144/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -725,7 +725,7 @@ SET INSERT_ID=6/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773143/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -752,7 +752,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -794,7 +794,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -866,7 +866,7 @@ SET INSERT_ID=1/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -931,7 +931,7 @@ SET INSERT_ID=3/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773144/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -976,7 +976,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1020,7 +1020,7 @@ SET INSERT_ID=3/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773144/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1047,7 +1047,7 @@ SET INSERT_ID=3/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773144/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1092,7 +1092,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1134,7 +1134,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1196,7 +1196,7 @@ SET INSERT_ID=6/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773143/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1226,7 +1226,7 @@ SET INSERT_ID=1/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1282,7 +1282,7 @@ SET INSERT_ID=6/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773143/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1311,7 +1311,7 @@ SET INSERT_ID=3/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773144/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1349,7 +1349,7 @@ SET INSERT_ID=6/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773143/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1376,7 +1376,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1450,7 +1450,7 @@ SET INSERT_ID=3/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773144/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1488,7 +1488,7 @@ SET INSERT_ID=6/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773143/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1515,7 +1515,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1557,7 +1557,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1773142/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result
index 0cc1805eadc..20c62920566 100644
--- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result
+++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result
@@ -371,7 +371,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result
index 22309e964be..89757605a95 100644
--- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result
+++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result
@@ -2268,7 +2268,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
@@ -5277,7 +5277,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
@@ -5677,7 +5677,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
@@ -6315,7 +6315,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result
index 8091242dab7..a7b5989ed9d 100644
--- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result
+++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result
@@ -2268,7 +2268,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
@@ -5300,7 +5300,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
@@ -5706,7 +5706,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
@@ -6354,7 +6354,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result
index 28070fab374..1d025cf38bc 100644
--- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result
+++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result
@@ -146,7 +146,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/suite/binlog/r/binlog_row_annotate.result b/mysql-test/suite/binlog/r/binlog_row_annotate.result
index bbdfe547b18..ecd55142241 100644
--- a/mysql-test/suite/binlog/r/binlog_row_annotate.result
+++ b/mysql-test/suite/binlog/r/binlog_row_annotate.result
@@ -116,7 +116,7 @@ ROLLBACK/*!*/;
#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -354,7 +354,7 @@ ROLLBACK/*!*/;
#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -514,7 +514,7 @@ ROLLBACK/*!*/;
#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -740,7 +740,7 @@ ROLLBACK/*!*/;
#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -978,7 +978,7 @@ ROLLBACK/*!*/;
#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -1138,7 +1138,7 @@ ROLLBACK/*!*/;
#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result b/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result
index 9e95f0a365e..194dc28cf3e 100644
--- a/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result
+++ b/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result
@@ -22,7 +22,7 @@ BEGIN
#Q> insert into t2 values (@v)
SET TIMESTAMP=10000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -92,7 +92,7 @@ DELIMITER /*!*/;
use `test`/*!*/;
SET TIMESTAMP=XXX/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
diff --git a/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result
index 8b138c461ab..a30d7efab95 100644
--- a/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result
+++ b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result
@@ -50,7 +50,7 @@ use `new_test1`/*!*/;
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -291,7 +291,7 @@ use `new_test1`/*!*/;
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result b/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result
index 00f7ce6ead0..f15159c68b3 100644
--- a/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result
@@ -21,7 +21,7 @@ SET @`v`:=_ucs2 X'006100620063' COLLATE `ucs2_general_ci`/*!*/;
use `test`/*!*/;
SET TIMESTAMP=10000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -94,7 +94,7 @@ DELIMITER /*!*/;
use `test`/*!*/;
SET TIMESTAMP=XXX/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
diff --git a/mysql-test/suite/binlog/r/flashback.result b/mysql-test/suite/binlog/r/flashback.result
index bdffaabd673..5ac6e31c080 100644
--- a/mysql-test/suite/binlog/r/flashback.result
+++ b/mysql-test/suite/binlog/r/flashback.result
@@ -60,7 +60,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -422,7 +422,7 @@ COMMIT
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/suite/binlog/r/foreign_key.result b/mysql-test/suite/binlog/r/foreign_key.result
new file mode 100644
index 00000000000..171018f22be
--- /dev/null
+++ b/mysql-test/suite/binlog/r/foreign_key.result
@@ -0,0 +1,34 @@
+reset master;
+CREATE TABLE t1 (
+id INT,
+k INT,
+c CHAR(8),
+KEY (k),
+PRIMARY KEY (id),
+FOREIGN KEY (id) REFERENCES t1 (k)
+) ENGINE=InnoDB;
+LOCK TABLES t1 WRITE;
+SET SESSION FOREIGN_KEY_CHECKS= OFF;
+SET AUTOCOMMIT=OFF;
+INSERT INTO t1 VALUES (1,1,'foo');
+DROP TABLE t1;
+SET SESSION FOREIGN_KEY_CHECKS= ON;
+SET AUTOCOMMIT=ON;
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (
+id INT,
+k INT,
+c CHAR(8),
+KEY (k),
+PRIMARY KEY (id),
+FOREIGN KEY (id) REFERENCES t1 (k)
+) ENGINE=InnoDB
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
+master-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1,1,'foo')
+master-bin.000001 # Table_map # # table_id: # (test.t1)
+master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; set foreign_key_checks=1; DROP TABLE `t1` /* generated by server */
diff --git a/mysql-test/suite/binlog_encryption/binlog_row_annotate.result b/mysql-test/suite/binlog_encryption/binlog_row_annotate.result
index b783488b07a..0cb4305d78b 100644
--- a/mysql-test/suite/binlog_encryption/binlog_row_annotate.result
+++ b/mysql-test/suite/binlog_encryption/binlog_row_annotate.result
@@ -120,7 +120,7 @@ ROLLBACK/*!*/;
#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -361,7 +361,7 @@ ROLLBACK/*!*/;
#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -524,7 +524,7 @@ ROLLBACK/*!*/;
#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/suite/galera/r/galera_gra_log.result b/mysql-test/suite/galera/r/galera_gra_log.result
index a6dca500719..a6c6b1afa0a 100644
--- a/mysql-test/suite/galera/r/galera_gra_log.result
+++ b/mysql-test/suite/galera/r/galera_gra_log.result
@@ -18,7 +18,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=<TIMESTAMP>/*!*/;
SET @@session.pseudo_thread_id=<PSEUDO_THREAD_ID>/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/suite/rpl/r/rpl_blackhole_row_annotate.result b/mysql-test/suite/rpl/r/rpl_blackhole_row_annotate.result
index 3c5711855d8..b88c3576462 100644
--- a/mysql-test/suite/rpl/r/rpl_blackhole_row_annotate.result
+++ b/mysql-test/suite/rpl/r/rpl_blackhole_row_annotate.result
@@ -200,7 +200,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/suite/rpl/r/rpl_hrtime.result b/mysql-test/suite/rpl/r/rpl_hrtime.result
index 7717dcf6700..59c572fd2d2 100644
--- a/mysql-test/suite/rpl/r/rpl_hrtime.result
+++ b/mysql-test/suite/rpl/r/rpl_hrtime.result
@@ -37,7 +37,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1293832861/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/suite/rpl/r/rpl_mariadb_slave_capability.result b/mysql-test/suite/rpl/r/rpl_mariadb_slave_capability.result
index d384422f88a..6b0a27f2134 100644
--- a/mysql-test/suite/rpl/r/rpl_mariadb_slave_capability.result
+++ b/mysql-test/suite/rpl/r/rpl_mariadb_slave_capability.result
@@ -40,12 +40,12 @@ a
1
include/show_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
-slave-relay-bin.000005 # Query # # BEGIN
+slave-relay-bin.000005 # Query # # set foreign_key_checks=1, check_constraint_checks=1; BEGIN
slave-relay-bin.000005 # Annotate_rows # # DELETE FROM t1
slave-relay-bin.000005 # Table_map # # table_id: # (test.t1)
slave-relay-bin.000005 # Delete_rows_v1 # # table_id: # flags: STMT_END_F
slave-relay-bin.000005 # Query # # COMMIT
-slave-relay-bin.000005 # Query # # BEGIN
+slave-relay-bin.000005 # Query # # set foreign_key_checks=1, check_constraint_checks=1; BEGIN
slave-relay-bin.000005 # Annotate_rows # # INSERT INTO t1 /* A comment just to make the annotate event sufficiently long that the dummy event will need to get padded with spaces so that we can test that this works */ VALUES(1)
slave-relay-bin.000005 # Table_map # # table_id: # (test.t1)
slave-relay-bin.000005 # Write_rows_v1 # # table_id: # flags: STMT_END_F
@@ -70,7 +70,7 @@ a
2
include/show_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
-slave-relay-bin.000007 # Query # # BEGIN
+slave-relay-bin.000007 # Query # # set foreign_key_checks=1, check_constraint_checks=1; BEGIN
slave-relay-bin.000007 # Annotate_rows # # INSERT INTO t1 VALUES(2)
slave-relay-bin.000007 # Table_map # # table_id: # (test.t1)
slave-relay-bin.000007 # Write_rows_v1 # # table_id: # flags: STMT_END_F
@@ -137,7 +137,7 @@ a
3
include/show_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
-slave-relay-bin.000008 # Query # # BEGIN
+slave-relay-bin.000008 # Query # # set foreign_key_checks=1, check_constraint_checks=1; BEGIN
slave-relay-bin.000008 # Annotate_rows # # UPDATE t1 SET a = 3
slave-relay-bin.000008 # Table_map # # table_id: # (test.t1)
slave-relay-bin.000008 # Update_rows_v1 # # table_id: # flags: STMT_END_F
diff --git a/mysql-test/suite/rpl/r/rpl_mdev382.result b/mysql-test/suite/rpl/r/rpl_mdev382.result
index ee9377906ad..22060954fd7 100644
--- a/mysql-test/suite/rpl/r/rpl_mdev382.result
+++ b/mysql-test/suite/rpl/r/rpl_mdev382.result
@@ -179,7 +179,7 @@ ROLLBACK/*!*/;
use `db1``; select 'oops!'`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -279,7 +279,7 @@ ROLLBACK/*!*/;
use `db1``; select 'oops!'`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -388,7 +388,7 @@ BEGIN
use `ts``et`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result b/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result
index 42d7fc39b5c..baabcf65dc5 100644
--- a/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result
+++ b/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result
@@ -168,7 +168,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -191,7 +191,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -306,7 +306,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
@@ -335,7 +335,7 @@ ROLLBACK/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/suite/rpl/r/rpl_sp.result b/mysql-test/suite/rpl/r/rpl_sp.result
index 97cc4dad8ad..8fe417d51cc 100644
--- a/mysql-test/suite/rpl/r/rpl_sp.result
+++ b/mysql-test/suite/rpl/r/rpl_sp.result
@@ -785,7 +785,7 @@ DELIMITER /*!*/;
ROLLBACK/*!*/;
SET TIMESTAMP=t/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
diff --git a/mysql-test/suite/s3/basic.result b/mysql-test/suite/s3/basic.result
index 94fe14ab989..9cddca79fc5 100644
--- a/mysql-test/suite/s3/basic.result
+++ b/mysql-test/suite/s3/basic.result
@@ -96,7 +96,15 @@ s3_pagecache_division_limit X
s3_pagecache_file_hash_size X
s3_protocol_version X
s3_region X
+s3_replicate_alter_as_create_select X
s3_secret_key X
+s3_slave_ignore_updates X
+show variables like "s3_slave%";
+Variable_name Value
+s3_slave_ignore_updates OFF
+show variables like "s3_replicate%";
+Variable_name Value
+s3_replicate_alter_as_create_select ON
show status like "s3%";
Variable_name Value
S3_pagecache_blocks_not_flushed X
diff --git a/mysql-test/suite/s3/basic.test b/mysql-test/suite/s3/basic.test
index f3f53a55a1c..91183841a62 100644
--- a/mysql-test/suite/s3/basic.test
+++ b/mysql-test/suite/s3/basic.test
@@ -47,8 +47,12 @@ drop table t1;
--replace_column 2 X
show variables like "s3%";
+show variables like "s3_slave%";
+show variables like "s3_replicate%";
+
--replace_column 2 X
show status like "s3%";
+
#
# clean up
#
diff --git a/mysql-test/suite/s3/my.cnf b/mysql-test/suite/s3/my.cnf
index 1958a04343f..cb0f837a128 100644
--- a/mysql-test/suite/s3/my.cnf
+++ b/mysql-test/suite/s3/my.cnf
@@ -9,3 +9,12 @@ s3=ON
#s3-access-key=...
#s3-secret-key=...
#s3-region=eu-north-1
+
+[mysqld.2]
+s3=ON
+#s3-host-name=s3.amazonaws.com
+#s3-protocol-version=Amazon
+#s3-bucket=MariaDB
+#s3-access-key=...
+#s3-secret-key=...
+#s3-region=eu-north-1
diff --git a/mysql-test/suite/s3/replication.inc b/mysql-test/suite/s3/replication.inc
new file mode 100644
index 00000000000..deef0209542
--- /dev/null
+++ b/mysql-test/suite/s3/replication.inc
@@ -0,0 +1,179 @@
+--source include/have_s3.inc
+--source include/have_sequence.inc
+
+#
+# Tests for S3 replication
+#
+
+connection slave;
+let $SLAVE_DATADIR= `select @@datadir`;
+connection master;
+
+#
+# Create unique database for running the tests
+#
+--source create_database.inc
+
+--echo #
+--echo # Test ALTER TABLE ENGINE S3
+--echo #
+
+create table t1 (a int, b int) engine=aria;
+insert into t1 select seq,seq+10 from seq_1_to_10;
+alter table t1 engine=s3;
+show create table t1;
+
+sync_slave_with_master;
+--replace_result $database database
+--eval use $database
+select * from t1 limit 2;
+--file_exists $SLAVE_DATADIR/$database/t1.frm
+
+connection master;
+alter table t1 add column c int;
+
+sync_slave_with_master;
+--error 1
+--file_exists $SLAVE_DATADIR/$database/t1.frm
+--replace_result $database database
+select * from t1,t1 as t1_tmp limit 2;
+
+--echo # Now test when the .frm table is out of date on the slave
+stop slave;
+
+connection master;
+alter table t1 add column d int, engine=s3;
+connection slave;
+select * from t1 limit 2;
+start slave;
+connection master;
+sync_slave_with_master;
+select * from t1 limit 2;
+
+--echo # Same without tables in the table cache;
+stop slave;
+flush tables;
+connection master;
+alter table t1 add column e int, engine=s3;
+connection slave;
+select * from t1 limit 2;
+start slave;
+connection master;
+sync_slave_with_master;
+select * from t1 limit 2;
+connection master;
+
+--echo # Convert S3 table to Aria. Rows should be binary logged
+alter table t1 engine=aria;
+sync_slave_with_master;
+select * from t1 limit 2;
+show create table t1;
+
+--echo # Convert S3 table to Aria with rename. Rows should be binary logged
+connection master;
+alter table t1 engine=s3;
+alter table t1 rename t2, engine=aria;
+sync_slave_with_master;
+select * from t2 limit 2;
+show create table t2;
+
+connection master;
+drop table t2;
+
+--echo #
+--echo # Test RENAME
+--echo #
+
+create table t1 (a int, b int) engine=aria;
+insert into t1 select seq,seq+10 from seq_1_to_10;
+alter table t1 engine=s3;
+
+rename table t1 to t2;
+sync_slave_with_master;
+--replace_result $database database
+--error 1
+--file_exists $SLAVE_DATADIR/$database/t2.frm
+--error ER_NO_SUCH_TABLE
+select * from t1 limit 2;
+select * from t2 limit 2;
+connection master;
+
+alter table t2 add column f int, rename t1;
+select * from t1 limit 2;
+sync_slave_with_master;
+--error 1
+--file_exists $SLAVE_DATADIR/$database/t1.frm
+--error 1
+--file_exists $SLAVE_DATADIR/$database/t2.frm
+select * from t1 limit 2;
+--replace_result $database database
+--error ER_NO_SUCH_TABLE
+select * from t2 limit 2;
+
+# Check rename of table when a new table has replaced the original one
+
+connection slave;
+stop slave;
+connection master;
+rename table t1 to t2;
+create table t1 (a int, b int) engine=aria;
+alter table t1 engine=s3;
+connection slave;
+start slave;
+connection master;
+sync_slave_with_master;
+select * from t1 limit 2;
+select * from t2 limit 2;
+connection master;
+
+--echo #
+--echo # Test DROP
+--echo #
+drop table t1,t2;
+
+sync_slave_with_master;
+--error 1
+--file_exists $SLAVE_DATADIR/$database/t1.frm
+--error 1
+--file_exists $SLAVE_DATADIR/$database/t2.frm
+--replace_result $database database
+--error ER_NO_SUCH_TABLE
+select * from t1 limit 2;
+--replace_result $database database
+--error ER_NO_SUCH_TABLE
+select * from t2 limit 2;
+
+connection master;
+
+--echo #
+--echo # Test LIKE
+--echo #
+
+create table t1 (a int,b int);
+alter table t1 engine=s3;
+--replace_result $database database
+--error ER_CANT_CREATE_TABLE
+create table t2 like t1;
+sync_slave_with_master;
+--replace_result $database database
+--error ER_NO_SUCH_TABLE
+show create table t2;
+connection master;
+--replace_result $database database
+drop table if exists t1,t2;
+
+--echo #
+--echo # Check slave binary log
+--echo #
+
+sync_slave_with_master;
+--let $binlog_database=$database
+--source include/show_binlog_events.inc
+connection master;
+
+--echo #
+--echo # clean up
+--echo #
+--source drop_database.inc
+sync_slave_with_master;
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/s3/replication_mixed.cnf b/mysql-test/suite/s3/replication_mixed.cnf
new file mode 100644
index 00000000000..0c5b0629cbf
--- /dev/null
+++ b/mysql-test/suite/s3/replication_mixed.cnf
@@ -0,0 +1,2 @@
+!include ../rpl/my.cnf
+!include ./my.cnf
diff --git a/mysql-test/suite/s3/replication_mixed.result b/mysql-test/suite/s3/replication_mixed.result
new file mode 100644
index 00000000000..98b9a78d5f5
--- /dev/null
+++ b/mysql-test/suite/s3/replication_mixed.result
@@ -0,0 +1,261 @@
+include/master-slave.inc
+[connection master]
+set binlog_format=mixed;
+RESET MASTER;
+connection slave;
+set binlog_format=mixed;
+RESET MASTER;
+connection master;
+connection slave;
+connection master;
+#
+# Test ALTER TABLE ENGINE S3
+#
+create table t1 (a int, b int) engine=aria;
+insert into t1 select seq,seq+10 from seq_1_to_10;
+alter table t1 engine=s3;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=S3 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+connection slave;
+use database;
+select * from t1 limit 2;
+a b
+1 11
+2 12
+connection master;
+alter table t1 add column c int;
+connection slave;
+select * from t1,t1 as t1_tmp limit 2;
+a b c a b c
+1 11 NULL 1 11 NULL
+2 12 NULL 1 11 NULL
+# Now test when the .frm table is out of date on the slave
+stop slave;
+connection master;
+alter table t1 add column d int, engine=s3;
+connection slave;
+select * from t1 limit 2;
+a b c d
+1 11 NULL NULL
+2 12 NULL NULL
+start slave;
+connection master;
+connection slave;
+select * from t1 limit 2;
+a b c d
+1 11 NULL NULL
+2 12 NULL NULL
+# Same without tables in the table cache;
+stop slave;
+flush tables;
+connection master;
+alter table t1 add column e int, engine=s3;
+connection slave;
+select * from t1 limit 2;
+a b c d e
+1 11 NULL NULL NULL
+2 12 NULL NULL NULL
+start slave;
+connection master;
+connection slave;
+select * from t1 limit 2;
+a b c d e
+1 11 NULL NULL NULL
+2 12 NULL NULL NULL
+connection master;
+# Convert S3 table to Aria. Rows should be binary logged
+alter table t1 engine=aria;
+connection slave;
+select * from t1 limit 2;
+a b c d e
+1 11 NULL NULL NULL
+2 12 NULL NULL NULL
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ `d` int(11) DEFAULT NULL,
+ `e` int(11) DEFAULT NULL
+) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+# Convert S3 table to Aria with rename. Rows should be binary logged
+connection master;
+alter table t1 engine=s3;
+alter table t1 rename t2, engine=aria;
+connection slave;
+select * from t2 limit 2;
+a b c d e
+1 11 NULL NULL NULL
+2 12 NULL NULL NULL
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ `d` int(11) DEFAULT NULL,
+ `e` int(11) DEFAULT NULL
+) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+connection master;
+drop table t2;
+#
+# Test RENAME
+#
+create table t1 (a int, b int) engine=aria;
+insert into t1 select seq,seq+10 from seq_1_to_10;
+alter table t1 engine=s3;
+rename table t1 to t2;
+connection slave;
+select * from t1 limit 2;
+ERROR 42S02: Table 'database.t1' doesn't exist
+select * from t2 limit 2;
+a b
+1 11
+2 12
+connection master;
+alter table t2 add column f int, rename t1;
+select * from t1 limit 2;
+a b f
+1 11 NULL
+2 12 NULL
+connection slave;
+select * from t1 limit 2;
+a b f
+1 11 NULL
+2 12 NULL
+select * from t2 limit 2;
+ERROR 42S02: Table 'database.t2' doesn't exist
+connection slave;
+stop slave;
+connection master;
+rename table t1 to t2;
+create table t1 (a int, b int) engine=aria;
+alter table t1 engine=s3;
+connection slave;
+start slave;
+connection master;
+connection slave;
+select * from t1 limit 2;
+a b
+select * from t2 limit 2;
+a b f
+1 11 NULL
+2 12 NULL
+connection master;
+#
+# Test DROP
+#
+drop table t1,t2;
+connection slave;
+select * from t1 limit 2;
+ERROR 42S02: Table 'database.t1' doesn't exist
+select * from t2 limit 2;
+ERROR 42S02: Table 'database.t2' doesn't exist
+connection master;
+#
+# Test LIKE
+#
+create table t1 (a int,b int);
+alter table t1 engine=s3;
+create table t2 like t1;
+ERROR HY000: Can't create table `database`.`t2` (errno: 131 "Command not supported by the engine")
+connection slave;
+show create table t2;
+ERROR 42S02: Table 'database.t2' doesn't exist
+connection master;
+drop table if exists t1,t2;
+Warnings:
+Note 1051 Unknown table 'database.t2'
+#
+# Check slave binary log
+#
+connection slave;
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # create database database
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; create table t1 (a int, b int) engine=aria
+slave-bin.000001 # Gtid # # BEGIN GTID #-#-#
+slave-bin.000001 # Query # # use `database`; insert into t1 select seq,seq+10 from seq_1_to_10
+slave-bin.000001 # Query # # COMMIT
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; alter table t1 engine=s3
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; set @@sql_if_exists=1; alter table t1 add column c int
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; set @@sql_if_exists=1; alter table t1 add column d int, engine=s3
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; flush tables
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; set @@sql_if_exists=1; alter table t1 add column e int, engine=s3
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; DROP TABLE IF EXISTS `t1` /* generated by server */
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ `d` int(11) DEFAULT NULL,
+ `e` int(11) DEFAULT NULL
+) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+slave-bin.000001 # Gtid # # BEGIN GTID #-#-#
+slave-bin.000001 # Annotate_rows # # alter table t1 engine=aria
+slave-bin.000001 # Table_map # # table_id: # (database.t1)
+slave-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Query # # COMMIT
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; alter table t1 engine=s3
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; DROP TABLE IF EXISTS `t1` /* generated by server */
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; CREATE TABLE `t2` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ `d` int(11) DEFAULT NULL,
+ `e` int(11) DEFAULT NULL
+) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+slave-bin.000001 # Gtid # # BEGIN GTID #-#-#
+slave-bin.000001 # Annotate_rows # # alter table t1 rename t2, engine=aria
+slave-bin.000001 # Table_map # # table_id: # (database.t2)
+slave-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Query # # COMMIT
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; DROP TABLE IF EXISTS `t2` /* generated by server */
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; create table t1 (a int, b int) engine=aria
+slave-bin.000001 # Gtid # # BEGIN GTID #-#-#
+slave-bin.000001 # Query # # use `database`; insert into t1 select seq,seq+10 from seq_1_to_10
+slave-bin.000001 # Query # # COMMIT
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; alter table t1 engine=s3
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; set @@sql_if_exists=1; rename table t1 to t2
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; set @@sql_if_exists=1; alter table t2 add column f int, rename t1
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; set @@sql_if_exists=1; rename table t1 to t2
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; create table t1 (a int, b int) engine=aria
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; alter table t1 engine=s3
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; DROP TABLE IF EXISTS `t1`,`t2` /* generated by server */
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; create table t1 (a int,b int)
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; alter table t1 engine=s3
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; DROP TABLE IF EXISTS `t1`,`t2` /* generated by server */
+connection master;
+#
+# clean up
+#
+connection slave;
+include/rpl_end.inc
diff --git a/mysql-test/suite/s3/replication_mixed.test b/mysql-test/suite/s3/replication_mixed.test
new file mode 100644
index 00000000000..b2dbc3958bd
--- /dev/null
+++ b/mysql-test/suite/s3/replication_mixed.test
@@ -0,0 +1,11 @@
+--source include/master-slave.inc
+--source include/have_binlog_format_mixed.inc
+
+set binlog_format=mixed;
+RESET MASTER;
+connection slave;
+set binlog_format=mixed;
+RESET MASTER;
+connection master;
+
+--source replication.inc
diff --git a/mysql-test/suite/s3/replication_stmt.cnf b/mysql-test/suite/s3/replication_stmt.cnf
new file mode 100644
index 00000000000..0c5b0629cbf
--- /dev/null
+++ b/mysql-test/suite/s3/replication_stmt.cnf
@@ -0,0 +1,2 @@
+!include ../rpl/my.cnf
+!include ./my.cnf
diff --git a/mysql-test/suite/s3/replication_stmt.result b/mysql-test/suite/s3/replication_stmt.result
new file mode 100644
index 00000000000..ba6573bf219
--- /dev/null
+++ b/mysql-test/suite/s3/replication_stmt.result
@@ -0,0 +1,261 @@
+include/master-slave.inc
+[connection master]
+set binlog_format=statement;
+RESET MASTER;
+connection slave;
+set binlog_format=statement;
+RESET MASTER;
+connection master;
+connection slave;
+connection master;
+#
+# Test ALTER TABLE ENGINE S3
+#
+create table t1 (a int, b int) engine=aria;
+insert into t1 select seq,seq+10 from seq_1_to_10;
+alter table t1 engine=s3;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=S3 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+connection slave;
+use database;
+select * from t1 limit 2;
+a b
+1 11
+2 12
+connection master;
+alter table t1 add column c int;
+connection slave;
+select * from t1,t1 as t1_tmp limit 2;
+a b c a b c
+1 11 NULL 1 11 NULL
+2 12 NULL 1 11 NULL
+# Now test when the .frm table is out of date on the slave
+stop slave;
+connection master;
+alter table t1 add column d int, engine=s3;
+connection slave;
+select * from t1 limit 2;
+a b c d
+1 11 NULL NULL
+2 12 NULL NULL
+start slave;
+connection master;
+connection slave;
+select * from t1 limit 2;
+a b c d
+1 11 NULL NULL
+2 12 NULL NULL
+# Same without tables in the table cache;
+stop slave;
+flush tables;
+connection master;
+alter table t1 add column e int, engine=s3;
+connection slave;
+select * from t1 limit 2;
+a b c d e
+1 11 NULL NULL NULL
+2 12 NULL NULL NULL
+start slave;
+connection master;
+connection slave;
+select * from t1 limit 2;
+a b c d e
+1 11 NULL NULL NULL
+2 12 NULL NULL NULL
+connection master;
+# Convert S3 table to Aria. Rows should be binary logged
+alter table t1 engine=aria;
+connection slave;
+select * from t1 limit 2;
+a b c d e
+1 11 NULL NULL NULL
+2 12 NULL NULL NULL
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ `d` int(11) DEFAULT NULL,
+ `e` int(11) DEFAULT NULL
+) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+# Convert S3 table to Aria with rename. Rows should be binary logged
+connection master;
+alter table t1 engine=s3;
+alter table t1 rename t2, engine=aria;
+connection slave;
+select * from t2 limit 2;
+a b c d e
+1 11 NULL NULL NULL
+2 12 NULL NULL NULL
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ `d` int(11) DEFAULT NULL,
+ `e` int(11) DEFAULT NULL
+) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+connection master;
+drop table t2;
+#
+# Test RENAME
+#
+create table t1 (a int, b int) engine=aria;
+insert into t1 select seq,seq+10 from seq_1_to_10;
+alter table t1 engine=s3;
+rename table t1 to t2;
+connection slave;
+select * from t1 limit 2;
+ERROR 42S02: Table 'database.t1' doesn't exist
+select * from t2 limit 2;
+a b
+1 11
+2 12
+connection master;
+alter table t2 add column f int, rename t1;
+select * from t1 limit 2;
+a b f
+1 11 NULL
+2 12 NULL
+connection slave;
+select * from t1 limit 2;
+a b f
+1 11 NULL
+2 12 NULL
+select * from t2 limit 2;
+ERROR 42S02: Table 'database.t2' doesn't exist
+connection slave;
+stop slave;
+connection master;
+rename table t1 to t2;
+create table t1 (a int, b int) engine=aria;
+alter table t1 engine=s3;
+connection slave;
+start slave;
+connection master;
+connection slave;
+select * from t1 limit 2;
+a b
+select * from t2 limit 2;
+a b f
+1 11 NULL
+2 12 NULL
+connection master;
+#
+# Test DROP
+#
+drop table t1,t2;
+connection slave;
+select * from t1 limit 2;
+ERROR 42S02: Table 'database.t1' doesn't exist
+select * from t2 limit 2;
+ERROR 42S02: Table 'database.t2' doesn't exist
+connection master;
+#
+# Test LIKE
+#
+create table t1 (a int,b int);
+alter table t1 engine=s3;
+create table t2 like t1;
+ERROR HY000: Can't create table `database`.`t2` (errno: 131 "Command not supported by the engine")
+connection slave;
+show create table t2;
+ERROR 42S02: Table 'database.t2' doesn't exist
+connection master;
+drop table if exists t1,t2;
+Warnings:
+Note 1051 Unknown table 'database.t2'
+#
+# Check slave binary log
+#
+connection slave;
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # create database database
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; create table t1 (a int, b int) engine=aria
+slave-bin.000001 # Gtid # # BEGIN GTID #-#-#
+slave-bin.000001 # Query # # use `database`; insert into t1 select seq,seq+10 from seq_1_to_10
+slave-bin.000001 # Query # # COMMIT
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; alter table t1 engine=s3
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; set @@sql_if_exists=1; alter table t1 add column c int
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; set @@sql_if_exists=1; alter table t1 add column d int, engine=s3
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; flush tables
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; set @@sql_if_exists=1; alter table t1 add column e int, engine=s3
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; DROP TABLE IF EXISTS `t1` /* generated by server */
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ `d` int(11) DEFAULT NULL,
+ `e` int(11) DEFAULT NULL
+) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+slave-bin.000001 # Gtid # # BEGIN GTID #-#-#
+slave-bin.000001 # Annotate_rows # # alter table t1 engine=aria
+slave-bin.000001 # Table_map # # table_id: # (database.t1)
+slave-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Query # # COMMIT
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; alter table t1 engine=s3
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; DROP TABLE IF EXISTS `t1` /* generated by server */
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; CREATE TABLE `t2` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ `d` int(11) DEFAULT NULL,
+ `e` int(11) DEFAULT NULL
+) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+slave-bin.000001 # Gtid # # BEGIN GTID #-#-#
+slave-bin.000001 # Annotate_rows # # alter table t1 rename t2, engine=aria
+slave-bin.000001 # Table_map # # table_id: # (database.t2)
+slave-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
+slave-bin.000001 # Query # # COMMIT
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; DROP TABLE IF EXISTS `t2` /* generated by server */
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; create table t1 (a int, b int) engine=aria
+slave-bin.000001 # Gtid # # BEGIN GTID #-#-#
+slave-bin.000001 # Query # # use `database`; insert into t1 select seq,seq+10 from seq_1_to_10
+slave-bin.000001 # Query # # COMMIT
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; alter table t1 engine=s3
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; set @@sql_if_exists=1; rename table t1 to t2
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; set @@sql_if_exists=1; alter table t2 add column f int, rename t1
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; set @@sql_if_exists=1; rename table t1 to t2
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; create table t1 (a int, b int) engine=aria
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; alter table t1 engine=s3
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; DROP TABLE IF EXISTS `t1`,`t2` /* generated by server */
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; create table t1 (a int,b int)
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; alter table t1 engine=s3
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `database`; DROP TABLE IF EXISTS `t1`,`t2` /* generated by server */
+connection master;
+#
+# clean up
+#
+connection slave;
+include/rpl_end.inc
diff --git a/mysql-test/suite/s3/replication_stmt.test b/mysql-test/suite/s3/replication_stmt.test
new file mode 100644
index 00000000000..0d0de166c64
--- /dev/null
+++ b/mysql-test/suite/s3/replication_stmt.test
@@ -0,0 +1,11 @@
+--source include/master-slave.inc
+--source include/have_binlog_format_statement.inc
+
+set binlog_format=statement;
+RESET MASTER;
+connection slave;
+set binlog_format=statement;
+RESET MASTER;
+connection master;
+
+--source replication.inc
diff --git a/mysql-test/suite/s3/unsupported.result b/mysql-test/suite/s3/unsupported.result
index 4ced713f73f..e12b57af2ba 100644
--- a/mysql-test/suite/s3/unsupported.result
+++ b/mysql-test/suite/s3/unsupported.result
@@ -6,3 +6,10 @@ create temporary table t1 (a int);
alter table t1 engine=S3;
ERROR HY000: Can't create table `database`.`t1` (errno: 131 "Command not supported by the engine")
drop temporary table t1;
+#
+# CREATE of S3 table
+#
+create or replace table t1 (a int, b int, key (a)) engine=S3;
+ERROR HY000: Can't create table `database`.`t1` (errno: 131 "Command not supported by the engine")
+select * from t1;
+ERROR 42S02: Table 'database.t1' doesn't exist
diff --git a/mysql-test/suite/s3/unsupported.test b/mysql-test/suite/s3/unsupported.test
index c2b2a89e424..dbc9584ec3c 100644
--- a/mysql-test/suite/s3/unsupported.test
+++ b/mysql-test/suite/s3/unsupported.test
@@ -26,6 +26,18 @@ create temporary table t1 (a int);
alter table t1 engine=S3;
drop temporary table t1;
+--echo #
+--echo # CREATE of S3 table
+--echo #
+
+--replace_result $database database
+--error ER_CANT_CREATE_TABLE
+create or replace table t1 (a int, b int, key (a)) engine=S3;
+--replace_result $database database
+--error ER_NO_SUCH_TABLE
+select * from t1;
+
+#
# clean up
#
--source drop_database.inc
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
index 593891425c3..57f68d20066 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
@@ -3203,6 +3203,16 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY NO
COMMAND_LINE_ARGUMENT NULL
+VARIABLE_NAME SQL_IF_EXISTS
+VARIABLE_SCOPE SESSION
+VARIABLE_TYPE BOOLEAN
+VARIABLE_COMMENT If set to 1 adds an implicate IF EXISTS to ALTER, RENAME and DROP of TABLES, VIEWS, FUNCTIONS and PACKAGES
+NUMERIC_MIN_VALUE NULL
+NUMERIC_MAX_VALUE NULL
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST OFF,ON
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT NULL
VARIABLE_NAME SQL_LOG_BIN
VARIABLE_SCOPE SESSION
VARIABLE_TYPE BOOLEAN
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
index 483da8a82e7..bed0bf53bb4 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
@@ -3873,6 +3873,16 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY NO
COMMAND_LINE_ARGUMENT NULL
+VARIABLE_NAME SQL_IF_EXISTS
+VARIABLE_SCOPE SESSION
+VARIABLE_TYPE BOOLEAN
+VARIABLE_COMMENT If set to 1 adds an implicate IF EXISTS to ALTER, RENAME and DROP of TABLES, VIEWS, FUNCTIONS and PACKAGES
+NUMERIC_MIN_VALUE NULL
+NUMERIC_MAX_VALUE NULL
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST OFF,ON
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT NULL
VARIABLE_NAME SQL_LOG_BIN
VARIABLE_SCOPE SESSION
VARIABLE_TYPE BOOLEAN
diff --git a/sql/handler.cc b/sql/handler.cc
index 2a92a041920..bcd7da1c711 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -4822,6 +4822,8 @@ handler::ha_rename_table(const char *from, const char *to)
int
handler::ha_delete_table(const char *name)
{
+ if (ha_check_if_updates_are_ignored(current_thd, ht, "DROP"))
+ return 0; // Simulate dropped
mark_trx_read_write();
return delete_table(name);
}
@@ -4840,9 +4842,11 @@ void
handler::ha_drop_table(const char *name)
{
DBUG_ASSERT(m_lock_type == F_UNLCK);
- mark_trx_read_write();
+ if (ha_check_if_updates_are_ignored(current_thd, ht, "DROP"))
+ return;
- return drop_table(name);
+ mark_trx_read_write();
+ drop_table(name);
}
@@ -5719,6 +5723,28 @@ bool ha_table_exists(THD *thd, const LEX_CSTRING *db,
DBUG_RETURN(FALSE);
}
+
+/*
+ Check if the CREATE/ALTER table should be ignored
+ This could happen for slaves where the table is shared between master
+ and slave
+
+ If statement is ignored, write a note
+*/
+
+bool ha_check_if_updates_are_ignored(THD *thd, handlerton *hton,
+ const char *op)
+{
+ DBUG_ENTER("ha_check_if_updates_are_ignored");
+ if (!thd->slave_thread || !(hton= ha_checktype(thd, hton, 1)))
+ DBUG_RETURN(0); // Not slave or no engine
+ if (!(hton->flags & HTON_IGNORE_UPDATES))
+ DBUG_RETURN(0); // Not shared table
+ my_error(ER_SLAVE_IGNORED_SHARED_TABLE, MYF(ME_NOTE), op);
+ DBUG_RETURN(1);
+}
+
+
/**
Discover all table names in a given database
*/
@@ -6406,33 +6432,12 @@ static int write_locked_table_maps(THD *thd)
++table_ptr)
{
TABLE *const table= *table_ptr;
- DBUG_PRINT("info", ("Checking table %s", table->s->table_name.str));
if (table->current_lock == F_WRLCK &&
table->file->check_table_binlog_row_based(0))
{
- /*
- We need to have a transactional behavior for SQLCOM_CREATE_TABLE
- (e.g. CREATE TABLE... SELECT * FROM TABLE) in order to keep a
- compatible behavior with the STMT based replication even when
- the table is not transactional. In other words, if the operation
- fails while executing the insert phase nothing is written to the
- binlog.
-
- Note that at this point, we check the type of a set of tables to
- create the table map events. In the function binlog_log_row(),
- which calls the current function, we check the type of the table
- of the current row.
- */
- bool const has_trans= thd->lex->sql_command == SQLCOM_CREATE_TABLE ||
- table->file->has_transactions();
- int const error= thd->binlog_write_table_map(table, has_trans,
- &with_annotate);
- /*
- If an error occurs, it is the responsibility of the caller to
- roll back the transaction.
- */
- if (unlikely(error))
+ if (binlog_write_table_map(thd, table, with_annotate))
DBUG_RETURN(1);
+ with_annotate= 0;
}
}
}
@@ -6440,6 +6445,38 @@ static int write_locked_table_maps(THD *thd)
}
+int binlog_write_table_map(THD *thd, TABLE *table, bool with_annotate)
+{
+ DBUG_ENTER("binlog_write_table_map");
+ DBUG_PRINT("info", ("table %s", table->s->table_name.str));
+ /*
+ We need to have a transactional behavior for SQLCOM_CREATE_TABLE
+ (e.g. CREATE TABLE... SELECT * FROM TABLE) in order to keep a
+ compatible behavior with the STMT based replication even when
+ the table is not transactional. In other words, if the operation
+ fails while executing the insert phase nothing is written to the
+ binlog.
+
+ Note that at this point, we check the type of a set of tables to
+ create the table map events. In the function binlog_log_row(),
+ which calls the current function, we check the type of the table
+ of the current row.
+ */
+ bool const has_trans= ((sql_command_flags[thd->lex->sql_command] &
+ (CF_SCHEMA_CHANGE | CF_ADMIN_COMMAND)) ||
+ table->file->has_transactions());
+ int const error= thd->binlog_write_table_map(table, has_trans,
+ &with_annotate);
+ /*
+ If an error occurs, it is the responsibility of the caller to
+ roll back the transaction.
+ */
+ if (unlikely(error))
+ DBUG_RETURN(1);
+ DBUG_RETURN(0);
+}
+
+
static int binlog_log_row_internal(TABLE* table,
const uchar *before_record,
const uchar *after_record,
@@ -6462,10 +6499,13 @@ static int binlog_log_row_internal(TABLE* table,
compatible behavior with the STMT based replication even when
the table is not transactional. In other words, if the operation
fails while executing the insert phase nothing is written to the
- binlog.
+ binlog. We need the same also for ALTER TABLE in the case we convert
+ a shared table to a not shared table as in this case we will log all
+ rows.
*/
- bool const has_trans= thd->lex->sql_command == SQLCOM_CREATE_TABLE ||
- table->file->has_transactions();
+ bool const has_trans= ((sql_command_flags[thd->lex->sql_command] &
+ (CF_SCHEMA_CHANGE | CF_ADMIN_COMMAND)) ||
+ table->file->has_transactions());
error= (*log_func)(thd, table, has_trans, before_record, after_record);
}
return error ? HA_ERR_RBR_LOGGING_FAILED : 0;
diff --git a/sql/handler.h b/sql/handler.h
index b99d33874e9..01e10d9c4c6 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1728,6 +1728,20 @@ handlerton *ha_default_tmp_handlerton(THD *thd);
/* can be replicated by wsrep replication provider plugin */
#define HTON_WSREP_REPLICATION (1 << 13)
+/* Shared storage on slave. Ignore on slave any CREATE TABLE, DROP or updates */
+#define HTON_IGNORE_UPDATES (1 << 14)
+
+/*
+ The table may not exists on the slave. The effects of having this flag are:
+ - ALTER TABLE that changes engine from this table to another engine will
+ be replicated as CREATE + INSERT
+ - CREATE ... LIKE shared_table will be replicated as a full CREATE TABLE
+ - ALTER TABLE for this engine will have "IF EXISTS" added.
+ - RENAME TABLE for this engine will have "IF EXISTS" added.
+ - DROP TABLE for this engine will have "IF EXISTS" added.
+*/
+#define HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE (1 << 15)
+
class Ha_trx_info;
struct THD_TRANS
@@ -5044,6 +5058,7 @@ int ha_discover_table_names(THD *thd, LEX_CSTRING *db, MY_DIR *dirp,
Discovered_table_list *result, bool reusable);
bool ha_table_exists(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name,
handlerton **hton= 0, bool *is_sequence= 0);
+bool ha_check_if_updates_are_ignored(THD *thd, handlerton *hton, const char *op);
#endif
/* key cache */
@@ -5181,7 +5196,7 @@ int binlog_log_row(TABLE* table,
if (unlikely(this_tracker)) \
tracker->stop_tracking(table->in_use); \
}
-
+int binlog_write_table_map(THD *thd, TABLE *table, bool with_annotate);
void print_keydup_error(TABLE *table, KEY *key, const char *msg, myf errflag);
void print_keydup_error(TABLE *table, KEY *key, myf errflag);
diff --git a/sql/log.cc b/sql/log.cc
index 647e5fbd60d..271fe647d87 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -5916,7 +5916,7 @@ binlog_start_consistent_snapshot(handlerton *hton, THD *thd)
nonzero if an error pops up when writing the table map event.
*/
int THD::binlog_write_table_map(TABLE *table, bool is_transactional,
- my_bool *with_annotate)
+ bool *with_annotate)
{
int error;
DBUG_ENTER("THD::binlog_write_table_map");
diff --git a/sql/log_event.h b/sql/log_event.h
index b634c6e2c94..6401ae326e3 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -524,11 +524,11 @@ class String;
*/
#define OPTIONS_WRITTEN_TO_BIN_LOG \
(OPTION_AUTO_IS_NULL | OPTION_NO_FOREIGN_KEY_CHECKS | \
- OPTION_RELAXED_UNIQUE_CHECKS | OPTION_NOT_AUTOCOMMIT)
+ OPTION_RELAXED_UNIQUE_CHECKS | OPTION_NOT_AUTOCOMMIT | OPTION_IF_EXISTS)
/* Shouldn't be defined before */
#define EXPECTED_OPTIONS \
- ((1ULL << 14) | (1ULL << 26) | (1ULL << 27) | (1ULL << 19))
+ ((1ULL << 14) | (1ULL << 26) | (1ULL << 27) | (1ULL << 19) | (1ULL << 28))
#if OPTIONS_WRITTEN_TO_BIN_LOG != EXPECTED_OPTIONS
#error OPTIONS_WRITTEN_TO_BIN_LOG must NOT change their values!
diff --git a/sql/log_event_client.cc b/sql/log_event_client.cc
index faec2a29407..5686148ceb3 100644
--- a/sql/log_event_client.cc
+++ b/sql/log_event_client.cc
@@ -1899,6 +1899,8 @@ bool Query_log_event::print_query_header(IO_CACHE* file,
print_set_option(file, tmp, OPTION_NO_CHECK_CONSTRAINT_CHECKS,
~flags2,
"@@session.check_constraint_checks", &need_comma) ||
+ print_set_option(file, tmp, OPTION_IF_EXISTS, flags2,
+ "@@session.sql_if_exists", &need_comma)||
my_b_printf(file,"%s\n", print_event_info->delimiter))
goto err;
print_event_info->flags2= flags2;
diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc
index f7156013069..bc7e7d7b7a1 100644
--- a/sql/log_event_server.cc
+++ b/sql/log_event_server.cc
@@ -1024,6 +1024,24 @@ void Query_log_event::pack_info(Protocol *protocol)
append_identifier(protocol->thd, &buf, db, db_len);
buf.append(STRING_WITH_LEN("; "));
}
+ if (flags2 & (OPTION_NO_FOREIGN_KEY_CHECKS | OPTION_AUTO_IS_NULL |
+ OPTION_RELAXED_UNIQUE_CHECKS |
+ OPTION_NO_CHECK_CONSTRAINT_CHECKS |
+ OPTION_IF_EXISTS))
+ {
+ buf.append(STRING_WITH_LEN("set "));
+ if (flags2 & OPTION_NO_FOREIGN_KEY_CHECKS)
+ buf.append(STRING_WITH_LEN("foreign_key_checks=1, "));
+ if (flags2 & OPTION_AUTO_IS_NULL)
+ buf.append(STRING_WITH_LEN("sql_auto_is_null, "));
+ if (flags2 & OPTION_RELAXED_UNIQUE_CHECKS)
+ buf.append(STRING_WITH_LEN("unique_checks=1, "));
+ if (flags2 & OPTION_NO_CHECK_CONSTRAINT_CHECKS)
+ buf.append(STRING_WITH_LEN("check_constraint_checks=1, "));
+ if (flags2 & OPTION_IF_EXISTS)
+ buf.append(STRING_WITH_LEN("@@sql_if_exists=1, "));
+ buf[buf.length()-2]=';';
+ }
if (query && q_len)
buf.append(query, q_len);
protocol->store(&buf);
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index afa9d72f2d8..2ff60a98c2b 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -7950,3 +7950,10 @@ ER_LOAD_INFILE_CAPABILITY_DISABLED
rum "Comanda folosită nu este permisă deoarece clientul sau serverul MariaDB a dezactivat această capabilitate"
ER_NO_SECURE_TRANSPORTS_CONFIGURED
eng "No secure transports are configured, unable to set --require_secure_transport=ON"
+ER_SLAVE_IGNORED_SHARED_TABLE
+ eng "Slave SQL thread ignored the '%s' because table is shared"
+ ger "Slave-SQL-Thread hat die Abfrage '%s' ignoriert"
+ nla "Slave SQL thread negeerde de query '%s'"
+ por "Slave SQL thread ignorado a consulta devido '%s'"
+ spa "Slave SQL thread ignorado el query '%s'"
+ swe "Slav SQL tråden ignorerade '%s' pga tabellen är delad"
diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc
index 131f74c2753..9ac0ac7a551 100644
--- a/sql/sql_alter.cc
+++ b/sql/sql_alter.cc
@@ -376,6 +376,9 @@ bool Sql_cmd_alter_table::execute(THD *thd)
/* first table of first SELECT_LEX */
TABLE_LIST *first_table= (TABLE_LIST*) select_lex->table_list.first;
+ if (thd->variables.option_bits & OPTION_IF_EXISTS)
+ lex->create_info.set(DDL_options_st::OPT_IF_EXISTS);
+
const bool used_engine= lex->create_info.used_fields & HA_CREATE_USED_ENGINE;
DBUG_ASSERT((m_storage_engine_name.str != NULL) == used_engine);
if (used_engine)
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 6d3a18259a0..def9cc9a05d 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -2577,7 +2577,7 @@ public:
void binlog_start_trans_and_stmt();
void binlog_set_stmt_begin();
int binlog_write_table_map(TABLE *table, bool is_transactional,
- my_bool *with_annotate= 0);
+ bool *with_annotate= 0);
int binlog_write_row(TABLE* table, bool is_transactional,
const uchar *buf);
int binlog_delete_row(TABLE* table, bool is_transactional,
@@ -5702,7 +5702,6 @@ public:
{}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
- int binlog_show_create_table(TABLE **tables, uint count);
void store_values(List<Item> &values);
bool send_eof();
virtual void abort_result_set();
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 708423c6214..d2331fd71ef 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -77,6 +77,7 @@
#include "sql_audit.h"
#include "sql_derived.h" // mysql_handle_derived
#include "sql_prepare.h"
+#include "rpl_filter.h" // binlog_filter
#include <my_bit.h>
#include "debug_sync.h"
@@ -95,6 +96,8 @@ pthread_handler_t handle_delayed_insert(void *arg);
static void unlink_blobs(TABLE *table);
#endif
static bool check_view_insertability(THD *thd, TABLE_LIST *view);
+static int binlog_show_create_table(THD *thd, TABLE *table,
+ Table_specification_st *create_info);
/*
Check that insert/update fields are from the same single table of a view.
@@ -4545,13 +4548,9 @@ select_create::prepare(List<Item> &_values, SELECT_LEX_UNIT *u)
return error;
TABLE const *const table = *tables;
- if (thd->is_current_stmt_binlog_format_row() &&
+ if (thd->is_current_stmt_binlog_format_row() &&
!table->s->tmp_table)
- {
- int error;
- if (unlikely((error= ptr->binlog_show_create_table(tables, count))))
- return error;
- }
+ return binlog_show_create_table(thd, *tables, ptr->create_info);
return 0;
}
select_create *ptr;
@@ -4650,8 +4649,9 @@ select_create::prepare(List<Item> &_values, SELECT_LEX_UNIT *u)
DBUG_RETURN(0);
}
-int
-select_create::binlog_show_create_table(TABLE **tables, uint count)
+
+static int binlog_show_create_table(THD *thd, TABLE *table,
+ Table_specification_st *create_info)
{
/*
Note 1: In RBR mode, we generate a CREATE TABLE statement for the
@@ -4670,14 +4670,12 @@ select_create::binlog_show_create_table(TABLE **tables, uint count)
statement transaction cache.
*/
DBUG_ASSERT(thd->is_current_stmt_binlog_format_row());
- DBUG_ASSERT(tables && *tables && count > 0);
-
StringBuffer<2048> query(system_charset_info);
int result;
TABLE_LIST tmp_table_list;
tmp_table_list.reset();
- tmp_table_list.table = *tables;
+ tmp_table_list.table = table;
result= show_create_table(thd, &tmp_table_list, &query,
create_info, WITH_DB_NAME);
@@ -4706,6 +4704,77 @@ select_create::binlog_show_create_table(TABLE **tables, uint count)
return result;
}
+
+/**
+ Log CREATE TABLE to binary log
+
+ @param thd Thread handler
+ @param table Log create statement for this table
+
+ This function is called from ALTER TABLE for a shared table converted
+ to a not shared table.
+*/
+
+bool binlog_create_table(THD *thd, TABLE *table)
+{
+ /* Don't log temporary tables in row format */
+ if (thd->variables.binlog_format == BINLOG_FORMAT_ROW &&
+ table->s->tmp_table)
+ return 0;
+ if (!mysql_bin_log.is_open() ||
+ !(thd->variables.option_bits & OPTION_BIN_LOG) ||
+ (thd->wsrep_binlog_format() == BINLOG_FORMAT_STMT &&
+ !binlog_filter->db_ok(table->s->db.str)))
+ return 0;
+
+ /*
+ We have to use ROW format to ensure that future row inserts will be
+ logged
+ */
+ thd->set_current_stmt_binlog_format_row();
+ return binlog_show_create_table(thd, table, 0) != 0;
+}
+
+
+/**
+ Log DROP TABLE to binary log
+
+ @param thd Thread handler
+ @param table Log create statement for this table
+
+ This function is called from ALTER TABLE for a shared table converted
+ to a not shared table.
+*/
+
+bool binlog_drop_table(THD *thd, TABLE *table)
+{
+ StringBuffer<2048> query(system_charset_info);
+ /* Don't log temporary tables in row format */
+ if (!table->s->table_creation_was_logged)
+ return 0;
+ if (!mysql_bin_log.is_open() ||
+ !(thd->variables.option_bits & OPTION_BIN_LOG) ||
+ (thd->wsrep_binlog_format() == BINLOG_FORMAT_STMT &&
+ !binlog_filter->db_ok(table->s->db.str)))
+ return 0;
+
+ query.append("DROP ");
+ if (table->s->tmp_table)
+ query.append("TEMPORARY ");
+ query.append("TABLE IF EXISTS ");
+ append_identifier(thd, &query, &table->s->db);
+ query.append(".");
+ append_identifier(thd, &query, &table->s->table_name);
+
+ return thd->binlog_query(THD::STMT_QUERY_TYPE,
+ query.ptr(), query.length(),
+ /* is_trans */ TRUE,
+ /* direct */ FALSE,
+ /* suppress_use */ TRUE,
+ 0) > 0;
+}
+
+
void select_create::store_values(List<Item> &values)
{
fill_record_n_invoke_before_triggers(thd, table, field, values, 1,
diff --git a/sql/sql_insert.h b/sql/sql_insert.h
index 977a0eb23c8..f1c2334235d 100644
--- a/sql/sql_insert.h
+++ b/sql/sql_insert.h
@@ -41,6 +41,8 @@ int vers_insert_history_row(TABLE *table);
int write_record(THD *thd, TABLE *table, COPY_INFO *info,
select_result *returning= NULL);
void kill_delayed_threads(void);
+bool binlog_create_table(THD *thd, TABLE *table);
+bool binlog_drop_table(THD *thd, TABLE *table);
#ifdef EMBEDDED_LIBRARY
inline void kill_delayed_threads(void) {}
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index b2f0272a7d2..56142023c82 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -859,7 +859,7 @@ protected:
bool saved_error;
bool prepare_join(THD *thd, SELECT_LEX *sl, select_result *result,
- ulong additional_options,
+ ulonglong additional_options,
bool is_union_select);
bool join_union_type_handlers(THD *thd,
class Type_holder *holders, uint count);
@@ -981,7 +981,7 @@ public:
/* UNION methods */
bool prepare(TABLE_LIST *derived_arg, select_result *sel_result,
- ulong additional_options);
+ ulonglong additional_options);
bool optimize();
void optimize_bag_operation(bool is_outer_distinct);
bool exec();
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 0c863a8c02d..6d40d951615 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3395,7 +3395,8 @@ mysql_execute_command(THD *thd)
according to slave filtering rules.
Returning success without producing any errors in this case.
*/
- if (!thd->lex->create_info.if_exists())
+ if (!thd->lex->create_info.if_exists() &&
+ !(thd->variables.option_bits & OPTION_IF_EXISTS))
DBUG_RETURN(0);
/*
DROP TRIGGER IF NOT EXISTS will return without an error later
@@ -4128,8 +4129,11 @@ mysql_execute_command(THD *thd)
res = ha_show_status(thd, lex->create_info.db_type, HA_ENGINE_MUTEX);
break;
}
- case SQLCOM_CREATE_INDEX:
case SQLCOM_DROP_INDEX:
+ if (thd->variables.option_bits & OPTION_IF_EXISTS)
+ lex->create_info.set(DDL_options_st::OPT_IF_EXISTS);
+ /* fall through */
+ case SQLCOM_CREATE_INDEX:
/*
CREATE INDEX and DROP INDEX are implemented by calling ALTER
TABLE with proper arguments.
@@ -4272,6 +4276,9 @@ mysql_execute_command(THD *thd)
WSREP_TO_ISOLATION_BEGIN(0, 0, first_table);
+ if (thd->variables.option_bits & OPTION_IF_EXISTS)
+ lex->create_info.set(DDL_options_st::OPT_IF_EXISTS);
+
if (mysql_rename_tables(thd, first_table, 0, lex->if_exists()))
goto error;
break;
@@ -4856,8 +4863,9 @@ mysql_execute_command(THD *thd)
recover from multi-table DROP TABLE that was aborted in the
middle.
*/
- if (thd->slave_thread && !thd->slave_expected_error &&
- slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT)
+ if ((thd->slave_thread && !thd->slave_expected_error &&
+ slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT) ||
+ thd->variables.option_bits & OPTION_IF_EXISTS)
lex->create_info.set(DDL_options_st::OPT_IF_EXISTS);
#ifdef WITH_WSREP
@@ -4878,7 +4886,7 @@ mysql_execute_command(THD *thd)
/* DDL and binlog write order are protected by metadata locks. */
res= mysql_rm_table(thd, first_table, lex->if_exists(), lex->tmp_table(),
- lex->table_type == TABLE_TYPE_SEQUENCE);
+ lex->table_type == TABLE_TYPE_SEQUENCE, 0);
/*
When dropping temporary tables if @@session_track_state_change is ON
@@ -5085,6 +5093,9 @@ mysql_execute_command(THD *thd)
}
case SQLCOM_DROP_DB:
{
+ if (thd->variables.option_bits & OPTION_IF_EXISTS)
+ lex->create_info.set(DDL_options_st::OPT_IF_EXISTS);
+
if (prepare_db_action(thd, DROP_ACL, &lex->name))
break;
@@ -5633,6 +5644,8 @@ mysql_execute_command(THD *thd)
case SQLCOM_ALTER_PROCEDURE:
case SQLCOM_ALTER_FUNCTION:
+ if (thd->variables.option_bits & OPTION_IF_EXISTS)
+ lex->create_info.set(DDL_options_st::OPT_IF_EXISTS);
if (alter_routine(thd, lex))
goto error;
break;
@@ -5640,8 +5653,9 @@ mysql_execute_command(THD *thd)
case SQLCOM_DROP_FUNCTION:
case SQLCOM_DROP_PACKAGE:
case SQLCOM_DROP_PACKAGE_BODY:
+ if (thd->variables.option_bits & OPTION_IF_EXISTS)
+ lex->create_info.set(DDL_options_st::OPT_IF_EXISTS);
if (drop_routine(thd, lex))
-
goto error;
break;
case SQLCOM_SHOW_CREATE_PROC:
@@ -5710,6 +5724,9 @@ mysql_execute_command(THD *thd)
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);
+ if (thd->variables.option_bits & OPTION_IF_EXISTS)
+ lex->create_info.set(DDL_options_st::OPT_IF_EXISTS);
+
/* Conditionally writes to binlog. */
res= mysql_drop_view(thd, first_table, thd->lex->drop_mode);
break;
@@ -5723,6 +5740,9 @@ mysql_execute_command(THD *thd)
}
case SQLCOM_DROP_TRIGGER:
{
+ if (thd->variables.option_bits & OPTION_IF_EXISTS)
+ lex->create_info.set(DDL_options_st::OPT_IF_EXISTS);
+
/* Conditionally writes to binlog. */
res= mysql_create_or_drop_trigger(thd, all_tables, 0);
break;
diff --git a/sql/sql_priv.h b/sql/sql_priv.h
index 7be2692a33b..c3ea9226643 100644
--- a/sql/sql_priv.h
+++ b/sql/sql_priv.h
@@ -146,7 +146,7 @@
/** The following speeds up inserts to InnoDB tables by suppressing unique
key checks in some cases */
#define OPTION_RELAXED_UNIQUE_CHECKS (1ULL << 27) // THD, user, binlog
-#define SELECT_NO_UNLOCK (1ULL << 28) // SELECT, intern
+#define OPTION_IF_EXISTS (1ULL << 28) // binlog
#define OPTION_SCHEMA_TABLE (1ULL << 29) // SELECT, intern
/** Flag set if setup_tables already done */
#define OPTION_SETUP_TABLES_DONE (1ULL << 30) // intern
@@ -179,7 +179,7 @@
#define OPTION_RPL_SKIP_PARALLEL (1ULL << 38)
#define OPTION_NO_QUERY_CACHE (1ULL << 39) // SELECT, user
#define OPTION_PROCEDURE_CLAUSE (1ULL << 40) // Internal usage
-
+#define SELECT_NO_UNLOCK (1ULL << 41) // SELECT, intern
#define OPTION_LEX_FOUND_COMMENT (1ULL << 0) // intern, parser
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index f6a0c53a022..73d0f377dd9 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -180,7 +180,15 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent,
if (likely(!silent && !error))
{
+ ulonglong save_option_bits= thd->variables.option_bits;
+ if (force_if_exists && ! if_exists)
+ {
+ /* Add IF EXISTS to binary log */
+ thd->variables.option_bits|= OPTION_IF_EXISTS;
+ }
binlog_error= write_bin_log(thd, TRUE, thd->query(), thd->query_length());
+ thd->variables.option_bits= save_option_bits;
+
if (likely(!binlog_error))
my_ok(thd);
}
@@ -295,6 +303,18 @@ do_rename(THD *thd, TABLE_LIST *ren_table, const LEX_CSTRING *new_db,
DBUG_RETURN(skip_error || if_exists ? 0 : 1);
}
+ if (ha_check_if_updates_are_ignored(thd, hton, "RENAME"))
+ {
+ /*
+ Shared table. Just drop the old .frm as it's not correct anymore
+ Discovery will find the old table when it's accessed
+ */
+ tdc_remove_table(thd, TDC_RT_REMOVE_ALL,
+ ren_table->db.str, ren_table->table_name.str);
+ quick_rm_table(thd, 0, &ren_table->db, &old_alias, FRM_ONLY, 0);
+ DBUG_RETURN(0);
+ }
+
if (ha_table_exists(thd, new_db, &new_alias, &new_hton))
{
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias.str);
@@ -315,6 +335,9 @@ do_rename(THD *thd, TABLE_LIST *ren_table, const LEX_CSTRING *new_db,
if (hton != view_pseudo_hton)
{
+ if (hton->flags & HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE)
+ *force_if_exists= 1;
+
if (!(rc= mysql_rename_table(hton, &ren_table->db, &old_alias,
new_db, &new_alias, 0)))
{
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index ed1f6fe7cbd..d589fbfb32d 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -54,6 +54,7 @@
#include "sql_audit.h"
#include "sql_sequence.h"
#include "tztime.h"
+#include "sql_insert.h" // binlog_drop_table
#include <algorithm>
#ifdef __WIN__
@@ -1995,6 +1996,26 @@ int write_bin_log(THD *thd, bool clear_error,
/*
+ Write to binary log with optional adding "IF EXISTS"
+
+ The query is taken from thd->query()
+*/
+
+int write_bin_log_with_if_exists(THD *thd, bool clear_error,
+ bool is_trans, bool add_if_exists)
+{
+ int result;
+ ulonglong save_option_bits= thd->variables.option_bits;
+ if (add_if_exists)
+ thd->variables.option_bits|= OPTION_IF_EXISTS;
+ result= write_bin_log(thd, clear_error, thd->query(), thd->query_length(),
+ is_trans);
+ thd->variables.option_bits= save_option_bits;
+ return result;
+}
+
+
+/*
delete (drop) tables.
SYNOPSIS
@@ -2004,6 +2025,7 @@ int write_bin_log(THD *thd, bool clear_error,
if_exists If 1, don't give error if one table doesn't exists
drop_temporary 1 if DROP TEMPORARY
drop_sequence 1 if DROP SEQUENCE
+ dont_log_query 1 if no write to binary log and no send of ok
NOTES
Will delete all tables that can be deleted and give a compact error
@@ -2021,7 +2043,8 @@ int write_bin_log(THD *thd, bool clear_error,
*/
bool mysql_rm_table(THD *thd,TABLE_LIST *tables, bool if_exists,
- bool drop_temporary, bool drop_sequence)
+ bool drop_temporary, bool drop_sequence,
+ bool dont_log_query)
{
bool error;
Drop_table_error_handler err_handler;
@@ -2119,12 +2142,14 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, bool if_exists,
/* mark for close and remove all cached entries */
thd->push_internal_handler(&err_handler);
error= mysql_rm_table_no_locks(thd, tables, if_exists, drop_temporary,
- false, drop_sequence, false, false);
+ false, drop_sequence, dont_log_query,
+ false);
thd->pop_internal_handler();
if (unlikely(error))
DBUG_RETURN(TRUE);
- my_ok(thd);
+ if (!dont_log_query)
+ my_ok(thd);
DBUG_RETURN(FALSE);
}
@@ -2223,8 +2248,9 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
bool trans_tmp_table_deleted= 0, non_trans_tmp_table_deleted= 0;
bool non_tmp_table_deleted= 0;
bool is_drop_tmp_if_exists_added= 0;
- bool was_view= 0, was_table= 0, is_sequence;
- String built_query;
+ bool was_view= 0, was_table= 0, is_sequence, log_if_exists= if_exists;
+ const char *object_to_drop= (drop_sequence) ? "SEQUENCE" : "TABLE";
+ String normal_tables;
String built_trans_tmp_query, built_non_trans_tmp_query;
DBUG_ENTER("mysql_rm_table_no_locks");
@@ -2263,30 +2289,10 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
logging, these commands will be written with fully qualified table names
and use `db` will be suppressed.
*/
+
+ normal_tables.set_charset(thd->charset());
if (!dont_log_query)
{
- const char *object_to_drop= (drop_sequence) ? "SEQUENCE" : "TABLE";
-
- if (!drop_temporary)
- {
- const char *comment_start;
- uint32 comment_len;
-
- built_query.set_charset(thd->charset());
- built_query.append("DROP ");
- built_query.append(object_to_drop);
- built_query.append(' ');
- if (if_exists)
- built_query.append("IF EXISTS ");
-
- /* Preserve comment in original query */
- if ((comment_len= comment_length(thd, if_exists ? 17:9, &comment_start)))
- {
- built_query.append(comment_start, comment_len);
- built_query.append(" ");
- }
- }
-
built_trans_tmp_query.set_charset(system_charset_info);
built_trans_tmp_query.append("DROP TEMPORARY ");
built_trans_tmp_query.append(object_to_drop);
@@ -2393,8 +2399,8 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
alias= (lower_case_table_names == 2) ? table->alias : table->table_name;
/* remove .frm file and engine files */
- path_length= build_table_filename(path, sizeof(path) - 1, db.str, alias.str,
- reg_ext, 0);
+ path_length= build_table_filename(path, sizeof(path) - 1, db.str,
+ alias.str, reg_ext, 0);
}
DEBUG_SYNC(thd, "rm_table_no_locks_before_delete_table");
error= 0;
@@ -2408,7 +2414,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
One of the following cases happened:
. "DROP TEMPORARY" but a temporary table was not found.
. "DROP" but table was not found
- . "DROP TABLE" statement, but it's a view.
+ . "DROP TABLE" statement, but it's a view.
. "DROP SEQUENCE", but it's not a sequence
*/
was_table= drop_sequence && table_type;
@@ -2491,8 +2497,12 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
// Remove extension for delete
*(end= path + path_length - reg_ext_length)= '\0';
- if ((error= ha_delete_table(thd, table_type, path, &db, &table->table_name,
- !dont_log_query)))
+ if (table_type && table_type != view_pseudo_hton &&
+ table_type->flags & HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE)
+ log_if_exists= 1;
+
+ if ((error= ha_delete_table(thd, table_type, path, &db,
+ &table->table_name, !dont_log_query)))
{
if (thd->is_killed())
{
@@ -2529,7 +2539,8 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
{
non_tmp_table_deleted= TRUE;
trigger_drop_error=
- Table_triggers_list::drop_all_triggers(thd, &db, &table->table_name);
+ Table_triggers_list::drop_all_triggers(thd, &db,
+ &table->table_name);
}
if (unlikely(trigger_drop_error) ||
@@ -2567,12 +2578,12 @@ log_query:
*/
if (thd->db.str == NULL || cmp(&db, &thd->db) != 0)
{
- append_identifier(thd, &built_query, &db);
- built_query.append(".");
+ append_identifier(thd, &normal_tables, &db);
+ normal_tables.append(".");
}
- append_identifier(thd, &built_query, &table->table_name);
- built_query.append(",");
+ append_identifier(thd, &normal_tables, &table->table_name);
+ normal_tables.append(",");
}
DBUG_PRINT("table", ("table: %p s: %p", table->table,
table->table ? table->table->s : NULL));
@@ -2642,16 +2653,35 @@ err:
}
if (non_tmp_table_deleted)
{
- /* Chop of the last comma */
- built_query.chop();
- built_query.append(" /* generated by server */");
- int error_code = non_tmp_error ? thd->get_stmt_da()->sql_errno()
- : 0;
- error |= (thd->binlog_query(THD::STMT_QUERY_TYPE,
- built_query.ptr(),
- built_query.length(),
- TRUE, FALSE, FALSE,
- error_code) > 0);
+ String built_query;
+ const char *comment_start;
+ uint32 comment_len;
+
+ built_query.set_charset(thd->charset());
+ built_query.append("DROP ");
+ built_query.append(object_to_drop);
+ built_query.append(' ');
+ if (log_if_exists)
+ built_query.append("IF EXISTS ");
+
+ /* Preserve comment in original query */
+ if ((comment_len= comment_length(thd, if_exists ? 17:9,
+ &comment_start)))
+ {
+ built_query.append(comment_start, comment_len);
+ built_query.append(" ");
+ }
+
+ /* Chop of the last comma */
+ normal_tables.chop();
+ built_query.append(normal_tables.ptr(), normal_tables.length());
+ built_query.append(" /* generated by server */");
+ int error_code = non_tmp_error ? thd->get_stmt_da()->sql_errno() : 0;
+ error |= (thd->binlog_query(THD::STMT_QUERY_TYPE,
+ built_query.ptr(),
+ built_query.length(),
+ TRUE, FALSE, FALSE,
+ error_code) > 0);
}
}
}
@@ -4960,6 +4990,17 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db,
}
else
{
+ if (ha_check_if_updates_are_ignored(thd, create_info->db_type, "CREATE"))
+ {
+ /*
+ Don't create table. CREATE will still be logged in binary log
+ This can happen for shared storage engines that supports
+ ENGINE= in the create statement (Note that S3 doesn't support this.
+ */
+ error= 0;
+ goto err;
+ }
+
if (!internal_tmp_table && ha_table_exists(thd, &db, &table_name))
{
if (options.or_replace())
@@ -5629,6 +5670,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
int res= 1;
bool is_trans= FALSE;
bool do_logging= FALSE;
+ bool force_generated_create;
uint not_used;
int create_res;
DBUG_ENTER("mysql_create_like_table");
@@ -5780,12 +5822,22 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
if (thd->is_current_stmt_binlog_disabled())
goto err;
- if (thd->is_current_stmt_binlog_format_row())
+ /*
+ If we do a create based on a shared table, log the full create of the
+ resulting table. This is needed as a shared table may look different
+ when the slave executes the command.
+ */
+ force_generated_create=
+ (((src_table->table->s->db_type()->flags &
+ HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE) &&
+ src_table->table->s->db_type() != local_create_info.db_type));
+
+ if (thd->is_current_stmt_binlog_format_row() || force_generated_create)
{
/*
Since temporary tables are not replicated under row-based
replication, CREATE TABLE ... LIKE ... needs special
- treatement. We have four cases to consider, according to the
+ treatement. We have some cases to consider, according to the
following decision table:
==== ========= ========= ==============================
@@ -5796,11 +5848,14 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
was created.
3 temporary normal Nothing
4 temporary temporary Nothing
+ 5 any shared Generated statement if the table
+ was created if engine changed
==== ========= ========= ==============================
*/
- if (!(create_info->tmp_table()))
+ if (!(create_info->tmp_table()) || force_generated_create)
{
- if (src_table->table->s->tmp_table) // Case 2
+ // Case 2 & 5
+ if (src_table->table->s->tmp_table || force_generated_create)
{
char buf[2048];
String query(buf, sizeof(buf), system_charset_info);
@@ -9493,6 +9548,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
mysql_prepare_create_table().
*/
bool varchar= create_info->varchar, table_creation_was_logged= 0;
+ bool binlog_done= 0, log_if_exists= 0;
uint tables_opened;
handlerton *new_db_type, *old_db_type;
ha_rows copied=0, deleted=0;
@@ -9541,6 +9597,23 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
THD_STAGE_INFO(thd, stage_init_update);
+ /* Check if the new table type is a shared table */
+ if (ha_check_if_updates_are_ignored(thd, create_info->db_type, "ALTER"))
+ {
+ /*
+ Remove old local .frm file if it exists. We should use the new
+ shared one in the future. The drop is not logged, the ALTER table is
+ logged.
+ */
+ table_list->mdl_request.type= MDL_EXCLUSIVE;
+ /* This will only drop the .frm file and local tables, not shared ones */
+ error= mysql_rm_table(thd, table_list, 1, 0, 0, 1);
+ if (write_bin_log(thd, true, thd->query(), thd->query_length()) || error)
+ DBUG_RETURN(true);
+ my_ok(thd);
+ DBUG_RETURN(0);
+ }
+
/*
Code below can handle only base tables so ensure that we won't open a view.
Note that RENAME TABLE the only ALTER clause which is supported for views
@@ -9630,6 +9703,29 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
Alter_table_ctx alter_ctx(thd, table_list, tables_opened, new_db, new_name);
mdl_ticket= table->mdl_ticket;
+ if (ha_check_if_updates_are_ignored(thd, table->s->db_type(), "ALTER"))
+ {
+ /*
+ Table is a shared table. Remove the .frm file. Discovery will create
+ a new one if needed.
+ */
+ if (thd->mdl_context.upgrade_shared_lock(mdl_ticket,
+ MDL_EXCLUSIVE,
+ thd->variables.lock_wait_timeout))
+ DBUG_RETURN(1);
+ quick_rm_table(thd, 0, &table_list->db, &table_list->table_name,
+ FRM_ONLY, 0);
+ goto end_inplace;
+ }
+ if (!if_exists &&
+ (table->s->db_type()->flags & HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE))
+ {
+ /*
+ Table is a shared table that may not exist on the slave.
+ We add 'if_exists' to the query if it was not used
+ */
+ log_if_exists= 1;
+ }
table_creation_was_logged= table->s->table_creation_was_logged;
table->use_all_columns();
@@ -9882,7 +9978,7 @@ do_continue:;
/* We don't replicate alter table statement on temporary tables */
if (table_creation_was_logged)
{
- if (write_bin_log(thd, true, thd->query(), thd->query_length()))
+ if (write_bin_log_with_if_exists(thd, true, false, log_if_exists))
DBUG_RETURN(true);
}
@@ -10328,6 +10424,42 @@ do_continue:;
my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0));
goto err_new_table_cleanup;
});
+
+ /*
+ If old table was a shared table and new table is not same type,
+ the slaves will not be able to recreate the data. In this case we
+ write the CREATE TABLE statement for the new table to the log and
+ log all inserted rows to the table.
+ */
+ if ((table->s->db_type()->flags & HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE) &&
+ (table->s->db_type() != new_table->s->db_type()) &&
+ (mysql_bin_log.is_open() &&
+ (thd->variables.option_bits & OPTION_BIN_LOG)))
+ {
+ /*
+ We new_table is marked as internal temp table, but we want to have
+ the logging based on the original table type
+ */
+ bool res;
+ tmp_table_type org_tmp_table= new_table->s->tmp_table;
+ new_table->s->tmp_table= table->s->tmp_table;
+
+ /* Force row logging, even if the table was created as 'temporary' */
+ new_table->s->can_do_row_logging= 1;
+
+ thd->binlog_start_trans_and_stmt();
+ res= binlog_drop_table(thd, table) || binlog_create_table(thd, new_table);
+ new_table->s->tmp_table= org_tmp_table;
+ if (res)
+ goto err_new_table_cleanup;
+ /*
+ ha_write_row() will log inserted rows in copy_data_between_tables().
+ No additional logging of query is needed
+ */
+ binlog_done= 1;
+ new_table->mark_columns_needed_for_insert();
+ thd->binlog_write_table_map(new_table, 1);
+ }
if (copy_data_between_tables(thd, table, new_table,
alter_info->create_list, ignore,
order_num, order, &copied, &deleted,
@@ -10378,7 +10510,9 @@ do_continue:;
goto err_new_table_cleanup;
/* We don't replicate alter table statement on temporary tables */
if (!thd->is_current_stmt_binlog_format_row() &&
- write_bin_log(thd, true, thd->query(), thd->query_length()))
+ table_creation_was_logged &&
+ !binlog_done &&
+ write_bin_log_with_if_exists(thd, true, false, log_if_exists))
DBUG_RETURN(true);
my_free(const_cast<uchar*>(frm.str));
goto end_temporary;
@@ -10560,9 +10694,11 @@ end_inplace:
DBUG_ASSERT(!(mysql_bin_log.is_open() &&
thd->is_current_stmt_binlog_format_row() &&
(create_info->tmp_table())));
- if (write_bin_log(thd, true, thd->query(), thd->query_length()))
- DBUG_RETURN(true);
-
+ if (!binlog_done)
+ {
+ if (write_bin_log_with_if_exists(thd, true, false, log_if_exists))
+ DBUG_RETURN(true);
+ }
table_list->table= NULL; // For query cache
query_cache_invalidate3(thd, table_list, false);
@@ -10622,7 +10758,8 @@ err_with_mdl_after_alter:
We can't reset error as we will return 'true' below and the server
expects that error is set
*/
- write_bin_log(thd, FALSE, thd->query(), thd->query_length());
+ if (!binlog_done)
+ write_bin_log_with_if_exists(thd, FALSE, FALSE, log_if_exists);
err_with_mdl:
/*
diff --git a/sql/sql_table.h b/sql/sql_table.h
index debd55e7ab9..b9dada41e80 100644
--- a/sql/sql_table.h
+++ b/sql/sql_table.h
@@ -29,6 +29,7 @@ class THD;
struct TABLE;
struct handlerton;
class handler;
+class String;
typedef struct st_ha_check_opt HA_CHECK_OPT;
struct HA_CREATE_INFO;
struct Table_specification_st;
@@ -154,6 +155,8 @@ uint build_tmptable_filename(THD* thd, char *buff, size_t bufflen);
bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
Table_specification_st *create_info,
Alter_info *alter_info);
+bool add_keyword_to_query(THD *thd, String *result, const LEX_CSTRING *keyword,
+ const LEX_CSTRING *add);
/*
mysql_create_table_no_lock can be called in one of the following
@@ -242,7 +245,8 @@ bool mysql_restore_table(THD* thd, TABLE_LIST* table_list);
bool mysql_checksum_table(THD* thd, TABLE_LIST* table_list,
HA_CHECK_OPT* check_opt);
bool mysql_rm_table(THD *thd,TABLE_LIST *tables, bool if_exists,
- bool drop_temporary, bool drop_sequence);
+ bool drop_temporary, bool drop_sequence,
+ bool dont_log_query);
int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
bool drop_temporary, bool drop_view,
bool drop_sequence,
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index f8025cdf701..bb2ab527754 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -1072,7 +1072,7 @@ st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg,
bool st_select_lex_unit::prepare_join(THD *thd_arg, SELECT_LEX *sl,
select_result *tmp_result,
- ulong additional_options,
+ ulonglong additional_options,
bool is_union_select)
{
DBUG_ENTER("st_select_lex_unit::prepare_join");
@@ -1278,7 +1278,7 @@ bool init_item_int(THD* thd, Item_int* &item)
bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg,
select_result *sel_result,
- ulong additional_options)
+ ulonglong additional_options)
{
SELECT_LEX *lex_select_save= thd->lex->current_select;
SELECT_LEX *sl, *first_sl= first_select();
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 04db55d11ab..8268ee26019 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -4469,6 +4469,11 @@ static Sys_var_bit Sys_auto_is_null(
SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_AUTO_IS_NULL,
DEFAULT(FALSE), NO_MUTEX_GUARD, IN_BINLOG);
+static Sys_var_bit Sys_if_exists(
+ "sql_if_exists", "If set to 1 adds an implicate IF EXISTS to ALTER, RENAME and DROP of TABLES, VIEWS, FUNCTIONS and PACKAGES",
+ SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_IF_EXISTS,
+ DEFAULT(FALSE), NO_MUTEX_GUARD, IN_BINLOG);
+
static Sys_var_bit Sys_safe_updates(
"sql_safe_updates", "If set to 1, UPDATEs and DELETEs need either a key in "
"the WHERE clause, or a LIMIT clause, or else they will aborted. Prevents "
diff --git a/storage/maria/CMakeLists.txt b/storage/maria/CMakeLists.txt
index 66cf6824a3a..eba86497e30 100644
--- a/storage/maria/CMakeLists.txt
+++ b/storage/maria/CMakeLists.txt
@@ -118,7 +118,7 @@ ENDIF()
IF (LIBXML2_FOUND AND CURL_FOUND)
MYSQL_ADD_PLUGIN(s3 ${S3_SOURCES} STORAGE_ENGINE STATIC_ONLY
LINK_LIBRARIES aria myisam mysys mysys_ssl xml2 curl
- RECOMPILE_FOR_EMBEDDED)
+ NOT_EMBEDDED)
ENDIF()
IF(TARGET s3)
diff --git a/storage/maria/aria_s3_copy.cc b/storage/maria/aria_s3_copy.cc
index 94f4055beb9..d6d0e6e0ba7 100644
--- a/storage/maria/aria_s3_copy.cc
+++ b/storage/maria/aria_s3_copy.cc
@@ -17,6 +17,8 @@
Allow copying of Aria tables to and from S3 and also delete them from S3
*/
+#include <my_global.h>
+#include <m_string.h>
#include "maria_def.h"
#include <aria_backup.h>
#include <my_getopt.h>
diff --git a/storage/maria/ha_s3.cc b/storage/maria/ha_s3.cc
index 27edc3dad5e..668530a7157 100644
--- a/storage/maria/ha_s3.cc
+++ b/storage/maria/ha_s3.cc
@@ -60,6 +60,8 @@
*/
#define MYSQL_SERVER 1
+#include <my_global.h>
+#include <m_string.h>
#include "maria_def.h"
#include "sql_class.h"
#include <mysys_err.h>
@@ -79,7 +81,8 @@ static ulonglong s3_pagecache_buffer_size;
static char *s3_bucket, *s3_access_key=0, *s3_secret_key=0, *s3_region;
static char *s3_host_name;
static char *s3_tmp_access_key=0, *s3_tmp_secret_key=0;
-static my_bool s3_debug= 0;
+static my_bool s3_debug= 0, s3_slave_ignore_updates= 0;
+static my_bool s3_replicate_alter_as_create_select= 0;
handlerton *s3_hton= 0;
/* Don't show access or secret keys to users if they exists */
@@ -124,6 +127,17 @@ static MYSQL_SYSVAR_BOOL(debug, s3_debug,
"Generates trace file from libmarias3 on stderr for debugging",
0, 0, 0);
+static MYSQL_SYSVAR_BOOL(slave_ignore_updates, s3_slave_ignore_updates,
+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+ "If the slave has shares same S3 storage as the master",
+ 0, 0, 0);
+
+static MYSQL_SYSVAR_BOOL(replicate_alter_as_create_select,
+ s3_replicate_alter_as_create_select,
+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+ "When converting S3 table to local table, log all rows in binary log",
+ 0, 0, 1);
+
static MYSQL_SYSVAR_ENUM(protocol_version, s3_protocol_version,
PLUGIN_VAR_RQCMDARG,
"Protocol used to communication with S3. One of "
@@ -165,7 +179,7 @@ static MYSQL_SYSVAR_STR(bucket, s3_bucket,
0, 0, "MariaDB");
static MYSQL_SYSVAR_STR(host_name, s3_host_name,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
- "AWS bucket",
+ "AWS host name",
0, 0, DEFAULT_AWS_HOST_NAME);
static MYSQL_SYSVAR_STR(access_key, s3_tmp_access_key,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC,
@@ -632,6 +646,37 @@ end:
DBUG_RETURN(0);
}
+/*
+ Check if definition of table in S3 is same as in MariaDB.
+ This also covers the case where the table is not in S3 anymore.
+
+ Called when a copy of the S3 table is taken from the MariaDB table cache
+
+ TODO: Could possible be optimized by checking if the file on S3 is
+ of same time, data and size since when table was originally opened.
+*/
+
+int ha_s3::discover_check_version()
+{
+ S3_INFO s3_info= *file->s->s3_path;
+ s3_info.tabledef_version= table->s->tabledef_version;
+ return s3_check_frm_version(file->s3, &s3_info);
+}
+
+
+int ha_s3::rebind()
+{
+ if (int error= handler::rebind())
+ return error;
+ if (discover_check_version())
+ {
+ handler::unbind_psi();
+ return HA_ERR_TABLE_DEF_CHANGED;
+ }
+ return 0;
+}
+
+
/**
Update the .frm file in S3
*/
@@ -703,7 +748,9 @@ static int ha_s3_init(void *p)
s3_hton->show_status= 0;
s3_hton->prepare_for_backup= 0;
s3_hton->end_backup= 0;
- s3_hton->flags= 0;
+ s3_hton->flags= ((s3_slave_ignore_updates ? HTON_IGNORE_UPDATES : 0) |
+ (s3_replicate_alter_as_create_select ?
+ HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE : 0));
/* Copy global arguments to s3_access_key and s3_secret_key */
update_access_key(0,0,0,0);
update_secret_key(0,0,0,0);
@@ -750,7 +797,8 @@ static struct st_mysql_sys_var* system_variables[]= {
MYSQL_SYSVAR(access_key),
MYSQL_SYSVAR(secret_key),
MYSQL_SYSVAR(region),
-
+ MYSQL_SYSVAR(slave_ignore_updates),
+ MYSQL_SYSVAR(replicate_alter_as_create_select),
NULL
};
diff --git a/storage/maria/ha_s3.h b/storage/maria/ha_s3.h
index e3884e8b834..61502449dac 100644
--- a/storage/maria/ha_s3.h
+++ b/storage/maria/ha_s3.h
@@ -64,6 +64,8 @@ public:
}
int delete_table(const char *name);
int rename_table(const char *from, const char *to);
+ int discover_check_version();
+ int rebind();
S3_INFO *s3_open_args() { return open_args; }
void register_handler(MARIA_HA *file);
};
diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h
index 8f6106edb3d..8e7bef9493c 100644
--- a/storage/maria/maria_def.h
+++ b/storage/maria/maria_def.h
@@ -16,6 +16,8 @@
/* This file is included by all internal maria files */
#include <my_global.h>
+
+C_MODE_START
#include "maria.h" /* Structs & some defines */
#include "ma_pagecache.h"
#include <myisampack.h> /* packing of keys */
@@ -1378,7 +1380,7 @@ void _ma_remap_file(MARIA_HA *info, my_off_t size);
MARIA_RECORD_POS _ma_write_init_default(MARIA_HA *info, const uchar *record);
my_bool _ma_write_abort_default(MARIA_HA *info);
int maria_delete_table_files(const char *name, my_bool temporary,
- myf sync_dir);
+ myf flags);
/*
This cannot be in my_base.h as it clashes with HA_SPATIAL.
@@ -1387,7 +1389,6 @@ int maria_delete_table_files(const char *name, my_bool temporary,
*/
#define HA_RTREE_INDEX 16384 /* For RTREE search */
-C_MODE_START
#define MARIA_FLUSH_DATA 1
#define MARIA_FLUSH_INDEX 2
int _ma_flush_table_files(MARIA_HA *info, uint flush_data_or_index,
@@ -1407,7 +1408,6 @@ void _ma_check_print_warning(HA_CHECK *param, const char *fmt, ...)
void _ma_check_print_info(HA_CHECK *param, const char *fmt, ...)
ATTRIBUTE_FORMAT(printf, 2, 3);
my_bool write_log_record_for_repair(const HA_CHECK *param, MARIA_HA *info);
-C_MODE_END
int _ma_flush_pending_blocks(MARIA_SORT_PARAM *param);
int _ma_sort_ft_buf_flush(MARIA_SORT_PARAM *sort_param);
@@ -1470,3 +1470,4 @@ static inline void unmap_file(MARIA_HA *info __attribute__((unused)))
_ma_unmap_file(info);
#endif
}
+C_MODE_END
diff --git a/storage/maria/s3_func.c b/storage/maria/s3_func.c
index 7ff8447679f..64f0d7f0ab2 100644
--- a/storage/maria/s3_func.c
+++ b/storage/maria/s3_func.c
@@ -299,6 +299,8 @@ int aria_copy_to_s3(ms3_st *s3_client, const char *aws_bucket,
int error;
my_bool frm_created= 0;
DBUG_ENTER("aria_copy_to_s3");
+ DBUG_PRINT("enter",("from: %s database: %s table: %s",
+ path, database, table_name));
aws_path_end= strxmov(aws_path, database, "/", table_name, NullS);
strmov(aws_path_end, "/aria");
@@ -826,11 +828,15 @@ my_bool s3_put_object(ms3_st *s3_client, const char *aws_bucket,
/**
Read an object for index or data information
+
+ @param print_error 0 Don't print error
+ @param print_error 1 Print error that object doesn't exists
+ @param print_error 2 Print error that table doesn't exists
*/
my_bool s3_get_object(ms3_st *s3_client, const char *aws_bucket,
const char *name, S3_BLOCK *block,
- my_bool compression, my_bool print_error)
+ my_bool compression, int print_error)
{
uint8_t error;
uchar *data;
@@ -899,9 +905,9 @@ my_bool s3_get_object(ms3_st *s3_client, const char *aws_bucket,
{
if (error == 9)
{
- my_printf_error(EE_FILENOTFOUND, "Expected object '%s' didn't exist",
+ my_errno= print_error == 1 ? EE_FILENOTFOUND : HA_ERR_NO_SUCH_TABLE;
+ my_printf_error(my_errno, "Expected object '%s' didn't exist",
MYF(0), name);
- my_errno= EE_FILENOTFOUND;
}
else
{
@@ -1323,23 +1329,27 @@ int s3_check_frm_version(ms3_st *s3_client, S3_INFO *s3_info)
char aws_path[AWS_PATH_LENGTH];
char uuid[MY_UUID_SIZE];
S3_BLOCK block;
+ DBUG_ENTER("s3_check_frm_version");
strxnmov(aws_path, sizeof(aws_path)-1, s3_info->database.str, "/",
s3_info->table.str, "/frm", NullS);
if (s3_get_object(s3_client, s3_info->bucket.str, aws_path, &block, 0, 0))
- return 2; /* Ignore check, use old frm */
+ DBUG_RETURN(2); /* Ignore check, use old frm */
if (get_tabledef_version_from_frm(uuid, (uchar*) block.str, block.length) ||
s3_info->tabledef_version.length != MY_UUID_SIZE)
{
s3_free(&block);
- return 3; /* Wrong definition */
+ DBUG_PRINT("error", ("Wrong definition"));
+ DBUG_RETURN(3); /* Wrong definition */
}
/* res is set to 1 if versions numbers doesn't match */
res= bcmp(s3_info->tabledef_version.str, uuid, MY_UUID_SIZE) != 0;
s3_free(&block);
- return res;
+ if (res)
+ DBUG_PRINT("error", ("Wrong table version"));
+ DBUG_RETURN(res);
}
@@ -1359,7 +1369,7 @@ my_bool read_index_header(ms3_st *client, S3_INFO *s3, S3_BLOCK *block)
DBUG_ENTER("read_index_header");
strxnmov(aws_path, sizeof(aws_path)-1, s3->database.str, "/", s3->table.str,
"/aria", NullS);
- DBUG_RETURN(s3_get_object(client, s3->bucket.str, aws_path, block, 0, 1));
+ DBUG_RETURN(s3_get_object(client, s3->bucket.str, aws_path, block, 0, 2));
}
diff --git a/storage/maria/s3_func.h b/storage/maria/s3_func.h
index 6f01d9ee56d..cfba29cd11f 100644
--- a/storage/maria/s3_func.h
+++ b/storage/maria/s3_func.h
@@ -73,7 +73,7 @@ my_bool s3_put_object(ms3_st *s3_client, const char *aws_bucket,
my_bool compression);
my_bool s3_get_object(ms3_st *s3_client, const char *aws_bucket,
const char *name, S3_BLOCK *block, my_bool compression,
- my_bool print_error);
+ int print_error);
my_bool s3_delete_object(ms3_st *s3_client, const char *aws_bucket,
const char *name, my_bool print_error);
my_bool s3_rename_object(ms3_st *s3_client, const char *aws_bucket,