diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2022-05-03 10:59:54 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2022-05-03 10:59:54 +0200 |
commit | 9614fde1aac6ffa4745804342ff70a96b2418e30 (patch) | |
tree | d53f4578ce0a6b5cf30f3eef854d50c16fbabcee | |
parent | 182b8a29e7a1a0f0fbffeed39518c2c9dc026e13 (diff) | |
parent | 70555454b4c224e85383d482411961c7f2eba2e2 (diff) | |
download | mariadb-git-9614fde1aac6ffa4745804342ff70a96b2418e30.tar.gz |
Merge branch '10.2' into 10.3
111 files changed, 2662 insertions, 551 deletions
diff --git a/config.h.cmake b/config.h.cmake index 065e636d55e..6e089ae3794 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -567,3 +567,5 @@ #endif // !defined(__STDC_FORMAT_MACROS) #endif + +#cmakedefine HAVE_VFORK 1 diff --git a/configure.cmake b/configure.cmake index cbcdab5e4f9..652b77b22bd 100644 --- a/configure.cmake +++ b/configure.cmake @@ -1018,3 +1018,19 @@ IF(NOT MSVC) HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE ) ENDIF() + +MY_CHECK_C_COMPILER_FLAG("-Werror") +IF(have_C__Werror) + SET(SAVE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) + SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror") + CHECK_C_SOURCE_COMPILES(" + #include <unistd.h> + int main() + { + pid_t pid=vfork(); + return (int)pid; + }" + HAVE_VFORK + ) + SET(CMAKE_REQUIRED_FLAGS ${SAVE_CMAKE_REQUIRED_FLAGS}) +ENDIF() diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index e721970f95e..cf46ca51b7f 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -266,7 +266,8 @@ free_mysql_variables(mysql_variable *vars) static char * -read_mysql_one_value(MYSQL *connection, const char *query) +read_mysql_one_value(MYSQL *connection, const char *query, + uint column, uint expect_columns) { MYSQL_RES *mysql_result; MYSQL_ROW row; @@ -274,10 +275,10 @@ read_mysql_one_value(MYSQL *connection, const char *query) mysql_result = xb_mysql_query(connection, query, true); - ut_ad(mysql_num_fields(mysql_result) == 1); + ut_ad(mysql_num_fields(mysql_result) == expect_columns); if ((row = mysql_fetch_row(mysql_result))) { - result = strdup(row[0]); + result = strdup(row[column]); } mysql_free_result(mysql_result); @@ -285,6 +286,15 @@ read_mysql_one_value(MYSQL *connection, const char *query) return(result); } + +static +char * +read_mysql_one_value(MYSQL *mysql, const char *query) +{ + return read_mysql_one_value(mysql, query, 0/*offset*/, 1/*total columns*/); +} + + static bool check_server_version(unsigned long version_number, @@ -1197,92 +1207,322 @@ cleanup: } +class Var +{ + const char *m_name; + char *m_value; + /* + Disable copying constructors for safety, as the default binary copying + which would be wrong. If we ever want them, the m_value + member should be copied using an strdup()-alike function. + */ + Var(const Var &); // Disabled + Var(Var &); // Disabled +public: + ~Var() + { + free(m_value); + } + Var(const char *name) + :m_name(name), + m_value(NULL) + { } + // Init using a SHOW VARIABLES LIKE 'name' query + Var(const char *name, MYSQL *mysql) + :m_name(name) + { + char buf[128]; + my_snprintf(buf, sizeof(buf), "SHOW VARIABLES LIKE '%s'", m_name); + m_value= read_mysql_one_value(mysql, buf, 1/*offset*/, 2/*total columns*/); + } + /* + Init by name from a result set. + If the variable name is not found in the result set metadata field names, + it's value stays untouched. + */ + bool init(MYSQL_RES *mysql_result, MYSQL_ROW row) + { + MYSQL_FIELD *field= mysql_fetch_fields(mysql_result); + for (uint i= 0; i < mysql_num_fields(mysql_result); i++) + { + if (!strcmp(field[i].name, m_name)) + { + free(m_value); // In case it was initialized earlier + m_value= row[i] ? strdup(row[i]) : NULL; + return false; + } + } + return true; + } + void replace(char from, char to) + { + ut_ad(m_value); + for (char *ptr= strchr(m_value, from); ptr; ptr= strchr(ptr, from)) + *ptr= to; + } + + const char *value() const { return m_value; } + bool eq_value(const char *str, size_t length) const + { + return m_value && !strncmp(m_value, str, length) && m_value[length] == '\0'; + } + bool is_null_or_empty() const { return !m_value || !m_value[0]; } + bool print(String *to) const + { + ut_ad(m_value); + return to->append(m_value); + } + bool print_quoted(String *to) const + { + ut_ad(m_value); + return to->append("'") || to->append(m_value) || to->append("'"); + } + bool print_set_global(String *to) const + { + ut_ad(m_value); + return + to->append("SET GLOBAL ") || + to->append(m_name) || + to->append(" = '") || + to->append(m_value) || + to->append("';\n"); + } +}; + + +class Show_slave_status +{ + Var m_mariadb_connection_name; // MariaDB: e.g. 'master1' + Var m_master; // e.g. 'localhost' + Var m_filename; // e.g. 'source-bin.000002' + Var m_position; // a number + Var m_mysql_gtid_executed; // MySQL56: e.g. single '<UUID>:1-5" or multiline + // '<UUID1>:1-10,\n<UUID2>:1-20\n<UUID3>:1-30' + Var m_mariadb_using_gtid; // MariaDB: 'No','Slave_Pos','Current_Pos' + +public: + + Show_slave_status() + :m_mariadb_connection_name("Connection_name"), + m_master("Master_Host"), + m_filename("Relay_Master_Log_File"), + m_position("Exec_Master_Log_Pos"), + m_mysql_gtid_executed("Executed_Gtid_Set"), + m_mariadb_using_gtid("Using_Gtid") + { } + + void init(MYSQL_RES *res, MYSQL_ROW row) + { + m_mariadb_connection_name.init(res, row); + m_master.init(res, row); + m_filename.init(res, row); + m_position.init(res, row); + m_mysql_gtid_executed.init(res, row); + m_mariadb_using_gtid.init(res, row); + // Normalize + if (m_mysql_gtid_executed.value()) + m_mysql_gtid_executed.replace('\n', ' '); + } + + static void msg_is_not_slave() + { + msg("Failed to get master binlog coordinates " + "from SHOW SLAVE STATUS.This means that the server is not a " + "replication slave. Ignoring the --slave-info option"); + } + + bool is_mariadb_using_gtid() const + { + return !m_mariadb_using_gtid.eq_value("No", 2); + } + + static bool start_comment_chunk(String *to) + { + return to->length() ? to->append("; ") : false; + } + + bool print_connection_name_if_set(String *to) const + { + if (!m_mariadb_connection_name.is_null_or_empty()) + return m_mariadb_connection_name.print_quoted(to) || to->append(' '); + return false; + } + + bool print_comment_master_identity(String *comment) const + { + if (comment->append("master ")) + return true; + if (!m_mariadb_connection_name.is_null_or_empty()) + return m_mariadb_connection_name.print_quoted(comment); + return comment->append("''"); // Default not named master + } + + bool print_using_master_log_pos(String *sql, String *comment) const + { + return + sql->append("CHANGE MASTER ") || + print_connection_name_if_set(sql) || + sql->append("TO MASTER_LOG_FILE=") || m_filename.print_quoted(sql) || + sql->append(", MASTER_LOG_POS=") || m_position.print(sql) || + sql->append(";\n") || + print_comment_master_identity(comment) || + comment->append(" filename ") || m_filename.print_quoted(comment) || + comment->append(" position ") || m_position.print_quoted(comment); + } + + bool print_mysql56(String *sql, String *comment) const + { + /* + SET @@GLOBAL.gtid_purged = '2174B383-5441-11E8-B90A-C80AA9429562:1-1029, ' + '224DA167-0C0C-11E8-8442-00059A3C7B00:1-2695'; + CHANGE MASTER TO MASTER_AUTO_POSITION=1; + */ + return + sql->append("SET GLOBAL gtid_purged=") || + m_mysql_gtid_executed.print_quoted(sql) || + sql->append(";\n") || + sql->append("CHANGE MASTER TO MASTER_AUTO_POSITION=1;\n") || + print_comment_master_identity(comment) || + comment->append(" purge list ") || + m_mysql_gtid_executed.print_quoted(comment); + } + + bool print_mariadb10_using_gtid(String *sql, String *comment) const + { + return + sql->append("CHANGE MASTER ") || + print_connection_name_if_set(sql) || + sql->append("TO master_use_gtid = slave_pos;\n") || + print_comment_master_identity(comment) || + comment->append(" master_use_gtid = slave_pos"); + } + + bool print(String *sql, String *comment, const Var >id_slave_pos) const + { + if (!m_mysql_gtid_executed.is_null_or_empty()) + { + /* MySQL >= 5.6 with GTID enabled */ + return print_mysql56(sql, comment); + } + + if (!gtid_slave_pos.is_null_or_empty() && is_mariadb_using_gtid()) + { + /* MariaDB >= 10.0 with GTID enabled */ + return print_mariadb10_using_gtid(sql, comment); + } + + return print_using_master_log_pos(sql, comment); + } + + /* + Get master info into strings "sql" and "comment" from a MYSQL_RES. + @return false on success + @return true on error + */ + static bool get_slave_info(MYSQL_RES *show_slave_info_result, + const Var >id_slave_pos, + String *sql, String *comment) + { + if (!gtid_slave_pos.is_null_or_empty()) + { + // Print gtid_slave_pos if any of the masters really needs it. + while (MYSQL_ROW row= mysql_fetch_row(show_slave_info_result)) + { + Show_slave_status status; + status.init(show_slave_info_result, row); + if (status.is_mariadb_using_gtid()) + { + if (gtid_slave_pos.print_set_global(sql) || + comment->append("gtid_slave_pos ") || + gtid_slave_pos.print_quoted(comment)) + return true; // Error + break; + } + } + } + + // Print the list of masters + mysql_data_seek(show_slave_info_result, 0); + while (MYSQL_ROW row= mysql_fetch_row(show_slave_info_result)) + { + Show_slave_status status; + status.init(show_slave_info_result, row); + if (start_comment_chunk(comment) || + status.print(sql, comment, gtid_slave_pos)) + return true; // Error + } + return false; // Success + } + + /* + Get master info into strings "sql" and "comment". + @return false on success + @return true on error + */ + static bool get_slave_info(MYSQL *mysql, bool show_all_slave_status, + String *sql, String *comment) + { + bool rc= false; // Success + // gtid_slave_pos - MariaDB variable : e.g. "0-1-1" or "1-10-100,2-20-500" + Var gtid_slave_pos("gtid_slave_pos", mysql); + const char *query= show_all_slave_status ? "SHOW ALL SLAVES STATUS" : + "SHOW SLAVE STATUS"; + MYSQL_RES *mysql_result= xb_mysql_query(mysql, query, true); + if (!mysql_num_rows(mysql_result)) + { + msg_is_not_slave(); + // Don't change rc, we still want to continue the backup + } + else + { + rc= get_slave_info(mysql_result, gtid_slave_pos, sql, comment); + } + mysql_free_result(mysql_result); + return rc; + } +}; + + + /*********************************************************************//** Retrieves MySQL binlog position of the master server in a replication setup and saves it in a file. It also saves it in mysql_slave_position -variable. */ +variable. +@returns false on error +@returns true on success +*/ bool write_slave_info(MYSQL *connection) { - char *master = NULL; - char *filename = NULL; - char *gtid_executed = NULL; - char *using_gtid = NULL; - char *position = NULL; - char *gtid_slave_pos = NULL; - char *ptr; - bool result = false; + String sql, comment; + bool show_all_slaves_status= false; - mysql_variable status[] = { - {"Master_Host", &master}, - {"Relay_Master_Log_File", &filename}, - {"Exec_Master_Log_Pos", &position}, - {"Executed_Gtid_Set", >id_executed}, - {"Using_Gtid", &using_gtid}, - {NULL, NULL} - }; - - mysql_variable variables[] = { - {"gtid_slave_pos", >id_slave_pos}, - {NULL, NULL} - }; - - read_mysql_variables(connection, "SHOW SLAVE STATUS", status, false); - read_mysql_variables(connection, "SHOW VARIABLES", variables, true); - - if (master == NULL || filename == NULL || position == NULL) { - msg("Failed to get master binlog coordinates " - "from SHOW SLAVE STATUS.This means that the server is not a " - "replication slave. Ignoring the --slave-info option"); - /* we still want to continue the backup */ - result = true; - goto cleanup; - } - - /* Print slave status to a file. - If GTID mode is used, construct a CHANGE MASTER statement with - MASTER_AUTO_POSITION and correct a gtid_purged value. */ - if (gtid_executed != NULL && *gtid_executed) { - /* MySQL >= 5.6 with GTID enabled */ - - for (ptr = strchr(gtid_executed, '\n'); - ptr; - ptr = strchr(ptr, '\n')) { - *ptr = ' '; - } + switch (server_flavor) + { + case FLAVOR_MARIADB: + show_all_slaves_status= mysql_server_version >= 100000; + break; + case FLAVOR_UNKNOWN: + case FLAVOR_MYSQL: + case FLAVOR_PERCONA_SERVER: + break; + } - result = backup_file_printf(XTRABACKUP_SLAVE_INFO, - "SET GLOBAL gtid_purged='%s';\n" - "CHANGE MASTER TO MASTER_AUTO_POSITION=1\n", - gtid_executed); - - ut_a(asprintf(&mysql_slave_position, - "master host '%s', purge list '%s'", - master, gtid_executed) != -1); - } else if (gtid_slave_pos && *gtid_slave_pos && - !(using_gtid && !strncmp(using_gtid, "No", 2))) { - /* MariaDB >= 10.0 with GTID enabled */ - result = backup_file_printf(XTRABACKUP_SLAVE_INFO, - "SET GLOBAL gtid_slave_pos = '%s';\n" - "CHANGE MASTER TO master_use_gtid = slave_pos\n", - gtid_slave_pos); - ut_a(asprintf(&mysql_slave_position, - "master host '%s', gtid_slave_pos %s", - master, gtid_slave_pos) != -1); - } else { - result = backup_file_printf(XTRABACKUP_SLAVE_INFO, - "CHANGE MASTER TO MASTER_LOG_FILE='%s', " - "MASTER_LOG_POS=%s\n", filename, position); - ut_a(asprintf(&mysql_slave_position, - "master host '%s', filename '%s', position '%s'", - master, filename, position) != -1); - } + if (Show_slave_status::get_slave_info(connection, show_all_slaves_status, + &sql, &comment)) + return false; // Error -cleanup: - free_mysql_variables(status); - free_mysql_variables(variables); + if (!sql.length()) + { + /* + SHOW [ALL] SLAVE STATUS returned no rows. + Don't create the file, but return success to continue the backup. + */ + return true; // Success + } - return(result); + mysql_slave_position= strdup(comment.c_ptr()); + return backup_file_print_buf(XTRABACKUP_SLAVE_INFO, sql.ptr(), sql.length()); } diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index f745c6ba163..4f6e48c1ee1 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -5390,11 +5390,23 @@ static ibool prepare_handle_new_files(const char *data_home_dir, const char *file_name, void *arg) { const char *dest_dir = static_cast<const char *>(arg); - std::string src_path = std::string(data_home_dir) + '/' + std::string(db_name) + '/' + file_name; + std::string src_path = std::string(data_home_dir) + '/' + std::string(db_name) + '/'; /* Copy "*.new" files from incremental to base dir for incremental backup */ std::string dest_path= dest_dir ? std::string(dest_dir) + '/' + std::string(db_name) + - '/' + file_name : src_path; + '/' : src_path; + + /* + A CREATE DATABASE could have happened during the base mariabackup run. + In case if the current table file (e.g. `t1.new`) is from such + a new database, the database directory may not exist yet in + the base backup directory. Let's make sure to check if the directory + exists (and create if needed). + */ + if (!directory_exists(dest_path.c_str(), true/*create if not exists*/)) + return FALSE; + src_path+= file_name; + dest_path+= file_name; size_t index = dest_path.find(".new"); DBUG_ASSERT(index != std::string::npos); diff --git a/libmariadb b/libmariadb -Subproject f6c3d9fd2af5d17db64cc996574aa312efd70fc +Subproject ab7a81e79e4be4324a2d09d19d4f5249801ef66 diff --git a/man/mysql_tzinfo_to_sql.1 b/man/mysql_tzinfo_to_sql.1 index 34a4c93c1e0..ef97591953d 100644 --- a/man/mysql_tzinfo_to_sql.1 +++ b/man/mysql_tzinfo_to_sql.1 @@ -41,6 +41,7 @@ can be invoked several ways: shell> \fBmysql_tzinfo_to_sql \fR\fB\fItz_dir\fR\fR shell> \fBmysql_tzinfo_to_sql \fR\fB\fItz_file tz_name\fR\fR shell> \fBmysql_tzinfo_to_sql \-\-leap \fR\fB\fItz_file\fR\fR +shell> \fBmysql_tzinfo_to_sql \-\-skip\-write\-binlog \fR\fB\fItz_dir\fR\fR .fi .if n \{\ .RE @@ -100,6 +101,9 @@ shell> \fBmysql_tzinfo_to_sql \-\-leap \fR\fB\fItz_file\fR\fR\fB | mysql \-u roo .RE .\} .PP +Using the \-\-skip\-write\-binlog option prevents writing of changes to the binary log or to other Galera +cluster members. This can be used with any form of running \fBmysql_tzinfo_to_sql\fR. +.PP After running \fBmysql_tzinfo_to_sql\fR, it is best to restart the server so that it does not continue to use any previously cached time zone data\&. .SH "COPYRIGHT" diff --git a/mysql-test/main/create_select_tmp.result b/mysql-test/main/create_select.result index f499e539baf..6c6ab77522d 100644 --- a/mysql-test/main/create_select_tmp.result +++ b/mysql-test/main/create_select.result @@ -1,4 +1,7 @@ -drop table if exists t1, t2; +CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +# +# Testcase for BUG#4551 +# CREATE TABLE t1 ( a int ); INSERT INTO t1 VALUES (1),(2),(1); CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; @@ -18,3 +21,17 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY' select * from t2; ERROR 42S02: Table 'test.t2' doesn't exist drop table t1; +# +# End of 4.1 tests +# +# +# MDEV-28393 Server crashes in TABLE::mark_default_fields_for_write +# +create table t1 (a int, b text not null default ''); +alter table t1 character set = utf8; +create table t2 select * from t1; +insert into t1 values (1,''); +drop table t1, t2; +# +# End of 10.2 tests +# diff --git a/mysql-test/main/create_select_tmp.test b/mysql-test/main/create_select.test index ef3315aed97..170bbba31d4 100644 --- a/mysql-test/main/create_select_tmp.test +++ b/mysql-test/main/create_select.test @@ -1,39 +1,52 @@ -# Testcase for BUG#4551 +# This does not work for RBR yet. +--source include/have_innodb.inc +--source include/have_binlog_format_mixed_or_statement.inc + +CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + +--echo # +--echo # Testcase for BUG#4551 +--echo # + # The bug was that when the table was TEMPORARY, it was not deleted if # the CREATE SELECT failed (the code intended too, but it actually # didn't). And as the CREATE TEMPORARY TABLE was not written to the # binlog if it was a transactional table, it resulted in an # inconsistency between binlog and the internal list of temp tables. -# This does not work for RBR yet. ---source include/have_binlog_format_mixed_or_statement.inc - ---disable_query_log -CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); ---enable_query_log - --- source include/have_innodb.inc ---disable_warnings -drop table if exists t1, t2; ---enable_warnings CREATE TABLE t1 ( a int ); INSERT INTO t1 VALUES (1),(2),(1); --error ER_DUP_ENTRY CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; ---error 1146 +--error ER_NO_SUCH_TABLE select * from t2; --error ER_DUP_ENTRY CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; ---error 1146 +--error ER_NO_SUCH_TABLE select * from t2; --error ER_DUP_ENTRY CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; ---error 1146 +--error ER_NO_SUCH_TABLE select * from t2; --error ER_DUP_ENTRY CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; ---error 1146 +--error ER_NO_SUCH_TABLE select * from t2; drop table t1; -# End of 4.1 tests +--echo # +--echo # End of 4.1 tests +--echo # + +--echo # +--echo # MDEV-28393 Server crashes in TABLE::mark_default_fields_for_write +--echo # +create table t1 (a int, b text not null default ''); +alter table t1 character set = utf8; +create table t2 select * from t1; +insert into t1 values (1,''); +drop table t1, t2; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result index af5f8cc1d3b..b2e21db2aef 100644 --- a/mysql-test/main/derived_view.result +++ b/mysql-test/main/derived_view.result @@ -3628,4 +3628,64 @@ f2 f3 DROP PROCEDURE p1; DROP VIEW v1,v2,v3; DROP TABLE t1; +# +# MDEV-27212: 2-nd execution of PS for select with embedded derived tables +# and correlated subquery in select list of outer derived +# +create table t1 ( id int, id2 int ) engine=myisam; +create table t2 ( x3 int , x1 int , x2 int, a1 int) engine=myisam; +insert into t1 values (3, 2), (4, 2), (3, 4); +insert into t2 values (1, 2, 2, 1), (1, 3, 3, 2), (2, 3, 3, 1); +prepare stmt from "select id from t1 +join +( select dt2.x1, +( select sum(a1) from t2 where t2.x1 = dt2.x1 ) m +from ( select x1 from t2 u where x3 = 1 ) dt2 +) dt +on t1.id = dt.x1 +where t1.id2 < dt.m"; +execute stmt; +id +3 +execute stmt; +id +3 +deallocate prepare stmt; +create procedure sp1() select id from t1 +join +( select dt2.x1, +( select sum(a1) from t2 where t2.x1 = dt2.x1 ) m +from ( select x1 from t2 u where x3 = 1 ) dt2 +) dt +on t1.id = dt.x1 +where t1.id2 < dt.m; +call sp1(); +id +3 +call sp1(); +id +3 +create view v2 as select x1 from t2 u where x3 = 1; +create view v as +select v2.x1, +( select sum(a1) from t2 where t2.x1 = v2.x1 ) m from v2; +prepare stmt from "select id from t1 join v on t1.id = v.x1 where t1.id2 < v.m"; +execute stmt; +id +3 +execute stmt; +id +3 +deallocate prepare stmt; +create procedure sp2() select id from t1 join v on t1.id = v.x1 where t1.id2 < v.m; +call sp2(); +id +3 +call sp2(); +id +3 +drop procedure sp1; +drop procedure sp2; +drop view v, v2; +drop table t1,t2; # End of 10.2 tests diff --git a/mysql-test/main/derived_view.test b/mysql-test/main/derived_view.test index 584bde2d75d..006bdaea5ef 100644 --- a/mysql-test/main/derived_view.test +++ b/mysql-test/main/derived_view.test @@ -2400,4 +2400,56 @@ DROP PROCEDURE p1; DROP VIEW v1,v2,v3; DROP TABLE t1; +--echo # +--echo # MDEV-27212: 2-nd execution of PS for select with embedded derived tables +--echo # and correlated subquery in select list of outer derived +--echo # +create table t1 ( id int, id2 int ) engine=myisam; +create table t2 ( x3 int , x1 int , x2 int, a1 int) engine=myisam; +insert into t1 values (3, 2), (4, 2), (3, 4); +insert into t2 values (1, 2, 2, 1), (1, 3, 3, 2), (2, 3, 3, 1); + +let $q= +select id from t1 + join + ( select dt2.x1, + ( select sum(a1) from t2 where t2.x1 = dt2.x1 ) m + from ( select x1 from t2 u where x3 = 1 ) dt2 + ) dt + on t1.id = dt.x1 +where t1.id2 < dt.m; + +eval prepare stmt from "$q"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +eval create procedure sp1() $q; +call sp1(); +call sp1(); + +create view v2 as select x1 from t2 u where x3 = 1; +create view v as +select v2.x1, + ( select sum(a1) from t2 where t2.x1 = v2.x1 ) m from v2; + +let $q= +select id from t1 join v on t1.id = v.x1 where t1.id2 < v.m; + +eval prepare stmt from "$q"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +eval create procedure sp2() $q; +call sp2(); +call sp2(); + +drop procedure sp1; +drop procedure sp2; + +drop view v, v2; + +drop table t1,t2; + --echo # End of 10.2 tests diff --git a/mysql-test/main/func_default.result b/mysql-test/main/func_default.result index 2b5c869ee66..8e4a647ff8e 100644 --- a/mysql-test/main/func_default.result +++ b/mysql-test/main/func_default.result @@ -167,8 +167,8 @@ create algorithm=temptable view v1 as select * from t1; create algorithm=merge view v2 as select * from t1; select default(a) = now() from v1; default(a) = now() -NULL -NULL +1 +1 select default(a) = now() from v2; default(a) = now() 1 @@ -191,16 +191,29 @@ default(v1) 2001-01-01 10:20:30 select default(v1) from (select v1 from t1 group by v1) dt; default(v1) -0000-00-00 00:00:00 +2001-01-01 10:20:30 drop table t1; create table t1 (a text default ''); create algorithm=temptable view v1 as select * from t1; insert into t1 values ('a'); select default(a) from v1; default(a) -NULL + drop view v1; drop table t1; # +# MDEV-28403 ASAN heap-use-after-free in String::copy / get_field_default_value +# +create table t (a blob default 'x'); +create view v as select * from t; +insert into t () values (); +update t set a = default; +select table_name,column_name,column_default from information_schema.columns where table_name = 'v'; +table_name v +column_name a +column_default 'x' +drop view v; +drop table t; +# # End of 10.2 tests # diff --git a/mysql-test/main/func_default.test b/mysql-test/main/func_default.test index daa99f1f459..25bf5d24b9f 100644 --- a/mysql-test/main/func_default.test +++ b/mysql-test/main/func_default.test @@ -167,5 +167,16 @@ drop view v1; drop table t1; --echo # +--echo # MDEV-28403 ASAN heap-use-after-free in String::copy / get_field_default_value +--echo # +create table t (a blob default 'x'); +create view v as select * from t; +insert into t () values (); +update t set a = default; +query_vertical select table_name,column_name,column_default from information_schema.columns where table_name = 'v'; +drop view v; +drop table t; + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/main/func_time.result b/mysql-test/main/func_time.result index b8b14e61b46..60b8da984e3 100644 --- a/mysql-test/main/func_time.result +++ b/mysql-test/main/func_time.result @@ -989,6 +989,12 @@ ADDTIME('916:40:00', '416:40:00') Warnings: Warning 1292 Truncated incorrect time value: '916:40:00' Warning 1292 Truncated incorrect time value: '1255:39:59.999999' +SELECT ADDTIME(20010101,1e0), ADDTIME(20010101,1.1e0); +ADDTIME(20010101,1e0) ADDTIME(20010101,1.1e0) +2001-01-01 00:00:01 2001-01-01 00:00:01.100000 +SELECT ADDTIME(ADDTIME(20010101,1e0), 0); +ADDTIME(ADDTIME(20010101,1e0), 0) +2001-01-01 00:00:01 SELECT SUBTIME('916:40:00', '416:40:00'); SUBTIME('916:40:00', '416:40:00') 422:19:59.999999 diff --git a/mysql-test/main/func_time.test b/mysql-test/main/func_time.test index 719b0ae13b6..3a1bb2bcb58 100644 --- a/mysql-test/main/func_time.test +++ b/mysql-test/main/func_time.test @@ -513,6 +513,10 @@ SELECT TIME_TO_SEC('916:40:00'); SELECT ADDTIME('500:00:00', '416:40:00'); SELECT ADDTIME('916:40:00', '416:40:00'); +# check if ADDTIME() handles NOT_FIXED_DEC correctly +SELECT ADDTIME(20010101,1e0), ADDTIME(20010101,1.1e0); +SELECT ADDTIME(ADDTIME(20010101,1e0), 0); + # check if SUBTIME() handles out-of-range values correctly SELECT SUBTIME('916:40:00', '416:40:00'); SELECT SUBTIME('-916:40:00', '416:40:00'); diff --git a/mysql-test/main/grant.result b/mysql-test/main/grant.result index 3d609cf2d4a..3dd1b393043 100644 --- a/mysql-test/main/grant.result +++ b/mysql-test/main/grant.result @@ -2,8 +2,6 @@ set GLOBAL sql_mode=""; set LOCAL sql_mode=""; SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; SET GLOBAL log_bin_trust_function_creators = 1; -drop table if exists t1; -drop database if exists mysqltest; connect master,localhost,root,,; connection master; SET NAMES binary; @@ -2789,6 +2787,14 @@ DROP USER foo; DROP TABLE db.t; DROP DATABASE db; # +# Bug#33578113: DROP privilege on performance_schema.* can't be revoked +# +connection default; +CREATE USER bug33578113; +GRANT DROP ON performance_schema.* TO bug33578113; +REVOKE DROP ON performance_schema.* FROM bug33578113; +DROP USER bug33578113; +# # End of 10.2 tests # # diff --git a/mysql-test/main/grant.test b/mysql-test/main/grant.test index eb677441e15..3279f2b381d 100644 --- a/mysql-test/main/grant.test +++ b/mysql-test/main/grant.test @@ -1,7 +1,7 @@ # Test of GRANT commands # Grant tests not performed with embedded server --- source include/not_embedded.inc +--source include/not_embedded.inc # Save the initial number of concurrent sessions --source include/count_sessions.inc @@ -11,12 +11,6 @@ set LOCAL sql_mode=""; SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; SET GLOBAL log_bin_trust_function_creators = 1; -# Cleanup ---disable_warnings -drop table if exists t1; -drop database if exists mysqltest; ---enable_warnings - connect (master,localhost,root,,); connection master; SET NAMES binary; @@ -2293,6 +2287,16 @@ DROP TABLE db.t; DROP DATABASE db; --echo # +--echo # Bug#33578113: DROP privilege on performance_schema.* can't be revoked +--echo # +connection default; +CREATE USER bug33578113; +GRANT DROP ON performance_schema.* TO bug33578113; +REVOKE DROP ON performance_schema.* FROM bug33578113; +DROP USER bug33578113; +--source include/wait_until_count_sessions.inc + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/main/information_schema_columns.result b/mysql-test/main/information_schema_columns.result new file mode 100644 index 00000000000..3624a6db368 --- /dev/null +++ b/mysql-test/main/information_schema_columns.result @@ -0,0 +1,47 @@ +# +# Start of 10.2 tests +# +# +# MDEV-25243 ASAN heap-use-after-free in Item_func_sp::execute_impl upon concurrent view DDL and I_S query with view and function +# +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE VIEW v01 AS SELECT f1(); +CREATE VIEW v02 AS SELECT f1(); +connect con1,localhost,root,,; +SELECT GET_LOCK('v01',30); +GET_LOCK('v01',30) +1 +SELECT GET_LOCK('v02',30); +GET_LOCK('v02',30) +1 +connection default; +SELECT * FROM INFORMATION_SCHEMA.COLUMNS +WHERE TABLE_SCHEMA='test' + AND TABLE_NAME LIKE 'v0%' + AND GET_LOCK(TABLE_NAME,30) +AND RELEASE_LOCK(TABLE_NAME) +AND f1()=1 +ORDER BY TABLE_NAME; +connection con1; +connection con1; +SELECT RELEASE_LOCK('v01') /* Let the first row evaluate f1 */; +RELEASE_LOCK('v01') +1 +CREATE FUNCTION f2() RETURNS INT RETURN 1 /* Invalidate SP cache*/; +SELECT RELEASE_LOCK('v02') /* Let the second row evaluate f1() */; +RELEASE_LOCK('v02') +1 +DROP FUNCTION f2; +disconnect con1; +connection default; +SELECT RELEASE_LOCK('v01'); +RELEASE_LOCK('v01') +NULL +SELECT RELEASE_LOCK('v02'); +RELEASE_LOCK('v02') +NULL +DROP VIEW v01, v02; +DROP FUNCTION f1; +# +# End of 10.2 tests +# diff --git a/mysql-test/main/information_schema_columns.test b/mysql-test/main/information_schema_columns.test new file mode 100644 index 00000000000..0171b221110 --- /dev/null +++ b/mysql-test/main/information_schema_columns.test @@ -0,0 +1,48 @@ +--echo # +--echo # Start of 10.2 tests +--echo # + +--echo # +--echo # MDEV-25243 ASAN heap-use-after-free in Item_func_sp::execute_impl upon concurrent view DDL and I_S query with view and function +--echo # + + +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE VIEW v01 AS SELECT f1(); +CREATE VIEW v02 AS SELECT f1(); + +--connect(con1,localhost,root,,) +SELECT GET_LOCK('v01',30); +SELECT GET_LOCK('v02',30); +--connection default + +--send + SELECT * FROM INFORMATION_SCHEMA.COLUMNS + WHERE TABLE_SCHEMA='test' + AND TABLE_NAME LIKE 'v0%' + AND GET_LOCK(TABLE_NAME,30) + AND RELEASE_LOCK(TABLE_NAME) + AND f1()=1 + ORDER BY TABLE_NAME; + +--connection con1 +--connection con1 +SELECT RELEASE_LOCK('v01') /* Let the first row evaluate f1 */; +CREATE FUNCTION f2() RETURNS INT RETURN 1 /* Invalidate SP cache*/; +SELECT RELEASE_LOCK('v02') /* Let the second row evaluate f1() */; +DROP FUNCTION f2; +--disconnect con1 + +--connection default +--disable_result_log +--reap +--enable_result_log +SELECT RELEASE_LOCK('v01'); +SELECT RELEASE_LOCK('v02'); + +DROP VIEW v01, v02; +DROP FUNCTION f1; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/main/information_schema_tables.result b/mysql-test/main/information_schema_tables.result new file mode 100644 index 00000000000..a3dd068831c --- /dev/null +++ b/mysql-test/main/information_schema_tables.result @@ -0,0 +1,77 @@ +# +# Start of 10.2 tests +# +# +# MDEV-25243 ASAN heap-use-after-free in Item_func_sp::execute_impl upon concurrent view DDL and I_S query with view and function +# +# The originally reported non-deterministic test. +# It did not fail reliably on every run. +CREATE TABLE t (a INT); +INSERT INTO t VALUES (1),(2); +CREATE FUNCTION f(b INT) RETURNS INT RETURN 1; +CREATE VIEW v AS SELECT f(SUM(a)) FROM t; +connect con1,localhost,root,,test; +LOOP +CREATE OR REPLACE VIEW vv AS SELECT 1; +END LOOP $ +connection default; +SELECT v.* FROM v JOIN INFORMATION_SCHEMA.TABLES WHERE DATA_LENGTH = -1; +f(SUM(a)) +KILL CONID; +disconnect con1; +connection default; +DROP VIEW IF EXISTS vv; +DROP VIEW v; +DROP FUNCTION f; +DROP TABLE t; +# The second test version from the MDEV. +# It failed more reliably, but still was not deterministic. +CREATE FUNCTION f() RETURNS INT RETURN 1; +CREATE VIEW v AS SELECT f() FROM seq_1_to_10; +SELECT * FROM INFORMATION_SCHEMA.TABLES, v;; +connect con1,localhost,root,,; +CREATE VIEW v2 AS SELECT 1; +connection default; +disconnect con1; +DROP VIEW v; +DROP VIEW v2; +DROP FUNCTION f; +# The third test version from the MDEV. +# It failed reliably, and should be deterninistic. +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE VIEW v01 AS SELECT f1(); +CREATE VIEW v02 AS SELECT f1(); +connect con1,localhost,root,,; +SELECT GET_LOCK('v01',30); +GET_LOCK('v01',30) +1 +SELECT GET_LOCK('v02',30); +GET_LOCK('v02',30) +1 +connection default; +SELECT * FROM INFORMATION_SCHEMA.TABLES +WHERE TABLE_SCHEMA='test' + AND TABLE_NAME LIKE 'v0%' + AND GET_LOCK(TABLE_NAME,30) +AND RELEASE_LOCK(TABLE_NAME) +AND f1()=1 +ORDER BY TABLE_NAME; +connection con1; +SELECT RELEASE_LOCK('v01') /* Let the first row evaluate f1 */; +RELEASE_LOCK('v01') +1 +CREATE FUNCTION f2() RETURNS INT RETURN 1 /* Invalidate SP cache*/; +SELECT RELEASE_LOCK('v02') /* Let the second row evaluate f1() */; +RELEASE_LOCK('v02') +1 +DROP FUNCTION f2; +disconnect con1; +connection default; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT MAX_INDEX_LENGTH TEMPORARY +def test v01 VIEW NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL VIEW NULL NULL +def test v02 VIEW NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL VIEW NULL NULL +DROP VIEW v01, v02; +DROP FUNCTION f1; +# +# End of 10.2 tests +# diff --git a/mysql-test/main/information_schema_tables.test b/mysql-test/main/information_schema_tables.test new file mode 100644 index 00000000000..bc4f269a3fb --- /dev/null +++ b/mysql-test/main/information_schema_tables.test @@ -0,0 +1,100 @@ +--source include/have_sequence.inc + +--echo # +--echo # Start of 10.2 tests +--echo # + +--echo # +--echo # MDEV-25243 ASAN heap-use-after-free in Item_func_sp::execute_impl upon concurrent view DDL and I_S query with view and function +--echo # + +--echo # The originally reported non-deterministic test. +--echo # It did not fail reliably on every run. + +CREATE TABLE t (a INT); +INSERT INTO t VALUES (1),(2); +CREATE FUNCTION f(b INT) RETURNS INT RETURN 1; +CREATE VIEW v AS SELECT f(SUM(a)) FROM t; +--connect (con1,localhost,root,,test) +--let $conid= `SELECT CONNECTION_ID()` +--delimiter $ +--send +LOOP + CREATE OR REPLACE VIEW vv AS SELECT 1; +END LOOP $ +--delimiter ; +--connection default +# Avoid "Prepared statement needs to be re-prepared" +# Note, the code could probably eventually fixed to avoid forcing re-pepare if +# the *temporary* instance of Sp_caches (not the permanent one) was invalidated. +--disable_ps_protocol +--disable_warnings +SELECT v.* FROM v JOIN INFORMATION_SCHEMA.TABLES WHERE DATA_LENGTH = -1; +--enable_warnings +--enable_ps_protocol +# Cleanup +--replace_result $conid CONID +--eval KILL $conid +--disconnect con1 +--connection default +DROP VIEW IF EXISTS vv; +DROP VIEW v; +DROP FUNCTION f; +DROP TABLE t; + + +--echo # The second test version from the MDEV. +--echo # It failed more reliably, but still was not deterministic. + + +CREATE FUNCTION f() RETURNS INT RETURN 1; +CREATE VIEW v AS SELECT f() FROM seq_1_to_10; +--send SELECT * FROM INFORMATION_SCHEMA.TABLES, v; +--connect(con1,localhost,root,,) +CREATE VIEW v2 AS SELECT 1; +--connection default +--disable_result_log +--reap +--enable_result_log +--disconnect con1 +DROP VIEW v; +DROP VIEW v2; +DROP FUNCTION f; + +--echo # The third test version from the MDEV. +--echo # It failed reliably, and should be deterninistic. + +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE VIEW v01 AS SELECT f1(); +CREATE VIEW v02 AS SELECT f1(); + +--connect(con1,localhost,root,,) +SELECT GET_LOCK('v01',30); +SELECT GET_LOCK('v02',30); +--connection default + +--send + SELECT * FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA='test' + AND TABLE_NAME LIKE 'v0%' + AND GET_LOCK(TABLE_NAME,30) + AND RELEASE_LOCK(TABLE_NAME) + AND f1()=1 + ORDER BY TABLE_NAME; + +--connection con1 +SELECT RELEASE_LOCK('v01') /* Let the first row evaluate f1 */; +CREATE FUNCTION f2() RETURNS INT RETURN 1 /* Invalidate SP cache*/; +SELECT RELEASE_LOCK('v02') /* Let the second row evaluate f1() */; +DROP FUNCTION f2; +--disconnect con1 +--connection default +--reap + + +DROP VIEW v01, v02; +DROP FUNCTION f1; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/main/mysql_tzinfo_to_sql_symlink.result b/mysql-test/main/mysql_tzinfo_to_sql_symlink.result index f56a2df2012..5753a719769 100644 --- a/mysql-test/main/mysql_tzinfo_to_sql_symlink.result +++ b/mysql-test/main/mysql_tzinfo_to_sql_symlink.result @@ -149,6 +149,29 @@ ALTER TABLE time_zone_transition_type ENGINE=MyISAM; END IF| \d ; # +# MDEV-28263: mariadb-tzinfo-to-sql improve wsrep and binlog cases +# +# +# Testing --skip-write-binlog +# +set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION WSREP_ON=OFF', 'do 0'); +SET SESSION SQL_LOG_BIN=0; +execute immediate @prep1; +INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); +SET @time_zone_id= LAST_INSERT_ID(); +INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id); +INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES + (@time_zone_id, 0, 0, 0, 'GMT') +; +set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION WSREP_ON=OFF', 'do 0'); +SET SESSION SQL_LOG_BIN=0; +execute immediate @prep1; +TRUNCATE TABLE time_zone_leap_second; +ALTER TABLE time_zone_leap_second ORDER BY Transition_time; +# +# End of 10.2 tests +# +# # MDEV-6236 - [PATCH] mysql_tzinfo_to_sql may produce invalid SQL # \d | diff --git a/mysql-test/main/mysql_tzinfo_to_sql_symlink.test b/mysql-test/main/mysql_tzinfo_to_sql_symlink.test index 8ca82b87e30..fcb5916c4a2 100644 --- a/mysql-test/main/mysql_tzinfo_to_sql_symlink.test +++ b/mysql-test/main/mysql_tzinfo_to_sql_symlink.test @@ -32,6 +32,23 @@ --exec $MYSQL_TZINFO_TO_SQL --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1 +--echo # +--echo # MDEV-28263: mariadb-tzinfo-to-sql improve wsrep and binlog cases +--echo # + +--echo # +--echo # Testing --skip-write-binlog +--echo # + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1 + +--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1 + +--echo # +--echo # End of 10.2 tests +--echo # + # # Cleanup # diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result index 214d848981a..0d7bcc1f56e 100644 --- a/mysql-test/main/order_by.result +++ b/mysql-test/main/order_by.result @@ -3508,6 +3508,26 @@ DELETE FROM t1 ORDER BY c; DROP TABLE t1; SET @@SESSION.max_sort_length=DEFAULT; SET sql_mode=DEFAULT; +# +# MDEV-25994 Crash with union of my_decimal type in ORDER BY clause +# +CREATE TABLE t1 (v1 INTEGER) ; +INSERT INTO t1 (v1) VALUES (8); +UPDATE t1 SET v1 = 1 ORDER BY (SELECT 1.1 UNION SELECT -1); +ERROR 21000: Subquery returns more than 1 row +# This one must be successful +UPDATE t1 SET v1 = 2 ORDER BY (SELECT 1 UNION SELECT 1); +UPDATE t1 SET v1 = 3 ORDER BY (SELECT 'a' UNION SELECT 'b'); +ERROR 21000: Subquery returns more than 1 row +# Insert some more data +INSERT INTO t1 (v1) VALUES (8),(9),(100),(-234),(46584),(0); +UPDATE t1 SET v1 = v1+1 ORDER BY (SELECT 100.122 UNION SELECT -189.2); +ERROR 21000: Subquery returns more than 1 row +# This one must be successful +UPDATE t1 SET v1 = v1-200 ORDER BY (SELECT 1 UNION SELECT 1); +UPDATE t1 SET v1 = v1 ORDER BY (SELECT 'abc' UNION SELECT 'bbb'); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; # End of 10.2 tests # # MDEV-16214: Incorrect plan taken by the optimizer , uses INDEX instead of ref access with ORDER BY diff --git a/mysql-test/main/order_by.test b/mysql-test/main/order_by.test index 1a0235c5c53..17b307208e0 100644 --- a/mysql-test/main/order_by.test +++ b/mysql-test/main/order_by.test @@ -2331,6 +2331,31 @@ DROP TABLE t1; SET @@SESSION.max_sort_length=DEFAULT; SET sql_mode=DEFAULT; +--echo # +--echo # MDEV-25994 Crash with union of my_decimal type in ORDER BY clause +--echo # + +CREATE TABLE t1 (v1 INTEGER) ; +INSERT INTO t1 (v1) VALUES (8); +--error ER_SUBQUERY_NO_1_ROW +UPDATE t1 SET v1 = 1 ORDER BY (SELECT 1.1 UNION SELECT -1); +--echo # This one must be successful +UPDATE t1 SET v1 = 2 ORDER BY (SELECT 1 UNION SELECT 1); +--error ER_SUBQUERY_NO_1_ROW +UPDATE t1 SET v1 = 3 ORDER BY (SELECT 'a' UNION SELECT 'b'); + +-- echo # Insert some more data +INSERT INTO t1 (v1) VALUES (8),(9),(100),(-234),(46584),(0); +--error ER_SUBQUERY_NO_1_ROW +UPDATE t1 SET v1 = v1+1 ORDER BY (SELECT 100.122 UNION SELECT -189.2); +--echo # This one must be successful +UPDATE t1 SET v1 = v1-200 ORDER BY (SELECT 1 UNION SELECT 1); +--error ER_SUBQUERY_NO_1_ROW +UPDATE t1 SET v1 = v1 ORDER BY (SELECT 'abc' UNION SELECT 'bbb'); + + +DROP TABLE t1; + --echo # End of 10.2 tests diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result index b7bce4269e2..7bb37e78fa5 100644 --- a/mysql-test/main/parser.result +++ b/mysql-test/main/parser.result @@ -1360,6 +1360,48 @@ SELECT tmp 1.e.test FROM scientific_notation AS tmp; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1.e.test FROM scientific_notation AS tmp' at line 1 DROP TABLE scientific_notation; # +# MDEV-6899 extra semicolon in show create event syntax +# +set timestamp=unix_timestamp('2020-10-10 5:5:5'); +create table t1 (a int); +create trigger a before insert on t1 for each row set @a:=1;select 2$ +2 +2 +show create trigger a; +Trigger a +sql_mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION +SQL Original Statement CREATE DEFINER=`root`@`localhost` trigger a before insert on t1 for each row set @a:=1 +character_set_client latin1 +collation_connection latin1_swedish_ci +Database Collation latin1_swedish_ci +Created 2020-10-10 05:05:05.00 +drop table t1; +create procedure a() select 1;select 2$ +2 +2 +show create procedure a; +Procedure a +sql_mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION +Create Procedure CREATE DEFINER=`root`@`localhost` PROCEDURE `a`() +select 1 +character_set_client latin1 +collation_connection latin1_swedish_ci +Database Collation latin1_swedish_ci +drop procedure a; +create function a() returns int return 1;select 2$ +2 +2 +show create function a; +Function a +sql_mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION +Create Function CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11) +return 1 +character_set_client latin1 +collation_connection latin1_swedish_ci +Database Collation latin1_swedish_ci +drop function a; +set timestamp=default; +# # End of 10.2 tests # # diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test index 023b54d1319..ca97398d8b6 100644 --- a/mysql-test/main/parser.test +++ b/mysql-test/main/parser.test @@ -1400,6 +1400,30 @@ SELECT tmp 1.e.test FROM scientific_notation AS tmp; DROP TABLE scientific_notation; --echo # +--echo # MDEV-6899 extra semicolon in show create event syntax +--echo # +set timestamp=unix_timestamp('2020-10-10 5:5:5'); +create table t1 (a int); +delimiter $; +create trigger a before insert on t1 for each row set @a:=1;select 2$ +delimiter ;$ +query_vertical show create trigger a; +drop table t1; + +delimiter $; +create procedure a() select 1;select 2$ +delimiter ;$ +query_vertical show create procedure a; +drop procedure a; + +delimiter $; +create function a() returns int return 1;select 2$ +delimiter ;$ +query_vertical show create function a; +drop function a; +set timestamp=default; + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/main/parser_not_embedded.result b/mysql-test/main/parser_not_embedded.result index 25349e51577..2147e25b3b1 100644 --- a/mysql-test/main/parser_not_embedded.result +++ b/mysql-test/main/parser_not_embedded.result @@ -102,3 +102,23 @@ ROLLBACK AND NO CHAIN NO RELEASE; # # End of 5.5 tests # +# +# MDEV-6899 extra semicolon in show create event syntax +# +set timestamp=unix_timestamp('2020-10-10 5:5:5'); +create event a on schedule every 1 day do set @a:=1;select 2$ +2 +2 +show create event a; +Event a +sql_mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION +time_zone SYSTEM +Create Event CREATE DEFINER=`root`@`localhost` EVENT `a` ON SCHEDULE EVERY 1 DAY STARTS '2020-10-10 05:05:05' ON COMPLETION NOT PRESERVE ENABLE DO set @a:=1 +character_set_client latin1 +collation_connection latin1_swedish_ci +Database Collation latin1_swedish_ci +drop event a; +set timestamp=default; +# +# End of 10.2 tests +# diff --git a/mysql-test/main/parser_not_embedded.test b/mysql-test/main/parser_not_embedded.test index 3af1260f4ad..270573ece93 100644 --- a/mysql-test/main/parser_not_embedded.test +++ b/mysql-test/main/parser_not_embedded.test @@ -99,3 +99,18 @@ ROLLBACK AND NO CHAIN NO RELEASE; --echo # --echo # End of 5.5 tests --echo # + +--echo # +--echo # MDEV-6899 extra semicolon in show create event syntax +--echo # +set timestamp=unix_timestamp('2020-10-10 5:5:5'); +delimiter $; +create event a on schedule every 1 day do set @a:=1;select 2$ +delimiter ;$ +query_vertical show create event a; +drop event a; +set timestamp=default; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/main/row-checksum-old.result b/mysql-test/main/row-checksum-old.result index d374013f61c..7caed4fc7dc 100644 --- a/mysql-test/main/row-checksum-old.result +++ b/mysql-test/main/row-checksum-old.result @@ -1,4 +1,3 @@ -drop table if exists t1; create table t1 (a int null, v varchar(100)) engine=myisam checksum=0; insert into t1 values(null, null), (1, "hello"); checksum table t1; @@ -98,4 +97,48 @@ CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 2326430205 drop table t1; +# # End of 5.5 tests +# +# +# MDEV-28020 CHECKSUM TABLE calculates different checksums +# +create table t1 ( a int, b int as (a) virtual, c text) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +Warnings: +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +checksum table t1 extended; +Table Checksum +test.t1 4101438232 +checksum table t1; +Table Checksum +test.t1 4101438232 +drop table t1; +create table t1 ( a int, b int as (a) virtual, c text, key(b)) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +Warnings: +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +checksum table t1 extended; +Table Checksum +test.t1 4101438232 +checksum table t1; +Table Checksum +test.t1 4101438232 +drop table t1; +create table t1 ( a int, b int as (a) stored, c text) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +Warnings: +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +checksum table t1 extended; +Table Checksum +test.t1 2897795735 +checksum table t1; +Table Checksum +test.t1 2897795735 +drop table t1; +# +# End of 10.2 tests +# diff --git a/mysql-test/main/row-checksum.result b/mysql-test/main/row-checksum.result index 4625e09c060..c80ca4eed9a 100644 --- a/mysql-test/main/row-checksum.result +++ b/mysql-test/main/row-checksum.result @@ -1,4 +1,3 @@ -drop table if exists t1; create table t1 (a int null, v varchar(100)) engine=myisam checksum=0; insert into t1 values(null, null), (1, "hello"); checksum table t1; @@ -98,4 +97,48 @@ CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 2326430205 drop table t1; +# # End of 5.5 tests +# +# +# MDEV-28020 CHECKSUM TABLE calculates different checksums +# +create table t1 ( a int, b int as (a) virtual, c text) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +Warnings: +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +checksum table t1 extended; +Table Checksum +test.t1 4101438232 +checksum table t1; +Table Checksum +test.t1 4101438232 +drop table t1; +create table t1 ( a int, b int as (a) virtual, c text, key(b)) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +Warnings: +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +checksum table t1 extended; +Table Checksum +test.t1 4101438232 +checksum table t1; +Table Checksum +test.t1 4101438232 +drop table t1; +create table t1 ( a int, b int as (a) stored, c text) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +Warnings: +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +checksum table t1 extended; +Table Checksum +test.t1 2897795735 +checksum table t1; +Table Checksum +test.t1 2897795735 +drop table t1; +# +# End of 10.2 tests +# diff --git a/mysql-test/main/row-checksum.test b/mysql-test/main/row-checksum.test index 5acfda45f75..3b510abba84 100644 --- a/mysql-test/main/row-checksum.test +++ b/mysql-test/main/row-checksum.test @@ -2,12 +2,8 @@ # Test checksum # --- source include/have_innodb.inc --- source include/have_maria.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings +--source include/have_innodb.inc +--source include/have_maria.inc create table t1 (a int null, v varchar(100)) engine=myisam checksum=0; insert into t1 values(null, null), (1, "hello"); @@ -76,4 +72,31 @@ CHECKSUM TABLE t1 EXTENDED; drop table t1; +--echo # --echo # End of 5.5 tests +--echo # + +--echo # +--echo # MDEV-28020 CHECKSUM TABLE calculates different checksums +--echo # +create table t1 ( a int, b int as (a) virtual, c text) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +checksum table t1 extended; +checksum table t1; +drop table t1; + +create table t1 ( a int, b int as (a) virtual, c text, key(b)) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +checksum table t1 extended; +checksum table t1; +drop table t1; + +create table t1 ( a int, b int as (a) stored, c text) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +checksum table t1 extended; +checksum table t1; +drop table t1; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result index 9809248e83b..ffdfe00199b 100644 --- a/mysql-test/main/subselect.result +++ b/mysql-test/main/subselect.result @@ -1260,7 +1260,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) NOT NULL + `a` int(3) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result index 6c1ede6914a..c2a24d3a0bd 100644 --- a/mysql-test/main/subselect4.result +++ b/mysql-test/main/subselect4.result @@ -2905,5 +2905,80 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY tn eq_ref PRIMARY PRIMARY 32 test.tms.key1 1 Using where set optimizer_switch=@tmp_os; drop table t1, t10, t11; +# +# MDEV-28268: Server crashes in Expression_cache_tracker::fetch_current_stats +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,2),(3,4); +ANALYZE FORMAT=JSON +SELECT DISTINCT +(SELECT MIN(a) FROM t1 WHERE b <= ANY (SELECT a FROM t1)) AS f +FROM t1; +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "duplicate_removal": { + "temporary_table": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 2, + "r_rows": 2, + "r_total_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "subqueries": [ + { + "expression_cache": { + "state": "disabled", + "r_loops": 0, + "query_block": { + "select_id": 2, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 2, + "r_rows": 2, + "r_total_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 50, + "attached_condition": "<nop>(<in_optimizer>(t1.b,(subquery#3) >= 4))" + }, + "subqueries": [ + { + "query_block": { + "select_id": 3, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 2, + "r_rows": 2, + "r_total_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + } + ] + } + } + } + ] + } + } + } +} +DROP TABLE t1; # End of 10.2 tests # End of 10.3 tests diff --git a/mysql-test/main/subselect4.test b/mysql-test/main/subselect4.test index 7da299c4a14..aeef8849fc5 100644 --- a/mysql-test/main/subselect4.test +++ b/mysql-test/main/subselect4.test @@ -2421,6 +2421,21 @@ set optimizer_switch=@tmp_os; drop table t1, t10, t11; +--echo # +--echo # MDEV-28268: Server crashes in Expression_cache_tracker::fetch_current_stats +--echo # +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,2),(3,4); + +--source include/analyze-format.inc +ANALYZE FORMAT=JSON +SELECT DISTINCT + (SELECT MIN(a) FROM t1 WHERE b <= ANY (SELECT a FROM t1)) AS f +FROM t1; + +# Cleanup +DROP TABLE t1; + --echo # End of 10.2 tests --echo # End of 10.3 tests diff --git a/mysql-test/main/subselect_innodb.result b/mysql-test/main/subselect_innodb.result index 4eaea099451..4796245f8e3 100644 --- a/mysql-test/main/subselect_innodb.result +++ b/mysql-test/main/subselect_innodb.result @@ -629,3 +629,35 @@ a b 2019-03-10 02:55:05 2019-03-10 02:55:05 DROP TABLE t1,t2; set character_set_connection=@save_character_set_connection; +# +# MDEV-26047: MariaDB server crash at Item_subselect::init_expr_cache_tracker +# +CREATE TABLE t1 (a int) engine=innodb; +SELECT 1 IN ( +SELECT NULL +FROM t1 +WHERE +a IS NOT NULL +GROUP BY +(SELECT NULL from dual WHERE a = 1) +); +1 IN ( +SELECT NULL +FROM t1 +WHERE +a IS NOT NULL +GROUP BY +(SELECT NULL from dual WHERE a = 1) +) +0 +drop table t1; +# Testcase from MDEV-26164 +create table t1(a int); +# Disable the warning as it includes current time and changes for every test run. +select 1 from t1 where not exists +( +select 1 from t1 where binary current_time() +group by (select a),(select 1) +); +1 +drop table t1; diff --git a/mysql-test/main/subselect_innodb.test b/mysql-test/main/subselect_innodb.test index 2c117fe00d6..f42ac514d53 100644 --- a/mysql-test/main/subselect_innodb.test +++ b/mysql-test/main/subselect_innodb.test @@ -627,3 +627,31 @@ SELECT * FROM t1 WHERE (SELECT 1,CONCAT(a) FROM t1) = (SELECT 1,CONCAT(a) FROM t DROP TABLE t1,t2; set character_set_connection=@save_character_set_connection; + +--echo # +--echo # MDEV-26047: MariaDB server crash at Item_subselect::init_expr_cache_tracker +--echo # +CREATE TABLE t1 (a int) engine=innodb; + +SELECT 1 IN ( + SELECT NULL + FROM t1 + WHERE + a IS NOT NULL + GROUP BY + (SELECT NULL from dual WHERE a = 1) +); +drop table t1; + +--echo # Testcase from MDEV-26164 +create table t1(a int); +--echo # Disable the warning as it includes current time and changes for every test run. +--disable_warnings +select 1 from t1 where not exists +( + select 1 from t1 where binary current_time() + group by (select a),(select 1) +); +--enable_warnings +drop table t1; + diff --git a/mysql-test/main/subselect_no_exists_to_in.result b/mysql-test/main/subselect_no_exists_to_in.result index a391b79037c..98f06503d42 100644 --- a/mysql-test/main/subselect_no_exists_to_in.result +++ b/mysql-test/main/subselect_no_exists_to_in.result @@ -1264,7 +1264,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) NOT NULL + `a` int(3) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect_no_mat.result b/mysql-test/main/subselect_no_mat.result index 12239aae5e8..1189d806a72 100644 --- a/mysql-test/main/subselect_no_mat.result +++ b/mysql-test/main/subselect_no_mat.result @@ -1267,7 +1267,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) NOT NULL + `a` int(3) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect_no_opts.result b/mysql-test/main/subselect_no_opts.result index 8c18ec4c063..44fe0fedd90 100644 --- a/mysql-test/main/subselect_no_opts.result +++ b/mysql-test/main/subselect_no_opts.result @@ -1263,7 +1263,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) NOT NULL + `a` int(3) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect_no_scache.result b/mysql-test/main/subselect_no_scache.result index 3590cd20cc6..feafecae4bf 100644 --- a/mysql-test/main/subselect_no_scache.result +++ b/mysql-test/main/subselect_no_scache.result @@ -1266,7 +1266,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) NOT NULL + `a` int(3) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result index f2d7077959b..bf876c02050 100644 --- a/mysql-test/main/subselect_no_semijoin.result +++ b/mysql-test/main/subselect_no_semijoin.result @@ -1263,7 +1263,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) NOT NULL + `a` int(3) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a int); diff --git a/mysql-test/main/type_newdecimal.result b/mysql-test/main/type_newdecimal.result index dbc6b1711f0..57b385eb8da 100644 --- a/mysql-test/main/type_newdecimal.result +++ b/mysql-test/main/type_newdecimal.result @@ -2456,5 +2456,29 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; # +# MDEV-25317 Assertion `scale <= precision' failed in +# decimal_bin_size And Assertion `scale >= 0 && precision > 0 && scale <= precision' +# failed in decimal_bin_size_inline/decimal_bin_size. +# +SELECT AVG(DISTINCT 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001); +AVG(DISTINCT 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0.00000000000000000000000000000000000000 +CREATE TABLE t1 AS SELECT NULL AS v1; +SELECT 1 FROM t1 GROUP BY v1 ORDER BY AVG ( from_unixtime ( '' ) ) ; +1 +1 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '' +DROP TABLE t1; +SELECT SUM(DISTINCT 0.000000000000000000000000000000000000001); +SUM(DISTINCT 0.000000000000000000000000000000000000001) +0.00000000000000000000000000000000000000 +CREATE TABLE t1 AS SELECT 1.000000000000000000000000000000000 AS a; +ALTER TABLE t1 ADD COLUMN b INT; +SELECT ROUND (a,b) AS c FROM t1 ORDER BY c; +c +NULL +DROP TABLE t1; +# # End of 10.2 tests # diff --git a/mysql-test/main/type_newdecimal.test b/mysql-test/main/type_newdecimal.test index e5d903e95cd..a5cb15e1a2c 100644 --- a/mysql-test/main/type_newdecimal.test +++ b/mysql-test/main/type_newdecimal.test @@ -1895,5 +1895,24 @@ show create table t1; drop table t1; --echo # +--echo # MDEV-25317 Assertion `scale <= precision' failed in +--echo # decimal_bin_size And Assertion `scale >= 0 && precision > 0 && scale <= precision' +--echo # failed in decimal_bin_size_inline/decimal_bin_size. +--echo # + +SELECT AVG(DISTINCT 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001); + +CREATE TABLE t1 AS SELECT NULL AS v1; +SELECT 1 FROM t1 GROUP BY v1 ORDER BY AVG ( from_unixtime ( '' ) ) ; +DROP TABLE t1; + +SELECT SUM(DISTINCT 0.000000000000000000000000000000000000001); + +CREATE TABLE t1 AS SELECT 1.000000000000000000000000000000000 AS a; +ALTER TABLE t1 ADD COLUMN b INT; +SELECT ROUND (a,b) AS c FROM t1 ORDER BY c; +DROP TABLE t1; + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/suite/binlog_encryption/rpl_parallel.result b/mysql-test/suite/binlog_encryption/rpl_parallel.result index 12e5455c6c1..79efad1a27a 100644 --- a/mysql-test/suite/binlog_encryption/rpl_parallel.result +++ b/mysql-test/suite/binlog_encryption/rpl_parallel.result @@ -1379,6 +1379,7 @@ include/stop_slave.inc SET GLOBAL slave_parallel_threads=1; SET @old_dbug= @@GLOBAL.debug_dbug; SET GLOBAL debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000"; +CALL mtr.add_suppression("Unexpected break of being relay-logged GTID"); connection server_1; INSERT INTO t2 VALUES (101); INSERT INTO t2 VALUES (102); diff --git a/mysql-test/suite/binlog_encryption/rpl_ssl.result b/mysql-test/suite/binlog_encryption/rpl_ssl.result index 0b3a6cd0eca..ce9e4d486cf 100644 --- a/mysql-test/suite/binlog_encryption/rpl_ssl.result +++ b/mysql-test/suite/binlog_encryption/rpl_ssl.result @@ -23,6 +23,8 @@ t Master_SSL_Allowed = 'Yes' Master_SSL_CA_Path = '' Master_SSL_CA_File = 'MYSQL_TEST_DIR/std_data/cacert.pem' +Master_SSL_Crl = '' +Master_SSL_Crlpath = '' Master_SSL_Cert = 'MYSQL_TEST_DIR/std_data/client-cert.pem' Master_SSL_Key = 'MYSQL_TEST_DIR/std_data/client-key.pem' include/check_slave_is_running.inc @@ -37,6 +39,8 @@ include/wait_for_slave_to_start.inc Master_SSL_Allowed = 'Yes' Master_SSL_CA_Path = '' Master_SSL_CA_File = 'MYSQL_TEST_DIR/std_data/cacert.pem' +Master_SSL_Crl = '' +Master_SSL_Crlpath = '' Master_SSL_Cert = 'MYSQL_TEST_DIR/std_data/client-cert.pem' Master_SSL_Key = 'MYSQL_TEST_DIR/std_data/client-key.pem' include/check_slave_is_running.inc diff --git a/mysql-test/suite/galera/r/mysql_tzinfo_to_sql.result b/mysql-test/suite/galera/r/mysql_tzinfo_to_sql.result new file mode 100644 index 00000000000..a140f517ac8 --- /dev/null +++ b/mysql-test/suite/galera/r/mysql_tzinfo_to_sql.result @@ -0,0 +1,152 @@ +# +# MDEV-28263: mariadb-tzinfo-to-sql improve wsrep and binlog cases +# + +# On node_1 +connection node_1; +CREATE TABLE time_zone LIKE mysql.time_zone; +CREATE TABLE time_zone_name LIKE mysql.time_zone_name; +CREATE TABLE time_zone_transition LIKE mysql.time_zone_transition; +CREATE TABLE time_zone_transition_type LIKE mysql.time_zone_transition_type; +CREATE TABLE time_zone_leap_second LIKE mysql.time_zone_leap_second; +# +# Run on zoneinfo directory --skip-write-binlog +# + +# Apply on node_1 + +load timezones +'binlog stationary as expected' +SELECT COUNT(*) FROM time_zone; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_name; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_transition; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition_type; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_leap_second; +COUNT(*) +0 + +# On node_2 (not replicated) + +connection node_2; +SELECT COUNT(*) FROM time_zone; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_name; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition_type; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_leap_second; +COUNT(*) +0 +# +# Run on zoneinfo directory without --skip-write-binlog +# + +# Apply on node_1 + +connection node_1; +load timezones +'binlog advanced as expected' +SELECT COUNT(*) FROM time_zone; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_name; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_transition; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition_type; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_leap_second; +COUNT(*) +0 + +# On node_2 (replicated via InnoDB) + +connection node_2; +SELECT COUNT(*) FROM time_zone; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_name; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_transition; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition_type; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_leap_second; +COUNT(*) +0 +TRUNCATE TABLE time_zone; +TRUNCATE TABLE time_zone_name; +TRUNCATE TABLE time_zone_transition; +TRUNCATE TABLE time_zone_transition_type; +TRUNCATE TABLE time_zone_leap_second; + +# Apply on node_1 (with wsrep_on=OFF) + +connection node_1; +SET GLOBAL WSREP_ON=OFF; +load timezones +SET GLOBAL WSREP_ON=ON; +'binlog advanced as expected' +SELECT COUNT(*) FROM time_zone; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_name; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_transition; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition_type; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_leap_second; +COUNT(*) +0 + +# On node_2 (Should not have been replicated) + +connection node_2; +SELECT COUNT(*) FROM time_zone; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_name; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition_type; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_leap_second; +COUNT(*) +0 +connection node_1; +DROP TABLE time_zone; +DROP TABLE time_zone_name; +DROP TABLE time_zone_transition; +DROP TABLE time_zone_transition_type; +DROP TABLE time_zone_leap_second; +# +# End of 10.2 tests +# diff --git a/mysql-test/suite/galera/t/mysql_tzinfo_to_sql.opt b/mysql-test/suite/galera/t/mysql_tzinfo_to_sql.opt new file mode 100644 index 00000000000..beae84b3862 --- /dev/null +++ b/mysql-test/suite/galera/t/mysql_tzinfo_to_sql.opt @@ -0,0 +1 @@ +--log-bin diff --git a/mysql-test/suite/galera/t/mysql_tzinfo_to_sql.test b/mysql-test/suite/galera/t/mysql_tzinfo_to_sql.test new file mode 100644 index 00000000000..6bfad2f18b5 --- /dev/null +++ b/mysql-test/suite/galera/t/mysql_tzinfo_to_sql.test @@ -0,0 +1,156 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/not_embedded.inc +# merge note: 10.6 change not_embedded.inc to no_protocol.inc + +# Unlike the similar galera.mariadb_tzinfo_to_sql.test in 10.6+, this +# tests that the output can be parsed by the mysql client. +--echo # +--echo # MDEV-28263: mariadb-tzinfo-to-sql improve wsrep and binlog cases +--echo # + +--exec mkdir $MYSQLTEST_VARDIR/zoneinfo +--exec ln -s $MYSQLTEST_VARDIR/zoneinfo $MYSQLTEST_VARDIR/zoneinfo/posix +--copy_file std_data/zoneinfo/GMT $MYSQLTEST_VARDIR/zoneinfo/GMT + +--echo +--echo # On node_1 +--connection node_1 + +CREATE TABLE time_zone LIKE mysql.time_zone; +CREATE TABLE time_zone_name LIKE mysql.time_zone_name; +CREATE TABLE time_zone_transition LIKE mysql.time_zone_transition; +CREATE TABLE time_zone_transition_type LIKE mysql.time_zone_transition_type; +CREATE TABLE time_zone_leap_second LIKE mysql.time_zone_leap_second; + +--echo # +--echo # Run on zoneinfo directory --skip-write-binlog +--echo # + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>/dev/null > $MYSQL_TMP_DIR/tz.sql + +--echo +--echo # Apply on node_1 +--echo +--let $snap_pos= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_position', Value, 1) +--echo load timezones +--exec $MYSQL test < "$MYSQL_TMP_DIR/tz.sql" +--let $new_snap_pos= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_position', Value, 1) + +if ($snap_pos == $new_snap_pos) +{ +--echo 'binlog stationary as expected' +} + +SELECT COUNT(*) FROM time_zone; +SELECT COUNT(*) FROM time_zone_name; +SELECT COUNT(*) FROM time_zone_transition; +SELECT COUNT(*) FROM time_zone_transition_type; +SELECT COUNT(*) FROM time_zone_leap_second; + +--echo +--echo # On node_2 (not replicated) +--echo +--connection node_2 + +SELECT COUNT(*) FROM time_zone; +SELECT COUNT(*) FROM time_zone_name; +SELECT COUNT(*) FROM time_zone_transition; +SELECT COUNT(*) FROM time_zone_transition_type; +SELECT COUNT(*) FROM time_zone_leap_second; + +--echo # +--echo # Run on zoneinfo directory without --skip-write-binlog +--echo # + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>/dev/null > $MYSQL_TMP_DIR/tz.sql + +--echo +--echo # Apply on node_1 +--echo +--connection node_1 + +--echo load timezones +--exec $MYSQL test < "$MYSQL_TMP_DIR/tz.sql" +--let $new_snap_pos= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_position', Value, 1) + +if ($snap_pos < $new_snap_pos) +{ +--echo 'binlog advanced as expected' +} + +SELECT COUNT(*) FROM time_zone; +SELECT COUNT(*) FROM time_zone_name; +SELECT COUNT(*) FROM time_zone_transition; +SELECT COUNT(*) FROM time_zone_transition_type; +SELECT COUNT(*) FROM time_zone_leap_second; + +--echo +--echo # On node_2 (replicated via InnoDB) +--echo +--connection node_2 + +SELECT COUNT(*) FROM time_zone; +SELECT COUNT(*) FROM time_zone_name; +SELECT COUNT(*) FROM time_zone_transition; +SELECT COUNT(*) FROM time_zone_transition_type; +SELECT COUNT(*) FROM time_zone_leap_second; + +TRUNCATE TABLE time_zone; +TRUNCATE TABLE time_zone_name; +TRUNCATE TABLE time_zone_transition; +TRUNCATE TABLE time_zone_transition_type; +TRUNCATE TABLE time_zone_leap_second; + +--echo +--echo # Apply on node_1 (with wsrep_on=OFF) +--echo +--connection node_1 + +SET GLOBAL WSREP_ON=OFF; +--let $snap_pos= $new_snap_pos +--echo load timezones +--exec $MYSQL test < "$MYSQL_TMP_DIR/tz.sql" +--let $new_snap_pos= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_position', Value, 1) +SET GLOBAL WSREP_ON=ON; + +if ($snap_pos < $new_snap_pos) +{ +--echo 'binlog advanced as expected' +} + +SELECT COUNT(*) FROM time_zone; +SELECT COUNT(*) FROM time_zone_name; +SELECT COUNT(*) FROM time_zone_transition; +SELECT COUNT(*) FROM time_zone_transition_type; +SELECT COUNT(*) FROM time_zone_leap_second; + +--echo +--echo # On node_2 (Should not have been replicated) +--echo +--connection node_2 + +SELECT COUNT(*) FROM time_zone; +SELECT COUNT(*) FROM time_zone_name; +SELECT COUNT(*) FROM time_zone_transition; +SELECT COUNT(*) FROM time_zone_transition_type; +SELECT COUNT(*) FROM time_zone_leap_second; + +# +# Cleanup +# + +--connection node_1 +--remove_file $MYSQL_TMP_DIR/tz.sql +--exec rm -rf $MYSQLTEST_VARDIR/zoneinfo +DROP TABLE time_zone; +DROP TABLE time_zone_name; +DROP TABLE time_zone_transition; +DROP TABLE time_zone_transition_type; +DROP TABLE time_zone_leap_second; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/suite/handler/aria.result b/mysql-test/suite/handler/aria.result index 6b02ac9b085..433a8a7008e 100644 --- a/mysql-test/suite/handler/aria.result +++ b/mysql-test/suite/handler/aria.result @@ -1845,3 +1845,19 @@ a b HANDLER t1 CLOSE; DROP TABLE t1; End of 5.1 tests +# +# 10.2 Test +# +# MDEV-20207: Assertion `! is_set()' failed in +# Diagnostics_area::set_eof_status upon HANDLER READ +# +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 'test.t1' +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; +HANDLER h READ a = (0); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +HANDLER h CLOSE; +DROP TABLE t1; +# End of 10.2 Test diff --git a/mysql-test/suite/handler/aria.test b/mysql-test/suite/handler/aria.test index 1913d2b791c..912a9e89721 100644 --- a/mysql-test/suite/handler/aria.test +++ b/mysql-test/suite/handler/aria.test @@ -80,3 +80,23 @@ HANDLER t1 CLOSE; DROP TABLE t1; --echo End of 5.1 tests + +--echo # +--echo # 10.2 Test +--echo # +--echo # MDEV-20207: Assertion `! is_set()' failed in +--echo # Diagnostics_area::set_eof_status upon HANDLER READ +--echo # + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; + +--error ER_CANT_CREATE_GEOMETRY_OBJECT +HANDLER h READ a = (0); + +HANDLER h CLOSE; +DROP TABLE t1; + +--echo # End of 10.2 Test diff --git a/mysql-test/suite/handler/innodb.result b/mysql-test/suite/handler/innodb.result index 80e8ed679a9..7f9995c9e84 100644 --- a/mysql-test/suite/handler/innodb.result +++ b/mysql-test/suite/handler/innodb.result @@ -1748,3 +1748,19 @@ HANDLER t1 READ `PRIMARY` PREV; f1 f2 3 3 DROP TABLE t1; +# +# 10.2 Test +# +# MDEV-20207: Assertion `! is_set()' failed in +# Diagnostics_area::set_eof_status upon HANDLER READ +# +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 'test.t1' +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; +HANDLER h READ a = (0); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +HANDLER h CLOSE; +DROP TABLE t1; +# End of 10.2 Test diff --git a/mysql-test/suite/handler/innodb.test b/mysql-test/suite/handler/innodb.test index 6527c4bb8bb..52c09f2e7c7 100644 --- a/mysql-test/suite/handler/innodb.test +++ b/mysql-test/suite/handler/innodb.test @@ -26,3 +26,23 @@ HANDLER t1 OPEN; HANDLER t1 READ FIRST WHERE f2 <= 1; HANDLER t1 READ `PRIMARY` PREV; DROP TABLE t1; + +--echo # +--echo # 10.2 Test +--echo # +--echo # MDEV-20207: Assertion `! is_set()' failed in +--echo # Diagnostics_area::set_eof_status upon HANDLER READ +--echo # + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; + +--error ER_CANT_CREATE_GEOMETRY_OBJECT +HANDLER h READ a = (0); + +HANDLER h CLOSE; +DROP TABLE t1; + +--echo # End of 10.2 Test diff --git a/mysql-test/suite/handler/interface.result b/mysql-test/suite/handler/interface.result index c4a169be185..0659d0c0902 100644 --- a/mysql-test/suite/handler/interface.result +++ b/mysql-test/suite/handler/interface.result @@ -313,6 +313,22 @@ handler v read next; ERROR 42S02: Unknown table 'v' in HANDLER drop view v; # +# 10.2 Test +# +# MDEV-20207: Assertion `! is_set()' failed in +# Diagnostics_area::set_eof_status upon HANDLER READ +# +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 'test.t1' +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; +HANDLER h READ a = (0); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +HANDLER h CLOSE; +DROP TABLE t1; +# End of 10.2 Test +# # MDEV-15813 ASAN use-after-poison in hp_hashnr upon # HANDLER READ on a versioned HEAP table # diff --git a/mysql-test/suite/handler/interface.test b/mysql-test/suite/handler/interface.test index 15853dfdbf5..4b9ab57394c 100644 --- a/mysql-test/suite/handler/interface.test +++ b/mysql-test/suite/handler/interface.test @@ -356,6 +356,26 @@ handler v read next; drop view v; --echo # +--echo # 10.2 Test +--echo # +--echo # MDEV-20207: Assertion `! is_set()' failed in +--echo # Diagnostics_area::set_eof_status upon HANDLER READ +--echo # + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; + +--error ER_CANT_CREATE_GEOMETRY_OBJECT +HANDLER h READ a = (0); + +HANDLER h CLOSE; +DROP TABLE t1; + +--echo # End of 10.2 Test + +--echo # --echo # MDEV-15813 ASAN use-after-poison in hp_hashnr upon --echo # HANDLER READ on a versioned HEAP table --echo # diff --git a/mysql-test/suite/handler/myisam.result b/mysql-test/suite/handler/myisam.result index 90e1767a1f3..c444027d062 100644 --- a/mysql-test/suite/handler/myisam.result +++ b/mysql-test/suite/handler/myisam.result @@ -1931,3 +1931,17 @@ test.t1 preload_keys status OK HANDLER t1 READ FIRST; ERROR 42S02: Unknown table 't1' in HANDLER End of 5.1 tests +# +# 10.2 Test +# +# MDEV-20207: Assertion `! is_set()' failed in +# Diagnostics_area::set_eof_status upon HANDLER READ +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; +HANDLER h READ a = (0); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +HANDLER h CLOSE; +DROP TABLE t1; +# End of 10.2 Test diff --git a/mysql-test/suite/handler/myisam.test b/mysql-test/suite/handler/myisam.test index a2d87630aef..2fce8548322 100644 --- a/mysql-test/suite/handler/myisam.test +++ b/mysql-test/suite/handler/myisam.test @@ -169,3 +169,23 @@ HANDLER t1 READ FIRST; --echo End of 5.1 tests + +--echo # +--echo # 10.2 Test +--echo # +--echo # MDEV-20207: Assertion `! is_set()' failed in +--echo # Diagnostics_area::set_eof_status upon HANDLER READ +--echo # + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; + +--error ER_CANT_CREATE_GEOMETRY_OBJECT +HANDLER h READ a = (0); + +HANDLER h CLOSE; +DROP TABLE t1; + +--echo # End of 10.2 Test diff --git a/mysql-test/suite/innodb/r/innodb-autoinc-part.result b/mysql-test/suite/innodb/r/innodb-autoinc-part.result new file mode 100644 index 00000000000..6872b5e02f5 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-autoinc-part.result @@ -0,0 +1,34 @@ +# +# MDEV-28416 Incorrect AUTO_INCREMENT may be issued +# +SET @aii=@@auto_increment_increment; +SET auto_increment_increment=300; +CREATE TABLE t1 (a SERIAL) ENGINE=innodb +PARTITION BY RANGE (a) ( +PARTITION p0 VALUES LESS THAN (6), +PARTITION p1 VALUES LESS THAN MAXVALUE +); +INSERT INTO t1 VALUES (18446744073709551613); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551614 DEFAULT CHARSET=latin1 + PARTITION BY RANGE (`a`) +(PARTITION `p0` VALUES LESS THAN (6) ENGINE = InnoDB, + PARTITION `p1` VALUES LESS THAN MAXVALUE ENGINE = InnoDB) +INSERT INTO t1 VALUES (NULL); +ERROR 22003: Out of range value for column 'a' at row 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=298 DEFAULT CHARSET=latin1 + PARTITION BY RANGE (`a`) +(PARTITION `p0` VALUES LESS THAN (6) ENGINE = InnoDB, + PARTITION `p1` VALUES LESS THAN MAXVALUE ENGINE = InnoDB) +DROP TABLE t1; +SET auto_increment_increment=@aii; +# End of 10.2 tests diff --git a/mysql-test/suite/innodb/r/innodb-autoinc.result b/mysql-test/suite/innodb/r/innodb-autoinc.result index 6c405627e08..00690ecaff7 100644 --- a/mysql-test/suite/innodb/r/innodb-autoinc.result +++ b/mysql-test/suite/innodb/r/innodb-autoinc.result @@ -1,4 +1,3 @@ -drop table if exists t1; CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; INSERT INTO t1 VALUES (9223372036854775807, null); INSERT INTO t1 (c2) VALUES ('innodb'); @@ -1619,3 +1618,27 @@ id name -1 dog 2 cat DROP PROCEDURE autoinc_mdev15353_one; +# +# MDEV-28416 Incorrect AUTO_INCREMENT may be issued +# +SET @aii=@@auto_increment_increment; +SET auto_increment_increment=300; +CREATE TABLE t1 (a SERIAL) ENGINE=innodb; +INSERT INTO t1 VALUES (18446744073709551613); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551614 DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (NULL); +ERROR 22003: Out of range value for column 'a' at row 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551615 DEFAULT CHARSET=latin1 +DROP TABLE t1; +SET auto_increment_increment=@aii; +# End of 10.2 tests diff --git a/mysql-test/suite/innodb/t/innodb-autoinc-part.test b/mysql-test/suite/innodb/t/innodb-autoinc-part.test new file mode 100644 index 00000000000..100546704ce --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-autoinc-part.test @@ -0,0 +1,24 @@ +--source include/have_partition.inc +--source include/have_innodb.inc + +--echo # +--echo # MDEV-28416 Incorrect AUTO_INCREMENT may be issued +--echo # + +SET @aii=@@auto_increment_increment; +SET auto_increment_increment=300; + +CREATE TABLE t1 (a SERIAL) ENGINE=innodb +PARTITION BY RANGE (a) ( + PARTITION p0 VALUES LESS THAN (6), + PARTITION p1 VALUES LESS THAN MAXVALUE +); +INSERT INTO t1 VALUES (18446744073709551613); +SHOW CREATE TABLE t1; +--error HA_ERR_AUTOINC_ERANGE +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +DROP TABLE t1; +SET auto_increment_increment=@aii; + +--echo # End of 10.2 tests diff --git a/mysql-test/suite/innodb/t/innodb-autoinc.test b/mysql-test/suite/innodb/t/innodb-autoinc.test index ca7727d4cef..158460558d5 100644 --- a/mysql-test/suite/innodb/t/innodb-autoinc.test +++ b/mysql-test/suite/innodb/t/innodb-autoinc.test @@ -1,10 +1,4 @@ --source include/have_innodb.inc -# embedded server ignores 'delayed', so skip this --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings # # Bug #34335 @@ -770,3 +764,20 @@ DROP TABLE t1; SET @engine='INNODB'; --source include/autoinc_mdev15353.inc + +--echo # +--echo # MDEV-28416 Incorrect AUTO_INCREMENT may be issued +--echo # + +SET @aii=@@auto_increment_increment; +SET auto_increment_increment=300; +CREATE TABLE t1 (a SERIAL) ENGINE=innodb; +INSERT INTO t1 VALUES (18446744073709551613); +SHOW CREATE TABLE t1; +--error HA_ERR_AUTOINC_ERANGE +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +DROP TABLE t1; +SET auto_increment_increment=@aii; + +--echo # End of 10.2 tests diff --git a/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info.inc b/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info.inc new file mode 100644 index 00000000000..4a83c9c394e --- /dev/null +++ b/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info.inc @@ -0,0 +1,14 @@ +--disable_query_log +--file_exists $targetdir/xtrabackup_slave_info +CREATE TEMPORARY TABLE tmp_slave_info(lineno SERIAL, line TEXT); +--replace_result $targetdir TARGETDIR +--eval LOAD DATA LOCAL INFILE '$targetdir/xtrabackup_slave_info' INTO TABLE tmp_slave_info (line); +SELECT + lineno, + regexp_replace( + regexp_replace(line, '(?<=MASTER_LOG_POS=)[0-9]+', '<NUM>'), + '[0-9]+-[0-9]+-[0-9]+', '<NUM-NUM-NUM>') + AS line +FROM tmp_slave_info ORDER BY lineno; +DROP TEMPORARY TABLE tmp_slave_info; +--enable_query_log diff --git a/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info_out.inc b/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info_out.inc new file mode 100644 index 00000000000..90b2d00b61d --- /dev/null +++ b/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info_out.inc @@ -0,0 +1,20 @@ +--disable_query_log +--file_exists $XTRABACKUP_OUT +CREATE TEMPORARY TABLE tmp_slave_info_out(lineno SERIAL, line TEXT); +--replace_result $targetdir TARGETDIR +--eval LOAD DATA LOCAL INFILE '$XTRABACKUP_OUT' INTO TABLE tmp_slave_info_out (line); +SELECT + replace( + regexp_replace( + regexp_replace(line, + '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]', + 'YYYY-MM-DD hh:mm:ss'), + '[0-9]+-[0-9]+-[0-9]+', '<NUM-NUM-NUM>'), + '\r','' /* Remove CR on Windows */) + AS line +FROM tmp_slave_info_out +WHERE line LIKE '%MySQL slave binlog position%' + OR line LIKE '%Failed to get master binlog coordinates%' +ORDER BY lineno; +DROP TEMPORARY TABLE tmp_slave_info_out; +--enable_query_log diff --git a/mysql-test/suite/mariabackup/incremental_newdb_while_backup.result b/mysql-test/suite/mariabackup/incremental_newdb_while_backup.result new file mode 100644 index 00000000000..e1d5c7a5df4 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_newdb_while_backup.result @@ -0,0 +1,24 @@ +call mtr.add_suppression("InnoDB: New log files created"); +# +# Start of 10.2 tests +# +# +# MDEV-28446 mariabackup prepare fails for incrementals if a new schema is created after full backup is taken +# +CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB; +# Prepare full backup, apply incremental one +# shutdown server +# remove datadir +# xtrabackup move back +# restart server +SELECT COUNT(*) FROM test.t1; +COUNT(*) +0 +SELECT COUNT(*) FROM test1.t1; +COUNT(*) +10000 +DROP TABLE t1; +DROP DATABASE test1; +# +# End of 10.2 tests +# diff --git a/mysql-test/suite/mariabackup/incremental_newdb_while_backup.test b/mysql-test/suite/mariabackup/incremental_newdb_while_backup.test new file mode 100644 index 00000000000..2433fb4a35a --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_newdb_while_backup.test @@ -0,0 +1,47 @@ +--source include/have_innodb.inc +--source include/have_debug.inc + +call mtr.add_suppression("InnoDB: New log files created"); + +--echo # +--echo # Start of 10.2 tests +--echo # + +--echo # +--echo # MDEV-28446 mariabackup prepare fails for incrementals if a new schema is created after full backup is taken +--echo # + +--let $basedir=$MYSQLTEST_VARDIR/tmp/backup +--let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1 + +CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB; + +--disable_result_log +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir +--enable_result_log + +--let after_load_tablespaces=BEGIN NOT ATOMIC CREATE DATABASE test1; CREATE TABLE test1.t1 ENGINE=INNODB SELECT UUID() from test.seq_1_to_10000; END + +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir --dbug=+d,mariabackup_events,mariabackup_inject_code +--let after_load_tablespaces= +--disable_result_log +--echo # Prepare full backup, apply incremental one +--exec $XTRABACKUP --apply-log-only --prepare --target-dir=$basedir +--exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir +--enable_result_log + +--let $targetdir=$basedir +--source include/restart_and_restore.inc +--enable_result_log + +SELECT COUNT(*) FROM test.t1; +SELECT COUNT(*) FROM test1.t1; + +DROP TABLE t1; +DROP DATABASE test1; +--rmdir $basedir +--rmdir $incremental_dir + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/suite/mariabackup/rpl_slave_info.result b/mysql-test/suite/mariabackup/rpl_slave_info.result index 13044fd6c39..ec27166ecfb 100644 --- a/mysql-test/suite/mariabackup/rpl_slave_info.result +++ b/mysql-test/suite/mariabackup/rpl_slave_info.result @@ -13,6 +13,9 @@ connection slave; "using_gtid: Slave_Pos" FOUND 1 /gtid_slave_pos/ in xtrabackup_slave_info NOT FOUND /MASTER_LOG_FILE/ in xtrabackup_slave_info +lineno line +1 SET GLOBAL gtid_slave_pos = '<NUM-NUM-NUM>'; +2 CHANGE MASTER TO master_use_gtid = slave_pos; ############### # If Using_Gtid != 'No' and !gtid_slave_pos, backup master position ######################## @@ -20,6 +23,8 @@ include/stop_slave.inc SET GLOBAL gtid_slave_pos=""; NOT FOUND /gtid_slave_pos/ in xtrabackup_slave_info FOUND 1 /MASTER_LOG_FILE/ in xtrabackup_slave_info +lineno line +1 CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=<NUM>; ############### # If Using_Gtid == 'No', backup Exec_Master_Log_Pos ######################## @@ -31,6 +36,8 @@ connection slave; "using_gtid: No" NOT FOUND /gtid_slave_pos/ in xtrabackup_slave_info FOUND 1 /MASTER_LOG_FILE/ in xtrabackup_slave_info +lineno line +1 CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=<NUM>; connection master; DROP TABLE t; connection slave; diff --git a/mysql-test/suite/mariabackup/rpl_slave_info.test b/mysql-test/suite/mariabackup/rpl_slave_info.test index ca7682d8af9..1c5dd89acc9 100644 --- a/mysql-test/suite/mariabackup/rpl_slave_info.test +++ b/mysql-test/suite/mariabackup/rpl_slave_info.test @@ -27,6 +27,7 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffi --source include/search_pattern_in_file.inc --let SEARCH_PATTERN=MASTER_LOG_FILE --source include/search_pattern_in_file.inc +--source include/show_xtrabackup_slave_info.inc rmdir $targetdir; @@ -35,7 +36,9 @@ rmdir $targetdir; --echo ######################## --source include/stop_slave.inc +--disable_warnings SET GLOBAL gtid_slave_pos=""; +--enable_warnings --let $targetdir=$MYSQLTEST_VARDIR/tmp/backup --disable_result_log @@ -47,6 +50,7 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffi --source include/search_pattern_in_file.inc --let SEARCH_PATTERN=MASTER_LOG_FILE --source include/search_pattern_in_file.inc +--source include/show_xtrabackup_slave_info.inc rmdir $targetdir; @@ -74,6 +78,7 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffi --source include/search_pattern_in_file.inc --let SEARCH_PATTERN=MASTER_LOG_FILE --source include/search_pattern_in_file.inc +--source include/show_xtrabackup_slave_info.inc rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/slave_info_norpl.result b/mysql-test/suite/mariabackup/slave_info_norpl.result new file mode 100644 index 00000000000..9fcd67a8916 --- /dev/null +++ b/mysql-test/suite/mariabackup/slave_info_norpl.result @@ -0,0 +1,59 @@ +# +# Start of 10.2 tests +# +# +# MDEV-21037 mariabackup does not detect multi-source replication slave +# +SELECT @@global.gtid_slave_pos; +@@global.gtid_slave_pos + + +# Without any masters the file xtrabackup_slave_info is not created +line +[00] YYYY-MM-DD hh:mm:ss Failed to get master binlog coordinates from SHOW SLAVE STATUS.This means that the server is not a replication slave. Ignoring the --slave-info option + +CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000; +lineno line +1 CHANGE MASTER TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +line +[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: master '' filename '' position '0' + +CHANGE MASTER 'master2' TO MASTER_HOST='localhost', MASTER_PORT=10002; +lineno line +1 CHANGE MASTER TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +2 CHANGE MASTER 'master2' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +line +[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: master '' filename '' position '0'; master 'master2' filename '' position '0' + +SET GLOBAL gtid_slave_pos='1-1-1,2-2-2'; +CHANGE MASTER 'master3' TO MASTER_HOST='localhost', MASTER_PORT=10003, MASTER_USE_GTID=slave_pos; +CHANGE MASTER 'master4' TO MASTER_HOST='localhost', MASTER_PORT=10004, MASTER_USE_GTID=no; +CHANGE MASTER 'master5' TO MASTER_HOST='localhost', MASTER_PORT=10005, MASTER_USE_GTID=slave_pos; +lineno line +1 SET GLOBAL gtid_slave_pos = '<NUM-NUM-NUM>,<NUM-NUM-NUM>'; +2 CHANGE MASTER TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +3 CHANGE MASTER 'master2' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +4 CHANGE MASTER 'master3' TO master_use_gtid = slave_pos; +5 CHANGE MASTER 'master4' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +6 CHANGE MASTER 'master5' TO master_use_gtid = slave_pos; +line +[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: gtid_slave_pos '<NUM-NUM-NUM>,<NUM-NUM-NUM>'; master '' filename '' position '0'; master 'master2' filename '' position '0'; master 'master3' master_use_gtid = slave_pos; master 'master4' filename '' position '0'; master 'master5' master_use_gtid = slave_pos + +CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000, MASTER_USE_GTID=slave_pos; +lineno line +1 SET GLOBAL gtid_slave_pos = '<NUM-NUM-NUM>,<NUM-NUM-NUM>'; +2 CHANGE MASTER TO master_use_gtid = slave_pos; +3 CHANGE MASTER 'master2' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +4 CHANGE MASTER 'master3' TO master_use_gtid = slave_pos; +5 CHANGE MASTER 'master4' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +6 CHANGE MASTER 'master5' TO master_use_gtid = slave_pos; +line +[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: gtid_slave_pos '<NUM-NUM-NUM>,<NUM-NUM-NUM>'; master '' master_use_gtid = slave_pos; master 'master2' filename '' position '0'; master 'master3' master_use_gtid = slave_pos; master 'master4' filename '' position '0'; master 'master5' master_use_gtid = slave_pos +RESET SLAVE ALL; +RESET SLAVE 'master2' ALL; +RESET SLAVE 'master3' ALL; +RESET SLAVE 'master4' ALL; +RESET SLAVE 'master5' ALL; +# +# End of 10.2 tests +# diff --git a/mysql-test/suite/mariabackup/slave_info_norpl.test b/mysql-test/suite/mariabackup/slave_info_norpl.test new file mode 100644 index 00000000000..0d2d2ed4861 --- /dev/null +++ b/mysql-test/suite/mariabackup/slave_info_norpl.test @@ -0,0 +1,86 @@ +# +# "mariabackup --slave-info" tests that can be run without +# actually starting the replication. +# + +--echo # +--echo # Start of 10.2 tests +--echo # + +--echo # +--echo # MDEV-21037 mariabackup does not detect multi-source replication slave +--echo # + +--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup +--let $XTRABACKUP_ARGS=--defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.2 --slave-info --backup --databases=test --target-dir=$targetdir +--let $XTRABACKUP_OUT=$MYSQLTEST_VARDIR/tmp/xtrabackup_out + +# Should be empty by default +SELECT @@global.gtid_slave_pos; + +--echo +--echo # Without any masters the file xtrabackup_slave_info is not created + +--disable_result_log +exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT; +--enable_result_log +--error 1 +--file_exists $targetdir/xtrabackup_slave_info +--source include/show_xtrabackup_slave_info_out.inc +--remove_file $XTRABACKUP_OUT +rmdir $targetdir; + +--echo +CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000; +--disable_result_log +exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT; +--enable_result_log +--source include/show_xtrabackup_slave_info.inc +--source include/show_xtrabackup_slave_info_out.inc +--remove_file $XTRABACKUP_OUT +rmdir $targetdir; + +--echo +CHANGE MASTER 'master2' TO MASTER_HOST='localhost', MASTER_PORT=10002; +--disable_result_log +exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT; +--enable_result_log +--source include/show_xtrabackup_slave_info.inc +--source include/show_xtrabackup_slave_info_out.inc +--remove_file $XTRABACKUP_OUT +rmdir $targetdir; + +--echo +SET GLOBAL gtid_slave_pos='1-1-1,2-2-2'; +CHANGE MASTER 'master3' TO MASTER_HOST='localhost', MASTER_PORT=10003, MASTER_USE_GTID=slave_pos; +CHANGE MASTER 'master4' TO MASTER_HOST='localhost', MASTER_PORT=10004, MASTER_USE_GTID=no; +CHANGE MASTER 'master5' TO MASTER_HOST='localhost', MASTER_PORT=10005, MASTER_USE_GTID=slave_pos; + +--disable_result_log +exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT; +--enable_result_log +--source include/show_xtrabackup_slave_info.inc +--source include/show_xtrabackup_slave_info_out.inc +--remove_file $XTRABACKUP_OUT +rmdir $targetdir; + +--echo +CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000, MASTER_USE_GTID=slave_pos; +--disable_result_log +exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT; +--enable_result_log +--source include/show_xtrabackup_slave_info.inc +--source include/show_xtrabackup_slave_info_out.inc +--remove_file $XTRABACKUP_OUT +rmdir $targetdir; + +RESET SLAVE ALL; +RESET SLAVE 'master2' ALL; +RESET SLAVE 'master3' ALL; +RESET SLAVE 'master4' ALL; +RESET SLAVE 'master5' ALL; + + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/suite/parts/inc/part_alter_values.inc b/mysql-test/suite/parts/inc/part_alter_values.inc index 2f16476c78b..ca18faa5758 100644 --- a/mysql-test/suite/parts/inc/part_alter_values.inc +++ b/mysql-test/suite/parts/inc/part_alter_values.inc @@ -1,3 +1,5 @@ +--source include/have_symlink.inc + --echo # --echo # MDEV-14641 Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine --echo # diff --git a/mysql-test/suite/parts/t/partition_alter_myisam.test b/mysql-test/suite/parts/t/partition_alter_myisam.test index 326cf52b018..d3abb8842e1 100644 --- a/mysql-test/suite/parts/t/partition_alter_myisam.test +++ b/mysql-test/suite/parts/t/partition_alter_myisam.test @@ -1,5 +1,4 @@ --source include/have_partition.inc ---source include/have_symlink.inc --let $engine=MyISAM --source inc/part_alter_values.inc diff --git a/mysql-test/suite/rpl/include/rpl_parallel.inc b/mysql-test/suite/rpl/include/rpl_parallel.inc index b88d2126d4d..9ba7a30f2eb 100644 --- a/mysql-test/suite/rpl/include/rpl_parallel.inc +++ b/mysql-test/suite/rpl/include/rpl_parallel.inc @@ -1872,6 +1872,7 @@ SET GLOBAL slave_parallel_threads=10; SET GLOBAL slave_parallel_threads=1; SET @old_dbug= @@GLOBAL.debug_dbug; SET GLOBAL debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000"; +CALL mtr.add_suppression("Unexpected break of being relay-logged GTID"); --connection server_1 INSERT INTO t2 VALUES (101); diff --git a/mysql-test/suite/rpl/include/rpl_ssl.inc b/mysql-test/suite/rpl/include/rpl_ssl.inc index aff5499c8e5..bd77f213ae1 100644 --- a/mysql-test/suite/rpl/include/rpl_ssl.inc +++ b/mysql-test/suite/rpl/include/rpl_ssl.inc @@ -37,7 +37,7 @@ select * from t1; # The slave is synced and waiting/reading from master # SHOW SLAVE STATUS will show "Waiting for master to send event" -let $status_items= Master_SSL_Allowed, Master_SSL_CA_Path, Master_SSL_CA_File, Master_SSL_Cert, Master_SSL_Key; +let $status_items= Master_SSL_Allowed, Master_SSL_CA_Path, Master_SSL_CA_File, Master_SSL_Crl, Master_SSL_Crlpath, Master_SSL_Cert, Master_SSL_Key; source include/show_slave_status.inc; source include/check_slave_is_running.inc; diff --git a/mysql-test/suite/rpl/r/rpl_gtid_grouping.result b/mysql-test/suite/rpl/r/rpl_gtid_grouping.result new file mode 100644 index 00000000000..ad7d6116c49 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_gtid_grouping.result @@ -0,0 +1,54 @@ +include/master-slave.inc +[connection master] +connection slave; +call mtr.add_suppression("Unexpected break of being relay-logged GTID 0-27697-1000"); +call mtr.add_suppression("Relay log write failure: could not queue event from master"); +call mtr.add_suppression("The current group of events starts with a non-GTID"); +include/stop_slave.inc +CHANGE MASTER TO MASTER_USE_GTID=slave_pos; +include/start_slave.inc +connection master; +CREATE TABLE t (a INT) ENGINE=innodb; +INSERT INTO t VALUES(1); +### A. Simulate an unnoticeable loss of Xid event +connection slave; +SET @@global.debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000"; +connection master; +SET @@gtid_seq_no=1000; +set @@server_id=27697; +INSERT INTO t VALUES(1000); +set @@server_id=default; +INSERT INTO t VALUES(1001); +## Prove the error occurs. +connection slave; +include/wait_for_slave_io_error.inc [errno=1595] +## Prove the slave recovers after the simulation condtion is lifted. +SET @@global.debug_dbug=default; +include/start_slave.inc +### B. Do the same to GTID event. +connection slave; +SET @@global.debug_dbug="+d,slave_discard_gtid_0_x_1002"; +connection master; +SET @@gtid_seq_no=1002; +set @@server_id=27697; +INSERT INTO t VALUES(1002); +set @@server_id=default; +INSERT INTO t VALUES(1003); +## Prove the error occurs. +connection slave; +include/wait_for_slave_io_error.inc [errno=1595] +## Prove the slave recovers after the simulation condtion is lifted. +SET @@global.debug_dbug=default; +include/start_slave.inc +connection master; +connection slave; +include/diff_tables.inc [master:t,slave:t] +"===== Clean up =====" +connection slave; +include/stop_slave.inc +CHANGE MASTER TO MASTER_USE_GTID=no; +include/start_slave.inc +connection master; +DROP TABLE t; +SET GLOBAL LOG_WARNINGS=default; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_parallel.result b/mysql-test/suite/rpl/r/rpl_parallel.result index 657b3ba7448..2601b30279e 100644 --- a/mysql-test/suite/rpl/r/rpl_parallel.result +++ b/mysql-test/suite/rpl/r/rpl_parallel.result @@ -1378,6 +1378,7 @@ include/stop_slave.inc SET GLOBAL slave_parallel_threads=1; SET @old_dbug= @@GLOBAL.debug_dbug; SET GLOBAL debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000"; +CALL mtr.add_suppression("Unexpected break of being relay-logged GTID"); connection server_1; INSERT INTO t2 VALUES (101); INSERT INTO t2 VALUES (102); diff --git a/mysql-test/suite/rpl/r/rpl_parallel_temptable.result b/mysql-test/suite/rpl/r/rpl_parallel_temptable.result index 52efed22541..1a1c12f836d 100644 --- a/mysql-test/suite/rpl/r/rpl_parallel_temptable.result +++ b/mysql-test/suite/rpl/r/rpl_parallel_temptable.result @@ -132,8 +132,13 @@ connection server_1; INSERT INTO t1 VALUES (0, 1); include/save_master_gtid.inc connection server_2; +set @@sql_log_bin=0; +call mtr.add_suppression("Unexpected break of being relay-logged GTID 1-1-32 event group by the current GTID event 0-1-4"); +set @@sql_log_bin=1; +set @@global.debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000"; include/start_slave.inc include/sync_with_master_gtid.inc +set @@global.debug_dbug=""; SELECT * FROM t1 ORDER BY a; a b 0 1 diff --git a/mysql-test/suite/rpl/r/rpl_ssl.result b/mysql-test/suite/rpl/r/rpl_ssl.result index 0b3a6cd0eca..ce9e4d486cf 100644 --- a/mysql-test/suite/rpl/r/rpl_ssl.result +++ b/mysql-test/suite/rpl/r/rpl_ssl.result @@ -23,6 +23,8 @@ t Master_SSL_Allowed = 'Yes' Master_SSL_CA_Path = '' Master_SSL_CA_File = 'MYSQL_TEST_DIR/std_data/cacert.pem' +Master_SSL_Crl = '' +Master_SSL_Crlpath = '' Master_SSL_Cert = 'MYSQL_TEST_DIR/std_data/client-cert.pem' Master_SSL_Key = 'MYSQL_TEST_DIR/std_data/client-key.pem' include/check_slave_is_running.inc @@ -37,6 +39,8 @@ include/wait_for_slave_to_start.inc Master_SSL_Allowed = 'Yes' Master_SSL_CA_Path = '' Master_SSL_CA_File = 'MYSQL_TEST_DIR/std_data/cacert.pem' +Master_SSL_Crl = '' +Master_SSL_Crlpath = '' Master_SSL_Cert = 'MYSQL_TEST_DIR/std_data/client-cert.pem' Master_SSL_Key = 'MYSQL_TEST_DIR/std_data/client-key.pem' include/check_slave_is_running.inc diff --git a/mysql-test/suite/rpl/t/rpl_gtid_grouping.test b/mysql-test/suite/rpl/t/rpl_gtid_grouping.test new file mode 100644 index 00000000000..66448c4f96c --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_grouping.test @@ -0,0 +1,97 @@ +# ==== Purpose ==== +# +# Test verifies that replicated transaction boundaries are set properly +# at receiving from master time. +# +# ==== Implementation ==== +# +# A. Simulate an unnoticeable loss of Xid event to observe a slave error, +# then restart slave to recover from the failure. +# B. Do the same to GTID event. +# +# ==== References ==== +# +# MDEV-27697 slave must recognize incomplete replication event group +# +--source include/have_binlog_format_mixed.inc +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/master-slave.inc + +--connection slave +call mtr.add_suppression("Unexpected break of being relay-logged GTID 0-27697-1000"); +call mtr.add_suppression("Relay log write failure: could not queue event from master"); +call mtr.add_suppression("The current group of events starts with a non-GTID"); + +--source include/stop_slave.inc +CHANGE MASTER TO MASTER_USE_GTID=slave_pos; +--source include/start_slave.inc + +--connection master +CREATE TABLE t (a INT) ENGINE=innodb; +INSERT INTO t VALUES(1); +save_master_pos; + +--echo ### A. Simulate an unnoticeable loss of Xid event +--sync_slave_with_master +SET @@global.debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000"; + +--connection master +SET @@gtid_seq_no=1000; +set @@server_id=27697; +INSERT INTO t VALUES(1000); +set @@server_id=default; +INSERT INTO t VALUES(1001); + +--echo ## Prove the error occurs. +--connection slave +# ER_SLAVE_RELAY_LOG_WRITE_FAILURE +--let $slave_io_errno = 1595 +--source include/wait_for_slave_io_error.inc +## EOP + +--echo ## Prove the slave recovers after the simulation condtion is lifted. +SET @@global.debug_dbug=default; +--source include/start_slave.inc + +--echo ### B. Do the same to GTID event. +--connection slave +SET @@global.debug_dbug="+d,slave_discard_gtid_0_x_1002"; + +--connection master +SET @@gtid_seq_no=1002; +set @@server_id=27697; +INSERT INTO t VALUES(1002); +set @@server_id=default; +INSERT INTO t VALUES(1003); + +--echo ## Prove the error occurs. +--connection slave +# ER_SLAVE_RELAY_LOG_WRITE_FAILURE +--let $slave_io_errno = 1595 +--source include/wait_for_slave_io_error.inc +## EOP + +--echo ## Prove the slave recovers after the simulation condtion is lifted. +SET @@global.debug_dbug=default; +--source include/start_slave.inc + +--connection master +save_master_pos; + +--sync_slave_with_master +## EOP + +--let $diff_tables=master:t,slave:t +--source include/diff_tables.inc + +--echo "===== Clean up =====" +--connection slave +--source include/stop_slave.inc +CHANGE MASTER TO MASTER_USE_GTID=no; +--source include/start_slave.inc + +--connection master +DROP TABLE t; +SET GLOBAL LOG_WARNINGS=default; +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_parallel_temptable.test b/mysql-test/suite/rpl/t/rpl_parallel_temptable.test index 04165ee4752..edb854842e1 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_temptable.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_temptable.test @@ -201,9 +201,16 @@ INSERT INTO t1 VALUES (0, 1); # execution of format_description event will not wait infinitely # for a commit of the incomplete group that never happens. +# Apart from the suppression, MDEV-27697 refinement to the original test needs +# an allowance to one time accept malformed event group. +set @@sql_log_bin=0; +call mtr.add_suppression("Unexpected break of being relay-logged GTID 1-1-32 event group by the current GTID event 0-1-4"); +set @@sql_log_bin=1; +set @@global.debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000"; --source include/start_slave.inc #--sync_with_master --source include/sync_with_master_gtid.inc +set @@global.debug_dbug=""; SELECT * FROM t1 ORDER BY a; SHOW STATUS LIKE 'Slave_open_temp_tables'; diff --git a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result deleted file mode 100644 index bcd96b86516..00000000000 --- a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result +++ /dev/null @@ -1,150 +0,0 @@ -# -# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above -# -# Verbose run -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=InnoDB; -ALTER TABLE time_zone_name ENGINE=InnoDB; -ALTER TABLE time_zone_transition ENGINE=InnoDB; -ALTER TABLE time_zone_transition_type ENGINE=InnoDB; -END IF| -\d ; -TRUNCATE TABLE time_zone; -TRUNCATE TABLE time_zone_name; -TRUNCATE TABLE time_zone_transition; -TRUNCATE TABLE time_zone_transition_type; -START TRANSACTION; -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it. -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/ignored.tab' as time zone. Skipping it. -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it. -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zone. Skipping it. -Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion. -COMMIT; -ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; -ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=MyISAM; -ALTER TABLE time_zone_name ENGINE=MyISAM; -ALTER TABLE time_zone_transition ENGINE=MyISAM; -ALTER TABLE time_zone_transition_type ENGINE=MyISAM; -END IF| -\d ; -# Silent run -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=InnoDB; -ALTER TABLE time_zone_name ENGINE=InnoDB; -ALTER TABLE time_zone_transition ENGINE=InnoDB; -ALTER TABLE time_zone_transition_type ENGINE=InnoDB; -END IF| -\d ; -TRUNCATE TABLE time_zone; -TRUNCATE TABLE time_zone_name; -TRUNCATE TABLE time_zone_transition; -TRUNCATE TABLE time_zone_transition_type; -START TRANSACTION; -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it. -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it. -COMMIT; -ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; -ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=MyISAM; -ALTER TABLE time_zone_name ENGINE=MyISAM; -ALTER TABLE time_zone_transition ENGINE=MyISAM; -ALTER TABLE time_zone_transition_type ENGINE=MyISAM; -END IF| -\d ; -# -# Testing with explicit timezonefile -# -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=InnoDB; -ALTER TABLE time_zone_name ENGINE=InnoDB; -ALTER TABLE time_zone_transition ENGINE=InnoDB; -ALTER TABLE time_zone_transition_type ENGINE=InnoDB; -END IF| -\d ; -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=MyISAM; -ALTER TABLE time_zone_name ENGINE=MyISAM; -ALTER TABLE time_zone_transition ENGINE=MyISAM; -ALTER TABLE time_zone_transition_type ENGINE=MyISAM; -END IF| -\d ; -# -# Testing --leap -# -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=InnoDB; -ALTER TABLE time_zone_name ENGINE=InnoDB; -ALTER TABLE time_zone_transition ENGINE=InnoDB; -ALTER TABLE time_zone_transition_type ENGINE=InnoDB; -END IF| -\d ; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone_leap_second ENGINE=InnoDB; -END IF| -\d ; -TRUNCATE TABLE time_zone_leap_second; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone_leap_second ENGINE=MyISAM; -END IF| -\d ; -ALTER TABLE time_zone_leap_second ORDER BY Transition_time; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=MyISAM; -ALTER TABLE time_zone_name ENGINE=MyISAM; -ALTER TABLE time_zone_transition ENGINE=MyISAM; -ALTER TABLE time_zone_transition_type ENGINE=MyISAM; -END IF| -\d ; diff --git a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result deleted file mode 100644 index aff02cb413e..00000000000 --- a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result +++ /dev/null @@ -1,78 +0,0 @@ -# -# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above -# -# Verbose run -set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); -prepare set_wsrep_write_binlog from @prep1; -set @toggle=0; execute set_wsrep_write_binlog using @toggle; -TRUNCATE TABLE time_zone; -TRUNCATE TABLE time_zone_name; -TRUNCATE TABLE time_zone_transition; -TRUNCATE TABLE time_zone_transition_type; -START TRANSACTION; -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it. -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/ignored.tab' as time zone. Skipping it. -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it. -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zone. Skipping it. -Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion. -COMMIT; -ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; -ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; -# Silent run -set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); -prepare set_wsrep_write_binlog from @prep1; -set @toggle=0; execute set_wsrep_write_binlog using @toggle; -TRUNCATE TABLE time_zone; -TRUNCATE TABLE time_zone_name; -TRUNCATE TABLE time_zone_transition; -TRUNCATE TABLE time_zone_transition_type; -START TRANSACTION; -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it. -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it. -COMMIT; -ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; -ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; -# -# Testing with explicit timezonefile -# -set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); -prepare set_wsrep_write_binlog from @prep1; -set @toggle=0; execute set_wsrep_write_binlog using @toggle; -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -# -# Testing --leap -# -set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); -prepare set_wsrep_write_binlog from @prep1; -set @toggle=0; execute set_wsrep_write_binlog using @toggle; -TRUNCATE TABLE time_zone_leap_second; -ALTER TABLE time_zone_leap_second ORDER BY Transition_time; diff --git a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.opt b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.opt deleted file mode 100644 index 864f7342cc7..00000000000 --- a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.opt +++ /dev/null @@ -1,3 +0,0 @@ ---wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep-on=1 --binlog_format=ROW - - diff --git a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.test b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.test deleted file mode 100644 index 87554635666..00000000000 --- a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.test +++ /dev/null @@ -1,41 +0,0 @@ ---source include/have_wsrep.inc ---source include/have_symlink.inc ---source include/not_windows.inc ---source include/have_innodb.inc - ---echo # ---echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above ---echo # - ---exec mkdir $MYSQLTEST_VARDIR/zoneinfo ---exec ln -s $MYSQLTEST_VARDIR/zoneinfo $MYSQLTEST_VARDIR/zoneinfo/posix ---copy_file std_data/zoneinfo/GMT $MYSQLTEST_VARDIR/zoneinfo/GMT ---copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/garbage ---copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/ignored.tab - ---echo # Verbose run ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---exec $MYSQL_TZINFO_TO_SQL --verbose $MYSQLTEST_VARDIR/zoneinfo 2>&1 - ---echo # Silent run ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>&1 - ---echo # ---echo # Testing with explicit timezonefile ---echo # - ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1 - ---echo # ---echo # Testing --leap ---echo # - ---exec $MYSQL_TZINFO_TO_SQL --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1 - -# -# Cleanup -# - ---exec rm -rf $MYSQLTEST_VARDIR/zoneinfo diff --git a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.opt b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.opt deleted file mode 100644 index 864f7342cc7..00000000000 --- a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.opt +++ /dev/null @@ -1,3 +0,0 @@ ---wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep-on=1 --binlog_format=ROW - - diff --git a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test deleted file mode 100644 index ab1f94cc1cf..00000000000 --- a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test +++ /dev/null @@ -1,41 +0,0 @@ ---source include/have_wsrep.inc ---source include/have_symlink.inc ---source include/not_windows.inc ---source include/have_innodb.inc - ---echo # ---echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above ---echo # - ---exec mkdir $MYSQLTEST_VARDIR/zoneinfo ---exec ln -s $MYSQLTEST_VARDIR/zoneinfo $MYSQLTEST_VARDIR/zoneinfo/posix ---copy_file std_data/zoneinfo/GMT $MYSQLTEST_VARDIR/zoneinfo/GMT ---copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/garbage ---copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/ignored.tab - ---echo # Verbose run ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---exec $MYSQL_TZINFO_TO_SQL --verbose --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>&1 - ---echo # Silent run ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>&1 - ---echo # ---echo # Testing with explicit timezonefile ---echo # - ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1 - ---echo # ---echo # Testing --leap ---echo # - ---exec $MYSQL_TZINFO_TO_SQL --leap --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1 - -# -# Cleanup -# - ---exec rm -rf $MYSQLTEST_VARDIR/zoneinfo diff --git a/sql/field.cc b/sql/field.cc index be9c10a3bae..57cf3deed35 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3116,6 +3116,15 @@ Field *Field_decimal::make_new_field(MEM_ROOT *root, TABLE *new_table, } +void Field_new_decimal::set_and_validate_prec(uint32 len_arg, + uint8 dec_arg, bool unsigned_arg) +{ + precision= my_decimal_length_to_precision(len_arg, dec_arg, unsigned_arg); + set_if_smaller(precision, DECIMAL_MAX_PRECISION); + bin_size= my_decimal_get_binary_size(precision, dec); +} + + /**************************************************************************** ** Field_new_decimal ****************************************************************************/ @@ -3134,12 +3143,10 @@ Field_new_decimal::Field_new_decimal(uchar *ptr_arg, uint8 dec_arg,bool zero_arg, bool unsigned_arg) :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, - unireg_check_arg, field_name_arg, dec_arg, zero_arg, unsigned_arg) + unireg_check_arg, field_name_arg, + MY_MIN(dec_arg, DECIMAL_MAX_SCALE), zero_arg, unsigned_arg) { - precision= get_decimal_precision(len_arg, dec_arg, unsigned_arg); - DBUG_ASSERT((precision <= DECIMAL_MAX_PRECISION) && - (dec <= DECIMAL_MAX_SCALE)); - bin_size= my_decimal_get_binary_size(precision, dec); + set_and_validate_prec(len_arg, dec_arg, unsigned_arg); } diff --git a/sql/field.h b/sql/field.h index 41bed111f50..4ef4483a15a 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1984,6 +1984,8 @@ public: class Field_new_decimal :public Field_num { private: int save_field_metadata(uchar *first_byte); + void set_and_validate_prec(uint32 len_arg, + uint8 dec_arg, bool unsigned_arg); public: /* The maximum number of decimal digits can be stored */ uint precision; diff --git a/sql/handler.cc b/sql/handler.cc index e4c377451c6..2048ce137da 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -5118,6 +5118,9 @@ int handler::calculate_checksum() for (uint i= 0; i < table->s->fields; i++ ) { Field *f= table->field[i]; + if (!f->stored_in_db()) + continue; + if (! thd->variables.old_mode && f->is_real_null(0)) { diff --git a/sql/item_func.cc b/sql/item_func.cc index b8355a38701..3fd69405456 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2463,7 +2463,7 @@ void Item_func_round::fix_arg_decimal() set_handler(&type_handler_newdecimal); unsigned_flag= args[0]->unsigned_flag; decimals= args[0]->decimals; - max_length= float_length(args[0]->decimals) + 1; + max_length= args[0]->max_length; } } diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 88db52db13d..2e33a71b8f9 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -763,6 +763,7 @@ bool Item_subselect::exec() DBUG_ENTER("Item_subselect::exec"); DBUG_ASSERT(fixed); + DBUG_ASSERT(!eliminated); DBUG_EXECUTE_IF("Item_subselect", Item::Print print(this, @@ -1272,11 +1273,18 @@ bool Item_singlerow_subselect::fix_length_and_dec() } unsigned_flag= value->unsigned_flag; /* - If there are not tables in subquery then ability to have NULL value - depends on SELECT list (if single row subquery have tables then it - always can be NULL if there are not records fetched). + If the subquery has no tables (1) and is not a UNION (2), like: + + (SELECT subq_value) + + then its NULLability is the same as subq_value's NULLability. + + (1): A subquery that uses a table will return NULL when the table is empty. + (2): A UNION subquery will return NULL if it produces a "Subquery returns + more than one row" error. */ - if (engine->no_tables()) + if (engine->no_tables() && + engine->engine_type() != subselect_engine::UNION_ENGINE) maybe_null= engine->may_be_null(); else { @@ -1312,6 +1320,16 @@ Item* Item_singlerow_subselect::expr_cache_insert_transformer(THD *tmp_thd, DBUG_ASSERT(thd == tmp_thd); + /* + Do not create subquery cache if the subquery was eliminated. + The optimizer may eliminate subquery items (see + eliminate_subselect_processor). However it does not update + all query's data structures, so the eliminated item may be + still reachable. + */ + if (eliminated) + DBUG_RETURN(this); + if (expr_cache) DBUG_RETURN(expr_cache); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 4c6c3258d11..72e01a1e0e4 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1539,6 +1539,8 @@ void Item_sum_sum::fix_length_and_dec_decimal() decimals= args[0]->decimals; /* SUM result can't be longer than length(arg) + length(MAX_ROWS) */ int precision= args[0]->decimal_precision() + DECIMAL_LONGLONG_DIGITS; + decimals= MY_MIN(decimals, DECIMAL_MAX_SCALE); + precision= MY_MIN(precision, DECIMAL_MAX_PRECISION); max_length= my_decimal_precision_to_length_no_truncation(precision, decimals, unsigned_flag); @@ -1954,12 +1956,12 @@ void Item_sum_avg::fix_length_and_dec_decimal() { Item_sum_sum::fix_length_and_dec_decimal(); int precision= args[0]->decimal_precision() + prec_increment; - decimals= MY_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE); + decimals= MY_MIN(args[0]->decimal_scale() + prec_increment, DECIMAL_MAX_SCALE); max_length= my_decimal_precision_to_length_no_truncation(precision, decimals, unsigned_flag); f_precision= MY_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION); - f_scale= args[0]->decimals; + f_scale= args[0]->decimal_scale(); dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale); } diff --git a/sql/rpl_gtid.h b/sql/rpl_gtid.h index b3341b20165..fec0cccdb0a 100644 --- a/sql/rpl_gtid.h +++ b/sql/rpl_gtid.h @@ -26,6 +26,7 @@ extern const LEX_CSTRING rpl_gtid_slave_state_table_name; class String; +#define PARAM_GTID(G) G.domain_id, G.server_id, G.seq_no struct rpl_gtid { diff --git a/sql/slave.cc b/sql/slave.cc index f64ab0d015f..0ecba3c42b8 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3214,9 +3214,9 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full, protocol->store((uint32) mi->master_id); // SQL_Delay // Master_Ssl_Crl - protocol->store(mi->ssl_ca, &my_charset_bin); + protocol->store(mi->ssl_crl, &my_charset_bin); // Master_Ssl_Crlpath - protocol->store(mi->ssl_capath, &my_charset_bin); + protocol->store(mi->ssl_crlpath, &my_charset_bin); // Using_Gtid protocol->store(mi->using_gtid_astext(mi->using_gtid), &my_charset_bin); // Gtid_IO_Pos @@ -3315,7 +3315,7 @@ bool show_all_master_info(THD* thd) String gtid_pos; Master_info **tmp; List<Item> field_list; - DBUG_ENTER("show_master_info"); + DBUG_ENTER("show_all_master_info"); mysql_mutex_assert_owner(&LOCK_active_mi); gtid_pos.length(0); @@ -6573,17 +6573,75 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len) mi->gtid_event_seen= true; /* - We have successfully queued to relay log everything before this GTID, so + Unless the previous group is malformed, + we have successfully queued to relay log everything before this GTID, so in case of reconnect we can start from after any previous GTID. - (Normally we would have updated gtid_current_pos earlier at the end of - the previous event group, but better leave an extra check here for - safety). + (We must have updated gtid_current_pos earlier at the end of + the previous event group. Unless ...) */ - if (mi->events_queued_since_last_gtid) + if (unlikely(mi->events_queued_since_last_gtid > 0)) { - mi->gtid_current_pos.update(&mi->last_queued_gtid); - mi->events_queued_since_last_gtid= 0; + /* + ...unless the last group has not been completed. An assert below + can be satisfied only with the strict mode that ensures + against "genuine" gtid duplicates. + */ + rpl_gtid *gtid_in_slave_state= + mi->gtid_current_pos.find(mi->last_queued_gtid.domain_id); + + // Slave gtid state must not have updated yet to the last received gtid. + DBUG_ASSERT((mi->using_gtid == Master_info::USE_GTID_NO || + !opt_gtid_strict_mode) || + (!gtid_in_slave_state || + !(*gtid_in_slave_state == mi->last_queued_gtid))); + + DBUG_EXECUTE_IF("slave_discard_xid_for_gtid_0_x_1000", + { + /* Inject an event group that is missing its XID commit event. */ + if ((mi->last_queued_gtid.domain_id == 0 && + mi->last_queued_gtid.seq_no == 1000) || + (mi->last_queued_gtid.domain_id == 1 && + mi->last_queued_gtid.seq_no == 32)) + { + sql_print_warning( + "Unexpected break of being relay-logged GTID %u-%u-%llu " + "event group by the current GTID event %u-%u-%llu", + PARAM_GTID(mi->last_queued_gtid),PARAM_GTID(event_gtid)); + DBUG_SET("-d,slave_discard_xid_for_gtid_0_x_1000"); + goto dbug_gtid_accept; + } + }); + error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE; + sql_print_error("Unexpected break of being relay-logged GTID %u-%u-%llu " + "event group by the current GTID event %u-%u-%llu", + PARAM_GTID(mi->last_queued_gtid),PARAM_GTID(event_gtid)); + goto err; } + else if (unlikely(mi->gtid_reconnect_event_skip_count > 0)) + { + if (mi->gtid_reconnect_event_skip_count == + mi->events_queued_since_last_gtid) + { + DBUG_ASSERT(event_gtid == mi->last_queued_gtid); + + goto default_action; + } + + DBUG_ASSERT(0); + } + // else_likely{... +#ifndef DBUG_OFF +dbug_gtid_accept: + DBUG_EXECUTE_IF("slave_discard_gtid_0_x_1002", + { + if (mi->last_queued_gtid.server_id == 27697 && + mi->last_queued_gtid.seq_no == 1002) + { + DBUG_SET("-d,slave_discard_gtid_0_x_1002"); + goto skip_relay_logging; + } + }); +#endif mi->last_queued_gtid= event_gtid; mi->last_queued_gtid_standalone= (gtid_flag & Gtid_log_event::FL_STANDALONE) != 0; @@ -6593,6 +6651,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len) ++mi->events_queued_since_last_gtid; inc_pos= event_len; + // ...} eof else_likely } break; /* @@ -6671,6 +6730,12 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len) case XID_EVENT: DBUG_EXECUTE_IF("slave_discard_xid_for_gtid_0_x_1000", { + if (mi->last_queued_gtid.server_id == 27697 && + mi->last_queued_gtid.seq_no == 1000) + { + DBUG_SET("-d,slave_discard_xid_for_gtid_0_x_1000"); + goto skip_relay_logging; + } /* Inject an event group that is missing its XID commit event. */ if (mi->last_queued_gtid.domain_id == 0 && mi->last_queued_gtid.seq_no == 1000) @@ -6716,15 +6781,48 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len) } };); - if (mi->using_gtid != Master_info::USE_GTID_NO && mi->gtid_event_seen) + if (mi->using_gtid != Master_info::USE_GTID_NO) { - if (unlikely(mi->gtid_reconnect_event_skip_count)) + if (likely(mi->gtid_event_seen)) { - --mi->gtid_reconnect_event_skip_count; - gtid_skip_enqueue= true; + if (unlikely(mi->gtid_reconnect_event_skip_count)) + { + if (!got_gtid_event && + mi->gtid_reconnect_event_skip_count == + mi->events_queued_since_last_gtid) + goto gtid_not_start; // the 1st re-sent must be gtid + + --mi->gtid_reconnect_event_skip_count; + gtid_skip_enqueue= true; + } + else if (likely(mi->events_queued_since_last_gtid)) + { + DBUG_ASSERT(!got_gtid_event); + + ++mi->events_queued_since_last_gtid; + } + else if (Log_event::is_group_event((Log_event_type) (uchar) + buf[EVENT_TYPE_OFFSET])) + { + goto gtid_not_start; // no first gtid event in this group + } + } + else if (Log_event::is_group_event((Log_event_type) (uchar) + buf[EVENT_TYPE_OFFSET])) + { + gtid_not_start: + + DBUG_ASSERT(!got_gtid_event); + + error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE; + sql_print_error("The current group of events starts with " + "a non-GTID %s event; " + "the last seen GTID is %u-%u-%llu", + Log_event::get_type_str((Log_event_type) (uchar) + buf[EVENT_TYPE_OFFSET]), + mi->last_queued_gtid); + goto err; } - else if (mi->events_queued_since_last_gtid) - ++mi->events_queued_since_last_gtid; } if (!is_compress_event) @@ -6917,11 +7015,13 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len) The whole of the current event group is queued. So in case of reconnect we can start from after the current GTID. */ - if (mi->gtid_reconnect_event_skip_count) + if (gtid_skip_enqueue) { bool first= true; StringBuffer<1024> gtid_text; + DBUG_ASSERT(mi->events_queued_since_last_gtid > 1); + rpl_slave_state_tostring_helper(>id_text, &mi->last_queued_gtid, &first); sql_print_error("Slave IO thread received a terminal event from " @@ -6931,12 +7031,39 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len) gtid_text.ptr(), mi->gtid_reconnect_event_skip_count, mi->events_queued_since_last_gtid); + error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE; + goto err; } mi->gtid_current_pos.update(&mi->last_queued_gtid); mi->events_queued_since_last_gtid= 0; - /* Reset the domain_id_filter flag. */ - mi->domain_id_filter.reset_filter(); + if (unlikely(gtid_skip_enqueue)) + { + error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE; + sql_print_error("Recieved a group closing %s event " + "at %llu position in the group while there are " + "still %llu events to skip upon reconnecting; " + "the last seen GTID is %u-%u-%llu", + Log_event::get_type_str((Log_event_type) (uchar) + buf[EVENT_TYPE_OFFSET]), + (mi->events_queued_since_last_gtid - + mi->gtid_reconnect_event_skip_count), + mi->events_queued_since_last_gtid, + mi->last_queued_gtid); + goto err; + } + else + { + /* + The whole of the current event group is queued. So in case of + reconnect we can start from after the current GTID. + */ + mi->gtid_current_pos.update(&mi->last_queued_gtid); + mi->events_queued_since_last_gtid= 0; + + /* Reset the domain_id_filter flag. */ + mi->domain_id_filter.reset_filter(); + } } skip_relay_logging: diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index e4ffbdcb155..e97f24c5487 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -312,3 +312,12 @@ sp_cache::cleanup() { my_hash_free(&m_hashtable); } + + +void Sp_caches::sp_caches_clear() +{ + sp_cache_clear(&sp_proc_cache); + sp_cache_clear(&sp_func_cache); + sp_cache_clear(&sp_package_spec_cache); + sp_cache_clear(&sp_package_body_cache); +} diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 1d1199aaa62..cc121c05a01 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -791,7 +791,7 @@ void sp_head::set_stmt_end(THD *thd) { Lex_input_stream *lip= & thd->m_parser_state->m_lip; /* shortcut */ - const char *end_ptr= lip->get_cpp_ptr(); /* shortcut */ + const char *end_ptr= lip->get_cpp_tok_start(); /* shortcut */ /* Make the string of parameters. */ diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 6203e5672fe..489f9f3c24d 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -812,11 +812,6 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) (my_hash_get_key) get_sequence_last_key, (my_hash_free_key) free_sequence_last, HASH_THREAD_SPECIFIC); - sp_proc_cache= NULL; - sp_func_cache= NULL; - sp_package_spec_cache= NULL; - sp_package_body_cache= NULL; - /* For user vars replication*/ if (opt_bin_log) my_init_dynamic_array(&user_var_events, @@ -1383,10 +1378,7 @@ void THD::change_user(void) my_hash_init(&sequences, system_charset_info, SEQUENCES_HASH_SIZE, 0, 0, (my_hash_get_key) get_sequence_last_key, (my_hash_free_key) free_sequence_last, HASH_THREAD_SPECIFIC); - sp_cache_clear(&sp_proc_cache); - sp_cache_clear(&sp_func_cache); - sp_cache_clear(&sp_package_spec_cache); - sp_cache_clear(&sp_package_body_cache); + sp_caches_clear(); } /** @@ -1512,10 +1504,7 @@ void THD::cleanup(void) my_hash_free(&user_vars); my_hash_free(&sequences); - sp_cache_clear(&sp_proc_cache); - sp_cache_clear(&sp_func_cache); - sp_cache_clear(&sp_package_spec_cache); - sp_cache_clear(&sp_package_body_cache); + sp_caches_clear(); auto_inc_intervals_forced.empty(); auto_inc_intervals_in_cur_stmt_for_binlog.empty(); diff --git a/sql/sql_class.h b/sql/sql_class.h index b4428714c28..d278a797c07 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2167,6 +2167,39 @@ struct wait_for_commit void reinit(); }; + +class Sp_caches +{ +public: + sp_cache *sp_proc_cache; + sp_cache *sp_func_cache; + sp_cache *sp_package_spec_cache; + sp_cache *sp_package_body_cache; + Sp_caches() + :sp_proc_cache(NULL), + sp_func_cache(NULL), + sp_package_spec_cache(NULL), + sp_package_body_cache(NULL) + { } + ~Sp_caches() + { + // All caches must be freed by the caller explicitly + DBUG_ASSERT(sp_proc_cache == NULL); + DBUG_ASSERT(sp_func_cache == NULL); + DBUG_ASSERT(sp_package_spec_cache == NULL); + DBUG_ASSERT(sp_package_body_cache == NULL); + } + void sp_caches_swap(Sp_caches &rhs) + { + swap_variables(sp_cache*, sp_proc_cache, rhs.sp_proc_cache); + swap_variables(sp_cache*, sp_func_cache, rhs.sp_func_cache); + swap_variables(sp_cache*, sp_package_spec_cache, rhs.sp_package_spec_cache); + swap_variables(sp_cache*, sp_package_body_cache, rhs.sp_package_body_cache); + } + void sp_caches_clear(); +}; + + extern "C" void my_message_sql(uint error, const char *str, myf MyFlags); /** @@ -2185,7 +2218,8 @@ class THD :public Statement, */ public Item_change_list, public MDL_context_owner, - public Open_tables_state + public Open_tables_state, + public Sp_caches { private: inline bool is_stmt_prepare() const @@ -3180,10 +3214,6 @@ public: enum_sql_command last_sql_command; // Last sql_command exceuted in mysql_execute_command() sp_rcontext *spcont; // SP runtime context - sp_cache *sp_proc_cache; - sp_cache *sp_func_cache; - sp_cache *sp_package_spec_cache; - sp_cache *sp_package_body_cache; /** number of name_const() substitutions, see sp_head.cc:subst_spvars() */ uint query_name_consts; diff --git a/sql/sql_expression_cache.cc b/sql/sql_expression_cache.cc index 351ec258ddb..bc44ecd79fa 100644 --- a/sql/sql_expression_cache.cc +++ b/sql/sql_expression_cache.cc @@ -63,7 +63,7 @@ void Expression_cache_tmptable::disable_cache() cache_table= NULL; update_tracker(); if (tracker) - tracker->cache= NULL; + tracker->detach_from_cache(); } @@ -189,6 +189,8 @@ Expression_cache_tmptable::~Expression_cache_tmptable() else { update_tracker(); + if (tracker) + tracker->detach_from_cache(); tracker= NULL; } } diff --git a/sql/sql_expression_cache.h b/sql/sql_expression_cache.h index 61e0c4c69b3..d4bb252dccb 100644 --- a/sql/sql_expression_cache.h +++ b/sql/sql_expression_cache.h @@ -83,7 +83,11 @@ public: cache(c), hit(0), miss(0), state(UNINITED) {} +private: + // This can be NULL if the cache is already deleted Expression_cache *cache; + +public: ulong hit, miss; enum expr_cache_state state; @@ -91,6 +95,7 @@ public: void set(ulong h, ulong m, enum expr_cache_state s) {hit= h; miss= m; state= s;} + void detach_from_cache() { cache= NULL; } void fetch_current_stats() { if (cache) diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 3475b622130..c86458c438d 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -701,8 +701,10 @@ mysql_ha_fix_cond_and_key(SQL_HANDLER *handler, if (!in_prepare) { MY_BITMAP *old_map= dbug_tmp_use_all_columns(table, &table->write_set); - (void) item->save_in_field(key_part->field, 1); + int res= item->save_in_field(key_part->field, 1); dbug_tmp_restore_column_map(&table->write_set, old_map); + if (res) + return 1; } key_len+= key_part->store_length; keypart_map= (keypart_map << 1) | 1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 864afc71311..d437da4b7cd 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -17144,8 +17144,7 @@ Field *create_tmp_field_from_field(THD *thd, Field *org_field, table->s->db_create_options|= HA_OPTION_PACK_RECORD; else if (org_field->type() == FIELD_TYPE_DOUBLE) ((Field_double *) new_field)->not_fixed= TRUE; - new_field->vcol_info= new_field->default_value= - new_field->check_constraint= 0; + new_field->vcol_info= 0; new_field->cond_selectivity= 1.0; new_field->next_equal_field= NULL; new_field->option_list= NULL; @@ -17740,6 +17739,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, table->intersect_keys.init(); table->keys_in_use_for_query.init(); table->no_rows_with_nulls= param->force_not_null_cols; + table->expr_arena= thd; table->s= share; init_tmp_table_share(thd, share, "", 0, "(temporary)", tmpname); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 6f607c2dfb0..1316dcd9c94 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -5143,6 +5143,7 @@ public: int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) { + DBUG_ENTER("get_all_tables"); LEX *lex= thd->lex; TABLE *table= tables->table; TABLE_LIST table_acl_check; @@ -5160,7 +5161,29 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) uint table_open_method= tables->table_open_method; bool can_deadlock; MEM_ROOT tmp_mem_root; - DBUG_ENTER("get_all_tables"); + /* + We're going to open FRM files for tables. + In case of VIEWs that contain stored function calls, + these stored functions will be parsed and put to the SP cache. + + Suppose we have a view containing a stored function call: + CREATE VIEW v1 AS SELECT f1() AS c1; + and now we're running: + SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME=f1(); + If a parallel thread invalidates the cache, + e.g. by creating or dropping some stored routine, + the SELECT query will re-parse f1() when processing "v1" + and replace the outdated cached version of f1() to a new one. + But the old version of f1() is referenced from the m_sp member + of the Item_func_sp instances used in the WHERE condition. + We cannot destroy it. To avoid such clashes, let's remember + all old routines into a temporary SP cache collection + and process tables with a new empty temporary SP cache collection. + Then restore to the old SP cache collection at the end. + */ + Sp_caches old_sp_caches; + + old_sp_caches.sp_caches_swap(*thd); bzero(&tmp_mem_root, sizeof(tmp_mem_root)); @@ -5334,6 +5357,13 @@ err: thd->restore_backup_open_tables_state(&open_tables_state_backup); free_root(&tmp_mem_root, 0); + /* + Now restore to the saved SP cache collection + and clear the temporary SP cache collection. + */ + old_sp_caches.sp_caches_swap(*thd); + old_sp_caches.sp_caches_clear(); + DBUG_RETURN(error); } diff --git a/sql/sql_type.cc b/sql/sql_type.cc index 128a4e68533..c92a437259f 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -1099,7 +1099,6 @@ Type_handler_decimal_result::make_num_distinct_aggregator_field( const Item *item) const { - DBUG_ASSERT(item->decimals <= DECIMAL_MAX_SCALE); return new (mem_root) Field_new_decimal(NULL, item->max_length, (uchar *) (item->maybe_null ? "" : 0), diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 9a0a9f3149e..770e5e1c3e7 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -899,7 +899,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); /* We should not introduce any further shift/reduce conflicts. */ -%expect 81 +%expect 85 /* Comments for TOKENS. @@ -1012,6 +1012,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token FIRST_VALUE_SYM /* SQL-2011 */ %token FLOAT_NUM %token FLOAT_SYM /* SQL-2003-R */ +%token FORCE_LOOKAHEAD /* INTERNAL never returned by the lexer */ %token FOREIGN /* SQL-2003-R */ %token FOR_SYM /* SQL-2003-R */ %token FOR_SYSTEM_TIME_SYM /* INTERNAL */ @@ -3060,6 +3061,9 @@ sequence_def: } ; +/* this rule is used to force look-ahead in the parser */ +force_lookahead: {} | FORCE_LOOKAHEAD {} ; + server_def: SERVER_SYM opt_if_not_exists ident_or_text { @@ -3260,7 +3264,7 @@ ev_sql_stmt: lex->sphead->set_body_start(thd, lip->get_cpp_ptr()); } - sp_proc_stmt + sp_proc_stmt force_lookahead { LEX *lex= thd->lex; @@ -18018,8 +18022,8 @@ trigger_tail: lex->sphead->set_body_start(thd, lip->get_cpp_tok_start()); } - sp_proc_stmt /* $19 */ - { /* $20 */ + sp_proc_stmt /* $19 */ force_lookahead /* $20 */ + { /* $21 */ LEX *lex= Lex; sp_head *sp= lex->sphead; @@ -18102,7 +18106,7 @@ sf_tail: lex->sphead->set_chistics(lex->sp_chistics); lex->sphead->set_body_start(thd, lip->get_cpp_tok_start()); } - sp_proc_stmt_in_returns_clause + sp_proc_stmt_in_returns_clause force_lookahead { if (unlikely(Lex->sp_body_finalize_function(thd))) MYSQL_YYABORT; @@ -18123,7 +18127,7 @@ sp_tail: Lex->sphead->set_chistics(Lex->sp_chistics); Lex->sphead->set_body_start(thd, YYLIP->get_cpp_tok_start()); } - sp_proc_stmt + sp_proc_stmt force_lookahead { if (unlikely(Lex->sp_body_finalize_procedure(thd))) MYSQL_YYABORT; diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index ea7ba454d0b..23e4a5deb7d 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -293,7 +293,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); /* We should not introduce any further shift/reduce conflicts. */ -%expect 83 +%expect 87 /* Comments for TOKENS. @@ -406,6 +406,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token FIRST_VALUE_SYM /* SQL-2011 */ %token FLOAT_NUM %token FLOAT_SYM /* SQL-2003-R */ +%token FORCE_LOOKAHEAD /* INTERNAL never returned by the lexer */ %token FOREIGN /* SQL-2003-R */ %token FOR_SYM /* SQL-2003-R */ %token FOR_SYSTEM_TIME_SYM /* INTERNAL */ @@ -2693,6 +2694,9 @@ sequence_def: } ; +/* this rule is used to force look-ahead in the parser */ +force_lookahead: {} | FORCE_LOOKAHEAD {} ; + server_def: SERVER_SYM opt_if_not_exists ident_or_text { @@ -2893,7 +2897,7 @@ ev_sql_stmt: lex->sphead->set_body_start(thd, lip->get_cpp_ptr()); } - sp_proc_stmt + sp_proc_stmt force_lookahead { LEX *lex= thd->lex; @@ -18084,8 +18088,8 @@ trigger_tail: lex->sphead->set_body_start(thd, lip->get_cpp_tok_start()); } - sp_proc_stmt /* $19 */ - { /* $20 */ + sp_proc_stmt /* $19 */ force_lookahead /* $20 */ + { /* $21 */ LEX *lex= Lex; sp_head *sp= lex->sphead; if (unlikely(sp->check_unresolved_goto())) @@ -18171,7 +18175,7 @@ sf_tail: lex->sphead->set_body_start(thd, lip->get_cpp_tok_start()); } sp_tail_is - sp_body + sp_body force_lookahead { if (unlikely(Lex->sp_body_finalize_function(thd))) MYSQL_YYABORT; @@ -18198,7 +18202,7 @@ sp_tail: Lex->sphead->set_body_start(thd, YYLIP->get_cpp_tok_start()); } sp_tail_is - sp_body + sp_body force_lookahead { if (unlikely(Lex->sp_body_finalize_procedure(thd))) MYSQL_YYABORT; diff --git a/sql/table.cc b/sql/table.cc index eac89d4b4c5..64fb3150a39 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -6196,7 +6196,7 @@ Item *Field_iterator_view::create_item(THD *thd) Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref, LEX_CSTRING *name) { - bool save_wrapper= thd->lex->select_lex.no_wrap_view_item; + bool save_wrapper= thd->lex->current_select->no_wrap_view_item; Item *field= *field_ref; DBUG_ENTER("create_view_field"); diff --git a/sql/tztime.cc b/sql/tztime.cc index 96b43e3d7f1..dfd0301037f 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2634,7 +2634,7 @@ static struct my_option my_long_options[] = &opt_verbose, &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"skip-write-binlog", 'S', "Do not replicate changes to time zone tables to other nodes in a Galera cluster.", + {"skip-write-binlog", 'S', "Do not replicate changes to time zone tables to the binary log, or to other nodes in a Galera cluster.", &opt_skip_write_binlog,&opt_skip_write_binlog, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -2730,9 +2730,9 @@ main(int argc, char **argv) sql_log_bin and wsrep_on to avoid Galera replicating below truncate table clauses. This will allow user to set different time zones to nodes in Galera cluster. */ - printf("set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');\n" - "prepare set_wsrep_write_binlog from @prep1;\n" - "set @toggle=0; execute set_wsrep_write_binlog using @toggle;\n"); + printf("set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION WSREP_ON=OFF', 'do 0');\n" + "SET SESSION SQL_LOG_BIN=0;\n" + "execute immediate @prep1;\n"); } else { diff --git a/storage/connect/tabrest.cpp b/storage/connect/tabrest.cpp index c66d8d76f3d..7e8b51714fb 100644 --- a/storage/connect/tabrest.cpp +++ b/storage/connect/tabrest.cpp @@ -112,7 +112,11 @@ int Xcurl(PGLOBAL g, PCSZ Http, PCSZ Uri, PCSZ filename) } // endif f - pID = vfork(); +#ifdef HAVE_VFORK + pID = vfork(); +#else + pID = fork(); +#endif sprintf(fn, "-o%s", filename); if (pID == 0) { diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 8eb4c1dd30d..497b0f24e93 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2020, MariaDB Corporation. +Copyright (c) 2013, 2022, MariaDB Corporation. Copyright (c) 2013, 2014, Fusion-io This program is free software; you can redistribute it and/or modify it under @@ -1162,15 +1162,10 @@ buf_flush_page( /* For table residing in temporary tablespace sync is done using IO_FIX and so before scheduling for flush ensure that page is not fixed. */ - flush = FALSE; + return FALSE; } else { rw_lock = &reinterpret_cast<buf_block_t*>(bpage)->lock; - if (flush_type != BUF_FLUSH_LIST) { - flush = rw_lock_sx_lock_nowait(rw_lock, BUF_IO_WRITE); - } else { - /* Will SX lock later */ - flush = TRUE; - } + flush = rw_lock_sx_lock_nowait(rw_lock, BUF_IO_WRITE); } if (flush) { @@ -1192,22 +1187,6 @@ buf_flush_page( buf_pool_mutex_exit(buf_pool); - if (flush_type == BUF_FLUSH_LIST - && is_uncompressed - && !rw_lock_sx_lock_nowait(rw_lock, BUF_IO_WRITE)) { - - if (!fsp_is_system_temporary(bpage->id.space())) { - /* avoiding deadlock possibility involves - doublewrite buffer, should flush it, because - it might hold the another block->lock. */ - buf_dblwr_flush_buffered_writes(); - } else { - buf_dblwr_sync_datafiles(); - } - - rw_lock_sx_lock_gen(rw_lock, BUF_IO_WRITE); - } - /* If there is an observer that want to know if the asynchronous flushing was sent then notify it. Note: we set flush observer to a page with x-latch, so we can diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 5ef90182cc2..40754a131ee 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -16792,8 +16792,8 @@ ha_innobase::get_auto_increment( (3) It is restricted only for insert operations. */ - if (increment > 1 && thd_sql_command(m_user_thd) != SQLCOM_ALTER_TABLE - && autoinc < col_max_value) { + if (increment > 1 && increment <= ~autoinc && autoinc < col_max_value + && thd_sql_command(m_user_thd) != SQLCOM_ALTER_TABLE) { ulonglong prev_auto_inc = autoinc; diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c index b1b0cf21edc..8a5357efce1 100644 --- a/tests/mysql_client_fw.c +++ b/tests/mysql_client_fw.c @@ -104,6 +104,7 @@ DBUG_PRINT("test", ("name: %s", str)); \ fprintf(stdout, "%u of (%u/%u): %s", test_count++, iter_count, \ opt_count, str); \ fprintf(stdout, " \n#####################################\n"); \ + fflush(stdout); \ } #define myheader_r(str) \ @@ -113,6 +114,7 @@ DBUG_PRINT("test", ("name: %s", str)); \ fprintf(stdout, "\n\n#####################################\n"); \ fprintf(stdout, "%s", str); \ fprintf(stdout, " \n#####################################\n"); \ + fflush(stdout); \ } static void print_error(const char *msg); diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 326544d58de..482bb106af7 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -20145,6 +20145,7 @@ static void test_proxy_header_tcp(const char *ipaddr, int port) // normalize IPv4-mapped IPv6 addresses, e.g ::ffff:127.0.0.2 to 127.0.0.2 const char *normalized_addr= strncmp(ipaddr, "::ffff:", 7)?ipaddr : ipaddr + 7; + myheader("test_proxy_header_tcp"); memset(&v2_header, 0, sizeof(v2_header)); sprintf(text_header,"PROXY %s %s %s %d 3306\r\n",family == AF_INET?"TCP4":"TCP6", ipaddr, ipaddr, port); @@ -20223,6 +20224,7 @@ static void test_proxy_header_localhost() MYSQL_RES *result; MYSQL_ROW row; int rc; + myheader("test_proxy_header_localhost"); memset(&v2_header, 0, sizeof(v2_header)); memcpy(v2_header.sig, "\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A", 12); @@ -20255,6 +20257,7 @@ static void test_proxy_header_ignore() int rc; MYSQL *m = mysql_client_init(NULL); v2_proxy_header v2_header; + myheader("test_ps_params_in_ctes"); DIE_UNLESS(m != NULL); mysql_optionsv(m, MARIADB_OPT_PROXY_HEADER, "PROXY UNKNOWN\r\n",15); DIE_UNLESS(mysql_real_connect(m, opt_host, "root", "", NULL, opt_port, opt_unix_socket, 0) == m); @@ -20285,6 +20288,7 @@ static void test_proxy_header_ignore() static void test_proxy_header() { + myheader("test_proxy_header"); test_proxy_header_tcp("192.0.2.1",3333); test_proxy_header_tcp("2001:db8:85a3::8a2e:370:7334",2222); test_proxy_header_tcp("::ffff:192.0.2.1",2222); @@ -20304,6 +20308,7 @@ static void test_bulk_autoinc() int i, id[]= {2, 3, 777}, count= sizeof(id)/sizeof(id[0]); MYSQL_RES *result; + myheader("test_bulk_autoinc"); rc= mysql_query(mysql, "DROP TABLE IF EXISTS ai_field_value"); myquery(rc); rc= mysql_query(mysql, "CREATE TABLE ai_field_value (id int not null primary key auto_increment)"); @@ -20357,6 +20362,7 @@ static void test_bulk_delete() int i, id[]= {1, 2, 4}, count= sizeof(id)/sizeof(id[0]); MYSQL_RES *result; + myheader("test_bulk_delete"); rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); myquery(rc); rc= mysql_query(mysql, "CREATE TABLE t1 (id int not null primary key)"); @@ -20419,6 +20425,7 @@ static void test_bulk_replace() count= sizeof(id)/sizeof(id[0]); MYSQL_RES *result; + myheader("test_bulk_replace"); rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); myquery(rc); rc= mysql_query(mysql, "CREATE TABLE t1 (id int not null primary key, active int)"); @@ -20477,6 +20484,7 @@ static void test_ps_params_in_ctes() int int_data[1]; MYSQL_STMT *stmt; + myheader("test_ps_params_in_ctes"); rc= mysql_query(mysql, "create table t1(a int, b int, key(a))"); myquery(rc); |